renamed [gpio] dipsw settings to [system]

This commit is contained in:
Dniel97 2024-08-20 10:48:08 +02:00
parent 6a4cae1165
commit c91c7db3c7
Signed by untrusted user: Dniel97
GPG Key ID: 6180B3C768FB2E08
19 changed files with 64 additions and 68 deletions

View File

@ -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++) {

View File

@ -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 */

View File

@ -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);
void cm_io_get_opbtns(uint8_t *opbtn);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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);
}
}

View File

@ -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);

View File

@ -34,7 +34,7 @@ platform_lib = static_library(
'platform.h',
'vfs.c',
'vfs.h',
'dipsw.c',
'dipsw.h',
'system.c',
'system.h',
],
)

View File

@ -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;

View File

@ -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(

View File

@ -4,7 +4,7 @@
#include <assert.h>
#include <string.h>
#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]);

View File

@ -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);