Browse Source

Unify upper and lower screen rendering

pull/380/head
Anders Jenbo 7 years ago
parent
commit
9e1b161bc0
  1. 508
      Source/engine.cpp
  2. 11
      Source/engine.h
  3. 1004
      Source/scrollrt.cpp
  4. 592
      Source/town.cpp
  5. 14
      Source/town.h

508
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;

11
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 */

1004
Source/scrollrt.cpp

File diff suppressed because it is too large Load Diff

592
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;
}
}

14
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);

Loading…
Cancel
Save