From dff71b530a02de74127697223d4f9aa2f510e604 Mon Sep 17 00:00:00 2001 From: Tau Date: Fri, 17 May 2019 23:35:53 -0400 Subject: [PATCH] chunihook/config.c: Consolidate config --- chunihook/config.c | 23 +++++++++++++++++++++++ chunihook/config.h | 16 ++++++++++++++++ chunihook/dllmain.c | 25 ++++++++++--------------- chunihook/meson.build | 2 ++ 4 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 chunihook/config.c create mode 100644 chunihook/config.h diff --git a/chunihook/config.c b/chunihook/config.c new file mode 100644 index 0000000..d2fe313 --- /dev/null +++ b/chunihook/config.c @@ -0,0 +1,23 @@ +#include + +#include +#include + +#include "amex/config.h" + +#include "chunihook/config.h" + +#include "platform/config.h" + +void chuni_hook_config_load( + struct chuni_hook_config *cfg, + const wchar_t *filename) +{ + assert(cfg != NULL); + assert(filename != NULL); + + memset(cfg, 0, sizeof(*cfg)); + + nu_config_load(&cfg->nu, filename); + amex_config_load(&cfg->amex, filename); +} diff --git a/chunihook/config.h b/chunihook/config.h new file mode 100644 index 0000000..f62459a --- /dev/null +++ b/chunihook/config.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +#include "amex/config.h" + +#include "platform/config.h" + +struct chuni_hook_config { + struct nu_config nu; + struct amex_config amex; +}; + +void chuni_hook_config_load( + struct chuni_hook_config *cfg, + const wchar_t *filename); diff --git a/chunihook/dllmain.c b/chunihook/dllmain.c index 56c0116..14361ca 100644 --- a/chunihook/dllmain.c +++ b/chunihook/dllmain.c @@ -4,8 +4,8 @@ #include #include "amex/amex.h" -#include "amex/config.h" +#include "chunihook/config.h" #include "chunihook/jvs.h" #include "chunihook/slider.h" @@ -18,18 +18,16 @@ #include "hooklib/serial.h" #include "hooklib/spike.h" -#include "platform/config.h" #include "platform/platform.h" #include "util/dprintf.h" static HMODULE chuni_hook_mod; static process_entry_t chuni_startup; +static struct chuni_hook_config chuni_hook_cfg; static DWORD CALLBACK chuni_pre_startup(void) { - struct amex_config amex_cfg; - struct nu_config nu_cfg; HMODULE d3dc; dprintf("--- Begin chuni_pre_startup ---\n"); @@ -44,25 +42,22 @@ static DWORD CALLBACK chuni_pre_startup(void) dprintf("Failed to load shader compiler!\n"); } + /* Config load */ + + chuni_hook_config_load(&chuni_hook_cfg, L".\\segatools.ini"); + /* Hook Win32 APIs */ clock_hook_init(); gfx_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, "SDBT", "AAV1", chuni_hook_mod); + platform_hook_init_nu(&chuni_hook_cfg.nu, "SDBT", "AAV1", chuni_hook_mod); + amex_hook_init(&chuni_hook_cfg.amex); - /* Initialize AMEX emulation */ - - amex_config_load(&amex_cfg, L".\\segatools.ini"); - amex_hook_init(&amex_cfg); - - /* Initialize Chunithm board emulation */ - - if (amex_cfg.jvs.enable) { + if (chuni_hook_cfg.amex.jvs.enable) { chunithm_jvs_init(); } diff --git a/chunihook/meson.build b/chunihook/meson.build index b450f89..ebb3403 100644 --- a/chunihook/meson.build +++ b/chunihook/meson.build @@ -18,6 +18,8 @@ shared_library( util_lib, ], sources : [ + 'config.c', + 'config.h', 'dllmain.c', 'jvs.c', 'jvs.h',