Browse Source

Check if panels conver the screen before affecting the viewport

pull/393/head
Anders Jenbo 6 years ago
parent
commit
8976e4fd39
  1. 35
      Source/cursor.cpp
  2. 2
      Source/items.cpp
  3. 61
      Source/scrollrt.cpp
  4. 2
      defs.h

35
Source/cursor.cpp

@ -179,22 +179,27 @@ void CheckCursMove()
sx = MouseX; sx = MouseX;
sy = MouseY; sy = MouseY;
if (chrflag || questlog) {
if (sx >= 160) { if (PANELS_COVER) {
sx -= 160; if (chrflag || questlog) {
} else { if (sx >= 160) {
sx = 0; sx -= 160;
} } else {
} else if (invflag || sbookflag) { sx = 0;
if (sx <= 320) { }
sx += 160; } else if (invflag || sbookflag) {
} else { if (sx <= 320) {
sx = 0; sx += 160;
} else {
sx = 0;
}
} }
} }
if (sy > PANEL_TOP - 1 && track_isscrolling()) { if (sy > PANEL_TOP - 1 && track_isscrolling()) {
sy = PANEL_TOP - 1; sy = PANEL_TOP - 1;
} }
sx -= (SCREEN_WIDTH % 64) / 2;
sy -= (VIEWPORT_HEIGHT % 32) / 2;
if (!zoomflag) { if (!zoomflag) {
sx >>= 1; sx >>= 1;
sy >>= 1; sy >>= 1;
@ -221,10 +226,10 @@ void CheckCursMove()
sy = SCREEN_HEIGHT; sy = SCREEN_HEIGHT;
} }
tx = sx >> 6; tx = sx >> 6; // sx / 64
ty = sy >> 5; ty = sy >> 5; // sy / 32
px = sx & 0x3F; px = sx & 0x3F; // sx % 64
py = sy & 0x1F; py = sy & 0x1F; // sx % 32
mx = ViewX + tx + ty - (zoomflag ? (SCREEN_WIDTH / 64) : (SCREEN_WIDTH / 2 / 64)); mx = ViewX + tx + ty - (zoomflag ? (SCREEN_WIDTH / 64) : (SCREEN_WIDTH / 2 / 64));
my = ViewY + ty - tx; my = ViewY + ty - tx;

2
Source/items.cpp

@ -2960,7 +2960,7 @@ void DrawUniqueInfo()
{ {
int uid, y; int uid, y;
if (!chrflag && !questlog) { if ((!chrflag && !questlog) || SCREEN_WIDTH >= 320 * 3) {
uid = curruitem._iUid; uid = curruitem._iUid;
DrawUTextBack(); DrawUTextBack();
PrintUString(0 + RIGHT_PANEL - 320, 2, 1, UniqueItemList[uid].UIName, 3); PrintUString(0 + RIGHT_PANEL - 320, 2, 1, UniqueItemList[uid].UIName, 3);

61
Source/scrollrt.cpp

@ -689,10 +689,10 @@ static void scrollrt_draw(int x, int y, int sx, int sy, int chunks, int row)
assert(gpBuffer); assert(gpBuffer);
if (row & 1) { if (row & 1) {
x--; x -= 1;
y++; y += 1;
sx -= 32; sx -= 32;
chunks++; chunks += 1;
} }
for (int j = 0; j < chunks; j++) { for (int j = 0; j < chunks; j++) {
@ -722,43 +722,49 @@ static void DrawGame(int x, int y)
int i, sx, sy, chunks, blocks; int i, sx, sy, chunks, blocks;
int wdt, nSrcOff, nDstOff; int wdt, nSrcOff, nDstOff;
sx = ScrollInfo._sxoff + SCREEN_X; sx = (SCREEN_WIDTH % 64) / 2;
if (zoomflag) { sy = (VIEWPORT_HEIGHT % 32) / 2;
sy = ScrollInfo._syoff + SCREEN_Y + 15;
if (zoomflag) {
chunks = ceil(SCREEN_WIDTH / 64); chunks = ceil(SCREEN_WIDTH / 64);
// Fill screen + keep evaulating untill MicroTiles can't affect screen blocks = ceil(VIEWPORT_HEIGHT / 32);
blocks = ceil(VIEWPORT_HEIGHT / 32) + ceil(MicroTileLen / 2);
gpBufStart = &gpBuffer[BUFFER_WIDTH * SCREEN_Y]; gpBufStart = &gpBuffer[BUFFER_WIDTH * SCREEN_Y];
gpBufEnd = &gpBuffer[BUFFER_WIDTH * (VIEWPORT_HEIGHT + SCREEN_Y)]; gpBufEnd = &gpBuffer[BUFFER_WIDTH * (VIEWPORT_HEIGHT + SCREEN_Y)];
} else { } else {
sy = ScrollInfo._syoff + -17 + SCREEN_Y ; sy -= 32;
chunks = ceil(SCREEN_WIDTH / 2 / 64) + 1; // TODO why +1? chunks = ceil(SCREEN_WIDTH / 2 / 64) + 1; // TODO why +1?
// Fill screen + keep evaulating untill MicroTiles can't affect screen blocks = ceil(VIEWPORT_HEIGHT / 2 / 32);
blocks = ceil(VIEWPORT_HEIGHT / 2 / 32) + ceil(MicroTileLen / 2);
gpBufStart = &gpBuffer[(-17 + SCREEN_Y) * BUFFER_WIDTH]; gpBufStart = &gpBuffer[(-17 + SCREEN_Y) * BUFFER_WIDTH];
gpBufEnd = &gpBuffer[(160 + SCREEN_Y) * BUFFER_WIDTH]; gpBufEnd = &gpBuffer[(160 + SCREEN_Y) * BUFFER_WIDTH];
} }
sx += ScrollInfo._sxoff + SCREEN_X;
sy += ScrollInfo._syoff + SCREEN_Y + 15;
// Center screen // Center screen
x -= chunks; x -= chunks;
y--; y--;
if (zoomflag && SCREEN_WIDTH <= PANEL_WIDTH && SCREEN_HEIGHT <= VIEWPORT_HEIGHT + PANEL_HEIGHT) { // Keep evaulating untill MicroTiles can't affect screen
if (chrflag || questlog) { blocks += ceil(MicroTileLen / 2);
x += 2;
y -= 2; if (PANELS_COVER) {
sx += 288; if (zoomflag) {
chunks -= 4; if (chrflag || questlog) {
} x += 2;
if (invflag || sbookflag) { y -= 2;
x += 2; sx += 288;
y -= 2; chunks -= 4;
sx -= 32; }
chunks -= 4; if (invflag || sbookflag) {
x += 2;
y -= 2;
sx -= 32;
chunks -= 4;
}
} }
} }
@ -810,7 +816,6 @@ static void DrawGame(int x, int y)
break; break;
} }
assert(gpBuffer);
for (i = 0; i < (blocks << 1); i++) { for (i = 0; i < (blocks << 1); i++) {
scrollrt_draw(x, y, sx, sy, chunks, i); scrollrt_draw(x, y, sx, sy, chunks, i);
sy += 16; sy += 16;
@ -828,7 +833,7 @@ static void DrawGame(int x, int y)
nSrcOff = SCREENXY(32, VIEWPORT_HEIGHT / 2 - 17); nSrcOff = SCREENXY(32, VIEWPORT_HEIGHT / 2 - 17);
nDstOff = SCREENXY(0, VIEWPORT_HEIGHT - 2); nDstOff = SCREENXY(0, VIEWPORT_HEIGHT - 2);
wdt = SCREEN_WIDTH / 2; wdt = SCREEN_WIDTH / 2;
if (SCREEN_WIDTH == PANEL_WIDTH && SCREEN_HEIGHT == VIEWPORT_HEIGHT + PANEL_HEIGHT) { if (PANELS_COVER) {
if (chrflag || questlog) { if (chrflag || questlog) {
nSrcOff = SCREENXY(112, VIEWPORT_HEIGHT / 2 - 17); nSrcOff = SCREENXY(112, VIEWPORT_HEIGHT / 2 - 17);
nDstOff = SCREENXY(320, VIEWPORT_HEIGHT - 2); nDstOff = SCREENXY(320, VIEWPORT_HEIGHT - 2);
@ -883,7 +888,8 @@ void DrawView(int StartX, int StartY)
DrawChr(); DrawChr();
} else if (questlog) { } else if (questlog) {
DrawQuestLog(); DrawQuestLog();
} else if (plr[myplr]._pStatPts != 0 && !spselflag) { }
if (!chrflag && plr[myplr]._pStatPts != 0 && !spselflag) {
DrawLevelUpIcon(); DrawLevelUpIcon();
} }
if (uitemflag) { if (uitemflag) {
@ -1067,9 +1073,6 @@ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt)
{ {
RECT SrcRect; RECT SrcRect;
assert(! (dwX & 3));
assert(! (dwWdt & 3));
SrcRect.left = dwX + SCREEN_X; SrcRect.left = dwX + SCREEN_X;
SrcRect.top = dwY + SCREEN_Y; SrcRect.top = dwY + SCREEN_Y;
SrcRect.right = SrcRect.left + dwWdt - 1; SrcRect.right = SrcRect.left + dwWdt - 1;

2
defs.h

@ -125,6 +125,8 @@
#define PANEL_X (SCREEN_X + PANEL_LEFT) #define PANEL_X (SCREEN_X + PANEL_LEFT)
#define PANEL_Y (SCREEN_Y + PANEL_TOP) #define PANEL_Y (SCREEN_Y + PANEL_TOP)
#define PANELS_COVER (SCREEN_WIDTH <= PANEL_WIDTH && SCREEN_HEIGHT <= 480)
#define RIGHT_PANEL (SCREEN_WIDTH - 320) #define RIGHT_PANEL (SCREEN_WIDTH - 320)
#define RIGHT_PANEL_X (SCREEN_X + RIGHT_PANEL) #define RIGHT_PANEL_X (SCREEN_X + RIGHT_PANEL)

Loading…
Cancel
Save