Merge pull request #19 from orbea/whitespace

Remove trailing white space.
This commit is contained in:
Twinaphex 2017-12-03 11:30:13 +01:00 committed by GitHub
commit 4932c46ec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 438 additions and 439 deletions

View File

@ -103,7 +103,6 @@ all: library;
include gameboy/Makefile include gameboy/Makefile
set-static: set-static:
ifneq ($(platform),win) ifneq ($(platform),win)
$(eval fpic := ) $(eval fpic := )
@ -114,7 +113,7 @@ static: set-static static-library;
%.o: $<; $(call compile) %.o: $<; $(call compile)
include $(snes)/Makefile include $(snes)/Makefile
clean: clean:
rm -f obj/*.o rm -f obj/*.o
rm -f obj/*.a rm -f obj/*.a
rm -f obj/*.so rm -f obj/*.so

View File

@ -24,7 +24,7 @@ asm (
".globl co_switch_arm\n" ".globl co_switch_arm\n"
".globl _co_switch_arm\n" ".globl _co_switch_arm\n"
"co_switch_arm:\n" "co_switch_arm:\n"
"_co_switch_arm:\n" "_co_switch_arm:\n"
" stmia r1!, {r4, r5, r6, r7, r8, r9, r10, r11, sp, lr}\n" " stmia r1!, {r4, r5, r6, r7, r8, r9, r10, r11, sp, lr}\n"
" ldmia r0!, {r4, r5, r6, r7, r8, r9, r10, r11, sp, pc}\n" " ldmia r0!, {r4, r5, r6, r7, r8, r9, r10, r11, sp, pc}\n"
); );

View File

@ -56,7 +56,7 @@ or are directly to function */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
/* Swap code is in ppc.S */ /* Swap code is in ppc.S */
void co_swap_asm( cothread_t, cothread_t ); void co_swap_asm( cothread_t, cothread_t );
#define CO_SWAP_ASM( x, y ) co_swap_asm( x, y ) #define CO_SWAP_ASM( x, y ) co_swap_asm( x, y )
@ -285,15 +285,15 @@ static const uint32_t libco_ppc_code [] = {
static uint32_t* co_create_( unsigned size, uintptr_t entry ) static uint32_t* co_create_( unsigned size, uintptr_t entry )
{ {
uint32_t* t = (uint32_t*) malloc( size ); uint32_t* t = (uint32_t*) malloc( size );
(void) entry; (void) entry;
#if LIBCO_PPCDESC #if LIBCO_PPCDESC
if ( t ) if ( t )
{ {
/* Copy entry's descriptor */ /* Copy entry's descriptor */
memcpy( t, (void*) entry, sizeof (void*) * 3 ); memcpy( t, (void*) entry, sizeof (void*) * 3 );
/* Set function pointer to swap routine */ /* Set function pointer to swap routine */
#ifdef LIBCO_PPC_ASM #ifdef LIBCO_PPC_ASM
*(const void**) t = *(void**) &co_swap_asm; *(const void**) t = *(void**) &co_swap_asm;
@ -302,7 +302,7 @@ static uint32_t* co_create_( unsigned size, uintptr_t entry )
#endif #endif
} }
#endif #endif
return t; return t;
} }
@ -310,38 +310,38 @@ cothread_t co_create( unsigned int size, void (*entry_)( void ) )
{ {
uintptr_t entry = (uintptr_t) entry_; uintptr_t entry = (uintptr_t) entry_;
uint32_t* t = NULL; uint32_t* t = NULL;
/* Be sure main thread was successfully allocated */ /* Be sure main thread was successfully allocated */
if ( co_active() ) if ( co_active() )
{ {
size += state_size + above_stack + stack_align; size += state_size + above_stack + stack_align;
t = co_create_( size, entry ); t = co_create_( size, entry );
} }
if ( t ) if ( t )
{ {
uintptr_t sp; uintptr_t sp;
int shift; int shift;
/* Save current registers into new thread, so that any special ones will /* Save current registers into new thread, so that any special ones will
have proper values when thread is begun */ have proper values when thread is begun */
CO_SWAP_ASM( t, t ); CO_SWAP_ASM( t, t );
#if LIBCO_PPCDESC #if LIBCO_PPCDESC
/* Get real address */ /* Get real address */
entry = (uintptr_t) *(void**) entry; entry = (uintptr_t) *(void**) entry;
#endif #endif
/* Put stack near end of block, and align */ /* Put stack near end of block, and align */
sp = (uintptr_t) t + size - above_stack; sp = (uintptr_t) t + size - above_stack;
sp -= sp % stack_align; sp -= sp % stack_align;
/* On PPC32, we save and restore GPRs as 32 bits. For PPC64, we /* On PPC32, we save and restore GPRs as 32 bits. For PPC64, we
save and restore them as 64 bits, regardless of the size the ABI save and restore them as 64 bits, regardless of the size the ABI
uses. So, we manually write pointers at the proper size. We always uses. So, we manually write pointers at the proper size. We always
save and restore at the same address, and since PPC is big-endian, save and restore at the same address, and since PPC is big-endian,
we must put the low byte first on PPC32. */ we must put the low byte first on PPC32. */
/* If uintptr_t is 32 bits, >>32 is undefined behavior, so we do two shifts /* If uintptr_t is 32 bits, >>32 is undefined behavior, so we do two shifts
and don't have to care how many bits uintptr_t is. */ and don't have to care how many bits uintptr_t is. */
#if LIBCO_PPC64 #if LIBCO_PPC64
@ -349,15 +349,15 @@ cothread_t co_create( unsigned int size, void (*entry_)( void ) )
#else #else
shift = 0; shift = 0;
#endif #endif
/* Set up so entry will be called on next swap */ /* Set up so entry will be called on next swap */
t [8] = (uint32_t) (entry >> shift >> shift); t [8] = (uint32_t) (entry >> shift >> shift);
t [9] = (uint32_t) entry; t [9] = (uint32_t) entry;
t [10] = (uint32_t) (sp >> shift >> shift); t [10] = (uint32_t) (sp >> shift >> shift);
t [11] = (uint32_t) sp; t [11] = (uint32_t) sp;
} }
return t; return t;
} }
@ -377,16 +377,16 @@ static void co_init_( void )
uintptr_t align = page_size; uintptr_t align = page_size;
uintptr_t begin = (uintptr_t) libco_ppc_code; uintptr_t begin = (uintptr_t) libco_ppc_code;
uintptr_t end = begin + sizeof libco_ppc_code; uintptr_t end = begin + sizeof libco_ppc_code;
/* Align beginning and end */ /* Align beginning and end */
end += align - 1; end += align - 1;
end -= end % align; end -= end % align;
begin -= begin % align; begin -= begin % align;
mprotect( (void*) begin, end - begin, PROT_READ | PROT_WRITE | PROT_EXEC ); mprotect( (void*) begin, end - begin, PROT_READ | PROT_WRITE | PROT_EXEC );
} }
#endif #endif
co_active_handle = co_create_( state_size, (uintptr_t) &co_switch ); co_active_handle = co_create_( state_size, (uintptr_t) &co_switch );
} }
@ -394,7 +394,7 @@ cothread_t co_active()
{ {
if ( !co_active_handle ) if ( !co_active_handle )
co_init_(); co_init_();
return co_active_handle; return co_active_handle;
} }
@ -402,6 +402,6 @@ void co_switch( cothread_t t )
{ {
cothread_t old = co_active_handle; cothread_t old = co_active_handle;
co_active_handle = t; co_active_handle = t;
CO_SWAP_ASM( t, old ); CO_SWAP_ASM( t, old );
} }

View File

@ -6,7 +6,7 @@ typedef float resample_samp_t;
// ...but don't comment this single RESAMPLE_SSEREGPARM define out when disabling SSE. // ...but don't comment this single RESAMPLE_SSEREGPARM define out when disabling SSE.
#define RESAMPLE_SSEREGPARM #define RESAMPLE_SSEREGPARM
#if defined(__SSE__) #if defined(__SSE__)
#define SINCRESAMPLE_USE_SSE 1 #define SINCRESAMPLE_USE_SSE 1
@ -168,7 +168,7 @@ resample_samp_t SincResampleHR::mac(const resample_samp_t *wave, const resample_
{ {
#if SINCRESAMPLE_USE_SSE #if SINCRESAMPLE_USE_SSE
__m128 accum_veca[2] = { _mm_set1_ps(0), _mm_set1_ps(0) }; __m128 accum_veca[2] = { _mm_set1_ps(0), _mm_set1_ps(0) };
resample_samp_t accum; resample_samp_t accum;
for(unsigned c = 0; c < count; c += 8) for(unsigned c = 0; c < count; c += 8)
@ -265,7 +265,7 @@ SincResample::SincResample(double input_rate, double output_rate, double desired
if(ioratio_rd >= 8) if(ioratio_rd >= 8)
{ {
hr.Init(ioratio_rd, desired_bandwidth, qtab[quality].beta, qtab[quality].d); //10.056, 6.4); hr.Init(ioratio_rd, desired_bandwidth, qtab[quality].beta, qtab[quality].d); //10.056, 6.4);
hr_used = true; hr_used = true;
input_rate /= ioratio_rd; input_rate /= ioratio_rd;
@ -511,19 +511,19 @@ void ResampleUtility::kaiser_window( double* io, int count, double beta)
void ResampleUtility::gen_sinc(double* out, int size, double cutoff, double kaiser) void ResampleUtility::gen_sinc(double* out, int size, double cutoff, double kaiser)
{ {
assert( size % 2 == 0 ); // size must be even assert( size % 2 == 0 ); // size must be even
int const half_size = size / 2; int const half_size = size / 2;
double* const mid = &out [half_size]; double* const mid = &out [half_size];
// Generate right half of sinc // Generate right half of sinc
for ( int i = 0; i < half_size; i++ ) for ( int i = 0; i < half_size; i++ )
{ {
double angle = (i * 2 + 1) * (M_PI / 2); double angle = (i * 2 + 1) * (M_PI / 2);
mid [i] = sin( angle * cutoff ) / angle; mid [i] = sin( angle * cutoff ) / angle;
} }
kaiser_window( mid, half_size, kaiser ); kaiser_window( mid, half_size, kaiser );
// Mirror for left half // Mirror for left half
for ( int i = 0; i < half_size; i++ ) for ( int i = 0; i < half_size; i++ )
out [i] = mid [half_size - 1 - i]; out [i] = mid [half_size - 1 - i];
@ -532,7 +532,7 @@ void ResampleUtility::gen_sinc(double* out, int size, double cutoff, double kais
void ResampleUtility::gen_sinc_os(double* out, int size, double cutoff, double kaiser) void ResampleUtility::gen_sinc_os(double* out, int size, double cutoff, double kaiser)
{ {
assert( size % 2 == 1); // size must be odd assert( size % 2 == 1); // size must be odd
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
if(i == (size / 2)) if(i == (size / 2))

View File

@ -81,7 +81,7 @@ namespace nall {
template<typename T1> template<typename T1>
inline string(T1 const &); inline string(T1 const &);
template<typename T1, typename T2> template<typename T1, typename T2>
inline string(T1 const &, T2 const &); inline string(T1 const &, T2 const &);
@ -143,7 +143,7 @@ namespace nall {
inline void qsplit(const char*, const char*, unsigned = 0); inline void qsplit(const char*, const char*, unsigned = 0);
lstring(); lstring();
lstring(const string &); lstring(const string &);
lstring(const string &, const string &); lstring(const string &, const string &);
lstring(const string &, const string &, const string &); lstring(const string &, const string &, const string &);
@ -152,7 +152,7 @@ namespace nall {
lstring(const string &, const string &, const string &, const string &, const string &, const string &); lstring(const string &, const string &, const string &, const string &, const string &, const string &);
lstring(const string &, const string &, const string &, const string &, const string &, const string &, const string &); lstring(const string &, const string &, const string &, const string &, const string &, const string &, const string &);
lstring(const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &); lstring(const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &);
inline bool operator==(const lstring&) const; inline bool operator==(const lstring&) const;
inline bool operator!=(const lstring&) const; inline bool operator!=(const lstring&) const;

View File

@ -35,7 +35,7 @@ ifneq ($(GIT_VERSION)," unknown")
extraflags += -DGIT_VERSION=\"$(GIT_VERSION)\" extraflags += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif endif
obj/libretro.o: $(snes)/libretro/libretro.cpp $(snes)/libretro/* obj/libretro.o: $(snes)/libretro/libretro.cpp $(snes)/libretro/*
obj/libco.o : libco/libco.c libco/* obj/libco.o : libco/libco.c libco/*

View File

@ -141,7 +141,7 @@ inline int SPC_DSP::interpolate( voice_t const* v )
int offset = v->interp_pos >> 4 & 0xFF; int offset = v->interp_pos >> 4 & 0xFF;
short const* fwd = gauss + 255 - offset; short const* fwd = gauss + 255 - offset;
short const* rev = gauss + offset; // mirror left half of gaussian short const* rev = gauss + offset; // mirror left half of gaussian
int const* in = &v->buf [(v->interp_pos >> 12) + v->buf_pos]; int const* in = &v->buf [(v->interp_pos >> 12) + v->buf_pos];
int out; int out;
out = (fwd [ 0] * in [0]) >> 11; out = (fwd [ 0] * in [0]) >> 11;
@ -149,7 +149,7 @@ inline int SPC_DSP::interpolate( voice_t const* v )
out += (rev [256] * in [2]) >> 11; out += (rev [256] * in [2]) >> 11;
out = (int16_t) out; out = (int16_t) out;
out += (rev [ 0] * in [3]) >> 11; out += (rev [ 0] * in [3]) >> 11;
CLAMP16( out ); CLAMP16( out );
out &= ~1; out &= ~1;
return out; return out;
@ -271,13 +271,13 @@ inline void SPC_DSP::run_envelope( voice_t* const v )
} }
} }
} }
// Sustain level // Sustain level
if ( (env >> 8) == (env_data >> 5) && v->env_mode == env_decay ) if ( (env >> 8) == (env_data >> 5) && v->env_mode == env_decay )
v->env_mode = env_sustain; v->env_mode = env_sustain;
v->hidden_env = env; v->hidden_env = env;
// unsigned cast because linear decrease going negative also triggers this // unsigned cast because linear decrease going negative also triggers this
if ( (unsigned) env > 0x7FF ) if ( (unsigned) env > 0x7FF )
{ {
@ -285,7 +285,7 @@ inline void SPC_DSP::run_envelope( voice_t* const v )
if ( v->env_mode == env_attack ) if ( v->env_mode == env_attack )
v->env_mode = env_decay; v->env_mode = env_decay;
} }
if ( !read_counter( rate ) ) if ( !read_counter( rate ) )
v->env = env; // nothing else is controlled by the counter v->env = env; // nothing else is controlled by the counter
} }
@ -298,27 +298,27 @@ inline void SPC_DSP::decode_brr( voice_t* v )
{ {
// Arrange the four input nybbles in 0xABCD order for easy decoding // Arrange the four input nybbles in 0xABCD order for easy decoding
int nybbles = m.t_brr_byte * 0x100 + m.ram [(v->brr_addr + v->brr_offset + 1) & 0xFFFF]; int nybbles = m.t_brr_byte * 0x100 + m.ram [(v->brr_addr + v->brr_offset + 1) & 0xFFFF];
int const header = m.t_brr_header; int const header = m.t_brr_header;
// Write to next four samples in circular buffer // Write to next four samples in circular buffer
int* pos = &v->buf [v->buf_pos]; int* pos = &v->buf [v->buf_pos];
int* end; int* end;
if ( (v->buf_pos += 4) >= brr_buf_size ) if ( (v->buf_pos += 4) >= brr_buf_size )
v->buf_pos = 0; v->buf_pos = 0;
// Decode four samples // Decode four samples
for ( end = pos + 4; pos < end; pos++, nybbles <<= 4 ) for ( end = pos + 4; pos < end; pos++, nybbles <<= 4 )
{ {
// Extract nybble and sign-extend // Extract nybble and sign-extend
int s = (int16_t) nybbles >> 12; int s = (int16_t) nybbles >> 12;
// Shift sample based on header // Shift sample based on header
int const shift = header >> 4; int const shift = header >> 4;
s = (s << shift) >> 1; s = (s << shift) >> 1;
if ( shift >= 0xD ) // handle invalid range if ( shift >= 0xD ) // handle invalid range
s = (s >> 25) << 11; // same as: s = (s < 0 ? -0x800 : 0) s = (s >> 25) << 11; // same as: s = (s < 0 ? -0x800 : 0)
// Apply IIR filter (8 is the most commonly used) // Apply IIR filter (8 is the most commonly used)
int const filter = header & 0x0C; int const filter = header & 0x0C;
int const p1 = pos [brr_buf_size - 1]; int const p1 = pos [brr_buf_size - 1];
@ -343,7 +343,7 @@ inline void SPC_DSP::decode_brr( voice_t* v )
s += p1 >> 1; s += p1 >> 1;
s += (-p1) >> 5; s += (-p1) >> 5;
} }
// Adjust and write sample // Adjust and write sample
CLAMP16( s ); CLAMP16( s );
s = (int16_t) (s * 2); s = (int16_t) (s * 2);
@ -376,11 +376,11 @@ MISC_CLOCK( 30 )
if ( m.every_other_sample ) if ( m.every_other_sample )
{ {
m.kon = m.new_kon; m.kon = m.new_kon;
m.t_koff = REG(koff) | m.mute_mask; m.t_koff = REG(koff) | m.mute_mask;
} }
run_counters(); run_counters();
// Noise // Noise
if ( !read_counter( REG(flg) & 0x1F ) ) if ( !read_counter( REG(flg) & 0x1F ) )
{ {
@ -406,9 +406,9 @@ inline VOICE_CLOCK( V2 )
if ( !v->kon_delay ) if ( !v->kon_delay )
entry += 2; entry += 2;
m.t_brr_next_addr = GET_LE16A( entry ); m.t_brr_next_addr = GET_LE16A( entry );
m.t_adsr0 = VREG(v->regs,adsr0); m.t_adsr0 = VREG(v->regs,adsr0);
// Read pitch, spread over two clocks // Read pitch, spread over two clocks
m.t_pitch = VREG(v->regs,pitchl); m.t_pitch = VREG(v->regs,pitchl);
} }
@ -427,7 +427,7 @@ VOICE_CLOCK( V3c )
// Pitch modulation using previous voice's output // Pitch modulation using previous voice's output
if ( m.t_pmon & v->vbit ) if ( m.t_pmon & v->vbit )
m.t_pitch += ((m.t_output >> 5) * m.t_pitch) >> 10; m.t_pitch += ((m.t_output >> 5) * m.t_pitch) >> 10;
if ( v->kon_delay ) if ( v->kon_delay )
{ {
// Get ready to start BRR decoding on next sample // Get ready to start BRR decoding on next sample
@ -439,46 +439,46 @@ VOICE_CLOCK( V3c )
m.t_brr_header = 0; // header is ignored on this sample m.t_brr_header = 0; // header is ignored on this sample
m.kon_check = true; m.kon_check = true;
} }
// Envelope is never run during KON // Envelope is never run during KON
v->env = 0; v->env = 0;
v->hidden_env = 0; v->hidden_env = 0;
// Disable BRR decoding until last three samples // Disable BRR decoding until last three samples
v->interp_pos = 0; v->interp_pos = 0;
if ( --v->kon_delay & 3 ) if ( --v->kon_delay & 3 )
v->interp_pos = 0x4000; v->interp_pos = 0x4000;
// Pitch is never added during KON // Pitch is never added during KON
m.t_pitch = 0; m.t_pitch = 0;
} }
// Gaussian interpolation // Gaussian interpolation
{ {
int output = interpolate( v ); int output = interpolate( v );
// Noise // Noise
if ( m.t_non & v->vbit ) if ( m.t_non & v->vbit )
output = (int16_t) (m.noise * 2); output = (int16_t) (m.noise * 2);
// Apply envelope // Apply envelope
m.t_output = (output * v->env) >> 11 & ~1; m.t_output = (output * v->env) >> 11 & ~1;
v->t_envx_out = (uint8_t) (v->env >> 4); v->t_envx_out = (uint8_t) (v->env >> 4);
} }
// Immediate silence due to end of sample or soft reset // Immediate silence due to end of sample or soft reset
if ( REG(flg) & 0x80 || (m.t_brr_header & 3) == 1 ) if ( REG(flg) & 0x80 || (m.t_brr_header & 3) == 1 )
{ {
v->env_mode = env_release; v->env_mode = env_release;
v->env = 0; v->env = 0;
} }
if ( m.every_other_sample ) if ( m.every_other_sample )
{ {
// KOFF // KOFF
if ( m.t_koff & v->vbit ) if ( m.t_koff & v->vbit )
v->env_mode = env_release; v->env_mode = env_release;
// KON // KON
if ( m.kon & v->vbit ) if ( m.kon & v->vbit )
{ {
@ -486,7 +486,7 @@ VOICE_CLOCK( V3c )
v->env_mode = env_attack; v->env_mode = env_attack;
} }
} }
// Run envelope for next sample // Run envelope for next sample
if ( !v->kon_delay ) if ( !v->kon_delay )
run_envelope( v ); run_envelope( v );
@ -495,11 +495,11 @@ inline void SPC_DSP::voice_output( voice_t const* v, int ch )
{ {
// Apply left/right volume // Apply left/right volume
int amp = (m.t_output * (int8_t) VREG(v->regs,voll + ch)) >> 7; int amp = (m.t_output * (int8_t) VREG(v->regs,voll + ch)) >> 7;
// Add to output total // Add to output total
m.t_main_out [ch] += amp; m.t_main_out [ch] += amp;
CLAMP16( m.t_main_out [ch] ); CLAMP16( m.t_main_out [ch] );
// Optionally add to echo total // Optionally add to echo total
if ( m.t_eon & v->vbit ) if ( m.t_eon & v->vbit )
{ {
@ -514,7 +514,7 @@ VOICE_CLOCK( V4 )
if ( v->interp_pos >= 0x4000 ) if ( v->interp_pos >= 0x4000 )
{ {
decode_brr( v ); decode_brr( v );
if ( (v->brr_offset += 2) >= brr_block_size ) if ( (v->brr_offset += 2) >= brr_block_size )
{ {
// Start decoding next BRR block // Start decoding next BRR block
@ -528,14 +528,14 @@ VOICE_CLOCK( V4 )
v->brr_offset = 1; v->brr_offset = 1;
} }
} }
// Apply pitch // Apply pitch
v->interp_pos = (v->interp_pos & 0x3FFF) + m.t_pitch; v->interp_pos = (v->interp_pos & 0x3FFF) + m.t_pitch;
// Keep from getting too far ahead (when using pitch modulation) // Keep from getting too far ahead (when using pitch modulation)
if ( v->interp_pos > 0x7FFF ) if ( v->interp_pos > 0x7FFF )
v->interp_pos = 0x7FFF; v->interp_pos = 0x7FFF;
// Output left // Output left
voice_output( v, 0 ); voice_output( v, 0 );
} }
@ -543,10 +543,10 @@ inline VOICE_CLOCK( V5 )
{ {
// Output right // Output right
voice_output( v, 1 ); voice_output( v, 1 );
// ENDX, OUTX, and ENVX won't update if you wrote to them 1-2 clocks earlier // ENDX, OUTX, and ENVX won't update if you wrote to them 1-2 clocks earlier
int endx_buf = REG(endx) | m.t_looped; int endx_buf = REG(endx) | m.t_looped;
// Clear bit in ENDX if KON just began // Clear bit in ENDX if KON just began
if ( v->kon_delay == 5 ) if ( v->kon_delay == 5 )
endx_buf &= ~v->vbit; endx_buf &= ~v->vbit;
@ -561,7 +561,7 @@ inline VOICE_CLOCK( V7 )
{ {
// Update ENDX // Update ENDX
REG(endx) = m.endx_buf; REG(endx) = m.endx_buf;
m.envx_buf = v->t_envx_out; m.envx_buf = v->t_envx_out;
} }
inline VOICE_CLOCK( V8 ) inline VOICE_CLOCK( V8 )
@ -615,14 +615,14 @@ ECHO_CLOCK( 22 )
// History // History
if ( ++m.echo_hist_pos >= &m.echo_hist [echo_hist_size] ) if ( ++m.echo_hist_pos >= &m.echo_hist [echo_hist_size] )
m.echo_hist_pos = m.echo_hist; m.echo_hist_pos = m.echo_hist;
m.t_echo_ptr = (m.t_esa * 0x100 + m.echo_offset) & 0xFFFF; m.t_echo_ptr = (m.t_esa * 0x100 + m.echo_offset) & 0xFFFF;
echo_read( 0 ); echo_read( 0 );
// FIR (using l and r temporaries below helps compiler optimize) // FIR (using l and r temporaries below helps compiler optimize)
int l = CALC_FIR( 0, 0 ); int l = CALC_FIR( 0, 0 );
int r = CALC_FIR( 0, 1 ); int r = CALC_FIR( 0, 1 );
m.t_echo_in [0] = l; m.t_echo_in [0] = l;
m.t_echo_in [1] = r; m.t_echo_in [1] = r;
} }
@ -630,17 +630,17 @@ ECHO_CLOCK( 23 )
{ {
int l = CALC_FIR( 1, 0 ) + CALC_FIR( 2, 0 ); int l = CALC_FIR( 1, 0 ) + CALC_FIR( 2, 0 );
int r = CALC_FIR( 1, 1 ) + CALC_FIR( 2, 1 ); int r = CALC_FIR( 1, 1 ) + CALC_FIR( 2, 1 );
m.t_echo_in [0] += l; m.t_echo_in [0] += l;
m.t_echo_in [1] += r; m.t_echo_in [1] += r;
echo_read( 1 ); echo_read( 1 );
} }
ECHO_CLOCK( 24 ) ECHO_CLOCK( 24 )
{ {
int l = CALC_FIR( 3, 0 ) + CALC_FIR( 4, 0 ) + CALC_FIR( 5, 0 ); int l = CALC_FIR( 3, 0 ) + CALC_FIR( 4, 0 ) + CALC_FIR( 5, 0 );
int r = CALC_FIR( 3, 1 ) + CALC_FIR( 4, 1 ) + CALC_FIR( 5, 1 ); int r = CALC_FIR( 3, 1 ) + CALC_FIR( 4, 1 ) + CALC_FIR( 5, 1 );
m.t_echo_in [0] += l; m.t_echo_in [0] += l;
m.t_echo_in [1] += r; m.t_echo_in [1] += r;
} }
@ -648,16 +648,16 @@ ECHO_CLOCK( 25 )
{ {
int l = m.t_echo_in [0] + CALC_FIR( 6, 0 ); int l = m.t_echo_in [0] + CALC_FIR( 6, 0 );
int r = m.t_echo_in [1] + CALC_FIR( 6, 1 ); int r = m.t_echo_in [1] + CALC_FIR( 6, 1 );
l = (int16_t) l; l = (int16_t) l;
r = (int16_t) r; r = (int16_t) r;
l += (int16_t) CALC_FIR( 7, 0 ); l += (int16_t) CALC_FIR( 7, 0 );
r += (int16_t) CALC_FIR( 7, 1 ); r += (int16_t) CALC_FIR( 7, 1 );
CLAMP16( l ); CLAMP16( l );
CLAMP16( r ); CLAMP16( r );
m.t_echo_in [0] = l & ~1; m.t_echo_in [0] = l & ~1;
m.t_echo_in [1] = r & ~1; m.t_echo_in [1] = r & ~1;
} }
@ -673,14 +673,14 @@ ECHO_CLOCK( 26 )
// Left output volumes // Left output volumes
// (save sample for next clock so we can output both together) // (save sample for next clock so we can output both together)
m.t_main_out [0] = echo_output( 0 ); m.t_main_out [0] = echo_output( 0 );
// Echo feedback // Echo feedback
int l = m.t_echo_out [0] + (int16_t) ((m.t_echo_in [0] * (int8_t) REG(efb)) >> 7); int l = m.t_echo_out [0] + (int16_t) ((m.t_echo_in [0] * (int8_t) REG(efb)) >> 7);
int r = m.t_echo_out [1] + (int16_t) ((m.t_echo_in [1] * (int8_t) REG(efb)) >> 7); int r = m.t_echo_out [1] + (int16_t) ((m.t_echo_in [1] * (int8_t) REG(efb)) >> 7);
CLAMP16( l ); CLAMP16( l );
CLAMP16( r ); CLAMP16( r );
m.t_echo_out [0] = l & ~1; m.t_echo_out [0] = l & ~1;
m.t_echo_out [1] = r & ~1; m.t_echo_out [1] = r & ~1;
} }
@ -691,7 +691,7 @@ ECHO_CLOCK( 27 )
int r = echo_output( 1 ); int r = echo_output( 1 );
m.t_main_out [0] = 0; m.t_main_out [0] = 0;
m.t_main_out [1] = 0; m.t_main_out [1] = 0;
// TODO: global muting isn't this simple (turns DAC on and off // TODO: global muting isn't this simple (turns DAC on and off
// or something, causing small ~37-sample pulse when first muted) // or something, causing small ~37-sample pulse when first muted)
if ( REG(flg) & 0x40 ) if ( REG(flg) & 0x40 )
@ -699,7 +699,7 @@ ECHO_CLOCK( 27 )
l = 0; l = 0;
r = 0; r = 0;
} }
// Output sample to DAC // Output sample to DAC
#ifdef SPC_DSP_OUT_HOOK #ifdef SPC_DSP_OUT_HOOK
SPC_DSP_OUT_HOOK( l, r ); SPC_DSP_OUT_HOOK( l, r );
@ -722,17 +722,17 @@ inline void SPC_DSP::echo_write( int ch )
ECHO_CLOCK( 29 ) ECHO_CLOCK( 29 )
{ {
m.t_esa = REG(esa); m.t_esa = REG(esa);
if ( !m.echo_offset ) if ( !m.echo_offset )
m.echo_length = (REG(edl) & 0x0F) * 0x800; m.echo_length = (REG(edl) & 0x0F) * 0x800;
m.echo_offset += 4; m.echo_offset += 4;
if ( m.echo_offset >= m.echo_length ) if ( m.echo_offset >= m.echo_length )
m.echo_offset = 0; m.echo_offset = 0;
// Write left echo // Write left echo
echo_write( 0 ); echo_write( 0 );
m.t_echo_enabled = REG(flg); m.t_echo_enabled = REG(flg);
} }
ECHO_CLOCK( 30 ) ECHO_CLOCK( 30 )
@ -795,17 +795,17 @@ PHASE(31) V(V4,0) V(V1,2)\
void SPC_DSP::run( int clocks_remain ) void SPC_DSP::run( int clocks_remain )
{ {
require( clocks_remain > 0 ); require( clocks_remain > 0 );
int const phase = m.phase; int const phase = m.phase;
m.phase = (phase + clocks_remain) & 31; m.phase = (phase + clocks_remain) & 31;
switch ( phase ) switch ( phase )
{ {
loop: loop:
#define PHASE( n ) if ( n && !--clocks_remain ) break; case n: #define PHASE( n ) if ( n && !--clocks_remain ) break; case n:
GEN_DSP_TIMING GEN_DSP_TIMING
#undef PHASE #undef PHASE
if ( --clocks_remain ) if ( --clocks_remain )
goto loop; goto loop;
} }
@ -823,19 +823,19 @@ void SPC_DSP::init( void* ram_64k )
disable_surround( false ); disable_surround( false );
set_output( 0, 0 ); set_output( 0, 0 );
reset(); reset();
#ifndef NDEBUG #ifndef NDEBUG
// be sure this sign-extends // be sure this sign-extends
assert( (int16_t) 0x8000 == -0x8000 ); assert( (int16_t) 0x8000 == -0x8000 );
// be sure right shift preserves sign // be sure right shift preserves sign
assert( (-1 >> 1) == -1 ); assert( (-1 >> 1) == -1 );
// check clamp macro // check clamp macro
int i; int i;
i = +0x8000; CLAMP16( i ); assert( i == +0x7FFF ); i = +0x8000; CLAMP16( i ); assert( i == +0x7FFF );
i = -0x8001; CLAMP16( i ); assert( i == -0x8000 ); i = -0x8001; CLAMP16( i ); assert( i == -0x8000 );
blargg_verify_byte_order(); blargg_verify_byte_order();
#endif #endif
} }
@ -843,13 +843,13 @@ void SPC_DSP::init( void* ram_64k )
void SPC_DSP::soft_reset_common() void SPC_DSP::soft_reset_common()
{ {
require( m.ram ); // init() must have been called already require( m.ram ); // init() must have been called already
m.noise = 0x4000; m.noise = 0x4000;
m.echo_hist_pos = m.echo_hist; m.echo_hist_pos = m.echo_hist;
m.every_other_sample = 1; m.every_other_sample = 1;
m.echo_offset = 0; m.echo_offset = 0;
m.phase = 0; m.phase = 0;
init_counter(); init_counter();
} }
@ -863,7 +863,7 @@ void SPC_DSP::load( uint8_t const regs [register_count] )
{ {
memcpy( m.regs, regs, sizeof m.regs ); memcpy( m.regs, regs, sizeof m.regs );
memset( &m.regs [register_count], 0, offsetof (state_t,ram) - register_count ); memset( &m.regs [register_count], 0, offsetof (state_t,ram) - register_count );
// Internal state // Internal state
for ( int i = voice_count; --i >= 0; ) for ( int i = voice_count; --i >= 0; )
{ {
@ -875,7 +875,7 @@ void SPC_DSP::load( uint8_t const regs [register_count] )
m.new_kon = REG(kon); m.new_kon = REG(kon);
m.t_dir = REG(dir); m.t_dir = REG(dir);
m.t_esa = REG(esa); m.t_esa = REG(esa);
soft_reset_common(); soft_reset_common();
} }
@ -928,18 +928,18 @@ void SPC_State_Copier::extra()
void SPC_DSP::copy_state( unsigned char** io, copy_func_t copy ) void SPC_DSP::copy_state( unsigned char** io, copy_func_t copy )
{ {
SPC_State_Copier copier( io, copy ); SPC_State_Copier copier( io, copy );
// DSP registers // DSP registers
copier.copy( m.regs, register_count ); copier.copy( m.regs, register_count );
// Internal state // Internal state
// Voices // Voices
int i; int i;
for ( i = 0; i < voice_count; i++ ) for ( i = 0; i < voice_count; i++ )
{ {
voice_t* v = &m.voices [i]; voice_t* v = &m.voices [i];
// BRR buffer // BRR buffer
int i; int i;
for ( i = 0; i < brr_buf_size; i++ ) for ( i = 0; i < brr_buf_size; i++ )
@ -948,7 +948,7 @@ void SPC_DSP::copy_state( unsigned char** io, copy_func_t copy )
SPC_COPY( int16_t, s ); SPC_COPY( int16_t, s );
v->buf [i] = v->buf [i + brr_buf_size] = s; v->buf [i] = v->buf [i + brr_buf_size] = s;
} }
SPC_COPY( uint16_t, v->interp_pos ); SPC_COPY( uint16_t, v->interp_pos );
SPC_COPY( uint16_t, v->brr_addr ); SPC_COPY( uint16_t, v->brr_addr );
SPC_COPY( uint16_t, v->env ); SPC_COPY( uint16_t, v->env );
@ -962,10 +962,10 @@ void SPC_DSP::copy_state( unsigned char** io, copy_func_t copy )
v->env_mode = (enum env_mode_t) m; v->env_mode = (enum env_mode_t) m;
} }
SPC_COPY( uint8_t, v->t_envx_out ); SPC_COPY( uint8_t, v->t_envx_out );
copier.extra(); copier.extra();
} }
// Echo history // Echo history
for ( i = 0; i < echo_hist_size; i++ ) for ( i = 0; i < echo_hist_size; i++ )
{ {
@ -979,28 +979,28 @@ void SPC_DSP::copy_state( unsigned char** io, copy_func_t copy )
} }
m.echo_hist_pos = m.echo_hist; m.echo_hist_pos = m.echo_hist;
memcpy( &m.echo_hist [echo_hist_size], m.echo_hist, echo_hist_size * sizeof m.echo_hist [0] ); memcpy( &m.echo_hist [echo_hist_size], m.echo_hist, echo_hist_size * sizeof m.echo_hist [0] );
// Misc // Misc
SPC_COPY( uint8_t, m.every_other_sample ); SPC_COPY( uint8_t, m.every_other_sample );
SPC_COPY( uint8_t, m.kon ); SPC_COPY( uint8_t, m.kon );
SPC_COPY( uint16_t, m.noise ); SPC_COPY( uint16_t, m.noise );
SPC_COPY( uint16_t, m.counter ); SPC_COPY( uint16_t, m.counter );
SPC_COPY( uint16_t, m.echo_offset ); SPC_COPY( uint16_t, m.echo_offset );
SPC_COPY( uint16_t, m.echo_length ); SPC_COPY( uint16_t, m.echo_length );
SPC_COPY( uint8_t, m.phase ); SPC_COPY( uint8_t, m.phase );
SPC_COPY( uint8_t, m.new_kon ); SPC_COPY( uint8_t, m.new_kon );
SPC_COPY( uint8_t, m.endx_buf ); SPC_COPY( uint8_t, m.endx_buf );
SPC_COPY( uint8_t, m.envx_buf ); SPC_COPY( uint8_t, m.envx_buf );
SPC_COPY( uint8_t, m.outx_buf ); SPC_COPY( uint8_t, m.outx_buf );
SPC_COPY( uint8_t, m.t_pmon ); SPC_COPY( uint8_t, m.t_pmon );
SPC_COPY( uint8_t, m.t_non ); SPC_COPY( uint8_t, m.t_non );
SPC_COPY( uint8_t, m.t_eon ); SPC_COPY( uint8_t, m.t_eon );
SPC_COPY( uint8_t, m.t_dir ); SPC_COPY( uint8_t, m.t_dir );
SPC_COPY( uint8_t, m.t_koff ); SPC_COPY( uint8_t, m.t_koff );
SPC_COPY( uint16_t, m.t_brr_next_addr ); SPC_COPY( uint16_t, m.t_brr_next_addr );
SPC_COPY( uint8_t, m.t_adsr0 ); SPC_COPY( uint8_t, m.t_adsr0 );
SPC_COPY( uint8_t, m.t_brr_header ); SPC_COPY( uint8_t, m.t_brr_header );
@ -1008,20 +1008,20 @@ void SPC_DSP::copy_state( unsigned char** io, copy_func_t copy )
SPC_COPY( uint8_t, m.t_srcn ); SPC_COPY( uint8_t, m.t_srcn );
SPC_COPY( uint8_t, m.t_esa ); SPC_COPY( uint8_t, m.t_esa );
SPC_COPY( uint8_t, m.t_echo_enabled ); SPC_COPY( uint8_t, m.t_echo_enabled );
SPC_COPY( int16_t, m.t_main_out [0] ); SPC_COPY( int16_t, m.t_main_out [0] );
SPC_COPY( int16_t, m.t_main_out [1] ); SPC_COPY( int16_t, m.t_main_out [1] );
SPC_COPY( int16_t, m.t_echo_out [0] ); SPC_COPY( int16_t, m.t_echo_out [0] );
SPC_COPY( int16_t, m.t_echo_out [1] ); SPC_COPY( int16_t, m.t_echo_out [1] );
SPC_COPY( int16_t, m.t_echo_in [0] ); SPC_COPY( int16_t, m.t_echo_in [0] );
SPC_COPY( int16_t, m.t_echo_in [1] ); SPC_COPY( int16_t, m.t_echo_in [1] );
SPC_COPY( uint16_t, m.t_dir_addr ); SPC_COPY( uint16_t, m.t_dir_addr );
SPC_COPY( uint16_t, m.t_pitch ); SPC_COPY( uint16_t, m.t_pitch );
SPC_COPY( int16_t, m.t_output ); SPC_COPY( int16_t, m.t_output );
SPC_COPY( uint16_t, m.t_echo_ptr ); SPC_COPY( uint16_t, m.t_echo_ptr );
SPC_COPY( uint8_t, m.t_looped ); SPC_COPY( uint8_t, m.t_looped );
copier.extra(); copier.extra();
} }
#endif #endif

View File

@ -11,7 +11,7 @@ extern "C" { typedef void (*dsp_copy_func_t)( unsigned char** io, void* state, s
class SPC_DSP { class SPC_DSP {
public: public:
typedef BOOST::uint8_t uint8_t; typedef BOOST::uint8_t uint8_t;
// Setup // Setup
// Initializes DSP and has it use the 64K RAM provided // Initializes DSP and has it use the 64K RAM provided
@ -34,7 +34,7 @@ public:
// Emulates pressing reset switch on SNES // Emulates pressing reset switch on SNES
void soft_reset(); void soft_reset();
// Reads/writes DSP registers. For accuracy, you must first call run() // Reads/writes DSP registers. For accuracy, you must first call run()
// to catch the DSP up to present. // to catch the DSP up to present.
int read ( int addr ) const; int read ( int addr ) const;
@ -43,7 +43,7 @@ public:
// Runs DSP for specified number of clocks (~1024000 per second). Every 32 clocks // Runs DSP for specified number of clocks (~1024000 per second). Every 32 clocks
// a pair of samples is be generated. // a pair of samples is be generated.
void run( int clock_count ); void run( int clock_count );
// Sound control // Sound control
// Mutes voices corresponding to non-zero bits in mask (issues repeated KOFF events). // Mutes voices corresponding to non-zero bits in mask (issues repeated KOFF events).
@ -52,7 +52,7 @@ public:
void mute_voices( int mask ); void mute_voices( int mask );
// State // State
// Resets DSP and uses supplied values to initialize registers // Resets DSP and uses supplied values to initialize registers
enum { register_count = 128 }; enum { register_count = 128 };
void load( uint8_t const regs [register_count] ); void load( uint8_t const regs [register_count] );
@ -64,7 +64,7 @@ public:
// Returns non-zero if new key-on events occurred since last call // Returns non-zero if new key-on events occurred since last call
bool check_kon(); bool check_kon();
// DSP register addresses // DSP register addresses
// Global registers // Global registers
@ -96,12 +96,12 @@ public:
void disable_surround( bool ) { } // not supported void disable_surround( bool ) { } // not supported
public: public:
BLARGG_DISABLE_NOTHROW BLARGG_DISABLE_NOTHROW
typedef BOOST::int8_t int8_t; typedef BOOST::int8_t int8_t;
typedef BOOST::int16_t int16_t; typedef BOOST::int16_t int16_t;
enum { echo_hist_size = 8 }; enum { echo_hist_size = 8 };
enum env_mode_t { env_release, env_attack, env_decay, env_sustain }; enum env_mode_t { env_release, env_attack, env_decay, env_sustain };
enum { brr_buf_size = 12 }; enum { brr_buf_size = 12 };
struct voice_t struct voice_t
@ -121,15 +121,15 @@ public:
}; };
private: private:
enum { brr_block_size = 9 }; enum { brr_block_size = 9 };
struct state_t struct state_t
{ {
uint8_t regs [register_count]; uint8_t regs [register_count];
// Echo history keeps most recent 8 samples (twice the size to simplify wrap handling) // Echo history keeps most recent 8 samples (twice the size to simplify wrap handling)
int echo_hist [echo_hist_size * 2] [2]; int echo_hist [echo_hist_size * 2] [2];
int (*echo_hist_pos) [2]; // &echo_hist [0 to 7] int (*echo_hist_pos) [2]; // &echo_hist [0 to 7]
int every_other_sample; // toggles every sample int every_other_sample; // toggles every sample
int kon; // KON value when last checked int kon; // KON value when last checked
int noise; int noise;
@ -138,22 +138,22 @@ private:
int echo_length; // number of bytes that echo_offset will stop at int echo_length; // number of bytes that echo_offset will stop at
int phase; // next clock cycle to run (0-31) int phase; // next clock cycle to run (0-31)
bool kon_check; // set when a new KON occurs bool kon_check; // set when a new KON occurs
// Hidden registers also written to when main register is written to // Hidden registers also written to when main register is written to
int new_kon; int new_kon;
uint8_t endx_buf; uint8_t endx_buf;
uint8_t envx_buf; uint8_t envx_buf;
uint8_t outx_buf; uint8_t outx_buf;
// Temporary state between clocks // Temporary state between clocks
// read once per sample // read once per sample
int t_pmon; int t_pmon;
int t_non; int t_non;
int t_eon; int t_eon;
int t_dir; int t_dir;
int t_koff; int t_koff;
// read a few clocks ahead then used // read a few clocks ahead then used
int t_brr_next_addr; int t_brr_next_addr;
int t_adsr0; int t_adsr0;
@ -162,21 +162,21 @@ private:
int t_srcn; int t_srcn;
int t_esa; int t_esa;
int t_echo_enabled; int t_echo_enabled;
// internal state that is recalculated every sample // internal state that is recalculated every sample
int t_dir_addr; int t_dir_addr;
int t_pitch; int t_pitch;
int t_output; int t_output;
int t_looped; int t_looped;
int t_echo_ptr; int t_echo_ptr;
// left/right sums // left/right sums
int t_main_out [2]; int t_main_out [2];
int t_echo_out [2]; int t_echo_out [2];
int t_echo_in [2]; int t_echo_in [2];
voice_t voices [voice_count]; voice_t voices [voice_count];
// non-emulation state // non-emulation state
uint8_t* ram; // 64K shared RAM between DSP and SMP uint8_t* ram; // 64K shared RAM between DSP and SMP
int mute_mask; int mute_mask;
@ -186,11 +186,11 @@ private:
sample_t extra [extra_size]; sample_t extra [extra_size];
}; };
state_t m; state_t m;
void init_counter(); void init_counter();
void run_counters(); void run_counters();
unsigned read_counter( int rate ); unsigned read_counter( int rate );
int interpolate( voice_t const* v ); int interpolate( voice_t const* v );
void run_envelope( voice_t* const v ); void run_envelope( voice_t* const v );
void decode_brr( voice_t* v ); void decode_brr( voice_t* v );
@ -229,7 +229,7 @@ private:
void echo_28(); void echo_28();
void echo_29(); void echo_29();
void echo_30(); void echo_30();
void soft_reset_common(); void soft_reset_common();
}; };
@ -246,22 +246,22 @@ inline int SPC_DSP::read( int addr ) const
inline void SPC_DSP::write( int addr, int data ) inline void SPC_DSP::write( int addr, int data )
{ {
assert( (unsigned) addr < register_count ); assert( (unsigned) addr < register_count );
m.regs [addr] = (uint8_t) data; m.regs [addr] = (uint8_t) data;
switch ( addr & 0x0F ) switch ( addr & 0x0F )
{ {
case v_envx: case v_envx:
m.envx_buf = (uint8_t) data; m.envx_buf = (uint8_t) data;
break; break;
case v_outx: case v_outx:
m.outx_buf = (uint8_t) data; m.outx_buf = (uint8_t) data;
break; break;
case 0x0C: case 0x0C:
if ( addr == r_kon ) if ( addr == r_kon )
m.new_kon = (uint8_t) data; m.new_kon = (uint8_t) data;
if ( addr == r_endx ) // always cleared, regardless of data written if ( addr == r_endx ) // always cleared, regardless of data written
{ {
m.endx_buf = 0; m.endx_buf = 0;

View File

@ -158,7 +158,7 @@ public:
typedef struct see_blargg_common_h int8_t; typedef struct see_blargg_common_h int8_t;
typedef struct see_blargg_common_h uint8_t; typedef struct see_blargg_common_h uint8_t;
#endif #endif
#if USHRT_MAX == 0xFFFF #if USHRT_MAX == 0xFFFF
typedef short int16_t; typedef short int16_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
@ -167,7 +167,7 @@ public:
typedef struct see_blargg_common_h int16_t; typedef struct see_blargg_common_h int16_t;
typedef struct see_blargg_common_h uint16_t; typedef struct see_blargg_common_h uint16_t;
#endif #endif
#if ULONG_MAX == 0xFFFFFFFF #if ULONG_MAX == 0xFFFFFFFF
typedef long int32_t; typedef long int32_t;
typedef unsigned long uint32_t; typedef unsigned long uint32_t;

View File

@ -133,7 +133,7 @@ inline void set_be32( void* p, blargg_ulong n )
#define GET_BE32( addr ) (*(BOOST::uint32_t*) (addr)) #define GET_BE32( addr ) (*(BOOST::uint32_t*) (addr))
#define SET_BE16( addr, data ) (void) (*(BOOST::uint16_t*) (addr) = (data)) #define SET_BE16( addr, data ) (void) (*(BOOST::uint16_t*) (addr) = (data))
#define SET_BE32( addr, data ) (void) (*(BOOST::uint32_t*) (addr) = (data)) #define SET_BE32( addr, data ) (void) (*(BOOST::uint32_t*) (addr) = (data))
#if BLARGG_CPU_POWERPC #if BLARGG_CPU_POWERPC
// PowerPC has special byte-reversed instructions // PowerPC has special byte-reversed instructions
#if defined (__MWERKS__) #if defined (__MWERKS__)

View File

@ -65,7 +65,7 @@ DEF_MIN_MAX( double )
// for built-in types, so they take arguments by value // for built-in types, so they take arguments by value
// TODO: remove // TODO: remove
inline int min( int x, int y ) inline int min( int x, int y )
template<class T> template<class T>
inline T min( T x, T y ) inline T min( T x, T y )
{ {

View File

@ -1,5 +1,5 @@
struct Cartridge : property<Cartridge> { struct Cartridge : property<Cartridge> {
struct Mode { struct Mode {
enum e { enum e {
Normal, Normal,
BsxSlotted, BsxSlotted,
@ -8,7 +8,7 @@ struct Cartridge : property<Cartridge> {
SuperGameBoy, SuperGameBoy,
} i; }; } i; };
struct Region { struct Region {
enum e { enum e {
NTSC, NTSC,
PAL, PAL,

View File

@ -103,7 +103,7 @@ bool Cheat::decode(const string &code, unsigned &addr, unsigned &data) {
unsigned Cheat::mirror(unsigned addr) const { unsigned Cheat::mirror(unsigned addr) const {
//$00-3f|80-bf:0000-1fff -> $7e:0000-1fff //$00-3f|80-bf:0000-1fff -> $7e:0000-1fff
if((addr & 0x40e000) == 0x000000) return (0x7e0000 + (addr & 0x1fff)); if((addr & 0x40e000) == 0x000000) return (0x7e0000 + (addr & 0x1fff));
return addr; return addr;
} }

View File

@ -274,7 +274,7 @@ void DSP::power() {
voice[i].t_envx_out = 0; voice[i].t_envx_out = 0;
voice[i].hidden_env = 0; voice[i].hidden_env = 0;
} }
//note: memory is pseudo-random at startup; but internal state is less so //note: memory is pseudo-random at startup; but internal state is less so
//exact differences are unknown. need to separate memory from internal state //exact differences are unknown. need to separate memory from internal state
for(unsigned r = 0; r < 0x80; r++) { for(unsigned r = 0; r < 0x80; r++) {

View File

@ -498,7 +498,7 @@ bool retro_load_game_special(unsigned game_type,
case RETRO_GAME_TYPE_BSX: case RETRO_GAME_TYPE_BSX:
return num_info == 2 && snes_load_cartridge_bsx(info[0].meta, (const uint8_t*)info[0].data, info[0].size, return num_info == 2 && snes_load_cartridge_bsx(info[0].meta, (const uint8_t*)info[0].data, info[0].size,
info[1].meta, (const uint8_t*)info[1].data, info[1].size); info[1].meta, (const uint8_t*)info[1].data, info[1].size);
case RETRO_GAME_TYPE_BSX_SLOTTED: case RETRO_GAME_TYPE_BSX_SLOTTED:
return num_info == 2 && snes_load_cartridge_bsx_slotted(info[0].meta, (const uint8_t*)info[0].data, info[0].size, return num_info == 2 && snes_load_cartridge_bsx_slotted(info[0].meta, (const uint8_t*)info[0].data, info[0].size,
info[1].meta, (const uint8_t*)info[1].data, info[1].size); info[1].meta, (const uint8_t*)info[1].data, info[1].size);

File diff suppressed because it is too large Load Diff

View File

@ -46,7 +46,7 @@ void SMPcore::op_cbne_dpx() {
if(regs.a == sp) return; if(regs.a == sp) return;
op_io(); op_io();
op_io(); op_io();
regs.pc += (int8)rd; regs.pc += (int8)rd;
} }
void SMPcore::op_dbnz_dp() { void SMPcore::op_dbnz_dp() {