From 708483ca78b807d59a923ad86049fad740a73894 Mon Sep 17 00:00:00 2001 From: nukeykt Date: Sat, 31 Aug 2019 19:36:26 +0900 Subject: [PATCH] wip --- source/build/src/engine.cpp | 4 ++-- source/exhumed/src/enginesubs.cpp | 2 ++ source/exhumed/src/exhumed.cpp | 4 ++-- source/exhumed/src/light.cpp | 3 +++ source/exhumed/src/menu.cpp | 5 +++-- source/exhumed/src/object.cpp | 29 ++++++++++++++++------------- source/exhumed/src/object.h | 6 +++--- source/exhumed/src/runlist.cpp | 4 ++-- source/exhumed/src/status.cpp | 4 ++-- source/exhumed/src/switch.cpp | 9 +++++---- source/exhumed/src/switch.h | 2 +- 11 files changed, 41 insertions(+), 31 deletions(-) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index a6dafafa6..607dee9fb 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -7110,7 +7110,7 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t if (d4 >= u4) vlineasm4(d4-u4+1, (char *)(ylookup[u4]+p)); - i = p+ylookup[d4+1]; + intptr_t i = p+ylookup[d4+1]; if (y2ve[0] > d4) prevlineasm1(vince[0],palookupoffse[0],y2ve[0]-d4-1,vplce[0],bufplce[0],i+0); if (y2ve[1] > d4) prevlineasm1(vince[1],palookupoffse[1],y2ve[1]-d4-1,vplce[1],bufplce[1],i+1); if (y2ve[2] > d4) prevlineasm1(vince[2],palookupoffse[2],y2ve[2]-d4-1,vplce[2],bufplce[2],i+2); @@ -7134,7 +7134,7 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t if (d4 >= u4) mvlineasm4(d4-u4+1, (char *)(ylookup[u4]+p)); - i = p+ylookup[d4+1]; + intptr_t i = p+ylookup[d4+1]; if (y2ve[0] > d4) mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-d4-1,vplce[0],bufplce[0],i+0); if (y2ve[1] > d4) mvlineasm1(vince[1],palookupoffse[1],y2ve[1]-d4-1,vplce[1],bufplce[1],i+1); if (y2ve[2] > d4) mvlineasm1(vince[2],palookupoffse[2],y2ve[2]-d4-1,vplce[2],bufplce[2],i+2); diff --git a/source/exhumed/src/enginesubs.cpp b/source/exhumed/src/enginesubs.cpp index f5bc23967..c344afd47 100644 --- a/source/exhumed/src/enginesubs.cpp +++ b/source/exhumed/src/enginesubs.cpp @@ -38,6 +38,8 @@ void kensetpalette(unsigned char *vgapal) //setbrightness(0, (char*)vgapal, 4 | 2); // TODO Bmemcpy(palette, vgapal, 768); + for (auto &i : palette) + i <<= 2; videoSetPalette(0, 0, /*4 | */2); #if 0 char vesapal[1024]; diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 40860f21c..8a71f04ad 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -3277,8 +3277,8 @@ int DoSpiritHead() } // loc_135F9 - curx[i] = ebx << 8; - cury[i] = esi << 8; + curx[i] = ebx * 256; + cury[i] = esi * 256; //ecx += 2; // ecx++; diff --git a/source/exhumed/src/light.cpp b/source/exhumed/src/light.cpp index 3b9f234b8..7c071cde7 100644 --- a/source/exhumed/src/light.cpp +++ b/source/exhumed/src/light.cpp @@ -90,6 +90,9 @@ int LoadPaletteLookups() } kread(hFile, buffer, 256*64); + // TODO: dumb hack + if (palookup[i]) + ALIGNED_FREE_AND_NULL(palookup[i]); paletteSetLookupTable(i, buffer); kclose(hFile); diff --git a/source/exhumed/src/menu.cpp b/source/exhumed/src/menu.cpp index 7349b82b7..974ff0d48 100644 --- a/source/exhumed/src/menu.cpp +++ b/source/exhumed/src/menu.cpp @@ -1860,12 +1860,13 @@ void ReadyCinemaText(uint16_t nVal) uint8_t AdvanceCinemaText() { int var_1C = nCDTrackLength; + int tmp = nHeight + nCrawlY > 0; - if (nHeight + nCrawlY > 0 || nCDTrackLength && nCDTrackLength > 0) + if (tmp || nCDTrackLength && nCDTrackLength > 0) { nextclock = totalclock + 14; - if ((nHeight + nCrawlY > 0) > 0) + if (tmp > 0) { short y = nCrawlY; int edi = 0; diff --git a/source/exhumed/src/object.cpp b/source/exhumed/src/object.cpp index 37ba469d1..5671e83d4 100644 --- a/source/exhumed/src/object.cpp +++ b/source/exhumed/src/object.cpp @@ -343,7 +343,7 @@ short FindWallSprites(short nSector) return nSprite; } -int BuildElevF(int nChannel, int nSector, int nWallSprite, int arg_4, int arg_5, int nCount, int zList ...) +int BuildElevF(int nChannel, int nSector, int nWallSprite, int arg_4, int arg_5, int nCount, ...) { assert(ElevCount > 0); @@ -368,8 +368,9 @@ int BuildElevF(int nChannel, int nSector, int nWallSprite, int arg_4, int arg_5, } Elevator[ElevCount].nSprite = nWallSprite; - - int *pZVals = (int*)&zList; + + va_list zlist; + va_start(zlist, nCount); while (1) { @@ -381,14 +382,14 @@ int BuildElevF(int nChannel, int nSector, int nWallSprite, int arg_4, int arg_5, Elevator[ElevCount].nCountZOffsets++; - Elevator[ElevCount].zOffsets[nVal] = *pZVals; - pZVals++; + Elevator[ElevCount].zOffsets[nVal] = va_arg(zlist, int); } + va_end(zlist); return ElevCount; } -int BuildElevC(int arg1, int nChannel, int nSector, int nWallSprite, int arg5, int arg6, int nCount, int zList ...) +int BuildElevC(int arg1, int nChannel, int nSector, int nWallSprite, int arg5, int arg6, int nCount, ...) { int edi = arg5; @@ -421,7 +422,8 @@ int BuildElevC(int arg1, int nChannel, int nSector, int nWallSprite, int arg5, i Elevator[ElevCount].nSprite = nWallSprite; - int *pZVals = (int*)&zList; + va_list zlist; + va_start(zlist, nCount); while (1) { @@ -433,9 +435,9 @@ int BuildElevC(int arg1, int nChannel, int nSector, int nWallSprite, int arg5, i Elevator[ElevCount].nCountZOffsets++; - Elevator[ElevCount].zOffsets[nVal] = *pZVals; - pZVals++; + Elevator[ElevCount].zOffsets[nVal] = va_arg(zlist, int); } + va_end(zlist); return ElevCount; } @@ -775,7 +777,7 @@ void InitWallFace() WallFaceCount = kMaxWallFace; } -int BuildWallFace(short nChannel, short nWall, short nCount, int nPics ...) +int BuildWallFace(short nChannel, short nWall, short nCount, ...) { if (WallFaceCount <= 0) { bail2dos("Too many wall faces!\n"); @@ -791,16 +793,17 @@ int BuildWallFace(short nChannel, short nWall, short nCount, int nPics ...) nCount = 8; } - int *pPicNums = (int*)&nPics; + va_list piclist; + va_start(piclist, nCount); while (WallFace[WallFaceCount].field_4 < nCount) { int i = WallFace[WallFaceCount].field_4; WallFace[WallFaceCount].field_4++; - WallFace[WallFaceCount].field_6[i] = *pPicNums; - pPicNums++; + WallFace[WallFaceCount].field_6[i] = va_arg(piclist, short); } + va_end(piclist); return WallFaceCount | 0x70000; } diff --git a/source/exhumed/src/object.h b/source/exhumed/src/object.h index 93ef15c64..0c880df65 100644 --- a/source/exhumed/src/object.h +++ b/source/exhumed/src/object.h @@ -59,10 +59,10 @@ void BuildDrip(int nSprite); int BuildEnergyBlock(short nSector); -int BuildElevC(int arg1, int nChannel, int nSector, int nWallSprite, int arg5, int arg6, int nCount, int zList ...); -int BuildElevF(int nChannel, int nSector, int nWallSprite, int arg_4, int arg_5, int nCount, int zList ...); +int BuildElevC(int arg1, int nChannel, int nSector, int nWallSprite, int arg5, int arg6, int nCount, ...); +int BuildElevF(int nChannel, int nSector, int nWallSprite, int arg_4, int arg_5, int nCount, ...); -int BuildWallFace(short nChannel, short nWall, short nCount, int nPics ...); +int BuildWallFace(short nChannel, short nWall, short nCount, ...); int BuildSlide(int nChannel, int edx, int ebx, int ecx, int arg1, int arg2, int arg3); diff --git a/source/exhumed/src/runlist.cpp b/source/exhumed/src/runlist.cpp index 9044c84a1..2e4f57461 100644 --- a/source/exhumed/src/runlist.cpp +++ b/source/exhumed/src/runlist.cpp @@ -1358,7 +1358,7 @@ 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), var_18 * 100, var_18 * 100, 2, (int)sector[nSector].floorz, (int)sector[nextSector].ceilingz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); @@ -1375,7 +1375,7 @@ void runlist_ProcessSectorTag(int nSector, int lotag, int hitag) case 74: { - int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, sector[nSector].ceilingz, sector[nSector].floorz); + int nElev = BuildElevC(0, nChannel, nSector, FindWallSprites(nSector), var_18 * 100, var_18 * 100, 2, (int)sector[nSector].ceilingz, (int)sector[nSector].floorz); runlist_AddRunRec(sRunChannels[nChannel].a, nElev); diff --git a/source/exhumed/src/status.cpp b/source/exhumed/src/status.cpp index c71dd862e..fbbbe55df 100644 --- a/source/exhumed/src/status.cpp +++ b/source/exhumed/src/status.cpp @@ -834,10 +834,10 @@ void DrawStatus() int x = (nViewLeft + nViewRight) / 2; - sprintf(coordBuf, "X %d", sprite[nSprite].x); + sprintf(coordBuf, "X %d", (int)sprite[nSprite].x); printext(x, nViewTop + 1, coordBuf, kTile159, 255); - sprintf(coordBuf, "Y %d", sprite[nSprite].y); + sprintf(coordBuf, "Y %d", (int)sprite[nSprite].y); printext(x, nViewTop + 10, coordBuf, kTile159, 255); } diff --git a/source/exhumed/src/switch.cpp b/source/exhumed/src/switch.cpp index a18126203..9f807090f 100644 --- a/source/exhumed/src/switch.cpp +++ b/source/exhumed/src/switch.cpp @@ -37,13 +37,14 @@ void InitLink() LinkCount = kMaxLinks; } -int BuildLink(int nCount, int argList ...) +int BuildLink(int nCount, ...) { if (LinkCount <= 0) { return -1; } - int *pList = &argList; + va_list list; + va_start(list, nCount); LinkCount--; @@ -57,12 +58,12 @@ int BuildLink(int nCount, int argList ...) } else { - ebx = *pList; - pList++; + ebx = va_arg(list, int); } LinkMap[LinkCount][i] = (int8_t)ebx; } + va_end(list); return LinkCount; } diff --git a/source/exhumed/src/switch.h b/source/exhumed/src/switch.h index d105ca71f..8b9471092 100644 --- a/source/exhumed/src/switch.h +++ b/source/exhumed/src/switch.h @@ -17,7 +17,7 @@ void FuncSwPressWall(int, int, int); int BuildSwPause(int nChannel, int nLink, int ebx); int BuildSwNotOnPause(int nChannel, int nLink, int nSector, int ecx); -int BuildLink(int nCount, int argList ...); +int BuildLink(int nCount, ...); int BuildSwPressSector(int nChannel, int nLink, int nSector, int ecx); int BuildSwStepOn(int nChannel, int nLink, int nSector); int BuildSwReady(int nChannel, short nLink);