Browse Source

Pass CelOutputBuffer to game text printing (#1095)

* Pass CelOutputBuffer to game text printing
* DrawHalfTransparentRectTo: minor cleanup
pull/1101/head
Gleb Mazovetskiy 5 years ago committed by GitHub
parent
commit
d55a1c8a7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      Source/automap.cpp
  2. 200
      Source/control.cpp
  3. 62
      Source/control.h
  4. 3
      Source/engine.cpp
  5. 5
      Source/engine.h
  6. 22
      Source/error.cpp
  7. 4
      Source/error.h
  8. 12
      Source/help.cpp
  9. 18
      Source/inv.cpp
  10. 2
      Source/inv.h
  11. 20
      Source/items.cpp
  12. 2
      Source/items.h
  13. 9
      Source/plrmsg.cpp
  14. 6
      Source/plrmsg.h
  15. 18
      Source/quests.cpp
  16. 4
      Source/quests.h
  17. 42
      Source/scrollrt.cpp
  18. 24
      Source/stores.cpp
  19. 4
      Source/stores.h
  20. 6
      SourceS/thread.h
  21. 284
      SourceX/controls/modifier_hints.cpp
  22. 16
      SourceX/controls/modifier_hints.h

8
Source/automap.cpp

@ -595,16 +595,16 @@ static void DrawAutomapText(CelOutputBuffer out)
if (gbIsMultiplayer) { if (gbIsMultiplayer) {
strcat(strcpy(desc, "game: "), szPlayerName); strcat(strcpy(desc, "game: "), szPlayerName);
PrintGameStr(8, 20, desc, COL_GOLD); PrintGameStr(out, 8, 20, desc, COL_GOLD);
nextline = 35; nextline = 35;
if (szPlayerDescript[0]) { if (szPlayerDescript[0]) {
strcat(strcpy(desc, "password: "), szPlayerDescript); strcat(strcpy(desc, "password: "), szPlayerDescript);
PrintGameStr(8, 35, desc, COL_GOLD); PrintGameStr(out, 8, 35, desc, COL_GOLD);
nextline = 50; nextline = 50;
} }
} }
if (setlevel) { if (setlevel) {
PrintGameStr(8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD); PrintGameStr(out, 8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD);
} else if (currlevel != 0) { } else if (currlevel != 0) {
if (currlevel < 17 || currlevel > 20) { if (currlevel < 17 || currlevel > 20) {
if (currlevel < 21 || currlevel > 24) if (currlevel < 21 || currlevel > 24)
@ -614,7 +614,7 @@ static void DrawAutomapText(CelOutputBuffer out)
} else { } else {
sprintf(desc, "Level: Nest %i", currlevel - 16); sprintf(desc, "Level: Nest %i", currlevel - 16);
} }
PrintGameStr(8, nextline, desc, COL_GOLD); PrintGameStr(out, 8, nextline, desc, COL_GOLD);
} }
} }

200
Source/control.cpp

@ -512,16 +512,9 @@ void ToggleSpell(int slot)
} }
} }
/** void PrintChar(CelOutputBuffer out, int sx, int sy, int nCel, char col)
* @brief Print letter to the back buffer
* @param sx Backbuffer offset
* @param sy Backbuffer offset
* @param nCel Number of letter in Windows-1252
* @param col text_color color value
*/
void PrintChar(int sx, int sy, int nCel, char col)
{ {
assert(gpBuffer); assert(out.begin);
int i; int i;
BYTE pix; BYTE pix;
@ -529,7 +522,7 @@ void PrintChar(int sx, int sy, int nCel, char col)
switch (col) { switch (col) {
case COL_WHITE: case COL_WHITE:
CelDraw(sx, sy, pPanelText, nCel, 13); CelDrawTo(out, sx, sy, pPanelText, nCel, 13);
return; return;
case COL_BLUE: case COL_BLUE:
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
@ -562,7 +555,7 @@ void PrintChar(int sx, int sy, int nCel, char col)
} }
break; break;
} }
CelDrawLight(sx, sy, pPanelText, nCel, 13, tbl); CelDrawLightTo(out, sx, sy, pPanelText, nCel, 13, tbl);
} }
void AddPanelString(const char *str, BOOL just) void AddPanelString(const char *str, BOOL just)
@ -580,22 +573,22 @@ void ClearPanel()
pinfoflag = FALSE; pinfoflag = FALSE;
} }
void DrawPanelBox(int x, int y, int w, int h, int sx, int sy) void DrawPanelBox(CelOutputBuffer out, int x, int y, int w, int h, int sx, int sy)
{ {
int nSrcOff, nDstOff; int nSrcOff, nDstOff;
assert(gpBuffer); assert(out.begin);
nSrcOff = x + PANEL_WIDTH * y; nSrcOff = x + PANEL_WIDTH * y;
nDstOff = sx + BUFFER_WIDTH * sy; nDstOff = sx + out.line_width * sy;
int hgt; int hgt;
BYTE *src, *dst; BYTE *src, *dst;
src = &pBtmBuff[nSrcOff]; src = &pBtmBuff[nSrcOff];
dst = &gpBuffer[nDstOff]; dst = out.begin + nDstOff;
for (hgt = h; hgt; hgt--, src += PANEL_WIDTH, dst += BUFFER_WIDTH) { for (hgt = h; hgt; hgt--, src += PANEL_WIDTH, dst += out.line_width) {
memcpy(dst, src, w); memcpy(dst, src, w);
} }
} }
@ -687,12 +680,7 @@ void DrawLifeFlask()
DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * (filled + 3) + 109, gpBuffer, SCREENXY(PANEL_LEFT + 109, PANEL_TOP - 13 + filled), 13 - filled); DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * (filled + 3) + 109, gpBuffer, SCREENXY(PANEL_LEFT + 109, PANEL_TOP - 13 + filled), 13 - filled);
} }
/** void UpdateLifeFlask(CelOutputBuffer out)
* Controls the drawing of the area of the life flask within the control panel.
* First sets the fill amount then draws the empty flask cel portion then the filled
* flask portion.
*/
void UpdateLifeFlask()
{ {
double p; double p;
int filled; int filled;
@ -711,7 +699,7 @@ void UpdateLifeFlask()
if (filled != 69) if (filled != 69)
SetFlaskHeight(pLifeBuff, 16, 85 - filled, 96 + PANEL_X, PANEL_Y); SetFlaskHeight(pLifeBuff, 16, 85 - filled, 96 + PANEL_X, PANEL_Y);
if (filled != 0) if (filled != 0)
DrawPanelBox(96, 85 - filled, 88, filled, 96 + PANEL_X, PANEL_Y + 69 - filled); DrawPanelBox(out, 96, 85 - filled, 88, filled, 96 + PANEL_X, PANEL_Y + 69 - filled);
} }
void DrawManaFlask() void DrawManaFlask()
@ -746,11 +734,7 @@ void control_update_life_mana()
plr[myplr]._pHPPer = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; plr[myplr]._pHPPer = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
} }
/** void UpdateManaFlask(CelOutputBuffer out)
* Controls the drawing of the area of the life flask within the control panel.
* Also for some reason draws the current right mouse button spell.
*/
void UpdateManaFlask()
{ {
int filled; int filled;
int maxMana = plr[myplr]._pMaxMana; int maxMana = plr[myplr]._pMaxMana;
@ -772,7 +756,7 @@ void UpdateManaFlask()
if (filled != 69) if (filled != 69)
SetFlaskHeight(pManaBuff, 16, 85 - filled, PANEL_X + 464, PANEL_Y); SetFlaskHeight(pManaBuff, 16, 85 - filled, PANEL_X + 464, PANEL_Y);
if (filled != 0) if (filled != 0)
DrawPanelBox(464, 85 - filled, 88, filled, PANEL_X + 464, PANEL_Y + 69 - filled); DrawPanelBox(out, 464, 85 - filled, 88, filled, PANEL_X + 464, PANEL_Y + 69 - filled);
DrawSpell(); DrawSpell();
} }
@ -866,32 +850,28 @@ void InitControlPan()
initialDropGoldIndex = 0; initialDropGoldIndex = 0;
} }
void DrawCtrlPan() void DrawCtrlPan(CelOutputBuffer out)
{ {
DrawPanelBox(0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT, PANEL_X, PANEL_Y); DrawPanelBox(out, 0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT, PANEL_X, PANEL_Y);
DrawInfoBox(); DrawInfoBox(out);
} }
/** void DrawCtrlBtns(CelOutputBuffer out)
* Draws the control panel buttons in their current state. If the button is in the default
* state draw it from the panel cel(extract its sub-rect). Else draw it from the buttons cel.
*/
void DrawCtrlBtns()
{ {
int i; int i;
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (!panbtn[i]) if (!panbtn[i])
DrawPanelBox(PanBtnPos[i][0], PanBtnPos[i][1] + 16, 71, 20, PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + PANEL_Y); DrawPanelBox(out, PanBtnPos[i][0], PanBtnPos[i][1] + 16, 71, 20, PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + PANEL_Y);
else else
CelDraw(PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + PANEL_Y + 18, pPanelButtons, i + 1, 71); CelDrawTo(out, PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + PANEL_Y + 18, pPanelButtons, i + 1, 71);
} }
if (numpanbtns == 8) { if (numpanbtns == 8) {
CelDraw(87 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[6] + 1, 33); CelDrawTo(out, 87 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[6] + 1, 33);
if (FriendlyMode) if (FriendlyMode)
CelDraw(527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 3, 33); CelDrawTo(out, 527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 3, 33);
else else
CelDraw(527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 5, 33); CelDrawTo(out, 527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 5, 33);
} }
} }
@ -1231,7 +1211,7 @@ BOOL control_WriteStringToBuffer(BYTE *str)
return TRUE; return TRUE;
} }
static void CPrintString(int y, const char *str, BOOL center, int lines) static void CPrintString(CelOutputBuffer out, int y, const char *str, BOOL center, int lines)
{ {
BYTE c; BYTE c;
const char *tmp; const char *tmp;
@ -1257,14 +1237,14 @@ static void CPrintString(int y, const char *str, BOOL center, int lines)
lineOffset += fontkern[c] + 2; lineOffset += fontkern[c] + 2;
if (c) { if (c) {
if (lineOffset < 288) { if (lineOffset < 288) {
PrintChar(sx, sy, c, infoclr); PrintChar(out, sx, sy, c, infoclr);
} }
} }
sx += fontkern[c] + 2; sx += fontkern[c] + 2;
} }
} }
static void PrintInfo() static void PrintInfo(CelOutputBuffer out)
{ {
int yo, lo, i; int yo, lo, i;
@ -1272,25 +1252,22 @@ static void PrintInfo()
yo = 0; yo = 0;
lo = 1; lo = 1;
if (infostr[0] != '\0') { if (infostr[0] != '\0') {
CPrintString(0, infostr, TRUE, pnumlines); CPrintString(out, 0, infostr, TRUE, pnumlines);
yo = 1; yo = 1;
lo = 0; lo = 0;
} }
for (i = 0; i < pnumlines; i++) { for (i = 0; i < pnumlines; i++) {
CPrintString(i + yo, panelstr[i], pstrjust[i], pnumlines - lo); CPrintString(out, i + yo, panelstr[i], pstrjust[i], pnumlines - lo);
} }
} }
} }
/** void DrawInfoBox(CelOutputBuffer out)
* Sets a string to be drawn in the info box and then draws it.
*/
void DrawInfoBox()
{ {
int nGold; int nGold;
DrawPanelBox(177, 62, 288, 60, PANEL_X + 177, PANEL_Y + 46); DrawPanelBox(out, 177, 62, 288, 60, PANEL_X + 177, PANEL_Y + 46);
if (!panelflag && !trigflag && pcursinvitem == -1 && !spselflag) { if (!panelflag && !trigflag && pcursinvitem == -1 && !spselflag) {
infostr[0] = '\0'; infostr[0] = '\0';
infoclr = COL_WHITE; infoclr = COL_WHITE;
@ -1347,12 +1324,12 @@ void DrawInfoBox()
} }
} }
if (infostr[0] != '\0' || pnumlines != 0) if (infostr[0] != '\0' || pnumlines != 0)
PrintInfo(); PrintInfo(out);
} }
#define ADD_PlrStringXY(x, y, width, pszStr, col) MY_PlrStringXY(x, y, width, pszStr, col, 1) #define ADD_PlrStringXY(out, x, y, width, pszStr, col) MY_PlrStringXY(out, x, y, width, pszStr, col, 1)
void PrintGameStr(int x, int y, const char *str, int color) void PrintGameStr(CelOutputBuffer out, int x, int y, const char *str, int color)
{ {
BYTE c; BYTE c;
int sx, sy; int sx, sy;
@ -1362,13 +1339,14 @@ void PrintGameStr(int x, int y, const char *str, int color)
c = gbFontTransTbl[(BYTE)*str++]; c = gbFontTransTbl[(BYTE)*str++];
c = fontframe[c]; c = fontframe[c];
if (c) if (c)
PrintChar(sx, sy, c, color); PrintChar(out, sx, sy, c, color);
sx += fontkern[c] + 1; sx += fontkern[c] + 1;
} }
} }
/** /**
* @brief Render text string to back buffer * @brief Render text string to the given buffer
* @param out Buffer to render to
* @param x Screen coordinate * @param x Screen coordinate
* @param y Screen coordinate * @param y Screen coordinate
* @param endX End of line in screen coordinate * @param endX End of line in screen coordinate
@ -1376,7 +1354,7 @@ void PrintGameStr(int x, int y, const char *str, int color)
* @param col text_color color value * @param col text_color color value
* @param base Letter spacing * @param base Letter spacing
*/ */
static void MY_PlrStringXY(int x, int y, int endX, const char *pszStr, char col, int base) static void MY_PlrStringXY(CelOutputBuffer out, int x, int y, int endX, const char *pszStr, char col, int base)
{ {
BYTE c; BYTE c;
const char *tmp; const char *tmp;
@ -1401,28 +1379,28 @@ static void MY_PlrStringXY(int x, int y, int endX, const char *pszStr, char col,
line += fontkern[c] + base; line += fontkern[c] + base;
if (c) { if (c) {
if (line < widthOffset) if (line < widthOffset)
PrintChar(sx, sy, c, col); PrintChar(out, sx, sy, c, col);
} }
sx += fontkern[c] + base; sx += fontkern[c] + base;
} }
} }
void DrawChr() void DrawChr(CelOutputBuffer out)
{ {
char col; char col;
char chrstr[64]; char chrstr[64];
int pc, mindam, maxdam; int pc, mindam, maxdam;
CelDraw(SCREEN_X, 351 + SCREEN_Y, pChrPanel, 1, SPANEL_WIDTH); CelDraw(SCREEN_X, 351 + SCREEN_Y, pChrPanel, 1, SPANEL_WIDTH);
ADD_PlrStringXY(20, 32, 151, plr[myplr]._pName, COL_WHITE); ADD_PlrStringXY(out, 20, 32, 151, plr[myplr]._pName, COL_WHITE);
ADD_PlrStringXY(168, 32, 299, ClassStrTblOld[plr[myplr]._pClass], COL_WHITE); ADD_PlrStringXY(out, 168, 32, 299, ClassStrTblOld[plr[myplr]._pClass], COL_WHITE);
sprintf(chrstr, "%i", plr[myplr]._pLevel); sprintf(chrstr, "%i", plr[myplr]._pLevel);
ADD_PlrStringXY(66, 69, 109, chrstr, COL_WHITE); ADD_PlrStringXY(out, 66, 69, 109, chrstr, COL_WHITE);
sprintf(chrstr, "%i", plr[myplr]._pExperience); sprintf(chrstr, "%i", plr[myplr]._pExperience);
ADD_PlrStringXY(216, 69, 300, chrstr, COL_WHITE); ADD_PlrStringXY(out, 216, 69, 300, chrstr, COL_WHITE);
if (plr[myplr]._pLevel == MAXCHARLEVEL - 1) { if (plr[myplr]._pLevel == MAXCHARLEVEL - 1) {
strcpy(chrstr, "None"); strcpy(chrstr, "None");
@ -1431,10 +1409,10 @@ void DrawChr()
sprintf(chrstr, "%i", plr[myplr]._pNextExper); sprintf(chrstr, "%i", plr[myplr]._pNextExper);
col = COL_WHITE; col = COL_WHITE;
} }
ADD_PlrStringXY(216, 97, 300, chrstr, col); ADD_PlrStringXY(out, 216, 97, 300, chrstr, col);
sprintf(chrstr, "%i", plr[myplr]._pGold); sprintf(chrstr, "%i", plr[myplr]._pGold);
ADD_PlrStringXY(216, 146, 300, chrstr, COL_WHITE); ADD_PlrStringXY(out, 216, 146, 300, chrstr, COL_WHITE);
col = COL_WHITE; col = COL_WHITE;
if (plr[myplr]._pIBonusAC > 0) if (plr[myplr]._pIBonusAC > 0)
@ -1442,7 +1420,7 @@ void DrawChr()
if (plr[myplr]._pIBonusAC < 0) if (plr[myplr]._pIBonusAC < 0)
col = COL_RED; col = COL_RED;
sprintf(chrstr, "%i", plr[myplr]._pIBonusAC + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5); sprintf(chrstr, "%i", plr[myplr]._pIBonusAC + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5);
ADD_PlrStringXY(258, 183, 301, chrstr, col); ADD_PlrStringXY(out, 258, 183, 301, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
if (plr[myplr]._pIBonusToHit > 0) if (plr[myplr]._pIBonusToHit > 0)
@ -1450,7 +1428,7 @@ void DrawChr()
if (plr[myplr]._pIBonusToHit < 0) if (plr[myplr]._pIBonusToHit < 0)
col = COL_RED; col = COL_RED;
sprintf(chrstr, "%i%%", (plr[myplr]._pDexterity >> 1) + plr[myplr]._pIBonusToHit + 50); sprintf(chrstr, "%i%%", (plr[myplr]._pDexterity >> 1) + plr[myplr]._pIBonusToHit + 50);
ADD_PlrStringXY(258, 211, 301, chrstr, col); ADD_PlrStringXY(out, 258, 211, 301, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
if (plr[myplr]._pIBonusDam > 0) if (plr[myplr]._pIBonusDam > 0)
@ -1481,9 +1459,9 @@ void DrawChr()
} }
sprintf(chrstr, "%i-%i", mindam, maxdam); sprintf(chrstr, "%i-%i", mindam, maxdam);
if (mindam >= 100 || maxdam >= 100) if (mindam >= 100 || maxdam >= 100)
MY_PlrStringXY(254, 239, 305, chrstr, col, -1); MY_PlrStringXY(out, 254, 239, 305, chrstr, col, -1);
else else
MY_PlrStringXY(258, 239, 301, chrstr, col, 0); MY_PlrStringXY(out, 258, 239, 301, chrstr, col, 0);
if (plr[myplr]._pMagResist == 0) if (plr[myplr]._pMagResist == 0)
col = COL_WHITE; col = COL_WHITE;
@ -1495,7 +1473,7 @@ void DrawChr()
col = COL_GOLD; col = COL_GOLD;
sprintf(chrstr, "MAX"); sprintf(chrstr, "MAX");
} }
ADD_PlrStringXY(257, 276, 300, chrstr, col); ADD_PlrStringXY(out, 257, 276, 300, chrstr, col);
if (plr[myplr]._pFireResist == 0) if (plr[myplr]._pFireResist == 0)
col = COL_WHITE; col = COL_WHITE;
@ -1507,7 +1485,7 @@ void DrawChr()
col = COL_GOLD; col = COL_GOLD;
sprintf(chrstr, "MAX"); sprintf(chrstr, "MAX");
} }
ADD_PlrStringXY(257, 304, 300, chrstr, col); ADD_PlrStringXY(out, 257, 304, 300, chrstr, col);
if (plr[myplr]._pLghtResist == 0) if (plr[myplr]._pLghtResist == 0)
col = COL_WHITE; col = COL_WHITE;
@ -1519,31 +1497,31 @@ void DrawChr()
col = COL_GOLD; col = COL_GOLD;
sprintf(chrstr, "MAX"); sprintf(chrstr, "MAX");
} }
ADD_PlrStringXY(257, 332, 300, chrstr, col); ADD_PlrStringXY(out, 257, 332, 300, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
sprintf(chrstr, "%i", plr[myplr]._pBaseStr); sprintf(chrstr, "%i", plr[myplr]._pBaseStr);
if (MaxStats[plr[myplr]._pClass][ATTRIB_STR] == plr[myplr]._pBaseStr) if (MaxStats[plr[myplr]._pClass][ATTRIB_STR] == plr[myplr]._pBaseStr)
col = COL_GOLD; col = COL_GOLD;
ADD_PlrStringXY(95, 155, 126, chrstr, col); ADD_PlrStringXY(out, 95, 155, 126, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
sprintf(chrstr, "%i", plr[myplr]._pBaseMag); sprintf(chrstr, "%i", plr[myplr]._pBaseMag);
if (MaxStats[plr[myplr]._pClass][ATTRIB_MAG] == plr[myplr]._pBaseMag) if (MaxStats[plr[myplr]._pClass][ATTRIB_MAG] == plr[myplr]._pBaseMag)
col = COL_GOLD; col = COL_GOLD;
ADD_PlrStringXY(95, 183, 126, chrstr, col); ADD_PlrStringXY(out, 95, 183, 126, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
sprintf(chrstr, "%i", plr[myplr]._pBaseDex); sprintf(chrstr, "%i", plr[myplr]._pBaseDex);
if (MaxStats[plr[myplr]._pClass][ATTRIB_DEX] == plr[myplr]._pBaseDex) if (MaxStats[plr[myplr]._pClass][ATTRIB_DEX] == plr[myplr]._pBaseDex)
col = COL_GOLD; col = COL_GOLD;
ADD_PlrStringXY(95, 211, 126, chrstr, col); ADD_PlrStringXY(out, 95, 211, 126, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
sprintf(chrstr, "%i", plr[myplr]._pBaseVit); sprintf(chrstr, "%i", plr[myplr]._pBaseVit);
if (MaxStats[plr[myplr]._pClass][ATTRIB_VIT] == plr[myplr]._pBaseVit) if (MaxStats[plr[myplr]._pClass][ATTRIB_VIT] == plr[myplr]._pBaseVit)
col = COL_GOLD; col = COL_GOLD;
ADD_PlrStringXY(95, 239, 126, chrstr, col); ADD_PlrStringXY(out, 95, 239, 126, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
if (plr[myplr]._pStrength > plr[myplr]._pBaseStr) if (plr[myplr]._pStrength > plr[myplr]._pBaseStr)
@ -1551,7 +1529,7 @@ void DrawChr()
if (plr[myplr]._pStrength < plr[myplr]._pBaseStr) if (plr[myplr]._pStrength < plr[myplr]._pBaseStr)
col = COL_RED; col = COL_RED;
sprintf(chrstr, "%i", plr[myplr]._pStrength); sprintf(chrstr, "%i", plr[myplr]._pStrength);
ADD_PlrStringXY(143, 155, 173, chrstr, col); ADD_PlrStringXY(out, 143, 155, 173, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
if (plr[myplr]._pMagic > plr[myplr]._pBaseMag) if (plr[myplr]._pMagic > plr[myplr]._pBaseMag)
@ -1559,7 +1537,7 @@ void DrawChr()
if (plr[myplr]._pMagic < plr[myplr]._pBaseMag) if (plr[myplr]._pMagic < plr[myplr]._pBaseMag)
col = COL_RED; col = COL_RED;
sprintf(chrstr, "%i", plr[myplr]._pMagic); sprintf(chrstr, "%i", plr[myplr]._pMagic);
ADD_PlrStringXY(143, 183, 173, chrstr, col); ADD_PlrStringXY(out, 143, 183, 173, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
if (plr[myplr]._pDexterity > plr[myplr]._pBaseDex) if (plr[myplr]._pDexterity > plr[myplr]._pBaseDex)
@ -1567,7 +1545,7 @@ void DrawChr()
if (plr[myplr]._pDexterity < plr[myplr]._pBaseDex) if (plr[myplr]._pDexterity < plr[myplr]._pBaseDex)
col = COL_RED; col = COL_RED;
sprintf(chrstr, "%i", plr[myplr]._pDexterity); sprintf(chrstr, "%i", plr[myplr]._pDexterity);
ADD_PlrStringXY(143, 211, 173, chrstr, col); ADD_PlrStringXY(out, 143, 211, 173, chrstr, col);
col = COL_WHITE; col = COL_WHITE;
if (plr[myplr]._pVitality > plr[myplr]._pBaseVit) if (plr[myplr]._pVitality > plr[myplr]._pBaseVit)
@ -1575,7 +1553,7 @@ void DrawChr()
if (plr[myplr]._pVitality < plr[myplr]._pBaseVit) if (plr[myplr]._pVitality < plr[myplr]._pBaseVit)
col = COL_RED; col = COL_RED;
sprintf(chrstr, "%i", plr[myplr]._pVitality); sprintf(chrstr, "%i", plr[myplr]._pVitality);
ADD_PlrStringXY(143, 239, 173, chrstr, col); ADD_PlrStringXY(out, 143, 239, 173, chrstr, col);
if (plr[myplr]._pStatPts > 0) { if (plr[myplr]._pStatPts > 0) {
if (CalcStatDiff(myplr) < plr[myplr]._pStatPts) { if (CalcStatDiff(myplr) < plr[myplr]._pStatPts) {
@ -1584,7 +1562,7 @@ void DrawChr()
} }
if (plr[myplr]._pStatPts > 0) { if (plr[myplr]._pStatPts > 0) {
sprintf(chrstr, "%i", plr[myplr]._pStatPts); sprintf(chrstr, "%i", plr[myplr]._pStatPts);
ADD_PlrStringXY(95, 266, 126, chrstr, COL_RED); ADD_PlrStringXY(out, 95, 266, 126, chrstr, COL_RED);
pc = plr[myplr]._pClass; pc = plr[myplr]._pClass;
if (plr[myplr]._pBaseStr < MaxStats[pc][ATTRIB_STR]) if (plr[myplr]._pBaseStr < MaxStats[pc][ATTRIB_STR])
CelDraw(137 + SCREEN_X, 159 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41); CelDraw(137 + SCREEN_X, 159 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41);
@ -1601,22 +1579,22 @@ void DrawChr()
else else
col = COL_WHITE; col = COL_WHITE;
sprintf(chrstr, "%i", plr[myplr]._pMaxHP >> 6); sprintf(chrstr, "%i", plr[myplr]._pMaxHP >> 6);
ADD_PlrStringXY(95, 304, 126, chrstr, col); ADD_PlrStringXY(out, 95, 304, 126, chrstr, col);
if (plr[myplr]._pHitPoints != plr[myplr]._pMaxHP) if (plr[myplr]._pHitPoints != plr[myplr]._pMaxHP)
col = COL_RED; col = COL_RED;
sprintf(chrstr, "%i", plr[myplr]._pHitPoints >> 6); sprintf(chrstr, "%i", plr[myplr]._pHitPoints >> 6);
ADD_PlrStringXY(143, 304, 174, chrstr, col); ADD_PlrStringXY(out, 143, 304, 174, chrstr, col);
if (plr[myplr]._pMaxMana > plr[myplr]._pMaxManaBase) if (plr[myplr]._pMaxMana > plr[myplr]._pMaxManaBase)
col = COL_BLUE; col = COL_BLUE;
else else
col = COL_WHITE; col = COL_WHITE;
sprintf(chrstr, "%i", plr[myplr]._pMaxMana >> 6); sprintf(chrstr, "%i", plr[myplr]._pMaxMana >> 6);
ADD_PlrStringXY(95, 332, 126, chrstr, col); ADD_PlrStringXY(out, 95, 332, 126, chrstr, col);
if (plr[myplr]._pMana != plr[myplr]._pMaxMana) if (plr[myplr]._pMana != plr[myplr]._pMaxMana)
col = COL_RED; col = COL_RED;
sprintf(chrstr, "%i", plr[myplr]._pMana >> 6); sprintf(chrstr, "%i", plr[myplr]._pMana >> 6);
ADD_PlrStringXY(143, 332, 174, chrstr, col); ADD_PlrStringXY(out, 143, 332, 174, chrstr, col);
} }
void CheckLvlBtn() void CheckLvlBtn()
@ -1632,13 +1610,13 @@ void ReleaseLvlBtn()
lvlbtndown = FALSE; lvlbtndown = FALSE;
} }
void DrawLevelUpIcon() void DrawLevelUpIcon(CelOutputBuffer out)
{ {
int nCel; int nCel;
if (stextflag == STORE_NONE) { if (stextflag == STORE_NONE) {
nCel = lvlbtndown ? 3 : 2; nCel = lvlbtndown ? 3 : 2;
ADD_PlrStringXY(PANEL_LEFT + 0, PANEL_TOP - 49, PANEL_LEFT + 120, "Level Up", COL_WHITE); ADD_PlrStringXY(out, PANEL_LEFT + 0, PANEL_TOP - 49, PANEL_LEFT + 120, "Level Up", COL_WHITE);
CelDraw(40 + PANEL_X, -17 + PANEL_Y, pChrButtons, nCel, 41); CelDraw(40 + PANEL_X, -17 + PANEL_Y, pChrButtons, nCel, 41);
} }
} }
@ -1813,7 +1791,7 @@ void RedBack()
} }
} }
static void PrintSBookStr(int x, int y, BOOL cjustflag, const char *pszStr, char col) static void PrintSBookStr(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *pszStr, char col)
{ {
BYTE c; BYTE c;
const char *tmp; const char *tmp;
@ -1838,7 +1816,7 @@ static void PrintSBookStr(int x, int y, BOOL cjustflag, const char *pszStr, char
line += fontkern[c] + 1; line += fontkern[c] + 1;
if (c) { if (c) {
if (line <= 222) if (line <= 222)
PrintChar(sx, y, c, col); PrintChar(out, sx, y, c, col);
} }
sx += fontkern[c] + 1; sx += fontkern[c] + 1;
} }
@ -1872,7 +1850,7 @@ char GetSBookTrans(int ii, BOOL townok)
return st; return st;
} }
void DrawSpellBook() void DrawSpellBook(CelOutputBuffer out)
{ {
int i, sn, mana, lvl, yp, min, max; int i, sn, mana, lvl, yp, min, max;
char st; char st;
@ -1902,7 +1880,7 @@ void DrawSpellBook()
SetSpellTrans(RSPLTYPE_SKILL); SetSpellTrans(RSPLTYPE_SKILL);
DrawSpellCel(RIGHT_PANEL_X + 11, yp, pSBkIconCels, SPLICONLAST, 37); DrawSpellCel(RIGHT_PANEL_X + 11, yp, pSBkIconCels, SPLICONLAST, 37);
} }
PrintSBookStr(10, yp - 23, FALSE, spelldata[sn].sNameText, COL_WHITE); PrintSBookStr(out, 10, yp - 23, FALSE, spelldata[sn].sNameText, COL_WHITE);
switch (GetSBookTrans(sn, FALSE)) { switch (GetSBookTrans(sn, FALSE)) {
case RSPLTYPE_SKILL: case RSPLTYPE_SKILL:
strcpy(tempstr, "Skill"); strcpy(tempstr, "Skill");
@ -1921,7 +1899,7 @@ void DrawSpellBook()
if (sn == SPL_BONESPIRIT) { if (sn == SPL_BONESPIRIT) {
sprintf(tempstr, "Mana: %i Dam: 1/3 tgt hp", mana); sprintf(tempstr, "Mana: %i Dam: 1/3 tgt hp", mana);
} }
PrintSBookStr(10, yp - 1, FALSE, tempstr, COL_WHITE); PrintSBookStr(out, 10, yp - 1, FALSE, tempstr, COL_WHITE);
lvl = plr[myplr]._pSplLvl[sn] + plr[myplr]._pISplLvlAdd; lvl = plr[myplr]._pSplLvl[sn] + plr[myplr]._pISplLvlAdd;
if (lvl < 0) { if (lvl < 0) {
lvl = 0; lvl = 0;
@ -1933,7 +1911,7 @@ void DrawSpellBook()
} }
break; break;
} }
PrintSBookStr(10, yp - 12, FALSE, tempstr, COL_WHITE); PrintSBookStr(out, 10, yp - 12, FALSE, tempstr, COL_WHITE);
} }
yp += 43; yp += 43;
} }
@ -1976,20 +1954,20 @@ const char *get_pieces_str(int nGold)
return result; return result;
} }
void DrawGoldSplit(int amount) void DrawGoldSplit(CelOutputBuffer out, int amount)
{ {
int screen_x, i; int screen_x, i;
screen_x = 0; screen_x = 0;
CelDraw(351 + SCREEN_X, 178 + SCREEN_Y, pGBoxBuff, 1, 261); CelDraw(351 + SCREEN_X, 178 + SCREEN_Y, pGBoxBuff, 1, 261);
sprintf(tempstr, "You have %u gold", initialDropGoldValue); sprintf(tempstr, "You have %u gold", initialDropGoldValue);
ADD_PlrStringXY(366, 87, 600, tempstr, COL_GOLD); ADD_PlrStringXY(out, 366, 87, 600, tempstr, COL_GOLD);
sprintf(tempstr, "%s. How many do", get_pieces_str(initialDropGoldValue)); sprintf(tempstr, "%s. How many do", get_pieces_str(initialDropGoldValue));
ADD_PlrStringXY(366, 103, 600, tempstr, COL_GOLD); ADD_PlrStringXY(out, 366, 103, 600, tempstr, COL_GOLD);
ADD_PlrStringXY(366, 121, 600, "you want to remove?", COL_GOLD); ADD_PlrStringXY(out, 366, 121, 600, "you want to remove?", COL_GOLD);
if (amount > 0) { if (amount > 0) {
sprintf(tempstr, "%u", amount); sprintf(tempstr, "%u", amount);
PrintGameStr(388, 140, tempstr, COL_WHITE); PrintGameStr(out, 388, 140, tempstr, COL_WHITE);
} }
if (amount > 0) { if (amount > 0) {
for (i = 0; i < tempstr[i]; i++) { for (i = 0; i < tempstr[i]; i++) {
@ -2000,7 +1978,7 @@ void DrawGoldSplit(int amount)
} else { } else {
screen_x = 450; screen_x = 450;
} }
CelDraw(screen_x, 140 + SCREEN_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); CelDrawTo(out, screen_x, 140 + SCREEN_Y, pSPentSpn2Cels, PentSpn2Spin(), 12);
} }
void control_drop_gold(char vkey) void control_drop_gold(char vkey)
@ -2073,7 +2051,7 @@ void control_set_gold_curs(int pnum)
NewCursor(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM); NewCursor(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM);
} }
static char *control_print_talk_msg(char *msg, int *x, int y, int color) static char *control_print_talk_msg(CelOutputBuffer out, char *msg, int *x, int y, int color)
{ {
BYTE c; BYTE c;
int width; int width;
@ -2090,14 +2068,14 @@ static char *control_print_talk_msg(char *msg, int *x, int y, int color)
return msg; return msg;
msg++; msg++;
if (c != 0) { if (c != 0) {
PrintChar(*x, y, c, color); PrintChar(out, *x, y, c, color);
} }
*x += fontkern[c] + 1; *x += fontkern[c] + 1;
} }
return NULL; return NULL;
} }
void DrawTalkPan() void DrawTalkPan(CelOutputBuffer out)
{ {
int i, off, talk_btn, color, nCel, x; int i, off, talk_btn, color, nCel, x;
char *msg; char *msg;
@ -2105,21 +2083,21 @@ void DrawTalkPan()
if (!talkflag) if (!talkflag)
return; return;
DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, PANEL_X + 175, PANEL_Y + 4); DrawPanelBox(out, 175, sgbPlrTalkTbl + 20, 294, 5, PANEL_X + 175, PANEL_Y + 4);
off = 0; off = 0;
for (i = 293; i > 283; off++, i--) { for (i = 293; i > 283; off++, i--) {
DrawPanelBox((off >> 1) + 175, sgbPlrTalkTbl + off + 25, i, 1, (off >> 1) + PANEL_X + 175, off + PANEL_Y + 9); DrawPanelBox(out, (off >> 1) + 175, sgbPlrTalkTbl + off + 25, i, 1, (off >> 1) + PANEL_X + 175, off + PANEL_Y + 9);
} }
DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, PANEL_X + 185, PANEL_Y + 19); DrawPanelBox(out, 185, sgbPlrTalkTbl + 35, 274, 30, PANEL_X + 185, PANEL_Y + 19);
DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, PANEL_X + 180, PANEL_Y + 49); DrawPanelBox(out, 180, sgbPlrTalkTbl + 65, 284, 5, PANEL_X + 180, PANEL_Y + 49);
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
DrawPanelBox(180, sgbPlrTalkTbl + i + 70, i + 284, 1, PANEL_X + 180, i + PANEL_Y + 54); DrawPanelBox(out, 180, sgbPlrTalkTbl + i + 70, i + 284, 1, PANEL_X + 180, i + PANEL_Y + 54);
} }
DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, PANEL_X + 170, PANEL_Y + 64); DrawPanelBox(out, 170, sgbPlrTalkTbl + 80, 310, 55, PANEL_X + 170, PANEL_Y + 64);
msg = sgszTalkMsg; msg = sgszTalkMsg;
for (i = 0; i < 39; i += 13) { for (i = 0; i < 39; i += 13) {
x = 0 + PANEL_LEFT; x = 0 + PANEL_LEFT;
msg = control_print_talk_msg(msg, &x, i, 0); msg = control_print_talk_msg(out, msg, &x, i, 0);
if (!msg) if (!msg)
break; break;
} }
@ -2151,7 +2129,7 @@ void DrawTalkPan()
} }
if (plr[i].plractive) { if (plr[i].plractive) {
x = 46 + PANEL_LEFT; x = 46 + PANEL_LEFT;
control_print_talk_msg(plr[i]._pName, &x, 60 + talk_btn * 18, color); control_print_talk_msg(out, plr[i]._pName, &x, 60 + talk_btn * 18, color);
} }
talk_btn++; talk_btn++;

62
Source/control.h

@ -6,6 +6,8 @@
#ifndef __CONTROL_H__ #ifndef __CONTROL_H__
#define __CONTROL_H__ #define __CONTROL_H__
#include "engine.h"
DEVILUTION_BEGIN_NAMESPACE DEVILUTION_BEGIN_NAMESPACE
#ifdef __cplusplus #ifdef __cplusplus
@ -49,18 +51,47 @@ void DrawSpellList();
void SetSpell(); void SetSpell();
void SetSpeedSpell(int slot); void SetSpeedSpell(int slot);
void ToggleSpell(int slot); void ToggleSpell(int slot);
void PrintChar(int sx, int sy, int nCel, char col);
/**
* @brief Print letter to the given buffer
* @param out The buffer to print to
* @param sx Backbuffer offset
* @param sy Backbuffer offset
* @param nCel Number of letter in Windows-1252
* @param col text_color color value
*/
void PrintChar(CelOutputBuffer out, int sx, int sy, int nCel, char col);
void AddPanelString(const char *str, BOOL just); void AddPanelString(const char *str, BOOL just);
void ClearPanel(); void ClearPanel();
void DrawPanelBox(int x, int y, int w, int h, int sx, int sy); void DrawPanelBox(CelOutputBuffer out, int x, int y, int w, int h, int sx, int sy);
void DrawLifeFlask(); void DrawLifeFlask();
void UpdateLifeFlask();
/**
* Controls the drawing of the area of the life flask within the control panel.
* First sets the fill amount then draws the empty flask cel portion then the filled
* flask portion.
*/
void UpdateLifeFlask(CelOutputBuffer out);
void DrawManaFlask(); void DrawManaFlask();
void control_update_life_mana(); void control_update_life_mana();
void UpdateManaFlask();
/**
* Controls the drawing of the area of the life flask within the control panel.
* Also for some reason draws the current right mouse button spell.
*/
void UpdateManaFlask(CelOutputBuffer out);
void InitControlPan(); void InitControlPan();
void DrawCtrlPan(); void DrawCtrlPan(CelOutputBuffer out);
void DrawCtrlBtns();
/**
* Draws the control panel buttons in their current state. If the button is in the default
* state draw it from the panel cel(extract its sub-rect). Else draw it from the buttons cel.
*/
void DrawCtrlBtns(CelOutputBuffer out);
void DoSpeedBook(); void DoSpeedBook();
void DoPanBtn(); void DoPanBtn();
void control_check_btn_press(); void control_check_btn_press();
@ -69,24 +100,29 @@ void CheckPanelInfo();
void CheckBtnUp(); void CheckBtnUp();
void FreeControlPan(); void FreeControlPan();
BOOL control_WriteStringToBuffer(BYTE *str); BOOL control_WriteStringToBuffer(BYTE *str);
void DrawInfoBox();
void PrintGameStr(int x, int y, const char *str, int color); /**
void DrawChr(); * Sets a string to be drawn in the info box and then draws it.
*/
void DrawInfoBox(CelOutputBuffer out);
void PrintGameStr(CelOutputBuffer out, int x, int y, const char *str, int color);
void DrawChr(CelOutputBuffer out);
void CheckLvlBtn(); void CheckLvlBtn();
void ReleaseLvlBtn(); void ReleaseLvlBtn();
void DrawLevelUpIcon(); void DrawLevelUpIcon(CelOutputBuffer out);
void CheckChrBtns(); void CheckChrBtns();
void ReleaseChrBtns(bool addAllStatPoints); void ReleaseChrBtns(bool addAllStatPoints);
void DrawDurIcon(); void DrawDurIcon();
void RedBack(); void RedBack();
void DrawSpellBook(); void DrawSpellBook(CelOutputBuffer out);
void CheckSBook(); void CheckSBook();
const char *get_pieces_str(int nGold); const char *get_pieces_str(int nGold);
void DrawGoldSplit(int amount); void DrawGoldSplit(CelOutputBuffer out, int amount);
void control_drop_gold(char vkey); void control_drop_gold(char vkey);
void control_remove_gold(int pnum, int gold_index); void control_remove_gold(int pnum, int gold_index);
void control_set_gold_curs(int pnum); void control_set_gold_curs(int pnum);
void DrawTalkPan(); void DrawTalkPan(CelOutputBuffer out);
BOOL control_check_talk_btn(); BOOL control_check_talk_btn();
void control_release_talk_btn(); void control_release_talk_btn();
void control_type_message(); void control_type_message();

3
Source/engine.cpp

@ -582,9 +582,6 @@ static void DrawHalfTransparentStippledRectTo(CelOutputBuffer out, int sx, int s
void DrawHalfTransparentRectTo(CelOutputBuffer out, int sx, int sy, int width, int height) void DrawHalfTransparentRectTo(CelOutputBuffer out, int sx, int sy, int width, int height)
{ {
int row, col;
BYTE *pix = out.at(sx, sy);
if (sgOptions.bBlendedTransparancy) { if (sgOptions.bBlendedTransparancy) {
DrawHalfTransparentBlendedRectTo(out, sx, sy, width, height); DrawHalfTransparentBlendedRectTo(out, sx, sy, width, height);
} else { } else {

5
Source/engine.h

@ -13,6 +13,8 @@
#ifndef __ENGINE_H__ #ifndef __ENGINE_H__
#define __ENGINE_H__ #define __ENGINE_H__
#include "../types.h"
#ifdef __cplusplus #ifdef __cplusplus
#include <algorithm> #include <algorithm>
#endif #endif
@ -346,9 +348,6 @@ void DrawLineTo(CelOutputBuffer out, int x0, int y0, int x1, int y1, BYTE color_
* Draws a half-transparent rectangle by blacking out odd pixels on odd lines, * Draws a half-transparent rectangle by blacking out odd pixels on odd lines,
* even pixels on even lines. * even pixels on even lines.
* *
* If blended transparency is enabled, uses `paletteTransparencyLookup` table instead
* of blacking pixels out.
*
* @brief Render a transparent black rectangle * @brief Render a transparent black rectangle
* @param out Target buffer * @param out Target buffer
* @param sx Screen coordinate * @param sx Screen coordinate

22
Source/error.cpp

@ -101,32 +101,32 @@ void ClrDiabloMsg()
msgcnt = 0; msgcnt = 0;
} }
void DrawDiabloMsg() void DrawDiabloMsg(CelOutputBuffer out)
{ {
int i, len, width, sx, sy; int i, len, width, sx, sy;
BYTE c; BYTE c;
CelDraw(PANEL_X + 101, DIALOG_Y, pSTextSlidCels, 1, 12); CelDrawTo(out, PANEL_X + 101, DIALOG_Y, pSTextSlidCels, 1, 12);
CelDraw(PANEL_X + 527, DIALOG_Y, pSTextSlidCels, 4, 12); CelDrawTo(out, PANEL_X + 527, DIALOG_Y, pSTextSlidCels, 4, 12);
CelDraw(PANEL_X + 101, DIALOG_Y + 48, pSTextSlidCels, 2, 12); CelDrawTo(out, PANEL_X + 101, DIALOG_Y + 48, pSTextSlidCels, 2, 12);
CelDraw(PANEL_X + 527, DIALOG_Y + 48, pSTextSlidCels, 3, 12); CelDrawTo(out, PANEL_X + 527, DIALOG_Y + 48, pSTextSlidCels, 3, 12);
sx = PANEL_X + 109; sx = PANEL_X + 109;
for (i = 0; i < 35; i++) { for (i = 0; i < 35; i++) {
CelDraw(sx, DIALOG_Y, pSTextSlidCels, 5, 12); CelDrawTo(out, sx, DIALOG_Y, pSTextSlidCels, 5, 12);
CelDraw(sx, DIALOG_Y + 48, pSTextSlidCels, 7, 12); CelDrawTo(out, sx, DIALOG_Y + 48, pSTextSlidCels, 7, 12);
sx += 12; sx += 12;
} }
sy = DIALOG_Y + 12; sy = DIALOG_Y + 12;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
CelDraw(PANEL_X + 101, sy, pSTextSlidCels, 6, 12); CelDrawTo(out, PANEL_X + 101, sy, pSTextSlidCels, 6, 12);
CelDraw(PANEL_X + 527, sy, pSTextSlidCels, 8, 12); CelDrawTo(out, PANEL_X + 527, sy, pSTextSlidCels, 8, 12);
sy += 12; sy += 12;
} }
assert(gpBuffer); assert(gpBuffer);
DrawHalfTransparentRectTo(GlobalBackBuffer(), PANEL_LEFT + 104, DIALOG_TOP - 8, 432, 54); DrawHalfTransparentRectTo(out, PANEL_LEFT + 104, DIALOG_TOP - 8, 432, 54);
strcpy(tempstr, MsgStrings[msgflag]); strcpy(tempstr, MsgStrings[msgflag]);
sx = PANEL_X + 101; sx = PANEL_X + 101;
@ -145,7 +145,7 @@ void DrawDiabloMsg()
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]; c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]];
if (c != '\0') { if (c != '\0') {
PrintChar(sx, sy, c, COL_GOLD); PrintChar(out, sx, sy, c, COL_GOLD);
} }
sx += fontkern[c] + 1; sx += fontkern[c] + 1;
} }

4
Source/error.h

@ -6,6 +6,8 @@
#ifndef __ERROR_H__ #ifndef __ERROR_H__
#define __ERROR_H__ #define __ERROR_H__
#include "engine.h"
DEVILUTION_BEGIN_NAMESPACE DEVILUTION_BEGIN_NAMESPACE
#ifdef __cplusplus #ifdef __cplusplus
@ -17,7 +19,7 @@ extern char msgflag;
void InitDiabloMsg(char e); void InitDiabloMsg(char e);
void ClrDiabloMsg(); void ClrDiabloMsg();
void DrawDiabloMsg(); void DrawDiabloMsg(CelOutputBuffer out);
#ifdef __cplusplus #ifdef __cplusplus
} }

12
Source/help.cpp

@ -447,7 +447,7 @@ void InitHelp()
helpflag = FALSE; helpflag = FALSE;
} }
static void DrawHelpLine(int x, int y, char *text, char color) static void DrawHelpLine(CelOutputBuffer out, int x, int y, char *text, char color)
{ {
int sx, sy, width; int sx, sy, width;
BYTE c; BYTE c;
@ -462,7 +462,7 @@ static void DrawHelpLine(int x, int y, char *text, char color)
width += fontkern[c] + 1; width += fontkern[c] + 1;
if (c) { if (c) {
if (width <= 577) if (width <= 577)
PrintChar(sx, sy, c, color); PrintChar(out, sx, sy, c, color);
} }
sx += fontkern[c] + 1; sx += fontkern[c] + 1;
} }
@ -477,9 +477,9 @@ void DrawHelp(CelOutputBuffer out)
DrawSTextHelp(); DrawSTextHelp();
DrawQTextBack(out); DrawQTextBack(out);
if (gbIsHellfire) if (gbIsHellfire)
PrintSString(0, 2, TRUE, "Hellfire Help", COL_GOLD, 0); PrintSString(out, 0, 2, TRUE, "Hellfire Help", COL_GOLD, 0);
else else
PrintSString(0, 2, TRUE, "Diablo Help", COL_GOLD, 0); PrintSString(out, 0, 2, TRUE, "Diablo Help", COL_GOLD, 0);
DrawSLine(5); DrawSLine(5);
s = &gszHelpText[0]; s = &gszHelpText[0];
@ -553,14 +553,14 @@ void DrawHelp(CelOutputBuffer out)
} }
if (c != 0) { if (c != 0) {
tempstr[c] = '\0'; tempstr[c] = '\0';
DrawHelpLine(0, i, tempstr, col); DrawHelpLine(out, 0, i, tempstr, col);
} }
if (*s == '|') { if (*s == '|') {
s++; s++;
} }
} }
PrintSString(0, 23, TRUE, "Press ESC to end or the arrow keys to scroll.", COL_GOLD, 0); PrintSString(out, 0, 23, TRUE, "Press ESC to end or the arrow keys to scroll.", COL_GOLD, 0);
} }
void DisplayHelp() void DisplayHelp()

18
Source/inv.cpp

@ -524,7 +524,7 @@ void DrawInv()
} }
} }
void DrawInvBelt() void DrawInvBelt(CelOutputBuffer out)
{ {
int i, frame, frame_width, color; int i, frame, frame_width, color;
BYTE fi, ff; BYTE fi, ff;
@ -533,7 +533,7 @@ void DrawInvBelt()
return; return;
} }
DrawPanelBox(205, 21, 232, 28, PANEL_X + 205, PANEL_Y + 5); DrawPanelBox(out, 205, 21, 232, 28, PANEL_X + 205, PANEL_Y + 5);
for (i = 0; i < MAXBELTITEMS; i++) { for (i = 0; i < MAXBELTITEMS; i++) {
if (plr[myplr].SpdList[i]._itype == ITYPE_NONE) { if (plr[myplr].SpdList[i]._itype == ITYPE_NONE) {
@ -552,22 +552,22 @@ void DrawInvBelt()
color = ICOL_RED; color = ICOL_RED;
if (!sgbControllerActive || invflag) { if (!sgbControllerActive || invflag) {
if (frame <= 179) if (frame <= 179)
CelBlitOutline(color, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width); CelBlitOutlineTo(out, color, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width);
else else
CelBlitOutline(color, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width); CelBlitOutlineTo(out, color, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width);
} }
} }
if (plr[myplr].SpdList[i]._iStatFlag) { if (plr[myplr].SpdList[i]._iStatFlag) {
if (frame <= 179) if (frame <= 179)
CelClippedDraw(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width); CelClippedDrawTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width);
else else
CelClippedDraw(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width); CelClippedDrawTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width);
} else { } else {
if (frame <= 179) if (frame <= 179)
CelDrawLightRed(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width, 1); CelDrawLightRedTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width, 1);
else else
CelDrawLightRed(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width, 1); CelDrawLightRedTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width, 1);
} }
if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable
@ -575,7 +575,7 @@ void DrawInvBelt()
&& 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]];
PrintChar(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X + INV_SLOT_SIZE_PX - fontkern[ff], InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, ff, 0); PrintChar(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X + INV_SLOT_SIZE_PX - fontkern[ff], InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, ff, 0);
} }
} }
} }

2
Source/inv.h

@ -19,7 +19,7 @@ extern const InvXY InvRect[73];
void FreeInvGFX(); void FreeInvGFX();
void InitInv(); void InitInv();
void DrawInv(); void DrawInv();
void DrawInvBelt(); void DrawInvBelt(CelOutputBuffer out);
BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag); BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag);
BOOL SpecialAutoPlace(int pnum, int ii, const ItemStruct &item); BOOL SpecialAutoPlace(int pnum, int ii, const ItemStruct &item);
BOOL GoldAutoPlace(int pnum); BOOL GoldAutoPlace(int pnum);

20
Source/items.cpp

@ -3960,7 +3960,7 @@ static void DrawUTextBack(CelOutputBuffer out)
DrawHalfTransparentRectTo(out, RIGHT_PANEL - SPANEL_WIDTH + 27, 28, 265, 297); DrawHalfTransparentRectTo(out, RIGHT_PANEL - SPANEL_WIDTH + 27, 28, 265, 297);
} }
void PrintUString(int x, int y, BOOL cjustflag, const char *str, int col) void PrintUString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *str, int col)
{ {
int len, width, sx, sy, i, k; int len, width, sx, sy, i, k;
BYTE c; BYTE c;
@ -3982,7 +3982,7 @@ void PrintUString(int x, int y, BOOL cjustflag, const char *str, int col)
c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; c = fontframe[gbFontTransTbl[(BYTE)str[i]]];
k += fontkern[c] + 1; k += fontkern[c] + 1;
if (c && k <= 257) { if (c && k <= 257) {
PrintChar(sx, sy, c, col); PrintChar(out, sx, sy, c, col);
} }
sx += fontkern[c] + 1; sx += fontkern[c] + 1;
} }
@ -4002,37 +4002,37 @@ void DrawULine(int y)
memcpy(dst, src, 266); // BUGFIX: should be 267 memcpy(dst, src, 266); // BUGFIX: should be 267
} }
void DrawUniqueInfo() void DrawUniqueInfo(CelOutputBuffer out)
{ {
int uid, y; int uid, y;
if ((!chrflag && !questlog) || SCREEN_WIDTH >= SPANEL_WIDTH * 3) { if ((!chrflag && !questlog) || SCREEN_WIDTH >= SPANEL_WIDTH * 3) {
uid = curruitem._iUid; uid = curruitem._iUid;
DrawUTextBack(GlobalBackBuffer()); DrawUTextBack(GlobalBackBuffer());
PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, 2, TRUE, UniqueItemList[uid].UIName, 3); PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, 2, TRUE, UniqueItemList[uid].UIName, 3);
DrawULine(5); DrawULine(5);
PrintItemPower(UniqueItemList[uid].UIPower1, &curruitem); PrintItemPower(UniqueItemList[uid].UIPower1, &curruitem);
y = 6 - UniqueItemList[uid].UINumPL + 8; y = 6 - UniqueItemList[uid].UINumPL + 8;
PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y, TRUE, tempstr, 0); PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y, TRUE, tempstr, 0);
if (UniqueItemList[uid].UINumPL > 1) { if (UniqueItemList[uid].UINumPL > 1) {
PrintItemPower(UniqueItemList[uid].UIPower2, &curruitem); PrintItemPower(UniqueItemList[uid].UIPower2, &curruitem);
PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 2, TRUE, tempstr, 0); PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 2, TRUE, tempstr, 0);
} }
if (UniqueItemList[uid].UINumPL > 2) { if (UniqueItemList[uid].UINumPL > 2) {
PrintItemPower(UniqueItemList[uid].UIPower3, &curruitem); PrintItemPower(UniqueItemList[uid].UIPower3, &curruitem);
PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 4, TRUE, tempstr, 0); PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 4, TRUE, tempstr, 0);
} }
if (UniqueItemList[uid].UINumPL > 3) { if (UniqueItemList[uid].UINumPL > 3) {
PrintItemPower(UniqueItemList[uid].UIPower4, &curruitem); PrintItemPower(UniqueItemList[uid].UIPower4, &curruitem);
PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 6, TRUE, tempstr, 0); PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 6, TRUE, tempstr, 0);
} }
if (UniqueItemList[uid].UINumPL > 4) { if (UniqueItemList[uid].UINumPL > 4) {
PrintItemPower(UniqueItemList[uid].UIPower5, &curruitem); PrintItemPower(UniqueItemList[uid].UIPower5, &curruitem);
PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 8, TRUE, tempstr, 0); PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 8, TRUE, tempstr, 0);
} }
if (UniqueItemList[uid].UINumPL > 5) { if (UniqueItemList[uid].UINumPL > 5) {
PrintItemPower(UniqueItemList[uid].UIPower6, &curruitem); PrintItemPower(UniqueItemList[uid].UIPower6, &curruitem);
PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 10, TRUE, tempstr, 0); PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 10, TRUE, tempstr, 0);
} }
} }
} }

2
Source/items.h

@ -75,7 +75,7 @@ void DoRepair(int pnum, int cii);
void DoRecharge(int pnum, int cii); void DoRecharge(int pnum, int cii);
void DoOil(int pnum, int cii); void DoOil(int pnum, int cii);
void PrintItemPower(char plidx, ItemStruct *x); void PrintItemPower(char plidx, ItemStruct *x);
void DrawUniqueInfo(); void DrawUniqueInfo(CelOutputBuffer out);
void PrintItemDetails(ItemStruct *x); void PrintItemDetails(ItemStruct *x);
void PrintItemDur(ItemStruct *x); void PrintItemDur(ItemStruct *x);
void UseItem(int p, int Mid, int spl); void UseItem(int p, int Mid, int spl);

9
Source/plrmsg.cpp

@ -84,7 +84,7 @@ void InitPlrMsg()
plr_msg_slot = 0; plr_msg_slot = 0;
} }
void DrawPlrMsg() void DrawPlrMsg(CelOutputBuffer out)
{ {
int i; int i;
DWORD x = 10 + SCREEN_X; DWORD x = 10 + SCREEN_X;
@ -105,13 +105,14 @@ void DrawPlrMsg()
pMsg = plr_msgs; pMsg = plr_msgs;
for (i = 0; i < PMSG_COUNT; i++) { for (i = 0; i < PMSG_COUNT; i++) {
if (pMsg->str[0]) if (pMsg->str[0])
PrintPlrMsg(x, y, width, pMsg->str, text_color_from_player_num[pMsg->player]); PrintPlrMsg(out, x, y, width, pMsg->str, text_color_from_player_num[pMsg->player]);
pMsg++; pMsg++;
y += 35; y += 35;
} }
} }
void PrintPlrMsg(DWORD x, DWORD y, DWORD width, const char *str, BYTE col) // TODO: Can be made static
void PrintPlrMsg(CelOutputBuffer out, DWORD x, DWORD y, DWORD width, const char *str, BYTE col)
{ {
int line = 0; int line = 0;
@ -141,7 +142,7 @@ void PrintPlrMsg(DWORD x, DWORD y, DWORD width, const char *str, BYTE col)
c = gbFontTransTbl[(BYTE)*str++]; c = gbFontTransTbl[(BYTE)*str++];
c = fontframe[c]; c = fontframe[c];
if (c) if (c)
PrintChar(sx, y, c, col); PrintChar(out, sx, y, c, col);
sx += fontkern[c] + 1; sx += fontkern[c] + 1;
} }

6
Source/plrmsg.h

@ -6,6 +6,8 @@
#ifndef __PLRMSG_H__ #ifndef __PLRMSG_H__
#define __PLRMSG_H__ #define __PLRMSG_H__
#include "engine.h"
DEVILUTION_BEGIN_NAMESPACE DEVILUTION_BEGIN_NAMESPACE
#ifdef __cplusplus #ifdef __cplusplus
@ -24,8 +26,8 @@ size_t EventPlrMsg(const char *pszFmt, ...);
void SendPlrMsg(int pnum, const char *pszStr); void SendPlrMsg(int pnum, const char *pszStr);
void ClearPlrMsg(); void ClearPlrMsg();
void InitPlrMsg(); void InitPlrMsg();
void DrawPlrMsg(); void DrawPlrMsg(CelOutputBuffer out);
void PrintPlrMsg(DWORD x, DWORD y, DWORD width, const char *str, BYTE col); void PrintPlrMsg(CelOutputBuffer out, DWORD x, DWORD y, DWORD width, const char *str, BYTE col);
#ifdef __cplusplus #ifdef __cplusplus
} }

18
Source/quests.cpp

@ -802,7 +802,7 @@ void ResyncQuests()
} }
} }
void PrintQLString(int x, int y, BOOL cjustflag, const char *str, int col) static void PrintQLString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *str, int col)
{ {
int len, width, i, k, sx, sy; int len, width, i, k, sx, sy;
BYTE c; BYTE c;
@ -820,33 +820,33 @@ void PrintQLString(int x, int y, BOOL cjustflag, const char *str, int col)
sx += k; sx += k;
} }
if (qline == y) { if (qline == y) {
CelDraw(cjustflag ? x + k + 12 + SCREEN_X : x + 12 + SCREEN_X, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); CelDrawTo(out, cjustflag ? x + k + 12 + SCREEN_X : x + 12 + SCREEN_X, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12);
} }
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; c = fontframe[gbFontTransTbl[(BYTE)str[i]]];
k += fontkern[c] + 1; k += fontkern[c] + 1;
if (c && k <= 257) { if (c && k <= 257) {
PrintChar(sx, sy, c, col); PrintChar(out, sx, sy, c, col);
} }
sx += fontkern[c] + 1; sx += fontkern[c] + 1;
} }
if (qline == y) { if (qline == y) {
CelDraw(cjustflag ? x + k + 36 + SCREEN_X : 276 + SCREEN_X - x, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); CelDrawTo(out, cjustflag ? x + k + 36 + SCREEN_X : 276 + SCREEN_X - x, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12);
} }
} }
void DrawQuestLog() void DrawQuestLog(CelOutputBuffer out)
{ {
int y, i; int y, i;
PrintQLString(0, 2, TRUE, "Quest Log", 3); PrintQLString(out, 0, 2, TRUE, "Quest Log", 3);
CelDraw(SCREEN_X, SCREEN_Y + 351, pQLogCel, 1, SPANEL_WIDTH); CelDrawTo(out, SCREEN_X, SCREEN_Y + 351, pQLogCel, 1, SPANEL_WIDTH);
y = qtopline; y = qtopline;
for (i = 0; i < numqlines; i++) { for (i = 0; i < numqlines; i++) {
PrintQLString(0, y, TRUE, questlist[qlist[i]]._qlstr, 0); PrintQLString(out, 0, y, TRUE, questlist[qlist[i]]._qlstr, 0);
y += 2; y += 2;
} }
PrintQLString(0, 22, TRUE, "Close Quest Log", 0); PrintQLString(out, 0, 22, TRUE, "Close Quest Log", 0);
} }
void StartQuestlog() void StartQuestlog()

4
Source/quests.h

@ -6,6 +6,8 @@
#ifndef __QUESTS_H__ #ifndef __QUESTS_H__
#define __QUESTS_H__ #define __QUESTS_H__
#include "engine.h"
DEVILUTION_BEGIN_NAMESPACE DEVILUTION_BEGIN_NAMESPACE
#ifdef __cplusplus #ifdef __cplusplus
@ -59,7 +61,7 @@ void GetReturnLvlPos();
void LoadPWaterPalette(); void LoadPWaterPalette();
void ResyncMPQuests(); void ResyncMPQuests();
void ResyncQuests(); void ResyncQuests();
void DrawQuestLog(); void DrawQuestLog(CelOutputBuffer out);
void StartQuestlog(); void StartQuestlog();
void QuestlogUp(); void QuestlogUp();
void QuestlogDown(); void QuestlogDown();

42
Source/scrollrt.cpp

@ -1217,7 +1217,7 @@ static void DrawGame(int x, int y)
} }
// DevilutionX extension. // DevilutionX extension.
extern void DrawControllerModifierHints(); extern void DrawControllerModifierHints(CelOutputBuffer out);
/** /**
* @brief Start rendering of screen, town variation * @brief Start rendering of screen, town variation
@ -1237,22 +1237,22 @@ void DrawView(int StartX, int StartY)
if (invflag) { if (invflag) {
DrawInv(); DrawInv();
} else if (sbookflag) { } else if (sbookflag) {
DrawSpellBook(); DrawSpellBook(out);
} }
DrawDurIcon(); DrawDurIcon();
if (chrflag) { if (chrflag) {
DrawChr(); DrawChr(out);
} else if (questlog) { } else if (questlog) {
DrawQuestLog(); DrawQuestLog(out);
} }
if (!chrflag && plr[myplr]._pStatPts != 0 && !spselflag if (!chrflag && plr[myplr]._pStatPts != 0 && !spselflag
&& (!questlog || SCREEN_HEIGHT >= SPANEL_HEIGHT + PANEL_HEIGHT + 74 || SCREEN_WIDTH >= 4 * SPANEL_WIDTH)) { && (!questlog || SCREEN_HEIGHT >= SPANEL_HEIGHT + PANEL_HEIGHT + 74 || SCREEN_WIDTH >= 4 * SPANEL_WIDTH)) {
DrawLevelUpIcon(); DrawLevelUpIcon(out);
} }
if (uitemflag) { if (uitemflag) {
DrawUniqueInfo(); DrawUniqueInfo(out);
} }
if (qtextflag) { if (qtextflag) {
DrawQText(out); DrawQText(out);
@ -1261,13 +1261,13 @@ void DrawView(int StartX, int StartY)
DrawSpellList(); DrawSpellList();
} }
if (dropGoldFlag) { if (dropGoldFlag) {
DrawGoldSplit(dropGoldValue); DrawGoldSplit(out, dropGoldValue);
} }
if (helpflag) { if (helpflag) {
DrawHelp(out); DrawHelp(out);
} }
if (msgflag) { if (msgflag) {
DrawDiabloMsg(); DrawDiabloMsg(out);
} }
if (deathflag) { if (deathflag) {
RedBack(); RedBack();
@ -1275,11 +1275,11 @@ void DrawView(int StartX, int StartY)
gmenu_draw_pause(); gmenu_draw_pause();
} }
DrawControllerModifierHints(); DrawControllerModifierHints(out);
DrawPlrMsg(); DrawPlrMsg(out);
gmenu_draw(); gmenu_draw();
doom_draw(); doom_draw();
DrawInfoBox(); DrawInfoBox(out);
DrawLifeFlask(); DrawLifeFlask();
DrawManaFlask(); DrawManaFlask();
} }
@ -1401,7 +1401,7 @@ void EnableFrameCount()
/** /**
* @brief Display the current average FPS over 1 sec * @brief Display the current average FPS over 1 sec
*/ */
static void DrawFPS() static void DrawFPS(CelOutputBuffer out)
{ {
DWORD tc, frames; DWORD tc, frames;
char String[12]; char String[12];
@ -1416,7 +1416,7 @@ static void DrawFPS()
frameend = 0; frameend = 0;
} }
snprintf(String, 12, "%d FPS", framerate); snprintf(String, 12, "%d FPS", framerate);
PrintGameStr(8, 65, String, COL_RED); PrintGameStr(out, 8, 65, String, COL_RED);
} }
} }
@ -1560,29 +1560,31 @@ void DrawAndBlit()
force_redraw = 0; force_redraw = 0;
lock_buf(0); lock_buf(0);
CelOutputBuffer out = GlobalBackBuffer();
DrawView(ViewX, ViewY); DrawView(ViewX, ViewY);
if (ctrlPan) { if (ctrlPan) {
DrawCtrlPan(); DrawCtrlPan(out);
} }
if (drawhpflag) { if (drawhpflag) {
UpdateLifeFlask(); UpdateLifeFlask(out);
} }
if (drawmanaflag) { if (drawmanaflag) {
UpdateManaFlask(); UpdateManaFlask(out);
} }
if (drawbtnflag) { if (drawbtnflag) {
DrawCtrlBtns(); DrawCtrlBtns(out);
} }
if (drawsbarflag) { if (drawsbarflag) {
DrawInvBelt(); DrawInvBelt(out);
} }
if (talkflag) { if (talkflag) {
DrawTalkPan(); DrawTalkPan(out);
hgt = SCREEN_HEIGHT; hgt = SCREEN_HEIGHT;
} }
scrollrt_draw_cursor_item(); scrollrt_draw_cursor_item();
DrawFPS(); DrawFPS(out);
unlock_buf(0); unlock_buf(0);

24
Source/stores.cpp

@ -124,7 +124,7 @@ static void DrawSTextBack(CelOutputBuffer out)
DrawHalfTransparentRectTo(out, PANEL_LEFT + 347, UI_OFFSET_Y + 28, 265, 297); DrawHalfTransparentRectTo(out, PANEL_LEFT + 347, UI_OFFSET_Y + 28, 265, 297);
} }
void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int val) void PrintSString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *str, char col, int val)
{ {
int len, width, sx, sy, i, k, s; int len, width, sx, sy, i, k, s;
int xx, yy; int xx, yy;
@ -159,7 +159,7 @@ void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int v
c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; c = fontframe[gbFontTransTbl[(BYTE)str[i]]];
k += fontkern[c] + 1; k += fontkern[c] + 1;
if (c != 0 && k <= yy) { if (c != 0 && k <= yy) {
PrintChar(sx, sy, c, col); PrintChar(out, sx, sy, c, col);
} }
sx += fontkern[c] + 1; sx += fontkern[c] + 1;
} }
@ -171,7 +171,7 @@ void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int v
c = fontframe[gbFontTransTbl[(BYTE)valstr[i]]]; c = fontframe[gbFontTransTbl[(BYTE)valstr[i]]];
sx -= fontkern[c] + 1; sx -= fontkern[c] + 1;
if (c != 0) { if (c != 0) {
PrintChar(sx, sy, c, col); PrintChar(out, sx, sy, c, col);
} }
} }
} }
@ -209,23 +209,23 @@ void DrawSLine(int y)
memcpy(dst, src, BUFFER_WIDTH - line); memcpy(dst, src, BUFFER_WIDTH - line);
} }
void DrawSSlider(int y1, int y2) static void DrawSSlider(CelOutputBuffer out, int y1, int y2)
{ {
int yd1, yd2, yd3; int yd1, yd2, yd3;
yd1 = y1 * 12 + 44 + SCREEN_Y + UI_OFFSET_Y; yd1 = y1 * 12 + 44 + SCREEN_Y + UI_OFFSET_Y;
yd2 = y2 * 12 + 44 + SCREEN_Y + UI_OFFSET_Y; yd2 = y2 * 12 + 44 + SCREEN_Y + UI_OFFSET_Y;
if (stextscrlubtn != -1) if (stextscrlubtn != -1)
CelDraw(PANEL_X + 601, yd1, pSTextSlidCels, 12, 12); CelDrawTo(out, PANEL_X + 601, yd1, pSTextSlidCels, 12, 12);
else else
CelDraw(PANEL_X + 601, yd1, pSTextSlidCels, 10, 12); CelDrawTo(out, PANEL_X + 601, yd1, pSTextSlidCels, 10, 12);
if (stextscrldbtn != -1) if (stextscrldbtn != -1)
CelDraw(PANEL_X + 601, yd2, pSTextSlidCels, 11, 12); CelDrawTo(out, PANEL_X + 601, yd2, pSTextSlidCels, 11, 12);
else else
CelDraw(PANEL_X + 601, yd2, pSTextSlidCels, 9, 12); CelDrawTo(out, PANEL_X + 601, yd2, pSTextSlidCels, 9, 12);
yd1 += 12; yd1 += 12;
for (yd3 = yd1; yd3 < yd2; yd3 += 12) { for (yd3 = yd1; yd3 < yd2; yd3 += 12) {
CelDraw(PANEL_X + 601, yd3, pSTextSlidCels, 14, 12); CelDrawTo(out, PANEL_X + 601, yd3, pSTextSlidCels, 14, 12);
} }
if (stextsel == 22) if (stextsel == 22)
yd3 = stextlhold; yd3 = stextlhold;
@ -235,7 +235,7 @@ void DrawSSlider(int y1, int y2)
yd3 = 1000 * (stextsval + ((yd3 - stextup) >> 2)) / (storenumh - 1) * (y2 * 12 - y1 * 12 - 24) / 1000; yd3 = 1000 * (stextsval + ((yd3 - stextup) >> 2)) / (storenumh - 1) * (y2 * 12 - y1 * 12 - 24) / 1000;
else else
yd3 = 0; yd3 = 0;
CelDraw(PANEL_X + 601, (y1 + 1) * 12 + 44 + SCREEN_Y + UI_OFFSET_Y + yd3, pSTextSlidCels, 13, 12); CelDrawTo(out, PANEL_X + 601, (y1 + 1) * 12 + 44 + SCREEN_Y + UI_OFFSET_Y + yd3, pSTextSlidCels, 13, 12);
} }
void DrawSTextHelp() void DrawSTextHelp()
@ -1612,11 +1612,11 @@ void DrawSText(CelOutputBuffer out)
if (stext[i]._sline) if (stext[i]._sline)
DrawSLine(i); DrawSLine(i);
if (stext[i]._sstr[0]) if (stext[i]._sstr[0])
PrintSString(stext[i]._sx, i, stext[i]._sjust, stext[i]._sstr, stext[i]._sclr, stext[i]._sval); PrintSString(out, stext[i]._sx, i, stext[i]._sjust, stext[i]._sstr, stext[i]._sclr, stext[i]._sval);
} }
if (stextscrl) if (stextscrl)
DrawSSlider(4, 20); DrawSSlider(out, 4, 20);
} }
void STextESC() void STextESC()

4
Source/stores.h

@ -6,6 +6,8 @@
#ifndef __STORES_H__ #ifndef __STORES_H__
#define __STORES_H__ #define __STORES_H__
#include "engine.h"
DEVILUTION_BEGIN_NAMESPACE DEVILUTION_BEGIN_NAMESPACE
#ifdef __cplusplus #ifdef __cplusplus
@ -41,7 +43,7 @@ void InitStores();
int PentSpn2Spin(); int PentSpn2Spin();
void SetupTownStores(); void SetupTownStores();
void FreeStoreMem(); void FreeStoreMem();
void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int val); void PrintSString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *str, char col, int val);
void DrawSLine(int y); void DrawSLine(int y);
void DrawSTextHelp(); void DrawSTextHelp();
void ClearSText(int s, int e); void ClearSText(int s, int e);

6
SourceS/thread.h

@ -1,5 +1,11 @@
#pragma once #pragma once
#include <SDL.h>
#ifdef USE_SDL1
#include "sdl2_to_1_2_backports.h"
#endif
namespace dvl { namespace dvl {
typedef struct event_emul { typedef struct event_emul {

284
SourceX/controls/modifier_hints.cpp

@ -1,142 +1,142 @@
#include "controls/modifier_hints.h" #include "controls/modifier_hints.h"
#include <cstddef> #include <cstddef>
#include "all.h" #include "all.h"
#include "controls/controller.h" #include "controls/controller.h"
#include "controls/game_controls.h" #include "controls/game_controls.h"
namespace dvl { namespace dvl {
namespace { namespace {
int CalculateTextWidth(const char *s) int CalculateTextWidth(const char *s)
{ {
int l = 0; int l = 0;
while (*s) { while (*s) {
l += fontkern[fontframe[gbFontTransTbl[static_cast<unsigned char>(*s++)]]] + 1; l += fontkern[fontframe[gbFontTransTbl[static_cast<unsigned char>(*s++)]]] + 1;
} }
return l; return l;
} }
int SpaceWidth() int SpaceWidth()
{ {
static const int kSpaceWidth = CalculateTextWidth(" "); static const int kSpaceWidth = CalculateTextWidth(" ");
return kSpaceWidth; return kSpaceWidth;
} }
struct CircleMenuHint { struct CircleMenuHint {
CircleMenuHint(bool is_dpad, const char *top, const char *right, const char *bottom, const char *left) CircleMenuHint(bool is_dpad, const char *top, const char *right, const char *bottom, const char *left)
: is_dpad(is_dpad) : is_dpad(is_dpad)
, top(top) , top(top)
, top_w(CalculateTextWidth(top)) , top_w(CalculateTextWidth(top))
, right(right) , right(right)
, right_w(CalculateTextWidth(right)) , right_w(CalculateTextWidth(right))
, bottom(bottom) , bottom(bottom)
, bottom_w(CalculateTextWidth(bottom)) , bottom_w(CalculateTextWidth(bottom))
, left(left) , left(left)
, left_w(CalculateTextWidth(left)) , left_w(CalculateTextWidth(left))
, x_mid(left_w + SpaceWidth() * 2.5) , x_mid(left_w + SpaceWidth() * 2.5)
{ {
} }
int width() const int width() const
{ {
return 2 * x_mid; return 2 * x_mid;
} }
bool is_dpad; bool is_dpad;
const char *top; const char *top;
int top_w; int top_w;
const char *right; const char *right;
int right_w; int right_w;
const char *bottom; const char *bottom;
int bottom_w; int bottom_w;
const char *left; const char *left;
int left_w; int left_w;
int x_mid; int x_mid;
}; };
bool IsTopActive(const CircleMenuHint &hint) bool IsTopActive(const CircleMenuHint &hint)
{ {
if (hint.is_dpad) if (hint.is_dpad)
return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_UP); return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_UP);
return IsControllerButtonPressed(ControllerButton_BUTTON_Y); return IsControllerButtonPressed(ControllerButton_BUTTON_Y);
} }
bool IsRightActive(const CircleMenuHint &hint) bool IsRightActive(const CircleMenuHint &hint)
{ {
if (hint.is_dpad) if (hint.is_dpad)
return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_RIGHT); return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_RIGHT);
return IsControllerButtonPressed(ControllerButton_BUTTON_B); return IsControllerButtonPressed(ControllerButton_BUTTON_B);
} }
bool IsBottomActive(const CircleMenuHint &hint) bool IsBottomActive(const CircleMenuHint &hint)
{ {
if (hint.is_dpad) if (hint.is_dpad)
return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_DOWN); return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_DOWN);
return IsControllerButtonPressed(ControllerButton_BUTTON_A); return IsControllerButtonPressed(ControllerButton_BUTTON_A);
} }
bool IsLeftActive(const CircleMenuHint &hint) bool IsLeftActive(const CircleMenuHint &hint)
{ {
if (hint.is_dpad) if (hint.is_dpad)
return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_LEFT); return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_LEFT);
return IsControllerButtonPressed(ControllerButton_BUTTON_X); return IsControllerButtonPressed(ControllerButton_BUTTON_X);
} }
text_color CircleMenuHintTextColor(bool active) text_color CircleMenuHintTextColor(bool active)
{ {
return active ? COL_BLUE : COL_GOLD; return active ? COL_BLUE : COL_GOLD;
} }
void DrawCircleMenuHint(const CircleMenuHint &hint, int x, int y) void DrawCircleMenuHint(CelOutputBuffer out, const CircleMenuHint &hint, int x, int y)
{ {
const int kLineHeight = 25; const int kLineHeight = 25;
PrintGameStr(x + hint.x_mid - hint.top_w / 2, y, hint.top, CircleMenuHintTextColor(IsTopActive(hint))); PrintGameStr(out, x + hint.x_mid - hint.top_w / 2, y, hint.top, CircleMenuHintTextColor(IsTopActive(hint)));
y += kLineHeight; y += kLineHeight;
PrintGameStr(x, y, hint.left, CircleMenuHintTextColor(IsLeftActive(hint))); PrintGameStr(out, x, y, hint.left, CircleMenuHintTextColor(IsLeftActive(hint)));
PrintGameStr(x + hint.left_w + 5 * SpaceWidth(), y, hint.right, CircleMenuHintTextColor(IsRightActive(hint))); PrintGameStr(out, x + hint.left_w + 5 * SpaceWidth(), y, hint.right, CircleMenuHintTextColor(IsRightActive(hint)));
y += kLineHeight; y += kLineHeight;
PrintGameStr(x + hint.x_mid - hint.bottom_w / 2, y, hint.bottom, CircleMenuHintTextColor(IsBottomActive(hint))); PrintGameStr(out, x + hint.x_mid - hint.bottom_w / 2, y, hint.bottom, CircleMenuHintTextColor(IsBottomActive(hint)));
} }
const int kCircleMarginX = 16; const int kCircleMarginX = 16;
const int kCirclesTop = 76; const int kCirclesTop = 76;
void DrawStartModifierMenu() void DrawStartModifierMenu(CelOutputBuffer out)
{ {
if (!start_modifier_active) if (!start_modifier_active)
return; return;
static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"Menu", /*right=*/"Inv", /*bottom=*/"Map", /*left=*/"Char"); static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"Menu", /*right=*/"Inv", /*bottom=*/"Map", /*left=*/"Char");
static const CircleMenuHint kButtons(/*is_dpad=*/false, /*top=*/"", /*right=*/"", /*bottom=*/"Spells", /*left=*/"Quests"); static const CircleMenuHint kButtons(/*is_dpad=*/false, /*top=*/"", /*right=*/"", /*bottom=*/"Spells", /*left=*/"Quests");
DrawCircleMenuHint(kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop); DrawCircleMenuHint(out, kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop);
DrawCircleMenuHint(kButtons, PANEL_LEFT + PANEL_WIDTH - kButtons.width() - kCircleMarginX, PANEL_TOP - kCirclesTop); DrawCircleMenuHint(out, kButtons, PANEL_LEFT + PANEL_WIDTH - kButtons.width() - kCircleMarginX, PANEL_TOP - kCirclesTop);
} }
void DrawSelectModifierMenu() void DrawSelectModifierMenu(CelOutputBuffer out)
{ {
if (!select_modifier_active) if (!select_modifier_active)
return; return;
if (dpad_hotkeys) if (dpad_hotkeys)
{ {
static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"F6", /*right=*/"F8", /*bottom=*/"F7", /*left=*/"F5"); static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"F6", /*right=*/"F8", /*bottom=*/"F7", /*left=*/"F5");
DrawCircleMenuHint(kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop); DrawCircleMenuHint(out, kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop);
} }
static const CircleMenuHint kSpells(/*is_dpad=*/false, "F6", "F8", "F7", "F5"); static const CircleMenuHint kSpells(/*is_dpad=*/false, "F6", "F8", "F7", "F5");
DrawCircleMenuHint(kSpells, PANEL_LEFT + PANEL_WIDTH - kSpells.width() - kCircleMarginX, PANEL_TOP - kCirclesTop); DrawCircleMenuHint(out, kSpells, PANEL_LEFT + PANEL_WIDTH - kSpells.width() - kCircleMarginX, PANEL_TOP - kCirclesTop);
} }
} // namespace } // namespace
void DrawControllerModifierHints() void DrawControllerModifierHints(CelOutputBuffer out)
{ {
DrawStartModifierMenu(); DrawStartModifierMenu(out);
DrawSelectModifierMenu(); DrawSelectModifierMenu(out);
} }
} // namespace dvl } // namespace dvl

16
SourceX/controls/modifier_hints.h

@ -1,7 +1,9 @@
#pragma once #pragma once
namespace dvl { #include "engine.h"
void DrawControllerModifierHints(); namespace dvl {
} // namespace dvl void DrawControllerModifierHints(CelOutputBuffer out);
} // namespace dvl

Loading…
Cancel
Save