1
0
mirror of https://gitea.tendokyu.moe/Dniel97/segatools.git synced 2024-11-27 14:30:49 +01:00

Tweak JVS coin count APIs

This makes things more consistent with the button/analog APIs.
This commit is contained in:
Tau 2019-08-03 17:41:39 -04:00
parent 40ba10e29a
commit 9ea6e09fdc
11 changed files with 53 additions and 25 deletions

View File

@ -459,10 +459,10 @@ static HRESULT io3_cmd_read_coin(
/* Write slot detail */
for (i = 0 ; i < req.nslots ; i++) {
ncoins = 0;
if (io3->ops->read_coin_counter != NULL) {
ncoins = io3->ops->read_coin_counter(io3->ops_ctx, i);
} else {
ncoins = 0;
io3->ops->read_coin_counter(io3->ops_ctx, i, &ncoins);
}
hr = iobuf_write_be16(resp_buf, ncoins);

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);
void (*read_analogs)(void *ctx, uint16_t *analogs, uint8_t nanalogs);
uint16_t (*read_coin_counter)(void *ctx, uint8_t slot_no);
void (*read_coin_counter)(void *ctx, uint8_t slot_no, uint16_t *out);
};
struct io3 {

View File

@ -21,7 +21,10 @@ struct chunithm_jvs_ir_mask {
};
static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out);
static uint16_t chunithm_jvs_read_coin_counter(void *ctx, uint8_t slot_no);
static void chunithm_jvs_read_coin_counter(
void *ctx,
uint8_t slot_no,
uint16_t *out);
static const struct io3_ops chunithm_jvs_io3_ops = {
.read_switches = chunithm_jvs_read_switches,
@ -81,11 +84,16 @@ static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out)
}
}
static uint16_t chunithm_jvs_read_coin_counter(void *ctx, uint8_t slot_no)
static void chunithm_jvs_read_coin_counter(
void *ctx,
uint8_t slot_no,
uint16_t *out)
{
assert(out != NULL);
if (slot_no > 0) {
return 0;
return;
}
return chuni_io_jvs_read_coin_counter();
chuni_io_jvs_read_coin_counter(out);
}

View File

@ -23,8 +23,12 @@ HRESULT chuni_io_init(void)
return S_OK;
}
uint16_t chuni_io_jvs_read_coin_counter(void)
void chuni_io_jvs_read_coin_counter(uint16_t *out)
{
if (out == NULL) {
return;
}
if (GetAsyncKeyState('3')) {
if (!chuni_io_coin) {
chuni_io_coin = true;
@ -34,7 +38,7 @@ uint16_t chuni_io_jvs_read_coin_counter(void)
chuni_io_coin = false;
}
return chuni_io_coins;
*out = chuni_io_coins;
}
void chuni_io_jvs_poll(uint8_t *opbtn, uint8_t *beams)

View File

@ -36,7 +36,7 @@ void chuni_io_jvs_poll(uint8_t *opbtn, uint8_t *beams);
for every coin detected by the coin acceptor mechanism. This count does not
need to persist beyond the lifetime of the process. */
uint16_t chuni_io_jvs_read_coin_counter(void);
void chuni_io_jvs_read_coin_counter(uint16_t *total);
/* Set the state of the coin blocker. Parameter is true if the blocker is
disengaged (i.e. coins can be inserted) and false if the blocker is engaged

View File

@ -15,7 +15,10 @@
#include "util/dprintf.h"
static void diva_jvs_read_switches(void *ctx, struct io3_switch_state *out);
static uint16_t diva_jvs_read_coin_counter(void *ctx, uint8_t slot_no);
static void diva_jvs_read_coin_counter(
void *ctx,
uint8_t slot_no,
uint16_t *out);
static const struct io3_ops diva_jvs_io3_ops = {
.read_switches = diva_jvs_read_switches,
@ -73,11 +76,14 @@ static void diva_jvs_read_switches(void *ctx, struct io3_switch_state *out)
}
}
static uint16_t diva_jvs_read_coin_counter(void *ctx, uint8_t slot_no)
static void diva_jvs_read_coin_counter(
void *ctx,
uint8_t slot_no,
uint16_t *out)
{
if (slot_no > 0) {
return 0;
return;
}
return diva_io_jvs_read_coin_counter();
diva_io_jvs_read_coin_counter(out);
}

View File

@ -47,8 +47,12 @@ void diva_io_jvs_poll(uint8_t *opbtn_out, uint8_t *gamebtn_out)
*gamebtn_out = gamebtn;
}
uint16_t diva_io_jvs_read_coin_counter(void)
void diva_io_jvs_read_coin_counter(uint16_t *out)
{
if (out == NULL) {
return;
}
if (GetAsyncKeyState('3')) {
if (!diva_io_coin) {
diva_io_coin = true;
@ -58,7 +62,7 @@ uint16_t diva_io_jvs_read_coin_counter(void)
diva_io_coin = false;
}
return diva_io_coins;
*out = diva_io_coins;
}
void diva_io_jvs_set_coin_blocker(bool open)

View File

@ -30,7 +30,7 @@ void diva_io_jvs_poll(uint8_t *opbtn, uint8_t *gamebtn);
for every coin detected by the coin acceptor mechanism. This count does not
need to persist beyond the lifetime of the process. */
uint16_t diva_io_jvs_read_coin_counter(void);
void diva_io_jvs_read_coin_counter(uint16_t *out);
/* Set the state of the coin blocker. Parameter is true if the blocker is
disengaged (i.e. coins can be inserted) and false if the blocker is engaged

View File

@ -20,7 +20,10 @@ static void idz_jvs_read_analogs(
uint16_t *analogs,
uint8_t nanalogs);
static void idz_jvs_read_switches(void *ctx, struct io3_switch_state *out);
static uint16_t idz_jvs_read_coin_counter(void *ctx, uint8_t slot_no);
static void idz_jvs_read_coin_counter(
void *ctx,
uint8_t slot_no,
uint16_t *out);
static const struct io3_ops idz_jvs_io3_ops = {
.read_switches = idz_jvs_read_switches,
@ -150,11 +153,14 @@ static void idz_jvs_read_analogs(
}
}
static uint16_t idz_jvs_read_coin_counter(void *ctx, uint8_t slot_no)
static void idz_jvs_read_coin_counter(
void *ctx,
uint8_t slot_no,
uint16_t *out)
{
if (slot_no > 0) {
return 0;
return;
}
return idz_io_jvs_read_coin_counter();
idz_io_jvs_read_coin_counter(out);
}

View File

@ -136,7 +136,7 @@ void idz_io_jvs_read_analogs(struct idz_io_analog_state *out)
out->brake = xi.Gamepad.bLeftTrigger << 8;
}
uint16_t idz_io_jvs_read_coin_counter(void)
void idz_io_jvs_read_coin_counter(uint16_t *out)
{
if (GetAsyncKeyState('3')) {
if (!idz_io_coin) {
@ -147,5 +147,5 @@ uint16_t idz_io_jvs_read_coin_counter(void)
idz_io_coin = false;
}
return idz_io_coins;
*out = idz_io_coins;
}

View File

@ -32,6 +32,6 @@ void idz_io_jvs_read_buttons(uint8_t *opbtn, uint8_t *gamebtn);
void idz_io_jvs_read_shifter(uint8_t *gear);
uint16_t idz_io_jvs_read_coin_counter(void);
void idz_io_jvs_read_coin_counter(uint16_t *total);
// TODO force feedback once that gets reverse engineered