mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-23 02:42:38 +01:00
- fix PVSDecode, GetPVSRegionCell2
This commit is contained in:
parent
7911f31f7b
commit
5ae3b0b710
@ -1221,142 +1221,137 @@ void GetVisSetAtPosition(VECTOR *pos, char *tgt, int *ccx, int *ccz)
|
|||||||
/* end block 3 */
|
/* end block 3 */
|
||||||
// End Line: 1807
|
// End Line: 1807
|
||||||
|
|
||||||
char nybblearray[512] = { 0 };
|
unsigned char nybblearray[512] = { 0 };
|
||||||
|
|
||||||
char* PVS_Buffers[4] = { 0 };
|
char* PVS_Buffers[4] = { 0 };
|
||||||
int pvsSize[4] = { 0, 0, 0, 0 };
|
int pvsSize[4] = { 0, 0, 0, 0 };
|
||||||
unsigned char *PVSEncodeTable = NULL;
|
unsigned char *PVSEncodeTable = NULL;
|
||||||
|
|
||||||
// [A] - bugged
|
// [D] [T]
|
||||||
void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBodge)
|
void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBodge)
|
||||||
{
|
{
|
||||||
// don't draw non-loaded regions
|
unsigned char scratchPad[1024];
|
||||||
//for (int k = 0; k < pvs_square_sq; k++)
|
|
||||||
// output[k] = 1;
|
|
||||||
|
|
||||||
//UNIMPLEMENTED();
|
int pixelIndex;
|
||||||
//return;
|
unsigned char* decodebuf;
|
||||||
|
unsigned char* op;
|
||||||
char scratchPad[1024];
|
int i, j;
|
||||||
|
int symIndex;
|
||||||
unsigned char bVar1;
|
int size;
|
||||||
int local_v0_580;
|
|
||||||
int iVar2;
|
|
||||||
char *pcVar3;
|
|
||||||
unsigned char *pbVar4;
|
|
||||||
uint uVar5;
|
|
||||||
int iVar6;
|
|
||||||
int iVar7;
|
|
||||||
int iVar8;
|
|
||||||
int iVar9;
|
|
||||||
char *decodebuf;
|
|
||||||
|
|
||||||
checkpad = 0;
|
|
||||||
checkpad2 = 0;
|
|
||||||
|
|
||||||
decodebuf = scratchPad;
|
decodebuf = scratchPad;
|
||||||
ClearMem(decodebuf,pvs_square_sq);
|
ClearMem((char*)decodebuf,pvs_square_sq);
|
||||||
|
|
||||||
iVar2 = 0;
|
// decode byte-swapped array
|
||||||
|
i = 0;
|
||||||
// this is correct I HOPE
|
while (i < sz)
|
||||||
if (sz != 0)
|
|
||||||
{
|
{
|
||||||
pcVar3 = nybblearray;
|
((ushort*)nybblearray)[i] = SW_SHORT((unsigned char)celldata[i], (unsigned char)celldata[i] >> 4) & 0xf0f;
|
||||||
do
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixelIndex = 0;
|
||||||
|
symIndex = 0;
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
// decompress image
|
||||||
|
while (i < sz * 2)
|
||||||
|
{
|
||||||
|
int ni;
|
||||||
|
int sym;
|
||||||
|
|
||||||
|
ni = nybblearray[i];
|
||||||
|
i++;
|
||||||
|
|
||||||
|
if (ni < 12)
|
||||||
{
|
{
|
||||||
pbVar4 = (unsigned char *)(celldata + iVar2);
|
symIndex = ni * 2;
|
||||||
|
spod:
|
||||||
|
sym = SW_SHORT(PVSEncodeTable[symIndex], PVSEncodeTable[symIndex + 1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (i == sz*2)
|
||||||
|
break;
|
||||||
|
|
||||||
*(ushort *)pcVar3 = SW_SHORT(*pbVar4,*pbVar4 >> 4) & 0xf0f;
|
sym = (ni & 3) * 16 + nybblearray[i];
|
||||||
pcVar3 += 2;
|
i++;
|
||||||
|
|
||||||
iVar2++;
|
if (sym < 60)
|
||||||
} while (iVar2 < sz);
|
|
||||||
}
|
|
||||||
|
|
||||||
iVar9 = ((uint)sz & 0x7fff) << 1;
|
|
||||||
iVar2 = 0;
|
|
||||||
|
|
||||||
if ((sz & 0x7fff) != 0) {
|
|
||||||
pcVar3 = nybblearray;
|
|
||||||
iVar8 = 0;
|
|
||||||
do {
|
|
||||||
bVar1 = *pcVar3;
|
|
||||||
iVar7 = iVar8 + 1;
|
|
||||||
if (bVar1 < 0xc)
|
|
||||||
{
|
{
|
||||||
iVar8 = bVar1 * 2;
|
symIndex = sym * 2 + 24;
|
||||||
LAB_0005d0c8:
|
goto spod;
|
||||||
uVar5 = (ushort)SW_SHORT(PVSEncodeTable[iVar8], PVSEncodeTable[iVar8+1]);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (iVar7 == iVar9) break;
|
|
||||||
uVar5 = (bVar1 & 3) * 0x10 + nybblearray[iVar8 + 1];
|
|
||||||
iVar7 = iVar8 + 2;
|
|
||||||
|
|
||||||
if (uVar5 < 0x3c)
|
sym = ((sym & 3) * 16 + nybblearray[i]) * 16 + nybblearray[i+1];
|
||||||
{
|
i += 2;
|
||||||
iVar8 = uVar5 * 2 + 0x18;
|
}
|
||||||
goto LAB_0005d0c8;
|
|
||||||
}
|
|
||||||
|
|
||||||
iVar7 = iVar8 + 4;
|
pixelIndex += (sym >> 1);
|
||||||
uVar5 = ((uVar5 & 3) * 0x10 + nybblearray[iVar8 + 2]) * 0x10 + nybblearray[iVar8 + 3];
|
decodebuf[pixelIndex] = 1;
|
||||||
}
|
pixelIndex++;
|
||||||
iVar8 = iVar2 + (uVar5 >> 1);
|
|
||||||
decodebuf[iVar8] = 1;
|
if ((sym & 1) != 0)
|
||||||
iVar2 = iVar8 + 1;
|
{
|
||||||
if ((uVar5 & 1) != 0) {
|
decodebuf[pixelIndex] = 1;
|
||||||
decodebuf[iVar8 + 1] = 1;
|
pixelIndex++;
|
||||||
iVar2 = iVar8 + 2;
|
}
|
||||||
}
|
|
||||||
pcVar3 = nybblearray + iVar7;
|
|
||||||
iVar8 = iVar7;
|
|
||||||
} while (iVar7 < iVar9);
|
|
||||||
}
|
}
|
||||||
iVar2 = pvs_square;
|
|
||||||
|
|
||||||
if (havanaCorruptCellBodge == 0)
|
if (havanaCorruptCellBodge == 0)
|
||||||
decodebuf[pvs_square_sq-1] ^= 1;
|
decodebuf[pvs_square_sq-1] ^= 1;
|
||||||
|
|
||||||
iVar7 = iVar2-2;
|
size = pvs_square - 2;
|
||||||
iVar8 = iVar2-1;
|
|
||||||
pbVar4 = (unsigned char *)(iVar7 * iVar2 + iVar2 + decodebuf - 1);
|
|
||||||
iVar9 = iVar7;
|
|
||||||
|
|
||||||
while (-1 < iVar9)
|
op = (decodebuf - 1) + (size * pvs_square + pvs_square);
|
||||||
|
i = size;
|
||||||
|
while (i >= 0)
|
||||||
{
|
{
|
||||||
iVar9--;
|
i--;
|
||||||
iVar6 = iVar2;
|
j = pvs_square;
|
||||||
|
while (j > 0)
|
||||||
if (0 < iVar2)
|
|
||||||
{
|
{
|
||||||
do {
|
*op = *op ^ op[pvs_square];
|
||||||
*pbVar4 = *pbVar4 ^ pbVar4[iVar2];
|
j--;
|
||||||
pbVar4--;
|
op--;
|
||||||
iVar6--;
|
|
||||||
} while (iVar6 != 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pbVar4 = (unsigned char *)(iVar8 * iVar2 + iVar2 + decodebuf - 2);
|
|
||||||
|
|
||||||
while (-1 < iVar8)
|
size = pvs_square - 1;
|
||||||
|
op = (decodebuf - 2) + (size * pvs_square + pvs_square);
|
||||||
|
i = size;
|
||||||
|
|
||||||
|
while (i >= 0)
|
||||||
{
|
{
|
||||||
iVar8--;
|
j = pvs_square-2;
|
||||||
iVar2 = iVar7;
|
while (j >= 0)
|
||||||
|
|
||||||
while (-1 < iVar2)
|
|
||||||
{
|
{
|
||||||
*pbVar4 = *pbVar4 ^ pbVar4[1];
|
*op = *op ^ op[1];
|
||||||
pbVar4--;
|
j--;
|
||||||
|
op--;
|
||||||
iVar2--;
|
|
||||||
}
|
}
|
||||||
|
i--;
|
||||||
pbVar4--;
|
op--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
printf("=========================\n");
|
||||||
|
for (i = 0; i < pvs_square; i++)
|
||||||
|
{
|
||||||
|
char line[64];
|
||||||
|
memcpy(line, (char*)decodebuf + i * pvs_square, pvs_square);
|
||||||
|
for (j = 0; j < pvs_square; j++)
|
||||||
|
{
|
||||||
|
if (line[j] == 0)
|
||||||
|
line[j] = '.';
|
||||||
|
else
|
||||||
|
line[j] = 'O';
|
||||||
|
}
|
||||||
|
line[j] = 0;
|
||||||
|
printf("%s\n", line);
|
||||||
|
}
|
||||||
|
printf("=========================\n");
|
||||||
|
#endif
|
||||||
memcpy(output, decodebuf, pvs_square_sq-1); // 110*4
|
memcpy(output, decodebuf, pvs_square_sq-1); // 110*4
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1447,9 +1442,7 @@ void GetPVSRegionCell2(int source_region, int region, int cell, char *output)
|
|||||||
PVSEncodeTable = (unsigned char *)(bp + 0x802);
|
PVSEncodeTable = (unsigned char *)(bp + 0x802);
|
||||||
tbp = bp + cell * 2;
|
tbp = bp + cell * 2;
|
||||||
|
|
||||||
|
length = SW_SHORT((unsigned char)tbp[2], (unsigned char)tbp[3]) - SW_SHORT((unsigned char)tbp[0], (unsigned char)tbp[1]) & 0xffff;
|
||||||
|
|
||||||
length = (ushort)SW_SHORT((unsigned char)tbp[2], (unsigned char)tbp[3]) - (ushort)SW_SHORT((unsigned char)tbp[0], (unsigned char)tbp[1]) & 0xffff;
|
|
||||||
|
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
{
|
{
|
||||||
@ -1462,9 +1455,7 @@ void GetPVSRegionCell2(int source_region, int region, int cell, char *output)
|
|||||||
if (regions_unpacked[source_region] == 158 && cell == 168)
|
if (regions_unpacked[source_region] == 158 && cell == 168)
|
||||||
havanaCorruptCellBodge = (GameLevel == 1);
|
havanaCorruptCellBodge = (GameLevel == 1);
|
||||||
|
|
||||||
printInfo("cell: %d, table: %x, pvs length: %d\n", cell, PVSEncodeTable, length);
|
PVSDecode(output, bp + SW_SHORT((unsigned char)tbp[0], (unsigned char)tbp[1]), length, havanaCorruptCellBodge);
|
||||||
|
|
||||||
PVSDecode(output, bp + (ushort)SW_SHORT(tbp[0], tbp[1]), length, havanaCorruptCellBodge);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user