Added a debug option to toggle the hex grid

Added HiResMode option to ddraw.ini, along with some edits.
Fixed db_init function wrapper.
Some edits to HRP code.
This commit is contained in:
NovaRain
2021-12-20 12:00:45 +08:00
parent 317c462918
commit 3cc98fc15d
8 changed files with 43 additions and 9 deletions
+12 -5
View File
@@ -2,7 +2,10 @@
;v4.3.3
[Main]
;Change to 1 if you want to use command line args to tell sfall to use another ini file
;Set to 1 to enable the built-in High Resolution Patch mode that is similar to the hi-res patch by Mash
HiResMode=1
;Set to 1 if you want to use command line args to tell sfall to use another ini file
;This option is always enabled in 4.3.3/3.8.33 or later. The information is left for reference only
UseCommandLine=0
@@ -185,7 +188,7 @@ BackgroundMouse=0
SpeedModKey=-1
;A key to press to toggle the speed tweak on or off
;Specify 0 if you don't want a toggle key, or a DX scancode otherwise
;Set to 0 if you don't want a toggle key, or a DX scancode otherwise
SpeedToggleKey=0
;The keys corresponding to the 10 speed slots
@@ -255,8 +258,8 @@ WorldMapEncounterFix=0
WorldMapEncounterRate=5
;The number of slots available in the locations list panel of the world map
;Set to 0 to leave unchanged. 17 is default.
;Setting this greater than 17 requires a replacement background FRM, or you'll get glitched graphics
;Set to 0 to leave the default unchanged (i.e. 17). The maximum is 127
;Setting this greater than 17 requires a replacement WMTABS.frm file in art\intrface\, or you'll get glitched graphics
WorldMapSlots=0
;To start a new game somewhere other than artemple.map, uncomment the next line and set it to the map you want to load
@@ -852,7 +855,7 @@ AllowUnsafeScripting=0
;Does not require sfall debugging mode
SkipSizeCheck=0
;Change to 1 to skip the compatibility mode check
;Set to 1 to skip the compatibility mode check
SkipCompatModeCheck=0
;Fallout 2 Debug Patch
@@ -875,6 +878,10 @@ DebugMode=0
;Set to 1 to hide error messages in debug output when a null value is passed to the function as an object
HideObjIsNullMsg=0
;A key to press to toggle the display of the hex grid in the game on or off
;Set to 0 to disable, or a DX scancode otherwise
ShowMapGridKey=0
;Set to 1 to stop Fallout from deleting non read-only protos at startup
;Has pretty nasty side effects when saving/reloading, so don't use for regular gameplay
DontDeleteProtos=0
+5
View File
@@ -162,6 +162,11 @@ void __declspec(naked) interpretError(const char* fmt, ...) {
__asm jmp fo::funcoffs::interpretError_;
}
long __fastcall db_init(const char* path_dat, const char* path_patches) {
__asm mov ebx, edx; // don't delete
WRAP_WATCOM_FCALL2(db_init_, path_dat, path_patches);
}
long __fastcall tile_num(long x, long y) {
__asm xor ebx, ebx; // don't delete (bug in tile_num_)
WRAP_WATCOM_FCALL2(tile_num_, x, y);
+2
View File
@@ -52,6 +52,8 @@ DWORD __fastcall interpretGetValue(Program* scriptPtr, DWORD &outType);
// USE WITH CAUTION
void __declspec() interpretError(const char* fmt, ...);
long __fastcall db_init(const char* path_dat, const char* path_patches);
long __fastcall tile_num(long x, long y);
void __fastcall square_xy(long x, long y, long* outSX, long* outSY);
-1
View File
@@ -309,7 +309,6 @@ WRAP_WATCOM_FUNC2(long, db_dir_entry, const char*, fileName, DWORD*, sizeOut) //
// Searches files in DB by given path/filename mask and stores result in fileList
// fileList is a pointer to a variable, that will be assigned with an address of an array of char* strings
WRAP_WATCOM_FUNC2(long, db_get_file_list, const char*, searchMask, char***, fileList) // Returns number of elements in *fileList
WRAP_WATCOM_FUNC2(long, db_init, const char*, path_dat, const char*, path_patches)
WRAP_WATCOM_FUNC1(void*, dbase_open, const char*, fileName)
WRAP_WATCOM_FUNC1(void, dbase_close, void*, dbPtr)
+2
View File
@@ -199,6 +199,7 @@
#define FO_VAR_map_global_vars 0x51956C
#define FO_VAR_map_name 0x631D58
#define FO_VAR_map_number 0x631D88
#define FO_VAR_map_scroll_refresh 0x519540
#define FO_VAR_map_state 0x631D28
#define FO_VAR_mapEntranceElevation 0x519558
#define FO_VAR_mapEntranceTileNum 0x51955C
@@ -337,6 +338,7 @@
#define FO_VAR_tile_mask 0x66B9C4
#define FO_VAR_tile_offx 0x66BDFC
#define FO_VAR_tile_offy 0x66BDF8
#define FO_VAR_tile_refresh 0x51D964
#define FO_VAR_tile_x 0x66BE18
#define FO_VAR_tile_y 0x66BE1C
#define FO_VAR_title_color 0x56D750
+1
View File
@@ -572,6 +572,7 @@ void IFaceBar::init() {
sf::SafeWrite8(0x481E2E, 1); // iso_init_
// replace subtract 99 with add 1
sf::SafeWrite8(0x481DC3, -1); // iso_init_
sf::SafeWrite8(0x482BF5, -1); // map_load_file_
sf::SafeWrite8(0x4827A9, -1); // map_scroll_
// remove subtract 100
sf::SafeWrite8(0x48284F, 0); // map_scroll_
+3
View File
@@ -266,8 +266,11 @@ long EdgeClipping::CheckMapClipping() {
void EdgeClipping::init() {
sf::HookCall(0x4B15F6, refresh_game_hook_rect_inside_bound);
sf::HookCall(0x4B1565, refresh_game_hook_rect_inside_bound); // refresh_mapper_
sf::HookCall(0x483EF0, map_scroll_refresh_game_hook_rect_inside_bound);
sf::HookCall(0x483F53, map_scroll_refresh_game_hook_rect_inside_bound); // map_scroll_refresh_mapper_
sf::MakeCall(0x44E481, gmouse_check_scrolling_hack); // from HRP 3.06 (TODO: redo the implementation so that the scrolling of the map works)
// Prevents the rendering of "post roof" objects (fixes the red pixels from the hex cursor remaining at the edges of the cropped part of the map)
+18 -3
View File
@@ -52,6 +52,7 @@ static const char* debugLog = "LOG";
static const char* debugGnw = "GNW";
static DWORD debugEditorKey = 0;
static DWORD showMapGridKey = 0;
struct sArray {
DWORD id;
@@ -61,7 +62,7 @@ struct sArray {
};
static void DEGameWinRedraw() {
if (Graphics::mode != 0) fo::func::process_bk();
if (Graphics::mode != 0) fo::func::process_bk(); // test for mode 1/2 (from built-in HRP)
}
static bool SetBlocking(SOCKET s, bool block) {
@@ -530,14 +531,28 @@ void DebugEditor::init() {
if (!isDebug) return;
DontDeleteProtosPatch();
debugEditorKey = IniReader::GetConfigInt("Input", "DebugEditorKey", 0);
if (debugEditorKey != 0) {
debugEditorKey = IniReader::GetConfigInt("Input", "DebugEditorKey", 0) & 0xFF;
if (debugEditorKey) {
OnKeyPressed() += [](DWORD scanCode, bool pressed) {
if (scanCode == debugEditorKey && pressed && IsGameLoaded()) {
RunDebugEditor();
}
};
}
showMapGridKey = IniReader::GetIntDefaultConfig("Debugging", "ShowMapGridKey", 0) & 0xFF;
if (showMapGridKey) {
OnKeyPressed() += [](DWORD scanCode, bool pressed) {
if (scanCode == showMapGridKey && pressed && IsGameLoaded()) {
__asm call fo::funcoffs::grid_toggle_;
fo::func::tile_refresh_display();
}
};
LoadGameHook::OnAfterGameInit() += []() {
fo::var::setInt(FO_VAR_tile_refresh) = fo::funcoffs::refresh_mapper_;
//fo::var::setInt(FO_VAR_map_scroll_refresh) = fo::funcoffs::map_scroll_refresh_mapper_;
};
}
}
}