divahook/config.c: Consolidate config

This commit is contained in:
Tau 2019-05-17 23:41:14 -04:00
parent dff71b530a
commit d44740647c
4 changed files with 47 additions and 16 deletions

19
divahook/config.c Normal file
View File

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

16
divahook/config.h Normal file
View File

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

View File

@ -4,10 +4,10 @@
#include <stdlib.h>
#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();
}

View File

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