aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Silva2017-02-12 01:52:03 +0000
committerJoão Silva2017-02-12 01:52:03 +0000
commit3777d1fcf4232cde426f46b7ee5c374fd949b1b0 (patch)
treee76f38bc1bac83bab19daea51d63ed87236e047e
parentb6006bc542f89ad1b7086268f851f0ba880ad6cd (diff)
downloadsnes9x2005-3777d1fcf4232cde426f46b7ee5c374fd949b1b0.tar.gz
snes9x2005-3777d1fcf4232cde426f46b7ee5c374fd949b1b0.tar.bz2
snes9x2005-3777d1fcf4232cde426f46b7ee5c374fd949b1b0.zip
Type fixes. Fixes from snes9x 1.50. Minor changes and optimizations.
-rw-r--r--libretro.c4
-rw-r--r--source/65c816.h61
-rw-r--r--source/apu.c7
-rw-r--r--source/apu.h8
-rw-r--r--source/apu_blargg.c60
-rw-r--r--source/apu_blargg.h46
-rw-r--r--source/cheats.c8
-rw-r--r--source/cheats.h45
-rw-r--r--source/cpu.c18
-rw-r--r--source/cpuexec.c85
-rw-r--r--source/cpuexec.h16
-rw-r--r--source/display.h2
-rw-r--r--source/dma.c29
-rw-r--r--source/dma.h2
-rw-r--r--source/dsp1.c512
-rw-r--r--source/dsp2emu.c52
-rw-r--r--source/dsp4emu.c15
-rw-r--r--source/fxemu.c68
-rw-r--r--source/fxemu.h5
-rw-r--r--source/fxinst.c92
-rw-r--r--source/fxinst.h22
-rw-r--r--source/getset.h97
-rw-r--r--source/gfx.c72
-rw-r--r--source/gfx.h2
-rw-r--r--source/memmap.c160
-rw-r--r--source/messages.h51
-rw-r--r--source/obc1.c19
-rw-r--r--source/port.h5
-rw-r--r--source/ppu.c516
-rw-r--r--source/ppu.h44
-rw-r--r--source/sa1.c11
-rw-r--r--source/sa1.h11
-rw-r--r--source/sa1cpu.c64
-rw-r--r--source/seta011.c16
-rw-r--r--source/seta018.c7
-rw-r--r--source/snes9x.h32
-rw-r--r--source/soundux.c25
-rw-r--r--source/spc700.c2
-rw-r--r--source/spc700.h16
-rw-r--r--source/spc7110.c36
-rw-r--r--source/spc7110.h10
-rw-r--r--source/srtc.c3
-rw-r--r--source/tile.c16
43 files changed, 517 insertions, 1855 deletions
diff --git a/libretro.c b/libretro.c
index 73d0d9f..53c652e 100644
--- a/libretro.c
+++ b/libretro.c
@@ -109,9 +109,9 @@ unsigned retro_api_version()
return RETRO_API_VERSION;
}
-void S9xMessage(int32_t type, int32_t number, const char* message)
+void S9xMessage(const char* message)
{
-#define MAX_MESSAGE_LEN (36 * 3)
+ #define MAX_MESSAGE_LEN (36 * 3)
static char buffer [MAX_MESSAGE_LEN + 1];
diff --git a/source/65c816.h b/source/65c816.h
index f180037..1d8eb60 100644
--- a/source/65c816.h
+++ b/source/65c816.h
@@ -26,50 +26,47 @@
#define Negative 128
#define Emulation 256
-#define ClearCarry() (ICPU._Carry = 0)
-#define SetCarry() (ICPU._Carry = 1)
-#define SetZero() (ICPU._Zero = 0)
-#define ClearZero() (ICPU._Zero = 1)
-#define SetIRQ() (ICPU.Registers.PL |= IRQ)
-#define ClearIRQ() (ICPU.Registers.PL &= ~IRQ)
-#define SetDecimal() (ICPU.Registers.PL |= Decimal)
-#define ClearDecimal() (ICPU.Registers.PL &= ~Decimal)
-#define SetIndex() (ICPU.Registers.PL |= IndexFlag)
-#define ClearIndex() (ICPU.Registers.PL &= ~IndexFlag)
-#define SetMemory() (ICPU.Registers.PL |= MemoryFlag)
-#define ClearMemory() (ICPU.Registers.PL &= ~MemoryFlag)
-#define SetOverflow() (ICPU._Overflow = 1)
-#define ClearOverflow() (ICPU._Overflow = 0)
-#define SetNegative() (ICPU._Negative = 0x80)
-#define ClearNegative() (ICPU._Negative = 0)
+#define SetCarry() (ICPU._Carry = 1)
+#define ClearCarry() (ICPU._Carry = 0)
+#define SetZero() (ICPU._Zero = 0)
+#define ClearZero() (ICPU._Zero = 1)
+#define SetIRQ() (ICPU.Registers.PL |= IRQ)
+#define ClearIRQ() (ICPU.Registers.PL &= ~IRQ)
+#define SetDecimal() (ICPU.Registers.PL |= Decimal)
+#define ClearDecimal() (ICPU.Registers.PL &= ~Decimal)
+#define SetIndex() (ICPU.Registers.PL |= IndexFlag)
+#define ClearIndex() (ICPU.Registers.PL &= ~IndexFlag)
+#define SetMemory() (ICPU.Registers.PL |= MemoryFlag)
+#define ClearMemory() (ICPU.Registers.PL &= ~MemoryFlag)
+#define SetOverflow() (ICPU._Overflow = 1)
+#define ClearOverflow() (ICPU._Overflow = 0)
+#define SetNegative() (ICPU._Negative = 0x80)
+#define ClearNegative() (ICPU._Negative = 0)
-#define CheckZero() (ICPU._Zero == 0)
-#define CheckCarry() (ICPU._Carry)
-#define CheckIRQ() (ICPU.Registers.PL & IRQ)
-#define CheckDecimal() (ICPU.Registers.PL & Decimal)
-#define CheckIndex() (ICPU.Registers.PL & IndexFlag)
-#define CheckMemory() (ICPU.Registers.PL & MemoryFlag)
-#define CheckOverflow() (ICPU._Overflow)
-#define CheckNegative() (ICPU._Negative & 0x80)
+#define CheckCarry() (ICPU._Carry)
+#define CheckZero() (ICPU._Zero == 0)
+#define CheckIRQ() (ICPU.Registers.PL & IRQ)
+#define CheckDecimal() (ICPU.Registers.PL & Decimal)
+#define CheckIndex() (ICPU.Registers.PL & IndexFlag)
+#define CheckMemory() (ICPU.Registers.PL & MemoryFlag)
+#define CheckOverflow() (ICPU._Overflow)
+#define CheckNegative() (ICPU._Negative & 0x80)
#define CheckEmulation() (ICPU.Registers.P.W & Emulation)
-#define ClearFlags(f) (ICPU.Registers.P.W &= ~(f))
-#define SetFlags(f) (ICPU.Registers.P.W |= (f))
-#define CheckFlag(f) (ICPU.Registers.PL & (f))
+#define SetFlags(f) (ICPU.Registers.P.W |= (f))
+#define ClearFlags(f) (ICPU.Registers.P.W &= ~(f))
+#define CheckFlag(f) (ICPU.Registers.PL & (f))
typedef union
{
-#ifdef MSB_FIRST
struct
{
+#ifdef MSB_FIRST
uint8_t h, l;
- } B;
#else
- struct
- {
uint8_t l, h;
- } B;
#endif
+ } B;
uint16_t W;
} pair;
diff --git a/source/apu.c b/source/apu.c
index a28469d..521d9b3 100644
--- a/source/apu.c
+++ b/source/apu.c
@@ -77,7 +77,6 @@ void S9xResetAPU()
for (i = 0; i < 3; i++)
{
APU.TimerEnabled [i] = false;
- APU.TimerValueWritten [i] = 0;
APU.TimerTarget [i] = 0;
APU.Timer [i] = 0;
}
@@ -388,9 +387,9 @@ void S9xSetAPUControl(uint8_t byte)
if ((APU.TimerTarget [2] = IAPU.RAM [0xfc]) == 0)
APU.TimerTarget [2] = 0x100;
}
- APU.TimerEnabled [0] = byte & 1;
- APU.TimerEnabled [1] = (byte & 2) >> 1;
- APU.TimerEnabled [2] = (byte & 4) >> 2;
+ APU.TimerEnabled [0] = (bool) (byte & 1);
+ APU.TimerEnabled [1] = (bool) (byte & 2);
+ APU.TimerEnabled [2] = (bool) (byte & 4);
if (byte & 0x10)
IAPU.RAM [0xF4] = IAPU.RAM [0xF5] = 0;
diff --git a/source/apu.h b/source/apu.h
index bafeac9..57ff79d 100644
--- a/source/apu.h
+++ b/source/apu.h
@@ -47,21 +47,21 @@ typedef struct
SAPU APU;
SIAPU IAPU;
-static inline void S9xAPUUnpackStatus(void)
+static inline void S9xAPUUnpackStatus()
{
IAPU._Zero = ((IAPU.Registers.P & Zero) == 0) | (IAPU.Registers.P & Negative);
IAPU._Carry = (IAPU.Registers.P & Carry);
IAPU._Overflow = (IAPU.Registers.P & Overflow) >> 6;
}
-static inline void S9xAPUPackStatus(void)
+static inline void S9xAPUPackStatus()
{
IAPU.Registers.P &= ~(Zero | Negative | Carry | Overflow);
IAPU.Registers.P |= IAPU._Carry | ((IAPU._Zero == 0) << 1) |
(IAPU._Zero & 0x80) | (IAPU._Overflow << 6);
}
-void S9xResetAPU(void);
+void S9xResetAPU();
bool S9xInitAPU();
void S9xDeinitAPU();
void S9xDecacheSamples();
@@ -73,7 +73,7 @@ void S9xOpenCloseSoundTracingFile(bool);
void S9xPrintAPUState();
extern uint16_t S9xAPUCycles [256]; // Scaled cycle lengths
extern uint16_t S9xAPUCycleLengths [256]; // Raw data.
-extern void (*S9xApuOpcodes [256])(void);
+extern void (*S9xApuOpcodes [256])();
#define APU_VOL_LEFT 0x00
#define APU_VOL_RIGHT 0x01
diff --git a/source/apu_blargg.c b/source/apu_blargg.c
index bbe02c9..abf982e 100644
--- a/source/apu_blargg.c
+++ b/source/apu_blargg.c
@@ -327,7 +327,7 @@ static INLINE void dsp_decode_brr( dsp_voice_t* v )
if ( (dsp_m.every_other_sample ^= 1) != 0 ) \
dsp_m.new_kon &= ~dsp_m.kon; /* clears KON 63 clocks after it was last read */
-static INLINE void dsp_misc_30 (void)
+static INLINE void dsp_misc_30()
{
if ( dsp_m.every_other_sample )
{
@@ -606,11 +606,11 @@ static void dsp_voice_V9_V6_V3( dsp_voice_t* const v )
ECHO_FIR( 0 ) [ch] = ECHO_FIR( 8 ) [ch] = s >> 1; \
}
-static INLINE void dsp_echo_22 (void)
+static INLINE void dsp_echo_22()
{
int32_t l, r;
- if ( ++dsp_m.echo_hist_pos >= &dsp_m.echo_hist [ECHO_HIST_SIZE] )
+ if (++dsp_m.echo_hist_pos >= &dsp_m.echo_hist [ECHO_HIST_SIZE])
dsp_m.echo_hist_pos = dsp_m.echo_hist;
dsp_m.t_echo_ptr = (dsp_m.t_esa * 0x100 + dsp_m.echo_offset) & 0xFFFF;
@@ -624,7 +624,7 @@ static INLINE void dsp_echo_22 (void)
dsp_m.t_echo_in [1] = r;
}
-static INLINE void dsp_echo_23 (void)
+static INLINE void dsp_echo_23()
{
int32_t l, r;
@@ -637,7 +637,7 @@ static INLINE void dsp_echo_23 (void)
ECHO_READ(1);
}
-static INLINE void dsp_echo_24 (void)
+static INLINE void dsp_echo_24()
{
int32_t l, r;
@@ -648,7 +648,7 @@ static INLINE void dsp_echo_24 (void)
dsp_m.t_echo_in [1] += r;
}
-static INLINE void dsp_echo_25 (void)
+static INLINE void dsp_echo_25()
{
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);
@@ -674,7 +674,7 @@ static INLINE void dsp_echo_25 (void)
CLAMP16( var ); \
}
-static INLINE void dsp_echo_26 (void)
+static INLINE void dsp_echo_26()
{
int32_t l, r;
@@ -690,7 +690,7 @@ static INLINE void dsp_echo_26 (void)
dsp_m.t_echo_out [1] = r & ~1;
}
-static INLINE void dsp_echo_27 (void)
+static INLINE void dsp_echo_27()
{
int32_t l, r;
int16_t *out;
@@ -733,7 +733,7 @@ static INLINE void dsp_echo_27 (void)
} \
dsp_m.t_echo_out [ch] = 0;
-static INLINE void dsp_echo_29 (void)
+static INLINE void dsp_echo_29()
{
dsp_m.t_esa = dsp_m.regs [R_ESA];
@@ -949,7 +949,7 @@ static void dsp_set_output( int16_t * out, int32_t size )
/* Setup */
-static void dsp_soft_reset_common (void)
+static void dsp_soft_reset_common()
{
dsp_m.noise = 0x4000;
dsp_m.echo_hist_pos = dsp_m.echo_hist;
@@ -962,7 +962,7 @@ static void dsp_soft_reset_common (void)
/* Resets DSP to power-on state */
-static void dsp_reset (void)
+static void dsp_reset()
{
int32_t i;
@@ -1009,7 +1009,7 @@ static void dsp_init( void* ram_64k )
/* Emulates pressing reset switch on SNES */
-static void dsp_soft_reset (void)
+static void dsp_soft_reset()
{
dsp_m.regs[R_FLG] = 0xE0;
dsp_soft_reset_common();
@@ -2576,7 +2576,6 @@ set_psw:
{
addr &= 0xFFFF;
SET_PC( addr );
- /* dprintf( "SPC: PC wrapped around\n" ); */
goto loop;
}
}
@@ -2670,7 +2669,7 @@ uint8_t * spc_apuram()
/* Init */
-static void spc_reset_buffer(void)
+static void spc_reset_buffer()
{
int16_t *out;
/* Start with half extra buffer of silence */
@@ -2745,7 +2744,7 @@ static void spc_reset_common( int32_t timer_counter_init )
/* Resets SPC to power-on state. This resets your output buffer, so you must
call set_output() after this. */
-static void spc_reset (void)
+static void spc_reset()
{
m.cpu_regs.pc = 0xFFC0;
m.cpu_regs.a = 0x00;
@@ -2782,9 +2781,9 @@ static void spc_reset (void)
/* Emulates pressing reset switch on SNES. This resets your output buffer, so
you must call set_output() after this. */
-static void spc_soft_reset (void)
+static void spc_soft_reset()
{
- spc_reset_common( 0 );
+ spc_reset_common(0);
dsp_soft_reset();
}
@@ -2926,7 +2925,7 @@ static INLINE int32_t hermite (int32_t mu1, int32_t a, int32_t b, int32_t c, int
return ((a0) + (a1) + (a2) + (a3)) >> 15;
}
-static void resampler_clear(void)
+static void resampler_clear()
{
rb_start = 0;
rb_size = 0;
@@ -3073,7 +3072,7 @@ bool S9xMixSamples (int16_t *buffer, uint32_t sample_count)
return (true);
}
-int32_t S9xGetSampleCount (void)
+int32_t S9xGetSampleCount()
{
return AVAIL();
}
@@ -3108,7 +3107,7 @@ static void spc_set_output( int16_t* out, int32_t size )
dsp_set_output( out, out_end - out );
}
-void S9xFinalizeSamples (void)
+void S9xFinalizeSamples()
{
bool ret;
@@ -3126,13 +3125,13 @@ void S9xFinalizeSamples (void)
spc_set_output(landing_buffer, buffer_size);
}
-void S9xClearSamples (void)
+void S9xClearSamples()
{
resampler_clear();
lag = lag_master;
}
-bool S9xSyncSound (void)
+bool S9xSyncSound()
{
if (!Settings.SoundSync || sound_in_sync)
return true;
@@ -3147,7 +3146,7 @@ void S9xSetSamplesAvailableCallback (apu_callback callback)
sa_callback = callback;
}
-static void UpdatePlaybackRate (void)
+static void UpdatePlaybackRate()
{
double time_ratio;
if (Settings.SoundInputRate == 0)
@@ -3179,8 +3178,6 @@ bool S9xInitSound (int32_t buffer_ms, int32_t lag_ms)
buffer_size <<= 1;
buffer_size <<= 1;
- printf("Sound buffer size: %d (%d samples)\n", buffer_size, sample_count);
-
if (landing_buffer)
free(landing_buffer);
landing_buffer = (int16_t*)malloc(buffer_size * 2);
@@ -3248,7 +3245,7 @@ static int8_t const reg_times_ [256] =
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
};
-bool S9xInitAPU (void)
+bool S9xInitAPU()
{
int32_t i;
@@ -3303,7 +3300,7 @@ bool S9xInitAPU (void)
return true;
}
-void S9xDeinitAPU (void)
+void S9xDeinitAPU()
{
if (resampler)
{
@@ -3338,7 +3335,7 @@ void S9xAPUSetReferenceTime (int32_t cpucycles)
reference_time = cpucycles;
}
-void S9xAPUExecute (void)
+void S9xAPUExecute()
{
/* Accumulate partial APU cycles */
spc_end_frame(S9X_APU_GET_CLOCK(CPU.Cycles));
@@ -3352,9 +3349,6 @@ void S9xAPUExecute (void)
void S9xAPUTimingSetSpeedup (int32_t ticks)
{
- if (ticks != 0)
- printf("APU speedup hack: %d\n", ticks);
-
timing_hack_denominator = TEMPO_UNIT - ticks;
spc_set_tempo(timing_hack_denominator);
@@ -3370,7 +3364,7 @@ void S9xAPUAllowTimeOverflow (bool allow)
allow_time_overflow = allow;
}
-void S9xResetAPU (void)
+void S9xResetAPU()
{
reference_time = 0;
spc_remainder = 0;
@@ -3383,7 +3377,7 @@ void S9xResetAPU (void)
resampler_clear();
}
-void S9xSoftResetAPU (void)
+void S9xSoftResetAPU()
{
reference_time = 0;
spc_remainder = 0;
diff --git a/source/apu_blargg.h b/source/apu_blargg.h
index 66c375f..00d9428 100644
--- a/source/apu_blargg.h
+++ b/source/apu_blargg.h
@@ -226,7 +226,7 @@ typedef struct
} Timer;
/* Support SNES_MEMORY_APURAM */
-uint8_t *spc_apuram (void);
+uint8_t* spc_apuram();
typedef struct
{
@@ -276,31 +276,31 @@ typedef struct
/* Number of samples written to output since last set */
#define SPC_SAMPLE_COUNT() ((m.extra_clocks >> 5) * 2)
-typedef void (*apu_callback)(void);
+typedef void (*apu_callback)();
#define SPC_SAVE_STATE_BLOCK_SIZE (STATE_SIZE + 8)
-bool S9xInitAPU (void);
-void S9xDeinitAPU (void);
-void S9xResetAPU (void);
-void S9xSoftResetAPU (void);
-uint8_t S9xAPUReadPort (int32_t port);
-void S9xAPUWritePort (int32_t port, uint8_t byte);
-void S9xAPUExecute (void);
-void S9xAPUSetReferenceTime (int32_t cpucycles);
-void S9xAPUTimingSetSpeedup (int32_t ticks);
-void S9xAPUAllowTimeOverflow (bool allow);
-void S9xAPULoadState (const uint8_t * block);
-void S9xAPUSaveState (uint8_t * block);
-
-bool S9xInitSound (int32_t buffer_ms, int32_t lag_ms);
-
-bool S9xSyncSound (void);
-int32_t S9xGetSampleCount (void);
-void S9xFinalizeSamples (void);
-void S9xClearSamples (void);
-bool S9xMixSamples (int16_t * buffer, uint32_t sample_count);
-void S9xSetSamplesAvailableCallback (apu_callback);
+bool S9xInitAPU();
+void S9xDeinitAPU();
+void S9xResetAPU();
+void S9xSoftResetAPU();
+uint8_t S9xAPUReadPort(int32_t port);
+void S9xAPUWritePort(int32_t port, uint8_t byte);
+void S9xAPUExecute();
+void S9xAPUSetReferenceTime(int32_t cpucycles);
+void S9xAPUTimingSetSpeedup(int32_t ticks);
+void S9xAPUAllowTimeOverflow(bool allow);
+void S9xAPULoadState(const uint8_t * block);
+void S9xAPUSaveState(uint8_t * block);
+
+bool S9xInitSound(int32_t buffer_ms, int32_t lag_ms);
+
+bool S9xSyncSound();
+int32_t S9xGetSampleCount();
+void S9xFinalizeSamples();
+void S9xClearSamples();
+bool S9xMixSamples(int16_t * buffer, uint32_t sample_count);
+void S9xSetSamplesAvailableCallback(apu_callback);
#endif // APU_BLARGG_H
diff --git a/source/cheats.c b/source/cheats.c
index b394032..5856769 100644
--- a/source/cheats.c
+++ b/source/cheats.c
@@ -34,8 +34,7 @@ const char* S9xProActionReplayToRaw(const char* code, uint32_t* address,
return (NULL);
}
-const char* S9xGoldFingerToRaw(const char* code, uint32_t* address, bool* sram,
- uint8_t* num_bytes, uint8_t bytes[3])
+const char* S9xGoldFingerToRaw(const char* code, uint32_t* address, bool* sram, uint8_t* num_bytes, uint8_t bytes[3])
{
char tmp [15];
if (strlen(code) != 14)
@@ -65,8 +64,7 @@ const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte
{
char new_code [12];
- if (strlen(code) != 9 || *(code + 4) != '-' || !S9xAllHex(code, 4) ||
- !S9xAllHex(code + 5, 4))
+ if (strlen(code) != 9 || *(code + 4) != '-' || !S9xAllHex(code, 4) || !S9xAllHex(code + 5, 4))
return ("Invalid Game Genie(tm) code - should be 'xxxx-xxxx'.");
strcpy(new_code, "0x");
@@ -104,7 +102,7 @@ const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte
((data & 0x0f0000) >> 12) +
((data & 0x0003c0) >> 6);
- return (NULL);
+ return NULL;
}
void S9xStartCheatSearch(SCheatData* d)
diff --git a/source/cheats.h b/source/cheats.h
index a4a5ba7..6c3c093 100644
--- a/source/cheats.h
+++ b/source/cheats.h
@@ -44,33 +44,28 @@ typedef enum
S9X_8_BITS, S9X_16_BITS, S9X_24_BITS, S9X_32_BITS
} S9xCheatDataSize;
-void S9xInitCheatData ();
+void S9xInitCheatData();
-const char *S9xGameGenieToRaw (const char *code, uint32_t *address, uint8_t *byte);
-const char *S9xProActionReplayToRaw (const char *code, uint32_t *address, uint8_t *byte);
-const char *S9xGoldFingerToRaw (const char *code, uint32_t *address, bool *sram,
- uint8_t *num_bytes, uint8_t bytes[3]);
-void S9xApplyCheats(void);
-void S9xApplyCheat (uint32_t which1);
-void S9xRemoveCheats ();
-void S9xRemoveCheat (uint32_t which1);
-void S9xEnableCheat (uint32_t which1);
-void S9xDisableCheat (uint32_t which1);
-void S9xDisableAllCheat(void);
-void S9xAddCheat (bool enable, bool save_current_value, uint32_t address,
- uint8_t byte);
-void S9xDeleteCheats(void);
-void S9xDeleteCheat (uint32_t which1);
-bool S9xLoadCheatFile (const char *filename);
-bool S9xSaveCheatFile (const char *filename);
+const char *S9xGameGenieToRaw(const char *code, uint32_t *address, uint8_t *byte);
+const char *S9xProActionReplayToRaw(const char *code, uint32_t *address, uint8_t *byte);
+const char *S9xGoldFingerToRaw(const char *code, uint32_t *address, bool *sram, uint8_t *num_bytes, uint8_t bytes[3]);
+void S9xApplyCheats();
+void S9xApplyCheat(uint32_t which1);
+void S9xRemoveCheats();
+void S9xRemoveCheat(uint32_t which1);
+void S9xEnableCheat(uint32_t which1);
+void S9xDisableCheat(uint32_t which1);
+void S9xDisableAllCheat();
+void S9xAddCheat(bool enable, bool save_current_value, uint32_t address, uint8_t byte);
+void S9xDeleteCheats();
+void S9xDeleteCheat(uint32_t which1);
+bool S9xLoadCheatFile(const char *filename);
+bool S9xSaveCheatFile(const char *filename);
-void S9xStartCheatSearch (SCheatData *cheats);
-void S9xSearchForChange (SCheatData *cheats, S9xCheatComparisonType cmp,
- S9xCheatDataSize size, bool is_signed, bool update);
-void S9xSearchForValue (SCheatData *cheats, S9xCheatComparisonType cmp,
- S9xCheatDataSize size, uint32_t value,
- bool is_signed, bool update);
-void S9xOutputCheatSearchResults (SCheatData *cheats);
+void S9xStartCheatSearch(SCheatData *cheats);
+void S9xSearchForChange(SCheatData *cheats, S9xCheatComparisonType cmp, S9xCheatDataSize size, bool is_signed, bool update);
+void S9xSearchForValue(SCheatData *cheats, S9xCheatComparisonType cmp, S9xCheatDataSize size, uint32_t value, bool is_signed, bool update);
+void S9xOutputCheatSearchResults(SCheatData *cheats);
#endif
diff --git a/source/cpu.c b/source/cpu.c
index e702670..15206c5 100644
--- a/source/cpu.c
+++ b/source/cpu.c
@@ -7,6 +7,7 @@
#include "cpuexec.h"
#include "apu.h"
#include "dma.h"
+#include "fxemu.h"
#include "sa1.h"
#include "cheats.h"
#include "srtc.h"
@@ -14,8 +15,6 @@
#include "spc7110.h"
#include "obc1.h"
-#include "fxemu.h"
-
extern struct FxInit_s SuperFX;
void S9xResetSuperFX()
@@ -27,11 +26,11 @@ void S9xResetSuperFX()
void S9xResetCPU()
{
ICPU.Registers.PB = 0;
- ICPU.Registers.PC = S9xGetWord(0xFFFC);
+ ICPU.Registers.PC = S9xGetWord(0xfffc);
ICPU.Registers.D.W = 0;
ICPU.Registers.DB = 0;
ICPU.Registers.SH = 1;
- ICPU.Registers.SL = 0xFF;
+ ICPU.Registers.SL = 0xff;
ICPU.Registers.XH = 0;
ICPU.Registers.YH = 0;
ICPU.Registers.P.W = 0;
@@ -52,13 +51,12 @@ void S9xResetCPU()
CPU.PCBase = NULL;
CPU.PCAtOpcodeStart = NULL;
CPU.WaitAddress = NULL;
- CPU.WaitCounter = 0;
- CPU.Cycles = 0;
+ CPU.WaitCounter = 1;
+ CPU.Cycles = 188; // This is the cycle count just after the jump to the Reset Vector.
CPU.NextEvent = Settings.HBlankStart;
CPU.V_Counter = 0;
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
- CPU.FastROMSpeed = SLOW_ONE_CYCLE;
CPU.AutoSaveTimer = 0;
CPU.SRAMModified = false;
CPU.BRKTriggered = false;
@@ -72,7 +70,7 @@ void S9xResetCPU()
S9xUnpackStatus();
}
-static void CommonS9xReset(void)
+static void CommonS9xReset()
{
if (Settings.SuperFX)
S9xResetSuperFX();
@@ -101,14 +99,14 @@ static void CommonS9xReset(void)
#endif
}
-void S9xReset(void)
+void S9xReset()
{
CommonS9xReset();
S9xResetPPU();
memset(Memory.RAM, 0x55, 0x20000);
}
-void S9xSoftReset(void)
+void S9xSoftReset()
{
CommonS9xReset();
S9xSoftResetPPU();
diff --git a/source/cpuexec.c b/source/cpuexec.c
index c834adf..d7151be 100644
--- a/source/cpuexec.c
+++ b/source/cpuexec.c
@@ -13,10 +13,10 @@
#include "sa1.h"
#include "spc7110.h"
-void S9xMainLoop_SA1_SFX(void);
-void S9xMainLoop_SA1_NoSFX(void);
-void S9xMainLoop_NoSA1_SFX(void);
-void S9xMainLoop_NoSA1_NoSFX(void);
+void S9xMainLoop_SA1_SFX();
+void S9xMainLoop_SA1_NoSFX();
+void S9xMainLoop_NoSA1_SFX();
+void S9xMainLoop_NoSA1_NoSFX();
/*
* This is a CATSFC modification inspired by a Snes9x-Euphoria modification.
@@ -27,7 +27,7 @@ void S9xMainLoop_NoSA1_NoSFX(void);
* to propagate modifications to the SA1_NoSFX, NoSA1_SFX and NoSA1_NoSFX
* versions.
*/
-void S9xMainLoop(void)
+void S9xMainLoop()
{
if (Settings.SA1)
{
@@ -41,7 +41,7 @@ void S9xMainLoop(void)
}
}
-void S9xMainLoop_SA1_SFX(void)
+void S9xMainLoop_SA1_SFX()
{
for (;;)
{
@@ -56,7 +56,7 @@ void S9xMainLoop_SA1_SFX(void)
if (CPU.WaitingForInterrupt)
{
CPU.WaitingForInterrupt = false;
- ++CPU.PC;
+ CPU.PC++;
}
S9xOpcode_NMI();
}
@@ -69,7 +69,7 @@ void S9xMainLoop_SA1_SFX(void)
if (CPU.WaitingForInterrupt)
{
CPU.WaitingForInterrupt = false;
- ++CPU.PC;
+ CPU.PC++;
}
if (CPU.IRQActive && !Settings.DisableIRQ)
{
@@ -79,13 +79,9 @@ void S9xMainLoop_SA1_SFX(void)
else
CPU.Flags &= ~IRQ_PENDING_FLAG;
}
- else
- {
- if (--CPU.IRQCycleCount == 0 && CheckFlag(IRQ))
- CPU.IRQCycleCount = 1;
- }
+ else if (--CPU.IRQCycleCount == 0 && CheckFlag(IRQ))
+ CPU.IRQCycleCount = 1;
}
-
if (CPU.Flags & SCAN_KEYS_FLAG)
break;
}
@@ -94,7 +90,6 @@ void S9xMainLoop_SA1_SFX(void)
CPU.PCAtOpcodeStart = CPU.PC;
#endif
CPU.Cycles += CPU.MemSpeed;
-
(*ICPU.S9xOpcodes [*CPU.PC++].S9xOpcode)();
if (SA1.Executing)
@@ -110,18 +105,9 @@ void S9xMainLoop_SA1_SFX(void)
#endif
if (CPU.Flags & SCAN_KEYS_FLAG)
CPU.Flags &= ~SCAN_KEYS_FLAG;
-
-#ifdef DETECT_NASTY_FX_INTERLEAVE
- if (CPU.BRKTriggered && Settings.SuperFX && !CPU.TriedInterleavedMode2)
- {
- CPU.TriedInterleavedMode2 = true;
- CPU.BRKTriggered = false;
- S9xDeinterleaveMode2();
- }
-#endif
}
-void S9xMainLoop_SA1_NoSFX(void)
+void S9xMainLoop_SA1_NoSFX()
{
for (;;)
{
@@ -159,13 +145,9 @@ void S9xMainLoop_SA1_NoSFX(void)
else
CPU.Flags &= ~IRQ_PENDING_FLAG;
}
- else
- {
- if (--CPU.IRQCycleCount == 0 && CheckFlag(IRQ))
- CPU.IRQCycleCount = 1;
- }
+ else if (--CPU.IRQCycleCount == 0 && CheckFlag(IRQ))
+ CPU.IRQCycleCount = 1;
}
-
if (CPU.Flags & SCAN_KEYS_FLAG)
break;
}
@@ -174,7 +156,6 @@ void S9xMainLoop_SA1_NoSFX(void)
CPU.PCAtOpcodeStart = CPU.PC;
#endif
CPU.Cycles += CPU.MemSpeed;
-
(*ICPU.S9xOpcodes [*CPU.PC++].S9xOpcode)();
if (SA1.Executing)
@@ -192,7 +173,7 @@ void S9xMainLoop_SA1_NoSFX(void)
CPU.Flags &= ~SCAN_KEYS_FLAG;
}
-void S9xMainLoop_NoSA1_SFX(void)
+void S9xMainLoop_NoSA1_SFX()
{
for (;;)
{
@@ -207,7 +188,7 @@ void S9xMainLoop_NoSA1_SFX(void)
if (CPU.WaitingForInterrupt)
{
CPU.WaitingForInterrupt = false;
- ++CPU.PC;
+ CPU.PC++;
}
S9xOpcode_NMI();
}
@@ -220,7 +201,7 @@ void S9xMainLoop_NoSA1_SFX(void)
if (CPU.WaitingForInterrupt)
{
CPU.WaitingForInterrupt = false;
- ++CPU.PC;
+ CPU.PC++;
}
if (CPU.IRQActive && !Settings.DisableIRQ)
{
@@ -230,13 +211,9 @@ void S9xMainLoop_NoSA1_SFX(void)
else
CPU.Flags &= ~IRQ_PENDING_FLAG;
}
- else
- {
- if (--CPU.IRQCycleCount == 0 && CheckFlag(IRQ))
- CPU.IRQCycleCount = 1;
- }
+ else if (--CPU.IRQCycleCount == 0 && CheckFlag(IRQ))
+ CPU.IRQCycleCount = 1;
}
-
if (CPU.Flags & SCAN_KEYS_FLAG)
break;
}
@@ -245,9 +222,7 @@ void S9xMainLoop_NoSA1_SFX(void)
CPU.PCAtOpcodeStart = CPU.PC;
#endif
CPU.Cycles += CPU.MemSpeed;
-
(*ICPU.S9xOpcodes [*CPU.PC++].S9xOpcode)();
-
DO_HBLANK_CHECK_SFX();
}
@@ -259,18 +234,9 @@ void S9xMainLoop_NoSA1_SFX(void)
#endif
if (CPU.Flags & SCAN_KEYS_FLAG)
CPU.Flags &= ~SCAN_KEYS_FLAG;
-
-#ifdef DETECT_NASTY_FX_INTERLEAVE
- if (CPU.BRKTriggered && Settings.SuperFX && !CPU.TriedInterleavedMode2)
- {
- CPU.TriedInterleavedMode2 = true;
- CPU.BRKTriggered = false;
- S9xDeinterleaveMode2();
- }
-#endif
}
-void S9xMainLoop_NoSA1_NoSFX(void)
+void S9xMainLoop_NoSA1_NoSFX()
{
for (;;)
{
@@ -308,13 +274,9 @@ void S9xMainLoop_NoSA1_NoSFX(void)
else
CPU.Flags &= ~IRQ_PENDING_FLAG;
}
- else
- {
- if (--CPU.IRQCycleCount == 0 && CheckFlag(IRQ))
- CPU.IRQCycleCount = 1;
- }
+ else if (--CPU.IRQCycleCount == 0 && CheckFlag(IRQ))
+ CPU.IRQCycleCount = 1;
}
-
if (CPU.Flags & SCAN_KEYS_FLAG)
break;
}
@@ -323,9 +285,7 @@ void S9xMainLoop_NoSA1_NoSFX(void)
CPU.PCAtOpcodeStart = CPU.PC;
#endif
CPU.Cycles += CPU.MemSpeed;
-
(*ICPU.S9xOpcodes [*CPU.PC++].S9xOpcode)();
-
DO_HBLANK_CHECK_NoSFX();
}
@@ -396,8 +356,7 @@ void S9xDoHBlankProcessing_SFX()
CPU.NextEvent = -1;
ICPU.Scanline++;
- if (++CPU.V_Counter >= (Settings.PAL ? SNES_MAX_PAL_VCOUNTER :
- SNES_MAX_NTSC_VCOUNTER))
+ if (++CPU.V_Counter >= (Settings.PAL ? SNES_MAX_PAL_VCOUNTER : SNES_MAX_NTSC_VCOUNTER))
{
CPU.V_Counter = 0;
Memory.FillRAM[0x213F] ^= 0x80;
diff --git a/source/cpuexec.h b/source/cpuexec.h
index c4342be..6d738dd 100644
--- a/source/cpuexec.h
+++ b/source/cpuexec.h
@@ -6,9 +6,9 @@
typedef struct
{
#ifdef __WIN32__
- void (__cdecl* S9xOpcode)(void);
+ void (__cdecl* S9xOpcode)();
#else
- void (*S9xOpcode)(void);
+ void (*S9xOpcode)();
#endif
} SOpcodes;
@@ -41,9 +41,9 @@ typedef struct
uint32_t FrameAdvanceCount;
} SICPU;
-void S9xMainLoop(void);
-void S9xReset(void);
-void S9xSoftReset(void);
+void S9xMainLoop();
+void S9xReset();
+void S9xSoftReset();
void S9xDoHBlankProcessing_SFX();
void S9xDoHBlankProcessing_NoSFX();
void S9xClearIRQ(uint32_t);
@@ -68,8 +68,7 @@ static inline void S9xUnpackStatus()
static inline void S9xPackStatus()
{
ICPU.Registers.PL &= ~(Zero | Negative | Carry | Overflow);
- ICPU.Registers.PL |= ICPU._Carry | ((ICPU._Zero == 0) << 1) |
- (ICPU._Negative & 0x80) | (ICPU._Overflow << 6);
+ ICPU.Registers.PL |= ICPU._Carry | ((ICPU._Zero == 0) << 1) | (ICPU._Negative & 0x80) | (ICPU._Overflow << 6);
}
static inline void CLEAR_IRQ_SOURCE(uint32_t M)
@@ -104,8 +103,7 @@ static inline void S9xReschedule()
uint8_t which;
int32_t max;
- if (CPU.WhichEvent == HBLANK_START_EVENT ||
- CPU.WhichEvent == HTIMER_AFTER_EVENT)
+ if (CPU.WhichEvent == HBLANK_START_EVENT || CPU.WhichEvent == HTIMER_AFTER_EVENT)
{
which = HBLANK_END_EVENT;
max = Settings.H_Max;
diff --git a/source/display.h b/source/display.h
index cee60bb..44e0900 100644
--- a/source/display.h
+++ b/source/display.h
@@ -8,7 +8,7 @@ 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 S9xInitDisplay();
void S9xDeinitDisplay();
void S9xToggleSoundChannel(int32_t channel);
void S9xSetInfoString(const char* string);
diff --git a/source/dma.c b/source/dma.c
index 3800c70..e943975 100644
--- a/source/dma.c
+++ b/source/dma.c
@@ -59,7 +59,7 @@ void S9xDoDMA(uint8_t Channel)
int32_t inc = d->AAddressFixed ? 0 : (!d->AAddressDecrement ? 1 : -1);
- if ((d->ABank == 0x7E || d->ABank == 0x7F) && d->BAddress == 0x80)
+ if ((d->ABank == 0x7E || d->ABank == 0x7F) && d->BAddress == 0x80 && !d->TransferDirection)
{
d->AAddress += d->TransferBytes;
//does an invalid DMA actually take time?
@@ -301,9 +301,7 @@ void S9xDoDMA(uint8_t Channel)
while (--count > 0);
break;
case 0x18:
-#ifndef CORRECT_VRAM_READS
IPPU.FirstVRAMRead = true;
-#endif
if (!PPU.VMA.FullGraphicCount)
{
do
@@ -326,9 +324,7 @@ void S9xDoDMA(uint8_t Channel)
}
break;
case 0x19:
-#ifndef CORRECT_VRAM_READS
IPPU.FirstVRAMRead = true;
-#endif
if (!PPU.VMA.FullGraphicCount)
{
do
@@ -384,9 +380,7 @@ void S9xDoDMA(uint8_t Channel)
if (d->BAddress == 0x18)
{
// Write to V-RAM
-#ifndef CORRECT_VRAM_READS
IPPU.FirstVRAMRead = true;
-#endif
if (!PPU.VMA.FullGraphicCount)
{
while (count > 1)
@@ -632,8 +626,6 @@ update_address:
d->TransferBytes = 0;
CPU.InDMA = false;
-
-
}
void S9xStartHDMA()
@@ -767,15 +759,6 @@ uint8_t S9xDoHDMA(uint8_t byte)
continue;
}
- if (p->BAddress == 0x04)
- {
- if (SNESGameFixes.Uniracers)
- {
- PPU.OAMAddr = 0x10c;
- PPU.OAMFlip = 0;
- }
- }
-
switch (p->TransferMode)
{
case 0:
@@ -881,18 +864,12 @@ void S9xResetDMA()
DMA [d].HDMAIndirectAddressing = false;
DMA [d].AAddressFixed = true;
DMA [d].AAddressDecrement = false;
- DMA [d].TransferMode = 0xff;
+ DMA [d].TransferMode = 7;
DMA [d].ABank = 0xff;
DMA [d].AAddress = 0xffff;
DMA [d].Address = 0xffff;
DMA [d].BAddress = 0xff;
DMA [d].TransferBytes = 0xffff;
- }
- for (c = 0x4300; c < 0x4380; c += 0x10)
- {
- for (d = c; d < c + 12; d++)
- Memory.FillRAM [d] = 0xff;
-
- Memory.FillRAM [c + 0xf] = 0xff;
+ DMA [d].IndirectAddress = 0xffff;
}
}
diff --git a/source/dma.h b/source/dma.h
index c93ce64..7782ee2 100644
--- a/source/dma.h
+++ b/source/dma.h
@@ -3,7 +3,7 @@
#ifndef _DMA_H_
#define _DMA_H_
-void S9xResetDMA(void);
+void S9xResetDMA();
uint8_t S9xDoHDMA(uint8_t);
void S9xStartHDMA();
void S9xDoDMA(uint8_t);
diff --git a/source/dsp1.c b/source/dsp1.c
index 42f20c8..5d4d522 100644
--- a/source/dsp1.c
+++ b/source/dsp1.c
@@ -12,21 +12,8 @@
void (*SetDSP)(uint8_t, uint16_t) = &DSP1SetByte;
uint8_t(*GetDSP)(uint16_t) = &DSP1GetByte;
-void S9xInitDSP1()
-{
- static bool init = false;
-
- if (!init)
- {
- InitDSP();
- init = true;
- }
-}
-
void S9xResetDSP1()
{
- S9xInitDSP1();
-
DSP1.waiting4command = true;
DSP1.in_count = 0;
DSP1.out_count = 0;
@@ -67,136 +54,89 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
// Mario Kart uses 0x00, 0x02, 0x06, 0x0c, 0x28, 0x0a
switch (byte)
{
- case 0x00:
- DSP1.in_count = 2;
- break;
- case 0x30:
- case 0x10:
- DSP1.in_count = 2;
- break;
- case 0x20:
- DSP1.in_count = 2;
- break;
- case 0x24:
- case 0x04:
- DSP1.in_count = 2;
- break;
- case 0x08:
- DSP1.in_count = 3;
- break;
- case 0x18:
- DSP1.in_count = 4;
- break;
- case 0x28:
- DSP1.in_count = 3;
- break;
- case 0x38:
- DSP1.in_count = 4;
- break;
- case 0x2c:
- case 0x0c:
- DSP1.in_count = 3;
- break;
- case 0x3c:
- case 0x1c:
- DSP1.in_count = 6;
- break;
- case 0x32:
- case 0x22:
- case 0x12:
- case 0x02:
- DSP1.in_count = 7;
- break;
+ case 0x07:
case 0x0a:
+ case 0x0f:
+ case 0x1f:
+ case 0x27:
+ case 0x2f:
DSP1.in_count = 1;
break;
- case 0x3a:
- case 0x2a:
- case 0x1a:
- DSP1. command = 0x1a;
- DSP1.in_count = 1;
- break;
- case 0x16:
- case 0x26:
- case 0x36:
- case 0x06:
- DSP1.in_count = 3;
- break;
+ case 0x00:
+ case 0x04:
+ case 0x0e:
+ case 0x10:
case 0x1e:
+ case 0x20:
+ case 0x24:
case 0x2e:
+ case 0x30:
case 0x3e:
- case 0x0e:
DSP1.in_count = 2;
break;
- case 0x05:
- case 0x35:
- case 0x31:
- case 0x01:
- DSP1.in_count = 4;
- break;
- case 0x15:
- case 0x11:
- DSP1.in_count = 4;
- break;
- case 0x25:
- case 0x21:
- DSP1.in_count = 4;
- break;
+ case 0x03:
+ case 0x06:
+ case 0x08:
case 0x09:
- case 0x39:
- case 0x3d:
+ case 0x0b:
+ case 0x0c:
case 0x0d:
- DSP1.in_count = 3;
- break;
+ case 0x13:
+ case 0x16:
case 0x19:
+ case 0x1b:
case 0x1d:
- DSP1.in_count = 3;
- break;
+ case 0x23:
+ case 0x26:
+ case 0x28:
case 0x29:
+ case 0x2b:
+ case 0x2c:
case 0x2d:
- DSP1.in_count = 3;
- break;
case 0x33:
- case 0x03:
- DSP1.in_count = 3;
- break;
- case 0x13:
- DSP1.in_count = 3;
- break;
- case 0x23:
- DSP1.in_count = 3;
- break;
+ case 0x36:
+ case 0x39:
case 0x3b:
- case 0x0b:
- DSP1.in_count = 3;
- break;
- case 0x1b:
+ case 0x3d:
DSP1.in_count = 3;
break;
- case 0x2b:
- DSP1.in_count = 3;
+ case 0x01:
+ case 0x05:
+ case 0x11:
+ case 0x15:
+ case 0x18:
+ case 0x21:
+ case 0x25:
+ case 0x31:
+ case 0x35:
+ case 0x38:
+ DSP1.in_count = 4;
break;
- case 0x34:
case 0x14:
+ case 0x1c:
+ case 0x34:
+ case 0x3c:
DSP1.in_count = 6;
break;
- case 0x07:
- case 0x0f:
- DSP1.in_count = 1;
+ case 0x02:
+ case 0x12:
+ case 0x22:
+ case 0x32:
+ DSP1.in_count = 7;
break;
- case 0x27:
- case 0x2F:
+ case 0x3a:
+ case 0x2a:
+ case 0x1a:
+ DSP1.command = 0x1a;
DSP1.in_count = 1;
break;
case 0x17:
case 0x37:
case 0x3F:
DSP1.command = 0x1f;
- case 0x1f:
DSP1.in_count = 1;
break;
default:
- case 0x80:
DSP1.in_count = 0;
DSP1.waiting4command = true;
DSP1.first_parameter = true;
@@ -211,17 +151,12 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.in_index++;
}
- if (DSP1.waiting4command ||
- (DSP1.first_parameter && byte == 0x80))
+ if (DSP1.waiting4command || (DSP1.first_parameter && byte == 0x80))
{
DSP1.waiting4command = true;
DSP1.first_parameter = false;
}
- else if (DSP1.first_parameter && (DSP1.in_count != 0 || (DSP1.in_count == 0
- && DSP1.in_index == 0)))
- {
- }
- else
+ else if (!(DSP1.first_parameter && (DSP1.in_count != 0 || (DSP1.in_count == 0 && DSP1.in_index == 0))))
{
if (DSP1.in_count)
{
@@ -245,7 +180,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = Op00Result & 0xFF;
DSP1.output [1] = (Op00Result >> 8) & 0xFF;
break;
-
case 0x20: // Multiple
Op20Multiplicand = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
Op20Multiplier = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
@@ -256,7 +190,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = Op20Result & 0xFF;
DSP1.output [1] = (Op20Result >> 8) & 0xFF;
break;
-
case 0x30:
case 0x10: // Inverse
Op10Coefficient = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -270,7 +203,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [2] = (uint8_t)(((int16_t) Op10ExponentR) & 0xff);
DSP1.output [3] = (uint8_t)((((int16_t) Op10ExponentR) >> 8) & 0xff);
break;
-
case 0x24:
case 0x04: // Sin and Cos of angle
Op04Angle = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -284,7 +216,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [2] = (uint8_t)(Op04Cos & 0xFF);
DSP1.output [3] = (uint8_t)((Op04Cos >> 8) & 0xFF);
break;
-
case 0x08: // Radius
Op08X = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
Op08Y = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
@@ -298,9 +229,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [2] = (uint8_t)(((int16_t) Op08Lh) & 0xFF);
DSP1.output [3] = (uint8_t)((((int16_t) Op08Lh) >> 8) & 0xFF);
break;
-
case 0x18: // Range
-
Op18X = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
Op18Y = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
Op18Z = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8));
@@ -312,7 +241,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = (uint8_t)(Op18D & 0xFF);
DSP1.output [1] = (uint8_t)((Op18D >> 8) & 0xFF);
break;
-
case 0x38: // Range
Op38X = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
Op38Y = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
@@ -325,7 +253,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = (uint8_t)(Op38D & 0xFF);
DSP1.output [1] = (uint8_t)((Op38D >> 8) & 0xFF);
break;
-
case 0x28: // Distance (vector length)
Op28X = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
Op28Y = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
@@ -337,7 +264,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = (uint8_t)(Op28R & 0xFF);
DSP1.output [1] = (uint8_t)((Op28R >> 8) & 0xFF);
break;
-
case 0x2c:
case 0x0c: // Rotate (2D rotate)
Op0CA = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -352,7 +278,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [2] = (uint8_t)(Op0CY2 & 0xFF);
DSP1.output [3] = (uint8_t)((Op0CY2 >> 8) & 0xFF);
break;
-
case 0x3c:
case 0x1c: // Polar (3D rotate)
Op1CZ = (DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -373,7 +298,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [4] = (uint8_t)(Op1CZAR & 0xFF);
DSP1.output [5] = (uint8_t)((Op1CZAR >> 8) & 0xFF);
break;
-
case 0x32:
case 0x22:
case 0x12:
@@ -398,7 +322,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [6] = (uint8_t)(Op02CY & 0xFF);
DSP1.output [7] = (uint8_t)((Op02CY >> 8) & 0xFF);
break;
-
case 0x3a: //1a Mirror
case 0x2a: //1a Mirror
case 0x1a: // Raster mode 7 matrix data
@@ -418,7 +341,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [7] = (uint8_t)((Op0AD >> 8) & 0xFF);
DSP1.in_index = 0;
break;
-
case 0x16:
case 0x26:
case 0x36:
@@ -437,7 +359,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [4] = (uint8_t)(Op06S & 0xFF);
DSP1.output [5] = (uint8_t)((Op06S >> 8) & 0xFF);
break;
-
case 0x1e:
case 0x2e:
case 0x3e:
@@ -453,7 +374,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [2] = (uint8_t)(Op0EY & 0xFF);
DSP1.output [3] = (uint8_t)((Op0EY >> 8) & 0xFF);
break;
-
// Extra commands used by Pilot Wings
case 0x05:
case 0x35:
@@ -466,7 +386,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSPOp01();
break;
-
case 0x15:
case 0x11: // Set attitude matrix B
Op11m = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -476,7 +395,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSPOp11();
break;
-
case 0x25:
case 0x21: // Set attitude matrix C
Op21m = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -486,7 +404,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSPOp21();
break;
-
case 0x09:
case 0x39:
case 0x3d:
@@ -505,7 +422,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [4] = (uint8_t)(Op0DU & 0xFF);
DSP1.output [5] = (uint8_t)((Op0DU >> 8) & 0xFF);
break;
-
case 0x19:
case 0x1d: // Objective matrix B
Op1DX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -522,7 +438,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [4] = (uint8_t)(Op1DU & 0xFF);
DSP1.output [5] = (uint8_t)((Op1DU >> 8) & 0xFF);
break;
-
case 0x29:
case 0x2d: // Objective matrix C
Op2DX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -539,7 +454,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [4] = (uint8_t)(Op2DU & 0xFF);
DSP1.output [5] = (uint8_t)((Op2DU >> 8) & 0xFF);
break;
-
case 0x33:
case 0x03: // Subjective matrix A
Op03F = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -556,7 +470,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [4] = (uint8_t)(Op03Z & 0xFF);
DSP1.output [5] = (uint8_t)((Op03Z >> 8) & 0xFF);
break;
-
case 0x13: // Subjective matrix B
Op13F = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
Op13L = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
@@ -572,7 +485,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [4] = (uint8_t)(Op13Z & 0xFF);
DSP1.output [5] = (uint8_t)((Op13Z >> 8) & 0xFF);
break;
-
case 0x23: // Subjective matrix C
Op23F = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
Op23L = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
@@ -588,7 +500,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [4] = (uint8_t)(Op23Z & 0xFF);
DSP1.output [5] = (uint8_t)((Op23Z >> 8) & 0xFF);
break;
-
case 0x3b:
case 0x0b:
Op0BX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -601,7 +512,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = (uint8_t)(Op0BS & 0xFF);
DSP1.output [1] = (uint8_t)((Op0BS >> 8) & 0xFF);
break;
-
case 0x1b:
Op1BX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
Op1BY = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
@@ -613,7 +523,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = (uint8_t)(Op1BS & 0xFF);
DSP1.output [1] = (uint8_t)((Op1BS >> 8) & 0xFF);
break;
-
case 0x2b:
Op2BX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
Op2BY = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
@@ -625,7 +534,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = (uint8_t)(Op2BS & 0xFF);
DSP1.output [1] = (uint8_t)((Op2BS >> 8) & 0xFF);
break;
-
case 0x34:
case 0x14:
Op14Zr = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -645,7 +553,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [4] = (uint8_t)(Op14Yrr & 0xFF);
DSP1.output [5] = (uint8_t)((Op14Yrr >> 8) & 0xFF);
break;
-
case 0x27:
case 0x2F:
Op2FUnknown = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -656,8 +563,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = (uint8_t)(Op2FSize & 0xFF);
DSP1.output [1] = (uint8_t)((Op2FSize >> 8) & 0xFF);
break;
-
-
case 0x07:
case 0x0F:
Op0FRamsize = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
@@ -668,7 +573,6 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
DSP1.output [0] = (uint8_t)(Op0FPass & 0xFF);
DSP1.output [1] = (uint8_t)((Op0FPass >> 8) & 0xFF);
break;
-
default:
break;
}
@@ -681,8 +585,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
uint8_t DSP1GetByte(uint16_t address)
{
uint8_t t;
- if ((address & 0xf000) == 0x6000 ||
- (address & 0x7fff) < 0x4000)
+ if ((address & 0xf000) == 0x6000 || (address & 0x7fff) < 0x4000)
{
if (DSP1.out_count)
{
@@ -715,11 +618,10 @@ uint8_t DSP1GetByte(uint16_t address)
DSP1.waiting4command = true;
}
else
- {
t = 0xff;
- }
}
- else t = 0x80;
+ else
+ t = 0x80;
return t;
}
@@ -735,28 +637,22 @@ void DSP2SetByte(uint8_t byte, uint16_t address)
DSP1.waiting4command = false;
switch (byte)
{
- case 0x01:
- DSP1.in_count = 32;
+ default:
+ DSP1.in_count = 0;
break;
case 0x03:
- DSP1.in_count = 1;
- break;
case 0x05:
- DSP1.in_count = 1;
- break;
- case 0x09:
- DSP1.in_count = 4;
- break;
case 0x06:
DSP1.in_count = 1;
break;
- case 0x0D:
+ case 0x0d:
DSP1.in_count = 2;
break;
- default:
- printf("Op%02X\n", byte);
- case 0x0f:
- DSP1.in_count = 0;
+ case 0x09:
+ DSP1.in_count = 4;
+ break;
+ case 0x01:
+ DSP1.in_count = 32;
break;
}
}
@@ -863,8 +759,7 @@ void DSP2SetByte(uint8_t byte, uint16_t address)
uint8_t DSP2GetByte(uint16_t address)
{
uint8_t t;
- if ((address & 0xf000) == 0x6000 ||
- (address >= 0x8000 && address < 0xc000))
+ if ((address & 0xf000) == 0x6000 || (address >= 0x8000 && address < 0xc000))
{
if (DSP1.out_count)
{
@@ -876,253 +771,11 @@ uint8_t DSP2GetByte(uint16_t address)
else
t = 0xff;
}
- else t = 0x80;
- return t;
-}
-
-//Disable non-working chips?
-#ifdef DSP_DUMMY_LOOPS
-uint16_t Dsp3Rom[1024] =
-{
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020,
- 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000,
- 0x4000, 0x7fff, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200,
- 0x0100, 0x0080, 0x0040, 0x0020, 0x0001, 0x0008, 0x0004, 0x0002,
- 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x8000, 0xffe5, 0x0100, 0x7fff, 0x7f02, 0x7e08,
- 0x7d12, 0x7c1f, 0x7b30, 0x7a45, 0x795d, 0x7878, 0x7797, 0x76ba,
- 0x75df, 0x7507, 0x7433, 0x7361, 0x7293, 0x71c7, 0x70fe, 0x7038,
- 0x6f75, 0x6eb4, 0x6df6, 0x6d3a, 0x6c81, 0x6bca, 0x6b16, 0x6a64,
- 0x69b4, 0x6907, 0x685b, 0x67b2, 0x670b, 0x6666, 0x65c4, 0x6523,
- 0x6484, 0x63e7, 0x634c, 0x62b3, 0x621c, 0x6186, 0x60f2, 0x6060,
- 0x5fd0, 0x5f41, 0x5eb5, 0x5e29, 0x5d9f, 0x5d17, 0x5c91, 0x5c0c,
- 0x5b88, 0x5b06, 0x5a85, 0x5a06, 0x5988, 0x590b, 0x5890, 0x5816,
- 0x579d, 0x5726, 0x56b0, 0x563b, 0x55c8, 0x5555, 0x54e4, 0x5474,
- 0x5405, 0x5398, 0x532b, 0x52bf, 0x5255, 0x51ec, 0x5183, 0x511c,
- 0x50b6, 0x5050, 0x4fec, 0x4f89, 0x4f26, 0x4ec5, 0x4e64, 0x4e05,
- 0x4da6, 0x4d48, 0x4cec, 0x4c90, 0x4c34, 0x4bda, 0x4b81, 0x4b28,
- 0x4ad0, 0x4a79, 0x4a23, 0x49cd, 0x4979, 0x4925, 0x48d1, 0x487f,
- 0x482d, 0x47dc, 0x478c, 0x473c, 0x46ed, 0x469f, 0x4651, 0x4604,
- 0x45b8, 0x456c, 0x4521, 0x44d7, 0x448d, 0x4444, 0x43fc, 0x43b4,
- 0x436d, 0x4326, 0x42e0, 0x429a, 0x4255, 0x4211, 0x41cd, 0x4189,
- 0x4146, 0x4104, 0x40c2, 0x4081, 0x4040, 0x3fff, 0x41f7, 0x43e1,
- 0x45bd, 0x478d, 0x4951, 0x4b0b, 0x4cbb, 0x4e61, 0x4fff, 0x5194,
- 0x5322, 0x54a9, 0x5628, 0x57a2, 0x5914, 0x5a81, 0x5be9, 0x5d4a,
- 0x5ea7, 0x5fff, 0x6152, 0x62a0, 0x63ea, 0x6530, 0x6672, 0x67b0,
- 0x68ea, 0x6a20, 0x6b53, 0x6c83, 0x6daf, 0x6ed9, 0x6fff, 0x7122,
- 0x7242, 0x735f, 0x747a, 0x7592, 0x76a7, 0x77ba, 0x78cb, 0x79d9,
- 0x7ae5, 0x7bee, 0x7cf5, 0x7dfa, 0x7efe, 0x7fff, 0x0000, 0x0324,
- 0x0647, 0x096a, 0x0c8b, 0x0fab, 0x12c8, 0x15e2, 0x18f8, 0x1c0b,
- 0x1f19, 0x2223, 0x2528, 0x2826, 0x2b1f, 0x2e11, 0x30fb, 0x33de,
- 0x36ba, 0x398c, 0x3c56, 0x3f17, 0x41ce, 0x447a, 0x471c, 0x49b4,
- 0x4c3f, 0x4ebf, 0x5133, 0x539b, 0x55f5, 0x5842, 0x5a82, 0x5cb4,
- 0x5ed7, 0x60ec, 0x62f2, 0x64e8, 0x66cf, 0x68a6, 0x6a6d, 0x6c24,
- 0x6dca, 0x6f5f, 0x70e2, 0x7255, 0x73b5, 0x7504, 0x7641, 0x776c,
- 0x7884, 0x798a, 0x7a7d, 0x7b5d, 0x7c29, 0x7ce3, 0x7d8a, 0x7e1d,
- 0x7e9d, 0x7f09, 0x7f62, 0x7fa7, 0x7fd8, 0x7ff6, 0x7fff, 0x7ff6,
- 0x7fd8, 0x7fa7, 0x7f62, 0x7f09, 0x7e9d, 0x7e1d, 0x7d8a, 0x7ce3,
- 0x7c29, 0x7b5d, 0x7a7d, 0x798a, 0x7884, 0x776c, 0x7641, 0x7504,
- 0x73b5, 0x7255, 0x70e2, 0x6f5f, 0x6dca, 0x6c24, 0x6a6d, 0x68a6,
- 0x66cf, 0x64e8, 0x62f2, 0x60ec, 0x5ed7, 0x5cb4, 0x5a82, 0x5842,
- 0x55f5, 0x539b, 0x5133, 0x4ebf, 0x4c3f, 0x49b4, 0x471c, 0x447a,
- 0x41ce, 0x3f17, 0x3c56, 0x398c, 0x36ba, 0x33de, 0x30fb, 0x2e11,
- 0x2b1f, 0x2826, 0x2528, 0x2223, 0x1f19, 0x1c0b, 0x18f8, 0x15e2,
- 0x12c8, 0x0fab, 0x0c8b, 0x096a, 0x0647, 0x0324, 0x7fff, 0x7ff6,
- 0x7fd8, 0x7fa7, 0x7f62, 0x7f09, 0x7e9d, 0x7e1d, 0x7d8a, 0x7ce3,
- 0x7c29, 0x7b5d, 0x7a7d, 0x798a, 0x7884, 0x776c, 0x7641, 0x7504,
- 0x73b5, 0x7255, 0x70e2, 0x6f5f, 0x6dca, 0x6c24, 0x6a6d, 0x68a6,
- 0x66cf, 0x64e8, 0x62f2, 0x60ec, 0x5ed7, 0x5cb4, 0x5a82, 0x5842,
- 0x55f5, 0x539b, 0x5133, 0x4ebf, 0x4c3f, 0x49b4, 0x471c, 0x447a,
- 0x41ce, 0x3f17, 0x3c56, 0x398c, 0x36ba, 0x33de, 0x30fb, 0x2e11,
- 0x2b1f, 0x2826, 0x2528, 0x2223, 0x1f19, 0x1c0b, 0x18f8, 0x15e2,
- 0x12c8, 0x0fab, 0x0c8b, 0x096a, 0x0647, 0x0324, 0x0000, 0xfcdc,
- 0xf9b9, 0xf696, 0xf375, 0xf055, 0xed38, 0xea1e, 0xe708, 0xe3f5,
- 0xe0e7, 0xdddd, 0xdad8, 0xd7da, 0xd4e1, 0xd1ef, 0xcf05, 0xcc22,
- 0xc946, 0xc674, 0xc3aa, 0xc0e9, 0xbe32, 0xbb86, 0xb8e4, 0xb64c,
- 0xb3c1, 0xb141, 0xaecd, 0xac65, 0xaa0b, 0xa7be, 0xa57e, 0xa34c,
- 0xa129, 0x9f14, 0x9d0e, 0x9b18, 0x9931, 0x975a, 0x9593, 0x93dc,
- 0x9236, 0x90a1, 0x8f1e, 0x8dab, 0x8c4b, 0x8afc, 0x89bf, 0x8894,
- 0x877c, 0x8676, 0x8583, 0x84a3, 0x83d7, 0x831d, 0x8276, 0x81e3,
- 0x8163, 0x80f7, 0x809e, 0x8059, 0x8028, 0x800a, 0x6488, 0x0080,
- 0x03ff, 0x0116, 0x0002, 0x0080, 0x4000, 0x3fd7, 0x3faf, 0x3f86,
- 0x3f5d, 0x3f34, 0x3f0c, 0x3ee3, 0x3eba, 0x3e91, 0x3e68, 0x3e40,
- 0x3e17, 0x3dee, 0x3dc5, 0x3d9c, 0x3d74, 0x3d4b, 0x3d22, 0x3cf9,
- 0x3cd0, 0x3ca7, 0x3c7f, 0x3c56, 0x3c2d, 0x3c04, 0x3bdb, 0x3bb2,
- 0x3b89, 0x3b60, 0x3b37, 0x3b0e, 0x3ae5, 0x3abc, 0x3a93, 0x3a69,
- 0x3a40, 0x3a17, 0x39ee, 0x39c5, 0x399c, 0x3972, 0x3949, 0x3920,
- 0x38f6, 0x38cd, 0x38a4, 0x387a, 0x3851, 0x3827, 0x37fe, 0x37d4,
- 0x37aa, 0x3781, 0x3757, 0x372d, 0x3704, 0x36da, 0x36b0, 0x3686,
- 0x365c, 0x3632, 0x3609, 0x35df, 0x35b4, 0x358a, 0x3560, 0x3536,
- 0x350c, 0x34e1, 0x34b7, 0x348d, 0x3462, 0x3438, 0x340d, 0x33e3,
- 0x33b8, 0x338d, 0x3363, 0x3338, 0x330d, 0x32e2, 0x32b7, 0x328c,
- 0x3261, 0x3236, 0x320b, 0x31df, 0x31b4, 0x3188, 0x315d, 0x3131,
- 0x3106, 0x30da, 0x30ae, 0x3083, 0x3057, 0x302b, 0x2fff, 0x2fd2,
- 0x2fa6, 0x2f7a, 0x2f4d, 0x2f21, 0x2ef4, 0x2ec8, 0x2e9b, 0x2e6e,
- 0x2e41, 0x2e14, 0x2de7, 0x2dba, 0x2d8d, 0x2d60, 0x2d32, 0x2d05,
- 0x2cd7, 0x2ca9, 0x2c7b, 0x2c4d, 0x2c1f, 0x2bf1, 0x2bc3, 0x2b94,
- 0x2b66, 0x2b37, 0x2b09, 0x2ada, 0x2aab, 0x2a7c, 0x2a4c, 0x2a1d,
- 0x29ed, 0x29be, 0x298e, 0x295e, 0x292e, 0x28fe, 0x28ce, 0x289d,
- 0x286d, 0x283c, 0x280b, 0x27da, 0x27a9, 0x2777, 0x2746, 0x2714,
- 0x26e2, 0x26b0, 0x267e, 0x264c, 0x2619, 0x25e7, 0x25b4, 0x2581,
- 0x254d, 0x251a, 0x24e6, 0x24b2, 0x247e, 0x244a, 0x2415, 0x23e1,
- 0x23ac, 0x2376, 0x2341, 0x230b, 0x22d6, 0x229f, 0x2269, 0x2232,
- 0x21fc, 0x21c4, 0x218d, 0x2155, 0x211d, 0x20e5, 0x20ad, 0x2074,
- 0x203b, 0x2001, 0x1fc7, 0x1f8d, 0x1f53, 0x1f18, 0x1edd, 0x1ea1,
- 0x1e66, 0x1e29, 0x1ded, 0x1db0, 0x1d72, 0x1d35, 0x1cf6, 0x1cb8,
- 0x1c79, 0x1c39, 0x1bf9, 0x1bb8, 0x1b77, 0x1b36, 0x1af4, 0x1ab1,
- 0x1a6e, 0x1a2a, 0x19e6, 0x19a1, 0x195c, 0x1915, 0x18ce, 0x1887,
- 0x183f, 0x17f5, 0x17ac, 0x1761, 0x1715, 0x16c9, 0x167c, 0x162e,
- 0x15df, 0x158e, 0x153d, 0x14eb, 0x1497, 0x1442, 0x13ec, 0x1395,
- 0x133c, 0x12e2, 0x1286, 0x1228, 0x11c9, 0x1167, 0x1104, 0x109e,
- 0x1036, 0x0fcc, 0x0f5f, 0x0eef, 0x0e7b, 0x0e04, 0x0d89, 0x0d0a,
- 0x0c86, 0x0bfd, 0x0b6d, 0x0ad6, 0x0a36, 0x098d, 0x08d7, 0x0811,
- 0x0736, 0x063e, 0x0519, 0x039a, 0x0000, 0x7fff, 0x0100, 0x0080,
- 0x021d, 0x00c8, 0x00ce, 0x0048, 0x0a26, 0x277a, 0x00ce, 0x6488,
- 0x14ac, 0x0001, 0x00f9, 0x00fc, 0x00ff, 0x00fc, 0x00f9, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
-
-};
-
-void DSP3SetByte(uint8_t byte, uint16_t address)
-{
- if ((address & 0xf000) == 0x6000 ||
- (address >= 0x8000 && address < 0xc000))
- {
- if (DSP1.waiting4command)
- {
- DSP1.command = byte;
- DSP1.in_index = 0;
- DSP1.waiting4command = false;
- switch (byte)
- {
- case 0x2F:
- DSP1.in_count = 2;
- break;
- case 0x1F:
- DSP1.in_count = 2;
- break;
- case 0x0F:
- DSP1.in_count = 2;
- break;
- case 0x38:
- DSP1.in_count = 4;
- break;
- default:
- break;
- }
- }
- else
- {
- DSP1.parameters [DSP1.in_index] = byte;
- DSP1.in_index++;
- }
-
- if (DSP1.in_count == DSP1.in_index)
- {
- // Actually execute the command
- DSP1.waiting4command = true;
- DSP1.out_index = 0;
- switch (DSP1.command)
- {
- case 0x2F:
- DSP1.out_count = 2;
- break;
- case 0x1F:
- DSP1.out_count = 2048;
- break;
- case 0x0F:
- DSP1.out_count = 2;
- DSP1.output[0] = 0;
- DSP1.output[1] = 0;
- break;
- case 0x38:
- {
- DSP1.out_count = 2;
- // 176B
- DSP1.output[0] = 0;
- DSP1.output[1] = 0x80;
-
- break;
- }
- default:
- break;
- }
- }
- }
-}
-
-uint8_t DSP3GetByte(uint16_t address)
-{
- uint8_t t;
- if ((address & 0xf000) == 0x6000 ||
- (address >= 0x8000 && address < 0xc000))
- {
- if (DSP1.command == 0x38 && DSP1.out_index == 1)
- t = 4;
-
- if (DSP1.out_count)
- {
- if (DSP1.command == 0x1f)
- {
- if ((DSP1.out_index % 2) != 0)
- t = (uint8_t)Dsp3Rom[DSP1.out_index >> 1];
- else
- t = Dsp3Rom[DSP1.out_index >> 1] >> 8;
- DSP1.out_index++;
- }
- else
- {
- t = (uint8_t) DSP1.output [DSP1.out_index];
- DSP1.out_index++;
- DSP1.out_index %= 512;
- if (DSP1.out_count == DSP1.out_index)
- DSP1.out_count = 0;
- }
- }
- else
- t = 0xff;
- }
else
- {
t = 0x80;
- }
return t;
}
-#endif
-
typedef struct
{
bool waiting4command;
@@ -1151,8 +804,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
DSP4_init = true;
}
- if ((address & 0xf000) == 0x6000 ||
- (address >= 0x8000 && address < 0xc000))
+ if ((address & 0xf000) == 0x6000 || (address >= 0x8000 && address < 0xc000))
{
if (DSP4.out_index < DSP4.out_count)
{
@@ -1167,7 +819,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
DSP4.command |= (byte << 8);
DSP4.in_index = 0;
DSP4.waiting4command = false;
- DSP4.half_command = 0;
+ DSP4.half_command = false;
DSP4.out_count = 0;
DSP4.out_index = 0;
DSP4_Logic = 0;
@@ -1181,11 +833,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
DSP4.in_count = 36;
break;
case 0x0003:
- DSP4.in_count = 0;
- break;
case 0x0005:
- DSP4.in_count = 0;
- break;
case 0x0006:
DSP4.in_count = 0;
break;
@@ -1199,8 +847,6 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
DSP4.in_count = 14;
break;
case 0x000A:
- DSP4.in_count = 6;
- break;
case 0x000B:
DSP4.in_count = 6;
break;
@@ -1221,7 +867,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
else
{
DSP4.command = byte;
- DSP4.half_command = 1;
+ DSP4.half_command = true;
}
}
else
@@ -1252,9 +898,8 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
DSP4.out_count = 4;
DSP4_WRITE_WORD(0, product);
DSP4_WRITE_WORD(2, product >> 16);
+ break;
}
- break;
-
// unknown: horizontal mapping command
case 0x0011:
{
@@ -1271,40 +916,33 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
DSP4_WRITE_WORD(0, m);
break;
}
-
// track projection
case 0x0001:
DSP4_Op01();
break;
-
// track projection (pass 2)
case 0x0007:
DSP4_Op07();
break;
-
// zone projections (fuel/repair/lap/teleport/...)
case 0x0008:
DSP4_Op08();
break;
-
// sprite transformation
case 0x0009:
DSP4_Op09();
break;
-
// fast track projection
case 0x000D:
DSP4_Op0D();
break;
-
// internal memory management (01)
case 0x0003:
{
// reset op09 data
- op09_mode = 0;
+ op09_mode = false;
break;
}
-
// internal memory management (06)
case 0x0005:
{
@@ -1316,15 +954,13 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
op06_OAM[lcv] = 0;
break;
}
-
// internal memory management (0D)
case 0x000E:
{
// reset op09 data
- op09_mode = 1;
+ op09_mode = true;
break;
}
-
// sprite OAM post-table data
case 0x0006:
{
@@ -1334,7 +970,6 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
DSP4.output[lcv] = op06_OAM[lcv];
}
break;
-
// unknown
case 0x000A:
{
@@ -1372,7 +1007,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
DSP4_WRITE_WORD(4, oam);
// OAM: size,msb data
- DSP4_Op06(0, 0);
+ DSP4_Op06(false, false);
}
// 4p mode
else
@@ -1381,9 +1016,8 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
DSP4.out_count = 0;
DSP4_WRITE_WORD(0, 0);
}
+ break;
}
- break;
-
default:
break;
}
diff --git a/source/dsp2emu.c b/source/dsp2emu.c
index d1b6410..9e3e137 100644
--- a/source/dsp2emu.c
+++ b/source/dsp2emu.c
@@ -130,13 +130,11 @@ bool DSP2Op0DHasLen = false;
int32_t DSP2Op0DOutLen = 0;
int32_t DSP2Op0DInLen = 0;
-#ifndef DSP2_BIT_ACCURRATE_CODE
-
// Scale bitmap based on input length out output length
void DSP2_Op0D()
{
- // (Modified) Overload's algorithm - use this unless doing hardware testing
+ // (Modified) Overload's algorithm
int32_t i;
@@ -150,51 +148,3 @@ void DSP2_Op0D()
DSP1.output[i] = (pixel_low << 4) | pixel_high;
}
}
-
-#else
-
-void DSP2_Op0D()
-{
- // Bit accurate hardware algorithm - uses fixed point math
- // This should match the DSP2 Op0D output exactly
- // I wouldn't recommend using this unless you're doing hardware debug.
- // In some situations it has small visual artifacts that
- // are not readily apparent on a TV screen but show up clearly
- // on a monitor. Use Overload's scaling instead.
- // This is for hardware verification testing.
- //
- // One note: the HW can do odd byte scaling but since we divide
- // by two to get the count of bytes this won't work well for
- // odd byte scaling (in any of the current algorithm implementations).
- // So far I haven't seen Dungeon Master use it.
- // If it does we can adjust the parameters and code to work with it
-
-
- uint32_t multiplier;
- uint32_t pixloc;
- int32_t i, j;
- uint8_t pixelarray[512];
-
- if (DSP2Op0DInLen <= DSP2Op0DOutLen)
- multiplier = 0x10000; // In our self defined fixed point 0x10000 == 1
- else
- multiplier = (DSP2Op0DInLen << 17) / ((DSP2Op0DOutLen << 1) + 1);
-
- pixloc = 0;
- for (i = 0; i < DSP2Op0DOutLen * 2; i++)
- {
- j = pixloc >> 16;
-
- if (j & 1)
- pixelarray[i] = DSP1.parameters[j >> 1] & 0x0f;
- else
- pixelarray[i] = (DSP1.parameters[j >> 1] & 0xf0) >> 4;
-
- pixloc += multiplier;
- }
-
- for (i = 0; i < DSP2Op0DOutLen; i++)
- DSP1.output[i] = (pixelarray[i << 1] << 4) | pixelarray[(i << 1) + 1];
-}
-
-#endif
diff --git a/source/dsp4emu.c b/source/dsp4emu.c
index c2ba8c8..3b3d843 100644
--- a/source/dsp4emu.c
+++ b/source/dsp4emu.c
@@ -160,7 +160,7 @@ resume2:
- 1.07629051 * project_focaly - 65.69315963);
// approximate # of raster lines
- segments = abs(project_y2 - project_y1);
+ segments = ABS(project_y2 - project_y1);
// prevent overdraw
if (project_y2 >= raster) segments = 0;
@@ -341,7 +341,7 @@ resume2:
- 1.07629051 * project_focaly - 65.69315963);
// approximate # of raster lines
- segments = abs(project_y2 - project_y1);
+ segments = ABS(project_y2 - project_y1);
// prevent overdraw
if (project_y2 >= raster) segments = 0;
@@ -555,7 +555,7 @@ DSP4_WAIT(2) resume2:
int16_t dx1 = 0, dx2 = 0, dx3, dx4;
// # segments to traverse
- segments = abs(y_left - path_y[0]);
+ segments = ABS(y_left - path_y[0]);
// prevent overdraw
if (y_left >= path_raster[0]) segments = 0;
@@ -638,7 +638,7 @@ DSP4_WAIT(2) resume2:
//////////////////////////////////////////////
// zone 2
- segments = abs(y_right - path_y[1]);
+ segments = ABS(y_right - path_y[1]);
// prevent overdraw
if (y_right >= path_raster[2]) segments = 0;
@@ -863,7 +863,7 @@ resume2:
- 1.07629051 * project_focaly - 65.69315963);
// approximate # of raster lines
- segments = abs(project_y2 - project_y1);
+ segments = ABS(project_y2 - project_y1);
// prevent overdraw
if (project_y2 >= raster) segments = 0;
@@ -994,7 +994,8 @@ void DSP4_Op09()
// convert track line to the window region
project_y2 = center_y + multi_raster[multi_index1] *
(viewport_bottom - center_y) / (0x33 - 0);
- if (op09_mode == 0) project_y2 -= 2;
+ if (!op09_mode)
+ project_y2 -= 2;
goto no_sprite;
@@ -1138,7 +1139,7 @@ DSP4_WAIT(5) resume5:
}
// default sprite size: 16x16
- sprite_size = 1;
+ sprite_size = true;
// convert tile data to OAM
diff --git a/source/fxemu.c b/source/fxemu.c
index 5b3aba3..a92e3df 100644
--- a/source/fxemu.c
+++ b/source/fxemu.c
@@ -9,10 +9,6 @@
/* The FxChip Emulator's internal variables */
struct FxRegs_s GSU; // This will be initialized when loading a ROM
-uint32_t(**fx_ppfFunctionTable)(uint32_t) = 0;
-void (**fx_ppfPlotTable)() = 0;
-void (**fx_ppfOpcodeTable)() = 0;
-
void FxCacheWriteAccess(uint16_t vAddress)
{
if ((vAddress & 0x00f) == 0x00f)
@@ -99,10 +95,10 @@ static void fx_readRegisterSpace()
GSU.pfPlot = fx_apfPlotTable[GSU.vMode];
GSU.pfRpix = fx_apfPlotTable[GSU.vMode + 5];
- fx_ppfOpcodeTable[0x04c] = GSU.pfPlot;
- fx_ppfOpcodeTable[0x14c] = GSU.pfRpix;
- fx_ppfOpcodeTable[0x24c] = GSU.pfPlot;
- fx_ppfOpcodeTable[0x34c] = GSU.pfRpix;
+ fx_apfOpcodeTable[0x04c] = GSU.pfPlot;
+ fx_apfOpcodeTable[0x14c] = GSU.pfRpix;
+ fx_apfOpcodeTable[0x24c] = GSU.pfPlot;
+ fx_apfOpcodeTable[0x34c] = GSU.pfRpix;
fx_computeScreenPointers();
}
@@ -277,27 +273,8 @@ static void fx_writeRegisterSpace()
/* Reset the FxChip */
void FxReset(struct FxInit_s* psFxInfo)
{
- int32_t i;
- static uint32_t(**appfFunction[])(uint32_t) =
- {
- &fx_apfFunctionTable[0]
- };
- static void (**appfPlot[])() =
- {
- &fx_apfPlotTable[0]
- };
- static void (**appfOpcode[])() =
- {
- &fx_apfOpcodeTable[0]
- };
-
- /* Get function pointers for the current emulation mode */
- fx_ppfFunctionTable = appfFunction[psFxInfo->vFlags & 0x3];
- fx_ppfPlotTable = appfPlot[psFxInfo->vFlags & 0x3];
- fx_ppfOpcodeTable = appfOpcode[psFxInfo->vFlags & 0x3];
-
/* Clear all internal variables */
- memset((uint8_t*)&GSU, 0, sizeof(struct FxRegs_s));
+ memset((uint8_t*) &GSU, 0, sizeof(struct FxRegs_s));
/* Set default registers */
GSU.pvSreg = GSU.pvDreg = &R0;
@@ -322,6 +299,7 @@ void FxReset(struct FxInit_s* psFxInfo)
GSU.pvRegisters[0x3b] = 0;
/* Make ROM bank table */
+ int32_t i;
for (i = 0; i < 256; i++)
{
uint32_t b = i & 0x7f;
@@ -360,13 +338,10 @@ void FxReset(struct FxInit_s* psFxInfo)
static bool fx_checkStartAddress()
{
/* Check if we start inside the cache */
- if (GSU.bCacheActive && R15 >= GSU.vCacheBaseReg
- && R15 < (GSU.vCacheBaseReg + 512))
+ if (GSU.bCacheActive && R15 >= GSU.vCacheBaseReg && R15 < (GSU.vCacheBaseReg + 512))
return true;
/* Check if we're in an unused area */
- if (GSU.vPrgBankReg < 0x40 && R15 < 0x8000)
- return false;
if (GSU.vPrgBankReg >= 0x60 && GSU.vPrgBankReg <= 0x6f)
return false;
if (GSU.vPrgBankReg >= 0x74)
@@ -402,7 +377,7 @@ int32_t FxEmulate(uint32_t nInstructions)
/* Execute GSU session */
CF(IRQ);
- vCount = fx_ppfFunctionTable[FX_FUNCTION_RUN](nInstructions);
+ vCount = fx_run(nInstructions);
/* Store GSU registers */
fx_writeRegisterSpace();
@@ -414,33 +389,6 @@ int32_t FxEmulate(uint32_t nInstructions)
return vCount;
}
-/* Step by step execution */
-int32_t FxStepOver(uint32_t nInstructions)
-{
- uint32_t vCount;
- fx_readRegisterSpace();
-
- /* Check if the start address is valid */
- if (!fx_checkStartAddress())
- {
- CF(G);
- return 0;
- }
-
- if (PIPE >= 0xf0)
- GSU.vStepPoint = USEX16(R15 + 3);
- else if ((PIPE >= 0x05 && PIPE <= 0x0f) || (PIPE >= 0xa0 && PIPE <= 0xaf))
- GSU.vStepPoint = USEX16(R15 + 2);
- else
- GSU.vStepPoint = USEX16(R15 + 1);
- vCount = fx_ppfFunctionTable[FX_FUNCTION_STEP_OVER](nInstructions);
- fx_writeRegisterSpace();
- if (GSU.vErrorCode)
- return GSU.vErrorCode;
- else
- return vCount;
-}
-
/* Errors */
int32_t FxGetErrorCode()
{
diff --git a/source/fxemu.h b/source/fxemu.h
index 3c0511c..2176976 100644
--- a/source/fxemu.h
+++ b/source/fxemu.h
@@ -26,9 +26,6 @@ extern int32_t FxEmulate(uint32_t nInstructions);
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 int32_t FxStepOver(uint32_t nInstructions);
-
/* Errors */
extern int32_t FxGetErrorCode();
extern int32_t FxGetIllegalAddress();
@@ -43,7 +40,7 @@ extern uint32_t FxGetDestinationRegisterIndex();
extern uint8_t FxPipe();
/* SCBR write seen. We need to update our cached screen pointers */
-extern void fx_dirtySCBR(void);
+extern void fx_dirtySCBR();
/* Update RamBankReg and RAM Bank pointer */
extern void fx_updateRamBank(uint8_t Byte);
diff --git a/source/fxinst.c b/source/fxinst.c
index e78d932..4ec1e01 100644
--- a/source/fxinst.c
+++ b/source/fxinst.c
@@ -10,10 +10,6 @@
extern struct FxRegs_s GSU;
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) */
-#define CHECK_LIMITS
-
/* Codes used:
*
* rn = a GSU register (r0-r15)
@@ -583,9 +579,6 @@ static void fx_plot_2bit()
CLRFLAGS;
R1++;
-#ifdef CHECK_LIMITS
- if (y >= GSU.vScreenHeight) return;
-#endif
if (GSU.vPlotOptionReg & 0x02)
c = (x ^ y) & 1 ? (uint8_t)(GSU.vColorReg >> 4) : (uint8_t)GSU.vColorReg;
else
@@ -611,9 +604,6 @@ static void fx_rpix_2bit()
R15++;
CLRFLAGS;
-#ifdef CHECK_LIMITS
- if (y >= GSU.vScreenHeight) return;
-#endif
a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);
v = 128 >> (x & 7);
@@ -636,9 +626,6 @@ static void fx_plot_4bit()
CLRFLAGS;
R1++;
-#ifdef CHECK_LIMITS
- if (y >= GSU.vScreenHeight) return;
-#endif
if (GSU.vPlotOptionReg & 0x02)
c = (x ^ y) & 1 ? (uint8_t)(GSU.vColorReg >> 4) : (uint8_t)GSU.vColorReg;
else
@@ -670,10 +657,6 @@ static void fx_rpix_4bit()
R15++;
CLRFLAGS;
-#ifdef CHECK_LIMITS
- if (y >= GSU.vScreenHeight) return;
-#endif
-
a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);
v = 128 >> (x & 7);
@@ -697,9 +680,6 @@ static void fx_plot_8bit()
CLRFLAGS;
R1++;
-#ifdef CHECK_LIMITS
- if (y >= GSU.vScreenHeight) return;
-#endif
c = (uint8_t)GSU.vColorReg;
if (!(GSU.vPlotOptionReg & 0x10))
{
@@ -739,9 +719,6 @@ static void fx_rpix_8bit()
R15++;
CLRFLAGS;
-#ifdef CHECK_LIMITS
- if (y >= GSU.vScreenHeight) return;
-#endif
a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);
v = 128 >> (x & 7);
@@ -759,15 +736,9 @@ static void fx_rpix_8bit()
}
/* 4o - plot - plot pixel with R1,R2 as x,y and the color register as the color */
-static void fx_plot_obj()
-{
- printf("ERROR fx_plot_obj called\n");
-}
-
/* 4c(ALT1) - rpix - read color of the pixel with R1,R2 as x,y */
-static void fx_rpix_obj()
+static void fx_obj_func()
{
- printf("ERROR fx_rpix_obj called\n");
}
/* 4d - swap - swap upper and lower byte of a register */
@@ -3238,7 +3209,7 @@ static void fx_sm_r15()
/*** GSU executions functions ***/
-static uint32_t fx_run(uint32_t nInstructions)
+uint32_t fx_run(uint32_t nInstructions)
{
GSU.vCounter = nInstructions;
READR14;
@@ -3247,70 +3218,15 @@ static uint32_t fx_run(uint32_t nInstructions)
return (nInstructions - GSU.vInstCount);
}
-static uint32_t fx_run_to_breakpoint(uint32_t nInstructions)
-{
- uint32_t vCounter = 0;
- while (TF(G) && vCounter < nInstructions)
- {
- vCounter++;
- FX_STEP;
- if (USEX16(R15) == GSU.vBreakPoint)
- {
- GSU.vErrorCode = FX_BREAKPOINT;
- break;
- }
- }
- return vCounter;
-}
-
-static uint32_t fx_step_over(uint32_t nInstructions)
-{
- uint32_t vCounter = 0;
- while (TF(G) && vCounter < nInstructions)
- {
- vCounter++;
- FX_STEP;
- if (USEX16(R15) == GSU.vBreakPoint)
- {
- GSU.vErrorCode = FX_BREAKPOINT;
- break;
- }
- if (USEX16(R15) == GSU.vStepPoint)
- break;
- }
- return vCounter;
-}
-
-#ifdef FX_FUNCTION_TABLE
-uint32_t(*FX_FUNCTION_TABLE[])(uint32_t) =
-#else
-uint32_t(*fx_apfFunctionTable[])(uint32_t) =
-#endif
-{
- &fx_run,
- &fx_run_to_breakpoint,
- &fx_step_over,
-};
-
/*** Special table for the different plot configurations ***/
-
-#ifdef FX_PLOT_TABLE
-void (*FX_PLOT_TABLE[])() =
-#else
void (*fx_apfPlotTable[])() =
-#endif
{
- &fx_plot_2bit, &fx_plot_4bit, &fx_plot_4bit, &fx_plot_8bit, &fx_plot_obj,
- &fx_rpix_2bit, &fx_rpix_4bit, &fx_rpix_4bit, &fx_rpix_8bit, &fx_rpix_obj,
+ &fx_plot_2bit, &fx_plot_4bit, &fx_plot_4bit, &fx_plot_8bit, &fx_obj_func,
+ &fx_rpix_2bit, &fx_rpix_4bit, &fx_rpix_4bit, &fx_rpix_8bit, &fx_obj_func,
};
/*** Opcode table ***/
-
-#ifdef FX_OPCODE_TABLE
-void (*FX_OPCODE_TABLE[])() =
-#else
void (*fx_apfOpcodeTable[])() =
-#endif
{
/*
* ALT0 Table
diff --git a/source/fxinst.h b/source/fxinst.h
index a78b6d4..ce9187d 100644
--- a/source/fxinst.h
+++ b/source/fxinst.h
@@ -337,28 +337,12 @@ struct FxRegs_s
/* Execute instruction from the pipe, and fetch next byte to the pipe */
#define FX_STEP { uint32_t vOpcode = (uint32_t)PIPE; FETCHPIPE; \
-(*fx_ppfOpcodeTable[ (GSU.vStatusReg & 0x300) | vOpcode ])(); } \
+(*fx_apfOpcodeTable[ (GSU.vStatusReg & 0x300) | vOpcode ])(); } \
-#define FX_FUNCTION_RUN 0
-#define FX_FUNCTION_RUN_TO_BREAKPOINT 1
-#define FX_FUNCTION_STEP_OVER 2
-
-extern uint32_t(**fx_ppfFunctionTable)(uint32_t);
-extern void (**fx_ppfPlotTable)();
-extern void (**fx_ppfOpcodeTable)();
-
-extern uint32_t(*fx_apfFunctionTable[])(uint32_t);
extern void (*fx_apfOpcodeTable[])();
extern void (*fx_apfPlotTable[])();
-extern uint32_t(*fx_a_apfFunctionTable[])(uint32_t);
-extern void (*fx_a_apfOpcodeTable[])();
-extern void (*fx_a_apfPlotTable[])();
-extern uint32_t(*fx_r_apfFunctionTable[])(uint32_t);
-extern void (*fx_r_apfOpcodeTable[])();
-extern void (*fx_r_apfPlotTable[])();
-extern uint32_t(*fx_ar_apfFunctionTable[])(uint32_t);
-extern void (*fx_ar_apfOpcodeTable[])();
-extern void (*fx_ar_apfPlotTable[])();
+
+uint32_t fx_run(uint32_t nInstructions);
/* Set this define if branches are relative to the instruction in the delay slot */
/* (I think they are) */
diff --git a/source/getset.h b/source/getset.h
index b0abba5..7d28a04 100644
--- a/source/getset.h
+++ b/source/getset.h
@@ -37,9 +37,6 @@ INLINE uint8_t S9xGetByte(uint32_t Address)
case MAP_CPU:
return (S9xGetCPU(Address & 0xffff));
case MAP_DSP:
-#ifdef DSP_DUMMY_LOOPS
- printf("Get DSP Byte @ %06X\n", Address);
-#endif
return (S9xGetDSP(Address & 0xffff));
case MAP_SA1RAM:
case MAP_LOROM_SRAM:
@@ -54,7 +51,7 @@ INLINE uint8_t S9xGetByte(uint32_t Address)
case MAP_BWRAM:
return (*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)));
case MAP_C4:
- return (S9xGetC4(Address & 0xffff));
+ return S9xGetC4(Address & 0xffff);
case MAP_SPC7110_ROM:
return S9xGetSPC7110Byte(Address);
case MAP_SPC7110_DRAM:
@@ -65,7 +62,6 @@ INLINE uint8_t S9xGetByte(uint32_t Address)
return S9xGetSetaDSP(Address);
case MAP_SETA_RISC:
return S9xGetST018(Address);
- case MAP_DEBUG:
default:
return OpenBus;
}
@@ -79,13 +75,11 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
return (OpenBus | (S9xGetByte(Address + 1) << 8));
}
int32_t block;
- uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) &
- MEMMAP_MASK];
+ uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
if (!CPU.InDMA)
CPU.Cycles += (Memory.MemorySpeed [block] << 1);
-
if (GetAddress >= (uint8_t*) MAP_LAST)
{
#ifdef CPU_SHUTDOWN
@@ -95,25 +89,18 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
#ifdef FAST_LSB_WORD_ACCESS
return (*(uint16_t*)(GetAddress + (Address & 0xffff)));
#else
- return (*(GetAddress + (Address & 0xffff)) |
- (*(GetAddress + (Address & 0xffff) + 1) << 8));
+ return (*(GetAddress + (Address & 0xffff)) | (*(GetAddress + (Address & 0xffff) + 1) << 8));
#endif
}
switch ((intptr_t) GetAddress)
{
case MAP_PPU:
- return (S9xGetPPU(Address & 0xffff) |
- (S9xGetPPU((Address + 1) & 0xffff) << 8));
+ return (S9xGetPPU(Address & 0xffff) | (S9xGetPPU((Address + 1) & 0xffff) << 8));
case MAP_CPU:
- return (S9xGetCPU(Address & 0xffff) |
- (S9xGetCPU((Address + 1) & 0xffff) << 8));
+ return (S9xGetCPU(Address & 0xffff) | (S9xGetCPU((Address + 1) & 0xffff) << 8));
case MAP_DSP:
-#ifdef DSP_DUMMY_LOOPS
- printf("Get DSP Word @ %06X\n", Address);
-#endif
- return (S9xGetDSP(Address & 0xffff) |
- (S9xGetDSP((Address + 1) & 0xffff) << 8));
+ return (S9xGetDSP(Address & 0xffff) | (S9xGetDSP((Address + 1) & 0xffff) << 8));
case MAP_SA1RAM:
case MAP_LOROM_SRAM:
//Address &0x7FFF -offset into bank
@@ -123,10 +110,8 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
/* BJ: no FAST_LSB_WORD_ACCESS here, since if Memory.SRAMMask=0x7ff
* then the high byte doesn't follow the low byte. */
return
- (*(Memory.SRAM + ((((Address & 0xFF0000) >> 1) | (Address & 0x7FFF))
- &Memory.SRAMMask))) |
- ((*(Memory.SRAM + (((((Address + 1) & 0xFF0000) >> 1) | ((
- Address + 1) & 0x7FFF)) &Memory.SRAMMask))) << 8);
+ (*(Memory.SRAM + ((((Address & 0xFF0000) >> 1) | (Address & 0x7FFF)) & 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
@@ -141,18 +126,14 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
#ifdef FAST_LSB_WORD_ACCESS
return (*(uint16_t*)(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)));
#else
- return (*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)) |
- (*(Memory.BWRAM + (((Address + 1) & 0x7fff) - 0x6000)) << 8));
+ 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));
+ return (S9xGetC4(Address & 0xffff) | (S9xGetC4((Address + 1) & 0xffff) << 8));
case MAP_SPC7110_ROM:
- return (S9xGetSPC7110Byte(Address) |
- (S9xGetSPC7110Byte(Address + 1)) << 8);
+ return (S9xGetSPC7110Byte(Address) | (S9xGetSPC7110Byte(Address + 1)) << 8);
case MAP_SPC7110_DRAM:
- return (S9xGetSPC7110(0x4800) |
- (S9xGetSPC7110(0x4800) << 8));
+ return (S9xGetSPC7110(0x4800) | (S9xGetSPC7110(0x4800) << 8));
case MAP_OBC_RAM:
return GetOBC1(Address & 0xFFFF) | (GetOBC1((Address + 1) & 0xFFFF) << 8);
case MAP_SETA_DSP:
@@ -170,8 +151,7 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
CPU.WaitAddress = NULL;
#endif
int32_t block;
- uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) &
- MEMMAP_MASK)];
+ uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) & MEMMAP_MASK)];
if (!CPU.InDMA)
CPU.Cycles += Memory.MemorySpeed [block];
@@ -203,24 +183,19 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
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)
{
- *(Memory.SRAM + ((((Address & 0xFF0000) >> 1) | (Address & 0x7FFF))&
- Memory.SRAMMask)) = Byte;
+ *(Memory.SRAM + ((((Address & 0xFF0000) >> 1) | (Address & 0x7FFF)) & Memory.SRAMMask)) = Byte;
CPU.SRAMModified = true;
}
return;
case MAP_HIROM_SRAM:
if (Memory.SRAMMask)
{
- *(Memory.SRAM + (((Address & 0x7fff) - 0x6000 +
- ((Address & 0xf0000) >> 3)) & Memory.SRAMMask)) = Byte;
+ *(Memory.SRAM + (((Address & 0x7fff) - 0x6000 + ((Address & 0xf0000) >> 3)) & Memory.SRAMMask)) = Byte;
CPU.SRAMModified = true;
}
return;
@@ -228,7 +203,6 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
*(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;
@@ -266,8 +240,7 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
CPU.WaitAddress = NULL;
#endif
int32_t block;
- uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) &
- MEMMAP_MASK)];
+ uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) & MEMMAP_MASK)];
if (!CPU.InDMA)
CPU.Cycles += Memory.MemorySpeed [block] << 1;
@@ -284,7 +257,7 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
SA1.WaitCounter = 0;
}
#ifdef FAST_LSB_WORD_ACCESS
- *(uint16_t*) SetAddress = Word;
+ *(uint16_t*)SetAddress = Word;
#else
*SetAddress = (uint8_t) Word;
*(SetAddress + 1) = Word >> 8;
@@ -307,14 +280,11 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
S9xSetPPU(Word >> 8, (Address & 0xffff) + 1);
return;
case MAP_CPU:
- S9xSetCPU((uint8_t) Word, (Address & 0xffff));
+ 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);
-#endif
- S9xSetDSP((uint8_t) Word, (Address & 0xffff));
+ S9xSetDSP((uint8_t) Word, Address & 0xffff);
S9xSetDSP(Word >> 8, (Address & 0xffff) + 1);
return;
case MAP_LOROM_SRAM:
@@ -322,11 +292,8 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
{
/* BJ: no FAST_LSB_WORD_ACCESS here, since if Memory.SRAMMask=0x7ff
* then the high byte doesn't follow the low byte. */
- *(Memory.SRAM + ((((Address & 0xFF0000) >> 1) | (Address & 0x7FFF))&
- Memory.SRAMMask)) = (uint8_t) Word;
- *(Memory.SRAM + (((((Address + 1) & 0xFF0000) >> 1) | ((
- Address + 1) & 0x7FFF))& Memory.SRAMMask)) = Word >> 8;
-
+ *(Memory.SRAM + ((((Address & 0xFF0000) >> 1) | (Address & 0x7FFF)) & Memory.SRAMMask)) = (uint8_t) Word;
+ *(Memory.SRAM + (((((Address + 1) & 0xFF0000) >> 1) | ((Address + 1) & 0x7FFF))& Memory.SRAMMask)) = Word >> 8;
CPU.SRAMModified = true;
}
return;
@@ -349,11 +316,10 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
*(uint16_t*)(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)) = Word;
#else
*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)) = (uint8_t) Word;
- *(Memory.BWRAM + (((Address + 1) & 0x7fff) - 0x6000)) = (uint8_t)(Word >> 8);
+ *(Memory.BWRAM + (((Address + 1) & 0x7fff) - 0x6000)) = (uint8_t) (Word >> 8);
#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;
@@ -400,22 +366,21 @@ INLINE uint8_t* GetBasePointer(uint32_t Address)
case MAP_PPU: //just a guess, but it looks like this should match the CPU as a source.
case MAP_CPU: //fixes Ogre Battle's green lines
case MAP_OBC_RAM:
- return (Memory.FillRAM);
+ return Memory.FillRAM;
case MAP_DSP:
return (Memory.FillRAM - 0x6000);
case MAP_SA1RAM:
case MAP_LOROM_SRAM:
- return (Memory.SRAM);
+ case MAP_SETA_DSP:
+ return Memory.SRAM;
case MAP_BWRAM:
return (Memory.BWRAM - 0x6000);
case MAP_HIROM_SRAM:
return (Memory.SRAM - 0x6000);
case MAP_C4:
return (Memory.C4RAM - 0x6000);
- case MAP_SETA_DSP:
- return Memory.SRAM;
default:
- return (0);
+ return NULL;
}
}
@@ -431,7 +396,7 @@ INLINE uint8_t* S9xGetMemPointer(uint32_t Address)
switch ((intptr_t) GetAddress)
{
case MAP_SPC7110_DRAM:
- return &s7r.bank50[Address & 0x0000FFFF];
+ return &s7r.bank50[Address & 0xffff];
case MAP_PPU:
return (Memory.FillRAM + (Address & 0xffff));
case MAP_CPU:
@@ -452,7 +417,7 @@ INLINE uint8_t* S9xGetMemPointer(uint32_t Address)
case MAP_SETA_DSP:
return Memory.SRAM + ((Address & 0xffff) & Memory.SRAMMask);
default:
- return (0);
+ return NULL;
}
}
@@ -470,18 +435,12 @@ INLINE void S9xSetPCBase(uint32_t Address)
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;
diff --git a/source/gfx.c b/source/gfx.c
index 5bd1a57..4b88295 100644
--- a/source/gfx.c
+++ b/source/gfx.c
@@ -336,7 +336,6 @@ bool S9xInitGFX()
// then the value is zero, otherwise multiply the value by 2. Used by
// the color subtraction code.
-#if defined(OLD_COLOUR_BLENDING)
for (r = 0; r <= MAX_RED; r++)
{
uint32_t r2 = r;
@@ -362,49 +361,10 @@ bool S9xInitGFX()
b2 = (b2 << 1) & MAX_BLUE;
GFX.ZERO_OR_X2 [BUILD_PIXEL2(r, g, b)] = BUILD_PIXEL2(r2, g2, b2);
- GFX.ZERO_OR_X2 [BUILD_PIXEL2(r, g, b) & ~ALPHA_BITS_MASK] = BUILD_PIXEL2(r2, g2,
- b2);
+ GFX.ZERO_OR_X2 [BUILD_PIXEL2(r, g, b) & ~ALPHA_BITS_MASK] = BUILD_PIXEL2(MAX(1, r2), MAX(1, g2), MAX(1, b2));
}
}
}
-#else
- for (r = 0; r <= MAX_RED; r++)
- {
- uint32_t r2 = r;
- if ((r2 & 0x10) == 0)
- r2 = 0;
- else
- r2 = (r2 << 1) & MAX_RED;
-
- if (r2 == 0)
- r2 = 1;
- for (g = 0; g <= MAX_GREEN; g++)
- {
- uint32_t g2 = g;
- if ((g2 & GREEN_HI_BIT) == 0)
- g2 = 0;
- else
- g2 = (g2 << 1) & MAX_GREEN;
-
- if (g2 == 0)
- g2 = 1;
- for (b = 0; b <= MAX_BLUE; b++)
- {
- uint32_t b2 = b;
- if ((b2 & 0x10) == 0)
- b2 = 0;
- else
- b2 = (b2 << 1) & MAX_BLUE;
-
- if (b2 == 0)
- b2 = 1;
- GFX.ZERO_OR_X2 [BUILD_PIXEL2(r, g, b)] = BUILD_PIXEL2(r2, g2, b2);
- GFX.ZERO_OR_X2 [BUILD_PIXEL2(r, g, b) & ~ALPHA_BITS_MASK] = BUILD_PIXEL2(r2, g2,
- b2);
- }
- }
- }
-#endif
// Build a lookup table that if the top bit of the color value is zero
// then the value is zero, otherwise its just the value.
@@ -439,7 +399,7 @@ bool S9xInitGFX()
return (true);
}
-void S9xDeinitGFX(void)
+void S9xDeinitGFX()
{
// Free any memory allocated in S9xInitGFX
if (GFX.X2)
@@ -495,8 +455,7 @@ void S9xStartScreenRefresh()
if (PPU.BGMode == 5 || PPU.BGMode == 6)
IPPU.Interlace = (Memory.FillRAM[0x2133] & 1);
- if (Settings.SupportHiRes && (PPU.BGMode == 5 || PPU.BGMode == 6
- || IPPU.Interlace))
+ if (Settings.SupportHiRes && (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace))
{
IPPU.RenderedScreenWidth = 512;
IPPU.DoubleWidthPixels = true;
@@ -519,8 +478,7 @@ void S9xStartScreenRefresh()
GFX.PPLx2 = GFX.PPL << 1;
}
}
- else if (!Settings.SupportHiRes && (PPU.BGMode == 5 || PPU.BGMode == 6
- || IPPU.Interlace))
+ else if (!Settings.SupportHiRes && (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace))
{
IPPU.RenderedScreenWidth = 256;
IPPU.DoubleWidthPixels = false;
@@ -1495,19 +1453,13 @@ static void DrawBackgroundOffset(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8
// hardware limitation that the offsets cannot be set
// for the tile at the left-hand edge of the screen.
VOffset = LineData [Y].BG[bg].VOffset;
-
- //MKendora; use temp var to reduce memory accesses
HOffset = LineHOffset;
- //End MK
-
left_hand_edge = false;
}
else
-
{
// All subsequent offset tile data is shifted left by one,
// hence the - 1 below.
-
Quot2 = ((HOff + Left - 1) & OffsetMask) >> 3;
if (Quot2 > 31)
@@ -1520,11 +1472,7 @@ static void DrawBackgroundOffset(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8
if (BGMode == 4)
{
VOffset = LineData [Y].BG[bg].VOffset;
-
- //MKendora; use temp var to reduce memory accesses
HOffset = LineHOffset;
- //end MK
-
if ((HCellOffset & OffsetEnableMask))
{
if (HCellOffset & 0x8000)
@@ -1638,8 +1586,7 @@ static void DrawBackgroundOffset(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8
Left += Count;
TotalCount += Count;
- s += (IPPU.HalfWidthPixels ? (Offset + Count) >> 1 : (Offset + Count)) *
- GFX.PixSize;
+ s += (IPPU.HalfWidthPixels ? (Offset + Count) >> 1 : (Offset + Count)) * GFX.PixSize;
MaxCount = 8;
}
}
@@ -1765,8 +1712,7 @@ static void DrawBackgroundMode5(uint32_t bg, uint8_t Z1, uint8_t Z2)
continue;
}
- uint32_t s = (IPPU.HalfWidthPixels ? Left >> 1 : Left) * GFX.PixSize + Y *
- GFX.PPL;
+ uint32_t s = (IPPU.HalfWidthPixels ? Left >> 1 : Left) * GFX.PixSize + Y * GFX.PPL;
uint32_t HPos = (HOffset + Left * GFX.PixSize) & 0x3ff;
uint32_t Quot = HPos >> 3;
@@ -1985,7 +1931,6 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
{
DrawBackgroundMosaic(BGMode, bg, Z1, Z2);
return;
-
}
switch (BGMode)
{
@@ -3108,7 +3053,7 @@ static void RenderScreen(uint8_t* Screen, bool sub, bool force_no_add, uint8_t D
}
}
-void S9xUpdateScreen(void)
+void S9xUpdateScreen()
{
int32_t x2 = 1;
@@ -3542,13 +3487,13 @@ void S9xUpdateScreen(void)
} // --if (SUB_OR_ADD(5))
else
{
+ uint32_t y;
// Subscreen not being added to back
uint32_t back = IPPU.ScreenColors [0] | (IPPU.ScreenColors [0] << 16);
pClip = &IPPU.Clip [0];
if (pClip->Count [5])
{
- uint32_t y;
for (y = starty; y <= endy; y++)
{
uint32_t b;
@@ -3573,7 +3518,6 @@ void S9xUpdateScreen(void)
}
else
{
- uint32_t y;
for (y = starty; y <= endy; y++)
{
uint16_t* p = (uint16_t*)(GFX.Screen + y * GFX.Pitch2);
diff --git a/source/gfx.h b/source/gfx.h
index c5f50cb..230d692 100644
--- a/source/gfx.h
+++ b/source/gfx.h
@@ -19,7 +19,7 @@ extern struct SGFX GFX;
bool S9xInitGFX();
void S9xDeinitGFX();
-bool S9xInitUpdate(void);
+bool S9xInitUpdate();
struct SGFX
{
diff --git a/source/memmap.c b/source/memmap.c
index 4a96f66..286abc6 100644
--- a/source/memmap.c
+++ b/source/memmap.c
@@ -31,10 +31,6 @@
#include "fxemu.h"
extern struct FxInit_s SuperFX;
-#ifndef SET_UI_COLOR
-#define SET_UI_COLOR(r,g,b) ;
-#endif
-
static int32_t retry_count = 0;
static uint8_t bytes0x2000 [0x2000];
int32_t is_bsx(uint8_t*);
@@ -103,12 +99,6 @@ const uint32_t crc32Table[256] =
void S9xDeinterleaveType1(int32_t TotalFileSize, uint8_t* base)
{
- if (Settings.DisplayColor == 0xffff)
- {
- Settings.DisplayColor = BUILD_PIXEL(0, 31, 0);
- SET_UI_COLOR(0, 255, 0);
- }
-
int32_t i;
int32_t nblocks = TotalFileSize >> 16;
uint8_t blocks [256];
@@ -152,12 +142,6 @@ void S9xDeinterleaveGD24(int32_t TotalFileSize, uint8_t* base)
if (TotalFileSize != 0x300000)
return;
- if (Settings.DisplayColor == 0xffff)
- {
- Settings.DisplayColor = BUILD_PIXEL(0, 31, 31);
- SET_UI_COLOR(0, 255, 255);
- }
-
// DS2 DMA notes: base may or may not be 32-byte aligned
uint8_t* tmp = (uint8_t*) malloc(0x80000);
if (tmp)
@@ -684,20 +668,6 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
}
while (more && (ROMFile = fopen(fname, "rb")) != NULL);
-
-
- if (Memory.HeaderCount == 0)
- S9xMessage(S9X_INFO, S9X_HEADERS_INFO, "No ROM file header found.");
- else
- {
- if (Memory.HeaderCount == 1)
- S9xMessage(S9X_INFO, S9X_HEADERS_INFO,
- "Found ROM file header (and ignored it).");
- else
- S9xMessage(S9X_INFO, S9X_HEADERS_INFO,
- "Found multiple ROM file headers (and ignored them).");
- }
-
return TotalFileSize;
}
#endif
@@ -735,9 +705,6 @@ bool LoadROM(
retry_count = 0;
again:
- Settings.DisplayColor = 0xffff;
- SET_UI_COLOR(255, 255, 255);
-
#ifdef LOAD_FROM_MEMORY_TEST
strncpy(Memory.ROMFilename, game->path, sizeof(Memory.ROMFilename));
@@ -748,17 +715,12 @@ again:
if ((((game->size & 0x1FFF) == 0x200) && !Settings.ForceNoHeader) || Settings.ForceHeader)
{
- S9xMessage(S9X_INFO, S9X_HEADERS_INFO,
- "Found ROM file header (and ignored it).");
TotalFileSize -= 0x200;
src += 0x200;
Memory.HeaderCount = 1;
}
- else
- {
- S9xMessage(S9X_INFO, S9X_HEADERS_INFO, "No ROM file header found.");
- }
+
if (TotalFileSize > MAX_ROM_SIZE)
return false;
@@ -777,25 +739,6 @@ again:
{
Memory.ROM[0x7FD5] = 0x31;
Memory.ROM[0x7FD6] = 0x02;
- Settings.DisplayColor = BUILD_PIXEL(31, 0, 0);
- SET_UI_COLOR(255, 0, 0);
- 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))
- {
- Memory.ROM[0xFFD5] = 0x31;
- Memory.ROM[0xFFD6] = 0x02;
- Settings.DisplayColor = BUILD_PIXEL(31, 0, 0);
- SET_UI_COLOR(255, 0, 0);
- 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))
- {
- Settings.DisplayColor = BUILD_PIXEL(31, 0, 0);
- SET_UI_COLOR(255, 0, 0);
- S9xMessage(S9X_ERROR, S9X_ROM_CONFUSING_FORMAT_INFO, "Warning! Hacked Dump!");
}
#ifndef NO_SPEEDHACKS
@@ -854,8 +797,6 @@ again:
memmove(Memory.ROM, Memory.ROM + 512, TotalFileSize - 512);
#endif
TotalFileSize -= 512;
- S9xMessage(S9X_INFO, S9X_HEADER_WARNING,
- "Try specifying the -nhd command line option if the game doesn't work\n");
}
Memory.CalculatedSize = TotalFileSize & ~0x1FFF; // round down to lower 0x2000
@@ -869,17 +810,10 @@ again:
//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 (Settings.DisplayColor == 0xffff)
- {
- Settings.DisplayColor = BUILD_PIXEL(0, 31, 0);
- SET_UI_COLOR(0, 255, 0);
- }
- if (!Settings.ForceInterleaved)
- S9xDeinterleaveType1(TotalFileSize, Memory.ROM);
- }
+ ((Memory.ROM[0x7FFC] | (Memory.ROM[0x7FFD] << 8)) < 0x8000) &&
+ ((Memory.ROM[0xFFFC] | (Memory.ROM[0xFFFD] << 8)) < 0x8000) &&
+ !Settings.ForceInterleaved)
+ S9xDeinterleaveType1(TotalFileSize, Memory.ROM);
//CalculatedSize is now set, so rescore
hi_score = ScoreHiROM(false, 0);
@@ -972,8 +906,6 @@ again:
if (!Settings.ForceNotInterleaved && Interleaved)
{
CPU.TriedInterleavedMode2 = true;
- S9xMessage(S9X_INFO, S9X_ROM_INTERLEAVED_INFO,
- "ROM image is in interleaved format - converting...");
if (Tales)
{
@@ -1003,11 +935,6 @@ again:
}
else
{
- if (Settings.DisplayColor == 0xffff)
- {
- Settings.DisplayColor = BUILD_PIXEL(0, 31, 0);
- SET_UI_COLOR(0, 255, 0);
- }
bool t = Memory.LoROM;
Memory.LoROM = Memory.HiROM;
@@ -1024,8 +951,6 @@ again:
{
if (retry_count == 0)
{
- S9xMessage(S9X_INFO, S9X_ROM_CONFUSING_FORMAT_INFO,
- "ROM lied about its type! Trying again.");
Settings.ForceNotInterleaved = true;
Settings.ForceInterleaved = false;
retry_count++;
@@ -1058,15 +983,6 @@ void S9xDeinterleaveMode2(void)
void S9xDeinterleaveType2(bool reset)
{
- if (Settings.DisplayColor == 0xffff || Settings.DisplayColor == BUILD_PIXEL(0, 31, 0))
- {
- Settings.DisplayColor = BUILD_PIXEL(31, 14, 6);
- SET_UI_COLOR(255, 119, 25);
-
- }
- S9xMessage(S9X_INFO, S9X_ROM_INTERLEAVED_INFO,
- "ROM image is in interleaved format - converting...");
-
int32_t nblocks = Memory.CalculatedSize >> 16;
int32_t step = 64;
@@ -1426,20 +1342,7 @@ void InitROM(bool Interleaved)
*p = 0;
}
- {
- 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 (Settings.DisplayColor == 0xffff || Settings.DisplayColor != BUILD_PIXEL(31, 0, 0))
- {
- Settings.DisplayColor = BUILD_PIXEL(31, 31, 0);
- SET_UI_COLOR(255, 255, 0);
- }
- }
+ Memory.SRAMMask = Memory.SRAMSize ? ((1 << (Memory.SRAMSize + 3)) * 128) - 1 : 0;
#ifndef USE_BLARGG_APU
IAPU.OneCycle = ONE_APU_CYCLE;
@@ -1470,7 +1373,7 @@ void InitROM(bool Interleaved)
Memory.CompanyId,
Memory.ROMCRC32);
- S9xMessage(S9X_INFO, S9X_ROM_INFO, String);
+ S9xMessage(String);
Settings.ForceHeader = Settings.ForceHiROM = Settings.ForceLoROM =
Settings.ForceInterleaved = Settings.ForceNoHeader =
Settings.ForceNotInterleaved =
@@ -1969,15 +1872,6 @@ void HiROMMap()
mask[0] = (Memory.CalculatedSize / 0x10000) - 1;
- if (Settings.ForceSA1 ||
- (!Settings.ForceNoSA1 && (Memory.ROMSpeed & ~0x10) == 0x23 &&
- (Memory.ROMType & 0xf) > 3 && (Memory.ROMType & 0xf0) == 0x30))
- {
- Settings.DisplayColor = BUILD_PIXEL(31, 0, 0);
- SET_UI_COLOR(255, 0, 0);
- }
-
-
int32_t x;
bool foundZeros;
bool pastZeros;
@@ -2097,15 +1991,6 @@ void TalesROMMap(bool Interleaved)
{
int32_t c;
int32_t i;
-
- if (Interleaved)
- {
- if (Settings.DisplayColor == 0xffff)
- {
- Settings.DisplayColor = BUILD_PIXEL(0, 31, 0);
- SET_UI_COLOR(0, 255, 0);
- }
- }
uint32_t OFFSET0 = 0x400000;
uint32_t OFFSET1 = 0x400000;
uint32_t OFFSET2 = 0x000000;
@@ -2171,15 +2056,6 @@ void TalesROMMap(bool Interleaved)
}
}
- if ((strncmp("TALES", (char*)Memory.Map[8] + 0xFFC0, 5) == 0))
- {
- if (*(Memory.Map[8] + 0xFFDE) == *(Memory.Map[0x808] + 0xFFDE))
- {
- Settings.DisplayColor = BUILD_PIXEL(31, 0, 0);
- SET_UI_COLOR(255, 0, 0);
- }
- }
-
Memory.ROMChecksum = *(Memory.Map[8] + 0xFFDE) + (*(Memory.Map[8] + 0xFFDF) << 8);
Memory.ROMComplementChecksum = *(Memory.Map[8] + 0xFFDC) + (*(Memory.Map[8] + 0xFFDD) << 8);
@@ -2975,15 +2851,6 @@ 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))
- {
- Settings.DisplayColor = BUILD_PIXEL(31, 0, 0);
- SET_UI_COLOR(255, 0, 0);
- }
-
//Ambiguous chip function pointer assignments
//DSP switching:
@@ -3173,24 +3040,11 @@ void ApplyROMFixes()
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);
Settings.HBlankStart = (256 * Settings.H_Max) / SNES_HCOUNTER_MAX;
//OAM hacks because we don't fully understand the
//behavior of the SNES.
- //Totally wacky display...
- //seems to need a disproven behavior, so
- //we're definitely overlooking some other bug?
- if (strncmp(Memory.ROMName, "UNIRACERS", 9) == 0)
- SNESGameFixes.Uniracers = true;
-
- //is this even useful now?
- if (strcmp(Memory.ROMName, "ALIENS vs. PREDATOR") == 0)
- SNESGameFixes.alienVSpredetorFix = true;
-
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 ||
diff --git a/source/messages.h b/source/messages.h
deleted file mode 100644
index 00776ca..0000000
--- a/source/messages.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "../copyright"
-
-#ifndef _messages_h_
-#define _messages_h_
-
-/* Types of message sent to S9xMessage routine */
-enum
-{
- S9X_TRACE,
- S9X_DEBUG,
- S9X_WARNING,
- S9X_INFO,
- S9X_ERROR,
- S9X_FATAL_ERROR
-};
-
-/* Individual message numbers */
-enum
-{
- S9X_ROM_INFO,
- S9X_HEADERS_INFO,
- S9X_ROM_CONFUSING_FORMAT_INFO,
- S9X_ROM_INTERLEAVED_INFO,
- S9X_SOUND_DEVICE_OPEN_FAILED,
- S9X_APU_STOPPED,
- S9X_USAGE,
- S9X_GAME_GENIE_CODE_ERROR,
- S9X_ACTION_REPLY_CODE_ERROR,
- S9X_GOLD_FINGER_CODE_ERROR,
- S9X_DEBUG_OUTPUT,
- S9X_DMA_TRACE,
- S9X_HDMA_TRACE,
- S9X_WRONG_FORMAT,
- S9X_WRONG_VERSION,
- S9X_ROM_NOT_FOUND,
- S9X_FREEZE_FILE_NOT_FOUND,
- S9X_PPU_TRACE,
- S9X_TRACE_DSP1,
- S9X_FREEZE_ROM_NAME,
- S9X_HEADER_WARNING,
- S9X_NETPLAY_NOT_SERVER,
- S9X_FREEZE_FILE_INFO,
- S9X_TURBO_MODE,
- S9X_SOUND_NOT_BUILT,
- S9X_MOVIE_INFO,
- S9X_WRONG_MOVIE_SNAPSHOT,
- S9X_NOT_A_MOVIE_SNAPSHOT,
- S9X_AVI_INFO
-};
-
-#endif
diff --git a/source/obc1.c b/source/obc1.c
index 2d46238..4263284 100644
--- a/source/obc1.c
+++ b/source/obc1.c
@@ -16,16 +16,12 @@ uint8_t GetOBC1(uint16_t Address)
{
case 0x7ff0:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2)];
-
case 0x7ff1:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 1];
-
case 0x7ff2:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 2];
-
case 0x7ff3:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 3];
-
case 0x7ff4:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address >> 2) + 0x200];
}
@@ -38,29 +34,17 @@ void SetOBC1(uint8_t Byte, uint16_t Address)
switch (Address)
{
case 0x7ff0:
- {
OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2)] = Byte;
break;
- }
-
case 0x7ff1:
- {
OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 1] = Byte;
break;
- }
-
case 0x7ff2:
- {
OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 2] = Byte;
break;
- }
-
case 0x7ff3:
- {
OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 3] = Byte;
break;
- }
-
case 0x7ff4:
{
uint8_t Temp;
@@ -69,7 +53,6 @@ void SetOBC1(uint8_t Byte, uint16_t Address)
OBC1_RAM[OBC1_BasePtr + (OBC1_Address >> 2) + 0x200] = Temp;
break;
}
-
case 0x7ff5:
{
if (Byte & 1)
@@ -80,14 +63,12 @@ void SetOBC1(uint8_t Byte, uint16_t Address)
OBC1_RAM[0x1ff5] = Byte;
break;
}
-
case 0x7ff6:
{
OBC1_Address = Byte & 0x7f;
OBC1_Shift = (Byte & 3) << 1;
break;
}
-
default:
OBC1_RAM[Address & 0x1fff] = Byte;
break;
diff --git a/source/port.h b/source/port.h
index b887fe1..bbe28c3 100644
--- a/source/port.h
+++ b/source/port.h
@@ -53,7 +53,8 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname,
#include <libretro.h>
-#define MIN(A,B) ((A) < (B) ? (A) : (B))
-#define MAX(A,B) ((A) > (B) ? (A) : (B))
+#define ABS(X) ((X) < 0 ? -(X) : (X))
+#define MIN(A,B) ((A) < (B) ? (A) : (B))
+#define MAX(A,B) ((A) > (B) ? (A) : (B))
#endif
diff --git a/source/ppu.c b/source/ppu.c
index 9ef69d5..bf1aa8a 100644
--- a/source/ppu.c
+++ b/source/ppu.c
@@ -18,19 +18,19 @@
extern struct FxInit_s SuperFX;
extern uint8_t mul_brightness [16][32];
-uint32_t justifiers = 0xFFFF00AA;
+uint32_t justifiers = 0xffff00aa;
uint8_t in_bit = 0;
extern uint8_t* HDMAMemPointers [8];
void S9xLatchCounters(bool force)
{
- if (!force && !(Memory.FillRAM[0x4213] & 0x80)) return;
+ if (!force && !(Memory.FillRAM[0x4213] & 0x80))
+ return;
PPU.HVBeamCounterLatched = 1;
PPU.VBeamPosLatched = (uint16_t) CPU.V_Counter;
- PPU.HBeamPosLatched = (uint16_t)((CPU.Cycles * SNES_HCOUNTER_MAX) /
- Settings.H_Max);
+ PPU.HBeamPosLatched = (uint16_t)((CPU.Cycles * SNES_HCOUNTER_MAX) / Settings.H_Max);
Memory.FillRAM [0x213F] |= 0x40;
}
@@ -100,8 +100,7 @@ void S9xFixColourBrightness()
IPPU.Red [i] = IPPU.XB [PPU.CGDATA [i] & 0x1f];
IPPU.Green [i] = IPPU.XB [(PPU.CGDATA [i] >> 5) & 0x1f];
IPPU.Blue [i] = IPPU.XB [(PPU.CGDATA [i] >> 10) & 0x1f];
- IPPU.ScreenColors [i] = BUILD_PIXEL(IPPU.Red [i], IPPU.Green [i],
- IPPU.Blue [i]);
+ IPPU.ScreenColors [i] = BUILD_PIXEL(IPPU.Red [i], IPPU.Green [i], IPPU.Blue [i]);
}
}
@@ -127,7 +126,6 @@ static void S9xSetSuperFX(uint8_t Byte, uint16_t Address)
FxFlushCache();
}
break;
-
case 0x3031:
case 0x3033:
case 0x3037:
@@ -151,7 +149,6 @@ static void S9xSetSuperFX(uint8_t Byte, uint16_t Address)
Memory.FillRAM [0x3000 + GSU_SFR] |= FLG_G;
S9xSuperFXExec();
break;
-
default:
if (Address >= 0x3100)
FxCacheWriteAccess(Address);
@@ -190,7 +187,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
}
}
break;
-
case 0x2101:
// Sprite (OBJ) tile address
if (Byte != Memory.FillRAM [0x2101])
@@ -202,7 +198,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
IPPU.OBJChanged = true;
}
break;
-
case 0x2102:
// Sprite write address (low)
PPU.OAMAddr = ((Memory.FillRAM[0x2103] & 1) << 8) | Byte;
@@ -215,7 +210,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
IPPU.OBJChanged = true;
}
break;
-
case 0x2103:
// Sprite register write address (high), sprite priority rotation
// bit.
@@ -242,12 +236,10 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
PPU.OAMReadFlip = 0;
PPU.SavedOAMAddr = PPU.OAMAddr;
break;
-
case 0x2104:
// Sprite register write
REGISTER_2104(Byte);
break;
-
case 0x2105:
// Screen mode (0 - 7), background tile sizes and background 3
// priority
@@ -262,10 +254,9 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
// BJ: BG3Priority only takes effect if BGMode==1 and the bit is set
PPU.BG3Priority = ((Byte & 0x0f) == 0x09);
if (PPU.BGMode == 5 || PPU.BGMode == 6)
- IPPU.Interlace = Memory.FillRAM[0x2133] & 1;
+ IPPU.Interlace = (bool) (Memory.FillRAM[0x2133] & 1);
}
break;
-
case 0x2106:
// Mosaic pixel size and enable
if (Byte != Memory.FillRAM [0x2106])
@@ -289,7 +280,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
PPU.BG[Address - 0x2107].SCBase = (Byte & 0x7c) << 8;
}
break;
-
case 0x210B: // [BG01NBA]
if (Byte != Memory.FillRAM [0x210b])
{
@@ -298,7 +288,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
PPU.BG[1].NameBase = ((Byte >> 4) & 7) << 12;
}
break;
-
case 0x210C: // [BG23NBA]
if (Byte != Memory.FillRAM [0x210c])
{
@@ -307,56 +296,44 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
PPU.BG[3].NameBase = ((Byte >> 4) & 7) << 12;
}
break;
-
-
//This is the Theme Park fix - it appears all these registers
//share a previous byte value for setting them.
-
case 0x210D:
PPU.BG[0].HOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
break;
-
case 0x210E:
PPU.BG[0].VOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
break;
-
case 0x210F:
PPU.BG[1].HOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
break;
-
case 0x2110:
PPU.BG[1].VOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
break;
-
case 0x2111:
PPU.BG[2].HOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
break;
-
case 0x2112:
PPU.BG[2].VOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
break;
-
case 0x2113:
PPU.BG[3].HOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
break;
-
case 0x2114:
PPU.BG[3].VOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
break;
-
//end Theme Park
-
case 0x2115:
// VRAM byte/word access flag and increment
- PPU.VMA.High = (Byte & 0x80) == 0 ? false : true;
+ PPU.VMA.High = (bool) (Byte & 0x80);
switch (Byte & 3)
{
case 0:
@@ -382,67 +359,28 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
else
PPU.VMA.FullGraphicCount = 0;
break;
-
case 0x2116:
// VRAM read/write address (low)
PPU.VMA.Address &= 0xFF00;
PPU.VMA.Address |= Byte;
-#ifdef CORRECT_VRAM_READS
- if (PPU.VMA.FullGraphicCount)
- {
- uint32_t addr = PPU.VMA.Address;
- uint32_t rem = addr & PPU.VMA.Mask1;
- uint32_t address = (addr & ~PPU.VMA.Mask1) +
- (rem >> PPU.VMA.Shift) +
- ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
- IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xFFFF));
- }
- else
- IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) &
- 0xffff));
-#else
IPPU.FirstVRAMRead = true;
-#endif
break;
-
case 0x2117:
// VRAM read/write address (high)
PPU.VMA.Address &= 0x00FF;
PPU.VMA.Address |= Byte << 8;
-#ifdef CORRECT_VRAM_READS
- if (PPU.VMA.FullGraphicCount)
- {
- uint32_t addr = PPU.VMA.Address;
- uint32_t rem = addr & PPU.VMA.Mask1;
- uint32_t address = (addr & ~PPU.VMA.Mask1) +
- (rem >> PPU.VMA.Shift) +
- ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
- IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xFFFF));
- }
- else
- IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) &
- 0xffff));
-#else
IPPU.FirstVRAMRead = true;
-#endif
break;
-
case 0x2118:
// VRAM write data (low)
-#ifndef CORRECT_VRAM_READS
IPPU.FirstVRAMRead = true;
-#endif
REGISTER_2118(Byte);
break;
-
case 0x2119:
// VRAM write data (high)
-#ifndef CORRECT_VRAM_READS
IPPU.FirstVRAMRead = true;
-#endif
REGISTER_2119(Byte);
break;
-
case 0x211a:
// Mode 7 outside rotation area display mode and flipping
if (Byte != Memory.FillRAM [0x211a])
@@ -451,8 +389,8 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
PPU.Mode7Repeat = Byte >> 6;
if (PPU.Mode7Repeat == 1)
PPU.Mode7Repeat = 0;
- PPU.Mode7VFlip = (Byte & 2) >> 1;
- PPU.Mode7HFlip = Byte & 1;
+ PPU.Mode7VFlip = (bool) (Byte & 2);
+ PPU.Mode7HFlip = (bool) (Byte & 1);
}
break;
case 0x211b:
@@ -481,18 +419,15 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
// Mode 7 centre of rotation Y (low & high)
PPU.CentreY = ((PPU.CentreY >> 8) & 0xff) | (Byte << 8);
break;
-
case 0x2121:
// CG-RAM address
- PPU.CGFLIP = 0;
- PPU.CGFLIPRead = 0;
+ PPU.CGFLIP = false;
+ PPU.CGFLIPRead = false;
PPU.CGADD = Byte;
break;
-
case 0x2122:
REGISTER_2122(Byte);
break;
-
case 0x2123:
// Window 1 and 2 enable for backgrounds 1 and 2
if (Byte != Memory.FillRAM [0x2123])
@@ -619,26 +554,16 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
return;
}
break;
- case 0x212e:
- // Window mask designation for main screen ?
- case 0x212f:
- // Window mask designation for sub-screen ?
+ case 0x212e: // Window mask designation for main screen ?
+ case 0x212f: // Window mask designation for sub-screen ?
+ case 0x2130: // Fixed colour addition or screen addition
if (Byte != Memory.FillRAM [Address])
{
FLUSH_REDRAW();
PPU.RecomputeClipWindows = true;
}
break;
- case 0x2130:
- // Fixed colour addition or screen addition
- if (Byte != Memory.FillRAM [0x2130])
- {
- FLUSH_REDRAW();
- PPU.RecomputeClipWindows = true;
- }
- break;
- case 0x2131:
- // Colour addition or subtraction select
+ case 0x2131: // Colour addition or subtraction select
if (Byte != Memory.FillRAM[0x2131])
{
FLUSH_REDRAW();
@@ -671,7 +596,8 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
else
IPPU.RenderedScreenHeight = PPU.ScreenHeight;
}
- else PPU.ScreenHeight = SNES_HEIGHT;
+ else
+ PPU.ScreenHeight = SNES_HEIGHT;
if ((Memory.FillRAM [0x2133] ^ Byte) & 3)
{
@@ -679,10 +605,9 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
if ((Memory.FillRAM [0x2133] ^ Byte) & 2)
IPPU.OBJChanged = true;
if (PPU.BGMode == 5 || PPU.BGMode == 6)
- IPPU.Interlace = Byte & 1;
- IPPU.InterlaceSprites = 0;
+ IPPU.Interlace = (bool) (Byte & 1);
+ IPPU.InterlaceSprites = false;
}
-
}
break;
case 0x2134:
@@ -829,11 +754,9 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
{
S9xSetSuperFX(Byte, Address);
return;
-
}
}
Memory.FillRAM[Address] = Byte;
-
}
/******************************************************************************/
@@ -849,18 +772,13 @@ uint8_t S9xGetPPU(uint16_t Address)
{
switch (Address)
{
- case 0x2100:
- case 0x2101:
- case 0x2102:
- case 0x2103:
- return OpenBus;
-
case 0x2104:
case 0x2105:
case 0x2106:
case 0x2108:
case 0x2109:
case 0x210a:
+ case 0x2114:
case 0x2115:
case 0x2116:
case 0x2118:
@@ -873,45 +791,6 @@ uint8_t S9xGetPPU(uint16_t Address)
case 0x2129:
case 0x212a:
return PPU.OpenBus1;
-
- case 0x2107:
- case 0x2117:
- case 0x2121:
- case 0x2122:
- case 0x2123:
- case 0x2127:
- case 0x212b:
- case 0x212c:
- case 0x212d:
- case 0x212e:
- case 0x212f:
- case 0x2130:
- case 0x2131:
- case 0x2132:
- case 0x2133:
- return OpenBus;
-
- case 0x210b:
- case 0x210c:
- case 0x210d:
- case 0x210e:
- case 0x210f:
- case 0x2110:
- case 0x2111:
- case 0x2112:
- case 0x2113:
- return OpenBus;
-
- case 0x2114:
- case 0x211b:
- case 0x211c:
- case 0x211d:
- case 0x211e:
- case 0x211f:
- case 0x2120:
- return OpenBus;
-
-
case 0x2134:
case 0x2135:
case 0x2136:
@@ -919,7 +798,6 @@ uint8_t S9xGetPPU(uint16_t Address)
if (PPU.Need16x8Mulitply)
{
int32_t r = (int32_t) PPU.MatrixA * (int32_t)(PPU.MatrixB >> 8);
-
Memory.FillRAM[0x2134] = (uint8_t) r;
Memory.FillRAM[0x2135] = (uint8_t)(r >> 8);
Memory.FillRAM[0x2136] = (uint8_t)(r >> 16);
@@ -929,7 +807,6 @@ uint8_t S9xGetPPU(uint16_t Address)
case 0x2137:
S9xLatchCounters(0);
return OpenBus;
-
case 0x2138:
// Read OAM (sprite) control data
if (PPU.OAMAddr & 0x100)
@@ -942,7 +819,7 @@ uint8_t S9xGetPPU(uint16_t Address)
PPU.OAMAddr = (PPU.OAMAddr + 1) & 0x1ff;
if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))
{
- PPU.FirstSprite = (PPU.OAMAddr & 0xFE) >> 1;
+ PPU.FirstSprite = (PPU.OAMAddr & 0xfe) >> 1;
IPPU.OBJChanged = true;
}
}
@@ -957,37 +834,17 @@ uint8_t S9xGetPPU(uint16_t Address)
++PPU.OAMAddr;
if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))
{
- PPU.FirstSprite = (PPU.OAMAddr & 0xFE) >> 1;
+ PPU.FirstSprite = (PPU.OAMAddr & 0xfe) >> 1;
IPPU.OBJChanged = true;
}
}
}
PPU.OAMFlip ^= 1;
return (PPU.OpenBus1 = byte);
-
case 0x2139:
// Read vram low byte
-#ifdef CORRECT_VRAM_READS
- byte = IPPU.VRAMReadBuffer & 0xff;
- if (!PPU.VMA.High)
- {
- if (PPU.VMA.FullGraphicCount)
- {
- uint32_t addr = PPU.VMA.Address;
- uint32_t rem = addr & PPU.VMA.Mask1;
- uint32_t address = (addr & ~PPU.VMA.Mask1) +
- (rem >> PPU.VMA.Shift) +
- ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
- IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xFFFF));
- }
- else
- IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) &
- 0xffff));
- PPU.VMA.Address += PPU.VMA.Increment;
- }
-#else
if (IPPU.FirstVRAMRead)
- byte = Memory.VRAM[(PPU.VMA.Address << 1) & 0xFFFF];
+ byte = Memory.VRAM[(PPU.VMA.Address << 1) & 0xffff];
else if (PPU.VMA.FullGraphicCount)
{
uint32_t addr = PPU.VMA.Address - 1;
@@ -995,7 +852,7 @@ uint8_t S9xGetPPU(uint16_t Address)
uint32_t address = (addr & ~PPU.VMA.Mask1) +
(rem >> PPU.VMA.Shift) +
((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
- byte = Memory.VRAM [((address << 1) - 2) & 0xFFFF];
+ byte = Memory.VRAM [((address << 1) - 2) & 0xffff];
}
else
byte = Memory.VRAM[((PPU.VMA.Address << 1) - 2) & 0xffff];
@@ -1005,30 +862,9 @@ uint8_t S9xGetPPU(uint16_t Address)
PPU.VMA.Address += PPU.VMA.Increment;
IPPU.FirstVRAMRead = false;
}
-#endif
- PPU.OpenBus1 = byte;
- break;
+ return (PPU.OpenBus1 = byte);
case 0x213A:
// Read vram high byte
-#ifdef CORRECT_VRAM_READS
- byte = (IPPU.VRAMReadBuffer >> 8) & 0xff;
- if (PPU.VMA.High)
- {
- if (PPU.VMA.FullGraphicCount)
- {
- uint32_t addr = PPU.VMA.Address;
- uint32_t rem = addr & PPU.VMA.Mask1;
- uint32_t address = (addr & ~PPU.VMA.Mask1) +
- (rem >> PPU.VMA.Shift) +
- ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
- IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xFFFF));
- }
- else
- IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) &
- 0xffff));
- PPU.VMA.Address += PPU.VMA.Increment;
- }
-#else
if (IPPU.FirstVRAMRead)
byte = Memory.VRAM[((PPU.VMA.Address << 1) + 1) & 0xffff];
else if (PPU.VMA.FullGraphicCount)
@@ -1038,67 +874,52 @@ uint8_t S9xGetPPU(uint16_t Address)
uint32_t address = (addr & ~PPU.VMA.Mask1) +
(rem >> PPU.VMA.Shift) +
((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
- byte = Memory.VRAM [((address << 1) - 1) & 0xFFFF];
+ byte = Memory.VRAM [((address << 1) - 1) & 0xffff];
}
else
- byte = Memory.VRAM[((PPU.VMA.Address << 1) - 1) & 0xFFFF];
+ byte = Memory.VRAM[((PPU.VMA.Address << 1) - 1) & 0xffff];
if (PPU.VMA.High)
{
PPU.VMA.Address += PPU.VMA.Increment;
IPPU.FirstVRAMRead = false;
}
-#endif
- PPU.OpenBus1 = byte;
- break;
-
+ return (PPU.OpenBus1 = byte);
case 0x213B:
// Read palette data
if (PPU.CGFLIPRead)
- byte = PPU.CGDATA [PPU.CGADD++] >> 8;
+ byte = (PPU.OpenBus2 & 0x80) | ((PPU.CGDATA[PPU.CGADD++] >> 8) & 0x7f);
else
byte = PPU.CGDATA [PPU.CGADD] & 0xff;
- PPU.CGFLIPRead ^= 1;
+ PPU.CGFLIPRead = !PPU.CGFLIPRead;
return (PPU.OpenBus2 = byte);
-
case 0x213C:
// Horizontal counter value 0-339
if (PPU.HBeamFlip)
- byte = (PPU.OpenBus2 & 0xfe)
- | ((PPU.HBeamPosLatched >> 8) & 0x01);
-
+ byte = (PPU.OpenBus2 & 0xfe) | ((PPU.HBeamPosLatched >> 8) & 0x01);
else
byte = (uint8_t)PPU.HBeamPosLatched;
- PPU.OpenBus2 = byte;
PPU.HBeamFlip ^= 1;
- break;
-
+ return (PPU.OpenBus2 = byte);
case 0x213D:
// Vertical counter value 0-262
if (PPU.VBeamFlip)
- byte = (PPU.OpenBus2 & 0xfe)
- | ((PPU.VBeamPosLatched >> 8) & 0x01);
+ byte = (PPU.OpenBus2 & 0xfe) | ((PPU.VBeamPosLatched >> 8) & 0x01);
else
byte = (uint8_t)PPU.VBeamPosLatched;
- PPU.OpenBus2 = byte;
PPU.VBeamFlip ^= 1;
- break;
-
+ return (PPU.OpenBus2 = byte);
case 0x213E:
// PPU time and range over flags
FLUSH_REDRAW();
-
- //so far, 5c77 version is always 1.
- return (PPU.OpenBus1 = (Model->_5C77 | PPU.RangeTimeOver));
-
+ byte = (PPU.OpenBus1 & 0x10) | PPU.RangeTimeOver | Model->_5C77;
+ return (PPU.OpenBus1 = byte);
case 0x213F:
// NTSC/PAL and which field flags
PPU.VBeamFlip = PPU.HBeamFlip = 0;
- //neviksti found a 2 and a 3 here. SNEeSe uses a 3.
- //XXX: field flags not emulated
- return ((Settings.PAL ? 0x10 : 0) | (Memory.FillRAM[0x213f] & 0xc0) |
- Model->_5C78) | (~PPU.OpenBus2 & 0x20);
-
+ byte = (PPU.OpenBus2 & 0x20) | (Memory.FillRAM[0x213f] & 0xc0) | (Settings.PAL ? 0x10 : 0) | Model->_5C78;
+ Memory.FillRAM[0x213f] &= ~0x40;
+ return (PPU.OpenBus2 = byte);
case 0x2140:
case 0x2141:
case 0x2142:
@@ -1175,10 +996,7 @@ uint8_t S9xGetPPU(uint16_t Address)
{
if (SNESGameFixes.APU_OutPorts_ReturnValueFix &&
Address >= 0x2140 && Address <= 0x2143 && !CPU.V_Counter)
- {
- return (uint8_t)((Address & 1) ? ((rand() & 0xff00) >> 8) :
- (rand() & 0xff));
- }
+ return (uint8_t)((Address & 1) ? ((rand() & 0xff00) >> 8) : (rand() & 0xff));
return (APU.OutPorts [Address & 3]);
}
@@ -1211,27 +1029,24 @@ uint8_t S9xGetPPU(uint16_t Address)
return ((r >> 3) & 0xff);
}
return (Memory.FillRAM[Address]);
-
#else // SPCTOOL
return (S9xAPUReadPort(Address & 3));
#endif //#ifndef USE_BLARGG_APU
-
case 0x2180:
// Read WRAM
byte = Memory.RAM [PPU.WRAM++];
PPU.WRAM &= 0x1FFFF;
- break;
- case 0x2181:
- case 0x2182:
- case 0x2183:
+ return byte;
default:
return OpenBus;
}
}
else
{
- if (Settings.SA1)
- return (S9xGetSA1(Address));
+ if (Settings.SA1 && Address >= 0x2200)
+ return S9xGetSA1(Address);
+ else if (Settings.SRTC && Address == 2800)
+ return S9xGetSRTC(Address);
if (Address <= 0x2fff || Address >= 0x3300)
{
@@ -1245,12 +1060,6 @@ uint8_t S9xGetPPU(uint16_t Address)
if (Model->_5C77 == 2)
return (0);
return OpenBus;
- case 0x2800:
- // For Dai Kaijyu Monogatari II
- if (Settings.SRTC)
- return (S9xGetSRTC(Address));
- /*FALL*/
-
default:
return OpenBus;
}
@@ -1271,9 +1080,9 @@ uint8_t S9xGetPPU(uint16_t Address)
CLEAR_IRQ_SOURCE(GSU_IRQ_SOURCE);
Memory.FillRAM [0x3031] = byte & 0x7f;
}
- return (byte);
+ return byte;
}
- return (byte);
+ return byte;
}
/******************************************************************************/
@@ -1340,15 +1149,13 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
PPU.HTimerEnabled = false;
PPU.HTimerPosition = Settings.H_Max + 1;
}
- if (!Settings.DaffyDuck)
+ if (!(byte & 0x30))
CLEAR_IRQ_SOURCE(PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE);
if ((byte & 0x80) &&
!(Memory.FillRAM [0x4200] & 0x80) &&
CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE &&
- CPU.V_Counter <= PPU.ScreenHeight +
- (SNESGameFixes.alienVSpredetorFix ? 25 : 15)
- && //jyam 15->25 alien vs predetor
+ // NMI can trigger during VBlank as long as NMI_read ($4210) wasn't cleared.
// Panic Bomberman clears the NMI pending flag @ scanline 230 before enabling
// NMIs again. The NMI routine crashes the CPU if it is called without the NMI
// pending flag being set...
@@ -1357,7 +1164,7 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
{
CPU.Flags |= NMI_FLAG;
CPU.NMIActive = true;
- CPU.NMICycleCount = CPU.NMITriggerPoint;
+ CPU.NMICycleCount = CPU.Cycles + TWO_CYCLES;
}
break;
case 0x4201:
@@ -1366,7 +1173,7 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
Memory.FillRAM[0x4201] = Memory.FillRAM[0x4213] = byte;
break;
case 0x4202:
- // Multiplier (for multply)
+ // Multiplier (for multiply)
break;
case 0x4203:
{
@@ -1416,7 +1223,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
if (PPU.HTimerEnabled && PPU.IRQHBeamPos != d)
S9xUpdateHTimer();
break;
-
case 0x4208:
d = PPU.IRQHBeamPos;
PPU.IRQHBeamPos = (PPU.IRQHBeamPos & 0xFF) | ((byte & 1) << 8);
@@ -1425,7 +1231,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
S9xUpdateHTimer();
break;
-
case 0x4209:
d = PPU.IRQVBeamPos;
PPU.IRQVBeamPos = (PPU.IRQVBeamPos & 0xFF00) | byte;
@@ -1440,7 +1245,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
}
}
break;
-
case 0x420A:
d = PPU.IRQVBeamPos;
PPU.IRQVBeamPos = (PPU.IRQVBeamPos & 0xFF) | ((byte & 1) << 8);
@@ -1455,7 +1259,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
}
}
break;
-
case 0x420B:
if ((byte & 0x01) != 0)
S9xDoDMA(0);
@@ -1480,19 +1283,18 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
Memory.FillRAM[0x420c] = byte;
IPPU.HDMA = byte;
break;
-
case 0x420d:
// Cycle speed 0 - 2.68Mhz, 1 - 3.58Mhz (banks 0x80 +)
if ((byte & 1) != (Memory.FillRAM [0x420d] & 1))
{
if (byte & 1)
CPU.FastROMSpeed = ONE_CYCLE;
- else CPU.FastROMSpeed = SLOW_ONE_CYCLE;
+ else
+ CPU.FastROMSpeed = SLOW_ONE_CYCLE;
FixROMSpeed();
}
break;
-
case 0x420e:
case 0x420f:
// --->>> Unknown
@@ -1529,7 +1331,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
case 0x421f:
// Joypad values (read-only)
return;
-
case 0x4300:
case 0x4310:
case 0x4320:
@@ -1539,13 +1340,13 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
case 0x4360:
case 0x4370:
d = (Address >> 4) & 0x7;
- DMA[d].TransferDirection = (byte & 128) != 0 ? 1 : 0;
- DMA[d].HDMAIndirectAddressing = (byte & 64) != 0 ? 1 : 0;
- DMA[d].AAddressDecrement = (byte & 16) != 0 ? 1 : 0;
- DMA[d].AAddressFixed = (byte & 8) != 0 ? 1 : 0;
+ DMA[d].TransferDirection = (bool) (byte & 0x80);
+ DMA[d].HDMAIndirectAddressing = (bool) (byte & 0x40);
+ Memory.FillRAM [Address | 0xf] = (byte & 0x20);
+ DMA[d].AAddressDecrement = (bool) (byte & 0x10);
+ DMA[d].AAddressFixed = (bool) (byte & 0x08);
DMA[d].TransferMode = (byte & 7);
break;
-
case 0x4301:
case 0x4311:
case 0x4321:
@@ -1556,7 +1357,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
case 0x4371:
DMA[((Address >> 4) & 0x7)].BAddress = byte;
break;
-
case 0x4302:
case 0x4312:
case 0x4322:
@@ -1569,7 +1369,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
DMA[d].AAddress &= 0xFF00;
DMA[d].AAddress |= byte;
break;
-
case 0x4303:
case 0x4313:
case 0x4323:
@@ -1582,7 +1381,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
DMA[d].AAddress &= 0xFF;
DMA[d].AAddress |= byte << 8;
break;
-
case 0x4304:
case 0x4314:
case 0x4324:
@@ -1593,9 +1391,7 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
case 0x4374:
DMA[((Address >> 4) & 0x7)].ABank = byte;
HDMAMemPointers[((Address >> 4) & 0x7)] = NULL;
-
break;
-
case 0x4305:
case 0x4315:
case 0x4325:
@@ -1605,13 +1401,12 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
case 0x4365:
case 0x4375:
d = (Address >> 4) & 0x7;
- DMA[d].TransferBytes &= 0xFF00;
+ DMA[d].TransferBytes &= 0xff00;
DMA[d].TransferBytes |= byte;
DMA[d].IndirectAddress &= 0xff00;
DMA[d].IndirectAddress |= byte;
HDMAMemPointers[d] = NULL;
break;
-
case 0x4306:
case 0x4316:
case 0x4326:
@@ -1627,7 +1422,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
DMA[d].IndirectAddress |= byte << 8;
HDMAMemPointers[d] = NULL;
break;
-
case 0x4307:
case 0x4317:
case 0x4327:
@@ -1639,7 +1433,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
DMA[d = ((Address >> 4) & 0x7)].IndirectBank = byte;
HDMAMemPointers[d] = NULL;
break;
-
case 0x4308:
case 0x4318:
case 0x4328:
@@ -1653,7 +1446,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
DMA[d].Address |= byte;
HDMAMemPointers[d] = NULL;
break;
-
case 0x4309:
case 0x4319:
case 0x4329:
@@ -1667,7 +1459,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
DMA[d].Address |= byte << 8;
HDMAMemPointers[d] = NULL;
break;
-
case 0x430A:
case 0x431A:
case 0x432A:
@@ -1680,17 +1471,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
DMA[d].LineCount = byte & 0x7f;
DMA[d].Repeat = !(byte & 0x80);
break;
-
- case 0x430F:
- case 0x431F:
- case 0x432F:
- case 0x433F:
- case 0x434F:
- case 0x435F:
- case 0x436F:
- case 0x437F:
- Address &= ~4; // Convert 43xF to 43xB
- /* fall through */
case 0x430B:
case 0x431B:
case 0x432B:
@@ -1699,9 +1479,17 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
case 0x435B:
case 0x436B:
case 0x437B:
- // Unknown, but they seem to be RAM-ish
+ case 0x430F:
+ case 0x431F:
+ case 0x432F:
+ case 0x433F:
+ case 0x434F:
+ case 0x435F:
+ case 0x436F:
+ case 0x437F:
+ Memory.FillRAM [Address | 0xf] = byte;
break;
-
+ /* fall through */
//These registers are used by both the S-DD1 and the SPC7110
case 0x4800:
case 0x4801:
@@ -1710,16 +1498,15 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
if (Settings.SPC7110)
S9xSetSPC7110(byte, Address);
break;
-
case 0x4804:
case 0x4805:
case 0x4806:
case 0x4807:
if (Settings.SPC7110)
S9xSetSPC7110(byte, Address);
- else S9xSetSDD1MemoryMap(Address - 0x4804, byte & 7);
+ else
+ S9xSetSDD1MemoryMap(Address - 0x4804, byte & 7);
break;
-
//these are used by the SPC7110
case 0x4808:
case 0x4809:
@@ -1765,7 +1552,6 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
S9xSetSPC7110(byte, Address);
break;
}
-
default:
break;
}
@@ -1778,6 +1564,7 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
/******************************************************************************/
uint8_t S9xGetCPU(uint16_t Address)
{
+ int32_t d;
uint8_t byte;
if (Address < 0x4200)
@@ -1866,7 +1653,6 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x420e:
case 0x420f:
return OpenBus;
-
case 0x4210:
#ifdef CPU_SHUTDOWN
CPU.WaitAddress = CPU.PCAtOpcodeStart;
@@ -1874,31 +1660,19 @@ uint8_t S9xGetCPU(uint16_t Address)
byte = Memory.FillRAM[0x4210];
Memory.FillRAM[0x4210] = Model->_5A22;
//SNEeSe returns 2 for 5A22 version.
- return ((byte & 0x80)
- | (OpenBus & 0x70)
- | Model->_5A22);
-
+ return ((byte & 0x80) | (OpenBus & 0x70) | Model->_5A22);
case 0x4211:
- byte = (CPU.IRQActive & (PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE)) ?
- 0x80 : 0;
- // Super Robot Wars Ex ROM bug requires this.
- byte |= CPU.Cycles >= Settings.HBlankStart ? 0x40 : 0;
+ byte = (CPU.IRQActive & (PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE)) ? 0x80 : 0;
CLEAR_IRQ_SOURCE(PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE);
-
- // Maybe? Register Scan indicated open bus...
- byte |= OpenBus & 0x3f;
+ byte |= OpenBus & 0x7f;
return (byte);
-
case 0x4212:
// V-blank, h-blank and joypads being read flags (read-only)
#ifdef CPU_SHUTDOWN
CPU.WaitAddress = CPU.PCAtOpcodeStart;
#endif
- return (REGISTER_4212()
- | (OpenBus & 0x3E)
- );
-
+ return (REGISTER_4212() | (OpenBus & 0x3E));
case 0x4213:
// I/O port input - returns 0 wherever $4201 is 0, and 1 elsewhere
// unless something else pulls it down (i.e. a gun)
@@ -1919,8 +1693,8 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x421d:
case 0x421e:
case 0x421f:
- // Joypads 1-4 button and direction state.
- /* fall through */
+ // Joypads 1-4 button and direction state.
+ return (Memory.FillRAM [Address]);
case 0x4300:
case 0x4310:
case 0x4320:
@@ -1929,8 +1703,13 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x4350:
case 0x4360:
case 0x4370:
- // DMA direction, address type, fixed flag,
- /* fall through */
+ d = (Address >> 4) & 0x7;
+ return ((DMA[d].TransferDirection ? 0x80 : 0x00) |
+ (DMA[d].HDMAIndirectAddressing ? 0x40 : 0x00) |
+ ((uint8_t) Memory.FillRAM [Address]) |
+ (DMA[d].AAddressDecrement ? 0x10 : 0x00) |
+ (DMA[d].AAddressFixed ? 0x08 : 0x00) |
+ (DMA[d].TransferMode & 7));
case 0x4301:
case 0x4311:
case 0x4321:
@@ -1939,7 +1718,7 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x4351:
case 0x4361:
case 0x4371:
- /* fall through */
+ return DMA[((Address >> 4) & 0x7)].BAddress;
case 0x4302:
case 0x4312:
case 0x4322:
@@ -1948,7 +1727,7 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x4352:
case 0x4362:
case 0x4372:
- /* fall through */
+ return (DMA[((Address >> 4) & 0x7)].AAddress & 0xFF);
case 0x4303:
case 0x4313:
case 0x4323:
@@ -1957,7 +1736,7 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x4353:
case 0x4363:
case 0x4373:
- /* fall through */
+ return (DMA[((Address >> 4) & 0x7)].AAddress >> 8);
case 0x4304:
case 0x4314:
case 0x4324:
@@ -1966,7 +1745,7 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x4354:
case 0x4364:
case 0x4374:
- /* fall through */
+ return DMA[((Address >> 4) & 0x7)].ABank;
case 0x4305:
case 0x4315:
case 0x4325:
@@ -1975,7 +1754,7 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x4355:
case 0x4365:
case 0x4375:
- /* fall through */
+ return (DMA[((Address >> 4) & 0x7)].IndirectAddress & 0xff);
case 0x4306:
case 0x4316:
case 0x4326:
@@ -1984,7 +1763,16 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x4356:
case 0x4366:
case 0x4376:
- /* fall through */
+ return (DMA[((Address >> 4) & 0x7)].IndirectAddress >> 8);
+ case 0x4307:
+ case 0x4317:
+ case 0x4327:
+ case 0x4337:
+ case 0x4347:
+ case 0x4357:
+ case 0x4367:
+ case 0x4377:
+ return DMA[((Address >> 4) & 0x7)].IndirectBank;
case 0x4308:
case 0x4318:
case 0x4328:
@@ -1993,7 +1781,7 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x4358:
case 0x4368:
case 0x4378:
- /* fall through */
+ return (DMA[((Address >> 4) & 0x7)].Address & 0xFF);
case 0x4309:
case 0x4319:
case 0x4329:
@@ -2002,18 +1790,7 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x4359:
case 0x4369:
case 0x4379:
- return (Memory.FillRAM[Address]);
-
- case 0x4307:
- case 0x4317:
- case 0x4327:
- case 0x4337:
- case 0x4347:
- case 0x4357:
- case 0x4367:
- case 0x4377:
- return (DMA[(Address >> 4) & 7].IndirectBank);
-
+ return (DMA[((Address >> 4) & 0x7)].Address >> 8);
case 0x430A:
case 0x431A:
case 0x432A:
@@ -2022,23 +1799,8 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x435A:
case 0x436A:
case 0x437A:
- {
- int32_t d = (Address & 0x70) >> 4;
- if (IPPU.HDMA & (1 << d))
- return (DMA[d].LineCount);
- return (Memory.FillRAM[Address]);
- }
-
- case 0x430F:
- case 0x431F:
- case 0x432F:
- case 0x433F:
- case 0x434F:
- case 0x435F:
- case 0x436F:
- case 0x437F:
- Address &= ~4; // Convert 43xF to 43xB
- /* fall through */
+ d = (Address >> 4) & 0x7;
+ return (DMA[d].LineCount ^ (DMA[d].Repeat ? 0x00 : 0x80));
case 0x430B:
case 0x431B:
case 0x432B:
@@ -2047,9 +1809,15 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x435B:
case 0x436B:
case 0x437B:
- // Unknown, but they seem to be RAM-ish
- return (Memory.FillRAM[Address]);
-
+ case 0x430F:
+ case 0x431F:
+ case 0x432F:
+ case 0x433F:
+ case 0x434F:
+ case 0x435F:
+ case 0x436F:
+ case 0x437F:
+ return (uint8_t) Memory.FillRAM [Address | 0xf];
default:
if (Address >= 0x4800 && Settings.SPC7110)
return S9xGetSPC7110(Address);
@@ -2066,7 +1834,7 @@ static void CommonPPUReset()
PPU.BGMode = 0;
PPU.BG3Priority = 0;
PPU.Brightness = 0;
- PPU.VMA.High = 0;
+ PPU.VMA.High = false;
PPU.VMA.Increment = 1;
PPU.VMA.Address = 0;
PPU.VMA.FullGraphicCount = 0;
@@ -2098,15 +1866,14 @@ static void CommonPPUReset()
PPU.ClipWindow1Inside[4] = PPU.ClipWindow1Inside[5] = true;
PPU.ClipWindow2Inside[4] = PPU.ClipWindow2Inside[5] = true;
- PPU.CGFLIP = 0;
+ PPU.CGFLIP = false;
int32_t c;
for (c = 0; c < 256; c++)
{
IPPU.Red [c] = (c & 7) << 2;
IPPU.Green [c] = ((c >> 3) & 7) << 2;
IPPU.Blue [c] = ((c >> 6) & 2) << 3;
- PPU.CGDATA [c] = IPPU.Red [c] | (IPPU.Green [c] << 5) |
- (IPPU.Blue [c] << 10);
+ PPU.CGDATA [c] = IPPU.Red [c] | (IPPU.Green [c] << 5) | (IPPU.Blue [c] << 10);
}
PPU.FirstSprite = 0;
@@ -2150,12 +1917,9 @@ static void CommonPPUReset()
PPU.WRAM = 0;
PPU.BG_Forced = 0;
PPU.ForcedBlanking = true;
- PPU.OBJThroughMain = false;
- PPU.OBJThroughSub = false;
PPU.OBJSizeSelect = 0;
PPU.OBJNameSelect = 0;
PPU.OBJNameBase = 0;
- PPU.OBJAddition = false;
PPU.OAMReadFlip = 0;
PPU.BGnxOFSbyte = 0;
memset(PPU.OAMData, 0, 512 + 32);
@@ -2174,7 +1938,7 @@ static void CommonPPUReset()
PPU.Window2Left = 1;
PPU.Window2Right = 0;
PPU.RecomputeClipWindows = true;
- PPU.CGFLIPRead = 0;
+ PPU.CGFLIPRead = false;
PPU.Need16x8Mulitply = false;
PPU.MouseSpeed[0] = PPU.MouseSpeed[1] = 0;
@@ -2182,7 +1946,7 @@ static void CommonPPUReset()
IPPU.HDMA = 0;
IPPU.HDMAStarted = false;
IPPU.MaxBrightness = 0;
- IPPU.LatchedBlanking = 0;
+ IPPU.LatchedBlanking = false;
IPPU.OBJChanged = true;
IPPU.RenderThisFrame = true;
IPPU.DirectColourMapsNeedRebuild = true;
@@ -2194,11 +1958,7 @@ static void CommonPPUReset()
memset(IPPU.TileCached [TILE_2BIT], 0, MAX_2BIT_TILES);
memset(IPPU.TileCached [TILE_4BIT], 0, MAX_4BIT_TILES);
memset(IPPU.TileCached [TILE_8BIT], 0, MAX_8BIT_TILES);
-#ifdef CORRECT_VRAM_READS
- IPPU.VRAMReadBuffer = 0; // XXX: FIXME: anything better?
-#else
IPPU.FirstVRAMRead = false;
-#endif
IPPU.Interlace = false;
IPPU.InterlaceSprites = false;
IPPU.DoubleWidthPixels = false;
@@ -2527,10 +2287,9 @@ void S9xUpdateJoypads()
uint32_t i;
for (i = 0; i < 5; i++)
+ {
IPPU.Joypads [i] = S9xReadJoypad(i);
- for (i = 0; i < 5; i++)
- {
if ((IPPU.Joypads [i] & (SNES_LEFT_MASK | SNES_RIGHT_MASK)) ==
(SNES_LEFT_MASK | SNES_RIGHT_MASK))
IPPU.Joypads [i] &= ~SNES_RIGHT_MASK;
@@ -2543,10 +2302,8 @@ void S9xUpdateJoypads()
if (IPPU.Controller == SNES_JOYPAD || IPPU.Controller == SNES_MULTIPLAYER5)
{
for (i = 0; i < 5; i++)
- {
if (IPPU.Joypads [i])
IPPU.Joypads [i] |= 0xffff0000;
- }
}
// Read mouse position if enabled
@@ -2599,7 +2356,6 @@ void S9xUpdateJoypads()
Memory.FillRAM [0x421b] = 0;
S9xUpdateJustifiers();
}
-
}
@@ -2681,17 +2437,16 @@ void REGISTER_2104(uint8_t byte)
IPPU.OBJChanged = true;
}
}
- else
- {
- if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1)) IPPU.OBJChanged = true;
- }
+ else if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1))
+ IPPU.OBJChanged = true;
}
else if (!(PPU.OAMFlip & 1))
{
PPU.OAMWriteRegister &= 0xff00;
PPU.OAMWriteRegister |= byte;
PPU.OAMFlip |= 1;
- if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1)) IPPU.OBJChanged = true;
+ if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1))
+ IPPU.OBJChanged = true;
}
else
{
@@ -2853,22 +2608,19 @@ void REGISTER_2122(uint8_t Byte)
}
PPU.CGADD++;
}
- else
+ else if (Byte != (uint8_t)(PPU.CGDATA[PPU.CGADD] & 0xff))
{
- if (Byte != (uint8_t)(PPU.CGDATA[PPU.CGADD] & 0xff))
- {
- FLUSH_REDRAW();
- PPU.CGDATA[PPU.CGADD] &= 0x7F00;
- PPU.CGDATA[PPU.CGADD] |= Byte;
- IPPU.ColorsChanged = true;
- IPPU.Red [PPU.CGADD] = IPPU.XB [Byte & 0x1f];
- IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f];
- IPPU.ScreenColors [PPU.CGADD] = (uint16_t) BUILD_PIXEL(IPPU.Red [PPU.CGADD],
- IPPU.Green [PPU.CGADD],
- IPPU.Blue [PPU.CGADD]);
- }
+ FLUSH_REDRAW();
+ PPU.CGDATA[PPU.CGADD] &= 0x7F00;
+ PPU.CGDATA[PPU.CGADD] |= Byte;
+ IPPU.ColorsChanged = true;
+ IPPU.Red [PPU.CGADD] = IPPU.XB [Byte & 0x1f];
+ IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f];
+ IPPU.ScreenColors [PPU.CGADD] = (uint16_t) BUILD_PIXEL(IPPU.Red [PPU.CGADD],
+ IPPU.Green [PPU.CGADD],
+ IPPU.Blue [PPU.CGADD]);
}
- PPU.CGFLIP ^= 1;
+ PPU.CGFLIP = !PPU.CGFLIP;
}
void REGISTER_2180(uint8_t Byte)
diff --git a/source/ppu.h b/source/ppu.h
index 1a83d6f..5101f02 100644
--- a/source/ppu.h
+++ b/source/ppu.h
@@ -18,9 +18,9 @@ extern uint16_t SignExtend [2];
#define PPU_H_BEAM_IRQ_SOURCE (1 << 0)
#define PPU_V_BEAM_IRQ_SOURCE (1 << 1)
-#define GSU_IRQ_SOURCE (1 << 2)
-#define SA1_IRQ_SOURCE (1 << 7)
-#define SA1_DMA_IRQ_SOURCE (1 << 5)
+#define GSU_IRQ_SOURCE (1 << 2)
+#define SA1_DMA_IRQ_SOURCE (1 << 5)
+#define SA1_IRQ_SOURCE (1 << 7)
struct ClipData
{
@@ -31,26 +31,22 @@ struct ClipData
typedef struct
{
- bool ColorsChanged;
- uint8_t HDMA;
- bool HDMAStarted;
- uint8_t MaxBrightness;
- bool LatchedBlanking;
- bool OBJChanged;
- bool RenderThisFrame;
- bool DirectColourMapsNeedRebuild;
- uint32_t FrameCount;
- uint32_t RenderedFramesCount;
- uint32_t DisplayedRenderedFrameCount;
- uint32_t SkippedFrames;
- uint32_t FrameSkip;
- uint8_t* TileCache [3];
- uint8_t* TileCached [3];
-#ifdef CORRECT_VRAM_READS
- uint16_t VRAMReadBuffer;
-#else
- bool FirstVRAMRead;
-#endif
+ bool ColorsChanged;
+ uint8_t HDMA;
+ bool HDMAStarted;
+ uint8_t MaxBrightness;
+ bool LatchedBlanking;
+ bool OBJChanged;
+ bool RenderThisFrame;
+ bool DirectColourMapsNeedRebuild;
+ uint32_t FrameCount;
+ uint32_t RenderedFramesCount;
+ uint32_t DisplayedRenderedFrameCount;
+ uint32_t SkippedFrames;
+ uint32_t FrameSkip;
+ uint8_t* TileCache [3];
+ uint8_t* TileCached [3];
+ bool FirstVRAMRead;
bool DoubleHeightPixels;
bool Interlace;
bool InterlaceSprites;
@@ -176,7 +172,7 @@ typedef struct
bool ClipWindow1Inside [6];
bool ClipWindow2Inside [6];
bool RecomputeClipWindows;
- uint8_t CGFLIPRead;
+ bool CGFLIPRead;
uint16_t OBJNameSelect;
bool Need16x8Mulitply;
uint8_t Joypad3ButtonReadPos;
diff --git a/source/sa1.c b/source/sa1.c
index f7324b5..54ed836 100644
--- a/source/sa1.c
+++ b/source/sa1.c
@@ -13,7 +13,7 @@ static void S9xSA1ReadVariableLengthData(bool inc, bool no_shift);
void S9xSA1Init()
{
SA1.NMIActive = false;
- SA1.IRQActive = false;
+ SA1.IRQActive = 0;
SA1.WaitingForInterrupt = false;
SA1.Waiting = false;
SA1.Flags = 0;
@@ -413,7 +413,7 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
break;
case 0x2231:
if (byte & 0x80)
- SA1.in_char_dma = false;
+ SA1.in_char_dma = 0;
break;
case 0x2236:
Memory.FillRAM [address] = byte;
@@ -426,7 +426,7 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
Memory.FillRAM [0x2300] |= 0x20;
if (Memory.FillRAM [0x2201] & 0x20)
S9xSetIRQ(SA1_DMA_IRQ_SOURCE);
- SA1.in_char_dma = true;
+ SA1.in_char_dma = 1;
}
return;
case 0x2237:
@@ -476,7 +476,7 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
SA1.sum = SA1.op1 << 16;
else
{
- uint64_t x = (SA1.op1 / (uint16_t) SA1.op2);
+ uint32_t x = (SA1.op1 / (uint16_t) SA1.op2);
SA1.sum = x | ((SA1.op1 - (x * (uint16_t) SA1.op2)) << 16);
}
break;
@@ -614,8 +614,7 @@ void S9xSA1ReadVariableLengthData(bool inc, bool no_shift)
addr += (s >> 4) << 1;
s &= 15;
}
- uint32_t data = S9xSA1GetWord(addr) |
- (S9xSA1GetWord(addr + 2) << 16);
+ uint32_t data = S9xSA1GetWord(addr) | (S9xSA1GetWord(addr + 2) << 16);
data >>= s;
Memory.FillRAM [0x230c] = (uint8_t) data;
diff --git a/source/sa1.h b/source/sa1.h
index 2b83eb3..6eb9935 100644
--- a/source/sa1.h
+++ b/source/sa1.h
@@ -51,7 +51,7 @@ typedef struct
int64_t sum;
bool overflow;
uint8_t VirtualBitmapFormat;
- bool in_char_dma;
+ uint8_t in_char_dma;
uint8_t variable_bit_pos;
SSA1Registers Registers;
} SSA1;
@@ -78,6 +78,7 @@ void S9xSA1SetPCBase(uint32_t);
uint8_t S9xGetSA1(uint32_t);
void S9xSetSA1(uint8_t, uint32_t);
+extern SOpcodes S9xSA1OpcodesE1 [256];
extern SOpcodes S9xSA1OpcodesM1X1 [256];
extern SOpcodes S9xSA1OpcodesM1X0 [256];
extern SOpcodes S9xSA1OpcodesM0X1 [256];
@@ -92,7 +93,7 @@ void S9xFixSA1AfterSnapshotLoad();
#define TIMER_IRQ_SOURCE (1 << 6)
#define DMA_IRQ_SOURCE (1 << 5)
-static inline void S9xSA1UnpackStatus(void)
+static inline void S9xSA1UnpackStatus()
{
SA1._Zero = (SA1.Registers.PL & Zero) == 0;
SA1._Negative = (SA1.Registers.PL & Negative);
@@ -100,17 +101,17 @@ static inline void S9xSA1UnpackStatus(void)
SA1._Overflow = (SA1.Registers.PL & Overflow) >> 6;
}
-static inline void S9xSA1PackStatus(void)
+static inline void S9xSA1PackStatus()
{
SA1.Registers.PL &= ~(Zero | Negative | Carry | Overflow);
SA1.Registers.PL |= SA1._Carry | ((SA1._Zero == 0) << 1) |
(SA1._Negative & 0x80) | (SA1._Overflow << 6);
}
-static inline void S9xSA1FixCycles(void)
+static inline void S9xSA1FixCycles()
{
if (SA1CheckEmulation())
- SA1.S9xOpcodes = S9xSA1OpcodesM1X1;
+ SA1.S9xOpcodes = S9xSA1OpcodesE1;
else if (SA1CheckMemory())
{
if (SA1CheckIndex())
diff --git a/source/sa1cpu.c b/source/sa1cpu.c
index 478df1e..272eb52 100644
--- a/source/sa1cpu.c
+++ b/source/sa1cpu.c
@@ -8,6 +8,7 @@
#include "sa1.h"
#define CPU SA1
#define ICPU SA1
+
#define S9xGetByte S9xSA1GetByte
#define S9xGetWord S9xSA1GetWord
#define S9xSetByte S9xSA1SetByte
@@ -46,69 +47,6 @@
#define StackRelative SA1StackRelative
#define StackRelativeIndirectIndexed SA1StackRelativeIndirectIndexed
-#define SetZN16 SA1SetZN16
-#define SetZN8 SA1SetZN8
-#define ADC8 SA1ADC8
-#define ADC16 SA1ADC16
-#define AND16 SA1AND16
-#define AND8 SA1AND8
-#define A_ASL16 SA1A_ASL16
-#define A_ASL8 SA1A_ASL8
-#define ASL16 SA1ASL16
-#define ASL8 SA1ASL8
-#define BIT16 SA1BIT16
-#define BIT8 SA1BIT8
-#define CMP16 SA1CMP16
-#define CMP8 SA1CMP8
-#define CMX16 SA1CMX16
-#define CMX8 SA1CMX8
-#define CMY16 SA1CMY16
-#define CMY8 SA1CMY8
-#define A_DEC16 SA1A_DEC16
-#define A_DEC8 SA1A_DEC8
-#define DEC16 SA1DEC16
-#define DEC8 SA1DEC8
-#define EOR16 SA1EOR16
-#define EOR8 SA1EOR8
-#define A_INC16 SA1A_INC16
-#define A_INC8 SA1A_INC8
-#define INC16 SA1INC16
-#define INC8 SA1INC8
-#define LDA16 SA1LDA16
-#define LDA8 SA1LDA8
-#define LDX16 SA1LDX16
-#define LDX8 SA1LDX8
-#define LDY16 SA1LDY16
-#define LDY8 SA1LDY8
-#define A_LSR16 SA1A_LSR16
-#define A_LSR8 SA1A_LSR8
-#define LSR16 SA1LSR16
-#define LSR8 SA1LSR8
-#define ORA16 SA1ORA16
-#define ORA8 SA1ORA8
-#define A_ROL16 SA1A_ROL16
-#define A_ROL8 SA1A_ROL8
-#define ROL16 SA1ROL16
-#define ROL8 SA1ROL8
-#define A_ROR16 SA1A_ROR16
-#define A_ROR8 SA1A_ROR8
-#define ROR16 SA1ROR16
-#define ROR8 SA1ROR8
-#define SBC16 SA1SBC16
-#define SBC8 SA1SBC8
-#define STA16 SA1STA16
-#define STA8 SA1STA8
-#define STX16 SA1STX16
-#define STX8 SA1STX8
-#define STY16 SA1STY16
-#define STY8 SA1STY8
-#define STZ16 SA1STZ16
-#define STZ8 SA1STZ8
-#define TSB16 SA1TSB16
-#define TSB8 SA1TSB8
-#define TRB16 SA1TRB16
-#define TRB8 SA1TRB8
-
#undef VAR_CYCLES
#define SA1_OPCODES
diff --git a/source/seta011.c b/source/seta011.c
index 26a0f54..a005f98 100644
--- a/source/seta011.c
+++ b/source/seta011.c
@@ -66,17 +66,9 @@ void S9xSetST011(uint32_t Address, uint8_t Byte)
ST011.in_count = 4;
break;
case 0x04:
- ST011.in_count = 0;
- break;
case 0x05:
- ST011.in_count = 0;
- break;
case 0x06:
- ST011.in_count = 0;
- break;
case 0x07:
- ST011.in_count = 0;
- break;
case 0x0E:
ST011.in_count = 0;
break;
@@ -107,13 +99,11 @@ void S9xSetST011(uint32_t Address, uint8_t Byte)
int32_t lcv;
for (lcv = 0; lcv < 9; lcv++)
memcpy(board[lcv], ST011.parameters + lcv * 10, 9 * 1);
+ break;
}
- break;
-
// unknown
case 0x02:
break;
-
// unknown
case 0x04:
case 0x05:
@@ -121,14 +111,12 @@ void S9xSetST011(uint32_t Address, uint8_t Byte)
// outputs
Memory.SRAM[0x12C] = 0x00;
Memory.SRAM[0x12E] = 0x00;
+ break;
}
- break;
-
// unknown
case 0x06:
case 0x07:
break;
-
// unknown
case 0x0E:
{
diff --git a/source/seta018.c b/source/seta018.c
index 00702d1..840e479 100644
--- a/source/seta018.c
+++ b/source/seta018.c
@@ -32,8 +32,6 @@ uint8_t S9xGetST018(uint32_t Address)
else if (address == 0x3800)
t = ST018.status;
- printf("ST018 R: %06X %02X\n", Address, t);
-
return t;
}
@@ -41,9 +39,6 @@ void S9xSetST018(uint8_t Byte, uint32_t Address)
{
uint16_t address = (uint16_t) Address & 0xFFFF;
static bool reset = false;
-
- printf("ST018 W: %06X %02X\n", Address, Byte);
-
line++;
if (!reset)
@@ -75,8 +70,6 @@ void S9xSetST018(uint8_t Byte, uint32_t Address)
switch (ST018.command & 0xFFFFFF)
{
case 0x0100:
- ST018.in_count = 0;
- break;
case 0xFF00:
ST018.in_count = 0;
break;
diff --git a/source/snes9x.h b/source/snes9x.h
index 1051af4..a3b6c98 100644
--- a/source/snes9x.h
+++ b/source/snes9x.h
@@ -9,11 +9,8 @@
#include <libretro.h>
-extern int cprintf(const char* fmt, ...);
-
#include "port.h"
#include "65c816.h"
-#include "messages.h"
#define ROM_NAME_LEN 23
@@ -196,18 +193,18 @@ typedef struct
bool SRTC;
uint32_t ControllerOption;
- bool ShutdownMaster;
- bool MultiPlayer5Master;
- bool SuperScopeMaster;
- bool MouseMaster;
- bool SuperFX;
- bool DSP1Master;
- bool SA1;
- bool C4;
- bool SDD1;
- bool SPC7110;
- bool SPC7110RTC;
- bool OBC1;
+ bool ShutdownMaster;
+ bool MultiPlayer5Master;
+ bool SuperScopeMaster;
+ bool MouseMaster;
+ bool SuperFX;
+ bool DSP1Master;
+ bool SA1;
+ bool C4;
+ bool SDD1;
+ bool SPC7110;
+ bool SPC7110RTC;
+ bool OBC1;
/* Sound options */
uint32_t SoundPlaybackRate;
#ifdef USE_BLARGG_APU
@@ -247,7 +244,6 @@ typedef struct
bool StarfoxHack;
bool WinterGold;
bool BS; /* Japanese Satellite System games. */
- bool DaffyDuck;
uint8_t APURAMInitialValue;
bool SampleCatchup;
bool JustifierMaster;
@@ -265,11 +261,9 @@ typedef struct
typedef struct
{
- uint8_t alienVSpredetorFix;
uint8_t APU_OutPorts_ReturnValueFix;
uint8_t SoundEnvelopeHeightReading2;
uint8_t SRAMInitialValue;
- uint8_t Uniracers;
bool EchoOnlyOutput;
} SSNESGameFixes;
@@ -278,7 +272,7 @@ extern SCPUState CPU;
extern SSNESGameFixes SNESGameFixes;
extern char String [513];
-void S9xMessage(int32_t type, int32_t number, const char* message);
+void S9xMessage(const char* message);
void S9xSetPause(uint32_t mask);
void S9xClearPause(uint32_t mask);
diff --git a/source/soundux.c b/source/soundux.c
index 237392e..9a2839e 100644
--- a/source/soundux.c
+++ b/source/soundux.c
@@ -381,8 +381,8 @@ void DecodeBlock(Channel* ch)
int8_t* compressed = (int8_t*) &IAPU.RAM [ch->block_pointer];
filter = *compressed;
- if ((ch->last_block = filter & 1))
- ch->loop = (filter & 2) != 0;
+ if ((ch->last_block = (bool) (filter & 1)))
+ ch->loop = (bool) (filter & 2);
int16_t* raw = ch->block = ch->decoded;
uint32_t i;
@@ -480,7 +480,7 @@ static inline void MixStereo(int32_t sample_count)
int32_t VL, VR;
uint32_t freq0 = ch->frequency;
- bool mod = pitch_mod & (1 << J);
+ uint8_t mod = pitch_mod & (1 << J);
if (ch->needs_decode)
{
@@ -497,8 +497,7 @@ static inline void MixStereo(int32_t sample_count)
ch->interpolate = 0;
if (Settings.InterpolatedSound && freq0 < FIXED_POINT && !mod)
- ch->interpolate = ((ch->next_sample - ch->sample) *
- (int32_t) freq0) / (int32_t) FIXED_POINT;
+ ch->interpolate = ((ch->next_sample - ch->sample) * (int32_t) freq0) / (int32_t) FIXED_POINT;
}
VL = (ch->sample * ch-> left_vol_level) / 128;
VR = (ch->sample * ch->right_vol_level) / 128;
@@ -702,10 +701,8 @@ static inline void MixStereo(int32_t sample_count)
{
if (Settings.InterpolatedSound && freq < FIXED_POINT && !mod)
{
- ch->interpolate = ((ch->next_sample - ch->sample) *
- (int32_t) freq) / (int32_t) FIXED_POINT;
- ch->sample = (int16_t)(ch->sample + (((ch->next_sample - ch->sample) *
- (int32_t)(ch->count)) / (int32_t) FIXED_POINT));
+ ch->interpolate = ((ch->next_sample - ch->sample) * (int32_t) freq) / (int32_t) FIXED_POINT;
+ ch->sample = (int16_t)(ch->sample + (((ch->next_sample - ch->sample) * (int32_t)(ch->count)) / (int32_t) FIXED_POINT));
}
else
ch->interpolate = 0;
@@ -931,7 +928,7 @@ bool S9xInitSound()
{
so.playback_rate = 0;
S9xResetSound(true);
- return (1);
+ return true;
}
bool S9xSetSoundMode(int32_t channel, int32_t mode)
@@ -944,7 +941,7 @@ bool S9xSetSoundMode(int32_t channel, int32_t mode)
if (ch->mode != MODE_NONE)
{
ch->mode = MODE_RELEASE;
- return (true);
+ return true;
}
break;
case MODE_DECREASE_LINEAR:
@@ -957,18 +954,18 @@ bool S9xSetSoundMode(int32_t channel, int32_t mode)
ch->mode = mode;
if (ch->state != SOUND_SILENT)
ch->state = mode;
- return (true);
+ return true;
}
break;
case MODE_ADSR:
if (ch->mode == MODE_NONE || ch->mode == MODE_ADSR)
{
ch->mode = mode;
- return (true);
+ return true;
}
}
- return (false);
+ return false;
}
void S9xPlaySample(int32_t channel)
diff --git a/source/spc700.c b/source/spc700.c
index 7b1a8b7..517f606 100644
--- a/source/spc700.c
+++ b/source/spc700.c
@@ -2465,7 +2465,7 @@ void ApuFB()
#include "apumem.h"
#endif
-void (*S9xApuOpcodes[256])(void) =
+void (*S9xApuOpcodes[256])() =
{
Apu00, Apu01, Apu02, Apu03, Apu04, Apu05, Apu06, Apu07,
Apu08, Apu09, Apu0A, Apu0B, Apu0C, Apu0D, Apu0E, Apu0F,
diff --git a/source/spc700.h b/source/spc700.h
index f1d7046..cbe6637 100644
--- a/source/spc700.h
+++ b/source/spc700.h
@@ -49,17 +49,14 @@
typedef union
{
-#ifdef MSB_FIRST
struct
{
+#ifdef MSB_FIRST
uint8_t Y, A;
- } B;
#else
- struct
- {
uint8_t A, Y;
- } B;
#endif
+ } B;
uint16_t W;
} YAndA;
@@ -76,11 +73,6 @@ typedef struct
// Needed by ILLUSION OF GAIA
#define ONE_APU_CYCLE 21
-// Needed by all games written by the software company called Human
-#define ONE_APU_CYCLE_HUMAN 21
-
-// 1.953us := 1.024065.54MHz
-
#ifdef SPCTOOL
int32_t ESPC(int32_t);
@@ -105,8 +97,8 @@ int32_t ESPC(int32_t);
#define APU_EXECUTE() \
if (IAPU.APUExecuting) \
{\
- while (APU.Cycles <= CPU.Cycles) \
- APU_EXECUTE1(); \
+ while (APU.Cycles <= CPU.Cycles) \
+ APU_EXECUTE1(); \
}
#endif
diff --git a/source/spc7110.c b/source/spc7110.c
index 1c87809..ffaf35f 100644
--- a/source/spc7110.c
+++ b/source/spc7110.c
@@ -40,9 +40,9 @@ char* osd_GetPackDir();
uint16_t cacheMegs = 5;
//using function pointers to initialize cache management
-void (*CleanUp7110)(void) = NULL;
+void (*CleanUp7110)() = NULL;
void (*LoadUp7110)(char*) = &SPC7110Load;
-void (*Copy7110)(void) = NULL;
+void (*Copy7110)() = NULL;
//size and offset of the pack data
//offset and size of reads from pack
@@ -143,8 +143,7 @@ void S9xSpc7110Init()
void MovePackData()
{
//log the last entry
- Data7110* log = &
- (decompack->tableEnts[decompack->idx].location[decompack->last_idx]);
+ Data7110* log = &(decompack->tableEnts[decompack->idx].location[decompack->last_idx]);
if ((log->used_len + log->used_offset) < (decompack->last_offset +
(uint16_t)s7r.bank50Internal))
{
@@ -238,11 +237,9 @@ void ReadPackData()
return;
}
- if (table_age_2 == 0 && table_age_3 == 0 && table_age_4 == 0
- && table_age_5 == 0)
+ if (table_age_2 == 0 && table_age_3 == 0 && table_age_4 == 0 && table_age_5 == 0)
table_age_2 = table_age_3 = table_age_4 = table_age_5 = MAX_TABLES;
- Data7110* log = &
- (decompack->tableEnts[decompack->idx].location[decompack->last_idx]);
+ Data7110* log = &(decompack->tableEnts[decompack->idx].location[decompack->last_idx]);
if ((log->used_len + log->used_offset) < (decompack->last_offset +
(uint16_t)s7r.bank50Internal))
{
@@ -292,8 +289,7 @@ void ReadPackData()
fclose(fp);
return;
}
- if (i != table_age_2 && i != table_age_3 && i != table_age_4
- && i != table_age_5)
+ if (i != table_age_2 && i != table_age_3 && i != table_age_4 && i != table_age_5)
{
if (table_age_5 != MAX_TABLES && decompack->binfiles[table_age_5])
{
@@ -511,7 +507,6 @@ uint8_t S9xGetSPC7110(uint16_t Address)
case 0x480C:
s7r.reg480C ^= 0x80;
return s7r.reg480C ^ 0x80;
-
//Data access port
//reads from the data ROM (anywhere over the first 8 mbits
//behavior is complex, will document later,
@@ -764,7 +759,6 @@ uint8_t S9xGetSPC7110(uint16_t Address)
//divisor high
case 0x4827:
return s7r.reg4827;
-
//result lowest
case 0x4828:
return s7r.reg4828;
@@ -1125,11 +1119,9 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
}
else
{
- uint32_t mul;
uint16_t m1 = (uint16_t)((s7r.reg4824) | (s7r.reg4825 << 8));
uint16_t m2 = (uint16_t)((s7r.reg4820) | (s7r.reg4821 << 8));
-
- mul = m1 * m2;
+ uint32_t mul = m1 * m2;
s7r.reg4828 = (uint8_t)(mul & 0x000000FF);
s7r.reg4829 = (uint8_t)((mul & 0x0000FF00) >> 8);
s7r.reg482A = (uint8_t)((mul & 0x00FF0000) >> 16);
@@ -1403,8 +1395,7 @@ void S9xUpdateRTC()
// 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.
- if (rtc_f9.init && 0 == (rtc_f9.reg[0x0D] & 0x01)
- && 0 == (rtc_f9.reg[0x0F] & 0x03))
+ if (rtc_f9.init && 0 == (rtc_f9.reg[0x0D] & 0x01) && 0 == (rtc_f9.reg[0x0F] & 0x03))
{
cur_systime = time(NULL);
@@ -1583,7 +1574,6 @@ bool Load7110Index(char* filename)
decompack->tableEnts[i].location[index].size = size;
decompack->tableEnts[i].location[index].used_len = 0;
decompack->tableEnts[i].location[index].used_offset = 0;
-
}
fclose(fp);
return true;
@@ -1604,8 +1594,7 @@ void SPC7110Load(char* dirname)
memset(decompack, 0, sizeof(Pack7110));
#if !defined(_XBOX) && !defined(VITA)
- if (-1 == chdir(dirname))
- S9xMessage(0, 0, "Graphics Pack not found!");
+ chdir(dirname);
#endif
#ifndef _XBOX
@@ -1661,8 +1650,7 @@ void SPC7110Open(char* dirname)
memset(decompack, 0, sizeof(Pack7110));
#if !defined(_XBOX) && !defined(VITA)
- if (-1 == chdir(dirname))
- S9xMessage(0, 0, "Graphics Pack not found!");
+ chdir(dirname);
#endif
#ifndef _XBOX
@@ -1701,9 +1689,7 @@ void SPC7110Grab(char* dirname)
memset(decompack, 0, sizeof(Pack7110));
#if !defined(_XBOX) && !defined(VITA)
-
- if (-1 == chdir(dirname))
- S9xMessage(0, 0, "Graphics Pack not found!");
+ chdir(dirname);
#endif
#ifndef _XBOX
diff --git a/source/spc7110.h b/source/spc7110.h
index 06a594a..351f29d 100644
--- a/source/spc7110.h
+++ b/source/spc7110.h
@@ -7,14 +7,14 @@
#define DECOMP_BUFFER_SIZE 0x10000
extern void (*LoadUp7110)(char*);
-extern void (*CleanUp7110)(void);
-extern void (*Copy7110)(void);
+extern void (*CleanUp7110)();
+extern void (*Copy7110)();
extern uint16_t cacheMegs;
-void Del7110Gfx(void);
-void Close7110Gfx(void);
-void Drop7110Gfx(void);
+void Del7110Gfx();
+void Close7110Gfx();
+void Drop7110Gfx();
uint8_t S9xGetSPC7110(uint16_t Address);
uint8_t S9xGetSPC7110Byte(uint32_t Address);
uint8_t* Get7110BasePtr(uint32_t);
diff --git a/source/srtc.c b/source/srtc.c
index 78cb4a7..bbc05ee 100644
--- a/source/srtc.c
+++ b/source/srtc.c
@@ -285,7 +285,6 @@ void S9xUpdateSrtcTime()
/**********************************************************************************************/
void S9xSetSRTC(uint8_t data, uint16_t Address)
{
-
data &= 0x0F; // Data is only 4-bits, mask out unused bits.
if (data >= 0xD)
@@ -353,7 +352,6 @@ void S9xSetSRTC(uint8_t data, uint16_t Address)
rtc.index = -1;
rtc.mode = MODE_COMMAND_DONE;
break;
-
case COMMAND_LOAD_RTC:
// Disable RTC counter
rtc.count_enable = false;
@@ -361,7 +359,6 @@ void S9xSetSRTC(uint8_t data, uint16_t Address)
rtc.index = 0; // Setup for writing
rtc.mode = MODE_LOAD_RTC;
break;
-
default:
rtc.mode = MODE_COMMAND_DONE;
// unrecognized command - need to implement.
diff --git a/source/tile.c b/source/tile.c
index ba3a1a7..43bcecb 100644
--- a/source/tile.c
+++ b/source/tile.c
@@ -17,16 +17,16 @@ static uint8_t ConvertTile(uint8_t* pCache, uint32_t TileAddr)
uint32_t* p = (uint32_t*) pCache;
uint32_t non_zero = 0;
uint8_t line;
+ uint32_t p1;
+ uint32_t p2;
+ uint8_t pix;
switch (BG.BitShift)
{
case 8:
for (line = 8; line != 0; line--, tp += 2)
{
- uint32_t p1 = 0;
- uint32_t p2 = 0;
- uint8_t pix;
-
+ p1 = p2 = 0;
if ((pix = *(tp + 0)))
{
p1 |= odd_high[0][pix >> 4];
@@ -76,9 +76,7 @@ static uint8_t ConvertTile(uint8_t* pCache, uint32_t TileAddr)
case 4:
for (line = 8; line != 0; line--, tp += 2)
{
- uint32_t p1 = 0;
- uint32_t p2 = 0;
- uint8_t pix;
+ p1 = p2 = 0;
if ((pix = *(tp + 0)))
{
p1 |= odd_high[0][pix >> 4];
@@ -108,9 +106,7 @@ static uint8_t ConvertTile(uint8_t* pCache, uint32_t TileAddr)
case 2:
for (line = 8; line != 0; line--, tp += 2)
{
- uint32_t p1 = 0;
- uint32_t p2 = 0;
- uint8_t pix;
+ p1 = p2 = 0;
if ((pix = *(tp + 0)))
{
p1 |= odd_high[0][pix >> 4];