forked from TeamTofuShop/segatools
chuniio 0x0101: Fix IR beam mapping
This commit is contained in:
@ -31,7 +31,8 @@ static const struct io3_ops chunithm_jvs_io3_ops = {
|
||||
.read_coin_counter = chunithm_jvs_read_coin_counter,
|
||||
};
|
||||
|
||||
static const struct chunithm_jvs_ir_mask chunithm_jvs_ir_masks[] = {
|
||||
// Incorrect IR beam mappings retained for backward compatibility
|
||||
static const struct chunithm_jvs_ir_mask chunithm_jvs_ir_masks_v1[] = {
|
||||
{ 0x0000, 0x0020 },
|
||||
{ 0x0020, 0x0000 },
|
||||
{ 0x0000, 0x0010 },
|
||||
@ -40,6 +41,15 @@ static const struct chunithm_jvs_ir_mask chunithm_jvs_ir_masks[] = {
|
||||
{ 0x0008, 0x0000 },
|
||||
};
|
||||
|
||||
static const struct chunithm_jvs_ir_mask chunithm_jvs_ir_masks[] = {
|
||||
{ 0x0020, 0x0000 },
|
||||
{ 0x0000, 0x0020 },
|
||||
{ 0x0010, 0x0000 },
|
||||
{ 0x0000, 0x0010 },
|
||||
{ 0x0008, 0x0000 },
|
||||
{ 0x0000, 0x0008 },
|
||||
};
|
||||
|
||||
static struct io3 chunithm_jvs_io3;
|
||||
|
||||
HRESULT chunithm_jvs_init(struct jvs_node **out)
|
||||
@ -66,6 +76,7 @@ HRESULT chunithm_jvs_init(struct jvs_node **out)
|
||||
|
||||
static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out)
|
||||
{
|
||||
const struct chunithm_jvs_ir_mask *masks;
|
||||
uint8_t opbtn;
|
||||
uint8_t beams;
|
||||
size_t i;
|
||||
@ -73,6 +84,14 @@ static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out)
|
||||
assert(out != NULL);
|
||||
assert(chuni_dll.jvs_poll != NULL);
|
||||
|
||||
if (chuni_dll.api_version >= 0x0101) {
|
||||
// Use correct mapping
|
||||
masks = chunithm_jvs_ir_masks;
|
||||
} else {
|
||||
// Use backwards-compatible incorrect mapping
|
||||
masks = chunithm_jvs_ir_masks_v1;
|
||||
}
|
||||
|
||||
opbtn = 0;
|
||||
beams = 0;
|
||||
|
||||
@ -95,8 +114,8 @@ static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out)
|
||||
for (i = 0 ; i < 6 ; i++) {
|
||||
/* Beam "press" is active-low hence the ~ */
|
||||
if (~beams & (1 << i)) {
|
||||
out->p1 |= chunithm_jvs_ir_masks[i].p1;
|
||||
out->p2 |= chunithm_jvs_ir_masks[i].p2;
|
||||
out->p1 |= masks[i].p1;
|
||||
out->p2 |= masks[i].p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user