From 86d8a92ce0814f7086d88ae8ea887c61fa3e8b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0imek?= Date: Sat, 21 May 2022 11:30:25 -0700 Subject: [PATCH] Add IFACE_BAR_MODE configuration option from HRP (#5) See #3 --- src/combat.cc | 2 +- src/core.cc | 13 +++++++++++++ src/core.h | 1 + src/elevator.cc | 3 ++- src/game_mouse.cc | 3 ++- src/interface.cc | 11 ++++------- src/interface.h | 7 +++++++ src/map.cc | 12 ++++++------ src/skilldex.cc | 3 ++- 9 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/combat.cc b/src/combat.cc index f161eb4..5f5eaa9 100644 --- a/src/combat.cc +++ b/src/combat.cc @@ -5266,7 +5266,7 @@ int calledShotSelectHitLocation(Object* critter, int* hitLocation, int hitMode) int calledShotWindowX = (screenGetWidth() - CALLED_SHOT_WINDOW_WIDTH) / 2; // Center vertically for HRP, otherwise maintain original location (20). int calledShotWindowY = screenGetHeight() != 480 - ? (screenGetHeight() - 100 - 1 - CALLED_SHOT_WINDOW_HEIGHT) / 2 + ? (screenGetHeight() - INTERFACE_BAR_HEIGHT - 1 - CALLED_SHOT_WINDOW_HEIGHT) / 2 : CALLED_SHOT_WINDOW_Y; gCalledShotWindow = windowCreate(calledShotWindowX, calledShotWindowY, diff --git a/src/core.cc b/src/core.cc index d94efcc..0ef12bd 100644 --- a/src/core.cc +++ b/src/core.cc @@ -4,6 +4,7 @@ #include "color.h" #include "dinput.h" #include "draw.h" +#include "interface.h" #include "memory.h" #include "mmx.h" #include "text_font.h" @@ -2047,6 +2048,8 @@ int _GNW95_init_mode_ex(int width, int height, int bpp) if (configGetBool(&resolutionConfig, "MAIN", "WINDOWED", &windowed)) { fullscreen = !windowed; } + + configGetBool(&resolutionConfig, "IFACE", "IFACE_BAR_MODE", &gInterfaceBarMode); } configFree(&resolutionConfig); } @@ -4617,6 +4620,16 @@ int screenGetHeight() return rectGetHeight(&_scr_size); } +int screenGetVisibleHeight() +{ + int windowBottomMargin = 0; + + if (!gInterfaceBarMode) { + windowBottomMargin = INTERFACE_BAR_HEIGHT; + } + return screenGetHeight() - windowBottomMargin; +} + void mouseGetPositionInWindow(int win, int* x, int* y) { mouseGetPosition(x, y); diff --git a/src/core.h b/src/core.h index 4ffc913..32ea738 100644 --- a/src/core.h +++ b/src/core.h @@ -636,6 +636,7 @@ bool _vcr_load_record(STRUCT_51E2F0* ptr, File* stream); int screenGetWidth(); int screenGetHeight(); +int screenGetVisibleHeight(); void mouseGetPositionInWindow(int win, int* x, int* y); bool mouseHitTestInWindow(int win, int left, int top, int right, int bottom); diff --git a/src/elevator.cc b/src/elevator.cc index 4f7e388..dd4589e 100644 --- a/src/elevator.cc +++ b/src/elevator.cc @@ -6,6 +6,7 @@ #include "draw.h" #include "game_mouse.h" #include "game_sound.h" +#include "interface.h" #include "map.h" #include "pipboy.h" #include "scripts.h" @@ -535,7 +536,7 @@ int elevatorWindowInit(int elevator) } int elevatorWindowX = (screenGetWidth() - gElevatorBackgroundFrmWidth) / 2; - int elevatorWindowY = (screenGetHeight() - 100 - 1 - gElevatorBackgroundFrmHeight) / 2; + int elevatorWindowY = (screenGetHeight() - INTERFACE_BAR_HEIGHT - 1 - gElevatorBackgroundFrmHeight) / 2; gElevatorWindow = windowCreate( elevatorWindowX, elevatorWindowY, diff --git a/src/game_mouse.cc b/src/game_mouse.cc index f35eade..0f3c3fb 100644 --- a/src/game_mouse.cc +++ b/src/game_mouse.cc @@ -852,7 +852,8 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState) } } - if (!_mouse_click_in(0, 0, _scr_size.right - _scr_size.left, _scr_size.bottom - _scr_size.top - 100)) { + // TODO: allow clicking to the left and right of the INTERFACE_BAR if gInterfaceBarMode is enabled + if (!_mouse_click_in(0, 0, _scr_size.right - _scr_size.left, _scr_size.bottom - _scr_size.top - INTERFACE_BAR_HEIGHT)) { return; } diff --git a/src/interface.cc b/src/interface.cc index 0f8271b..13bc579 100644 --- a/src/interface.cc +++ b/src/interface.cc @@ -29,12 +29,6 @@ #include -#define INDICATOR_BOX_WIDTH 130 -#define INDICATOR_BOX_HEIGHT 21 - -#define INTERFACE_BAR_WIDTH 640 -#define INTERFACE_BAR_HEIGHT 100 - // The width of connectors in the indicator box. // // There are male connectors on the left, and female connectors on the right. @@ -337,6 +331,9 @@ unsigned char* gInventoryButtonDownFrmData; // 0x59D40C unsigned char gInterfaceActionPointsBarBackground[90 * 5]; +// Should the game window stretch all the way to the bottom or sit at the top of the interface bar (default) +bool gInterfaceBarMode = false; + // intface_init // 0x45D880 int interfaceInit() @@ -352,7 +349,7 @@ int interfaceInit() gInterfaceBarInitialized = 1; int interfaceBarWindowX = (screenGetWidth() - INTERFACE_BAR_WIDTH) / 2; - int interfaceBarWindowY = screenGetHeight() - INTERFACE_BAR_HEIGHT - 1; + int interfaceBarWindowY = screenGetHeight() - INTERFACE_BAR_HEIGHT; gInterfaceBarWindow = windowCreate(interfaceBarWindowX, interfaceBarWindowY, INTERFACE_BAR_WIDTH, INTERFACE_BAR_HEIGHT, _colorTable[0], WINDOW_HIDDEN); if (gInterfaceBarWindow == -1) { diff --git a/src/interface.h b/src/interface.h index 828c4f0..b7f3141 100644 --- a/src/interface.h +++ b/src/interface.h @@ -35,6 +35,12 @@ typedef enum InterfaceNumbersColor { INTERFACE_NUMBERS_COLOR_RED = 240, } InterfaceNumbersColor; +#define INDICATOR_BOX_WIDTH 130 +#define INDICATOR_BOX_HEIGHT 21 + +#define INTERFACE_BAR_WIDTH 640 +#define INTERFACE_BAR_HEIGHT 100 + // The maximum number of indicator boxes the indicator bar can display. // // For unknown reason this number is 6, even though there are only 5 different @@ -171,6 +177,7 @@ extern unsigned char* gOptionsButtonDownFrmData; extern unsigned char* gSkilldexButtonUpFrmData; extern unsigned char* gInventoryButtonDownFrmData; extern unsigned char gInterfaceActionPointsBarBackground[450]; +extern bool gInterfaceBarMode; int interfaceInit(); void interfaceReset(); diff --git a/src/map.cc b/src/map.cc index c829cad..ba7c55d 100644 --- a/src/map.cc +++ b/src/map.cc @@ -143,7 +143,7 @@ int isoInit() _square[elevation] = &(_square_data[elevation]); } - gIsoWindow = windowCreate(0, 0, _scr_size.right - _scr_size.left + 1, _scr_size.bottom - _scr_size.top - 99, 256, 10); + gIsoWindow = windowCreate(0, 0, screenGetWidth(), screenGetVisibleHeight(), 256, 10); if (gIsoWindow == -1) { debugPrint("win_add failed in iso_init\n"); return -1; @@ -167,14 +167,14 @@ int isoInit() debugPrint(">art_init\t\t"); - if (tileInit(_square, SQUARE_GRID_WIDTH, SQUARE_GRID_HEIGHT, HEX_GRID_WIDTH, HEX_GRID_HEIGHT, gIsoWindowBuffer, _scr_size.right - _scr_size.left + 1, _scr_size.bottom - _scr_size.top - 99, _scr_size.right - _scr_size.left + 1, isoWindowRefreshRect) != 0) { + if (tileInit(_square, SQUARE_GRID_WIDTH, SQUARE_GRID_HEIGHT, HEX_GRID_WIDTH, HEX_GRID_HEIGHT, gIsoWindowBuffer, screenGetWidth(), screenGetVisibleHeight(), screenGetWidth(), isoWindowRefreshRect) != 0) { debugPrint("tile_init failed in iso_init\n"); return -1; } debugPrint(">tile_init\t\t"); - if (objectsInit(gIsoWindowBuffer, _scr_size.right - _scr_size.left + 1, _scr_size.bottom - _scr_size.top - 99, _scr_size.right - _scr_size.left + 1) != 0) { + if (objectsInit(gIsoWindowBuffer, screenGetWidth(), screenGetVisibleHeight(), screenGetWidth()) != 0) { debugPrint("obj_init failed in iso_init\n"); return -1; } @@ -577,9 +577,9 @@ int mapScroll(int dx, int dy) Rect r2; rectCopy(&r2, &r1); - int width = _scr_size.right - _scr_size.left + 1; + int width = screenGetWidth(); int pitch = width; - int height = _scr_size.bottom - _scr_size.top - 99; + int height = screenGetVisibleHeight(); if (screenDx != 0) { width -= 32; @@ -601,7 +601,7 @@ int mapScroll(int dx, int dy) if (screenDy < 0) { r1.bottom = r1.top - screenDy; src = gIsoWindowBuffer + pitch * (height - 1); - dest = gIsoWindowBuffer + pitch * (_scr_size.bottom - _scr_size.top - 100); + dest = gIsoWindowBuffer + pitch * (screenGetVisibleHeight() - 1); if (screenDx < 0) { dest -= screenDx; } else { diff --git a/src/skilldex.cc b/src/skilldex.cc index 711e00b..3c18c84 100644 --- a/src/skilldex.cc +++ b/src/skilldex.cc @@ -8,6 +8,7 @@ #include "game.h" #include "game_mouse.h" #include "game_sound.h" +#include "interface.h" #include "map.h" #include "memory.h" #include "object.h" @@ -187,7 +188,7 @@ int skilldexWindowInit() // Maintain original position relative to centered interface bar. int skilldexWindowX = (screenGetWidth() - 640) / 2 + 640 - gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].width - SKILLDEX_WINDOW_RIGHT_MARGIN; - int skilldexWindowY = screenGetHeight() - 100 - 1 - gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].height - SKILLDEX_WINDOW_BOTTOM_MARGIN; + int skilldexWindowY = screenGetHeight() - INTERFACE_BAR_HEIGHT - 1 - gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].height - SKILLDEX_WINDOW_BOTTOM_MARGIN; gSkilldexWindow = windowCreate(skilldexWindowX, skilldexWindowY, gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].width,