1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-11-28 00:10:51 +01:00

Actually implement the coin mech in BIO2 based games

Properly fixes #45
This commit is contained in:
Will Xyen 2020-11-10 18:06:51 -08:00
parent f39843b41f
commit e737d60893
4 changed files with 33 additions and 5 deletions

View File

@ -39,7 +39,7 @@ struct bi2a_iidx_state_out {
uint8_t UNK2; uint8_t UNK2;
struct bi2a_iidx_slider SLIDER4; struct bi2a_iidx_slider SLIDER4;
struct bi2a_iidx_slider SLIDER5; struct bi2a_iidx_slider SLIDER5;
uint8_t UNK3; // coin mech? uint8_t coins; // coin mech?
struct bi2a_iidx_panel PANEL; struct bi2a_iidx_panel PANEL;
uint8_t UNK4; uint8_t UNK4;
uint8_t UNK5; uint8_t UNK5;

View File

@ -36,7 +36,7 @@ struct bi2a_sdvx_state_in {
uint16_t raw[8]; uint16_t raw[8];
struct { struct {
struct bi2a_sdvx_analog analogs[4]; struct bi2a_sdvx_analog analogs[4];
uint8_t unk_1; // coin mech? uint8_t coins;
struct bi2a_sdvx_buttons1 buttons_1; struct bi2a_sdvx_buttons1 buttons_1;
struct bi2a_sdvx_buttons2 buttons_2; struct bi2a_sdvx_buttons2 buttons_2;
uint8_t unk_2[5]; uint8_t unk_2[5];

View File

@ -24,6 +24,8 @@ static void bio2_emu_bi2a_send_status(
static int default_sliders[5]; static int default_sliders[5];
static bool poll_delay; static bool poll_delay;
static bool coin_latch;
static uint8_t coin_count;
int get_default_slider_valid(size_t idx) int get_default_slider_valid(size_t idx)
{ {
@ -277,5 +279,16 @@ bio2_emu_bi2a_send_state(struct ac_io_emu *emu, const struct ac_io_message *req)
body->SYSTEM.v_service = (input_sys >> IIDX_IO_SYS_SERVICE) & 1; body->SYSTEM.v_service = (input_sys >> IIDX_IO_SYS_SERVICE) & 1;
body->SYSTEM.v_coin = (input_sys >> IIDX_IO_SYS_COIN) & 1; body->SYSTEM.v_coin = (input_sys >> IIDX_IO_SYS_COIN) & 1;
if (body->SYSTEM.v_coin) {
if (!coin_latch) {
coin_latch = true;
coin_count += 1;
}
} else {
coin_latch = false;
}
body->coins = coin_count;
ac_io_emu_response_push(emu, &resp, 0); ac_io_emu_response_push(emu, &resp, 0);
} }

View File

@ -27,6 +27,9 @@ static bool poll_delay;
static bool force_headphones_on; static bool force_headphones_on;
static bool coin_latch;
static uint8_t coin_count;
void bio2_emu_bi2a_init( void bio2_emu_bi2a_init(
struct bio2emu_port *bio2_emu, struct bio2emu_port *bio2_emu,
bool disable_poll_limiter, bool disable_poll_limiter,
@ -241,10 +244,22 @@ bio2_emu_bi2a_send_state(struct ac_io_emu *emu, const struct ac_io_message *req)
pin->analogs[0].a_val = sdvx_io_get_spinner_pos(0); pin->analogs[0].a_val = sdvx_io_get_spinner_pos(0);
pin->analogs[1].a_val = sdvx_io_get_spinner_pos(1); pin->analogs[1].a_val = sdvx_io_get_spinner_pos(1);
pin->analogs[0].a_coin = check_pin(sys, SDVX_IO_IN_GPIO_SYS_COIN);
pin->analogs[0].a_test = check_pin(sys, SDVX_IO_IN_GPIO_SYS_TEST); pin->analogs[0].a_test = check_pin(sys, SDVX_IO_IN_GPIO_SYS_TEST);
pin->analogs[0].a_service = check_pin(sys, SDVX_IO_IN_GPIO_SYS_SERVICE) || pin->analogs[0].a_service = check_pin(sys, SDVX_IO_IN_GPIO_SYS_SERVICE);
check_pin(sys, SDVX_IO_IN_GPIO_SYS_COIN); pin->analogs[0].a_coin = check_pin(sys, SDVX_IO_IN_GPIO_SYS_COIN);
if (pin->analogs[0].a_coin) {
if (!coin_latch) {
coin_latch = true;
coin_count += 1;
}
} else {
coin_latch = false;
}
// this is NOT byteswapped, only the analogs are
pin->coins = coin_count;
pin->raw[0] = ac_io_u16(pin->raw[0]); pin->raw[0] = ac_io_u16(pin->raw[0]);
pin->raw[1] = ac_io_u16(pin->raw[1]); pin->raw[1] = ac_io_u16(pin->raw[1]);