diff options
Diffstat (limited to 'apps/codecs/libspc')
-rw-r--r-- | apps/codecs/libspc/spc_codec.h | 20 | ||||
-rw-r--r-- | apps/codecs/libspc/spc_dsp.c | 21 |
2 files changed, 22 insertions, 19 deletions
diff --git a/apps/codecs/libspc/spc_codec.h b/apps/codecs/libspc/spc_codec.h index 923645b4aa..cf72f90af4 100644 --- a/apps/codecs/libspc/spc_codec.h +++ b/apps/codecs/libspc/spc_codec.h | |||
@@ -137,16 +137,15 @@ static inline void set_le16( void* p, unsigned n ) | |||
137 | } | 137 | } |
138 | 138 | ||
139 | #define GET_LE16( addr ) get_le16( addr ) | 139 | #define GET_LE16( addr ) get_le16( addr ) |
140 | #define GET_LE16A( addr ) get_le16( addr ) | ||
140 | #define SET_LE16( addr, data ) set_le16( addr, data ) | 141 | #define SET_LE16( addr, data ) set_le16( addr, data ) |
141 | #define INT16A( addr ) (*(uint16_t*) (addr)) | 142 | #define INT16A( addr ) (*(uint16_t*) (addr)) |
142 | #define INT16SA( addr ) (*(int16_t*) (addr)) | 143 | #define INT16SA( addr ) (*(int16_t*) (addr)) |
143 | 144 | ||
144 | #ifdef ROCKBOX_LITTLE_ENDIAN | 145 | #ifdef ROCKBOX_LITTLE_ENDIAN |
145 | #define GET_LE16A( addr ) (*(uint16_t*) (addr)) | ||
146 | #define GET_LE16SA( addr ) (*( int16_t*) (addr)) | 146 | #define GET_LE16SA( addr ) (*( int16_t*) (addr)) |
147 | #define SET_LE16A( addr, data ) (void) (*(uint16_t*) (addr) = (data)) | 147 | #define SET_LE16A( addr, data ) (void) (*(uint16_t*) (addr) = (data)) |
148 | #else | 148 | #else |
149 | #define GET_LE16A( addr ) get_le16 ( addr ) | ||
150 | #define GET_LE16SA( addr ) get_le16s( addr ) | 149 | #define GET_LE16SA( addr ) get_le16s( addr ) |
151 | #define SET_LE16A( addr, data ) set_le16 ( addr, data ) | 150 | #define SET_LE16A( addr, data ) set_le16 ( addr, data ) |
152 | #endif | 151 | #endif |
@@ -166,13 +165,22 @@ struct cpu_regs_t | |||
166 | uint8_t sp; | 165 | uint8_t sp; |
167 | }; | 166 | }; |
168 | 167 | ||
168 | struct src_dir | ||
169 | { | ||
170 | uint16_t start; | ||
171 | uint16_t loop; | ||
172 | }; | ||
173 | |||
169 | struct cpu_ram_t | 174 | struct cpu_ram_t |
170 | { | 175 | { |
171 | union { | 176 | union { |
172 | uint8_t padding1 [0x100]; | 177 | uint8_t padding1 [0x100]; |
173 | uint16_t align; | 178 | uint16_t align; |
174 | } padding1 [1]; | 179 | } padding1 [1]; |
175 | uint8_t ram [0x10000]; | 180 | union { |
181 | uint8_t ram [0x10000]; | ||
182 | struct src_dir sd [0x10000/sizeof(struct src_dir)]; | ||
183 | }; | ||
176 | uint8_t padding2 [0x100]; | 184 | uint8_t padding2 [0x100]; |
177 | }; | 185 | }; |
178 | 186 | ||
@@ -339,12 +347,6 @@ struct Spc_Dsp | |||
339 | #endif | 347 | #endif |
340 | }; | 348 | }; |
341 | 349 | ||
342 | struct src_dir | ||
343 | { | ||
344 | char start [2]; | ||
345 | char loop [2]; | ||
346 | }; | ||
347 | |||
348 | void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) ICODE_ATTR; | 350 | void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) ICODE_ATTR; |
349 | void DSP_reset( struct Spc_Dsp* this ); | 351 | void DSP_reset( struct Spc_Dsp* this ); |
350 | 352 | ||
diff --git a/apps/codecs/libspc/spc_dsp.c b/apps/codecs/libspc/spc_dsp.c index d1facf89a2..9ebd3e6353 100644 --- a/apps/codecs/libspc/spc_dsp.c +++ b/apps/codecs/libspc/spc_dsp.c | |||
@@ -77,12 +77,13 @@ static void decode_brr( struct Spc_Dsp* this, unsigned start_addr, | |||
77 | /* setup same variables as where decode_brr() is called from */ | 77 | /* setup same variables as where decode_brr() is called from */ |
78 | #undef RAM | 78 | #undef RAM |
79 | #define RAM ram.ram | 79 | #define RAM ram.ram |
80 | |||
80 | struct src_dir const* const sd = | 81 | struct src_dir const* const sd = |
81 | (struct src_dir*) &RAM [this->r.g.wave_page * 0x100]; | 82 | &ram.sd[this->r.g.wave_page * 0x100/sizeof(struct src_dir)]; |
82 | struct cache_entry_t* const wave_entry = | 83 | struct cache_entry_t* const wave_entry = |
83 | &this->wave_entry [raw_voice->waveform]; | 84 | &this->wave_entry [raw_voice->waveform]; |
84 | 85 | ||
85 | /* the following block can be put in place of the call to | 86 | /* the following block can be put in place of the call to |
86 | decode_brr() below | 87 | decode_brr() below |
87 | */ | 88 | */ |
88 | { | 89 | { |
@@ -106,7 +107,7 @@ static void decode_brr( struct Spc_Dsp* this, unsigned start_addr, | |||
106 | wave_entry->start_addr = start_addr; | 107 | wave_entry->start_addr = start_addr; |
107 | 108 | ||
108 | uint8_t const* const loop_ptr = | 109 | uint8_t const* const loop_ptr = |
109 | RAM + GET_LE16A( sd [raw_voice->waveform].loop ); | 110 | RAM + letoh16(sd[raw_voice->waveform].loop); |
110 | short* loop_start = 0; | 111 | short* loop_start = 0; |
111 | 112 | ||
112 | short* out = BRRcache + start_addr * 2; | 113 | short* out = BRRcache + start_addr * 2; |
@@ -251,7 +252,7 @@ static void key_on(struct Spc_Dsp* const this, struct voice_t* const voice, | |||
251 | voice->envx = 0; | 252 | voice->envx = 0; |
252 | voice->env_mode = state_attack; | 253 | voice->env_mode = state_attack; |
253 | voice->env_timer = env_rate_init; /* TODO: inaccurate? */ | 254 | voice->env_timer = env_rate_init; /* TODO: inaccurate? */ |
254 | unsigned start_addr = GET_LE16A(sd [raw_voice->waveform].start); | 255 | unsigned start_addr = letoh16(sd[raw_voice->waveform].start); |
255 | #if !SPC_BRRCACHE | 256 | #if !SPC_BRRCACHE |
256 | { | 257 | { |
257 | voice->addr = RAM + start_addr; | 258 | voice->addr = RAM + start_addr; |
@@ -331,9 +332,9 @@ void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) | |||
331 | } | 332 | } |
332 | while ( (vbit >>= 1) != 0 ); | 333 | while ( (vbit >>= 1) != 0 ); |
333 | } | 334 | } |
334 | 335 | ||
335 | struct src_dir const* const sd = | 336 | struct src_dir const* const sd = |
336 | (struct src_dir*) &RAM [this->r.g.wave_page * 0x100]; | 337 | &ram.sd[this->r.g.wave_page * 0x100/sizeof(struct src_dir)]; |
337 | 338 | ||
338 | #ifdef ROCKBOX_BIG_ENDIAN | 339 | #ifdef ROCKBOX_BIG_ENDIAN |
339 | /* Convert endiannesses before entering loops - these | 340 | /* Convert endiannesses before entering loops - these |
@@ -358,7 +359,7 @@ void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) | |||
358 | const int echo_start = this->r.g.echo_page * 0x100; | 359 | const int echo_start = this->r.g.echo_page * 0x100; |
359 | #endif /* CPU_COLDFIRE */ | 360 | #endif /* CPU_COLDFIRE */ |
360 | #else | 361 | #else |
361 | #define VOICE_RATE(x) (INT16A(raw_voice->rate) & 0x3FFF) | 362 | #define VOICE_RATE(x) (GET_LE16(raw_voice->rate) & 0x3FFF) |
362 | #define IF_RBE(...) | 363 | #define IF_RBE(...) |
363 | #endif /* ROCKBOX_BIG_ENDIAN */ | 364 | #endif /* ROCKBOX_BIG_ENDIAN */ |
364 | 365 | ||
@@ -590,7 +591,7 @@ void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) | |||
590 | /* action based on previous block's header */ | 591 | /* action based on previous block's header */ |
591 | if ( voice->block_header & 1 ) | 592 | if ( voice->block_header & 1 ) |
592 | { | 593 | { |
593 | addr = RAM + GET_LE16A( sd [raw_voice->waveform].loop ); | 594 | addr = RAM + letoh16(sd[raw_voice->waveform].loop); |
594 | this->r.g.wave_ended |= vbit; | 595 | this->r.g.wave_ended |= vbit; |
595 | if ( !(voice->block_header & 2) ) /* 1% of the time */ | 596 | if ( !(voice->block_header & 2) ) /* 1% of the time */ |
596 | { | 597 | { |