From d44740647c6a25e7d5dd9dbe1afd5a2758259a84 Mon Sep 17 00:00:00 2001 From: Tau Date: Fri, 17 May 2019 23:41:14 -0400 Subject: [PATCH] divahook/config.c: Consolidate config --- divahook/config.c | 19 +++++++++++++++++++ divahook/config.h | 16 ++++++++++++++++ divahook/dllmain.c | 26 ++++++++++---------------- divahook/meson.build | 2 ++ 4 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 divahook/config.c create mode 100644 divahook/config.h diff --git a/divahook/config.c b/divahook/config.c new file mode 100644 index 0000000..0aeffd2 --- /dev/null +++ b/divahook/config.c @@ -0,0 +1,19 @@ +#include +#include + +#include "amex/config.h" + +#include "divahook/config.h" + +#include "platform/config.h" + +void diva_hook_config_load( + struct diva_hook_config *cfg, + const wchar_t *filename) +{ + assert(cfg != NULL); + assert(filename != NULL); + + amex_config_load(&cfg->amex, filename); + nu_config_load(&cfg->nu, filename); +} diff --git a/divahook/config.h b/divahook/config.h new file mode 100644 index 0000000..4e9f086 --- /dev/null +++ b/divahook/config.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +#include "amex/config.h" + +#include "platform/config.h" + +struct diva_hook_config { + struct nu_config nu; + struct amex_config amex; +}; + +void diva_hook_config_load( + struct diva_hook_config *cfg, + const wchar_t *filename); diff --git a/divahook/dllmain.c b/divahook/dllmain.c index c7fadba..4d78742 100644 --- a/divahook/dllmain.c +++ b/divahook/dllmain.c @@ -4,10 +4,10 @@ #include #include "amex/amex.h" -#include "amex/config.h" #include "board/sg-reader.h" +#include "divahook/config.h" #include "divahook/jvs.h" #include "divahook/slider.h" @@ -18,39 +18,33 @@ #include "hooklib/serial.h" #include "hooklib/spike.h" -#include "platform/config.h" #include "platform/platform.h" #include "util/dprintf.h" static HMODULE diva_hook_mod; static process_entry_t diva_startup; +static struct diva_hook_config diva_hook_cfg; static DWORD CALLBACK diva_pre_startup(void) { - struct amex_config amex_cfg; - struct nu_config nu_cfg; - dprintf("--- Begin diva_pre_startup ---\n"); + /* Config load */ + + diva_hook_config_load(&diva_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, "SBZV", "AAV0", diva_hook_mod); + platform_hook_init_nu(&diva_hook_cfg.nu, "SBZV", "AAV0", diva_hook_mod); + amex_hook_init(&diva_hook_cfg.amex); - /* Initialize AMEX emulation */ - - amex_config_load(&amex_cfg, L".\\segatools.ini"); - amex_hook_init(&amex_cfg); - - /* Initialize Project Diva I/O board emulation */ - - if (amex_cfg.jvs.enable) { + if (diva_hook_cfg.amex.jvs.enable) { diva_jvs_init(); } diff --git a/divahook/meson.build b/divahook/meson.build index d401470..d49c157 100644 --- a/divahook/meson.build +++ b/divahook/meson.build @@ -20,6 +20,8 @@ shared_library( util_lib, ], sources : [ + 'config.c', + 'config.h', 'dllmain.c', 'jvs.c', 'jvs.h',