- implement GetCarPalIndex

- implement ProcessPalletLump
- fixed clut rectangle in LoadPermanentTPages
- human-understandable LoadPermanentTPages two dimensional arrays access
This commit is contained in:
Ilya Shurumov 2020-04-07 16:56:13 +06:00
parent 132b84188e
commit 941160d6fc
9 changed files with 1560 additions and 1516 deletions

View File

@ -1,6 +1,6 @@
#include "THISDUST.H"
#include "CARS.H"
#include "TEXTURE.H"
SVECTOR day_vectors[4] =
{
@ -75,8 +75,9 @@ int PolySizes[56] = {
// End Line: 1671
void plotNewCarModel(CAR_MODEL *car, int palette)
{
UNIMPLEMENTED();
/*
undefined4 in_zero;
undefined4 in_at;
int iVar1;
@ -127,7 +128,7 @@ void plotNewCarModel(CAR_MODEL *car,int palette)
*(uchar **)&current->primptr = local_48.primptr;
restoreLightingMatrices();
}
return;
return;*/
}
@ -168,8 +169,9 @@ void plotNewCarModel(CAR_MODEL *car,int palette)
// End Line: 6231
void plotCarPolyB3(int numTris, CAR_POLY *src, SVECTOR *vlist, plotCarGlobals *pg)
{
UNIMPLEMENTED();
/*
int iVar1;
undefined4 in_zero;
undefined4 in_at;
@ -218,7 +220,7 @@ void plotCarPolyB3(int numTris,CAR_POLY *src,SVECTOR *vlist,plotCarGlobals *pg)
} while (0 < numTris);
}
*(uint **)&pg->primptr = puVar7;
return;
return;*/
}
@ -271,8 +273,9 @@ void plotCarPolyB3(int numTris,CAR_POLY *src,SVECTOR *vlist,plotCarGlobals *pg)
// End Line: 6393
void plotCarPolyFT3(int numTris, CAR_POLY *src, SVECTOR *vlist, plotCarGlobals *pg)
{
UNIMPLEMENTED();
/*
undefined4 in_zero;
undefined4 in_at;
uint uVar1;
@ -334,7 +337,7 @@ void plotCarPolyFT3(int numTris,CAR_POLY *src,SVECTOR *vlist,plotCarGlobals *pg)
} while (0 < numTris);
}
*(uint **)&pg->primptr = puVar9;
return;
return;*/
}
@ -392,10 +395,10 @@ void plotCarPolyFT3(int numTris,CAR_POLY *src,SVECTOR *vlist,plotCarGlobals *pg)
/* end block 2 */
// End Line: 2295
void plotCarPolyGT3(int numTris,CAR_POLY *src,SVECTOR *vlist,SVECTOR *nlist,plotCarGlobals *pg,
int palette)
void plotCarPolyGT3(int numTris, CAR_POLY *src, SVECTOR *vlist, SVECTOR *nlist, plotCarGlobals *pg, int palette)
{
UNIMPLEMENTED();
/*
int iVar1;
int iVar2;
undefined4 in_zero;
@ -465,7 +468,7 @@ void plotCarPolyGT3(int numTris,CAR_POLY *src,SVECTOR *vlist,SVECTOR *nlist,plot
numTris = numTris + -1;
}
*(uint **)&pg->primptr = puVar10;
return;
return;*/
}
@ -519,8 +522,9 @@ void plotCarPolyGT3(int numTris,CAR_POLY *src,SVECTOR *vlist,SVECTOR *nlist,plot
// End Line: 7230
void plotCarPolyGT3nolight(int numTris, CAR_POLY *src, SVECTOR *vlist, plotCarGlobals *pg, int palette)
{
UNIMPLEMENTED();
/*
ushort uVar1;
int iVar2;
uint uVar3;
@ -574,7 +578,7 @@ void plotCarPolyGT3nolight(int numTris,CAR_POLY *src,SVECTOR *vlist,plotCarGloba
local_4 = (uint **)(plVar15 + ((int)local_4 >> 1));
uVar3 = getCopReg(2, 0xc);
puVar11[2] = uVar3;
uVar3 = getCopReg(2,0xd);
7 uVar3 = getCopReg(2, 0xd);
puVar11[4] = uVar3;
uVar3 = getCopReg(2, 0xe);
puVar11[6] = uVar3;
@ -592,7 +596,7 @@ void plotCarPolyGT3nolight(int numTris,CAR_POLY *src,SVECTOR *vlist,plotCarGloba
} while (0 < numTris);
}
*(uint **)&pg->primptr = puVar11;
return;
return;*/
}
@ -726,8 +730,9 @@ void plotCarPolyGT3nolight(int numTris,CAR_POLY *src,SVECTOR *vlist,plotCarGloba
// End Line: 3114
void DrawCar(_CAR_DATA *cp, int view)
{
UNIMPLEMENTED();
/*
byte bVar1;
uchar uVar2;
short sVar3;
@ -990,7 +995,7 @@ LAB_00021aac:
if (cp->ai[0x13] < 0x4b) {
AddCopCarLight(cp);
}
return;
return;*/
}
@ -1030,10 +1035,10 @@ LAB_00021aac:
/* end block 2 */
// End Line: 3587
void DrawCarObject(CAR_MODEL *car,MATRIX *matrix,VECTOR *pos,VECTOR *pos1,int palette,_CAR_DATA *cp,
int detail)
void DrawCarObject(CAR_MODEL *car, MATRIX *matrix, VECTOR *pos, VECTOR *pos1, int palette, _CAR_DATA *cp, int detail)
{
UNIMPLEMENTED();
/*
undefined4 uVar1;
undefined4 uVar2;
undefined4 uVar3;
@ -1065,6 +1070,7 @@ void DrawCarObject(CAR_MODEL *car,MATRIX *matrix,VECTOR *pos,VECTOR *pos1,int pa
plotNewCarModel(car, palette);
SetSp(savedSP_21);
return;
*/
}
@ -1155,8 +1161,9 @@ void DrawCarObject(CAR_MODEL *car,MATRIX *matrix,VECTOR *pos,VECTOR *pos1,int pa
// End Line: 4193
void DrawCarWheels(_CAR_DATA *cp, MATRIX *RearMatrix, VECTOR *pos, int zclip)
{
UNIMPLEMENTED();
/*
short sVar1;
short sVar2;
undefined4 in_zero;
@ -1367,7 +1374,7 @@ void DrawCarWheels(_CAR_DATA *cp,MATRIX *RearMatrix,VECTOR *pos,int zclip)
DrawWheelObject(model, verts, (uint)(byte)TransparentObject, wheelnum);
wheelnum = uVar13;
} while ((int)uVar13 < 4);
return;
return;*/
}
@ -1422,8 +1429,9 @@ void DrawCarWheels(_CAR_DATA *cp,MATRIX *RearMatrix,VECTOR *pos,int zclip)
// End Line: 5089
void DrawWheelObject(MODEL *model, SVECTOR *verts, int transparent, int wheelnum)
{
UNIMPLEMENTED();
/*
undefined2 uVar1;
ushort uVar2;
int iVar3;
@ -1519,7 +1527,7 @@ void DrawWheelObject(MODEL *model,SVECTOR *verts,int transparent,int wheelnum)
iVar13 = iVar13 + 0x14;
}
*(uint **)&current->primptr = puVar12;
return;
return;*/
}
@ -1553,8 +1561,9 @@ void DrawWheelObject(MODEL *model,SVECTOR *verts,int transparent,int wheelnum)
// End Line: 6921
void PlayerCarFX(_CAR_DATA *cp)
{
UNIMPLEMENTED();
/*
int iVar1;
iVar1 = (cp->hd).wheel_speed;
@ -1585,7 +1594,7 @@ LAB_00023598:
AddIndicatorLight(cp, 1);
}
}
return;
return;*/
}
@ -1650,8 +1659,9 @@ LAB_00023598:
/* WARNING: Could not reconcile some variable overlaps */
void ComputeCarLightingLevels(_CAR_DATA *cp, char detail)
{
UNIMPLEMENTED();
/*
byte bVar1;
bool bVar2;
undefined4 in_zero;
@ -1781,7 +1791,7 @@ void ComputeCarLightingLevels(_CAR_DATA *cp,char detail)
}
restoreLightingMatrices();
}
return;
return;*/
}
@ -1808,8 +1818,9 @@ void ComputeCarLightingLevels(_CAR_DATA *cp,char detail)
/* WARNING: Unknown calling convention yet parameter storage is locked */
void buildNewCars(void)
{
UNIMPLEMENTED();
/*
buildNewCarFromModel(&NewCarModel, gCarCleanModelPtr5[0], 1);
buildNewCarFromModel(&NewLowCarModel, gCarLowModelPtr5[0], 0);
buildNewCarFromModel(&CAR_MODEL_000acb88, gCarCleanModelPtr5[1], 0);
@ -1822,6 +1833,7 @@ void buildNewCars(void)
buildNewCarFromModel(&CAR_MODEL_000acbe8, gCarCleanModelPtr5[4], 0);
buildNewCarFromModel(&CAR_MODEL_000b8840, gCarLowModelPtr5[4], 0);
return;
*/
}
@ -1956,8 +1968,9 @@ void buildNewCars(void)
// End Line: 5849
void buildNewCarFromModel(CAR_MODEL *car, MODEL *model, int first)
{
UNIMPLEMENTED();
/*
byte bVar1;
byte bVar2;
byte bVar3;
@ -2163,7 +2176,7 @@ LAB_00022fd8:
whichCP = iVar12;
} while (iVar16 < 3);
}
return;
return;*/
}
@ -2210,8 +2223,9 @@ LAB_00022fd8:
/* WARNING: Unknown calling convention yet parameter storage is locked */
void MangleWheelModels(void)
{
UNIMPLEMENTED();
/*
undefined2 uVar1;
char cVar2;
int iVar3;
@ -2285,10 +2299,12 @@ void MangleWheelModels(void)
puVar4 = puVar4 + 5;
} while (-1 < iVar6);
} while (iVar3 < 3);
// HACK: Show clean model only in Rio.
if (GameLevel == 3) {
gFastWheelModelPtr = gCleanWheelModelPtr;
}
return;
return;*/
}
@ -2315,8 +2331,9 @@ void MangleWheelModels(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */
void setupLightingMatrices(void)
{
UNIMPLEMENTED();
/*
save_colour_matrix.m[0]._0_4_ = getCopControlWord(2, 0x8000);
save_colour_matrix.m._4_4_ = getCopControlWord(2, 0x8800);
save_colour_matrix.m[1]._2_4_ = getCopControlWord(2, 0x9000);
@ -2352,7 +2369,7 @@ void setupLightingMatrices(void)
setCopControlWord(2, 0x6800, 0x8c0);
setCopControlWord(2, 0x7000, 0x8c0);
setCopControlWord(2, 0x7800, 0x8c0);
return;
return;*/
}
@ -2374,8 +2391,9 @@ void setupLightingMatrices(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */
void restoreLightingMatrices(void)
{
UNIMPLEMENTED();
/*
setCopControlWord(2, 0x8000, save_colour_matrix.m[0]._0_4_);
setCopControlWord(2, 0x8800, save_colour_matrix.m._4_4_);
setCopControlWord(2, 0x9000, save_colour_matrix.m[1]._2_4_);
@ -2387,6 +2405,7 @@ void restoreLightingMatrices(void)
setCopControlWord(2, 0x5800, save_light_matrix.m[2]._0_4_);
setCopControlWord(2, 0x6000, save_light_matrix._16_4_);
return;
*/
}
@ -2419,21 +2438,24 @@ void restoreLightingMatrices(void)
/* end block 4 */
// End Line: 7077
// [D]
char GetCarPalIndex(int tpage)
{
byte *pbVar1;
char *pbVar1;
int iVar2;
iVar2 = 0;
pbVar1 = (byte *)(carTpages + GameLevel * 8);
pbVar1 = carTpages[GameLevel];
do {
if (tpage == (uint)*pbVar1) {
if (tpage == (uint)*pbVar1)
return (char)iVar2;
}
iVar2 = iVar2 + 1;
pbVar1 = pbVar1 + 1;
iVar2++;
pbVar1++;
} while (iVar2 < 8);
return '\0';
}

View File

@ -2,31 +2,31 @@
#define CARS_H
extern void plotNewCarModel(struct CAR_MODEL *car, int palette); // 0x00020C94
extern void plotNewCarModel(CAR_MODEL *car, int palette); // 0x00020C94
extern void plotCarPolyB3(int numTris, struct CAR_POLY *src, struct SVECTOR *vlist, struct plotCarGlobals *pg); // 0x000237B8
extern void plotCarPolyB3(int numTris, CAR_POLY *src, SVECTOR *vlist, plotCarGlobals *pg); // 0x000237B8
extern void plotCarPolyFT3(int numTris, struct CAR_POLY *src, struct SVECTOR *vlist, struct plotCarGlobals *pg); // 0x000238C4
extern void plotCarPolyFT3(int numTris, CAR_POLY *src, SVECTOR *vlist, plotCarGlobals *pg); // 0x000238C4
extern void plotCarPolyGT3(int numTris, struct CAR_POLY *src, struct SVECTOR *vlist, struct SVECTOR *nlist, struct plotCarGlobals *pg, int palette); // 0x00020EA0
extern void plotCarPolyGT3(int numTris, CAR_POLY *src, SVECTOR *vlist, SVECTOR *nlist, plotCarGlobals *pg, int palette); // 0x00020EA0
extern void plotCarPolyGT3nolight(int numTris, struct CAR_POLY *src, struct SVECTOR *vlist, struct plotCarGlobals *pg, int palette); // 0x00023A20
extern void plotCarPolyGT3nolight(int numTris, CAR_POLY *src, SVECTOR *vlist, plotCarGlobals *pg, int palette); // 0x00023A20
extern void DrawCar(struct _CAR_DATA *cp, int view); // 0x000210B8
extern void DrawCar(_CAR_DATA *cp, int view); // 0x000210B8
extern void DrawCarObject(struct CAR_MODEL *car, struct MATRIX *matrix, struct VECTOR *pos, struct VECTOR *pos1, int palette, struct _CAR_DATA *cp, int detail); // 0x000233DC
extern void DrawCarObject(CAR_MODEL *car, MATRIX *matrix, VECTOR *pos, VECTOR *pos1, int palette, _CAR_DATA *cp, int detail); // 0x000233DC
extern void DrawCarWheels(struct _CAR_DATA *cp, struct MATRIX *RearMatrix, struct VECTOR *pos, int zclip); // 0x00021AF8
extern void DrawCarWheels(_CAR_DATA *cp, MATRIX *RearMatrix, VECTOR *pos, int zclip); // 0x00021AF8
extern void DrawWheelObject(struct MODEL *model, struct SVECTOR *verts, int transparent, int wheelnum); // 0x00022180
extern void DrawWheelObject(MODEL *model, SVECTOR *verts, int transparent, int wheelnum); // 0x00022180
extern void PlayerCarFX(struct _CAR_DATA *cp); // 0x000234DC
extern void PlayerCarFX(_CAR_DATA *cp); // 0x000234DC
extern void ComputeCarLightingLevels(struct _CAR_DATA *cp, char detail); // 0x00022458
extern void ComputeCarLightingLevels(_CAR_DATA *cp, char detail); // 0x00022458
extern void buildNewCars(); // 0x00022860
extern void buildNewCarFromModel(struct CAR_MODEL *car, struct MODEL *model, int first); // 0x00022960
extern void buildNewCarFromModel(CAR_MODEL *car, MODEL *model, int first); // 0x00022960
extern void MangleWheelModels(); // 0x000230C8

View File

@ -1,6 +1,7 @@
#include "THISDUST.H"
#include "OVERMAP.H"
#include "TEXTURE.H"
#include "CARS.H"
OVERMAP overlaidmaps[4] =
{
@ -2076,44 +2077,56 @@ void WorldToMultiplayerMap(VECTOR *in, VECTOR *out)
/* end block 3 */
// End Line: 3941
unsigned short civ_clut[8][32][6];
// [D]
void ProcessPalletLump(char *lump_ptr, int lump_size)
{
UNIMPLEMENTED();
/*
char cVar1;
ushort uVar2;
undefined3 extraout_var;
int *piVar3;
int *piVar4;
int iVar5;
int iVar6;
u_short *puVar7;
u_short local_2a8[320];
int *local_s0_96;
int *local_s0_228;
int iVar3;
int iVar4;
u_short *puVar5;
unsigned short clutTable[320];
if ((*(int *)lump_ptr != 0) && (*(int *)(lump_ptr + 4) != -1)) {
piVar3 = (int *)(lump_ptr + 4);
puVar7 = local_2a8;
if ((*(int *)lump_ptr != 0) && (*(int *)(lump_ptr + 4) != -1))
{
local_s0_96 = (int *)(lump_ptr + 4);
puVar5 = (u_short *)clutTable;
do {
iVar6 = *piVar3;
iVar5 = piVar3[1];
cVar1 = GetCarPalIndex(piVar3[2]);
piVar4 = piVar3 + 4;
if (piVar3[3] == -1) {
LoadImage(&clutpos, piVar4);
piVar4 = piVar3 + 0xc;
iVar4 = *local_s0_96;
iVar3 = local_s0_96[1];
cVar1 = GetCarPalIndex(local_s0_96[2]);
local_s0_228 = local_s0_96 + 4;
if (local_s0_96[3] == -1) {
LoadImage(&clutpos, (u_long *)local_s0_228);
local_s0_228 = local_s0_96 + 12;
uVar2 = GetClut((int)clutpos.x, (int)clutpos.y);
*puVar7 = uVar2;
puVar7 = puVar7 + 1;
*puVar5 = uVar2;
puVar5 = puVar5 + 1;
IncrementClutNum(&clutpos);
}
else {
uVar2 = local_2a8[piVar3[3]];
uVar2 = clutTable[local_s0_96[3]];
}
civ_clut[CONCAT31(extraout_var, cVar1) * 0xc0 + iVar5 * 6 + iVar6 + 1] = uVar2;
piVar3 = piVar4;
} while (*piVar4 != -1);
civ_clut[cVar1][iVar3][iVar4 + 1] = uVar2;
local_s0_96 = local_s0_228;
} while (*local_s0_228 != -1);
}
return;*/
Emulator_SaveVRAM("VRAM_CLUTS.TGA", 0, 0, VRAM_WIDTH, VRAM_HEIGHT, TRUE);
}

View File

@ -648,10 +648,10 @@ extern char g_CurrentLevelFileName[64];
// [D]
void LoadPermanentTPages(int *sector)
{
char bVar1;
char bVar2;
int page1;
int page2;
bool bVar3;
_MISSION *p_Var4;
short sVar5;
short sVar6;
short sVar7;
@ -665,7 +665,7 @@ void LoadPermanentTPages(int *sector)
int iVar13;
short *psVar14;
u_short *puVar15;
uint tpageId;
int tpageId;
DVECTOR *pDVar16;
int nsectors_00;
int iVar17;
@ -689,14 +689,14 @@ void LoadPermanentTPages(int *sector)
do {
puVar15 = (u_short *)(texture_cluts[nsectors_00]);
nsectors_00 = 0x1f;
nsectors_00 = 31;
do {
uVar9 = GetClut(0x3c0, 0x10);
uVar9 = GetClut(960, 16);
*puVar15 = uVar9;
nsectors_00 = nsectors_00 + -1;
puVar15 = puVar15 + 1;
} while (-1 < nsectors_00);
bVar3 = iVar17 < 0x80;
bVar3 = iVar17 < 128;
nsectors_00 = iVar17;
iVar17 = iVar17 + 1;
} while (bVar3);
@ -706,15 +706,17 @@ void LoadPermanentTPages(int *sector)
clutpos.x = 960;
clutpos.y = 256;
clutpos.w = 256;
clutpos.h = 16;
clutpos.w = 16;
clutpos.h = 1;
tpage.w = 0x40;
tpage.h = 0x100;
mapclutpos.x = 0x3c0;
mapclutpos.y = 0x100;
mapclutpos.w = 0x10;
tpage.w = 64;
tpage.h = 256;
mapclutpos.x = 960;
mapclutpos.y = 256;
mapclutpos.w = 16;
mapclutpos.h = 1;
tpage.x = tpagepos[0].x;
tpage.y = tpagepos[0].y;
nsectors_00 = 0;
@ -766,22 +768,22 @@ void LoadPermanentTPages(int *sector)
} while (nsectors < nperms);
}
iVar17 = slotsused;
addr = (int *)mallocptr;
nsectors_00 = GameLevel;
slot_clutpos[slotsused].vx = clutpos.x;
p_Var4 = MissionHeader;
slot_clutpos[iVar17].vy = clutpos.y;
nsectors = nsectors_00 * 0xc;
nsectors_00 = nsectors_00 * 8;
iVar13 = (p_Var4->residentModels[4] + -8) * 2;
slot_clutpos[slotsused].vy = clutpos.y;
iVar13 = (MissionHeader->residentModels[4] - 8) * 2; // int specmodel
specialSlot = (short)slotsused;
bVar1 = ((char*)specTpages)[iVar13 + nsectors];
((char*)carTpages)[nsectors_00 + 6] = bVar1;
page1 = specTpages[GameLevel][iVar13];
page2 = specTpages[GameLevel][iVar13 + 1];
carTpages[GameLevel][6] = page1;
carTpages[GameLevel][7] = page2;
iVar17 = nspecpages;
bVar2 = ((char*)specTpages)[iVar13 + nsectors + 1];
bVar3 = nspecpages != 0;
((char*)carTpages)[nsectors_00 + 7] = bVar2;
if (bVar3) {
iVar13 = 0;
@ -820,7 +822,7 @@ void LoadPermanentTPages(int *sector)
}
iVar13 = 0;
}
if ((tpageId == (uint)bVar1) || (tpageId == (uint)bVar2)) {
if ((tpageId == page1) || (tpageId == page2)) {
update_slotinfo(tpageId, slotsused, &tpage);
LoadTPageAndCluts(&tpage, &clutpos, tpageId, (char *)addr);
nsectors_00 = nsectors_00 + *addr;
@ -866,7 +868,7 @@ void LoadPermanentTPages(int *sector)
} while (nsectors_00 < 19);
}
//Emulator_SaveVRAM("VRAM.TGA", 0, 0, VRAM_WIDTH, VRAM_HEIGHT, TRUE);
Emulator_SaveVRAM("VRAM_CLUTS_TPAGES.TGA", 0, 0, VRAM_WIDTH, VRAM_HEIGHT, TRUE);
}

View File

@ -1,8 +1,11 @@
#ifndef TEXTURE_H
#define TEXTURE_H
extern char carTpages[4][8];
extern char* texturename_buffer;
extern char* palette_lump;
extern RECT16 clutpos;
extern RECT16 fontclutpos;
extern void IncrementClutNum(RECT16 *clut); // 0x00080DDC

View File

@ -183,6 +183,7 @@
<ClCompile Include="GAME\C\AI.C" />
<ClCompile Include="GAME\C\BOMBERMAN.C" />
<ClCompile Include="GAME\C\CAMERA.C" />
<ClCompile Include="GAME\C\CARS.C" />
<ClCompile Include="GAME\C\CIV_AI.C" />
<ClCompile Include="GAME\C\CONVERT.C" />
<ClCompile Include="GAME\C\COP_AI.C" />

View File

@ -222,6 +222,9 @@
<ClCompile Include="GAME\C\PAUSE.C">
<Filter>main\C</Filter>
</ClCompile>
<ClCompile Include="GAME\C\CARS.C">
<Filter>EMULATOR</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="EMULATOR\ABS.H">