Browse Source

Documentations, enums and clean ups

pull/393/head
Anders Jenbo 7 years ago
parent
commit
2348c3a8fd
  1. 10
      Source/control.cpp
  2. 2
      Source/cursor.cpp
  3. 3
      Source/diablo.cpp
  4. 4
      Source/drlg_l1.cpp
  5. 4
      Source/drlg_l2.cpp
  6. 4
      Source/drlg_l3.cpp
  7. 4
      Source/drlg_l4.cpp
  8. 2
      Source/gmenu.cpp
  9. 13
      Source/inv.cpp
  10. 5
      Source/minitext.cpp
  11. 2
      Source/quests.cpp
  12. 4
      Source/render.cpp
  13. 335
      Source/scrollrt.cpp
  14. 6
      Source/scrollrt.h
  15. 2
      Source/stores.cpp
  16. 217
      Source/town.cpp
  17. 12
      Source/town.h

10
Source/control.cpp

@ -18,7 +18,7 @@ BOOL drawmanaflag;
BOOL chrbtnactive; BOOL chrbtnactive;
char sgszTalkMsg[MAX_SEND_STR_LEN]; char sgszTalkMsg[MAX_SEND_STR_LEN];
BYTE *pPanelText; BYTE *pPanelText;
int nGoldFrame; int nGoldFrame; /** current frame # for the pentagram caret in gold input */
BYTE *pLifeBuff; BYTE *pLifeBuff;
BYTE *pBtmBuff; BYTE *pBtmBuff;
BYTE *pTalkBtns; BYTE *pTalkBtns;
@ -36,7 +36,7 @@ char tempstr[256];
BOOLEAN whisper[MAX_PLRS]; BOOLEAN whisper[MAX_PLRS];
int sbooktab; int sbooktab;
int pSplType; int pSplType;
int frame; int frame; /** current frame # for the pentagram caret in chat input */
int initialDropGoldIndex; int initialDropGoldIndex;
BOOL talkflag; BOOL talkflag;
BYTE *pSBkIconCels; BYTE *pSBkIconCels;
@ -947,6 +947,9 @@ void DrawPanelBox(int x, int y, int w, int h, int sx, int sy)
#endif #endif
} }
/**
* Draws parts of the flasks that are on the panel
*/
void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r) void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r)
{ {
int nSrcOff, nDstOff, w; int nSrcOff, nDstOff, w;
@ -982,6 +985,9 @@ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r)
#endif #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) void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int h)
{ {
#ifdef USE_ASM #ifdef USE_ASM

2
Source/cursor.cpp

@ -226,7 +226,7 @@ void CheckCursMove()
mx = ViewX + tx + ty - (zoomflag ? 10 : 5); mx = ViewX + tx + ty - (zoomflag ? 10 : 5);
my = ViewY + ty - tx; my = ViewY + ty - tx;
flipy = py<px>> 1; flipy = py < (px >> 1);
if (flipy) { if (flipy) {
my--; my--;
} }

3
Source/diablo.cpp

@ -1538,6 +1538,9 @@ void LoadAllGFX()
IncProgress(); IncProgress();
} }
/**
* @param lvldir method of entry
*/
void CreateLevel(int lvldir) void CreateLevel(int lvldir)
{ {
switch (leveltype) { switch (leveltype) {

4
Source/drlg_l1.cpp

@ -419,7 +419,7 @@ static void DRLG_L1Pass3()
mov v4, eax mov v4, eax
} }
#else #else
v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1;
v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1;
v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1;
v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1;
@ -462,7 +462,7 @@ static void DRLG_L1Pass3()
mov v4, eax mov v4, eax
} }
#else #else
v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1;
v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1;
v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1;
v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1;

4
Source/drlg_l2.cpp

@ -446,7 +446,7 @@ void DRLG_L2Pass3()
mov v4, eax mov v4, eax
} }
#else #else
v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1;
v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1;
v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1;
v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1;
@ -488,7 +488,7 @@ void DRLG_L2Pass3()
mov v4, eax mov v4, eax
} }
#else #else
v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1;
v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1;
v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1;
v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1;

4
Source/drlg_l3.cpp

@ -1633,7 +1633,7 @@ static void DRLG_L3Pass3()
mov v4, eax mov v4, eax
} }
#else #else
v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1;
v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1;
v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1;
v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1;
@ -1683,7 +1683,7 @@ static void DRLG_L3Pass3()
} }
#else #else
if (lv >= 0) { if (lv >= 0) {
v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1;
v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1;
v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1;
v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1;

4
Source/drlg_l4.cpp

@ -1902,7 +1902,7 @@ static void DRLG_L4Pass3()
mov v4, eax mov v4, eax
} }
#else #else
v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1;
v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1;
v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1;
v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1;
@ -1952,7 +1952,7 @@ static void DRLG_L4Pass3()
} }
#else #else
if (lv >= 0) { if (lv >= 0) {
v1 = *((WORD *)&pMegaTiles[lv * 8]) + 1; v1 = *((WORD *)&pMegaTiles[lv * 8] + 0) + 1;
v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1; v2 = *((WORD *)&pMegaTiles[lv * 8] + 1) + 1;
v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1; v3 = *((WORD *)&pMegaTiles[lv * 8] + 2) + 1;
v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1; v4 = *((WORD *)&pMegaTiles[lv * 8] + 3) + 1;

2
Source/gmenu.cpp

@ -163,7 +163,7 @@ void gmenu_draw()
} }
ticks = GetTickCount(); ticks = GetTickCount();
if ((int)(ticks - PentSpin_tick) > 25) { if ((int)(ticks - PentSpin_tick) > 25) { // BUGFIX: thould be 50ms
PentSpin_frame++; PentSpin_frame++;
if (PentSpin_frame == 9) if (PentSpin_frame == 9)
PentSpin_frame = 1; PentSpin_frame = 1;

13
Source/inv.cpp

@ -426,7 +426,7 @@ void DrawInvBelt()
continue; 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 = plr[myplr].SpdList[i]._iCurs + CURSOR_FIRSTITEM;
frame_width = InvItemWidth[frame]; frame_width = InvItemWidth[frame];
@ -436,20 +436,20 @@ void DrawInvBelt()
colour = ICOL_BLUE; colour = ICOL_BLUE;
if (!plr[myplr].SpdList[i]._iStatFlag) if (!plr[myplr].SpdList[i]._iStatFlag)
colour = ICOL_RED; 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) 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 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 if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable
&& plr[myplr].SpdList[i]._iStatFlag && plr[myplr].SpdList[i]._iStatFlag
&& plr[myplr].SpdList[i]._itype != ITYPE_GOLD) { && plr[myplr].SpdList[i]._itype != ITYPE_GOLD) {
fi = i + 49; fi = i + 49;
ff = fontframe[gbFontTransTbl[fi]]; 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() void CheckInvScrn()
{ {
if (MouseX > 190 && MouseX < 437 if (MouseX > 190 && MouseX < 437

5
Source/minitext.cpp

@ -35,6 +35,9 @@ const BYTE mfontkern[56] = {
/* data */ /* 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 }; int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 };
void FreeQuestText() void FreeQuestText()
@ -57,7 +60,7 @@ void InitQTextMsg(int m)
qtextptr = alltext[m].txtstr; qtextptr = alltext[m].txtstr;
qtextflag = TRUE; qtextflag = TRUE;
qtexty = 500; qtexty = 500;
sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1]; /* double check offset */ sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1];
scrolltexty = sgLastScroll; scrolltexty = sgLastScroll;
qtextSpd = GetTickCount(); qtextSpd = GetTickCount();
} }

2
Source/quests.cpp

@ -11,7 +11,7 @@ int WaterDone;
int ReturnLvlY; int ReturnLvlY;
int ReturnLvlX; int ReturnLvlX;
int ReturnLvlT; int ReturnLvlT;
int ALLQUESTS; int ALLQUESTS; /** current frame # for the pentagram selector */
int ReturnLvl; int ReturnLvl;
QuestData questlist[MAXQUESTS] = { QuestData questlist[MAXQUESTS] = {

4
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) void world_draw_black_tile(BYTE *pBuff)
{ {
BYTE *dst; BYTE *dst;

335
Source/scrollrt.cpp

@ -66,6 +66,9 @@ void ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp
sgdwCursWdtOld = 0; sgdwCursWdtOld = 0;
} }
/**
* @brief Remove the cursor from the backbuffer
*/
static void scrollrt_draw_cursor_back_buffer() static void scrollrt_draw_cursor_back_buffer()
{ {
int i; int i;
@ -90,6 +93,9 @@ static void scrollrt_draw_cursor_back_buffer()
sgdwCursWdt = 0; sgdwCursWdt = 0;
} }
/**
* @brief Draw the cursor on the backbuffer
*/
static void scrollrt_draw_cursor_item() static void scrollrt_draw_cursor_item()
{ {
int i, mx, my, col; 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) void DrawMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL pre)
{ {
int i, mx, my, nCel; 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) void DrawClippedMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL pre)
{ {
int i, mx, my, nCel; 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) static void DrawMonster(int x, int y, int mx, int my, int m, int CelSkip, int CelCap)
{ {
int nCel; 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) static void DrawClippedMonster(int x, int y, int mx, int my, int m, int CelSkip, int CelCap)
{ {
int nCel; 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) 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; 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) 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; 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) void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL clipped)
{ {
int i, px, py, nCel; 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) static void DrawObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int CelCap)
{ {
int sx, sy, xx, yy, nCel; 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) static void DrawClippedObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int CelCap)
{ {
int sx, sy, xx, yy, nCel; 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); 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) 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; 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; 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) 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; 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) static void scrollrt_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag)
{ {
int i, j; 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_dungeon_2(BYTE *pBuff, int sx, int sy, int row, 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) /**
* 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; int lti_old, cta_old, lpi_old;
BYTE *dst; 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]; level_piece_id = dPiece[x][y];
light_table_index = dLight[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]]); cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]);
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
switch (skipChunks) { switch (row) {
case 0: case 0:
level_cel_block = pMap->mt[2]; level_cel_block = pMap->mt[2];
if (level_cel_block != 0) { 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) { 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; 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; 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; int px, py, nCel, nMon, negMon, p;
char bFlag, bDead, bObj, bItem, bPlr, bArch, bMap, negPlr, dd; 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); DrawClippedPlayer(p, sx, sy - 1, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth, CelSkip, 8);
if (eflag && pPlayer->_peflag != 0) { if (eflag && pPlayer->_peflag != 0) {
if (pPlayer->_peflag == 2) { 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 { } else {
// app_fatal("draw player clipped: tried to draw illegal player %d", p); // 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); DrawClippedMonster(sx, sy, px, py, draw_monster_num, CelSkip, 8);
if (eflag && !pMonster->_meflag) { 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 { } else {
// app_fatal("Draw Monster \"%s\" Clipped: uninitialized monster", pMonster->mName); // 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); DrawClippedPlayer(p, sx, sy, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth, CelSkip, 8);
if (eflag && pPlayer->_peflag != 0) { if (eflag && pPlayer->_peflag != 0) {
if (pPlayer->_peflag == 2) { 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 { } else {
// app_fatal("draw player clipped: tried to draw illegal player %d", p); // 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); DrawClippedMonster(sx, sy, px, py, draw_monster_num, CelSkip, 8);
if (eflag && !pMonster->_meflag) { 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 { } else {
// app_fatal("Draw Monster \"%s\" Clipped: uninitialized monster", pMonster->mName); // 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; int i, j, CelSkip;
BYTE *dst; 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); /// ASSERT: assert(gpBuffer);
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
CelSkip = 2 * skipChunks + 2; CelSkip = 2 * row + 2;
if (eflag) { if (eflag) {
if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { 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]]; dst = &gpBuffer[sx - (BUFFER_WIDTH * 32 - 32) + PitchTbl[sy]];
cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]);
for (i = 0; i < (MicroTileLen >> 1) - 1; i++) { for (i = 0; i < (MicroTileLen >> 1) - 1; i++) {
if (skipChunks <= i) { if (row <= i) {
level_cel_block = pMap->mt[2 * i + 3]; level_cel_block = pMap->mt[2 * i + 3];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawLowerScreen(dst); 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; dst -= BUFFER_WIDTH * 32;
} }
if (CelSkip < 8) { 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]]); cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]);
i = 0; i = 0;
while (i < (MicroTileLen >> 1) - 1) { while (i < (MicroTileLen >> 1) - 1) {
if (skipChunks <= i) { if (row <= i) {
level_cel_block = pMap->mt[2 * i + 2]; level_cel_block = pMap->mt[2 * i + 2];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawLowerScreen(dst); 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; dst -= BUFFER_WIDTH * 32;
} }
if (CelSkip < 8) { 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]]; dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]];
cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]);
for (i = 0; i < (MicroTileLen >> 1) - 1; i++) { for (i = 0; i < (MicroTileLen >> 1) - 1; i++) {
if (skipChunks <= i) { if (row <= i) {
level_cel_block = pMap->mt[2 * i + 2]; level_cel_block = pMap->mt[2 * i + 2];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawLowerScreen(dst); 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; dst -= BUFFER_WIDTH * 32;
} }
if (CelSkip < 8) { 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_dungeon(BYTE *pBuff, int sx, int sy, int row, 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) /**
* 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; int i, lti_old, cta_old, lpi_old;
BYTE *dst; 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; arch_draw_type = 0;
for (i = 1; i < (MicroTileLen >> 1) - 1; i++) { for (i = 1; i < (MicroTileLen >> 1) - 1; i++) {
dst -= BUFFER_WIDTH * 32; dst -= BUFFER_WIDTH * 32;
if (capChunks >= i) { if (row >= i) {
level_cel_block = pMap->mt[2 * i]; level_cel_block = pMap->mt[2 * i];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); 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; light_table_index = lti_old;
cel_transparency_active = cta_old; cel_transparency_active = cta_old;
level_piece_id = lpi_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; int px, py, nCel, nMon, negMon, p, tx, ty;
char bFlag, bDead, bObj, bItem, bPlr, bArch, bMap, negPlr, dd; 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); DrawPlayer(p, sx, sy - 1, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth, 0, CelCap);
if (eflag && pPlayer->_peflag != 0) { if (eflag && pPlayer->_peflag != 0) {
if (pPlayer->_peflag == 2) { 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 { } else {
// app_fatal("draw player: tried to draw illegal player %d", p); // 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); DrawMonster(sx, sy, px, py, draw_monster_num, 0, CelCap);
if (eflag && !pMonster->_meflag) { 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 { } else {
// app_fatal("Draw Monster \"%s\": uninitialized monster", pMonster->mName); // 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); DrawPlayer(p, sx, sy, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth, 0, CelCap);
if (eflag && pPlayer->_peflag != 0) { if (eflag && pPlayer->_peflag != 0) {
if (pPlayer->_peflag == 2) { 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 { } else {
// app_fatal("draw player: tried to draw illegal player %d", p); // 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); DrawMonster(sx, sy, px, py, draw_monster_num, 0, CelCap);
if (eflag && !pMonster->_meflag) { 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 { } else {
// app_fatal("Draw Monster \"%s\": uninitialized monster", pMonster->mName); // 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; int i, j, CelCap;
BYTE *dst; 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); /// ASSERT: assert(gpBuffer);
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
CelCap = 2 * capChunks + 2; CelCap = 2 * row + 2;
if (CelCap > 8) { if (CelCap > 8) {
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) { if (level_piece_id != 0) {
dst = &gpBuffer[sx + 32 + PitchTbl[sy]]; dst = &gpBuffer[sx + 32 + PitchTbl[sy]];
cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]);
if (capChunks >= 0) { if (row >= 0) {
level_cel_block = pMap->mt[1]; level_cel_block = pMap->mt[1];
if (level_cel_block != 0) { if (level_cel_block != 0) {
arch_draw_type = 2; 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; dst -= BUFFER_WIDTH * 32;
if (capChunks >= 1) { if (row >= 1) {
level_cel_block = pMap->mt[3]; level_cel_block = pMap->mt[3];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); drawUpperScreen(dst);
} }
} }
dst -= BUFFER_WIDTH * 32; dst -= BUFFER_WIDTH * 32;
if (capChunks >= 2) { if (row >= 2) {
level_cel_block = pMap->mt[5]; level_cel_block = pMap->mt[5];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); drawUpperScreen(dst);
} }
} }
dst -= BUFFER_WIDTH * 32; dst -= BUFFER_WIDTH * 32;
if (capChunks >= 3) { if (row >= 3) {
level_cel_block = pMap->mt[7]; level_cel_block = pMap->mt[7];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); 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 { } else {
world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); 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; arch_draw_type = 0;
for (i = 1; i < (MicroTileLen >> 1) - 1; i++) { for (i = 1; i < (MicroTileLen >> 1) - 1; i++) {
dst -= BUFFER_WIDTH * 32; dst -= BUFFER_WIDTH * 32;
if (capChunks >= i) { if (row >= i) {
level_cel_block = pMap->mt[2 * i]; level_cel_block = pMap->mt[2 * i];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); 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 { } else {
world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); 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]]; dst = &gpBuffer[sx + PitchTbl[sy]];
cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]);
arch_draw_type = 1; arch_draw_type = 1;
if (capChunks >= 0) { if (row >= 0) {
level_cel_block = pMap->mt[0]; level_cel_block = pMap->mt[0];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); 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; arch_draw_type = 0;
dst -= BUFFER_WIDTH * 32; dst -= BUFFER_WIDTH * 32;
if (capChunks >= 1) { if (row >= 1) {
level_cel_block = pMap->mt[2]; level_cel_block = pMap->mt[2];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); drawUpperScreen(dst);
} }
} }
dst -= BUFFER_WIDTH * 32; dst -= BUFFER_WIDTH * 32;
if (capChunks >= 2) { if (row >= 2) {
level_cel_block = pMap->mt[4]; level_cel_block = pMap->mt[4];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); drawUpperScreen(dst);
} }
} }
dst -= BUFFER_WIDTH * 32; dst -= BUFFER_WIDTH * 32;
if (capChunks >= 3) { if (row >= 3) {
level_cel_block = pMap->mt[6]; level_cel_block = pMap->mt[6];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); 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 { } else {
world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); 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) static void DrawGame(int x, int y)
{ {
int i, sx, sy, chunks, blocks; 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) static void DrawZoom(int x, int y)
{ {
int i, sx, sy, chunks, blocks; int i, sx, sy, chunks, blocks;
@ -2135,6 +2340,11 @@ static void DrawZoom(int x, int y)
#endif #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) void DrawView(int StartX, int StartY)
{ {
if (zoomflag) { if (zoomflag) {
@ -2192,6 +2402,9 @@ void DrawView(int StartX, int StartY)
DrawManaFlask(); DrawManaFlask();
} }
/**
* @brief Render the whole screen black
*/
void ClearScreenBuffer() void ClearScreenBuffer()
{ {
lock_buf(3); lock_buf(3);
@ -2226,6 +2439,9 @@ void ClearScreenBuffer()
} }
#ifdef _DEBUG #ifdef _DEBUG
/**
* @brief Scroll the screen when mouse is close to the edge
*/
void ScrollView() void ScrollView()
{ {
BOOL scroll; BOOL scroll;
@ -2304,12 +2520,18 @@ void ScrollView()
ScrollInfo._sdir = SDIR_NONE; ScrollInfo._sdir = SDIR_NONE;
} }
/**
* @brief Initialize the FPS meter
*/
void EnableFrameCount() void EnableFrameCount()
{ {
frameflag = frameflag == 0; frameflag = frameflag == 0;
framestart = GetTickCount(); framestart = GetTickCount();
} }
/**
* @brief Display the current average FPS over 1 sec
*/
static void DrawFPS() static void DrawFPS()
{ {
DWORD tc, frames; DWORD tc, frames;
@ -2343,6 +2565,13 @@ static void DrawFPS()
} }
#endif #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) static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt)
{ {
int nSrcOff, nDstOff, nSrcWdt, nDstWdt; 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) static void DrawMain(int dwHgt, BOOL draw_desc, BOOL draw_hp, BOOL draw_mana, BOOL draw_sbar, BOOL draw_btn)
{ {
int ysize; int ysize;
@ -2585,6 +2823,9 @@ void scrollrt_draw_game_screen(BOOL draw_cursor)
} }
} }
/**
* @brief Render the game
*/
void DrawAndBlit() void DrawAndBlit()
{ {
int hgt; int hgt;

6
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; extern int draw_monster_num;
void ClearCursor(); void ClearCursor();
void DrawMissile(int x, int y, int sx, int sy, int CelSkip, int capChunks, BOOL pre); 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 capChunks, 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 capChunks, BOOL clipped); void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL clipped);
void DrawView(int StartX, int StartY); void DrawView(int StartX, int StartY);
void ClearScreenBuffer(); void ClearScreenBuffer();
#ifdef _DEBUG #ifdef _DEBUG

2
Source/stores.cpp

@ -12,7 +12,7 @@ int talker;
STextStruct stext[24]; STextStruct stext[24];
char stextsize; char stextsize;
int stextsmax; int stextsmax;
int InStoreFlag; int InStoreFlag; /** current frame # for the pentagram selector */
ItemStruct storehold[48]; ItemStruct storehold[48];
int gossipstart; int gossipstart;
ItemStruct witchitem[20]; ItemStruct witchitem[20];

217
Source/town.cpp

@ -1,5 +1,10 @@
#include "diablo.h" #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) void town_clear_upper_buf(BYTE *pBuff)
{ {
/// ASSERT: assert(gpBuffer); /// ASSERT: assert(gpBuffer);
@ -62,6 +67,11 @@ void town_clear_upper_buf(BYTE *pBuff)
#endif #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) void town_clear_low_buf(BYTE *pBuff)
{ {
/// ASSERT: assert(gpBuffer); /// ASSERT: assert(gpBuffer);
@ -138,6 +148,11 @@ void town_clear_low_buf(BYTE *pBuff)
#endif #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) void town_special_lower(BYTE *pBuff, int nCel)
{ {
#if 0 #if 0
@ -252,6 +267,11 @@ void town_special_lower(BYTE *pBuff, int nCel)
#endif #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) void town_special_upper(BYTE *pBuff, int nCel)
{ {
#if 0 #if 0
@ -362,6 +382,16 @@ void town_special_upper(BYTE *pBuff, int nCel)
#endif #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) void town_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy)
{ {
int i; 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); 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) void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag)
{ {
int mi, px, py; 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) void town_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag)
{ {
int i, j; 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; int i;
BYTE *dst; BYTE *dst;
MICROS *pMap; MICROS *pMap;
if (skipChunks == 0) { if (row == 0) {
dst = pBuff; dst = pBuff;
} else { } else {
dst = &pBuff[BUFFER_WIDTH * 32 * skipChunks]; dst = &pBuff[BUFFER_WIDTH * 32 * row];
} }
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (skipChunks <= i) { if (row <= i) {
level_cel_block = pMap->mt[2 * i + 2]; level_cel_block = pMap->mt[2 * i + 2];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawLowerScreen(dst); 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) { 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; int mi, px, py;
char bv; 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); Cl2DrawSafe(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, CelSkip, 8);
if (eflag && plr[bv]._peflag) { 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) { 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); Cl2DrawSafe(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, CelSkip, 8);
if (eflag && plr[bv]._peflag) { 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) { 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; int i, j, CelSkip;
BYTE *dst; 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); /// ASSERT: assert(gpBuffer);
CelSkip = 2 * skipChunks + 2; CelSkip = 2 * row + 2;
if (eflag) { if (eflag) {
if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { 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]]; dst = &gpBuffer[sx - (BUFFER_WIDTH * 32 - 32) + PitchTbl[sy]];
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (skipChunks <= i) { if (row <= i) {
level_cel_block = pMap->mt[2 * i + 3]; level_cel_block = pMap->mt[2 * i + 3];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawLowerScreen(dst); 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; dst -= BUFFER_WIDTH * 32;
} }
if (CelSkip < 8) { 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 { } else {
town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); 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]]; dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]];
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (skipChunks <= i) { if (row <= i) {
level_cel_block = pMap->mt[2 * i + 2]; level_cel_block = pMap->mt[2 * i + 2];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawLowerScreen(dst); 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; dst -= BUFFER_WIDTH * 32;
} }
if (CelSkip < 8) { 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 { } else {
town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); 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]]; dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]];
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (skipChunks <= i) { if (row <= i) {
level_cel_block = pMap->mt[2 * i + 2]; level_cel_block = pMap->mt[2 * i + 2];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawLowerScreen(dst); 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; dst -= BUFFER_WIDTH * 32;
} }
if (CelSkip < 8) { 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 { } else {
town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); 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; int i;
BYTE *dst; 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)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (capChunks >= i) { if (row >= i) {
level_cel_block = pMap->mt[2 * i]; level_cel_block = pMap->mt[2 * i];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); 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; 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; int mi, px, py;
char bv; 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); /// ASSERT: assert(plr[bv]._pAnimData);
Cl2Draw(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap); Cl2Draw(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap);
if (eflag && plr[bv]._peflag) { 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) { 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); /// ASSERT: assert(plr[bv]._pAnimData);
Cl2Draw(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap); Cl2Draw(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap);
if (eflag && plr[bv]._peflag) { 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) { 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; int i, j, CelCap;
BYTE *dst; 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); /// ASSERT: assert(gpBuffer);
CelCap = 2 * capChunks + 2; CelCap = 2 * row + 2;
if (CelCap > 8) { if (CelCap > 8) {
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]]; dst = &gpBuffer[sx + 32 + PitchTbl[sy]];
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (capChunks >= i) { if (row >= i) {
level_cel_block = pMap->mt[2 * i + 1]; level_cel_block = pMap->mt[2 * i + 1];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); 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; 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 { } else {
town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); 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]]; dst = &gpBuffer[sx + PitchTbl[sy]];
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (capChunks >= i) { if (row >= i) {
level_cel_block = pMap->mt[2 * i]; level_cel_block = pMap->mt[2 * i];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); 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; 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 { } else {
town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); 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]]; dst = &gpBuffer[sx + PitchTbl[sy]];
pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)];
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (capChunks >= i) { if (row >= i) {
level_cel_block = pMap->mt[2 * i]; level_cel_block = pMap->mt[2 * i];
if (level_cel_block != 0) { if (level_cel_block != 0) {
drawUpperScreen(dst); 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; 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 { } else {
town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); 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) void T_DrawGame(int x, int y)
{ {
int i, sx, sy, chunks, blocks; 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) void T_DrawZoom(int x, int y)
{ {
int i, sx, sy, chunks, blocks; int i, sx, sy, chunks, blocks;
@ -1207,6 +1331,12 @@ void T_DrawZoom(int x, int y)
#endif #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) void T_DrawView(int StartX, int StartY)
{ {
light_table_index = 0; 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) void T_FillSector(BYTE *P3Tiles, BYTE *pSector, int xi, int yi, int w, int h)
{ {
int i, j, xx, yy; 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]; Map = (WORD *)&pSector[ii];
if (*Map) { 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; v2 = *((WORD *)&P3Tiles[(*Map - 1) * 8] + 1) + 1;
v3 = *((WORD *)&P3Tiles[(*Map - 1) * 8] + 2) + 1; v3 = *((WORD *)&P3Tiles[(*Map - 1) * 8] + 2) + 1;
v4 = *((WORD *)&P3Tiles[(*Map - 1) * 8] + 3) + 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) void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t)
{ {
long v1, v2, v3, v4; long v1, v2, v3, v4;
@ -1408,7 +1554,7 @@ void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t)
nop nop
} }
#else #else
v1 = *((WORD *)&P3Tiles[(t - 1) * 8]) + 1; v1 = *((WORD *)&P3Tiles[(t - 1) * 8] + 0) + 1;
v2 = *((WORD *)&P3Tiles[(t - 1) * 8] + 1) + 1; v2 = *((WORD *)&P3Tiles[(t - 1) * 8] + 1) + 1;
v3 = *((WORD *)&P3Tiles[(t - 1) * 8] + 2) + 1; v3 = *((WORD *)&P3Tiles[(t - 1) * 8] + 2) + 1;
v4 = *((WORD *)&P3Tiles[(t - 1) * 8] + 3) + 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; dPiece[xx + 1][yy + 1] = v4;
} }
/**
* @brief Initialize all of the levels data
*/
void T_Pass3() void T_Pass3()
{ {
int xx, yy, x; int xx, yy, x;
@ -1480,6 +1629,10 @@ void T_Pass3()
mem_free_dbg(P3Tiles); mem_free_dbg(P3Tiles);
} }
/**
* @brief Initialize town level
* @param entry Methode of entry
*/
void CreateTown(int entry) void CreateTown(int entry)
{ {
int x, y; int x, y;

12
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_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_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_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_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 skipChunks, int CelSkip, int dx, int dy, int eflag); 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 skipChunks, 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 capChunks, int CelCap, int sx, int sy); 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 capChunks, int CelCap, int sx, int sy, int eflag); 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 capChunks, 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_DrawGame(int x, int y);
void T_DrawZoom(int x, int y); void T_DrawZoom(int x, int y);
void T_DrawView(int StartX, int StartY); void T_DrawView(int StartX, int StartY);

Loading…
Cancel
Save