From b6090152ac53017a06efa668f2e5695d7d442900 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 20 Aug 2012 21:28:48 +0000 Subject: [PATCH] splitscreen: support for above/below screen split. To enable it, the HUD-less (maximized) screen size must be selected. git-svn-id: https://svn.eduke32.com/eduke32@2944 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/samples/splitscr.con | 20 ++++++-- polymer/eduke32/source/game.c | 77 +++++++++++++++++++--------- polymer/eduke32/source/player.c | 23 +++++++-- 3 files changed, 89 insertions(+), 31 deletions(-) diff --git a/polymer/eduke32/samples/splitscr.con b/polymer/eduke32/samples/splitscr.con index 5a9743110..ce455d4bb 100644 --- a/polymer/eduke32/samples/splitscr.con +++ b/polymer/eduke32/samples/splitscr.con @@ -301,10 +301,24 @@ state show_player_view ifvarg psect -1 { - ifvare arg_player_id 0 - showviewunbiased px py pz pang phoriz psect 0 0 160 199 + getuserdef .screen_size tmp + + ifvare tmp 0 + { + // above/below split: first player is above + ifvare arg_player_id 0 + showviewunbiased px py pz pang phoriz psect 0 0 319 100 + else + showviewunbiased px py pz pang phoriz psect 0 100 319 199 + } else - showviewunbiased px py pz pang phoriz psect 160 0 319 199 + { + // side by side split: first player is left + ifvare arg_player_id 0 + showviewunbiased px py pz pang phoriz psect 0 0 160 199 + else + showviewunbiased px py pz pang phoriz psect 160 0 319 199 + } } ends diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index a698a7e4e..f16074a79 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -487,6 +487,9 @@ int32_t mpgametext(int32_t y,const char *t,int32_t s,int32_t dabits) return(G_PrintGameText(4,STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536)); } +// minitext_yofs: in hud_scale-independent, (<<16)-scaled, 0-200-normalized y coords, +// (sb&ROTATESPRITE_MAX) only. +static int32_t minitext_yofs = 0; int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t sb) { int32_t ac; @@ -527,7 +530,7 @@ int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t } else ac = ch - '!' + MINIFONT; - if (cmode) rotatesprite_fs(sbarx(x),sbary(y),sbarsc(65536L),0,ac,s,p,sb); + if (cmode) rotatesprite_fs(sbarx(x),minitext_yofs+sbary(y),sbarsc(65536L),0,ac,s,p,sb); else rotatesprite_fs(x<<16,y<<16,65536L,0,ac,s,p,sb); x += 4; // tilesizx[ac]+1; @@ -736,14 +739,15 @@ void G_DrawTilePalSmall(int32_t x, int32_t y, int32_t tilenum, int32_t shade, in #define POLYMOSTTRANS (1) #define POLYMOSTTRANS2 (1|32) -// draws inventory numbers in the HUD for both the full and mini status bars -static void G_DrawInvNum(int32_t x,int32_t y,char num1,char ha,int32_t sbits) +// Draws inventory numbers in the HUD for both the full and mini status bars. +// yofs: in hud_scale-independent, (<<16)-scaled, 0-200-normalized y coords. +static void G_DrawInvNum(int32_t x, int32_t yofs, int32_t y, char num1, char ha, int32_t sbits) { char dabuf[16]; int32_t i, shd = (x < 0); const int32_t sbscale = sbarsc(65536); - const int32_t sby = sbary(y), sbyp1 = sbary(y+1); + const int32_t sby = yofs+sbary(y), sbyp1 = yofs+sbary(y+1); if (shd) x = -x; @@ -949,8 +953,8 @@ static void G_DrawWeapAmounts(const DukePlayer_t *p,int32_t x,int32_t y,int32_t } } - -static void G_DrawDigiNum(int32_t x, int32_t y, int32_t n, char s, int32_t cs) +// yofs: in hud_scale-independent, (<<16)-scaled, 0-200-normalized y coords. +static void G_DrawDigiNum_(int32_t x, int32_t yofs, int32_t y, int32_t n, char s, int32_t cs) { int32_t i, j = 0, k, p, c; char b[12]; @@ -968,11 +972,16 @@ static void G_DrawDigiNum(int32_t x, int32_t y, int32_t n, char s, int32_t cs) for (k=0; k 0) { @@ -1335,23 +1344,40 @@ static void G_DrawStatusBar(int32_t snum) else { // ORIGINAL MINI STATUS BAR - int32_t orient = 2+8+16+256 + (g_fakeMultiMode && snum==1)*RS_CENTERORIGIN; + int32_t orient = 2+8+16+256, yofs=0, yofssh=0; - rotatesprite_fs(sbarx(5),sbary(200-28),sb16,0,HEALTHBOX,0,21,orient); + if (g_fakeMultiMode) + { + const int32_t sidebyside = (ud.screen_size!=0); + + if (sidebyside && snum==1) + { + orient |= RS_CENTERORIGIN; + } + else if (!sidebyside && snum==0) + { + yofs = -100; + yofssh = yofs<<16; + } + } + + rotatesprite_fs(sbarx(5), yofssh+sbary(200-28), sb16, 0, HEALTHBOX, 0, 21, orient); if (p->inven_icon) - rotatesprite_fs(sbarx(69),sbary(200-30),sb16,0,INVENTORYBOX,0,21,orient); + rotatesprite_fs(sbarx(69), yofssh+sbary(200-30), sb16, 0, INVENTORYBOX, 0, 21, orient); // health { int32_t health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - G_DrawDigiNum(20, 200-17, health, -16, orient); + G_DrawDigiNum_(20, yofssh, 200-17, health, -16, orient); } - rotatesprite_fs(sbarx(37),sbary(200-28),sb16,0,AMMOBOX,0,21,orient); + rotatesprite_fs(sbarx(37), yofssh+sbary(200-28), sb16, 0, AMMOBOX, 0, 21, orient); - if (p->curr_weapon == HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; - else i = p->curr_weapon; - G_DrawDigiNum(53,200-17,p->ammo_amount[i],-16,orient); + if (p->curr_weapon == HANDREMOTE_WEAPON) + i = HANDBOMB_WEAPON; + else + i = p->curr_weapon; + G_DrawDigiNum_(53, yofssh, 200-17, p->ammo_amount[i], -16, orient); o = 158; permbit = 0; @@ -1361,25 +1387,28 @@ static void G_DrawStatusBar(int32_t snum) i = ((unsigned)p->inven_icon < 8) ? item_icons[p->inven_icon] : -1; if (i >= 0) - rotatesprite_fs(sbarx(231-o),sbary(200-21),sb16,0,i,0,0, orient); + rotatesprite_fs(sbarx(231-o), yofssh+sbary(200-21), sb16, 0, i, 0, 0, orient); // scale by status bar size orient |= ROTATESPRITE_MAX; - minitext(292-30-o,190,"%",6, orient); + minitext_yofs = yofssh; + minitext(292-30-o, 190, "%", 6, orient); i = G_GetInvAmount(p); j = G_GetInvOn(p); - G_DrawInvNum(284-30-o,200-6,(uint8_t)i,0, orient&~16); + G_DrawInvNum(284-30-o, yofssh, 200-6, (uint8_t)i, 0, orient&~16); if (j > 0) - minitext(288-30-o,180,"On",0, orient); + minitext(288-30-o, 180, "On", 0, orient); else if ((uint32_t)j != 0x80000000) - minitext(284-30-o,180,"Off",2, orient); + minitext(284-30-o, 180, "Off", 2, orient); if (p->inven_icon >= 6) - minitext(284-35-o,180,"Auto",2, orient); + minitext(284-35-o, 180, "Auto", 2, orient); + + minitext_yofs = 0; } } @@ -1610,7 +1639,7 @@ static void G_DrawStatusBar(int32_t snum) if (u&8192) { i = G_GetInvAmount(p); - G_DrawInvNum(284-30-o,SBY+28,(uint8_t)i,0,10+permbit); + G_DrawInvNum(284-30-o,0,SBY+28,(uint8_t)i,0,10+permbit); } } } diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 569ef6295..de3bdcad0 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -2032,6 +2032,8 @@ static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shad int32_t xoff = 192; int32_t wx[2] = { windowx1, windowx2 }; + int32_t wy[2] = { windowy1, windowy2 }; + int32_t yofs = 0; switch (g_currentweapon) { @@ -2054,9 +2056,22 @@ static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shad if (g_fakeMultiMode && ud.multimode==2) { + const int32_t sidebyside = (ud.screen_size!=0); + // splitscreen HACK - orientation &= ~(1024|512|256|8); - wx[(g_snum==0)] = (wx[0]+wx[1])/2+1; + orientation &= ~(1024|512|256); + if (sidebyside) + { + orientation &= ~8; + wx[(g_snum==0)] = (wx[0]+wx[1])/2 + 2; + } + else + { + orientation |= 8; + if (g_snum==0) + yofs = -(100<<16); + wy[(g_snum==0)] = (wy[0]+wy[1])/2 + 2; + } } #ifdef USE_OPENGL @@ -2064,9 +2079,9 @@ static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shad y += (224-weapsc(224)); #endif rotatesprite(weapsc(x<<16) + ((xoff-weapsc(xoff))<<16), - weapsc(y<<16) + ((200-weapsc(200))<<16), + weapsc(y<<16) + ((200-weapsc(200))<<16) + yofs, weapsc(65536L),ang,tilenum,shade,p,(2|orientation), - wx[0],windowy1,wx[1],windowy2); + wx[0],wy[0], wx[1],wy[1]); } static void G_DrawWeaponTile(int32_t x, int32_t y, int32_t tilenum, int32_t shade,