mirror of
https://gitea.tendokyu.moe/Dniel97/segatools.git
synced 2025-03-04 08:54:28 +01:00
system: add dip switch label configurations
This commit is contained in:
parent
b8af67377c
commit
4d0ef54279
@ -86,11 +86,18 @@ static DWORD CALLBACK chusan_pre_startup(void) {
|
|||||||
|
|
||||||
/* Initialize emulation hooks */
|
/* Initialize emulation hooks */
|
||||||
|
|
||||||
hr = platform_hook_init(
|
struct dipsw_config new_dipsw_config[8] = {
|
||||||
&chusan_hook_cfg.platform,
|
{L"Delivery Server", L"Server", L"Client"},
|
||||||
"SDHD",
|
{L"Monitor Type", L"60FPS", L"120FPS"},
|
||||||
"ACA2",
|
{L"Cabinet Type", L"CVT", L"SP"},
|
||||||
chusan_hook_mod);
|
};
|
||||||
|
|
||||||
|
// Set the system dip switch configuration
|
||||||
|
memcpy(chusan_hook_cfg.platform.system.dipsw_config, new_dipsw_config,
|
||||||
|
sizeof(new_dipsw_config));
|
||||||
|
|
||||||
|
hr = platform_hook_init(&chusan_hook_cfg.platform, "SDHD", "ACA2",
|
||||||
|
chusan_hook_mod);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -114,27 +121,7 @@ static DWORD CALLBACK chusan_pre_startup(void) {
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool *dipsw = &chusan_hook_cfg.platform.system.dipsw[0];
|
bool is_cvt = chusan_hook_cfg.platform.system.dipsw[2];
|
||||||
bool is_cvt = dipsw[2];
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
switch (i) {
|
|
||||||
case 0:
|
|
||||||
dprintf("DipSw: NetInstall: %s\n", dipsw[0] ? "Server" : "Client");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
dprintf("DipSw: Monitor Type: %dFPS\n", dipsw[1] ? 60 : 120);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
dprintf("DipSw: Cab Type: %s\n", is_cvt ? "CVT" : "SP");
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int first_port = is_cvt ? 2 : 20;
|
|
||||||
|
|
||||||
if (!is_cvt) {
|
if (!is_cvt) {
|
||||||
hr = vfd_hook_init(&chusan_hook_cfg.vfd, 2);
|
hr = vfd_hook_init(&chusan_hook_cfg.vfd, 2);
|
||||||
|
@ -63,6 +63,14 @@ static DWORD CALLBACK cm_pre_startup(void)
|
|||||||
|
|
||||||
/* Initialize emulation hooks */
|
/* Initialize emulation hooks */
|
||||||
|
|
||||||
|
struct dipsw_config new_dipsw_config[8] = {
|
||||||
|
{L"Delivery Server", L"Client", L"Server"},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set the system dip switch configuration
|
||||||
|
memcpy(cm_hook_cfg.platform.system.dipsw_config, new_dipsw_config,
|
||||||
|
sizeof(new_dipsw_config));
|
||||||
|
|
||||||
hr = platform_hook_init(
|
hr = platform_hook_init(
|
||||||
&cm_hook_cfg.platform,
|
&cm_hook_cfg.platform,
|
||||||
"SDED",
|
"SDED",
|
||||||
|
2
dist/fgo/segatools.ini
vendored
2
dist/fgo/segatools.ini
vendored
@ -41,7 +41,7 @@ portNo=17
|
|||||||
; 837-15093-06 LED board emulation setting.
|
; 837-15093-06 LED board emulation setting.
|
||||||
enable=1
|
enable=1
|
||||||
; COM port number for the LED board. Has to be the same as the FTDI port.
|
; COM port number for the LED board. Has to be the same as the FTDI port.
|
||||||
portNo=17
|
portNo1=17
|
||||||
|
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
; Network settings
|
; Network settings
|
||||||
|
@ -4,7 +4,7 @@ hooklib_lib = static_library(
|
|||||||
implicit_include_directories : false,
|
implicit_include_directories : false,
|
||||||
dependencies : [
|
dependencies : [
|
||||||
capnhook.get_variable('hook_dep'),
|
capnhook.get_variable('hook_dep'),
|
||||||
Ws2_32_lib
|
ws2_32_lib
|
||||||
],
|
],
|
||||||
sources : [
|
sources : [
|
||||||
'cursor.c',
|
'cursor.c',
|
||||||
|
@ -60,6 +60,18 @@ static DWORD CALLBACK idac_pre_startup(void)
|
|||||||
|
|
||||||
/* Initialize emulation hooks */
|
/* Initialize emulation hooks */
|
||||||
|
|
||||||
|
struct dipsw_config new_dipsw_config[8] = {
|
||||||
|
{L"Delivery Server", L"Server", L"Client"},
|
||||||
|
{L"Cabinet Type", L"SWDC CVT", L"DZero CVT"},
|
||||||
|
{L"Single Seat", L"ON", L"OFF"},
|
||||||
|
{L"Seat Setting 1", L"ON", L"OFF"},
|
||||||
|
{L"Seat Setting 2", L"ON", L"OFF"},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set the system dip switch configuration
|
||||||
|
memcpy(idac_hook_cfg.platform.system.dipsw_config, new_dipsw_config,
|
||||||
|
sizeof(new_dipsw_config));
|
||||||
|
|
||||||
hr = platform_hook_init(
|
hr = platform_hook_init(
|
||||||
&idac_hook_cfg.platform,
|
&idac_hook_cfg.platform,
|
||||||
"SDGT",
|
"SDGT",
|
||||||
|
@ -66,6 +66,14 @@ static DWORD CALLBACK mai2_pre_startup(void)
|
|||||||
|
|
||||||
/* Initialize emulation hooks */
|
/* Initialize emulation hooks */
|
||||||
|
|
||||||
|
struct dipsw_config new_dipsw_config[8] = {
|
||||||
|
{L"Delivery Server", L"Server", L"Client"},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set the system dip switch configuration
|
||||||
|
memcpy(mai2_hook_cfg.platform.system.dipsw_config, new_dipsw_config,
|
||||||
|
sizeof(new_dipsw_config));
|
||||||
|
|
||||||
hr = platform_hook_init(
|
hr = platform_hook_init(
|
||||||
&mai2_hook_cfg.platform,
|
&mai2_hook_cfg.platform,
|
||||||
"SDEZ",
|
"SDEZ",
|
||||||
|
@ -64,6 +64,14 @@ static DWORD CALLBACK mercury_pre_startup(void)
|
|||||||
|
|
||||||
/* Initialize emulation hooks */
|
/* Initialize emulation hooks */
|
||||||
|
|
||||||
|
struct dipsw_config new_dipsw_config[8] = {
|
||||||
|
{L"Delivery Server", L"Server", L"Client"},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set the system dip switch configuration
|
||||||
|
memcpy(mercury_hook_cfg.platform.system.dipsw_config, new_dipsw_config,
|
||||||
|
sizeof(new_dipsw_config));
|
||||||
|
|
||||||
hr = platform_hook_init(
|
hr = platform_hook_init(
|
||||||
&mercury_hook_cfg.platform,
|
&mercury_hook_cfg.platform,
|
||||||
"SDFE",
|
"SDFE",
|
||||||
|
@ -89,7 +89,7 @@ dxguid_lib = cc.find_library('dxguid')
|
|||||||
xinput_lib = cc.find_library('xinput')
|
xinput_lib = cc.find_library('xinput')
|
||||||
pathcch_lib = cc.find_library('pathcch')
|
pathcch_lib = cc.find_library('pathcch')
|
||||||
imagehlp_lib = cc.find_library('imagehlp')
|
imagehlp_lib = cc.find_library('imagehlp')
|
||||||
Ws2_32_lib = cc.find_library('Ws2_32')
|
ws2_32_lib = cc.find_library('ws2_32')
|
||||||
|
|
||||||
inc = include_directories('.')
|
inc = include_directories('.')
|
||||||
capnhook = subproject('capnhook')
|
capnhook = subproject('capnhook')
|
||||||
|
@ -65,6 +65,14 @@ static DWORD CALLBACK mu3_pre_startup(void)
|
|||||||
|
|
||||||
/* Initialize emulation hooks */
|
/* Initialize emulation hooks */
|
||||||
|
|
||||||
|
struct dipsw_config new_dipsw_config[8] = {
|
||||||
|
{L"Delivery Server", L"Server", L"Client"},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set the system dip switch configuration
|
||||||
|
memcpy(mu3_hook_cfg.platform.system.dipsw_config, new_dipsw_config,
|
||||||
|
sizeof(new_dipsw_config));
|
||||||
|
|
||||||
hr = platform_hook_init(
|
hr = platform_hook_init(
|
||||||
&mu3_hook_cfg.platform,
|
&mu3_hook_cfg.platform,
|
||||||
"SDDT",
|
"SDDT",
|
||||||
|
@ -1,40 +1,37 @@
|
|||||||
#include <windows.h>
|
#include "platform/system.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <ntstatus.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include "platform/system.h"
|
|
||||||
#include "platform/vfs.h"
|
#include "platform/vfs.h"
|
||||||
|
#include "util/crc.h"
|
||||||
#include "util/dprintf.h"
|
#include "util/dprintf.h"
|
||||||
#include "util/str.h"
|
#include "util/str.h"
|
||||||
#include "util/crc.h"
|
|
||||||
|
|
||||||
#define DATA_SIZE 503
|
#define DATA_SIZE 503
|
||||||
#define BLOCK_SIZE (sizeof(uint32_t) + 4 + 1 + DATA_SIZE)
|
#define BLOCK_SIZE (sizeof(uint32_t) + 4 + 1 + DATA_SIZE)
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32_t checksum;
|
uint32_t checksum;
|
||||||
char padding[6];
|
char padding[6];
|
||||||
uint8_t freeplay;
|
uint8_t freeplay;
|
||||||
char data[DATA_SIZE - 2];
|
char data[DATA_SIZE - 2];
|
||||||
} CreditBlock;
|
} CreditBlock;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32_t checksum;
|
uint32_t checksum;
|
||||||
char padding[4];
|
char padding[4];
|
||||||
uint8_t dip_switches;
|
uint8_t dip_switches;
|
||||||
char data[DATA_SIZE];
|
char data[DATA_SIZE];
|
||||||
} DipSwBlock;
|
} DipSwBlock;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
CreditBlock credit_block;
|
CreditBlock credit_block;
|
||||||
DipSwBlock dip_switch_block;
|
DipSwBlock dip_switch_block;
|
||||||
char *data;
|
char *data;
|
||||||
@ -50,16 +47,15 @@ static struct vfs_config vfs_config;
|
|||||||
static void system_read_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);
|
static void system_save_sysfile(const wchar_t *sys_file);
|
||||||
|
|
||||||
HRESULT system_init(const struct system_config *cfg, const struct vfs_config *vfs_cfg)
|
HRESULT system_init(const struct system_config *cfg,
|
||||||
{
|
const struct vfs_config *vfs_cfg) {
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
wchar_t sys_file_path[MAX_PATH];
|
wchar_t sys_file_path[MAX_PATH];
|
||||||
|
|
||||||
assert(cfg != NULL);
|
assert(cfg != NULL);
|
||||||
assert(vfs_cfg != NULL);
|
assert(vfs_cfg != NULL);
|
||||||
|
|
||||||
if (!cfg->enable)
|
if (!cfg->enable) {
|
||||||
{
|
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,13 +74,13 @@ HRESULT system_init(const struct system_config *cfg, const struct vfs_config *vf
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void system_read_sysfile(const wchar_t *sys_file)
|
static void system_read_sysfile(const wchar_t *sys_file) {
|
||||||
{
|
|
||||||
FILE *f = _wfopen(sys_file, L"r");
|
FILE *f = _wfopen(sys_file, L"r");
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
{
|
dprintf(
|
||||||
dprintf("System: First run detected, system settings can only be applied AFTER the first run\n");
|
"System: First run detected, system settings can only be applied "
|
||||||
|
"AFTER the first run\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +88,7 @@ static void system_read_sysfile(const wchar_t *sys_file)
|
|||||||
long file_size = ftell(f);
|
long file_size = ftell(f);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
if (file_size != 0x6000)
|
if (file_size != 0x6000) {
|
||||||
{
|
|
||||||
dprintf("System: Invalid sysfile.dat file size\n");
|
dprintf("System: Invalid sysfile.dat file size\n");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
@ -106,11 +101,11 @@ static void system_read_sysfile(const wchar_t *sys_file)
|
|||||||
|
|
||||||
// copy the credit_block and dip_switch_block from the sysfile.dat
|
// copy the credit_block and dip_switch_block from the sysfile.dat
|
||||||
memcpy(&system_info.credit_block, system_info.data, BLOCK_SIZE);
|
memcpy(&system_info.credit_block, system_info.data, BLOCK_SIZE);
|
||||||
memcpy(&system_info.dip_switch_block, system_info.data + 0x2800, BLOCK_SIZE);
|
memcpy(&system_info.dip_switch_block, system_info.data + 0x2800,
|
||||||
|
BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void system_save_sysfile(const wchar_t *sys_file)
|
static void system_save_sysfile(const wchar_t *sys_file) {
|
||||||
{
|
|
||||||
char block[BLOCK_SIZE];
|
char block[BLOCK_SIZE];
|
||||||
uint8_t system = 0;
|
uint8_t system = 0;
|
||||||
uint8_t freeplay = 0;
|
uint8_t freeplay = 0;
|
||||||
@ -118,24 +113,28 @@ static void system_save_sysfile(const wchar_t *sys_file)
|
|||||||
// open the sysfile.dat for writing in bytes mode
|
// open the sysfile.dat for writing in bytes mode
|
||||||
FILE *f = _wfopen(sys_file, L"rb+");
|
FILE *f = _wfopen(sys_file, L"rb+");
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the system_config.system to the dip_switch_block
|
// write the system_config.system to the dip_switch_block
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++) {
|
||||||
{
|
// print the dip switch configuration with labels if present
|
||||||
if (system_config.dipsw[i])
|
if (system_config.dipsw_config[i].label[0] != L'\0') {
|
||||||
{
|
dprintf("System: %ls: %ls\n", system_config.dipsw_config[i].label,
|
||||||
// print which system is enabled
|
system_config.dipsw[i] ? system_config.dipsw_config[i].on
|
||||||
|
: system_config.dipsw_config[i].off);
|
||||||
|
} else if (system_config.dipsw[i]) {
|
||||||
dprintf("System: DipSw%d=1 set\n", i + 1);
|
dprintf("System: DipSw%d=1 set\n", i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the system variable to the dip switch configuration
|
||||||
|
if (system_config.dipsw[i]) {
|
||||||
system |= (1 << i);
|
system |= (1 << i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (system_config.freeplay)
|
if (system_config.freeplay) {
|
||||||
{
|
|
||||||
// print that freeplay is enabled
|
// print that freeplay is enabled
|
||||||
dprintf("System: Freeplay enabled\n");
|
dprintf("System: Freeplay enabled\n");
|
||||||
freeplay = 1;
|
freeplay = 1;
|
||||||
@ -149,10 +148,10 @@ static void system_save_sysfile(const wchar_t *sys_file)
|
|||||||
// calculate the new checksum, skip the old crc32 value
|
// calculate the new checksum, skip the old crc32 value
|
||||||
// which is at the beginning of the block, thats's why the +4
|
// which is at the beginning of the block, thats's why the +4
|
||||||
// conver the struct to chars in order for the crc32 calculation to work
|
// conver the struct to chars in order for the crc32 calculation to work
|
||||||
system_info.credit_block.checksum = crc32(
|
system_info.credit_block.checksum =
|
||||||
(char *)&system_info.credit_block + 4, BLOCK_SIZE - 4, 0);
|
crc32((char *)&system_info.credit_block + 4, BLOCK_SIZE - 4, 0);
|
||||||
system_info.dip_switch_block.checksum = crc32(
|
system_info.dip_switch_block.checksum =
|
||||||
(char *)&system_info.dip_switch_block + 4, BLOCK_SIZE - 4, 0);
|
crc32((char *)&system_info.dip_switch_block + 4, BLOCK_SIZE - 4, 0);
|
||||||
|
|
||||||
// build the new credit block
|
// build the new credit block
|
||||||
memcpy(block, (char *)&system_info.credit_block, BLOCK_SIZE);
|
memcpy(block, (char *)&system_info.credit_block, BLOCK_SIZE);
|
||||||
|
@ -7,10 +7,20 @@
|
|||||||
|
|
||||||
#include "platform/vfs.h"
|
#include "platform/vfs.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct dipsw_config
|
||||||
|
{
|
||||||
|
wchar_t label[MAX_PATH];
|
||||||
|
wchar_t on[MAX_PATH];
|
||||||
|
wchar_t off[MAX_PATH];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct system_config {
|
struct system_config {
|
||||||
bool enable;
|
bool enable;
|
||||||
bool freeplay;
|
bool freeplay;
|
||||||
bool dipsw[8];
|
bool dipsw[8];
|
||||||
|
struct dipsw_config dipsw_config[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT system_init(const struct system_config *cfg, const struct vfs_config *vfs_cfg);
|
HRESULT system_init(const struct system_config *cfg, const struct vfs_config *vfs_cfg);
|
||||||
|
@ -50,6 +50,16 @@ static DWORD CALLBACK tokyo_pre_startup(void)
|
|||||||
|
|
||||||
/* Initialize emulation hooks */
|
/* Initialize emulation hooks */
|
||||||
|
|
||||||
|
struct dipsw_config new_dipsw_config[8] = {
|
||||||
|
{L"Delivery Server", L"Server", L"Client"},
|
||||||
|
{L"Cabinet ID Setting", L"ON", L"OFF"},
|
||||||
|
{L"Cabinet ID Setting", L"ON", L"OFF"},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set the system dip switch configuration
|
||||||
|
memcpy(tokyo_hook_cfg.platform.system.dipsw_config, new_dipsw_config,
|
||||||
|
sizeof(new_dipsw_config));
|
||||||
|
|
||||||
hr = platform_hook_init(
|
hr = platform_hook_init(
|
||||||
&tokyo_hook_cfg.platform,
|
&tokyo_hook_cfg.platform,
|
||||||
"SDFV",
|
"SDFV",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user