Browse Source

Replace magic number 352 with VIEWPORT_HEIGHT (#1232)

pull/127/head
Manuel K 7 years ago committed by Anders Jenbo
parent
commit
896933f55e
  1. 2
      Source/automap.cpp
  2. 8
      Source/control.cpp
  3. 6
      Source/cursor.cpp
  4. 18
      Source/diablo.cpp
  5. 4
      Source/engine.cpp
  6. 2
      Source/gendung.cpp
  7. 2
      Source/gmenu.cpp
  8. 2
      Source/inv.cpp
  9. 2
      Source/player.cpp
  10. 4
      Source/scrollrt.cpp
  11. 4
      Source/town.cpp
  12. 2
      Source/trigs.cpp
  13. 2
      defs.h

2
Source/automap.cpp

@ -173,7 +173,7 @@ void DrawAutomap()
return;
}
gpBufEnd = (unsigned char *)&gpBuffer[(352 + 160) * 768];
gpBufEnd = (unsigned char *)&gpBuffer[(VIEWPORT_HEIGHT + 160) * 768];
MapX = (ViewX - 16) >> 1;
while (MapX + AutoMapXOfs < 0)

8
Source/control.cpp

@ -2092,7 +2092,7 @@ void RedBack()
add edi, SCREENXY(0, 0)
mov ebx, pLightTbl
add ebx, idx
mov edx, 352
mov edx, VIEWPORT_HEIGHT
lx_label1:
mov ecx, 640
lx_label2:
@ -2110,7 +2110,7 @@ void RedBack()
add edi, SCREENXY(0, 0)
mov ebx, pLightTbl
add ebx, idx
mov edx, 352
mov edx, VIEWPORT_HEIGHT
l4_label1:
mov ecx, 640
l4_label2:
@ -2133,7 +2133,7 @@ void RedBack()
if (leveltype != DTYPE_HELL) {
dst = &gpBuffer[SCREENXY(0, 0)];
tbl = &pLightTbl[idx];
for (h = 352; h; h--, dst += 768 - 640) {
for (h = VIEWPORT_HEIGHT; h; h--, dst += 768 - 640) {
for (w = 640; w; w--) {
*dst = tbl[*dst];
dst++;
@ -2142,7 +2142,7 @@ void RedBack()
} else {
dst = &gpBuffer[SCREENXY(0, 0)];
tbl = &pLightTbl[idx];
for (h = 352; h; h--, dst += 768 - 640) {
for (h = VIEWPORT_HEIGHT; h; h--, dst += 768 - 640) {
for (w = 640; w; w--) {
if (*dst >= 32)
*dst = tbl[*dst];

6
Source/cursor.cpp

@ -190,8 +190,8 @@ void CheckCursMove()
sx = 0;
}
}
if(sy > 351 && track_isscrolling()) {
sy = 351;
if(sy > VIEWPORT_HEIGHT - 1 && track_isscrolling()) {
sy = VIEWPORT_HEIGHT - 1;
}
if(!zoomflag) {
sx >>= 1;
@ -271,7 +271,7 @@ void CheckCursMove()
cursmy = my;
return;
}
if(MouseY > 352) {
if(MouseY > VIEWPORT_HEIGHT) {
CheckPanelInfo();
return;
}

18
Source/diablo.cpp

@ -801,7 +801,7 @@ BOOL LeftMouseDown(int wParam)
SetSpell();
} else if (stextflag) {
CheckStoreBtn();
} else if (MouseY < 352) {
} else if (MouseY < VIEWPORT_HEIGHT) {
if (!gmenu_exception() && !TryIconCurs()) {
if (questlog && MouseX > 32 && MouseX < 288 && MouseY > 32 && MouseY < 308) {
QuestlogESC();
@ -844,7 +844,7 @@ BOOL LeftMouseCmd(BOOL bShift)
{
BOOL bNear;
/// ASSERT: assert(MouseY < 352);
/// ASSERT: assert(MouseY < VIEWPORT_HEIGHT);
if (leveltype == DTYPE_TOWN) {
if (pcursitem != -1 && pcurs == CURSOR_HAND)
@ -972,7 +972,7 @@ void RightMouseDown()
} else if (!stextflag) {
if (spselflag) {
SetSpell();
} else if (MouseY >= 352
} else if (MouseY >= VIEWPORT_HEIGHT
|| (!sbookflag || MouseX <= 320)
&& !TryIconCurs()
&& (pcursinvitem == -1 || !UseInvItem(myplr, pcursinvitem))) {
@ -1210,10 +1210,10 @@ void PressKey(int vkey)
} else if(vkey == VK_TAB) {
DoAutoMap();
} else if(vkey == VK_SPACE) {
if(!chrflag && invflag && MouseX < 480 && MouseY < 352) {
if(!chrflag && invflag && MouseX < 480 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX + 160, MouseY);
}
if(!invflag && chrflag && MouseX > 160 && MouseY < 352) {
if(!invflag && chrflag && MouseX > 160 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX - 160, MouseY);
}
helpflag = 0;
@ -1294,11 +1294,11 @@ void PressChar(int vkey)
sbookflag = 0;
invflag = invflag == 0;
if(!invflag || chrflag) {
if(MouseX < 480 && MouseY < 352) {
if(MouseX < 480 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX + 160, MouseY);
}
} else {
if(MouseX > 160 && MouseY < 352) {
if(MouseX > 160 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX - 160, MouseY);
}
}
@ -1310,11 +1310,11 @@ void PressChar(int vkey)
questlog = FALSE;
chrflag = chrflag == 0;
if(!chrflag || invflag) {
if(MouseX > 160 && MouseY < 352) {
if(MouseX > 160 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX - 160, MouseY);
}
} else {
if(MouseX < 480 && MouseY < 352) {
if(MouseX < 480 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX + 160, MouseY);
}
}

4
Source/engine.cpp

@ -2123,10 +2123,10 @@ void DrawLine(int x0, int y0, int x1, int y1, BYTE col)
if (x1 < 0 + 64 || x1 >= 640 + 64) {
gbNotInView = TRUE;
}
if (y0 < 0 + 160 || y0 >= 352 + 160) {
if (y0 < 0 + 160 || y0 >= VIEWPORT_HEIGHT + 160) {
gbNotInView = TRUE;
}
if (y1 < 0 + 160 || y1 >= 352 + 160) {
if (y1 < 0 + 160 || y1 >= VIEWPORT_HEIGHT + 160) {
gbNotInView = TRUE;
}

2
Source/gendung.cpp

@ -539,7 +539,7 @@ void SetDungeonMicros()
if (zoomflag) {
scr_pix_width = 640;
scr_pix_height = 352;
scr_pix_height = VIEWPORT_HEIGHT;
dword_5C2FF8 = 10;
dword_5C2FFC = 11;
} else {

2
Source/gmenu.cpp

@ -359,7 +359,7 @@ BOOL gmenu_left_mouse(BOOL isDown)
if (!sgpCurrentMenu) {
return FALSE;
}
if (MouseY >= 352) {
if (MouseY >= VIEWPORT_HEIGHT) {
return FALSE;
}
if (MouseY - 117 >= 0) {

2
Source/inv.cpp

@ -1363,7 +1363,7 @@ void CheckInvItem()
void CheckInvScrn()
{
if (MouseX > 190 && MouseX < 437
&& MouseY > 352 && MouseY < 385) {
&& MouseY > VIEWPORT_HEIGHT && MouseY < 385) {
CheckInvItem();
}
}

2
Source/player.cpp

@ -3618,7 +3618,7 @@ void CheckPlrSpell()
}
if (pcurs != CURSOR_HAND
|| MouseY >= 352
|| MouseY >= VIEWPORT_HEIGHT
|| (chrflag && MouseX < 320 || invflag && MouseX > 320)
&& rspell != SPL_HEAL
&& rspell != SPL_IDENTIFY

4
Source/scrollrt.cpp

@ -432,7 +432,7 @@ void DrawGame(int x, int y)
int i, sx, sy, chunks, blocks;
scr_pix_width = 640;
scr_pix_height = 352;
scr_pix_height = VIEWPORT_HEIGHT;
dword_5C2FF8 = 10;
dword_5C2FFC = 11;
@ -505,7 +505,7 @@ void DrawGame(int x, int y)
sy += 16;
}
/// ASSERT: assert(gpBuffer);
gpBufEnd = &gpBuffer[PitchTbl[352 + SCREEN_Y]];
gpBufEnd = &gpBuffer[PitchTbl[VIEWPORT_HEIGHT + SCREEN_Y]];
for (i = 0; i < blocks; i++) {
scrollrt_draw_lower(x, y, sx, sy, chunks, 0);
y++;

4
Source/town.cpp

@ -931,7 +931,7 @@ void T_DrawGame(int x, int y)
int i, sx, sy, chunks, blocks;
scr_pix_width = 640;
scr_pix_height = 352;
scr_pix_height = VIEWPORT_HEIGHT;
dword_5C2FF8 = 10;
dword_5C2FFC = 11;
@ -1280,7 +1280,7 @@ void SetTownMicros()
if (zoomflag) {
scr_pix_width = 640;
scr_pix_height = 352;
scr_pix_height = VIEWPORT_HEIGHT;
dword_5C2FF8 = 10;
dword_5C2FFC = 11;
} else {

2
Source/trigs.cpp

@ -654,7 +654,7 @@ void CheckTrigForce()
{
trigflag = FALSE;
if(MouseY > 352 - 1) {
if(MouseY > VIEWPORT_HEIGHT - 1) {
return;
}

2
defs.h

@ -108,6 +108,8 @@
#define BUFFER_HEIGHT (BORDER_TOP + SCREEN_HEIGHT + BORDER_BOTTOM)
#define TILE_SIZE 32
#define VIEWPORT_HEIGHT 352
#define SCREENXY(x, y) ((x) + SCREEN_X + ((y) + SCREEN_Y) * BUFFER_WIDTH)
#define MemFreeDbg(p) \

Loading…
Cancel
Save