From efaefff3d0446b4d045d97ab1037d1f123ddabfd Mon Sep 17 00:00:00 2001 From: sirlemonhead Date: Tue, 4 Feb 2020 21:45:10 +0000 Subject: [PATCH] PCExhumed: Misc code tidying. Changed cases in runlist_ProcessSectorTag() to match editor tag numbers, consolidated duplicate code in runlist_ProcessWallTag(), renamed ActiveSound struct vars etc. # Conflicts: # source/exhumed/src/cd.cpp # source/exhumed/src/exhumed.cpp # source/exhumed/src/fish.cpp # source/exhumed/src/grenade.cpp # source/exhumed/src/mummy.cpp # source/exhumed/src/sound.cpp --- source/exhumed/src/aistuff.h | 3 + source/exhumed/src/bullet.cpp | 4 +- source/exhumed/src/bullet.h | 2 +- source/exhumed/src/cd.cpp | 1 - source/exhumed/src/exhumed.cpp | 38 +-- source/exhumed/src/fish.cpp | 7 +- source/exhumed/src/grenade.cpp | 19 +- source/exhumed/src/gun.cpp | 6 +- source/exhumed/src/init.cpp | 78 +++-- source/exhumed/src/lighting.cpp | 10 +- source/exhumed/src/lighting.h | 2 +- source/exhumed/src/move.cpp | 154 ++++------ source/exhumed/src/move.h | 4 +- source/exhumed/src/movie.cpp | 3 +- source/exhumed/src/mummy.cpp | 21 +- source/exhumed/src/names.h | 32 +- source/exhumed/src/object.cpp | 85 +++--- source/exhumed/src/player.cpp | 14 +- source/exhumed/src/runlist.cpp | 513 ++++++++++++-------------------- source/exhumed/src/runlist.h | 4 +- source/exhumed/src/snake.cpp | 2 +- source/exhumed/src/sound.h | 14 +- source/exhumed/src/switch.cpp | 4 +- source/exhumed/src/trigdat.cpp | 1 - 24 files changed, 415 insertions(+), 606 deletions(-) diff --git a/source/exhumed/src/aistuff.h b/source/exhumed/src/aistuff.h index c5365b31c..7022d2162 100644 --- a/source/exhumed/src/aistuff.h +++ b/source/exhumed/src/aistuff.h @@ -42,6 +42,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS #define KMaxTimeSlots 16 +#define kMessageMask 0x7F0000 + +#define kAIFish 0x120000 void InitTimeSlot(); int GrabTimeSlot(int nVal); diff --git a/source/exhumed/src/bullet.cpp b/source/exhumed/src/bullet.cpp index 6aabdb4eb..4a074e5ac 100644 --- a/source/exhumed/src/bullet.cpp +++ b/source/exhumed/src/bullet.cpp @@ -518,11 +518,11 @@ HITWALL: } // loc_2A639: - if (BulletInfo[nType].field_10) + if (BulletInfo[nType].nRadius) { nRadialBullet = nType; - runlist_RadialDamageEnemy(nSprite, pBulletInfo->nDamage, pBulletInfo->field_10); + runlist_RadialDamageEnemy(nSprite, pBulletInfo->nDamage, pBulletInfo->nRadius); nRadialBullet = -1; diff --git a/source/exhumed/src/bullet.h b/source/exhumed/src/bullet.h index c51ea97a6..e00d5c142 100644 --- a/source/exhumed/src/bullet.h +++ b/source/exhumed/src/bullet.h @@ -31,7 +31,7 @@ struct bulletInfo short nSeq; // 10 short field_C; // 12 short nFlags; - short field_10; // damage radius? + short nRadius; // damage radius short xyRepeat; char pad[12]; }; diff --git a/source/exhumed/src/cd.cpp b/source/exhumed/src/cd.cpp index 44375b96b..7f8eefec7 100644 --- a/source/exhumed/src/cd.cpp +++ b/source/exhumed/src/cd.cpp @@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -extern short word_9AC30; int nLastVolumeSet = 0; diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 8cc77207a..d0823fa5c 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -1467,9 +1467,9 @@ void DrawClock() while (nVal) { int v2 = nVal & 0xF; - int yPos = 32 - tilesiz[v2 + kTile3606].y / 2; + int yPos = 32 - tilesiz[v2 + kClockSymbol1].y / 2; - CopyTileToBitmap(v2 + kTile3606, kTile3603, ebp - tilesiz[v2 + kTile3606].x / 2, yPos); + CopyTileToBitmap(v2 + kClockSymbol1, kTile3603, ebp - tilesiz[v2 + kClockSymbol1].x / 2, yPos); ebp -= 15; @@ -2491,13 +2491,9 @@ void DoGameOverScene() SetOverscan(BASEPAL); } -// TODO - missing some values? -short word_10010[] = {6, 25, 43, 50, 68, 78, 101, 111, 134, 158, 173, 230, 6000}; - void DoTitle() { - short theArray[13]; - memcpy(theArray, word_10010, sizeof(word_10010)); + short skullDurations[] = { 6, 25, 43, 50, 68, 78, 101, 111, 134, 158, 173, 230, 6000 }; videoSetViewableArea(0, 0, xdim - 1, ydim - 1); @@ -2576,12 +2572,12 @@ void DoTitle() int nStartTime = (int)totalclock; int nCount = 0; - int var_18 = (int)totalclock; + int var_18 = (int)totalclock + skullDurations[0]; int var_4 = 0; int esi = 130; - var_18 += theArray[0]; + inputState.ClearAllInput(); while (LocalSoundPlaying()) @@ -2607,8 +2603,7 @@ void DoTitle() nCount++; if (nCount > 12) break; - var_18 = nStartTime + theArray[nCount]; - + var_18 = nStartTime + skullDurations[nCount]; var_4 = var_4 == 0; } @@ -2924,9 +2919,6 @@ int DoSpiritHead() nHeadTimeStart = (int)totalclock + 480; } -// int ecx = 0; - - // loc_1362C for (int i = 0; i < nPixelsToShow; i++) { if (destvely[i] >= 0) @@ -2968,7 +2960,6 @@ int DoSpiritHead() } } - // loc_13593 int esi = vely[i] + (cury[i] >> 8); if (esi < 106) @@ -2985,7 +2976,6 @@ int DoSpiritHead() esi = 0; } - // loc_135C6 int ebx = velx[i] + (curx[i] >> 8); if (ebx < 97) @@ -3002,13 +2992,9 @@ int DoSpiritHead() ebx = 0; } - // loc_135F9 curx[i] = ebx * 256; cury[i] = esi * 256; - //ecx += 2; -// ecx++; - esi += (ebx + 97) * 212; Worktile[106 + esi] = pixelval[i]; @@ -3018,7 +3004,6 @@ int DoSpiritHead() } else { - // loc_13679: if (nHeadStage != 1) { return 1; } @@ -3047,11 +3032,8 @@ int DoSpiritHead() } } - // loc_13705 int esi = 0; -// int edx = 0; - // loc_137E7: for (int i = 0; i < nPixels; i++) { int eax = (origx[i] << 8) - curx[i]; @@ -3077,7 +3059,6 @@ int DoSpiritHead() ecx >>= 3; } - // loc_1374B int var_1C = (origy[i] << 8) - cury[i]; int ebp = var_1C; @@ -3114,7 +3095,6 @@ int DoSpiritHead() ecx = (((curx[i] >> 8) + 97) * 212) + (cury[i] >> 8); -// edx++; Worktile[106 + ecx] = pixelval[i]; } @@ -3146,7 +3126,6 @@ int DoSpiritHead() } else { - // loc_138A7 FixPalette(); if (!nPalDiff) @@ -3209,7 +3188,6 @@ int DoSpiritHead() ebx += word_964EA; - // TODO - fixme. How big is worktile? uint8_t *pDest = &Worktile[10441]; const uint8_t* pSrc = tilePtr(ebx); @@ -3237,10 +3215,6 @@ int DoSpiritHead() short nTileSizeX = tilesiz[nMouthTile + 598].x; short nTileSizeY = tilesiz[nMouthTile + 598].y; - // TODO - checkme. near loc_133AA -// uint8_t *pDest = (uint8_t*)worktile; -// pDest += (212 * (97 - nTileSizeX / 2)) + (159 - nTileSizeY); - uint8_t *pDest = &Worktile[212 * (97 - nTileSizeX / 2)] + (159 - nTileSizeY); const uint8_t *pSrc = tilePtr(nMouthTile + 598); diff --git a/source/exhumed/src/fish.cpp b/source/exhumed/src/fish.cpp index b770abaeb..72d1c4772 100644 --- a/source/exhumed/src/fish.cpp +++ b/source/exhumed/src/fish.cpp @@ -16,6 +16,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #include "ns.h" +#include "aistuff.h" #include "fish.h" #include "anims.h" #include "engine.h" @@ -161,7 +162,7 @@ void FuncFishLimb(int a, int UNUSED(nDamage), int nRun) int nSeq = SeqOffsets[kSeqFish] + FishChunk[nFish].field_4; - int nMessage = a & 0x7F0000; + int nMessage = a & kMessageMask; switch (nMessage) { @@ -328,13 +329,13 @@ void FuncFish(int a, int nDamage, int nRun) short nSprite = FishList[nFish].nSprite; short nAction = FishList[nFish].nAction; - int nMessage = a & 0x7F0000; + int nMessage = a & kMessageMask; switch (nMessage) { default: { - Printf("unknown msg %d for Fish\n", a & 0x7F0000); + Printf("unknown msg %d for Fish\n", nMessage); return; } diff --git a/source/exhumed/src/grenade.cpp b/source/exhumed/src/grenade.cpp index 7e908a921..3f343baa8 100644 --- a/source/exhumed/src/grenade.cpp +++ b/source/exhumed/src/grenade.cpp @@ -16,6 +16,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #include "ns.h" +#include "aistuff.h" #include "grenade.h" #include "engine.h" #include "player.h" @@ -96,7 +97,7 @@ void BounceGrenade(short nGrenade, short nAngle) { GrenadeList[nGrenade].field_10 >>= 1; - GrenadeList[nGrenade].x = (Sin(nAngle + 512) >> 5) * GrenadeList[nGrenade].field_10; + GrenadeList[nGrenade].x = (Cos(nAngle) >> 5) * GrenadeList[nGrenade].field_10; GrenadeList[nGrenade].y = (Sin(nAngle) >> 5) * GrenadeList[nGrenade].field_10; D3PlayFX(StaticSound[kSound3], GrenadeList[nGrenade].nSprite); @@ -134,7 +135,7 @@ int ThrowGrenade(short nPlayer, int UNUSED(edx), int UNUSED(ebx), int ecx, int p GrenadeList[nGrenade].field_10 = ((90 - GrenadeList[nGrenade].field_E) * (90 - GrenadeList[nGrenade].field_E)) + nVel; sprite[nGrenadeSprite].zvel = (-64 * push1) - 4352; - int nMov = movesprite(nGrenadeSprite, Sin(nAngle + 512) * (sprite[nPlayerSprite].clipdist << 3), Sin(nAngle) * (sprite[nPlayerSprite].clipdist << 3), ecx, 0, 0, CLIPMASK1); + int nMov = movesprite(nGrenadeSprite, Cos(nAngle) * (sprite[nPlayerSprite].clipdist << 3), Sin(nAngle) * (sprite[nPlayerSprite].clipdist << 3), ecx, 0, 0, CLIPMASK1); if (nMov & 0x8000) { nAngle = GetWallNormal(nMov & 0x3FFF); @@ -147,7 +148,7 @@ int ThrowGrenade(short nPlayer, int UNUSED(edx), int UNUSED(ebx), int ecx, int p sprite[nGrenadeSprite].zvel = sprite[nPlayerSprite].zvel; } - GrenadeList[nGrenade].x = Sin(nAngle + 512) >> 4; + GrenadeList[nGrenade].x = Cos(nAngle) >> 4; GrenadeList[nGrenade].x *= GrenadeList[nGrenade].field_10; GrenadeList[nGrenade].y = Sin(nAngle) >> 4; @@ -176,16 +177,16 @@ int BuildGrenade(int nPlayer) sprite[nSprite].shade = -64; sprite[nSprite].xrepeat = 20; sprite[nSprite].yrepeat = 20; - sprite[nSprite].cstat = 0x8000u; + sprite[nSprite].cstat = 0x8000; sprite[nSprite].picnum = 1; sprite[nSprite].pal = 0; sprite[nSprite].clipdist = 30; sprite[nSprite].xoffset = 0; sprite[nSprite].yoffset = 0; sprite[nSprite].ang = sprite[nPlayerSprite].ang; - sprite[nSprite].yvel = 0; sprite[nSprite].owner = nPlayerSprite; sprite[nSprite].xvel = 0; + sprite[nSprite].yvel = 0; sprite[nSprite].zvel = 0; sprite[nSprite].hitag = 0; sprite[nSprite].lotag = runlist_HeadRun() + 1; @@ -248,7 +249,7 @@ void ExplodeGrenade(short nGrenade) short nAngle = sprite[nPlayerSprite].ang; sprite[nGrenadeSprite].z = sprite[nPlayerSprite].z; - sprite[nGrenadeSprite].x = (Sin(nAngle + 512) >> 5) + sprite[nPlayerSprite].x; + sprite[nGrenadeSprite].x = (Cos(nAngle) >> 5) + sprite[nPlayerSprite].x; sprite[nGrenadeSprite].y = (Sin(nAngle) >> 5) + sprite[nPlayerSprite].y; changespritesect(nGrenadeSprite, sprite[nPlayerSprite].sectnum); @@ -264,7 +265,7 @@ void ExplodeGrenade(short nGrenade) nDamage *= 2; } - runlist_RadialDamageEnemy(nGrenadeSprite, nDamage, BulletInfo[kWeaponGrenade].field_10); + runlist_RadialDamageEnemy(nGrenadeSprite, nDamage, BulletInfo[kWeaponGrenade].nRadius); BuildAnim(-1, var_28, 0, sprite[nGrenadeSprite].x, sprite[nGrenadeSprite].y, sprite[nGrenadeSprite].z, sprite[nGrenadeSprite].sectnum, var_20, 4); AddFlash(sprite[nGrenadeSprite].sectnum, sprite[nGrenadeSprite].x, sprite[nGrenadeSprite].y, sprite[nGrenadeSprite].z, 128); @@ -290,7 +291,7 @@ void FuncGrenade(int a, int UNUSED(nDamage), int nRun) nSeq = SeqOffsets[kSeqGrenRoll] + GrenadeList[nGrenade].field_A; } - int nMessage = a & 0x7F0000; + int nMessage = a & kMessageMask; switch (nMessage) { @@ -302,7 +303,7 @@ void FuncGrenade(int a, int UNUSED(nDamage), int nRun) default: { - Printf("unknown msg %d for bullet\n", a & 0x7F0000); // TODO - change 'bullet' to 'grenade' ? + Printf("unknown msg %d for grenade\n", nMessage); return; } diff --git a/source/exhumed/src/gun.cpp b/source/exhumed/src/gun.cpp index 4e724c5ca..ca9f21776 100644 --- a/source/exhumed/src/gun.cpp +++ b/source/exhumed/src/gun.cpp @@ -700,7 +700,7 @@ loc_flag: int theY = sprite[nPlayerSprite].y; int theZ = sprite[nPlayerSprite].z; - int ebp = Sin(nAngle + 512) * (sprite[nPlayerSprite].clipdist << 3); + int ebp = Cos(nAngle) * (sprite[nPlayerSprite].clipdist << 3); int ebx = Sin(nAngle) * (sprite[nPlayerSprite].clipdist << 3); if (WeaponInfo[nWeapon].c) @@ -714,7 +714,7 @@ loc_flag: ecx = theVal; int var_44 = (nAngle + 512) & kAngleMask; - ebp += ((Sin(var_44 + 512) >> 11) * ecx); + ebp += (Cos(var_44) >> 11) * ecx; ebx += (Sin(var_44) >> 11) * ecx; } @@ -884,7 +884,7 @@ loc_flag: nDamage *= 2; } - runlist_RadialDamageEnemy(nPlayerSprite, nDamage, BulletInfo[kWeaponMummified].field_10); + runlist_RadialDamageEnemy(nPlayerSprite, nDamage, BulletInfo[kWeaponMummified].nRadius); break; } } diff --git a/source/exhumed/src/init.cpp b/source/exhumed/src/init.cpp index 9708234eb..ce71028c3 100644 --- a/source/exhumed/src/init.cpp +++ b/source/exhumed/src/init.cpp @@ -342,33 +342,29 @@ void InitSectFlag() } } -void ProcessSpriteTag(short nSprite, short lotag, short hitag) +void ProcessSpriteTag(short nSprite, short nLotag, short nHitag) { - int nChannel = runlist_AllocChannel(hitag % 1000); -// int ebp = nChannel; + int nChannel = runlist_AllocChannel(nHitag % 1000); -// int nHitag2 = hitag / 1000; - - int nLotag2 = lotag / 1000; - if (nLotag2 == 0) { - nLotag2 = 1; + int nSpeed = nLotag / 1000; + if (!nSpeed) { + nSpeed = 1; } - // this value can change in the below code but we also need to retain the original hitag value - int nVal = hitag; + int nVal = nHitag; - if (lotag >= 900 && lotag <= 949) + if (nLotag >= 900 && nLotag <= 949) { - ProcessTrailSprite(nSprite, lotag, hitag); + ProcessTrailSprite(nSprite, nLotag, nHitag); return; } // handle tags 6 to 60 - switch (lotag) + switch (nLotag) { case 8: // M-60 ammo belt { - nVal = 3 * (hitag / 3); + nVal = 3 * (nHitag / 3); // fall through to 6,7 etc fallthrough__; } @@ -420,7 +416,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) case 60: { sprite[nSprite].hitag = nVal; - changespritestat(nSprite, lotag + 900); + changespritestat(nSprite, nLotag + 900); sprite[nSprite].cstat &= 0xFEFE; BuildItemAnim(nSprite); return; @@ -428,7 +424,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) case 12: // berry twig { sprite[nSprite].hitag = 40; - changespritestat(nSprite, lotag + 900); + changespritestat(nSprite, nLotag + 900); sprite[nSprite].cstat &= 0xFEFE; BuildItemAnim(nSprite); return; @@ -436,7 +432,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) case 13: // blood bowl { sprite[nSprite].hitag = 160; - changespritestat(nSprite, lotag + 900); + changespritestat(nSprite, nLotag + 900); sprite[nSprite].cstat &= 0xFEFE; BuildItemAnim(nSprite); return; @@ -444,7 +440,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) case 14: // venom bowl { sprite[nSprite].hitag = -200; - changespritestat(nSprite, lotag + 900); + changespritestat(nSprite, nLotag + 900); sprite[nSprite].cstat &= 0xFEFE; BuildItemAnim(nSprite); return; @@ -467,7 +463,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) else { sprite[nSprite].hitag = nVal; - changespritestat(nSprite, lotag + 900); + changespritestat(nSprite, nLotag + 900); sprite[nSprite].cstat &= 0xFEFE; BuildItemAnim(nSprite); return; @@ -487,14 +483,14 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) nVal++; nVal--; // CHECKME ?? sprite[nSprite].hitag = nVal; - changespritestat(nSprite, lotag + 900); + changespritestat(nSprite, nLotag + 900); sprite[nSprite].cstat &= 0xFEFE; BuildItemAnim(nSprite); return; } } - int v6 = lotag % 1000; + int v6 = nLotag % 1000; if (!bNoCreatures || v6 < 100 || v6 > 118) { @@ -507,12 +503,12 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) { case 999: { - AddFlicker(sprite[nSprite].sectnum, nLotag2); + AddFlicker(sprite[nSprite].sectnum, nSpeed); break; } case 998: { - AddGlow(sprite[nSprite].sectnum, nLotag2); + AddGlow(sprite[nSprite].sectnum, nSpeed); break; } case 118: // Anubis with drum @@ -658,7 +654,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) case 99: // underwater type 2 { short nSector = sprite[nSprite].sectnum; - SetAbove(nSector, hitag); + SetAbove(nSector, nHitag); SectFlag[nSector] |= kSectUnderwater; mydeletesprite(nSprite); @@ -667,29 +663,29 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) case 98: { short nSector = sprite[nSprite].sectnum; - SetBelow(nSector, hitag); - SnapSectors(nSector, hitag, 1); + SetBelow(nSector, nHitag); + SnapSectors(nSector, nHitag, 1); mydeletesprite(nSprite); return; } case 97: { - AddSectorBob(sprite[nSprite].sectnum, hitag, 1); + AddSectorBob(sprite[nSprite].sectnum, nHitag, 1); mydeletesprite(nSprite); return; } case 96: // Lava sector { - hitag /= 4; // hitag is damage level? - if (hitag == 0) { - hitag = 1; + int nDamage = nHitag / 4; + if (!nDamage) { + nDamage = 1; } short nSector = sprite[nSprite].sectnum; - SectDamage[nSector] = hitag; + SectDamage[nSector] = nDamage; SectFlag[nSector] |= kSectLava; mydeletesprite(nSprite); @@ -697,7 +693,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) } case 95: { - AddSectorBob(sprite[nSprite].sectnum, hitag, 0); + AddSectorBob(sprite[nSprite].sectnum, nHitag, 0); mydeletesprite(nSprite); return; @@ -705,7 +701,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) case 94: // water { short nSector = sprite[nSprite].sectnum; - SectDepth[nSector] = hitag << 8; + SectDepth[nSector] = nHitag << 8; mydeletesprite(nSprite); return; @@ -717,7 +713,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) } case 90: { - BuildObject(nSprite, 3, hitag); + BuildObject(nSprite, 3, nHitag); return; } case 79: @@ -725,7 +721,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) { short nSector = sprite[nSprite].sectnum; - SectSpeed[nSector] = nLotag2; + SectSpeed[nSector] = nSpeed; SectFlag[nSector] |= sprite[nSprite].ang; mydeletesprite(nSprite); @@ -733,7 +729,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) } case 88: { - AddFlow(nSprite, nLotag2, 0); + AddFlow(nSprite, nSpeed, 0); mydeletesprite(nSprite); return; @@ -748,7 +744,7 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) } case 78: { - AddFlow(nSprite, nLotag2, 1); + AddFlow(nSprite, nSpeed, 1); short nSector = sprite[nSprite].sectnum; SectFlag[nSector] |= 0x8000; @@ -758,24 +754,24 @@ void ProcessSpriteTag(short nSprite, short lotag, short hitag) } case 77: { - int nArrow = BuildArrow(nSprite, nLotag2); + int nArrow = BuildArrow(nSprite, nSpeed); runlist_AddRunRec(sRunChannels[nChannel].a, nArrow); return; } case 76: // Explosion Trigger (Exploding Fire Cauldron) { - BuildObject(nSprite, 0, hitag); + BuildObject(nSprite, 0, nHitag); return; } case 75: // Explosion Target (Cauldrons, fireballs and grenades will destroy nearby 75 sprites) { - BuildObject(nSprite, 1, hitag); + BuildObject(nSprite, 1, nHitag); return; } case 71: { - int nFireball = BuildFireBall(nSprite, hitag, nLotag2); + int nFireball = BuildFireBall(nSprite, nHitag, nSpeed); runlist_AddRunRec(sRunChannels[nChannel].a, nFireball); return; diff --git a/source/exhumed/src/lighting.cpp b/source/exhumed/src/lighting.cpp index 49d2b4260..d794b4312 100644 --- a/source/exhumed/src/lighting.cpp +++ b/source/exhumed/src/lighting.cpp @@ -612,7 +612,7 @@ void DoFlickers() } // nWall can also be passed in here via nSprite parameter - TODO - rename nSprite parameter :) -void AddFlow(int nSprite, int a, int b) +void AddFlow(int nSprite, int nSpeed, int b) { if (nFlowCount >= kMaxFlows) return; @@ -630,8 +630,8 @@ void AddFlow(int nSprite, int a, int b) sFlowInfo[nFlow].field_14 = (tilesiz[nPic].x << 14) - 1; sFlowInfo[nFlow].field_18 = (tilesiz[nPic].y << 14) - 1; - sFlowInfo[nFlow].field_C = -Cos(nAngle) * a; - sFlowInfo[nFlow].field_10 = Sin(nAngle) * a; + sFlowInfo[nFlow].field_C = -Cos(nAngle) * nSpeed; + sFlowInfo[nFlow].field_10 = Sin(nAngle) * nSpeed; } else { @@ -649,8 +649,8 @@ void AddFlow(int nSprite, int a, int b) sFlowInfo[nFlow].field_14 = (tilesiz[nPic].x * wall[var_18].xrepeat) << 8; sFlowInfo[nFlow].field_18 = (tilesiz[nPic].y * wall[var_18].yrepeat) << 8; - sFlowInfo[nFlow].field_C = -Cos(nAngle) * a; - sFlowInfo[nFlow].field_10 = Sin(nAngle) * a; + sFlowInfo[nFlow].field_C = -Cos(nAngle) * nSpeed; + sFlowInfo[nFlow].field_10 = Sin(nAngle) * nSpeed; } sFlowInfo[nFlow].field_8 = 0; diff --git a/source/exhumed/src/lighting.h b/source/exhumed/src/lighting.h index fdd146486..86bcb06c6 100644 --- a/source/exhumed/src/lighting.h +++ b/source/exhumed/src/lighting.h @@ -28,7 +28,7 @@ void AddFlash(short nSector, int x, int y, int z, int val); void SetTorch(int nPlayer, int bTorchOnOff); void UndoFlashes(); void DoLights(); -void AddFlow(int nSprite, int a, int b); +void AddFlow(int nSprite, int nSpeed, int b); void BuildFlash(short nPlayer, short nSector, int nVal); void AddGlow(short nSector, int nVal); void AddFlicker(short nSector, int nVal); diff --git a/source/exhumed/src/move.cpp b/source/exhumed/src/move.cpp index 27c556e78..9e616f4fa 100644 --- a/source/exhumed/src/move.cpp +++ b/source/exhumed/src/move.cpp @@ -82,27 +82,29 @@ static SavegameHelper sgh("move", signed int lsqrt(int a1) { - int v1; // edx@1 - int v2; // ebx@1 - signed int result; // eax@1 + int v1; + int v2; + signed int result; v1 = a1; v2 = a1 - 0x40000000; + result = 0; + if (v2 >= 0) { - result = 0x8000; + result = 32768; v1 = v2; } if (v1 - ((result << 15) + 0x10000000) >= 0) { v1 -= (result << 15) + 0x10000000; - result += 0x4000; + result += 16384; } if (v1 - ((result << 14) + 0x4000000) >= 0) { v1 -= (result << 14) + 0x4000000; - result += 0x2000; + result += 8192; } if (v1 - ((result << 13) + 0x1000000) >= 0) { @@ -165,7 +167,8 @@ signed int lsqrt(int a1) result += 2; } if (v1 - (2 * result + 1) >= 0) - ++result; + result += 1; + return result; } @@ -694,7 +697,7 @@ int PlotCourseToSprite(int nSprite1, int nSprite2) return ksqrt(y * y + x * x); } -int FindPlayer(int nSprite, int nVal) +int FindPlayer(int nSprite, int nDistance) { int var_18 = 0; if (nSprite >= 0) @@ -703,8 +706,8 @@ int FindPlayer(int nSprite, int nVal) if (nSprite < 0) nSprite = -nSprite; - if (nVal < 0) - nVal = 100; + if (nDistance < 0) + nDistance = 100; int x = sprite[nSprite].x; int y = sprite[nSprite].y; @@ -712,7 +715,7 @@ int FindPlayer(int nSprite, int nVal) int z = sprite[nSprite].z - GetSpriteHeight(nSprite); - nVal <<= 8; + nDistance <<= 8; short nPlayerSprite; int i = 0; @@ -726,20 +729,13 @@ int FindPlayer(int nSprite, int nVal) if ((sprite[nPlayerSprite].cstat & 0x101) && (!(sprite[nPlayerSprite].cstat & 0x8000))) { - int v9 = sprite[nPlayerSprite].x - x; - if (v9 < 0) { - v9 = -v9; - } + int v9 = klabs(sprite[nPlayerSprite].x - x); - int v10 = sprite[nPlayerSprite].y - y; - - if (v9 < nVal) + if (v9 < nDistance) { - if (v10 < 0) { - v10 = -v10; - } + int v10 = klabs(sprite[nPlayerSprite].y - y); - if (v10 < nVal && cansee(sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].z - 7680, sprite[nPlayerSprite].sectnum, x, y, z, nSector)) + if (v10 < nDistance && cansee(sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].z - 7680, sprite[nPlayerSprite].sectnum, x, y, z, nSector)) { break; } @@ -756,7 +752,7 @@ int FindPlayer(int nSprite, int nVal) return nPlayerSprite; } -void CheckSectorFloor(short nSector, int z, int *a, int *b) +void CheckSectorFloor(short nSector, int z, int *x, int *y) { short nSpeed = SectSpeed[nSector]; @@ -769,13 +765,13 @@ void CheckSectorFloor(short nSector, int z, int *a, int *b) if (z >= sector[nSector].floorz) { - *a += (Sin(nAng + 512) << 3) * nSpeed; - *b += (sintable[nAng] << 3) * nSpeed; + *x += (Cos(nAng) << 3) * nSpeed; + *y += (sintable[nAng] << 3) * nSpeed; // no anglemask in original code } else if (nFlag & 0x800) { - *a += (Sin(nAng + 512) << 4) * nSpeed; - *b += (sintable[nAng] << 4) * nSpeed; + *x += (Cos(nAng) << 4) * nSpeed; + *y += (sintable[nAng] << 4) * nSpeed; // no anglemask in original code } } @@ -821,27 +817,27 @@ void CreatePushBlock(int nSector) int startwall = sector[nSector].wallptr; int nWalls = sector[nSector].wallnum; - int ecx = 0; - int ebx = 0; + int xSum = 0; + int ySum = 0; for (i = 0; i < nWalls; i++) { - ecx += wall[startwall + i].x; - ebx += wall[startwall + i].y; + xSum += wall[startwall + i].x; + ySum += wall[startwall + i].y; } - int avgx = ecx / nWalls; - int avgy = ebx / nWalls; + int xAvg = xSum / nWalls; + int yAvg = ySum / nWalls; - sBlockInfo[nBlock].x = avgx; - sBlockInfo[nBlock].y = avgy; + sBlockInfo[nBlock].x = xAvg; + sBlockInfo[nBlock].y = yAvg; int nSprite = insertsprite(nSector, 0); sBlockInfo[nBlock].nSprite = nSprite; - sprite[nSprite].x = avgx; - sprite[nSprite].y = avgy; + sprite[nSprite].x = xAvg; + sprite[nSprite].y = yAvg; sprite[nSprite].z = sector[nSector].floorz - 256; sprite[nSprite].cstat = 0x8000; @@ -849,8 +845,8 @@ void CreatePushBlock(int nSector) for (i = 0; i < nWalls; i++) { - int x = avgx - wall[startwall + i].x; - int y = avgy - wall[startwall + i].y; + int x = xAvg - wall[startwall + i].x; + int y = yAvg - wall[startwall + i].y; int nSqrt = ksqrt(x * x + y * y); if (nSqrt > var_28) { @@ -1095,14 +1091,18 @@ void SetQuake(short nSprite, int nVal) int x = sprite[nSprite].x; int y = sprite[nSprite].y; + nVal *= 256; + for (int i = 0; i < nTotalPlayers; i++) { int nPlayerSprite = PlayerList[i].nSprite; - int nSqrt = ksqrt(((sprite[nPlayerSprite].x - x) >> 8) * ((sprite[nPlayerSprite].x - x) >> 8) + ((sprite[nPlayerSprite].y - y) >> 8) - * ((sprite[nPlayerSprite].y - y) >> 8)); + int xDiff = sprite[nPlayerSprite].x - x; + int yDiff = sprite[nPlayerSprite].y - y; - int eax = nVal * 256; + int nSqrt = ksqrt((xDiff >> 8)* (xDiff >> 8) + (yDiff >> 8)* (yDiff >> 8)); + + int eax = nVal; if (nSqrt) { @@ -1149,48 +1149,30 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1) { int nHeight = tilesiz[sprite[nSprite2].picnum].y * sprite[nSprite2].yrepeat * 2; - int nMyAngle = GetMyAngle(sprite[nSprite2].x - sprite[nSprite].x, sprite[nSprite2].y - sprite[nSprite].y); + int xDiff = sprite[nSprite2].x - sprite[nSprite].x; + int yDiff = sprite[nSprite2].y - sprite[nSprite].y; - int nSqrt = ksqrt( - (sprite[nSprite2].y - sprite[nSprite].y) - * - (sprite[nSprite2].y - sprite[nSprite].y) - + - (sprite[nSprite2].x - sprite[nSprite].x) - * - (sprite[nSprite2].x - sprite[nSprite].x) - ); + int nMyAngle = GetMyAngle(xDiff, yDiff); + + int nSqrt = ksqrt(xDiff * xDiff + yDiff * yDiff); int var_18 = GetMyAngle(nSqrt, ((sprite[nSprite2].z - nHeight) - sprite[nSprite].z) >> 8); -// int edx = nMyAngle; - int nAngDelta = AngleDelta(sprite[nSprite].ang, nMyAngle, 1024); - int nAngDelta2 = nAngDelta; - - if (nAngDelta2 < 0) - nAngDelta2 = -nAngDelta2; + int nAngDelta2 = klabs(nAngDelta); if (nAngDelta2 > 63) { - nAngDelta2 = nAngDelta; - nAngDelta2 >>= 6; - -// edx = ebx; - - if (nAngDelta2 < 0) - nAngDelta2 = -nAngDelta2; + nAngDelta2 = klabs(nAngDelta >> 6); ebx /= nAngDelta2; - if (ebx < 5) + if (ebx < 5) { ebx = 5; + } } - int nAngDeltaC = nAngDelta; - - if (nAngDeltaC < 0) - nAngDeltaC = -nAngDeltaC; + int nAngDeltaC = klabs(nAngDelta); if (nAngDeltaC > push1) { @@ -1200,32 +1182,23 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1) nAngDelta = -push1; } - int nAngDeltaD = AngleDelta(sprite[nSprite].zvel, var_18, 24); nAngle = (nAngDelta + sprite[nSprite].ang) & kAngleMask; - - // TODO - CHECKME int ebx = 24; + int nAngDeltaD = AngleDelta(sprite[nSprite].zvel, var_18, 24); sprite[nSprite].zvel = (sprite[nSprite].zvel + nAngDeltaD) & kAngleMask; } sprite[nSprite].ang = nAngle; - int eax = Sin(sprite[nSprite].zvel + 512); - int edx = (nAngle + 512) & kAngleMask; - - if (eax < 0) - eax = -eax; - - // rename this var. CHECKME - int x = ((sintable[edx] * ebx) >> 14) * eax; - - int ceildist = x >> 8; + int eax = klabs(Cos(sprite[nSprite].zvel)); + int x = ((Cos(nAngle) * ebx) >> 14)* eax; int y = ((Sin(nAngle) * ebx) >> 14) * eax; - int nVal = y >> 8; + int xshift = x >> 8; + int yshift = y >> 8; - int z = Sin(sprite[nSprite].zvel) * ksqrt((nVal * nVal) + (ceildist * ceildist)); + int z = Sin(sprite[nSprite].zvel) * ksqrt((yshift * yshift) + (xshift * xshift)); return movesprite(nSprite, x >> 2, y >> 2, (z >> 13) + (Sin(ecx) >> 5), 0, 0, nClipType); } @@ -1253,7 +1226,7 @@ void WheresMyMouth(int nPlayer, int *x, int *y, int *z, short *sectnum) *sectnum = sprite[nSprite].sectnum; clipmove_old((int32_t*)x, (int32_t*)y, (int32_t*)z, sectnum, - Sin(sprite[nSprite].ang + 512) << 7, + Cos(sprite[nSprite].ang) << 7, Sin(sprite[nSprite].ang) << 7, 5120, 1280, 1280, CLIPMASK1); } @@ -1323,8 +1296,7 @@ int GrabBody() if (nCurBodyNum >= 50) { nCurBodyNum = 0; } - } - while (sprite[nSprite].cstat & 0x101); + } while (sprite[nSprite].cstat & 0x101); if (nBodyTotal < 50) { nBodyTotal++; @@ -1445,9 +1417,9 @@ void FuncCreatureChunk(int a, int, int nRun) // re-grab this variable as it may have changed in movesprite(). Note the check above is against the value *before* movesprite so don't change it. nSector = sprite[nSprite].sectnum; - sprite[nSprite].zvel = 0; - sprite[nSprite].yvel = 0; sprite[nSprite].xvel = 0; + sprite[nSprite].yvel = 0; + sprite[nSprite].zvel = 0; sprite[nSprite].z = sector[nSector].floorz; } else @@ -1487,7 +1459,7 @@ void FuncCreatureChunk(int a, int, int nRun) int nSqrt = lsqrt(((sprite[nSprite].yvel >> 10) * (sprite[nSprite].yvel >> 10) + (sprite[nSprite].xvel >> 10) * (sprite[nSprite].xvel >> 10)) >> 8); - sprite[nSprite].xvel = Sin(nAngle + 512) * (nSqrt >> 1); + sprite[nSprite].xvel = Cos(nAngle) * (nSqrt >> 1); sprite[nSprite].yvel = Sin(nAngle) * (nSqrt >> 1); return; } diff --git a/source/exhumed/src/move.h b/source/exhumed/src/move.h index d6123ba01..827f44815 100644 --- a/source/exhumed/src/move.h +++ b/source/exhumed/src/move.h @@ -55,7 +55,7 @@ void CreatePushBlock(int nSector); void FuncCreatureChunk(int a, int, int nRun); -int FindPlayer(int nSprite, int nVal); +int FindPlayer(int nSprite, int nDistance); int BuildCreatureChunk(int nVal, int nPic); @@ -64,7 +64,7 @@ int BelowNear(short nSprite); int PlotCourseToSprite(int nSprite1, int nSprite2); -void CheckSectorFloor(short nSector, int z, int *a, int *b); +void CheckSectorFloor(short nSector, int z, int *x, int *y); int GetAngleToSprite(int nSprite1, int nSprite2); diff --git a/source/exhumed/src/movie.cpp b/source/exhumed/src/movie.cpp index 752f7d0f6..018559c04 100644 --- a/source/exhumed/src/movie.cpp +++ b/source/exhumed/src/movie.cpp @@ -161,7 +161,6 @@ int ReadFrame(FileReader &fp) } tileInvalidate(kMovieTile, -1, -1); - break; } case kFrameDone: @@ -173,7 +172,7 @@ int ReadFrame(FileReader &fp) } } -void ServeSample(const char** ptr, uint32_t* length) +static void ServeSample(const char** ptr, uint32_t* length) { //mutex_lock(&mutex); diff --git a/source/exhumed/src/mummy.cpp b/source/exhumed/src/mummy.cpp index d09bf9818..e80b77ad5 100644 --- a/source/exhumed/src/mummy.cpp +++ b/source/exhumed/src/mummy.cpp @@ -16,6 +16,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #include "ns.h" +#include "aistuff.h" #include "mummy.h" #include "sequence.h" #include "move.h" @@ -64,13 +65,12 @@ static SavegameHelper sgh("mummy", SA(MummyList), nullptr); -// done + void InitMummy() { nMummies = 0; } -// done int BuildMummy(int nSprite, int x, int y, int z, int nSector, int nAngle) { if (nMummies >= kMaxMummies) { @@ -134,7 +134,6 @@ int BuildMummy(int nSprite, int x, int y, int z, int nSector, int nAngle) return (nMummy | 0xE0000); } -// done void CheckMummyRevive(short nMummy) { short nSprite = MummyList[nMummy].nSprite; @@ -179,7 +178,7 @@ void FuncMummy(int a, int nDamage, int nRun) short nSprite = MummyList[nMummy].nSprite; short nAction = MummyList[nMummy].nAction; - int nMessage = a & 0x7F0000; + int nMessage = a & kMessageMask; switch (nMessage) { @@ -196,14 +195,14 @@ void FuncMummy(int a, int nDamage, int nRun) seq_MoveSequence(nSprite, nSeq, MummyList[nMummy].B); - short ecx = 0; + bool bVal = 0; MummyList[nMummy].B++; if (MummyList[nMummy].B >= SeqSize[nSeq]) { MummyList[nMummy].B = 0; - ecx = 1; + bVal = true; } if (nTarget != -1 && nAction < 4) @@ -378,7 +377,7 @@ void FuncMummy(int a, int nDamage, int nRun) case 3: { - if (ecx) + if (bVal) { MummyList[nMummy].B = 0; MummyList[nMummy].nAction = 0; @@ -391,7 +390,7 @@ void FuncMummy(int a, int nDamage, int nRun) SetQuake(nSprite, 100); // low 16 bits of returned var contains the sprite index, the high 16 the bullet number - int nBullet = BuildBullet(nSprite, 9, 0, 0, 0x0FFFFC400, sprite[nSprite].ang, nTarget + 10000, 1); + int nBullet = BuildBullet(nSprite, 9, 0, 0, -15360, sprite[nSprite].ang, nTarget + 10000, 1); CheckMummyRevive(nMummy); if (nBullet > -1) @@ -410,7 +409,7 @@ void FuncMummy(int a, int nDamage, int nRun) case 4: { - if (ecx) + if (bVal) { MummyList[nMummy].B = 0; MummyList[nMummy].nAction = 5; @@ -426,7 +425,7 @@ void FuncMummy(int a, int nDamage, int nRun) case 6: { - if (ecx) + if (bVal) { MummyList[nMummy].nAction = 0; sprite[nSprite].cstat = 0x101; @@ -445,7 +444,7 @@ void FuncMummy(int a, int nDamage, int nRun) sprite[nSprite].yvel >>= 1; } - if (ecx) + if (bVal) { sprite[nSprite].xvel = 0; sprite[nSprite].yvel = 0; diff --git a/source/exhumed/src/names.h b/source/exhumed/src/names.h index 08b1e1f8d..9bb8225b6 100644 --- a/source/exhumed/src/names.h +++ b/source/exhumed/src/names.h @@ -3625,22 +3625,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define kTile3603 3603 #define kEnergy1 3604 #define kEnergy2 3605 -#define kTile3606 3606 -#define kTile3607 3607 -#define kTile3608 3608 -#define kTile3609 3609 -#define kTile3610 3610 -#define kTile3611 3611 -#define kTile3612 3612 -#define kTile3613 3613 -#define kTile3614 3614 -#define kTile3615 3615 -#define kTile3616 3616 -#define kTile3617 3617 -#define kTile3618 3618 -#define kTile3619 3619 -#define kTile3620 3620 -#define kTile3621 3621 +#define kClockSymbol1 3606 +#define kClockSymbol2 3607 +#define kClockSymbol3 3608 +#define kClockSymbol4 3609 +#define kClockSymbol5 3610 +#define kClockSymbol6 3611 +#define kClockSymbol7 3612 +#define kClockSymbol8 3613 +#define kClockSymbol9 3614 +#define kClockSymbol10 3615 +#define kClockSymbol11 3616 +#define kClockSymbol12 3617 +#define kClockSymbol13 3618 +#define kClockSymbol14 3619 +#define kClockSymbol15 3620 +#define kClockSymbol16 3621 #define kTile3622 3622 #define kTileLoboLaptop 3623 #define kTile3624 3624 diff --git a/source/exhumed/src/object.cpp b/source/exhumed/src/object.cpp index 0af6271b6..038b56679 100644 --- a/source/exhumed/src/object.cpp +++ b/source/exhumed/src/object.cpp @@ -150,10 +150,10 @@ struct slideData int field_4; int field_8; int field_C; - int field_10; - int field_14; - int field_18; - int field_1C; + int x1; + int y1; + int x2; + int y2; int field_20; int field_24; int field_28; @@ -888,12 +888,8 @@ int IdentifySector(int nVal) return -1; } -int BuildSlide(int nChannel, int edx, int ebx, int ecx, int arg1, int arg2, int arg3) +int BuildSlide(int nChannel, int nStartWall, int ebx, int ecx, int nWall2, int nWall3, int nWall4) { - int var_1C = edx; - int ebp = ebx; - int nVal = ecx; - if (SlideCount <= 0) { I_Error("Too many slides!\n"); return -1; @@ -903,7 +899,7 @@ int BuildSlide(int nChannel, int edx, int ebx, int ecx, int arg1, int arg2, int int nSlide = SlideCount; - short nSector = IdentifySector(var_1C); + short nSector = IdentifySector(nStartWall); SlideData2[nSlide].field_4 = -1; SlideData2[nSlide].nChannel = nChannel; @@ -948,33 +944,35 @@ int BuildSlide(int nChannel, int edx, int ebx, int ecx, int arg1, int arg2, int } } - SlideData[nSlide].field_0 = var_1C; - SlideData[nSlide].field_8 = arg1; - SlideData[nSlide].field_C = arg2; - SlideData[nSlide].field_10 = wall[var_1C].x; - SlideData[nSlide].field_14 = wall[var_1C].y; + SlideData[nSlide].field_0 = nStartWall; + SlideData[nSlide].field_4 = ebx; + SlideData[nSlide].field_8 = nWall2; + SlideData[nSlide].field_C = nWall3; - SlideData[nSlide].field_1C = wall[arg1].y; - SlideData[nSlide].field_18 = wall[arg1].x; + SlideData[nSlide].x1 = wall[nStartWall].x; + SlideData[nSlide].y1 = wall[nStartWall].y; - SlideData[nSlide].field_24 = wall[ebp].y; - SlideData[nSlide].field_20 = wall[ebp].x; + SlideData[nSlide].x2 = wall[nWall2].x; + SlideData[nSlide].y2 = wall[nWall2].y; - SlideData[nSlide].field_2C = wall[arg2].y; - SlideData[nSlide].field_28 = wall[arg2].x; + SlideData[nSlide].field_20 = wall[ebx].x; + SlideData[nSlide].field_24 = wall[ebx].y; - SlideData[nSlide].field_34 = wall[nVal].y; - SlideData[nSlide].field_4 = ebp; - SlideData[nSlide].field_30 = wall[nVal].x; - SlideData[nSlide].field_38 = wall[arg3].x; - SlideData[nSlide].field_3C = wall[arg3].y; + SlideData[nSlide].field_28 = wall[nWall3].x; + SlideData[nSlide].field_2C = wall[nWall3].y; + + SlideData[nSlide].field_30 = wall[ecx].x; + SlideData[nSlide].field_34 = wall[ecx].y; + + SlideData[nSlide].field_38 = wall[nWall4].x; + SlideData[nSlide].field_3C = wall[nWall4].y; int nSprite = insertsprite(nSector, 899); SlideData2[nSlide].field_6 = nSprite; sprite[nSprite].cstat = 0x8000; - sprite[nSprite].x = wall[var_1C].x; - sprite[nSprite].y = wall[var_1C].y; + sprite[nSprite].x = wall[nStartWall].x; + sprite[nSprite].y = wall[nStartWall].y; sprite[nSprite].z = sector[nSector].floorz; SlideData2[nSlide].field_8 = 0; @@ -1088,11 +1086,11 @@ void FuncSlide(int a, int UNUSED(b), int nRun) int x = wall[nWall].x; int y = wall[nWall].y; - int nSeekA = LongSeek(&x, SlideData[nSlide].field_10, 20, 20); + int nSeekA = LongSeek(&x, SlideData[nSlide].x1, 20, 20); int edi = nSeekA; int var_1C = nSeekA; - int nSeekB = LongSeek(&y, SlideData[nSlide].field_14, 20, 20); + int nSeekB = LongSeek(&y, SlideData[nSlide].y1, 20, 20); int ecx = nSeekB; int var_28 = nSeekB; @@ -1114,11 +1112,11 @@ void FuncSlide(int a, int UNUSED(b), int nRun) x = wall[nWall].x; y = wall[nWall].y; - int nSeekC = LongSeek(&x, SlideData[nSlide].field_18, 20, 20); + int nSeekC = LongSeek(&x, SlideData[nSlide].x2, 20, 20); edi = nSeekC; var_1C = nSeekC; - int nSeekD = LongSeek(&y, SlideData[nSlide].field_1C, 20, 20); + int nSeekD = LongSeek(&y, SlideData[nSlide].y2, 20, 20); ecx = nSeekD; var_28 = nSeekD; @@ -1391,17 +1389,17 @@ int BuildSpark(int nSprite, int nVal) if (nVal) { - sprite[var_14].xvel = Sin(nAngle + 512) >> 5; + sprite[var_14].xvel = Cos(nAngle) >> 5; sprite[var_14].yvel = Sin(nAngle) >> 5; } else { - sprite[var_14].xvel = Sin(nAngle + 512) >> 6; + sprite[var_14].xvel = Cos(nAngle) >> 6; sprite[var_14].yvel = Sin(nAngle) >> 6; } sprite[var_14].zvel = -(RandomSize(4) << 7); - sprite[var_14].picnum = nVal + 985; + sprite[var_14].picnum = kTile985 + nVal; } sprite[var_14].z = sprite[nSprite].z; @@ -1436,6 +1434,7 @@ void FuncSpark(int a, int UNUSED(b), int nRun) { sprite[nSprite].yrepeat -= 2; + // calling BuildSpark() with 2nd parameter as '1' will set kTile986 if (sprite[nSprite].picnum == kTile986 && (sprite[nSprite].xrepeat & 2)) { BuildSpark(nSprite, 2); @@ -1539,7 +1538,7 @@ void DoFinale() StopLocalSound(); PlayLocalSound(StaticSound[kSound76], 0); dword_1542FC = (int)totalclock + 120; - ++nFinaleStage; + nFinaleStage++; } } else if (nFinaleStage <= 2) @@ -1578,7 +1577,7 @@ int BuildEnergyBlock(short nSector) x += wall[startwall + i].x; y += wall[startwall + i].y; - wall[startwall + i].picnum = kTile3621; + wall[startwall + i].picnum = kClockSymbol16; wall[startwall + i].pal = 0; wall[startwall + i].shade = 50; } @@ -1698,8 +1697,7 @@ void ExplodeEnergyBlock(int nSprite) for (i = 0; i < 20; i++) { sprite[nSprite].ang = RandomSize(11); - - BuildSpark(nSprite, 1); + BuildSpark(nSprite, 1); // shoot out blue orbs } TintPalette(64, 64, 64); @@ -1707,7 +1705,6 @@ void ExplodeEnergyBlock(int nSprite) if (nEnergyTowers == 1) { runlist_ChangeChannel(nEnergyChan, nEnergyTowers); - StatusMessage(1000, "TAKE OUT THE CONTROL CENTER!"); } else if (nEnergyTowers != 0) @@ -1810,13 +1807,12 @@ void FuncEnergyBlock(int a, int nDamage, int nRun) sprite[nSprite2].y = lasthity; sprite[nSprite2].z = lasthitz; - BuildSpark(nSprite2, 0); + BuildSpark(nSprite2, 0); // shoot out blue orb when damaged mydeletesprite(nSprite2); } else { - sprite[nSprite].xrepeat = 0; - + sprite[nSprite].xrepeat = 0; // using xrepeat to store health ExplodeEnergyBlock(nSprite); } @@ -1893,12 +1889,13 @@ int BuildObject(short nSprite, int nOjectType, int nHitag) return nObject | 0x170000; } +// in-game destructable wall mounted screen void ExplodeScreen(short nSprite) { sprite[nSprite].z -= GetSpriteHeight(nSprite) / 2; for (int i = 0; i < 30; i++) { - BuildSpark(nSprite, 0); + BuildSpark(nSprite, 0); // shoot out blue orbs } sprite[nSprite].cstat = 0x8000; diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 151698803..2121587ca 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -1688,7 +1688,7 @@ do_default_b: { if (AddAmmo(nPlayer, 1, sprite[nValB].hitag)) { - var_88 = StaticSound[kSound69]; + var_88 = StaticSound[kSoundAmmoPickup]; goto do_default; } @@ -1698,7 +1698,7 @@ do_default_b: { if (AddAmmo(nPlayer, 3, sprite[nValB].hitag)) { - var_88 = StaticSound[kSound69]; + var_88 = StaticSound[kSoundAmmoPickup]; goto do_default; } break; @@ -1707,7 +1707,7 @@ do_default_b: { if (AddAmmo(nPlayer, 2, sprite[nValB].hitag)) { - var_88 = StaticSound[kSound69]; + var_88 = StaticSound[kSoundAmmoPickup]; CheckClip(nPlayer); goto do_default; } @@ -1719,7 +1719,7 @@ do_default_b: { if (AddAmmo(nPlayer, 4, 1)) { - var_88 = StaticSound[kSound69]; + var_88 = StaticSound[kSoundAmmoPickup]; if (!(nPlayerWeapons[nPlayer] & 0x10)) { nPlayerWeapons[nPlayer] |= 0x10; @@ -2474,7 +2474,7 @@ do_default_b: case 31: // Cobra staff ammo { if (AddAmmo(nPlayer, 5, 1)) { - var_88 = StaticSound[kSound69]; + var_88 = StaticSound[kSoundAmmoPickup]; goto do_default; } @@ -2484,7 +2484,7 @@ do_default_b: case 32: // Raw Energy { if (AddAmmo(nPlayer, 6, sprite[nValB].hitag)) { - var_88 = StaticSound[kSound69]; + var_88 = StaticSound[kSoundAmmoPickup]; goto do_default; } @@ -2604,7 +2604,7 @@ do_default_b: break; } - var_88 = StaticSound[kSound67]; + var_88 = StaticSound[kSoundMana1]; PlayerList[nPlayer].nMagic += 100; if (PlayerList[nPlayer].nMagic >= 1000) { diff --git a/source/exhumed/src/runlist.cpp b/source/exhumed/src/runlist.cpp index 442d5170b..194ece37a 100644 --- a/source/exhumed/src/runlist.cpp +++ b/source/exhumed/src/runlist.cpp @@ -56,10 +56,10 @@ BEGIN_PS_NS #define kMaxRunStack 200 -short RunCount = -1; +short RunCount = -1; short nRadialSpr = -1; -short nStackCount = 0; -short word_966BE = 0; +short nStackCount = 0; +short word_966BE = 0; short ChannelList = -1; short ChannelLast = -1; @@ -289,7 +289,7 @@ void runlist_SubRunRec(int RunPtr) RunData[RunPtr].nMoves = -totalmoves; } -void runlist_SendMessageToRunRec(int nRun, int edx, int nDamage) +void runlist_SendMessageToRunRec(int nRun, int nMessage, int nDamage) { int nFunc = RunData[nRun].nRef;// >> 16; @@ -306,7 +306,7 @@ void runlist_SendMessageToRunRec(int nRun, int edx, int nDamage) assert(nFunc < kFuncMax); // REMOVE // do function pointer call here. - aiFunctions[nFunc](edx, nDamage, nRun); + aiFunctions[nFunc](nMessage, nDamage, nRun); } void runlist_ExplodeSignalRun() @@ -411,7 +411,7 @@ void runlist_InitChan() } } -void runlist_ChangeChannel(int eax, short dx) +void runlist_ChangeChannel(int eax, short nVal) { if (sRunChannels[eax].b < 0) { @@ -420,7 +420,7 @@ void runlist_ChangeChannel(int eax, short dx) sRunChannels[eax].b = nChannel; } - sRunChannels[eax].c = dx; + sRunChannels[eax].c = nVal; sRunChannels[eax].d |= 2; } @@ -454,21 +454,16 @@ void runlist_ProcessChannels() { b = sRunChannels[ChannelList].b; d = sRunChannels[ChannelList].d; - //v3 = v2[3]; - //b = v2[1]; if (d & 2) { sRunChannels[ChannelList].d = d ^ 2; - //v2[3] = v3 ^ 2; runlist_SignalRun(sRunChannels[ChannelList].a, ChannelList | 0x10000); } -// v4 = v3 & 1; if (d & 1) { sRunChannels[ChannelList].d ^= 1; -// *((_BYTE *)v2 + offsetof(RunChannel, d)) ^= 1u; runlist_SignalRun(sRunChannels[ChannelList].a, 0x30000); } @@ -589,30 +584,28 @@ void runlist_ExecObjects() runlist_SignalRun(RunChain, 0x20000); } -void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) +void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag) { int zListA[8]; int zListB[8]; - int _lotag = lotag; - int nChannel = runlist_AllocChannel(hitag % 1000); - assert(nChannel >= 0); // REMOVE + int nChannel = runlist_AllocChannel(nHitag % 1000); + assert(nChannel >= 0 && nChannel < kMaxChannels); - int var_24 = (hitag / 1000) << 12; - int var_18 = lotag / 1000; + int keyMask = (nHitag / 1000) << 12; + int nSpeed = nLotag / 1000; - if (!var_18) { - var_18 = 1; + if (!nSpeed) { + nSpeed = 1; } - var_18 <<= 2; + nSpeed <<= 2; - _lotag = (lotag % 1000); - int eax = _lotag - 1; + int nEffectTag = (nLotag % 1000); - switch (eax) + switch (nEffectTag) { - case 0: // Ceiling Doom door + case 1: // Ceiling Doom door { /* This function searches z-coordinates of neighboring sectors to find the @@ -621,11 +614,11 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - int nSwPress = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, var_24); + int nSwPress = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask); runlist_AddRunRec(sRunChannels[nChannel].a, nSwPress); @@ -635,16 +628,16 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 1: // Floor Doom door + case 2: // Floor Doom door { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].ceilingz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].ceilingz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - int nSwPress = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, var_24); + int nSwPress = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask); runlist_AddRunRec(sRunChannels[nChannel].a, nSwPress); @@ -654,48 +647,48 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 2: case 3: - case 18: + case 4: case 19: - case 21: - case 28: + case 20: + case 22: case 29: - case 45: + case 30: case 46: - case 59: - case 64: + case 47: + case 60: case 65: case 66: - case 68: - case 71: + case 67: + case 69: case 72: case 73: - case 75: + case 74: case 76: case 77: case 78: - case 80: + case 79: case 81: case 82: case 83: case 84: + case 85: { return; } - case 4: // Permanent floor raise + case 5: // Permanent floor raise { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz + 1, -1, -1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 5: // Touchplate floor lower, single + case 6: // Touchplate floor lower, single { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, -1); assert(nextSector > -1); @@ -712,12 +705,12 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 6: // Touchplate floor lower, multiple + case 7: // Touchplate floor lower, multiple { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -731,23 +724,23 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 7: // Permanent floor lower + case 8: // Permanent floor lower { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 8: // Switch activated lift down + case 9: // Switch activated lift down { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -757,12 +750,12 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 9: // Touchplate Floor Raise + case 10: // Touchplate Floor Raise { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, -1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -776,9 +769,9 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 10: // Permanent floor raise - case 13: // Sector raise / lower - case 37: // Sector raise / lower + case 11: // Permanent floor raise + case 14: // Sector raise / lower + case 38: // Sector raise / lower { /* fix for original behaviour - nextSector could be -1 the and game would do an invalid memory read @@ -792,13 +785,13 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) zVal = sector[nextSector].floorz; } - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, zVal); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, zVal); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 11: // Switch activated lift up + case 12: // Switch activated lift up { /* fix for original behaviour - nextSector could be -1 the and game would do an invalid memory read @@ -812,7 +805,7 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) zVal = sector[nextSector].floorz; } - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, zVal); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, zVal); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -822,7 +815,7 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 12: // Bobbing floor + case 13: // Bobbing floor { /* fix for original behaviour - nextSector could be -1 the and game would do an invalid memory read @@ -836,7 +829,7 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) zVal = sector[nextSector].floorz; } - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, zVal); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, zVal); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -846,20 +839,20 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 14: // Sector raise/lower + case 15: // Sector raise/lower { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, -1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 15: // Stuttering noise (floor makes noise) + case 16: // Stuttering noise (floor makes noise) { - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, var_18 * 100, 2, sector[nSector].ceilingz, sector[nSector].floorz - 8); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, nSpeed * 100, 2, sector[nSector].ceilingz, sector[nSector].floorz - 8); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -873,9 +866,9 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 16: // Reserved? + case 17: // Reserved? { - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, var_18 * 100, 2, sector[nSector].ceilingz, sector[nSector].floorz - 8); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, nSpeed * 100, 2, sector[nSector].ceilingz, sector[nSector].floorz - 8); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -885,17 +878,17 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 17: // Raises floor AND lowers ceiling + case 18: // Raises floor AND lowers ceiling { int ebx = ((sector[nSector].floorz - sector[nSector].ceilingz) / 2) + sector[nSector].ceilingz; - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), 200, var_18 * 100, 2, sector[nSector].floorz, ebx); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), 200, nSpeed * 100, 2, sector[nSector].floorz, ebx); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); int ebx2 = (((sector[nSector].floorz - sector[nSector].ceilingz) / 2) + sector[nSector].ceilingz) - 8; - int nElev2 = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, var_18 * 100, 2, sector[nSector].ceilingz, ebx2); + int nElev2 = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, nSpeed * 100, 2, sector[nSector].ceilingz, ebx2); runlist_AddRunRec(sRunChannels[nChannel].a, nElev2); @@ -905,7 +898,7 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 20: // Touchplate + case 21: // Touchplate { int nSwitch = BuildSwStepOn(nChannel, BuildLink(2, 1, 1), nSector); @@ -913,7 +906,7 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 22: // Floor raise, Sychronize + case 23: // Floor raise, Sychronize { /* fix for original behaviour - nextSector could be -1 the and game would do an invalid memory read @@ -931,18 +924,18 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - int nSwitch = BuildSwPause(nChannel, BuildLink(2, -1, 0), var_18 * 60); + int nSwitch = BuildSwPause(nChannel, BuildLink(2, -1, 0), nSpeed * 60); runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); return; } - case 23: // Ceiling door, channel trigger only + case 24: // Ceiling door, channel trigger only { short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -952,31 +945,16 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 24: - { - short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); - assert(nextSector > -1); - - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); - - runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - - int nSwitch = BuildSwPause(nChannel, BuildLink(2, -1, 0), 300); - - runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); - return; - } - case 25: { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - int nSwitch = BuildSwPause(nChannel, BuildLink(2, -1, 0), 450); + int nSwitch = BuildSwPause(nChannel, BuildLink(2, -1, 0), 300); runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); return; @@ -987,11 +965,11 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - int nSwitch = BuildSwPause(nChannel, BuildLink(2, -1, 0), 600); + int nSwitch = BuildSwPause(nChannel, BuildLink(2, -1, 0), 450); runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); return; @@ -1002,7 +980,22 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + + runlist_AddRunRec(sRunChannels[nChannel].a, nElev); + + int nSwitch = BuildSwPause(nChannel, BuildLink(2, -1, 0), 600); + + runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); + return; + } + + case 28: + { + short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); + assert(nextSector > -1); + + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -1012,7 +1005,7 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 30: // Touchplate + case 31: // Touchplate { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); @@ -1027,7 +1020,7 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 31: + case 32: { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); @@ -1038,54 +1031,54 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 32: // Ceiling Crusher + case 33: // Ceiling Crusher { short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevC(20, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nextSector].ceilingz, sector[nSector].floorz); + int nElev = BuildElevC(20, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nextSector].ceilingz, sector[nSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 33: // Triggerable Ceiling Crusher(Inactive) + case 34: // Triggerable Ceiling Crusher(Inactive) { short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevC(28, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nextSector].ceilingz, sector[nSector].floorz); + int nElev = BuildElevC(28, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nextSector].ceilingz, sector[nSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 34: // Destructible sector - case 35: + case 35: // Destructible sector + case 36: { nEnergyTowers++; int nEnergyBlock = BuildEnergyBlock(nSector); - if (_lotag == 36) { + if (nLotag == 36) { nFinaleSpr = nEnergyBlock; } return; } - case 36: + case 37: { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 38: // Touchplate + case 39: // Touchplate { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); @@ -1104,43 +1097,43 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 39: // Moving sector(follows waypoints) - { - AddMovingSector(nSector, lotag, hitag % 1000, 2); - return; - } - case 40: // Moving sector(follows waypoints) { - AddMovingSector(nSector, lotag, hitag % 1000, 18); + AddMovingSector(nSector, nLotag, nHitag % 1000, 2); return; } case 41: // Moving sector(follows waypoints) { - AddMovingSector(nSector, lotag, hitag % 1000, 58); + AddMovingSector(nSector, nLotag, nHitag % 1000, 18); return; } case 42: // Moving sector(follows waypoints) { - AddMovingSector(nSector, lotag, hitag % 1000, 122); + AddMovingSector(nSector, nLotag, nHitag % 1000, 58); return; } case 43: // Moving sector(follows waypoints) { - AddMovingSector(nSector, lotag, hitag % 1000, 90); + AddMovingSector(nSector, nLotag, nHitag % 1000, 122); return; } - case 44: // Pushbox sector + case 44: // Moving sector(follows waypoints) + { + AddMovingSector(nSector, nLotag, nHitag % 1000, 90); + return; + } + + case 45: // Pushbox sector { CreatePushBlock(nSector); return; } - case 47: // Ceiling lower + case 48: // Ceiling lower { /* fix for original behaviour - nextSector could be -1 the and game would do an invalid memory read @@ -1154,24 +1147,24 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) zVal = sector[nextSector].ceilingz; } - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, var_18 * 100, 2, sector[nSector].ceilingz, zVal); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, nSpeed * 100, 2, sector[nSector].ceilingz, zVal); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 48: + case 49: { short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, var_18 * 100, 2, sector[nSector].ceilingz, sector[nextSector].ceilingz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, nSpeed * 100, 2, sector[nSector].ceilingz, sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 49: // Floor lower / raise + case 50: // Floor lower / raise { short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, 1, 1); assert(nextSector > -1); @@ -1182,17 +1175,17 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 50: + case 51: { int edx = ((sector[nSector].floorz - sector[nSector].ceilingz) / 2) + sector[nSector].ceilingz; - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), 200, var_18 * 100, 2, sector[nSector].floorz, edx); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), 200, nSpeed * 100, 2, sector[nSector].floorz, edx); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); int eax = (((sector[nSector].floorz - sector[nSector].ceilingz) / 2) + sector[nSector].ceilingz) - 8; - nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, var_18 * 100, 2, sector[nSector].ceilingz, eax); + nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), 200, nSpeed * 100, 2, sector[nSector].ceilingz, eax); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -1202,21 +1195,21 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 51: + case 52: { int eax = ((sector[nSector].floorz - sector[nSector].ceilingz) / 2) + sector[nSector].ceilingz; - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, eax, sector[nSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, eax, sector[nSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); eax = ((sector[nSector].floorz - sector[nSector].ceilingz) / 2) + sector[nSector].ceilingz; - nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, eax, sector[nSector].ceilingz); + nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, eax, sector[nSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, var_24); + int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask); runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); @@ -1226,17 +1219,17 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 52: + case 53: { int eax = ((sector[nSector].floorz - sector[nSector].ceilingz) / 2) + sector[nSector].ceilingz; - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, eax, sector[nSector].floorz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, eax, sector[nSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); eax = ((sector[nSector].floorz - sector[nSector].ceilingz) / 2) + sector[nSector].ceilingz; - nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, eax, sector[nSector].ceilingz); + nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, eax, sector[nSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -1246,31 +1239,16 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 53: - { - short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); - assert(nextSector > -1); - - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); - - runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - - int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, var_24); - - runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); - return; - } - case 54: { short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, var_24); + int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask); runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); return; @@ -1281,18 +1259,22 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); + + int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask); + + runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); return; } case 56: { - short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); + short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].ceilingz, sector[nextSector].floorz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; @@ -1300,7 +1282,18 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) case 57: { - int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, var_24); + short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); + assert(nextSector > -1); + + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].ceilingz, sector[nextSector].floorz); + + runlist_AddRunRec(sRunChannels[nChannel].a, nElev); + return; + } + + case 58: + { + int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask); runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); @@ -1309,25 +1302,25 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) } case 62: { - if (_lotag == 63) { + if (nLotag == 63) { nEnergyChan = nChannel; } short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); return; } - case 58: + case 59: { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -1341,7 +1334,7 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) return; } - case 60: + case 61: { zListB[0] = sector[nSector].floorz; int var_1C = 1; @@ -1358,15 +1351,14 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) var_1C++; } - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, var_1C, + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, var_1C, zListB[0], zListB[1], zListB[2], zListB[3], zListB[4], zListB[5], zListB[6], zListB[7]); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - return; } - case 61: + case 63: { zListA[0] = sector[nSector].floorz; int var_20 = 1; @@ -1383,65 +1375,60 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) var_20++; } - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, var_20, + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, var_20, zListA[0], zListA[1], zListA[2], zListA[3], zListA[4], zListA[5], zListA[6], zListA[7]); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - return; } - case 63: + case 64: { int nSwitch = BuildSwStepOn(nChannel, BuildLink(2, 0, 0), nSector); runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); - return; } - case 67: + case 68: { short nextSector = nextsectorneighborz(nSector, sector[nSector].floorz, 1, 1); assert(nextSector > -1); - int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); + int nElev = BuildElevF(nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, sector[nSector].floorz, sector[nextSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - return; } - case 69: case 70: + case 71: { short nextSector = nextsectorneighborz(nSector, sector[nSector].ceilingz, -1, -1); assert(nextSector > -1); - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, (int)sector[nSector].floorz, (int)sector[nextSector].ceilingz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, (int)sector[nSector].floorz, (int)sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, var_24); + int nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask); runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch); int nSwitch2 = BuildSwPause(nChannel, BuildLink(2, -1, 0), 60); runlist_AddRunRec(sRunChannels[nChannel].a, nSwitch2); - return; } - case 74: + case 75: { - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, (int)sector[nSector].ceilingz, (int)sector[nSector].floorz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), nSpeed * 100, nSpeed * 100, 2, (int)sector[nSector].ceilingz, (int)sector[nSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); - return; } - case 79: + case 80: { SectFlag[nSector] |= 0x8000; return; @@ -1449,34 +1436,19 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) } } -void runlist_ProcessWallTag(int nWall, short lotag, short hitag) +void runlist_ProcessWallTag(int nWall, short nLotag, short nHitag) { - int nChannel = runlist_AllocChannel(hitag % 1000); + int nChannel = runlist_AllocChannel(nHitag % 1000); assert(nChannel >= 0 && nChannel < kMaxChannels); - int var_18 = 0; // TODO - FIXME CHECKME. This doesn't seem to be initialised in the ASM? - int var_28; - - int var_20 = 0; // TODO - FIXME CHECKME. This doesn't seem to be initialised in the ASM? - int var_34; - - int var_14 = 0; // TODO - FIXME CHECKME. This doesn't seem to be initialised in the ASM? - int var_24; - - int var_38 = 0; // TODO - FIXME CHECKME. This doesn't seem to be initialised in the ASM? - int var_2C; - - int ebp = 0; // TODO - FIXME CHECKME. This doesn't seem to be initialised in the ASM? - int var_30; - - int eax = lotag / 1000; - if (!eax) { - eax = 1; + int nPanSpeed = nLotag / 1000; + if (!nPanSpeed) { + nPanSpeed = 1; } - int nEffectTag = lotag % 1000; - // int edi = nEffectTag; - eax <<= 2; + nPanSpeed <<= 2; + + int nEffectTag = nLotag % 1000; switch (nEffectTag) { @@ -1511,7 +1483,7 @@ void runlist_ProcessWallTag(int nWall, short lotag, short hitag) return; } - case 8: + case 8: // Reverse switch { int nWallFace = BuildWallFace(nChannel, nWall, 2, wall[nWall].picnum, wall[nWall].picnum + 1); runlist_AddRunRec(sRunChannels[nChannel].a, nWallFace); @@ -1536,145 +1508,48 @@ void runlist_ProcessWallTag(int nWall, short lotag, short hitag) return; } - case 12: - { - short nStart = nWall; - - while (1) - { - nWall = wall[nWall].point2; - - if (nStart == nWall) { - break; - } - - var_28 = var_18; - var_18 = nWall; - } - - short nWall2 = wall[nStart].point2; - short nWall3 = wall[nWall2].point2; - short nWall4 = wall[nWall3].point2; - - int nSlide = BuildSlide(nChannel, nStart, var_18, var_28, nWall2, nWall3, nWall4); - - runlist_AddRunRec(sRunChannels[nChannel].a, nSlide); - return; - } - + case 12: // Twin star trek door case 14: - { - short nStart = nWall; - - while (1) - { - nWall = wall[nWall].point2; - - if (nStart == nWall) { - break; - } - - var_34 = var_20; - var_20 = nWall; - } - - short nWall2 = wall[nStart].point2; - short nWall3 = wall[nWall2].point2; - short nWall4 = wall[nWall3].point2; - - int nSlide = BuildSlide(nChannel, nStart, var_20, var_34, nWall2, nWall3, nWall4); - - runlist_AddRunRec(sRunChannels[nChannel].a, nSlide); - return; - } - case 16: - { - short nStart = nWall; - - while (1) - { - nWall = wall[nWall].point2; - - if (nStart == nWall) { - break; - } - - var_24 = var_14; - var_14 = nWall; - } - - short nWall2 = wall[nStart].point2; - short nWall3 = wall[nWall2].point2; - short nWall4 = wall[nWall3].point2; - - int nSlide = BuildSlide(nChannel, nStart, var_14, var_24, nWall2, nWall3, nWall4); - - runlist_AddRunRec(sRunChannels[nChannel].a, nSlide); - return; - } - case 19: - { - short nStart = nWall; - - while (1) - { - nWall = wall[nWall].point2; - - if (nStart == nWall) { - break; - } - - var_2C = var_38; - var_38 = nWall; - } - - short nWall2 = wall[nStart].point2; - short nWall3 = wall[nWall2].point2; - short nWall4 = wall[nWall3].point2; - - int nSlide = BuildSlide(nChannel, nStart, var_38, var_2C, nWall2, nWall3, nWall4); - - runlist_AddRunRec(sRunChannels[nChannel].a, nSlide); - return; - } - case 20: { + int nLastWall = 0; + int n2ndLastWall = 0; + short nStart = nWall; while (1) { - nWall = wall[nWall].point2; + nWall = wall[nWall].point2; // get the next (right side) wall point - if (nStart == nWall) { + if (nStart == nWall) { // we've looped back around break; } - var_30 = ebp; - ebp = nWall; + n2ndLastWall = nLastWall; + nLastWall = nWall; } short nWall2 = wall[nStart].point2; short nWall3 = wall[nWall2].point2; short nWall4 = wall[nWall3].point2; - int nSlide = BuildSlide(nChannel, nStart, ebp, var_30, nWall2, nWall3, nWall4); + int nSlide = BuildSlide(nChannel, nStart, nLastWall, n2ndLastWall, nWall2, nWall3, nWall4); runlist_AddRunRec(sRunChannels[nChannel].a, nSlide); return; } - case 24: + case 24: // Waterfall { - AddFlow(nWall, eax, 3); + AddFlow(nWall, nPanSpeed, 3); return; } - case 25: + case 25: // Inverse waterfall { - AddFlow(nWall, eax, 2); + AddFlow(nWall, nPanSpeed, 2); return; } } @@ -1702,25 +1577,19 @@ int runlist_CheckRadialDamage(short nSprite) int y = (sprite[nSprite].y - sprite[nRadialSpr].y) >> 8; int z = (sprite[nSprite].z - sprite[nRadialSpr].z) >> 12; - if (x < 0) { - x = -x; - } + x = klabs(x); if (x > nDamageRadius) { return 0; } - if (y < 0) { - y = -y; - } + y = klabs(y); if (y > nDamageRadius) { return 0; } - if (z < 0) { - z = -z; - } + z = klabs(z); if (z > nDamageRadius) { return 0; @@ -1753,8 +1622,8 @@ int runlist_CheckRadialDamage(short nSprite) else if (edi > 20) { int nAngle = GetMyAngle(x, y); - sprite[nSprite].xvel += (short)((edi * Sin(nAngle + 512)) >> 3); - sprite[nSprite].yvel += (short)((edi * Sin(nAngle)) >> 3); + sprite[nSprite].xvel += (edi * Cos(nAngle)) >> 3; + sprite[nSprite].yvel += (edi * Sin(nAngle)) >> 3; sprite[nSprite].zvel -= edi * 24; if (sprite[nSprite].zvel < -3584) { @@ -1811,7 +1680,7 @@ void runlist_DamageEnemy(int nSprite, int nSprite2, short nDamage) runlist_SendMessageToRunRec(nRun, (nSprite2 & 0xFFFF) | 0x80000, nDamage * 4); // is there now one less creature? (has one died) - if (nPreCreaturesLeft > nCreaturesLeft && nSprite2 > -1) + if (nPreCreaturesLeft > nCreaturesLeft&& nSprite2 > -1) { if (sprite[nSprite2].statnum != 100) { return; diff --git a/source/exhumed/src/runlist.h b/source/exhumed/src/runlist.h index 543d7c9aa..704d1c358 100644 --- a/source/exhumed/src/runlist.h +++ b/source/exhumed/src/runlist.h @@ -68,11 +68,11 @@ int runlist_HeadRun(); void runlist_InitChan(); void runlist_ChangeChannel(int eax, short dx); void runlist_ReadyChannel(short eax); -void runlist_ProcessSectorTag(int nSector, int lotag, int hitag); +void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag); int runlist_AllocChannel(int a); void runlist_DoSubRunRec(int RunPtr); void runlist_SubRunRec(int RunPtr); -void runlist_ProcessWallTag(int nWall, short lotag, short hitag); +void runlist_ProcessWallTag(int nWall, short nLotag, short nHitag); int runlist_CheckRadialDamage(short nSprite); void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius); void runlist_DamageEnemy(int nSprite, int nSprite2, short nDamage); diff --git a/source/exhumed/src/snake.cpp b/source/exhumed/src/snake.cpp index 5b52fc982..d77fbb47f 100644 --- a/source/exhumed/src/snake.cpp +++ b/source/exhumed/src/snake.cpp @@ -113,7 +113,7 @@ void ExplodeSnakeSprite(int nSprite, short nPlayer) short nOwner = sprite[nSprite].owner; sprite[nSprite].owner = PlayerList[nPlayer].nSprite; - runlist_RadialDamageEnemy(nSprite, nDamage, BulletInfo[kWeaponStaff].field_10); + runlist_RadialDamageEnemy(nSprite, nDamage, BulletInfo[kWeaponStaff].nRadius); sprite[nSprite].owner = nOwner; diff --git a/source/exhumed/src/sound.h b/source/exhumed/src/sound.h index 02276dcc2..f9649f3d3 100644 --- a/source/exhumed/src/sound.h +++ b/source/exhumed/src/sound.h @@ -42,7 +42,7 @@ enum { kSound7, kSound8, kSound9, - kSound10, + kSoundItemSpecial, kSound11, kSoundTorchOn, kSound13, @@ -60,7 +60,7 @@ enum { kSound25, kSound26, kSound27, - kSound28, + kSoundJonLaugh2, kSound29, kSound30, kSound31, @@ -87,9 +87,9 @@ enum { kSound64, kSound65, kSound66, - kSound67, - kSound68, - kSound69, + kSoundMana1, + kSoundMana2, + kSoundAmmoPickup, kSound70, kSound71, kSound72, @@ -135,8 +135,8 @@ void BendAmbientSound(); void CheckAmbience(short nSector); short PlayFX2(unsigned short nSound, short nSprite); -short PlayFXAtXYZ(unsigned short ax, int x, int y, int z, int nSector); -short D3PlayFX(unsigned short nSound, short nVal); +short PlayFXAtXYZ(unsigned short nSound, int x, int y, int z, int nSector); +short D3PlayFX(unsigned short nSound, short nSprite); void StopSpriteSound(short nSprite); void StartSwirlies(); diff --git a/source/exhumed/src/switch.cpp b/source/exhumed/src/switch.cpp index a720cab64..cf3f5b2f6 100644 --- a/source/exhumed/src/switch.cpp +++ b/source/exhumed/src/switch.cpp @@ -401,7 +401,7 @@ void FuncSwNotOnPause(int a, int, int nRun) } } -int BuildSwPressSector(int nChannel, int nLink, int nSector, int ecx) +int BuildSwPressSector(int nChannel, int nLink, int nSector, int keyMask) { if (SwitchCount <= 0 || nLink < 0 || nSector < 0) I_Error("Too many switches!\n"); @@ -411,7 +411,7 @@ int BuildSwPressSector(int nChannel, int nLink, int nSector, int ecx) SwitchData[nSwitch].nChannel = nChannel; SwitchData[nSwitch].nLink = nLink; SwitchData[nSwitch].nSector = nSector; - SwitchData[nSwitch].field_12 = ecx; + SwitchData[nSwitch].field_12 = keyMask; SwitchData[nSwitch].field_C = -1; return nSwitch | 0x50000; diff --git a/source/exhumed/src/trigdat.cpp b/source/exhumed/src/trigdat.cpp index 7c3bd539b..68fbf25cc 100644 --- a/source/exhumed/src/trigdat.cpp +++ b/source/exhumed/src/trigdat.cpp @@ -39,7 +39,6 @@ int GetMyAngle(int x, int y) if (ebx >= 0) { // left path - edx = ebx << 11; if (y >= 0)