From bc7474392a91fa9838e6ecb5b16ccebdd97ab9ec Mon Sep 17 00:00:00 2001 From: João Silva Date: Sun, 15 Jan 2017 01:08:40 +0000 Subject: Fixed input for games like SMAS and removed joypad swapping option. --- source/ppu.c | 67 ++++++++++++++++++++---------------------------------------- 1 file changed, 22 insertions(+), 45 deletions(-) (limited to 'source/ppu.c') diff --git a/source/ppu.c b/source/ppu.c index 2d38c94..bc94e6e 100644 --- a/source/ppu.c +++ b/source/ppu.c @@ -1299,7 +1299,7 @@ void S9xSetCPU(uint8_t byte, uint16_t Address) } break; case 0x4017: - break; + return; default: break; } @@ -1788,20 +1788,12 @@ uint8_t S9xGetCPU(uint16_t Address) case 0x4016: { if (Memory.FillRAM [0x4016] & 1) - { - if ((!Settings.SwapJoypads && - IPPU.Controller == SNES_MOUSE_SWAPPED) || - (Settings.SwapJoypads && - IPPU.Controller == SNES_MOUSE)) - { - if (++PPU.MouseSpeed [0] > 2) - PPU.MouseSpeed [0] = 0; - } - return (0); - } + return 0; + + if (PPU.Joypad1ButtonReadPos >= 16) // Joypad 1 is enabled + return 1; - int ind = Settings.SwapJoypads ? 1 : 0; - return (IPPU.Joypads[ind] >> (PPU.Joypad1ButtonReadPos++ ^ 15)) & 1; + return (IPPU.Joypads[0] >> (PPU.Joypad1ButtonReadPos++ ^ 15)) & 1; } case 0x4017: { @@ -1812,26 +1804,18 @@ uint8_t S9xGetCPU(uint16_t Address) { case SNES_MULTIPLAYER5: return (2); - case SNES_MOUSE_SWAPPED: - if (Settings.SwapJoypads && ++PPU.MouseSpeed [0] > 2) - PPU.MouseSpeed [0] = 0; - break; - case SNES_MOUSE: - if (!Settings.SwapJoypads && ++PPU.MouseSpeed [0] > 2) - PPU.MouseSpeed [0] = 0; break; } - return (0x00); - } - int ind = Settings.SwapJoypads ? 0 : 1; + return 0; + } if (IPPU.Controller == SNES_MULTIPLAYER5) { if (Memory.FillRAM [0x4201] & 0x80) { - byte = ((IPPU.Joypads[ind] >> (PPU.Joypad2ButtonReadPos ^ 15)) & 1) | + byte = ((IPPU.Joypads[1] >> (PPU.Joypad2ButtonReadPos ^ 15)) & 1) | (((IPPU.Joypads[2] >> (PPU.Joypad2ButtonReadPos ^ 15)) & 1) << 1); PPU.Joypad2ButtonReadPos++; return (byte); @@ -1852,7 +1836,11 @@ uint8_t S9xGetCPU(uint16_t Address) in_bit %= 32; return rv; } - return ((IPPU.Joypads[ind] >> (PPU.Joypad2ButtonReadPos++ ^ 15)) & 1); + + if (PPU.Joypad2ButtonReadPos >= 16) // Joypad 2 is enabled + return 1; + + return (IPPU.Joypads[1] >> (PPU.Joypad2ButtonReadPos++ ^ 15)) & 1; } default: return OpenBus; @@ -2299,8 +2287,7 @@ void S9xProcessMouse(int which1) int x, y; uint32_t buttons; - if ((IPPU.Controller == SNES_MOUSE || IPPU.Controller == SNES_MOUSE_SWAPPED) - && S9xReadMousePosition(which1, &x, &y, &buttons)) + if (IPPU.Controller == SNES_MOUSE && S9xReadMousePosition(which1, &x, &y, &buttons)) { int delta_x, delta_y; #define MOUSE_SIGNATURE 0x1 @@ -2353,10 +2340,7 @@ void S9xProcessMouse(int which1) else IPPU.Mouse [which1] |= delta_y << 24; - if (IPPU.Controller == SNES_MOUSE_SWAPPED) - IPPU.Joypads [0] = IPPU.Mouse [which1]; - else - IPPU.Joypads [1] = IPPU.Mouse [which1]; + IPPU.Joypads [1] = IPPU.Mouse [which1]; } } @@ -2403,12 +2387,6 @@ void S9xNextController() IPPU.Controller = SNES_JOYPAD; break; case SNES_JOYPAD: - if (Settings.MouseMaster) - { - IPPU.Controller = SNES_MOUSE_SWAPPED; - break; - } - case SNES_MOUSE_SWAPPED: if (Settings.MouseMaster) { IPPU.Controller = SNES_MOUSE; @@ -2595,16 +2573,15 @@ void S9xUpdateJoypads() PPU.Joypad2ButtonReadPos = 0; PPU.Joypad3ButtonReadPos = 16; } - int ind = Settings.SwapJoypads ? 1 : 0; - Memory.FillRAM [0x4218] = (uint8_t) IPPU.Joypads [ind]; - Memory.FillRAM [0x4219] = (uint8_t)(IPPU.Joypads [ind] >> 8); - Memory.FillRAM [0x421a] = (uint8_t) IPPU.Joypads [ind ^ 1]; - Memory.FillRAM [0x421b] = (uint8_t)(IPPU.Joypads [ind ^ 1] >> 8); + Memory.FillRAM [0x4218] = (uint8_t) IPPU.Joypads [0]; + Memory.FillRAM [0x4219] = (uint8_t)(IPPU.Joypads [0] >> 8); + Memory.FillRAM [0x421a] = (uint8_t) IPPU.Joypads [1]; + Memory.FillRAM [0x421b] = (uint8_t)(IPPU.Joypads [1] >> 8); if (Memory.FillRAM [0x4201] & 0x80) { - Memory.FillRAM [0x421c] = (uint8_t) IPPU.Joypads [ind]; - Memory.FillRAM [0x421d] = (uint8_t)(IPPU.Joypads [ind] >> 8); + Memory.FillRAM [0x421c] = (uint8_t) IPPU.Joypads [0]; + Memory.FillRAM [0x421d] = (uint8_t)(IPPU.Joypads [0] >> 8); Memory.FillRAM [0x421e] = (uint8_t) IPPU.Joypads [2]; Memory.FillRAM [0x421f] = (uint8_t)(IPPU.Joypads [2] >> 8); } -- cgit v1.2.3