From 1223154665f712fd698cda3957fa57d0a21d753f Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sun, 1 Sep 2024 18:38:58 +0200 Subject: [PATCH] jvs: fix analog axes values encoding The least significant byte of analog axis values seems to be handled as signed. Fixes crazy taxi going right when turning full left. Issue #1627 --- core/hw/maple/maple_jvs.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/hw/maple/maple_jvs.cpp b/core/hw/maple/maple_jvs.cpp index 133d0e56e..8730925d9 100644 --- a/core/hw/maple/maple_jvs.cpp +++ b/core/hw/maple/maple_jvs.cpp @@ -2267,7 +2267,7 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou } else { - axis_value = read_analog_axis(player_num, axisDesc.axis, axisDesc.inverted); + axis_value = read_analog_axis(player_num, axisDesc.axis, axisDesc.inverted); } } else @@ -2280,6 +2280,11 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou axis_value = read_analog_axis(player_num, player_axis, false); } LOGJVS("%d:%4x ", axis, axis_value); + // Strangely, the least significant byte appears to be handled as signed, + // so we compensate when it's negative. + // This might overflow but the value is still read correctly. + if (axis_value & 0x80) + axis_value += 0x100; JVS_OUT(axis_value >> 8); JVS_OUT(axis_value); }