board/io3.c: Fix JVS coin counter emulation

This commit is contained in:
Tau 2019-05-02 19:38:39 -04:00
parent 025102fc58
commit 0271abb21e
5 changed files with 31 additions and 37 deletions

View File

@ -454,8 +454,8 @@ static HRESULT io3_cmd_read_coin(
/* Write slot detail */
for (i = 0 ; i < req.nslots ; i++) {
if (io3->ops->consume_coins != NULL) {
ncoins = io3->ops->consume_coins(io3->ops_ctx, i);
if (io3->ops->read_coin_counter != NULL) {
ncoins = io3->ops->read_coin_counter(io3->ops_ctx, i);
} else {
ncoins = 0;
}

View File

@ -18,7 +18,7 @@ struct io3_ops {
void (*write_gpio)(void *ctx, uint32_t state);
void (*read_switches)(void *ctx, struct io3_switch_state *out);
uint16_t (*read_analog)(void *ctx, uint8_t analog_no);
uint16_t (*consume_coins)(void *ctx, uint8_t slot_no);
uint16_t (*read_coin_counter)(void *ctx, uint8_t slot_no);
};
struct io3 {

View File

@ -14,16 +14,17 @@
#include "util/dprintf.h"
static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out);
static uint16_t chunithm_jvs_consume_coins(void *ctx, uint8_t slot_no);
static uint16_t chunithm_jvs_read_coin_counter(void *ctx, uint8_t slot_no);
static const struct io3_ops chunithm_jvs_io3_ops = {
.read_switches = chunithm_jvs_read_switches,
.consume_coins = chunithm_jvs_consume_coins,
.read_switches = chunithm_jvs_read_switches,
.read_coin_counter = chunithm_jvs_read_coin_counter,
};
static struct io3 chunithm_jvs_io3;
static size_t chunithm_jvs_rise_pos;
static bool chunithm_jvs_coin;
static uint16_t chunithm_jvs_coins;
void chunithm_jvs_init(void)
{
@ -74,24 +75,21 @@ static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out)
}
}
static uint16_t chunithm_jvs_consume_coins(void *ctx, uint8_t slot_no)
static uint16_t chunithm_jvs_read_coin_counter(void *ctx, uint8_t slot_no)
{
if (slot_no > 0) {
return 0;
}
if (GetAsyncKeyState('3')) {
if (chunithm_jvs_coin) {
return 0;
} else {
if (!chunithm_jvs_coin) {
dprintf("Chunithm JVS: Coin drop\n");
chunithm_jvs_coin = true;
return 1;
chunithm_jvs_coins++;
}
} else {
chunithm_jvs_coin = false;
return 0;
}
return chunithm_jvs_coins;
}

View File

@ -13,15 +13,16 @@
#include "util/dprintf.h"
static void diva_jvs_read_switches(void *ctx, struct io3_switch_state *out);
static uint16_t diva_jvs_consume_coins(void *ctx, uint8_t slot_no);
static uint16_t diva_jvs_read_coin_counter(void *ctx, uint8_t slot_no);
static const struct io3_ops diva_jvs_io3_ops = {
.read_switches = diva_jvs_read_switches,
.consume_coins = diva_jvs_consume_coins,
.read_switches = diva_jvs_read_switches,
.read_coin_counter = diva_jvs_read_coin_counter,
};
static struct io3 diva_jvs_io3;
static bool diva_jvs_coin;
static uint16_t diva_jvs_coins;
void diva_jvs_init(void)
{
@ -70,24 +71,21 @@ static void diva_jvs_read_switches(void *ctx, struct io3_switch_state *out)
}
}
static uint16_t diva_jvs_consume_coins(void *ctx, uint8_t slot_no)
static uint16_t diva_jvs_read_coin_counter(void *ctx, uint8_t slot_no)
{
if (slot_no > 0) {
return 0;
}
if (GetAsyncKeyState('3')) {
if (diva_jvs_coin) {
return 0;
} else {
if (!diva_jvs_coin) {
dprintf("Diva JVS: Coin drop\n");
diva_jvs_coin = true;
return 1;
diva_jvs_coins++;
}
} else {
diva_jvs_coin = false;
return 0;
}
return diva_jvs_coins;
}

View File

@ -19,16 +19,17 @@
static void idz_jvs_read_switches(void *ctx, struct io3_switch_state *out);
static uint16_t idz_jvs_read_analog(void *ctx, uint8_t analog_no);
static uint16_t idz_jvs_consume_coins(void *ctx, uint8_t slot_no);
static uint16_t idz_jvs_read_coin_counter(void *ctx, uint8_t slot_no);
static const struct io3_ops idz_jvs_io3_ops = {
.read_switches = idz_jvs_read_switches,
.read_analog = idz_jvs_read_analog,
.consume_coins = idz_jvs_consume_coins,
.read_switches = idz_jvs_read_switches,
.read_analog = idz_jvs_read_analog,
.read_coin_counter = idz_jvs_read_coin_counter,
};
static struct io3 idz_jvs_io3;
static bool idz_jvs_coin;
static uint16_t idz_jvs_coins;
static bool idz_jvs_shifting;
static uint8_t idz_jvs_gear;
@ -178,24 +179,21 @@ static uint16_t idz_jvs_read_analog(void *ctx, uint8_t analog_no)
}
}
static uint16_t idz_jvs_consume_coins(void *ctx, uint8_t slot_no)
static uint16_t idz_jvs_read_coin_counter(void *ctx, uint8_t slot_no)
{
if (slot_no > 0) {
return 0;
}
if (GetAsyncKeyState('3')) {
if (idz_jvs_coin) {
return 0;
} else {
if (!idz_jvs_coin) {
dprintf("IDZero JVS: Coin drop\n");
idz_jvs_coin = true;
return 1;
idz_jvs_coins++;
}
} else {
idz_jvs_coin = false;
return 0;
}
return idz_jvs_coins;
}