From 2348c3a8fdff09f407323189d5e5d45dfc657cc1 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 21 Oct 2019 00:51:47 +0200 Subject: [PATCH] Documentations, enums and clean ups --- Source/control.cpp | 10 +- Source/cursor.cpp | 2 +- Source/diablo.cpp | 3 + Source/drlg_l1.cpp | 4 +- Source/drlg_l2.cpp | 4 +- Source/drlg_l3.cpp | 4 +- Source/drlg_l4.cpp | 4 +- Source/gmenu.cpp | 2 +- Source/inv.cpp | 13 +- Source/minitext.cpp | 5 +- Source/quests.cpp | 2 +- Source/render.cpp | 4 + Source/scrollrt.cpp | 335 +++++++++++++++++++++++++++++++++++++------- Source/scrollrt.h | 6 +- Source/stores.cpp | 2 +- Source/town.cpp | 217 +++++++++++++++++++++++----- Source/town.h | 12 +- 17 files changed, 521 insertions(+), 108 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index b163d31db..6ccc3929a 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -18,7 +18,7 @@ BOOL drawmanaflag; BOOL chrbtnactive; char sgszTalkMsg[MAX_SEND_STR_LEN]; BYTE *pPanelText; -int nGoldFrame; +int nGoldFrame; /** current frame # for the pentagram caret in gold input */ BYTE *pLifeBuff; BYTE *pBtmBuff; BYTE *pTalkBtns; @@ -36,7 +36,7 @@ char tempstr[256]; BOOLEAN whisper[MAX_PLRS]; int sbooktab; int pSplType; -int frame; +int frame; /** current frame # for the pentagram caret in chat input */ int initialDropGoldIndex; BOOL talkflag; BYTE *pSBkIconCels; @@ -947,6 +947,9 @@ void DrawPanelBox(int x, int y, int w, int h, int sx, int sy) #endif } +/** + * Draws parts of the flasks that are on the panel + */ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r) { int nSrcOff, nDstOff, w; @@ -982,6 +985,9 @@ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r) #endif } +/** + * Draws parts of the flasks that are above the panel + */ void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int h) { #ifdef USE_ASM diff --git a/Source/cursor.cpp b/Source/cursor.cpp index d04284aac..adc9075e7 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -226,7 +226,7 @@ void CheckCursMove() mx = ViewX + tx + ty - (zoomflag ? 10 : 5); my = ViewY + ty - tx; - flipy = py> 1; + flipy = py < (px >> 1); if (flipy) { my--; } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 25e5a6b28..010a976e7 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1538,6 +1538,9 @@ void LoadAllGFX() IncProgress(); } +/** + * @param lvldir method of entry + */ void CreateLevel(int lvldir) { switch (leveltype) { diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index ad87c7f06..d8150f5d6 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -419,7 +419,7 @@ static void DRLG_L1Pass3() mov v4, eax } #else - v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; + v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; @@ -462,7 +462,7 @@ static void DRLG_L1Pass3() mov v4, eax } #else - v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; + v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 4dc79a77d..137132e6c 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -446,7 +446,7 @@ void DRLG_L2Pass3() mov v4, eax } #else - v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; + v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; @@ -488,7 +488,7 @@ void DRLG_L2Pass3() mov v4, eax } #else - v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; + v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index ab7e8647c..b88161c24 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1633,7 +1633,7 @@ static void DRLG_L3Pass3() mov v4, eax } #else - v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; + v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; @@ -1683,7 +1683,7 @@ static void DRLG_L3Pass3() } #else if (lv >= 0) { - v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; + v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 68a91dcfc..d41eeaf4f 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1902,7 +1902,7 @@ static void DRLG_L4Pass3() mov v4, eax } #else - v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; + v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; @@ -1952,7 +1952,7 @@ static void DRLG_L4Pass3() } #else if (lv >= 0) { - v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; + v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 39e28b331..b3f92f09b 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -163,7 +163,7 @@ void gmenu_draw() } ticks = GetTickCount(); - if ((int)(ticks - PentSpin_tick) > 25) { + if ((int)(ticks - PentSpin_tick) > 25) { // BUGFIX: thould be 50ms PentSpin_frame++; if (PentSpin_frame == 9) PentSpin_frame = 1; diff --git a/Source/inv.cpp b/Source/inv.cpp index f44644669..4928b7b82 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -426,7 +426,7 @@ void DrawInvBelt() continue; } - InvDrawSlotBack(InvRect[i + SLOTXY_BELT_FIRST].X + 64, InvRect[i + SLOTXY_BELT_FIRST].Y + 159, 28, 28); + InvDrawSlotBack(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, 28, 28); frame = plr[myplr].SpdList[i]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -436,20 +436,20 @@ void DrawInvBelt() colour = ICOL_BLUE; if (!plr[myplr].SpdList[i]._iStatFlag) colour = ICOL_RED; - CelBlitOutline(colour, InvRect[i + SLOTXY_BELT_FIRST].X + 64, InvRect[i + SLOTXY_BELT_FIRST].Y + 159, pCursCels, frame, frame_width, 0, 8); + CelBlitOutline(colour, InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].SpdList[i]._iStatFlag) - CelClippedDraw(InvRect[i + SLOTXY_BELT_FIRST].X + 64, InvRect[i + SLOTXY_BELT_FIRST].Y + 159, pCursCels, frame, frame_width, 0, 8); + CelClippedDraw(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, pCursCels, frame, frame_width, 0, 8); else - CelDrawLightRed(InvRect[i + SLOTXY_BELT_FIRST].X + 64, InvRect[i + SLOTXY_BELT_FIRST].Y + 159, pCursCels, frame, frame_width, 0, 8, 1); + CelDrawLightRed(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, pCursCels, frame, frame_width, 0, 8, 1); if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable && plr[myplr].SpdList[i]._iStatFlag && plr[myplr].SpdList[i]._itype != ITYPE_GOLD) { fi = i + 49; ff = fontframe[gbFontTransTbl[fi]]; - CPrintString(InvRect[i + SLOTXY_BELT_FIRST].X + 64 + PitchTbl[InvRect[i + SLOTXY_BELT_FIRST].Y + 159] - fontkern[ff] + 28, ff, 0); + CPrintString(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X + PitchTbl[InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1] - fontkern[ff] + 28, ff, 0); } } } @@ -1354,6 +1354,9 @@ void CheckInvItem() } } +/** + * Check for interactions with belt + */ void CheckInvScrn() { if (MouseX > 190 && MouseX < 437 diff --git a/Source/minitext.cpp b/Source/minitext.cpp index 194db7ec1..e7adc0f5e 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -35,6 +35,9 @@ const BYTE mfontkern[56] = { /* data */ +/** + * Positive numbers will delay scrolling 1 out of n frames, negative numbers will scroll 1+(-n) pixels. + */ int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 }; void FreeQuestText() @@ -57,7 +60,7 @@ void InitQTextMsg(int m) qtextptr = alltext[m].txtstr; qtextflag = TRUE; qtexty = 500; - sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1]; /* double check offset */ + sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1]; scrolltexty = sgLastScroll; qtextSpd = GetTickCount(); } diff --git a/Source/quests.cpp b/Source/quests.cpp index ca0ec2249..bc83ade9b 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -11,7 +11,7 @@ int WaterDone; int ReturnLvlY; int ReturnLvlX; int ReturnLvlT; -int ALLQUESTS; +int ALLQUESTS; /** current frame # for the pentagram selector */ int ReturnLvl; QuestData questlist[MAXQUESTS] = { diff --git a/Source/render.cpp b/Source/render.cpp index fae2d3138..bf740a637 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -5191,6 +5191,10 @@ void drawLowerScreen(BYTE *pBuff) } } +/** + * @brief Render a black tile + * @param pBuff pointer where to render the tile + */ void world_draw_black_tile(BYTE *pBuff) { BYTE *dst; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 1b331dfe5..63078c524 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -66,6 +66,9 @@ void ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp sgdwCursWdtOld = 0; } +/** + * @brief Remove the cursor from the backbuffer + */ static void scrollrt_draw_cursor_back_buffer() { int i; @@ -90,6 +93,9 @@ static void scrollrt_draw_cursor_back_buffer() sgdwCursWdt = 0; } +/** + * @brief Draw the cursor on the backbuffer + */ static void scrollrt_draw_cursor_item() { int i, mx, my, col; @@ -164,6 +170,16 @@ static void scrollrt_draw_cursor_item() } } +/** + * @brief Render a missile sprite + * @param x dPice coordinate + * @param y dPice coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param CelSkip Skip part of sprite, see Cl2Draw + * @param CelCap Skip part of sprite, see Cl2Draw + * @param pre Is the sprite in the background + */ void DrawMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL pre) { int i, mx, my, nCel; @@ -225,6 +241,16 @@ void DrawMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL pre } } +/** + * @brief Render a missile sprite, check for overdraw on lower screen + * @param x dPice coordinate + * @param y dPice coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param CelSkip Skip part of sprite, see Cl2Draw + * @param CelCap Skip part of sprite, see Cl2Draw + * @param pre Is the sprite in the background + */ void DrawClippedMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL pre) { int i, mx, my, nCel; @@ -286,6 +312,15 @@ void DrawClippedMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, B } } +/** + * @brief Render a monster sprite + * @param x dPice coordinate + * @param y dPice coordinate + * @param mx Backbuffer coordinate + * @param my Backbuffer coordinate + * @param CelSkip Skip part of sprite, see Cl2Draw + * @param CelCap Skip part of sprite, see Cl2Draw + */ static void DrawMonster(int x, int y, int mx, int my, int m, int CelSkip, int CelCap) { int nCel; @@ -339,6 +374,15 @@ static void DrawMonster(int x, int y, int mx, int my, int m, int CelSkip, int Ce } } +/** + * @brief Render a monster sprite, check for overdraw on lower screen + * @param x dPice coordinate + * @param y dPice coordinate + * @param mx Backbuffer coordinate + * @param my Backbuffer coordinate + * @param CelSkip Skip part of sprite, see Cl2Draw + * @param CelCap Skip part of sprite, see Cl2Draw + */ static void DrawClippedMonster(int x, int y, int mx, int my, int m, int CelSkip, int CelCap) { int nCel; @@ -392,6 +436,19 @@ static void DrawClippedMonster(int x, int y, int mx, int my, int m, int CelSkip, } } +/** + * @brief Render a monster sprite + * @param pnum Player id + * @param x dPice coordinate + * @param y dPice coordinate + * @param px Backbuffer coordinate + * @param py Backbuffer coordinate + * @param pCelBuff sprite buffer + * @param nCel frame + * @param nWidth width + * @param CelSkip Skip part of sprite, see Cl2Draw + * @param CelCap Skip part of sprite, see Cl2Draw + */ static void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { int l; @@ -465,6 +522,19 @@ static void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i } } +/** + * @brief Render a monster sprite, check for overdraw on lower screen + * @param pnum Player id + * @param x dPice coordinate + * @param y dPice coordinate + * @param px Backbuffer coordinate + * @param py Backbuffer coordinate + * @param pCelBuff sprite buffer + * @param nCel frame + * @param nWidth width + * @param CelSkip Skip part of sprite, see Cl2Draw + * @param CelCap Skip part of sprite, see Cl2Draw + */ static void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { int l; @@ -538,6 +608,16 @@ static void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCel } } +/** + * @brief Render a monster sprite + * @param x dPice coordinate + * @param y dPice coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param CelSkip Skip part of sprite, see Cl2Draw + * @param CelCap Skip part of sprite, see Cl2Draw + * @param clipped check for overdraw on lower screen + */ void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL clipped) { int i, px, py, nCel; @@ -574,6 +654,16 @@ void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL } } +/** + * @brief Render an object sprite + * @param x dPice coordinate + * @param y dPice coordinate + * @param ox Backbuffer coordinate + * @param oy Backbuffer coordinate + * @param pre Is the sprite in the background + * @param CelSkip Skip part of sprite, see Cl2Draw + * @param CelCap Skip part of sprite, see Cl2Draw + */ static void DrawObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int CelCap) { int sx, sy, xx, yy, nCel; @@ -627,6 +717,16 @@ static void DrawObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int } } +/** + * @brief Render an object sprite, check for overdraw on lower screen + * @param x dPice coordinate + * @param y dPice coordinate + * @param ox Backbuffer coordinate + * @param oy Backbuffer coordinate + * @param pre Is the sprite in the background + * @param CelSkip Skip part of sprite, see Cl2Draw + * @param CelCap Skip part of sprite, see Cl2Draw + */ static void DrawClippedObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int CelCap) { int sx, sy, xx, yy, nCel; @@ -679,6 +779,16 @@ static void DrawClippedObject(int x, int y, int ox, int oy, BOOL pre, int CelSki static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag); +/** + * This variant checks for of screen element on the lower screen + * This function it self causes rendering issues since it will render on top of objects on the other side of walls + * @brief Re render tile to workaround sorting issues with players walking east/west + * @param pBuff Pointer to output buffer at location sx,sy + * @param y dPiece coordinate + * @param x dPiece coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + */ 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; @@ -727,6 +837,15 @@ static void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int level_piece_id = lpi_old; } +/** + * @brief Render object sprites + * @param pBuff where to render to with sx,sy already applied + * @param sx dPice coordinate + * @param sy dPice coordinate + * @param dx Backbuffer coordinate + * @param dy Backbuffer coordinate + * @param eflag Should the sorting workaround be applied + */ 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; @@ -941,6 +1060,15 @@ static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, i } } +/** + * @brief Render a row of tile + * @param x dPice coordinate + * @param y dPice coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param chunks tile width of row + * @param eflag is it an even (0) or odd (1) row + */ static void scrollrt_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag) { int i, j; @@ -1089,9 +1217,21 @@ static void scrollrt_draw_lower(int x, int y, int sx, int sy, int chunks, int ef } } -static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks, int CelSkip, int dx, int dy, int eflag); - -static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int CelSkip, int sx, int sy) +static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row, int CelSkip, int dx, int dy, int eflag); + +/** + * This variant checks for of screen element on the lower screen + * This function it self causes rendering issues since it will render on top of objects on the other side of walls + * @brief Re render tile to workaround sorting issues with players walking east/west + * @param pBuff Pointer to output buffer at location sx,sy + * @param y dPiece coordinate + * @param x dPiece coordinate + * @param row The current row being rendered + * @param CelSkip chunks of cell to skip + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + */ +static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int row, int CelSkip, int sx, int sy) { int lti_old, cta_old, lpi_old; BYTE *dst; @@ -1103,11 +1243,11 @@ static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipCh level_piece_id = dPiece[x][y]; light_table_index = dLight[x][y]; - dst = &pBuff[BUFFER_WIDTH * 32 * skipChunks]; + dst = &pBuff[BUFFER_WIDTH * 32 * row]; cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - switch (skipChunks) { + switch (row) { case 0: level_cel_block = pMap->mt[2]; if (level_cel_block != 0) { @@ -1151,7 +1291,7 @@ static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipCh } if (CelSkip < 8) { - scrollrt_draw_clipped_dungeon_2(pBuff, x, y, skipChunks, CelSkip, sx, sy, 0); + scrollrt_draw_clipped_dungeon_2(pBuff, x, y, row, CelSkip, sx, sy, 0); } light_table_index = lti_old; @@ -1159,7 +1299,19 @@ static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipCh level_piece_id = lpi_old; } -static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks, int CelSkip, int dx, int dy, int eflag) +/** + * This variant checks for of screen element on the lower screen + * @brief Render object sprites, skip offscreen parts for lower screen + * @param pBuff where to render to with sx,sy already applied + * @param sx dPice coordinate + * @param sy dPice coordinate + * @param row The current row being rendered + * @param CelSkip chunks of cell to skip + * @param dx Backbuffer coordinate + * @param dy Backbuffer coordinate + * @param eflag Should the sorting workaround be applied + */ +static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row, int CelSkip, int dx, int dy, int eflag) { int px, py, nCel, nMon, negMon, p; char bFlag, bDead, bObj, bItem, bPlr, bArch, bMap, negPlr, dd; @@ -1256,9 +1408,9 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int ski DrawClippedPlayer(p, sx, sy - 1, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth, CelSkip, 8); 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, CelSkip, dx - 96, dy - 16); + scrollrt_draw_clipped_e_flag_2(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, row, CelSkip, dx - 96, dy - 16); } - scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, CelSkip, dx - 64, dy); + scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, row, CelSkip, dx - 64, dy); } } else { // app_fatal("draw player clipped: tried to draw illegal player %d", p); @@ -1277,7 +1429,7 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int ski } DrawClippedMonster(sx, sy, px, py, draw_monster_num, CelSkip, 8); if (eflag && !pMonster->_meflag) { - scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, CelSkip, dx - 64, dy); + scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, row, CelSkip, dx - 64, dy); } } else { // app_fatal("Draw Monster \"%s\" Clipped: uninitialized monster", pMonster->mName); @@ -1299,9 +1451,9 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int ski DrawClippedPlayer(p, sx, sy, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth, CelSkip, 8); 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, CelSkip, dx - 96, dy - 16); + scrollrt_draw_clipped_e_flag_2(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, row, CelSkip, dx - 96, dy - 16); } - scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, CelSkip, dx - 64, dy); + scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, row, CelSkip, dx - 64, dy); } } else { // app_fatal("draw player clipped: tried to draw illegal player %d", p); @@ -1320,7 +1472,7 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int ski } DrawClippedMonster(sx, sy, px, py, draw_monster_num, CelSkip, 8); if (eflag && !pMonster->_meflag) { - scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, CelSkip, dx - 64, dy); + scrollrt_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, row, CelSkip, dx - 64, dy); } } else { // app_fatal("Draw Monster \"%s\" Clipped: uninitialized monster", pMonster->mName); @@ -1373,7 +1525,17 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int ski } } -static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, int eflag) +/** + * @brief Render a row of tile, checking for overdrawing on lower part of screen + * @param x dPice coordinate + * @param y dPice coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param chunks tile width of row + * @param row current row being rendered + * @param eflag is it an even (0) or odd (1) row + */ +static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int row, int eflag) { int i, j, CelSkip; BYTE *dst; @@ -1382,7 +1544,7 @@ static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int /// ASSERT: assert(gpBuffer); pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - CelSkip = 2 * skipChunks + 2; + CelSkip = 2 * row + 2; if (eflag) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { @@ -1392,7 +1554,7 @@ static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int 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) { + if (row <= i) { level_cel_block = pMap->mt[2 * i + 3]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -1401,7 +1563,7 @@ static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int dst -= BUFFER_WIDTH * 32; } if (CelSkip < 8) { - scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * CelSkip], x, y, skipChunks, CelSkip, sx, sy, 0); + scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * CelSkip], x, y, row, CelSkip, sx, sy, 0); } } } @@ -1425,7 +1587,7 @@ static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); i = 0; while (i < (MicroTileLen >> 1) - 1) { - if (skipChunks <= i) { + if (row <= i) { level_cel_block = pMap->mt[2 * i + 2]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -1439,7 +1601,7 @@ static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int dst -= BUFFER_WIDTH * 32; } if (CelSkip < 8) { - scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 32 * (skipChunks + 1)], x, y, skipChunks, CelSkip, sx, sy, 1); + scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 32 * (row + 1)], x, y, row, CelSkip, sx, sy, 1); } } } @@ -1457,7 +1619,7 @@ static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int 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) { + if (row <= i) { level_cel_block = pMap->mt[2 * i + 2]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -1466,16 +1628,28 @@ static void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int dst -= BUFFER_WIDTH * 32; } if (CelSkip < 8) { - scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * CelSkip], x, y, skipChunks, CelSkip, sx, sy, 0); + scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * CelSkip], x, y, row, CelSkip, sx, sy, 0); } } } } } -static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, int CelCap, int dx, int dy, int eflag); - -static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int CelCap, int sx, int sy) +static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelCap, int dx, int dy, int eflag); + +/** + * This variant checks for of screen element on the upper screen + * This function it self causes rendering issues since it will render on top of objects on the other side of walls + * @brief Re render tile to workaround sorting issues with players walking east/west + * @param pBuff Pointer to output buffer at location sx,sy + * @param y dPiece coordinate + * @param x dPiece coordinate + * @param row The current row being rendered + * @param CelCap chunks of cell to skip + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + */ +static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int row, int CelCap, int sx, int sy) { int i, lti_old, cta_old, lpi_old; BYTE *dst; @@ -1505,7 +1679,7 @@ static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int C arch_draw_type = 0; for (i = 1; i < (MicroTileLen >> 1) - 1; i++) { dst -= BUFFER_WIDTH * 32; - if (capChunks >= i) { + if (row >= i) { level_cel_block = pMap->mt[2 * i]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -1517,14 +1691,25 @@ static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int C } } - scrollrt_draw_dungeon(pBuff, x, y, capChunks, CelCap, sx, sy, 0); + scrollrt_draw_dungeon(pBuff, x, y, row, CelCap, 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 CelCap, int dx, int dy, int eflag) +/** + * @brief Render object sprites, skip offscreen parts for upper screen + * @param pBuff where to render to with sx,sx already applied + * @param sx dPice coordinate + * @param sy dPice coordinate + * @param row The current row being rendered + * @param CelCap chunks of cell to skip + * @param dx Backbuffer coordinate + * @param dy Backbuffer coordinate + * @param eflag Should the sorting workaround be applied + */ +static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelCap, int dx, int dy, int eflag) { int px, py, nCel, nMon, negMon, p, tx, ty; char bFlag, bDead, bObj, bItem, bPlr, bArch, bMap, negPlr, dd; @@ -1618,9 +1803,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, 0, CelCap); if (eflag && pPlayer->_peflag != 0) { if (pPlayer->_peflag == 2) { - scrollrt_draw_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, capChunks, CelCap, tx, ty); + scrollrt_draw_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, row, CelCap, tx, ty); } - scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, capChunks, CelCap, dx - 64, dy); + scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, row, CelCap, dx - 64, dy); } } else { // app_fatal("draw player: tried to draw illegal player %d", p); @@ -1639,7 +1824,7 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, in } DrawMonster(sx, sy, px, py, draw_monster_num, 0, CelCap); if (eflag && !pMonster->_meflag) { - scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, capChunks, CelCap, dx - 64, dy); + scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, row, CelCap, dx - 64, dy); } } else { // app_fatal("Draw Monster \"%s\": uninitialized monster", pMonster->mName); @@ -1661,9 +1846,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, 0, CelCap); if (eflag && pPlayer->_peflag != 0) { if (pPlayer->_peflag == 2) { - scrollrt_draw_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, capChunks, CelCap, dx - 96, dy - 16); + scrollrt_draw_e_flag(pBuff - (BUFFER_WIDTH * 16 + 96), sx - 2, sy + 1, row, CelCap, dx - 96, dy - 16); } - scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, capChunks, CelCap, dx - 64, dy); + scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, row, CelCap, dx - 64, dy); } } else { // app_fatal("draw player: tried to draw illegal player %d", p); @@ -1682,7 +1867,7 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, in } DrawMonster(sx, sy, px, py, draw_monster_num, 0, CelCap); if (eflag && !pMonster->_meflag) { - scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, capChunks, CelCap, dx - 64, dy); + scrollrt_draw_e_flag(pBuff - 64, sx - 1, sy + 1, row, CelCap, dx - 64, dy); } } else { // app_fatal("Draw Monster \"%s\": uninitialized monster", pMonster->mName); @@ -1728,7 +1913,17 @@ 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) +/** + * @brief Render a row of tile, checking for overdrawing on upper part of screen + * @param x dPice coordinate + * @param y dPice coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param chunks tile width of row + * @param row current row being rendered + * @param eflag is it an even (0) or odd (1) row + */ +static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int row, int eflag) { int i, j, CelCap; BYTE *dst; @@ -1737,7 +1932,7 @@ static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int ca /// ASSERT: assert(gpBuffer); pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; - CelCap = 2 * capChunks + 2; + CelCap = 2 * row + 2; if (CelCap > 8) { CelCap = 8; } @@ -1749,7 +1944,7 @@ 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) { + if (row >= 0) { level_cel_block = pMap->mt[1]; if (level_cel_block != 0) { arch_draw_type = 2; @@ -1758,27 +1953,27 @@ static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int ca } } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 1) { + if (row >= 1) { level_cel_block = pMap->mt[3]; if (level_cel_block != 0) { drawUpperScreen(dst); } } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 2) { + if (row >= 2) { level_cel_block = pMap->mt[5]; if (level_cel_block != 0) { drawUpperScreen(dst); } } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 3) { + if (row >= 3) { level_cel_block = pMap->mt[7]; if (level_cel_block != 0) { drawUpperScreen(dst); } } - scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 0); + scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, row, CelCap, sx, sy, 0); } else { world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } @@ -1810,7 +2005,7 @@ 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) { + if (row >= i) { level_cel_block = pMap->mt[2 * i]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -1821,7 +2016,7 @@ static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int ca } } } - scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 1); + scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, row, CelCap, sx, sy, 1); } else { world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } @@ -1840,7 +2035,7 @@ 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) { + if (row >= 0) { level_cel_block = pMap->mt[0]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -1848,27 +2043,27 @@ static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int ca } arch_draw_type = 0; dst -= BUFFER_WIDTH * 32; - if (capChunks >= 1) { + if (row >= 1) { level_cel_block = pMap->mt[2]; if (level_cel_block != 0) { drawUpperScreen(dst); } } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 2) { + if (row >= 2) { level_cel_block = pMap->mt[4]; if (level_cel_block != 0) { drawUpperScreen(dst); } } dst -= BUFFER_WIDTH * 32; - if (capChunks >= 3) { + if (row >= 3) { level_cel_block = pMap->mt[6]; if (level_cel_block != 0) { drawUpperScreen(dst); } } - scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 0); + scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, row, CelCap, sx, sy, 0); } else { world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } @@ -1876,6 +2071,11 @@ static void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int ca } } +/** + * @brief Configure render and process screen rows + * @param x Center of view in dPice coordinate + * @param y Center of view in dPice coordinate + */ static void DrawGame(int x, int y) { int i, sx, sy, chunks, blocks; @@ -1978,6 +2178,11 @@ static void DrawGame(int x, int y) } } +/** + * @brief Configure render for zoomed view and process screen rows + * @param x Center of view in dPice coordinate + * @param y Center of view in dPice coordinate + */ static void DrawZoom(int x, int y) { int i, sx, sy, chunks, blocks; @@ -2135,6 +2340,11 @@ static void DrawZoom(int x, int y) #endif } +/** + * @brief Start rendering of screen, town variation + * @param StartX Center of view in dPice coordinate + * @param StartY Center of view in dPice coordinate + */ void DrawView(int StartX, int StartY) { if (zoomflag) { @@ -2192,6 +2402,9 @@ void DrawView(int StartX, int StartY) DrawManaFlask(); } +/** + * @brief Render the whole screen black + */ void ClearScreenBuffer() { lock_buf(3); @@ -2226,6 +2439,9 @@ void ClearScreenBuffer() } #ifdef _DEBUG +/** + * @brief Scroll the screen when mouse is close to the edge + */ void ScrollView() { BOOL scroll; @@ -2304,12 +2520,18 @@ void ScrollView() ScrollInfo._sdir = SDIR_NONE; } +/** + * @brief Initialize the FPS meter + */ void EnableFrameCount() { frameflag = frameflag == 0; framestart = GetTickCount(); } +/** + * @brief Display the current average FPS over 1 sec + */ static void DrawFPS() { DWORD tc, frames; @@ -2343,6 +2565,13 @@ static void DrawFPS() } #endif +/** + * @brief Update part of the screen from the backbuffer + * @param dwX Backbuffer coordinate + * @param dwY Backbuffer coordinate + * @param dwWdt Backbuffer coordinate + * @param dwHgt Backbuffer coordinate + */ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt) { int nSrcOff, nDstOff, nSrcWdt, nDstWdt; @@ -2440,6 +2669,15 @@ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt) } } +/** + * @brief Check render pipline and blit indivudal screen parts + * @param dwHgt Section of screen to update from top to bottom + * @param draw_desc Render info box + * @param draw_hp Render halth bar + * @param draw_mana Render mana bar + * @param draw_sbar Render belt + * @param draw_btn Render panel buttons + */ static void DrawMain(int dwHgt, BOOL draw_desc, BOOL draw_hp, BOOL draw_mana, BOOL draw_sbar, BOOL draw_btn) { int ysize; @@ -2585,6 +2823,9 @@ void scrollrt_draw_game_screen(BOOL draw_cursor) } } +/** + * @brief Render the game + */ void DrawAndBlit() { int hgt; diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 4b334c622..56d69dfa2 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -14,9 +14,9 @@ extern void (*DrawPlrProc)(int, int, int, int, int, BYTE *, int, int, int, int); extern int draw_monster_num; void ClearCursor(); -void DrawMissile(int x, int y, int sx, int sy, int CelSkip, int capChunks, BOOL pre); -void DrawClippedMissile(int x, int y, int sx, int sy, int CelSkip, int capChunks, BOOL pre); -void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int capChunks, BOOL clipped); +void DrawMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL pre); +void DrawClippedMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL pre); +void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL clipped); void DrawView(int StartX, int StartY); void ClearScreenBuffer(); #ifdef _DEBUG diff --git a/Source/stores.cpp b/Source/stores.cpp index 3e7a9b6f3..686b4ce0e 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -12,7 +12,7 @@ int talker; STextStruct stext[24]; char stextsize; int stextsmax; -int InStoreFlag; +int InStoreFlag; /** current frame # for the pentagram selector */ ItemStruct storehold[48]; int gossipstart; ItemStruct witchitem[20]; diff --git a/Source/town.cpp b/Source/town.cpp index 5c6d9b5c9..8fc5cb538 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1,5 +1,10 @@ #include "diablo.h" +/** + * Used under building to avoid HOM and outside of level + * @brief world_draw_black_tile but limited to upper half of screen + * @param pBuff location in back buffer to render the tile, must be on upper half of screen + */ void town_clear_upper_buf(BYTE *pBuff) { /// ASSERT: assert(gpBuffer); @@ -62,6 +67,11 @@ void town_clear_upper_buf(BYTE *pBuff) #endif } +/** + * Used under building to avoid HOM and outside of level + * @brief world_draw_black_tile but limited to lower half of screen + * @param pBuff location in back buffer to render the tile, must be on lower half of screen + */ void town_clear_low_buf(BYTE *pBuff) { /// ASSERT: assert(gpBuffer); @@ -138,6 +148,11 @@ void town_clear_low_buf(BYTE *pBuff) #endif } +/** + * @brief Render trees on top of player, buggy disabled in 1.09 + * @param pBuff backbuffer pointing where to render on lower part of screen + * @param nCel Frame number for pSpecialCels tile to draw + */ void town_special_lower(BYTE *pBuff, int nCel) { #if 0 @@ -252,6 +267,11 @@ void town_special_lower(BYTE *pBuff, int nCel) #endif } +/** + * @brief Render trees on top of player, buggy disabled in 1.09 + * @param pBuff backbuffer pointing where to render on upper part of screen + * @param nCel Frame number for pSpecialCels tile to draw + */ void town_special_upper(BYTE *pBuff, int nCel) { #if 0 @@ -362,6 +382,16 @@ void town_special_upper(BYTE *pBuff, int nCel) #endif } +/** + * This variant checks for of screen element on the lower screen + * This function it self causes rendering issues since it will render on top of objects on the other side of walls + * @brief Re render tile to workaround sorting issues with players walking east/west + * @param pBuff Pointer to output buffer at location sx,sy + * @param y dPiece coordinate + * @param x dPiece coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + */ void town_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy) { int i; @@ -386,6 +416,15 @@ void town_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy) town_draw_clipped_town(pBuff, x, y, sx, sy, 0); } +/** + * @brief Render object sprites + * @param pBuff where to render to with sx,sy already applied + * @param sx dPice coordinate + * @param sy dPice coordinate + * @param dx Backbuffer coordinate + * @param dy Backbuffer coordinate + * @param eflag Should the sorting workaround be applied + */ void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag) { int mi, px, py; @@ -454,6 +493,15 @@ void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int efl } } +/** + * @brief Render a row of tile + * @param x dPice coordinate + * @param y dPice coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param chunks tile width of row + * @param eflag is it an even (0) or odd (1) row + */ void town_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag) { int i, j; @@ -539,22 +587,34 @@ void town_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag) } } -void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int CelSkip, int sx, int sy) +/** + * This variant checks for of screen element on the lower screen + * This function it self causes rendering issues since it will render on top of objects on the other side of walls + * @brief Re render tile to workaround sorting issues with players walking east/west + * @param pBuff Pointer to output buffer at location sx,sy + * @param y dPiece coordinate + * @param x dPiece coordinate + * @param row The current row being rendered + * @param CelSkip chunks of cell to skip + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + */ +void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int row, int CelSkip, int sx, int sy) { int i; BYTE *dst; MICROS *pMap; - if (skipChunks == 0) { + if (row == 0) { dst = pBuff; } else { - dst = &pBuff[BUFFER_WIDTH * 32 * skipChunks]; + dst = &pBuff[BUFFER_WIDTH * 32 * row]; } pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 6; i++) { - if (skipChunks <= i) { + if (row <= i) { level_cel_block = pMap->mt[2 * i + 2]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -568,11 +628,22 @@ void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int C } if (CelSkip < 8) { - town_draw_clipped_town_2(pBuff, x, y, skipChunks, CelSkip, sx, sy, 0); + town_draw_clipped_town_2(pBuff, x, y, row, CelSkip, sx, sy, 0); } } -void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int skipChunks, int CelSkip, int dx, int dy, int eflag) +/** + * @brief Render object sprites, skip offscreen parts for lower screen + * @param pBuff where to render to with sx,sy already applied + * @param sx dPice coordinate + * @param sy dPice coordinate + * @param row The current row being rendered + * @param CelSkip chunks of cell to skip + * @param dx Backbuffer coordinate + * @param dy Backbuffer coordinate + * @param eflag Should the sorting workaround be applied + */ +void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int row, int CelSkip, int dx, int dy, int eflag) { int mi, px, py; char bv; @@ -610,7 +681,7 @@ void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int skipChunks, int C } Cl2DrawSafe(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, CelSkip, 8); if (eflag && plr[bv]._peflag) { - town_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, CelSkip, dx - 64, dy); + town_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, row, CelSkip, dx - 64, dy); } } if (dFlags[sx][sy] & BFLAG_DEAD_PLAYER) { @@ -625,7 +696,7 @@ void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int skipChunks, int C } Cl2DrawSafe(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, CelSkip, 8); if (eflag && plr[bv]._peflag) { - town_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, CelSkip, dx - 64, dy); + town_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, row, CelSkip, dx - 64, dy); } } if (dFlags[sx][sy] & BFLAG_MISSILE) { @@ -636,7 +707,17 @@ void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int skipChunks, int C } } -void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, int eflag) +/** + * @brief Render a row of tile, checking for overdrawing on lower part of screen + * @param x dPice coordinate + * @param y dPice coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param chunks tile width of row + * @param row current row being rendered + * @param eflag is it an even (0) or odd (1) row + */ +void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int row, int eflag) { int i, j, CelSkip; BYTE *dst; @@ -644,7 +725,7 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, /// ASSERT: assert(gpBuffer); - CelSkip = 2 * skipChunks + 2; + CelSkip = 2 * row + 2; if (eflag) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { @@ -653,7 +734,7 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, 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) { + if (row <= i) { level_cel_block = pMap->mt[2 * i + 3]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -662,7 +743,7 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, dst -= BUFFER_WIDTH * 32; } if (CelSkip < 8) { - town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, skipChunks, CelSkip, sx, sy, 0); + town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, row, CelSkip, sx, sy, 0); } } else { town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); @@ -682,7 +763,7 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, 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) { + if (row <= i) { level_cel_block = pMap->mt[2 * i + 2]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -695,7 +776,7 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, dst -= BUFFER_WIDTH * 32; } if (CelSkip < 8) { - town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * CelSkip], x, y, skipChunks, CelSkip, sx, sy, 1); + town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * CelSkip], x, y, row, CelSkip, sx, sy, 1); } } else { town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); @@ -715,7 +796,7 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, 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) { + if (row <= i) { level_cel_block = pMap->mt[2 * i + 2]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -724,7 +805,7 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, dst -= BUFFER_WIDTH * 32; } if (CelSkip < 8) { - town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, skipChunks, CelSkip, sx, sy, 0); + town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, row, CelSkip, sx, sy, 0); } } else { town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); @@ -735,7 +816,19 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, } } -void town_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int CelCap, int sx, int sy) +/** + * This variant checks for of screen element on the upper screen + * This function it self causes rendering issues since it will render on top of objects on the other side of walls + * @brief Re render tile to workaround sorting issues with players walking east/west + * @param pBuff Pointer to output buffer at location sx,sy + * @param y dPiece coordinate + * @param x dPiece coordinate + * @param row The current row being rendered + * @param CelCap chunks of cell to skip + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + */ +void town_draw_e_flag(BYTE *pBuff, int x, int y, int row, int CelCap, int sx, int sy) { int i; BYTE *dst; @@ -745,7 +838,7 @@ void town_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int CelCap, int pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (capChunks >= i) { + if (row >= i) { level_cel_block = pMap->mt[2 * i]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -758,10 +851,21 @@ void town_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int CelCap, int dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(pBuff, x, y, capChunks, CelCap, sx, sy, 0); + town_draw_town_all(pBuff, x, y, row, CelCap, sx, sy, 0); } -void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int CelCap, int sx, int sy, int eflag) +/** + * @brief Render object sprites, skip offscreen parts for upper screen + * @param pBuff where to render to with sx,sx already applied + * @param x dPice coordinate + * @param y dPice coordinate + * @param row The current row being rendered + * @param CelCap chunks of cell to skip + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param eflag Should the sorting workaround be applied + */ +void town_draw_town_all(BYTE *pBuff, int x, int y, int row, int CelCap, int sx, int sy, int eflag) { int mi, px, py; char bv; @@ -803,7 +907,7 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int CelCap, in /// ASSERT: assert(plr[bv]._pAnimData); Cl2Draw(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap); if (eflag && plr[bv]._peflag) { - town_draw_e_flag(pBuff - 64, x - 1, y + 1, capChunks, CelCap, sx - 64, sy); + town_draw_e_flag(pBuff - 64, x - 1, y + 1, row, CelCap, sx - 64, sy); } } if (dFlags[x][y] & BFLAG_DEAD_PLAYER) { @@ -819,7 +923,7 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int CelCap, in /// ASSERT: assert(plr[bv]._pAnimData); Cl2Draw(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap); if (eflag && plr[bv]._peflag) { - town_draw_e_flag(pBuff - 64, x - 1, y + 1, capChunks, CelCap, sx - 64, sy); + town_draw_e_flag(pBuff - 64, x - 1, y + 1, row, CelCap, sx - 64, sy); } } if (dFlags[x][y] & BFLAG_MISSILE) { @@ -830,7 +934,17 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int CelCap, in } } -void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag) +/** + * @brief Render a row of tile, checking for overdrawing on upper part of screen + * @param x dPice coordinate + * @param y dPice coordinate + * @param sx Backbuffer coordinate + * @param sy Backbuffer coordinate + * @param chunks tile width of row + * @param row current row being rendered + * @param eflag is it an even (0) or odd (1) row + */ +void town_draw_upper(int x, int y, int sx, int sy, int chunks, int row, int eflag) { int i, j, CelCap; BYTE *dst; @@ -838,7 +952,7 @@ void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, in /// ASSERT: assert(gpBuffer); - CelCap = 2 * capChunks + 2; + CelCap = 2 * row + 2; if (CelCap > 8) { CelCap = 8; } @@ -850,7 +964,7 @@ 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) { + if (row >= i) { level_cel_block = pMap->mt[2 * i + 1]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -858,7 +972,7 @@ void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, in } dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 0); + town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, row, CelCap, sx, sy, 0); } else { town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); } @@ -877,7 +991,7 @@ 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) { + if (row >= i) { level_cel_block = pMap->mt[2 * i]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -889,7 +1003,7 @@ void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, in } dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 1); + town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, row, CelCap, sx, sy, 1); } else { town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); } @@ -908,7 +1022,7 @@ 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) { + if (row >= i) { level_cel_block = pMap->mt[2 * i]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -916,7 +1030,7 @@ void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, in } dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 0); + town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, row, CelCap, sx, sy, 0); } else { town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); } @@ -926,6 +1040,11 @@ void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, in } } +/** + * @brief Configure render and process screen rows + * @param x Center of view in dPice coordinate + * @param y Center of view in dPice coordinate + */ void T_DrawGame(int x, int y) { int i, sx, sy, chunks, blocks; @@ -1039,6 +1158,11 @@ void T_DrawGame(int x, int y) } } +/** + * @brief Configure render for zoomed view and process screen rows + * @param x Center of view in dPice coordinate + * @param y Center of view in dPice coordinate + */ void T_DrawZoom(int x, int y) { int i, sx, sy, chunks, blocks; @@ -1207,6 +1331,12 @@ void T_DrawZoom(int x, int y) #endif } +/** + * Mostly like DrawView but enables stores and lacks death screen + * @brief Start rendering of screen, town variation + * @param StartX Center of view in dPice coordinate + * @param StartY Center of view in dPice coordinate + */ void T_DrawView(int StartX, int StartY) { light_table_index = 0; @@ -1303,6 +1433,15 @@ void SetTownMicros() } } +/** + * @brief Load level data into dPiece + * @param P3Tiles Tile set + * @param pSector Sector data + * @param xi upper left destination + * @param yi upper left destination + * @param w width of sector + * @param h height of sector + */ void T_FillSector(BYTE *P3Tiles, BYTE *pSector, int xi, int yi, int w, int h) { int i, j, xx, yy; @@ -1353,7 +1492,7 @@ void T_FillSector(BYTE *P3Tiles, BYTE *pSector, int xi, int yi, int w, int h) Map = (WORD *)&pSector[ii]; if (*Map) { - v1 = *((WORD *)&P3Tiles[(*Map - 1) * 8]) + 1; + v1 = *((WORD *)&P3Tiles[(*Map - 1) * 8] + 0) + 1; v2 = *((WORD *)&P3Tiles[(*Map - 1) * 8] + 1) + 1; v3 = *((WORD *)&P3Tiles[(*Map - 1) * 8] + 2) + 1; v4 = *((WORD *)&P3Tiles[(*Map - 1) * 8] + 3) + 1; @@ -1375,6 +1514,13 @@ void T_FillSector(BYTE *P3Tiles, BYTE *pSector, int xi, int yi, int w, int h) } } +/** + * @brief Load a tile in to dPiece + * @param P3Tiles Tile set + * @param xx upper left destination + * @param yy upper left destination + * @param t tile id + */ void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t) { long v1, v2, v3, v4; @@ -1408,7 +1554,7 @@ void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t) nop } #else - v1 = *((WORD *)&P3Tiles[(t - 1) * 8]) + 1; + v1 = *((WORD *)&P3Tiles[(t - 1) * 8] + 0) + 1; v2 = *((WORD *)&P3Tiles[(t - 1) * 8] + 1) + 1; v3 = *((WORD *)&P3Tiles[(t - 1) * 8] + 2) + 1; v4 = *((WORD *)&P3Tiles[(t - 1) * 8] + 3) + 1; @@ -1420,6 +1566,9 @@ void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t) dPiece[xx + 1][yy + 1] = v4; } +/** + * @brief Initialize all of the levels data + */ void T_Pass3() { int xx, yy, x; @@ -1480,6 +1629,10 @@ void T_Pass3() mem_free_dbg(P3Tiles); } +/** + * @brief Initialize town level + * @param entry Methode of entry + */ void CreateTown(int entry) { int x, y; diff --git a/Source/town.h b/Source/town.h index 842a43c7c..5327894d1 100644 --- a/Source/town.h +++ b/Source/town.h @@ -9,12 +9,12 @@ 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_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int CelSkip, int sx, int sy); -void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int skipChunks, int CelSkip, 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 CelCap, int sx, int sy); -void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int CelCap, 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_clipped_e_flag_2(BYTE *pBuff, int x, int y, int row, int CelSkip, int sx, int sy); +void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int row, int CelSkip, int dx, int dy, int eflag); +void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int row, int eflag); +void town_draw_e_flag(BYTE *pBuff, int x, int y, int row, int CelCap, int sx, int sy); +void town_draw_town_all(BYTE *pBuff, int x, int y, int row, int CelCap, int sx, int sy, int eflag); +void town_draw_upper(int x, int y, int sx, int sy, int chunks, int row, int eflag); void T_DrawGame(int x, int y); void T_DrawZoom(int x, int y); void T_DrawView(int StartX, int StartY);