- 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

File diff suppressed because it is too large Load Diff

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">