aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJoão Silva2017-01-15 01:08:40 +0000
committerJoão Silva2017-01-15 01:08:40 +0000
commitbc7474392a91fa9838e6ecb5b16ccebdd97ab9ec (patch)
tree3447568188fd4e707386acb3a2034958f9ba1fed /source
parenta06ce12a2acdc993742df298f6d40811da70a432 (diff)
downloadsnes9x2005-bc7474392a91fa9838e6ecb5b16ccebdd97ab9ec.tar.gz
snes9x2005-bc7474392a91fa9838e6ecb5b16ccebdd97ab9ec.tar.bz2
snes9x2005-bc7474392a91fa9838e6ecb5b16ccebdd97ab9ec.zip
Fixed input for games like SMAS and removed joypad swapping option.
Diffstat (limited to 'source')
-rw-r--r--source/cpu.c5
-rw-r--r--source/ppu.c67
-rw-r--r--source/snes9x.h2
3 files changed, 24 insertions, 50 deletions
diff --git a/source/cpu.c b/source/cpu.c
index ba1b45f..62587de 100644
--- a/source/cpu.c
+++ b/source/cpu.c
@@ -104,14 +104,13 @@ static void CommonS9xReset(void)
void S9xReset(void)
{
- S9xResetPPU();
CommonS9xReset();
+ S9xResetPPU();
memset(Memory.RAM, 0x55, 0x20000);
}
void S9xSoftReset(void)
{
- S9xSoftResetPPU();
CommonS9xReset();
+ S9xSoftResetPPU();
}
-
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];
}
}
@@ -2405,12 +2389,6 @@ void S9xNextController()
case SNES_JOYPAD:
if (Settings.MouseMaster)
{
- IPPU.Controller = SNES_MOUSE_SWAPPED;
- break;
- }
- case SNES_MOUSE_SWAPPED:
- if (Settings.MouseMaster)
- {
IPPU.Controller = SNES_MOUSE;
break;
}
@@ -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);
}
diff --git a/source/snes9x.h b/source/snes9x.h
index 9e94c91..4da02bc 100644
--- a/source/snes9x.h
+++ b/source/snes9x.h
@@ -81,7 +81,6 @@ enum
{
SNES_MULTIPLAYER5,
SNES_JOYPAD,
- SNES_MOUSE_SWAPPED,
SNES_MOUSE,
SNES_SUPERSCOPE,
SNES_JUSTIFIER,
@@ -160,7 +159,6 @@ typedef struct
bool TraceDSP;
/* Joystick options */
- bool SwapJoypads;
bool JoystickEnabled;
/* ROM timing options (see also H_Max above) */