summaryrefslogtreecommitdiff
path: root/src/ppu_.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ppu_.c')
-rw-r--r--src/ppu_.c62
1 files changed, 19 insertions, 43 deletions
diff --git a/src/ppu_.c b/src/ppu_.c
index e68efec..b24bbb1 100644
--- a/src/ppu_.c
+++ b/src/ppu_.c
@@ -1400,7 +1400,7 @@ void S9xSetCPU(uint8 byte, uint16 Address)
}
break;
case 0x4017:
- break;
+ return;
default:
#ifdef DEBUGGER
missing.unknowncpu_write = Address;
@@ -1850,20 +1850,12 @@ uint8 S9xGetCPU(uint16 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);
- }
- int ind = Settings.SwapJoypads ? 1 : 0;
- byte = IPPU.Joypads[ind] >> (PPU.Joypad1ButtonReadPos ^ 15);
+ if (PPU.Joypad1ButtonReadPos >= 16) // Joypad 1 is enabled
+ return 1;
+
+ byte = IPPU.Joypads[0] >> (PPU.Joypad1ButtonReadPos ^ 15);
PPU.Joypad1ButtonReadPos++;
return (byte & 1);
}
@@ -1876,26 +1868,17 @@ uint8 S9xGetCPU(uint16 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;
-
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);
@@ -1908,7 +1891,11 @@ uint8 S9xGetCPU(uint16 Address)
return (byte);
}
}
- 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:
#ifdef DEBUGGER
@@ -2324,8 +2311,7 @@ void S9xProcessMouse(int which1)
int x, y;
uint32 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
@@ -2378,10 +2364,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];
}
}
@@ -2426,12 +2409,6 @@ void S9xNextController(void)
case SNES_JOYPAD:
if (Settings.MouseMaster)
{
- IPPU.Controller = SNES_MOUSE_SWAPPED;
- break;
- }
- case SNES_MOUSE_SWAPPED:
- if (Settings.MouseMaster)
- {
IPPU.Controller = SNES_MOUSE;
break;
}
@@ -2501,16 +2478,15 @@ void S9xUpdateJoypads(void)
PPU.Joypad2ButtonReadPos = 0;
PPU.Joypad3ButtonReadPos = 16;
}
- int ind = Settings.SwapJoypads ? 1 : 0;
- Memory.FillRAM [0x4218] = (uint8) IPPU.Joypads [ind];
- Memory.FillRAM [0x4219] = (uint8)(IPPU.Joypads [ind] >> 8);
- Memory.FillRAM [0x421a] = (uint8) IPPU.Joypads [ind ^ 1];
- Memory.FillRAM [0x421b] = (uint8)(IPPU.Joypads [ind ^ 1] >> 8);
+ Memory.FillRAM [0x4218] = (uint8) IPPU.Joypads [0];
+ Memory.FillRAM [0x4219] = (uint8)(IPPU.Joypads [0] >> 8);
+ Memory.FillRAM [0x421a] = (uint8) IPPU.Joypads [1];
+ Memory.FillRAM [0x421b] = (uint8)(IPPU.Joypads [1] >> 8);
if (Memory.FillRAM [0x4201] & 0x80)
{
- Memory.FillRAM [0x421c] = (uint8) IPPU.Joypads [ind];
- Memory.FillRAM [0x421d] = (uint8)(IPPU.Joypads [ind] >> 8);
+ Memory.FillRAM [0x421c] = (uint8) IPPU.Joypads [0];
+ Memory.FillRAM [0x421d] = (uint8)(IPPU.Joypads [0] >> 8);
Memory.FillRAM [0x421e] = (uint8) IPPU.Joypads [2];
Memory.FillRAM [0x421f] = (uint8)(IPPU.Joypads [2] >> 8);
}