summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ppu.c33
-rw-r--r--src/ppu_.c62
-rw-r--r--src/snes9x.h2
3 files changed, 31 insertions, 66 deletions
diff --git a/src/ppu.c b/src/ppu.c
index 27bedbb..31d1388 100644
--- a/src/ppu.c
+++ b/src/ppu.c
@@ -172,7 +172,7 @@ void S9xSetCPU(uint8 byte, uint16 Address)
}
break;
case 0x4017 :
- break;
+ return;
default :
#ifdef DEBUGGER
missing.unknowncpu_write = Address;
@@ -648,6 +648,9 @@ uint8 S9xGetCPU(uint16 Address)
if (Memory.FillRAM[0x4016] & 1)
return (0);
+ if (PPU.Joypad1ButtonReadPos >= 16) // Joypad 1 is enabled
+ return 1;
+
byte = IPPU.Joypads[0] >> (PPU.Joypad1ButtonReadPos ^ 15);
PPU.Joypad1ButtonReadPos++;
return (byte & 1);
@@ -663,8 +666,6 @@ uint8 S9xGetCPU(uint16 Address)
return (2);
case SNES_MOUSE :
- if (++PPU.MouseSpeed[0] > 2)
- PPU.MouseSpeed[0] = 0;
break;
}
return (0x00);
@@ -675,7 +676,7 @@ uint8 S9xGetCPU(uint16 Address)
if (Memory.FillRAM[0x4201] & 0x80)
{
byte =
- ((IPPU.Joypads[0]
+ ((IPPU.Joypads[1]
>> (PPU.Joypad2ButtonReadPos ^ 15))
& 1)
| (((IPPU.Joypads[2]
@@ -699,10 +700,11 @@ uint8 S9xGetCPU(uint16 Address)
return (byte);
}
}
- return (
- (IPPU.Joypads[1]
- >> (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
@@ -1158,9 +1160,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
@@ -1215,10 +1215,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];
}
}
@@ -1266,12 +1263,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;
}
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);
}
diff --git a/src/snes9x.h b/src/snes9x.h
index b051828..ac1dcfe 100644
--- a/src/snes9x.h
+++ b/src/snes9x.h
@@ -125,7 +125,6 @@ enum
{
SNES_MULTIPLAYER5,
SNES_JOYPAD,
- SNES_MOUSE_SWAPPED,
SNES_MOUSE,
SNES_SUPERSCOPE,
SNES_JUSTIFIER,
@@ -253,7 +252,6 @@ typedef struct
bool8 TraceDSP;
// Joystick options
- bool8 SwapJoypads;
bool8 JoystickEnabled;
// ROM timing options (see also H_Max above)