From 96fe28b66c3fac7de4b3444b3488b587b8039c7d Mon Sep 17 00:00:00 2001 From: Tau Date: Fri, 17 May 2019 23:48:21 -0400 Subject: [PATCH] idzhook/config.c: Consolidate config --- idzhook/config.c | 18 ++++++++++++++++++ idzhook/config.h | 16 ++++++++++++++++ idzhook/dllmain.c | 26 ++++++++++---------------- idzhook/meson.build | 2 ++ 4 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 idzhook/config.c create mode 100644 idzhook/config.h diff --git a/idzhook/config.c b/idzhook/config.c new file mode 100644 index 0000000..302d8c5 --- /dev/null +++ b/idzhook/config.c @@ -0,0 +1,18 @@ +#include + +#include "amex/config.h" + +#include "idzhook/config.h" + +#include "platform/config.h" + +void idz_hook_config_load( + struct idz_hook_config *cfg, + const wchar_t *filename) +{ + assert(cfg != NULL); + assert(filename != NULL); + + nu_config_load(&cfg->nu, filename); + amex_config_load(&cfg->amex, filename); +} diff --git a/idzhook/config.h b/idzhook/config.h new file mode 100644 index 0000000..f82986e --- /dev/null +++ b/idzhook/config.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +#include "amex/config.h" + +#include "platform/config.h" + +struct idz_hook_config { + struct nu_config nu; + struct amex_config amex; +}; + +void idz_hook_config_load( + struct idz_hook_config *cfg, + const wchar_t *filename); diff --git a/idzhook/dllmain.c b/idzhook/dllmain.c index a96ef96..27a7f0c 100644 --- a/idzhook/dllmain.c +++ b/idzhook/dllmain.c @@ -4,7 +4,6 @@ #include #include "amex/amex.h" -#include "amex/config.h" #include "board/sg-reader.h" @@ -15,43 +14,38 @@ #include "hooklib/serial.h" #include "hooklib/spike.h" +#include "idzhook/config.h" #include "idzhook/jvs.h" -#include "platform/config.h" #include "platform/platform.h" #include "util/dprintf.h" static HMODULE idz_hook_mod; static process_entry_t idz_startup; +static struct idz_hook_config idz_hook_cfg; static DWORD CALLBACK idz_pre_startup(void) { - struct nu_config nu_cfg; - struct amex_config amex_cfg; - dprintf("--- Begin idz_pre_startup ---\n"); + /* Config load */ + + idz_hook_config_load(&idz_hook_cfg, L".\\segatools.ini"); + /* Hook Win32 APIs */ clock_hook_init(); serial_hook_init(); - /* Initialize platform API emulation */ + /* Initialize emulation hooks */ - nu_config_load(&nu_cfg, L".\\segatools.ini"); - platform_hook_init_nu(&nu_cfg, "SDDF", "AAV2", idz_hook_mod); - - /* Initialize AMEX emulation */ - - amex_config_load(&amex_cfg, L".\\segatools.ini"); - amex_hook_init(&amex_cfg); - - /* Initialize Initial D Zero I/O board emulation */ + platform_hook_init_nu(&idz_hook_cfg.nu, "SDDF", "AAV2", idz_hook_mod); + amex_hook_init(&idz_hook_cfg.amex); sg_reader_hook_init(10); - if (amex_cfg.jvs.enable) { + if (idz_hook_cfg.amex.jvs.enable) { idz_jvs_init(); } diff --git a/idzhook/meson.build b/idzhook/meson.build index ac6e857..f876692 100644 --- a/idzhook/meson.build +++ b/idzhook/meson.build @@ -21,6 +21,8 @@ shared_library( util_lib, ], sources : [ + 'config.c', + 'config.h', 'dllmain.c', 'jvs.c', 'jvs.h',