diff --git a/Source/engine.cpp b/Source/engine.cpp index 23dd30714..448c991e7 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -117,29 +117,6 @@ void CelClippedDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Ce nWidth); } -/** - * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 - * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 - */ -void CelClippedBlit(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) -{ - BYTE *pRLEBytes; - int nDataSize; - - /// ASSERT: assert(pCelBuff != NULL); - if (!pCelBuff) - return; - /// ASSERT: assert(pBuff != NULL); - if (!pBuff) - return; - - pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, CelSkip, CelCap, &nDataSize); - if (pRLEBytes == NULL) - return; - - CelBlit(pBuff, pRLEBytes, nDataSize, nWidth); -} - void CelBlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *tbl) { int w; @@ -196,87 +173,6 @@ void CelBlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, B } } -void CelBlitLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) -{ - int w; - BOOL shift; - BYTE *tbl; - - /// ASSERT: assert(pDecodeTo != NULL); - if (!pDecodeTo) - return; - /// ASSERT: assert(pRLEBytes != NULL); - if (!pRLEBytes) - return; - - int i; - BYTE width; - BYTE *src, *dst; - - src = pRLEBytes; - dst = pDecodeTo; - tbl = &pLightTbl[light_table_index * 256]; - w = nWidth; - shift = (BYTE)(size_t)dst & 1; - - for (; src != &pRLEBytes[nDataSize]; dst -= BUFFER_WIDTH + w, shift = (shift + 1) & 1) { - for (i = w; i;) { - width = *src++; - if (!(width & 0x80)) { - i -= width; - if (((BYTE)(size_t)dst & 1) == shift) { - if (!(width & 1)) { - goto L_ODD; - } else { - src++; - dst++; - L_EVEN: - width >>= 1; - if (width & 1) { - dst[0] = tbl[src[0]]; - src += 2; - dst += 2; - } - width >>= 1; - for (; width; width--) { - dst[0] = tbl[src[0]]; - dst[2] = tbl[src[2]]; - src += 4; - dst += 4; - } - } - } else { - if (!(width & 1)) { - goto L_EVEN; - } else { - dst[0] = tbl[src[0]]; - src++; - dst++; - L_ODD: - width >>= 1; - if (width & 1) { - dst[1] = tbl[src[1]]; - src += 2; - dst += 2; - } - width >>= 1; - for (; width; width--) { - dst[1] = tbl[src[1]]; - dst[3] = tbl[src[3]]; - src += 4; - dst += 4; - } - } - } - } else { - width = -(char)width; - dst += width; - i -= width; - } - } - } -} - void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { int nDataSize; @@ -293,9 +189,9 @@ void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) pDecodeTo = &gpBuffer[sx + PitchTbl[sy]]; if (light_table_index) - CelBlitLight(pDecodeTo, pRLEBytes, nDataSize, nWidth); + CelBlitLightSafe(pDecodeTo, pRLEBytes, nDataSize, nWidth); else - CelBlit(pDecodeTo, pRLEBytes, nDataSize, nWidth); + CelBlitSafe(pDecodeTo, pRLEBytes, nDataSize, nWidth); } /** @@ -326,34 +222,6 @@ void CelClippedDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i CelBlit(pDecodeTo, pRLEBytes, nDataSize, nWidth); } -/** - * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 - * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 - */ -void CelClippedBlitLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) -{ - int nDataSize; - BYTE *pRLEBytes; - - /// ASSERT: assert(pCelBuff != NULL); - if (!pCelBuff) - return; - /// ASSERT: assert(pBuff != NULL); - if (!pBuff) - return; - - pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, CelSkip, CelCap, &nDataSize); - if (pRLEBytes == NULL) - return; - - if (cel_transparency_active) - CelBlitLightTrans(pBuff, pRLEBytes, nDataSize, nWidth); - else if (light_table_index) - CelBlitLight(pBuff, pRLEBytes, nDataSize, nWidth); - else - CelBlit(pBuff, pRLEBytes, nDataSize, nWidth); -} - /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 @@ -504,7 +372,7 @@ void CelClippedDrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, in * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ -void CelClippedBlitSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) +void CelClippedBlit(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { BYTE *pRLEBytes; int nDataSize; @@ -686,35 +554,7 @@ void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ -void CelDrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) -{ - int nDataSize; - BYTE *pRLEBytes, *pDecodeTo; - - /// ASSERT: assert(gpBuffer); - if (!gpBuffer) - return; - /// ASSERT: assert(pCelBuff != NULL); - if (!pCelBuff) - return; - - pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, CelSkip, CelCap, &nDataSize); - if (pRLEBytes == NULL) - return; - - pDecodeTo = &gpBuffer[sx + PitchTbl[sy - 16 * CelSkip]]; - - if (light_table_index) - CelBlitLightSafe(pDecodeTo, pRLEBytes, nDataSize, nWidth); - else - CelBlitSafe(pDecodeTo, pRLEBytes, nDataSize, nWidth); -} - -/** - * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 - * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 - */ -void CelClippedBlitLightTransSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) +void CelClippedBlitLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { int nDataSize; BYTE *pRLEBytes; @@ -1398,340 +1238,6 @@ void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, BYTE *pRLEBytes; int nDataSize; - /// ASSERT: assert(gpBuffer != NULL); - if (!gpBuffer) - return; - /// ASSERT: assert(pCelBuff != NULL); - if (!pCelBuff) - return; - /// ASSERT: assert(nCel > 0); - if (nCel <= 0) - return; - - pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, CelSkip, CelCap, &nDataSize); - if (pRLEBytes == NULL) - return; - - Cl2Blit( - &gpBuffer[sx + PitchTbl[sy - 16 * CelSkip]], - pRLEBytes, - nDataSize, - nWidth); -} - -void Cl2Blit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) -{ - int w; - char width; - BYTE fill; - BYTE *src, *dst; - - src = pRLEBytes; - dst = pDecodeTo; - w = nWidth; - - while (nDataSize) { - width = *src++; - nDataSize--; - if (width < 0) { - width = -width; - if (width > 65) { - width -= 65; - nDataSize--; - fill = *src++; - w -= width; - while (width) { - *dst = fill; - dst++; - width--; - } - if (!w) { - w = nWidth; - dst -= BUFFER_WIDTH + w; - } - continue; - } else { - nDataSize -= width; - w -= width; - while (width) { - *dst = *src; - src++; - dst++; - width--; - } - if (!w) { - w = nWidth; - dst -= BUFFER_WIDTH + w; - } - continue; - } - } - while (width) { - if (width > w) { - dst += w; - width -= w; - w = 0; - } else { - dst += width; - w -= width; - width = 0; - } - if (!w) { - w = nWidth; - dst -= BUFFER_WIDTH + w; - } - } - } -} - -/** - * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 - * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 - */ -void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) -{ - int nDataSize; - BYTE *pRLEBytes; - - /// ASSERT: assert(gpBuffer != NULL); - if (!gpBuffer) - return; - /// ASSERT: assert(pCelBuff != NULL); - if (!pCelBuff) - return; - /// ASSERT: assert(nCel > 0); - if (nCel <= 0) - return; - - pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, CelSkip, CelCap, &nDataSize); - if (pRLEBytes == NULL) - return; - - Cl2BlitOutline( - &gpBuffer[sx + PitchTbl[sy - 16 * CelSkip]], - pRLEBytes, - nDataSize, - nWidth, - col); -} - -void Cl2BlitOutline(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) -{ - int w; - char width; - BYTE *src, *dst; - - src = pRLEBytes; - dst = pDecodeTo; - w = nWidth; - - while (nDataSize) { - width = *src++; - nDataSize--; - if (width < 0) { - width = -width; - if (width > 65) { - width -= 65; - nDataSize--; - if (*src++) { - w -= width; - dst[-1] = col; - dst[width] = col; - while (width) { - dst[-BUFFER_WIDTH] = col; - dst[BUFFER_WIDTH] = col; - dst++; - width--; - } - if (!w) { - w = nWidth; - dst -= BUFFER_WIDTH + w; - } - continue; - } - } else { - nDataSize -= width; - w -= width; - while (width) { - if (*src++) { - dst[-1] = col; - dst[1] = col; - dst[-BUFFER_WIDTH] = col; - dst[BUFFER_WIDTH] = col; - } - dst++; - width--; - } - if (!w) { - w = nWidth; - dst -= BUFFER_WIDTH + w; - } - continue; - } - } - while (width) { - if (width > w) { - dst += w; - width -= w; - w = 0; - } else { - dst += width; - w -= width; - width = 0; - } - if (!w) { - w = nWidth; - dst -= BUFFER_WIDTH + w; - } - } - } -} - -/** - * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 - * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 - */ -void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) -{ - int nDataSize, idx; - BYTE *pRLEBytes, *pDecodeTo; - - /// ASSERT: assert(gpBuffer != NULL); - if (!gpBuffer) - return; - /// ASSERT: assert(pCelBuff != NULL); - if (!pCelBuff) - return; - /// ASSERT: assert(nCel > 0); - if (nCel <= 0) - return; - - pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, CelSkip, CelCap, &nDataSize); - if (pRLEBytes == NULL) - return; - - pDecodeTo = &gpBuffer[sx + PitchTbl[sy - 16 * CelSkip]]; - - idx = light4flag ? 1024 : 4096; - if (light == 2) - idx += 256; - if (light >= 4) - idx += (light - 1) << 8; - - Cl2BlitLight( - pDecodeTo, - pRLEBytes, - nDataSize, - nWidth, - &pLightTbl[idx]); -} - -void Cl2BlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) -{ - int w; - char width; - BYTE fill; - BYTE *src, *dst; - - src = pRLEBytes; - dst = pDecodeTo; - w = nWidth; - sgnWidth = nWidth; - - while (nDataSize) { - width = *src++; - nDataSize--; - if (width < 0) { - width = -width; - if (width > 65) { - width -= 65; - nDataSize--; - fill = pTable[*src++]; - w -= width; - while (width) { - *dst = fill; - dst++; - width--; - } - if (!w) { - w = sgnWidth; - dst -= BUFFER_WIDTH + w; - } - continue; - } else { - nDataSize -= width; - w -= width; - while (width) { - *dst = pTable[*src]; - src++; - dst++; - width--; - } - if (!w) { - w = sgnWidth; - dst -= BUFFER_WIDTH + w; - } - continue; - } - } - while (width) { - if (width > w) { - dst += w; - width -= w; - w = 0; - } else { - dst += width; - w -= width; - width = 0; - } - if (!w) { - w = sgnWidth; - dst -= BUFFER_WIDTH + w; - } - } - } -} - -/** - * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 - * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 - */ -void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) -{ - int nDataSize; - BYTE *pRLEBytes, *pDecodeTo; - - /// ASSERT: assert(gpBuffer != NULL); - if (!gpBuffer) - return; - /// ASSERT: assert(pCelBuff != NULL); - if (!pCelBuff) - return; - /// ASSERT: assert(nCel > 0); - if (nCel <= 0) - return; - - pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, CelSkip, CelCap, &nDataSize); - if (pRLEBytes == NULL) - return; - - pDecodeTo = &gpBuffer[sx + PitchTbl[sy - 16 * CelSkip]]; - - if (light_table_index) - Cl2BlitLight(pDecodeTo, pRLEBytes, nDataSize, nWidth, &pLightTbl[light_table_index * 256]); - else - Cl2Blit(pDecodeTo, pRLEBytes, nDataSize, nWidth); -} - -/** - * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 - * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 - */ -void Cl2DrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) -{ - BYTE *pRLEBytes; - int nDataSize; - /// ASSERT: assert(gpBuffer != NULL); if (!gpBuffer) return; @@ -1828,7 +1334,7 @@ void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ -void Cl2DrawOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) +void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { int nDataSize; BYTE *pRLEBytes; @@ -1937,7 +1443,7 @@ void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ -void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) +void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) { int nDataSize, idx; BYTE *pRLEBytes, *pDecodeTo; @@ -2048,7 +1554,7 @@ void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ -void Cl2DrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) +void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { int nDataSize; BYTE *pRLEBytes, *pDecodeTo; diff --git a/Source/engine.h b/Source/engine.h index 7109ea782..0bfc6eed1 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -89,18 +89,14 @@ void CelBlitFrame(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth); void CelClippedDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); void CelClippedBlit(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); void CelBlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *tbl = NULL); -void CelBlitLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth); void CelClippedDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); void CelClippedBlitLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light); void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); void CelClippedDrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); -void CelClippedBlitSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); -void CelDrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); -void CelClippedBlitLightTransSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light); void CelBlitWidth(BYTE *pBuff, int always_0, int hgt, int wdt, BYTE *pCelBuff, int nCel, int nWidth); void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); @@ -119,19 +115,12 @@ BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen); DWORD LoadFileWithMem(const char *pszName, void *p); void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel); void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); -void Cl2Blit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); -void Cl2BlitOutline(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col); void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light); -void Cl2BlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable); void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); -void Cl2DrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); -void Cl2DrawOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col); -void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light); void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable); -void Cl2DrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip = 0, int CelCap = 8); void PlayInGameMovie(char *pszMovie); /* rdata */ diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index fc3b2472f..f03d298b4 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -417,794 +417,9 @@ static void DrawObject(int x, int y, int ox, int oy, BOOL pre) } } -static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag); +static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag); -static void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy) -{ - int i, lti_old, cta_old, lpi_old; - BYTE *dst; - MICROS *pMap; - - lti_old = light_table_index; - cta_old = cel_transparency_active; - lpi_old = level_piece_id; - - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - - dst = pBuff; - arch_draw_type = 1; - level_cel_block = pMap->mt[0]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - arch_draw_type = 2; - level_cel_block = pMap->mt[1]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - - dst = pBuff; - arch_draw_type = 0; - for (i = 2; i < MicroTileLen; i += 2) { - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[i]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[i + 1]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - } - - scrollrt_draw_clipped_dungeon(pBuff, x, y, sx, sy, 0); - - light_table_index = lti_old; - cel_transparency_active = cta_old; - level_piece_id = lpi_old; -} - -static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag) -{ - int px, py, nCel, nMon, negMon, p, frames; - char bFlag, bDead, bObj, bItem, bPlr, bArch, bMap, negPlr, dd; - DeadStruct *pDeadGuy; - ItemStruct *pItem; - PlayerStruct *pPlayer; - MonsterStruct *pMonster; - BYTE *pCelBuff; - - /// ASSERT: assert((DWORD)sx < MAXDUNX); - /// ASSERT: assert((DWORD)sy < MAXDUNY); - bFlag = dFlags[sx][sy]; - bDead = dDead[sx][sy]; - bObj = dObject[sx][sy]; - bItem = dItem[sx][sy]; - bPlr = dPlayer[sx][sy]; - bArch = dArch[sx][sy]; - bMap = dTransVal[sx][sy]; - nMon = dMonster[sx][sy]; - - /// ASSERT: assert((DWORD)(sy-1) < MAXDUNY); - negPlr = dPlayer[sx][sy - 1]; - negMon = dMonster[sx][sy - 1]; - - if (visiondebug && bFlag & BFLAG_LIT) { - CelClippedBlitSafe(pBuff, pSquareCel, 1, 64); - } - if (MissilePreFlag && bFlag & BFLAG_MISSILE) { - DrawMissile(sx, sy, dx, dy, 1); - } - if (light_table_index < lightmax) { - if (bDead != 0) { - pDeadGuy = &dead[(bDead & 0x1F) - 1]; - dd = (bDead >> 5) & 7; - px = dx - pDeadGuy->_deadWidth2; - pCelBuff = pDeadGuy->_deadData[dd]; - /// ASSERT: assert(pDeadGuy->_deadData[dd] != NULL); - if (pCelBuff != NULL) { - frames = SDL_SwapLE32(*(DWORD *)pDeadGuy->_deadData[dd]); - nCel = pDeadGuy->_deadFrame; - if (nCel >= 1 && frames <= 50 && nCel <= frames) { - if (pDeadGuy->_deadtrans != 0) { - Cl2DrawLightTblSafe(px, dy, pCelBuff, nCel, pDeadGuy->_deadWidth, 0, 8, pDeadGuy->_deadtrans); - } else { - Cl2DrawLightSafe(px, dy, pCelBuff, pDeadGuy->_deadFrame, pDeadGuy->_deadWidth); - } - } else { - // app_fatal("Clipped dead sub: frame %d of %d, deadnum==%d", nCel, frames, (bDead & 0x1F) - 1); - } - } - } - if (bObj != 0) { - DrawObject(sx, sy, dx, dy, 1); - } - } - if (bItem != 0) { - pItem = &item[bItem - 1]; - if (!pItem->_iPostDraw) { - /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((BYTE)bItem <= MAXITEMS) { - pCelBuff = pItem->_iAnimData; - if (pCelBuff != NULL) { - frames = SDL_SwapLE32(*(DWORD *)pCelBuff); - nCel = pItem->_iAnimFrame; - if (nCel >= 1 && frames <= 50 && nCel <= frames) { - px = dx - pItem->_iAnimWidth2; - if (bItem - 1 == pcursitem) { - CelBlitOutlineSafe(181, px, dy, pCelBuff, nCel, pItem->_iAnimWidth); - } - CelDrawLightSafe(px, dy, pItem->_iAnimData, pItem->_iAnimFrame, pItem->_iAnimWidth); - } else { - /* - app_fatal( - "Draw Clipped \"%s\" Item: frame %d of %d, item type==%d", - pItem->_iIName, - nCel, - frames, - pItem->_itype); - */ - } - } else { - // app_fatal("Draw Item \"%s\" Clipped 1: NULL Cel Buffer", pItem->_iIName); - } - } - } - } - if (bFlag & BFLAG_PLAYERLR) { - p = -(negPlr + 1); - if ((DWORD)p < MAX_PLRS) { - pPlayer = &plr[p]; - px = dx + pPlayer->_pxoff - pPlayer->_pAnimWidth2; - py = dy + pPlayer->_pyoff; - DrawPlayer(p, sx, sy - 1, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth); - if (eflag && pPlayer->_peflag != 0) { - if (pPlayer->_peflag == 2) { - scrollrt_draw_clipped_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, dx - 96, dy - 16); - } - scrollrt_draw_clipped_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); - } - } else { - // app_fatal("draw player clipped: tried to draw illegal player %d", p); - } - } - if (bFlag & BFLAG_MONSTLR && (bFlag & BFLAG_LIT || plr[myplr]._pInfraFlag) && negMon < 0) { - draw_monster_num = -(negMon + 1); - if ((DWORD)draw_monster_num < MAXMONSTERS) { - pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { - if (pMonster->MType != NULL) { - px = dx + pMonster->_mxoff - pMonster->MType->width2; - py = dy + pMonster->_myoff; - if (draw_monster_num == pcursmonst) { - Cl2DrawOutlineSafe(233, px, py, pMonster->_mAnimData, pMonster->_mAnimFrame, pMonster->MType->width); - } - DrawMonster(sx, sy, px, py, draw_monster_num); - if (eflag && pMonster->_meflag) { - scrollrt_draw_clipped_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); - } - } else { - // app_fatal("Draw Monster \"%s\" Clipped: uninitialized monster", pMonster->mName); - } - } - } else { - // app_fatal("Draw Monster Clipped: tried to draw illegal monster %d", draw_monster_num); - } - } - if (bFlag & BFLAG_DEAD_PLAYER) { - DrawDeadPlayer(sx, sy, dx, dy); - } - if (bPlr > 0) { - p = bPlr - 1; - if ((DWORD)p < MAX_PLRS) { - pPlayer = &plr[p]; - px = dx + pPlayer->_pxoff - pPlayer->_pAnimWidth2; - py = dy + pPlayer->_pyoff; - DrawPlayer(p, sx, sy, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth); - if (eflag && pPlayer->_peflag != 0) { - if (pPlayer->_peflag == 2) { - scrollrt_draw_clipped_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, dx - 96, dy - 16); - } - scrollrt_draw_clipped_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); - } - } else { - // app_fatal("draw player clipped: tried to draw illegal player %d", p); - } - } - if (nMon > 0 && (bFlag & BFLAG_LIT || plr[myplr]._pInfraFlag)) { - draw_monster_num = nMon - 1; - if ((DWORD)draw_monster_num < MAXMONSTERS) { - pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { - if (pMonster->MType != NULL) { - px = dx + pMonster->_mxoff - pMonster->MType->width2; - py = dy + pMonster->_myoff; - if (draw_monster_num == pcursmonst) { - Cl2DrawOutlineSafe(233, px, py, pMonster->_mAnimData, pMonster->_mAnimFrame, pMonster->MType->width); - } - DrawMonster(sx, sy, px, py, draw_monster_num); - if (eflag && pMonster->_meflag) { - scrollrt_draw_clipped_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); - } - } else { - // app_fatal("Draw Monster \"%s\" Clipped: uninitialized monster", pMonster->mName); - } - } - } else { - // app_fatal("Draw Monster Clipped: tried to draw illegal monster %d", draw_monster_num); - } - } - if (bFlag & BFLAG_MISSILE) { - DrawMissile(sx, sy, dx, dy, 0); - } - if (bObj != 0 && light_table_index < lightmax) { - DrawObject(sx, sy, dx, dy, 0); - } - if (bItem != 0) { - pItem = &item[bItem - 1]; - if (pItem->_iPostDraw) { - /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((BYTE)bItem <= MAXITEMS) { - pCelBuff = pItem->_iAnimData; - if (pCelBuff != NULL) { - frames = SDL_SwapLE32(*(DWORD *)pCelBuff); - nCel = pItem->_iAnimFrame; - if (nCel >= 1 && frames <= 50 && nCel <= frames) { - px = dx - pItem->_iAnimWidth2; - if (bItem - 1 == pcursitem) { - CelBlitOutlineSafe(181, px, dy, pCelBuff, nCel, pItem->_iAnimWidth); - } - CelDrawLightSafe(px, dy, pItem->_iAnimData, pItem->_iAnimFrame, pItem->_iAnimWidth); - } else { - /* - app_fatal( - "Draw Clipped \"%s\" Item 2: frame %d of %d, item type==%d", - pItem->_iIName, - nCel, - frames, - pItem->_itype); - */ - } - } else { - // app_fatal("Draw Item \"%s\" Clipped 2: NULL Cel Buffer", pItem->_iIName); - } - } - } - } - if (bArch != 0) { - cel_transparency_active = TransList[bMap]; - CelClippedBlitLightTransSafe(pBuff, pSpecialCels, bArch, 64); - } -} - -static void scrollrt_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag) -{ - int i, j; - BYTE *dst; - MICROS *pMap; - - /// ASSERT: assert(gpBuffer); - - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - - if (eflag) { - if ((DWORD)y < MAXDUNY && (DWORD)x < MAXDUNX) { - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - if (level_piece_id != 0) { - dst = &gpBuffer[sx + 32 + PitchTbl[sy]]; - cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - arch_draw_type = 2; - level_cel_block = pMap->mt[1]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - arch_draw_type = 0; - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[3]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[5]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[7]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[9]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[11]; - if (level_cel_block != 0 && leveltype == DTYPE_HELL) { - drawLowerScreen(dst); - } - scrollrt_draw_clipped_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 0); - } else { - world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); - } - } - x++; - y--; - sx += 64; - pMap++; - chunks--; - } - - j = chunks; - while (j-- != 0) { - if (y < 0 || x >= MAXDUNX) { - break; - } - if (y < MAXDUNY && x >= 0) { - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - if (level_piece_id == 0) { - world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); - } else { - dst = &gpBuffer[sx + PitchTbl[sy]]; - cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - arch_draw_type = 1; - level_cel_block = pMap->mt[0]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - arch_draw_type = 2; - level_cel_block = pMap->mt[1]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - arch_draw_type = 0; - for (i = 2; i < MicroTileLen; i += 2) { - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[i]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[i + 1]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - } - scrollrt_draw_clipped_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 1); - } - } - x++; - y--; - sx += 64; - pMap++; - } - - if (eflag && (DWORD)y < MAXDUNY && (DWORD)x < MAXDUNX) { - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - if (level_piece_id == 0) { - world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); - } else { - dst = &gpBuffer[sx + PitchTbl[sy]]; - cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - arch_draw_type = 1; - level_cel_block = pMap->mt[0]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - arch_draw_type = 0; - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[2]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[4]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[6]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[8]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[10]; - if (level_cel_block != 0 && leveltype == DTYPE_HELL) { - drawLowerScreen(dst); - } - scrollrt_draw_clipped_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 0); - } - } -} - -static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks, int dx, int dy, int eflag); - -static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int sx, int sy) -{ - int lti_old, cta_old, lpi_old; - BYTE *dst; - MICROS *pMap; - - lti_old = light_table_index; - cta_old = cel_transparency_active; - lpi_old = level_piece_id; - - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - dst = &pBuff[BUFFER_WIDTH * 32 * skipChunks]; - cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - - switch (skipChunks) { - case 0: - level_cel_block = pMap->mt[2]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[3]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - case 1: - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[4]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[5]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - case 2: - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[6]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[7]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - case 3: - dst -= BUFFER_WIDTH * 32; - level_cel_block = pMap->mt[8]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[9]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - break; - } - - scrollrt_draw_clipped_dungeon_2(pBuff, x, y, skipChunks, sx, sy, 0); - - light_table_index = lti_old; - cel_transparency_active = cta_old; - level_piece_id = lpi_old; -} - -static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks, int dx, int dy, int eflag) -{ - int px, py, nCel, nMon, negMon, p, frames; - char bFlag, bDead, bObj, bItem, bPlr, bArch, bMap, negPlr, dd; - DeadStruct *pDeadGuy; - ItemStruct *pItem; - PlayerStruct *pPlayer; - MonsterStruct *pMonster; - BYTE *pCelBuff; - - /// ASSERT: assert((DWORD)sx < MAXDUNX); - /// ASSERT: assert((DWORD)sy < MAXDUNY); - bFlag = dFlags[sx][sy]; - bDead = dDead[sx][sy]; - bObj = dObject[sx][sy]; - bItem = dItem[sx][sy]; - bPlr = dPlayer[sx][sy]; - bArch = dArch[sx][sy]; - bMap = dTransVal[sx][sy]; - nMon = dMonster[sx][sy]; - - /// ASSERT: assert((DWORD)(sy-1) < MAXDUNY); - negPlr = dPlayer[sx][sy - 1]; - negMon = dMonster[sx][sy - 1]; - - if (visiondebug && bFlag & BFLAG_LIT) { - CelClippedBlitSafe(pBuff, pSquareCel, 1, 64); - } - if (MissilePreFlag && bFlag & BFLAG_MISSILE) { - DrawMissile(sx, sy, dx, dy, 1); - } - if (light_table_index < lightmax) { - if (bDead != 0) { - pDeadGuy = &dead[(bDead & 0x1F) - 1]; - dd = (bDead >> 5) & 7; - px = dx - pDeadGuy->_deadWidth2; - pCelBuff = pDeadGuy->_deadData[dd]; - /// ASSERT: assert(pDeadGuy->_deadData[dd] != NULL); - if (pCelBuff != NULL) { - frames = SDL_SwapLE32(*(DWORD *)pDeadGuy->_deadData[dd]); - nCel = pDeadGuy->_deadFrame; - if (nCel >= 1 && frames <= 50 && nCel <= frames) { - if (pDeadGuy->_deadtrans != 0) { - Cl2DrawLightTblSafe(px, dy, pCelBuff, nCel, pDeadGuy->_deadWidth, 0, 8, pDeadGuy->_deadtrans); - } else { - Cl2DrawLightSafe(px, dy, pCelBuff, pDeadGuy->_deadFrame, pDeadGuy->_deadWidth); - } - } else { - // app_fatal("Clipped dead sub2: frame %d of %d, deadnum==%d", nCel, frames, (bDead & 0x1F) - 1); - } - } - } - if (bObj != 0) { - DrawObject(sx, sy, dx, dy, 1); - } - } - if (bItem != 0) { - pItem = &item[bItem - 1]; - if (!pItem->_iPostDraw) { - /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((BYTE)bItem <= MAXITEMS) { - pCelBuff = pItem->_iAnimData; - if (pCelBuff != NULL) { - frames = SDL_SwapLE32(*(DWORD *)pCelBuff); - nCel = pItem->_iAnimFrame; - if (nCel >= 1 && frames <= 50 && nCel <= (int)frames) { - px = dx - pItem->_iAnimWidth2; - if (bItem - 1 == pcursitem) { - CelBlitOutlineSafe(181, px, dy, pCelBuff, nCel, pItem->_iAnimWidth); - } - CelDrawLightSafe(px, dy, pItem->_iAnimData, pItem->_iAnimFrame, pItem->_iAnimWidth); - } else { - /* - app_fatal( - "Draw Clipped \"%s\" Item 3: frame %d of %d, item type==%d", - pItem->_iIName, - nCel, - frames, - pItem->_itype); - */ - } - } else { - // app_fatal("Draw Item \"%s\" Clipped 3: NULL Cel Buffer", pItem->_iIName); - } - } - } - } - if (bFlag & BFLAG_PLAYERLR) { - p = -(negPlr + 1); - if ((DWORD)p < MAX_PLRS) { - pPlayer = &plr[p]; - px = dx + pPlayer->_pxoff - pPlayer->_pAnimWidth2; - py = dy + pPlayer->_pyoff; - DrawPlayer(p, sx, sy - 1, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth); - if (eflag && pPlayer->_peflag != 0) { - if (pPlayer->_peflag == 2) { - scrollrt_draw_clipped_e_flag_2(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, skipChunks, dx - 96, dy - 16); - } - scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, dx - 64, dy); - } - } else { - // app_fatal("draw player clipped: tried to draw illegal player %d", p); - } - } - if (bFlag & BFLAG_MONSTLR && (bFlag & BFLAG_LIT || plr[myplr]._pInfraFlag) && negMon < 0) { - draw_monster_num = -(negMon + 1); - if ((DWORD)draw_monster_num < MAXMONSTERS) { - pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { - if (pMonster->MType != NULL) { - px = dx + pMonster->_mxoff - pMonster->MType->width2; - py = dy + pMonster->_myoff; - if (draw_monster_num == pcursmonst) { - Cl2DrawOutlineSafe(233, px, py, pMonster->_mAnimData, pMonster->_mAnimFrame, pMonster->MType->width); - } - DrawMonster(sx, sy, px, py, draw_monster_num); - if (eflag && !pMonster->_meflag) { - scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, dx - 64, dy); - } - } else { - // app_fatal("Draw Monster \"%s\" Clipped: uninitialized monster", pMonster->mName); - } - } - } else { - // app_fatal("Draw Monster Clipped: tried to draw illegal monster %d", draw_monster_num); - } - } - if (bFlag & BFLAG_DEAD_PLAYER) { - DrawDeadPlayer(sx, sy, dx, dy); - } - if (bPlr > 0) { - p = bPlr - 1; - if ((DWORD)p < MAX_PLRS) { - pPlayer = &plr[p]; - px = dx + pPlayer->_pxoff - pPlayer->_pAnimWidth2; - py = dy + pPlayer->_pyoff; - DrawPlayer(p, sx, sy, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth); - if (eflag && pPlayer->_peflag != 0) { - if (pPlayer->_peflag == 2) { - scrollrt_draw_clipped_e_flag_2(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, skipChunks, dx - 96, dy - 16); - } - scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, dx - 64, dy); - } - } else { - // app_fatal("draw player clipped: tried to draw illegal player %d", p); - } - } - if (nMon > 0 && (bFlag & BFLAG_LIT || plr[myplr]._pInfraFlag)) { - draw_monster_num = nMon - 1; - if ((DWORD)draw_monster_num < MAXMONSTERS) { - pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { - if (pMonster->MType != NULL) { - px = dx + pMonster->_mxoff - pMonster->MType->width2; - py = dy + pMonster->_myoff; - if (draw_monster_num == pcursmonst) { - Cl2DrawOutlineSafe(233, px, py, pMonster->_mAnimData, pMonster->_mAnimFrame, pMonster->MType->width); - } - DrawMonster(sx, sy, px, py, draw_monster_num); - if (eflag && !pMonster->_meflag) { - scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, dx - 64, dy); - } - } else { - // app_fatal("Draw Monster \"%s\" Clipped: uninitialized monster", pMonster->mName); - } - } - } else { - // app_fatal("Draw Monster Clipped: tried to draw illegal monster %d", draw_monster_num); - } - } - if (bFlag & BFLAG_MISSILE) { - DrawMissile(sx, sy, dx, dy, 0); - } - if (bObj != 0 && light_table_index < lightmax) { - DrawObject(sx, sy, dx, dy, 0); - } - if (bItem != 0) { - pItem = &item[bItem - 1]; - if (pItem->_iPostDraw) { - /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((BYTE)bItem <= MAXITEMS) { - pCelBuff = pItem->_iAnimData; - if (pCelBuff != NULL) { - frames = SDL_SwapLE32(*(DWORD *)pCelBuff); - nCel = pItem->_iAnimFrame; - if (nCel >= 1 && frames <= 50 && nCel <= frames) { - px = dx - pItem->_iAnimWidth2; - if (bItem - 1 == pcursitem) { - CelBlitOutlineSafe(181, px, dy, pCelBuff, nCel, pItem->_iAnimWidth); - } - CelDrawLightSafe(px, dy, pItem->_iAnimData, pItem->_iAnimFrame, pItem->_iAnimWidth); - } else { - /* - app_fatal( - "Draw Clipped \"%s\" Item 4: frame %d of %d, item type==%d", - pItem->_iIName, - nCel, - frames, - pItem->_itype); - */ - } - } else { - // app_fatal("Draw Item \"%s\" Clipped 4: NULL Cel Buffer", pItem->_iIName); - } - } - } - } - if (bArch != 0) { - cel_transparency_active = TransList[bMap]; - CelClippedBlitLightTransSafe(pBuff, pSpecialCels, bArch, 64); - } -} - -static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, int eflag) -{ - int i, j; - BYTE *dst; - MICROS *pMap; - - /// ASSERT: assert(gpBuffer); - - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - - if (eflag) { - if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - if (level_piece_id != 0) { - dst = &gpBuffer[sx - (BUFFER_WIDTH * 32 - 32) + PitchTbl[sy]]; - cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - for (i = 0; i < (MicroTileLen >> 1) - 1; i++) { - if (skipChunks <= i) { - level_cel_block = pMap->mt[2 * i + 3]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - } - dst -= BUFFER_WIDTH * 32; - } - scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy]], x, y, skipChunks, sx, sy, 0); - } - } - x++; - y--; - sx += 64; - chunks--; - pMap++; - } - - j = chunks; - while (j-- != 0) { - if (x >= MAXDUNX || y < 0) { - break; - } - if (y < MAXDUNY && x >= 0) { - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - if (level_piece_id != 0) { - dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]]; - cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - i = 0; - while (i < (MicroTileLen >> 1) - 1) { - if (skipChunks <= i) { - level_cel_block = pMap->mt[2 * i + 2]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[2 * i + 3]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - } - i++; - dst -= BUFFER_WIDTH * 32; - } - scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 32 * (skipChunks + 1)], x, y, skipChunks, sx, sy, 1); - } - } - x++; - y--; - sx += 64; - pMap++; - } - - if (eflag) { - if ((DWORD)y < MAXDUNY && (DWORD)x < MAXDUNX) { - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - if (level_piece_id != 0) { - dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]]; - cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - for (i = 0; i < (MicroTileLen >> 1) - 1; i++) { - if (skipChunks <= i) { - level_cel_block = pMap->mt[2 * i + 2]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - } - dst -= BUFFER_WIDTH * 32; - } - scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy]], x, y, skipChunks, sx, sy, 0); - } - } - } -} - -static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, int dx, int dy, int eflag); - -static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int sx, int sy) +static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int sx, int sy) { int i, lti_old, cta_old, lpi_old; BYTE *dst; @@ -1232,28 +447,26 @@ static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int s } arch_draw_type = 0; - for (i = 1; i < (MicroTileLen >> 1) - 1; i++) { + for (i = 2; i < MicroTileLen; i += 2) { dst -= BUFFER_WIDTH * 32; - if (capChunks >= i) { - level_cel_block = pMap->mt[2 * i]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } - level_cel_block = pMap->mt[2 * i + 1]; - if (level_cel_block != 0) { - drawUpperScreen(dst + 32); - } + level_cel_block = pMap->mt[i]; + if (level_cel_block != 0) { + drawLowerScreen(dst); + } + level_cel_block = pMap->mt[i + 1]; + if (level_cel_block != 0) { + drawLowerScreen(dst + 32); } } - scrollrt_draw_dungeon(pBuff, x, y, capChunks, sx, sy, 0); + scrollrt_draw_dungeon(pBuff, x, y, sx, sy, 0); light_table_index = lti_old; cel_transparency_active = cta_old; level_piece_id = lpi_old; } -static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, int dx, int dy, int eflag) +static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag) { int px, py, nCel, nMon, negMon, p, tx, ty, frames; char bFlag, bDead, bObj, bItem, bPlr, bArch, bMap, negPlr, dd; @@ -1346,9 +559,9 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, in DrawPlayer(p, sx, sy - 1, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth); if (eflag && pPlayer->_peflag != 0) { if (pPlayer->_peflag == 2) { - scrollrt_draw_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, capChunks, tx, ty); + scrollrt_draw_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, tx, ty); } - scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, capChunks, dx - 64, dy); + scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); } } else { // app_fatal("draw player: tried to draw illegal player %d", p); @@ -1367,7 +580,7 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, in } DrawMonster(sx, sy, px, py, draw_monster_num); if (eflag && !pMonster->_meflag) { - scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, capChunks, dx - 64, dy); + scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); } } else { // app_fatal("Draw Monster \"%s\": uninitialized monster", pMonster->mName); @@ -1389,9 +602,9 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, in DrawPlayer(p, sx, sy, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth); if (eflag && pPlayer->_peflag != 0) { if (pPlayer->_peflag == 2) { - scrollrt_draw_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, capChunks, dx - 96, dy - 16); + scrollrt_draw_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, dx - 96, dy - 16); } - scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, capChunks, dx - 64, dy); + scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); } } else { // app_fatal("draw player: tried to draw illegal player %d", p); @@ -1410,7 +623,7 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, in } DrawMonster(sx, sy, px, py, draw_monster_num); if (eflag && !pMonster->_meflag) { - scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, capChunks, dx - 64, dy); + scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); } } else { // app_fatal("Draw Monster \"%s\": uninitialized monster", pMonster->mName); @@ -1456,7 +669,7 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, in } } -static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag) +static void scrollrt_draw(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag) { int i, j; BYTE *dst; @@ -1473,36 +686,38 @@ static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int ca if (level_piece_id != 0) { dst = &gpBuffer[sx + 32 + PitchTbl[sy]]; cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - if (capChunks >= 0) { - level_cel_block = pMap->mt[1]; - if (level_cel_block != 0) { - arch_draw_type = 2; - drawUpperScreen(dst); - arch_draw_type = 0; - } + level_cel_block = pMap->mt[1]; + if (level_cel_block != 0) { + arch_draw_type = 2; + drawUpperScreen(dst); + arch_draw_type = 0; } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 1) { - level_cel_block = pMap->mt[3]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } + level_cel_block = pMap->mt[3]; + if (level_cel_block != 0) { + drawUpperScreen(dst); } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 2) { - level_cel_block = pMap->mt[5]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } + level_cel_block = pMap->mt[5]; + if (level_cel_block != 0) { + drawUpperScreen(dst); } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 3) { - level_cel_block = pMap->mt[7]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } + level_cel_block = pMap->mt[7]; + if (level_cel_block != 0) { + drawUpperScreen(dst); + } + dst -= BUFFER_WIDTH * 32; + level_cel_block = pMap->mt[9]; + if (level_cel_block != 0) { + drawUpperScreen(dst); } - scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, sx, sy, 0); + dst -= BUFFER_WIDTH * 32; + level_cel_block = pMap->mt[11]; + if (level_cel_block != 0 && leveltype == DTYPE_HELL) { + drawUpperScreen(dst); + } + scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 0); } else { world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } @@ -1534,18 +749,16 @@ static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int ca arch_draw_type = 0; for (i = 1; i < (MicroTileLen >> 1) - 1; i++) { dst -= BUFFER_WIDTH * 32; - if (capChunks >= i) { - level_cel_block = pMap->mt[2 * i]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } - level_cel_block = pMap->mt[2 * i + 1]; - if (level_cel_block != 0) { - drawUpperScreen(dst + 32); - } + level_cel_block = pMap->mt[2 * i]; + if (level_cel_block != 0) { + drawUpperScreen(dst); + } + level_cel_block = pMap->mt[2 * i + 1]; + if (level_cel_block != 0) { + drawUpperScreen(dst + 32); } } - scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, sx, sy, 1); + scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 1); } else { world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } @@ -1564,35 +777,38 @@ static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int ca dst = &gpBuffer[sx + PitchTbl[sy]]; cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); arch_draw_type = 1; - if (capChunks >= 0) { - level_cel_block = pMap->mt[0]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } + level_cel_block = pMap->mt[0]; + if (level_cel_block != 0) { + drawUpperScreen(dst); } arch_draw_type = 0; dst -= BUFFER_WIDTH * 32; - if (capChunks >= 1) { - level_cel_block = pMap->mt[2]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } + level_cel_block = pMap->mt[2]; + if (level_cel_block != 0) { + drawUpperScreen(dst); } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 2) { - level_cel_block = pMap->mt[4]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } + level_cel_block = pMap->mt[4]; + if (level_cel_block != 0) { + drawUpperScreen(dst); } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 3) { - level_cel_block = pMap->mt[6]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } + level_cel_block = pMap->mt[6]; + if (level_cel_block != 0) { + drawUpperScreen(dst); + } + // TODO debug thease to see if they are even on screen + dst -= BUFFER_WIDTH * 32; + level_cel_block = pMap->mt[8]; + if (level_cel_block != 0) { + drawUpperScreen(dst); + } + dst -= BUFFER_WIDTH * 32; + level_cel_block = pMap->mt[10]; + if (level_cel_block != 0 && leveltype == DTYPE_HELL) { + drawUpperScreen(dst); } - scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, sx, sy, 0); + scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 0); } else { world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } @@ -1606,15 +822,14 @@ static void DrawGame(int x, int y) scr_pix_width = SCREEN_WIDTH; scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; sx = ScrollInfo._sxoff + 64; sy = ScrollInfo._syoff + 175; x -= 10; y--; chunks = 10; - blocks = 8; + // Fill screen, keep evaulating untill files can't affect screen + blocks = ceil(VIEWPORT_HEIGHT / 32) + ceil(MicroTileLen / 2); if (chrflag || questlog) { x += 2; @@ -1665,37 +880,14 @@ static void DrawGame(int x, int y) break; } - /// ASSERT: assert(gpBuffer); - gpBufEnd = &gpBuffer[PitchTbl[0 + SCREEN_Y]]; - for (i = 0; i < 4; i++) { - scrollrt_draw_upper(x, y, sx, sy, chunks, i, 0); - y++; - sx -= 32; - sy += 16; - scrollrt_draw_upper(x, y, sx, sy, chunks, i, 1); - x++; - sx += 32; - sy += 16; - } /// ASSERT: assert(gpBuffer); gpBufEnd = &gpBuffer[PitchTbl[VIEWPORT_HEIGHT + SCREEN_Y]]; for (i = 0; i < blocks; i++) { - scrollrt_draw_lower(x, y, sx, sy, chunks, 0); - y++; - sx -= 32; - sy += 16; - scrollrt_draw_lower(x, y, sx, sy, chunks, 1); - x++; - sx += 32; - sy += 16; - } - arch_draw_type = 0; - for (i = 0; i < 4; i++) { - scrollrt_draw_lower_2(x, y, sx, sy, chunks, i, 0); + scrollrt_draw(x, y, sx, sy, chunks, i, 0); y++; sx -= 32; sy += 16; - scrollrt_draw_lower_2(x, y, sx, sy, chunks, i, 1); + scrollrt_draw(x, y, sx, sy, chunks, i, 1); x++; sx += 32; sy += 16; @@ -1709,15 +901,14 @@ static void DrawZoom(int x, int y) scr_pix_width = ZOOM_WIDTH; scr_pix_height = 192; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = 192 / 32; sx = ScrollInfo._sxoff + 64; sy = ScrollInfo._syoff + 143; x -= 6; y--; chunks = 6; - blocks = 3; + // Fill screen, keep evaulating untill files can't affect screen + blocks = ceil(VIEWPORT_HEIGHT / 2 / 32) + ceil(MicroTileLen / 2); switch (ScrollInfo._sdir) { case SDIR_NONE: @@ -1756,36 +947,13 @@ static void DrawZoom(int x, int y) } /// ASSERT: assert(gpBuffer); - gpBufEnd = &gpBuffer[PitchTbl[-17 + SCREEN_Y]]; - for (i = 0; i < 4; i++) { - scrollrt_draw_upper(x, y, sx, sy, chunks, i, 0); - y++; - sx -= 32; - sy += 16; - scrollrt_draw_upper(x, y, sx, sy, chunks, i, 1); - x++; - sx += 32; - sy += 16; - } - /// ASSERT: assert(gpBuffer); - gpBufEnd = &gpBuffer[PitchTbl[160 + SCREEN_Y]]; + gpBufEnd = &gpBuffer[PitchTbl[(int)ceil(VIEWPORT_HEIGHT / 2) + SCREEN_Y]]; for (i = 0; i < blocks; i++) { - scrollrt_draw_lower(x, y, sx, sy, chunks, 0); - y++; - sx -= 32; - sy += 16; - scrollrt_draw_lower(x, y, sx, sy, chunks, 1); - x++; - sx += 32; - sy += 16; - } - arch_draw_type = 0; - for (i = 0; i < 4; i++) { - scrollrt_draw_lower_2(x, y, sx, sy, chunks, i, 0); + scrollrt_draw(x, y, sx, sy, chunks, i, 0); y++; sx -= 32; sy += 16; - scrollrt_draw_lower_2(x, y, sx, sy, chunks, i, 1); + scrollrt_draw(x, y, sx, sy, chunks, i, 1); x++; sx += 32; sy += 16; @@ -2003,7 +1171,7 @@ static void DrawFPS() if (framerate > 99) framerate = 99; wsprintf(String, "%2d", framerate); - TextOut(hdc, 0, 400, String, strlen(String)); + TextOut(hdc, 0, 400, String, strlen(String)); } } #endif diff --git a/Source/town.cpp b/Source/town.cpp index 62fc6ca81..5f2d50490 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -2,7 +2,7 @@ DEVILUTION_BEGIN_NAMESPACE -void town_clear_upper_buf(BYTE *pBuff) +void town_clear_buf(BYTE *pBuff) { /// ASSERT: assert(gpBuffer); @@ -11,13 +11,13 @@ void town_clear_upper_buf(BYTE *pBuff) dst = pBuff; - for (i = 30, j = 1; i >= 0 && dst >= gpBufEnd; i -= 2, j++, dst -= BUFFER_WIDTH + 64) { + for (i = 30, j = 1; i >= 0; i -= 2, j++, dst -= BUFFER_WIDTH + 64) { dst += i; for (k = 0; k < 4 * j; k++) *dst++ = 0; dst += i; } - for (i = 2, j = 15; i != 32 && dst >= gpBufEnd; i += 2, j--, dst -= BUFFER_WIDTH + 64) { + for (i = 2, j = 15; i != 32; i += 2, j--, dst -= BUFFER_WIDTH + 64) { dst += i; for (k = 0; k < 4 * j; k++) *dst++ = 0; @@ -25,458 +25,18 @@ void town_clear_upper_buf(BYTE *pBuff) } } -void town_clear_low_buf(BYTE *pBuff) -{ - /// ASSERT: assert(gpBuffer); - - int i, j, k; - BYTE *dst; - - dst = pBuff; - - for (i = 30, j = 1; i >= 0; i -= 2, j++, dst -= BUFFER_WIDTH + 64) { - if (dst < gpBufEnd) { - dst += i; - for (k = 0; k < 4 * j; k++) - *dst++ = 0; - dst += i; - } else { - dst += 64; - } - } - for (i = 2, j = 15; i != 32; i += 2, j--, dst -= BUFFER_WIDTH + 64) { - if (dst < gpBufEnd) { - dst += i; - for (k = 0; k < 4 * j; k++) - *dst++ = 0; - dst += i; - } else { - dst += 64; - } - } -} - -void town_special_lower(BYTE *pBuff, int nCel) +void town_special(BYTE *pBuff, int nCel) { #if 0 - int nDataSize; - BYTE *pRLEBytes; - - pRLEBytes = CelGetFrame(pSpecialCels, nCel, &nDataSize); - CelBlitSafe(pBuff, pRLEBytes, nDataSize, 64); -#endif -} - -void town_special_upper(BYTE *dst, int nCel) -{ -#if 0 - int w; - BYTE *end, *src; - BYTE width; - - src = CelGetFrame(pSpecialCels, nCel, &nDataSize); - end = &src[nDataSize]; - - for(; src != end; dst -= BUFFER_WIDTH + 64) { - for(w = 64; w;) { - width = *src++; - if(!(width & 0x80)) { - w -= width; - if(dst < gpBufEnd) { - return; - } - if(width & 1) { - dst[0] = src[0]; - src++; - dst++; - } - width >>= 1; - if(width & 1) { - dst[0] = src[0]; - dst[1] = src[1]; - src += 2; - dst += 2; - } - width >>= 1; - for(; width; width--) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; - src += 4; - dst += 4; - } - } else { - width = -(char)width; - dst += width; - w -= width; - } - } - } + CelBlitFrame(pBuff, pSpecialCels, nCel, 64); #endif } -void town_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy) -{ - int i; - BYTE *dst; - MICROS *pMap; - - dst = pBuff; - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - - for (i = 0; i < 12; i += 2) { - level_cel_block = pMap->mt[i]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[i + 1]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - dst -= BUFFER_WIDTH * 32; - } - - town_draw_clipped_town(pBuff, x, y, sx, sy, 0); -} - -void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag) -{ - int mi, px, py; - char bv; - - /// ASSERT: assert(gpBuffer); - - pBuff = &gpBuffer[dx + PitchTbl[dy]]; - - if (dItem[sx][sy] != 0) { - bv = dItem[sx][sy] - 1; - px = dx - item[bv]._iAnimWidth2; - if (bv == pcursitem) { - CelBlitOutlineSafe(181, px, dy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth); - } - CelClippedDrawSafe(px, dy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth); - } - if (dFlags[sx][sy] & BFLAG_MONSTLR) { - mi = -(dMonster[sx][sy - 1] + 1); - px = dx - towner[mi]._tAnimWidth2; - if (mi == pcursmonst) { - CelBlitOutlineSafe(166, px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth); - } - CelClippedDrawSafe(px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth); - } - if (dMonster[sx][sy] > 0) { - mi = dMonster[sx][sy] - 1; - px = dx - towner[mi]._tAnimWidth2; - if (mi == pcursmonst) { - CelBlitOutlineSafe(166, px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth); - } - CelClippedDrawSafe(px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth); - } - if (dFlags[sx][sy] & BFLAG_PLAYERLR) { - bv = -(dPlayer[sx][sy - 1] + 1); - px = dx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; - py = dy + plr[bv]._pyoff; - if (bv == pcursplr) { - Cl2DrawOutlineSafe(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); - } - Cl2DrawSafe(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); - if (eflag && plr[bv]._peflag) { - town_draw_clipped_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); - } - } - if (dFlags[sx][sy] & BFLAG_DEAD_PLAYER) { - DrawDeadPlayer(sx, sy, dx, dy); - } - if (dPlayer[sx][sy] > 0) { - bv = dPlayer[sx][sy] - 1; - px = dx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; - py = dy + plr[bv]._pyoff; - if (bv == pcursplr) { - Cl2DrawOutlineSafe(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); - } - Cl2DrawSafe(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); - if (eflag && plr[bv]._peflag) { - town_draw_clipped_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); - } - } - if (dFlags[sx][sy] & BFLAG_MISSILE) { - DrawMissile(sx, sy, dx, dy, 0); - } - if (dArch[sx][sy] != 0) { - town_special_lower(pBuff, dArch[sx][sy]); - } -} - -void town_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag) -{ - int i, j; - BYTE *dst; - MICROS *pMap; - - /// ASSERT: assert(gpBuffer); - - if (eflag) { - if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { - level_cel_block = dPiece[x][y]; - if (level_cel_block != 0) { - dst = &gpBuffer[sx + 32 + PitchTbl[sy]]; - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - for (i = 1; i < 17; i += 2) { - level_cel_block = pMap->mt[i]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - } - town_draw_clipped_town(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 0); - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - x++; - y--; - sx += 64; - } - - for (j = 0; j < chunks - eflag; j++) { - if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { - level_cel_block = dPiece[x][y]; - if (level_cel_block != 0) { - dst = &gpBuffer[sx + PitchTbl[sy]]; - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - for (i = 0; i < 16; i += 2) { - level_cel_block = pMap->mt[i]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[i + 1]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - dst -= BUFFER_WIDTH * 32; - } - town_draw_clipped_town(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 1); - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - x++; - y--; - sx += 64; - } - - if (eflag) { - if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { - level_cel_block = dPiece[x][y]; - if (level_cel_block != 0) { - dst = &gpBuffer[sx + PitchTbl[sy]]; - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - for (i = 0; i < 16; i += 2) { - level_cel_block = pMap->mt[i]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - dst -= BUFFER_WIDTH * 32; - } - town_draw_clipped_town(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 0); - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - } -} - -void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int sx, int sy) -{ - int i; - BYTE *dst; - MICROS *pMap; - - if (skipChunks == 0) { - dst = pBuff; - } else { - dst = &pBuff[BUFFER_WIDTH * 32 * skipChunks]; - } - - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - - for (i = 0; i < 6; i++) { - if (skipChunks <= i) { - level_cel_block = pMap->mt[2 * i + 2]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[2 * i + 3]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - } - dst -= BUFFER_WIDTH * 32; - } - - town_draw_clipped_town_2(pBuff, x, y, skipChunks, sx, sy, 0); -} - -void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int skipChunks, int dx, int dy, int eflag) -{ - int mi, px, py; - char bv; - - if (dItem[sx][sy] != 0) { - bv = dItem[sx][sy] - 1; - px = dx - item[bv]._iAnimWidth2; - if (bv == pcursitem) { - CelBlitOutlineSafe(181, px, dy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth); - } - CelClippedDrawSafe(px, dy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth); - } - if (dFlags[sx][sy] & BFLAG_MONSTLR) { - mi = -(dMonster[sx][sy - 1] + 1); - px = dx - towner[mi]._tAnimWidth2; - if (mi == pcursmonst) { - CelBlitOutlineSafe(166, px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth); - } - CelClippedDrawSafe(px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth); - } - if (dMonster[sx][sy] > 0) { - mi = dMonster[sx][sy] - 1; - px = dx - towner[mi]._tAnimWidth2; - if (mi == pcursmonst) { - CelBlitOutlineSafe(166, px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth); - } - CelClippedDrawSafe(px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth); - } - if (dFlags[sx][sy] & BFLAG_PLAYERLR) { - bv = -(dPlayer[sx][sy - 1] + 1); - px = dx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; - py = dy + plr[bv]._pyoff; - if (bv == pcursplr) { - Cl2DrawOutlineSafe(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); - } - Cl2DrawSafe(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); - if (eflag && plr[bv]._peflag) { - town_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, dx - 64, dy); - } - } - if (dFlags[sx][sy] & BFLAG_DEAD_PLAYER) { - DrawDeadPlayer(sx, sy, dx, dy); - } - if (dPlayer[sx][sy] > 0) { - bv = dPlayer[sx][sy] - 1; - px = dx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; - py = dy + plr[bv]._pyoff; - if (bv == pcursplr) { - Cl2DrawOutlineSafe(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); - } - Cl2DrawSafe(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); - if (eflag && plr[bv]._peflag) { - town_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, dx - 64, dy); - } - } - if (dFlags[sx][sy] & BFLAG_MISSILE) { - DrawMissile(sx, sy, dx, dy, 0); - } - if (dArch[sx][sy] != 0) { - town_special_lower(&pBuff[PitchTbl[0]], dArch[sx][sy]); - } -} - -void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, int eflag) -{ - int i, j; - BYTE *dst; - MICROS *pMap; - - if (eflag) { - if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { - level_cel_block = dPiece[x][y]; - if (level_cel_block != 0) { - dst = &gpBuffer[sx - (BUFFER_WIDTH * 32 - 32) + PitchTbl[sy]]; - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - for (i = 0; i < 7; i++) { - if (skipChunks <= i) { - level_cel_block = pMap->mt[2 * i + 3]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - } - dst -= BUFFER_WIDTH * 32; - } - town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, skipChunks, sx, sy, 0); - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - x++; - y--; - sx += 64; - } - - for (j = 0; j < chunks - eflag; j++) { - if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { - level_cel_block = dPiece[x][y]; - if (level_cel_block != 0) { - dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]]; - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - for (i = 0; i < 7; i++) { - if (skipChunks <= i) { - level_cel_block = pMap->mt[2 * i + 2]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - level_cel_block = pMap->mt[2 * i + 3]; - if (level_cel_block != 0) { - drawLowerScreen(dst + 32); - } - } - dst -= BUFFER_WIDTH * 32; - } - town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, skipChunks, sx, sy, 1); - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - x++; - y--; - sx += 64; - } - - if (eflag) { - if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { - level_cel_block = dPiece[x][y]; - if (level_cel_block != 0) { - dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]]; - pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - for (i = 0; i < 7; i++) { - if (skipChunks <= i) { - level_cel_block = pMap->mt[2 * i + 2]; - if (level_cel_block != 0) { - drawLowerScreen(dst); - } - } - dst -= BUFFER_WIDTH * 32; - } - town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, skipChunks, sx, sy, 0); - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - } else { - town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); - } - } -} - +/** + * This function it self causes rendering issues since it will render some walls a secound time after all items have been drawn. + * + * @brief Avoid actors sticking threw the walls when walking east + */ void town_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int sx, int sy) { int i; @@ -500,10 +60,10 @@ void town_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int sx, int sy) dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(pBuff, x, y, capChunks, sx, sy, 0); + town_draw_town_all(pBuff, x, y, sx, sy, 0); } -void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int sx, int sy, int eflag) +void town_draw_town_all(BYTE *pBuff, int x, int y, int sx, int sy, int eflag) { int mi, px, py; char bv; @@ -545,7 +105,7 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int sx, int sy /// ASSERT: assert(plr[bv]._pAnimData); Cl2Draw(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); if (eflag && plr[bv]._peflag) { - town_draw_e_flag(pBuff - 64, x - 1, y + 1, capChunks, sx - 64, sy); + town_draw_e_flag(pBuff - 64, x - 1, y + 1, 8, sx - 64, sy); } } if (dFlags[x][y] & BFLAG_DEAD_PLAYER) { @@ -561,18 +121,18 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int sx, int sy /// ASSERT: assert(plr[bv]._pAnimData); Cl2Draw(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth); if (eflag && plr[bv]._peflag) { - town_draw_e_flag(pBuff - 64, x - 1, y + 1, capChunks, sx - 64, sy); + town_draw_e_flag(pBuff - 64, x - 1, y + 1, 8, sx - 64, sy); } } if (dFlags[x][y] & BFLAG_MISSILE) { DrawMissile(x, y, sx, sy, 0); } if (dArch[x][y] != 0) { - town_special_upper(pBuff, dArch[x][y]); + town_special(pBuff, dArch[x][y]); } } -void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag) +void town_draw(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag) { int i, j; BYTE *dst; @@ -587,20 +147,18 @@ void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, in dst = &gpBuffer[sx + 32 + PitchTbl[sy]]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (capChunks >= i) { - level_cel_block = pMap->mt[2 * i + 1]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } + level_cel_block = pMap->mt[2 * i + 1]; + if (level_cel_block != 0) { + drawUpperScreen(dst); } dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, sx, sy, 0); + town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 0); } else { - town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); + town_clear_buf(&gpBuffer[sx + PitchTbl[sy]]); } } else { - town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); + town_clear_buf(&gpBuffer[sx + PitchTbl[sy]]); } x++; y--; @@ -613,25 +171,23 @@ void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, in if (level_cel_block != 0) { dst = &gpBuffer[sx + PitchTbl[sy]]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - for (i = 0; i < 7; i++) { - if (capChunks >= i) { - level_cel_block = pMap->mt[2 * i]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } - level_cel_block = pMap->mt[2 * i + 1]; - if (level_cel_block != 0) { - drawUpperScreen(dst + 32); - } + for (i = 0; i < MicroTileLen >> 1; i++) { + level_cel_block = pMap->mt[2 * i]; + if (level_cel_block != 0) { + drawUpperScreen(dst); + } + level_cel_block = pMap->mt[2 * i + 1]; + if (level_cel_block != 0) { + drawUpperScreen(dst + 32); } dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, sx, sy, 1); + town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 1); } else { - town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); + town_clear_buf(&gpBuffer[sx + PitchTbl[sy]]); } } else { - town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); + town_clear_buf(&gpBuffer[sx + PitchTbl[sy]]); } x++; y--; @@ -645,20 +201,18 @@ void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, in dst = &gpBuffer[sx + PitchTbl[sy]]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (capChunks >= i) { - level_cel_block = pMap->mt[2 * i]; - if (level_cel_block != 0) { - drawUpperScreen(dst); - } + level_cel_block = pMap->mt[2 * i]; + if (level_cel_block != 0) { + drawUpperScreen(dst); } dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, sx, sy, 0); + town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, sx, sy, 0); } else { - town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); + town_clear_buf(&gpBuffer[sx + PitchTbl[sy]]); } } else { - town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); + town_clear_buf(&gpBuffer[sx + PitchTbl[sy]]); } } } @@ -669,15 +223,14 @@ void T_DrawGame(int x, int y) scr_pix_width = SCREEN_WIDTH; scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; sx = ScrollInfo._sxoff + 64; sy = ScrollInfo._syoff + 175; x -= 10; y--; chunks = 10; - blocks = 5; + // Fill screen, keep evaulating untill files can't affect screen + blocks = ceil(VIEWPORT_HEIGHT / 32) + ceil(MicroTileLen / 2); if (chrflag || questlog) { x += 2; @@ -740,36 +293,14 @@ void T_DrawGame(int x, int y) break; } - /// ASSERT: assert(gpBuffer); - gpBufEnd = &gpBuffer[PitchTbl[SCREEN_Y]]; - for (i = 0; i < 7; i++) { - town_draw_upper(x, y, sx, sy, chunks, i, 0); - y++; - sx -= 32; - sy += 16; - town_draw_upper(x, y, sx, sy, chunks, i, 1); - x++; - sx += 32; - sy += 16; - } /// ASSERT: assert(gpBuffer); gpBufEnd = &gpBuffer[PitchTbl[VIEWPORT_HEIGHT + SCREEN_Y]]; for (i = 0; i < blocks; i++) { - town_draw_lower(x, y, sx, sy, chunks, 0); - y++; - sx -= 32; - sy += 16; - town_draw_lower(x, y, sx, sy, chunks, 1); - x++; - sx += 32; - sy += 16; - } - for (i = 0; i < 7; i++) { - town_draw_lower_2(x, y, sx, sy, chunks, i, 0); + town_draw(x, y, sx, sy, chunks, i, 0); y++; sx -= 32; sy += 16; - town_draw_lower_2(x, y, sx, sy, chunks, i, 1); + town_draw(x, y, sx, sy, chunks, i, 1); x++; sx += 32; sy += 16; @@ -783,15 +314,14 @@ void T_DrawZoom(int x, int y) scr_pix_width = ZOOM_WIDTH; scr_pix_height = 192; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = 192 / 32; sx = ScrollInfo._sxoff + 64; sy = ScrollInfo._syoff + 143; x -= 6; y--; chunks = 6; - blocks = 0; + // Fill screen, keep evaulating untill files can't affect screen + blocks = ceil(VIEWPORT_HEIGHT / 2 / 32) + ceil(MicroTileLen / 2); switch (ScrollInfo._sdir) { case SDIR_NONE: @@ -841,36 +371,14 @@ void T_DrawZoom(int x, int y) break; } - /// ASSERT: assert(gpBuffer); - gpBufEnd = &gpBuffer[PitchTbl[-17 + SCREEN_Y]]; - for (i = 0; i < 7; i++) { - town_draw_upper(x, y, sx, sy, chunks, i, 0); - y++; - sx -= 32; - sy += 16; - town_draw_upper(x, y, sx, sy, chunks, i, 1); - x++; - sx += 32; - sy += 16; - } /// ASSERT: assert(gpBuffer); gpBufEnd = &gpBuffer[PitchTbl[160 + SCREEN_Y]]; for (i = 0; i < blocks; i++) { - town_draw_lower(x, y, sx, sy, chunks, 0); + town_draw(x, y, sx, sy, chunks, i, 0); y++; sx -= 32; sy += 16; - town_draw_lower(x, y, sx, sy, chunks, 1); - x++; - sx += 32; - sy += 16; - } - for (i = 0; i < 7; i++) { - town_draw_lower_2(x, y, sx, sy, chunks, i, 0); - y++; - sx -= 32; - sy += 16; - town_draw_lower_2(x, y, sx, sy, chunks, i, 1); + town_draw(x, y, sx, sy, chunks, i, 1); x++; sx += 32; sy += 16; @@ -975,6 +483,8 @@ void SetTownMicros() WORD *pPiece; MICROS *pMap; + MicroTileLen = 16; + for (y = 0; y < MAXDUNY; y++) { for (x = 0; x < MAXDUNX; x++) { lv = dPiece[x][y]; @@ -996,13 +506,9 @@ void SetTownMicros() if (zoomflag) { scr_pix_width = SCREEN_WIDTH; scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; } else { scr_pix_width = ZOOM_WIDTH; scr_pix_height = ZOOM_HEIGHT; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = ZOOM_HEIGHT / 32; } } diff --git a/Source/town.h b/Source/town.h index 44c80d1e5..d8a9e84dc 100644 --- a/Source/town.h +++ b/Source/town.h @@ -2,19 +2,11 @@ #ifndef __TOWN_H__ #define __TOWN_H__ -void town_clear_upper_buf(BYTE *pBuff); -void town_clear_low_buf(BYTE *pBuff); -void town_special_lower(BYTE *pBuff, int nCel); -void town_special_upper(BYTE *pBuff, int nCel); -void town_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy); -void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag); -void town_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag); +void town_clear_buf(BYTE *pBuff); void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int sx, int sy); -void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int skipChunks, int dx, int dy, int eflag); -void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, int eflag); void town_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int sx, int sy); -void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int sx, int sy, int eflag); -void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag); +void town_draw_town_all(BYTE *pBuff, int x, int y, int sx, int sy, int eflag); +void town_draw(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag); void T_DrawGame(int x, int y); void T_DrawZoom(int x, int y); void T_DrawView(int StartX, int StartY);