From c91c7db3c7ebe336f073715babb7a3bdfe01fee6 Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Tue, 20 Aug 2024 10:48:08 +0200 Subject: [PATCH] renamed [gpio] dipsw settings to [system] --- chusanhook/dllmain.c | 2 +- cmhook/dllmain.c | 2 +- cmio/cmio.h | 4 +-- dist/chusan/segatools.ini | 4 +-- dist/cm/segatools.ini | 4 +-- dist/fgo/segatools.ini | 4 +-- dist/idac/segatools.ini | 4 +-- dist/mai2/segatools.ini | 4 +-- dist/mercury/segatools.ini | 4 +-- dist/mu3/segatools.ini | 4 +-- dist/swdc/segatools.ini | 4 +-- fgoio/fgoio.h | 10 ++----- platform/config.c | 12 ++++---- platform/config.h | 4 +-- platform/meson.build | 4 +-- platform/platform.c | 4 +-- platform/platform.h | 4 +-- platform/{dipsw.c => system.c} | 50 +++++++++++++++++----------------- platform/{dipsw.h => system.h} | 4 +-- 19 files changed, 64 insertions(+), 68 deletions(-) rename platform/{dipsw.c => system.c} (72%) rename platform/{dipsw.h => system.h} (59%) diff --git a/chusanhook/dllmain.c b/chusanhook/dllmain.c index 9f59301..85c6228 100644 --- a/chusanhook/dllmain.c +++ b/chusanhook/dllmain.c @@ -123,7 +123,7 @@ static DWORD CALLBACK chusan_pre_startup(void) goto fail; } - bool *dipsw = &chusan_hook_cfg.platform.dipsw.dipsw[0]; + bool *dipsw = &chusan_hook_cfg.platform.system.dipsw[0]; bool is_cvt = dipsw[2]; for (int i = 0; i < 3; i++) { diff --git a/cmhook/dllmain.c b/cmhook/dllmain.c index b004db3..ac54a9d 100644 --- a/cmhook/dllmain.c +++ b/cmhook/dllmain.c @@ -58,7 +58,7 @@ static DWORD CALLBACK cm_pre_startup(void) /* Hook external DLL APIs */ - printer_hook_init(&cm_hook_cfg.printer, 4, cm_hook_mod); + printer_hook_init(&cm_hook_cfg.printer, 0, cm_hook_mod); /* Initialize emulation hooks */ diff --git a/cmio/cmio.h b/cmio/cmio.h index cb4aa9c..86d8ac9 100644 --- a/cmio/cmio.h +++ b/cmio/cmio.h @@ -36,9 +36,9 @@ HRESULT cm_io_init(void); HRESULT cm_io_poll(void); /* Get the state of the cabinet's operator buttons as of the last poll. See - cm_IO_OPBTN enum above: this contains bit mask definitions for button + CM_IO_OPBTN enum above: this contains bit mask definitions for button states returned in *opbtn. All buttons are active-high. Minimum API version: 0x0100 */ -void cm_io_get_opbtns(uint8_t *opbtn); \ No newline at end of file +void cm_io_get_opbtns(uint8_t *opbtn); diff --git a/dist/chusan/segatools.ini b/dist/chusan/segatools.ini index c0b19de..556df02 100644 --- a/dist/chusan/segatools.ini +++ b/dist/chusan/segatools.ini @@ -59,8 +59,8 @@ addrSuffix=11 ; that subnet must start with 192.168. subnet=192.168.139.0 -[gpio] -; ALLS DIP switches. +[system] +; Enable ALLS system settings. enable=1 ; Enable freeplay mode. This will disable the coin slot and set the game to diff --git a/dist/cm/segatools.ini b/dist/cm/segatools.ini index f752b6b..2cd86b0 100644 --- a/dist/cm/segatools.ini +++ b/dist/cm/segatools.ini @@ -52,8 +52,8 @@ enable=1 ; that subnet must start with 192.168. subnet=192.168.165.0 -[gpio] -; ALLS DIP switches. +[system] +; Enable ALLS system settings. enable=1 ; LAN Install: If multiple machines are present on the same LAN then set diff --git a/dist/fgo/segatools.ini b/dist/fgo/segatools.ini index 0884c2d..945f9a1 100644 --- a/dist/fgo/segatools.ini +++ b/dist/fgo/segatools.ini @@ -72,8 +72,8 @@ addrSuffix=11 ; that subnet must start with 192.168. subnet=192.168.167.0 -[gpio] -; ALLS DIP switches. +[system] +; Enable ALLS system settings. enable=1 ; Enable freeplay mode. This will disable the coin slot and set the game to diff --git a/dist/idac/segatools.ini b/dist/idac/segatools.ini index f678a77..d4c828c 100644 --- a/dist/idac/segatools.ini +++ b/dist/idac/segatools.ini @@ -54,8 +54,8 @@ subnet=192.168.158.0 ; 1: JPN: Japan, 4: EXP: Export (for Asian markets) region=4 -[gpio] -; ALLS DIP switches. +[system] +; Enable ALLS system settings. enable=1 ; Enable freeplay mode. This will disable the coin slot and set the game to diff --git a/dist/mai2/segatools.ini b/dist/mai2/segatools.ini index 596a295..71dbf15 100644 --- a/dist/mai2/segatools.ini +++ b/dist/mai2/segatools.ini @@ -56,8 +56,8 @@ addrSuffix=11 ; that subnet must start with 192.168. subnet=192.168.172.0 -[gpio] -; ALLS DIP switches. +[system] +; Enable ALLS system settings. enable=1 ; Enable freeplay mode. This will disable the coin slot and set the game to diff --git a/dist/mercury/segatools.ini b/dist/mercury/segatools.ini index a31abd7..891c4d8 100644 --- a/dist/mercury/segatools.ini +++ b/dist/mercury/segatools.ini @@ -56,8 +56,8 @@ addrSuffix=11 ; that subnet must start with 192.168. subnet=192.168.174.0 -[gpio] -; ALLS DIP switches. +[system] +; Enable ALLS system settings. enable=1 ; Enable freeplay mode. This will disable the coin slot and set the game to diff --git a/dist/mu3/segatools.ini b/dist/mu3/segatools.ini index d7b8166..182e1d8 100644 --- a/dist/mu3/segatools.ini +++ b/dist/mu3/segatools.ini @@ -52,8 +52,8 @@ enable=1 ; that subnet must start with 192.168. subnet=192.168.162.0 -[gpio] -; ALLS DIP switches. +[system] +; Enable ALLS system settings. enable=1 ; Enable freeplay mode. This will disable the coin slot and set the game to diff --git a/dist/swdc/segatools.ini b/dist/swdc/segatools.ini index 71de4e3..6fdee71 100644 --- a/dist/swdc/segatools.ini +++ b/dist/swdc/segatools.ini @@ -56,8 +56,8 @@ addrSuffix=11 ; in order to find the MAIN cabinet. subnet=192.168.160.0 -[gpio] -; ALLS DIP switches. +[system] +; Enable ALLS system settings. enable=1 ; Enable freeplay mode. This will disable the coin slot and set the game to diff --git a/fgoio/fgoio.h b/fgoio/fgoio.h index 1adf6b7..c5b5fd8 100644 --- a/fgoio/fgoio.h +++ b/fgoio/fgoio.h @@ -52,16 +52,12 @@ HRESULT fgo_io_poll(void); void fgo_io_get_opbtns(uint8_t *opbtn); /* Get the state of the cabinet's gameplay buttons as of the last poll. See - FGO_IO_GAMEBTN enum above for bit mask definitions. Inputs are split into - a left hand side set of inputs and a right hand side set of inputs: the bit - mappings are the same in both cases. - - All buttons are active-high, even though some buttons' electrical signals - on a real cabinet are active-low. + FGO_IO_GAMEBTN enum above: this contains bit mask definitions for button + states returned in *gamebtn. All buttons are active-high. Minimum API version: 0x0100 */ -void fgo_io_get_gamebtns(uint8_t *btn); +void fgo_io_get_gamebtns(uint8_t *gamebtn); /* Get the position of the cabinet stick as of the last poll. The center position should be equal to or close to 32767. diff --git a/platform/config.c b/platform/config.c index fd48a3e..ad97905 100644 --- a/platform/config.c +++ b/platform/config.c @@ -22,7 +22,7 @@ #include "platform/pcbid.h" #include "platform/platform.h" #include "platform/vfs.h" -#include "platform/dipsw.h" +#include "platform/system.h" void platform_config_load(struct platform_config *cfg, const wchar_t *filename) { @@ -40,7 +40,7 @@ void platform_config_load(struct platform_config *cfg, const wchar_t *filename) netenv_config_load(&cfg->netenv, filename); nusec_config_load(&cfg->nusec, filename); vfs_config_load(&cfg->vfs, filename); - dipsw_config_load(&cfg->dipsw, filename); + system_config_load(&cfg->system, filename); } void amvideo_config_load(struct amvideo_config *cfg, const wchar_t *filename) @@ -329,7 +329,7 @@ void vfs_config_load(struct vfs_config *cfg, const wchar_t *filename) filename); } -void dipsw_config_load(struct dipsw_config *cfg, const wchar_t *filename) +void system_config_load(struct system_config *cfg, const wchar_t *filename) { wchar_t name[7]; size_t i; @@ -337,14 +337,14 @@ void dipsw_config_load(struct dipsw_config *cfg, const wchar_t *filename) assert(cfg != NULL); assert(filename != NULL); - cfg->enable = GetPrivateProfileIntW(L"gpio", L"enable", 0, filename); - cfg->freeplay = GetPrivateProfileIntW(L"gpio", L"freeplay", 0, filename); + cfg->enable = GetPrivateProfileIntW(L"system", L"enable", 0, filename); + cfg->freeplay = GetPrivateProfileIntW(L"system", L"freeplay", 0, filename); wcscpy_s(name, _countof(name), L"dipsw0"); for (i = 0 ; i < 8 ; i++) { name[5] = L'1' + i; - cfg->dipsw[i] = GetPrivateProfileIntW(L"gpio", name, 0, filename); + cfg->dipsw[i] = GetPrivateProfileIntW(L"system", name, 0, filename); } } diff --git a/platform/config.h b/platform/config.h index eb04b56..e945378 100644 --- a/platform/config.h +++ b/platform/config.h @@ -18,7 +18,7 @@ #include "platform/pcbid.h" #include "platform/platform.h" #include "platform/vfs.h" -#include "platform/dipsw.h" +#include "platform/system.h" void platform_config_load( struct platform_config *cfg, @@ -35,4 +35,4 @@ void netenv_config_load(struct netenv_config *cfg, const wchar_t *filename); void nusec_config_load(struct nusec_config *cfg, const wchar_t *filename); void pcbid_config_load(struct pcbid_config *cfg, const wchar_t *filename); void vfs_config_load(struct vfs_config *cfg, const wchar_t *filename); -void dipsw_config_load(struct dipsw_config *cfg, const wchar_t *filename); +void system_config_load(struct system_config *cfg, const wchar_t *filename); diff --git a/platform/meson.build b/platform/meson.build index 4ca2a38..aa0d362 100644 --- a/platform/meson.build +++ b/platform/meson.build @@ -34,7 +34,7 @@ platform_lib = static_library( 'platform.h', 'vfs.c', 'vfs.h', - 'dipsw.c', - 'dipsw.h', + 'system.c', + 'system.h', ], ) diff --git a/platform/platform.c b/platform/platform.c index 5a1b5f6..a769c97 100644 --- a/platform/platform.c +++ b/platform/platform.c @@ -13,7 +13,7 @@ #include "platform/pcbid.h" #include "platform/platform.h" #include "platform/vfs.h" -#include "platform/dipsw.h" +#include "platform/system.h" HRESULT platform_hook_init( const struct platform_config *cfg, @@ -82,7 +82,7 @@ HRESULT platform_hook_init( return hr; } - hr = dipsw_init(&cfg->dipsw, &cfg->vfs); + hr = system_init(&cfg->system, &cfg->vfs); if (FAILED(hr)) { return hr; diff --git a/platform/platform.h b/platform/platform.h index 8774f01..0b69f12 100644 --- a/platform/platform.h +++ b/platform/platform.h @@ -13,7 +13,7 @@ #include "platform/nusec.h" #include "platform/pcbid.h" #include "platform/vfs.h" -#include "platform/dipsw.h" +#include "platform/system.h" struct platform_config { struct amvideo_config amvideo; @@ -27,7 +27,7 @@ struct platform_config { struct netenv_config netenv; struct nusec_config nusec; struct vfs_config vfs; - struct dipsw_config dipsw; + struct system_config system; }; HRESULT platform_hook_init( diff --git a/platform/dipsw.c b/platform/system.c similarity index 72% rename from platform/dipsw.c rename to platform/system.c index 22b88ed..49f7999 100644 --- a/platform/dipsw.c +++ b/platform/system.c @@ -4,7 +4,7 @@ #include #include -#include "platform/dipsw.h" +#include "platform/system.h" #include "platform/vfs.h" #include "util/dprintf.h" @@ -30,12 +30,12 @@ typedef struct char padding[4]; uint8_t dip_switches; char data[DATA_SIZE]; -} DipSwitchBlock; +} DipSwBlock; typedef struct { CreditBlock credit_block; - DipSwitchBlock dip_switch_block; + DipSwBlock dip_switch_block; char *data; } SystemInfo; @@ -43,13 +43,13 @@ typedef struct static SystemInfo system_info; -static struct dipsw_config dipsw_config; +static struct system_config system_config; static struct vfs_config vfs_config; -static void dipsw_read_sysfile(const wchar_t *sys_file); -static void dipsw_save_sysfile(const wchar_t *sys_file); +static void system_read_sysfile(const wchar_t *sys_file); +static void system_save_sysfile(const wchar_t *sys_file); -HRESULT dipsw_init(const struct dipsw_config *cfg, const struct vfs_config *vfs_cfg) +HRESULT system_init(const struct system_config *cfg, const struct vfs_config *vfs_cfg) { HRESULT hr; wchar_t sys_file_path[MAX_PATH]; @@ -62,28 +62,28 @@ HRESULT dipsw_init(const struct dipsw_config *cfg, const struct vfs_config *vfs_ return S_FALSE; } - memcpy(&dipsw_config, cfg, sizeof(*cfg)); + memcpy(&system_config, cfg, sizeof(*cfg)); sys_file_path[0] = L'\0'; // concatenate vfs_config.amfs with L"sysfile.dat" wcsncpy(sys_file_path, vfs_cfg->amfs, MAX_PATH); wcsncat(sys_file_path, L"\\sysfile.dat", MAX_PATH); - dipsw_read_sysfile(sys_file_path); + system_read_sysfile(sys_file_path); - // now write the dipsw_config.dipsw to the dip_switch_block - dipsw_save_sysfile(sys_file_path); + // now write the system_config.system to the dip_switch_block + system_save_sysfile(sys_file_path); return S_OK; } -static void dipsw_read_sysfile(const wchar_t *sys_file) +static void system_read_sysfile(const wchar_t *sys_file) { FILE *f = _wfopen(sys_file, L"r"); if (f == NULL) { - dprintf("DipSw: First run detected, DipSw settings can only be applied AFTER the first run\n"); + dprintf("System: First run detected, system settings can only be applied AFTER the first run\n"); return; } @@ -93,7 +93,7 @@ static void dipsw_read_sysfile(const wchar_t *sys_file) if (file_size != 0x6000) { - dprintf("DipSw: Invalid sysfile.dat file size\n"); + dprintf("System: Invalid sysfile.dat file size\n"); fclose(f); return; @@ -108,10 +108,10 @@ static void dipsw_read_sysfile(const wchar_t *sys_file) memcpy(&system_info.dip_switch_block, system_info.data + 0x2800, BLOCK_SIZE); } -static void dipsw_save_sysfile(const wchar_t *sys_file) +static void system_save_sysfile(const wchar_t *sys_file) { char block[BLOCK_SIZE]; - uint8_t dipsw = 0; + uint8_t system = 0; uint8_t freeplay = 0; // open the sysfile.dat for writing in bytes mode @@ -122,28 +122,28 @@ static void dipsw_save_sysfile(const wchar_t *sys_file) return; } - // write the dipsw_config.dipsw to the dip_switch_block + // write the system_config.system to the dip_switch_block for (int i = 0; i < 8; i++) { - if (dipsw_config.dipsw[i]) + if (system_config.dipsw[i]) { - // print which dipsw is enabled - dprintf("DipSw: DipSw%d=1 set\n", i + 1); - dipsw |= (1 << i); + // print which system is enabled + dprintf("System: DipSw%d=1 set\n", i + 1); + system |= (1 << i); } } - if (dipsw_config.freeplay) + if (system_config.freeplay) { // print that freeplay is enabled - dprintf("DipSw: Freeplay enabled\n"); + dprintf("System: Freeplay enabled\n"); freeplay = 1; } // set the new credit block system_info.credit_block.freeplay = freeplay; // set the new dip_switch_block - system_info.dip_switch_block.dip_switches = dipsw; + system_info.dip_switch_block.dip_switches = system; // calculate the new checksum, skip the old crc32 value // which is at the beginning of the block, thats's why the +4 @@ -167,7 +167,7 @@ static void dipsw_save_sysfile(const wchar_t *sys_file) // print the dip_switch_block in hex /* - dprintf("DipSw Block: "); + dprintf("System Block: "); for (size_t i = 0; i < BLOCK_SIZE; i++) { dprintf("%02X ", ((uint8_t *)&system_info.dip_switch_block)[i]); diff --git a/platform/dipsw.h b/platform/system.h similarity index 59% rename from platform/dipsw.h rename to platform/system.h index 336b0d7..ba0f2a6 100644 --- a/platform/dipsw.h +++ b/platform/system.h @@ -7,10 +7,10 @@ #include "platform/vfs.h" -struct dipsw_config { +struct system_config { bool enable; bool freeplay; bool dipsw[8]; }; -HRESULT dipsw_init(const struct dipsw_config *cfg, const struct vfs_config *vfs_cfg); +HRESULT system_init(const struct system_config *cfg, const struct vfs_config *vfs_cfg);