From b43325028f441975930f718c6190e28385383e3e Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Fri, 5 Mar 2021 07:04:15 +0000 Subject: [PATCH] Migrate `CelDraw` to `CelDrawTo` --- Source/control.cpp | 40 +++++++++++++++++------------------ Source/control.h | 2 +- Source/doom.cpp | 4 ++-- Source/doom.h | 4 +++- Source/engine.h | 5 ----- Source/gmenu.cpp | 28 ++++++++++++------------- Source/gmenu.h | 6 ++++-- Source/interfac.cpp | 2 +- Source/inv.cpp | 8 ++----- Source/inv.h | 7 ++++++- Source/scrollrt.cpp | 51 +++++++++++++++++++++------------------------ Source/scrollrt.h | 10 ++++++++- Source/stores.cpp | 4 ++-- 13 files changed, 88 insertions(+), 83 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index bf201714b..78f49583f 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1398,7 +1398,7 @@ void DrawChr(CelOutputBuffer out) char chrstr[64]; int pc, mindam, maxdam; - CelDraw(SCREEN_X, 351 + SCREEN_Y, pChrPanel, 1, SPANEL_WIDTH); + CelDrawTo(out, SCREEN_X, 351 + SCREEN_Y, pChrPanel, 1, SPANEL_WIDTH); ADD_PlrStringXY(out, 20, 32, 151, plr[myplr]._pName, COL_WHITE); ADD_PlrStringXY(out, 168, 32, 299, ClassStrTblOld[plr[myplr]._pClass], COL_WHITE); @@ -1572,13 +1572,13 @@ void DrawChr(CelOutputBuffer out) ADD_PlrStringXY(out, 95, 266, 126, chrstr, COL_RED); pc = plr[myplr]._pClass; if (plr[myplr]._pBaseStr < MaxStats[pc][ATTRIB_STR]) - CelDraw(137 + SCREEN_X, 159 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41); + CelDrawTo(out, 137 + SCREEN_X, 159 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41); if (plr[myplr]._pBaseMag < MaxStats[pc][ATTRIB_MAG]) - CelDraw(137 + SCREEN_X, 187 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_MAG] + 4, 41); + CelDrawTo(out, 137 + SCREEN_X, 187 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_MAG] + 4, 41); if (plr[myplr]._pBaseDex < MaxStats[pc][ATTRIB_DEX]) - CelDraw(137 + SCREEN_X, 216 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_DEX] + 6, 41); + CelDrawTo(out, 137 + SCREEN_X, 216 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_DEX] + 6, 41); if (plr[myplr]._pBaseVit < MaxStats[pc][ATTRIB_VIT]) - CelDraw(137 + SCREEN_X, 244 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_VIT] + 8, 41); + CelDrawTo(out, 137 + SCREEN_X, 244 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_VIT] + 8, 41); } if (plr[myplr]._pMaxHP > plr[myplr]._pMaxHPBase) @@ -1624,7 +1624,7 @@ void DrawLevelUpIcon(CelOutputBuffer out) if (stextflag == STORE_NONE) { nCel = lvlbtndown ? 3 : 2; 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); + CelDrawTo(out, 40 + PANEL_X, -17 + PANEL_Y, pChrButtons, nCel, 41); } } @@ -1704,7 +1704,7 @@ void ReleaseChrBtns(bool addAllStatPoints) } } -static int DrawDurIcon4Item(ItemStruct *pItem, int x, int c) +static int DrawDurIcon4Item(CelOutputBuffer out, ItemStruct *pItem, int x, int c) { if (pItem->isEmpty()) return x; @@ -1735,11 +1735,11 @@ static int DrawDurIcon4Item(ItemStruct *pItem, int x, int c) } if (pItem->_iDurability > 2) c += 8; - CelDraw(x, -17 + PANEL_Y, pDurIcons, c, 32); + CelDrawTo(out, x, -17 + PANEL_Y, pDurIcons, c, 32); return x - 32 - 8; } -void DrawDurIcon() +void DrawDurIcon(CelOutputBuffer out) { PlayerStruct *p; int x; @@ -1759,10 +1759,10 @@ void DrawDurIcon() } p = &plr[myplr]; - x = DrawDurIcon4Item(&p->InvBody[INVLOC_HEAD], x, 4); - x = DrawDurIcon4Item(&p->InvBody[INVLOC_CHEST], x, 3); - x = DrawDurIcon4Item(&p->InvBody[INVLOC_HAND_LEFT], x, 0); - DrawDurIcon4Item(&p->InvBody[INVLOC_HAND_RIGHT], x, 0); + x = DrawDurIcon4Item(out, &p->InvBody[INVLOC_HEAD], x, 4); + x = DrawDurIcon4Item(out, &p->InvBody[INVLOC_CHEST], x, 3); + x = DrawDurIcon4Item(out, &p->InvBody[INVLOC_HAND_LEFT], x, 0); + DrawDurIcon4Item(out, &p->InvBody[INVLOC_HAND_RIGHT], x, 0); } void RedBack() @@ -1863,16 +1863,16 @@ void DrawSpellBook(CelOutputBuffer out) char st; unsigned __int64 spl; - CelDraw(RIGHT_PANEL_X, 351 + SCREEN_Y, pSpellBkCel, 1, SPANEL_WIDTH); + CelDrawTo(out, RIGHT_PANEL_X, 351 + SCREEN_Y, pSpellBkCel, 1, SPANEL_WIDTH); if (gbIsHellfire && sbooktab < 5) { - CelDraw(RIGHT_PANEL_X + 61 * sbooktab + 7, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 61); + CelDrawTo(out, RIGHT_PANEL_X + 61 * sbooktab + 7, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 61); } else { // BUGFIX: rendering of page 3 and page 4 buttons are both off-by-one pixel (fixed). int sx = RIGHT_PANEL_X + 76 * sbooktab + 7; if (sbooktab == 2 || sbooktab == 3) { sx++; } - CelDraw(sx, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 76); + CelDrawTo(out, sx, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 76); } spl = plr[myplr]._pMemSpells | plr[myplr]._pISpells | plr[myplr]._pAblSpells; @@ -1966,7 +1966,7 @@ void DrawGoldSplit(CelOutputBuffer out, int amount) int screen_x, i; screen_x = 0; - CelDraw(351 + SCREEN_X, 178 + SCREEN_Y, pGBoxBuff, 1, 261); + CelDrawTo(out, 351 + SCREEN_X, 178 + SCREEN_Y, pGBoxBuff, 1, 261); sprintf(tempstr, "You have %u gold", initialDropGoldValue); ADD_PlrStringXY(out, 366, 87, 600, tempstr, COL_GOLD); sprintf(tempstr, "%s. How many do", get_pieces_str(initialDropGoldValue)); @@ -2110,7 +2110,7 @@ void DrawTalkPan(CelOutputBuffer out) } if (msg) *msg = '\0'; - CelDraw(x, i + 22 + PANEL_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); + CelDrawTo(out, x, i + 22 + PANEL_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); talk_btn = 0; for (i = 0; i < 4; i++) { if (i == myplr) @@ -2122,7 +2122,7 @@ void DrawTalkPan(CelOutputBuffer out) nCel = 4; else nCel = 3; - CelDraw(172 + PANEL_X, 84 + 18 * talk_btn + PANEL_Y, pTalkBtns, nCel, 61); + CelDrawTo(out, 172 + PANEL_X, 84 + 18 * talk_btn + PANEL_Y, pTalkBtns, nCel, 61); } } else { color = COL_RED; @@ -2132,7 +2132,7 @@ void DrawTalkPan(CelOutputBuffer out) nCel = 1; if (talkbtndown[talk_btn]) nCel += 4; - CelDraw(172 + PANEL_X, 84 + 18 * talk_btn + PANEL_Y, pTalkBtns, nCel, 61); + CelDrawTo(out, 172 + PANEL_X, 84 + 18 * talk_btn + PANEL_Y, pTalkBtns, nCel, 61); } if (plr[i].plractive) { x = 46 + PANEL_LEFT; diff --git a/Source/control.h b/Source/control.h index a34d8838c..908a70707 100644 --- a/Source/control.h +++ b/Source/control.h @@ -113,7 +113,7 @@ void ReleaseLvlBtn(); void DrawLevelUpIcon(CelOutputBuffer out); void CheckChrBtns(); void ReleaseChrBtns(bool addAllStatPoints); -void DrawDurIcon(); +void DrawDurIcon(CelOutputBuffer out); void RedBack(); void DrawSpellBook(CelOutputBuffer out); void CheckSBook(); diff --git a/Source/doom.cpp b/Source/doom.cpp index 60289c4ca..a2a12c0ed 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -86,13 +86,13 @@ void doom_close() doom_cleanup(); } -void doom_draw() +void doom_draw(CelOutputBuffer out) { if (!doomflag) { return; } - CelDraw(PANEL_X, PANEL_Y - 1, pDoomCel, 1, 640); + CelDrawTo(out, PANEL_X, PANEL_Y - 1, pDoomCel, 1, 640); } DEVILUTION_END_NAMESPACE diff --git a/Source/doom.h b/Source/doom.h index 24f16f8c6..c08efd289 100644 --- a/Source/doom.h +++ b/Source/doom.h @@ -6,6 +6,8 @@ #ifndef __DOOM_H__ #define __DOOM_H__ +#include "engine.h" + DEVILUTION_BEGIN_NAMESPACE #ifdef __cplusplus @@ -18,7 +20,7 @@ extern int DoomQuestState; int doom_get_frame_from_time(); void doom_init(); void doom_close(); -void doom_draw(); +void doom_draw(CelOutputBuffer out); #ifdef __cplusplus } diff --git a/Source/engine.h b/Source/engine.h index 546dc828b..c1bd1d90c 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -96,10 +96,6 @@ inline CelOutputBuffer GlobalBackBuffer() * @param nWidth Width of sprite */ void CelDrawTo(CelOutputBuffer out, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth); -inline void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) -{ - CelDrawTo(GlobalBackBuffer(), sx, sy, pCelBuff, nCel, nWidth); -} /** * @briefBlit CEL sprite to the given buffer, does not perform bounds-checking. @@ -343,7 +339,6 @@ void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth); */ void DrawLineTo(CelOutputBuffer out, int x0, int y0, int x1, int y1, BYTE color_index); - /** * Draws a half-transparent rectangle by blacking out odd pixels on odd lines, * even pixels on even lines. diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 1ac83487d..dea6c714d 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -48,7 +48,7 @@ const BYTE lfontkern[] = { 11, 10, 12, 11, 21, 23 }; -static void gmenu_print_text(int x, int y, const char *pszStr) +static void gmenu_print_text(CelOutputBuffer out, int x, int y, const char *pszStr) { BYTE c; @@ -56,18 +56,18 @@ static void gmenu_print_text(int x, int y, const char *pszStr) c = gbFontTransTbl[(BYTE)*pszStr++]; c = lfontframe[c]; if (c != 0) - CelDrawLight(x, y, BigTGold_cel, c, 46, NULL); + CelDrawLightTo(out, x, y, BigTGold_cel, c, 46, NULL); x += lfontkern[c] + 2; } } -void gmenu_draw_pause() +void gmenu_draw_pause(CelOutputBuffer out) { if (currlevel != 0) RedBack(); if (!sgpCurrentMenu) { light_table_index = 0; - gmenu_print_text(316 + PANEL_LEFT, 336, "Pause"); + gmenu_print_text(out, 316 + PANEL_LEFT, 336, "Pause"); } } @@ -184,31 +184,31 @@ static int gmenu_get_lfont(TMenuItem *pItem) return i - 2; } -static void gmenu_draw_menu_item(TMenuItem *pItem, int y) +static void gmenu_draw_menu_item(CelOutputBuffer out, TMenuItem *pItem, int y) { DWORD w, x, nSteps, step, pos; w = gmenu_get_lfont(pItem); if (pItem->dwFlags & GMENU_SLIDER) { x = 16 + w / 2 + SCREEN_X; - CelDraw(x + PANEL_LEFT, y - 10, optbar_cel, 1, 287); + CelDrawTo(out, x + PANEL_LEFT, y - 10, optbar_cel, 1, 287); step = pItem->dwFlags & 0xFFF; nSteps = (pItem->dwFlags & 0xFFF000) >> 12; if (nSteps < 2) nSteps = 2; pos = step * 256 / nSteps; gmenu_clear_buffer(x + 2 + PANEL_LEFT, y - 12, pos + 13, 28); - CelDraw(x + 2 + pos + PANEL_LEFT, y - 12, option_cel, 1, 27); + CelDrawTo(out, x + 2 + pos + PANEL_LEFT, y - 12, option_cel, 1, 27); } x = gnScreenWidth / 2 - w / 2 + SCREEN_X; light_table_index = (pItem->dwFlags & GMENU_ENABLED) ? 0 : 15; - gmenu_print_text(x, y, pItem->pszStr); + gmenu_print_text(out, x, y, pItem->pszStr); if (pItem == sgpCurrItem) { - CelDraw(x - 54, y + 1, PentSpin_cel, PentSpn2Spin(), 48); - CelDraw(x + 4 + w, y + 1, PentSpin_cel, PentSpn2Spin(), 48); + CelDrawTo(out, x - 54, y + 1, PentSpin_cel, PentSpn2Spin(), 48); + CelDrawTo(out, x + 4 + w, y + 1, PentSpin_cel, PentSpn2Spin(), 48); } } -void gmenu_draw() +void gmenu_draw(CelOutputBuffer out) { int y; TMenuItem *i; @@ -225,15 +225,15 @@ void gmenu_draw() LogoAnim_frame = 1; LogoAnim_tick = ticks; } - CelDraw((gnScreenWidth - 430) / 2 + SCREEN_X, 102 + SCREEN_Y + UI_OFFSET_Y, sgpLogo, LogoAnim_frame, 430); + CelDrawTo(out, (gnScreenWidth - 430) / 2 + SCREEN_X, 102 + SCREEN_Y + UI_OFFSET_Y, sgpLogo, LogoAnim_frame, 430); } else { - CelDraw((gnScreenWidth - 296) / 2 + SCREEN_X, 102 + SCREEN_Y + UI_OFFSET_Y, sgpLogo, 1, 296); + CelDrawTo(out, (gnScreenWidth - 296) / 2 + SCREEN_X, 102 + SCREEN_Y + UI_OFFSET_Y, sgpLogo, 1, 296); } y = 160 + SCREEN_Y + UI_OFFSET_Y; i = sgpCurrentMenu; if (sgpCurrentMenu->fnMenu) { while (i->fnMenu) { - gmenu_draw_menu_item(i, y); + gmenu_draw_menu_item(out, i, y); i++; y += 45; } diff --git a/Source/gmenu.h b/Source/gmenu.h index 1c488152c..cffece809 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -6,6 +6,8 @@ #ifndef __GMENU_H__ #define __GMENU_H__ +#include "engine.h" + DEVILUTION_BEGIN_NAMESPACE #ifdef __cplusplus @@ -14,12 +16,12 @@ extern "C" { extern TMenuItem *sgpCurrentMenu; -void gmenu_draw_pause(); +void gmenu_draw_pause(CelOutputBuffer out); void FreeGMenu(); void gmenu_init_menu(); BOOL gmenu_is_active(); void gmenu_set_items(TMenuItem *pItem, void (*gmFunc)(TMenuItem *)); -void gmenu_draw(); +void gmenu_draw(CelOutputBuffer out); BOOL gmenu_presskeys(int vkey); BOOL gmenu_on_mouse_move(); BOOL gmenu_left_mouse(BOOL isDown); diff --git a/Source/interfac.cpp b/Source/interfac.cpp index f9f5c747e..73e8ce95d 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -247,7 +247,7 @@ static void DrawCutscene() DWORD i; lock_buf(1); - CelDraw(PANEL_X, 480 + SCREEN_Y - 1 + UI_OFFSET_Y, sgpBackCel, 1, 640); + CelDrawTo(GlobalBackBuffer(), PANEL_X, 480 + SCREEN_Y - 1 + UI_OFFSET_Y, sgpBackCel, 1, 640); for (i = 0; i < sgdwProgress; i++) { DrawProgress( diff --git a/Source/inv.cpp b/Source/inv.cpp index 3963316bc..925e648eb 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -164,16 +164,12 @@ void InvDrawSlotBack(int X, int Y, int W, int H) } } -/** - * @brief Render the inventory panel to the back buffer - */ -void DrawInv() +void DrawInv(CelOutputBuffer out) { BOOL invtest[NUM_INV_GRID_ELEM]; int frame, frame_width, color, screen_x, screen_y, i, j, ii; - BYTE *pBuff; - CelDraw(RIGHT_PANEL_X, 351 + SCREEN_Y, pInvCels, 1, SPANEL_WIDTH); + CelDrawTo(out, RIGHT_PANEL_X, 351 + SCREEN_Y, pInvCels, 1, SPANEL_WIDTH); if (!plr[myplr].InvBody[INVLOC_HEAD].isEmpty()) { InvDrawSlotBack(RIGHT_PANEL_X + 133, 59 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX); diff --git a/Source/inv.h b/Source/inv.h index d363233ad..0a31e0b68 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -20,7 +20,12 @@ extern const InvXY InvRect[73]; void FreeInvGFX(); void InitInv(); -void DrawInv(); + +/** + * @brief Render the inventory panel to the given buffer. + */ +void DrawInv(CelOutputBuffer out); + void DrawInvBelt(CelOutputBuffer out); BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag); BOOL SpecialAutoPlace(int pnum, int ii, const ItemStruct &item); diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 5a3ce1fa8..1af19f574 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -533,7 +533,7 @@ static void DrawObject(int x, int y, int ox, int oy, BOOL pre) } } -static void scrollrt_draw_dungeon(int sx, int sy, int dx, int dy); +static void scrollrt_draw_dungeon(CelOutputBuffer out, int sx, int sy, int dx, int dy); /** * @brief Render a cell @@ -716,12 +716,13 @@ static void DrawPlayerHelper(int x, int y, int sx, int sy) /** * @brief Render object sprites + * @param out Buffer to render to * @param sx dPiece coordinate * @param sy dPiece coordinate - * @param dx Back buffer coordinate - * @param dy Back buffer coordinate + * @param dx Buffer coordinate + * @param dy Buffer coordinate */ -static void scrollrt_draw_dungeon(int sx, int sy, int dx, int dy) +static void scrollrt_draw_dungeon(CelOutputBuffer out, int sx, int sy, int dx, int dy) { int mi, px, py, nCel, nMon, negMon, frames; char bFlag, bDead, bObj, bItem, bPlr, bArch, bMap, negPlr, dd; @@ -825,7 +826,7 @@ static void scrollrt_draw_dungeon(int sx, int sy, int dx, int dy) if (sx > 0 && sy > 0 && dy > TILE_HEIGHT + SCREEN_Y) { bArch = dSpecial[sx - 1][sy - 1]; if (bArch != 0) { - CelDraw(dx, dy - TILE_HEIGHT, pSpecialCels, bArch, 64); + CelDrawTo(out, dx, dy - TILE_HEIGHT, pSpecialCels, bArch, 64); } } } @@ -883,14 +884,15 @@ static void scrollrt_drawFloor(int x, int y, int sx, int sy, int rows, int colum /** * @brief Render a row of tile + * @param out Output buffer * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Back buffer coordinate - * @param sy Back buffer coordinate + * @param sx Buffer coordinate + * @param sy Buffer coordinate * @param rows Number of rows * @param columns Tile in a row */ -static void scrollrt_draw(int x, int y, int sx, int sy, int rows, int columns) +static void scrollrt_draw(CelOutputBuffer out, int x, int y, int sx, int sy, int rows, int columns) { assert(gpBuffer); @@ -908,12 +910,12 @@ static void scrollrt_draw(int x, int y, int sx, int sy, int rows, int columns) // sprite screen position rather than tile position. if (IsWall(x, y) && (IsWall(x + 1, y) || (x > 0 && IsWall(x - 1, y)))) { // Part of a wall aligned on the x-axis if (IsWalkable(x + 1, y - 1) && IsWalkable(x, y - 1)) { // Has walkable area behind it - scrollrt_draw_dungeon(x + 1, y - 1, sx + TILE_WIDTH, sy); + scrollrt_draw_dungeon(out, x + 1, y - 1, sx + TILE_WIDTH, sy); } } } if (dPiece[x][y] != 0) { - scrollrt_draw_dungeon(x, y, sx, sy); + scrollrt_draw_dungeon(out, x, y, sx, sy); } } ShiftGrid(&x, &y, 1, 0); @@ -1112,10 +1114,11 @@ void CalcViewportGeometry() /** * @brief Configure render and process screen rows + * @param out Buffer to render to * @param x Center of view in dPiece coordinate * @param y Center of view in dPiece coordinate */ -static void DrawGame(int x, int y) +static void DrawGame(CelOutputBuffer out, int x, int y) { int sx, sy, columns, rows; @@ -1124,6 +1127,7 @@ static void DrawGame(int x, int y) gpBufEnd = &gpBuffer[BUFFER_WIDTH * (gnViewportHeight + SCREEN_Y)]; else gpBufEnd = &gpBuffer[BUFFER_WIDTH * (gnViewportHeight / 2 + SCREEN_Y)]; + out.end = gpBufEnd; // Adjust by player offset and tile grid alignment sx = ScrollInfo._sxoff + tileOffsetX + SCREEN_X; @@ -1206,7 +1210,7 @@ static void DrawGame(int x, int y) } scrollrt_drawFloor(x, y, sx, sy, rows, columns); - scrollrt_draw(x, y, sx, sy, rows, columns); + scrollrt_draw(out, x, y, sx, sy, rows, columns); // Allow rendering to the whole screen gpBufEnd = &gpBuffer[BUFFER_WIDTH * (gnScreenHeight + SCREEN_Y)]; @@ -1219,16 +1223,9 @@ static void DrawGame(int x, int y) // DevilutionX extension. extern void DrawControllerModifierHints(CelOutputBuffer out); -/** - * @brief Start rendering of screen, town variation - * @param StartX Center of view in dPiece coordinate - * @param StartY Center of view in dPiece coordinate - */ -void DrawView(int StartX, int StartY) +void DrawView(CelOutputBuffer out, int StartX, int StartY) { - CelOutputBuffer out = GlobalBackBuffer(); - - DrawGame(StartX, StartY); + DrawGame(out, StartX, StartY); if (automapflag) { DrawAutomap(out.subregion(0, 0, out.line_width, SCREEN_Y + gnViewportHeight)); } @@ -1237,12 +1234,12 @@ void DrawView(int StartX, int StartY) if (stextflag && !qtextflag) DrawSText(out); if (invflag) { - DrawInv(); + DrawInv(out); } else if (sbookflag) { DrawSpellBook(out); } - DrawDurIcon(); + DrawDurIcon(out); if (chrflag) { DrawChr(out); @@ -1274,13 +1271,13 @@ void DrawView(int StartX, int StartY) if (deathflag) { RedBack(); } else if (PauseMode != 0) { - gmenu_draw_pause(); + gmenu_draw_pause(out); } DrawControllerModifierHints(out); DrawPlrMsg(out); - gmenu_draw(); - doom_draw(); + gmenu_draw(out); + doom_draw(out); DrawInfoBox(out); DrawLifeFlask(); DrawManaFlask(); @@ -1552,7 +1549,7 @@ void DrawAndBlit() lock_buf(0); CelOutputBuffer out = GlobalBackBuffer(); - DrawView(ViewX, ViewY); + DrawView(out, ViewX, ViewY); if (ctrlPan) { DrawCtrlPan(out); } diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 27d391658..675cac37b 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -31,7 +31,15 @@ int RowsCoveredByPanel(); void CalcTileOffset(int *offsetX, int *offsetY); void TilesInView(int *columns, int *rows); void CalcViewportGeometry(); -void DrawView(int StartX, int StartY); + +/** + * @brief Start rendering of screen, town variation + * @param out Buffer to render to + * @param StartX Center of view in dPiece coordinate + * @param StartY Center of view in dPiece coordinate + */ +void DrawView(CelOutputBuffer out, int StartX, int StartY); + void ClearScreenBuffer(); #ifdef _DEBUG void ScrollView(); diff --git a/Source/stores.cpp b/Source/stores.cpp index fb12101df..4d5957052 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -153,7 +153,7 @@ void PrintSString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char sx += k; } if (stextsel == y) { - CelDraw(cjustflag ? xx + x + k - 20 : xx + x - 20, s + 45 + SCREEN_Y + UI_OFFSET_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); + CelDrawTo(out, cjustflag ? xx + x + k - 20 : xx + x - 20, s + 45 + SCREEN_Y + UI_OFFSET_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); } for (i = 0; i < len; i++) { c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; @@ -176,7 +176,7 @@ void PrintSString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char } } if (stextsel == y) { - CelDraw(cjustflag ? (xx + x + k + 4) : (PANEL_X + 596 - x), s + 45 + SCREEN_Y + UI_OFFSET_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); + CelDrawTo(out, cjustflag ? (xx + x + k + 4) : (PANEL_X + 596 - x), s + 45 + SCREEN_Y + UI_OFFSET_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); } }