Unverified Commit 22124a90 authored by twinaphex's avatar twinaphex Committed by GitHub
Browse files

Merge pull request #161 from kps501/merge

backport ppu fix, libretro cleanup, remove rom headers
parents 3773f823 f82c9252
......@@ -131,6 +131,9 @@ static short const gauss [512] =
inline int SPC_DSP::interpolate( voice_t const* v )
{
// libretro: alternate methods
if(libretro_get_snes_interp()) return libretro_snes_interp((void*)v);
// Make pointers into gaussian based on fractional position between samples
int offset = v->interp_pos >> 4 & 0xFF;
short const* fwd = gauss + 255 - offset;
......@@ -416,8 +419,8 @@ inline VOICE_CLOCK( V3b )
m.t_brr_byte = m.ram [(v->brr_addr + v->brr_offset) & 0xFFFF];
m.t_brr_header = m.ram [v->brr_addr]; // brr_addr doesn't need masking
}
inline VOICE_CLOCK( V3c )
inline VOICE_CLOCK( V3c )
{
// Pitch modulation using previous voice's output
if ( m.t_pmon & v->vbit )
......@@ -511,8 +514,8 @@ inline void SPC_DSP::voice_output( voice_t const* v, int ch )
CLAMP16( m.t_echo_out [ch] );
}
}
inline VOICE_CLOCK( V4 )
inline VOICE_CLOCK( V4 )
{
// Decode BRR
m.t_looped = 0;
......
......@@ -482,8 +482,6 @@ static int32 ApplyMulti (s9xcommand_t *, int32, int16);
static void do_polling (int);
static void UpdatePolledMouse (int);
extern int macsrifle_adjust_x, macsrifle_adjust_y;
static string& operator += (string &s, int i)
{
......@@ -527,8 +525,8 @@ static void DoGunLatch (int x, int y)
static void DoMacsRifleLatch (int x, int y)
{
PPU.GunVLatch = (uint16) (y + 42) + (int16) macsrifle_adjust_y;
PPU.GunHLatch = (uint16) (x + 76) + (int16) macsrifle_adjust_x;
PPU.GunVLatch = (uint16) (y + 42);
PPU.GunHLatch = (uint16) (x + 76);
}
static int maptype (int t)
......@@ -688,8 +686,8 @@ void S9xSetController (int port, enum controllers controller, int8 id1, int8 id2
if (id1 < 0 || id1 > 7)
break;
newcontrollers[port] = JOYPAD0 + id1;
curcontrollers[port] = newcontrollers[port];
// libretro: hotplug immediately
curcontrollers[port] = newcontrollers[port] = JOYPAD0 + id1;
return;
case CTL_MOUSE:
......@@ -701,8 +699,8 @@ void S9xSetController (int port, enum controllers controller, int8 id1, int8 id2
break;
}
newcontrollers[port] = MOUSE0 + id1;
curcontrollers[port] = newcontrollers[port];
// libretro: hotplug immediately
curcontrollers[port] = newcontrollers[port] = MOUSE0 + id1;
return;
case CTL_SUPERSCOPE:
......@@ -712,8 +710,8 @@ void S9xSetController (int port, enum controllers controller, int8 id1, int8 id2
break;
}
newcontrollers[port] = SUPERSCOPE;
curcontrollers[port] = newcontrollers[port];
// libretro: hotplug immediately
curcontrollers[port] = newcontrollers[port] = SUPERSCOPE;
return;
case CTL_JUSTIFIER:
......@@ -725,8 +723,8 @@ void S9xSetController (int port, enum controllers controller, int8 id1, int8 id2
break;
}
newcontrollers[port] = ONE_JUSTIFIER + id1;
curcontrollers[port] = newcontrollers[port];
// libretro: hotplug immediately
curcontrollers[port] = newcontrollers[port] = ONE_JUSTIFIER + id1;
return;
case CTL_MACSRIFLE:
......@@ -736,8 +734,8 @@ void S9xSetController (int port, enum controllers controller, int8 id1, int8 id2
break;
}
newcontrollers[port] = MACSRIFLE;
curcontrollers[port] = newcontrollers[port];
// libretro: hotplug immediately
curcontrollers[port] = newcontrollers[port] = MACSRIFLE;
return;
case CTL_MP5:
......@@ -755,9 +753,8 @@ void S9xSetController (int port, enum controllers controller, int8 id1, int8 id2
break;
}
newcontrollers[port] = MP5;
curcontrollers[port] = newcontrollers[port];
// libretro: hotplug immediately
curcontrollers[port] = newcontrollers[port] = MP5;
mp5[port].pads[0] = (id1 < 0) ? NONE : JOYPAD0 + id1;
mp5[port].pads[1] = (id2 < 0) ? NONE : JOYPAD0 + id2;
mp5[port].pads[2] = (id3 < 0) ? NONE : JOYPAD0 + id3;
......@@ -769,8 +766,8 @@ void S9xSetController (int port, enum controllers controller, int8 id1, int8 id2
break;
}
newcontrollers[port] = NONE;
curcontrollers[port] = newcontrollers[port];
// libretro: hotplug immediately
curcontrollers[port] = newcontrollers[port] = NONE;
}
bool S9xVerifyControllers (void)
......@@ -2185,7 +2182,6 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
{
uint16 r, s, t, st;
s = t = st = 0;
r = cmd.button.joypad.buttons;
st = r & joypad[cmd.button.joypad.idx].togglestick & joypad[cmd.button.joypad.idx].toggleturbo;
r ^= st;
......@@ -2474,7 +2470,7 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
if (S9xUnfreezeGame(filename))
{
sprintf(buf, "%s.%.*s loaded", def, _MAX_EXT - 1, "oops");
snprintf(buf, 256, "%s.%.*s loaded", def, _MAX_EXT - 1, "oops");
S9xSetInfoString (buf);
}
else
......@@ -2511,7 +2507,7 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
if (S9xUnfreezeGame(filename))
{
sprintf(buf, "%s.%03d loaded", def, i - QuickLoad000);
snprintf(buf, 256, "%s.%03d loaded", def, i - QuickLoad000);
S9xSetInfoString(buf);
}
else
......@@ -2538,7 +2534,7 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
_splitpath(Memory.ROMFilename, drive, dir, def, ext);
snprintf(filename, PATH_MAX + 1, "%s%s%s.%03d", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, i - QuickSave000);
sprintf(buf, "%s.%03d saved", def, i - QuickSave000);
snprintf(buf, 256, "%s.%03d saved", def, i - QuickSave000);
S9xSetInfoString(buf);
S9xFreezeGame(filename);
......@@ -3702,7 +3698,6 @@ void S9xControlPostLoadState (struct SControlSnapshot *s)
COPY(superscope.next_buttons);
COPY(superscope.read_buttons);
for (int j = 0; j < 2; j++)
COPY(justifier.x[j]);
for (int j = 0; j < 2; j++)
......
......@@ -206,7 +206,6 @@
static void S9xResetCPU (void);
static void S9xSoftResetCPU (void);
extern bool randomize_memory;
static void S9xResetCPU (void)
......@@ -288,14 +287,7 @@ void S9xReset (void)
S9xResetSaveTimer(FALSE);
S9xResetLogger();
if(!randomize_memory)
memset(Memory.RAM, 0x55, 0x20000);
else
{
srand(time(NULL));
for(int lcv=0; lcv<0x20000; lcv++)
Memory.RAM[lcv] = rand()%256;
}
memset(Memory.RAM, 0x55, 0x20000);
memset(Memory.VRAM, 0x00, 0x10000);
memset(Memory.FillRAM, 0, 0x8000);
......
......@@ -315,7 +315,7 @@ uint8 S9xGetSuperFX (uint16 address)
uint8 byte;
byte = Memory.FillRAM[address];
if (address == 0x3031)
{
CPU.IRQExternal = FALSE;
......
This diff is collapsed.
......@@ -195,7 +195,11 @@
#include <assert.h>
#ifdef UNZIP_SUPPORT
#include "unzip/unzip.h"
# ifdef SYSTEM_ZIP
# include <minizip/unzip.h>
# else
# include "unzip/unzip.h"
# endif
#endif
#ifdef JMA_SUPPORT
......@@ -204,11 +208,6 @@
#include <ctype.h>
#include <sys/stat.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
#include "snes9x.h"
#include "memmap.h"
......@@ -220,8 +219,10 @@
#include "cheats.h"
#include "display.h"
#ifdef __LIBRETRO__
#include "libretro/libretro.h"
extern retro_log_printf_t log_cb;
#endif
int dma_kludge;
void S9xAppendMapping(struct retro_memory_descriptor *desc);
......@@ -1247,12 +1248,14 @@ static bool8 is_BSCart_BIOS(const uint8 *data, uint32 size)
{
Memory.LoROM = TRUE;
Memory.HiROM = FALSE;
return (TRUE);
}
else if ((data[0xFFB2] == 0x5A) && (data[0xFFB5] != 0x20) && (data[0xFFDA] == 0x33))
{
Memory.LoROM = FALSE;
Memory.HiROM = TRUE;
return (TRUE);
}
else
......@@ -1427,7 +1430,7 @@ uint32 CMemory::FileLoader (uint8 *buffer, const char *filename, uint32 maxsize)
_makepath(fname, drive, dir, name, exts);
int nFormat = FILE_DEFAULT;
if (strcasecmp(ext, "zip") == 0)
if (strcasecmp(ext, "zip") == 0 || strcasecmp(ext, "msu1") == 0)
nFormat = FILE_ZIP;
else
if (strcasecmp(ext, "jma") == 0)
......@@ -1540,16 +1543,6 @@ bool8 CMemory::LoadROMMem (const uint8 *source, uint32 sourceSize)
return FALSE;
strcpy(ROMFilename,"MemoryROM");
//allows headered roms to be loaded from ram instead of file
uint32 calc_size = (sourceSize / 0x2000) * 0x2000;
if ((sourceSize - calc_size == 512 && !Settings.ForceNoHeader) || Settings.ForceHeader)
{
source += 512;
sourceSize -= 512;
S9xMessage(S9X_INFO, S9X_HEADERS_INFO, "Found ROM file header (and ignored it).");
}
//end of header fix
do
{
......@@ -1804,7 +1797,7 @@ bool8 CMemory::LoadMultiCartMem (const uint8 *sourceA, uint32 sourceASize,
uint32 offset = 0;
memset(ROM, 0, MAX_ROM_SIZE);
memset(&Multi, 0, sizeof(Multi));
if(bios) {
if(!is_SufamiTurbo_BIOS(bios,biosSize))
return FALSE;
......@@ -1860,7 +1853,6 @@ bool8 CMemory::LoadMultiCart (const char *cartA, const char *cartB)
return LoadMultiCartInt();
}
extern int is_bsx (unsigned char *p);
bool8 CMemory::LoadMultiCartInt ()
{
bool8 r = TRUE;
......@@ -2666,7 +2658,7 @@ void CMemory::InitROM (void)
Checksum_Calculate();
bool8 isChecksumOK = (ROMChecksum + ROMComplementChecksum == 0xffff) &
(ROMChecksum == CalculatedChecksum);
(ROMChecksum == CalculatedChecksum);
//// Build more ROM information
......@@ -2678,7 +2670,7 @@ void CMemory::InitROM (void)
int offset = HiROM ? 0xffc0 : 0x7fc0;
// Backup
uint8 BSMagic0 = ROM[offset + 22],
BSMagic1 = ROM[offset + 23];
BSMagic1 = ROM[offset + 23];
// uCONSRT standard
ROM[offset + 22] = 0x42;
ROM[offset + 23] = 0x00;
......
......@@ -311,7 +311,11 @@ void S9xUpdateIRQPositions (bool initial)
PPU.HTimerPosition += PPU.IRQHBeamPos > 326 ? (ONE_DOT_CYCLE / 2) : 0;
PPU.VTimerPosition = PPU.IRQVBeamPos;
if (!PPU.HTimerEnabled && !PPU.VTimerEnabled)
if (PPU.VTimerEnabled && (PPU.VTimerPosition >= (Timings.V_Max + (IPPU.Interlace ? 1 : 0))))
{
Timings.NextIRQTimer = 0x0fffffff;
}
else if (!PPU.HTimerEnabled && !PPU.VTimerEnabled)
{
Timings.NextIRQTimer = 0x0fffffff;
}
......@@ -1861,7 +1865,7 @@ uint8 S9xGetCPU (uint16 Address)
CPU.IRQLine = FALSE;
CPU.IRQTransition = FALSE;
}
return (byte | (OpenBus & 0x7f));
case 0x4212: // HVBJOY
......
......@@ -254,7 +254,7 @@
#define SNES_MAX_PAL_VCOUNTER 312
#define SNES_HCOUNTER_MAX 341
#define ONE_CYCLE (overclock_cycles ? one_c : 6)
#define ONE_CYCLE (overclock_cycles ? one_c : 6)
#define SLOW_ONE_CYCLE (overclock_cycles ? slow_one_c : 8)
#define TWO_CYCLES (overclock_cycles ? two_c : 12)
#define ONE_DOT_CYCLE 4
......@@ -491,7 +491,7 @@ enum
void S9xSetPause(uint32);
void S9xClearPause(uint32);
void S9xExit(void);
void S9xMessage(int type, int, const char *s);
void S9xMessage(int, int, const char *);
extern struct SSettings Settings;
extern struct SCPUState CPU;
......@@ -499,4 +499,7 @@ extern struct STimings Timings;
extern struct SSNESGameFixes SNESGameFixes;
extern char String[513];
extern bool8 libretro_get_snes_interp();
extern int libretro_snes_interp(void *ptr);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment