Skip to content

Commit

Permalink
Document more attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Oct 28, 2019
1 parent c65060c commit 71adfe5
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 46 deletions.
41 changes: 28 additions & 13 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,12 @@ void ToggleSpell(int slot)
}
}

/**
* @brief Print letter to the backbuffer
* @param nOffset Backbuffer offset
* @param nCel Number of letter in Windows-1252
* @param col text_color color value
*/
void CPrintString(int nOffset, int nCel, char col)
{
/// ASSERT: assert(gpBuffer);
Expand Down Expand Up @@ -890,7 +896,7 @@ void DrawPanelBox(int x, int y, int w, int h, int sx, int sy)
/// ASSERT: assert(gpBuffer);

nSrcOff = x + PANEL_WIDTH * y;
nDstOff = sx + BUFFER_WIDTH * sy + PANEL_LEFT;
nDstOff = sx + BUFFER_WIDTH * sy;

#ifdef USE_ASM
__asm {
Expand Down Expand Up @@ -1009,7 +1015,7 @@ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int sx, int sy)
* into the target buffer.
* @param pCelBuff The flask cel buffer.
* @param w Width of the cel.
* @param nSrcOffset Offset of the source buffer from where the bytes will start to be copied from.
* @param nSrcOff Offset of the source buffer from where the bytes will start to be copied from.
* @param pBuff Target buffer.
* @param nDstOff Offset of the target buffer where the bytes will start to be copied to.
* @param h How many lines of the source buffer that will be copied.
Expand Down Expand Up @@ -1073,9 +1079,9 @@ void DrawLifeFlask()
filled = 11;
filled += 2;

DrawFlask(pLifeBuff, 88, 277, gpBuffer, BUFFER_WIDTH * 499 + 173, filled);
DrawFlask(pLifeBuff, 88, 277, gpBuffer, SCREENXY(PANEL_LEFT + 109, PANEL_TOP - 13), filled);
if (filled != 13)
DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * filled + 2029, gpBuffer, BUFFER_WIDTH * filled + BUFFER_WIDTH * 499 + 173, 13 - filled);
DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * (filled + 3) + 109, gpBuffer, SCREENXY(PANEL_LEFT + 109, PANEL_TOP - 13 + filled), 13 - filled);
}

/**
Expand Down Expand Up @@ -1108,9 +1114,9 @@ void DrawManaFlask()
filled = 11;
filled += 2;

DrawFlask(pManaBuff, 88, 277, gpBuffer, BUFFER_WIDTH * 499 + 173 + 366, filled);
DrawFlask(pManaBuff, 88, 277, gpBuffer, SCREENXY(PANEL_LEFT + 475, PANEL_TOP - 13), filled);
if (filled != 13)
DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * filled + 2029 + 366, gpBuffer, BUFFER_WIDTH * filled + BUFFER_WIDTH * 499 + 173 + 366, 13 - filled);
DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * (filled + 3) + 475, gpBuffer, SCREENXY(PANEL_LEFT + 475, PANEL_TOP - 13 + filled), 13 - filled);
}

void control_update_life_mana()
Expand Down Expand Up @@ -1261,9 +1267,9 @@ void DrawCtrlPan()

for (i = 0; i < 6; i++) {
if (!panbtn[i])
DrawPanelBox(PanBtnPos[i][0] - PANEL_LEFT, PanBtnPos[i][1] - (PANEL_TOP - 16), 71, 20, PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + SCREEN_Y);
DrawPanelBox(PanBtnPos[i][0] - PANEL_LEFT, PanBtnPos[i][1] - (PANEL_TOP - 16), 71, 20, PanBtnPos[i][0] + SCREEN_X, PanBtnPos[i][1] + SCREEN_Y);
else
CelDraw(PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + (PANEL_Y - 334), pPanelButtons, i + 1, 71);
CelDraw(PanBtnPos[i][0] + SCREEN_X, PanBtnPos[i][1] + (PANEL_Y - 334), pPanelButtons, i + 1, 71);
}
if (numpanbtns == 8) {
CelDraw(87 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[6] + 1, 33);
Expand Down Expand Up @@ -1972,14 +1978,23 @@ void ADD_PlrStringXY(int x, int y, int width, char *pszStr, char col)
}
}

void MY_PlrStringXY(int x, int y, int width, char *pszStr, char col, int base)
/**
* @brief Render text string to back buffer
* @param x Screen coordinate
* @param y Screen coordinate
* @param endX End of line in screen coordinate
* @param pszStr String to print, in Windows-1252 encoding
* @param col text_color color value
* @param base Letter spacing
*/
void MY_PlrStringXY(int x, int y, int endX, char *pszStr, char col, int base)
{
BYTE c;
char *tmp;
int nOffset, screen_x, line, widthOffset;

nOffset = x + PitchTbl[y + SCREEN_Y] + SCREEN_X;
widthOffset = width - x + 1;
widthOffset = endX - x + 1;
line = 0;
screen_x = 0;
tmp = pszStr;
Expand Down Expand Up @@ -2021,7 +2036,7 @@ void DrawLevelUpIcon()

if (!stextflag) {
nCel = lvlbtndown ? 3 : 2;
ADD_PlrStringXY(0, 303, 120, "Level Up", COL_WHITE);
ADD_PlrStringXY(PANEL_LEFT + 0, PANEL_TOP - 49, PANEL_LEFT + 120, "Level Up", COL_WHITE);
CelDraw(40 + PANEL_X, -17 + PANEL_Y, pChrButtons, nCel, 41);
}
}
Expand Down Expand Up @@ -2207,7 +2222,7 @@ void RedBack()
if (leveltype != DTYPE_HELL) {
dst = &gpBuffer[SCREENXY(0, 0)];
tbl = &pLightTbl[idx];
for (h = PANEL_TOP; h; h--, dst += BUFFER_WIDTH - SCREEN_WIDTH) {
for (h = VIEWPORT_HEIGHT; h; h--, dst += BUFFER_WIDTH - SCREEN_WIDTH) {
for (w = SCREEN_WIDTH; w; w--) {
*dst = tbl[*dst];
dst++;
Expand All @@ -2216,7 +2231,7 @@ void RedBack()
} else {
dst = &gpBuffer[SCREENXY(0, 0)];
tbl = &pLightTbl[idx];
for (h = PANEL_TOP; h; h--, dst += BUFFER_WIDTH - SCREEN_WIDTH) {
for (h = VIEWPORT_HEIGHT; h; h--, dst += BUFFER_WIDTH - SCREEN_WIDTH) {
for (w = SCREEN_WIDTH; w; w--) {
if (*dst >= 32)
*dst = tbl[*dst];
Expand Down
2 changes: 1 addition & 1 deletion Source/gmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void gmenu_draw_pause()
RedBack();
if (!sgpCurrentMenu) {
light_table_index = 0;
gmenu_print_text(316 + PANEL_LEFT, -16 + PANEL_TOP, "Pause");
gmenu_print_text(316 + PANEL_LEFT, 336, "Pause");
}
}

Expand Down
26 changes: 13 additions & 13 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2908,9 +2908,9 @@ void PrintItemPower(char plidx, ItemStruct *x)

void DrawUTextBack()
{
CelDraw(88, 487, pSTextBoxCels, 1, 271);
CelDraw(PANEL_X + 24, SCREEN_Y + 327, pSTextBoxCels, 1, 271);

#define TRANS_RECT_X 27
#define TRANS_RECT_X (PANEL_LEFT + 27)
#define TRANS_RECT_Y 28
#define TRANS_RECT_WIDTH 265
#define TRANS_RECT_HEIGHT 297
Expand Down Expand Up @@ -2951,12 +2951,12 @@ void DrawULine(int y)
#ifdef USE_ASM
int yy;

yy = PitchTbl[SStringY[y] + 198] + 26 + 64;
yy = PitchTbl[SStringY[y] + 198] + 26 + PANEL_X;

__asm {
mov esi, gpBuffer
mov edi, esi
add esi, SCREENXY(26, 25)
add esi, SCREENXY(PANEL_LEFT + 26, 25)
add edi, yy
mov ebx, BUFFER_WIDTH - 266
mov edx, 3
Expand All @@ -2973,8 +2973,8 @@ void DrawULine(int y)
int i;
BYTE *src, *dst;

src = &gpBuffer[SCREENXY(26, 25)];
dst = &gpBuffer[PitchTbl[SStringY[y] + 198] + 26 + 64];
src = &gpBuffer[SCREENXY(PANEL_LEFT + 26, 25)];
dst = &gpBuffer[PitchTbl[SStringY[y] + 198] + 26 + PANEL_X];

for (i = 0; i < 3; i++, src += BUFFER_WIDTH, dst += BUFFER_WIDTH)
memcpy(dst, src, 266);
Expand All @@ -2988,30 +2988,30 @@ void DrawUniqueInfo()
if (!chrflag && !questlog) {
uid = curruitem._iUid;
DrawUTextBack();
PrintUString(0, 2, 1, UniqueItemList[uid].UIName, 3);
PrintUString(PANEL_LEFT + 0, 2, 1, UniqueItemList[uid].UIName, 3);
DrawULine(5);
PrintItemPower(UniqueItemList[uid].UIPower1, &curruitem);
y = 6 - UniqueItemList[uid].UINumPL + 8;
PrintUString(0, y, 1, tempstr, 0);
PrintUString(PANEL_LEFT + 0, y, 1, tempstr, 0);
if (UniqueItemList[uid].UINumPL > 1) {
PrintItemPower(UniqueItemList[uid].UIPower2, &curruitem);
PrintUString(0, y + 2, 1, tempstr, 0);
PrintUString(PANEL_LEFT + 0, y + 2, 1, tempstr, 0);
}
if (UniqueItemList[uid].UINumPL > 2) {
PrintItemPower(UniqueItemList[uid].UIPower3, &curruitem);
PrintUString(0, y + 4, 1, tempstr, 0);
PrintUString(PANEL_LEFT + 0, y + 4, 1, tempstr, 0);
}
if (UniqueItemList[uid].UINumPL > 3) {
PrintItemPower(UniqueItemList[uid].UIPower4, &curruitem);
PrintUString(0, y + 6, 1, tempstr, 0);
PrintUString(PANEL_LEFT + 0, y + 6, 1, tempstr, 0);
}
if (UniqueItemList[uid].UINumPL > 4) {
PrintItemPower(UniqueItemList[uid].UIPower5, &curruitem);
PrintUString(0, y + 8, 1, tempstr, 0);
PrintUString(PANEL_LEFT + 0, y + 8, 1, tempstr, 0);
}
if (UniqueItemList[uid].UINumPL > 5) {
PrintItemPower(UniqueItemList[uid].UIPower6, &curruitem);
PrintUString(0, y + 10, 1, tempstr, 0);
PrintUString(PANEL_LEFT + 0, y + 10, 1, tempstr, 0);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/minitext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void DrawQTextBack()
{
CelDraw(PANEL_X + 24, 487, pTextBoxCels, 1, 591);

#define TRANS_RECT_X 27
#define TRANS_RECT_X (PANEL_LEFT + 27)
#define TRANS_RECT_Y 28
#define TRANS_RECT_WIDTH 585
#define TRANS_RECT_HEIGHT 297
Expand Down Expand Up @@ -208,7 +208,7 @@ void DrawQText()

p = qtextptr;
pnl = NULL;
tx = 112;
tx = 48 + PANEL_X;
ty = qtexty;

doneflag = FALSE;
Expand Down Expand Up @@ -251,7 +251,7 @@ void DrawQText()
if (pnl == NULL) {
pnl = p;
}
tx = 112;
tx = 48 + PANEL_X;
ty += 38;
if (ty > 501) {
doneflag = TRUE;
Expand Down
16 changes: 8 additions & 8 deletions Source/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2273,16 +2273,16 @@ static void DrawZoom(int x, int y)
}

if (chrflag || questlog) {
nSrcOff = SCREENXY(112, 159);
nDstOff = SCREENXY(320, 350);
nSrcOff = SCREENXY(112, VIEWPORT_HEIGHT / 2 - 17);
nDstOff = SCREENXY(320, VIEWPORT_HEIGHT - 2);
wdt = (SCREEN_WIDTH - 320) / 2;
} else if (invflag || sbookflag) {
nSrcOff = SCREENXY(112, 159);
nDstOff = SCREENXY(0, 350);
nSrcOff = SCREENXY(112, VIEWPORT_HEIGHT / 2 - 17);
nDstOff = SCREENXY(0, VIEWPORT_HEIGHT - 2);
wdt = (SCREEN_WIDTH - 320) / 2;
} else {
nSrcOff = SCREENXY(32, 159);
nDstOff = SCREENXY(0, 350);
nSrcOff = SCREENXY(32, VIEWPORT_HEIGHT / 2 - 17);
nDstOff = SCREENXY(0, VIEWPORT_HEIGHT - 2);
wdt = SCREEN_WIDTH / 2;
}

Expand All @@ -2298,7 +2298,7 @@ static void DrawZoom(int x, int y)
add esi, ecx
mov ebx, edi
add ebx, BUFFER_WIDTH
mov edx, 176
mov edx, (VIEWPORT_HEIGHT / 2)
label1:
mov ecx, wdt
label2:
Expand Down Expand Up @@ -2328,7 +2328,7 @@ static void DrawZoom(int x, int y)
dst1 = &gpBuffer[nDstOff];
dst2 = &gpBuffer[nDstOff + BUFFER_WIDTH];

for (hgt = 176; hgt != 0; hgt--, src -= BUFFER_WIDTH + wdt, dst1 -= 2 * (BUFFER_WIDTH + wdt), dst2 -= 2 * (BUFFER_WIDTH + wdt)) {
for (hgt = VIEWPORT_HEIGHT / 2; hgt != 0; hgt--, src -= BUFFER_WIDTH + wdt, dst1 -= 2 * (BUFFER_WIDTH + wdt), dst2 -= 2 * (BUFFER_WIDTH + wdt)) {
for (i = wdt; i != 0; i--) {
*dst1++ = *src;
*dst1++ = *src;
Expand Down
14 changes: 7 additions & 7 deletions Source/stores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void DrawSTextBack()
{
CelDraw(PANEL_X + 344, 487, pSTextBoxCels, 1, 271);

#define TRANS_RECT_X 347
#define TRANS_RECT_X (PANEL_LEFT + 347)
#define TRANS_RECT_Y 28
#define TRANS_RECT_WIDTH 265
#define TRANS_RECT_HEIGHT 297
Expand Down Expand Up @@ -179,7 +179,7 @@ void PrintSString(int x, int y, BOOL cjustflag, char *str, char col, int val)
}
if (!cjustflag && val >= 0) {
sprintf(valstr, "%i", val);
off = PitchTbl[s + 204] + 656 - x;
off = PitchTbl[s + 204] + PANEL_X + 592 - x;
for (i = strlen(valstr) - 1; i >= 0; i--) {
c = fontframe[gbFontTransTbl[(BYTE)valstr[i]]];
off -= fontkern[c] + 1;
Expand All @@ -189,7 +189,7 @@ void PrintSString(int x, int y, BOOL cjustflag, char *str, char col, int val)
}
}
if (stextsel == y) {
CelDraw(cjustflag ? xx + x + k + 4 : 660 - x, s + 205, pSPentSpn2Cels, InStoreFlag, 12);
CelDraw(cjustflag ? (xx + x + k + 4) : (PANEL_X + 596 - x), s + 205, pSPentSpn2Cels, InStoreFlag, 12);
}
}

Expand All @@ -199,13 +199,13 @@ void DrawSLine(int y)

sy = SStringY[y];
if (stextsize == 1) {
xy = SCREENXY(26, 25);
yy = PitchTbl[sy + 198] + 26 + 64;
xy = SCREENXY(PANEL_LEFT + 26, 25);
yy = PitchTbl[sy + 198] + 26 + PANEL_X;
width = 586 / 4;
line = BUFFER_WIDTH - 586;
} else {
xy = SCREENXY(346, 25);
yy = PitchTbl[sy + 198] + 346 + 64;
xy = SCREENXY(PANEL_LEFT + 346, 25);
yy = PitchTbl[sy + 198] + 346 + PANEL_X;
width = 266 / 4;
line = BUFFER_WIDTH - 266;
}
Expand Down
2 changes: 1 addition & 1 deletion defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
#define RIGHT_PANEL (SCREEN_WIDTH - 320)
#define RIGHT_PANEL_X (SCREEN_X + RIGHT_PANEL)

#if SCREEN_WIDTH == PANEL_WIDTH
#if SCREEN_WIDTH <= PANEL_WIDTH
#define VIEWPORT_HEIGHT (SCREEN_HEIGHT - PANEL_HEIGHT)
#else
#define VIEWPORT_HEIGHT SCREEN_HEIGHT
Expand Down

0 comments on commit 71adfe5

Please sign in to comment.