aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/apu_blargg.c73
-rw-r--r--source/cpuexec.h4
-rw-r--r--source/getset.c (renamed from source/getset.h)20
-rw-r--r--source/gfx.c10
-rw-r--r--source/memmap.c13
-rw-r--r--source/port.h6
-rw-r--r--source/ppu.h2
-rw-r--r--source/snes9x.h10
8 files changed, 84 insertions, 54 deletions
diff --git a/source/apu_blargg.c b/source/apu_blargg.c
index d87d8d3..2976580 100644
--- a/source/apu_blargg.c
+++ b/source/apu_blargg.c
@@ -761,7 +761,8 @@ V(V9_V6_V3,2) -> V(V9,2) V(V6,3) V(V3,4) */
static void dsp_run( int32_t clocks_remain )
{
int32_t phase;
-
+ if (Settings.HardDisableAudio)
+ return;
phase = dsp_m.phase;
dsp_m.phase = (phase + clocks_remain) & 31;
@@ -2891,7 +2892,6 @@ static int32_t r_left[4], r_right[4];
#define SPACE_EMPTY() (rb_buffer_size - rb_size)
#define SPACE_FILLED() (rb_size)
#define MAX_WRITE() (SPACE_EMPTY() >> 1)
-#define AVAIL() (((((uint32_t) rb_size) << 14) - r_frac) / r_step * 2)
#define RESAMPLER_MIN(a, b) ((a) < (b) ? (a) : (b))
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
@@ -2934,6 +2934,34 @@ static void resampler_time_ratio(double ratio)
static void resampler_read(int16_t *data, int32_t num_samples)
{
+ if (r_step == 65536)
+ {
+ //direct copy if we are not resampling
+ int bytesUntilBufferEnd = rb_buffer_size - rb_start;
+ while (num_samples > 0)
+ {
+ int bytesToConsume = num_samples * sizeof(int16_t);
+ if (bytesToConsume >= bytesUntilBufferEnd)
+ {
+ bytesToConsume = bytesUntilBufferEnd;
+ }
+ if (rb_start >= rb_buffer_size)
+ {
+ rb_start = 0;
+ }
+ memcpy(data, &rb_buffer[rb_start], bytesToConsume);
+ data += bytesToConsume / sizeof(int16_t);
+ rb_start += bytesToConsume;
+ rb_size -= bytesToConsume;
+ num_samples -= bytesToConsume / sizeof(int16_t);
+ if (rb_start >= rb_buffer_size)
+ {
+ rb_start = 0;
+ }
+ }
+ return;
+ }
+
int32_t i_position, o_position, consumed;
int16_t *internal_buffer;
@@ -2944,16 +2972,13 @@ static void resampler_read(int16_t *data, int32_t num_samples)
while (o_position < num_samples && consumed < rb_buffer_size)
{
- int32_t s_left, s_right, max_samples;
- int32_t hermite_val;
-
- s_left = internal_buffer[i_position];
- s_right = internal_buffer[i_position + 1];
- max_samples = rb_buffer_size >> 1;
+ int32_t s_left = internal_buffer[i_position];
+ int32_t s_right = internal_buffer[i_position + 1];
+ int32_t max_samples = rb_buffer_size >> 1;
while (r_frac <= 65536 && o_position < num_samples)
{
- hermite_val = hermite(r_frac >> 1, r_left [0], r_left [1], r_left [2], r_left [3]);
+ int32_t hermite_val = hermite(r_frac >> 1, r_left [0], r_left [1], r_left [2], r_left [3]);
data[o_position] = SHORT_CLAMP (hermite_val);
hermite_val = hermite(r_frac >> 1, r_right[0], r_right[1], r_right[2], r_right[3]);
data[o_position + 1] = SHORT_CLAMP (hermite_val);
@@ -3005,10 +3030,9 @@ static void resampler_new(int32_t num_samples)
static INLINE bool resampler_push(int16_t *src, int32_t num_samples)
{
- int32_t bytes, end, first_write_size;
- uint8_t *src_ring;
-
- bytes = num_samples << 1;
+ int32_t end, first_write_size;
+ uint8_t *src_ring;
+ int32_t bytes = num_samples << 1;
if (MAX_WRITE() < num_samples || SPACE_EMPTY() < bytes)
return false;
@@ -3045,7 +3069,7 @@ static INLINE void resampler_resize (int32_t num_samples)
bool S9xMixSamples (int16_t *buffer, uint32_t sample_count)
{
- if (AVAIL() >= (sample_count + lag))
+ if (S9xGetSampleCount() >= (sample_count + lag))
{
resampler_read(buffer, sample_count);
if (lag == lag_master)
@@ -3065,16 +3089,18 @@ bool S9xMixSamples (int16_t *buffer, uint32_t sample_count)
int32_t S9xGetSampleCount()
{
- return AVAIL();
+ if (r_step == 65536)
+ return rb_size / sizeof(int16_t);
+ return (((((uint32_t)rb_size) << 14) - r_frac) / r_step * 2);
}
/* Sets destination for output samples */
static void spc_set_output( int16_t* out, int32_t size )
{
- int16_t *out_end, *in;
+ int16_t *in;
+ int16_t *out_end = out + size;
- out_end = out + size;
m.buf_begin = out;
m.buf_end = out_end;
@@ -3098,11 +3124,9 @@ static void spc_set_output( int16_t* out, int32_t size )
dsp_set_output( out, out_end - out );
}
-void S9xFinalizeSamples()
+void S9xFinalizeSamples(void)
{
- bool ret;
-
- ret = resampler_push(landing_buffer, SPC_SAMPLE_COUNT());
+ bool ret = resampler_push(landing_buffer, SPC_SAMPLE_COUNT());
sound_in_sync = false;
/* We weren't able to process the entire buffer. Potential overrun. */
@@ -3116,7 +3140,7 @@ void S9xFinalizeSamples()
spc_set_output(landing_buffer, buffer_size);
}
-void S9xClearSamples()
+void S9xClearSamples(void)
{
resampler_clear();
lag = lag_master;
@@ -3236,6 +3260,11 @@ static int8_t const reg_times_ [256] =
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
};
+void S9xSetSoundMute(bool mute)
+{
+ Settings.Mute = mute;
+}
+
bool S9xInitAPU()
{
int32_t i;
diff --git a/source/cpuexec.h b/source/cpuexec.h
index 3a5075b..4898207 100644
--- a/source/cpuexec.h
+++ b/source/cpuexec.h
@@ -5,11 +5,7 @@
typedef struct
{
-#ifdef __WIN32__
- void (__cdecl* S9xOpcode)(void);
-#else
void (*S9xOpcode)(void);
-#endif
} SOpcodes;
#include "ppu.h"
diff --git a/source/getset.h b/source/getset.c
index a5fd6f3..eefc5b5 100644
--- a/source/getset.h
+++ b/source/getset.c
@@ -1,8 +1,5 @@
#include "../copyright"
-#ifndef _GETSET_H_
-#define _GETSET_H_
-
#include "ppu.h"
#include "dsp1.h"
#include "cpuexec.h"
@@ -11,11 +8,9 @@
#include "obc1.h"
#include "seta.h"
-#include <retro_inline.h>
-
extern uint8_t OpenBus;
-INLINE uint8_t S9xGetByte(uint32_t Address)
+uint8_t S9xGetByte(uint32_t Address)
{
int32_t block;
uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
@@ -67,7 +62,7 @@ INLINE uint8_t S9xGetByte(uint32_t Address)
}
}
-INLINE uint16_t S9xGetWord(uint32_t Address)
+uint16_t S9xGetWord(uint32_t Address)
{
int32_t block;
uint8_t* GetAddress;
@@ -138,7 +133,7 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
}
}
-INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
+void S9xSetByte(uint8_t Byte, uint32_t Address)
{
int32_t block;
uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) & MEMMAP_MASK)];
@@ -209,7 +204,7 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
}
}
-INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
+void S9xSetWord(uint16_t Word, uint32_t Address)
{
int32_t block;
uint8_t* SetAddress;
@@ -313,7 +308,7 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
}
}
-INLINE uint8_t* GetBasePointer(uint32_t Address)
+uint8_t* GetBasePointer(uint32_t Address)
{
uint8_t* GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
if (GetAddress >= (uint8_t*) MAP_LAST)
@@ -347,7 +342,7 @@ INLINE uint8_t* GetBasePointer(uint32_t Address)
}
}
-INLINE uint8_t* S9xGetMemPointer(uint32_t Address)
+uint8_t* S9xGetMemPointer(uint32_t Address)
{
uint8_t* GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
if (GetAddress >= (uint8_t*) MAP_LAST)
@@ -384,7 +379,7 @@ INLINE uint8_t* S9xGetMemPointer(uint32_t Address)
}
}
-INLINE void S9xSetPCBase(uint32_t Address)
+void S9xSetPCBase(uint32_t Address)
{
int32_t block;
uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
@@ -421,4 +416,3 @@ INLINE void S9xSetPCBase(uint32_t Address)
CPU.PC = CPU.PCBase + (Address & 0xffff);
}
-#endif
diff --git a/source/gfx.c b/source/gfx.c
index e01538d..00fb4d1 100644
--- a/source/gfx.c
+++ b/source/gfx.c
@@ -36,6 +36,8 @@ extern SLineMatrixData LineMatrixData [240];
extern uint8_t Mode7Depths [2];
+extern bool reduce_sprite_flicker;
+
#define CLIP_10_BIT_SIGNED(a) \
((a) & ((1 << 10) - 1)) + (((((a) & (1 << 13)) ^ (1 << 13)) - (1 << 13)) >> 3)
@@ -476,10 +478,10 @@ void S9xEndScreenRefresh(void)
GFX.Pitch = GFX.Pitch2 = GFX.RealPitch;
GFX.PPL = GFX.PPLx2 >> 1;
+ }
#ifdef LAGFIX
- finishedFrame = true;
+ finishedFrame = true;
#endif
- }
S9xApplyCheats();
@@ -611,7 +613,7 @@ void S9xSetupOBJ(void)
for (i = 0; i < SNES_HEIGHT_EXTENDED; i++)
{
GFX.OBJLines[i].RTOFlags = 0;
- GFX.OBJLines[i].Tiles = 34;
+ GFX.OBJLines[i].Tiles = (reduce_sprite_flicker ? 60 : 34);
}
FirstSprite = PPU.FirstSprite;
S = FirstSprite;
@@ -733,7 +735,7 @@ void S9xSetupOBJ(void)
for (Y = 0; Y < SNES_HEIGHT_EXTENDED; Y++)
{
GFX.OBJLines[Y].RTOFlags = Y ? GFX.OBJLines[Y - 1].RTOFlags : 0;
- GFX.OBJLines[Y].Tiles = 34;
+ GFX.OBJLines[Y].Tiles = (reduce_sprite_flicker ? 60 : 34);
j = 0;
if (AnyOBJOnLine[Y])
{
diff --git a/source/memmap.c b/source/memmap.c
index cfdc997..4f76fc8 100644
--- a/source/memmap.c
+++ b/source/memmap.c
@@ -24,6 +24,11 @@
#include <malloc.h>
#endif
+#ifdef _MSC_VER
+/* Necessary to build on MSVC */
+#define strnicmp _strnicmp
+#endif
+
#define MAP_HIROM_SRAM_OR_NONE (Memory.SRAMSize == 0 ? (uint8_t*) MAP_NONE : (uint8_t*) MAP_HIROM_SRAM)
#define MAP_LOROM_SRAM_OR_NONE (Memory.SRAMSize == 0 ? (uint8_t*) MAP_NONE : (uint8_t*) MAP_LOROM_SRAM)
#define MAP_RONLY_SRAM_OR_NONE (Memory.SRAMSize == 0 ? (uint8_t*) MAP_NONE : (uint8_t*) MAP_RONLY_SRAM)
@@ -471,7 +476,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
_splitpath(filename, drive, dir, name, ext);
_makepath(fname, drive, dir, name, ext);
-#ifdef __WIN32__
+#ifdef _WIN32
/* memmove required: Overlapping addresses [Neb] */
memmove(&ext [0], &ext[1], 4);
#endif
@@ -524,7 +529,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
{
more = true;
ext [0]++;
-#ifdef __WIN32__
+#ifdef _WIN32
/* memmove required: Overlapping addresses [Neb] */
memmove(&ext [1], &ext [0], 4);
ext [0] = '.';
@@ -535,7 +540,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
{
more = true;
name [len - 1]++;
-#ifdef __WIN32__
+#ifdef _WIN32
/* memmove required: Overlapping addresses [Neb] */
memmove(&ext [1], &ext [0], 4);
ext [0] = '.';
@@ -3044,5 +3049,3 @@ void ParseSNESHeader(uint8_t* RomHeader)
else
sprintf(Memory.CompanyId, "%02X", RomHeader[0x2A]);
}
-
-#include "getset.h"
diff --git a/source/port.h b/source/port.h
index c2a9b7f..fcfe836 100644
--- a/source/port.h
+++ b/source/port.h
@@ -18,7 +18,7 @@
#include "pixform.h"
-#ifndef __WIN32__
+#ifndef _WIN32
#ifndef PATH_MAX
#define PATH_MAX 1024
@@ -46,7 +46,7 @@
void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext);
void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext);
-#else /* __WIN32__ */
+#else /* _WIN32 */
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
@@ -54,7 +54,7 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext
#define SLASH_STR "/"
#define SLASH_CHAR '/'
-#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__WIN32__) || defined(__alpha__)
+#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(_XBOX1) || defined(__alpha__)
#define FAST_LSB_WORD_ACCESS
#elif defined(__MIPSEL__)
/* On little-endian MIPS, a 16-bit word can be read directly from an address
diff --git a/source/ppu.h b/source/ppu.h
index e04c4ad..447f7f1 100644
--- a/source/ppu.h
+++ b/source/ppu.h
@@ -2,6 +2,8 @@
#define _PPU_H_
#include "../copyright"
+#include <stdint.h>
+#include <boolean.h>
#include <retro_inline.h>
#define FIRST_VISIBLE_LINE 1
diff --git a/source/snes9x.h b/source/snes9x.h
index 9e7d91d..ad410e1 100644
--- a/source/snes9x.h
+++ b/source/snes9x.h
@@ -46,9 +46,9 @@
#define SNES_CYCLES_PER_SCANLINE ((uint32_t) ((SNES_SCANLINE_TIME / SNES_CLOCK_LEN) * 6 + 0.5))
-#define ONE_CYCLE 6u
-#define SLOW_ONE_CYCLE 8u
-#define TWO_CYCLES 12u
+#define ONE_CYCLE (overclock_cycles ? one_c : 6u)
+#define SLOW_ONE_CYCLE (overclock_cycles ? slow_one_c : 8u)
+#define TWO_CYCLES (overclock_cycles ? two_c : 12u)
#define SNES_TR_MASK (1u << 4)
#define SNES_TL_MASK (1u << 5)
@@ -63,6 +63,9 @@
#define SNES_Y_MASK (1u << 14)
#define SNES_B_MASK (1u << 15)
+extern bool overclock_cycles;
+extern int one_c, slow_one_c, two_c;
+
enum
{
SNES_MULTIPLAYER5,
@@ -211,6 +214,7 @@ typedef struct
bool Justifier;
bool SecondJustifier;
int8_t SETA;
+ bool HardDisableAudio;
} SSettings;
extern SSettings Settings;