diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index d3d90c9a6..fbb98be86 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -1092,7 +1092,7 @@ short lastfps; short nCDTracks = 0; -short bMapMode = kFalse; +short nMapMode = 0; short bNoCreatures = kFalse; short nTotalPlayers = 1; @@ -1808,7 +1808,7 @@ void FinishLevel() StopAllSounds(); bCamera = kFalse; - bMapMode = kFalse; + nMapMode = 0; if (levelnum != kMap20) { @@ -2072,26 +2072,6 @@ static void GameDisplay(void) auto smoothRatio = calc_smoothratio(totalclock, tclocks); DrawView(smoothRatio); - UpdateMap(); - - if (bMapMode) - { -#if 0 - if (bHiRes && nViewBottom > nMaskY) - { - videoSetViewableArea(nViewLeft, nViewTop, nViewRight, nMaskY); - DrawMap(); - videoSetViewableArea(nViewLeft, nViewTop, nViewRight, nViewBottom); - } - else - { - DrawMap(); - } -#else - // TODO: Map should not be drawn on top of status bar. Redraw status bar? - DrawMap(); -#endif - } if (bPause) { @@ -2201,6 +2181,8 @@ int G_FPSLimit(void) return 0; } +static int32_t nonsharedtimer; + int app_main(int argc, char const* const* argv) { char tempbuf[256]; @@ -3064,41 +3046,22 @@ LOOP3: CONTROL_ClearButton(gamefunc_Map); if (!nFreeze) { - bMapMode = !bMapMode; + nMapMode = (nMapMode+1)%3; } } - else if (BUTTON(gamefunc_Zoom_Out)) + + if (nMapMode != 0) { - lMapZoom -= ldMapZoom; + int const timerOffset = ((int) totalclock - nonsharedtimer); + nonsharedtimer += timerOffset; - if (lMapZoom <= 32) - { - lMapZoom = 32; - } - else if (ldMapZoom <= 16) - { - ldMapZoom = 16; - } - else - { - ldMapZoom -= 2; - } - } - else if (BUTTON(gamefunc_Zoom_In)) - { - lMapZoom += ldMapZoom; - if (lMapZoom >= 1280) - { - lMapZoom = 1280; - } - else if (ldMapZoom >= 128) - { - ldMapZoom = 128; - } - else - { - ldMapZoom += 2; - } + if (BUTTON(gamefunc_Zoom_In)) + lMapZoom += mulscale6(timerOffset, max(lMapZoom, 256)); + + if (BUTTON(gamefunc_Zoom_Out)) + lMapZoom -= mulscale6(timerOffset, max(lMapZoom, 256)); + + lMapZoom = clamp(lMapZoom, 48, 2048); } if (PlayerList[nLocalPlayer].nHealth > 0) diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 29bcd2b18..001edb14e 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -144,7 +144,7 @@ extern short levelnum; //extern short nScreenWidth; //extern short nScreenHeight; -extern short bMapMode; +extern short nMapMode; extern short nButtonColor; diff --git a/source/exhumed/src/init.cpp b/source/exhumed/src/init.cpp index bfdc2b86f..c54a0a3ef 100644 --- a/source/exhumed/src/init.cpp +++ b/source/exhumed/src/init.cpp @@ -398,15 +398,6 @@ uint8_t LoadLevel(int nMap) levelnum = nMap; - // TEMP - show full 2D map// TEMP - for (i = 0; i < (kMaxWalls >> 3); i++) - show2dwall[i] = 0xFF; - for (i = 0; i < (kMaxSprites >> 3); i++) - show2dsprite[i] = 0xFF; - for (i = 0; i < numsectors; i++) { - show2dsector[i >> 3] |= (1 << (i & 7)); - } - return kTrue; } diff --git a/source/exhumed/src/map.cpp b/source/exhumed/src/map.cpp index 91556f373..7318f9db1 100644 --- a/source/exhumed/src/map.cpp +++ b/source/exhumed/src/map.cpp @@ -5,6 +5,7 @@ #include "init.h" #include "engine.h" #include "exhumed.h" +#include "view.h" short bShowTowers = kTrue; //kFalse; REVERT to kFalse int ldMapZoom; @@ -264,6 +265,329 @@ void drawoverheadmap(int cposx, int cposy, int czoom, short cang) #endif } +static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16_t cang) +{ + int32_t i, j, k, l, x1, y1, x2=0, y2=0, x3, y3, x4, y4, ox, oy, xoff, yoff; + int32_t dax, day, cosang, sinang, xspan, yspan, sprx, spry; + int32_t xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang; + int32_t xvect, yvect, xvect2, yvect2; + int16_t p; + char col; + uwallptr_t wal, wal2; + spritetype *spr; + + int32_t tmpydim = (xdim*5)/8; + + renderSetAspect(65536, divscale16(tmpydim*320, xdim*200)); + + xvect = sintable[(-cang)&2047] * czoom; + yvect = sintable[(1536-cang)&2047] * czoom; + xvect2 = mulscale16(xvect, yxaspect); + yvect2 = mulscale16(yvect, yxaspect); + + renderDisableFog(); + + // draw player position arrow + renderDrawLine(xdim << 11, (ydim << 11) - 20480, xdim << 11, (ydim << 11) + 20480, 24); + renderDrawLine((xdim << 11) - 20480, ydim << 11, xdim << 11, (ydim << 11) - 20480, 24); + renderDrawLine((xdim << 11) + 20480, ydim << 11, xdim << 11, (ydim << 11) - 20480, 24); + + short nPlayerSprite = PlayerList[nLocalPlayer].nSprite; + + int nPlayerZ = sprite[nPlayerSprite].z; + + //Draw red lines + for (i=numsectors-1; i>=0; i--) + { + if (!(show2dsector[i>>3]&pow2char[i&7])) continue; + + startwall = sector[i].wallptr; + endwall = sector[i].wallptr + sector[i].wallnum; + + z1 = sector[i].ceilingz; + z2 = sector[i].floorz; + + for (j=startwall, wal=(uwallptr_t)&wall[startwall]; jnextwall; + if (k < 0) continue; + + if (sector[wal->nextsector].ceilingz == z1 && sector[wal->nextsector].floorz == z2) + if (((wal->cstat|wall[wal->nextwall].cstat)&(16+32)) == 0) continue; + + if (nMapMode == 2) + col = 111; + else + col = 111 - min(klabs(z2 - nPlayerZ) >> 13, 12); + + ox = wal->x-cposx; + oy = wal->y-cposy; + x1 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11); + y1 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11); + + wal2 = (uwallptr_t)&wall[wal->point2]; + ox = wal2->x-cposx; + oy = wal2->y-cposy; + x2 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11); + y2 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11); + + renderDrawLine(x1, y1, x2, y2, col); + } + } + +#if 0 + renderEnableFog(); + + //Draw sprites + k = PlayerList[nLocalPlayer].nSprite; + if (!FURY) for (i=numsectors-1; i>=0; i--) + { + if (!(show2dsector[i>>3]&pow2char[i&7])) continue; + for (j=headspritesect[i]; j>=0; j=nextspritesect[j]) + { + spr = &sprite[j]; + + if (j == k || (spr->cstat&0x8000) || spr->cstat == 257 || spr->xrepeat == 0) continue; + + col = editorcolors[6]; //cyan + if (spr->cstat&1) col = editorcolors[5]; //magenta + + sprx = spr->x; + spry = spr->y; + + if ((spr->cstat&257) != 0) switch (spr->cstat&48) + { + case 0: + // break; + + ox = sprx-cposx; + oy = spry-cposy; + x1 = dmulscale16(ox, xvect, -oy, yvect); + y1 = dmulscale16(oy, xvect2, ox, yvect2); + + ox = (sintable[(spr->ang+512)&2047]>>7); + oy = (sintable[(spr->ang)&2047]>>7); + x2 = dmulscale16(ox, xvect, -oy, yvect); + y2 = dmulscale16(oy, xvect, ox, yvect); + + x3 = mulscale16(x2, yxaspect); + y3 = mulscale16(y2, yxaspect); + + renderDrawLine(x1-x2+(xdim<<11), y1-y3+(ydim<<11), + x1+x2+(xdim<<11), y1+y3+(ydim<<11), col); + renderDrawLine(x1-y2+(xdim<<11), y1+x3+(ydim<<11), + x1+x2+(xdim<<11), y1+y3+(ydim<<11), col); + renderDrawLine(x1+y2+(xdim<<11), y1-x3+(ydim<<11), + x1+x2+(xdim<<11), y1+y3+(ydim<<11), col); + break; + + case 16: + if (spr->picnum == LASERLINE) + { + x1 = sprx; + y1 = spry; + tilenum = spr->picnum; + xoff = picanm[tilenum].xofs + spr->xoffset; + if ((spr->cstat&4) > 0) xoff = -xoff; + k = spr->ang; + l = spr->xrepeat; + dax = sintable[k&2047]*l; + day = sintable[(k+1536)&2047]*l; + l = tilesiz[tilenum].x; + k = (l>>1)+xoff; + x1 -= mulscale16(dax, k); + x2 = x1+mulscale16(dax, l); + y1 -= mulscale16(day, k); + y2 = y1+mulscale16(day, l); + + ox = x1-cposx; + oy = y1-cposy; + x1 = dmulscale16(ox, xvect, -oy, yvect); + y1 = dmulscale16(oy, xvect2, ox, yvect2); + + ox = x2-cposx; + oy = y2-cposy; + x2 = dmulscale16(ox, xvect, -oy, yvect); + y2 = dmulscale16(oy, xvect2, ox, yvect2); + + renderDrawLine(x1+(xdim<<11), y1+(ydim<<11), + x2+(xdim<<11), y2+(ydim<<11), col); + } + + break; + + case 32: + tilenum = spr->picnum; + xoff = picanm[tilenum].xofs + spr->xoffset; + yoff = picanm[tilenum].yofs + spr->yoffset; + if ((spr->cstat&4) > 0) xoff = -xoff; + if ((spr->cstat&8) > 0) yoff = -yoff; + + k = spr->ang; + cosang = sintable[(k+512)&2047]; + sinang = sintable[k&2047]; + xspan = tilesiz[tilenum].x; + xrepeat = spr->xrepeat; + yspan = tilesiz[tilenum].y; + yrepeat = spr->yrepeat; + + dax = ((xspan>>1)+xoff)*xrepeat; + day = ((yspan>>1)+yoff)*yrepeat; + x1 = sprx + dmulscale16(sinang, dax, cosang, day); + y1 = spry + dmulscale16(sinang, day, -cosang, dax); + l = xspan*xrepeat; + x2 = x1 - mulscale16(sinang, l); + y2 = y1 + mulscale16(cosang, l); + l = yspan*yrepeat; + k = -mulscale16(cosang, l); + x3 = x2+k; + x4 = x1+k; + k = -mulscale16(sinang, l); + y3 = y2+k; + y4 = y1+k; + + ox = x1-cposx; + oy = y1-cposy; + x1 = dmulscale16(ox, xvect, -oy, yvect); + y1 = dmulscale16(oy, xvect2, ox, yvect2); + + ox = x2-cposx; + oy = y2-cposy; + x2 = dmulscale16(ox, xvect, -oy, yvect); + y2 = dmulscale16(oy, xvect2, ox, yvect2); + + ox = x3-cposx; + oy = y3-cposy; + x3 = dmulscale16(ox, xvect, -oy, yvect); + y3 = dmulscale16(oy, xvect2, ox, yvect2); + + ox = x4-cposx; + oy = y4-cposy; + x4 = dmulscale16(ox, xvect, -oy, yvect); + y4 = dmulscale16(oy, xvect2, ox, yvect2); + + renderDrawLine(x1+(xdim<<11), y1+(ydim<<11), + x2+(xdim<<11), y2+(ydim<<11), col); + + renderDrawLine(x2+(xdim<<11), y2+(ydim<<11), + x3+(xdim<<11), y3+(ydim<<11), col); + + renderDrawLine(x3+(xdim<<11), y3+(ydim<<11), + x4+(xdim<<11), y4+(ydim<<11), col); + + renderDrawLine(x4+(xdim<<11), y4+(ydim<<11), + x1+(xdim<<11), y1+(ydim<<11), col); + + break; + } + } + } + + renderDisableFog(); +#endif + + //Draw white lines + for (i=numsectors-1; i>=0; i--) + { + if (!(show2dsector[i>>3]&pow2char[i&7])) continue; + + startwall = sector[i].wallptr; + endwall = sector[i].wallptr + sector[i].wallnum; + z2 = sector[i].floorz; + + if (nMapMode == 2) + { + col = 111; + } + else + { + col = klabs(z2 - nPlayerZ) >> 13; + if (col > 15) + continue; + col = 111 - col; + } + + k = -1; + for (j=startwall, wal=(uwallptr_t)&wall[startwall]; jnextwall >= 0) continue; + + if (tilesiz[wal->picnum].x == 0) continue; + if (tilesiz[wal->picnum].y == 0) continue; + + if (j == k) + { + x1 = x2; + y1 = y2; + } + else + { + ox = wal->x-cposx; + oy = wal->y-cposy; + x1 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11); + y1 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11); + } + + k = wal->point2; + wal2 = (uwallptr_t)&wall[k]; + ox = wal2->x-cposx; + oy = wal2->y-cposy; + x2 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11); + y2 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11); + + renderDrawLine(x1, y1, x2, y2, col); + } + } + + renderEnableFog(); + + videoSetCorrectedAspect(); + +#if 0 + for (TRAVERSE_CONNECT(p)) + { + if (ud.scrollmode && p == screenpeek) continue; + + auto const pPlayer = g_player[p].ps; + auto const pSprite = (uspriteptr_t)&sprite[pPlayer->i]; + + ox = pSprite->x - cposx; + oy = pSprite->y - cposy; + daang = (pSprite->ang - cang) & 2047; + if (p == screenpeek) + { + ox = 0; + oy = 0; + daang = 0; + } + x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect); + y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2); + + if (p == screenpeek || GTFLAGS(GAMETYPE_OTHERPLAYERSINMAP)) + { + if (pSprite->xvel > 16 && pPlayer->on_ground) + i = APLAYERTOP+(((int32_t) totalclock>>4)&3); + else + i = APLAYERTOP; + + i = VM_OnEventWithReturn(EVENT_DISPLAYOVERHEADMAPPLAYER, pPlayer->i, p, i); + + if (i < 0) + continue; + + j = klabs(pPlayer->truefz - pPlayer->pos.z) >> 8; + j = mulscale16(czoom * (pSprite->yrepeat + j), yxaspect); + + if (j < 22000) j = 22000; + else if (j > (65536<<1)) j = (65536<<1); + + rotatesprite_win((x1<<4)+(xdim<<15), (y1<<4)+(ydim<<15), j, daang, i, pSprite->shade, + P_GetOverheadPal(pPlayer), 0); + } + } +#endif +} + void UpdateMap() { if (sector[initsect].ceilingpal != 3 || (nPlayerTorch[nLocalPlayer] != 0)) { @@ -273,7 +597,14 @@ void UpdateMap() void DrawMap() { - if (!nFreeze) { - drawoverheadmap(initx, inity, lMapZoom, inita); + if (!nFreeze && nMapMode) { + //drawoverheadmap(initx, inity, lMapZoom, inita); + if (nMapMode == 2) + { + videoClearViewableArea(blackcol); + RefreshBackground(); + renderDrawMapView(initx, inity, lMapZoom, inita); + } + G_DrawOverheadMap(initx, inity, lMapZoom, inita); } } diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 90637829a..0eaf718f5 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -582,7 +582,7 @@ void InitPlayerInventory(short nPlayer) PlayerList[nPlayer].nCurrentWeapon = 0; if (nPlayer == nLocalPlayer) { - bMapMode = 0; + nMapMode = 0; } nPlayerScore[nPlayer] = 0; diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index a6f9de6f3..046071516 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -17,6 +17,7 @@ #include "cd.h" #include "cdaudio.h" #include "typedefs.h" +#include "map.h" #include "move.h" #include "sound.h" #include "engine.h" @@ -479,6 +480,8 @@ void DrawView(int smoothRatio) UnMaskStatus(); } + UpdateMap(); + if (nFreeze != 3) { static uint8_t sectorFloorPal[MAXSECTORS]; @@ -580,6 +583,7 @@ void DrawView(int smoothRatio) if (nSnakeCam < 0) { DrawWeapons(smoothRatio); + DrawMap(); DrawStatus(); } else @@ -589,6 +593,8 @@ void DrawView(int smoothRatio) sprite[enemy].pal = nEnemyPal; } + DrawMap(); + if (!bFullScreen) { MaskStatus(); }