diff --git a/Source/automap.cpp b/Source/automap.cpp index 0762f32ca..ea123f573 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -277,8 +277,8 @@ void SearchAutomapItem(CelOutputBuffer out) Sint32 px = i - 2 * AutoMapXOfs - ViewX; Sint32 py = j - 2 * AutoMapYOfs - ViewY; - x = (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AmLine16 + gnScreenWidth / 2 + SCREEN_X; - y = (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AmLine8 + (gnScreenHeight - PANEL_HEIGHT) / 2 + SCREEN_Y; + x = (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AmLine16 + gnScreenWidth / 2; + y = (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AmLine8 + (gnScreenHeight - PANEL_HEIGHT) / 2; if (PANELS_COVER) { if (invflag || sbookflag) @@ -318,8 +318,8 @@ void DrawAutomapPlr(CelOutputBuffer out, int pnum) px = x - 2 * AutoMapXOfs - ViewX; py = y - 2 * AutoMapYOfs - ViewY; - x = (plr[pnum]._pxoff * AutoMapScale / 100 >> 1) + (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AmLine16 + gnScreenWidth / 2 + SCREEN_X; - y = (plr[pnum]._pyoff * AutoMapScale / 100 >> 1) + (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AmLine8 + (gnScreenHeight - PANEL_HEIGHT) / 2 + SCREEN_Y; + x = (plr[pnum]._pxoff * AutoMapScale / 100 >> 1) + (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AmLine16 + gnScreenWidth / 2; + y = (plr[pnum]._pyoff * AutoMapScale / 100 >> 1) + (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AmLine8 + (gnScreenHeight - PANEL_HEIGHT) / 2; if (PANELS_COVER) { if (invflag || sbookflag) @@ -621,11 +621,11 @@ void DrawAutomap(CelOutputBuffer out) mapy = AutoMapY - 1; if (cells & 1) { - sx = gnScreenWidth / 2 + SCREEN_X - AmLine64 * ((cells - 1) >> 1); - sy = (gnScreenHeight - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * ((cells + 1) >> 1); + sx = gnScreenWidth / 2 - AmLine64 * ((cells - 1) >> 1); + sy = (gnScreenHeight - PANEL_HEIGHT) / 2 - AmLine32 * ((cells + 1) >> 1); } else { - sx = gnScreenWidth / 2 + SCREEN_X - AmLine64 * (cells >> 1) + AmLine32; - sy = (gnScreenHeight - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * (cells >> 1) - AmLine16; + sx = gnScreenWidth / 2 - AmLine64 * (cells >> 1) + AmLine32; + sy = (gnScreenHeight - PANEL_HEIGHT) / 2 - AmLine32 * (cells >> 1) - AmLine16; } if (ViewX & 1) { sx -= AmLine16; diff --git a/Source/capture.cpp b/Source/capture.cpp index 2393e9de3..c73c19e40 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -152,8 +152,8 @@ static void RedPalette() } palette_update(); SDL_Rect SrcRect = { - SCREEN_X, - SCREEN_Y, + BUFFER_BORDER_LEFT, + BUFFER_BORDER_TOP, gnScreenWidth, gnScreenHeight, }; @@ -180,7 +180,6 @@ void CaptureScreen() lock_buf(2); CelOutputBuffer buf = GlobalBackBuffer(); - buf = buf.subregion(SCREEN_X, SCREEN_Y, gnScreenWidth, gnScreenHeight); success = CaptureHdr(buf.w(), buf.h(), out_stream); if (success) { success = CapturePix(buf, out_stream); diff --git a/Source/control.cpp b/Source/control.cpp index 8d2fd2b20..ee039522d 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -385,8 +385,8 @@ void DrawSpellList(CelOutputBuffer out) if (currlevel == 0 && !spelldata[j].sTownSpell) SetSpellTrans(RSPLTYPE_INVALID); DrawSpellCel(out, x, y, pSpellCels, SpellITbl[j], SPLICONLENGTH); - lx = x - BORDER_LEFT; - ly = y - BORDER_TOP - SPLICONLENGTH; + lx = x; + ly = y - SPLICONLENGTH; if (MouseX >= lx && MouseX < lx + SPLICONLENGTH && MouseY >= ly && MouseY < ly + SPLICONLENGTH) { pSpell = (spell_id)j; pSplType = (spell_type)i; @@ -656,9 +656,9 @@ void DrawLifeFlask(CelOutputBuffer out) filled = 11; filled += 2; - DrawFlask(out, pLifeBuff, 13, 3, SCREEN_X + PANEL_LEFT + 109, SCREEN_Y + PANEL_TOP - 13, filled); + DrawFlask(out, pLifeBuff, 13, 3, PANEL_LEFT + 109, PANEL_TOP - 13, filled); if (filled != 13) - DrawFlask(out, pBtmBuff, 109, filled + 3, SCREEN_X + PANEL_LEFT + 109, SCREEN_Y + PANEL_TOP - 13 + filled, 13 - filled); + DrawFlask(out, pBtmBuff, 109, filled + 3, PANEL_LEFT + 109, PANEL_TOP - 13 + filled, 13 - filled); } void UpdateLifeFlask(CelOutputBuffer out) @@ -693,9 +693,9 @@ void DrawManaFlask(CelOutputBuffer out) filled = 11; filled += 2; - DrawFlask(out, pManaBuff, 13, 3, SCREEN_X + PANEL_LEFT + 475, SCREEN_Y + PANEL_TOP - 13, filled); + DrawFlask(out, pManaBuff, 13, 3, PANEL_LEFT + 475, PANEL_TOP - 13, filled); if (filled != 13) - DrawFlask(out, pBtmBuff, 475, filled + 3, SCREEN_X + PANEL_LEFT + 475, SCREEN_Y + PANEL_TOP - 13 + filled, 13 - filled); + DrawFlask(out, pBtmBuff, 475, filled + 3, PANEL_LEFT + 475, PANEL_TOP - 13 + filled, 13 - filled); } void control_update_life_mana() @@ -861,8 +861,8 @@ void DoSpeedBook() spselflag = TRUE; xo = PANEL_X + 12 + SPLICONLENGTH * 10; yo = PANEL_Y - 17; - X = xo - (BORDER_LEFT - SPLICONLENGTH / 2); - Y = yo - (BORDER_TOP + SPLICONLENGTH / 2); + X = xo + SPLICONLENGTH / 2; + Y = yo - SPLICONLENGTH / 2; if (plr[myplr]._pRSpell != SPL_INVALID) { for (i = 0; i < 4; i++) { @@ -884,8 +884,8 @@ void DoSpeedBook() for (j = 1; j < MAX_SPELLS; j++) { if (spell & spells) { if (j == plr[myplr]._pRSpell && i == plr[myplr]._pRSplType) { - X = xo - (BORDER_LEFT - SPLICONLENGTH / 2); - Y = yo - (BORDER_TOP + SPLICONLENGTH / 2); + X = xo + SPLICONLENGTH / 2; + Y = yo - SPLICONLENGTH / 2; } xo -= SPLICONLENGTH; if (xo == PANEL_X + 12 - SPLICONLENGTH) { @@ -1311,16 +1311,12 @@ void DrawInfoBox(CelOutputBuffer out) void PrintGameStr(CelOutputBuffer out, int x, int y, const char *str, int color) { - BYTE c; - int sx, sy; - sx = x + SCREEN_X; - sy = y + SCREEN_Y; while (*str) { - c = gbFontTransTbl[(BYTE)*str++]; + BYTE c = gbFontTransTbl[(BYTE)*str++]; c = fontframe[c]; if (c) - PrintChar(out, sx, sy, c, color); - sx += fontkern[c] + 1; + PrintChar(out, x, y, c, color); + x += fontkern[c] + 1; } } @@ -1338,10 +1334,8 @@ static void MY_PlrStringXY(CelOutputBuffer out, int x, int y, int endX, const ch { BYTE c; const char *tmp; - int sx, sy, screen_x, line, widthOffset; + int screen_x, line, widthOffset; - sx = x + SCREEN_X; - sy = y + SCREEN_Y; widthOffset = endX - x + 1; line = 0; screen_x = 0; @@ -1352,16 +1346,16 @@ static void MY_PlrStringXY(CelOutputBuffer out, int x, int y, int endX, const ch } if (screen_x < widthOffset) line = (widthOffset - screen_x) >> 1; - sx += line; + x += line; while (*pszStr) { c = gbFontTransTbl[(BYTE)*pszStr++]; c = fontframe[c]; line += fontkern[c] + base; if (c) { if (line < widthOffset) - PrintChar(out, sx, sy, c, col); + PrintChar(out, x, y, c, col); } - sx += fontkern[c] + base; + x += fontkern[c] + base; } } @@ -1371,7 +1365,7 @@ void DrawChr(CelOutputBuffer out) char chrstr[64]; int mindam, maxdam; - CelDrawTo(out, SCREEN_X, 351 + SCREEN_Y, pChrPanel, 1, SPANEL_WIDTH); + CelDrawTo(out, 0, 351, 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); @@ -1545,13 +1539,13 @@ void DrawChr(CelOutputBuffer out) ADD_PlrStringXY(out, 95, 266, 126, chrstr, COL_RED); plr_class pc = plr[myplr]._pClass; if (plr[myplr]._pBaseStr < MaxStats[pc][ATTRIB_STR]) - CelDrawTo(out, 137 + SCREEN_X, 159 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41); + CelDrawTo(out, 137, 159, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41); if (plr[myplr]._pBaseMag < MaxStats[pc][ATTRIB_MAG]) - CelDrawTo(out, 137 + SCREEN_X, 187 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_MAG] + 4, 41); + CelDrawTo(out, 137, 187, pChrButtons, chrbtn[ATTRIB_MAG] + 4, 41); if (plr[myplr]._pBaseDex < MaxStats[pc][ATTRIB_DEX]) - CelDrawTo(out, 137 + SCREEN_X, 216 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_DEX] + 6, 41); + CelDrawTo(out, 137, 216, pChrButtons, chrbtn[ATTRIB_DEX] + 6, 41); if (plr[myplr]._pBaseVit < MaxStats[pc][ATTRIB_VIT]) - CelDrawTo(out, 137 + SCREEN_X, 244 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_VIT] + 8, 41); + CelDrawTo(out, 137, 244, pChrButtons, chrbtn[ATTRIB_VIT] + 8, 41); } if (plr[myplr]._pMaxHP > plr[myplr]._pMaxHPBase) @@ -1747,7 +1741,7 @@ void RedBack(CelOutputBuffer out) BYTE *dst, *tbl; if (leveltype != DTYPE_HELL) { - dst = out.at(SCREEN_X, SCREEN_Y); + dst = out.begin(); tbl = &pLightTbl[idx]; for (h = gnViewportHeight; h; h--, dst += out.pitch() - gnScreenWidth) { for (w = gnScreenWidth; w; w--) { @@ -1756,7 +1750,7 @@ void RedBack(CelOutputBuffer out) } } } else { - dst = out.at(SCREEN_X, SCREEN_Y); + dst = out.begin(); tbl = &pLightTbl[idx]; for (h = gnViewportHeight; h; h--, dst += out.pitch() - gnScreenWidth) { for (w = gnScreenWidth; w; w--) { @@ -1833,20 +1827,20 @@ void DrawSpellBook(CelOutputBuffer out) char st; unsigned __int64 spl; - CelDrawTo(out, RIGHT_PANEL_X, 351 + SCREEN_Y, pSpellBkCel, 1, SPANEL_WIDTH); + CelDrawTo(out, RIGHT_PANEL_X, 351, pSpellBkCel, 1, SPANEL_WIDTH); if (gbIsHellfire && sbooktab < 5) { - CelDrawTo(out, RIGHT_PANEL_X + 61 * sbooktab + 7, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 61); + CelDrawTo(out, RIGHT_PANEL_X + 61 * sbooktab + 7, 348, 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++; } - CelDrawTo(out, sx, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 76); + CelDrawTo(out, sx, 348, pSBkBtnCel, sbooktab + 1, 76); } spl = plr[myplr]._pMemSpells | plr[myplr]._pISpells | plr[myplr]._pAblSpells; - yp = 55 + SCREEN_Y; + yp = 55; for (i = 1; i < 8; i++) { sn = SpellPages[sbooktab][i - 1]; if (sn != -1 && spl & SPELLBIT(sn)) { @@ -1932,7 +1926,7 @@ void DrawGoldSplit(CelOutputBuffer out, int amount) int screen_x, i; screen_x = 0; - CelDrawTo(out, 351 + SCREEN_X, 178 + SCREEN_Y, pGBoxBuff, 1, 261); + CelDrawTo(out, 351, 178, 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)); @@ -1951,7 +1945,7 @@ void DrawGoldSplit(CelOutputBuffer out, int amount) } else { screen_x = 450; } - CelDrawTo(out, screen_x, 140 + SCREEN_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); + CelDrawTo(out, screen_x, 140, pSPentSpn2Cels, PentSpn2Spin(), 12); } void control_drop_gold(char vkey) @@ -2029,7 +2023,7 @@ static char *control_print_talk_msg(CelOutputBuffer out, char *msg, int *x, int BYTE c; int width; - *x += 200 + SCREEN_X; + *x += 200; y += 22 + PANEL_Y; width = *x; while (*msg) { diff --git a/Source/engine.h b/Source/engine.h index 0e763bac5..061f75454 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -137,7 +137,7 @@ struct CelOutputBuffer { */ CelOutputBuffer subregion(Sint16 x, Sint16 y, Uint16 w, Uint16 h) const { - return CelOutputBuffer(surface, SDL_Rect { x, y, w, h }); + return CelOutputBuffer(surface, SDL_Rect { region.x + x, region.y + y, w, h }); } /** @@ -146,7 +146,7 @@ struct CelOutputBuffer { CelOutputBuffer subregionY(Sint16 y, Sint16 h) const { SDL_Rect subregion = region; - subregion.y = y; + subregion.y += y; subregion.h = h; return CelOutputBuffer(surface, subregion); } diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index d70b1f857..8ce983277 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -187,7 +187,7 @@ 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; + x = 16 + w / 2; CelDrawTo(out, x + PANEL_LEFT, y - 10, optbar_cel, 1, 287); step = pItem->dwFlags & 0xFFF; nSteps = (pItem->dwFlags & 0xFFF000) >> 12; @@ -197,7 +197,7 @@ static void gmenu_draw_menu_item(CelOutputBuffer out, TMenuItem *pItem, int y) gmenu_clear_buffer(out, x + 2 + PANEL_LEFT, y - 12, pos + 13, 28); CelDrawTo(out, x + 2 + pos + PANEL_LEFT, y - 12, option_cel, 1, 27); } - x = gnScreenWidth / 2 - w / 2 + SCREEN_X; + x = gnScreenWidth / 2 - w / 2; light_table_index = (pItem->dwFlags & GMENU_ENABLED) ? 0 : 15; gmenu_print_text(out, x, y, pItem->pszStr); if (pItem == sgpCurrItem) { @@ -223,11 +223,11 @@ void gmenu_draw(CelOutputBuffer out) LogoAnim_frame = 1; LogoAnim_tick = ticks; } - CelDrawTo(out, (gnScreenWidth - 430) / 2 + SCREEN_X, 102 + SCREEN_Y + UI_OFFSET_Y, sgpLogo, LogoAnim_frame, 430); + CelDrawTo(out, (gnScreenWidth - 430) / 2, 102 + UI_OFFSET_Y, sgpLogo, LogoAnim_frame, 430); } else { - CelDrawTo(out, (gnScreenWidth - 296) / 2 + SCREEN_X, 102 + SCREEN_Y + UI_OFFSET_Y, sgpLogo, 1, 296); + CelDrawTo(out, (gnScreenWidth - 296) / 2, 102 + UI_OFFSET_Y, sgpLogo, 1, 296); } - y = 160 + SCREEN_Y + UI_OFFSET_Y; + y = 160 + UI_OFFSET_Y; i = sgpCurrentMenu; if (sgpCurrentMenu->fnMenu) { while (i->fnMenu) { diff --git a/Source/help.cpp b/Source/help.cpp index 4df8b2330..96099c72f 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -460,7 +460,7 @@ static void DrawHelpLine(CelOutputBuffer out, int x, int y, char *text, char col width = 0; sx = x + 32 + PANEL_X; - sy = y * 12 + 44 + SCREEN_Y + UI_OFFSET_Y; + sy = y * 12 + 44 + UI_OFFSET_Y; while (*text) { c = gbFontTransTbl[(BYTE)*text]; text++; diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 2e4c992d7..38bee1885 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -244,13 +244,13 @@ static void DrawCutscene() lock_buf(1); CelOutputBuffer out = GlobalBackBuffer(); - CelDrawTo(out, PANEL_X, 480 + SCREEN_Y - 1 + UI_OFFSET_Y, sgpBackCel, 1, 640); + CelDrawTo(out, PANEL_X, 480 - 1 + UI_OFFSET_Y, sgpBackCel, 1, 640); for (i = 0; i < sgdwProgress; i++) { DrawProgress( out, BarPos[progress_id][0] + i + PANEL_X, - BarPos[progress_id][1] + SCREEN_Y + UI_OFFSET_Y, + BarPos[progress_id][1] + UI_OFFSET_Y, progress_id); } diff --git a/Source/inv.cpp b/Source/inv.cpp index 2e69d217e..9f94b2b22 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -167,10 +167,10 @@ void DrawInv(CelOutputBuffer out) BOOL invtest[NUM_INV_GRID_ELEM]; int frame, frame_width, color, screen_x, screen_y, i, j, ii; - CelDrawTo(out, RIGHT_PANEL_X, 351 + SCREEN_Y, pInvCels, 1, SPANEL_WIDTH); + CelDrawTo(out, RIGHT_PANEL_X, 351, pInvCels, 1, SPANEL_WIDTH); if (!plr[myplr].InvBody[INVLOC_HEAD].isEmpty()) { - InvDrawSlotBack(out, RIGHT_PANEL_X + 133, 59 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(out, RIGHT_PANEL_X + 133, 59, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_HEAD]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -184,29 +184,29 @@ void DrawInv(CelOutputBuffer out) color = ICOL_RED; } if (frame <= 179) { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 133, 59, pCursCels, frame, frame_width); } else { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 133, 59, pCursCels2, frame - 179, frame_width); } } if (plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) { if (frame <= 179) { - CelClippedDrawTo(out, RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 133, 59, pCursCels, frame, frame_width); } else { - CelClippedDrawTo(out, RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 133, 59, pCursCels2, frame - 179, frame_width); } } else { if (frame <= 179) { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 133, 59, pCursCels, frame, frame_width, 1); } else { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels2, frame - 179, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 133, 59, pCursCels2, frame - 179, frame_width, 1); } } } if (!plr[myplr].InvBody[INVLOC_RING_LEFT].isEmpty()) { - InvDrawSlotBack(out, RIGHT_PANEL_X + 48, 205 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); + InvDrawSlotBack(out, RIGHT_PANEL_X + 48, 205, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_RING_LEFT]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -220,29 +220,29 @@ void DrawInv(CelOutputBuffer out) color = ICOL_RED; } if (frame <= 179) { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 48, 205, pCursCels, frame, frame_width); } else { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 48, 205, pCursCels2, frame - 179, frame_width); } } if (plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) { if (frame <= 179) { - CelClippedDrawTo(out, RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 48, 205, pCursCels, frame, frame_width); } else { - CelClippedDrawTo(out, RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 48, 205, pCursCels2, frame - 179, frame_width); } } else { if (frame <= 179) { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 48, 205, pCursCels, frame, frame_width, 1); } else { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels2, frame - 179, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 48, 205, pCursCels2, frame - 179, frame_width, 1); } } } if (!plr[myplr].InvBody[INVLOC_RING_RIGHT].isEmpty()) { - InvDrawSlotBack(out, RIGHT_PANEL_X + 249, 205 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); + InvDrawSlotBack(out, RIGHT_PANEL_X + 249, 205, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_RING_RIGHT]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -256,29 +256,29 @@ void DrawInv(CelOutputBuffer out) color = ICOL_RED; } if (frame <= 179) { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 249, 205, pCursCels, frame, frame_width); } else { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 249, 205, pCursCels2, frame - 179, frame_width); } } if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) { if (frame <= 179) { - CelClippedDrawTo(out, RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 249, 205, pCursCels, frame, frame_width); } else { - CelClippedDrawTo(out, RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 249, 205, pCursCels2, frame - 179, frame_width); } } else { if (frame <= 179) { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 249, 205, pCursCels, frame, frame_width, 1); } else { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels2, frame - 179, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 249, 205, pCursCels2, frame - 179, frame_width, 1); } } } if (!plr[myplr].InvBody[INVLOC_AMULET].isEmpty()) { - InvDrawSlotBack(out, RIGHT_PANEL_X + 205, 60 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); + InvDrawSlotBack(out, RIGHT_PANEL_X + 205, 60, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_AMULET]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -292,35 +292,35 @@ void DrawInv(CelOutputBuffer out) color = ICOL_RED; } if (frame <= 179) { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 205, 60, pCursCels, frame, frame_width); } else { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 205, 60, pCursCels2, frame - 179, frame_width); } } if (plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) { if (frame <= 179) { - CelClippedDrawTo(out, RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 205, 60, pCursCels, frame, frame_width); } else { - CelClippedDrawTo(out, RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 205, 60, pCursCels2, frame - 179, frame_width); } } else { if (frame <= 179) { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 205, 60, pCursCels, frame, frame_width, 1); } else { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels2, frame - 179, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 205, 60, pCursCels2, frame - 179, frame_width, 1); } } } if (!plr[myplr].InvBody[INVLOC_HAND_LEFT].isEmpty()) { - InvDrawSlotBack(out, RIGHT_PANEL_X + 17, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(out, RIGHT_PANEL_X + 17, 160, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; // calc item offsets for weapons smaller than 2x3 slots screen_x = frame_width == INV_SLOT_SIZE_PX ? (RIGHT_PANEL_X + 31) : (RIGHT_PANEL_X + 17); - screen_y = InvItemHeight[frame] == (3 * INV_SLOT_SIZE_PX) ? (160 + SCREEN_Y) : (146 + SCREEN_Y); + screen_y = InvItemHeight[frame] == (3 * INV_SLOT_SIZE_PX) ? (160) : (146); if (pcursinvitem == INVITEM_HAND_LEFT) { color = ICOL_WHITE; @@ -355,12 +355,12 @@ void DrawInv(CelOutputBuffer out) if (plr[myplr]._pClass != PC_BARBARIAN || plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_SWORD && plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_MACE) { - InvDrawSlotBack(out, RIGHT_PANEL_X + 248, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(out, RIGHT_PANEL_X + 248, 160, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); light_table_index = 0; cel_transparency_active = TRUE; const int dst_x = RIGHT_PANEL_X + (frame_width == INV_SLOT_SIZE_PX ? 261 : 247); - const int dst_y = SCREEN_Y + 160; + const int dst_y = 160; if (frame <= 179) { CelClippedBlitLightTransTo(out, dst_x, dst_y, pCursCels, frame, frame_width); } else { @@ -372,13 +372,13 @@ void DrawInv(CelOutputBuffer out) } } if (!plr[myplr].InvBody[INVLOC_HAND_RIGHT].isEmpty()) { - InvDrawSlotBack(out, RIGHT_PANEL_X + 248, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(out, RIGHT_PANEL_X + 248, 160, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; // calc item offsets for weapons smaller than 2x3 slots screen_x = frame_width == INV_SLOT_SIZE_PX ? (RIGHT_PANEL_X + 261) : (RIGHT_PANEL_X + 249); - screen_y = InvItemHeight[frame] == 3 * INV_SLOT_SIZE_PX ? (160 + SCREEN_Y) : (146 + SCREEN_Y); + screen_y = InvItemHeight[frame] == 3 * INV_SLOT_SIZE_PX ? (160) : (146); if (pcursinvitem == INVITEM_HAND_RIGHT) { color = ICOL_WHITE; @@ -411,7 +411,7 @@ void DrawInv(CelOutputBuffer out) } if (!plr[myplr].InvBody[INVLOC_CHEST].isEmpty()) { - InvDrawSlotBack(out, RIGHT_PANEL_X + 133, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(out, RIGHT_PANEL_X + 133, 160, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_CHEST]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -425,23 +425,23 @@ void DrawInv(CelOutputBuffer out) color = ICOL_RED; } if (frame <= 179) { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 133, 160, pCursCels, frame, frame_width); } else { - CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelBlitOutlineTo(out, color, RIGHT_PANEL_X + 133, 160, pCursCels2, frame - 179, frame_width); } } if (plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) { if (frame <= 179) { - CelClippedDrawTo(out, RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 133, 160, pCursCels, frame, frame_width); } else { - CelClippedDrawTo(out, RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels2, frame - 179, frame_width); + CelClippedDrawTo(out, RIGHT_PANEL_X + 133, 160, pCursCels2, frame - 179, frame_width); } } else { if (frame <= 179) { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 133, 160, pCursCels, frame, frame_width, 1); } else { - CelDrawLightRedTo(out, RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels2, frame - 179, frame_width, 1); + CelDrawLightRedTo(out, RIGHT_PANEL_X + 133, 160, pCursCels2, frame - 179, frame_width, 1); } } } @@ -452,7 +452,7 @@ void DrawInv(CelOutputBuffer out) InvDrawSlotBack( out, InvRect[i + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X, - InvRect[i + SLOTXY_INV_FIRST].Y + SCREEN_Y - 1, + InvRect[i + SLOTXY_INV_FIRST].Y - 1, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); } @@ -480,14 +480,14 @@ void DrawInv(CelOutputBuffer out) out, color, InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X, - InvRect[j + SLOTXY_INV_FIRST].Y + SCREEN_Y - 1, + InvRect[j + SLOTXY_INV_FIRST].Y - 1, pCursCels, frame, frame_width); } else { CelBlitOutlineTo( out, color, InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X, - InvRect[j + SLOTXY_INV_FIRST].Y + SCREEN_Y - 1, + InvRect[j + SLOTXY_INV_FIRST].Y - 1, pCursCels2, frame - 179, frame_width); } } @@ -497,13 +497,13 @@ void DrawInv(CelOutputBuffer out) CelClippedDrawTo( out, InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X, - InvRect[j + SLOTXY_INV_FIRST].Y + SCREEN_Y - 1, + InvRect[j + SLOTXY_INV_FIRST].Y - 1, pCursCels, frame, frame_width); } else { CelClippedDrawTo( out, InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X, - InvRect[j + SLOTXY_INV_FIRST].Y + SCREEN_Y - 1, + InvRect[j + SLOTXY_INV_FIRST].Y - 1, pCursCels2, frame - 179, frame_width); } } else { @@ -511,13 +511,13 @@ void DrawInv(CelOutputBuffer out) CelDrawLightRedTo( out, InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X, - InvRect[j + SLOTXY_INV_FIRST].Y + SCREEN_Y - 1, + InvRect[j + SLOTXY_INV_FIRST].Y - 1, pCursCels, frame, frame_width, 1); } else { CelDrawLightRedTo( out, InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X, - InvRect[j + SLOTXY_INV_FIRST].Y + SCREEN_Y - 1, + InvRect[j + SLOTXY_INV_FIRST].Y - 1, pCursCels2, frame - 179, frame_width, 1); } } diff --git a/Source/items.cpp b/Source/items.cpp index 8939d9b76..fd8e20550 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3962,8 +3962,8 @@ void PrintItemPower(char plidx, ItemStruct *x) static void DrawUTextBack(CelOutputBuffer out) { - CelDrawTo(out, RIGHT_PANEL_X - SPANEL_WIDTH + 24, SCREEN_Y + 327, pSTextBoxCels, 1, 271); - DrawHalfTransparentRectTo(out, RIGHT_PANEL_X - SPANEL_WIDTH + 27, SCREEN_Y + 28, 265, 297); + CelDrawTo(out, RIGHT_PANEL_X - SPANEL_WIDTH + 24, 327, pSTextBoxCels, 1, 271); + DrawHalfTransparentRectTo(out, RIGHT_PANEL_X - SPANEL_WIDTH + 27, 28, 265, 297); } void PrintUString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *str, int col) @@ -3971,8 +3971,8 @@ void PrintUString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char int len, width, sx, sy, i, k; BYTE c; - sx = x + 32 + SCREEN_X; - sy = y * 12 + 44 + SCREEN_Y; + sx = x + 32; + sy = y * 12 + 44; len = strlen(str); k = 0; if (cjustflag) { @@ -3996,8 +3996,8 @@ void PrintUString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char static void DrawULine(CelOutputBuffer out, int y) { - BYTE *src = out.at(SCREEN_X + 26 + RIGHT_PANEL - SPANEL_WIDTH, SCREEN_Y + 25); - BYTE *dst = out.at(26 + RIGHT_PANEL_X - SPANEL_WIDTH, SCREEN_Y + y * 12 + 38); + BYTE *src = out.at(26 + RIGHT_PANEL - SPANEL_WIDTH, 25); + BYTE *dst = out.at(26 + RIGHT_PANEL_X - SPANEL_WIDTH, y * 12 + 38); for (int i = 0; i < 3; i++, src += out.pitch(), dst += out.pitch()) memcpy(dst, src, 267); // BUGFIX: should be 267 (fixed) diff --git a/Source/minitext.cpp b/Source/minitext.cpp index f8afab401..ba2c8f0f3 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -145,7 +145,7 @@ int CalcTextSpeed(int nSFX) void PrintQTextChr(int sx, int sy, Uint8 *pCelBuff, int nCel) { CelOutputBuffer buf = GlobalBackBuffer(); - const int start_y = 49 + SCREEN_Y + UI_OFFSET_Y; + const int start_y = 49 + UI_OFFSET_Y; buf = buf.subregionY(start_y, 260); CelDrawTo(buf, sx, sy - start_y, pCelBuff, nCel, 22); } @@ -158,7 +158,7 @@ void ScrollQTextContent(const char *pnl) { for (Uint32 currTime = SDL_GetTicks(); sgLastScroll + qtextSpd < currTime; sgLastScroll += qtextSpd) { qtexty--; - if (qtexty <= 49 + SCREEN_Y + UI_OFFSET_Y) { + if (qtexty <= 49 + UI_OFFSET_Y) { qtexty += 38; qtextptr = pnl; if (*pnl == '|') { @@ -202,7 +202,7 @@ static void DrawQTextContent(CelOutputBuffer out) } tx = 48 + PANEL_X; ty += lineHeight; - if (ty > 341 + SCREEN_Y + UI_OFFSET_Y) { + if (ty > 341 + UI_OFFSET_Y) { doneflag = true; } } @@ -241,7 +241,7 @@ void InitQTextMsg(int m) questlog = false; qtextptr = alltext[m].txtstr; qtextflag = true; - qtexty = 340 + SCREEN_Y + UI_OFFSET_Y; + qtexty = 340 + UI_OFFSET_Y; qtextSpd = CalcTextSpeed(alltext[m].sfxnr); sgLastScroll = SDL_GetTicks(); } @@ -250,8 +250,8 @@ void InitQTextMsg(int m) void DrawQTextBack(CelOutputBuffer out) { - CelDrawTo(out, PANEL_X + 24, SCREEN_Y + 327 + UI_OFFSET_Y, pTextBoxCels, 1, 591); - DrawHalfTransparentRectTo(out, PANEL_X + 27, SCREEN_Y + UI_OFFSET_Y + 28, 585, 297); + CelDrawTo(out, PANEL_X + 24, 327 + UI_OFFSET_Y, pTextBoxCels, 1, 591); + DrawHalfTransparentRectTo(out, PANEL_X + 27, UI_OFFSET_Y + 28, 585, 297); } void DrawQText(CelOutputBuffer out) diff --git a/Source/palette.cpp b/Source/palette.cpp index bb34342ee..7242eee44 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -230,7 +230,7 @@ void PaletteFadeIn(int fr) DWORD tc = SDL_GetTicks(); for (i = 0; i < 256; i = (SDL_GetTicks() - tc) / 2.083) { // 32 frames @ 60hz SetFadeLevel(i); - SDL_Rect SrcRect = { SCREEN_X, SCREEN_Y, gnScreenWidth, gnScreenHeight }; + SDL_Rect SrcRect = { BUFFER_BORDER_LEFT, BUFFER_BORDER_TOP, gnScreenWidth, gnScreenHeight }; BltFast(&SrcRect, NULL); RenderPresent(); } @@ -247,7 +247,7 @@ void PaletteFadeOut(int fr) DWORD tc = SDL_GetTicks(); for (i = 256; i > 0; i = 256 - (SDL_GetTicks() - tc) / 2.083) { // 32 frames @ 60hz SetFadeLevel(i); - SDL_Rect SrcRect = { SCREEN_X, SCREEN_Y, gnScreenWidth, gnScreenHeight }; + SDL_Rect SrcRect = { BUFFER_BORDER_LEFT, BUFFER_BORDER_TOP, gnScreenWidth, gnScreenHeight }; BltFast(&SrcRect, NULL); RenderPresent(); } diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index b9ae07577..a547207bd 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -87,8 +87,8 @@ void InitPlrMsg() void DrawPlrMsg(CelOutputBuffer out) { int i; - DWORD x = 10 + SCREEN_X; - DWORD y = 70 + SCREEN_Y; + DWORD x = 10; + DWORD y = 70; DWORD width = gnScreenWidth - 20; _plrmsg *pMsg; diff --git a/Source/quests.cpp b/Source/quests.cpp index b6fe6cd06..7c0feb847 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -810,8 +810,8 @@ static void PrintQLString(CelOutputBuffer out, int x, int y, BOOL cjustflag, con int len, width, i, k, sx, sy; BYTE c; - sx = x + 32 + SCREEN_X; - sy = y * 12 + 44 + SCREEN_Y; + sx = x + 32; + sy = y * 12 + 44; len = strlen(str); k = 0; if (cjustflag) { @@ -823,7 +823,7 @@ static void PrintQLString(CelOutputBuffer out, int x, int y, BOOL cjustflag, con sx += k; } if (qline == y) { - CelDrawTo(out, cjustflag ? x + k + 12 + SCREEN_X : x + 12 + SCREEN_X, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); + CelDrawTo(out, cjustflag ? x + k + 12 : x + 12, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); } for (i = 0; i < len; i++) { c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; @@ -834,7 +834,7 @@ static void PrintQLString(CelOutputBuffer out, int x, int y, BOOL cjustflag, con sx += fontkern[c] + 1; } if (qline == y) { - CelDrawTo(out, cjustflag ? x + k + 36 + SCREEN_X : 276 + SCREEN_X - x, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); + CelDrawTo(out, cjustflag ? x + k + 36 : 276 - x, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); } } @@ -843,7 +843,7 @@ void DrawQuestLog(CelOutputBuffer out) int y, i; PrintQLString(out, 0, 2, TRUE, "Quest Log", 3); - CelDrawTo(out, SCREEN_X, SCREEN_Y + 351, pQLogCel, 1, SPANEL_WIDTH); + CelDrawTo(out, 0, 351, pQLogCel, 1, SPANEL_WIDTH); y = qtopline; for (i = 0; i < numqlines; i++) { PrintQLString(out, 0, y, TRUE, questlist[qlist[i]]._qlstr, 0); diff --git a/Source/render.cpp b/Source/render.cpp index 28314448c..d2090435c 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -453,6 +453,14 @@ void RenderTile(CelOutputBuffer out, int x, int y) DWORD m, *pFrameTable; const DWORD *mask; + // TODO: Get rid of overdraw by rendering edge tiles separately. + out.region.x -= BUFFER_BORDER_LEFT; + out.region.y -= BUFFER_BORDER_TOP; + out.region.w += BUFFER_BORDER_LEFT; + out.region.h += BUFFER_BORDER_TOP; + x += BUFFER_BORDER_LEFT; + y += BUFFER_BORDER_TOP; + pFrameTable = (DWORD *)pDungeonCels; src = &pDungeonCels[SDL_SwapLE32(pFrameTable[level_cel_block & 0xFFF])]; @@ -505,7 +513,7 @@ void RenderTile(CelOutputBuffer out, int x, int y) } #endif - BYTE *dst_begin = out.at(0, SCREEN_Y); + BYTE *dst_begin = out.at(0, BUFFER_BORDER_TOP); BYTE *dst_end = out.end(); BYTE *dst = out.at(x, y); const int dst_pitch = out.pitch(); @@ -580,12 +588,20 @@ void world_draw_black_tile(CelOutputBuffer out, int sx, int sy) { int i, j; - if (sx >= SCREEN_X + gnScreenWidth || sy >= SCREEN_Y + gnViewportHeight + TILE_WIDTH / 2) + if (sx >= gnScreenWidth || sy >= gnViewportHeight + TILE_WIDTH / 2) return; - if (sx < SCREEN_X - (TILE_WIDTH - 4) || sy < SCREEN_Y) + if (sx < -(TILE_WIDTH - 4) || sy < 0) return; + // TODO: Get rid of overdraw by rendering edge tiles separately. + out.region.x -= BUFFER_BORDER_LEFT; + out.region.y -= BUFFER_BORDER_TOP; + out.region.w += BUFFER_BORDER_LEFT; + out.region.h += BUFFER_BORDER_TOP; + sx += BUFFER_BORDER_LEFT; + sy += BUFFER_BORDER_TOP; + BYTE *dst = out.at(sx + TILE_WIDTH / 2 - 2, sy); for (i = TILE_HEIGHT - 2, j = 1; i >= 0; i -= 2, j++, dst -= out.pitch() + 2) { if (dst < out.end()) diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 8db2c9f24..b30fa68c8 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -122,9 +122,7 @@ static void scrollrt_draw_cursor_back_buffer(CelOutputBuffer out) return; } - BlitCursor( - out.at(SCREEN_X + sgdwCursX, SCREEN_Y + sgdwCursY), out.pitch(), - sgSaveBack, sgdwCursWdt); + BlitCursor(out.at(sgdwCursX, sgdwCursY), out.pitch(), sgSaveBack, sgdwCursWdt); sgdwCursXOld = sgdwCursX; sgdwCursYOld = sgdwCursY; @@ -182,14 +180,12 @@ static void scrollrt_draw_cursor_item(CelOutputBuffer out) sgdwCursHgt -= sgdwCursY; sgdwCursHgt++; - BlitCursor( - sgSaveBack, sgdwCursWdt, - out.at(SCREEN_X + sgdwCursX, SCREEN_Y + sgdwCursY), out.pitch()); + BlitCursor(sgSaveBack, sgdwCursWdt, out.at(sgdwCursX, sgdwCursY), out.pitch()); mx++; my++; - out = out.subregion(0, 0, out.w() - 2, SCREEN_Y + gnScreenHeight); + out = out.subregion(0, 0, out.w() - 2, out.h()); if (pcurs >= CURSOR_FIRSTITEM) { col = PAL16_YELLOW + 5; if (plr[myplr].HoldItem._iMagical != 0) { @@ -199,22 +195,22 @@ static void scrollrt_draw_cursor_item(CelOutputBuffer out) col = PAL16_RED + 5; } if (pcurs <= 179) { - CelBlitOutlineTo(out, col, mx + SCREEN_X, my + cursH + SCREEN_Y - 1, pCursCels, pcurs, cursW); + CelBlitOutlineTo(out, col, mx, my + cursH - 1, pCursCels, pcurs, cursW); if (col != PAL16_RED + 5) { - CelClippedDrawSafeTo(out, mx + SCREEN_X, my + cursH + SCREEN_Y - 1, pCursCels, pcurs, cursW); + CelClippedDrawSafeTo(out, mx, my + cursH - 1, pCursCels, pcurs, cursW); } else { - CelDrawLightRedSafeTo(out, mx + SCREEN_X, my + cursH + SCREEN_Y - 1, pCursCels, pcurs, cursW, 1); + CelDrawLightRedSafeTo(out, mx, my + cursH - 1, pCursCels, pcurs, cursW, 1); } } else { - CelBlitOutlineTo(out, col, mx + SCREEN_X, my + cursH + SCREEN_Y - 1, pCursCels2, pcurs - 179, cursW); + CelBlitOutlineTo(out, col, mx, my + cursH - 1, pCursCels2, pcurs - 179, cursW); if (col != PAL16_RED + 5) { - CelClippedDrawSafeTo(out, mx + SCREEN_X, my + cursH + SCREEN_Y - 1, pCursCels2, pcurs - 179, cursW); + CelClippedDrawSafeTo(out, mx, my + cursH - 1, pCursCels2, pcurs - 179, cursW); } else { - CelDrawLightRedSafeTo(out, mx + SCREEN_X, my + cursH + SCREEN_Y - 1, pCursCels2, pcurs - 179, cursW, 0); + CelDrawLightRedSafeTo(out, mx, my + cursH - 1, pCursCels2, pcurs - 179, cursW, 0); } } } else { - CelClippedDrawSafeTo(out, mx + SCREEN_X, my + cursH + SCREEN_Y - 1, pCursCels, pcurs, cursW); + CelClippedDrawSafeTo(out, mx, my + cursH - 1, pCursCels, pcurs, cursW); } } @@ -799,7 +795,7 @@ static void scrollrt_draw_dungeon(CelOutputBuffer out, int sx, int sy, int dx, i // Tree leaves should always cover player when entering or leaving the tile, // So delay the rendering until after the next row is being drawn. // This could probably have been better solved by sprites in screen space. - if (sx > 0 && sy > 0 && dy > TILE_HEIGHT + SCREEN_Y) { + if (sx > 0 && sy > 0 && dy > TILE_HEIGHT) { char bArch = dSpecial[sx - 1][sy - 1]; if (bArch != 0) { CelDrawTo(out, dx, dy - TILE_HEIGHT, pSpecialCels, bArch, 64); @@ -876,7 +872,7 @@ static void scrollrt_draw(CelOutputBuffer out, int x, int y, int sx, int sy, int for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { if (x >= 0 && x < MAXDUNX && y >= 0 && y < MAXDUNY) { - if (x + 1 < MAXDUNX && y - 1 >= 0 && sx + TILE_WIDTH <= SCREEN_X + gnScreenWidth) { + if (x + 1 < MAXDUNX && y - 1 >= 0 && sx + TILE_WIDTH <= gnScreenWidth) { // Render objects behind walls first to prevent sprites, that are moving // between tiles, from poking through the walls as they exceed the tile bounds. // A proper fix for this would probably be to layout the sceen and render by @@ -919,8 +915,8 @@ static void Zoom(CelOutputBuffer out) { int wdt = gnScreenWidth / 2; - int src_x = SCREEN_X + gnScreenWidth / 2 - 1; - int dst_x = SCREEN_X + gnScreenWidth - 1; + int src_x = gnScreenWidth / 2 - 1; + int dst_x = gnScreenWidth - 1; if (PANELS_COVER) { if (chrflag || questlog) { @@ -933,8 +929,8 @@ static void Zoom(CelOutputBuffer out) } } - BYTE *src = out.at(src_x, SCREEN_Y + gnViewportHeight / 2 - 1); - BYTE *dst = out.at(dst_x, SCREEN_Y + gnViewportHeight - 1); + BYTE *src = out.at(src_x, gnViewportHeight / 2 - 1); + BYTE *dst = out.at(dst_x, gnViewportHeight - 1); for (int hgt = 0; hgt < gnViewportHeight / 2; hgt++) { for (int i = 0; i < wdt; i++) { @@ -1098,12 +1094,12 @@ static void DrawGame(CelOutputBuffer full_out, int x, int y) // Limit rendering to the view area CelOutputBuffer out = zoomflag - ? full_out.subregionY(0, SCREEN_Y + gnViewportHeight) - : full_out.subregionY(0, SCREEN_Y + gnViewportHeight / 2); + ? full_out.subregionY(0, gnViewportHeight) + : full_out.subregionY(0, gnViewportHeight / 2); // Adjust by player offset and tile grid alignment - sx = ScrollInfo._sxoff + tileOffsetX + SCREEN_X; - sy = ScrollInfo._syoff + tileOffsetY + SCREEN_Y; + sx = ScrollInfo._sxoff + tileOffsetX; + sy = ScrollInfo._syoff + tileOffsetY; columns = tileColums; rows = tileRows; @@ -1185,7 +1181,7 @@ static void DrawGame(CelOutputBuffer full_out, int x, int y) scrollrt_draw(out, x, y, sx, sy, rows, columns); if (!zoomflag) { - Zoom(full_out.subregionY(0, SCREEN_Y + gnScreenHeight)); + Zoom(full_out.subregionY(0, gnScreenHeight)); } } @@ -1196,7 +1192,7 @@ void DrawView(CelOutputBuffer out, int StartX, int StartY) { DrawGame(out, StartX, StartY); if (automapflag) { - DrawAutomap(out.subregionY(0, SCREEN_Y + gnViewportHeight)); + DrawAutomap(out.subregionY(0, gnViewportHeight)); } DrawMonsterHealthBar(out); @@ -1264,8 +1260,8 @@ void ClearScreenBuffer() assert(pal_surface != NULL); SDL_Rect SrcRect = { - SCREEN_X, - SCREEN_Y, + BUFFER_BORDER_LEFT, + BUFFER_BORDER_TOP, gnScreenWidth, gnScreenHeight, }; @@ -1397,10 +1393,7 @@ static void DrawFPS(CelOutputBuffer out) */ static void DoBlitScreen(Sint16 dwX, Sint16 dwY, Uint16 dwWdt, Uint16 dwHgt) { - SDL_Rect SrcRect = { dwX, dwY, dwWdt, dwHgt }; - SrcRect.x += SCREEN_X; - SrcRect.y += SCREEN_Y; - + SDL_Rect SrcRect = { BUFFER_BORDER_LEFT + dwX, BUFFER_BORDER_TOP + dwY, dwWdt, dwHgt }; SDL_Rect DstRect = { dwX, dwY, dwWdt, dwHgt }; BltFast(&SrcRect, &DstRect); diff --git a/Source/stores.cpp b/Source/stores.cpp index bf5975bb3..19d557c8e 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -63,16 +63,16 @@ const char *const talkname[] = { void DrawSTextBack(CelOutputBuffer out) { - CelDrawTo(out, PANEL_X + 344, 327 + SCREEN_Y + UI_OFFSET_Y, pSTextBoxCels, 1, 271); - DrawHalfTransparentRectTo(out, PANEL_X + 347, SCREEN_Y + UI_OFFSET_Y + 28, 265, 297); + CelDrawTo(out, PANEL_X + 344, 327 + UI_OFFSET_Y, pSTextBoxCels, 1, 271); + DrawHalfTransparentRectTo(out, PANEL_X + 347, UI_OFFSET_Y + 28, 265, 297); } void DrawSSlider(CelOutputBuffer out, int y1, int y2) { int yd1, yd2, yd3; - yd1 = y1 * 12 + 44 + SCREEN_Y + UI_OFFSET_Y; - yd2 = y2 * 12 + 44 + SCREEN_Y + UI_OFFSET_Y; + yd1 = y1 * 12 + 44 + UI_OFFSET_Y; + yd2 = y2 * 12 + 44 + UI_OFFSET_Y; if (stextscrlubtn != -1) CelDrawTo(out, PANEL_X + 601, yd1, pSTextSlidCels, 12, 12); else @@ -93,7 +93,7 @@ void DrawSSlider(CelOutputBuffer out, int y1, int y2) yd3 = 1000 * (stextsval + ((yd3 - stextup) >> 2)) / (storenumh - 1) * (y2 * 12 - y1 * 12 - 24) / 1000; else yd3 = 0; - CelDrawTo(out, 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 + UI_OFFSET_Y + yd3, pSTextSlidCels, 13, 12); } void AddSLine(int y) @@ -2289,7 +2289,7 @@ void PrintSString(CelOutputBuffer out, int x, int y, bool cjustflag, const char else xx = PANEL_X + 352; sx = xx + x; - sy = s + 44 + SCREEN_Y + UI_OFFSET_Y; + sy = s + 44 + UI_OFFSET_Y; len = strlen(str); if (stextsize) yy = 577; @@ -2305,7 +2305,7 @@ void PrintSString(CelOutputBuffer out, int x, int y, bool cjustflag, const char sx += k; } if (stextsel == y) { - CelDrawTo(out, 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 + UI_OFFSET_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); } for (i = 0; i < len; i++) { c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; @@ -2328,7 +2328,7 @@ void PrintSString(CelOutputBuffer out, int x, int y, bool cjustflag, const char } } if (stextsel == y) { - CelDrawTo(out, 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 + UI_OFFSET_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); } } @@ -2338,12 +2338,12 @@ void DrawSLine(CelOutputBuffer out, int y) BYTE *src, *dst; int width; if (stextsize) { - src = out.at(SCREEN_X + PANEL_LEFT + 26, SCREEN_Y + 25 + UI_OFFSET_Y); - dst = out.at(26 + PANEL_X, SCREEN_Y + sy + 38 + UI_OFFSET_Y); + src = out.at(PANEL_LEFT + 26, 25 + UI_OFFSET_Y); + dst = out.at(26 + PANEL_X, sy + 38 + UI_OFFSET_Y); width = 587; // BUGFIX: should be 587, not 586 (fixed) } else { - src = out.at(SCREEN_X + PANEL_LEFT + 346, SCREEN_Y + 25 + UI_OFFSET_Y); - dst = out.at(346 + PANEL_X, SCREEN_Y + sy + 38 + UI_OFFSET_Y); + src = out.at(PANEL_LEFT + 346, 25 + UI_OFFSET_Y); + dst = out.at(346 + PANEL_X, sy + 38 + UI_OFFSET_Y); width = 267; // BUGFIX: should be 267, not 266 (fixed) } diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index b391cf6fc..94ceb39c4 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -36,7 +36,12 @@ SDL_Surface *pal_surface; static void dx_create_back_buffer() { - pal_surface = SDL_CreateRGBSurfaceWithFormat(0, BUFFER_WIDTH, BUFFER_HEIGHT, 8, SDL_PIXELFORMAT_INDEX8); + pal_surface = SDL_CreateRGBSurfaceWithFormat( + /*flags=*/0, + /*width=*/BUFFER_BORDER_LEFT + gnScreenWidth + BUFFER_BORDER_RIGHT, + /*height=*/BUFFER_BORDER_TOP + gnScreenHeight + BUFFER_BORDER_BOTTOM, + /*depth=*/8, + SDL_PIXELFORMAT_INDEX8); if (pal_surface == NULL) { ErrSdl(); } @@ -125,7 +130,7 @@ CelOutputBuffer GlobalBackBuffer() return CelOutputBuffer(); } - return CelOutputBuffer(pal_surface); + return CelOutputBuffer(pal_surface, SDL_Rect{BUFFER_BORDER_LEFT, BUFFER_BORDER_TOP, gnScreenWidth, gnScreenHeight}); } void dx_cleanup() diff --git a/SourceX/qol.cpp b/SourceX/qol.cpp index cb47a3f53..f35fd3166 100644 --- a/SourceX/qol.cpp +++ b/SourceX/qol.cpp @@ -20,12 +20,12 @@ int GetTextWidth(const char *s) void FastDrawHorizLine(CelOutputBuffer out, int x, int y, int width, BYTE col) { - memset(out.at(SCREEN_X + x, SCREEN_Y + y), col, width); + memset(out.at(x, y), col, width); } void FastDrawVertLine(CelOutputBuffer out, int x, int y, int height, BYTE col) { - BYTE *p = out.at(SCREEN_X + x, SCREEN_Y + y); + BYTE *p = out.at(x, y); for (int j = 0; j < height; j++) { *p = col; p += out.pitch(); diff --git a/defs.h b/defs.h index bae3e0a75..04e2a5018 100644 --- a/defs.h +++ b/defs.h @@ -123,16 +123,10 @@ #define SCREEN_BPP 32 #endif -#define BORDER_LEFT 64 -#define BORDER_TOP 160 -#define BORDER_RIGHT dvl::borderRight -#define BORDER_BOTTOM 16 - -#define SCREEN_X BORDER_LEFT -#define SCREEN_Y BORDER_TOP - -#define BUFFER_WIDTH (BORDER_LEFT + gnScreenWidth + BORDER_RIGHT) -#define BUFFER_HEIGHT (BORDER_TOP + gnScreenHeight + BORDER_BOTTOM) +#define BUFFER_BORDER_LEFT 64 +#define BUFFER_BORDER_TOP 160 +#define BUFFER_BORDER_RIGHT dvl::borderRight +#define BUFFER_BORDER_BOTTOM 16 #define UI_OFFSET_Y ((Sint16)((gnScreenHeight - 480) / 2)) @@ -143,18 +137,18 @@ #define PANEL_HEIGHT 128 #define PANEL_TOP (gnScreenHeight - PANEL_HEIGHT) #define PANEL_LEFT (gnScreenWidth - PANEL_WIDTH) / 2 -#define PANEL_X (SCREEN_X + PANEL_LEFT) -#define PANEL_Y (SCREEN_Y + PANEL_TOP) +#define PANEL_X PANEL_LEFT +#define PANEL_Y PANEL_TOP #define SPANEL_WIDTH 320 #define SPANEL_HEIGHT 352 #define PANELS_COVER (gnScreenWidth <= PANEL_WIDTH && gnScreenHeight <= SPANEL_HEIGHT + PANEL_HEIGHT) #define RIGHT_PANEL (gnScreenWidth - SPANEL_WIDTH) -#define RIGHT_PANEL_X (SCREEN_X + RIGHT_PANEL) +#define RIGHT_PANEL_X RIGHT_PANEL #define DIALOG_TOP ((gnScreenHeight - PANEL_HEIGHT) / 2 - 18) -#define DIALOG_Y (SCREEN_Y + DIALOG_TOP) +#define DIALOG_Y DIALOG_TOP #define NIGHTMARE_TO_HIT_BONUS 85 #define HELL_TO_HIT_BONUS 120