Clean up signedness

This commit is contained in:
Anders Jenbo
2019-07-21 00:57:53 +02:00
parent e2bff090d6
commit 5ab9f4609a
33 changed files with 290 additions and 306 deletions
+191 -207
View File
@@ -2,13 +2,13 @@
#include "_asm.cpp"
int WorldBoolFlag = 0;
unsigned int gdwCurrentMask = 0;
DWORD gdwCurrentMask = 0;
// char world_4B3264 = 0;
unsigned char *gpCelFrame = NULL;
unsigned int *gpDrawMask = NULL;
BYTE *gpCelFrame = NULL;
DWORD *gpDrawMask = NULL;
// char world_4B326D[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
unsigned int RightMask[32] = {
DWORD RightMask[32] = {
0xEAAAAAAA, 0xF5555555,
0xFEAAAAAA, 0xFF555555,
0xFFEAAAAA, 0xFFF55555,
@@ -27,7 +27,7 @@ unsigned int RightMask[32] = {
0xFFFFFFFF, 0xFFFFFFFF
};
unsigned int LeftMask[32] = {
DWORD LeftMask[32] = {
0xAAAAAAAB, 0x5555555F,
0xAAAAAABF, 0x555555FF,
0xAAAAABFF, 0x55555FFF,
@@ -46,7 +46,7 @@ unsigned int LeftMask[32] = {
0xFFFFFFFF, 0xFFFFFFFF
};
unsigned int WallMask[32] = {
DWORD WallMask[32] = {
0xAAAAAAAA, 0x55555555,
0xAAAAAAAA, 0x55555555,
0xAAAAAAAA, 0x55555555,
@@ -116,35 +116,32 @@ int WorldTbl17_2[17] = { 0, 32, 60, 88, 112, 136, 156, 176, 192, 208, 220, 232,
#else
void drawTopArchesUpperScreen(BYTE *pBuff)
{
unsigned char *dst; // edi MAPDST
unsigned char *tbl; // ebx
unsigned char *src; // esi MAPDST
short cel_type_16; // ax MAPDST
signed int xx_32; // ebp MAPDST
signed int yy_32; // edx MAPDST
unsigned int width; // eax MAPDST
unsigned int chk_sh_and; // ecx MAPDST
unsigned int n_draw_shift; // ecx MAPDST
unsigned int x_minus; // ecx MAPDST
unsigned int y_minus; // ecx MAPDST
signed int i; // edx MAPDST
signed int j; // ecx MAPDST
BYTE *dst, *src;
BYTE *tbl;
short cel_type_16;
unsigned int width;
unsigned int chk_sh_and;
unsigned int n_draw_shift;
unsigned int x_minus;
unsigned int y_minus;
int xx_32, yy_32;
int i, j;
gpCelFrame = (unsigned char *)SpeedFrameTbl;
gpCelFrame = (BYTE *)SpeedFrameTbl;
dst = pBuff;
if (!(BYTE)light_table_index) {
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = ((level_cel_block >> 12) & 7) + 8;
goto LABEL_11;
}
if ((BYTE)light_table_index != lightmax) {
if (!(level_cel_block & 0x8000)) {
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
tbl = &pLightTbl[256 * light_table_index];
cel_type_16 = (unsigned char)(level_cel_block >> 12);
cel_type_16 = (BYTE)(level_cel_block >> 12);
switch (cel_type_16) {
case 0: // upper (top transparent), with lighting
i = 16;
@@ -161,13 +158,13 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
} while (i);
break;
case 1: // upper (top transparent), with lighting
WorldBoolFlag = (unsigned char)pBuff & 1;
WorldBoolFlag = (BYTE)pBuff & 1;
xx_32 = 32;
do {
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0)
break;
_LOBYTE(width) = -(char)width;
@@ -178,7 +175,7 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
}
if (dst < gpBufEnd)
return;
if (((unsigned char)dst & 1) == WorldBoolFlag) {
if (((BYTE)dst & 1) == WorldBoolFlag) {
asm_trans_light_cel_0_2(width, tbl, &dst, &src);
} else {
asm_trans_light_cel_1_3(width, tbl, &dst, &src);
@@ -235,7 +232,7 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
} else {
asm_trans_light_cel_1_3(32 - xx_32, tbl, &dst, &src);
}
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
if (xx_32 < 0) {
@@ -249,7 +246,7 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
} else {
asm_trans_light_cel_1_3(32 - yy_32, tbl, &dst, &src);
}
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[yy_32 - (SCREEN_WIDTH + 160)];
yy_32 += 2;
} while (yy_32 != 32);
@@ -298,7 +295,7 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
} else {
asm_trans_light_cel_1_3(32 - xx_32, tbl, &dst, &src);
}
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
if (xx_32 < 0) {
@@ -321,9 +318,9 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
}
return;
}
src = (unsigned char *)pSpeedCels
src = pSpeedCels
+ *(DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))];
cel_type_16 = (unsigned char)(level_cel_block >> 12);
cel_type_16 = (BYTE)(level_cel_block >> 12);
LABEL_11:
switch (cel_type_16) {
@@ -356,13 +353,13 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
} while (i);
break;
case 9: // upper (top transparent), without lighting
WorldBoolFlag = (unsigned char)pBuff & 1;
WorldBoolFlag = (BYTE)pBuff & 1;
yy_32 = 32;
LABEL_251:
xx_32 = 32;
while (1) {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0)
break;
_LOBYTE(width) = -(char)width;
@@ -380,7 +377,7 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
xx_32 -= width;
if (dst < gpBufEnd)
return;
if (((unsigned char)dst & 1) == WorldBoolFlag) {
if (((BYTE)dst & 1) == WorldBoolFlag) {
chk_sh_and = width >> 1;
if (!(width & 1))
goto LABEL_258;
@@ -741,8 +738,8 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
}
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = (level_cel_block >> 12) & 7;
switch (cel_type_16) {
case 0: // upper (top transparent), black
@@ -772,20 +769,20 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
} while (i);
break;
case 1: // upper (top transparent), black
WorldBoolFlag = (unsigned char)pBuff & 1;
WorldBoolFlag = (BYTE)pBuff & 1;
xx_32 = 32;
while (1) {
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) != 0)
break;
yy_32 -= width;
if (dst < gpBufEnd)
return;
src += width;
if (((unsigned char)dst & 1) == WorldBoolFlag) {
if (((BYTE)dst & 1) == WorldBoolFlag) {
chk_sh_and = width >> 1;
if (!(width & 1))
goto LABEL_378;
@@ -1140,28 +1137,26 @@ void drawTopArchesUpperScreen(BYTE *pBuff)
}
}
void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
void drawBottomArchesUpperScreen(BYTE *pBuff, DWORD *pMask)
{
unsigned char *dst; // edi MAPDST
unsigned char *src; // esi MAPDST
short cel_type_16; // ax MAPDST
int xx_32; // edx MAPDST
unsigned int left_shift; // edx MAPDST
int yy_32; // edx MAPDST
int width; // eax MAPDST
int and80_i; // ecx MAPDST
unsigned int n_draw_shift; // ecx MAPDST
signed int i; // ecx MAPDST
unsigned char *tbl;
BYTE *dst, *src;
BYTE *tbl;
short cel_type_16;
unsigned int left_shift;
unsigned int n_draw_shift;
int width;
int and80_i;
int i;
int xx_32, yy_32;
gpCelFrame = (unsigned char *)SpeedFrameTbl;
gpCelFrame = (BYTE *)SpeedFrameTbl;
dst = pBuff;
gpDrawMask = pMask;
if (!(BYTE)light_table_index) {
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = ((level_cel_block >> 12) & 7) + 8;
LABEL_12:
switch (cel_type_16) {
@@ -1192,7 +1187,7 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0)
break;
_LOBYTE(width) = -(char)width;
@@ -1383,7 +1378,7 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
++dst;
--i;
} while (i);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst -= (SCREEN_WIDTH + 160);
--gpDrawMask;
--yy_32;
@@ -1397,9 +1392,9 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
}
if ((BYTE)light_table_index != lightmax) {
if (!(level_cel_block & 0x8000)) {
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
tbl = &pLightTbl[256 * light_table_index];
cel_type_16 = (unsigned char)(level_cel_block >> 12);
cel_type_16 = (BYTE)(level_cel_block >> 12);
switch (cel_type_16) {
case 0: // upper (bottom transparent), with lighting
xx_32 = 32;
@@ -1419,7 +1414,7 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0)
break;
_LOBYTE(width) = -(char)width;
@@ -1468,7 +1463,7 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
xx_32 = 30;
while (dst >= gpBufEnd) {
asm_cel_light_edge(32 - xx_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
if (xx_32 < 0) {
@@ -1477,7 +1472,7 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
if (dst < gpBufEnd)
break;
asm_cel_light_edge(32 - yy_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[yy_32 - (SCREEN_WIDTH + 160)];
yy_32 += 2;
} while (yy_32 != 32);
@@ -1499,7 +1494,7 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
do {
if (dst < gpBufEnd)
break;
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
asm_trans_light_mask(32, tbl, &dst, &src, *gpDrawMask);
dst -= (SCREEN_WIDTH + 160);
--gpDrawMask;
@@ -1513,7 +1508,7 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
xx_32 = 30;
while (dst >= gpBufEnd) {
asm_cel_light_edge(32 - xx_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
if (xx_32 < 0) {
@@ -1523,7 +1518,7 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
if (dst < gpBufEnd)
break;
asm_trans_light_mask(32, tbl, &dst, &src, *gpDrawMask);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst -= (SCREEN_WIDTH + 160);
--gpDrawMask;
--yy_32;
@@ -1535,15 +1530,15 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
}
return;
}
src = (unsigned char *)pSpeedCels
src = pSpeedCels
+ *(DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))];
cel_type_16 = (unsigned char)(level_cel_block >> 12);
cel_type_16 = (BYTE)(level_cel_block >> 12);
goto LABEL_12;
}
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = (level_cel_block >> 12) & 7;
switch (cel_type_16) {
case 0: // upper (bottom transparent), black
@@ -1572,7 +1567,7 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0)
break;
_LOBYTE(width) = -(char)width;
@@ -1776,17 +1771,14 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, unsigned int *pMask)
void drawUpperScreen(BYTE *pBuff)
{
unsigned char *dst; // edi MAPDST
unsigned char *tbl; // ebx
unsigned char *src; // esi MAPDST
short cel_type_16; // ax MAPDST
signed int xx_32; // ebp MAPDST
signed int yy_32; // edx MAPDST
unsigned int width; // eax MAPDST
unsigned int chk_sh_and; // ecx MAPDST
unsigned int n_draw_shift; // ecx MAPDST
signed int i; // edx MAPDST
signed int j; // ecx MAPDST
BYTE *dst, *src;
BYTE *tbl;
short cel_type_16;
unsigned int width;
unsigned int chk_sh_and;
unsigned int n_draw_shift;
int i, j;
int xx_32, yy_32;
if (cel_transparency_active) {
if (!arch_draw_type) {
@@ -1806,13 +1798,13 @@ void drawUpperScreen(BYTE *pBuff)
}
}
}
gpCelFrame = (unsigned char *)SpeedFrameTbl;
gpCelFrame = (BYTE *)SpeedFrameTbl;
dst = pBuff;
if (!(BYTE)light_table_index) {
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = ((level_cel_block >> 12) & 7) + 8;
LABEL_22:
switch (cel_type_16) {
@@ -2038,9 +2030,9 @@ void drawUpperScreen(BYTE *pBuff)
}
if ((BYTE)light_table_index != lightmax) {
if (!(level_cel_block & 0x8000)) {
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
tbl = &pLightTbl[256 * light_table_index];
cel_type_16 = (unsigned short)level_cel_block >> 12;
cel_type_16 = (WORD)level_cel_block >> 12;
switch (cel_type_16) {
case 0: // upper (solid), with lighting
xx_32 = 32;
@@ -2104,7 +2096,7 @@ void drawUpperScreen(BYTE *pBuff)
xx_32 = 30;
while (dst >= gpBufEnd) {
asm_cel_light_edge(32 - xx_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
if (xx_32 < 0) {
@@ -2113,7 +2105,7 @@ void drawUpperScreen(BYTE *pBuff)
if (dst < gpBufEnd)
break;
asm_cel_light_edge(32 - yy_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[yy_32 - (SCREEN_WIDTH + 160)];
yy_32 += 2;
} while (yy_32 != 32);
@@ -2146,7 +2138,7 @@ void drawUpperScreen(BYTE *pBuff)
xx_32 = 30;
while (dst >= gpBufEnd) {
asm_cel_light_edge(32 - xx_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
if (xx_32 < 0) {
@@ -2165,15 +2157,15 @@ void drawUpperScreen(BYTE *pBuff)
}
return;
}
src = (unsigned char *)pSpeedCels
src = pSpeedCels
+ *(DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))];
cel_type_16 = (unsigned short)level_cel_block >> 12;
cel_type_16 = (WORD)level_cel_block >> 12;
goto LABEL_22;
}
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = ((unsigned int)level_cel_block >> 12) & 7;
switch (cel_type_16) {
case 0: // upper (solid), black
@@ -2396,37 +2388,34 @@ void drawUpperScreen(BYTE *pBuff)
void drawTopArchesLowerScreen(BYTE *pBuff)
{
unsigned char *dst; // edi MAPDST
unsigned char *tbl; // ebx
unsigned char *src; // esi MAPDST
short cel_type_16; // ax MAPDST
signed int tile_42_45; // eax MAPDST
unsigned int world_tbl; // ecx MAPDST
unsigned int width; // eax MAPDST
unsigned int chk_sh_and; // ecx MAPDST
int xx_32; // edx MAPDST
unsigned int x_minus; // ecx MAPDST
unsigned int n_draw_shift; // ecx MAPDST
int yy_32; // edx MAPDST
unsigned int y_minus; // ecx MAPDST
signed int i; // edx MAPDST
signed int j; // ecx MAPDST
BYTE *dst, *src;
BYTE *tbl;
short cel_type_16;
unsigned int world_tbl;
unsigned int width;
unsigned int chk_sh_and;
unsigned int x_minus;
unsigned int n_draw_shift;
unsigned int y_minus;
int tile_42_45;
int xx_32, yy_32;
int i, j;
gpCelFrame = (unsigned char *)SpeedFrameTbl;
gpCelFrame = (BYTE *)SpeedFrameTbl;
dst = pBuff;
if (!(BYTE)light_table_index) {
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = ((level_cel_block >> 12) & 7) + 8;
goto LABEL_11;
}
if ((BYTE)light_table_index == lightmax) {
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = (level_cel_block >> 12) & 7;
switch (cel_type_16) {
case 0: // lower (top transparent), black
@@ -2462,13 +2451,13 @@ void drawTopArchesLowerScreen(BYTE *pBuff)
} while (i);
break;
case 1: // lower (top transparent), black
WorldBoolFlag = (unsigned char)pBuff & 1;
WorldBoolFlag = (BYTE)pBuff & 1;
xx_32 = 32;
LABEL_412:
yy_32 = 32;
while (1) {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0)
break;
_LOBYTE(width) = -(char)width;
@@ -2486,7 +2475,7 @@ void drawTopArchesLowerScreen(BYTE *pBuff)
yy_32 -= width;
if (dst < gpBufEnd) {
src += width;
if (((unsigned char)dst & 1) == WorldBoolFlag) {
if (((BYTE)dst & 1) == WorldBoolFlag) {
chk_sh_and = width >> 1;
if (!(width & 1))
goto LABEL_420;
@@ -2867,9 +2856,9 @@ void drawTopArchesLowerScreen(BYTE *pBuff)
return;
}
if (!(level_cel_block & 0x8000)) {
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
tbl = &pLightTbl[256 * light_table_index];
cel_type_16 = (unsigned char)(level_cel_block >> 12);
cel_type_16 = (BYTE)(level_cel_block >> 12);
switch (cel_type_16) {
case 0: // lower (top transparent), with lighting
i = 16;
@@ -2892,13 +2881,13 @@ void drawTopArchesLowerScreen(BYTE *pBuff)
} while (i);
break;
case 1: // lower (top transparent), with lighting
WorldBoolFlag = (unsigned char)pBuff & 1;
WorldBoolFlag = (BYTE)pBuff & 1;
xx_32 = 32;
do {
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0)
break;
_LOBYTE(width) = -(char)width;
@@ -2909,7 +2898,7 @@ void drawTopArchesLowerScreen(BYTE *pBuff)
}
yy_32 -= width;
if (dst < gpBufEnd) {
if (((unsigned char)dst & 1) == WorldBoolFlag) {
if (((BYTE)dst & 1) == WorldBoolFlag) {
asm_trans_light_cel_0_2(width, tbl, &dst, &src);
} else {
asm_trans_light_cel_1_3(width, tbl, &dst, &src);
@@ -3008,7 +2997,7 @@ void drawTopArchesLowerScreen(BYTE *pBuff)
} else {
asm_trans_light_cel_1_3(32 - yy_32, tbl, &dst, &src);
}
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[yy_32 - (SCREEN_WIDTH + 160)];
yy_32 += 2;
} while (yy_32 != 32);
@@ -3028,7 +3017,7 @@ void drawTopArchesLowerScreen(BYTE *pBuff)
} else {
asm_trans_light_cel_1_3(32 - xx_32, tbl, &dst, &src);
}
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
} while (xx_32 >= 0);
@@ -3125,7 +3114,7 @@ void drawTopArchesLowerScreen(BYTE *pBuff)
} else {
asm_trans_light_cel_1_3(32 - xx_32, tbl, &dst, &src);
}
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
} while (xx_32 >= 0);
@@ -3133,8 +3122,8 @@ void drawTopArchesLowerScreen(BYTE *pBuff)
}
return;
}
src = (unsigned char *)pSpeedCels + *(DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))];
cel_type_16 = (unsigned char)(level_cel_block >> 12);
src = pSpeedCels + *(DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))];
cel_type_16 = (BYTE)(level_cel_block >> 12);
LABEL_11:
switch (cel_type_16) {
case 8: // lower (top transparent), without lighting
@@ -3172,18 +3161,18 @@ LABEL_11:
} while (i);
break;
case 9: // lower (top transparent), without lighting
WorldBoolFlag = (unsigned char)pBuff & 1;
WorldBoolFlag = (BYTE)pBuff & 1;
xx_32 = 32;
while (1) {
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) != 0)
break;
yy_32 -= width;
if (dst < gpBufEnd) {
if (((unsigned char)dst & 1) == WorldBoolFlag) {
if (((BYTE)dst & 1) == WorldBoolFlag) {
chk_sh_and = width >> 1;
if (!(width & 1))
goto LABEL_280;
@@ -3633,31 +3622,29 @@ LABEL_11:
}
}
void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
void drawBottomArchesLowerScreen(BYTE *pBuff, DWORD *pMask)
{
unsigned char *dst; // edi MAPDST
short cel_type_16; // ax MAPDST
unsigned char *src; // esi MAPDST
int and80_i; // ecx MAPDST
signed int tile_42_45; // eax MAPDST
unsigned int world_tbl; // ecx MAPDST
int xx_32; // ecx MAPDST
int yy_32; // edx MAPDST
int width; // eax MAPDST
unsigned int left_shift; // edx MAPDST
signed int i; // edx MAPDST
unsigned int n_draw_shift; // ecx MAPDST
unsigned char *tbl;
BYTE *dst, *src;
BYTE *tbl;
short cel_type_16;
int and80_i;
unsigned int world_tbl;
unsigned int left_shift;
unsigned int n_draw_shift;
int tile_42_45;
int width;
int xx_32, yy_32;
int i;
gpCelFrame = (unsigned char *)SpeedFrameTbl;
gpCelFrame = (BYTE *)SpeedFrameTbl;
dst = pBuff;
gpDrawMask = pMask;
if ((BYTE)light_table_index) {
if ((BYTE)light_table_index == lightmax) {
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = (level_cel_block >> 12) & 7;
switch (cel_type_16) {
case 0: // lower (bottom transparent), black
@@ -3689,7 +3676,7 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) != 0)
break;
yy_32 -= width;
@@ -3915,9 +3902,9 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
return;
}
if (!(level_cel_block & 0x8000)) {
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
tbl = &pLightTbl[256 * light_table_index];
cel_type_16 = (unsigned char)(level_cel_block >> 12);
cel_type_16 = (BYTE)(level_cel_block >> 12);
switch (cel_type_16) {
case 0: // lower (bottom transparent), with lighting
yy_32 = 32;
@@ -3940,7 +3927,7 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) != 0)
break;
yy_32 -= width;
@@ -4026,7 +4013,7 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
do {
asm_cel_light_edge(32 - yy_32, tbl, &dst, &src);
/// BUGFIX: uncomment this line
// src += (unsigned char)src & 2;
// src += (BYTE)src & 2;
dst = &dst[yy_32 - (SCREEN_WIDTH + 160)];
yy_32 += 2;
} while (yy_32 != 32);
@@ -4039,7 +4026,7 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
}
do {
asm_cel_light_edge(32 - xx_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
} while (xx_32 >= 0);
@@ -4093,7 +4080,7 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
do {
if (dst < gpBufEnd) {
asm_trans_light_mask(32, tbl, &dst, &src, *gpDrawMask);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
} else {
src += 32;
dst += 32;
@@ -4111,7 +4098,7 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
}
do {
asm_cel_light_edge(32 - xx_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
} while (xx_32 >= 0);
@@ -4119,14 +4106,14 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
}
return;
}
src = (unsigned char *)pSpeedCels
src = pSpeedCels
+ *(DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))];
cel_type_16 = (unsigned char)(level_cel_block >> 12);
cel_type_16 = (BYTE)(level_cel_block >> 12);
} else {
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = ((level_cel_block >> 12) & 7) + 8;
}
switch (cel_type_16) {
@@ -4160,7 +4147,7 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) != 0)
break;
yy_32 -= width;
@@ -4393,7 +4380,7 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
++dst;
--i;
} while (i);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
} else {
src += 32;
dst += 32;
@@ -4429,19 +4416,16 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, unsigned int *pMask)
void drawLowerScreen(BYTE *pBuff)
{
unsigned char *dst; // edi MAPDST
unsigned char *src; // esi MAPDST
unsigned char *tbl; // ebx
short cel_type_16; // ax MAPDST
int xx_32; // edx MAPDST
int yy_32; // ebp MAPDST
unsigned int chk_sh_and; // ecx MAPDST
signed int tile_42_45; // eax MAPDST
unsigned int world_tbl; // ecx MAPDST
unsigned int n_draw_shift; // ecx MAPDST
unsigned int width; // eax MAPDST
signed int i; // edx MAPDST
signed int j; // ecx MAPDST
BYTE *dst, *src;
BYTE *tbl;
short cel_type_16;
unsigned int chk_sh_and;
unsigned int world_tbl;
unsigned int n_draw_shift;
unsigned int width;
int tile_42_45;
int xx_32, yy_32;
int i, j;
if (cel_transparency_active) {
if (!arch_draw_type) {
@@ -4461,14 +4445,14 @@ void drawLowerScreen(BYTE *pBuff)
}
}
}
gpCelFrame = (unsigned char *)SpeedFrameTbl;
gpCelFrame = (BYTE *)SpeedFrameTbl;
dst = pBuff;
if ((BYTE)light_table_index) {
if ((BYTE)light_table_index == lightmax) {
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = (level_cel_block >> 12) & 7;
switch (cel_type_16) {
case 0: // lower (solid), black
@@ -4495,7 +4479,7 @@ void drawLowerScreen(BYTE *pBuff)
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0)
break;
_LOBYTE(width) = -(char)width;
@@ -4717,9 +4701,9 @@ void drawLowerScreen(BYTE *pBuff)
return;
}
if (!(level_cel_block & 0x8000)) {
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
tbl = &pLightTbl[256 * light_table_index];
cel_type_16 = (unsigned short)level_cel_block >> 12;
cel_type_16 = (WORD)level_cel_block >> 12;
switch (cel_type_16) {
case 0: // lower (solid), with lighting
xx_32 = 32;
@@ -4739,7 +4723,7 @@ void drawLowerScreen(BYTE *pBuff)
do {
yy_32 = 32;
do {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0) {
yy_32 -= width;
if (dst < gpBufEnd) {
@@ -4818,7 +4802,7 @@ void drawLowerScreen(BYTE *pBuff)
}
do {
asm_cel_light_edge(32 - yy_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[yy_32 - (SCREEN_WIDTH + 160)];
yy_32 += 2;
} while (yy_32 != 32);
@@ -4831,7 +4815,7 @@ void drawLowerScreen(BYTE *pBuff)
}
do {
asm_cel_light_edge(32 - xx_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
} while (xx_32 >= 0);
@@ -4898,7 +4882,7 @@ void drawLowerScreen(BYTE *pBuff)
}
do {
asm_cel_light_edge(32 - xx_32, tbl, &dst, &src);
src += (unsigned char)src & 2;
src += (BYTE)src & 2;
dst = &dst[xx_32 - (SCREEN_WIDTH + 160)];
xx_32 -= 2;
} while (xx_32 >= 0);
@@ -4906,14 +4890,14 @@ void drawLowerScreen(BYTE *pBuff)
}
return;
}
src = (unsigned char *)pSpeedCels
src = pSpeedCels
+ *(DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))];
cel_type_16 = (unsigned short)level_cel_block >> 12;
cel_type_16 = (WORD)level_cel_block >> 12;
} else {
if (level_cel_block & 0x8000)
level_cel_block = *(DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)]
+ (unsigned short)(level_cel_block & 0xF000);
src = (unsigned char *)pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
+ (WORD)(level_cel_block & 0xF000);
src = pDungeonCels + *((DWORD *)pDungeonCels + (level_cel_block & 0xFFF));
cel_type_16 = (((unsigned int)level_cel_block >> 12) & 7) + 8;
}
switch (cel_type_16) {
@@ -4942,7 +4926,7 @@ void drawLowerScreen(BYTE *pBuff)
yy_32 = 32;
do {
while (1) {
width = (unsigned char)*src++;
width = *src++;
if ((width & 0x80u) == 0)
break;
_LOBYTE(width) = -(char)width;
@@ -5209,40 +5193,40 @@ void drawLowerScreen(BYTE *pBuff)
void world_draw_black_tile(BYTE *pBuff)
{
unsigned char *dst; // edi MAPDST
signed int xx_32; // edx
signed int i; // ebx MAPDST
signed int j; // ecx MAPDST
signed int yy_32; // edx
BYTE *dst;
int i, j;
int xx, yy;
dst = pBuff;
xx_32 = 30;
for (i = 1;; ++i) {
dst += xx_32;
xx = 30;
for (i = 1;; i++) {
dst += xx;
j = i;
do {
*(DWORD *)dst = 0;
dst += 4;
--j;
j--;
} while (j);
dst = &dst[xx_32 - 832];
if (!xx_32)
dst = &dst[xx - 832];
if (!xx)
break;
xx_32 -= 2;
xx -= 2;
}
yy_32 = 2;
yy = 2;
i = 15;
do {
dst += yy_32;
dst += yy;
j = i;
do {
*(DWORD *)dst = 0;
dst += 4;
--j;
j--;
} while (j);
dst = &dst[yy_32 - 832];
--i;
yy_32 += 2;
} while (yy_32 != 32);
dst = &dst[yy - 832];
i--;
yy += 2;
} while (yy != 32);
}
#endif