- Exhumed compiles without errors.

This commit is contained in:
Christoph Oelckers 2019-11-24 16:34:23 +01:00
parent 8d11990494
commit 11b8017752
5 changed files with 45 additions and 88 deletions

View file

@ -624,12 +624,13 @@ int loaddefinitions_game(const char *fileName, int32_t firstPass)
//////// ////////
#define kSpiritX = 106; const uint32_t kSpiritX = 106;
#define kSpiritY = 97; const uint32_t kSpiritY = 97;
short cPupData[300]; short cPupData[300];
//int worktile[97 * 106] = { 0 }; //int worktile[97 * 106] = { 0 };
uint8_t worktile[(97*2) * (106*2)] = { 0 }; uint8_t *Worktile;
const uint32_t WorktileSize = kSpiritX * 2 * kSpiritY * 2;
int lHeadStartClock; int lHeadStartClock;
short *pPupData; short *pPupData;
int lNextStateChange; int lNextStateChange;
@ -1991,7 +1992,7 @@ int app_main(int argc, char const* const* argv)
Bsprintf(tempbuf, "Exhumed %s", s_buildRev); Bsprintf(tempbuf, "Exhumed %s", s_buildRev);
registerosdcommands(); registerosdcommands();
SetupInput(); //SetupInput();
system_getcvars(); system_getcvars();
@ -2057,7 +2058,7 @@ int app_main(int argc, char const* const* argv)
// loc_11745: // loc_11745:
FadeOut(0); FadeOut(0);
// InstallEngine(); // InstallEngine();
KB_Startup(); //KB_Startup();
InitView(); InitView();
myloadconfig(); myloadconfig();
InitFX(); InitFX();
@ -3081,13 +3082,13 @@ void InitSpiritHead()
nHeadStage = 0; nHeadStage = 0;
// work tile is twice as big as the normal head size // work tile is twice as big as the normal head size
TileFiles.tileSetExternal(kTileRamsesWorkTile, 97 * 2, 106 * 2, worktile); Worktile = TileFiles.tileCreate(kTileRamsesWorkTile, 97 * 2, 106 * 2);
sprite[nSpiritSprite].cstat &= 0x7FFF; sprite[nSpiritSprite].cstat &= 0x7FFF;
nHeadTimeStart = (int)totalclock; nHeadTimeStart = (int)totalclock;
memset(worktile, -1, sizeof(worktile)); memset(Worktile, -1, WorktileSize);
tileInvalidate(kTileRamsesWorkTile, -1, -1); tileInvalidate(kTileRamsesWorkTile, -1, -1);
nPixelsToShow = 0; nPixelsToShow = 0;
@ -3153,7 +3154,7 @@ void DimSector(short nSector)
void CopyHeadToWorkTile(short nTile) void CopyHeadToWorkTile(short nTile)
{ {
const uint8_t* pSrc = tilePtr(nTile); const uint8_t* pSrc = tilePtr(nTile);
uint8_t *pDest = (uint8_t*)&worktile[212 * 49 + 53]; uint8_t *pDest = &Worktile[212 * 49 + 53];
for (int i = 0; i < 97; i++) for (int i = 0; i < 97; i++)
{ {
@ -3175,7 +3176,7 @@ int DoSpiritHead()
if (nHeadStage < 2) if (nHeadStage < 2)
{ {
memset(worktile, -1, sizeof(worktile)); memset(Worktile, -1, WorktileSize);
} }
if (nHeadStage < 2 || nHeadStage != 5) if (nHeadStage < 2 || nHeadStage != 5)
@ -3296,11 +3297,7 @@ int DoSpiritHead()
esi += (ebx + 97) * 212; esi += (ebx + 97) * 212;
// uint8_t *pVal = (uint8_t*)worktile; Worktile[106 + esi] = pixelval[i];
worktile[106 + esi] = pixelval[i];
//pVal += (106 + esi);
//*pVal = pixelval[i];
} }
return 1; return 1;
@ -3405,12 +3402,7 @@ int DoSpiritHead()
// edx++; // edx++;
// uint8_t *pVal = (uint8_t*)worktile; Worktile[106 + ecx] = pixelval[i];
worktile[106 + ecx] = pixelval[i];
//pVal += (106 + ecx);
//*pVal = pixelval[i];
} }
if (((int)totalclock - lHeadStartClock) > 600) { if (((int)totalclock - lHeadStartClock) > 600) {
@ -3504,7 +3496,7 @@ int DoSpiritHead()
ebx += word_964EA; ebx += word_964EA;
// TODO - fixme. How big is worktile? // TODO - fixme. How big is worktile?
uint8_t *pDest = (uint8_t*)&worktile[10441]; uint8_t *pDest = &Worktile[10441];
const uint8_t* pSrc = tilePtr(ebx); const uint8_t* pSrc = tilePtr(ebx);
for (int i = 0; i < 97; i++) for (int i = 0; i < 97; i++)
@ -3535,7 +3527,7 @@ int DoSpiritHead()
// uint8_t *pDest = (uint8_t*)worktile; // uint8_t *pDest = (uint8_t*)worktile;
// pDest += (212 * (97 - nTileSizeX / 2)) + (159 - nTileSizeY); // pDest += (212 * (97 - nTileSizeX / 2)) + (159 - nTileSizeY);
uint8_t *pDest = (uint8_t*)&worktile[212 * (97 - nTileSizeX / 2)] + (159 - nTileSizeY); uint8_t *pDest = &Worktile[212 * (97 - nTileSizeX / 2)] + (159 - nTileSizeY);
const uint8_t *pSrc = tilePtr(nMouthTile + 598); const uint8_t *pSrc = tilePtr(nMouthTile + 598);
while (nTileSizeX > 0) while (nTileSizeX > 0)

View file

@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "keyboard.h" #include "keyboard.h"
#include "control.h" #include "control.h"
#include "config.h" #include "config.h"
#include "input.h"
#include <string.h> #include <string.h>
BEGIN_PS_NS BEGIN_PS_NS
@ -195,20 +196,7 @@ int WaitAnyKey(int nSecs)
if (nTotalTime <= (int)totalclock || nSecs == -1) { if (nTotalTime <= (int)totalclock || nSecs == -1) {
return -1; return -1;
} }
if (I_AdvanceTrigger()) return 1;
int i = 0;
do
{
if (KB_KeyDown[i])
{
KB_KeyDown[i] = 0;
return i;
}
i++;
} while (i < 106);
} }
} }

View file

@ -285,6 +285,10 @@ void drawoverheadmap(int cposx, int cposy, int czoom, short cang)
#endif #endif
} }
#ifdef _MSC_VER
#pragma warning(disable:4101) // this function produces a little bit too much noise
#endif
static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16_t cang) static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16_t cang)
{ {
int32_t i, j, k, l, x1, y1, x2=0, y2=0, x3, y3, x4, y4, ox, oy, xoff, yoff; int32_t i, j, k, l, x1, y1, x2=0, y2=0, x3, y3, x4, y4, ox, oy, xoff, yoff;
@ -305,7 +309,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
xvect2 = mulscale16(xvect, yxaspect); xvect2 = mulscale16(xvect, yxaspect);
yvect2 = mulscale16(yvect, yxaspect); yvect2 = mulscale16(yvect, yxaspect);
renderDisableFog(); //renderDisableFog();
// draw player position arrow // draw player position arrow
renderDrawLine(xdim << 11, (ydim << 11) - 20480, xdim << 11, (ydim << 11) + 20480, 24); renderDrawLine(xdim << 11, (ydim << 11) - 20480, xdim << 11, (ydim << 11) + 20480, 24);

View file

@ -59,7 +59,7 @@ GameStat GameStats;
short nCinemaSeen[30]; short nCinemaSeen[30];
// this might be static within the DoPlasma function? // this might be static within the DoPlasma function?
uint8_t plasmaBuffer[25600]; uint8_t * PlasmaBuffer;
uint8_t energytile[66 * 66] = {0}; uint8_t energytile[66 * 66] = {0};
@ -145,13 +145,12 @@ void InitEnergyTile()
void DoEnergyTile() void DoEnergyTile()
{ {
tileLoad(kEnergy1);
tileLoad(kEnergy2);
nButtonColor += nButtonColor < 0 ? 8 : 0; nButtonColor += nButtonColor < 0 ? 8 : 0;
uint8_t *ptr1 = (uint8_t*)(waloff[kEnergy1] + 1984); auto energy1 = TileFiles.tileMakeWritable(kEnergy1);
uint8_t *ptr2 = (uint8_t*)(waloff[kEnergy1] + 2048); auto energy2 = TileFiles.tileMakeWritable(kEnergy2);
uint8_t *ptr1 = energy1 + 1984;
uint8_t *ptr2 = energy2 + 2048;
short nColor = nButtonColor + 161; short nColor = nButtonColor + 161;
@ -177,7 +176,7 @@ void DoEnergyTile()
if (nSmokeSparks) if (nSmokeSparks)
{ {
uint8_t *c = &energytile[67]; // skip a line uint8_t *c = &energytile[67]; // skip a line
uint8_t *ptrW = (uint8_t*)waloff[kEnergy2]; uint8_t *ptrW = energy2;
for (i = 0; i < 64; i++) for (i = 0; i < 64; i++)
{ {
@ -266,7 +265,7 @@ void DoEnergyTile()
} }
c = &energytile[67]; c = &energytile[67];
ptrW = (uint8_t*)waloff[kEnergy2]; ptrW = energy2;
for (i = 0; i < 64; i++) for (i = 0; i < 64; i++)
{ {
@ -275,7 +274,7 @@ void DoEnergyTile()
ptrW += 64; ptrW += 64;
} }
ptrW = (uint8_t*)waloff[kEnergy2]; ptrW = energy2;
for (i = 0; i < 4096; i++) for (i = 0; i < 4096; i++)
{ {
@ -314,21 +313,18 @@ void menu_DoPlasma()
{ {
if (!nLogoTile) if (!nLogoTile)
nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo; nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo;
if (waloff[kTile4092] == 0)
if (!PlasmaBuffer)
{ {
tileCreate(kTile4092, kPlasmaWidth, kPlasmaHeight); auto pixels = TileFiles.tileCreate(kTile4092, kPlasmaWidth, kPlasmaHeight);
memset(pixels, 96, kPlasmaWidth*kPlasmaHeight);
memset((void*)waloff[kTile4092], 96, kPlasmaWidth*kPlasmaHeight); PlasmaBuffer = TileFiles.tileCreate(kTile4093, kPlasmaWidth, kPlasmaHeight);
memset(PlasmaBuffer, 96, kPlasmaWidth * kPlasmaHeight);
waloff[kTile4093] = (intptr_t)plasmaBuffer;
memset(plasmaBuffer, 96, sizeof(plasmaBuffer));
nSmokeLeft = 160 - tilesiz[nLogoTile].x / 2; nSmokeLeft = 160 - tilesiz[nLogoTile].x / 2;
nSmokeRight = nSmokeLeft + tilesiz[nLogoTile].x; nSmokeRight = nSmokeLeft + tilesiz[nLogoTile].x;
tilesiz[kTile4093].x = kPlasmaWidth;
tilesiz[kTile4093].y = kPlasmaHeight;
nSmokeTop = 40 - tilesiz[nLogoTile].y / 2; nSmokeTop = 40 - tilesiz[nLogoTile].y / 2;
nSmokeBottom = nSmokeTop + tilesiz[nLogoTile].y - 1; nSmokeBottom = nSmokeTop + tilesiz[nLogoTile].y - 1;
@ -339,33 +335,8 @@ void menu_DoPlasma()
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
int logoWidth = tilesiz[nLogoTile].x; int logoWidth = tilesiz[nLogoTile].x;
#if 1
plasma_C[i] = (nSmokeLeft + rand() % logoWidth) << 16; plasma_C[i] = (nSmokeLeft + rand() % logoWidth) << 16;
plasma_B[i] = (menu_RandomLong2() % 327680) + 0x10000; plasma_B[i] = (menu_RandomLong2() % 327680) + 0x10000;
#else
int r = rand();
int rand2 = menu_RandomLong2();
__asm {
mov ebx, i
mov ecx, logoWidth
mov eax, r
mov edx, eax
sar edx, 31
idiv ecx
add edx, nSmokeLeft
shl edx, 16
mov ecx, 327680
mov plasma_C[ebx * 4], edx
xor edx, edx
mov eax, rand2
// call menu_RandomLong2
div ecx
add edx, 10000h
mov plasma_B[ebx * 4], edx
};
#endif
if (menu_RandomBit2()) { if (menu_RandomBit2()) {
plasma_B[i] = -plasma_B[i]; plasma_B[i] = -plasma_B[i];
@ -377,8 +348,10 @@ void menu_DoPlasma()
videoClearScreen(overscanindex); videoClearScreen(overscanindex);
uint8_t *r_ebx = (uint8_t*)waloff[nPlasmaTile] + 81;
uint8_t *r_edx = (uint8_t*)waloff[nPlasmaTile ^ 1] + 81; // flip between value of 4092 and 4093 with xor uint8_t* plasmapix = const_cast<uint8_t*>(tilePtr(nPlasmaTile));
uint8_t *r_ebx = plasmapix + 81;
const uint8_t *r_edx = tilePtr(nPlasmaTile ^ 1) + 81; // flip between value of 4092 and 4093 with xor
for (int x = 0; x < kPlasmaWidth - 2; x++) for (int x = 0; x < kPlasmaWidth - 2; x++)
// for (int x = 1; x < 318; x++) // for (int x = 1; x < 318; x++)
@ -468,7 +441,7 @@ void menu_DoPlasma()
r_ebx += 2; r_ebx += 2;
} }
tileLoad(nLogoTile); auto logopix = tilePtr(nLogoTile);
for (int j = 0; j < 5; j++) for (int j = 0; j < 5; j++)
{ {
@ -476,7 +449,7 @@ void menu_DoPlasma()
int pC = plasma_C[j]; int pC = plasma_C[j];
int badOffset = (pC>>16) < nSmokeLeft || (pC>>16) >= nSmokeRight; int badOffset = (pC>>16) < nSmokeLeft || (pC>>16) >= nSmokeRight;
uint8_t *ptr3 = (uint8_t*)(waloff[nLogoTile] + ((pC >> 16) - nSmokeLeft) * tilesiz[nLogoTile].y); const uint8_t *ptr3 = (logopix + ((pC >> 16) - nSmokeLeft) * tilesiz[nLogoTile].y);
plasma_C[j] += plasma_B[j]; plasma_C[j] += plasma_B[j];
@ -525,7 +498,7 @@ void menu_DoPlasma()
} }
} }
uint8_t *v28 = (uint8_t*)(80 * (plasma_C[j] >> 16) + waloff[nPlasmaTile]); uint8_t *v28 = plasmapix + (80 * (plasma_C[j] >> 16));
v28[nSmokeOffset] = 175; v28[nSmokeOffset] = 175;
} }

View file

@ -826,16 +826,16 @@ void DrawStatus()
int x = (nViewLeft + nViewRight) / 2; int x = (nViewLeft + nViewRight) / 2;
sprintf(coordBuf, "X %d", (int)sprite[nSprite].x); snprintf(coordBuf, 50, "X %d", (int)sprite[nSprite].x.cast());
printext(x, nViewTop + 1, coordBuf, kTile159, 255); printext(x, nViewTop + 1, coordBuf, kTile159, 255);
sprintf(coordBuf, "Y %d", sprite[nSprite].y); snprintf(coordBuf, 50, "Y %d", sprite[nSprite].y.cast());
printext(x, nViewTop + 10, coordBuf, kTile159, 255); printext(x, nViewTop + 10, coordBuf, kTile159, 255);
} }
if (bHolly) if (bHolly)
{ {
sprintf(message_text, "HOLLY: %s", sHollyStr); snprintf(message_text, 80, "HOLLY: %s", sHollyStr);
printext(0, 0, message_text, kTile159, 255); printext(0, 0, message_text, kTile159, 255);
} }
else if (nSnakeCam < 0) else if (nSnakeCam < 0)