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,10 +86,17 @@ static DWORD CALLBACK chusan_pre_startup(void) {
|
||||
|
||||
/* Initialize emulation hooks */
|
||||
|
||||
hr = platform_hook_init(
|
||||
&chusan_hook_cfg.platform,
|
||||
"SDHD",
|
||||
"ACA2",
|
||||
struct dipsw_config new_dipsw_config[8] = {
|
||||
{L"Delivery Server", L"Server", L"Client"},
|
||||
{L"Monitor Type", L"60FPS", L"120FPS"},
|
||||
{L"Cabinet Type", L"CVT", L"SP"},
|
||||
};
|
||||
|
||||
// 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)) {
|
||||
@ -114,27 +121,7 @@ static DWORD CALLBACK chusan_pre_startup(void) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bool *dipsw = &chusan_hook_cfg.platform.system.dipsw[0];
|
||||
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;
|
||||
bool is_cvt = chusan_hook_cfg.platform.system.dipsw[2];
|
||||
|
||||
if (!is_cvt) {
|
||||
hr = vfd_hook_init(&chusan_hook_cfg.vfd, 2);
|
||||
|
@ -63,6 +63,14 @@ static DWORD CALLBACK cm_pre_startup(void)
|
||||
|
||||
/* 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(
|
||||
&cm_hook_cfg.platform,
|
||||
"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.
|
||||
enable=1
|
||||
; COM port number for the LED board. Has to be the same as the FTDI port.
|
||||
portNo=17
|
||||
portNo1=17
|
||||
|
||||
; -----------------------------------------------------------------------------
|
||||
; Network settings
|
||||
|
@ -4,7 +4,7 @@ hooklib_lib = static_library(
|
||||
implicit_include_directories : false,
|
||||
dependencies : [
|
||||
capnhook.get_variable('hook_dep'),
|
||||
Ws2_32_lib
|
||||
ws2_32_lib
|
||||
],
|
||||
sources : [
|
||||
'cursor.c',
|
||||
|
@ -60,6 +60,18 @@ static DWORD CALLBACK idac_pre_startup(void)
|
||||
|
||||
/* 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(
|
||||
&idac_hook_cfg.platform,
|
||||
"SDGT",
|
||||
|
@ -66,6 +66,14 @@ static DWORD CALLBACK mai2_pre_startup(void)
|
||||
|
||||
/* 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(
|
||||
&mai2_hook_cfg.platform,
|
||||
"SDEZ",
|
||||
|
@ -64,6 +64,14 @@ static DWORD CALLBACK mercury_pre_startup(void)
|
||||
|
||||
/* 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(
|
||||
&mercury_hook_cfg.platform,
|
||||
"SDFE",
|
||||
|
@ -89,7 +89,7 @@ dxguid_lib = cc.find_library('dxguid')
|
||||
xinput_lib = cc.find_library('xinput')
|
||||
pathcch_lib = cc.find_library('pathcch')
|
||||
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('.')
|
||||
capnhook = subproject('capnhook')
|
||||
|
@ -65,6 +65,14 @@ static DWORD CALLBACK mu3_pre_startup(void)
|
||||
|
||||
/* 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(
|
||||
&mu3_hook_cfg.platform,
|
||||
"SDDT",
|
||||
|
@ -1,40 +1,37 @@
|
||||
#include <windows.h>
|
||||
#include "platform/system.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <ntstatus.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "platform/system.h"
|
||||
#include "platform/vfs.h"
|
||||
|
||||
#include "util/crc.h"
|
||||
#include "util/dprintf.h"
|
||||
#include "util/str.h"
|
||||
#include "util/crc.h"
|
||||
|
||||
#define DATA_SIZE 503
|
||||
#define BLOCK_SIZE (sizeof(uint32_t) + 4 + 1 + DATA_SIZE)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint32_t checksum;
|
||||
char padding[6];
|
||||
uint8_t freeplay;
|
||||
char data[DATA_SIZE - 2];
|
||||
} CreditBlock;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint32_t checksum;
|
||||
char padding[4];
|
||||
uint8_t dip_switches;
|
||||
char data[DATA_SIZE];
|
||||
} DipSwBlock;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
CreditBlock credit_block;
|
||||
DipSwBlock dip_switch_block;
|
||||
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_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;
|
||||
wchar_t sys_file_path[MAX_PATH];
|
||||
|
||||
assert(cfg != NULL);
|
||||
assert(vfs_cfg != NULL);
|
||||
|
||||
if (!cfg->enable)
|
||||
{
|
||||
if (!cfg->enable) {
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
@ -78,13 +74,13 @@ HRESULT system_init(const struct system_config *cfg, const struct vfs_config *vf
|
||||
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");
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
dprintf("System: First run detected, system settings can only be applied AFTER the first run\n");
|
||||
if (f == NULL) {
|
||||
dprintf(
|
||||
"System: First run detected, system settings can only be applied "
|
||||
"AFTER the first run\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -92,8 +88,7 @@ static void system_read_sysfile(const wchar_t *sys_file)
|
||||
long file_size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (file_size != 0x6000)
|
||||
{
|
||||
if (file_size != 0x6000) {
|
||||
dprintf("System: Invalid sysfile.dat file size\n");
|
||||
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
|
||||
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];
|
||||
uint8_t system = 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
|
||||
FILE *f = _wfopen(sys_file, L"rb+");
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
if (f == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// write the system_config.system to the dip_switch_block
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (system_config.dipsw[i])
|
||||
{
|
||||
// print which system is enabled
|
||||
for (int i = 0; i < 8; i++) {
|
||||
// print the dip switch configuration with labels if present
|
||||
if (system_config.dipsw_config[i].label[0] != L'\0') {
|
||||
dprintf("System: %ls: %ls\n", system_config.dipsw_config[i].label,
|
||||
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);
|
||||
}
|
||||
|
||||
// set the system variable to the dip switch configuration
|
||||
if (system_config.dipsw[i]) {
|
||||
system |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
if (system_config.freeplay)
|
||||
{
|
||||
if (system_config.freeplay) {
|
||||
// print that freeplay is enabled
|
||||
dprintf("System: Freeplay enabled\n");
|
||||
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
|
||||
// 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
|
||||
system_info.credit_block.checksum = crc32(
|
||||
(char *)&system_info.credit_block + 4, BLOCK_SIZE - 4, 0);
|
||||
system_info.dip_switch_block.checksum = crc32(
|
||||
(char *)&system_info.dip_switch_block + 4, BLOCK_SIZE - 4, 0);
|
||||
system_info.credit_block.checksum =
|
||||
crc32((char *)&system_info.credit_block + 4, BLOCK_SIZE - 4, 0);
|
||||
system_info.dip_switch_block.checksum =
|
||||
crc32((char *)&system_info.dip_switch_block + 4, BLOCK_SIZE - 4, 0);
|
||||
|
||||
// build the new credit block
|
||||
memcpy(block, (char *)&system_info.credit_block, BLOCK_SIZE);
|
||||
|
@ -7,10 +7,20 @@
|
||||
|
||||
#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 {
|
||||
bool enable;
|
||||
bool freeplay;
|
||||
bool dipsw[8];
|
||||
struct dipsw_config dipsw_config[8];
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
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(
|
||||
&tokyo_hook_cfg.platform,
|
||||
"SDFV",
|
||||
|
Loading…
x
Reference in New Issue
Block a user