mirror of
https://github.com/libretro/bsnes-libretro-cplusplus98.git
synced 2025-04-13 15:40:27 +00:00
Merge pull request #19 from orbea/whitespace
Remove trailing white space.
This commit is contained in:
commit
4932c46ec8
3
Makefile
3
Makefile
@ -103,7 +103,6 @@ all: library;
|
||||
|
||||
include gameboy/Makefile
|
||||
|
||||
|
||||
set-static:
|
||||
ifneq ($(platform),win)
|
||||
$(eval fpic := )
|
||||
@ -114,7 +113,7 @@ static: set-static static-library;
|
||||
%.o: $<; $(call compile)
|
||||
include $(snes)/Makefile
|
||||
|
||||
clean:
|
||||
clean:
|
||||
rm -f obj/*.o
|
||||
rm -f obj/*.a
|
||||
rm -f obj/*.so
|
||||
|
@ -24,7 +24,7 @@ asm (
|
||||
".globl co_switch_arm\n"
|
||||
".globl _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"
|
||||
" ldmia r0!, {r4, r5, r6, r7, r8, r9, r10, r11, sp, pc}\n"
|
||||
);
|
||||
|
42
libco/ppc.c
42
libco/ppc.c
@ -56,7 +56,7 @@ or are directly to function */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
|
||||
/* Swap code is in ppc.S */
|
||||
void co_swap_asm( cothread_t, cothread_t );
|
||||
#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 )
|
||||
{
|
||||
uint32_t* t = (uint32_t*) malloc( size );
|
||||
|
||||
|
||||
(void) entry;
|
||||
|
||||
|
||||
#if LIBCO_PPCDESC
|
||||
if ( t )
|
||||
{
|
||||
/* Copy entry's descriptor */
|
||||
memcpy( t, (void*) entry, sizeof (void*) * 3 );
|
||||
|
||||
|
||||
/* Set function pointer to swap routine */
|
||||
#ifdef LIBCO_PPC_ASM
|
||||
*(const void**) t = *(void**) &co_swap_asm;
|
||||
@ -302,7 +302,7 @@ static uint32_t* co_create_( unsigned size, uintptr_t entry )
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@ -310,38 +310,38 @@ cothread_t co_create( unsigned int size, void (*entry_)( void ) )
|
||||
{
|
||||
uintptr_t entry = (uintptr_t) entry_;
|
||||
uint32_t* t = NULL;
|
||||
|
||||
|
||||
/* Be sure main thread was successfully allocated */
|
||||
if ( co_active() )
|
||||
{
|
||||
size += state_size + above_stack + stack_align;
|
||||
t = co_create_( size, entry );
|
||||
}
|
||||
|
||||
|
||||
if ( t )
|
||||
{
|
||||
uintptr_t sp;
|
||||
int shift;
|
||||
|
||||
|
||||
/* Save current registers into new thread, so that any special ones will
|
||||
have proper values when thread is begun */
|
||||
CO_SWAP_ASM( t, t );
|
||||
|
||||
|
||||
#if LIBCO_PPCDESC
|
||||
/* Get real address */
|
||||
entry = (uintptr_t) *(void**) entry;
|
||||
#endif
|
||||
|
||||
|
||||
/* Put stack near end of block, and align */
|
||||
sp = (uintptr_t) t + size - above_stack;
|
||||
sp -= sp % stack_align;
|
||||
|
||||
|
||||
/* 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
|
||||
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,
|
||||
we must put the low byte first on PPC32. */
|
||||
|
||||
|
||||
/* 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. */
|
||||
#if LIBCO_PPC64
|
||||
@ -349,15 +349,15 @@ cothread_t co_create( unsigned int size, void (*entry_)( void ) )
|
||||
#else
|
||||
shift = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/* Set up so entry will be called on next swap */
|
||||
t [8] = (uint32_t) (entry >> shift >> shift);
|
||||
t [9] = (uint32_t) entry;
|
||||
|
||||
t [10] = (uint32_t) (sp >> shift >> shift);
|
||||
|
||||
t [10] = (uint32_t) (sp >> shift >> shift);
|
||||
t [11] = (uint32_t) sp;
|
||||
}
|
||||
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@ -377,16 +377,16 @@ static void co_init_( void )
|
||||
uintptr_t align = page_size;
|
||||
uintptr_t begin = (uintptr_t) libco_ppc_code;
|
||||
uintptr_t end = begin + sizeof libco_ppc_code;
|
||||
|
||||
|
||||
/* Align beginning and end */
|
||||
end += align - 1;
|
||||
end -= end % align;
|
||||
begin -= begin % align;
|
||||
|
||||
|
||||
mprotect( (void*) begin, end - begin, PROT_READ | PROT_WRITE | PROT_EXEC );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
co_active_handle = co_create_( state_size, (uintptr_t) &co_switch );
|
||||
}
|
||||
|
||||
@ -394,7 +394,7 @@ cothread_t co_active()
|
||||
{
|
||||
if ( !co_active_handle )
|
||||
co_init_();
|
||||
|
||||
|
||||
return co_active_handle;
|
||||
}
|
||||
|
||||
@ -402,6 +402,6 @@ void co_switch( cothread_t t )
|
||||
{
|
||||
cothread_t old = co_active_handle;
|
||||
co_active_handle = t;
|
||||
|
||||
|
||||
CO_SWAP_ASM( t, old );
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ typedef float resample_samp_t;
|
||||
|
||||
|
||||
// ...but don't comment this single RESAMPLE_SSEREGPARM define out when disabling SSE.
|
||||
#define RESAMPLE_SSEREGPARM
|
||||
#define RESAMPLE_SSEREGPARM
|
||||
|
||||
#if defined(__SSE__)
|
||||
#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
|
||||
__m128 accum_veca[2] = { _mm_set1_ps(0), _mm_set1_ps(0) };
|
||||
|
||||
|
||||
resample_samp_t accum;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
assert( size % 2 == 0 ); // size must be even
|
||||
|
||||
|
||||
int const half_size = size / 2;
|
||||
double* const mid = &out [half_size];
|
||||
|
||||
|
||||
// Generate right half of sinc
|
||||
for ( int i = 0; i < half_size; i++ )
|
||||
{
|
||||
double angle = (i * 2 + 1) * (M_PI / 2);
|
||||
mid [i] = sin( angle * cutoff ) / angle;
|
||||
}
|
||||
|
||||
|
||||
kaiser_window( mid, half_size, kaiser );
|
||||
|
||||
|
||||
// Mirror for left half
|
||||
for ( int i = 0; i < half_size; 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)
|
||||
{
|
||||
assert( size % 2 == 1); // size must be odd
|
||||
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
if(i == (size / 2))
|
||||
|
@ -81,7 +81,7 @@ namespace nall {
|
||||
|
||||
template<typename T1>
|
||||
inline string(T1 const &);
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline string(T1 const &, T2 const &);
|
||||
|
||||
@ -143,7 +143,7 @@ namespace nall {
|
||||
inline void qsplit(const char*, const char*, unsigned = 0);
|
||||
|
||||
lstring();
|
||||
|
||||
|
||||
lstring(const string &);
|
||||
lstring(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 &, 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;
|
||||
|
||||
|
@ -35,7 +35,7 @@ ifneq ($(GIT_VERSION)," unknown")
|
||||
extraflags += -DGIT_VERSION=\"$(GIT_VERSION)\"
|
||||
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/*
|
||||
|
||||
|
@ -141,7 +141,7 @@ inline int SPC_DSP::interpolate( voice_t const* v )
|
||||
int offset = v->interp_pos >> 4 & 0xFF;
|
||||
short const* fwd = gauss + 255 - offset;
|
||||
short const* rev = gauss + offset; // mirror left half of gaussian
|
||||
|
||||
|
||||
int const* in = &v->buf [(v->interp_pos >> 12) + v->buf_pos];
|
||||
int out;
|
||||
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 = (int16_t) out;
|
||||
out += (rev [ 0] * in [3]) >> 11;
|
||||
|
||||
|
||||
CLAMP16( out );
|
||||
out &= ~1;
|
||||
return out;
|
||||
@ -271,13 +271,13 @@ inline void SPC_DSP::run_envelope( voice_t* const v )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Sustain level
|
||||
if ( (env >> 8) == (env_data >> 5) && v->env_mode == env_decay )
|
||||
v->env_mode = env_sustain;
|
||||
|
||||
|
||||
v->hidden_env = env;
|
||||
|
||||
|
||||
// unsigned cast because linear decrease going negative also triggers this
|
||||
if ( (unsigned) env > 0x7FF )
|
||||
{
|
||||
@ -285,7 +285,7 @@ inline void SPC_DSP::run_envelope( voice_t* const v )
|
||||
if ( v->env_mode == env_attack )
|
||||
v->env_mode = env_decay;
|
||||
}
|
||||
|
||||
|
||||
if ( !read_counter( rate ) )
|
||||
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
|
||||
int nybbles = m.t_brr_byte * 0x100 + m.ram [(v->brr_addr + v->brr_offset + 1) & 0xFFFF];
|
||||
|
||||
|
||||
int const header = m.t_brr_header;
|
||||
|
||||
|
||||
// Write to next four samples in circular buffer
|
||||
int* pos = &v->buf [v->buf_pos];
|
||||
int* end;
|
||||
if ( (v->buf_pos += 4) >= brr_buf_size )
|
||||
v->buf_pos = 0;
|
||||
|
||||
|
||||
// Decode four samples
|
||||
for ( end = pos + 4; pos < end; pos++, nybbles <<= 4 )
|
||||
{
|
||||
// Extract nybble and sign-extend
|
||||
int s = (int16_t) nybbles >> 12;
|
||||
|
||||
|
||||
// Shift sample based on header
|
||||
int const shift = header >> 4;
|
||||
s = (s << shift) >> 1;
|
||||
if ( shift >= 0xD ) // handle invalid range
|
||||
s = (s >> 25) << 11; // same as: s = (s < 0 ? -0x800 : 0)
|
||||
|
||||
|
||||
// Apply IIR filter (8 is the most commonly used)
|
||||
int const filter = header & 0x0C;
|
||||
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) >> 5;
|
||||
}
|
||||
|
||||
|
||||
// Adjust and write sample
|
||||
CLAMP16( s );
|
||||
s = (int16_t) (s * 2);
|
||||
@ -376,11 +376,11 @@ MISC_CLOCK( 30 )
|
||||
if ( m.every_other_sample )
|
||||
{
|
||||
m.kon = m.new_kon;
|
||||
m.t_koff = REG(koff) | m.mute_mask;
|
||||
m.t_koff = REG(koff) | m.mute_mask;
|
||||
}
|
||||
|
||||
|
||||
run_counters();
|
||||
|
||||
|
||||
// Noise
|
||||
if ( !read_counter( REG(flg) & 0x1F ) )
|
||||
{
|
||||
@ -406,9 +406,9 @@ inline VOICE_CLOCK( V2 )
|
||||
if ( !v->kon_delay )
|
||||
entry += 2;
|
||||
m.t_brr_next_addr = GET_LE16A( entry );
|
||||
|
||||
|
||||
m.t_adsr0 = VREG(v->regs,adsr0);
|
||||
|
||||
|
||||
// Read pitch, spread over two clocks
|
||||
m.t_pitch = VREG(v->regs,pitchl);
|
||||
}
|
||||
@ -427,7 +427,7 @@ VOICE_CLOCK( V3c )
|
||||
// Pitch modulation using previous voice's output
|
||||
if ( m.t_pmon & v->vbit )
|
||||
m.t_pitch += ((m.t_output >> 5) * m.t_pitch) >> 10;
|
||||
|
||||
|
||||
if ( v->kon_delay )
|
||||
{
|
||||
// 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.kon_check = true;
|
||||
}
|
||||
|
||||
|
||||
// Envelope is never run during KON
|
||||
v->env = 0;
|
||||
v->hidden_env = 0;
|
||||
|
||||
|
||||
// Disable BRR decoding until last three samples
|
||||
v->interp_pos = 0;
|
||||
if ( --v->kon_delay & 3 )
|
||||
v->interp_pos = 0x4000;
|
||||
|
||||
|
||||
// Pitch is never added during KON
|
||||
m.t_pitch = 0;
|
||||
}
|
||||
|
||||
|
||||
// Gaussian interpolation
|
||||
{
|
||||
int output = interpolate( v );
|
||||
|
||||
|
||||
// Noise
|
||||
if ( m.t_non & v->vbit )
|
||||
output = (int16_t) (m.noise * 2);
|
||||
|
||||
|
||||
// Apply envelope
|
||||
m.t_output = (output * v->env) >> 11 & ~1;
|
||||
v->t_envx_out = (uint8_t) (v->env >> 4);
|
||||
}
|
||||
|
||||
|
||||
// Immediate silence due to end of sample or soft reset
|
||||
if ( REG(flg) & 0x80 || (m.t_brr_header & 3) == 1 )
|
||||
{
|
||||
v->env_mode = env_release;
|
||||
v->env = 0;
|
||||
}
|
||||
|
||||
|
||||
if ( m.every_other_sample )
|
||||
{
|
||||
// KOFF
|
||||
if ( m.t_koff & v->vbit )
|
||||
v->env_mode = env_release;
|
||||
|
||||
|
||||
// KON
|
||||
if ( m.kon & v->vbit )
|
||||
{
|
||||
@ -486,7 +486,7 @@ VOICE_CLOCK( V3c )
|
||||
v->env_mode = env_attack;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Run envelope for next sample
|
||||
if ( !v->kon_delay )
|
||||
run_envelope( v );
|
||||
@ -495,11 +495,11 @@ inline void SPC_DSP::voice_output( voice_t const* v, int ch )
|
||||
{
|
||||
// Apply left/right volume
|
||||
int amp = (m.t_output * (int8_t) VREG(v->regs,voll + ch)) >> 7;
|
||||
|
||||
|
||||
// Add to output total
|
||||
m.t_main_out [ch] += amp;
|
||||
CLAMP16( m.t_main_out [ch] );
|
||||
|
||||
|
||||
// Optionally add to echo total
|
||||
if ( m.t_eon & v->vbit )
|
||||
{
|
||||
@ -514,7 +514,7 @@ VOICE_CLOCK( V4 )
|
||||
if ( v->interp_pos >= 0x4000 )
|
||||
{
|
||||
decode_brr( v );
|
||||
|
||||
|
||||
if ( (v->brr_offset += 2) >= brr_block_size )
|
||||
{
|
||||
// Start decoding next BRR block
|
||||
@ -528,14 +528,14 @@ VOICE_CLOCK( V4 )
|
||||
v->brr_offset = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Apply pitch
|
||||
v->interp_pos = (v->interp_pos & 0x3FFF) + m.t_pitch;
|
||||
|
||||
|
||||
// Keep from getting too far ahead (when using pitch modulation)
|
||||
if ( v->interp_pos > 0x7FFF )
|
||||
v->interp_pos = 0x7FFF;
|
||||
|
||||
|
||||
// Output left
|
||||
voice_output( v, 0 );
|
||||
}
|
||||
@ -543,10 +543,10 @@ inline VOICE_CLOCK( V5 )
|
||||
{
|
||||
// Output right
|
||||
voice_output( v, 1 );
|
||||
|
||||
|
||||
// ENDX, OUTX, and ENVX won't update if you wrote to them 1-2 clocks earlier
|
||||
int endx_buf = REG(endx) | m.t_looped;
|
||||
|
||||
|
||||
// Clear bit in ENDX if KON just began
|
||||
if ( v->kon_delay == 5 )
|
||||
endx_buf &= ~v->vbit;
|
||||
@ -561,7 +561,7 @@ inline VOICE_CLOCK( V7 )
|
||||
{
|
||||
// Update ENDX
|
||||
REG(endx) = m.endx_buf;
|
||||
|
||||
|
||||
m.envx_buf = v->t_envx_out;
|
||||
}
|
||||
inline VOICE_CLOCK( V8 )
|
||||
@ -615,14 +615,14 @@ ECHO_CLOCK( 22 )
|
||||
// History
|
||||
if ( ++m.echo_hist_pos >= &m.echo_hist [echo_hist_size] )
|
||||
m.echo_hist_pos = m.echo_hist;
|
||||
|
||||
|
||||
m.t_echo_ptr = (m.t_esa * 0x100 + m.echo_offset) & 0xFFFF;
|
||||
echo_read( 0 );
|
||||
|
||||
|
||||
// FIR (using l and r temporaries below helps compiler optimize)
|
||||
int l = CALC_FIR( 0, 0 );
|
||||
int r = CALC_FIR( 0, 1 );
|
||||
|
||||
|
||||
m.t_echo_in [0] = l;
|
||||
m.t_echo_in [1] = r;
|
||||
}
|
||||
@ -630,17 +630,17 @@ ECHO_CLOCK( 23 )
|
||||
{
|
||||
int l = CALC_FIR( 1, 0 ) + CALC_FIR( 2, 0 );
|
||||
int r = CALC_FIR( 1, 1 ) + CALC_FIR( 2, 1 );
|
||||
|
||||
|
||||
m.t_echo_in [0] += l;
|
||||
m.t_echo_in [1] += r;
|
||||
|
||||
|
||||
echo_read( 1 );
|
||||
}
|
||||
ECHO_CLOCK( 24 )
|
||||
{
|
||||
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 );
|
||||
|
||||
|
||||
m.t_echo_in [0] += l;
|
||||
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 r = m.t_echo_in [1] + CALC_FIR( 6, 1 );
|
||||
|
||||
|
||||
l = (int16_t) l;
|
||||
r = (int16_t) r;
|
||||
|
||||
|
||||
l += (int16_t) CALC_FIR( 7, 0 );
|
||||
r += (int16_t) CALC_FIR( 7, 1 );
|
||||
|
||||
|
||||
CLAMP16( l );
|
||||
CLAMP16( r );
|
||||
|
||||
|
||||
m.t_echo_in [0] = l & ~1;
|
||||
m.t_echo_in [1] = r & ~1;
|
||||
}
|
||||
@ -673,14 +673,14 @@ ECHO_CLOCK( 26 )
|
||||
// Left output volumes
|
||||
// (save sample for next clock so we can output both together)
|
||||
m.t_main_out [0] = echo_output( 0 );
|
||||
|
||||
|
||||
// Echo feedback
|
||||
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);
|
||||
|
||||
|
||||
CLAMP16( l );
|
||||
CLAMP16( r );
|
||||
|
||||
|
||||
m.t_echo_out [0] = l & ~1;
|
||||
m.t_echo_out [1] = r & ~1;
|
||||
}
|
||||
@ -691,7 +691,7 @@ ECHO_CLOCK( 27 )
|
||||
int r = echo_output( 1 );
|
||||
m.t_main_out [0] = 0;
|
||||
m.t_main_out [1] = 0;
|
||||
|
||||
|
||||
// TODO: global muting isn't this simple (turns DAC on and off
|
||||
// or something, causing small ~37-sample pulse when first muted)
|
||||
if ( REG(flg) & 0x40 )
|
||||
@ -699,7 +699,7 @@ ECHO_CLOCK( 27 )
|
||||
l = 0;
|
||||
r = 0;
|
||||
}
|
||||
|
||||
|
||||
// Output sample to DAC
|
||||
#ifdef SPC_DSP_OUT_HOOK
|
||||
SPC_DSP_OUT_HOOK( l, r );
|
||||
@ -722,17 +722,17 @@ inline void SPC_DSP::echo_write( int ch )
|
||||
ECHO_CLOCK( 29 )
|
||||
{
|
||||
m.t_esa = REG(esa);
|
||||
|
||||
|
||||
if ( !m.echo_offset )
|
||||
m.echo_length = (REG(edl) & 0x0F) * 0x800;
|
||||
|
||||
|
||||
m.echo_offset += 4;
|
||||
if ( m.echo_offset >= m.echo_length )
|
||||
m.echo_offset = 0;
|
||||
|
||||
|
||||
// Write left echo
|
||||
echo_write( 0 );
|
||||
|
||||
|
||||
m.t_echo_enabled = REG(flg);
|
||||
}
|
||||
ECHO_CLOCK( 30 )
|
||||
@ -795,17 +795,17 @@ PHASE(31) V(V4,0) V(V1,2)\
|
||||
void SPC_DSP::run( int clocks_remain )
|
||||
{
|
||||
require( clocks_remain > 0 );
|
||||
|
||||
|
||||
int const phase = m.phase;
|
||||
m.phase = (phase + clocks_remain) & 31;
|
||||
switch ( phase )
|
||||
{
|
||||
loop:
|
||||
|
||||
|
||||
#define PHASE( n ) if ( n && !--clocks_remain ) break; case n:
|
||||
GEN_DSP_TIMING
|
||||
#undef PHASE
|
||||
|
||||
|
||||
if ( --clocks_remain )
|
||||
goto loop;
|
||||
}
|
||||
@ -823,19 +823,19 @@ void SPC_DSP::init( void* ram_64k )
|
||||
disable_surround( false );
|
||||
set_output( 0, 0 );
|
||||
reset();
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
// be sure this sign-extends
|
||||
assert( (int16_t) 0x8000 == -0x8000 );
|
||||
|
||||
|
||||
// be sure right shift preserves sign
|
||||
assert( (-1 >> 1) == -1 );
|
||||
|
||||
|
||||
// check clamp macro
|
||||
int i;
|
||||
i = +0x8000; CLAMP16( i ); assert( i == +0x7FFF );
|
||||
i = -0x8001; CLAMP16( i ); assert( i == -0x8000 );
|
||||
|
||||
|
||||
blargg_verify_byte_order();
|
||||
#endif
|
||||
}
|
||||
@ -843,13 +843,13 @@ void SPC_DSP::init( void* ram_64k )
|
||||
void SPC_DSP::soft_reset_common()
|
||||
{
|
||||
require( m.ram ); // init() must have been called already
|
||||
|
||||
|
||||
m.noise = 0x4000;
|
||||
m.echo_hist_pos = m.echo_hist;
|
||||
m.every_other_sample = 1;
|
||||
m.echo_offset = 0;
|
||||
m.phase = 0;
|
||||
|
||||
|
||||
init_counter();
|
||||
}
|
||||
|
||||
@ -863,7 +863,7 @@ void SPC_DSP::load( uint8_t const regs [register_count] )
|
||||
{
|
||||
memcpy( m.regs, regs, sizeof m.regs );
|
||||
memset( &m.regs [register_count], 0, offsetof (state_t,ram) - register_count );
|
||||
|
||||
|
||||
// Internal state
|
||||
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.t_dir = REG(dir);
|
||||
m.t_esa = REG(esa);
|
||||
|
||||
|
||||
soft_reset_common();
|
||||
}
|
||||
|
||||
@ -928,18 +928,18 @@ void SPC_State_Copier::extra()
|
||||
void SPC_DSP::copy_state( unsigned char** io, copy_func_t copy )
|
||||
{
|
||||
SPC_State_Copier copier( io, copy );
|
||||
|
||||
|
||||
// DSP registers
|
||||
copier.copy( m.regs, register_count );
|
||||
|
||||
|
||||
// Internal state
|
||||
|
||||
|
||||
// Voices
|
||||
int i;
|
||||
for ( i = 0; i < voice_count; i++ )
|
||||
{
|
||||
voice_t* v = &m.voices [i];
|
||||
|
||||
|
||||
// BRR buffer
|
||||
int 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 );
|
||||
v->buf [i] = v->buf [i + brr_buf_size] = s;
|
||||
}
|
||||
|
||||
|
||||
SPC_COPY( uint16_t, v->interp_pos );
|
||||
SPC_COPY( uint16_t, v->brr_addr );
|
||||
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;
|
||||
}
|
||||
SPC_COPY( uint8_t, v->t_envx_out );
|
||||
|
||||
|
||||
copier.extra();
|
||||
}
|
||||
|
||||
|
||||
// Echo history
|
||||
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;
|
||||
memcpy( &m.echo_hist [echo_hist_size], m.echo_hist, echo_hist_size * sizeof m.echo_hist [0] );
|
||||
|
||||
|
||||
// Misc
|
||||
SPC_COPY( uint8_t, m.every_other_sample );
|
||||
SPC_COPY( uint8_t, m.kon );
|
||||
|
||||
|
||||
SPC_COPY( uint16_t, m.noise );
|
||||
SPC_COPY( uint16_t, m.counter );
|
||||
SPC_COPY( uint16_t, m.echo_offset );
|
||||
SPC_COPY( uint16_t, m.echo_length );
|
||||
SPC_COPY( uint8_t, m.phase );
|
||||
|
||||
|
||||
SPC_COPY( uint8_t, m.new_kon );
|
||||
SPC_COPY( uint8_t, m.endx_buf );
|
||||
SPC_COPY( uint8_t, m.envx_buf );
|
||||
SPC_COPY( uint8_t, m.outx_buf );
|
||||
|
||||
|
||||
SPC_COPY( uint8_t, m.t_pmon );
|
||||
SPC_COPY( uint8_t, m.t_non );
|
||||
SPC_COPY( uint8_t, m.t_eon );
|
||||
SPC_COPY( uint8_t, m.t_dir );
|
||||
SPC_COPY( uint8_t, m.t_koff );
|
||||
|
||||
|
||||
SPC_COPY( uint16_t, m.t_brr_next_addr );
|
||||
SPC_COPY( uint8_t, m.t_adsr0 );
|
||||
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_esa );
|
||||
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 [1] );
|
||||
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_in [0] );
|
||||
SPC_COPY( int16_t, m.t_echo_in [1] );
|
||||
|
||||
|
||||
SPC_COPY( uint16_t, m.t_dir_addr );
|
||||
SPC_COPY( uint16_t, m.t_pitch );
|
||||
SPC_COPY( int16_t, m.t_output );
|
||||
SPC_COPY( uint16_t, m.t_echo_ptr );
|
||||
SPC_COPY( uint8_t, m.t_looped );
|
||||
|
||||
|
||||
copier.extra();
|
||||
}
|
||||
#endif
|
||||
|
@ -11,7 +11,7 @@ extern "C" { typedef void (*dsp_copy_func_t)( unsigned char** io, void* state, s
|
||||
class SPC_DSP {
|
||||
public:
|
||||
typedef BOOST::uint8_t uint8_t;
|
||||
|
||||
|
||||
// Setup
|
||||
|
||||
// Initializes DSP and has it use the 64K RAM provided
|
||||
@ -34,7 +34,7 @@ public:
|
||||
|
||||
// Emulates pressing reset switch on SNES
|
||||
void soft_reset();
|
||||
|
||||
|
||||
// Reads/writes DSP registers. For accuracy, you must first call run()
|
||||
// to catch the DSP up to present.
|
||||
int read ( int addr ) const;
|
||||
@ -43,7 +43,7 @@ public:
|
||||
// Runs DSP for specified number of clocks (~1024000 per second). Every 32 clocks
|
||||
// a pair of samples is be generated.
|
||||
void run( int clock_count );
|
||||
|
||||
|
||||
// Sound control
|
||||
|
||||
// Mutes voices corresponding to non-zero bits in mask (issues repeated KOFF events).
|
||||
@ -52,7 +52,7 @@ public:
|
||||
void mute_voices( int mask );
|
||||
|
||||
// State
|
||||
|
||||
|
||||
// Resets DSP and uses supplied values to initialize registers
|
||||
enum { register_count = 128 };
|
||||
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
|
||||
bool check_kon();
|
||||
|
||||
|
||||
// DSP register addresses
|
||||
|
||||
// Global registers
|
||||
@ -96,12 +96,12 @@ public:
|
||||
void disable_surround( bool ) { } // not supported
|
||||
public:
|
||||
BLARGG_DISABLE_NOTHROW
|
||||
|
||||
|
||||
typedef BOOST::int8_t int8_t;
|
||||
typedef BOOST::int16_t int16_t;
|
||||
|
||||
|
||||
enum { echo_hist_size = 8 };
|
||||
|
||||
|
||||
enum env_mode_t { env_release, env_attack, env_decay, env_sustain };
|
||||
enum { brr_buf_size = 12 };
|
||||
struct voice_t
|
||||
@ -121,15 +121,15 @@ public:
|
||||
};
|
||||
private:
|
||||
enum { brr_block_size = 9 };
|
||||
|
||||
|
||||
struct state_t
|
||||
{
|
||||
uint8_t regs [register_count];
|
||||
|
||||
|
||||
// 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_pos) [2]; // &echo_hist [0 to 7]
|
||||
|
||||
|
||||
int every_other_sample; // toggles every sample
|
||||
int kon; // KON value when last checked
|
||||
int noise;
|
||||
@ -138,22 +138,22 @@ private:
|
||||
int echo_length; // number of bytes that echo_offset will stop at
|
||||
int phase; // next clock cycle to run (0-31)
|
||||
bool kon_check; // set when a new KON occurs
|
||||
|
||||
|
||||
// Hidden registers also written to when main register is written to
|
||||
int new_kon;
|
||||
uint8_t endx_buf;
|
||||
uint8_t envx_buf;
|
||||
uint8_t outx_buf;
|
||||
|
||||
|
||||
// Temporary state between clocks
|
||||
|
||||
|
||||
// read once per sample
|
||||
int t_pmon;
|
||||
int t_non;
|
||||
int t_eon;
|
||||
int t_dir;
|
||||
int t_koff;
|
||||
|
||||
|
||||
// read a few clocks ahead then used
|
||||
int t_brr_next_addr;
|
||||
int t_adsr0;
|
||||
@ -162,21 +162,21 @@ private:
|
||||
int t_srcn;
|
||||
int t_esa;
|
||||
int t_echo_enabled;
|
||||
|
||||
|
||||
// internal state that is recalculated every sample
|
||||
int t_dir_addr;
|
||||
int t_pitch;
|
||||
int t_output;
|
||||
int t_looped;
|
||||
int t_echo_ptr;
|
||||
|
||||
|
||||
// left/right sums
|
||||
int t_main_out [2];
|
||||
int t_echo_out [2];
|
||||
int t_echo_in [2];
|
||||
|
||||
|
||||
voice_t voices [voice_count];
|
||||
|
||||
|
||||
// non-emulation state
|
||||
uint8_t* ram; // 64K shared RAM between DSP and SMP
|
||||
int mute_mask;
|
||||
@ -186,11 +186,11 @@ private:
|
||||
sample_t extra [extra_size];
|
||||
};
|
||||
state_t m;
|
||||
|
||||
|
||||
void init_counter();
|
||||
void run_counters();
|
||||
unsigned read_counter( int rate );
|
||||
|
||||
|
||||
int interpolate( voice_t const* v );
|
||||
void run_envelope( voice_t* const v );
|
||||
void decode_brr( voice_t* v );
|
||||
@ -229,7 +229,7 @@ private:
|
||||
void echo_28();
|
||||
void echo_29();
|
||||
void echo_30();
|
||||
|
||||
|
||||
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 )
|
||||
{
|
||||
assert( (unsigned) addr < register_count );
|
||||
|
||||
|
||||
m.regs [addr] = (uint8_t) data;
|
||||
switch ( addr & 0x0F )
|
||||
{
|
||||
case v_envx:
|
||||
m.envx_buf = (uint8_t) data;
|
||||
break;
|
||||
|
||||
|
||||
case v_outx:
|
||||
m.outx_buf = (uint8_t) data;
|
||||
break;
|
||||
|
||||
|
||||
case 0x0C:
|
||||
if ( addr == r_kon )
|
||||
m.new_kon = (uint8_t) data;
|
||||
|
||||
|
||||
if ( addr == r_endx ) // always cleared, regardless of data written
|
||||
{
|
||||
m.endx_buf = 0;
|
||||
|
@ -158,7 +158,7 @@ public:
|
||||
typedef struct see_blargg_common_h int8_t;
|
||||
typedef struct see_blargg_common_h uint8_t;
|
||||
#endif
|
||||
|
||||
|
||||
#if USHRT_MAX == 0xFFFF
|
||||
typedef short int16_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 uint16_t;
|
||||
#endif
|
||||
|
||||
|
||||
#if ULONG_MAX == 0xFFFFFFFF
|
||||
typedef long int32_t;
|
||||
typedef unsigned long uint32_t;
|
||||
|
@ -133,7 +133,7 @@ inline void set_be32( void* p, blargg_ulong n )
|
||||
#define GET_BE32( addr ) (*(BOOST::uint32_t*) (addr))
|
||||
#define SET_BE16( addr, data ) (void) (*(BOOST::uint16_t*) (addr) = (data))
|
||||
#define SET_BE32( addr, data ) (void) (*(BOOST::uint32_t*) (addr) = (data))
|
||||
|
||||
|
||||
#if BLARGG_CPU_POWERPC
|
||||
// PowerPC has special byte-reversed instructions
|
||||
#if defined (__MWERKS__)
|
||||
|
@ -65,7 +65,7 @@ DEF_MIN_MAX( double )
|
||||
// for built-in types, so they take arguments by value
|
||||
|
||||
// TODO: remove
|
||||
inline int min( int x, int y )
|
||||
inline int min( int x, int y )
|
||||
template<class T>
|
||||
inline T min( T x, T y )
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
struct Cartridge : property<Cartridge> {
|
||||
struct Mode {
|
||||
struct Mode {
|
||||
enum e {
|
||||
Normal,
|
||||
BsxSlotted,
|
||||
@ -8,7 +8,7 @@ struct Cartridge : property<Cartridge> {
|
||||
SuperGameBoy,
|
||||
} i; };
|
||||
|
||||
struct Region {
|
||||
struct Region {
|
||||
enum e {
|
||||
NTSC,
|
||||
PAL,
|
||||
|
@ -103,7 +103,7 @@ bool Cheat::decode(const string &code, unsigned &addr, unsigned &data) {
|
||||
|
||||
unsigned Cheat::mirror(unsigned addr) const {
|
||||
//$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;
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ void DSP::power() {
|
||||
voice[i].t_envx_out = 0;
|
||||
voice[i].hidden_env = 0;
|
||||
}
|
||||
|
||||
|
||||
//note: memory is pseudo-random at startup; but internal state is less so
|
||||
//exact differences are unknown. need to separate memory from internal state
|
||||
for(unsigned r = 0; r < 0x80; r++) {
|
||||
|
@ -498,7 +498,7 @@ bool retro_load_game_special(unsigned game_type,
|
||||
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,
|
||||
info[1].meta, (const uint8_t*)info[1].data, info[1].size);
|
||||
|
||||
|
||||
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,
|
||||
info[1].meta, (const uint8_t*)info[1].data, info[1].size);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,7 @@ void SMPcore::op_cbne_dpx() {
|
||||
if(regs.a == sp) return;
|
||||
op_io();
|
||||
op_io();
|
||||
regs.pc += (int8)rd;
|
||||
regs.pc += (int8)rd;
|
||||
}
|
||||
|
||||
void SMPcore::op_dbnz_dp() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user