From aef91917f7ae66da1e93e1f4c1b21f5b2555ad35 Mon Sep 17 00:00:00 2001 From: João Silva Date: Wed, 16 Aug 2017 17:59:11 +0100 Subject: Changed compile-time flags to use C89 and fixed new warnings raised. --- source/apu_blargg.c | 68 ++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) (limited to 'source/apu_blargg.c') diff --git a/source/apu_blargg.c b/source/apu_blargg.c index a89a905..d87d8d3 100644 --- a/source/apu_blargg.c +++ b/source/apu_blargg.c @@ -8,9 +8,7 @@ #include #include -#ifdef PSP -#define inline __attribute((force_inline)) -#endif +#include #include "blargg_endian.h" #include "apu_blargg.h" @@ -103,7 +101,7 @@ static int16_t gauss [512] = /* Gaussian interpolation */ -static inline int32_t dsp_interpolate( dsp_voice_t *v ) +static INLINE int32_t dsp_interpolate( dsp_voice_t *v ) { int32_t offset, out, *in; int16_t *fwd, *rev; @@ -171,7 +169,7 @@ static uint32_t const counter_offsets [32] = /* Envelope */ -static inline void dsp_run_envelope( dsp_voice_t* const v ) +static INLINE void dsp_run_envelope( dsp_voice_t* const v ) { int32_t env, rate, env_data; @@ -245,7 +243,7 @@ static inline void dsp_run_envelope( dsp_voice_t* const v ) /* BRR Decoding */ -static inline void dsp_decode_brr( dsp_voice_t* v ) +static INLINE void dsp_decode_brr( dsp_voice_t* v ) { int32_t nybbles, *pos, *end, header; @@ -320,7 +318,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() +static INLINE void dsp_misc_30() { if ( dsp_m.every_other_sample ) { @@ -340,13 +338,13 @@ static inline void dsp_misc_30() /* Voices */ -static inline void dsp_voice_V1( dsp_voice_t* const v ) +static INLINE void dsp_voice_V1( dsp_voice_t* const v ) { dsp_m.t_dir_addr = dsp_m.t_dir * 0x100 + dsp_m.t_srcn * 4; dsp_m.t_srcn = v->regs[V_SRCN]; } -static inline void dsp_voice_V2( dsp_voice_t* const v ) +static INLINE void dsp_voice_V2( dsp_voice_t* const v ) { uint8_t *entry; @@ -362,12 +360,12 @@ static inline void dsp_voice_V2( dsp_voice_t* const v ) dsp_m.t_pitch = v->regs [V_PITCHL]; } -static inline void dsp_voice_V3a( dsp_voice_t* const v ) +static INLINE void dsp_voice_V3a( dsp_voice_t* const v ) { dsp_m.t_pitch += (v->regs [V_PITCHH] & 0x3F) << 8; } -static inline void dsp_voice_V3b( dsp_voice_t* const v ) +static INLINE void dsp_voice_V3b( dsp_voice_t* const v ) { dsp_m.t_brr_byte = dsp_m.ram [(v->brr_addr + v->brr_offset) & 0xffff]; dsp_m.t_brr_header = dsp_m.ram [v->brr_addr]; @@ -453,7 +451,7 @@ static void dsp_voice_V3c( dsp_voice_t* const v ) } } -static inline void dsp_voice_output( dsp_voice_t const* v, int32_t ch ) +static INLINE void dsp_voice_output( dsp_voice_t const* v, int32_t ch ) { int32_t amp; @@ -472,7 +470,7 @@ static inline void dsp_voice_output( dsp_voice_t const* v, int32_t ch ) } } -static inline void dsp_voice_V4( dsp_voice_t* const v ) +static INLINE void dsp_voice_V4( dsp_voice_t* const v ) { /* Decode BRR */ dsp_m.t_looped = 0; @@ -504,7 +502,7 @@ static inline void dsp_voice_V4( dsp_voice_t* const v ) dsp_voice_output( v, 0 ); } -static inline void dsp_voice_V5( dsp_voice_t* const v ) +static INLINE void dsp_voice_V5( dsp_voice_t* const v ) { int32_t endx_buf; /* Output right */ @@ -519,13 +517,13 @@ static inline void dsp_voice_V5( dsp_voice_t* const v ) dsp_m.endx_buf = (uint8_t) endx_buf; } -static inline void dsp_voice_V6( dsp_voice_t* const v ) +static INLINE void dsp_voice_V6( dsp_voice_t* const v ) { (void) v; /* avoid compiler warning about unused v */ dsp_m.outx_buf = (uint8_t) (dsp_m.t_output >> 8); } -static inline void dsp_voice_V7( dsp_voice_t* const v ) +static INLINE void dsp_voice_V7( dsp_voice_t* const v ) { /* Update ENDX */ dsp_m.regs[R_ENDX] = dsp_m.endx_buf; @@ -533,20 +531,20 @@ static inline void dsp_voice_V7( dsp_voice_t* const v ) dsp_m.envx_buf = v->t_envx_out; } -static inline void dsp_voice_V8( dsp_voice_t* const v ) +static INLINE void dsp_voice_V8( dsp_voice_t* const v ) { /* Update OUTX */ v->regs [V_OUTX] = dsp_m.outx_buf; } -static inline void dsp_voice_V9( dsp_voice_t* const v ) +static INLINE void dsp_voice_V9( dsp_voice_t* const v ) { v->regs [V_ENVX] = dsp_m.envx_buf; } /* Most voices do all these in one clock, so make a handy composite */ -static inline void dsp_voice_V3( dsp_voice_t* const v ) +static INLINE void dsp_voice_V3( dsp_voice_t* const v ) { dsp_voice_V3a( v ); dsp_voice_V3b( v ); @@ -554,7 +552,7 @@ static inline void dsp_voice_V3( dsp_voice_t* const v ) } /* Common combinations of voice steps on different voices. This greatly reduces - code size and allows everything to be inlined in these functions. */ + code size and allows everything to be INLINEd in these functions. */ static void dsp_voice_V7_V4_V1( dsp_voice_t* const v ) { @@ -599,7 +597,7 @@ 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() +static INLINE void dsp_echo_22() { int32_t l, r; @@ -617,7 +615,7 @@ static inline void dsp_echo_22() dsp_m.t_echo_in [1] = r; } -static inline void dsp_echo_23() +static INLINE void dsp_echo_23() { int32_t l, r; @@ -630,7 +628,7 @@ static inline void dsp_echo_23() ECHO_READ(1); } -static inline void dsp_echo_24() +static INLINE void dsp_echo_24() { int32_t l, r; @@ -641,7 +639,7 @@ static inline void dsp_echo_24() dsp_m.t_echo_in [1] += r; } -static inline void dsp_echo_25() +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); @@ -667,7 +665,7 @@ static inline void dsp_echo_25() CLAMP16( var ); \ } -static inline void dsp_echo_26() +static INLINE void dsp_echo_26() { int32_t l, r; @@ -683,7 +681,7 @@ static inline void dsp_echo_26() dsp_m.t_echo_out [1] = r & ~1; } -static inline void dsp_echo_27() +static INLINE void dsp_echo_27() { int32_t l, r; int16_t *out; @@ -726,7 +724,7 @@ static inline void dsp_echo_27() } \ dsp_m.t_echo_out [ch] = 0; -static inline void dsp_echo_29() +static INLINE void dsp_echo_29() { dsp_m.t_esa = dsp_m.regs [R_ESA]; @@ -1246,9 +1244,10 @@ void spc_enable_rom( int32_t enable ) dsp_run( clock_count ); \ } -static inline void spc_dsp_write( int32_t data, int32_t time ) +static INLINE void spc_dsp_write( int32_t data, int32_t time ) { int32_t addr; + (void) time; /* Writes DSP registers. */ addr = m.smp_regs[0][R_DSPADDR]; @@ -1863,8 +1862,6 @@ mov_abs_temp: SET_SP( x ); goto loop; - /* case 0xC6: // MOV (X),A (handled by MOV addr,A in group 2) */ - case 0xAF: /* MOV (X)+,A */ WRITE_DP( 0, x, a + NO_READ_BEFORE_WRITE ); x++; @@ -2900,7 +2897,7 @@ static int32_t r_left[4], r_right[4]; #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) #define SHORT_CLAMP(n) ((int16_t) CLAMP((n), -32768, 32767)) -static inline int32_t hermite (int32_t mu1, int32_t a, int32_t b, int32_t c, int32_t d) +static INLINE int32_t hermite (int32_t mu1, int32_t a, int32_t b, int32_t c, int32_t d) { int32_t mu2, mu3, m0, m1, a0, a1, a2, a3; @@ -3006,7 +3003,7 @@ static void resampler_new(int32_t num_samples) resampler_clear(); } -static inline bool resampler_push(int16_t *src, int32_t num_samples) +static INLINE bool resampler_push(int16_t *src, int32_t num_samples) { int32_t bytes, end, first_write_size; uint8_t *src_ring; @@ -3030,8 +3027,9 @@ static inline bool resampler_push(int16_t *src, int32_t num_samples) return true; } -static inline void resampler_resize (int32_t num_samples) +static INLINE void resampler_resize (int32_t num_samples) { + (void) num_samples; free(rb_buffer); rb_buffer_size = rb_size; rb_buffer = (uint8_t *)malloc(rb_buffer_size); @@ -3394,8 +3392,8 @@ static void to_apu_from_state (uint8_t **buf, void *var, size_t size) *buf += size; } -// work around optimization bug in android GCC -// similar to this: http://jeffq.com/blog/over-aggressive-gcc-optimization-can-cause-sigbus-crash-when-using-memcpy-with-the-android-ndk/ +/* work around optimization bug in android GCC + similar to this: http://jeffq.com/blog/over-aggressive-gcc-optimization-can-cause-sigbus-crash-when-using-memcpy-with-the-android-ndk/ */ #if defined(ANDROID) || defined(__QNX__) void __attribute__((optimize(0))) S9xAPUSaveState (uint8_t *block) #else -- cgit v1.2.3