chunihook/config.c: Consolidate config

This commit is contained in:
Tau 2019-05-17 23:35:53 -04:00
parent 55062bf56b
commit dff71b530a
4 changed files with 51 additions and 15 deletions

23
chunihook/config.c Normal file
View File

@ -0,0 +1,23 @@
#include <windows.h>
#include <assert.h>
#include <stddef.h>
#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);
}

16
chunihook/config.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include <stddef.h>
#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);

View File

@ -4,8 +4,8 @@
#include <stdlib.h> #include <stdlib.h>
#include "amex/amex.h" #include "amex/amex.h"
#include "amex/config.h"
#include "chunihook/config.h"
#include "chunihook/jvs.h" #include "chunihook/jvs.h"
#include "chunihook/slider.h" #include "chunihook/slider.h"
@ -18,18 +18,16 @@
#include "hooklib/serial.h" #include "hooklib/serial.h"
#include "hooklib/spike.h" #include "hooklib/spike.h"
#include "platform/config.h"
#include "platform/platform.h" #include "platform/platform.h"
#include "util/dprintf.h" #include "util/dprintf.h"
static HMODULE chuni_hook_mod; static HMODULE chuni_hook_mod;
static process_entry_t chuni_startup; static process_entry_t chuni_startup;
static struct chuni_hook_config chuni_hook_cfg;
static DWORD CALLBACK chuni_pre_startup(void) static DWORD CALLBACK chuni_pre_startup(void)
{ {
struct amex_config amex_cfg;
struct nu_config nu_cfg;
HMODULE d3dc; HMODULE d3dc;
dprintf("--- Begin chuni_pre_startup ---\n"); dprintf("--- Begin chuni_pre_startup ---\n");
@ -44,25 +42,22 @@ static DWORD CALLBACK chuni_pre_startup(void)
dprintf("Failed to load shader compiler!\n"); dprintf("Failed to load shader compiler!\n");
} }
/* Config load */
chuni_hook_config_load(&chuni_hook_cfg, L".\\segatools.ini");
/* Hook Win32 APIs */ /* Hook Win32 APIs */
clock_hook_init(); clock_hook_init();
gfx_hook_init(); gfx_hook_init();
serial_hook_init(); serial_hook_init();
/* Initialize platform API emulation */ /* Initialize emulation hooks */
nu_config_load(&nu_cfg, L".\\segatools.ini"); platform_hook_init_nu(&chuni_hook_cfg.nu, "SDBT", "AAV1", chuni_hook_mod);
platform_hook_init_nu(&nu_cfg, "SDBT", "AAV1", chuni_hook_mod); amex_hook_init(&chuni_hook_cfg.amex);
/* Initialize AMEX emulation */ if (chuni_hook_cfg.amex.jvs.enable) {
amex_config_load(&amex_cfg, L".\\segatools.ini");
amex_hook_init(&amex_cfg);
/* Initialize Chunithm board emulation */
if (amex_cfg.jvs.enable) {
chunithm_jvs_init(); chunithm_jvs_init();
} }

View File

@ -18,6 +18,8 @@ shared_library(
util_lib, util_lib,
], ],
sources : [ sources : [
'config.c',
'config.h',
'dllmain.c', 'dllmain.c',
'jvs.c', 'jvs.c',
'jvs.h', 'jvs.h',