From 49f0d833ab27e1259615ce6e0d366544c840227b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0imek?= Date: Sat, 28 May 2022 05:57:53 +0200 Subject: [PATCH] Fix help and end game window positions (#21) --- src/endgame.cc | 17 +++++++++++------ src/game.cc | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/endgame.cc b/src/endgame.cc index 8462148..cde8413 100644 --- a/src/endgame.cc +++ b/src/endgame.cc @@ -33,6 +33,9 @@ // The maximum number of subtitle lines per slide. #define ENDGAME_ENDING_MAX_SUBTITLES (50) +#define ENDGAME_ENDING_WINDOW_WIDTH 640 +#define ENDGAME_ENDING_WINDOW_HEIGHT 480 + // 0x50B00C char _aEnglish_2[] = ENGLISH; @@ -270,7 +273,7 @@ void endgameEndingRenderPanningScene(int direction, const char* narratorFileName int width = artGetWidth(background, 0, 0); int height = artGetHeight(background, 0, 0); unsigned char* backgroundData = artGetFrameData(background, 0, 0); - bufferFill(gEndgameEndingSlideshowWindowBuffer, 640, 480, 640, _colorTable[0]); + bufferFill(gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, ENDGAME_ENDING_WINDOW_WIDTH, _colorTable[0]); endgameEndingLoadPalette(6, 327); unsigned char palette[768]; @@ -312,7 +315,7 @@ void endgameEndingRenderPanningScene(int direction, const char* narratorFileName // TODO: Complex math, setup scene in debugger. if (getTicksSince(since) >= v9) { - blitBufferToBuffer(backgroundData + start, 640, 480, width, gEndgameEndingSlideshowWindowBuffer, 640); + blitBufferToBuffer(backgroundData + start, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, width, gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH); if (subtitlesLoaded) { endgameEndingRefreshSubtitles(); @@ -371,7 +374,7 @@ void endgameEndingRenderPanningScene(int direction, const char* narratorFileName artUnlock(backgroundHandle); paletteFadeTo(gPaletteBlack); - bufferFill(gEndgameEndingSlideshowWindowBuffer, 640, 480, 640, _colorTable[0]); + bufferFill(gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, ENDGAME_ENDING_WINDOW_WIDTH, _colorTable[0]); windowRefresh(gEndgameEndingSlideshowWindow); } @@ -391,7 +394,7 @@ void endgameEndingRenderStaticScene(int fid, const char* narratorFileName) unsigned char* backgroundData = artGetFrameData(background, 0, 0); if (backgroundData != NULL) { - blitBufferToBuffer(backgroundData, 640, 480, 640, gEndgameEndingSlideshowWindowBuffer, 640); + blitBufferToBuffer(backgroundData, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, ENDGAME_ENDING_WINDOW_WIDTH, gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH); windowRefresh(gEndgameEndingSlideshowWindow); endgameEndingLoadPalette((fid & 0xF000000) >> 24, fid & 0xFFF); @@ -434,7 +437,7 @@ void endgameEndingRenderStaticScene(int fid, const char* narratorFileName) break; } - blitBufferToBuffer(backgroundData, 640, 480, 640, gEndgameEndingSlideshowWindowBuffer, 640); + blitBufferToBuffer(backgroundData, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, ENDGAME_ENDING_WINDOW_WIDTH, gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH); endgameEndingRefreshSubtitles(); windowRefresh(gEndgameEndingSlideshowWindow); soundContinueAll(); @@ -487,7 +490,9 @@ int endgameEndingSlideshowWindowInit() paletteFadeTo(gPaletteBlack); - gEndgameEndingSlideshowWindow = windowCreate(0, 0, 640, 480, _colorTable[0], 4); + int windowEndgameEndingX = (screenGetWidth() - ENDGAME_ENDING_WINDOW_WIDTH) / 2; + int windowEndgameEndingY = (screenGetHeight() - ENDGAME_ENDING_WINDOW_HEIGHT) / 2; + gEndgameEndingSlideshowWindow = windowCreate(windowEndgameEndingX, windowEndgameEndingY, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, _colorTable[0], 4); if (gEndgameEndingSlideshowWindow == -1) { return -1; } diff --git a/src/game.cc b/src/game.cc index 5bd4563..4647d27 100644 --- a/src/game.cc +++ b/src/game.cc @@ -1055,7 +1055,9 @@ void showHelp() bool colorCycleWasEnabled = colorCycleEnabled(); colorCycleDisable(); - int win = windowCreate(0, 0, HELP_SCREEN_WIDTH, HELP_SCREEN_HEIGHT, 0, WINDOW_HIDDEN | WINDOW_FLAG_0x04); + int helpWindowX = (screenGetWidth() - HELP_SCREEN_WIDTH) / 2; + int helpWindowY = (screenGetHeight() - HELP_SCREEN_HEIGHT) / 2; + int win = windowCreate(helpWindowX, helpWindowY, HELP_SCREEN_WIDTH, HELP_SCREEN_HEIGHT, 0, WINDOW_HIDDEN | WINDOW_FLAG_0x04); if (win != -1) { unsigned char* windowBuffer = windowGetBuffer(win); if (windowBuffer != NULL) {