1
0
Fork 0

added freeplay setting to ALLS games

This commit is contained in:
Dniel97 2023-12-03 22:22:17 +01:00
parent 3dd6054a1e
commit 4ffcf25555
Signed by untrusted user: Dniel97
GPG Key ID: 6180B3C768FB2E08
12 changed files with 116 additions and 40 deletions

View File

@ -110,7 +110,6 @@ $(BUILD_DIR_ZIP)/swdc.zip:
$(V)mkdir -p $(BUILD_DIR_ZIP)/swdc/DEVICE
$(V)cp $(BUILD_DIR_64)/subprojects/capnhook/inject/inject.exe \
$(BUILD_DIR_64)/swdchook/swdchook.dll \
$(DIST_DIR)/swdc/config_hook.json \
$(DIST_DIR)/swdc/segatools.ini \
$(DIST_DIR)/swdc/start.bat \
$(BUILD_DIR_ZIP)/swdc

View File

@ -41,6 +41,11 @@ subnet=192.168.100.0
; ALLS DIP switches.
enable=1
; Enable freeplay mode. This will disable the coin slot and set the game to
; freeplay. Keep in mind that some game modes (e.g. Freedom/Time Modes) will not
; allow you to start a game in freeplay mode.
freeplay=0
; LAN Install: If multiple machines are present on the same LAN then set
; this to 1 on exactly one machine and set this to 0 on all others.
dipsw1=1

View File

@ -42,6 +42,11 @@ region=4
; ALLS DIP switches.
enable=1
; Enable freeplay mode. This will disable the coin slot and set the game to
; freeplay. Keep in mind that some game modes (e.g. Freedom/Time Modes) will not
; allow you to start a game in freeplay mode.
freeplay=0
; If multiple machines are present on the same LAN then set this to 1 on
; exactly one machine and set this to 0 on all others.
dipsw1=1

View File

@ -34,6 +34,11 @@ subnet=192.168.100.0
; ALLS DIP switches.
enable=1
; Enable freeplay mode. This will disable the coin slot and set the game to
; freeplay. Keep in mind that some game modes (e.g. Freedom/Time Modes) will not
; allow you to start a game in freeplay mode.
freeplay=0
; LAN Install: If multiple machines are present on the same LAN then set
; this to 1 on exactly one machine and set this to 0 on all others.
dipsw1=1

View File

@ -12,14 +12,6 @@ option=option
; Note that 127.0.0.1, localhost etc are specifically rejected.
default=127.0.0.1
[ds]
; Region code on the emulated AMEX board DS EEPROM.
; 1: Japan
; 4: Export (some UI elements in English)
;
; NOTE: Changing this setting causes a factory reset.
region=1
[netenv]
; Simulate an ideal LAN environment. This may interfere with head-to-head play.
; SEGA games are somewhat picky about their LAN environment, so leaving this
@ -35,12 +27,42 @@ subnet=192.168.174.0
[gfx]
enable=1
[gpio]
; ALLS DIP switches.
enable=1
; Enable freeplay mode. This will disable the coin slot and set the game to
; freeplay. Keep in mind that some game modes (e.g. Freedom/Time Modes) will not
; allow you to start a game in freeplay mode.
freeplay=0
; LAN Install: If multiple machines are present on the same LAN then set
; this to 1 on exactly one machine and set this to 0 on all others.
dipsw1=1
; -----------------------------------------------------------------------------
; Input settings
; -----------------------------------------------------------------------------
; Keyboard bindings are specified as hexadecimal (prefixed with 0x) or decimal
; (not prefixed with 0x) virtual-key codes, a list of which can be found here:
;
; https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
;
; This is, admittedly, not the most user-friendly configuration method in the
; world. An improved solution will be provided later.
[io4]
; Input API selection for JVS input emulator.
test=0x2D
service=0x2E
coin=0x24
; Test button virtual-key code. Default is the 1 key.
test=0x31
; Service button virtual-key code. Default is the 2 key.
service=0x32
; Keyboard button to increment coin counter. Default is the 3 key.
coin=0x33
; Volume up virtual-key code. Default is the "UP" key.
volup=0x26
; Volume down virtual-key code. Default is the "DOWN" key.
voldown=0x28
; Hooks related to the touch boards

View File

@ -34,6 +34,11 @@ subnet=192.168.162.0
; ALLS DIP switches.
enable=1
; Enable freeplay mode. This will disable the coin slot and set the game to
; freeplay. Keep in mind that some game modes (e.g. Freedom/Time Modes) will not
; allow you to start a game in freeplay mode.
freeplay=0
; LAN Install: If multiple machines are present on the same LAN then set
; this to 1 on exactly one machine and set this to 0 on all others.
dipsw1=1
@ -41,6 +46,10 @@ dipsw1=1
[gfx]
enable=1
[led15093]
; 837-15093-06 LED board emulation setting.
enable=1
; -----------------------------------------------------------------------------
; Input settings
; -----------------------------------------------------------------------------

View File

@ -1,10 +0,0 @@
{
"aime" :
{
"firmware_path" :
[
".\\aime_firm\\TN32MSEC003S_V12.hex",
".\\aime_firm\\update_15396_6728_94.bin"
]
}
}

View File

@ -40,6 +40,15 @@ path=
; Leave empty if you want to use Segatools built-in gamepad/wheel input.
path=
[gpio]
; ALLS DIP switches.
enable=1
; Enable freeplay mode. This will disable the coin slot and set the game to
; freeplay. Keep in mind that some game modes (e.g. Freedom/Time Modes) will not
; allow you to start a game in freeplay mode.
freeplay=0
; -----------------------------------------------------------------------------
; Input settings
; -----------------------------------------------------------------------------

2
dist/swdc/start.bat vendored
View File

@ -5,7 +5,7 @@ pushd %~dp0
rem Matching Server
start /min ..\..\..\Tools\tdrserver.exe
REM start /min inject -d -k swdchook.dll amdaemon.exe -c config.json config_LanClient.json config_MiniCabinet.json config_hook.json
start /min inject -d -k swdchook.dll amdaemon.exe -c config.json config_LanServer.json config_MiniCabinet.json config_hook.json
start /min inject -d -k swdchook.dll amdaemon.exe -c config.json config_LanServer.json config_MiniCabinet.json
REM Valid -launch parameters are "PC", "Cabinet" and "MiniCabinet
inject -d -k swdchook.dll ..\Todoroki\Binaries\Win64\Todoroki-Win64-Shipping.exe -launch=MiniCabinet -ABSLOG="..\..\..\..\..\Userdata\Todoroki.log" -UserDir="..\..\..\Userdata" -NotInstalled -UNATTENDED

View File

@ -330,6 +330,7 @@ void dipsw_config_load(struct dipsw_config *cfg, const wchar_t *filename)
assert(filename != NULL);
cfg->enable = GetPrivateProfileIntW(L"gpio", L"enable", 0, filename);
cfg->freeplay = GetPrivateProfileIntW(L"gpio", L"freeplay", 0, filename);
wcscpy_s(name, _countof(name), L"dipsw0");

View File

@ -19,20 +19,29 @@
typedef struct
{
uint32_t checksum;
char padding_1[4];
char padding[6];
uint8_t freeplay;
char data[DATA_SIZE - 2];
} CreditBlock;
typedef struct
{
uint32_t checksum;
char padding[4];
uint8_t dip_switches;
char data[DATA_SIZE];
} DipSwitchBlock;
typedef struct
{
CreditBlock credit_block;
DipSwitchBlock dip_switch_block;
char *data;
} DipSwitches;
} SystemInfo;
#pragma pack(pop)
static DipSwitches dip_switches;
static SystemInfo system_info;
static struct dipsw_config dipsw_config;
static struct vfs_config vfs_config;
@ -90,16 +99,21 @@ static void dipsw_read_sysfile(const wchar_t *sys_file)
return;
}
dip_switches.data = malloc(file_size);
fread(dip_switches.data, 1, file_size, f);
system_info.data = malloc(file_size);
fread(system_info.data, 1, file_size, f);
fclose(f);
memcpy(&dip_switches.dip_switch_block, dip_switches.data + 0x2800, BLOCK_SIZE);
// 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);
}
static void dipsw_save_sysfile(const wchar_t *sys_file)
{
char block[BLOCK_SIZE];
uint8_t dipsw = 0;
uint8_t freeplay = 0;
// open the sysfile.dat for writing in bytes mode
FILE *f = _wfopen(sys_file, L"rb+");
@ -119,33 +133,49 @@ static void dipsw_save_sysfile(const wchar_t *sys_file)
}
}
dip_switches.dip_switch_block.dip_switches = dipsw;
if (dipsw_config.freeplay)
{
// print that freeplay is enabled
dprintf("DipSw: 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;
// 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
dip_switches.dip_switch_block.checksum = crc32(
(char *)&dip_switches.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);
memcpy(system_info.data, block, BLOCK_SIZE);
memcpy(system_info.data + 0x3000, block, BLOCK_SIZE);
// build the new dip switch block
char block[BLOCK_SIZE];
memcpy(block, (char *)&dip_switches.dip_switch_block, BLOCK_SIZE);
memcpy(block, (char *)&system_info.dip_switch_block, BLOCK_SIZE);
// replace the old block with the new one
memcpy(dip_switches.data + 0x2800, block, BLOCK_SIZE);
memcpy(dip_switches.data + 0x5800, block, BLOCK_SIZE);
memcpy(system_info.data + 0x2800, block, BLOCK_SIZE);
memcpy(system_info.data + 0x5800, block, BLOCK_SIZE);
// print the dip_switch_block in hex
/*
dprintf("DipSw Block: ");
for (size_t i = 0; i < BLOCK_SIZE; i++)
{
dprintf("%02X ", ((uint8_t *)&dip_switches.dip_switch_block)[i]);
dprintf("%02X ", ((uint8_t *)&system_info.dip_switch_block)[i]);
}
dprintf("\n");
*/
fwrite(dip_switches.data, 1, 0x6000, f);
fwrite(system_info.data, 1, 0x6000, f);
fclose(f);
}

View File

@ -9,6 +9,7 @@
struct dipsw_config {
bool enable;
bool freeplay;
bool dipsw[8];
};