X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fjoystick.cpp;h=4b2549384fc9d9fa311edf254399782381f5fbf4;hb=48dd9ba5b6742935eef61cec80964afe093139ad;hp=619a751df7490dec02c0a156e71201a1de1be441;hpb=240a6df48aebb5e17f82452c32e770cdfe9b5d5e;p=virtualjaguar diff --git a/src/joystick.cpp b/src/joystick.cpp index 619a751..4b25493 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -131,11 +131,12 @@ uint16_t JoystickReadWord(uint32_t offset) // Joystick data returns active low for buttons pressed, high for non- // pressed. - uint8_t offset0 = joypad0Offset[joystick_ram[1] & 0x0F] / 4; - uint8_t offset1 = joypad1Offset[(joystick_ram[1] >> 4) & 0x0F] / 4; + uint8_t offset0 = joypad0Offset[joystick_ram[1] & 0x0F]; + uint8_t offset1 = joypad1Offset[(joystick_ram[1] >> 4) & 0x0F]; if (offset0 != 0xFF) { + offset0 /= 4; // Make index 0, 1, 2, 3 instead of 0, 4, 8, 12 uint8_t mask[4][2] = { { BUTTON_A, BUTTON_PAUSE }, { BUTTON_B, -1 }, { BUTTON_C, -1 }, { BUTTON_OPTION, -1 } }; data &= (joypad0Buttons[mask[offset0][0]] ? 0xFFFD : 0xFFFF); @@ -145,6 +146,7 @@ uint16_t JoystickReadWord(uint32_t offset) if (offset1 != 0xFF) { + offset1 /= 4; // Make index 0, 1, 2, 3 instead of 0, 4, 8, 12 uint8_t mask[4][2] = { { BUTTON_A, BUTTON_PAUSE }, { BUTTON_B, -1 }, { BUTTON_C, -1 }, { BUTTON_OPTION, -1 } }; data &= (joypad1Buttons[mask[offset1][0]] ? 0xFFF7 : 0xFFFF);