aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libretro.c60
-rw-r--r--source/apu.c16
-rw-r--r--source/apu.h2
-rw-r--r--source/apu_blargg.c322
-rw-r--r--source/apu_blargg.h142
-rw-r--r--source/blargg_endian.h36
-rw-r--r--source/c4emu.c30
-rw-r--r--source/cheats.c28
-rw-r--r--source/cheats2.c4
-rw-r--r--source/clip.c818
-rw-r--r--source/cpuaddr.h56
-rw-r--r--source/cpuexec.h10
-rw-r--r--source/cpumacro.h118
-rw-r--r--source/cpuops.c41
-rw-r--r--source/display.h8
-rw-r--r--source/dma.c32
-rw-r--r--source/dsp1.c6
-rw-r--r--source/dsp1emu.c20
-rw-r--r--source/dsp2emu.c46
-rw-r--r--source/dsp4.h4
-rw-r--r--source/dsp4emu.c10
-rw-r--r--source/font.h4
-rw-r--r--source/fxemu.c20
-rw-r--r--source/fxemu.h8
-rw-r--r--source/fxinst.c2
-rw-r--r--source/fxinst.h2
-rw-r--r--source/getset.h197
-rw-r--r--source/gfx.c248
-rw-r--r--source/gfx.h17
-rw-r--r--source/globals.c6
-rw-r--r--source/memmap.c604
-rw-r--r--source/obc1.c9
-rw-r--r--source/pixform.h28
-rw-r--r--source/ppu.c38
-rw-r--r--source/ppu.h32
-rw-r--r--source/sa1.c28
-rw-r--r--source/sa1.h18
-rw-r--r--source/sa1cpu.c2
-rw-r--r--source/sar.h8
-rw-r--r--source/sdd1.c8
-rw-r--r--source/sdd1emu.c18
-rw-r--r--source/sdd1emu.h2
-rw-r--r--source/seta010.c20
-rw-r--r--source/seta011.c4
-rw-r--r--source/seta018.c2
-rw-r--r--source/snes9x.h48
-rw-r--r--source/soundux.c104
-rw-r--r--source/soundux.h72
-rw-r--r--source/spc700.c4
-rw-r--r--source/spc7110.c116
-rw-r--r--source/spc7110.h116
-rw-r--r--source/srtc.c51
-rw-r--r--source/tile.h8
53 files changed, 1672 insertions, 1981 deletions
diff --git a/libretro.c b/libretro.c
index 3ccd6b8..73d0d9f 100644
--- a/libretro.c
+++ b/libretro.c
@@ -109,7 +109,7 @@ unsigned retro_api_version()
return RETRO_API_VERSION;
}
-void S9xMessage(int type, int number, const char* message)
+void S9xMessage(int32_t type, int32_t number, const char* message)
{
#define MAX_MESSAGE_LEN (36 * 3)
@@ -146,22 +146,21 @@ void S9xDeinitDisplay(void)
void S9xInitDisplay(void)
{
- int h = IMAGE_HEIGHT;
- int safety = 32;
+ int32_t h = IMAGE_HEIGHT;
+ int32_t safety = 32;
GFX.Pitch = IMAGE_WIDTH * 2;
#ifdef DS2_DMA
- GFX.Screen_buffer = (unsigned char*) AlignedMalloc(GFX.Pitch * h + safety, 32,
- &PtrAdj.GFXScreen);
+ GFX.Screen_buffer = (uint8_t *) AlignedMalloc(GFX.Pitch * h + safety, 32, &PtrAdj.GFXScreen);
#elif defined(_3DS)
safety = 0x80;
- GFX.Screen_buffer = (unsigned char*) linearMemAlign(GFX.Pitch * h + safety, 0x80);
+ GFX.Screen_buffer = (uint8_t *) linearMemAlign(GFX.Pitch * h + safety, 0x80);
#else
- GFX.Screen_buffer = (unsigned char*) malloc(GFX.Pitch * h + safety);
+ GFX.Screen_buffer = (uint8_t *) malloc(GFX.Pitch * h + safety);
#endif
- GFX.SubScreen_buffer = (unsigned char*) malloc(GFX.Pitch * h + safety);
- GFX.ZBuffer_buffer = (unsigned char*) malloc((GFX.Pitch >> 1) * h + safety);
- GFX.SubZBuffer_buffer = (unsigned char*) malloc((GFX.Pitch >> 1) * h + safety);
+ GFX.SubScreen_buffer = (uint8_t *) malloc(GFX.Pitch * h + safety);
+ GFX.ZBuffer_buffer = (uint8_t *) malloc((GFX.Pitch >> 1) * h + safety);
+ GFX.SubZBuffer_buffer = (uint8_t *) malloc((GFX.Pitch >> 1) * h + safety);
GFX.Screen = GFX.Screen_buffer + safety;
GFX.SubScreen = GFX.SubScreen_buffer + safety;
@@ -333,15 +332,7 @@ void retro_init(void)
S9xInitDisplay();
S9xInitGFX();
#ifdef USE_BLARGG_APU
- //very slow devices will still pop
-
- //this needs to be applied to all snes9x cores
-
- //increasing the buffer size does not cause extra lag(tested with 1000ms buffer)
- //bool8 S9xInitSound (int buffer_ms, int lag_ms)
-
- S9xInitSound(1000, 0);//just give it a 1 second buffer
-
+ S9xInitSound(1000, 0); //just give it a 1 second buffer
S9xSetSamplesAvailableCallback(S9xAudioCallback);
#else
S9xInitSound();
@@ -364,7 +355,7 @@ void retro_deinit(void)
#endif
}
-uint32_t S9xReadJoypad(int port)
+uint32_t S9xReadJoypad(int32_t port)
{
static const uint32_t snes_lut[] =
{
@@ -382,7 +373,7 @@ uint32_t S9xReadJoypad(int port)
SNES_TR_MASK
};
- int i;
+ int32_t i;
uint32_t joypad = 0;
for (i = RETRO_DEVICE_ID_JOYPAD_B; i <= RETRO_DEVICE_ID_JOYPAD_R; i++)
@@ -436,9 +427,9 @@ void retro_run(void)
if (samples_to_play > 512)
{
- S9xMixSamples((void*)audio_buf, ((int)samples_to_play) * 2);
- audio_batch_cb(audio_buf, (int)samples_to_play);
- samples_to_play -= (int)samples_to_play;
+ S9xMixSamples(audio_buf, ((int32_t)samples_to_play) * 2);
+ audio_batch_cb(audio_buf, (int32_t)samples_to_play);
+ samples_to_play -= (int32_t)samples_to_play;
}
#endif
@@ -492,12 +483,12 @@ void retro_run(void)
#endif
}
-bool S9xReadMousePosition(int which1, int* x, int* y, uint32_t* buttons)
+bool S9xReadMousePosition(int32_t which1, int32_t* x, int32_t* y, uint32_t* buttons)
{
return (false);
}
-bool S9xReadSuperScopePosition(int* x, int* y, uint32_t* buttons)
+bool S9xReadSuperScopePosition(int32_t* x, int32_t* y, uint32_t* buttons)
{
return (true);
}
@@ -620,19 +611,10 @@ size_t retro_serialize_size(void)
bool retro_serialize(void* data, size_t size)
{
- int i;
+ int32_t i;
S9xUpdateRTC();
S9xSRTCPreSaveState();
-#ifndef USE_BLARGG_APU
- for (i = 0; i < 8; i++)
- {
- SoundData.channels[i].previous16[0] = (int16_t)
- SoundData.channels[i].previous[0];
- SoundData.channels[i].previous16[1] = (int16_t)
- SoundData.channels[i].previous[1];
- }
-#endif
uint8_t* buffer = data;
memcpy(buffer, &CPU, sizeof(CPU));
buffer += sizeof(CPU);
@@ -684,7 +666,7 @@ bool retro_unserialize(const void* data, size_t size)
S9xReset();
#ifndef USE_BLARGG_APU
uint8_t* IAPU_RAM_current = IAPU.RAM;
- uintptr_t IAPU_RAM_offset;
+ uint32_t IAPU_RAM_offset;
#endif
memcpy(&CPU, buffer, sizeof(CPU));
buffer += sizeof(CPU);
@@ -929,12 +911,12 @@ void* retro_get_memory_data(unsigned type)
size_t retro_get_memory_size(unsigned type)
{
- unsigned size;
+ uint32_t size;
switch(type)
{
case RETRO_MEMORY_SAVE_RAM:
- size = (unsigned) (Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0);
+ size = (uint32_t) (Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0);
if (size > 0x20000)
size = 0x20000;
break;
diff --git a/source/apu.c b/source/apu.c
index 1ac4c06..a28469d 100644
--- a/source/apu.c
+++ b/source/apu.c
@@ -27,7 +27,7 @@ void S9xDeinitAPU()
{
if (IAPU.RAM)
{
- free((char*) IAPU.RAM);
+ free(IAPU.RAM);
IAPU.RAM = NULL;
}
}
@@ -36,7 +36,7 @@ uint8_t APUROM [64];
void S9xResetAPU()
{
- int i, j;
+ int32_t i, j;
Settings.APUEnabled = true;
@@ -104,7 +104,7 @@ void S9xSetAPUDSP(uint8_t byte)
uint8_t reg = IAPU.RAM [0xf2];
static uint8_t KeyOn;
static uint8_t KeyOnPrev;
- int i;
+ int32_t i;
switch (reg)
{
@@ -133,11 +133,11 @@ void S9xSetAPUDSP(uint8_t byte)
case APU_NON:
if (byte != APU.DSP [APU_NON])
{
- int c;
+ int32_t c;
uint8_t mask = 1;
for (c = 0; c < 8; c++, mask <<= 1)
{
- int type;
+ int32_t type;
if (byte & mask)
type = SOUND_NOISE;
@@ -169,7 +169,7 @@ void S9xSetAPUDSP(uint8_t byte)
break;
case APU_KOFF:
{
- int c;
+ int32_t c;
uint8_t mask = 1;
for (c = 0; c < 8; c++, mask <<= 1)
{
@@ -199,7 +199,7 @@ void S9xSetAPUDSP(uint8_t byte)
case APU_KON:
if (byte)
{
- int c;
+ int32_t c;
uint8_t mask = 1;
for (c = 0; c < 8; c++, mask <<= 1)
{
@@ -327,7 +327,7 @@ void S9xSetAPUDSP(uint8_t byte)
APU.DSP [reg] = byte;
}
-void S9xFixEnvelope(int channel, uint8_t gain, uint8_t adsr1, uint8_t adsr2)
+void S9xFixEnvelope(int32_t channel, uint8_t gain, uint8_t adsr1, uint8_t adsr2)
{
if (adsr1 & 0x80) // ADSR mode
{
diff --git a/source/apu.h b/source/apu.h
index 6b40363..bafeac9 100644
--- a/source/apu.h
+++ b/source/apu.h
@@ -65,8 +65,6 @@ void S9xResetAPU(void);
bool S9xInitAPU();
void S9xDeinitAPU();
void S9xDecacheSamples();
-int S9xTraceAPU();
-int S9xAPUOPrint(char* buffer, uint16_t Address);
void S9xSetAPUControl(uint8_t byte);
void S9xSetAPUDSP(uint8_t byte);
uint8_t S9xGetAPUDSP();
diff --git a/source/apu_blargg.c b/source/apu_blargg.c
index b6188bc..bbe02c9 100644
--- a/source/apu_blargg.c
+++ b/source/apu_blargg.c
@@ -40,10 +40,6 @@ details. You should have received a copy of the GNU Lesser General Public
License along with this module; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
-#if INT_MAX < 0x7FFFFFFF
- #error "Requires that int type have at least 32 bits"
-#endif
-
/* if ( io < -32768 ) io = -32768; */
/* if ( io > 32767 ) io = 32767; */
#define CLAMP16( io )\
@@ -114,9 +110,9 @@ static int16_t gauss [512] =
/* Gaussian interpolation */
-static INLINE int dsp_interpolate( dsp_voice_t *v )
+static INLINE int32_t dsp_interpolate( dsp_voice_t *v )
{
- int offset, out, *in;
+ int32_t offset, out, *in;
int16_t *fwd, *rev;
/* Make pointers into gaussian based on fractional position between samples */
@@ -141,7 +137,7 @@ static INLINE int dsp_interpolate( dsp_voice_t *v )
/* 30720 = 2048 * 5 * 3 */
#define SIMPLE_COUNTER_RANGE 30720
-static unsigned const counter_rates [32] =
+static uint32_t const counter_rates [32] =
{
SIMPLE_COUNTER_RANGE + 1, /* never fires */
2048, 1536,
@@ -158,7 +154,7 @@ static unsigned const counter_rates [32] =
1
};
-static unsigned const counter_offsets [32] =
+static uint32_t const counter_offsets [32] =
{
1, 0, 1040,
536, 0, 1040,
@@ -178,13 +174,13 @@ static unsigned const counter_offsets [32] =
if ( --dsp_m.counter < 0 ) \
dsp_m.counter = SIMPLE_COUNTER_RANGE - 1;
-#define READ_COUNTER(rate) (((unsigned) dsp_m.counter + counter_offsets [rate]) % counter_rates [rate])
+#define READ_COUNTER(rate) (((uint32_t) dsp_m.counter + counter_offsets [rate]) % counter_rates [rate])
/* Envelope */
static INLINE void dsp_run_envelope( dsp_voice_t* const v )
{
- int env, rate, env_data;
+ int32_t env, rate, env_data;
env = v->env;
env_data = v->regs[V_ADSR1];
@@ -207,7 +203,7 @@ static INLINE void dsp_run_envelope( dsp_voice_t* const v )
}
else /* GAIN */
{
- int mode;
+ int32_t mode;
env_data = v->regs[V_GAIN];
mode = env_data >> 5;
if ( mode < 4 ) /* direct */
@@ -230,7 +226,7 @@ static INLINE void dsp_run_envelope( dsp_voice_t* const v )
else /* 6,7: linear increase */
{
env += 0x20;
- if ( mode > 6 && (unsigned) v->hidden_env >= 0x600 )
+ if ( mode > 6 && (uint32_t) v->hidden_env >= 0x600 )
env += 0x8 - 0x20; /* 7: two-slope linear increase */
}
}
@@ -243,7 +239,7 @@ static INLINE void dsp_run_envelope( dsp_voice_t* const v )
v->hidden_env = env;
/* unsigned cast because linear decrease going negative also triggers this */
- if ( (unsigned) env > 0x7FF )
+ if ( (uint32_t) env > 0x7FF )
{
env = (env < 0 ? 0 : 0x7FF);
if ( v->env_mode == ENV_ATTACK )
@@ -258,7 +254,7 @@ static INLINE void dsp_run_envelope( dsp_voice_t* const v )
static INLINE void dsp_decode_brr( dsp_voice_t* v )
{
- int nybbles, *pos, *end, header;
+ int32_t nybbles, *pos, *end, header;
/* Arrange the four input nybbles in 0xABCD order for easy decoding */
nybbles = dsp_m.t_brr_byte * 0x100 + dsp_m.ram [(v->brr_addr + v->brr_offset + 1) & 0xFFFF];
@@ -274,7 +270,7 @@ static INLINE void dsp_decode_brr( dsp_voice_t* v )
/* Decode four samples */
for ( end = pos + 4; pos < end; pos++, nybbles <<= 4 )
{
- int filter, p1, p2, s, shift;
+ int32_t filter, p1, p2, s, shift;
/* Extract nybble and sign-extend */
s = (int16_t) nybbles >> 12;
@@ -344,7 +340,7 @@ static INLINE void dsp_misc_30 (void)
/* Noise */
if ( !READ_COUNTER( dsp_m.regs[R_FLG] & 0x1F ) )
{
- int feedback = (dsp_m.noise << 13) ^ (dsp_m.noise << 14);
+ int32_t feedback = (dsp_m.noise << 13) ^ (dsp_m.noise << 14);
dsp_m.noise = (feedback & 0x4000) ^ (dsp_m.noise >> 1);
}
}
@@ -386,7 +382,7 @@ static INLINE void dsp_voice_V3b( dsp_voice_t* const v )
static void dsp_voice_V3c( dsp_voice_t* const v )
{
- int output;
+ int32_t output;
/* Pitch modulation using previous voice's output */
if ( dsp_m.t_pmon & v->vbit )
@@ -450,7 +446,7 @@ static void dsp_voice_V3c( dsp_voice_t* const v )
/* Run envelope for next sample */
if ( !v->kon_delay )
{
- int env = v->env;
+ int32_t env = v->env;
if ( v->env_mode == ENV_RELEASE ) /* 60% */
{
if ( (env -= 0x8) < 0 )
@@ -464,9 +460,9 @@ static void dsp_voice_V3c( dsp_voice_t* const v )
}
}
-static INLINE void dsp_voice_output( dsp_voice_t const* v, int ch )
+static INLINE void dsp_voice_output( dsp_voice_t const* v, int32_t ch )
{
- int amp;
+ int32_t amp;
/* Apply left/right volume */
amp = (dsp_m.t_output * (int8_t) VREG(v->regs,VOLL + ch)) >> 7;
@@ -517,7 +513,7 @@ static INLINE void dsp_voice_V4( dsp_voice_t* const v )
static INLINE void dsp_voice_V5( dsp_voice_t* const v )
{
- int endx_buf;
+ int32_t endx_buf;
/* Output right */
dsp_voice_output( v, 1 );
@@ -601,7 +597,7 @@ static void dsp_voice_V9_V6_V3( dsp_voice_t* const v )
#define ECHO_READ(ch) \
{ \
- int s; \
+ int32_t s; \
if ( dsp_m.t_echo_ptr >= 0xffc0 && dsp_m.rom_enabled ) \
s = GET_LE16SA( &dsp_m.hi_ram [dsp_m.t_echo_ptr + ch * 2 - 0xffc0] ); \
else \
@@ -612,7 +608,7 @@ static void dsp_voice_V9_V6_V3( dsp_voice_t* const v )
static INLINE void dsp_echo_22 (void)
{
- int l, r;
+ int32_t l, r;
if ( ++dsp_m.echo_hist_pos >= &dsp_m.echo_hist [ECHO_HIST_SIZE] )
dsp_m.echo_hist_pos = dsp_m.echo_hist;
@@ -630,7 +626,7 @@ static INLINE void dsp_echo_22 (void)
static INLINE void dsp_echo_23 (void)
{
- int l, r;
+ int32_t l, r;
l = (((dsp_m.echo_hist_pos [1 + 1]) [0] * (int8_t) dsp_m.regs [R_FIR + 1 * 0x10]) >> 6) + (((dsp_m.echo_hist_pos [2 + 1]) [0] * (int8_t) dsp_m.regs [R_FIR + 2 * 0x10]) >> 6);
r = (((dsp_m.echo_hist_pos [1 + 1]) [1] * (int8_t) dsp_m.regs [R_FIR + 1 * 0x10]) >> 6) + (((dsp_m.echo_hist_pos [2 + 1]) [1] * (int8_t) dsp_m.regs [R_FIR + 2 * 0x10]) >> 6);
@@ -643,7 +639,7 @@ static INLINE void dsp_echo_23 (void)
static INLINE void dsp_echo_24 (void)
{
- int l, r;
+ int32_t l, r;
l = (((dsp_m.echo_hist_pos [3 + 1]) [0] * (int8_t) dsp_m.regs [R_FIR + 3 * 0x10]) >> 6) + (((dsp_m.echo_hist_pos [4 + 1]) [0] * (int8_t) dsp_m.regs [R_FIR + 4 * 0x10]) >> 6) + (((dsp_m.echo_hist_pos [5 + 1]) [0] * (int8_t) dsp_m.regs [R_FIR + 5 * 0x10]) >> 6);
r = (((dsp_m.echo_hist_pos [3 + 1]) [1] * (int8_t) dsp_m.regs [R_FIR + 3 * 0x10]) >> 6) + (((dsp_m.echo_hist_pos [4 + 1]) [1] * (int8_t) dsp_m.regs [R_FIR + 4 * 0x10]) >> 6) + (((dsp_m.echo_hist_pos [5 + 1]) [1] * (int8_t) dsp_m.regs [R_FIR + 5 * 0x10]) >> 6);
@@ -654,8 +650,8 @@ static INLINE void dsp_echo_24 (void)
static INLINE void dsp_echo_25 (void)
{
- int l = dsp_m.t_echo_in [0] + (((dsp_m.echo_hist_pos [6 + 1]) [0] * (int8_t) dsp_m.regs [R_FIR + 6 * 0x10]) >> 6);
- int r = dsp_m.t_echo_in [1] + (((dsp_m.echo_hist_pos [6 + 1]) [1] * (int8_t) dsp_m.regs [R_FIR + 6 * 0x10]) >> 6);
+ int32_t l = dsp_m.t_echo_in [0] + (((dsp_m.echo_hist_pos [6 + 1]) [0] * (int8_t) dsp_m.regs [R_FIR + 6 * 0x10]) >> 6);
+ int32_t r = dsp_m.t_echo_in [1] + (((dsp_m.echo_hist_pos [6 + 1]) [1] * (int8_t) dsp_m.regs [R_FIR + 6 * 0x10]) >> 6);
l = (int16_t) l;
r = (int16_t) r;
@@ -680,7 +676,7 @@ static INLINE void dsp_echo_25 (void)
static INLINE void dsp_echo_26 (void)
{
- int l, r;
+ int32_t l, r;
ECHO_OUTPUT(dsp_m.t_main_out[0], 0 );
@@ -696,7 +692,7 @@ static INLINE void dsp_echo_26 (void)
static INLINE void dsp_echo_27 (void)
{
- int l, r;
+ int32_t l, r;
int16_t *out;
l = dsp_m.t_main_out [0];
@@ -771,9 +767,9 @@ V(V9_V6_V3,2) -> V(V9,2) V(V6,3) V(V3,4) */
/* Runs DSP for specified number of clocks (~1024000 per second). Every 32 clocks
a pair of samples is be generated. */
-static void dsp_run( int clocks_remain )
+static void dsp_run( int32_t clocks_remain )
{
- int phase;
+ int32_t phase;
phase = dsp_m.phase;
dsp_m.phase = (phase + clocks_remain) & 31;
@@ -939,7 +935,7 @@ loop:
/* Sets destination for output samples. If out is NULL or out_size is 0,
doesn't generate any. */
-static void dsp_set_output( int16_t * out, int size )
+static void dsp_set_output( int16_t * out, int32_t size )
{
if ( !out )
{
@@ -968,7 +964,7 @@ static void dsp_soft_reset_common (void)
static void dsp_reset (void)
{
- int i;
+ int32_t i;
uint8_t const initial_regs [REGISTER_COUNT] =
{
@@ -1029,7 +1025,7 @@ static void spc_copier_copy(spc_state_copy_t * copier, void* state, size_t size
copier->func(copier->buf, state, size );
}
-static int spc_copier_copy_int(spc_state_copy_t * copier, int state, int size )
+static int32_t spc_copier_copy_int(spc_state_copy_t * copier, int32_t state, int32_t size )
{
uint8_t s [2];
SET_LE16( s, state );
@@ -1039,16 +1035,16 @@ static int spc_copier_copy_int(spc_state_copy_t * copier, int state, int size )
static void spc_copier_extra(spc_state_copy_t * copier)
{
- int n = 0;
+ int32_t n = 0;
n = (uint8_t) spc_copier_copy_int(copier, n, sizeof (uint8_t) );
if ( n > 0 )
{
- char temp [64];
+ int8_t temp [64];
memset( temp, 0, sizeof(temp));
do
{
- int size_n = sizeof(temp);
+ int32_t size_n = sizeof(temp);
if ( size_n > n )
size_n = n;
n -= size_n;
@@ -1060,9 +1056,9 @@ static void spc_copier_extra(spc_state_copy_t * copier)
/* Saves/loads exact emulator state */
-static void dsp_copy_state( unsigned char** io, dsp_copy_func_t copy )
+static void dsp_copy_state( uint8_t ** io, dsp_copy_func_t copy )
{
- int i, j;
+ int32_t i, j;
spc_state_copy_t copier;
copier.func = copy;
@@ -1083,7 +1079,7 @@ static void dsp_copy_state( unsigned char** io, dsp_copy_func_t copy )
/* BRR buffer */
for ( j = 0; j < BRR_BUF_SIZE; j++ )
{
- int s;
+ int32_t s;
s = v->buf [j];
SPC_COPY( int16_t, s );
@@ -1098,7 +1094,7 @@ static void dsp_copy_state( unsigned char** io, dsp_copy_func_t copy )
SPC_COPY( uint8_t, v->brr_offset );
SPC_COPY( uint8_t, v->kon_delay );
{
- int m;
+ int32_t m;
m = v->env_mode;
SPC_COPY( uint8_t, m );
@@ -1112,7 +1108,7 @@ static void dsp_copy_state( unsigned char** io, dsp_copy_func_t copy )
/* Echo history */
for ( i = 0; i < ECHO_HIST_SIZE; i++ )
{
- int s, s2;
+ int32_t s, s2;
s = dsp_m.echo_hist_pos [i] [0];
s2 = dsp_m.echo_hist_pos [i] [1];
@@ -1181,7 +1177,7 @@ static void dsp_copy_state( unsigned char** io, dsp_copy_func_t copy )
***********************************************************************************/
static spc_state_t m;
-static signed char reg_times [256];
+static int8_t reg_times [256];
static bool allow_time_overflow;
/* Copyright (C) 2004-2007 Shay Green. This module is free software; you
@@ -1203,16 +1199,16 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
#define TIMER_DIV( t, n ) ((n) >> t->prescaler)
#define TIMER_MUL( t, n ) ((n) << t->prescaler)
-static Timer* spc_run_timer_( Timer* t, int time )
+static Timer* spc_run_timer_( Timer* t, int32_t time )
{
- int elapsed;
+ int32_t elapsed;
elapsed = TIMER_DIV( t, time - t->next_time ) + 1;
t->next_time += TIMER_MUL( t, elapsed );
if ( t->enabled )
{
- int remain, divider, over, n;
+ int32_t remain, divider, over, n;
remain = IF_0_THEN_256( t->period - t->divider );
divider = t->divider + elapsed;
@@ -1230,7 +1226,7 @@ static Timer* spc_run_timer_( Timer* t, int time )
/* ROM */
-void spc_enable_rom( int enable )
+void spc_enable_rom( int32_t enable )
{
if ( m.rom_enabled != enable )
{
@@ -1248,18 +1244,18 @@ void spc_enable_rom( int enable )
#define MAX_REG_TIME 29
#define RUN_DSP( time, offset ) \
- int count = (time) - (offset) - m.dsp_time; \
+ int32_t count = (time) - (offset) - m.dsp_time; \
if ( count >= 0 ) \
{ \
- int clock_count; \
+ int32_t clock_count; \
clock_count = (count & ~(CLOCKS_PER_SAMPLE - 1)) + CLOCKS_PER_SAMPLE; \
m.dsp_time += clock_count; \
dsp_run( clock_count ); \
}
-static INLINE void spc_dsp_write( int data, int time )
+static INLINE void spc_dsp_write( int32_t data, int32_t time )
{
- int addr;
+ int32_t addr;
/* Writes DSP registers. */
addr = m.smp_regs[0][R_DSPADDR];
@@ -1295,12 +1291,12 @@ static INLINE void spc_dsp_write( int data, int time )
so often-used functionality can be optimized better by compiler */
/* If write isn't preceded by read, data has this added to it
- int const no_read_before_write = 0x2000; */
+ int32_t const no_read_before_write = 0x2000; */
#define NO_READ_BEFORE_WRITE 8192
#define NO_READ_BEFORE_WRITE_DIVIDED_BY_TWO 4096
-static void spc_cpu_write_smp_reg_( int data, int time, int addr )
+static void spc_cpu_write_smp_reg_( int32_t data, int32_t time, int32_t addr )
{
switch ( addr )
{
@@ -1308,7 +1304,7 @@ static void spc_cpu_write_smp_reg_( int data, int time, int addr )
case R_T1TARGET:
case R_T2TARGET:
{
- int period;
+ int32_t period;
Timer *t;
t = &m.timers [addr - R_T0TARGET];
@@ -1345,7 +1341,7 @@ static void spc_cpu_write_smp_reg_( int data, int time, int addr )
case R_CONTROL:
{
- int i;
+ int32_t i;
/* port clears */
if ( data & 0x10 )
{
@@ -1363,7 +1359,7 @@ static void spc_cpu_write_smp_reg_( int data, int time, int addr )
for ( i = 0; i < TIMER_COUNT; i++ )
{
Timer* t = &m.timers [i];
- int enabled = data >> i & 1;
+ int32_t enabled = data >> i & 1;
if ( t->enabled != enabled )
{
if ( time >= t->next_time )
@@ -1383,11 +1379,9 @@ static void spc_cpu_write_smp_reg_( int data, int time, int addr )
}
}
-static int const bits_in_int = CHAR_BIT * sizeof (int);
-
-static void spc_cpu_write( int data, uint16_t addr, int time )
+static void spc_cpu_write( int32_t data, uint16_t addr, int32_t time )
{
- int reg;
+ int32_t reg;
/* RAM */
m.ram.ram[addr] = (uint8_t) data;
reg = addr - 0xF0;
@@ -1402,7 +1396,7 @@ static void spc_cpu_write( int data, uint16_t addr, int time )
if ( reg != 2 && reg != 4 && reg != 5 && reg != 6 && reg != 7 )
TODO: this is a bit on the fragile side */
- if ( ((~0x2F00 << (bits_in_int - 16)) << reg) < 0 ) /* 36% */
+ if ( ((~0x2F00 << 16) << reg) < 0 ) /* 36% */
{
if ( reg == R_DSPDATA ) /* 99% */
{
@@ -1430,9 +1424,9 @@ static void spc_cpu_write( int data, uint16_t addr, int time )
/* CPU read */
-static int spc_cpu_read( uint16_t addr, int time )
+static int32_t spc_cpu_read( uint16_t addr, int32_t time )
{
- int result, reg;
+ int32_t result, reg;
/* RAM */
result = m.ram.ram[addr];
@@ -1441,12 +1435,12 @@ static int spc_cpu_read( uint16_t addr, int time )
if ( reg >= 0 ) /* 40% */
{
reg -= 0x10;
- if ( (unsigned) reg >= 0xFF00 ) /* 21% */
+ if ( (uint32_t) reg >= 0xFF00 ) /* 21% */
{
reg += 0x10 - R_T0OUT;
/* Timers */
- if ( (unsigned) reg < TIMER_COUNT ) /* 90% */
+ if ( (uint32_t) reg < TIMER_COUNT ) /* 90% */
{
Timer* t = &m.timers [reg];
if ( time >= t->next_time )
@@ -1457,16 +1451,16 @@ static int spc_cpu_read( uint16_t addr, int time )
/* Other registers */
else /* 10% */
{
- int reg_tmp;
+ int32_t reg_tmp;
reg_tmp = reg + R_T0OUT;
result = m.smp_regs[1][reg_tmp];
reg_tmp -= R_DSPADDR;
/* DSP addr and data */
- if ( (unsigned) reg_tmp <= 1 ) /* 4% 0xF2 and 0xF3 */
+ if ( (uint32_t) reg_tmp <= 1 ) /* 4% 0xF2 and 0xF3 */
{
result = m.smp_regs[0][R_DSPADDR];
- if ( (unsigned) reg_tmp == 1 )
+ if ( (uint32_t) reg_tmp == 1 )
{
RUN_DSP( time, reg_times [m.smp_regs[0][R_DSPADDR] & 0x7F] );
@@ -1490,11 +1484,11 @@ static int spc_cpu_read( uint16_t addr, int time )
#define CPU_READ_TIMER( time, offset, addr_, out )\
{\
- int adj_time, dp_addr, ti; \
+ int32_t adj_time, dp_addr, ti; \
adj_time = time + offset;\
dp_addr = addr_;\
ti = dp_addr - (R_T0OUT + 0xF0);\
- if ( (unsigned) ti < TIMER_COUNT )\
+ if ( (uint32_t) ti < TIMER_COUNT )\
{\
Timer* t = &m.timers [ti];\
if ( adj_time >= t->next_time )\
@@ -1504,19 +1498,19 @@ static int spc_cpu_read( uint16_t addr, int time )
}\
else\
{\
- int i, reg; \
+ int32_t i, reg; \
out = ram [dp_addr];\
i = dp_addr - 0xF0;\
- if ( (unsigned) i < 0x10 )\
+ if ( (uint32_t) i < 0x10 )\
{ \
reg = i; \
out = m.smp_regs[1][reg]; \
reg -= R_DSPADDR; \
/* DSP addr and data */ \
- if ( (unsigned) reg <= 1 ) /* 4% 0xF2 and 0xF3 */ \
+ if ( (uint32_t) reg <= 1 ) /* 4% 0xF2 and 0xF3 */ \
{ \
out = m.smp_regs[0][R_DSPADDR]; \
- if ( (unsigned) reg == 1 ) \
+ if ( (uint32_t) reg == 1 ) \
{ \
RUN_DSP( adj_time, reg_times [m.smp_regs[0][R_DSPADDR] & 0x7F] ); \
out = dsp_m.regs[m.smp_regs[0][R_DSPADDR] & 0x7F ]; /* 0xF3 */ \
@@ -1530,9 +1524,9 @@ static int spc_cpu_read( uint16_t addr, int time )
#define SPC_CPU_READ( time, addr ) spc_cpu_read((addr), rel_time + time )
#define SPC_CPU_WRITE( time, addr, data ) spc_cpu_write((data), (addr), rel_time + time )
-static unsigned spc_CPU_mem_bit( uint8_t const* pc, int rel_time )
+static uint32_t spc_CPU_mem_bit( uint8_t const* pc, int32_t rel_time )
{
- unsigned addr, t;
+ uint32_t addr, t;
addr = GET_LE16( pc );
t = SPC_CPU_READ( 0, addr & 0x1FFF ) >> (addr >> 13);
@@ -1577,11 +1571,11 @@ static unsigned spc_CPU_mem_bit( uint8_t const* pc, int rel_time )
nz = (in << 4 & 0x800) | (~in & Z02);\
}
-static uint8_t* spc_run_until_( int end_time )
+static uint8_t* spc_run_until_( int32_t end_time )
{
- int dp, nz, c, psw, a, x, y;
+ int32_t dp, nz, c, psw, a, x, y;
uint8_t *ram, *pc, *sp;
- int rel_time = m.spc_time - end_time;
+ int32_t rel_time = m.spc_time - end_time;
m.spc_time = end_time;
m.dsp_time += rel_time;
m.timers [0].next_time += rel_time;
@@ -1607,7 +1601,7 @@ inc_pc_loop:
pc++;
loop:
{
- unsigned opcode, data;
+ uint32_t opcode, data;
opcode = *pc;
@@ -1642,7 +1636,7 @@ loop:
case 0x3F:
{ /* CALL */
- int old_addr;
+ int32_t old_addr;
old_addr = GET_PC() + 2;
SET_PC( GET_LE16( pc ) );
PUSH16( old_addr );
@@ -1660,26 +1654,26 @@ loop:
goto loop;
case 0xFA:{ /* MOV dp,dp */
- int temp;
+ int32_t temp;
READ_DP_TIMER( -2, data, temp );
data = temp + NO_READ_BEFORE_WRITE ;
}
/* fall through */
case 0x8F:
{ /* MOV dp,#imm */
- int i, temp;
+ int32_t i, temp;
temp = READ_PC( pc + 1 );
pc += 2;
i = dp + temp;
ram [i] = (uint8_t) data;
i -= 0xF0;
- if ( (unsigned) i < 0x10 ) /* 76% */
+ if ( (uint32_t) i < 0x10 ) /* 76% */
{
m.smp_regs[0][i] = (uint8_t) data;
/* Registers other than $F2 and $F4-$F7 */
- if ( ((~0x2F00 << (bits_in_int - 16)) << i) < 0 ) /* 12% */
+ if ( ((~0x2F00 << 16) << i) < 0 ) /* 12% */
{
if ( i == R_DSPDATA ) /* 99% */
{
@@ -1697,13 +1691,13 @@ loop:
case 0xC4: /* MOV dp,a */
++pc;
{
- int i;
+ int32_t i;
i = dp + data;
ram [i] = (uint8_t) a;
i -= 0xF0;
- if ( (unsigned) i < 0x10 ) /* 39% */
+ if ( (uint32_t) i < 0x10 ) /* 39% */
{
- unsigned sel;
+ uint32_t sel;
sel = i - 2;
m.smp_regs[0][i] = (uint8_t) a;
@@ -1766,7 +1760,7 @@ loop:
case 0xBF:
{
/* MOV A,(X)+ */
- int temp;
+ int32_t temp;
temp = x + dp;
x = (uint8_t) (x + 1);
a = nz = SPC_CPU_READ( -1, temp );
@@ -1803,7 +1797,7 @@ loop:
case 0xEC:
{ /* MOV Y,abs */
- int temp;
+ int32_t temp;
temp = GET_LE16( pc );
pc += 2;
READ_TIMER( 0, temp, y = nz );
@@ -1822,7 +1816,7 @@ loop:
goto inc_pc_loop;
{
- int temp;
+ int32_t temp;
case 0xCC: /* MOV abs,Y */
temp = y;
goto mov_abs_temp;
@@ -1891,7 +1885,7 @@ mov_abs_temp:
case op: /* imm */\
nz = a func##= data;\
goto inc_pc_loop;\
- { unsigned addr;\
+ { uint32_t addr;\
case op + 0x11: /* X,Y */\
data = READ_DP( -2, y );\
addr = x + dp;\
@@ -1969,7 +1963,7 @@ cmp_y_addr:
goto inc_pc_loop;
{
- int addr;
+ int32_t addr;
case 0xB9: /* SBC (x),(y) */
case 0x99: /* ADC (x),(y) */
pc--; /* compensate for inc later */
@@ -1996,7 +1990,7 @@ adc_addr:
addr = -1; /* A */
nz = a;
adc_data: {
- int flags;
+ int32_t flags;
if ( opcode >= 0xA0 ) /* SBC */
data ^= 0xFF;
@@ -2066,7 +2060,7 @@ inc_abs:
c = 0;
case 0x3C:
{/* ROL A */
- int temp;
+ int32_t temp;
temp = c >> 8 & 1;
c = a << 1;
nz = c | temp;
@@ -2113,7 +2107,7 @@ rol_mem:
data = GET_LE16( pc );
pc++;
ror_mem: {
- int temp = SPC_CPU_READ( -1, data );
+ int32_t temp = SPC_CPU_READ( -1, data );
nz = (c >> 1 & 0x80) | (temp >> 1);
c = temp << 8;
SPC_CPU_WRITE( 0, data, nz );
@@ -2142,7 +2136,7 @@ ror_mem: {
case 0x3A: /* INCW dp */
case 0x1A:{/* DECW dp */
- int temp;
+ int32_t temp;
/* low byte */
data += dp;
temp = SPC_CPU_READ( -3, data );
@@ -2162,7 +2156,7 @@ ror_mem: {
case 0x7A: /* ADDW YA,dp */
case 0x9A:
{/* SUBW YA,dp */
- int lo, hi, result, flags;
+ int32_t lo, hi, result, flags;
lo = READ_DP( -2, data );
hi = READ_DP( 0, (uint8_t) (data + 1) );
@@ -2190,7 +2184,7 @@ ror_mem: {
case 0x5A:
{ /* CMPW YA,dp */
- int temp;
+ int32_t temp;
temp = a - READ_DP( -1, data );
nz = ((temp >> 1) | temp) & 0x7F;
temp = y + (temp >> 8);
@@ -2204,7 +2198,7 @@ ror_mem: {
/* 10. MULTIPLICATION & DIVISON COMMANDS */
case 0xCF: { /* MUL YA */
- unsigned temp = y * a;
+ uint32_t temp = y * a;
a = (uint8_t) temp;
nz = ((temp >> 1) | temp) & 0x7F;
y = temp >> 8;
@@ -2214,7 +2208,7 @@ ror_mem: {
case 0x9E: /* DIV YA,X */
{
- unsigned ya = y * 0x100 + a;
+ uint32_t ya = y * 0x100 + a;
psw &= ~(H08 | V40);
@@ -2328,14 +2322,14 @@ ror_mem: {
data = (uint8_t) (data + x);
/* fall through */
case 0x2E:{ /* CBNE dp,rel */
- int temp;
+ int32_t temp;
/* 61% from timer */
READ_DP_TIMER( -4, data, temp );
CBRANCH( temp != a )
}
case 0x6E: { /* DBNZ dp,rel */
- unsigned temp = READ_DP( -4, data ) - 1;
+ uint32_t temp = READ_DP( -4, data ) - 1;
WRITE_DP( -3, (uint8_t) data, /*(uint8_t)*/ temp + NO_READ_BEFORE_WRITE );
CBRANCH( temp )
}
@@ -2354,8 +2348,8 @@ ror_mem: {
/* 13. SUB-ROUTINE CALL RETURN COMMANDS */
case 0x0F:{/* BRK */
- int temp;
- int ret_addr = GET_PC();
+ int32_t temp;
+ int32_t ret_addr = GET_PC();
SET_PC( READ_PROG16( 0xFFDE ) ); /* vector address verified */
PUSH16( ret_addr );
GET_PSW( temp );
@@ -2365,7 +2359,7 @@ ror_mem: {
}
case 0x4F:{/* PCALL offset */
- int ret_addr = GET_PC() + 1;
+ int32_t ret_addr = GET_PC() + 1;
SET_PC( 0xFF00 | data );
PUSH16( ret_addr );
goto loop;
@@ -2387,7 +2381,7 @@ ror_mem: {
case 0xD1:
case 0xE1:
case 0xF1: {
- int ret_addr = GET_PC();
+ int32_t ret_addr = GET_PC();
SET_PC( READ_PROG16( 0xFFDE - (opcode >> 3) ) );
PUSH16( ret_addr );
goto loop;
@@ -2396,7 +2390,7 @@ ror_mem: {
/* 14. STACK OPERATION COMMANDS */
{
- int temp;
+ int32_t temp;
case 0x7F: /* RET1 */
temp = *sp;
SET_PC( GET_LE16( sp + 1 ) );
@@ -2410,7 +2404,7 @@ set_psw:
}
case 0x0D: { /* PUSH PSW */
- int temp;
+ int32_t temp;
GET_PSW( temp );
PUSH( temp );
goto loop;
@@ -2459,7 +2453,7 @@ set_psw:
case 0xD2:
case 0xF2:
{
- int bit, mask;
+ int32_t bit, mask;
bit = 1 << (opcode >> 5);
mask = ~bit;
if ( opcode & 0x10 )
@@ -2474,7 +2468,7 @@ set_psw:
data = GET_LE16( pc );
pc += 2;
{
- unsigned temp = SPC_CPU_READ( -2, data );
+ uint32_t temp = SPC_CPU_READ( -2, data );
nz = (uint8_t) (a - temp);
temp &= ~a;
if ( opcode == 0x0E )
@@ -2512,7 +2506,7 @@ set_psw:
data = GET_LE16( pc );
pc += 2;
{
- unsigned temp = SPC_CPU_READ( -1, data & 0x1FFF );
+ uint32_t temp = SPC_CPU_READ( -1, data & 0x1FFF );
temp ^= 1 << (data >> 13);
SPC_CPU_WRITE( 0, data & 0x1FFF, temp );
}
@@ -2522,7 +2516,7 @@ set_psw:
data = GET_LE16( pc );
pc += 2;
{
- unsigned temp, bit;
+ uint32_t temp, bit;
temp = SPC_CPU_READ( -2, data & 0x1FFF );
bit = data >> 13;
temp = (temp & ~(1 << bit)) | ((c >> 8 & 1) << bit);
@@ -2577,7 +2571,7 @@ set_psw:
case 0xFF:
{ /* STOP */
/* handle PC wrap-around */
- unsigned addr = GET_PC() - 1;
+ uint32_t addr = GET_PC() - 1;
if ( addr >= 0x10000 )
{
addr &= 0xFFFF;
@@ -2604,7 +2598,7 @@ stop:
m.cpu_regs.x = ( uint8_t) x;
m.cpu_regs.y = ( uint8_t) y;
{
- int temp;
+ int32_t temp;
GET_PSW( temp );
m.cpu_regs.psw = (uint8_t) temp;
}
@@ -2618,9 +2612,9 @@ stop:
/* Runs SPC to end_time and starts a new time frame at 0 */
-static void spc_end_frame( int end_time )
+static void spc_end_frame( int32_t end_time )
{
- int i;
+ int32_t i;
/* Catch CPU up to as close to end as possible. If final instruction
would exceed end, does NOT execute it and leaves m.spc_time < end. */
@@ -2690,9 +2684,9 @@ static void spc_reset_buffer(void)
/* Sets tempo, where tempo_unit = normal, tempo_unit / 2 = half speed, etc. */
-static void spc_set_tempo( int t )
+static void spc_set_tempo( int32_t t )
{
- int timer2_shift, other_shift;
+ int32_t timer2_shift, other_shift;
m.tempo = t;
timer2_shift = 4; /* 64 kHz */
other_shift = 3; /* 8 kHz */
@@ -2702,9 +2696,9 @@ static void spc_set_tempo( int t )
m.timers [0].prescaler = timer2_shift + other_shift;
}
-static void spc_reset_common( int timer_counter_init )
+static void spc_reset_common( int32_t timer_counter_init )
{
- int i;
+ int32_t i;
for ( i = 0; i < TIMER_COUNT; i++ )
m.smp_regs[1][R_T0OUT + i] = timer_counter_init;
@@ -2795,9 +2789,9 @@ static void spc_soft_reset (void)
}
#if !SPC_NO_COPY_STATE_FUNCS
-void spc_copy_state( unsigned char** io, dsp_copy_func_t copy )
+void spc_copy_state( uint8_t ** io, dsp_copy_func_t copy )
{
- int i;
+ int32_t i;
spc_state_copy_t copier;
copier.func = copy;
copier.buf = io;
@@ -2875,20 +2869,20 @@ void spc_copy_state( unsigned char** io, dsp_copy_func_t copy )
static apu_callback sa_callback = NULL;
-static bool sound_in_sync = true;
+static bool sound_in_sync = true;
-static int buffer_size;
-static int lag_master = 0;
-static int lag = 0;
+static int32_t buffer_size;
+static int32_t lag_master = 0;
+static int32_t lag = 0;
-static int16_t *landing_buffer = NULL;
+static int16_t* landing_buffer = NULL;
-static bool resampler = false;
+static bool resampler = false;
static int32_t reference_time;
static uint32_t spc_remainder;
-static int timing_hack_denominator = TEMPO_UNIT;
+static int32_t timing_hack_denominator = TEMPO_UNIT;
/* Set these to NTSC for now. Will change to PAL in S9xAPUTimingSetSpeedup
if necessary on game load. */
static uint32_t ratio_numerator = APU_NUMERATOR_NTSC;
@@ -2897,13 +2891,13 @@ static uint32_t ratio_denominator = APU_DENOMINATOR_NTSC;
/***********************************************************************************
RESAMPLER
************************************************************************************/
-static int rb_size;
-static int rb_buffer_size;
-static int rb_start;
-static unsigned char *rb_buffer;
+static int32_t rb_size;
+static int32_t rb_buffer_size;
+static int32_t rb_start;
+static uint8_t* rb_buffer;
static uint32_t r_step;
static uint32_t r_frac;
-static int r_left[4], r_right[4];
+static int32_t r_left[4], r_right[4];
#define SPACE_EMPTY() (rb_buffer_size - rb_size)
#define SPACE_FILLED() (rb_size)
@@ -2949,9 +2943,9 @@ static void resampler_time_ratio(double ratio)
resampler_clear();
}
-static void resampler_read(int16_t *data, int num_samples)
+static void resampler_read(int16_t *data, int32_t num_samples)
{
- int i_position, o_position, consumed;
+ int32_t i_position, o_position, consumed;
int16_t *internal_buffer;
i_position = rb_start >> 1;
@@ -2961,8 +2955,8 @@ static void resampler_read(int16_t *data, int num_samples)
while (o_position < num_samples && consumed < rb_buffer_size)
{
- int s_left, s_right, max_samples;
- int hermite_val;
+ 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];
@@ -3007,12 +3001,12 @@ static void resampler_read(int16_t *data, int num_samples)
rb_start -= rb_buffer_size;
}
-static void resampler_new(int num_samples)
+static void resampler_new(int32_t num_samples)
{
- int new_size = num_samples << 1;
+ int32_t new_size = num_samples << 1;
rb_buffer_size = new_size;
- rb_buffer = (unsigned char*)malloc(rb_buffer_size);
+ rb_buffer = (uint8_t *)malloc(rb_buffer_size);
memset (rb_buffer, 0, rb_buffer_size);
rb_size = 0;
@@ -3020,17 +3014,17 @@ static void resampler_new(int num_samples)
resampler_clear();
}
-static INLINE bool resampler_push(int16_t *src, int num_samples)
+static INLINE bool resampler_push(int16_t *src, int32_t num_samples)
{
- int bytes, end, first_write_size;
- unsigned char *src_ring;
+ int32_t bytes, end, first_write_size;
+ uint8_t *src_ring;
bytes = num_samples << 1;
if (MAX_WRITE() < num_samples || SPACE_EMPTY() < bytes)
return false;
/* Ring buffer push */
- src_ring = (unsigned char*)src;
+ src_ring = (uint8_t *)src;
end = (rb_start + rb_size) % rb_buffer_size;
first_write_size = RESAMPLER_MIN(bytes, rb_buffer_size - end);
@@ -3044,11 +3038,11 @@ static INLINE bool resampler_push(int16_t *src, int num_samples)
return true;
}
-static INLINE void resampler_resize (int num_samples)
+static INLINE void resampler_resize (int32_t num_samples)
{
free(rb_buffer);
rb_buffer_size = rb_size;
- rb_buffer = (unsigned char*)malloc(rb_buffer_size);
+ rb_buffer = (uint8_t *)malloc(rb_buffer_size);
memset (rb_buffer, 0, rb_buffer_size);
rb_size = 0;
@@ -3059,7 +3053,7 @@ static INLINE void resampler_resize (int num_samples)
APU
***********************************************************************************/
-bool S9xMixSamples (int16_t *buffer, unsigned sample_count)
+bool S9xMixSamples (int16_t *buffer, uint32_t sample_count)
{
if (AVAIL() >= (sample_count + lag))
{
@@ -3079,14 +3073,14 @@ bool S9xMixSamples (int16_t *buffer, unsigned sample_count)
return (true);
}
-int S9xGetSampleCount (void)
+int32_t S9xGetSampleCount (void)
{
return AVAIL();
}
/* Sets destination for output samples */
-static void spc_set_output( int16_t* out, int size )
+static void spc_set_output( int16_t* out, int32_t size )
{
int16_t *out_end, *in;
@@ -3163,11 +3157,11 @@ static void UpdatePlaybackRate (void)
resampler_time_ratio(time_ratio);
}
-bool S9xInitSound (int buffer_ms, int lag_ms)
+bool S9xInitSound (int32_t buffer_ms, int32_t lag_ms)
{
/* buffer_ms : buffer size given in millisecond
lag_ms : allowable time-lag given in millisecond */
- int sample_count, lag_sample_count;
+ int32_t sample_count, lag_sample_count;
sample_count = buffer_ms * 32000 / 1000;
lag_sample_count = lag_ms * 32000 / 1000;
@@ -3213,7 +3207,7 @@ bool S9xInitSound (int buffer_ms, int lag_ms)
}
/* Must be called once before using */
-static unsigned char cycle_table [128] =
+static uint8_t cycle_table [128] =
{/* 01 23 45 67 89 AB CD EF */
0x28,0x47,0x34,0x36,0x26,0x54,0x54,0x68, /* 0 */
0x48,0x47,0x45,0x56,0x55,0x65,0x22,0x46, /* 1 */
@@ -3233,7 +3227,7 @@ static unsigned char cycle_table [128] =
0x48,0x47,0x45,0x56,0x34,0x54,0x22,0x60, /* F */
};
-static signed char const reg_times_ [256] =
+static int8_t const reg_times_ [256] =
{
-1, 0,-11,-10,-15,-11, -2, -2, 4, 3, 14, 14, 26, 26, 14, 22,
2, 3, 0, 1,-12, 0, 1, 1, 7, 6, 14, 14, 27, 14, 14, 23,
@@ -3256,7 +3250,7 @@ static signed char const reg_times_ [256] =
bool S9xInitAPU (void)
{
- int i;
+ int32_t i;
uint8_t APUROM[64] =
{
@@ -3285,7 +3279,7 @@ bool S9xInitAPU (void)
/* unpack cycle table */
for ( i = 0; i < 128; i++ )
{
- int n;
+ int32_t n;
n = cycle_table [i];
m.cycle_table [i * 2 + 0] = n >> 4;
m.cycle_table [i * 2 + 1] = n & 0x0F;
@@ -3329,11 +3323,11 @@ void S9xDeinitAPU (void)
/* Emulated port read at specified time */
-uint8_t S9xAPUReadPort (int port) { return ((uint8_t) spc_run_until_(S9X_APU_GET_CLOCK(CPU.Cycles))[port]); }
+uint8_t S9xAPUReadPort (int32_t port) { return ((uint8_t) spc_run_until_(S9X_APU_GET_CLOCK(CPU.Cycles))[port]); }
/* Emulated port write at specified time */
-void S9xAPUWritePort (int port, uint8_t byte)
+void S9xAPUWritePort (int32_t port, uint8_t byte)
{
spc_run_until_( S9X_APU_GET_CLOCK(CPU.Cycles) ) [0x10 + port] = byte;
m.ram.ram [0xF4 + port] = byte;
@@ -3356,7 +3350,7 @@ void S9xAPUExecute (void)
sa_callback();
}
-void S9xAPUTimingSetSpeedup (int ticks)
+void S9xAPUTimingSetSpeedup (int32_t ticks)
{
if (ticks != 0)
printf("APU speedup hack: %d\n", ticks);
@@ -3434,14 +3428,12 @@ void S9xAPUSaveState (uint8_t *block)
}
#if defined(ANDROID) || defined(__QNX__)
-void __attribute__((optimize(0))) S9xAPULoadState (uint8_t *block)
+void __attribute__((optimize(0))) S9xAPULoadState (const uint8_t *block)
#else
-void S9xAPULoadState (uint8_t *block)
+void S9xAPULoadState (const uint8_t *block)
#endif
{
- uint8_t *ptr;
-
- ptr = block;
+ uint8_t *ptr = (uint8_t*) block;
S9xResetAPU();
diff --git a/source/apu_blargg.h b/source/apu_blargg.h
index f2a89ec..66c375f 100644
--- a/source/apu_blargg.h
+++ b/source/apu_blargg.h
@@ -7,7 +7,7 @@
#include "snes9x.h"
-typedef void (*dsp_copy_func_t)( unsigned char** io, void* state, size_t );
+typedef void (*dsp_copy_func_t)( uint8_t ** io, void* state, size_t );
#define ECHO_HIST_SIZE 8
#define ECHO_HIST_SIZE_X2 16
@@ -82,17 +82,17 @@ typedef void (*dsp_copy_func_t)( unsigned char** io, void* state, size_t );
typedef struct
{
- int buf [BRR_BUF_SIZE_X2]; // decoded samples (twice the size to simplify wrap handling)
- int buf_pos; // place in buffer where next samples will be decoded
- int interp_pos; // relative fractional position in sample (0x1000 = 1.0)
- int brr_addr; // address of current BRR block
- int brr_offset; // current decoding offset in BRR block
+ int32_t buf [BRR_BUF_SIZE_X2]; // decoded samples (twice the size to simplify wrap handling)
+ int32_t buf_pos; // place in buffer where next samples will be decoded
+ int32_t interp_pos; // relative fractional position in sample (0x1000 = 1.0)
+ int32_t brr_addr; // address of current BRR block
+ int32_t brr_offset; // current decoding offset in BRR block
uint8_t* regs; // pointer to voice's DSP registers
- int vbit; // bitmask for voice: 0x01 for voice 0, 0x02 for voice 1, etc.
- int kon_delay; // KON delay/current setup phase
- int env_mode;
- int env; // current envelope level
- int hidden_env; // used by GAIN mode 7, very obscure quirk
+ int32_t vbit; // bitmask for voice: 0x01 for voice 0, 0x02 for voice 1, etc.
+ int32_t kon_delay; // KON delay/current setup phase
+ int32_t env_mode;
+ int32_t env; // current envelope level
+ int32_t hidden_env; // used by GAIN mode 7, very obscure quirk
uint8_t t_envx_out;
} dsp_voice_t;
@@ -102,20 +102,20 @@ typedef struct
/* Echo history keeps most recent 8 samples (twice the size to simplify wrap handling) */
- int echo_hist [ECHO_HIST_SIZE_X2] [2];
+ int32_t echo_hist [ECHO_HIST_SIZE_X2] [2];
- int (*echo_hist_pos) [2]; /* &echo_hist [0 to 7] */
+ int32_t (*echo_hist_pos) [2]; /* &echo_hist [0 to 7] */
- int every_other_sample; /* toggles every sample */
- int kon; /* KON value when last checked */
- int noise;
- int counter;
- int echo_offset; /* offset from ESA in echo buffer */
- int echo_length; /* number of bytes that echo_offset will stop at */
- int phase; /* next clock cycle to run (0-31) */
+ int32_t every_other_sample; /* toggles every sample */
+ int32_t kon; /* KON value when last checked */
+ int32_t noise;
+ int32_t counter;
+ int32_t echo_offset; /* offset from ESA in echo buffer */
+ int32_t echo_length; /* number of bytes that echo_offset will stop at */
+ int32_t phase; /* next clock cycle to run (0-31) */
/* Hidden registers also written to when main register is written to */
- int new_kon;
+ int32_t new_kon;
uint8_t endx_buf;
uint8_t envx_buf;
uint8_t outx_buf;
@@ -123,32 +123,32 @@ typedef struct
/* Temporary state between clocks */
/* read once per sample */
- int t_pmon;
- int t_non;
- int t_eon;
- int t_dir;
- int t_koff;
+ int32_t t_pmon;
+ int32_t t_non;
+ int32_t t_eon;
+ int32_t t_dir;
+ int32_t t_koff;
/* read a few clocks ahead then used */
- int t_brr_next_addr;
- int t_adsr0;
- int t_brr_header;
- int t_brr_byte;
- int t_srcn;
- int t_esa;
- int t_echo_enabled;
+ int32_t t_brr_next_addr;
+ int32_t t_adsr0;
+ int32_t t_brr_header;
+ int32_t t_brr_byte;
+ int32_t t_srcn;
+ int32_t t_esa;
+ int32_t t_echo_enabled;
/* internal state that is recalculated every sample */
- int t_dir_addr;
- int t_pitch;
- int t_output;
- int t_looped;
- int t_echo_ptr;
+ int32_t t_dir_addr;
+ int32_t t_pitch;
+ int32_t t_output;
+ int32_t t_looped;
+ int32_t t_echo_ptr;
/* left/right sums */
- int t_main_out [2];
- int t_echo_out [2];
- int t_echo_in [2];
+ int32_t t_main_out [2];
+ int32_t t_echo_out [2];
+ int32_t t_echo_in [2];
dsp_voice_t voices [VOICE_COUNT];
@@ -159,16 +159,16 @@ typedef struct
int16_t* out_begin;
int16_t extra [EXTRA_SIZE];
- int rom_enabled;
- uint8_t *rom;
- uint8_t *hi_ram;
+ int32_t rom_enabled;
+ uint8_t* rom;
+ uint8_t* hi_ram;
} dsp_state_t;
#if !SPC_NO_COPY_STATE_FUNCS
typedef struct {
dsp_copy_func_t func;
- unsigned char** buf;
+ uint8_t** buf;
} spc_state_copy_t;
#define SPC_COPY( type, state ) state = (type) spc_copier_copy_int(&copier, state, sizeof (type) );
@@ -208,7 +208,7 @@ typedef struct {
#if !SPC_NO_COPY_STATE_FUNCS
/* Saves/loads state */
- void spc_copy_state( unsigned char** io, dsp_copy_func_t );
+ void spc_copy_state( uint8_t ** io, dsp_copy_func_t );
#endif
/* rel_time_t - Time relative to m_spc_time. Speeds up code a bit by eliminating
@@ -217,12 +217,12 @@ typedef struct {
typedef struct
{
- int next_time; /* time of next event */
- int prescaler;
- int period;
- int divider;
- int enabled;
- int counter;
+ int32_t next_time; /* time of next event */
+ int32_t prescaler;
+ int32_t period;
+ int32_t divider;
+ int32_t enabled;
+ int32_t counter;
} Timer;
/* Support SNES_MEMORY_APURAM */
@@ -236,30 +236,30 @@ typedef struct
struct
{
- int pc;
- int a;
- int x;
- int y;
- int psw;
- int sp;
+ int32_t pc;
+ int32_t a;
+ int32_t x;
+ int32_t y;
+ int32_t psw;
+ int32_t sp;
} cpu_regs;
- int dsp_time;
- int spc_time;
+ int32_t dsp_time;
+ int32_t spc_time;
- int tempo;
+ int32_t tempo;
- int extra_clocks;
+ int32_t extra_clocks;
int16_t* buf_begin;
int16_t* buf_end;
int16_t* extra_pos;
int16_t extra_buf [EXTRA_SIZE];
- int rom_enabled;
+ int32_t rom_enabled;
uint8_t rom [ROM_SIZE];
uint8_t hi_ram [ROM_SIZE];
- unsigned char cycle_table [256];
+ uint8_t cycle_table [256];
struct
{
@@ -284,22 +284,22 @@ bool S9xInitAPU (void);
void S9xDeinitAPU (void);
void S9xResetAPU (void);
void S9xSoftResetAPU (void);
-uint8_t S9xAPUReadPort (int port);
-void S9xAPUWritePort (int port, uint8_t byte);
+uint8_t S9xAPUReadPort (int32_t port);
+void S9xAPUWritePort (int32_t port, uint8_t byte);
void S9xAPUExecute (void);
void S9xAPUSetReferenceTime (int32_t cpucycles);
-void S9xAPUTimingSetSpeedup (int ticks);
+void S9xAPUTimingSetSpeedup (int32_t ticks);
void S9xAPUAllowTimeOverflow (bool allow);
-void S9xAPULoadState (uint8_t * block);
+void S9xAPULoadState (const uint8_t * block);
void S9xAPUSaveState (uint8_t * block);
-bool S9xInitSound (int buffer_ms, int lag_ms);
+bool S9xInitSound (int32_t buffer_ms, int32_t lag_ms);
bool S9xSyncSound (void);
-int S9xGetSampleCount (void);
+int32_t S9xGetSampleCount (void);
void S9xFinalizeSamples (void);
void S9xClearSamples (void);
-bool S9xMixSamples (int16_t * buffer, unsigned sample_count);
+bool S9xMixSamples (int16_t * buffer, uint32_t sample_count);
void S9xSetSamplesAvailableCallback (apu_callback);
#endif // APU_BLARGG_H
diff --git a/source/blargg_endian.h b/source/blargg_endian.h
index 80ce61e..3fc7296 100644
--- a/source/blargg_endian.h
+++ b/source/blargg_endian.h
@@ -19,12 +19,6 @@
#include <boolean.h>
-#if UINT_MAX < 0xFFFFFFFF || ULONG_MAX == 0xFFFFFFFF
- typedef unsigned long blargg_ulong;
-#else
- typedef unsigned blargg_ulong;
-#endif
-
#include <stdint.h>
/* BLARGG_CPU_CISC: Defined if CPU has very few general-purpose registers (< 16) */
@@ -75,31 +69,31 @@
#define SET_LE32( addr, data ) (void) (*(uint32_t*) (addr) = (data))
#endif
#else
-static INLINE unsigned get_le16( void const* p )
+static INLINE uint32_t get_le16( void const* p )
{
- return (unsigned) ((unsigned char const*) p) [1] << 8 | (unsigned) ((unsigned char const*) p) [0];
+ return (uint32_t) ((uint8_t const*) p) [1] << 8 | (uint32_t) ((uint8_t const*) p) [0];
}
-static INLINE blargg_ulong get_le32( void const* p )
+static INLINE uint32_t get_le32( void const* p )
{
- return (blargg_ulong) ((unsigned char const*) p) [3] << 24 |
- (blargg_ulong) ((unsigned char const*) p) [2] << 16 |
- (blargg_ulong) ((unsigned char const*) p) [1] << 8 |
- (blargg_ulong) ((unsigned char const*) p) [0];
+ return (uint32_t) ((uint8_t const*) p) [3] << 24 |
+ (uint32_t) ((uint8_t const*) p) [2] << 16 |
+ (uint32_t) ((uint8_t const*) p) [1] << 8 |
+ (uint32_t) ((uint8_t const*) p) [0];
}
-static INLINE void set_le16( void* p, unsigned n )
+static INLINE void set_le16( void* p, uint32_t n )
{
- ((unsigned char*) p) [1] = (unsigned char) (n >> 8);
- ((unsigned char*) p) [0] = (unsigned char) n;
+ ((uint8_t*) p) [1] = (uint8_t) (n >> 8);
+ ((uint8_t*) p) [0] = (uint8_t) n;
}
-static INLINE void set_le32( void* p, blargg_ulong n )
+static INLINE void set_le32( void* p, uint32_t n )
{
- ((unsigned char*) p) [0] = (unsigned char) n;
- ((unsigned char*) p) [1] = (unsigned char) (n >> 8);
- ((unsigned char*) p) [2] = (unsigned char) (n >> 16);
- ((unsigned char*) p) [3] = (unsigned char) (n >> 24);
+ ((uint8_t*) p) [0] = (uint8_t) n;
+ ((uint8_t*) p) [1] = (uint8_t) (n >> 8);
+ ((uint8_t*) p) [2] = (uint8_t) (n >> 16);
+ ((uint8_t*) p) [3] = (uint8_t) (n >> 24);
}
#endif
diff --git a/source/c4emu.c b/source/c4emu.c
index 06cdfe3..a6baecf 100644
--- a/source/c4emu.c
+++ b/source/c4emu.c
@@ -59,7 +59,7 @@ static void C4ConvOAM(void)
if (Memory.C4RAM[0x0620] != 0)
{
- int prio, i;
+ int32_t prio, i;
SprCount = 128 - Memory.C4RAM[0x626];
uint8_t offset = (Memory.C4RAM[0x626] & 3) * 2;
for (prio = 0x30; prio >= 0; prio -= 0x10)
@@ -76,7 +76,7 @@ static void C4ConvOAM(void)
uint8_t* sprptr = S9xGetMemPointer(READ_3WORD(srcptr + 7));
if (*sprptr != 0)
{
- int SprCnt;
+ int32_t SprCnt;
int16_t X, Y;
for (SprCnt = *sprptr++; SprCnt > 0 && SprCount > 0; SprCnt--, sprptr += 4)
{
@@ -127,7 +127,7 @@ static void C4ConvOAM(void)
// XXX: Copy to OAM? I doubt it.
}
-static void C4DoScaleRotate(int row_padding)
+static void C4DoScaleRotate(int32_t row_padding)
{
int16_t A, B, C, D;
@@ -203,8 +203,8 @@ static void C4DoScaleRotate(int row_padding)
// Start loop
uint32_t X, Y;
uint8_t byte;
- int outidx = 0;
- int x, y;
+ int32_t outidx = 0;
+ int32_t x, y;
uint8_t bit = 0x80;
for (y = 0; y < h; y++)
{
@@ -279,7 +279,7 @@ static void C4DrawLine(int32_t X1, int32_t Y1, int16_t Z1,
Y2 = (int16_t)C4WFYVal;
// render line
- int i;
+ int32_t i;
for (i = C4WFDist ? C4WFDist : 1; i > 0; i--)
{
//.loop
@@ -306,7 +306,7 @@ static void C4DrawWireFrame(void)
int16_t X2, Y2, Z2;
uint8_t Color;
- int i;
+ int32_t i;
for (i = Memory.C4RAM[0x0295]; i > 0; i--, line += 5)
{
if (line[0] == 0xff && line[1] == 0xff)
@@ -340,7 +340,7 @@ static void C4TransformLines(void)
C4WFDist = Memory.C4RAM[0x1f89];
C4WFScale = Memory.C4RAM[0x1f8c];
- int i;
+ int32_t i;
// transform vertices
uint8_t* ptr = Memory.C4RAM;
@@ -367,7 +367,7 @@ static void C4TransformLines(void)
ptr = Memory.C4RAM + 0xb02;
uint8_t* ptr2 = Memory.C4RAM;
{
- int i;
+ int32_t i;
for (i = READ_WORD(Memory.C4RAM + 0xb00); i > 0; i--, ptr += 2, ptr2 += 8)
{
C4WFXVal = READ_WORD(Memory.C4RAM + (ptr[0] << 4) + 1);
@@ -397,7 +397,7 @@ static void C4BitPlaneWave()
uint16_t mask1 = 0xc0c0;
uint16_t mask2 = 0x3f3f;
- int i, j;
+ int32_t i, j;
for (j = 0; j < 0x10; j++)
{
do
@@ -425,7 +425,7 @@ static void C4BitPlaneWave()
do
{
- int i;
+ int32_t i;
int16_t height = -((int8_t)Memory.C4RAM[waveptr + 0xb00]) - 16;
for (i = 0; i < 40; i++)
{
@@ -477,7 +477,7 @@ static void C4SprDisintegrate()
if ((x >> 8) < width && (y >> 8) < height && (y >> 8)*width + (x >> 8) < 0x2000)
{
uint8_t pixel = (j & 1) ? (*src >> 4) : *src;
- int idx = (y >> 11) * width * 4 + (x >> 11) * 32 + ((y >> 8) & 7) * 2;
+ int32_t idx = (y >> 11) * width * 4 + (x >> 11) * 32 + ((y >> 8) & 7) * 2;
uint8_t mask = 0x80 >> ((x >> 8) & 7);
if (pixel & 1) Memory.C4RAM[idx] |= mask;
if (pixel & 2) Memory.C4RAM[idx + 1] |= mask;
@@ -528,7 +528,7 @@ static void S9xC4ProcessSprites()
void S9xSetC4(uint8_t byte, uint16_t Address)
{
- int i;
+ int32_t i;
Memory.C4RAM [Address - 0x6000] = byte;
if (Address == 0x7f4f)
{
@@ -613,7 +613,7 @@ void S9xSetC4(uint8_t byte, uint16_t Address)
C4CosTable[angle2]) : 0x80000000;
int16_t y = READ_WORD(Memory.C4RAM + 0x1f83) - READ_WORD(Memory.C4RAM + 0x1f89);
int16_t left, right;
- int j;
+ int32_t j;
for (j = 0; j < 225; j++)
{
if (y >= 0)
@@ -681,7 +681,7 @@ void S9xSetC4(uint8_t byte, uint16_t Address)
case 0x40: // Sum
{
- int i;
+ int32_t i;
uint16_t sum = 0;
for (i = 0; i < 0x800; sum += Memory.C4RAM[i++]);
WRITE_WORD(Memory.C4RAM + 0x1f80, sum);
diff --git a/source/cheats.c b/source/cheats.c
index c308c93..b394032 100644
--- a/source/cheats.c
+++ b/source/cheats.c
@@ -9,9 +9,9 @@
#include "cheats.h"
#include "memmap.h"
-static bool S9xAllHex(const char* code, int len)
+static bool S9xAllHex(const char* code, int32_t len)
{
- int i;
+ int32_t i;
for (i = 0; i < len; i++)
if ((code [i] < '0' || code [i] > '9') &&
(code [i] < 'a' || code [i] > 'f') &&
@@ -46,12 +46,12 @@ const char* S9xGoldFingerToRaw(const char* code, uint32_t* address, bool* sram,
if (sscanf(tmp, "%x", address) != 1)
return ("Invalid Gold Finger code.");
- int i;
+ int32_t i;
for (i = 0; i < 3; i++)
{
strncpy(tmp, code + 5 + i * 2, 2);
tmp [2] = 0;
- int byte;
+ int32_t byte;
if (sscanf(tmp, "%x", &byte) != 1)
break;
bytes [i] = (uint8_t) byte;
@@ -76,12 +76,12 @@ const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte
static char* real_hex = "0123456789ABCDEF";
static char* genie_hex = "DF4709156BC8A23E";
- int i;
+ int32_t i;
for (i = 2; i < 10; i++)
{
if (islower(new_code [i]))
new_code [i] = toupper(new_code [i]);
- int j;
+ int32_t j;
for (j = 0; j < 16; j++)
{
if (new_code [i] == genie_hex [j])
@@ -115,9 +115,9 @@ void S9xStartCheatSearch(SCheatData* d)
memmove(d->CSRAM, d->SRAM, 0x10000);
// memmove may be required: Source is usually a different malloc, but could be pointed to d->CIRAM [Neb]
memmove(d->CIRAM, &d->FillRAM [0x3000], 0x2000);
- memset((char*) d->WRAM_BITS, 0xff, 0x20000 >> 3);
- memset((char*) d->SRAM_BITS, 0xff, 0x10000 >> 3);
- memset((char*) d->IRAM_BITS, 0xff, 0x2000 >> 3);
+ memset(d->WRAM_BITS, 0xff, 0x20000 >> 3);
+ memset(d->SRAM_BITS, 0xff, 0x10000 >> 3);
+ memset(d->IRAM_BITS, 0xff, 0x2000 >> 3);
}
#define BIT_CLEAR(a,v) \
@@ -152,7 +152,7 @@ void S9xStartCheatSearch(SCheatData* d)
void S9xSearchForChange(SCheatData* d, S9xCheatComparisonType cmp,
S9xCheatDataSize size, bool is_signed, bool update)
{
- int l;
+ int32_t l;
switch (size)
{
@@ -171,7 +171,7 @@ void S9xSearchForChange(SCheatData* d, S9xCheatComparisonType cmp,
break;
}
- int i;
+ int32_t i;
if (is_signed)
{
for (i = 0; i < 0x20000 - l; i++)
@@ -254,7 +254,7 @@ void S9xSearchForValue(SCheatData* d, S9xCheatComparisonType cmp,
S9xCheatDataSize size, uint32_t value,
bool is_signed, bool update)
{
- int l;
+ int32_t l;
switch (size)
{
@@ -273,7 +273,7 @@ void S9xSearchForValue(SCheatData* d, S9xCheatComparisonType cmp,
break;
}
- int i;
+ int32_t i;
if (is_signed)
{
@@ -355,7 +355,7 @@ void S9xSearchForValue(SCheatData* d, S9xCheatComparisonType cmp,
void S9xOutputCheatSearchResults(SCheatData* d)
{
- int i;
+ int32_t i;
for (i = 0; i < 0x20000; i++)
{
if (TEST_BIT(d->WRAM_BITS, i))
diff --git a/source/cheats2.c b/source/cheats2.c
index 4ca6b1d..dd4033f 100644
--- a/source/cheats2.c
+++ b/source/cheats2.c
@@ -81,7 +81,7 @@ void S9xRemoveCheat(uint32_t which1)
{
uint32_t address = Cheat.c [which1].address;
- int block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK;
+ int32_t block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK;
uint8_t* ptr = Memory.Map [block];
if (ptr >= (uint8_t*) MAP_LAST)
@@ -100,7 +100,7 @@ void S9xApplyCheat(uint32_t which1)
if (!Cheat.c [which1].saved)
Cheat.c [which1].saved_byte = S9xGetByte(address);
- int block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK;
+ int32_t block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK;
uint8_t* ptr = Memory.Map [block];
if (ptr >= (uint8_t*) MAP_LAST)
diff --git a/source/clip.c b/source/clip.c
index 7931101..1a52bea 100644
--- a/source/clip.c
+++ b/source/clip.c
@@ -23,7 +23,7 @@ struct Band
R.Left = MAX(A.Left, B.Left); \
R.Right = MIN(A.Right, B.Right);}
-static int IntCompare(const void* d1, const void* d2)
+static int32_t IntCompare(const void* d1, const void* d2)
{
if (*(uint32_t*) d1 > *(uint32_t*) d2)
return (1);
@@ -32,7 +32,7 @@ static int IntCompare(const void* d1, const void* d2)
return (0);
}
-static int BandCompare(const void* d1, const void* d2)
+static int32_t BandCompare(const void* d1, const void* d2)
{
if (((struct Band*) d1)->Left > ((struct Band*) d2)->Left)
return (1);
@@ -44,7 +44,7 @@ static int BandCompare(const void* d1, const void* d2)
void ComputeClipWindows()
{
struct ClipData* pClip = &IPPU.Clip [0];
- int c, w, i;
+ int32_t c, w, i;
// Loop around the main screen then the sub-screen.
for (c = 0; c < 2; c++, pClip++)
@@ -81,7 +81,7 @@ void ComputeClipWindows()
{
// The sub-screen is switched off, completely
// clip everything.
- int i;
+ int32_t i;
for (i = 0; i < 6; i++)
{
IPPU.Clip [1].Count [i] = 1;
@@ -95,578 +95,566 @@ void ComputeClipWindows()
}
}
+ if (w == 5 || pClip->Count [5] ||
+ (Memory.FillRAM [0x212c + c] & Memory.FillRAM [0x212e + c] & (1 << w)))
{
- if (w == 5 || pClip->Count [5] ||
+ struct Band Win1[3];
+ struct Band Win2[3];
+ uint32_t Window1Enabled = 0;
+ uint32_t Window2Enabled = 0;
+ bool invert = (w == 5 &&
+ ((c == 1 && (Memory.FillRAM [0x2130] & 0x30) == 0x10) ||
+ (c == 0 && (Memory.FillRAM [0x2130] & 0xc0) == 0x40)));
+
+ if (w == 5 ||
(Memory.FillRAM [0x212c + c] & Memory.FillRAM [0x212e + c] & (1 << w)))
{
- struct Band Win1[3];
- struct Band Win2[3];
- uint32_t Window1Enabled = 0;
- uint32_t Window2Enabled = 0;
- bool invert = (w == 5 &&
- ((c == 1 && (Memory.FillRAM [0x2130] & 0x30) == 0x10) ||
- (c == 0 && (Memory.FillRAM [0x2130] & 0xc0) == 0x40)));
-
- if (w == 5 ||
- (Memory.FillRAM [0x212c + c] & Memory.FillRAM [0x212e + c] & (1 << w)))
+ if (PPU.ClipWindow1Enable [w])
{
- if (PPU.ClipWindow1Enable [w])
+ if (!PPU.ClipWindow1Inside [w])
{
- if (!PPU.ClipWindow1Inside [w])
- {
- Win1[Window1Enabled].Left = PPU.Window1Left;
- Win1[Window1Enabled++].Right = PPU.Window1Right + 1;
- }
- else
+ Win1[Window1Enabled].Left = PPU.Window1Left;
+ Win1[Window1Enabled++].Right = PPU.Window1Right + 1;
+ }
+ else
+ {
+ if (PPU.Window1Left <= PPU.Window1Right)
{
- if (PPU.Window1Left <= PPU.Window1Right)
+ if (PPU.Window1Left > 0)
{
- if (PPU.Window1Left > 0)
- {
- Win1[Window1Enabled].Left = 0;
- Win1[Window1Enabled++].Right = PPU.Window1Left;
- }
- if (PPU.Window1Right < 255)
- {
- Win1[Window1Enabled].Left = PPU.Window1Right + 1;
- Win1[Window1Enabled++].Right = 256;
- }
- if (Window1Enabled == 0)
- {
- Win1[Window1Enabled].Left = 1;
- Win1[Window1Enabled++].Right = 0;
- }
+ Win1[Window1Enabled].Left = 0;
+ Win1[Window1Enabled++].Right = PPU.Window1Left;
}
- else
+ if (PPU.Window1Right < 255)
{
- // 'outside' a window with no range -
- // appears to be the whole screen.
- Win1[Window1Enabled].Left = 0;
+ Win1[Window1Enabled].Left = PPU.Window1Right + 1;
Win1[Window1Enabled++].Right = 256;
}
+ if (Window1Enabled == 0)
+ {
+ Win1[Window1Enabled].Left = 1;
+ Win1[Window1Enabled++].Right = 0;
+ }
}
- }
- if (PPU.ClipWindow2Enable [w])
- {
- if (!PPU.ClipWindow2Inside [w])
+ else
{
- Win2[Window2Enabled].Left = PPU.Window2Left;
- Win2[Window2Enabled++].Right = PPU.Window2Right + 1;
+ // 'outside' a window with no range -
+ // appears to be the whole screen.
+ Win1[Window1Enabled].Left = 0;
+ Win1[Window1Enabled++].Right = 256;
}
- else
+ }
+ }
+ if (PPU.ClipWindow2Enable [w])
+ {
+ if (!PPU.ClipWindow2Inside [w])
+ {
+ Win2[Window2Enabled].Left = PPU.Window2Left;
+ Win2[Window2Enabled++].Right = PPU.Window2Right + 1;
+ }
+ else
+ {
+ if (PPU.Window2Left <= PPU.Window2Right)
{
- if (PPU.Window2Left <= PPU.Window2Right)
+ if (PPU.Window2Left > 0)
{
- if (PPU.Window2Left > 0)
- {
- Win2[Window2Enabled].Left = 0;
- Win2[Window2Enabled++].Right = PPU.Window2Left;
- }
- if (PPU.Window2Right < 255)
- {
- Win2[Window2Enabled].Left = PPU.Window2Right + 1;
- Win2[Window2Enabled++].Right = 256;
- }
- if (Window2Enabled == 0)
- {
- Win2[Window2Enabled].Left = 1;
- Win2[Window2Enabled++].Right = 0;
- }
+ Win2[Window2Enabled].Left = 0;
+ Win2[Window2Enabled++].Right = PPU.Window2Left;
}
- else
+ if (PPU.Window2Right < 255)
{
- Win2[Window2Enabled].Left = 0;
+ Win2[Window2Enabled].Left = PPU.Window2Right + 1;
Win2[Window2Enabled++].Right = 256;
}
+ if (Window2Enabled == 0)
+ {
+ Win2[Window2Enabled].Left = 1;
+ Win2[Window2Enabled++].Right = 0;
+ }
+ }
+ else
+ {
+ Win2[Window2Enabled].Left = 0;
+ Win2[Window2Enabled++].Right = 256;
}
}
}
- if (Window1Enabled && Window2Enabled)
+ }
+ if (Window1Enabled && Window2Enabled)
+ {
+ // Overlap logic
+ //
+ // Each window will be in one of three states:
+ // 1. <no range> (Left > Right. One band)
+ // 2. | ---------------- | (Left >= 0, Right <= 255, Left <= Right. One band)
+ // 3. |------------ ----------| (Left1 == 0, Right1 < Left2; Left2 > Right1, Right2 == 255. Two bands)
+ struct Band Bands [6];
+ int32_t B = 0;
+ switch (PPU.ClipWindowOverlapLogic [w] ^ 1)
{
- // Overlap logic
- //
- // Each window will be in one of three states:
- // 1. <no range> (Left > Right. One band)
- // 2. | ---------------- | (Left >= 0, Right <= 255, Left <= Right. One band)
- // 3. |------------ ----------| (Left1 == 0, Right1 < Left2; Left2 > Right1, Right2 == 255. Two bands)
-
- struct Band Bands [6];
- int B = 0;
- switch (PPU.ClipWindowOverlapLogic [w] ^ 1)
+ case CLIP_OR:
+ if (Window1Enabled == 1)
{
- case CLIP_OR:
- if (Window1Enabled == 1)
+ if (BAND_EMPTY(Win1[0]))
{
- if (BAND_EMPTY(Win1[0]))
- {
- B = Window2Enabled;
- // memmove converted: Different stack allocations [Neb]
- memcpy(Bands, Win2,
- sizeof(Win2[0]) * Window2Enabled);
- }
- else
+ B = Window2Enabled;
+ // memmove converted: Different stack allocations [Neb]
+ memcpy(Bands, Win2, sizeof(Win2[0]) * Window2Enabled);
+ }
+ else
+ {
+ if (Window2Enabled == 1)
{
- if (Window2Enabled == 1)
- {
- if (BAND_EMPTY(Win2[0]))
- Bands[B++] = Win1[0];
- else
- {
- if (BANDS_INTERSECT(Win1[0], Win2[0]))
- {
- OR_BANDS(Bands[0], Win1[0], Win2[0])
- B = 1;
- }
- else
- {
- Bands[B++] = Win1[0];
- Bands[B++] = Win2[0];
- }
- }
- }
+ if (BAND_EMPTY(Win2[0]))
+ Bands[B++] = Win1[0];
else
{
if (BANDS_INTERSECT(Win1[0], Win2[0]))
{
OR_BANDS(Bands[0], Win1[0], Win2[0])
- if (BANDS_INTERSECT(Win1[0], Win2[1]))
- OR_BANDS(Bands[1], Win1[0], Win2[1])
- else
- Bands[1] = Win2[1];
B = 1;
- if (BANDS_INTERSECT(Bands[0], Bands[1]))
- OR_BANDS(Bands[0], Bands[0], Bands[1])
- else
- B = 2;
- }
- else if (BANDS_INTERSECT(Win1[0], Win2[1]))
- {
- Bands[B++] = Win2[0];
- OR_BANDS(Bands[B], Win1[0], Win2[1]);
- B++;
}
else
{
- Bands[0] = Win2[0];
- Bands[1] = Win1[0];
- Bands[2] = Win2[1];
- B = 3;
+ Bands[B++] = Win1[0];
+ Bands[B++] = Win2[0];
}
}
}
- }
- else if (Window2Enabled == 1)
- {
- if (BAND_EMPTY(Win2[0]))
- {
- // Window 2 defines an empty range - just
- // use window 1 as the clipping (which
- // could also be empty).
- B = Window1Enabled;
- // memmove converted: Different stack allocations [Neb]
- memcpy(Bands, Win1,
- sizeof(Win1[0]) * Window1Enabled);
- }
else
{
- // Window 1 has two bands and Window 2 has one.
- // Neither is an empty region.
- if (BANDS_INTERSECT(Win2[0], Win1[0]))
+ if (BANDS_INTERSECT(Win1[0], Win2[0]))
{
- OR_BANDS(Bands[0], Win2[0], Win1[0])
- if (BANDS_INTERSECT(Win2[0], Win1[1]))
- OR_BANDS(Bands[1], Win2[0], Win1[1])
- else
- Bands[1] = Win1[1];
+ OR_BANDS(Bands[0], Win1[0], Win2[0])
+ if (BANDS_INTERSECT(Win1[0], Win2[1]))
+ OR_BANDS(Bands[1], Win1[0], Win2[1])
+ else
+ Bands[1] = Win2[1];
B = 1;
if (BANDS_INTERSECT(Bands[0], Bands[1]))
OR_BANDS(Bands[0], Bands[0], Bands[1])
- else
- B = 2;
+ else
+ B = 2;
}
- else if (BANDS_INTERSECT(Win2[0], Win1[1]))
+ else if (BANDS_INTERSECT(Win1[0], Win2[1]))
{
- Bands[B++] = Win1[0];
- OR_BANDS(Bands[B], Win2[0], Win1[1]);
+ Bands[B++] = Win2[0];
+ OR_BANDS(Bands[B], Win1[0], Win2[1]);
B++;
}
else
{
- Bands[0] = Win1[0];
- Bands[1] = Win2[0];
- Bands[2] = Win1[1];
+ Bands[0] = Win2[0];
+ Bands[1] = Win1[0];
+ Bands[2] = Win2[1];
B = 3;
}
}
}
- else
+ }
+ else if (Window2Enabled == 1)
+ {
+ if (BAND_EMPTY(Win2[0]))
{
- // Both windows have two bands
- OR_BANDS(Bands[0], Win1[0], Win2[0]);
- OR_BANDS(Bands[1], Win1[1], Win2[1]);
- B = 1;
- if (BANDS_INTERSECT(Bands[0], Bands[1]))
- OR_BANDS(Bands[0], Bands[0], Bands[1])
- else
- B = 2;
+ // Window 2 defines an empty range - just
+ // use window 1 as the clipping (which
+ // could also be empty).
+ B = Window1Enabled;
+ // memmove converted: Different stack allocations [Neb]
+ memcpy(Bands, Win1, sizeof(Win1[0]) * Window1Enabled);
}
- break;
-
- case CLIP_AND:
- if (Window1Enabled == 1)
+ else
{
- // Window 1 has one band
- if (BAND_EMPTY(Win1[0]))
- Bands [B++] = Win1[0];
- else if (Window2Enabled == 1)
+ // Window 1 has two bands and Window 2 has one.
+ // Neither is an empty region.
+ if (BANDS_INTERSECT(Win2[0], Win1[0]))
{
- if (BAND_EMPTY(Win2[0]))
- Bands [B++] = Win2[0];
+ OR_BANDS(Bands[0], Win2[0], Win1[0])
+ if (BANDS_INTERSECT(Win2[0], Win1[1]))
+ OR_BANDS(Bands[1], Win2[0], Win1[1])
else
- {
- AND_BANDS(Bands[0], Win1[0], Win2[0]);
- B = 1;
- }
+ Bands[1] = Win1[1];
+ B = 1;
+ if (BANDS_INTERSECT(Bands[0], Bands[1]))
+ OR_BANDS(Bands[0], Bands[0], Bands[1])
+ else
+ B = 2;
+ }
+ else if (BANDS_INTERSECT(Win2[0], Win1[1]))
+ {
+ Bands[B++] = Win1[0];
+ OR_BANDS(Bands[B], Win2[0], Win1[1]);
+ B++;
}
else
{
- AND_BANDS(Bands[0], Win1[0], Win2[0]);
- AND_BANDS(Bands[1], Win1[0], Win2[1]);
- B = 2;
+ Bands[0] = Win1[0];
+ Bands[1] = Win2[0];
+ Bands[2] = Win1[1];
+ B = 3;
}
}
+ }
+ else
+ {
+ // Both windows have two bands
+ OR_BANDS(Bands[0], Win1[0], Win2[0]);
+ OR_BANDS(Bands[1], Win1[1], Win2[1]);
+ B = 1;
+ if (BANDS_INTERSECT(Bands[0], Bands[1]))
+ OR_BANDS(Bands[0], Bands[0], Bands[1])
+ else
+ B = 2;
+ }
+ break;
+ case CLIP_AND:
+ if (Window1Enabled == 1)
+ {
+ // Window 1 has one band
+ if (BAND_EMPTY(Win1[0]))
+ Bands [B++] = Win1[0];
else if (Window2Enabled == 1)
{
if (BAND_EMPTY(Win2[0]))
- Bands[B++] = Win2[0];
+ Bands [B++] = Win2[0];
else
{
- // Window 1 has two bands.
AND_BANDS(Bands[0], Win1[0], Win2[0]);
- AND_BANDS(Bands[1], Win1[1], Win2[0]);
- B = 2;
+ B = 1;
}
}
else
{
- // Both windows have two bands.
AND_BANDS(Bands[0], Win1[0], Win2[0]);
- AND_BANDS(Bands[1], Win1[1], Win2[1]);
+ AND_BANDS(Bands[1], Win1[0], Win2[1]);
B = 2;
- if (BANDS_INTERSECT(Win1[0], Win2[1]))
- {
- AND_BANDS(Bands[2], Win1[0], Win2[1]);
- B = 3;
- }
- else if (BANDS_INTERSECT(Win1[1], Win2[0]))
- {
- AND_BANDS(Bands[2], Win1[1], Win2[0]);
- B = 3;
- }
}
- break;
- case CLIP_XNOR:
- invert = !invert;
+ }
+ else if (Window2Enabled == 1)
+ {
+ if (BAND_EMPTY(Win2[0]))
+ Bands[B++] = Win2[0];
+ else
+ {
+ // Window 1 has two bands.
+ AND_BANDS(Bands[0], Win1[0], Win2[0]);
+ AND_BANDS(Bands[1], Win1[1], Win2[0]);
+ B = 2;
+ }
+ }
+ else
+ {
+ // Both windows have two bands.
+ AND_BANDS(Bands[0], Win1[0], Win2[0]);
+ AND_BANDS(Bands[1], Win1[1], Win2[1]);
+ B = 2;
+ if (BANDS_INTERSECT(Win1[0], Win2[1]))
+ {
+ AND_BANDS(Bands[2], Win1[0], Win2[1]);
+ B = 3;
+ }
+ else if (BANDS_INTERSECT(Win1[1], Win2[0]))
+ {
+ AND_BANDS(Bands[2], Win1[1], Win2[0]);
+ B = 3;
+ }
+ }
+ break;
+ case CLIP_XNOR:
+ invert = !invert;
// Fall...
+ case CLIP_XOR:
+ if (Window1Enabled == 1 && BAND_EMPTY(Win1[0]))
+ {
+ B = Window2Enabled;
+ // memmove converted: Different stack allocations [Neb]
+ memcpy(Bands, Win2, sizeof(Win2[0]) * Window2Enabled);
+ }
+ else if (Window2Enabled == 1 && BAND_EMPTY(Win2[0]))
+ {
+ B = Window1Enabled;
+ // memmove converted: Different stack allocations [Neb]
+ memcpy(Bands, Win1, sizeof(Win1[0]) * Window1Enabled);
+ }
+ else
+ {
+ uint32_t p = 0;
+ uint32_t points [10];
+ uint32_t i;
- case CLIP_XOR:
- if (Window1Enabled == 1 && BAND_EMPTY(Win1[0]))
+ invert = !invert;
+ // Build an array of points (window edges)
+ points [p++] = 0;
+ for (i = 0; i < Window1Enabled; i++)
{
- B = Window2Enabled;
- // memmove converted: Different stack allocations [Neb]
- memcpy(Bands, Win2,
- sizeof(Win2[0]) * Window2Enabled);
+ points [p++] = Win1[i].Left;
+ points [p++] = Win1[i].Right;
}
- else if (Window2Enabled == 1 && BAND_EMPTY(Win2[0]))
+ for (i = 0; i < Window2Enabled; i++)
{
- B = Window1Enabled;
- // memmove converted: Different stack allocations [Neb]
- memcpy(Bands, Win1,
- sizeof(Win1[0]) * Window1Enabled);
+ points [p++] = Win2[i].Left;
+ points [p++] = Win2[i].Right;
+ }
+ points [p++] = 256;
+ // Sort them
+ qsort((void*) points, p, sizeof(points [0]), IntCompare);
+ for (i = 0; i < p; i += 2)
+ {
+ if (points [i] == points [i + 1])
+ continue;
+ Bands [B].Left = points [i];
+ while (i + 2 < p && points [i + 1] == points [i + 2])
+ i += 2;
+ Bands [B++].Right = points [i + 1];
+ }
+ }
+ break;
+ }
+ if (invert)
+ {
+ int32_t b;
+ int32_t j = 0;
+ int32_t empty_band_count = 0;
+
+ // First remove all empty bands from the list.
+ for (b = 0; b < B; b++)
+ {
+ if (!BAND_EMPTY(Bands[b]))
+ {
+ if (b != j)
+ Bands[j] = Bands[b];
+ j++;
}
else
+ empty_band_count++;
+ }
+
+ if (j > 0)
+ {
+ if (j == 1)
{
- uint32_t p = 0;
- uint32_t points [10];
- uint32_t i;
+ j = 0;
+ // Easy case to deal with, so special case it.
- invert = !invert;
- // Build an array of points (window edges)
- points [p++] = 0;
- for (i = 0; i < Window1Enabled; i++)
+ if (Bands[0].Left > 0)
{
- points [p++] = Win1[i].Left;
- points [p++] = Win1[i].Right;
+ pClip->Left[j][w] = 0;
+ pClip->Right[j++][w] = Bands[0].Left + 1;
}
- for (i = 0; i < Window2Enabled; i++)
+ if (Bands[0].Right < 256)
{
- points [p++] = Win2[i].Left;
- points [p++] = Win2[i].Right;
+ pClip->Left[j][w] = Bands[0].Right;
+ pClip->Right[j++][w] = 256;
}
- points [p++] = 256;
- // Sort them
- qsort((void*) points, p, sizeof(points [0]),
- IntCompare);
- for (i = 0; i < p; i += 2)
+ if (j == 0)
{
- if (points [i] == points [i + 1])
- continue;
- Bands [B].Left = points [i];
- while (i + 2 < p &&
- points [i + 1] == points [i + 2])
- i += 2;
- Bands [B++].Right = points [i + 1];
+ pClip->Left[j][w] = 1;
+ pClip->Right[j++][w] = 0;
}
}
- break;
- }
- if (invert)
- {
- int b;
- int j = 0;
- int empty_band_count = 0;
-
- // First remove all empty bands from the list.
- for (b = 0; b < B; b++)
+ else
{
- if (!BAND_EMPTY(Bands[b]))
- {
- if (b != j)
- Bands[j] = Bands[b];
- j++;
- }
- else
- empty_band_count++;
- }
+ // Now sort the bands into order
+ B = j;
+ qsort((void*) Bands, B, sizeof(Bands [0]), BandCompare);
- if (j > 0)
- {
- if (j == 1)
+ // Now invert the area the bands cover
+ j = 0;
+ for (b = 0; b < B; b++)
{
- j = 0;
- // Easy case to deal with, so special case it.
-
- if (Bands[0].Left > 0)
+ if (b == 0 && Bands[b].Left > 0)
{
pClip->Left[j][w] = 0;
- pClip->Right[j++][w] = Bands[0].Left + 1;
+ pClip->Right[j++][w] = Bands[b].Left + 1;
}
- if (Bands[0].Right < 256)
+ else if (b == B - 1 && Bands[b].Right < 256)
{
- pClip->Left[j][w] = Bands[0].Right;
+ pClip->Left[j][w] = Bands[b].Right;
pClip->Right[j++][w] = 256;
}
- if (j == 0)
- {
- pClip->Left[j][w] = 1;
- pClip->Right[j++][w] = 0;
- }
- }
- else
- {
- // Now sort the bands into order
- B = j;
- qsort((void*) Bands, B,
- sizeof(Bands [0]), BandCompare);
-
- // Now invert the area the bands cover
- j = 0;
- for (b = 0; b < B; b++)
+ if (b < B - 1)
{
- if (b == 0 && Bands[b].Left > 0)
- {
- pClip->Left[j][w] = 0;
- pClip->Right[j++][w] = Bands[b].Left + 1;
- }
- else if (b == B - 1 && Bands[b].Right < 256)
- {
- pClip->Left[j][w] = Bands[b].Right;
- pClip->Right[j++][w] = 256;
- }
- if (b < B - 1)
- {
- pClip->Left[j][w] = Bands[b].Right;
- pClip->Right[j++][w] = Bands[b + 1].Left + 1;
- }
+ pClip->Left[j][w] = Bands[b].Right;
+ pClip->Right[j++][w] = Bands[b + 1].Left + 1;
}
}
}
- else
- {
- // Inverting a window that consisted of only
- // empty bands is the whole width of the screen.
- // Needed for Mario Kart's rear-view mirror display.
- if (empty_band_count)
- {
- pClip->Left[j][w] = 0;
- pClip->Right[j][w] = 256;
- j++;
- }
- }
- pClip->Count[w] = j;
}
else
{
- int j;
- for (j = 0; j < B; j++)
+ // Inverting a window that consisted of only
+ // empty bands is the whole width of the screen.
+ // Needed for Mario Kart's rear-view mirror display.
+ if (empty_band_count)
{
- pClip->Left[j][w] = Bands[j].Left;
- pClip->Right[j][w] = Bands[j].Right;
+ pClip->Left[j][w] = 0;
+ pClip->Right[j][w] = 256;
+ j++;
}
- pClip->Count [w] = B;
}
+ pClip->Count[w] = j;
}
else
{
- // Only one window enabled so no need to perform
- // complex overlap logic...
+ int32_t j;
+ for (j = 0; j < B; j++)
+ {
+ pClip->Left[j][w] = Bands[j].Left;
+ pClip->Right[j][w] = Bands[j].Right;
+ }
+ pClip->Count [w] = B;
+ }
+ }
+ else
+ {
+ // Only one window enabled so no need to perform
+ // complex overlap logic...
- if (Window1Enabled)
+ if (Window1Enabled)
+ {
+ if (invert)
{
- if (invert)
- {
- int j = 0;
+ int32_t j = 0;
- if (Window1Enabled == 1)
+ if (Window1Enabled == 1)
+ {
+ if (Win1[0].Left <= Win1[0].Right)
{
- if (Win1[0].Left <= Win1[0].Right)
+ if (Win1[0].Left > 0)
{
- if (Win1[0].Left > 0)
- {
- pClip->Left[j][w] = 0;
- pClip->Right[j++][w] = Win1[0].Left;
- }
- if (Win1[0].Right < 256)
- {
- pClip->Left[j][w] = Win1[0].Right;
- pClip->Right[j++][w] = 256;
- }
- if (j == 0)
- {
- pClip->Left[j][w] = 1;
- pClip->Right[j++][w] = 0;
- }
+ pClip->Left[j][w] = 0;
+ pClip->Right[j++][w] = Win1[0].Left;
}
- else
+ if (Win1[0].Right < 256)
{
- pClip->Left[j][w] = 0;
+ pClip->Left[j][w] = Win1[0].Right;
pClip->Right[j++][w] = 256;
}
+ if (j == 0)
+ {
+ pClip->Left[j][w] = 1;
+ pClip->Right[j++][w] = 0;
+ }
}
else
{
- pClip->Left [j][w] = Win1[0].Right;
- pClip->Right[j++][w] = Win1[1].Left;
+ pClip->Left[j][w] = 0;
+ pClip->Right[j++][w] = 256;
}
- pClip->Count [w] = j;
}
else
{
- uint32_t j;
- for (j = 0; j < Window1Enabled; j++)
- {
- pClip->Left [j][w] = Win1[j].Left;
- pClip->Right [j][w] = Win1[j].Right;
- }
- pClip->Count [w] = Window1Enabled;
+ pClip->Left [j][w] = Win1[0].Right;
+ pClip->Right[j++][w] = Win1[1].Left;
}
+ pClip->Count [w] = j;
}
- else if (Window2Enabled)
+ else
{
- if (invert)
+ uint32_t j;
+ for (j = 0; j < Window1Enabled; j++)
{
- int j = 0;
- if (Window2Enabled == 1)
+ pClip->Left [j][w] = Win1[j].Left;
+ pClip->Right [j][w] = Win1[j].Right;
+ }
+ pClip->Count [w] = Window1Enabled;
+ }
+ }
+ else if (Window2Enabled)
+ {
+ if (invert)
+ {
+ int32_t j = 0;
+ if (Window2Enabled == 1)
+ {
+ if (Win2[0].Left <= Win2[0].Right)
{
- if (Win2[0].Left <= Win2[0].Right)
+ if (Win2[0].Left > 0)
{
- if (Win2[0].Left > 0)
- {
- pClip->Left[j][w] = 0;
- pClip->Right[j++][w] = Win2[0].Left;
- }
- if (Win2[0].Right < 256)
- {
- pClip->Left[j][w] = Win2[0].Right;
- pClip->Right[j++][w] = 256;
- }
- if (j == 0)
- {
- pClip->Left[j][w] = 1;
- pClip->Right[j++][w] = 0;
- }
+ pClip->Left[j][w] = 0;
+ pClip->Right[j++][w] = Win2[0].Left;
}
- else
+ if (Win2[0].Right < 256)
{
- pClip->Left[j][w] = 0;
+ pClip->Left[j][w] = Win2[0].Right;
pClip->Right[j++][w] = 256;
}
+ if (j == 0)
+ {
+ pClip->Left[j][w] = 1;
+ pClip->Right[j++][w] = 0;
+ }
}
else
{
- pClip->Left [j][w] = Win2[0].Right;
- pClip->Right[j++][w] = Win2[1].Left + 1;
+ pClip->Left[j][w] = 0;
+ pClip->Right[j++][w] = 256;
}
- pClip->Count [w] = j;
}
else
{
- uint32_t j;
- for (j = 0; j < Window2Enabled; j++)
- {
- pClip->Left [j][w] = Win2[j].Left;
- pClip->Right [j][w] = Win2[j].Right;
- }
- pClip->Count [w] = Window2Enabled;
+ pClip->Left [j][w] = Win2[0].Right;
+ pClip->Right[j++][w] = Win2[1].Left + 1;
+ }
+ pClip->Count [w] = j;
+ }
+ else
+ {
+ uint32_t j;
+ for (j = 0; j < Window2Enabled; j++)
+ {
+ pClip->Left [j][w] = Win2[j].Left;
+ pClip->Right [j][w] = Win2[j].Right;
}
+ pClip->Count [w] = Window2Enabled;
}
}
+ }
- if (w != 5 && pClip->Count [5])
+ if (w != 5 && pClip->Count [5])
+ {
+ // Colour window enabled. Set the
+ // clip windows for all remaining backgrounds to be
+ // the same as the colour window.
+ if (pClip->Count [w] == 0)
{
- // Colour window enabled. Set the
- // clip windows for all remaining backgrounds to be
- // the same as the colour window.
- if (pClip->Count [w] == 0)
+ uint32_t i;
+ pClip->Count [w] = pClip->Count [5];
+ for (i = 0; i < pClip->Count [w]; i++)
{
- uint32_t i;
- pClip->Count [w] = pClip->Count [5];
- for (i = 0; i < pClip->Count [w]; i++)
- {
- pClip->Left [i][w] = pClip->Left [i][5];
- pClip->Right [i][w] = pClip->Right [i][5];
- }
+ pClip->Left [i][w] = pClip->Left [i][5];
+ pClip->Right [i][w] = pClip->Right [i][5];
}
- else
+ }
+ else
+ {
+ // Intersect the colour window with the bg's
+ // own clip window.
+ uint32_t i;
+ for (i = 0; i < pClip->Count [w]; i++)
{
- // Intersect the colour window with the bg's
- // own clip window.
- uint32_t i;
- for (i = 0; i < pClip->Count [w]; i++)
+ uint32_t j;
+ for (j = 0; j < pClip->Count [5]; j++)
{
- uint32_t j;
- for (j = 0; j < pClip->Count [5]; j++)
+ if ((pClip->Left[i][w] >= pClip->Left[j][5]
+ && pClip->Left[i][w] < pClip->Right[j][5])
+ || (pClip->Left[j][5] >= pClip->Left[i][w]
+ && pClip->Left[j][5] < pClip->Right[i][w]))
{
- if ((pClip->Left[i][w] >= pClip->Left[j][5]
- && pClip->Left[i][w] < pClip->Right[j][5])
- || (pClip->Left[j][5] >= pClip->Left[i][w]
- && pClip->Left[j][5] < pClip->Right[i][w]))
- {
- // Found an intersection!
- pClip->Left[i][w] = MAX(pClip->Left[i][w], pClip->Left[j][5]);
- pClip->Right[i][w] = MIN(pClip->Right[i][w], pClip->Right[j][5]);
- goto Clip_ok;
- }
+ // Found an intersection!
+ pClip->Left[i][w] = MAX(pClip->Left[i][w], pClip->Left[j][5]);
+ pClip->Right[i][w] = MIN(pClip->Right[i][w], pClip->Right[j][5]);
+ goto Clip_ok;
}
- // no intersection, nullify it
- pClip->Left[i][w] = 1;
- pClip->Right[i][w] = 0;
-Clip_ok:;
}
+ // no intersection, nullify it
+ pClip->Left[i][w] = 1;
+ pClip->Right[i][w] = 0;
+Clip_ok:;
}
}
- } // if (w == 5 | ...
- } // if (!Settings.DisableGraphicWindows)
- } // for (int w...
- } // for (int c...
+ }
+ } // if (w == 5 || pClip->Count [5] ...
+ } // for (w...
+ } // for (c...
}
diff --git a/source/cpuaddr.h b/source/cpuaddr.h
index 6f5e930..3531686 100644
--- a/source/cpuaddr.h
+++ b/source/cpuaddr.h
@@ -13,18 +13,18 @@ typedef enum
} AccessMode;
// The type for a function that can run after the addressing mode is resolved:
-typedef void (*InternalOp)(long);
+typedef void (*InternalOp)(int32_t);
static void Immediate8(AccessMode a, InternalOp op)
{
- long Addr = ICPU.ShiftedPB + CPU.PC - CPU.PCBase;
+ int32_t Addr = ICPU.ShiftedPB + CPU.PC - CPU.PCBase;
CPU.PC++;
(*op)(Addr);
}
static void Immediate16(AccessMode a, InternalOp op)
{
- long Addr = ICPU.ShiftedPB + CPU.PC - CPU.PCBase;
+ int32_t Addr = ICPU.ShiftedPB + CPU.PC - CPU.PCBase;
CPU.PC += 2;
(*op)(Addr);
}
@@ -32,13 +32,13 @@ static void Immediate16(AccessMode a, InternalOp op)
static void Relative(AccessMode a, InternalOp op)
{
int8_t Int8 = *CPU.PC++;
- long Addr = ((intptr_t)(CPU.PC - CPU.PCBase) + Int8) & 0xffff;
+ int32_t Addr = ((int32_t)(CPU.PC - CPU.PCBase) + Int8) & 0xffff;
(*op)(Addr);
}
static void RelativeLong(AccessMode a, InternalOp op)
{
- long Addr;
+ int32_t Addr;
#ifdef FAST_LSB_WORD_ACCESS
Addr = *(uint16_t*) CPU.PC;
#else
@@ -52,7 +52,7 @@ static void RelativeLong(AccessMode a, InternalOp op)
static void AbsoluteIndexedIndirect(AccessMode a, InternalOp op)
{
- long Addr;
+ int32_t Addr;
#ifdef FAST_LSB_WORD_ACCESS
Addr = (ICPU.Registers.X.W + * (uint16_t*) CPU.PC) & 0xffff;
#else
@@ -67,7 +67,7 @@ static void AbsoluteIndexedIndirect(AccessMode a, InternalOp op)
static void AbsoluteIndirectLong(AccessMode a, InternalOp op)
{
- long Addr;
+ int32_t Addr;
#ifdef FAST_LSB_WORD_ACCESS
Addr = *(uint16_t*) CPU.PC;
#else
@@ -85,7 +85,7 @@ static void AbsoluteIndirectLong(AccessMode a, InternalOp op)
static void AbsoluteIndirect(AccessMode a, InternalOp op)
{
- long Addr;
+ int32_t Addr;
#ifdef FAST_LSB_WORD_ACCESS
Addr = *(uint16_t*) CPU.PC;
#else
@@ -102,7 +102,7 @@ static void AbsoluteIndirect(AccessMode a, InternalOp op)
static void Absolute(AccessMode a, InternalOp op)
{
- long Addr;
+ int32_t Addr;
#ifdef FAST_LSB_WORD_ACCESS
Addr = *(uint16_t*) CPU.PC + ICPU.ShiftedDB;
#else
@@ -115,11 +115,11 @@ static void Absolute(AccessMode a, InternalOp op)
static void AbsoluteLong(AccessMode a, InternalOp op)
{
- long Addr;
+ int32_t Addr;
#ifdef FAST_LSB_WORD_ACCESS
Addr = (*(uint32_t*) CPU.PC) & 0xffffff;
#elif defined FAST_ALIGNED_LSB_WORD_ACCESS
- if (((intptr_t) CPU.PC & 1) == 0)
+ if (((int32_t) CPU.PC & 1) == 0)
Addr = (*(uint16_t*) CPU.PC) + (*(CPU.PC + 2) << 16);
else
Addr = *CPU.PC + ((*(uint16_t*)(CPU.PC + 1)) << 8);
@@ -134,14 +134,14 @@ static void AbsoluteLong(AccessMode a, InternalOp op)
static void Direct(AccessMode a, InternalOp op)
{
if (a & READ) OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
(*op)(Addr);
}
static void DirectIndirectIndexed(AccessMode a, InternalOp op)
{
OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
Addr = S9xGetWord(Addr);
if (a & READ) OpenBus = (uint8_t)(Addr >> 8);
@@ -155,7 +155,7 @@ static void DirectIndirectIndexed(AccessMode a, InternalOp op)
static void DirectIndirectIndexedLong(AccessMode a, InternalOp op)
{
OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
if (a & READ)
Addr = S9xGetWord(Addr) + ((OpenBus = S9xGetByte(Addr + 2)) << 16) +
@@ -168,7 +168,7 @@ static void DirectIndirectIndexedLong(AccessMode a, InternalOp op)
static void DirectIndexedIndirect(AccessMode a, InternalOp op)
{
OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.D.W + ICPU.Registers.X.W) & 0xffff;
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.D.W + ICPU.Registers.X.W) & 0xffff;
Addr = S9xGetWord(Addr);
if (a & READ) OpenBus = (uint8_t)(Addr >> 8);
@@ -179,7 +179,7 @@ static void DirectIndexedIndirect(AccessMode a, InternalOp op)
static void DirectIndexedX(AccessMode a, InternalOp op)
{
if (a & READ) OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.D.W + ICPU.Registers.X.W);
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.D.W + ICPU.Registers.X.W);
Addr &= CheckEmulation() ? 0xff : 0xffff;
(*op)(Addr);
@@ -188,14 +188,14 @@ static void DirectIndexedX(AccessMode a, InternalOp op)
static void DirectIndexedY(AccessMode a, InternalOp op)
{
if (a & READ) OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.D.W + ICPU.Registers.Y.W);
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.D.W + ICPU.Registers.Y.W);
Addr &= CheckEmulation() ? 0xff : 0xffff;
(*op)(Addr);
}
static void AbsoluteIndexedX(AccessMode a, InternalOp op)
{
- long Addr;
+ int32_t Addr;
#ifdef FAST_LSB_WORD_ACCESS
Addr = ICPU.ShiftedDB + *(uint16_t*) CPU.PC + ICPU.Registers.X.W;
#else
@@ -211,7 +211,7 @@ static void AbsoluteIndexedX(AccessMode a, InternalOp op)
static void AbsoluteIndexedY(AccessMode a, InternalOp op)
{
- long Addr;
+ int32_t Addr;
#ifdef FAST_LSB_WORD_ACCESS
Addr = ICPU.ShiftedDB + *(uint16_t*) CPU.PC + ICPU.Registers.Y.W;
#else
@@ -227,16 +227,14 @@ static void AbsoluteIndexedY(AccessMode a, InternalOp op)
static void AbsoluteLongIndexedX(AccessMode a, InternalOp op)
{
- long Addr;
+ int32_t Addr;
#ifdef FAST_LSB_WORD_ACCESS
Addr = (*(uint32_t*) CPU.PC + ICPU.Registers.X.W) & 0xffffff;
#elif defined FAST_ALIGNED_LSB_WORD_ACCESS
- if (((intptr_t) CPU.PC & 1) == 0)
- Addr = ((*(uint16_t*) CPU.PC) + (*(CPU.PC + 2) << 16) + ICPU.Registers.X.W) &
- 0xFFFFFF;
+ if (((int32_t) CPU.PC & 1) == 0)
+ Addr = ((*(uint16_t*) CPU.PC) + (*(CPU.PC + 2) << 16) + ICPU.Registers.X.W) & 0xFFFFFF;
else
- Addr = (*CPU.PC + ((*(uint16_t*)(CPU.PC + 1)) << 8) + ICPU.Registers.X.W) &
- 0xFFFFFF;
+ Addr = (*CPU.PC + ((*(uint16_t*)(CPU.PC + 1)) << 8) + ICPU.Registers.X.W) & 0xFFFFFF;
#else
Addr = (*CPU.PC + (*(CPU.PC + 1) << 8) + (*(CPU.PC + 2) << 16) +
ICPU.Registers.X.W) & 0xffffff;
@@ -249,7 +247,7 @@ static void AbsoluteLongIndexedX(AccessMode a, InternalOp op)
static void DirectIndirect(AccessMode a, InternalOp op)
{
OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
Addr = S9xGetWord(Addr);
if (a & READ) OpenBus = (uint8_t)(Addr >> 8);
Addr += ICPU.ShiftedDB;
@@ -259,7 +257,7 @@ static void DirectIndirect(AccessMode a, InternalOp op)
static void DirectIndirectLong(AccessMode a, InternalOp op)
{
OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
if (a & READ)
Addr = S9xGetWord(Addr) + ((OpenBus = S9xGetByte(Addr + 2)) << 16);
else
@@ -270,14 +268,14 @@ static void DirectIndirectLong(AccessMode a, InternalOp op)
static void StackRelative(AccessMode a, InternalOp op)
{
if (a & READ) OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.S.W) & 0xffff;
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.S.W) & 0xffff;
(*op)(Addr);
}
static void StackRelativeIndirectIndexed(AccessMode a, InternalOp op)
{
OpenBus = *CPU.PC;
- long Addr = (*CPU.PC++ + ICPU.Registers.S.W) & 0xffff;
+ int32_t Addr = (*CPU.PC++ + ICPU.Registers.S.W) & 0xffff;
Addr = S9xGetWord(Addr);
if (a & READ) OpenBus = (uint8_t)(Addr >> 8);
Addr = (Addr + ICPU.ShiftedDB +
diff --git a/source/cpuexec.h b/source/cpuexec.h
index 5ecce18..c4342be 100644
--- a/source/cpuexec.h
+++ b/source/cpuexec.h
@@ -102,7 +102,7 @@ static inline void S9xFixCycles()
static inline void S9xReschedule()
{
uint8_t which;
- long max;
+ int32_t max;
if (CPU.WhichEvent == HBLANK_START_EVENT ||
CPU.WhichEvent == HTIMER_AFTER_EVENT)
@@ -117,12 +117,12 @@ static inline void S9xReschedule()
}
if (PPU.HTimerEnabled &&
- (long) PPU.HTimerPosition < max &&
- (long) PPU.HTimerPosition > CPU.NextEvent &&
+ (int32_t) PPU.HTimerPosition < max &&
+ (int32_t) PPU.HTimerPosition > CPU.NextEvent &&
(!PPU.VTimerEnabled ||
- (PPU.VTimerEnabled && CPU.V_Counter == PPU.IRQVBeamPos)))
+ (PPU.VTimerEnabled && CPU.V_Counter == PPU.IRQVBeamPos)))
{
- which = (long) PPU.HTimerPosition < Settings.HBlankStart ?
+ which = (int32_t) PPU.HTimerPosition < Settings.HBlankStart ?
HTIMER_BEFORE_EVENT : HTIMER_AFTER_EVENT;
max = PPU.HTimerPosition;
}
diff --git a/source/cpumacro.h b/source/cpumacro.h
index b9195ef..eb76b69 100644
--- a/source/cpumacro.h
+++ b/source/cpumacro.h
@@ -15,7 +15,7 @@ static void SetZN8(uint8_t Work)
ICPU._Negative = Work;
}
-static void ADC8(long Addr)
+static void ADC8(int32_t Addr)
{
uint8_t Work8 = S9xGetByte(Addr);
@@ -68,7 +68,7 @@ static void ADC8(long Addr)
SetZN8(ICPU.Registers.AL);
}
-static void ADC16(long Addr)
+static void ADC16(int32_t Addr)
{
uint16_t Work16 = S9xGetWord(Addr);
@@ -141,13 +141,13 @@ static void ADC16(long Addr)
SetZN16(ICPU.Registers.A.W);
}
-static void AND16(long Addr)
+static void AND16(int32_t Addr)
{
ICPU.Registers.A.W &= S9xGetWord(Addr);
SetZN16(ICPU.Registers.A.W);
}
-static void AND8(long Addr)
+static void AND8(int32_t Addr)
{
ICPU.Registers.AL &= S9xGetByte(Addr);
SetZN8(ICPU.Registers.AL);
@@ -173,7 +173,7 @@ static inline void A_ASL8()
SetZN8(ICPU.Registers.AL);
}
-static void ASL16(long Addr)
+static void ASL16(int32_t Addr)
{
uint16_t Work16 = S9xGetWord(Addr);
ICPU._Carry = (Work16 & 0x8000) != 0;
@@ -183,7 +183,7 @@ static void ASL16(long Addr)
SetZN16(Work16);
}
-static void ASL8(long Addr)
+static void ASL8(int32_t Addr)
{
uint8_t Work8 = S9xGetByte(Addr);
ICPU._Carry = (Work8 & 0x80) != 0;
@@ -192,7 +192,7 @@ static void ASL8(long Addr)
SetZN8(Work8);
}
-static void BIT16(long Addr)
+static void BIT16(int32_t Addr)
{
uint16_t Work16 = S9xGetWord(Addr);
ICPU._Overflow = (Work16 & 0x4000) != 0;
@@ -200,7 +200,7 @@ static void BIT16(long Addr)
ICPU._Zero = (Work16 & ICPU.Registers.A.W) != 0;
}
-static void BIT8(long Addr)
+static void BIT8(int32_t Addr)
{
uint8_t Work8 = S9xGetByte(Addr);
ICPU._Overflow = (Work8 & 0x40) != 0;
@@ -208,31 +208,28 @@ static void BIT8(long Addr)
ICPU._Zero = Work8 & ICPU.Registers.AL;
}
-static void CMP16(long Addr)
+static void CMP16(int32_t Addr)
{
- int32_t Int32 = (long) ICPU.Registers.A.W -
- (long) S9xGetWord(Addr);
+ int32_t Int32 = (int32_t) ICPU.Registers.A.W - (int32_t) S9xGetWord(Addr);
ICPU._Carry = Int32 >= 0;
SetZN16((uint16_t) Int32);
}
-static void CMP8(long Addr)
+static void CMP8(int32_t Addr)
{
- int16_t Int16 = (int16_t) ICPU.Registers.AL -
- (int16_t) S9xGetByte(Addr);
+ int16_t Int16 = (int16_t) ICPU.Registers.AL - (int16_t) S9xGetByte(Addr);
ICPU._Carry = Int16 >= 0;
SetZN8((uint8_t) Int16);
}
-static void CMX16(long Addr)
+static void CMX16(int32_t Addr)
{
- int32_t Int32 = (long) ICPU.Registers.X.W -
- (long) S9xGetWord(Addr);
+ int32_t Int32 = (int32_t) ICPU.Registers.X.W - (int32_t) S9xGetWord(Addr);
ICPU._Carry = Int32 >= 0;
SetZN16((uint16_t) Int32);
}
-static void CMX8(long Addr)
+static void CMX8(int32_t Addr)
{
int16_t Int16 = (int16_t) ICPU.Registers.XL -
(int16_t) S9xGetByte(Addr);
@@ -240,15 +237,14 @@ static void CMX8(long Addr)
SetZN8((uint8_t) Int16);
}
-static void CMY16(long Addr)
+static void CMY16(int32_t Addr)
{
- int32_t Int32 = (long) ICPU.Registers.Y.W -
- (long) S9xGetWord(Addr);
+ int32_t Int32 = (int32_t) ICPU.Registers.Y.W - (int32_t) S9xGetWord(Addr);
ICPU._Carry = Int32 >= 0;
SetZN16((uint16_t) Int32);
}
-static void CMY8(long Addr)
+static void CMY8(int32_t Addr)
{
int16_t Int16 = (int16_t) ICPU.Registers.YL -
(int16_t) S9xGetByte(Addr);
@@ -282,7 +278,7 @@ static inline void A_DEC8()
SetZN8(ICPU.Registers.AL);
}
-static void DEC16(long Addr)
+static void DEC16(int32_t Addr)
{
#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
@@ -294,7 +290,7 @@ static void DEC16(long Addr)
SetZN16(Work16);
}
-static void DEC8(long Addr)
+static void DEC8(int32_t Addr)
{
#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
@@ -305,13 +301,13 @@ static void DEC8(long Addr)
SetZN8(Work8);
}
-static void EOR16(long Addr)
+static void EOR16(int32_t Addr)
{
ICPU.Registers.A.W ^= S9xGetWord(Addr);
SetZN16(ICPU.Registers.A.W);
}
-static void EOR8(long Addr)
+static void EOR8(int32_t Addr)
{
ICPU.Registers.AL ^= S9xGetByte(Addr);
SetZN8(ICPU.Registers.AL);
@@ -343,7 +339,7 @@ static inline void A_INC8()
SetZN8(ICPU.Registers.AL);
}
-static void INC16(long Addr)
+static void INC16(int32_t Addr)
{
#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
@@ -355,7 +351,7 @@ static void INC16(long Addr)
SetZN16(Work16);
}
-static void INC8(long Addr)
+static void INC8(int32_t Addr)
{
#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
@@ -366,37 +362,37 @@ static void INC8(long Addr)
SetZN8(Work8);
}
-static void LDA16(long Addr)
+static void LDA16(int32_t Addr)
{
ICPU.Registers.A.W = S9xGetWord(Addr);
SetZN16(ICPU.Registers.A.W);
}
-static void LDA8(long Addr)
+static void LDA8(int32_t Addr)
{
ICPU.Registers.AL = S9xGetByte(Addr);
SetZN8(ICPU.Registers.AL);
}
-static void LDX16(long Addr)
+static void LDX16(int32_t Addr)
{
ICPU.Registers.X.W = S9xGetWord(Addr);
SetZN16(ICPU.Registers.X.W);
}
-static void LDX8(long Addr)
+static void LDX8(int32_t Addr)
{
ICPU.Registers.XL = S9xGetByte(Addr);
SetZN8(ICPU.Registers.XL);
}
-static void LDY16(long Addr)
+static void LDY16(int32_t Addr)
{
ICPU.Registers.Y.W = S9xGetWord(Addr);
SetZN16(ICPU.Registers.Y.W);
}
-static void LDY8(long Addr)
+static void LDY8(int32_t Addr)
{
ICPU.Registers.YL = S9xGetByte(Addr);
SetZN8(ICPU.Registers.YL);
@@ -422,7 +418,7 @@ static inline void A_LSR8()
SetZN8(ICPU.Registers.AL);
}
-static void LSR16(long Addr)
+static void LSR16(int32_t Addr)
{
uint16_t Work16 = S9xGetWord(Addr);
ICPU._Carry = Work16 & 1;
@@ -432,7 +428,7 @@ static void LSR16(long Addr)
SetZN16(Work16);
}
-static void LSR8(long Addr)
+static void LSR8(int32_t Addr)
{
uint8_t Work8 = S9xGetByte(Addr);
ICPU._Carry = Work8 & 1;
@@ -441,13 +437,13 @@ static void LSR8(long Addr)
SetZN8(Work8);
}
-static void ORA16(long Addr)
+static void ORA16(int32_t Addr)
{
ICPU.Registers.A.W |= S9xGetWord(Addr);
SetZN16(ICPU.Registers.A.W);
}
-static void ORA8(long Addr)
+static void ORA8(int32_t Addr)
{
ICPU.Registers.AL |= S9xGetByte(Addr);
SetZN8(ICPU.Registers.AL);
@@ -477,7 +473,7 @@ static inline void A_ROL8()
SetZN8((uint8_t) Work16);
}
-static void ROL16(long Addr)
+static void ROL16(int32_t Addr)
{
uint32_t Work32 = S9xGetWord(Addr);
Work32 <<= 1;
@@ -488,7 +484,7 @@ static void ROL16(long Addr)
SetZN16((uint16_t) Work32);
}
-static void ROL8(long Addr)
+static void ROL8(int32_t Addr)
{
uint16_t Work16 = S9xGetByte(Addr);
Work16 <<= 1;
@@ -504,7 +500,7 @@ static inline void A_ROR16()
CPU.Cycles += ONE_CYCLE;
#endif
uint32_t Work32 = ICPU.Registers.A.W;
- Work32 |= (int) CheckCarry() << 16;
+ Work32 |= (int32_t) CheckCarry() << 16;
ICPU._Carry = (uint8_t)(Work32 & 1);
Work32 >>= 1;
ICPU.Registers.A.W = (uint16_t) Work32;
@@ -523,10 +519,10 @@ static inline void A_ROR8()
SetZN8((uint8_t) Work16);
}
-static void ROR16(long Addr)
+static void ROR16(int32_t Addr)
{
uint32_t Work32 = S9xGetWord(Addr);
- Work32 |= (int) CheckCarry() << 16;
+ Work32 |= (int32_t) CheckCarry() << 16;
ICPU._Carry = (uint8_t)(Work32 & 1);
Work32 >>= 1;
S9xSetByte((Work32 >> 8) & 0x00FF, Addr + 1);
@@ -534,17 +530,17 @@ static void ROR16(long Addr)
SetZN16((uint16_t) Work32);
}
-static void ROR8(long Addr)
+static void ROR8(int32_t Addr)
{
uint16_t Work16 = S9xGetByte(Addr);
- Work16 |= (int) CheckCarry() << 8;
+ Work16 |= (int32_t) CheckCarry() << 8;
ICPU._Carry = (uint8_t)(Work16 & 1);
Work16 >>= 1;
S9xSetByte((uint8_t) Work16, Addr);
SetZN8((uint8_t) Work16);
}
-static void SBC16(long Addr)
+static void SBC16(int32_t Addr)
{
uint16_t Work16 = S9xGetWord(Addr);
@@ -597,9 +593,7 @@ static void SBC16(long Addr)
}
else
{
-
- int32_t Int32 = (long) ICPU.Registers.A.W - (long) Work16 +
- (long) CheckCarry() - 1;
+ int32_t Int32 = (int32_t) ICPU.Registers.A.W - (int32_t) Work16 + (int32_t) CheckCarry() - 1;
ICPU._Carry = Int32 >= 0;
@@ -613,7 +607,7 @@ static void SBC16(long Addr)
}
}
-static void SBC8(long Addr)
+static void SBC8(int32_t Addr)
{
uint8_t Work8 = S9xGetByte(Addr);
if (CheckDecimal())
@@ -663,47 +657,47 @@ static void SBC8(long Addr)
}
}
-static void STA16(long Addr)
+static void STA16(int32_t Addr)
{
S9xSetWord(ICPU.Registers.A.W, Addr);
}
-static void STA8(long Addr)
+static void STA8(int32_t Addr)
{
S9xSetByte(ICPU.Registers.AL, Addr);
}
-static void STX16(long Addr)
+static void STX16(int32_t Addr)
{
S9xSetWord(ICPU.Registers.X.W, Addr);
}
-static void STX8(long Addr)
+static void STX8(int32_t Addr)
{
S9xSetByte(ICPU.Registers.XL, Addr);
}
-static void STY16(long Addr)
+static void STY16(int32_t Addr)
{
S9xSetWord(ICPU.Registers.Y.W, Addr);
}
-static void STY8(long Addr)
+static void STY8(int32_t Addr)
{
S9xSetByte(ICPU.Registers.YL, Addr);
}
-static void STZ16(long Addr)
+static void STZ16(int32_t Addr)
{
S9xSetWord(0, Addr);
}
-static void STZ8(long Addr)
+static void STZ8(int32_t Addr)
{
S9xSetByte(0, Addr);
}
-static void TSB16(long Addr)
+static void TSB16(int32_t Addr)
{
uint16_t Work16 = S9xGetWord(Addr);
ICPU._Zero = (Work16 & ICPU.Registers.A.W) != 0;
@@ -712,7 +706,7 @@ static void TSB16(long Addr)
S9xSetByte(Work16 & 0xFF, Addr);
}
-static void TSB8(long Addr)
+static void TSB8(int32_t Addr)
{
uint8_t Work8 = S9xGetByte(Addr);
ICPU._Zero = Work8 & ICPU.Registers.AL;
@@ -720,7 +714,7 @@ static void TSB8(long Addr)
S9xSetByte(Work8, Addr);
}
-static void TRB16(long Addr)
+static void TRB16(int32_t Addr)
{
uint16_t Work16 = S9xGetWord(Addr);
ICPU._Zero = (Work16 & ICPU.Registers.A.W) != 0;
@@ -729,7 +723,7 @@ static void TRB16(long Addr)
S9xSetByte(Work16 & 0xFF, Addr);
}
-static void TRB8(long Addr)
+static void TRB8(int32_t Addr)
{
uint8_t Work8 = S9xGetByte(Addr);
ICPU._Zero = Work8 & ICPU.Registers.AL;
diff --git a/source/cpuops.c b/source/cpuops.c
index 3bf9a36..2325255 100644
--- a/source/cpuops.c
+++ b/source/cpuops.c
@@ -18,10 +18,10 @@
#include "cpumacro.h"
#include "apu.h"
-long OpAddress;
+int32_t OpAddress;
// For use with the opcodes whose functions here examine the OpAddress.
-static void OpAddressPassthrough(long Addr)
+static void OpAddressPassthrough(int32_t Addr)
{
OpAddress = Addr;
}
@@ -678,7 +678,7 @@ static void Op3CM0(void)
/* CMP *************************************************************************************** */
static void OpC9M1(void)
{
- int32_t Int32 = (int) ICPU.Registers.AL - (intptr_t) * CPU.PC++;
+ int32_t Int32 = (int32_t) ICPU.Registers.AL - (int32_t) *CPU.PC++;
ICPU._Carry = Int32 >= 0;
SetZN8((uint8_t) Int32);
#ifndef SA1_OPCODES
@@ -690,10 +690,9 @@ static void OpC9M0(void)
{
int32_t Int32;
#ifdef FAST_LSB_WORD_ACCESS
- Int32 = (long) ICPU.Registers.A.W - (long) * (uint16_t*) CPU.PC;
+ Int32 = (int32_t) ICPU.Registers.A.W - (int32_t) *(uint16_t*)CPU.PC;
#else
- Int32 = (long) ICPU.Registers.A.W -
- (long)(*CPU.PC + (*(CPU.PC + 1) << 8));
+ Int32 = (int32_t) ICPU.Registers.A.W - (int32_t)(*CPU.PC + (*(CPU.PC + 1) << 8));
#endif
ICPU._Carry = Int32 >= 0;
SetZN16((uint16_t) Int32);
@@ -932,7 +931,7 @@ static void OpD3M0(void)
/* CMX *************************************************************************************** */
static void OpE0X1(void)
{
- int32_t Int32 = (int) ICPU.Registers.XL - (intptr_t) * CPU.PC++;
+ int32_t Int32 = (int32_t) ICPU.Registers.XL - (int32_t) *CPU.PC++;
ICPU._Carry = Int32 >= 0;
SetZN8((uint8_t) Int32);
#ifndef SA1_OPCODES
@@ -944,10 +943,9 @@ static void OpE0X0(void)
{
int32_t Int32;
#ifdef FAST_LSB_WORD_ACCESS
- Int32 = (long) ICPU.Registers.X.W - (long) * (uint16_t*) CPU.PC;
+ Int32 = (int32_t) ICPU.Registers.X.W - (int32_t) *(uint16_t*)CPU.PC;
#else
- Int32 = (long) ICPU.Registers.X.W -
- (long)(*CPU.PC + (*(CPU.PC + 1) << 8));
+ Int32 = (int32_t) ICPU.Registers.X.W - (int32_t)(*CPU.PC + (*(CPU.PC + 1) << 8));
#endif
ICPU._Carry = Int32 >= 0;
SetZN16((uint16_t) Int32);
@@ -994,7 +992,7 @@ static void OpECX0(void)
/* CMY *************************************************************************************** */
static void OpC0X1(void)
{
- int32_t Int32 = (int) ICPU.Registers.YL - (intptr_t) * CPU.PC++;
+ int32_t Int32 = (int32_t) ICPU.Registers.YL - (int32_t) *CPU.PC++;
ICPU._Carry = Int32 >= 0;
SetZN8((uint8_t) Int32);
#ifndef SA1_OPCODES
@@ -1006,10 +1004,9 @@ static void OpC0X0(void)
{
int32_t Int32;
#ifdef FAST_LSB_WORD_ACCESS
- Int32 = (long) ICPU.Registers.Y.W - (long) * (uint16_t*) CPU.PC;
+ Int32 = (int32_t) ICPU.Registers.Y.W - (int32_t) *(uint16_t*)CPU.PC;
#else
- Int32 = (long) ICPU.Registers.Y.W -
- (long)(*CPU.PC + (*(CPU.PC + 1) << 8));
+ Int32 = (int32_t) ICPU.Registers.Y.W - (int32_t)(*CPU.PC + (*(CPU.PC + 1) << 8));
#endif
ICPU._Carry = Int32 >= 0;
SetZN16((uint16_t) Int32);
@@ -3555,7 +3552,7 @@ static void OpF4E1(void)
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2;
#endif
- PushWE((unsigned short)OpAddress);
+ PushWE((uint16_t)OpAddress);
}
static void OpF4(void)
@@ -3564,7 +3561,7 @@ static void OpF4(void)
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2;
#endif
- PushW((unsigned short)OpAddress);
+ PushW((uint16_t)OpAddress);
}
//PEI NL
@@ -3574,7 +3571,7 @@ static void OpD4E1(void)
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeed;
#endif
- PushWE((unsigned short)OpAddress);
+ PushWE((uint16_t)OpAddress);
}
static void OpD4(void)
@@ -3583,7 +3580,7 @@ static void OpD4(void)
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeed;
#endif
- PushW((unsigned short)OpAddress);
+ PushW((uint16_t)OpAddress);
}
//PER NL
@@ -3593,7 +3590,7 @@ static void Op62E1(void)
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2 + ONE_CYCLE;
#endif
- PushWE((unsigned short)OpAddress);
+ PushWE((uint16_t)OpAddress);
}
static void Op62(void)
@@ -3602,7 +3599,7 @@ static void Op62(void)
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2 + ONE_CYCLE;
#endif
- PushW((unsigned short)OpAddress);
+ PushW((uint16_t)OpAddress);
}
@@ -4747,7 +4744,7 @@ static void OpDB(void)
int8_t BranchOffset = (NextByte & 0x7F) | ((NextByte & 0x40) << 1);
// ^ -64 .. +63, sign extend bit 6 into 7 for unpacking
- long TargetAddress = ((int) (CPU.PC - CPU.PCBase) + BranchOffset) & 0xffff;
+ int32_t TargetAddress = ((int32_t) (CPU.PC - CPU.PCBase) + BranchOffset) & 0xffff;
switch (NextByte & 0x80)
{
@@ -4795,7 +4792,7 @@ static void Op42(void)
ForceShutdown();
int8_t BranchOffset = 0xF0 | (NextByte & 0xF); // always negative
- long TargetAddress = ((int) (CPU.PC - CPU.PCBase) + BranchOffset) & 0xffff;
+ int32_t TargetAddress = ((int32_t) (CPU.PC - CPU.PCBase) + BranchOffset) & 0xffff;
switch (NextByte & 0xF0)
{
diff --git a/source/display.h b/source/display.h
index d43d4ff..cee60bb 100644
--- a/source/display.h
+++ b/source/display.h
@@ -4,13 +4,13 @@
#define _DISPLAY_H_
// Routines the port specific code has to implement
-uint32_t S9xReadJoypad(int port);
-bool S9xReadMousePosition(int which1_0_to_1, int* x, int* y, uint32_t* buttons);
-bool S9xReadSuperScopePosition(int* x, int* y, uint32_t* buttons);
+uint32_t S9xReadJoypad(int32_t port);
+bool S9xReadMousePosition(int32_t which1_0_to_1, int32_t* x, int32_t* y, uint32_t* buttons);
+bool S9xReadSuperScopePosition(int32_t* x, int32_t* y, uint32_t* buttons);
void S9xInitDisplay(void);
void S9xDeinitDisplay();
-void S9xToggleSoundChannel(int channel);
+void S9xToggleSoundChannel(int32_t channel);
void S9xSetInfoString(const char* string);
void S9xNextController();
bool S9xLoadROMImage(const char* string);
diff --git a/source/dma.c b/source/dma.c
index f404d4f..3800c70 100644
--- a/source/dma.c
+++ b/source/dma.c
@@ -23,7 +23,7 @@
static uint8_t sdd1_decode_buffer[0x10000];
#endif
-extern int HDMA_ModeByteCounts [8];
+extern int32_t HDMA_ModeByteCounts [8];
extern uint8_t* HDMAMemPointers [8];
extern uint8_t* HDMABasePointers [8];
@@ -51,13 +51,13 @@ void S9xDoDMA(uint8_t Channel)
SDMA* d = &DMA[Channel];
- int count = d->TransferBytes;
+ int32_t count = d->TransferBytes;
// Prepare for custom chip DMA
if (count == 0)
count = 0x10000;
- int inc = d->AAddressFixed ? 0 : (!d->AAddressDecrement ? 1 : -1);
+ int32_t inc = d->AAddressFixed ? 0 : (!d->AAddressDecrement ? 1 : -1);
if ((d->ABank == 0x7E || d->ABank == 0x7F) && d->BAddress == 0x80)
{
@@ -115,7 +115,7 @@ void S9xDoDMA(uint8_t Channel)
memcpy(&spc7110_dma[j], s7r.bank50, d->TransferBytes - j);
s7_wrap = true;
}
- int icount = s7r.reg4809 | (s7r.reg480A << 8);
+ int32_t icount = s7r.reg4809 | (s7r.reg480A << 8);
icount -= d->TransferBytes;
s7r.reg4809 = 0x00ff & icount;
s7r.reg480A = (0xff00 & icount) >> 8;
@@ -129,13 +129,13 @@ void S9xDoDMA(uint8_t Channel)
{
// Perform packed bitmap to PPU character format conversion on the
// data before transmitting it to V-RAM via-DMA.
- int num_chars = 1 << ((Memory.FillRAM [0x2231] >> 2) & 7);
- int depth = (Memory.FillRAM [0x2231] & 3) == 0 ? 8 :
- (Memory.FillRAM [0x2231] & 3) == 1 ? 4 : 2;
+ int32_t num_chars = 1 << ((Memory.FillRAM [0x2231] >> 2) & 7);
+ int32_t depth = (Memory.FillRAM [0x2231] & 3) == 0 ? 8 :
+ (Memory.FillRAM [0x2231] & 3) == 1 ? 4 : 2;
- int bytes_per_char = 8 * depth;
- int bytes_per_line = depth * num_chars;
- int char_line_bytes = bytes_per_char * num_chars;
+ int32_t bytes_per_char = 8 * depth;
+ int32_t bytes_per_line = depth * num_chars;
+ int32_t char_line_bytes = bytes_per_char * num_chars;
uint32_t addr = (d->AAddress / char_line_bytes) * char_line_bytes;
uint8_t* base = GetBasePointer((d->ABank << 16) + addr) + addr;
uint8_t* buffer = &Memory.ROM [MAX_ROM_SIZE - 0x10000];
@@ -144,7 +144,7 @@ void S9xDoDMA(uint8_t Channel)
uint32_t char_count = inc / bytes_per_char;
in_sa1_dma = true;
- int i;
+ int32_t i;
switch (depth)
{
@@ -157,7 +157,7 @@ void S9xDoDMA(uint8_t Channel)
for (j = 0; j < char_count && p - buffer < count;
j++, line += 2)
{
- int b, l;
+ int32_t b, l;
uint8_t* q = line;
for (l = 0; l < 8; l++, q += bytes_per_line)
{
@@ -188,7 +188,7 @@ void S9xDoDMA(uint8_t Channel)
j++, line += 4)
{
uint8_t* q = line;
- int b, l;
+ int32_t b, l;
for (l = 0; l < 8; l++, q += bytes_per_line)
{
for (b = 0; b < 4; b++)
@@ -219,7 +219,7 @@ void S9xDoDMA(uint8_t Channel)
j++, line += 8)
{
uint8_t* q = line;
- int b, l;
+ int32_t b, l;
for (l = 0; l < 8; l++, q += bytes_per_line)
{
for (b = 0; b < 8; b++)
@@ -672,7 +672,7 @@ uint8_t S9xDoHDMA(uint8_t byte)
{
SDMA* p = &DMA [0];
- int d = 0;
+ int32_t d = 0;
CPU.InDMA = true;
CPU.Cycles += ONE_CYCLE * 3;
@@ -874,7 +874,7 @@ uint8_t S9xDoHDMA(uint8_t byte)
void S9xResetDMA()
{
- int c, d;
+ int32_t c, d;
for (d = 0; d < 8; d++)
{
DMA [d].TransferDirection = false;
diff --git a/source/dsp1.c b/source/dsp1.c
index a5b5e79..42f20c8 100644
--- a/source/dsp1.c
+++ b/source/dsp1.c
@@ -1242,7 +1242,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
case 0x0000:
{
int16_t multiplier, multiplicand;
- int product;
+ int32_t product;
multiplier = DSP4_READ_WORD(0);
multiplicand = DSP4_READ_WORD(2);
@@ -1311,7 +1311,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
// clear OAM tables
op06_index = 0;
op06_offset = 0;
- int lcv;
+ int32_t lcv;
for (lcv = 0; lcv < 32; lcv++)
op06_OAM[lcv] = 0;
break;
@@ -1329,7 +1329,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
case 0x0006:
{
DSP4.out_count = 32;
- int lcv;
+ int32_t lcv;
for (lcv = 0; lcv < 32; lcv++)
DSP4.output[lcv] = op06_OAM[lcv];
}
diff --git a/source/dsp1emu.c b/source/dsp1emu.c
index 3999d5d..a2767b0 100644
--- a/source/dsp1emu.c
+++ b/source/dsp1emu.c
@@ -172,7 +172,7 @@ double Atan(double x)
void InitDSP(void)
{
#ifdef __OPT__
- unsigned int i;
+ uint32_t i;
for (i = 0; i < INCR; i++)
{
CosTable2[i] = (cos((double)(2 * PI * i / INCR)));
@@ -349,8 +349,8 @@ int16_t DSP1_Sin(int16_t Angle)
if (Angle == -32768) return 0;
return -DSP1_Sin(-Angle);
}
- int S = DSP1_SinTable[Angle >> 8] + (DSP1_MulTable[Angle & 0xff] *
- DSP1_SinTable[0x40 + (Angle >> 8)] >> 15);
+ int32_t S = DSP1_SinTable[Angle >> 8] + (DSP1_MulTable[Angle & 0xff] *
+ DSP1_SinTable[0x40 + (Angle >> 8)] >> 15);
if (S > 32767) S = 32767;
return (int16_t) S;
}
@@ -362,8 +362,8 @@ int16_t DSP1_Cos(int16_t Angle)
if (Angle == -32768) return -32768;
Angle = -Angle;
}
- int S = DSP1_SinTable[0x40 + (Angle >> 8)] - (DSP1_MulTable[Angle & 0xff] *
- DSP1_SinTable[Angle >> 8] >> 15);
+ int32_t S = DSP1_SinTable[0x40 + (Angle >> 8)] - (DSP1_MulTable[Angle & 0xff] *
+ DSP1_SinTable[Angle >> 8] >> 15);
if (S < -32768) S = -32767;
return (int16_t) S;
}
@@ -394,7 +394,7 @@ void DSP1_Normalize(int16_t m, int16_t* Coefficient, int16_t* Exponent)
*Exponent -= e;
}
-void DSP1_NormalizeDouble(int Product, int16_t* Coefficient, int16_t* Exponent)
+void DSP1_NormalizeDouble(int32_t Product, int16_t* Coefficient, int16_t* Exponent)
{
int16_t n = Product & 0x7fff;
int16_t m = Product >> 15;
@@ -671,8 +671,8 @@ double ObjPX2;
double ObjPY2;
double ObjPZ2;
double DivideOp06;
-int Temp;
-int tanval2;
+int32_t Temp;
+int32_t tanval2;
#ifdef __OPT06__
void DSPOp06()
@@ -1091,7 +1091,7 @@ int16_t Op08X, Op08Y, Op08Z, Op08Ll, Op08Lh;
void DSPOp08()
{
- int Op08Size = (Op08X * Op08X + Op08Y * Op08Y + Op08Z * Op08Z) << 1;
+ int32_t Op08Size = (Op08X * Op08X + Op08Y * Op08Y + Op08Z * Op08Z) << 1;
Op08Ll = Op08Size & 0xffff;
Op08Lh = (Op08Size >> 16) & 0xffff;
@@ -1121,7 +1121,7 @@ int16_t Op28R;
void DSPOp28()
{
- int Radius = Op28X * Op28X + Op28Y * Op28Y + Op28Z * Op28Z;
+ int32_t Radius = Op28X * Op28X + Op28Y * Op28Y + Op28Z * Op28Z;
if (Radius == 0) Op28R = 0;
else
diff --git a/source/dsp2emu.c b/source/dsp2emu.c
index 1ec79bc..d1b6410 100644
--- a/source/dsp2emu.c
+++ b/source/dsp2emu.c
@@ -3,9 +3,9 @@
uint16_t DSP2Op09Word1 = 0;
uint16_t DSP2Op09Word2 = 0;
bool DSP2Op05HasLen = false;
-int DSP2Op05Len = 0;
+int32_t DSP2Op05Len = 0;
bool DSP2Op06HasLen = false;
-int DSP2Op06Len = 0;
+int32_t DSP2Op06Len = 0;
uint8_t DSP2Op05Transparent = 0;
void DSP2_Op05()
@@ -36,12 +36,12 @@ void DSP2_Op05()
// size = 0. I don't think it's worth implementing this quirk unless it's
// proven necessary.
- int n;
- unsigned char c1;
- unsigned char c2;
- unsigned char* p1 = DSP1.parameters;
- unsigned char* p2 = &DSP1.parameters[DSP2Op05Len];
- unsigned char* p3 = DSP1.output;
+ int32_t n;
+ uint8_t c1;
+ uint8_t c2;
+ uint8_t* p1 = DSP1.parameters;
+ uint8_t* p2 = &DSP1.parameters[DSP2Op05Len];
+ uint8_t* p3 = DSP1.output;
color = DSP2Op05Transparent & 0x0f;
@@ -59,11 +59,11 @@ void DSP2_Op01()
// Op01 size is always 32 bytes input and output.
// The hardware does strange things if you vary the size.
- int j;
- unsigned char c0, c1, c2, c3;
- unsigned char* p1 = DSP1.parameters;
- unsigned char* p2a = DSP1.output;
- unsigned char* p2b = &DSP1.output[16]; // halfway
+ int32_t j;
+ uint8_t c0, c1, c2, c3;
+ uint8_t* p1 = DSP1.parameters;
+ uint8_t* p2a = DSP1.output;
+ uint8_t* p2b = &DSP1.output[16]; // halfway
// Process 8 blocks of 4 bytes each
@@ -120,15 +120,15 @@ void DSP2_Op06()
// size
// bitmap
- int i, j;
+ int32_t i, j;
for (i = 0, j = DSP2Op06Len - 1; i < DSP2Op06Len; i++, j--)
DSP1.output[j] = (DSP1.parameters[i] << 4) | (DSP1.parameters[i] >> 4);
}
bool DSP2Op0DHasLen = false;
-int DSP2Op0DOutLen = 0;
-int DSP2Op0DInLen = 0;
+int32_t DSP2Op0DOutLen = 0;
+int32_t DSP2Op0DInLen = 0;
#ifndef DSP2_BIT_ACCURRATE_CODE
@@ -138,13 +138,13 @@ void DSP2_Op0D()
{
// (Modified) Overload's algorithm - use this unless doing hardware testing
- int i;
+ int32_t i;
for(i = 0 ; i < DSP2Op0DOutLen ; i++)
{
- int j = i << 1;
- int pixel_offset_low = ((j * DSP2Op0DInLen) / DSP2Op0DOutLen) >> 1;
- int pixel_offset_high = (((j + 1) * DSP2Op0DInLen) / DSP2Op0DOutLen) >> 1;
+ int32_t j = i << 1;
+ int32_t pixel_offset_low = ((j * DSP2Op0DInLen) / DSP2Op0DOutLen) >> 1;
+ int32_t pixel_offset_high = (((j + 1) * DSP2Op0DInLen) / DSP2Op0DOutLen) >> 1;
uint8_t pixel_low = DSP1.parameters[pixel_offset_low] >> 4;
uint8_t pixel_high = DSP1.parameters[pixel_offset_high] & 0x0f;
DSP1.output[i] = (pixel_low << 4) | pixel_high;
@@ -170,9 +170,9 @@ void DSP2_Op0D()
// If it does we can adjust the parameters and code to work with it
- uint32_t multiplier; // Any size int >= 32-bits
- uint32_t pixloc; // match size of multiplier
- int i, j;
+ uint32_t multiplier;
+ uint32_t pixloc;
+ int32_t i, j;
uint8_t pixelarray[512];
if (DSP2Op0DInLen <= DSP2Op0DOutLen)
diff --git a/source/dsp4.h b/source/dsp4.h
index 488b5f6..760891c 100644
--- a/source/dsp4.h
+++ b/source/dsp4.h
@@ -4,8 +4,8 @@
#define _DSP4_H_
// debug
-int block; // current block number
-extern int c;
+int32_t block; // current block number
+extern int32_t c;
// op control
int8_t DSP4_Logic; // controls op flow
diff --git a/source/dsp4emu.c b/source/dsp4emu.c
index 4ea8fcb..c2ba8c8 100644
--- a/source/dsp4emu.c
+++ b/source/dsp4emu.c
@@ -16,7 +16,7 @@
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
-int DSP4_Multiply(int16_t Multiplicand, int16_t Multiplier)
+int32_t DSP4_Multiply(int16_t Multiplicand, int16_t Multiplier)
{
return Multiplicand * Multiplier;
}
@@ -515,7 +515,7 @@ DSP4_WAIT(2) resume2:
// first init
if (plane == 0x7fff)
{
- int pos1, pos2;
+ int32_t pos1, pos2;
// initialize projection
path_x[0] = x_left;
@@ -1095,7 +1095,7 @@ DSP4_WAIT(3) resume3:
DSP4_WAIT(4)
// store final values
- int height;
+ int32_t height;
resume4:
height = DSP4_READ_WORD(0);
@@ -1229,7 +1229,7 @@ resume7:
out_index = 6;
// OAM: size,msb data
- DSP4_Op06(sprite_size, (char) sp_msb);
+ DSP4_Op06(sprite_size, (int8_t) sp_msb);
}
// normal data
@@ -1247,7 +1247,7 @@ resume7:
DSP4_WRITE_WORD(out_index + 6, 0);
// OAM: size,msb data
- DSP4_Op06(sprite_size, (char) sp_msb);
+ DSP4_Op06(sprite_size, (int8_t) sp_msb);
}
// no sprite information
diff --git a/source/font.h b/source/font.h
index 8a4908f..01ed497 100644
--- a/source/font.h
+++ b/source/font.h
@@ -58,6 +58,6 @@ static const char* font[] =
" . . . ",
};
-static int font_width = 8;
-static int font_height = 9;
+static int32_t font_width = 8;
+static int32_t font_height = 9;
diff --git a/source/fxemu.c b/source/fxemu.c
index c789e23..5b3aba3 100644
--- a/source/fxemu.c
+++ b/source/fxemu.c
@@ -43,7 +43,7 @@ void fx_updateRamBank(uint8_t Byte)
static void fx_readRegisterSpace()
{
- int i;
+ int32_t i;
uint8_t* p;
static uint32_t avHeight[] = { 128, 160, 192, 256 };
static uint32_t avMult[] = { 16, 32, 32, 64 };
@@ -81,8 +81,8 @@ static void fx_readRegisterSpace()
/* Set screen pointers */
GSU.pvScreenBase = &GSU.pvRam[ USEX8(p[GSU_SCBR]) << 10 ];
- i = (int)(!!(p[GSU_SCMR] & 0x04));
- i |= ((int)(!!(p[GSU_SCMR] & 0x20))) << 1;
+ i = (int32_t)(!!(p[GSU_SCMR] & 0x04));
+ i |= ((int32_t)(!!(p[GSU_SCMR] & 0x20))) << 1;
GSU.vScreenHeight = GSU.vScreenRealHeight = avHeight[i];
GSU.vMode = p[GSU_SCMR] & 0x03;
if (i == 3)
@@ -118,7 +118,7 @@ void fx_computeScreenPointers()
GSU.vPrevScreenHeight != GSU.vScreenHeight ||
GSU.vSCBRDirty)
{
- int i;
+ int32_t i;
GSU.vSCBRDirty = false;
@@ -244,7 +244,7 @@ void fx_computeScreenPointers()
static void fx_writeRegisterSpace()
{
- int i;
+ int32_t i;
uint8_t* p;
p = GSU.pvRegisters;
@@ -277,7 +277,7 @@ static void fx_writeRegisterSpace()
/* Reset the FxChip */
void FxReset(struct FxInit_s* psFxInfo)
{
- int i;
+ int32_t i;
static uint32_t(**appfFunction[])(uint32_t) =
{
&fx_apfFunctionTable[0]
@@ -384,7 +384,7 @@ static bool fx_checkStartAddress()
}
/* Execute until the next stop instruction */
-int FxEmulate(uint32_t nInstructions)
+int32_t FxEmulate(uint32_t nInstructions)
{
uint32_t vCount;
@@ -415,7 +415,7 @@ int FxEmulate(uint32_t nInstructions)
}
/* Step by step execution */
-int FxStepOver(uint32_t nInstructions)
+int32_t FxStepOver(uint32_t nInstructions)
{
uint32_t vCount;
fx_readRegisterSpace();
@@ -442,12 +442,12 @@ int FxStepOver(uint32_t nInstructions)
}
/* Errors */
-int FxGetErrorCode()
+int32_t FxGetErrorCode()
{
return GSU.vErrorCode;
}
-int FxGetIllegalAddress()
+int32_t FxGetIllegalAddress()
{
return GSU.vIllegalAddress;
}
diff --git a/source/fxemu.h b/source/fxemu.h
index 6c717e3..3c0511c 100644
--- a/source/fxemu.h
+++ b/source/fxemu.h
@@ -20,18 +20,18 @@ struct FxInit_s
extern void FxReset(struct FxInit_s* psFxInfo);
/* Execute until the next stop instruction */
-extern int FxEmulate(uint32_t nInstructions);
+extern int32_t FxEmulate(uint32_t nInstructions);
/* Write access to the cache */
extern void FxCacheWriteAccess(uint16_t vAddress);
extern void FxFlushCache(); /* Callled when the G flag in SFR is set to zero */
/* Step by step execution */
-extern int FxStepOver(uint32_t nInstructions);
+extern int32_t FxStepOver(uint32_t nInstructions);
/* Errors */
-extern int FxGetErrorCode();
-extern int FxGetIllegalAddress();
+extern int32_t FxGetErrorCode();
+extern int32_t FxGetIllegalAddress();
/* Access to internal registers */
extern uint32_t FxGetColorRegister();
diff --git a/source/fxinst.c b/source/fxinst.c
index 05ebba2..e78d932 100644
--- a/source/fxinst.c
+++ b/source/fxinst.c
@@ -8,7 +8,7 @@
#include <stdio.h>
extern struct FxRegs_s GSU;
-int gsu_bank [512] = {0};
+int32_t gsu_bank [512] = {0};
/* Set this define if you wish the plot instruction to check for y-pos limits */
/* (I don't think it's nessecary) */
diff --git a/source/fxinst.h b/source/fxinst.h
index f7450a9..a78b6d4 100644
--- a/source/fxinst.h
+++ b/source/fxinst.h
@@ -168,7 +168,7 @@ struct FxRegs_s
uint32_t vPrevMode; /* Previous depth */
uint8_t* pvScreenBase;
uint8_t* apvScreen[32]; /* Pointer to each of the 32 screen colums */
- int x[32];
+ int32_t x[32];
uint32_t vScreenHeight; /* 128, 160, 192 or 256 (could be overriden by cmode) */
uint32_t vScreenRealHeight; /* 128, 160, 192 or 256 */
uint32_t vPrevScreenHeight;
diff --git a/source/getset.h b/source/getset.h
index ebd377a..b0abba5 100644
--- a/source/getset.h
+++ b/source/getset.h
@@ -15,9 +15,8 @@ extern uint8_t OpenBus;
INLINE uint8_t S9xGetByte(uint32_t Address)
{
- int block;
- uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) &
- MEMMAP_MASK];
+ int32_t block;
+ uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
if (!CPU.InDMA)
CPU.Cycles += Memory.MemorySpeed [block];
@@ -48,49 +47,26 @@ INLINE uint8_t S9xGetByte(uint32_t Address)
//Address&0xFF0000 -bank
//bank>>1 | offset = s-ram address, unbound
//unbound & SRAMMask = Sram offset
- return (*(Memory.SRAM + ((((Address & 0xFF0000) >> 1) |
- (Address & 0x7FFF)) &Memory.SRAMMask)));
-
+ return (*(Memory.SRAM + ((((Address & 0xFF0000) >> 1) | (Address & 0x7FFF)) &Memory.SRAMMask)));
case MAP_RONLY_SRAM:
case MAP_HIROM_SRAM:
- return (*(Memory.SRAM + (((Address & 0x7fff) - 0x6000 +
- ((Address & 0xf0000) >> 3)) & Memory.SRAMMask)));
-
+ return (*(Memory.SRAM + (((Address & 0x7fff) - 0x6000 + ((Address & 0xf0000) >> 3)) & Memory.SRAMMask)));
case MAP_BWRAM:
return (*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)));
-
case MAP_C4:
return (S9xGetC4(Address & 0xffff));
-
case MAP_SPC7110_ROM:
return S9xGetSPC7110Byte(Address);
-
case MAP_SPC7110_DRAM:
return S9xGetSPC7110(0x4800);
-
case MAP_OBC_RAM:
return GetOBC1(Address & 0xffff);
-
case MAP_SETA_DSP:
return S9xGetSetaDSP(Address);
-
case MAP_SETA_RISC:
return S9xGetST018(Address);
-
-
-
case MAP_DEBUG:
- return OpenBus;
-
-
default:
- case MAP_NONE:
-#ifdef MK_TRACE_BAD_READS
- char address[20];
- sprintf(address, TEXT("%06X"), Address);
- MessageBox(GUI.hWnd, address, TEXT("GetByte"), MB_OK);
-#endif
-
return OpenBus;
}
}
@@ -102,7 +78,7 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
OpenBus = S9xGetByte(Address);
return (OpenBus | (S9xGetByte(Address + 1) << 8));
}
- int block;
+ int32_t block;
uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) &
MEMMAP_MASK];
@@ -151,7 +127,6 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
&Memory.SRAMMask))) |
((*(Memory.SRAM + (((((Address + 1) & 0xFF0000) >> 1) | ((
Address + 1) & 0x7FFF)) &Memory.SRAMMask))) << 8);
-
case MAP_RONLY_SRAM:
case MAP_HIROM_SRAM:
/* BJ: no FAST_LSB_WORD_ACCESS here, since if Memory.SRAMMask=0x7ff
@@ -162,7 +137,6 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
(*(Memory.SRAM +
((((Address + 1) & 0x7fff) - 0x6000 +
(((Address + 1) & 0xf0000) >> 3)) & Memory.SRAMMask)) << 8));
-
case MAP_BWRAM:
#ifdef FAST_LSB_WORD_ACCESS
return (*(uint16_t*)(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)));
@@ -170,11 +144,9 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
return (*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)) |
(*(Memory.BWRAM + (((Address + 1) & 0x7fff) - 0x6000)) << 8));
#endif
-
case MAP_C4:
return (S9xGetC4(Address & 0xffff) |
(S9xGetC4((Address + 1) & 0xffff) << 8));
-
case MAP_SPC7110_ROM:
return (S9xGetSPC7110Byte(Address) |
(S9xGetSPC7110Byte(Address + 1)) << 8);
@@ -183,24 +155,11 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
(S9xGetSPC7110(0x4800) << 8));
case MAP_OBC_RAM:
return GetOBC1(Address & 0xFFFF) | (GetOBC1((Address + 1) & 0xFFFF) << 8);
-
case MAP_SETA_DSP:
return S9xGetSetaDSP(Address) | (S9xGetSetaDSP((Address + 1)) << 8);
-
case MAP_SETA_RISC:
return S9xGetST018(Address) | (S9xGetST018((Address + 1)) << 8);
-
- case MAP_DEBUG:
- return (OpenBus | (OpenBus << 8));
-
default:
- case MAP_NONE:
-#ifdef MK_TRACE_BAD_READS
- char address[20];
- sprintf(address, TEXT("%06X"), Address);
- MessageBox(GUI.hWnd, address, TEXT("GetWord"), MB_OK);
-#endif
-
return (OpenBus | (OpenBus << 8));
}
}
@@ -210,7 +169,7 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
#if defined(CPU_SHUTDOWN)
CPU.WaitAddress = NULL;
#endif
- int block;
+ int32_t block;
uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) &
MEMMAP_MASK)];
@@ -240,18 +199,15 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
case MAP_PPU:
S9xSetPPU(Byte, Address & 0xffff);
return;
-
case MAP_CPU:
S9xSetCPU(Byte, Address & 0xffff);
return;
-
case MAP_DSP:
#ifdef DSP_DUMMY_LOOPS
printf("DSP Byte: %02X to %06X\n", Byte, Address);
#endif
S9xSetDSP(Byte, Address & 0xffff);
return;
-
case MAP_LOROM_SRAM:
if (Memory.SRAMMask)
{
@@ -260,7 +216,6 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
CPU.SRAMModified = true;
}
return;
-
case MAP_HIROM_SRAM:
if (Memory.SRAMMask)
{
@@ -269,46 +224,31 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
CPU.SRAMModified = true;
}
return;
-
case MAP_BWRAM:
*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)) = Byte;
CPU.SRAMModified = true;
return;
-
case MAP_DEBUG:
-
case MAP_SA1RAM:
*(Memory.SRAM + (Address & 0xffff)) = Byte;
SA1.Executing = !SA1.Waiting;
break;
-
case MAP_C4:
S9xSetC4(Byte, Address & 0xffff);
return;
-
case MAP_SPC7110_DRAM:
s7r.bank50[(Address & 0xffff)] = (uint8_t) Byte;
break;
-
case MAP_OBC_RAM:
SetOBC1(Byte, Address & 0xFFFF);
return;
-
case MAP_SETA_DSP:
S9xSetSetaDSP(Byte, Address);
return;
-
case MAP_SETA_RISC:
S9xSetST018(Byte, Address);
return;
default:
- case MAP_NONE:
-#ifdef MK_TRACE_BAD_WRITES
- char address[20];
- sprintf(address, TEXT("%06X"), Address);
- MessageBox(GUI.hWnd, address, TEXT("SetByte"), MB_OK);
-#endif
-
return;
}
}
@@ -325,7 +265,7 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
#if defined(CPU_SHUTDOWN)
CPU.WaitAddress = NULL;
#endif
- int block;
+ int32_t block;
uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) &
MEMMAP_MASK)];
@@ -366,12 +306,10 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
S9xSetPPU((uint8_t) Word, Address & 0xffff);
S9xSetPPU(Word >> 8, (Address & 0xffff) + 1);
return;
-
case MAP_CPU:
S9xSetCPU((uint8_t) Word, (Address & 0xffff));
S9xSetCPU(Word >> 8, (Address & 0xffff) + 1);
return;
-
case MAP_DSP:
#ifdef DSP_DUMMY_LOOPS
printf("DSP Word: %04X to %06X\n", Word, Address);
@@ -379,7 +317,6 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
S9xSetDSP((uint8_t) Word, (Address & 0xffff));
S9xSetDSP(Word >> 8, (Address & 0xffff) + 1);
return;
-
case MAP_LOROM_SRAM:
if (Memory.SRAMMask)
{
@@ -393,7 +330,6 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
CPU.SRAMModified = true;
}
return;
-
case MAP_HIROM_SRAM:
if (Memory.SRAMMask)
{
@@ -408,7 +344,6 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
CPU.SRAMModified = true;
}
return;
-
case MAP_BWRAM:
#ifdef FAST_LSB_WORD_ACCESS
*(uint16_t*)(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)) = Word;
@@ -418,9 +353,7 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
#endif
CPU.SRAMModified = true;
return;
-
case MAP_DEBUG:
-
case MAP_SPC7110_DRAM:
s7r.bank50[(Address & 0xffff)] = (uint8_t) Word;
s7r.bank50[((Address + 1) & 0xffff)] = (uint8_t) Word;
@@ -430,35 +363,23 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
*(Memory.SRAM + ((Address + 1) & 0xffff)) = (uint8_t)(Word >> 8);
SA1.Executing = !SA1.Waiting;
break;
-
case MAP_C4:
S9xSetC4(Word & 0xff, Address & 0xffff);
S9xSetC4((uint8_t)(Word >> 8), (Address + 1) & 0xffff);
return;
-
case MAP_OBC_RAM:
SetOBC1(Word & 0xff, Address & 0xFFFF);
SetOBC1((uint8_t)(Word >> 8), (Address + 1) & 0xffff);
return;
-
case MAP_SETA_DSP:
S9xSetSetaDSP(Word & 0xff, Address);
S9xSetSetaDSP((uint8_t)(Word >> 8), (Address + 1));
return;
-
case MAP_SETA_RISC:
S9xSetST018(Word & 0xff, Address);
S9xSetST018((uint8_t)(Word >> 8), (Address + 1));
return;
-
default:
- case MAP_NONE:
-#ifdef MK_TRACE_BAD_WRITES
- char address[20];
- sprintf(address, TEXT("%06X"), Address);
- MessageBox(GUI.hWnd, address, TEXT("SetWord"), MB_OK);
-#endif
-
return;
}
}
@@ -473,9 +394,7 @@ INLINE uint8_t* GetBasePointer(uint32_t Address)
switch ((intptr_t) GetAddress)
{
case MAP_SPC7110_DRAM:
- {
return s7r.bank50;
- }
case MAP_SPC7110_ROM:
return Get7110BasePtr(Address);
case MAP_PPU: //just a guess, but it looks like this should match the CPU as a source.
@@ -495,16 +414,7 @@ INLINE uint8_t* GetBasePointer(uint32_t Address)
return (Memory.C4RAM - 0x6000);
case MAP_SETA_DSP:
return Memory.SRAM;
- case MAP_DEBUG:
-
default:
- case MAP_NONE:
-#if defined(MK_TRACE_BAD_READS) || defined(MK_TRACE_BAD_WRITES)
- char fsd[12];
- sprintf(fsd, TEXT("%06X"), Address);
- MessageBox(GUI.hWnd, fsd, TEXT("Rogue DMA"), MB_OK);
-#endif
-
return (0);
}
}
@@ -541,80 +451,53 @@ INLINE uint8_t* S9xGetMemPointer(uint32_t Address)
return GetMemPointerOBC1(Address);
case MAP_SETA_DSP:
return Memory.SRAM + ((Address & 0xffff) & Memory.SRAMMask);
- case MAP_DEBUG:
default:
- case MAP_NONE:
-#if defined(MK_TRACE_BAD_READS) || defined(MK_TRACE_BAD_WRITES)
- char fsd[12];
- sprintf(fsd, TEXT("%06X"), Address);
- MessageBox(GUI.hWnd, fsd, TEXT("Rogue DMA"), MB_OK);
-#endif
-
return (0);
}
}
INLINE void S9xSetPCBase(uint32_t Address)
{
- int block;
- uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) &
- MEMMAP_MASK];
-
+ int32_t block;
+ uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
CPU.MemSpeed = Memory.MemorySpeed [block];
CPU.MemSpeedx2 = CPU.MemSpeed << 1;
if (GetAddress >= (uint8_t*) MAP_LAST)
- {
CPU.PCBase = GetAddress;
- CPU.PC = GetAddress + (Address & 0xffff);
- return;
- }
-
- switch ((intptr_t) GetAddress)
+ else
{
- case MAP_PPU:
- CPU.PCBase = Memory.FillRAM;
- CPU.PC = CPU.PCBase + (Address & 0xffff);
- return;
-
- case MAP_CPU:
- CPU.PCBase = Memory.FillRAM;
- CPU.PC = CPU.PCBase + (Address & 0xffff);
- return;
-
- case MAP_DSP:
- CPU.PCBase = Memory.FillRAM - 0x6000;
- CPU.PC = CPU.PCBase + (Address & 0xffff);
- return;
-
- case MAP_SA1RAM:
- case MAP_LOROM_SRAM:
- CPU.PCBase = Memory.SRAM;
- CPU.PC = CPU.PCBase + (Address & 0xffff);
- return;
-
- case MAP_BWRAM:
- CPU.PCBase = Memory.BWRAM - 0x6000;
- CPU.PC = CPU.PCBase + (Address & 0xffff);
- return;
- case MAP_HIROM_SRAM:
- CPU.PCBase = Memory.SRAM - 0x6000;
- CPU.PC = CPU.PCBase + (Address & 0xffff);
- return;
-
- case MAP_C4:
- CPU.PCBase = Memory.C4RAM - 0x6000;
- CPU.PC = CPU.PCBase + (Address & 0xffff);
- return;
-
- case MAP_DEBUG:
-
- default:
- case MAP_NONE:
- CPU.PCBase = Memory.SRAM;
- CPU.PC = Memory.SRAM + (Address & 0xffff);
- return;
+ switch ((intptr_t) GetAddress)
+ {
+ case MAP_PPU:
+ CPU.PCBase = Memory.FillRAM;
+ break;
+ case MAP_CPU:
+ CPU.PCBase = Memory.FillRAM;
+ break;
+ case MAP_DSP:
+ CPU.PCBase = Memory.FillRAM - 0x6000;
+ break;
+ case MAP_SA1RAM:
+ case MAP_LOROM_SRAM:
+ CPU.PCBase = Memory.SRAM;
+ break;
+ case MAP_BWRAM:
+ CPU.PCBase = Memory.BWRAM - 0x6000;
+ break;
+ case MAP_HIROM_SRAM:
+ CPU.PCBase = Memory.SRAM - 0x6000;
+ break;
+ case MAP_C4:
+ CPU.PCBase = Memory.C4RAM - 0x6000;
+ break;
+ default:
+ CPU.PCBase = Memory.SRAM;
+ break;
+ }
}
+
+ CPU.PC = CPU.PCBase + (Address & 0xffff);
}
#endif
diff --git a/source/gfx.c b/source/gfx.c
index f4848f3..5bd1a57 100644
--- a/source/gfx.c
+++ b/source/gfx.c
@@ -171,7 +171,7 @@ bool S9xInitGFX()
uint8_t bitshift;
for (bitshift = 0; bitshift < 4; bitshift++)
{
- int i;
+ int32_t i;
for (i = 0; i < 16; i++)
{
uint32_t h = 0;
@@ -296,12 +296,12 @@ bool S9xInitGFX()
{
if (GFX.ZERO_OR_X2)
{
- free((char*) GFX.ZERO_OR_X2);
+ free(GFX.ZERO_OR_X2);
GFX.ZERO_OR_X2 = NULL;
}
if (GFX.X2)
{
- free((char*) GFX.X2);
+ free(GFX.X2);
GFX.X2 = NULL;
}
return (false);
@@ -444,17 +444,17 @@ void S9xDeinitGFX(void)
// Free any memory allocated in S9xInitGFX
if (GFX.X2)
{
- free((char*) GFX.X2);
+ free(GFX.X2);
GFX.X2 = NULL;
}
if (GFX.ZERO_OR_X2)
{
- free((char*) GFX.ZERO_OR_X2);
+ free(GFX.ZERO_OR_X2);
GFX.ZERO_OR_X2 = NULL;
}
if (GFX.ZERO)
{
- free((char*) GFX.ZERO);
+ free(GFX.ZERO);
GFX.ZERO = NULL;
}
}
@@ -698,8 +698,8 @@ static inline void SelectTileRenderer(bool normal)
void S9xSetupOBJ()
{
- int SmallWidth, SmallHeight;
- int LargeWidth, LargeHeight;
+ int32_t SmallWidth, SmallHeight;
+ int32_t LargeWidth, LargeHeight;
switch (PPU.OBJSizeSelect)
{
@@ -750,7 +750,7 @@ void S9xSetupOBJ()
* normal FirstSprite, or priority is FirstSprite+Y. The first two are
* easy, the last is somewhat more ... interesting. So we split them up. */
- int Height;
+ int32_t Height;
uint8_t S;
if (!PPU.OAMPriorityRotation || !(PPU.OAMFlip & PPU.OAMAddr & 1))
@@ -758,7 +758,7 @@ void S9xSetupOBJ()
/* normal case */
uint8_t LineOBJ[SNES_HEIGHT_EXTENDED];
memset(LineOBJ, 0, sizeof(LineOBJ));
- int i;
+ int32_t i;
for (i = 0; i < SNES_HEIGHT_EXTENDED; i++)
{
GFX.OBJLines[i].RTOFlags = 0;
@@ -778,7 +778,7 @@ void S9xSetupOBJ()
GFX.OBJWidths[S] = SmallWidth;
Height = SmallHeight;
}
- int HPos = PPU.OBJ[S].HPos;
+ int32_t HPos = PPU.OBJ[S].HPos;
if (HPos == -256) HPos = 256;
if (HPos > -GFX.OBJWidths[S] && HPos <= 256)
{
@@ -815,7 +815,7 @@ void S9xSetupOBJ()
}
while (S != FirstSprite);
- int Y;
+ int32_t Y;
for (Y = 0; Y < SNES_HEIGHT_EXTENDED; Y++)
{
if (LineOBJ[Y] < 32) // Add the sentinel
@@ -848,7 +848,7 @@ void S9xSetupOBJ()
GFX.OBJWidths[S] = SmallWidth;
Height = SmallHeight;
}
- int HPos = PPU.OBJ[S].HPos;
+ int32_t HPos = PPU.OBJ[S].HPos;
if (HPos == -256) HPos = 256;
if (HPos > -GFX.OBJWidths[S] && HPos <= 256)
{
@@ -880,7 +880,7 @@ void S9xSetupOBJ()
}
/* Now go through and pull out those OBJ that are actually visible. */
- int j, Y;
+ int32_t j, Y;
for (Y = 0; Y < SNES_HEIGHT_EXTENDED; Y++)
{
GFX.OBJLines[Y].RTOFlags = Y ? GFX.OBJLines[Y - 1].RTOFlags : 0;
@@ -937,7 +937,7 @@ static void DrawOBJS(bool OnMain, uint8_t D)
bool Value;
} Windows[7];
- int clipcount = GFX.pCurrentClip->Count [4];
+ int32_t clipcount = GFX.pCurrentClip->Count [4];
if (!clipcount)
{
Windows[0].Pos = 0;
@@ -951,12 +951,12 @@ static void DrawOBJS(bool OnMain, uint8_t D)
{
Windows[0].Pos = 1000;
Windows[0].Value = false;
- int clip, i;
+ int32_t clip, i;
for (clip = 0, i = 1; clip < clipcount; clip++)
{
if (GFX.pCurrentClip->Right[clip][4] <= GFX.pCurrentClip->Left[clip][4])
continue;
- int j;
+ int32_t j;
for (j = 0; j < i && Windows[j].Pos < GFX.pCurrentClip->Left[clip][4]; j++);
if (j < i && Windows[j].Pos == GFX.pCurrentClip->Left[clip][4])
Windows[j].Value = true;
@@ -1026,13 +1026,9 @@ static void DrawOBJS(bool OnMain, uint8_t D)
for (Y = GFX.StartY, Offset = Y * GFX.PPL; Y <= GFX.EndY;
Y++, Offset += GFX.PPL)
{
- int I = 0;
-#ifdef MK_DISABLE_TIME_OVER
- int tiles = 0;
-#else
- int tiles = GFX.OBJLines[Y].Tiles;
-#endif
- int S;
+ int32_t I = 0;
+ int32_t tiles = GFX.OBJLines[Y].Tiles;
+ int32_t S;
for (S = GFX.OBJLines[Y].OBJ[I].Sprite; S >= 0
&& I < 32; S = GFX.OBJLines[Y].OBJ[++I].Sprite)
{
@@ -1043,11 +1039,11 @@ static void DrawOBJS(bool OnMain, uint8_t D)
if (OnMain && SUB_OR_ADD(4))
SelectTileRenderer(!GFX.Pseudo && PPU.OBJ [S].Palette < 4);
- int BaseTile = (((GFX.OBJLines[Y].OBJ[I].Line << 1) + (PPU.OBJ[S].Name & 0xf0))
- & 0xf0) | (PPU.OBJ[S].Name & 0x100) | (PPU.OBJ[S].Palette << 10);
- int TileX = PPU.OBJ[S].Name & 0x0f;
- int TileLine = (GFX.OBJLines[Y].OBJ[I].Line & 7) * 8;
- int TileInc = 1;
+ int32_t BaseTile = (((GFX.OBJLines[Y].OBJ[I].Line << 1) + (PPU.OBJ[S].Name & 0xf0))
+ & 0xf0) | (PPU.OBJ[S].Name & 0x100) | (PPU.OBJ[S].Palette << 10);
+ int32_t TileX = PPU.OBJ[S].Name & 0x0f;
+ int32_t TileLine = (GFX.OBJLines[Y].OBJ[I].Line & 7) * 8;
+ int32_t TileInc = 1;
if (PPU.OBJ[S].HFlip)
{
@@ -1059,10 +1055,10 @@ static void DrawOBJS(bool OnMain, uint8_t D)
GFX.Z2 = (PPU.OBJ[S].Priority + 1) * 4 + D;
bool WinStat = true;
- int WinIdx = 0, NextPos = -1000;
- int X = PPU.OBJ[S].HPos;
+ int32_t WinIdx = 0, NextPos = -1000;
+ int32_t X = PPU.OBJ[S].HPos;
if (X == -256) X = 256;
- int t, O;
+ int32_t t, O;
for (t = tiles, O = Offset + X * GFX.PixSize; X <= 256
&& X < PPU.OBJ[S].HPos + GFX.OBJWidths[S];
TileX = (TileX + TileInc) & 0x0f, X += 8, O += 8 * GFX.PixSize)
@@ -1082,7 +1078,7 @@ static void DrawOBJS(bool OnMain, uint8_t D)
}
else
{
- int x = X;
+ int32_t x = X;
while (x < X + 8)
{
if (WinStat)(*DrawClippedTilePtr)(BaseTile | TileX, O, x - X, NextPos - x,
@@ -1157,7 +1153,7 @@ static void DrawBackgroundMosaic(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8
OffsetShift = 3;
}
- int m5 = (BGMode == 5 || BGMode == 6) ? 1 : 0;
+ int32_t m5 = (BGMode == 5 || BGMode == 6) ? 1 : 0;
uint32_t Y;
for (Y = GFX.StartY; Y <= GFX.EndY; Y += Lines)
@@ -1341,7 +1337,7 @@ static void DrawBackgroundOffset(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8
uint16_t* BPS2;
uint16_t* BPS3;
uint32_t Width;
- int VOffsetOffset = BGMode == 4 ? 0 : 32;
+ int32_t VOffsetOffset = BGMode == 4 ? 0 : 32;
uint8_t depths [2] = {Z1, Z2};
BG.StartPalette = 0;
@@ -1392,10 +1388,10 @@ static void DrawBackgroundOffset(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8
SC3 -= 0x08000;
- static const int Lines = 1;
- int OffsetMask;
- int OffsetShift;
- int OffsetEnableMask = 1 << (bg + 13);
+ static const int32_t Lines = 1;
+ int32_t OffsetMask;
+ int32_t OffsetShift;
+ int32_t OffsetEnableMask = 1 << (bg + 13);
if (BG.TileSize == 16)
{
@@ -1414,10 +1410,10 @@ static void DrawBackgroundOffset(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8
uint32_t VOff = LineData [Y].BG[2].VOffset - 1;
uint32_t HOff = LineData [Y].BG[2].HOffset;
- int VirtAlign;
- int ScreenLine = VOff >> 3;
- int t1;
- int t2;
+ int32_t VirtAlign;
+ int32_t ScreenLine = VOff >> 3;
+ int32_t t1;
+ int32_t t2;
uint16_t* s0;
uint16_t* s1;
uint16_t* s2;
@@ -1443,11 +1439,11 @@ static void DrawBackgroundOffset(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8
VOffsetOffset = 32;
}
- int clipcount = GFX.pCurrentClip->Count [bg];
+ int32_t clipcount = GFX.pCurrentClip->Count [bg];
if (!clipcount)
clipcount = 1;
- int clip;
+ int32_t clip;
for (clip = 0; clip < clipcount; clip++)
{
uint32_t Left;
@@ -1676,7 +1672,7 @@ static void DrawBackgroundMode5(uint32_t bg, uint8_t Z1, uint8_t Z2)
else
SC1 = SC0;
- if ((SC1 - (unsigned short*)Memory.VRAM) > 0x10000)
+ if ((SC1 - (uint16_t*)Memory.VRAM) > 0x10000)
SC1 = (uint16_t*)&Memory.VRAM[(((uint8_t*)SC1) - Memory.VRAM) % 0x10000];
if ((PPU.BG[bg].SCSize & 2))
@@ -1686,8 +1682,6 @@ static void DrawBackgroundMode5(uint32_t bg, uint8_t Z1, uint8_t Z2)
if (((uint8_t*)SC2 - Memory.VRAM) >= 0x10000)
SC2 -= 0x08000;
-
-
if ((PPU.BG[bg].SCSize & 1))
SC3 = SC2 + 1024;
else
@@ -1696,24 +1690,22 @@ static void DrawBackgroundMode5(uint32_t bg, uint8_t Z1, uint8_t Z2)
if (((uint8_t*)SC3 - Memory.VRAM) >= 0x10000)
SC3 -= 0x08000;
-
-
- int Lines;
- int VOffsetShift;
+ int32_t Lines;
+ int32_t VOffsetShift;
if (BG.TileSize == 16)
VOffsetShift = 4;
else
VOffsetShift = 3;
- int endy = IPPU.Interlace ? 1 + (GFX.EndY << 1) : GFX.EndY;
+ int32_t endy = IPPU.Interlace ? 1 + (GFX.EndY << 1) : GFX.EndY;
- int Y;
+ int32_t Y;
for (Y = IPPU.Interlace ? GFX.StartY << 1 : GFX.StartY; Y <= endy; Y += Lines)
{
- int y = IPPU.Interlace ? (Y >> 1) : Y;
+ int32_t y = IPPU.Interlace ? (Y >> 1) : Y;
uint32_t VOffset = LineData [y].BG[bg].VOffset;
uint32_t HOffset = LineData [y].BG[bg].HOffset;
- int VirtAlign = (Y + VOffset) & 7;
+ int32_t VirtAlign = (Y + VOffset) & 7;
for (Lines = 1; Lines < 8 - VirtAlign; Lines++)
if ((VOffset != LineData [y + Lines].BG[bg].VOffset) ||
@@ -1725,9 +1717,9 @@ static void DrawBackgroundMode5(uint32_t bg, uint8_t Z1, uint8_t Z2)
Lines = endy + 1 - Y;
VirtAlign <<= 3;
- int ScreenLine = (VOffset + Y) >> VOffsetShift;
- int t1;
- int t2;
+ int32_t ScreenLine = (VOffset + Y) >> VOffsetShift;
+ int32_t t1;
+ int32_t t2;
if (((VOffset + Y) & 15) > 7)
{
t1 = 16;
@@ -1749,15 +1741,15 @@ static void DrawBackgroundMode5(uint32_t bg, uint8_t Z1, uint8_t Z2)
b1 += (ScreenLine & 0x1f) << 5;
b2 += (ScreenLine & 0x1f) << 5;
- int clipcount = GFX.pCurrentClip->Count [bg];
+ int32_t clipcount = GFX.pCurrentClip->Count [bg];
if (!clipcount)
clipcount = 1;
- int clip;
+ int32_t clip;
for (clip = 0; clip < clipcount; clip++)
{
- int Left;
- int Right;
+ int32_t Left;
+ int32_t Right;
if (!GFX.pCurrentClip->Count [bg])
{
@@ -1790,7 +1782,7 @@ static void DrawBackgroundMode5(uint32_t bg, uint8_t Z1, uint8_t Z2)
// Left hand edge clipped tile
if (HPos & 7)
{
- int Offset = (HPos & 7);
+ int32_t Offset = (HPos & 7);
Count = 8 - Offset;
if (Count > Width)
Count = Width;
@@ -1855,10 +1847,10 @@ static void DrawBackgroundMode5(uint32_t bg, uint8_t Z1, uint8_t Z2)
// Middle, unclipped tiles
Count = Width - Count;
- int Middle = Count >> 3;
+ int32_t Middle = Count >> 3;
Count &= 7;
- int C;
+ int32_t C;
for (C = Middle; C > 0; s += (IPPU.HalfWidthPixels ? 4 : 8), Quot++, C--)
{
Tile = READ_2BYTES(t);
@@ -2029,7 +2021,7 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
else
SC1 = SC0;
- if (SC1 >= (unsigned short*)(Memory.VRAM + 0x10000))
+ if (SC1 >= (uint16_t*)(Memory.VRAM + 0x10000))
SC1 = (uint16_t*)&Memory.VRAM[((uint8_t*)SC1 - &Memory.VRAM[0]) % 0x10000];
if (PPU.BG[bg].SCSize & 2)
@@ -2048,11 +2040,9 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
if (((uint8_t*)SC3 - Memory.VRAM) >= 0x10000)
SC3 -= 0x08000;
-
-
- int Lines;
- int OffsetMask;
- int OffsetShift;
+ int32_t Lines;
+ int32_t OffsetMask;
+ int32_t OffsetShift;
if (BG.TileSize == 16)
{
@@ -2070,7 +2060,7 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
{
uint32_t VOffset = LineData [Y].BG[bg].VOffset;
uint32_t HOffset = LineData [Y].BG[bg].HOffset;
- int VirtAlign = (Y + VOffset) & 7;
+ int32_t VirtAlign = (Y + VOffset) & 7;
for (Lines = 1; Lines < 8 - VirtAlign; Lines++)
if ((VOffset != LineData [Y + Lines].BG[bg].VOffset) ||
@@ -2106,10 +2096,10 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
b1 += (ScreenLine & 0x1f) << 5;
b2 += (ScreenLine & 0x1f) << 5;
- int clipcount = GFX.pCurrentClip->Count [bg];
+ int32_t clipcount = GFX.pCurrentClip->Count [bg];
if (!clipcount)
clipcount = 1;
- int clip;
+ int32_t clip;
for (clip = 0; clip < clipcount; clip++)
{
uint32_t Left;
@@ -2221,9 +2211,9 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
// Middle, unclipped tiles
Count = Width - Count;
- int Middle = Count >> 3;
+ int32_t Middle = Count >> 3;
Count &= 7;
- int C;
+ int32_t C;
for (C = Middle; C > 0;
s += (IPPU.HalfWidthPixels ? 4 : 8) * GFX.PixSize, Quot++, C--)
{
@@ -2344,9 +2334,9 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
ScreenColors = DirectColourMaps [0]; \
} \
\
- int aa, cc; \
- int dir; \
- int startx, endx; \
+ int32_t aa, cc; \
+ int32_t dir; \
+ int32_t startx, endx; \
uint32_t Left = 0; \
uint32_t Right = 256; \
uint32_t ClipCount = GFX.pCurrentClip->Count [bg]; \
@@ -2361,7 +2351,7 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
uint32_t Line; \
for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX.Pitch, Depth += GFX.PPL, l++) \
{ \
- int yy; \
+ int32_t yy; \
\
int32_t HOffset = ((int32_t) LineData [Line].BG[0].HOffset << M7) >> M7; \
int32_t VOffset = ((int32_t) LineData [Line].BG[0].VOffset << M7) >> M7; \
@@ -2370,14 +2360,14 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
int32_t CentreY = ((int32_t) l->CentreY << M7) >> M7; \
\
if (PPU.Mode7VFlip) \
- yy = 255 - (int) Line; \
+ yy = 255 - (int32_t) Line; \
else \
yy = Line; \
\
yy += CLIP_10_BIT_SIGNED(VOffset - CentreY); \
\
- int BB = l->MatrixB * yy + (CentreX << 8); \
- int DD = l->MatrixD * yy + (CentreY << 8); \
+ int32_t BB = l->MatrixB * yy + (CentreX << 8); \
+ int32_t DD = l->MatrixD * yy + (CentreY << 8); \
\
uint32_t clip; \
for (clip = 0; clip < ClipCount; clip++) \
@@ -2409,17 +2399,17 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
cc = l->MatrixC; \
} \
\
- int xx = startx + CLIP_10_BIT_SIGNED(HOffset - CentreX); \
- int AA = l->MatrixA * xx; \
- int CC = l->MatrixC * xx; \
+ int32_t xx = startx + CLIP_10_BIT_SIGNED(HOffset - CentreX); \
+ int32_t AA = l->MatrixA * xx; \
+ int32_t CC = l->MatrixC * xx; \
\
if (!PPU.Mode7Repeat) \
{ \
- int x; \
+ int32_t x; \
for (x = startx; x != endx; x += dir, AA += aa, CC += cc, p++, d++) \
{ \
- int X = ((AA + BB) >> 8) & 0x3ff; \
- int Y = ((CC + DD) >> 8) & 0x3ff; \
+ int32_t X = ((AA + BB) >> 8) & 0x3ff; \
+ int32_t Y = ((CC + DD) >> 8) & 0x3ff; \
uint8_t *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
uint32_t b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
@@ -2432,11 +2422,11 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
} \
else \
{ \
- int x; \
+ int32_t x; \
for (x = startx; x != endx; x += dir, AA += aa, CC += cc, p++, d++) \
{ \
- int X = ((AA + BB) >> 8); \
- int Y = ((CC + DD) >> 8); \
+ int32_t X = ((AA + BB) >> 8); \
+ int32_t Y = ((CC + DD) >> 8); \
\
if (((X | Y) & ~0x3ff) == 0) \
{ \
@@ -2469,17 +2459,17 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
} \
}
-static void DrawBGMode7Background(uint8_t* Screen, int bg)
+static void DrawBGMode7Background(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7(uint8_t, (uint8_t)(b & GFX.Mode7Mask))
}
-static void DrawBGMode7Background16(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7(uint16_t, ScreenColors [b & GFX.Mode7Mask]);
}
-static void DrawBGMode7Background16Add(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16Add(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7(uint16_t, *(d + GFX.DepthDelta) ?
(*(d + GFX.DepthDelta) != 1 ?
@@ -2490,7 +2480,7 @@ static void DrawBGMode7Background16Add(uint8_t* Screen, int bg)
ScreenColors [b & GFX.Mode7Mask]);
}
-static void DrawBGMode7Background16Add1_2(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16Add1_2(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7(uint16_t, *(d + GFX.DepthDelta) ?
(*(d + GFX.DepthDelta) != 1 ?
@@ -2501,7 +2491,7 @@ static void DrawBGMode7Background16Add1_2(uint8_t* Screen, int bg)
ScreenColors [b & GFX.Mode7Mask]);
}
-static void DrawBGMode7Background16Sub(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16Sub(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7(uint16_t, *(d + GFX.DepthDelta) ?
(*(d + GFX.DepthDelta) != 1 ?
@@ -2512,7 +2502,7 @@ static void DrawBGMode7Background16Sub(uint8_t* Screen, int bg)
ScreenColors [b & GFX.Mode7Mask]);
}
-static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7(uint16_t, *(d + GFX.DepthDelta) ?
(*(d + GFX.DepthDelta) != 1 ?
@@ -2535,9 +2525,9 @@ static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int bg)
else \
ScreenColors = IPPU.ScreenColors; \
\
- int aa, cc; \
- int dir; \
- int startx, endx; \
+ int32_t aa, cc; \
+ int32_t dir; \
+ int32_t startx, endx; \
uint32_t Left = 0; \
uint32_t Right = 256; \
uint32_t ClipCount = GFX.pCurrentClip->Count [bg]; \
@@ -2558,24 +2548,24 @@ static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int bg)
uint32_t Line; \
for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX.Pitch, Depth += GFX.PPL, l++) \
{ \
- int yy; \
+ int32_t yy; \
\
- int HOffset = ((int) LineData [Line].BG[0].HOffset << M7) >> M7; \
- int VOffset = ((int) LineData [Line].BG[0].VOffset << M7) >> M7; \
+ int32_t HOffset = ((int32_t) LineData [Line].BG[0].HOffset << M7) >> M7; \
+ int32_t VOffset = ((int32_t) LineData [Line].BG[0].VOffset << M7) >> M7; \
\
- int CentreX = ((int) l->CentreX << M7) >> M7; \
- int CentreY = ((int) l->CentreY << M7) >> M7; \
+ int32_t CentreX = ((int32_t) l->CentreX << M7) >> M7; \
+ int32_t CentreY = ((int32_t) l->CentreY << M7) >> M7; \
\
if (PPU.Mode7VFlip) \
- yy = 255 - (int) Line; \
+ yy = 255 - (int32_t) Line; \
else \
yy = Line; \
\
\
yy += CLIP_10_BIT_SIGNED(VOffset - CentreY); \
bool simpleCase = false; \
- int BB; \
- int DD; \
+ int32_t BB; \
+ int32_t DD; \
/* Make a special case for the identity matrix, since it's a common case and */ \
/* can be done much more quickly without special effects */ \
if (allowSimpleCase && !l->MatrixB && !l->MatrixC && (l->MatrixA == 0x0100) && (l->MatrixD == 0x0100)) \
@@ -2619,10 +2609,10 @@ static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int bg)
aa = l->MatrixA; \
cc = l->MatrixC; \
} \
- int xx; \
+ int32_t xx; \
\
xx = startx + CLIP_10_BIT_SIGNED(HOffset - CentreX); \
- int AA, CC = 0; \
+ int32_t AA, CC = 0; \
if (simpleCase) \
{ \
AA = xx << 8; \
@@ -2636,11 +2626,11 @@ static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int bg)
{ \
if (!PPU.Mode7Repeat) \
{ \
- int x = startx; \
+ int32_t x = startx; \
do \
{ \
- int X = ((AA + BB) >> 8) & 0x3ff; \
- int Y = (DD >> 8) & 0x3ff; \
+ int32_t X = ((AA + BB) >> 8) & 0x3ff; \
+ int32_t Y = (DD >> 8) & 0x3ff; \
uint8_t *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
uint32_t b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
@@ -2656,10 +2646,10 @@ static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int bg)
} \
else \
{ \
- int x = startx; \
+ int32_t x = startx; \
do { \
- int X = (AA + BB) >> 8; \
- int Y = DD >> 8; \
+ int32_t X = (AA + BB) >> 8; \
+ int32_t Y = DD >> 8; \
\
if (((X | Y) & ~0x3ff) == 0) \
{ \
@@ -2706,7 +2696,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int bg)
/* You can think of this as a kind of mipmapping. */ \
if ((aa < 460 && aa > -460) && (cc < 460 && cc > -460)) \
{\
- int x; \
+ int32_t x; \
for (x = startx; x != endx; x += dir, AA += aa, CC += cc, p++, d++) \
{ \
uint32_t xPos = AA + BB; \
@@ -2785,7 +2775,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int bg)
uint32_t DD10 = DD + ccDelX; \
uint32_t DD01 = DD + ddDelY; \
uint32_t DD11 = DD + ccDelX + ddDelY; \
- int x; \
+ int32_t x; \
for (x = startx; x != endx; x += dir, AA += aa, CC += cc, p++, d++) \
{ \
uint32_t X = ((AA + BB) >> 8) & 0x3ff; \
@@ -2822,7 +2812,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int bg)
} \
else \
{ \
- int x; \
+ int32_t x; \
for (x = startx; x != endx; x += dir, AA += aa, CC += cc, p++, d++) \
{ \
uint32_t xPos = AA + BB; \
@@ -2909,12 +2899,12 @@ static uint32_t Q_INTERPOLATE(uint32_t A, uint32_t B, uint32_t C, uint32_t D)
return x + y;
}
-static void DrawBGMode7Background16_i(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16_i(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7_i(uint16_t, theColor, (ScreenColors[b & GFX.Mode7Mask]));
}
-static void DrawBGMode7Background16Add_i(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16Add_i(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7_i(uint16_t, *(d + GFX.DepthDelta) ?
(*(d + GFX.DepthDelta) != 1 ?
@@ -2925,7 +2915,7 @@ static void DrawBGMode7Background16Add_i(uint8_t* Screen, int bg)
theColor, (ScreenColors[b & GFX.Mode7Mask]));
}
-static void DrawBGMode7Background16Add1_2_i(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16Add1_2_i(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7_i(uint16_t, *(d + GFX.DepthDelta) ?
(*(d + GFX.DepthDelta) != 1 ?
@@ -2936,7 +2926,7 @@ static void DrawBGMode7Background16Add1_2_i(uint8_t* Screen, int bg)
theColor, (ScreenColors[b & GFX.Mode7Mask]));
}
-static void DrawBGMode7Background16Sub_i(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16Sub_i(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7_i(uint16_t, *(d + GFX.DepthDelta) ?
(*(d + GFX.DepthDelta) != 1 ?
@@ -2947,7 +2937,7 @@ static void DrawBGMode7Background16Sub_i(uint8_t* Screen, int bg)
theColor, (ScreenColors[b & GFX.Mode7Mask]));
}
-static void DrawBGMode7Background16Sub1_2_i(uint8_t* Screen, int bg)
+static void DrawBGMode7Background16Sub1_2_i(uint8_t* Screen, int32_t bg)
{
RENDER_BACKGROUND_MODE7_i(uint16_t, *(d + GFX.DepthDelta) ?
(*(d + GFX.DepthDelta) != 1 ?
@@ -3049,7 +3039,7 @@ static void RenderScreen(uint8_t* Screen, bool sub, bool force_no_add, uint8_t D
}
if (BG0 || ((Memory.FillRAM [0x2133] & 0x40) && BG1))
{
- int bg;
+ int32_t bg;
if ((Memory.FillRAM [0x2133] & 0x40) && BG1)
{
@@ -3184,7 +3174,7 @@ void S9xUpdateScreen(void)
uint32_t y;
for (y = 0; y < starty; y++)
{
- int x;
+ int32_t x;
uint16_t* p = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 255;
uint16_t* q = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 510;
for (x = 255; x >= 0; x--, p--, q -= 2)
@@ -3672,7 +3662,7 @@ void S9xUpdateScreen(void)
uint32_t y;
for (y = starty; y <= endy; y++)
{
- int x;
+ int32_t x;
uint16_t* p = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 255;
uint16_t* q = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 510;
for (x = 255; x >= 0; x--, p--, q -= 2)
diff --git a/source/gfx.h b/source/gfx.h
index c840d58..c5f50cb 100644
--- a/source/gfx.h
+++ b/source/gfx.h
@@ -14,8 +14,7 @@ void S9xUpdateScreen();
void RenderLine(uint8_t line);
void S9xBuildDirectColourMaps();
-// External port interface which must be implemented or initialised for each
-// port.
+// External port interface which must be implemented or initialised for each port.
extern struct SGFX GFX;
bool S9xInitGFX();
@@ -37,7 +36,7 @@ struct SGFX
uint32_t Pitch;
// Setup in call to S9xInitGFX()
- int Delta;
+ int32_t Delta;
uint16_t* X2;
uint16_t* ZERO_OR_X2;
uint16_t* ZERO;
@@ -118,12 +117,12 @@ typedef struct
struct SLineMatrixData
{
- short MatrixA;
- short MatrixB;
- short MatrixC;
- short MatrixD;
- short CentreX;
- short CentreY;
+ int16_t MatrixA;
+ int16_t MatrixB;
+ int16_t MatrixC;
+ int16_t MatrixD;
+ int16_t CentreX;
+ int16_t CentreY;
};
extern uint32_t odd_high [4][16];
diff --git a/source/globals.c b/source/globals.c
index e65d1b5..eecb297 100644
--- a/source/globals.c
+++ b/source/globals.c
@@ -41,7 +41,7 @@ SnesModel* Model = &M1SNES;
uint8_t* C4RAM = NULL;
-long OpAddress = 0;
+int32_t OpAddress = 0;
CMemory Memory;
@@ -97,7 +97,7 @@ uint16_t SignExtend [2] =
};
//modified per anomie Mode 5 findings
-int HDMA_ModeByteCounts [8] =
+int32_t HDMA_ModeByteCounts [8] =
{
1, 2, 2, 4, 4, 4, 2, 4
};
@@ -163,7 +163,7 @@ uint8_t BGSizes [2] =
};
uint16_t DirectColourMaps [8][256];
-long FilterValues[4][2] =
+int32_t FilterValues[4][2] =
{
{0, 0},
{240, 0},
diff --git a/source/memmap.c b/source/memmap.c
index 81093df..4a96f66 100644
--- a/source/memmap.c
+++ b/source/memmap.c
@@ -35,12 +35,12 @@ extern struct FxInit_s SuperFX;
#define SET_UI_COLOR(r,g,b) ;
#endif
-static int retry_count = 0;
+static int32_t retry_count = 0;
static uint8_t bytes0x2000 [0x2000];
-int is_bsx(unsigned char*);
-int bs_name(unsigned char*);
+int32_t is_bsx(uint8_t*);
+int32_t bs_name(uint8_t*);
-static int check_char(unsigned c)
+static int32_t check_char(uint32_t c)
{
if ((c & 0x80) == 0)
return 0;
@@ -101,7 +101,7 @@ const uint32_t crc32Table[256] =
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
-void S9xDeinterleaveType1(int TotalFileSize, uint8_t* base)
+void S9xDeinterleaveType1(int32_t TotalFileSize, uint8_t* base)
{
if (Settings.DisplayColor == 0xffff)
{
@@ -109,8 +109,8 @@ void S9xDeinterleaveType1(int TotalFileSize, uint8_t* base)
SET_UI_COLOR(0, 255, 0);
}
- int i;
- int nblocks = TotalFileSize >> 16;
+ int32_t i;
+ int32_t nblocks = TotalFileSize >> 16;
uint8_t blocks [256];
for (i = 0; i < nblocks; i++)
{
@@ -123,7 +123,7 @@ void S9xDeinterleaveType1(int TotalFileSize, uint8_t* base)
{
for (i = 0; i < nblocks * 2; i++)
{
- int j;
+ int32_t j;
for (j = i; j < nblocks * 2; j++)
{
if (blocks [j] == i)
@@ -143,13 +143,12 @@ void S9xDeinterleaveType1(int TotalFileSize, uint8_t* base)
}
}
}
- free((char*) tmp);
+ free(tmp);
}
}
-void S9xDeinterleaveGD24(int TotalFileSize, uint8_t* base)
+void S9xDeinterleaveGD24(int32_t TotalFileSize, uint8_t* base)
{
-
if (TotalFileSize != 0x300000)
return;
@@ -171,15 +170,15 @@ void S9xDeinterleaveGD24(int TotalFileSize, uint8_t* base)
memcpy(&base[0x200000], &base[0x280000], 0x80000);
// memmove converted: Different mallocs [Neb]
memcpy(&base[0x280000], tmp, 0x80000);
- free((char*) tmp);
+ free(tmp);
S9xDeinterleaveType1(TotalFileSize, base);
}
}
-static bool AllASCII(uint8_t* b, int size)
+static bool AllASCII(uint8_t* b, int32_t size)
{
- int i;
+ int32_t i;
for (i = 0; i < size; i++)
{
if (b[i] < 32 || b[i] > 126)
@@ -188,10 +187,10 @@ static bool AllASCII(uint8_t* b, int size)
return (true);
}
-static int ScoreHiROM(bool skip_header, int32_t romoff)
+static int32_t ScoreHiROM(bool skip_header, int32_t romoff)
{
- int score = 0;
- int o = skip_header ? 0xff00 + 0x200 : 0xff00;
+ int32_t score = 0;
+ int32_t o = skip_header ? 0xff00 + 0x200 : 0xff00;
o += romoff;
@@ -233,10 +232,10 @@ static int ScoreHiROM(bool skip_header, int32_t romoff)
return (score);
}
-static int ScoreLoROM(bool skip_header, int32_t romoff)
+static int32_t ScoreLoROM(bool skip_header, int32_t romoff)
{
- int score = 0;
- int o = skip_header ? 0x7f00 + 0x200 : 0x7f00;
+ int32_t score = 0;
+ int32_t o = skip_header ? 0x7f00 + 0x200 : 0x7f00;
o += romoff;
@@ -278,26 +277,26 @@ static int ScoreLoROM(bool skip_header, int32_t romoff)
static char* Safe(const char* s)
{
static char* safe;
- static int safe_len = 0;
+ static int32_t safe_len = 0;
if (s == NULL)
{
if (safe != NULL)
{
- free((char*)safe);
+ free(safe);
safe = NULL;
}
return NULL;
}
- int len = strlen(s);
+ int32_t len = strlen(s);
if (!safe || len + 1 > safe_len)
{
if (safe)
- free((char*) safe);
+ free(safe);
safe = (char*) malloc(safe_len = len + 1);
}
- int i;
+ int32_t i;
for (i = 0; i < len; i++)
{
if (s [i] >= 32 && s [i] < 127)
@@ -391,65 +390,65 @@ void S9xDeinitMemory()
{
if (Memory.RAM)
{
- free((char*) Memory.RAM);
+ free(Memory.RAM);
Memory.RAM = NULL;
}
if (Memory.SRAM)
{
- free((char*) Memory.SRAM);
+ free(Memory.SRAM);
Memory.SRAM = NULL;
}
if (Memory.VRAM)
{
- free((char*) Memory.VRAM);
+ free(Memory.VRAM);
Memory.VRAM = NULL;
}
if (Memory.ROM)
{
Memory.ROM -= 0x8000;
#ifdef DS2_RAM
- AlignedFree((char*) ROM, PtrAdj.ROM);
+ AlignedFree(ROM, PtrAdj.ROM);
#else
- free((char*) Memory.ROM);
+ free(Memory.ROM);
#endif
Memory.ROM = NULL;
}
if (Memory.BSRAM)
{
- free((char*) Memory.BSRAM);
+ free(Memory.BSRAM);
Memory.BSRAM = NULL;
}
if (IPPU.TileCache [TILE_2BIT])
{
- free((char*) IPPU.TileCache [TILE_2BIT]);
+ free(IPPU.TileCache [TILE_2BIT]);
IPPU.TileCache [TILE_2BIT] = NULL;
}
if (IPPU.TileCache [TILE_4BIT])
{
- free((char*) IPPU.TileCache [TILE_4BIT]);
+ free(IPPU.TileCache [TILE_4BIT]);
IPPU.TileCache [TILE_4BIT] = NULL;
}
if (IPPU.TileCache [TILE_8BIT])
{
- free((char*) IPPU.TileCache [TILE_8BIT]);
+ free(IPPU.TileCache [TILE_8BIT]);
IPPU.TileCache [TILE_8BIT] = NULL;
}
if (IPPU.TileCached [TILE_2BIT])
{
- free((char*) IPPU.TileCached [TILE_2BIT]);
+ free(IPPU.TileCached [TILE_2BIT]);
IPPU.TileCached [TILE_2BIT] = NULL;
}
if (IPPU.TileCached [TILE_4BIT])
{
- free((char*) IPPU.TileCached [TILE_4BIT]);
+ free(IPPU.TileCached [TILE_4BIT]);
IPPU.TileCached [TILE_4BIT] = NULL;
}
if (IPPU.TileCached [TILE_8BIT])
{
- free((char*) IPPU.TileCached [TILE_8BIT]);
+ free(IPPU.TileCached [TILE_8BIT]);
IPPU.TileCached [TILE_8BIT] = NULL;
}
FreeSDD1Data();
@@ -460,12 +459,12 @@ void FreeSDD1Data()
{
if (Memory.SDD1Index)
{
- free((char*) Memory.SDD1Index);
+ free(Memory.SDD1Index);
Memory.SDD1Index = NULL;
}
if (Memory.SDD1Data)
{
- free((char*) Memory.SDD1Data);
+ free(Memory.SDD1Data);
Memory.SDD1Data = NULL;
}
}
@@ -473,12 +472,12 @@ void FreeSDD1Data()
#ifndef LOAD_FROM_MEMORY_TEST
/* Read variable size MSB int from a file */
-static long ReadInt(FILE* f, unsigned nbytes)
+static int32_t ReadInt(FILE* f, uint32_t nbytes)
{
- long v = 0;
+ int32_t v = 0;
while (nbytes--)
{
- int c = fgetc(f);
+ int32_t c = fgetc(f);
if (c == EOF)
return -1;
v = (v << 8) | (c & 0xFF);
@@ -488,8 +487,7 @@ static long ReadInt(FILE* f, unsigned nbytes)
#define IPS_EOF 0x00454F46l
-static void CheckForIPSPatch(const char* rom_filename, bool header,
- int32_t* rom_size)
+static void CheckForIPSPatch(const char* rom_filename, bool header, int32_t* rom_size)
{
char dir [_MAX_DIR + 1];
char drive [_MAX_DRIVE + 1];
@@ -497,18 +495,16 @@ static void CheckForIPSPatch(const char* rom_filename, bool header,
char ext [_MAX_EXT + 1];
char fname [_MAX_PATH + 1];
FILE* patch_file = NULL;
- long offset = header ? 512 : 0;
+ int32_t offset = header ? 512 : 0;
_splitpath(rom_filename, drive, dir, name, ext);
_makepath(fname, drive, dir, name, "ips");
if (!(patch_file = fopen(fname, "rb")))
- {
if (!(patch_file = fopen(S9xGetFilename("ips"), "rb")))
return;
- }
- if (fread((unsigned char*)fname, 1, 5, patch_file) != 5 ||
+ if (fread(fname, 1, 5, patch_file) != 5 ||
strncmp(fname, "PATCH", 5) != 0)
{
fclose(patch_file);
@@ -519,9 +515,9 @@ static void CheckForIPSPatch(const char* rom_filename, bool header,
for (;;)
{
- long len;
- long rlen;
- int rchar;
+ int32_t len;
+ int32_t rlen;
+ int32_t rchar;
ofs = ReadInt(patch_file, 3);
if (ofs == -1)
@@ -592,7 +588,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
{
FILE* ROMFile;
int32_t TotalFileSize = 0;
- int len = 0;
+ int32_t len = 0;
char dir [_MAX_DIR + 1];
char drive [_MAX_DRIVE + 1];
@@ -600,7 +596,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
char ext [_MAX_EXT + 1];
char fname [_MAX_PATH + 1];
- unsigned long FileSize = 0;
+ uint32_t FileSize = 0;
_splitpath(filename, drive, dir, name, ext);
_makepath(fname, drive, dir, name, ext);
@@ -624,7 +620,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
FileSize = fread(ptr, 1, maxsize + 0x200 - (ptr - Memory.ROM), ROMFile);
fclose(ROMFile);
- int calc_size = FileSize & ~0x1FFF; // round to the lower 0x2000
+ int32_t calc_size = FileSize & ~0x1FFF; // round to the lower 0x2000
if ((FileSize - calc_size == 512 && !Settings.ForceNoHeader) ||
Settings.ForceHeader)
@@ -634,7 +630,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
#ifdef DS2_DMA
__dcache_writeback_all();
{
- unsigned int i;
+ uint32_t i;
for (i = 0; i < calc_size; i += 512)
{
ds2_DMAcopy_32Byte(2 /* channel: emu internal */, ptr + i, ptr + i + 512, 512);
@@ -724,10 +720,8 @@ bool LoadROM(
bool Tales = false;
uint8_t* RomHeader = Memory.ROM;
-
Memory.ExtendedFormat = NOPE;
-
if (CleanUp7110 != NULL)
(*CleanUp7110)();
@@ -752,8 +746,7 @@ again:
const uint8_t* src = game->data;
Memory.HeaderCount = 0;
- if ((((game->size & 0x1FFF) == 0x200) && !Settings.ForceNoHeader)
- || Settings.ForceHeader)
+ if ((((game->size & 0x1FFF) == 0x200) && !Settings.ForceNoHeader) || Settings.ForceHeader)
{
S9xMessage(S9X_INFO, S9X_HEADERS_INFO,
"Found ROM file header (and ignored it).");
@@ -780,8 +773,7 @@ again:
CheckForIPSPatch(filename, Memory.HeaderCount != 0, &TotalFileSize);
#endif
//fix hacked games here.
- if ((strncmp("HONKAKUHA IGO GOSEI", (char*)&Memory.ROM[0x7FC0], 19) == 0)
- && (Memory.ROM[0x7FD5] != 0x31))
+ if ((strncmp("HONKAKUHA IGO GOSEI", (char*)&Memory.ROM[0x7FC0], 19) == 0) && (Memory.ROM[0x7FD5] != 0x31))
{
Memory.ROM[0x7FD5] = 0x31;
Memory.ROM[0x7FD6] = 0x02;
@@ -790,8 +782,7 @@ again:
S9xMessage(S9X_ERROR, S9X_ROM_CONFUSING_FORMAT_INFO, "Warning! Hacked Dump!");
}
- if ((strncmp("HONKAKUHA IGO GOSEI", (char*)&Memory.ROM[0xFFC0], 19) == 0)
- && (Memory.ROM[0xFFD5] != 0x31))
+ if ((strncmp("HONKAKUHA IGO GOSEI", (char*)&Memory.ROM[0xFFC0], 19) == 0) && (Memory.ROM[0xFFD5] != 0x31))
{
Memory.ROM[0xFFD5] = 0x31;
Memory.ROM[0xFFD6] = 0x02;
@@ -800,8 +791,7 @@ again:
S9xMessage(S9X_ERROR, S9X_ROM_CONFUSING_FORMAT_INFO, "Warning! Hacked Dump!");
}
- if ((Memory.ROM[0x7FD5] == 0x42) && (Memory.ROM[0x7FD6] == 0x13)
- && (strncmp("METAL COMBAT", (char*)&Memory.ROM[0x7FC0], 12) == 0))
+ if ((Memory.ROM[0x7FD5] == 0x42) && (Memory.ROM[0x7FD6] == 0x13) && (strncmp("METAL COMBAT", (char*)&Memory.ROM[0x7FC0], 12) == 0))
{
Settings.DisplayColor = BUILD_PIXEL(31, 0, 0);
SET_UI_COLOR(255, 0, 0);
@@ -841,8 +831,8 @@ again:
}
#endif
- int hi_score=ScoreHiROM(true, 0);
- int lo_score=ScoreLoROM(true, 0);
+ int32_t hi_score = ScoreHiROM(true, 0);
+ int32_t lo_score = ScoreLoROM(true, 0);
if (Memory.HeaderCount == 0 && !Settings.ForceNoHeader &&
((hi_score > lo_score && ScoreHiROM(true, 0) > hi_score) ||
@@ -851,11 +841,10 @@ again:
#ifdef DS2_DMA
__dcache_writeback_all();
{
- unsigned int i;
+ uint32_t i;
for (i = 0; i < TotalFileSize; i += 512)
{
- ds2_DMAcopy_32Byte(2 /* channel: emu internal */, Memory.ROM + i,
- Memory.ROM + i + 512, 512);
+ ds2_DMAcopy_32Byte(2 /* channel: emu internal */, Memory.ROM + i, Memory.ROM + i + 512, 512);
ds2_DMA_wait(2);
ds2_DMA_stop(2);
}
@@ -870,24 +859,18 @@ again:
}
Memory.CalculatedSize = TotalFileSize & ~0x1FFF; // round down to lower 0x2000
- memset(Memory.ROM + Memory.CalculatedSize, 0,
- MAX_ROM_SIZE - Memory.CalculatedSize);
+ memset(Memory.ROM + Memory.CalculatedSize, 0, MAX_ROM_SIZE - Memory.CalculatedSize);
if (Memory.CalculatedSize > 0x400000 &&
- !(Memory.ROM[0x7FD5] == 0x32 && ((Memory.ROM[0x7FD6] & 0xF0) == 0x40))
- && //exclude S-DD1
- !(Memory.ROM[0xFFD5] == 0x3A
- && ((Memory.ROM[0xFFD6] & 0xF0) == 0xF0))) //exclude SPC7110
- {
- //you might be a Jumbo!
- Memory.ExtendedFormat = YEAH;
- }
+ !(Memory.ROM[0x7FD5] == 0x32 && ((Memory.ROM[0x7FD6] & 0xF0) == 0x40)) && //exclude S-DD1
+ !(Memory.ROM[0xFFD5] == 0x3A && ((Memory.ROM[0xFFD6] & 0xF0) == 0xF0))) //exclude SPC7110
+ Memory.ExtendedFormat = YEAH; //you might be a Jumbo!
//If both vectors are invalid, it's type 1 LoROM
- if (Memory.ExtendedFormat == NOPE
- && ((Memory.ROM[0x7FFC] | (Memory.ROM[0x7FFD] << 8)) < 0x8000)
- && ((Memory.ROM[0xFFFC] | (Memory.ROM[0xFFFD] << 8)) < 0x8000))
+ if (Memory.ExtendedFormat == NOPE &&
+ ((Memory.ROM[0x7FFC] | (Memory.ROM[0x7FFD] << 8)) < 0x8000) &&
+ ((Memory.ROM[0xFFFC] | (Memory.ROM[0xFFFD] << 8)) < 0x8000))
{
if (Settings.DisplayColor == 0xffff)
{
@@ -904,7 +887,7 @@ again:
if (Memory.ExtendedFormat != NOPE)
{
- int loromscore, hiromscore, swappedlorom, swappedhirom;
+ int32_t loromscore, hiromscore, swappedlorom, swappedhirom;
loromscore = ScoreLoROM(false, 0);
hiromscore = ScoreHiROM(false, 0);
swappedlorom = ScoreLoROM(false, 0x400000);
@@ -966,30 +949,18 @@ again:
}
// More
- if (!Settings.ForceHiROM && !Settings.ForceLoROM &&
- !Settings.ForceInterleaved && !Settings.ForceInterleaved2 &&
- !Settings.ForceNotInterleaved && !Settings.ForcePAL &&
- !Settings.ForceSuperFX && !Settings.ForceDSP1 &&
- !Settings.ForceSA1 && !Settings.ForceC4 &&
- !Settings.ForceSDD1)
+ if (!Settings.ForceHiROM &&
+ !Settings.ForceLoROM &&
+ !Settings.ForceInterleaved &&
+ !Settings.ForceInterleaved2 &&
+ !Settings.ForceNotInterleaved &&
+ !Settings.ForcePAL &&
+ !Settings.ForceSuperFX &&
+ !Settings.ForceDSP1 &&
+ !Settings.ForceSA1 &&
+ !Settings.ForceC4 &&
+ !Settings.ForceSDD1)
{
-
-
-#ifdef DETECT_NASTY_FX_INTERLEAVE
- //MK: Damn. YI trips a BRK currently. Maybe even on a real cart.
-
-#ifdef MSB_FIRST
- if (strncmp((char*) &ROM [0x7fc0], "YOSHI'S ISLAND", 14) == 0
- && (ROM[0x7FDE] + (ROM[0x7FDF] << 8)) == 57611 && ROM[0x10002] == 0xA9)
-#else
- if (strncmp((char*) &ROM [0x7fc0], "YOSHI'S ISLAND", 14) == 0
- && (*(uint16_t*)&ROM[0x7FDE]) == 57611 && ROM[0x10002] == 0xA9)
-#endif
- {
- Interleaved = true;
- Settings.ForceInterleaved2 = true;
- }
-#endif
if (strncmp((char*) &Memory.ROM [0x7fc0], "YUYU NO QUIZ DE GO!GO!", 22) == 0)
{
Memory.LoROM = true;
@@ -1019,8 +990,6 @@ again:
Memory.LoROM = false;
Memory.HiROM = true;
-
-
}
else if (Settings.ForceInterleaved2)
S9xDeinterleaveType2(false);
@@ -1050,10 +1019,8 @@ again:
hi_score = ScoreHiROM(false, 0);
lo_score = ScoreLoROM(false, 0);
- if ((Memory.HiROM &&
- (lo_score >= hi_score || hi_score < 0)) ||
- (Memory.LoROM &&
- (hi_score > lo_score || lo_score < 0)))
+ if ((Memory.HiROM && (lo_score >= hi_score || hi_score < 0)) ||
+ (Memory.LoROM && (hi_score > lo_score || lo_score < 0)))
{
if (retry_count == 0)
{
@@ -1091,8 +1058,7 @@ void S9xDeinterleaveMode2(void)
void S9xDeinterleaveType2(bool reset)
{
- if (Settings.DisplayColor == 0xffff
- || Settings.DisplayColor == BUILD_PIXEL(0, 31, 0))
+ if (Settings.DisplayColor == 0xffff || Settings.DisplayColor == BUILD_PIXEL(0, 31, 0))
{
Settings.DisplayColor = BUILD_PIXEL(31, 14, 6);
SET_UI_COLOR(255, 119, 25);
@@ -1101,15 +1067,15 @@ void S9xDeinterleaveType2(bool reset)
S9xMessage(S9X_INFO, S9X_ROM_INTERLEAVED_INFO,
"ROM image is in interleaved format - converting...");
- int nblocks = Memory.CalculatedSize >> 16;
- int step = 64;
+ int32_t nblocks = Memory.CalculatedSize >> 16;
+ int32_t step = 64;
while (nblocks <= step)
step >>= 1;
nblocks = step;
uint8_t blocks [256];
- int i;
+ int32_t i;
for (i = 0; i < nblocks * 2; i++)
{
@@ -1118,7 +1084,7 @@ void S9xDeinterleaveType2(bool reset)
}
#ifdef DS2_DMA
- unsigned int TmpAdj;
+ uint32_t TmpAdj;
uint8_t* tmp = (uint8_t*) AlignedMalloc(0x10000, 32, &TmpAdj);
#else
uint8_t* tmp = (uint8_t*) malloc(0x10000);
@@ -1131,7 +1097,7 @@ void S9xDeinterleaveType2(bool reset)
#endif
for (i = 0; i < nblocks * 2; i++)
{
- int j;
+ int32_t j;
for (j = i; j < nblocks * 2; j++)
{
if (blocks [j] == i)
@@ -1169,7 +1135,7 @@ void S9xDeinterleaveType2(bool reset)
}
}
}
- free((char*) tmp);
+ free(tmp);
tmp = NULL;
}
if (reset)
@@ -1226,7 +1192,6 @@ void InitROM(bool Interleaved)
Memory.LoROM = true;
Memory.HiROM = false;
}
-
else
{
Settings.BS = (-1 != is_bsx(Memory.ROM + 0xFFC0));
@@ -1269,7 +1234,8 @@ void InitROM(bool Interleaved)
SPC7110HiROMMap();
else if ((Memory.ROMSpeed & ~0x10) == 0x25)
TalesROMMap(Interleaved);
- else HiROMMap();
+ else
+ HiROMMap();
}
else
{
@@ -1332,8 +1298,8 @@ void InitROM(bool Interleaved)
Settings.SDD1 = false;
}
else if (Settings.ForceSA1 ||
- (!Settings.ForceNoSA1 && (Memory.ROMSpeed & ~0x10) == 0x23 &&
- (Memory.ROMType & 0xf) > 3 && (Memory.ROMType & 0xf0) == 0x30))
+ (!Settings.ForceNoSA1 && (Memory.ROMSpeed & ~0x10) == 0x23 &&
+ (Memory.ROMType & 0xf) > 3 && (Memory.ROMType & 0xf0) == 0x30))
{
Settings.SA1 = true;
Settings.DSP1Master = false;
@@ -1351,9 +1317,7 @@ void InitROM(bool Interleaved)
LoROM24MBSMap();
Settings.DSP1Master = false;
}
-
- else if (strncmp((char*) &Memory.ROM [0x7fc0], "THOROUGHBRED BREEDER3",
- 21) == 0 ||
+ else if (strncmp((char*) &Memory.ROM [0x7fc0], "THOROUGHBRED BREEDER3", 21) == 0 ||
strncmp((char*) &Memory.ROM [0x7fc0], "RPG-TCOOL 2", 11) == 0)
{
SRAM512KLoROMMap();
@@ -1373,7 +1337,8 @@ void InitROM(bool Interleaved)
AlphaROMMap();
else if (Settings.BS)
BSLoROMMap();
- else LoROMMap();
+ else
+ LoROMMap();
}
if (Settings.BS)
@@ -1383,8 +1348,8 @@ void InitROM(bool Interleaved)
uint32_t sum2 = 0;
if (0 == Memory.CalculatedChecksum)
{
- int power2 = 0;
- int size = Memory.CalculatedSize;
+ int32_t power2 = 0;
+ int32_t size = Memory.CalculatedSize;
while (size >>= 1)
power2++;
@@ -1392,27 +1357,23 @@ void InitROM(bool Interleaved)
size = 1 << power2;
uint32_t remainder = Memory.CalculatedSize - size;
- int i;
+ int32_t i;
for (i = 0; i < size; i++)
sum1 += Memory.ROM [i];
- for (i = 0; i < (int) remainder; i++)
+ for (i = 0; i < (int32_t) remainder; i++)
sum2 += Memory.ROM [size + i];
- int sub = 0;
+ int32_t sub = 0;
if (Settings.BS && Memory.ROMType != 0xE5)
{
if (Memory.HiROM)
- {
for (i = 0; i < 48; i++)
sub += Memory.ROM[0xffb0 + i];
- }
else if (Memory.LoROM)
- {
for (i = 0; i < 48; i++)
sub += Memory.ROM[0x7fb0 + i];
- }
sum1 -= sub;
}
@@ -1469,13 +1430,11 @@ void InitROM(bool Interleaved)
Memory.SRAMMask = Memory.SRAMSize ?
((1 << (Memory.SRAMSize + 3)) * 128) - 1 : 0;
}
- if ((Memory.ROMChecksum + Memory.ROMComplementChecksum != 0xffff)
- || Memory.ROMChecksum != Memory.CalculatedChecksum
- || ((uint32_t)Memory.CalculatedSize > (uint32_t)(((1 << (Memory.ROMSize - 7)) * 128)
- * 1024)))
+ if ((Memory.ROMChecksum + Memory.ROMComplementChecksum != 0xffff) ||
+ Memory.ROMChecksum != Memory.CalculatedChecksum ||
+ ((uint32_t)Memory.CalculatedSize > (uint32_t)(((1 << (Memory.ROMSize - 7)) * 128) * 1024)))
{
- if (Settings.DisplayColor == 0xffff
- || Settings.DisplayColor != BUILD_PIXEL(31, 0, 0))
+ if (Settings.DisplayColor == 0xffff || Settings.DisplayColor != BUILD_PIXEL(31, 0, 0))
{
Settings.DisplayColor = BUILD_PIXEL(31, 31, 0);
SET_UI_COLOR(255, 255, 0);
@@ -1500,8 +1459,7 @@ void InitROM(bool Interleaved)
"\"%s\" [%s] %s, %s, Type: %s, Mode: %s, TV: %s, S-RAM: %s, ROMId: %s Company: %2.2s CRC32: %08X",
Memory.ROMName,
(Memory.ROMChecksum + Memory.ROMComplementChecksum != 0xffff ||
- Memory.ROMChecksum != Memory.CalculatedChecksum) ? "bad checksum" :
- "checksum ok",
+ Memory.ROMChecksum != Memory.CalculatedChecksum) ? "bad checksum" : "checksum ok",
MapType(),
Size(),
KartContents(),
@@ -1513,16 +1471,15 @@ void InitROM(bool Interleaved)
Memory.ROMCRC32);
S9xMessage(S9X_INFO, S9X_ROM_INFO, String);
-
Settings.ForceHeader = Settings.ForceHiROM = Settings.ForceLoROM =
- Settings.ForceInterleaved = Settings.ForceNoHeader =
- Settings.ForceNotInterleaved =
- Settings.ForceInterleaved2 = false;
+ Settings.ForceInterleaved = Settings.ForceNoHeader =
+ Settings.ForceNotInterleaved =
+ Settings.ForceInterleaved2 = false;
}
void FixROMSpeed()
{
- int c;
+ int32_t c;
if (CPU.FastROMSpeed == 0)
CPU.FastROMSpeed = SLOW_ONE_CYCLE;
@@ -1532,10 +1489,9 @@ void FixROMSpeed()
Memory.MemorySpeed [c] = (uint8_t) CPU.FastROMSpeed;
}
-
void ResetSpeedMap()
{
- int i;
+ int32_t i;
memset(Memory.MemorySpeed, SLOW_ONE_CYCLE, 0x1000);
for (i = 0; i < 0x400; i += 0x10)
{
@@ -1550,33 +1506,27 @@ void ResetSpeedMap()
void WriteProtectROM()
{
// memmove converted: Different mallocs [Neb]
- memcpy((void*) Memory.WriteMap, (void*) Memory.Map, sizeof(Memory.Map));
- int c;
+ memcpy(Memory.WriteMap, Memory.Map, sizeof(Memory.Map));
+ int32_t c;
for (c = 0; c < 0x1000; c++)
- {
if (Memory.BlockIsROM [c])
Memory.WriteMap [c] = (uint8_t*) MAP_NONE;
- }
}
void MapRAM()
{
- int c;
+ int32_t c, i;
if (Memory.LoROM && !Settings.SDD1)
{
// Banks 70->77, S-RAM
for (c = 0; c < 0x0f; c++)
{
- int i;
for (i = 0; i < 8; i++)
{
- Memory.Map [(c << 4) + 0xF00 + i] = Memory.Map [(c << 4) + 0x700 + i] =
- (uint8_t*) MAP_LOROM_SRAM;
- Memory.BlockIsRAM [(c << 4) + 0xF00 + i] = Memory.BlockIsRAM [(c << 4) + 0x700 +
- i] = true;
- Memory.BlockIsROM [(c << 4) + 0xF00 + i] = Memory.BlockIsROM [(c << 4) + 0x700 +
- i] = false;
+ Memory.Map [(c << 4) + 0xF00 + i] = Memory.Map [(c << 4) + 0x700 + i] = (uint8_t*) MAP_LOROM_SRAM;
+ Memory.BlockIsRAM [(c << 4) + 0xF00 + i] = Memory.BlockIsRAM [(c << 4) + 0x700 + i] = true;
+ Memory.BlockIsROM [(c << 4) + 0xF00 + i] = Memory.BlockIsROM [(c << 4) + 0x700 + i] = false;
}
}
}
@@ -1585,7 +1535,6 @@ void MapRAM()
// Banks 70->77, S-RAM
for (c = 0; c < 0x0f; c++)
{
- int i;
for (i = 0; i < 8; i++)
{
Memory.Map [(c << 4) + 0x700 + i] = (uint8_t*) MAP_LOROM_SRAM;
@@ -1609,7 +1558,7 @@ void MapRAM()
void MapExtraRAM()
{
- int c;
+ int32_t c;
// Banks 7e->7f, RAM
for (c = 0; c < 16; c++)
@@ -1643,16 +1592,16 @@ void MapExtraRAM()
void LoROMMap()
{
- int c;
- int i;
- int j;
- int mask[4];
+ int32_t c;
+ int32_t i;
+ int32_t j;
+ int32_t mask[4];
for (j = 0; j < 4; j++)
mask[j] = 0x00ff;
mask[0] = (Memory.CalculatedSize / 0x8000) - 1;
- int x;
+ int32_t x;
bool foundZeros;
bool pastZeros;
@@ -1720,8 +1669,8 @@ void LoROMMap()
for (i = c + 8; i < c + 16; i++)
{
- int e = 3;
- int d = c >> 4;
+ int32_t e = 3;
+ int32_t d = c >> 4;
while (d > mask[0])
{
d &= mask[e];
@@ -1749,21 +1698,19 @@ void LoROMMap()
for (c = 0; c < 0x400; c += 16)
{
for (i = c; i < c + 8; i++)
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) %
- Memory.CalculatedSize];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) % Memory.CalculatedSize];
for (i = c + 8; i < c + 16; i++)
{
- int e = 3;
- int d = (c + 0x400) >> 4;
+ int32_t e = 3;
+ int32_t d = (c + 0x400) >> 4;
while (d > mask[0])
{
d &= mask[e];
e--;
}
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = Memory.ROM + (((
- d) - 1) * 0x8000);
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = Memory.ROM + (((d) - 1) * 0x8000);
}
for (i = c; i < c + 16; i++)
@@ -1779,7 +1726,7 @@ void LoROMMap()
}
}
- int sum = 0, k, l, bankcount;
+ int32_t sum = 0, k, l, bankcount;
bankcount = 1 << (Memory.ROMSize - 7); //Mbits
//safety for corrupt headers
@@ -1802,16 +1749,16 @@ void LoROMMap()
void SetaDSPMap()
{
- int c;
- int i;
- int j;
- int mask[4];
+ int32_t c;
+ int32_t i;
+ int32_t j;
+ int32_t mask[4];
for (j = 0; j < 4; j++)
mask[j] = 0x00ff;
mask[0] = (Memory.CalculatedSize / 0x8000) - 1;
- int x;
+ int32_t x;
bool foundZeros;
bool pastZeros;
@@ -1859,8 +1806,8 @@ void SetaDSPMap()
for (i = c + 8; i < c + 16; i++)
{
- int e = 3;
- int d = c >> 4;
+ int32_t e = 3;
+ int32_t d = c >> 4;
while (d > mask[0])
{
d &= mask[e];
@@ -1876,16 +1823,15 @@ void SetaDSPMap()
{
for (i = c + 8; i < c + 16; i++)
{
- int e = 3;
- int d = (c + 0x400) >> 4;
+ int32_t e = 3;
+ int32_t d = (c + 0x400) >> 4;
while (d > mask[0])
{
d &= mask[e];
e--;
}
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = Memory.ROM + (((
- d) - 1) * 0x8000);
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = Memory.ROM + (((d) - 1) * 0x8000);
}
//only upper half is ROM
@@ -1913,7 +1859,7 @@ void SetaDSPMap()
}
}
- int sum = 0, k, l, bankcount;
+ int32_t sum = 0, k, l, bankcount;
bankcount = 1 << (Memory.ROMSize - 7); //Mbits
//safety for corrupt headers
if (bankcount > 128)
@@ -1935,8 +1881,8 @@ void SetaDSPMap()
void BSLoROMMap()
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
if (Settings.BS)
Memory.SRAMSize = 5;
@@ -2013,11 +1959,11 @@ void BSLoROMMap()
void HiROMMap()
{
- int i;
- int c;
- int j;
+ int32_t i;
+ int32_t c;
+ int32_t j;
- int mask[4];
+ int32_t mask[4];
for (j = 0; j < 4; j++)
mask[j] = 0x00ff;
@@ -2032,7 +1978,7 @@ void HiROMMap()
}
- int x;
+ int32_t x;
bool foundZeros;
bool pastZeros;
@@ -2088,8 +2034,8 @@ void HiROMMap()
for (i = c + 8; i < c + 16; i++)
{
- int e = 3;
- int d = c >> 4;
+ int32_t e = 3;
+ int32_t d = c >> 4;
while (d > mask[0])
{
d &= mask[e];
@@ -2118,8 +2064,8 @@ void HiROMMap()
{
for (i = c; i < c + 16; i++)
{
- int e = 3;
- int d = (c) >> 4;
+ int32_t e = 3;
+ int32_t d = (c) >> 4;
while (d > mask[0])
{
d &= mask[e];
@@ -2130,11 +2076,11 @@ void HiROMMap()
}
}
- int bankmax = 0x40 + (1 << (Memory.ROMSize - 6));
+ int32_t bankmax = 0x40 + (1 << (Memory.ROMSize - 6));
//safety for corrupt headers
if (bankmax > 128)
bankmax = 0x80;
- int sum = 0;
+ int32_t sum = 0;
for (i = 0x40; i < bankmax; i++)
{
uint8_t* bank_low = (uint8_t*)Memory.Map[i << 4];
@@ -2149,8 +2095,8 @@ void HiROMMap()
void TalesROMMap(bool Interleaved)
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
if (Interleaved)
{
@@ -2168,8 +2114,7 @@ void TalesROMMap(bool Interleaved)
{
OFFSET0 = 0x000000;
OFFSET1 = 0x000000;
- OFFSET2 = Memory.CalculatedSize -
- 0x400000; //changed to work with interleaved DKJM2.
+ OFFSET2 = Memory.CalculatedSize - 0x400000; //changed to work with interleaved DKJM2.
}
// Banks 00->3f and 80->bf
@@ -2192,7 +2137,7 @@ void TalesROMMap(bool Interleaved)
Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8_t*) MAP_HIROM_SRAM;
Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8_t*) MAP_HIROM_SRAM;
Memory.BlockIsRAM [6 + c] = Memory.BlockIsRAM [7 + c] =
- Memory.BlockIsRAM [0x806 + c] = Memory.BlockIsRAM [0x807 + c] = true;
+ Memory.BlockIsRAM [0x806 + c] = Memory.BlockIsRAM [0x807 + c] = true;
}
else
{
@@ -2215,10 +2160,8 @@ void TalesROMMap(bool Interleaved)
{
for (i = c; i < c + 8; i++)
{
- Memory.Map [i + 0x400] = &Memory.ROM [((c << 12) % (Memory.CalculatedSize -
- 0x400000)) + OFFSET1];
- Memory.Map [i + 0x408] = &Memory.ROM [((c << 12) % (Memory.CalculatedSize -
- 0x400000)) + OFFSET1];
+ Memory.Map [i + 0x400] = &Memory.ROM [((c << 12) % (Memory.CalculatedSize - 0x400000)) + OFFSET1];
+ Memory.Map [i + 0x408] = &Memory.ROM [((c << 12) % (Memory.CalculatedSize - 0x400000)) + OFFSET1];
Memory.Map [i + 0xc00] = &Memory.ROM [((c << 12) % 0x400000) + OFFSET2];
Memory.Map [i + 0xc08] = &Memory.ROM [((c << 12) % 0x400000) + OFFSET2];
Memory.BlockIsROM [i + 0x400] = true;
@@ -2237,12 +2180,10 @@ void TalesROMMap(bool Interleaved)
}
}
- Memory.ROMChecksum = *(Memory.Map[8] + 0xFFDE) + (*(Memory.Map[8] + 0xFFDF) <<
- 8);
- Memory.ROMComplementChecksum = *(Memory.Map[8] + 0xFFDC) + (*
- (Memory.Map[8] + 0xFFDD) << 8);
+ Memory.ROMChecksum = *(Memory.Map[8] + 0xFFDE) + (*(Memory.Map[8] + 0xFFDF) << 8);
+ Memory.ROMComplementChecksum = *(Memory.Map[8] + 0xFFDC) + (*(Memory.Map[8] + 0xFFDD) << 8);
- int sum = 0;
+ int32_t sum = 0;
for (i = 0x40; i < 0x80; i++)
{
uint8_t* bank_low = (uint8_t*)Memory.Map[i << 4];
@@ -2262,8 +2203,8 @@ void TalesROMMap(bool Interleaved)
void AlphaROMMap()
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
// Banks 00->3f and 80->bf
for (c = 0; c < 0x400; c += 16)
@@ -2311,14 +2252,15 @@ void DetectSuperFxRamSize()
{
if (strncmp(Memory.ROMName, "STAR FOX 2", 10) == 0)
Memory.SRAMSize = 6;
- else Memory.SRAMSize = 5;
+ else
+ Memory.SRAMSize = 5;
}
}
void SuperFXROMMap()
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
DetectSuperFxRamSize();
@@ -2336,8 +2278,7 @@ void SuperFXROMMap()
Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8_t*) MAP_CPU;
Memory.Map [0x006 + c] = Memory.Map [0x806 + c] = (uint8_t*) Memory.SRAM - 0x6000;
Memory.Map [0x007 + c] = Memory.Map [0x807 + c] = (uint8_t*) Memory.SRAM - 0x6000;
- Memory.BlockIsRAM [0x006 + c] = Memory.BlockIsRAM [0x007 + c] =
- Memory.BlockIsRAM [0x806 + c] = Memory.BlockIsRAM [0x807 + c] = true;
+ Memory.BlockIsRAM [0x006 + c] = Memory.BlockIsRAM [0x007 + c] = Memory.BlockIsRAM [0x806 + c] = Memory.BlockIsRAM [0x807 + c] = true;
for (i = c + 8; i < c + 16; i++)
{
@@ -2351,8 +2292,7 @@ void SuperFXROMMap()
{
for (i = c; i < c + 16; i++)
{
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) %
- Memory.CalculatedSize];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = true;
}
}
@@ -2405,8 +2345,8 @@ void SuperFXROMMap()
void SA1ROMMap()
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
// Banks 00->3f and 80->bf
for (c = 0; c < 0x400; c += 16)
@@ -2417,8 +2357,7 @@ void SA1ROMMap()
Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = true;
Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8_t*) MAP_PPU;
- Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8_t*) &Memory.FillRAM [0x3000]
- - 0x3000;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8_t*) &Memory.FillRAM [0x3000] - 0x3000;
Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8_t*) MAP_CPU;
Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8_t*) MAP_CPU;
Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8_t*) MAP_BWRAM;
@@ -2485,8 +2424,8 @@ void SA1ROMMap()
void LoROM24MBSMap()
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
// Banks 00->3f and 80->bf
for (c = 0; c < 0x400; c += 16)
@@ -2536,12 +2475,10 @@ void LoROM24MBSMap()
for (c = 0; c < 0x400; c += 16)
{
for (i = c; i < c + 8; i++)
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) +
- 0x200000];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000];
for (i = c + 8; i < c + 16; i++)
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) +
- 0x200000 - 0x8000];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000 - 0x8000];
for (i = c; i < c + 16; i++)
Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = true;
@@ -2553,8 +2490,8 @@ void LoROM24MBSMap()
void SufamiTurboLoROMMap()
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
// Banks 00->3f and 80->bf
for (c = 0; c < 0x400; c += 16)
@@ -2581,12 +2518,10 @@ void SufamiTurboLoROMMap()
for (c = 0; c < 0x400; c += 16)
{
for (i = c; i < c + 8; i++)
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) +
- 0x200000];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000];
for (i = c + 8; i < c + 16; i++)
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) +
- 0x200000 - 0x8000];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000 - 0x8000];
for (i = c; i < c + 16; i++)
Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = true;
@@ -2625,8 +2560,8 @@ void SufamiTurboLoROMMap()
void SRAM512KLoROMMap()
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
// Banks 00->3f and 80->bf
for (c = 0; c < 0x400; c += 16)
@@ -2642,7 +2577,6 @@ void SRAM512KLoROMMap()
Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8_t*) MAP_CPU;
Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8_t*) MAP_NONE;
Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8_t*) MAP_NONE;
-
for (i = c + 8; i < c + 16; i++)
{
Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [c << 11] - 0x8000;
@@ -2654,12 +2588,10 @@ void SRAM512KLoROMMap()
for (c = 0; c < 0x400; c += 16)
{
for (i = c; i < c + 8; i++)
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) +
- 0x200000];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000];
for (i = c + 8; i < c + 16; i++)
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) +
- 0x200000 - 0x8000];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000 - 0x8000];
for (i = c; i < c + 16; i++)
Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = true;
@@ -2671,8 +2603,8 @@ void SRAM512KLoROMMap()
void BSHiROMMap()
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
Memory.SRAMSize = 5;
@@ -2695,11 +2627,9 @@ void BSHiROMMap()
Memory.BlockIsRAM [c + 6] = Memory.BlockIsRAM [c + 0x806] = true;
Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8_t*) Memory.RAM;
Memory.BlockIsRAM [c + 7] = Memory.BlockIsRAM [c + 0x807] = true;
-
for (i = c + 8; i < c + 16; i++)
{
- Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [(c << 12) %
- Memory.CalculatedSize];
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = true;
}
}
@@ -2727,8 +2657,7 @@ void BSHiROMMap()
{
for (i = c; i < c + 16; i++)
{
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) %
- Memory.CalculatedSize];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = true;
}
}
@@ -2740,14 +2669,9 @@ void BSHiROMMap()
}
for (i = 0; i < 8; i++)
{
- Memory.Map[0x205 + (i << 4)] = Memory.Map[0x285 + (i << 4)] = Memory.Map[0x305
- + (i << 4)] = Memory.Map[0x385 + (i << 4)] = Memory.Map[0x705 + (i << 4)];
- Memory.BlockIsRAM[0x205 + (i << 4)] = Memory.BlockIsRAM[0x285 +
- (i << 4)] = Memory.BlockIsRAM[0x305 + (i << 4)] = Memory.BlockIsRAM[0x385 +
- (i << 4)] = true;
- Memory.BlockIsROM[0x205 + (i << 4)] = Memory.BlockIsROM[0x285 +
- (i << 4)] = Memory.BlockIsROM[0x305 + (i << 4)] = Memory.BlockIsROM[0x385 +
- (i << 4)] = false;
+ Memory.Map[0x205 + (i << 4)] = Memory.Map[0x285 + (i << 4)] = Memory.Map[0x305 + (i << 4)] = Memory.Map[0x385 + (i << 4)] = Memory.Map[0x705 + (i << 4)];
+ Memory.BlockIsRAM[0x205 + (i << 4)] = Memory.BlockIsRAM[0x285 + (i << 4)] = Memory.BlockIsRAM[0x305 + (i << 4)] = Memory.BlockIsRAM[0x385 + (i << 4)] = true;
+ Memory.BlockIsROM[0x205 + (i << 4)] = Memory.BlockIsROM[0x285 + (i << 4)] = Memory.BlockIsROM[0x305 + (i << 4)] = Memory.BlockIsROM[0x385 + (i << 4)] = false;
}
MapRAM();
@@ -2756,8 +2680,8 @@ void BSHiROMMap()
void JumboLoROMMap(bool Interleaved)
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
uint32_t OFFSET0 = 0x400000;
uint32_t OFFSET2 = 0x000000;
@@ -2765,8 +2689,7 @@ void JumboLoROMMap(bool Interleaved)
if (Interleaved)
{
OFFSET0 = 0x000000;
- OFFSET2 = Memory.CalculatedSize -
- 0x400000; //changed to work with interleaved DKJM2.
+ OFFSET2 = Memory.CalculatedSize - 0x400000; //changed to work with interleaved DKJM2.
}
// Banks 00->3f and 80->bf
for (c = 0; c < 0x400; c += 16)
@@ -2798,10 +2721,8 @@ void JumboLoROMMap(bool Interleaved)
for (i = c + 8; i < c + 16; i++)
{
- Memory.Map [i] = &Memory.ROM [((c << 11) % (Memory.CalculatedSize - 0x400000)) +
- OFFSET0] - 0x8000;
- Memory.Map [i + 0x800] = &Memory.ROM [((c << 11) % (0x400000)) + OFFSET2] -
- 0x8000;
+ Memory.Map [i] = &Memory.ROM [((c << 11) % (Memory.CalculatedSize - 0x400000)) + OFFSET0] - 0x8000;
+ Memory.Map [i + 0x800] = &Memory.ROM [((c << 11) % (0x400000)) + OFFSET2] - 0x8000;
Memory.BlockIsROM [i + 0x800] = Memory.BlockIsROM [i] = true;
}
}
@@ -2825,17 +2746,14 @@ void JumboLoROMMap(bool Interleaved)
//updated mappings to correct A15 mirroring
for (i = c; i < c + 8; i++)
{
- Memory.Map [i] = &Memory.ROM [((c << 11) % (Memory.CalculatedSize - 0x400000)) +
- OFFSET0];
+ Memory.Map [i] = &Memory.ROM [((c << 11) % (Memory.CalculatedSize - 0x400000)) + OFFSET0];
Memory.Map [i + 0x800] = &Memory.ROM [((c << 11) % 0x400000) + OFFSET2];
}
for (i = c + 8; i < c + 16; i++)
{
- Memory.Map [i] = &Memory.ROM [((c << 11) % (Memory.CalculatedSize - 0x400000)) +
- OFFSET0] - 0x8000;
- Memory.Map [i + 0x800] = &Memory.ROM [((c << 11) % 0x400000) + OFFSET2 ] -
- 0x8000;
+ Memory.Map [i] = &Memory.ROM [((c << 11) % (Memory.CalculatedSize - 0x400000)) + OFFSET0] - 0x8000;
+ Memory.Map [i + 0x800] = &Memory.ROM [((c << 11) % 0x400000) + OFFSET2 ] - 0x8000;
}
for (i = c; i < c + 16; i++)
@@ -2843,11 +2761,10 @@ void JumboLoROMMap(bool Interleaved)
}
//ROM type has to be 64 Mbit header!
- int sum = 0, k, l;
+ int32_t sum = 0, k, l;
for (k = 0; k < 256; k++)
{
- uint8_t* bank = 0x8000 + Memory.Map[8 + (k <<
- 4)]; //use upper half of the banks, and adjust for LoROM.
+ uint8_t* bank = 0x8000 + Memory.Map[8 + (k << 4)]; //use upper half of the banks, and adjust for LoROM.
for (l = 0; l < 0x8000; l++)
sum += bank[l];
}
@@ -2859,8 +2776,8 @@ void JumboLoROMMap(bool Interleaved)
void SPC7110HiROMMap()
{
- int c;
- int i;
+ int32_t c;
+ int32_t i;
// Banks 00->3f and 80->bf
for (c = 0; c < 0x400; c += 16)
@@ -2881,8 +2798,7 @@ void SPC7110HiROMMap()
for (i = c + 8; i < c + 16; i++)
{
- Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [(c << 12) %
- Memory.CalculatedSize];
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = true;
}
}
@@ -2903,8 +2819,7 @@ void SPC7110HiROMMap()
{
for (i = c; i < c + 16; i++)
{
- Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) %
- Memory.CalculatedSize];
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = true;
}
}
@@ -2920,14 +2835,13 @@ void SPC7110HiROMMap()
Memory.Map [0xD00 + c] = (uint8_t*) MAP_SPC7110_ROM;
Memory.Map [0xE00 + c] = (uint8_t*) MAP_SPC7110_ROM;
Memory.Map [0xF00 + c] = (uint8_t*) MAP_SPC7110_ROM;
- Memory.BlockIsROM [0xD00 + c] = Memory.BlockIsROM [0xE00 + c] =
- Memory.BlockIsROM [0xF00 + c] = true;
+ Memory.BlockIsROM [0xD00 + c] = Memory.BlockIsROM [0xE00 + c] = Memory.BlockIsROM [0xF00 + c] = true;
}
S9xSpc7110Init();
- int sum = 0;
- for (i = 0; i < (int)Memory.CalculatedSize; i++)
+ int32_t sum = 0;
+ for (i = 0; i < (int32_t)Memory.CalculatedSize; i++)
sum += Memory.ROM[i];
if (Memory.CalculatedSize == 0x300000)
@@ -2937,6 +2851,7 @@ void SPC7110HiROMMap()
MapRAM();
WriteProtectROM();
}
+
void SPC7110Sram(uint8_t newstate)
{
if (newstate & 0x80)
@@ -2954,6 +2869,7 @@ void SPC7110Sram(uint8_t newstate)
Memory.Map[0x307] = (uint8_t*)MAP_RONLY_SRAM;
}
}
+
const char* TVStandard()
{
return (Settings.PAL ? "PAL" : "NTSC");
@@ -3007,7 +2923,6 @@ const char* KartContents()
sprintf(tmp, "%s", Contents [(Memory.ROMType & 0xf) % 3]);
-
if (Settings.BS)
sprintf(tmp, "%s+%s", tmp, "BSX");
else if (Settings.SPC7110 && Settings.SPC7110RTC)
@@ -3024,11 +2939,9 @@ const char* KartContents()
case ST_011:
sprintf(tmp, "%s+%s", tmp, "ST-011");
break;
-
case ST_018:
sprintf(tmp, "%s+%s", tmp, "ST-018");
break;
-
}
}
else if ((Memory.ROMType & 0xf) >= 3)
@@ -3062,11 +2975,10 @@ void ApplyROMFixes()
[14:25:27] <@Nach> case 0x340f23e5: //Donkey Kong Country 3 (U) copier hack - handled
*/
- if (Memory.ROMCRC32 == 0x6810aa95 || Memory.ROMCRC32 == 0x340f23e5
- || Memory.ROMCRC32 == 0x77fd806a ||
- strncmp(Memory.ROMName, "HIGHWAY BATTLE 2", 16) == 0 ||
- (strcmp(Memory.ROMName, "FX SKIING NINTENDO 96") == 0
- && Memory.ROM[0x7FDA] == 0))
+ if (Memory.ROMCRC32 == 0x6810aa95 || Memory.ROMCRC32 == 0x340f23e5 || Memory.ROMCRC32 == 0x77fd806a ||
+ strncmp(Memory.ROMName, "HIGHWAY BATTLE 2", 16) == 0 ||
+ (strcmp(Memory.ROMName, "FX SKIING NINTENDO 96") == 0
+ && Memory.ROM[0x7FDA] == 0))
{
Settings.DisplayColor = BUILD_PIXEL(31, 0, 0);
SET_UI_COLOR(255, 0, 0);
@@ -3102,7 +3014,7 @@ void ApplyROMFixes()
//memory map corrections
if (strncmp(Memory.ROMName, "XBAND", 5) == 0)
{
- int c;
+ int32_t c;
for (c = 0xE00; c < 0xE10; c++)
{
Memory.Map [c] = (uint8_t*) MAP_LOROM_SRAM;
@@ -3115,7 +3027,7 @@ void ApplyROMFixes()
//not MAD-1 compliant
if (strcmp(Memory.ROMName, "WANDERERS FROM YS") == 0)
{
- int c;
+ int32_t c;
for (c = 0; c < 0xE0; c++)
{
Memory.Map[c + 0x700] = (uint8_t*)MAP_LOROM_SRAM;
@@ -3129,7 +3041,7 @@ void ApplyROMFixes()
strcmp(Memory.ROMName, "HOME ALONE") == 0)
{
// Banks 00->3f and 80->bf
- int c;
+ int32_t c;
for (c = 0; c < 0x400; c += 16)
{
Memory.Map [c + 6] = Memory.Map [c + 0x806] = Memory.SRAM;
@@ -3145,7 +3057,7 @@ void ApplyROMFixes()
if (strcmp(Memory.ROMName, "RADICAL DREAMERS") == 0 ||
strcmp(Memory.ROMName, "TREASURE CONFLIX") == 0)
{
- int c;
+ int32_t c;
for (c = 0; c < 0x80; c++)
{
@@ -3206,8 +3118,7 @@ void ApplyROMFixes()
// RENDERING RANGER R2
if (strcmp(Memory.ROMId, "AVCJ") == 0 ||
//Mark Davis
- strncmp(Memory.ROMName, "THE FISHING MASTER", 18) == 0
- || //needs >= actual APU timing. (21 is .002 Mhz slower)
+ strncmp(Memory.ROMName, "THE FISHING MASTER", 18) == 0 || //needs >= actual APU timing. (21 is .002 Mhz slower)
// Star Ocean
strncmp(Memory.ROMId, "ARF", 3) == 0 ||
// Tales of Phantasia
@@ -3217,7 +3128,6 @@ void ApplyROMFixes()
// Soulblazer
strcmp(Memory.ROMName, "SOULBLAZER - 1 USA") == 0 ||
strcmp(Memory.ROMName, "SOULBLADER - 1") == 0 ||
-
// Terranigma
strncmp(Memory.ROMId, "AQT", 3) == 0 ||
// Robotrek
@@ -3233,21 +3143,20 @@ void ApplyROMFixes()
// Panic Bomber World
strncmp(Memory.ROMId, "APB", 3) == 0 ||
((strncmp(Memory.ROMName, "Parlor", 6) == 0 ||
- strcmp(Memory.ROMName, "HEIWA Parlor!Mini8") == 0 ||
- strncmp(Memory.ROMName, "SANKYO Fever! ̨��ް!", 21) == 0) &&
- strcmp(Memory.CompanyId, "A0") == 0) ||
+ strcmp(Memory.ROMName, "HEIWA Parlor!Mini8") == 0 ||
+ strncmp(Memory.ROMName, "SANKYO Fever! \xCC\xA8\xB0\xCA\xDE\xB0!", 21) == 0) &&
+ strcmp(Memory.CompanyId, "A0") == 0) ||
strcmp(Memory.ROMName, "DARK KINGDOM") == 0 ||
strcmp(Memory.ROMName, "ZAN3 SFC") == 0 ||
strcmp(Memory.ROMName, "HIOUDEN") == 0 ||
- strcmp(Memory.ROMName, "�ݼɳ�") == 0 || //Tenshi no Uta
+ strcmp(Memory.ROMName, "\xC3\xDD\xBC\xC9\xB3\xC0") == 0 || //Tenshi no Uta
strcmp(Memory.ROMName, "FORTUNE QUEST") == 0 ||
strcmp(Memory.ROMName, "FISHING TO BASSING") == 0 ||
strncmp(Memory.ROMName, "TokyoDome '95Battle 7", 21) == 0 ||
strcmp(Memory.ROMName, "OHMONO BLACKBASS") == 0 ||
strncmp(Memory.ROMName, "SWORD WORLD SFC", 15) == 0 ||
strcmp(Memory.ROMName, "MASTERS") == 0 || //Augusta 2 J
- strcmp(Memory.ROMName, "SFC ���ײ�ް") == 0
- || //Kamen Rider
+ strcmp(Memory.ROMName, "SFC \xB6\xD2\xDD\xD7\xB2\xC0\xDE\xB0") == 0 || //Kamen Rider
strncmp(Memory.ROMName, "LETs PACHINKO(", 14) == 0) //A set of BS games
IAPU.OneCycle = 15;
#endif
@@ -3260,15 +3169,13 @@ void ApplyROMFixes()
strcmp(Memory.ROMName, "DIRT RACER") == 0 ||
Settings.StarfoxHack;
-
if ((strcmp(Memory.ROMName, "LEGEND") == 0 && !Settings.PAL) ||
strcmp(Memory.ROMName, "King Arthurs World") == 0)
SNESGameFixes.EchoOnlyOutput = true;
-
Settings.DaffyDuck = (strcmp(Memory.ROMName, "DAFFY DUCK: MARV MISS") == 0) ||
(strcmp(Memory.ROMName, "ROBOCOP VS THE TERMIN") == 0) ||
- (strcmp(Memory.ROMName, "ROBOCOP VS TERMINATOR") == 0); //ROBOCOP VS THE TERMIN
+ (strcmp(Memory.ROMName, "ROBOCOP VS TERMINATOR") == 0);
Settings.HBlankStart = (256 * Settings.H_Max) / SNES_HCOUNTER_MAX;
//OAM hacks because we don't fully understand the
@@ -3284,20 +3191,17 @@ void ApplyROMFixes()
if (strcmp(Memory.ROMName, "ALIENS vs. PREDATOR") == 0)
SNESGameFixes.alienVSpredetorFix = true;
- if (strcmp(Memory.ROMName, "���̧߰н�") == 0
- || //Super Famista
- strcmp(Memory.ROMName, "���̧߰н� 2") == 0
- || //Super Famista 2
- strcmp(Memory.ROMName, "ZENKI TENCHIMEIDOU") == 0 ||
- strcmp(Memory.ROMName, "GANBA LEAGUE") == 0)
+ if (strcmp(Memory.ROMName, "\xBD\xB0\xCA\xDF\xB0\xCC\xA7\xD0\xBD\xC0") == 0 || //Super Famista
+ strcmp(Memory.ROMName, "\xBD\xB0\xCA\xDF\xB0\xCC\xA7\xD0\xBD\xC0 2") == 0 || //Super Famista 2
+ strcmp(Memory.ROMName, "ZENKI TENCHIMEIDOU") == 0 ||
+ strcmp(Memory.ROMName, "GANBA LEAGUE") == 0)
SNESGameFixes.APU_OutPorts_ReturnValueFix = true;
if (strcmp(Memory.ROMName, "FURAI NO SIREN") == 0)
SNESGameFixes.SoundEnvelopeHeightReading2 = true;
//CPU timing hacks
- Settings.H_Max = (SNES_CYCLES_PER_SCANLINE *
- Settings.CyclesPercentage) / 100;
+ Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * Settings.CyclesPercentage) / 100;
// A Couple of HDMA related hacks - Lantus
if ((strcmp(Memory.ROMName, "SFX SUPERBUTOUDEN2") == 0) ||
@@ -3323,28 +3227,10 @@ void ApplyROMFixes()
// Mortal Kombat 3. Fixes cut off speech sample
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 110) / 100;
- //Darkness Beyond Twilight
- //Crimson beyond blood that flows
- //buried in the stream of time
- //is where your power grows
- //I pledge myself to conquer
- //all the foes who stand
- //before the might gift betsowed
- //in my unworthy hand
if (strcmp(Memory.ROMName, "\x0bd\x0da\x0b2\x0d4\x0b0\x0bd\x0de") == 0 &&
Settings.CyclesPercentage == 100)
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 101) / 100;
-#ifdef DETECT_NASTY_FX_INTERLEAVE
- //XXX: Test without these. Win32 port indicates they aren't needed?
- //Apparently are needed!
- if (strcmp(Memory.ROMName, "WILD TRAX") == 0 ||
- strcmp(Memory.ROMName, "STAR FOX 2") == 0 ||
- strcmp(Memory.ROMName, "YOSSY'S ISLAND") == 0 ||
- strcmp(Memory.ROMName, "YOSHI'S ISLAND") == 0)
- CPU.TriedInterleavedMode2 = true;
-#endif
-
// Start Trek: Deep Sleep 9
if (strncmp(Memory.ROMId, "A9D", 3) == 0 && Settings.CyclesPercentage == 100)
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 110) / 100;
@@ -3482,11 +3368,6 @@ void ApplyROMFixes()
SA1.WaitAddress = SA1.Map [0x009899 >> MEMMAP_SHIFT] + 0x9899;
SA1.WaitByteAddress1 = Memory.FillRAM + 0x3000;
}
- /* PACHISURO PALUSUPE */
- if (strcmp(Memory.ROMId, "AGFJ") == 0)
- {
- // Never seems to turn on the SA-1!
- }
/* SD F1 GRAND PRIX */
if (strcmp(Memory.ROMId, "AGFJ") == 0)
SA1.WaitAddress = SA1.Map [0x0181bc >> MEMMAP_SHIFT] + 0x81bc;
@@ -3500,7 +3381,6 @@ void ApplyROMFixes()
/* shogisai2 */
if (strcmp(Memory.ROMId, "AX2J") == 0)
SA1.WaitAddress = SA1.Map [0x00d675 >> MEMMAP_SHIFT] + 0xd675;
-
/* SHINING SCORPION */
if (strcmp(Memory.ROMId, "A4WJ") == 0)
SA1.WaitAddress = SA1.Map [0xc048be >> MEMMAP_SHIFT] + 0x48be;
@@ -3515,9 +3395,8 @@ void ApplyROMFixes()
//Other
// Additional game fixes by sanmaiwashi ...
- if (strcmp(Memory.ROMName,
- "SFX ŲĶ������ɶ��� 1") ==
- 0) //Gundam Knight Story
+ //Gundam Knight Story
+ if (strcmp(Memory.ROMName, "SFX \xC5\xB2\xC4\xB6\xDE\xDD\xC0\xDE\xD1\xD3\xC9\xB6\xDE\xC0\xD8 1") == 0)
{
bytes0x2000 [0xb18] = 0x4c;
bytes0x2000 [0xb19] = 0x4b;
@@ -3529,8 +3408,7 @@ void ApplyROMFixes()
if (strcmp(Memory.ROMName, "HITOMI3") == 0)
{
Memory.SRAMSize = 1;
- Memory.SRAMMask = Memory.SRAMSize ?
- ((1 << (Memory.SRAMSize + 3)) * 128) - 1 : 0;
+ Memory.SRAMMask = Memory.SRAMSize ? ((1 << (Memory.SRAMSize + 3)) * 128) - 1 : 0;
}
//sram value fixes
@@ -3568,9 +3446,9 @@ void ApplyROMFixes()
//BNE
}
-int is_bsx(unsigned char* p)
+int32_t is_bsx(uint8_t* p)
{
- unsigned c;
+ uint32_t c;
if (p[0x19] & 0x4f)
goto notbsx;
@@ -3601,11 +3479,12 @@ int is_bsx(unsigned char* p)
notbsx:
return -1;
}
-int bs_name(unsigned char* p)
+
+int32_t bs_name(uint8_t* p)
{
- unsigned c;
- int lcount;
- int numv; // number of valid name characters seen so far
+ uint32_t c;
+ int32_t lcount;
+ int32_t numv; // number of valid name characters seen so far
numv = 0;
for (lcount = 16; lcount > 0; lcount--)
{
@@ -3662,7 +3541,8 @@ void ParseSNESHeader(uint8_t* RomHeader)
if (RomHeader[0x2A] == 0x33)
// memmove converted: Different mallocs [Neb]
memcpy(Memory.CompanyId, &RomHeader [0], 2);
- else sprintf(Memory.CompanyId, "%02X", RomHeader[0x2A]);
+ else
+ sprintf(Memory.CompanyId, "%02X", RomHeader[0x2A]);
}
#undef INLINE
diff --git a/source/obc1.c b/source/obc1.c
index f0afdd4..2d46238 100644
--- a/source/obc1.c
+++ b/source/obc1.c
@@ -6,9 +6,9 @@
static uint8_t* OBC1_RAM = NULL;
-int OBC1_Address;
-int OBC1_BasePtr;
-int OBC1_Shift;
+int32_t OBC1_Address;
+int32_t OBC1_BasePtr;
+int32_t OBC1_Shift;
uint8_t GetOBC1(uint16_t Address)
{
@@ -63,8 +63,7 @@ void SetOBC1(uint8_t Byte, uint16_t Address)
case 0x7ff4:
{
- unsigned char Temp;
-
+ uint8_t Temp;
Temp = OBC1_RAM[OBC1_BasePtr + (OBC1_Address >> 2) + 0x200];
Temp = (Temp & ~(3 << OBC1_Shift)) | ((Byte & 3) << OBC1_Shift);
OBC1_RAM[OBC1_BasePtr + (OBC1_Address >> 2) + 0x200] = Temp;
diff --git a/source/pixform.h b/source/pixform.h
index 1a8c917..dc4eacc 100644
--- a/source/pixform.h
+++ b/source/pixform.h
@@ -4,8 +4,8 @@
#define _PIXFORM_H_
/* RGB565 format */
-#define BUILD_PIXEL_RGB565(R,G,B) (((int) (R) << 11) | ((int) (G) << 6) | (int) (B))
-#define BUILD_PIXEL2_RGB565(R,G,B) (((int) (R) << 11) | ((int) (G) << 5) | (int) (B))
+#define BUILD_PIXEL_RGB565(R,G,B) (((int32_t) (R) << 11) | ((int32_t) (G) << 6) | (int32_t) (B))
+#define BUILD_PIXEL2_RGB565(R,G,B) (((int32_t) (R) << 11) | ((int32_t) (G) << 5) | (int32_t) (B))
#define DECOMPOSE_PIXEL_RGB565(PIX,R,G,B) {(R) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (B) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB565 (1 << 5)
@@ -24,8 +24,8 @@
#define ALPHA_BITS_MASK_RGB565 0x0000
/* RGB555 format */
-#define BUILD_PIXEL_RGB555(R,G,B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B))
-#define BUILD_PIXEL2_RGB555(R,G,B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B))
+#define BUILD_PIXEL_RGB555(R,G,B) (((int32_t) (R) << 10) | ((int32_t) (G) << 5) | (int32_t) (B))
+#define BUILD_PIXEL2_RGB555(R,G,B) (((int32_t) (R) << 10) | ((int32_t) (G) << 5) | (int32_t) (B))
#define DECOMPOSE_PIXEL_RGB555(PIX,R,G,B) {(R) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (B) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB555 (1 << 15)
@@ -44,8 +44,8 @@
#define ALPHA_BITS_MASK_RGB555 0x0000
/* BGR565 format */
-#define BUILD_PIXEL_BGR565(R,G,B) (((int) (B) << 11) | ((int) (G) << 6) | (int) (R))
-#define BUILD_PIXEL2_BGR565(R,G,B) (((int) (B) << 11) | ((int) (G) << 5) | (int) (R))
+#define BUILD_PIXEL_BGR565(R,G,B) (((int32_t) (B) << 11) | ((int32_t) (G) << 6) | (int32_t) (R))
+#define BUILD_PIXEL2_BGR565(R,G,B) (((int32_t) (B) << 11) | ((int32_t) (G) << 5) | (int32_t) (R))
#define DECOMPOSE_PIXEL_BGR565(PIX,R,G,B) {(B) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_BGR565 (1 << 5)
@@ -64,8 +64,8 @@
#define ALPHA_BITS_MASK_BGR565 0x0000
/* BGR555 format */
-#define BUILD_PIXEL_BGR555(R,G,B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
-#define BUILD_PIXEL2_BGR555(R,G,B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
+#define BUILD_PIXEL_BGR555(R,G,B) (((int32_t) (B) << 10) | ((int32_t) (G) << 5) | (int32_t) (R))
+#define BUILD_PIXEL2_BGR555(R,G,B) (((int32_t) (B) << 10) | ((int32_t) (G) << 5) | (int32_t) (R))
#define DECOMPOSE_PIXEL_BGR555(PIX,R,G,B) {(B) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_BGR555 (1 << 15)
@@ -84,8 +84,8 @@
#define ALPHA_BITS_MASK_BGR555 0x0000
/* GBR565 format */
-#define BUILD_PIXEL_GBR565(R,G,B) (((int) (G) << 11) | ((int) (B) << 6) | (int) (R))
-#define BUILD_PIXEL2_GBR565(R,G,B) (((int) (G) << 11) | ((int) (B) << 5) | (int) (R))
+#define BUILD_PIXEL_GBR565(R,G,B) (((int32_t) (G) << 11) | ((int32_t) (B) << 6) | (int32_t) (R))
+#define BUILD_PIXEL2_GBR565(R,G,B) (((int32_t) (G) << 11) | ((int32_t) (B) << 5) | (int32_t) (R))
#define DECOMPOSE_PIXEL_GBR565(PIX,R,G,B) {(G) = (PIX) >> 11; (B) = ((PIX) >> 6) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_GBR565 (1 << 5)
@@ -104,8 +104,8 @@
#define ALPHA_BITS_MASK_GBR565 0x0000
/* GBR555 format */
-#define BUILD_PIXEL_GBR555(R,G,B) (((int) (G) << 10) | ((int) (B) << 5) | (int) (R))
-#define BUILD_PIXEL2_GBR555(R,G,B) (((int) (G) << 10) | ((int) (B) << 5) | (int) (R))
+#define BUILD_PIXEL_GBR555(R,G,B) (((int32_t) (G) << 10) | ((int32_t) (B) << 5) | (int32_t) (R))
+#define BUILD_PIXEL2_GBR555(R,G,B) (((int32_t) (G) << 10) | ((int32_t) (B) << 5) | (int32_t) (R))
#define DECOMPOSE_PIXEL_GBR555(PIX,R,G,B) {(G) = (PIX) >> 10; (B) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_GBR555 (1 << 15)
@@ -124,8 +124,8 @@
#define ALPHA_BITS_MASK_GBR555 0x0000
/* RGB5551 format */
-#define BUILD_PIXEL_RGB5551(R,G,B) (((int) (R) << 11) | ((int) (G) << 6) | (int) ((B) << 1) | 1)
-#define BUILD_PIXEL2_RGB5551(R,G,B) (((int) (R) << 11) | ((int) (G) << 6) | (int) ((B) << 1) | 1)
+#define BUILD_PIXEL_RGB5551(R,G,B) (((int32_t) (R) << 11) | ((int32_t) (G) << 6) | (int32_t) ((B) << 1) | 1)
+#define BUILD_PIXEL2_RGB5551(R,G,B) (((int32_t) (R) << 11) | ((int32_t) (G) << 6) | (int32_t) ((B) << 1) | 1)
#define DECOMPOSE_PIXEL_RGB5551(PIX,R,G,B) {(R) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (B) = ((PIX) >> 1) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB5551 (1)
diff --git a/source/ppu.c b/source/ppu.c
index 8dcb52b..9ef69d5 100644
--- a/source/ppu.c
+++ b/source/ppu.c
@@ -94,7 +94,7 @@ void S9xUpdateHTimer()
void S9xFixColourBrightness()
{
IPPU.XB = mul_brightness [PPU.Brightness];
- int i;
+ int32_t i;
for (i = 0; i < 256; i++)
{
IPPU.Red [i] = IPPU.XB [PPU.CGDATA [i] & 0x1f];
@@ -1195,7 +1195,7 @@ uint8_t S9xGetPPU(uint16_t Address)
}
if ((Address & 3) < 2)
{
- int r = rand();
+ int32_t r = rand();
if (r & 2)
{
if (r & 4)
@@ -1206,7 +1206,7 @@ uint8_t S9xGetPPU(uint16_t Address)
}
else
{
- int r = rand();
+ int32_t r = rand();
if (r & 2)
return ((r >> 3) & 0xff);
}
@@ -1282,7 +1282,7 @@ uint8_t S9xGetPPU(uint16_t Address)
/******************************************************************************/
void S9xSetCPU(uint8_t byte, uint16_t Address)
{
- int d;
+ int32_t d;
if (Address < 0x4200)
{
@@ -2023,7 +2023,7 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x436A:
case 0x437A:
{
- int d = (Address & 0x70) >> 4;
+ int32_t d = (Address & 0x70) >> 4;
if (IPPU.HDMA & (1 << d))
return (DMA[d].LineCount);
return (Memory.FillRAM[Address]);
@@ -2099,7 +2099,7 @@ static void CommonPPUReset()
PPU.ClipWindow2Inside[4] = PPU.ClipWindow2Inside[5] = true;
PPU.CGFLIP = 0;
- int c;
+ int32_t c;
for (c = 0; c < 256; c++)
{
IPPU.Red [c] = (c & 7) << 2;
@@ -2111,7 +2111,7 @@ static void CommonPPUReset()
PPU.FirstSprite = 0;
PPU.LastSprite = 127;
- int Sprite;
+ int32_t Sprite;
for (Sprite = 0; Sprite < 128; Sprite++)
{
PPU.OBJ[Sprite].HPos = 0;
@@ -2242,12 +2242,12 @@ void S9xResetPPU()
IPPU.PrevMouseX[0] = IPPU.PrevMouseX[1] = 256 / 2;
IPPU.PrevMouseY[0] = IPPU.PrevMouseY[1] = 224 / 2;
- int c;
+ int32_t c;
for (c = 0; c < 0x8000; c += 0x100)
{
if (!Settings.SuperFX)
memset(&Memory.FillRAM [c], c >> 8, 0x100);
- else if ((unsigned)c < 0x3000 || (unsigned)c >= 0x3300)
+ else if ((uint32_t)c < 0x3000 || (uint32_t)c >= 0x3300)
{
/* Don't overwrite SFX pvRegisters at 0x3000-0x32FF,
* they were set in FxReset.
@@ -2269,7 +2269,7 @@ void S9xSoftResetPPU()
{
CommonPPUReset();
- int c;
+ int32_t c;
for (c = 0; c < 0x8000; c += 0x100)
memset(&Memory.FillRAM [c], c >> 8, 0x100);
@@ -2282,14 +2282,14 @@ void S9xSoftResetPPU()
Memory.FillRAM[0x4201] = Memory.FillRAM[0x4213] = 0xFF;
}
-void S9xProcessMouse(int which1)
+void S9xProcessMouse(int32_t which1)
{
- int x, y;
+ int32_t x, y;
uint32_t buttons;
if (IPPU.Controller == SNES_MOUSE && S9xReadMousePosition(which1, &x, &y, &buttons))
{
- int delta_x, delta_y;
+ int32_t delta_x, delta_y;
#define MOUSE_SIGNATURE 0x1
IPPU.Mouse [which1] = MOUSE_SIGNATURE |
(PPU.MouseSpeed [which1] << 4) |
@@ -2346,7 +2346,7 @@ void S9xProcessMouse(int which1)
void ProcessSuperScope()
{
- int x, y;
+ int32_t x, y;
uint32_t buttons;
if (IPPU.Controller == SNES_SUPERSCOPE &&
@@ -2436,7 +2436,7 @@ void S9xUpdateJustifiers()
if (!last_p1)
justifiers |= 0x1000;
- int x, y;
+ int32_t x, y;
uint32_t buttons;
if (Memory.FillRAM[0x4201] & 0x80)
@@ -2614,8 +2614,8 @@ void S9xSuperFXExec()
FxEmulate(~0);
else
FxEmulate((Memory.FillRAM [0x3000 + GSU_CLSR] & 1) ? 700 : 350);
- int GSUStatus = Memory.FillRAM [0x3000 + GSU_SFR] |
- (Memory.FillRAM [0x3000 + GSU_SFR + 1] << 8);
+ int32_t GSUStatus = Memory.FillRAM [0x3000 + GSU_SFR] |
+ (Memory.FillRAM [0x3000 + GSU_SFR + 1] << 8);
if ((GSUStatus & (FLG_G | FLG_IRQ)) == FLG_IRQ)
{
// Trigger a GSU IRQ.
@@ -2651,7 +2651,7 @@ void REGISTER_2104(uint8_t byte)
{
if (PPU.OAMAddr & 0x100)
{
- int addr = ((PPU.OAMAddr & 0x10f) << 1) + (PPU.OAMFlip & 1);
+ int32_t addr = ((PPU.OAMAddr & 0x10f) << 1) + (PPU.OAMFlip & 1);
if (byte != PPU.OAMData [addr])
{
FLUSH_REDRAW();
@@ -2700,7 +2700,7 @@ void REGISTER_2104(uint8_t byte)
uint8_t highbyte = byte;
PPU.OAMWriteRegister |= byte << 8;
- int addr = (PPU.OAMAddr << 1);
+ int32_t addr = (PPU.OAMAddr << 1);
if (lowbyte != PPU.OAMData [addr] ||
highbyte != PPU.OAMData [addr + 1])
diff --git a/source/ppu.h b/source/ppu.h
index 7ad3489..1a83d6f 100644
--- a/source/ppu.h
+++ b/source/ppu.h
@@ -56,27 +56,27 @@ typedef struct
bool InterlaceSprites;
bool DoubleWidthPixels;
bool HalfWidthPixels;
- int RenderedScreenHeight;
- int RenderedScreenWidth;
+ int32_t RenderedScreenHeight;
+ int32_t RenderedScreenWidth;
uint32_t Red [256];
uint32_t Green [256];
uint32_t Blue [256];
uint8_t* XB;
uint16_t ScreenColors [256];
- int PreviousLine;
- int CurrentLine;
- int Controller;
+ int32_t PreviousLine;
+ int32_t CurrentLine;
+ int32_t Controller;
uint32_t Joypads[5];
uint32_t SuperScope;
uint32_t Mouse[2];
- int PrevMouseX[2];
- int PrevMouseY[2];
+ int32_t PrevMouseX[2];
+ int32_t PrevMouseY[2];
struct ClipData Clip [2];
} InternalPPU;
struct SOBJ
{
- short HPos;
+ int16_t HPos;
uint16_t VPos;
uint16_t Name;
uint8_t VFlip;
@@ -132,12 +132,12 @@ typedef struct
uint8_t VBeamFlip;
uint8_t HVBeamCounterLatched;
- short MatrixA;
- short MatrixB;
- short MatrixC;
- short MatrixD;
- short CentreX;
- short CentreY;
+ int16_t MatrixA;
+ int16_t MatrixB;
+ int16_t MatrixC;
+ int16_t MatrixD;
+ int16_t CentreX;
+ int16_t CentreY;
uint8_t Joypad1ButtonReadPos;
uint8_t Joypad2ButtonReadPos;
@@ -159,7 +159,7 @@ typedef struct
uint8_t OAMData [512 + 32];
bool VTimerEnabled;
bool HTimerEnabled;
- short HTimerPosition;
+ int16_t HTimerPosition;
uint8_t Mosaic;
bool BGMosaic [4];
bool Mode7HFlip;
@@ -223,7 +223,7 @@ void S9xResetPPU();
void S9xSoftResetPPU();
void S9xFixColourBrightness();
void S9xUpdateJoypads();
-void S9xProcessMouse(int which1);
+void S9xProcessMouse(int32_t which1);
void S9xSuperFXExec();
void S9xSetPPU(uint8_t Byte, uint16_t Address);
diff --git a/source/sa1.c b/source/sa1.c
index 17e7258..a0d4bba 100644
--- a/source/sa1.c
+++ b/source/sa1.c
@@ -65,7 +65,7 @@ void S9xSA1Reset()
void S9xSA1SetBWRAMMemMap(uint8_t val)
{
- int c;
+ int32_t c;
if (val & 0x80)
{
@@ -147,15 +147,15 @@ uint16_t S9xSA1GetWord(uint32_t address)
void S9xSA1SetByte(uint8_t byte, uint32_t address)
{
- uint8_t* Setaddress = SA1.WriteMap [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
+ uint8_t* SetAddress = SA1.WriteMap [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (Setaddress >= (uint8_t*) MAP_LAST)
+ if (SetAddress >= (uint8_t*) MAP_LAST)
{
- *(Setaddress + (address & 0xffff)) = byte;
+ *(SetAddress + (address & 0xffff)) = byte;
return;
}
- switch ((intptr_t) Setaddress)
+ switch ((intptr_t) SetAddress)
{
case MAP_PPU:
S9xSetSA1(byte, address & 0xffff);
@@ -248,10 +248,10 @@ void S9xSA1SetPCBase(uint32_t address)
void S9xSetSA1MemMap(uint32_t which1, uint8_t map)
{
- int c;
- int i;
- int start = which1 * 0x100 + 0xc00;
- int start2 = which1 * 0x200;
+ int32_t c;
+ int32_t i;
+ int32_t start = which1 * 0x100 + 0xc00;
+ int32_t start2 = which1 * 0x200;
if (which1 >= 2)
start2 += 0x400;
@@ -508,18 +508,18 @@ static void S9xSA1CharConv2()
{
uint32_t dest = Memory.FillRAM [0x2235] | (Memory.FillRAM [0x2236] << 8);
uint32_t offset = (SA1.in_char_dma & 7) ? 0 : 1;
- int depth = (Memory.FillRAM [0x2231] & 3) == 0 ? 8 :
- (Memory.FillRAM [0x2231] & 3) == 1 ? 4 : 2;
- int bytes_per_char = 8 * depth;
+ int32_t depth = (Memory.FillRAM [0x2231] & 3) == 0 ? 8 :
+ (Memory.FillRAM [0x2231] & 3) == 1 ? 4 : 2;
+ int32_t bytes_per_char = 8 * depth;
uint8_t* p = &Memory.FillRAM [0x3000] + dest + offset * bytes_per_char;
uint8_t* q = &Memory.ROM [MAX_ROM_SIZE - 0x10000] + offset * 64;
if (depth == 8)
{
- int l;
+ int32_t l;
for (l = 0; l < 8; l++, q += 8)
{
- int b;
+ int32_t b;
for (b = 0; b < 8; b++)
{
uint8_t r = *(q + b);
diff --git a/source/sa1.h b/source/sa1.h
index 079fef5..2b83eb3 100644
--- a/source/sa1.h
+++ b/source/sa1.h
@@ -47,7 +47,7 @@ typedef struct
uint8_t* WriteMap [MEMMAP_NUM_BLOCKS];
int16_t op1;
int16_t op2;
- int arithmetic_op;
+ int arithmetic_op; // For savestate compatibility can't change to int32_t
int64_t sum;
bool overflow;
uint8_t VirtualBitmapFormat;
@@ -56,14 +56,14 @@ typedef struct
SSA1Registers Registers;
} SSA1;
-#define SA1CheckZero() (SA1._Zero == 0)
-#define SA1CheckCarry() (SA1._Carry)
-#define SA1CheckIRQ() (SA1.Registers.PL & IRQ)
-#define SA1CheckDecimal() (SA1.Registers.PL & Decimal)
-#define SA1CheckIndex() (SA1.Registers.PL & IndexFlag)
-#define SA1CheckMemory() (SA1.Registers.PL & MemoryFlag)
-#define SA1CheckOverflow() (SA1._Overflow)
-#define SA1CheckNegative() (SA1._Negative & 0x80)
+#define SA1CheckZero() (SA1._Zero == 0)
+#define SA1CheckCarry() (SA1._Carry)
+#define SA1CheckIRQ() (SA1.Registers.PL & IRQ)
+#define SA1CheckDecimal() (SA1.Registers.PL & Decimal)
+#define SA1CheckIndex() (SA1.Registers.PL & IndexFlag)
+#define SA1CheckMemory() (SA1.Registers.PL & MemoryFlag)
+#define SA1CheckOverflow() (SA1._Overflow)
+#define SA1CheckNegative() (SA1._Negative & 0x80)
#define SA1CheckEmulation() (SA1.Registers.P.W & Emulation)
#define SA1ClearFlags(f) (SA1.Registers.P.W &= ~(f))
diff --git a/source/sa1cpu.c b/source/sa1cpu.c
index baaa929..478df1e 100644
--- a/source/sa1cpu.c
+++ b/source/sa1cpu.c
@@ -116,7 +116,7 @@
void S9xSA1MainLoop()
{
- int i;
+ int32_t i;
if (SA1.Flags & IRQ_PENDING_FLAG)
{
diff --git a/source/sar.h b/source/sar.h
index 4ab4ecb..3f160a6 100644
--- a/source/sar.h
+++ b/source/sar.h
@@ -16,7 +16,7 @@
#define SAR64(b, n) ((b)>>(n))
#else
-static inline int8_t SAR8(const int8_t b, const int n)
+static inline int8_t SAR8(const int8_t b, const int32_t n)
{
#ifndef RIGHTSHIFT_INT8_IS_SAR
if (b < 0) return (b >> n) | (-1 << (8 - n));
@@ -24,7 +24,7 @@ static inline int8_t SAR8(const int8_t b, const int n)
return b >> n;
}
-static inline int16_t SAR16(const int16_t b, const int n)
+static inline int16_t SAR16(const int16_t b, const int32_t n)
{
#ifndef RIGHTSHIFT_INT16_IS_SAR
if (b < 0) return (b >> n) | (-1 << (16 - n));
@@ -32,7 +32,7 @@ static inline int16_t SAR16(const int16_t b, const int n)
return b >> n;
}
-static inline int32_t SAR32(const int32_t b, const int n)
+static inline int32_t SAR32(const int32_t b, const int32_t n)
{
#ifndef RIGHTSHIFT_INT32_IS_SAR
if (b < 0) return (b >> n) | (-1 << (32 - n));
@@ -40,7 +40,7 @@ static inline int32_t SAR32(const int32_t b, const int n)
return b >> n;
}
-static inline int64_t SAR64(const int64_t b, const int n)
+static inline int64_t SAR64(const int64_t b, const int32_t n)
{
#ifndef RIGHTSHIFT_INT64_IS_SAR
if (b < 0) return (b >> n) | (-1 << (64 - n));
diff --git a/source/sdd1.c b/source/sdd1.c
index 93e3a7e..58b934e 100644
--- a/source/sdd1.c
+++ b/source/sdd1.c
@@ -10,12 +10,12 @@ void S9xSetSDD1MemoryMap(uint32_t bank, uint32_t value)
bank = 0xc00 + bank * 0x100;
value = value * 1024 * 1024;
- int c;
+ int32_t c;
for (c = 0; c < 0x100; c += 16)
{
uint8_t* block = &Memory.ROM [value + (c << 12)];
- int i;
+ int32_t i;
for (i = c; i < c + 16; i++)
Memory.Map [i + bank] = block;
@@ -25,7 +25,7 @@ void S9xSetSDD1MemoryMap(uint32_t bank, uint32_t value)
void S9xResetSDD1()
{
memset(&Memory.FillRAM [0x4800], 0, 4);
- int i;
+ int32_t i;
for (i = 0; i < 4; i++)
{
Memory.FillRAM [0x4804 + i] = i;
@@ -35,7 +35,7 @@ void S9xResetSDD1()
void S9xSDD1PostLoadState()
{
- int i;
+ int32_t i;
for (i = 0; i < 4; i++)
S9xSetSDD1MemoryMap(i, Memory.FillRAM [0x4804 + i]);
}
diff --git a/source/sdd1emu.c b/source/sdd1emu.c
index c788b49..5634960 100644
--- a/source/sdd1emu.c
+++ b/source/sdd1emu.c
@@ -18,16 +18,16 @@
#include "port.h"
#include "sdd1emu.h"
-static int valid_bits;
+static int32_t valid_bits;
static uint16_t in_stream;
static uint8_t* in_buf;
static uint8_t bit_ctr[8];
static uint8_t context_states[32];
-static int context_MPS[32];
-static int bitplane_type;
-static int high_context_bits;
-static int low_context_bits;
-static int prev_bits[8];
+static int32_t context_MPS[32];
+static int32_t bitplane_type;
+static int32_t high_context_bits;
+static int32_t low_context_bits;
+static int32_t prev_bits[8];
static struct
{
@@ -84,7 +84,7 @@ static uint8_t run_table[128] =
113, 49, 81, 17, 97, 33, 65, 1
};
-static inline uint8_t GetCodeword(int bits)
+static inline uint8_t GetCodeword(int32_t bits)
{
uint8_t tmp;
@@ -108,7 +108,7 @@ static inline uint8_t GetCodeword(int bits)
return run_table[tmp];
}
-static inline uint8_t GolombGetBit(int code_size)
+static inline uint8_t GolombGetBit(int32_t code_size)
{
if (!bit_ctr[code_size]) bit_ctr[code_size] = GetCodeword(code_size);
bit_ctr[code_size]--;
@@ -159,7 +159,7 @@ static inline uint8_t GetBit(uint8_t cur_bitplane)
return bit;
}
-void SDD1_decompress(uint8_t* out, uint8_t* in, int len)
+void SDD1_decompress(uint8_t* out, uint8_t* in, int32_t len)
{
uint8_t bit, i, plane;
uint8_t byte1, byte2;
diff --git a/source/sdd1emu.h b/source/sdd1emu.h
index a968f7d..07bdeb6 100644
--- a/source/sdd1emu.h
+++ b/source/sdd1emu.h
@@ -3,6 +3,6 @@
#ifndef SDD1EMU_H
#define SDD1EMU_H
-void SDD1_decompress(uint8_t* out, uint8_t* in, int output_length);
+void SDD1_decompress(uint8_t* out, uint8_t* in, int32_t output_length);
#endif
diff --git a/source/seta010.c b/source/seta010.c
index b9ce7c3..0e64248 100644
--- a/source/seta010.c
+++ b/source/seta010.c
@@ -86,7 +86,7 @@ const int16_t ST010_SinTable[256] =
-0x18f8, -0x15e2, -0x12c8, -0x0fab, -0x0c8b, -0x096a, -0x0647, -0x0324
};
-const unsigned char ST010_ArcTan[32][32] =
+const uint8_t ST010_ArcTan[32][32] =
{
{
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
@@ -267,13 +267,13 @@ void ST010_OP01(int16_t x0, int16_t y0, int16_t* x1, int16_t* y1, int16_t* Quadr
*Theta = (ST010_ArcTan[*y1][*x1] << 8) ^ *Quadrant;
}
-void ST010_Scale(int16_t Multiplier, int16_t X0, int16_t Y0, int* X1, int* Y1)
+void ST010_Scale(int16_t Multiplier, int16_t X0, int16_t Y0, int32_t* X1, int32_t* Y1)
{
*X1 = X0 * Multiplier << 1;
*Y1 = Y0 * Multiplier << 1;
}
-void ST010_Multiply(int16_t Multiplicand, int16_t Multiplier, int* Product)
+void ST010_Multiply(int16_t Multiplicand, int16_t Multiplier, int32_t* Product)
{
*Product = Multiplicand * Multiplier << 1;
}
@@ -293,7 +293,7 @@ void ST010_SortDrivers(uint16_t Positions, uint16_t Places[32], uint16_t Drivers
do
{
Sorted = true;
- int i;
+ int32_t i;
for (i = 0; i < Positions - 1; i++)
if (Places[i] < Places[i + 1])
{
@@ -351,7 +351,7 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
#else
uint16_t Places[32];
uint16_t Positions = ST010_WORD(0x0024);
- int Pos, Offset;
+ int32_t Pos, Offset;
Offset = 0;
@@ -392,9 +392,9 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
/* TODO - FIXME */
ST010_Scale(*(int16_t*)&Memory.SRAM[0x0004], *(int16_t*)&Memory.SRAM[0x0000],
*(int16_t*)&Memory.SRAM[0x0002],
- (int*)&Memory.SRAM[0x0010], (int*)&Memory.SRAM[0x0014]);
+ (int32_t*)&Memory.SRAM[0x0010], (int32_t*)&Memory.SRAM[0x0014]);
#else
- int x1, y1;
+ int32_t x1, y1;
ST010_Scale(ST010_WORD(0x0004), ST010_WORD(0x0000), ST010_WORD(0x0002), &x1,
&y1);
@@ -424,9 +424,9 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
#if defined(FAST_LSB_WORD_ACCESS) && !defined(ANDROID)
/* TODO - FIXME */
ST010_Multiply(*(int16_t*)&Memory.SRAM[0x0000], *(int16_t*)&Memory.SRAM[0x0002],
- (int*)&Memory.SRAM[0x0010]);
+ (int32_t*)&Memory.SRAM[0x0010]);
#else
- int Product;
+ int32_t Product;
ST010_Multiply(ST010_WORD(0x0000), ST010_WORD(0x0002), &Product);
@@ -577,7 +577,7 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
// calculate AI orientation based on specific guidelines
case 0x05:
{
- int dx, dy;
+ int32_t dx, dy;
int16_t a1, b1, c1;
uint16_t o1;
diff --git a/source/seta011.c b/source/seta011.c
index c2f2f3d..26a0f54 100644
--- a/source/seta011.c
+++ b/source/seta011.c
@@ -10,7 +10,7 @@ ST011_Regs ST011;
uint8_t board[9][9];
// debug
-static int line = 0;
+static int32_t line = 0;
uint8_t S9xGetST011(uint32_t Address)
{
@@ -104,7 +104,7 @@ void S9xSetST011(uint32_t Address, uint8_t Byte)
{
// 9x9 board data: top to bottom, left to right
// Values represent piece types and ownership
- int lcv;
+ int32_t lcv;
for (lcv = 0; lcv < 9; lcv++)
memcpy(board[lcv], ST011.parameters + lcv * 10, 9 * 1);
}
diff --git a/source/seta018.c b/source/seta018.c
index b385adf..00702d1 100644
--- a/source/seta018.c
+++ b/source/seta018.c
@@ -5,7 +5,7 @@
ST018_Regs ST018;
-static int line; // line counter
+static int32_t line; // line counter
uint8_t S9xGetST018(uint32_t Address)
{
diff --git a/source/snes9x.h b/source/snes9x.h
index de67001..1051af4 100644
--- a/source/snes9x.h
+++ b/source/snes9x.h
@@ -115,12 +115,12 @@ typedef struct
uint8_t* PCAtOpcodeStart;
uint8_t* WaitAddress;
uint32_t WaitCounter;
- long Cycles;
- long NextEvent;
- long V_Counter;
- long MemSpeed;
- long MemSpeedx2;
- long FastROMSpeed;
+ long Cycles; // For savestate compatibility can't change to int32_t
+ long NextEvent; // For savestate compatibility can't change to int32_t
+ long V_Counter; // For savestate compatibility can't change to int32_t
+ long MemSpeed; // For savestate compatibility can't change to int32_t
+ long MemSpeedx2; // For savestate compatibility can't change to int32_t
+ long FastROMSpeed; // For savestate compatibility can't change to int32_t
uint32_t AutoSaveTimer;
bool SRAMModified;
uint32_t NMITriggerPoint;
@@ -142,9 +142,9 @@ typedef struct
bool APUEnabled;
bool Shutdown;
uint8_t SoundSkipMethod;
- long H_Max;
- long HBlankStart;
- long CyclesPercentage;
+ int32_t H_Max;
+ int32_t HBlankStart;
+ int32_t CyclesPercentage;
bool DisableIRQ;
bool Paused;
bool ForcedPause;
@@ -213,18 +213,18 @@ typedef struct
#ifdef USE_BLARGG_APU
uint32_t SoundInputRate;
#endif
- bool TraceSoundDSP;
- bool EightBitConsoleSound; // due to caching, this needs S9xSetEightBitConsoleSound()
- int SoundBufferSize;
- int SoundMixInterval;
- bool SoundEnvelopeHeightReading;
- bool DisableSoundEcho;
- bool DisableMasterVolume;
- bool SoundSync;
- bool InterpolatedSound;
- bool ThreadSound;
- bool Mute;
- bool NextAPUEnabled;
+ bool TraceSoundDSP;
+ bool EightBitConsoleSound; // due to caching, this needs S9xSetEightBitConsoleSound()
+ int32_t SoundBufferSize;
+ int32_t SoundMixInterval;
+ bool SoundEnvelopeHeightReading;
+ bool DisableSoundEcho;
+ bool DisableMasterVolume;
+ bool SoundSync;
+ bool InterpolatedSound;
+ bool ThreadSound;
+ bool Mute;
+ bool NextAPUEnabled;
/* Graphics options */
bool Transparency;
@@ -257,8 +257,8 @@ typedef struct
bool TakeScreenshot;
int8_t StretchScreenshots;
uint16_t DisplayColor;
- int SoundDriver;
- int AIDOShmId;
+ int32_t SoundDriver;
+ int32_t AIDOShmId;
bool NoPatch;
bool ForceInterleaveGD24;
} SSettings;
@@ -278,7 +278,7 @@ extern SCPUState CPU;
extern SSNESGameFixes SNESGameFixes;
extern char String [513];
-void S9xMessage(int type, int number, const char* message);
+void S9xMessage(int32_t type, int32_t number, const char* message);
void S9xSetPause(uint32_t mask);
void S9xClearPause(uint32_t mask);
diff --git a/source/soundux.c b/source/soundux.c
index a67ca6b..237392e 100644
--- a/source/soundux.c
+++ b/source/soundux.c
@@ -35,7 +35,7 @@ static uint8_t FilterTapDefinitionBitfield;
extern uint32_t Z;
extern int32_t Loop [16];
-extern long FilterValues[4][2];
+extern int32_t FilterValues[4][2];
extern int32_t NoiseFreq [32];
uint32_t AttackRate [16] =
{
@@ -92,13 +92,13 @@ void DecodeBlockAsm(int8_t*, int16_t*, int32_t*, int32_t*);
#define LAST_SAMPLE 0xffffff
#define JUST_PLAYED_LAST_SAMPLE(c) ((c)->sample_pointer >= LAST_SAMPLE)
-static inline uint8_t* S9xGetSampleAddress(int sample_number)
+static inline uint8_t* S9xGetSampleAddress(int32_t sample_number)
{
uint32_t addr = (((APU.DSP[APU_DIR] << 8) + (sample_number << 2)) & 0xffff);
return (IAPU.RAM + addr);
}
-void S9xAPUSetEndOfSample(int i, Channel* ch)
+void S9xAPUSetEndOfSample(int32_t i, Channel* ch)
{
ch->state = SOUND_SILENT;
ch->mode = MODE_NONE;
@@ -108,12 +108,12 @@ void S9xAPUSetEndOfSample(int i, Channel* ch)
APU.KeyedChannels &= ~(1 << i);
}
-void S9xAPUSetEndX(int ch)
+void S9xAPUSetEndX(int32_t ch)
{
APU.DSP [APU_ENDX] |= 1 << ch;
}
-void S9xSetEnvRate(Channel* ch, uint32_t rate, int direction, int target, unsigned int mode)
+void S9xSetEnvRate(Channel* ch, uint32_t rate, int32_t direction, int32_t target, uint32_t mode)
{
ch->envx_target = target;
@@ -153,12 +153,12 @@ void S9xSetEnvRate(Channel* ch, uint32_t rate, int direction, int target, unsign
}
}
-void S9xSetEnvelopeRate(int channel, uint32_t rate, int direction, int target, unsigned int mode)
+void S9xSetEnvelopeRate(int32_t channel, uint32_t rate, int32_t direction, int32_t target, uint32_t mode)
{
S9xSetEnvRate(&SoundData.channels [channel], rate, direction, target, mode);
}
-void S9xSetSoundVolume(int channel, int16_t volume_left, int16_t volume_right)
+void S9xSetSoundVolume(int32_t channel, int16_t volume_left, int16_t volume_right)
{
Channel* ch = &SoundData.channels[channel];
ch->volume_left = volume_left;
@@ -196,7 +196,7 @@ void S9xSetEchoEnable(uint8_t byte)
}
SoundData.echo_enable = byte;
- int i;
+ int32_t i;
for (i = 0; i < NUM_CHANNELS; i++)
{
if (byte & (1 << i))
@@ -206,13 +206,13 @@ void S9xSetEchoEnable(uint8_t byte)
}
}
-void S9xSetEchoFeedback(int feedback)
+void S9xSetEchoFeedback(int32_t feedback)
{
CLIP8(feedback);
SoundData.echo_feedback = feedback;
}
-void S9xSetEchoDelay(int delay)
+void S9xSetEchoDelay(int32_t delay)
{
SoundData.echo_buffer_size = (512 * delay * so.playback_rate) >> 15;
SoundData.echo_buffer_size <<= 1;
@@ -234,7 +234,7 @@ void S9xSetFrequencyModulationEnable(uint8_t byte)
SoundData.pitch_mod = byte & 0xFE;
}
-void S9xSetSoundKeyOff(int channel)
+void S9xSetSoundKeyOff(int32_t channel)
{
Channel* ch = &SoundData.channels[channel];
@@ -251,17 +251,17 @@ void S9xFixSoundAfterSnapshotLoad()
SoundData.echo_write_enabled = !(APU.DSP [APU_FLG] & 0x20);
SoundData.echo_channel_enable = APU.DSP [APU_EON];
S9xSetEchoDelay(APU.DSP [APU_EDL] & 0xf);
- S9xSetEchoFeedback((signed char) APU.DSP [APU_EFB]);
-
- S9xSetFilterCoefficient(0, (signed char) APU.DSP [APU_C0]);
- S9xSetFilterCoefficient(1, (signed char) APU.DSP [APU_C1]);
- S9xSetFilterCoefficient(2, (signed char) APU.DSP [APU_C2]);
- S9xSetFilterCoefficient(3, (signed char) APU.DSP [APU_C3]);
- S9xSetFilterCoefficient(4, (signed char) APU.DSP [APU_C4]);
- S9xSetFilterCoefficient(5, (signed char) APU.DSP [APU_C5]);
- S9xSetFilterCoefficient(6, (signed char) APU.DSP [APU_C6]);
- S9xSetFilterCoefficient(7, (signed char) APU.DSP [APU_C7]);
- int i;
+ S9xSetEchoFeedback((int8_t) APU.DSP [APU_EFB]);
+
+ S9xSetFilterCoefficient(0, (int8_t) APU.DSP [APU_C0]);
+ S9xSetFilterCoefficient(1, (int8_t) APU.DSP [APU_C1]);
+ S9xSetFilterCoefficient(2, (int8_t) APU.DSP [APU_C2]);
+ S9xSetFilterCoefficient(3, (int8_t) APU.DSP [APU_C3]);
+ S9xSetFilterCoefficient(4, (int8_t) APU.DSP [APU_C4]);
+ S9xSetFilterCoefficient(5, (int8_t) APU.DSP [APU_C5]);
+ S9xSetFilterCoefficient(6, (int8_t) APU.DSP [APU_C6]);
+ S9xSetFilterCoefficient(7, (int8_t) APU.DSP [APU_C7]);
+ int32_t i;
for (i = 0; i < 8; i++)
{
SoundData.channels[i].needs_decode = true;
@@ -270,7 +270,7 @@ void S9xFixSoundAfterSnapshotLoad()
}
}
-void S9xSetFilterCoefficient(int tap, int value)
+void S9xSetFilterCoefficient(int32_t tap, int32_t value)
{
FilterTaps [tap & 7] = value;
if (value == 0 || (tap == 0 && value == 127))
@@ -279,11 +279,11 @@ void S9xSetFilterCoefficient(int tap, int value)
FilterTapDefinitionBitfield |= 1 << (tap & 7);
}
-void S9xSetSoundADSR(int channel, int attack_ind, int decay_ind, int sustain_ind, int sustain_level, int release_rate)
+void S9xSetSoundADSR(int32_t channel, int32_t attack_ind, int32_t decay_ind, int32_t sustain_ind, int32_t sustain_level, int32_t release_rate)
{
- int attack_rate = AttackRate [attack_ind];
- int decay_rate = DecayRate [decay_ind];
- int sustain_rate = SustainRate [sustain_ind];
+ int32_t attack_rate = AttackRate [attack_ind];
+ int32_t decay_rate = DecayRate [decay_ind];
+ int32_t sustain_rate = SustainRate [sustain_ind];
// Hack for ROMs that use a very short attack rate, key on a
// channel, then switch to decay mode. e.g. Final Fantasy II.
@@ -315,7 +315,7 @@ void S9xSetSoundADSR(int channel, int attack_ind, int decay_ind, int sustain_ind
}
}
-void S9xSetEnvelopeHeight(int channel, int level)
+void S9xSetEnvelopeHeight(int32_t channel, int32_t level)
{
Channel* ch = &SoundData.channels[channel];
@@ -329,7 +329,7 @@ void S9xSetEnvelopeHeight(int channel, int level)
S9xAPUSetEndOfSample(channel, ch);
}
-int S9xGetEnvelopeHeight(int channel)
+int32_t S9xGetEnvelopeHeight(int32_t channel)
{
if ((Settings.SoundEnvelopeHeightReading ||
SNESGameFixes.SoundEnvelopeHeightReading2) &&
@@ -345,20 +345,20 @@ int S9xGetEnvelopeHeight(int channel)
return (0);
}
-void S9xSetSoundFrequency(int channel, int hertz) // hertz [0~64K<<1]
+void S9xSetSoundFrequency(int32_t channel, int32_t hertz) // hertz [0~64K<<1]
{
if (SoundData.channels[channel].type == SOUND_NOISE)
hertz = NoiseFreq [APU.DSP [APU_FLG] & 0x1f];
SoundData.channels[channel].frequency = (hertz * so.freqbase) >> 11;
}
-void S9xSetSoundHertz(int channel, int hertz)
+void S9xSetSoundHertz(int32_t channel, int32_t hertz)
{
SoundData.channels[channel].hertz = hertz;
S9xSetSoundFrequency(channel, hertz);
}
-void S9xSetSoundType(int channel, int type_of_sound)
+void S9xSetSoundType(int32_t channel, int32_t type_of_sound)
{
SoundData.channels[channel].type = type_of_sound;
}
@@ -367,8 +367,8 @@ void DecodeBlock(Channel* ch)
{
int32_t out;
uint8_t filter;
- unsigned char shift;
- signed char sample1, sample2;
+ uint8_t shift;
+ int8_t sample1, sample2;
if (ch->block_pointer >= 0x10000 - 9)
{
@@ -385,7 +385,7 @@ void DecodeBlock(Channel* ch)
ch->loop = (filter & 2) != 0;
int16_t* raw = ch->block = ch->decoded;
- unsigned int i;
+ uint32_t i;
compressed++;
@@ -463,11 +463,11 @@ void DecodeBlock(Channel* ch)
ch->block_pointer += 9;
}
-static inline void MixStereo(int sample_count)
+static inline void MixStereo(int32_t sample_count)
{
static int32_t wave[SOUND_BUFFER_SIZE];
- int pitch_mod = SoundData.pitch_mod & ~APU.DSP[APU_NON];
+ int32_t pitch_mod = SoundData.pitch_mod & ~APU.DSP[APU_NON];
uint32_t J;
for (J = 0; J < NUM_CHANNELS; J++)
@@ -498,7 +498,7 @@ static inline void MixStereo(int sample_count)
if (Settings.InterpolatedSound && freq0 < FIXED_POINT && !mod)
ch->interpolate = ((ch->next_sample - ch->sample) *
- (long) freq0) / (long) FIXED_POINT;
+ (int32_t) freq0) / (int32_t) FIXED_POINT;
}
VL = (ch->sample * ch-> left_vol_level) / 128;
VR = (ch->sample * ch->right_vol_level) / 128;
@@ -703,9 +703,9 @@ static inline void MixStereo(int sample_count)
if (Settings.InterpolatedSound && freq < FIXED_POINT && !mod)
{
ch->interpolate = ((ch->next_sample - ch->sample) *
- (long) freq) / (long) FIXED_POINT;
+ (int32_t) freq) / (int32_t) FIXED_POINT;
ch->sample = (int16_t)(ch->sample + (((ch->next_sample - ch->sample) *
- (long)(ch->count)) / (long) FIXED_POINT));
+ (int32_t)(ch->count)) / (int32_t) FIXED_POINT));
}
else
ch->interpolate = 0;
@@ -713,7 +713,7 @@ static inline void MixStereo(int sample_count)
else
{
// Snes9x 1.53's SPC_DSP.cpp, by blargg
- int feedback = (noise_gen << 13) ^ (noise_gen << 14);
+ int32_t feedback = (noise_gen << 13) ^ (noise_gen << 14);
noise_gen = (feedback & 0x4000) ^ (noise_gen >> 1);
ch->sample = (noise_gen << 17) >> 17;
ch->interpolate = 0;
@@ -752,10 +752,10 @@ stereo_exit:
}
}
-void S9xMixSamples(uint16_t* buffer, int sample_count)
+void S9xMixSamples(int16_t* buffer, int32_t sample_count)
{
- int J;
- int I;
+ int32_t J;
+ int32_t I;
if (SoundData.echo_enable)
memset(EchoBuffer, 0, sample_count * sizeof(EchoBuffer [0]));
@@ -771,7 +771,7 @@ void S9xMixSamples(uint16_t* buffer, int sample_count)
// ... but no filter defined.
for (J = 0; J < sample_count; J++)
{
- int E = Echo [SoundData.echo_ptr];
+ int32_t E = Echo [SoundData.echo_ptr];
Echo[SoundData.echo_ptr++] = (E * SoundData.echo_feedback) / 128 + EchoBuffer [J];
if (SoundData.echo_ptr >= SoundData.echo_buffer_size)
@@ -788,7 +788,7 @@ void S9xMixSamples(uint16_t* buffer, int sample_count)
for (J = 0; J < sample_count; J++)
{
Loop [(Z - 0) & 15] = Echo [SoundData.echo_ptr];
- int E = Loop [(Z - 0) & 15] * FilterTaps [0];
+ int32_t E = Loop [(Z - 0) & 15] * FilterTaps [0];
if (FilterTapDefinitionBitfield & 0x02) E += Loop [(Z - 2) & 15] * FilterTaps [1];
if (FilterTapDefinitionBitfield & 0x04) E += Loop [(Z - 4) & 15] * FilterTaps [2];
if (FilterTapDefinitionBitfield & 0x08) E += Loop [(Z - 6) & 15] * FilterTaps [3];
@@ -824,7 +824,7 @@ void S9xMixSamples(uint16_t* buffer, int sample_count)
void S9xResetSound(bool full)
{
- int i;
+ int32_t i;
for (i = 0; i < 8; i++)
{
SoundData.channels[i].state = SOUND_SILENT;
@@ -893,12 +893,12 @@ void S9xSetPlaybackRate(uint32_t playback_rate)
// notaz: calculate a value (let's call it freqbase) to simplify channel freq calculations later.
so.freqbase = (FIXED_POINT << 11) / (playback_rate * 33 / 32);
// now precalculate env rates for S9xSetEnvRate
- static int steps [] =
+ static int32_t steps [] =
{
0, 64, 619, 619, 128, 1, 64, 55, 64, 619
};
- int i, u;
+ int32_t i, u;
for (u = 0 ; u < 10 ; u++)
{
@@ -922,7 +922,7 @@ void S9xSetPlaybackRate(uint32_t playback_rate)
}
S9xSetEchoDelay(APU.DSP [APU_EDL] & 0xf);
- int i;
+ int32_t i;
for (i = 0; i < 8; i++)
S9xSetSoundFrequency(i, SoundData.channels [i].hertz);
}
@@ -934,7 +934,7 @@ bool S9xInitSound()
return (1);
}
-bool S9xSetSoundMode(int channel, int mode)
+bool S9xSetSoundMode(int32_t channel, int32_t mode)
{
Channel* ch = &SoundData.channels[channel];
@@ -971,7 +971,7 @@ bool S9xSetSoundMode(int channel, int mode)
return (false);
}
-void S9xPlaySample(int channel)
+void S9xPlaySample(int32_t channel)
{
Channel* ch = &SoundData.channels[channel];
diff --git a/source/soundux.h b/source/soundux.h
index e4cf3ad..72f00df 100644
--- a/source/soundux.h
+++ b/source/soundux.h
@@ -31,8 +31,8 @@ enum { MODE_NONE = SOUND_SILENT, MODE_ADSR, MODE_RELEASE = SOUND_RELEASE,
typedef struct
{
- int playback_rate;
- int buffer_size;
+ int32_t playback_rate;
+ int32_t buffer_size;
uint32_t freqbase; // notaz
bool mute_sound;
} SoundStatus;
@@ -41,21 +41,21 @@ SoundStatus so;
typedef struct
{
- int state;
- int type;
+ int32_t state;
+ int32_t type;
int16_t volume_left;
int16_t volume_right;
uint32_t hertz;
uint32_t frequency;
uint32_t count;
bool loop;
- int envx;
+ int32_t envx;
int16_t left_vol_level;
int16_t right_vol_level;
int16_t envx_target;
uint32_t env_error;
uint32_t erate;
- int direction;
+ int32_t direction;
uint32_t attack_rate;
uint32_t decay_rate;
uint32_t sustain_rate;
@@ -70,8 +70,8 @@ typedef struct
bool needs_decode;
uint32_t block_pointer;
uint32_t sample_pointer;
- int* echo_buf_ptr;
- int mode;
+ int32_t* echo_buf_ptr;
+ int32_t mode;
int32_t envxx;
int16_t next_sample;
int32_t interpolate;
@@ -86,52 +86,52 @@ typedef struct
typedef struct
{
- int echo_enable;
- int echo_feedback; /* range is -128 .. 127 */
- int echo_ptr;
- int echo_buffer_size;
- int echo_write_enabled;
- int echo_channel_enable;
- int pitch_mod;
+ int32_t echo_enable;
+ int32_t echo_feedback; /* range is -128 .. 127 */
+ int32_t echo_ptr;
+ int32_t echo_buffer_size;
+ int32_t echo_write_enabled;
+ int32_t echo_channel_enable;
+ int32_t pitch_mod;
// Just incase they are needed in the future, for snapshot compatibility.
uint32_t dummy [3];
Channel channels [NUM_CHANNELS];
int16_t master_volume [2]; /* range is -128 .. 127 */
int16_t echo_volume [2]; /* range is -128 .. 127 */
- int noise_hertz;
+ int32_t noise_hertz;
} SSoundData;
SSoundData SoundData;
-void S9xSetSoundVolume(int channel, int16_t volume_left, int16_t volume_right);
-void S9xSetSoundFrequency(int channel, int hertz);
-void S9xSetSoundHertz(int channel, int hertz);
-void S9xSetSoundType(int channel, int type_of_sound);
+void S9xSetSoundVolume(int32_t channel, int16_t volume_left, int16_t volume_right);
+void S9xSetSoundFrequency(int32_t channel, int32_t hertz);
+void S9xSetSoundHertz(int32_t channel, int32_t hertz);
+void S9xSetSoundType(int32_t channel, int32_t type_of_sound);
void S9xSetMasterVolume(int16_t master_volume_left, int16_t master_volume_right);
void S9xSetEchoVolume(int16_t echo_volume_left, int16_t echo_volume_right);
-void S9xSetEnvelopeHeight(int channel, int height);
-void S9xSetSoundADSR(int channel, int attack, int decay, int sustain, int sustain_level, int release);
-void S9xSetSoundKeyOff(int channel);
-void S9xSetSoundDecayMode(int channel);
-void S9xSetSoundAttachMode(int channel);
+void S9xSetEnvelopeHeight(int32_t channel, int32_t height);
+void S9xSetSoundADSR(int32_t channel, int32_t attack, int32_t decay, int32_t sustain, int32_t sustain_level, int32_t release);
+void S9xSetSoundKeyOff(int32_t channel);
+void S9xSetSoundDecayMode(int32_t channel);
+void S9xSetSoundAttachMode(int32_t channel);
void S9xSoundStartEnvelope(Channel*);
-void S9xSetEchoFeedback(int echo_feedback);
+void S9xSetEchoFeedback(int32_t echo_feedback);
void S9xSetEchoEnable(uint8_t byte);
-void S9xSetEchoDelay(int byte);
+void S9xSetEchoDelay(int32_t byte);
void S9xSetEchoWriteEnable(uint8_t byte);
-void S9xSetFilterCoefficient(int tap, int value);
+void S9xSetFilterCoefficient(int32_t tap, int32_t value);
void S9xSetFrequencyModulationEnable(uint8_t byte);
-void S9xSetEnvelopeRate(int channel, uint32_t rate, int direction, int target, unsigned int mode);
-bool S9xSetSoundMode(int channel, int mode);
+void S9xSetEnvelopeRate(int32_t channel, uint32_t rate, int32_t direction, int32_t target, uint32_t mode);
+bool S9xSetSoundMode(int32_t channel, int32_t mode);
void S9xResetSound(bool full);
void S9xFixSoundAfterSnapshotLoad();
-void S9xPlaybackSoundSetting(int channel);
-void S9xPlaySample(int channel);
-void S9xFixEnvelope(int channel, uint8_t gain, uint8_t adsr1, uint8_t adsr2);
-void S9xStartSample(int channel);
+void S9xPlaybackSoundSetting(int32_t channel);
+void S9xPlaySample(int32_t channel);
+void S9xFixEnvelope(int32_t channel, uint8_t gain, uint8_t adsr1, uint8_t adsr2);
+void S9xStartSample(int32_t channel);
-void S9xMixSamples(uint16_t* buffer, int sample_count);
-bool S9xOpenSoundDevice(int, bool, int);
+void S9xMixSamples(int16_t* buffer, int32_t sample_count);
+bool S9xOpenSoundDevice(int32_t, bool, int32_t);
void S9xSetPlaybackRate(uint32_t rate);
#endif
diff --git a/source/spc700.c b/source/spc700.c
index 5e50cf3..7b1a8b7 100644
--- a/source/spc700.c
+++ b/source/spc700.c
@@ -158,11 +158,11 @@ APUSetZN8 ((uint8_t) Int16);
#define Relative()\
Int8 = OP1;\
- Int16 = (intptr_t) (IAPU.PC + 2 - IAPU.RAM) + Int8;
+ Int16 = (int16_t) (IAPU.PC + 2 - IAPU.RAM) + Int8;
#define Relative2()\
Int8 = OP2;\
- Int16 = (intptr_t) (IAPU.PC + 3 - IAPU.RAM) + Int8;
+ Int16 = (int16_t) (IAPU.PC + 3 - IAPU.RAM) + Int8;
#ifdef FAST_LSB_WORD_ACCESS
#define IndexedXIndirect()\
diff --git a/source/spc7110.c b/source/spc7110.c
index 66bfecc..1c87809 100644
--- a/source/spc7110.c
+++ b/source/spc7110.c
@@ -57,7 +57,7 @@ typedef struct SPC7110DecompressionLocationStruct
//this maps an index.bin table to the decompression pack
typedef struct SPC7110DecompressionIndexStruct
{
- int table;
+ int32_t table;
bool is_file;
Data7110 location[256];
} Index7110;
@@ -67,8 +67,8 @@ typedef struct SPC7110DecompressionPackStructure
{
uint8_t* binfiles[MAX_TABLES];
Index7110 tableEnts[MAX_TABLES];
- int last_table;
- int idx;
+ int32_t last_table;
+ int32_t idx;
uint8_t last_idx;
uint16_t last_offset;
} Pack7110;
@@ -158,10 +158,10 @@ void MovePackData()
decompack->last_idx = s7r.reg4804;
//start decompression
- int table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801;
+ int32_t table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801;
//the table is a offset multiplier byte and a big-endian pointer
- int j = 4 * s7r.reg4804;
+ int32_t j = 4 * s7r.reg4804;
j += s7r.DataRomOffset;
j += table;
@@ -194,7 +194,7 @@ void MovePackData()
//find the table
if (table != decompack->last_table)
{
- int i = 0;
+ int32_t i = 0;
while (i < MAX_TABLES && decompack->tableEnts[i].table != table)
i++;
if (i == MAX_TABLES)
@@ -225,12 +225,12 @@ void MovePackData()
// and reads the data directly. Method 2
void ReadPackData()
{
- static int table_age_2;
- static int table_age_3;
- static int table_age_4;
- static int table_age_5;
+ static int32_t table_age_2;
+ static int32_t table_age_3;
+ static int32_t table_age_4;
+ static int32_t table_age_5;
- int table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801;
+ int32_t table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801;
if (table == 0)
{
@@ -254,7 +254,7 @@ void ReadPackData()
decompack->last_idx = s7r.reg4804;
- int j = 4 * s7r.reg4804;
+ int32_t j = 4 * s7r.reg4804;
j += s7r.DataRomOffset;
j += table;
@@ -283,7 +283,7 @@ void ReadPackData()
decompack->last_offset %= DECOMP_BUFFER_SIZE;
if (table != decompack->last_table)
{
- int i = 0;
+ int32_t i = 0;
while (i < MAX_TABLES && decompack->tableEnts[i].table != table)
i++;
if (i == MAX_TABLES)
@@ -376,9 +376,9 @@ void GetPackData()
decompack->last_offset = (s7r.reg4805) | (s7r.reg4806 << 8);
decompack->last_idx = s7r.reg4804;
- int table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801;
+ int32_t table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801;
- int j = 4 * s7r.reg4804;
+ int32_t j = 4 * s7r.reg4804;
j += s7r.DataRomOffset;
j += table;
@@ -407,7 +407,7 @@ void GetPackData()
decompack->last_offset %= DECOMP_BUFFER_SIZE;
if (table != decompack->last_table)
{
- int i = 0;
+ int32_t i = 0;
while (i < MAX_TABLES && decompack->tableEnts[i].table != table)
i++;
if (i == MAX_TABLES)
@@ -899,9 +899,9 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
case 0x480B:
{
s7r.reg480B = data;
- int table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801;
+ int32_t table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801;
- int j = 4 * s7r.reg4804;
+ int32_t j = 4 * s7r.reg4804;
j += s7r.DataRomOffset;
j += table;
@@ -965,7 +965,7 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
{
uint32_t i = (s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811;
if (s7r.reg4818 & 0x08)
- i += (signed char)s7r.reg4814;
+ i += (int8_t)s7r.reg4814;
else
i += s7r.reg4814;
i %= s7r.DataRomSize;
@@ -1029,7 +1029,7 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
uint32_t i = (s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811;
if (s7r.reg4818 & 0x08)
- i += (signed char)s7r.reg4814;
+ i += (int8_t)s7r.reg4814;
else
i += s7r.reg4814;
i %= s7r.DataRomSize;
@@ -1117,7 +1117,7 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
{
int16_t m1 = (int16_t)((s7r.reg4824) | (s7r.reg4825 << 8));
int16_t m2 = (int16_t)((s7r.reg4820) | (s7r.reg4821 << 8));
- int mul = m1 * m2;
+ int32_t mul = m1 * m2;
s7r.reg4828 = (uint8_t)(mul & 0x000000FF);
s7r.reg4829 = (uint8_t)((mul & 0x0000FF00) >> 8);
s7r.reg482A = (uint8_t)((mul & 0x00FF0000) >> 16);
@@ -1146,14 +1146,14 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
s7r.reg4827 = data;
if (s7r.reg482E & 0x01)
{
- int quotient;
+ int32_t quotient;
int16_t remainder;
- int dividend = (int)(s7r.reg4820 | (s7r.reg4821 << 8) | (s7r.reg4822 << 16) |
- (s7r.reg4823 << 24));
+ int32_t dividend = (int32_t)(s7r.reg4820 | (s7r.reg4821 << 8) | (s7r.reg4822 << 16) |
+ (s7r.reg4823 << 24));
int16_t divisor = (int16_t)(s7r.reg4826 | (s7r.reg4827 << 8));
if (divisor != 0)
{
- quotient = (int)(dividend / divisor);
+ quotient = (int32_t)(dividend / divisor);
remainder = (int16_t)(dividend % divisor);
}
else
@@ -1358,9 +1358,9 @@ uint8_t S9xGetSPC7110Byte(uint32_t Address)
/* Return the number of days in a specific month for a certain year */
/* copied directly for RTC functionality, separated in case of incompatibilities */
/**********************************************************************************************/
-int S9xRTCDaysInMonth(int month, int year)
+int32_t S9xRTCDaysInMonth(int32_t month, int32_t year)
{
- int mdays;
+ int32_t mdays;
switch (month)
{
@@ -1397,8 +1397,8 @@ int S9xRTCDaysInMonth(int month, int year)
void S9xUpdateRTC()
{
- time_t cur_systime;
- long time_diff;
+ time_t cur_systime;
+ int32_t time_diff;
// Keep track of game time by computing the number of seconds that pass on the system
// clock and adding the same number of seconds to the RTC clock structure.
@@ -1413,21 +1413,21 @@ void S9xUpdateRTC()
// If your tick interval is different adjust the
// DAYTICK, HOURTICK, and MINUTETICK defines
- time_diff = (long)(cur_systime - rtc_f9.last_used);
+ time_diff = (int32_t)(cur_systime - rtc_f9.last_used);
rtc_f9.last_used = cur_systime;
if (time_diff > 0)
{
- int seconds;
- int minutes;
- int hours;
- int days;
- int month;
- int year;
- int temp_days;
+ int32_t seconds;
+ int32_t minutes;
+ int32_t hours;
+ int32_t days;
+ int32_t month;
+ int32_t year;
+ int32_t temp_days;
- int year_tens;
- int year_ones;
+ int32_t year_tens;
+ int32_t year_ones;
if (time_diff > DAYTICKS)
@@ -1551,16 +1551,16 @@ bool Load7110Index(char* filename)
{
FILE* fp;
uint8_t buffer[12];
- int table = 0;
+ int32_t table = 0;
uint8_t index = 0;
uint32_t offset = 0;
uint32_t size = 0;
- int i = 0;
+ int32_t i = 0;
fp = fopen(filename, "rb");
if (NULL == fp)
return false;
- int f_len;
+ int32_t f_len;
while (1)
{
i = 0;
@@ -1593,7 +1593,7 @@ bool Load7110Index(char* filename)
void SPC7110Load(char* dirname)
{
char temp_path[PATH_MAX];
- int i = 0;
+ int32_t i = 0;
decompack = (Pack7110*)malloc(sizeof(Pack7110));
@@ -1650,7 +1650,7 @@ void SPC7110Load(char* dirname)
void SPC7110Open(char* dirname)
{
char temp_path[PATH_MAX];
- int i = 0;
+ int32_t i = 0;
decompack = (Pack7110*)malloc(sizeof(Pack7110));
@@ -1689,7 +1689,7 @@ void SPC7110Open(char* dirname)
void SPC7110Grab(char* dirname)
{
char temp_path[PATH_MAX];
- int i = 0;
+ int32_t i = 0;
decompack = (Pack7110*)malloc(sizeof(Pack7110));
@@ -1761,7 +1761,7 @@ void SPC7110Grab(char* dirname)
//Cache 1 clean up function
void Del7110Gfx()
{
- int i;
+ int32_t i;
if (Settings.SPC7110)
{
Do7110Logging();
@@ -1786,7 +1786,7 @@ void Del7110Gfx()
//Cache2 cleanup function
void Close7110Gfx()
{
- int i;
+ int32_t i;
if (Settings.SPC7110)
{
Do7110Logging();
@@ -1811,7 +1811,7 @@ void Close7110Gfx()
//cache 3's clean-up code
void Drop7110Gfx()
{
- int i;
+ int32_t i;
if (Settings.SPC7110)
{
Do7110Logging();
@@ -1904,7 +1904,7 @@ void Do7110Logging()
{
uint8_t ent_temp;
FILE* flog;
- int entries = 0;
+ int32_t entries = 0;
if (Settings.SPC7110)
{
@@ -1955,15 +1955,15 @@ void Do7110Logging()
if (flog)
{
uint8_t buffer[8];
- int table = 0;
+ int32_t table = 0;
uint16_t offset = 0;
uint16_t length = 0;
fseek(flog, 35, 0);
- int f_len;
+ int32_t f_len;
while (1)
{
- int i = 0;
+ int32_t i = 0;
Data7110* log = NULL;
f_len = fread(buffer, 1, 8, flog);
if (f_len < 8) break;
@@ -2032,11 +2032,11 @@ void Do7110Logging()
//count entries
if (flog)
{
- int j = 0;
- int temp = 0;
+ int32_t j = 0;
+ int32_t temp = 0;
for (j = 0; j < MAX_TABLES; j++)
{
- int k;
+ int32_t k;
for (k = 0; k < 256; k++)
{
if (decompack->tableEnts[j].location[k].used_len != 0)
@@ -2068,7 +2068,7 @@ void Do7110Logging()
for (j = 0; j < MAX_TABLES; j++)
{
- int k;
+ int32_t k;
for (k = 0; k < 256; k++)
{
if (decompack->tableEnts[j].location[k].used_len != 0)
@@ -2105,7 +2105,7 @@ bool S9xSaveSPC7110RTC(S7RTC* rtc_f9)
if ((fp = fopen(S9xGetFilename("rtc"), "wb")) == NULL)
return (false);
- int i = 0;
+ int32_t i = 0;
uint8_t temp = 0;
for (i = 0; i < 16; i++)
fwrite(&rtc_f9->reg[i], 1, 1, fp);
@@ -2135,7 +2135,7 @@ bool S9xLoadSPC7110RTC(S7RTC* rtc_f9)
if ((fp = fopen(S9xGetFilename("rtc"), "rb")) == NULL)
return (false);
- int i;
+ int32_t i;
for (i = 0; i < 16; i++)
fread(&(rtc_f9->reg[i]), 1, 1, fp);
uint8_t temp = 0;
diff --git a/source/spc7110.h b/source/spc7110.h
index 92fb1d3..06a594a 100644
--- a/source/spc7110.h
+++ b/source/spc7110.h
@@ -24,7 +24,7 @@ uint8_t* Get7110BasePtr(uint32_t);
void S9xSpc7110Reset();
void S9xUpdateRTC();
void Do7110Logging();
-int S9xRTCDaysInMonth(int month, int year);
+int32_t S9xRTCDaysInMonth(int32_t month, int32_t year);
//These are platform-dependant functions, but should work on
//most systems that use GNU compilers, and on Win32.
@@ -34,67 +34,67 @@ void SPC7110Grab(char*);
typedef struct SPC7110RTC
{
- unsigned char reg[16];
- int16_t index;
- uint8_t control;
- bool init;
- time_t last_used;
+ uint8_t reg[16];
+ int16_t index;
+ uint8_t control;
+ bool init;
+ time_t last_used;
} S7RTC;
typedef struct SPC7110EmuVars
{
- unsigned char reg4800;
- unsigned char reg4801;
- unsigned char reg4802;
- unsigned char reg4803;
- unsigned char reg4804;
- unsigned char reg4805;
- unsigned char reg4806;
- unsigned char reg4807;
- unsigned char reg4808;
- unsigned char reg4809;
- unsigned char reg480A;
- unsigned char reg480B;
- unsigned char reg480C;
- unsigned char reg4811;
- unsigned char reg4812;
- unsigned char reg4813;
- unsigned char reg4814;
- unsigned char reg4815;
- unsigned char reg4816;
- unsigned char reg4817;
- unsigned char reg4818;
- unsigned char reg4820;
- unsigned char reg4821;
- unsigned char reg4822;
- unsigned char reg4823;
- unsigned char reg4824;
- unsigned char reg4825;
- unsigned char reg4826;
- unsigned char reg4827;
- unsigned char reg4828;
- unsigned char reg4829;
- unsigned char reg482A;
- unsigned char reg482B;
- unsigned char reg482C;
- unsigned char reg482D;
- unsigned char reg482E;
- unsigned char reg482F;
- unsigned char reg4830;
- unsigned char reg4831;
- unsigned char reg4832;
- unsigned char reg4833;
- unsigned char reg4834;
- unsigned char reg4840;
- unsigned char reg4841;
- unsigned char reg4842;
- uint8_t AlignBy;
- uint8_t written;
- uint8_t offset_add;
- uint32_t DataRomOffset;
- uint32_t DataRomSize;
- uint32_t bank50Internal;
- uint8_t bank50[DECOMP_BUFFER_SIZE];
+ uint8_t reg4800;
+ uint8_t reg4801;
+ uint8_t reg4802;
+ uint8_t reg4803;
+ uint8_t reg4804;
+ uint8_t reg4805;
+ uint8_t reg4806;
+ uint8_t reg4807;
+ uint8_t reg4808;
+ uint8_t reg4809;
+ uint8_t reg480A;
+ uint8_t reg480B;
+ uint8_t reg480C;
+ uint8_t reg4811;
+ uint8_t reg4812;
+ uint8_t reg4813;
+ uint8_t reg4814;
+ uint8_t reg4815;
+ uint8_t reg4816;
+ uint8_t reg4817;
+ uint8_t reg4818;
+ uint8_t reg4820;
+ uint8_t reg4821;
+ uint8_t reg4822;
+ uint8_t reg4823;
+ uint8_t reg4824;
+ uint8_t reg4825;
+ uint8_t reg4826;
+ uint8_t reg4827;
+ uint8_t reg4828;
+ uint8_t reg4829;
+ uint8_t reg482A;
+ uint8_t reg482B;
+ uint8_t reg482C;
+ uint8_t reg482D;
+ uint8_t reg482E;
+ uint8_t reg482F;
+ uint8_t reg4830;
+ uint8_t reg4831;
+ uint8_t reg4832;
+ uint8_t reg4833;
+ uint8_t reg4834;
+ uint8_t reg4840;
+ uint8_t reg4841;
+ uint8_t reg4842;
+ uint8_t AlignBy;
+ uint8_t written;
+ uint8_t offset_add;
+ uint32_t DataRomOffset;
+ uint32_t DataRomSize;
+ uint32_t bank50Internal;
+ uint8_t bank50[DECOMP_BUFFER_SIZE];
} SPC7110Regs;
extern SPC7110Regs s7r;
diff --git a/source/srtc.c b/source/srtc.c
index 94ad27f..78cb4a7 100644
--- a/source/srtc.c
+++ b/source/srtc.c
@@ -35,7 +35,7 @@ Index Description Range (nibble)
SRTC_DATA rtc;
-static int month_keys[12] = { 1, 4, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6 };
+static int32_t month_keys[12] = { 1, 4, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6 };
/*********************************************************************************************
@@ -77,12 +77,12 @@ void S9xHardResetSRTC()
/* S9xSRTCComputeDayOfWeek() */
/* Return 0-6 for Sunday-Saturday */
/**********************************************************************************************/
-unsigned int S9xSRTCComputeDayOfWeek()
+uint32_t S9xSRTCComputeDayOfWeek()
{
- unsigned year = rtc.data[10] * 10 + rtc.data[9];
- unsigned month = rtc.data[8];
- unsigned day = rtc.data[7] * 10 + rtc.data[6];
- unsigned day_of_week;
+ uint32_t year = rtc.data[10] * 10 + rtc.data[9];
+ uint32_t month = rtc.data[8];
+ uint32_t day = rtc.data[7] * 10 + rtc.data[6];
+ uint32_t day_of_week;
year += (rtc.data[11] - 9) * 100;
@@ -105,9 +105,9 @@ unsigned int S9xSRTCComputeDayOfWeek()
/* S9xSRTCDaysInMonth() */
/* Return the number of days in a specific month for a certain year */
/**********************************************************************************************/
-int S9xSRTCDaysInMmonth(int month, int year)
+int32_t S9xSRTCDaysInMmonth(int32_t month, int32_t year)
{
- int mdays;
+ int32_t mdays;
switch (month)
{
@@ -145,8 +145,8 @@ int S9xSRTCDaysInMmonth(int month, int year)
/**********************************************************************************************/
void S9xUpdateSrtcTime()
{
- time_t cur_systime;
- long time_diff;
+ time_t cur_systime;
+ int32_t time_diff;
// Keep track of game time by computing the number of seconds that pass on the system
// clock and adding the same number of seconds to the S-RTC clock structure.
@@ -166,23 +166,22 @@ void S9xUpdateSrtcTime()
// If your tick interval is different adjust the
// DAYTICK, HOURTICK, and MINUTETICK defines
- time_diff = (long)(cur_systime - rtc.system_timestamp);
+ time_diff = (int32_t)(cur_systime - rtc.system_timestamp);
rtc.system_timestamp = cur_systime;
if (time_diff > 0)
{
- int seconds;
- int minutes;
- int hours;
- int days;
- int month;
- int year;
- int temp_days;
-
- int year_hundreds;
- int year_tens;
- int year_ones;
-
+ int32_t seconds;
+ int32_t minutes;
+ int32_t hours;
+ int32_t days;
+ int32_t month;
+ int32_t year;
+ int32_t temp_days;
+
+ int32_t year_hundreds;
+ int32_t year_tens;
+ int32_t year_ones;
if (time_diff > DAYTICKS)
{
@@ -420,8 +419,7 @@ void S9xSRTCPreSaveState()
{
S9xUpdateSrtcTime();
- int s = Memory.SRAMSize ?
- (1 << (Memory.SRAMSize + 3)) * 128 : 0;
+ int32_t s = Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0;
if (s > 0x20000)
s = 0x20000;
@@ -452,8 +450,7 @@ void S9xSRTCPostLoadState()
{
if (Settings.SRTC)
{
- int s = Memory.SRAMSize ?
- (1 << (Memory.SRAMSize + 3)) * 128 : 0;
+ int32_t s = Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0;
if (s > 0x20000)
s = 0x20000;
diff --git a/source/tile.h b/source/tile.h
index 427c975..6bc4e23 100644
--- a/source/tile.h
+++ b/source/tile.h
@@ -172,7 +172,7 @@
pixel = PIXEL; \
for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
{ \
- int z; \
+ int32_t z; \
for (z = Pixels - 1; z >= 0; z--) \
if (GFX.Z1 > Depth [z]) \
{ \
@@ -191,7 +191,7 @@
pixel = PIXEL; \
for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
{ \
- int z; \
+ int32_t z; \
for (z = Pixels - 1; z >= 0; z--) \
if (GFX.Z1 > Depth [z]) \
{ \
@@ -217,7 +217,7 @@
pixel = PIXEL; \
for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
{ \
- int z; \
+ int32_t z; \
for (z = Pixels - 2; z >= 0; z -= 2) \
if (GFX.Z1 > Depth [z]) \
{ \
@@ -236,7 +236,7 @@
pixel = PIXEL; \
for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
{ \
- int z; \
+ int32_t z; \
for (z = Pixels - 2; z >= 0; z -= 2) \
if (GFX.Z1 > Depth [z]) \
{ \