aboutsummaryrefslogtreecommitdiff
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
parenta06ce12a2acdc993742df298f6d40811da70a432 (diff)
downloadsnesemu-bc7474392a91fa9838e6ecb5b16ccebdd97ab9ec.tar.gz
snesemu-bc7474392a91fa9838e6ecb5b16ccebdd97ab9ec.tar.bz2
snesemu-bc7474392a91fa9838e6ecb5b16ccebdd97ab9ec.zip
Fixed input for games like SMAS and removed joypad swapping option.
-rw-r--r--libretro.c11
-rw-r--r--source/cpu.c5
-rw-r--r--source/ppu.c67
-rw-r--r--source/snes9x.h2
4 files changed, 28 insertions, 57 deletions
diff --git a/libretro.c b/libretro.c
index 3512013..eb67db4 100644
--- a/libretro.c
+++ b/libretro.c
@@ -195,7 +195,10 @@ void _makepath(char* path, const char* drive, const char* dir,
}
else
*path = 0;
- strcat(path, fname);
+
+ if (fname)
+ strcat(path, fname);
+
if (ext && *ext)
{
strcat(path, ".");
@@ -322,7 +325,6 @@ void retro_init(void)
struct retro_log_callback log;
enum retro_pixel_format rgb565;
static const struct retro_variable vars[] = {
- { "catsfc_SwapJoypads", "Swap Joypads; disabled|enabled" },
{ "catsfc_VideoMode", "Video Mode; auto|NTSC|PAL" },
{ NULL, NULL },
};
@@ -410,11 +412,6 @@ static void check_variables(void)
{
struct retro_variable var;
- var.key = "catsfc_SwapJoypads";
- var.value = NULL;
- if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
- Settings.SwapJoypads = strcmp(var.value, "disabled");
-
var.key = "catsfc_VideoMode";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
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) */