Skip to content

Commit

Permalink
naomi: limit max analog values to avoid overflow
Browse files Browse the repository at this point in the history
Fixes overflow in wild riders when going full right or full accel/brake.
Follow up to Issue #1627
  • Loading branch information
flyinghead committed Sep 2, 2024
1 parent 1223154 commit f039a80
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/hw/maple/maple_jvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,8 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou
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.
// Avoid overflow (wild riders)
axis_value = std::min<u16>(0xff7f, axis_value);
if (axis_value & 0x80)
axis_value += 0x100;
JVS_OUT(axis_value >> 8);
Expand Down

0 comments on commit f039a80

Please sign in to comment.