Index: apps/codecs/asap.c =================================================================== --- apps/codecs/asap.c (revision 29863) +++ apps/codecs/asap.c (working copy) @@ -27,7 +27,7 @@ #define CHUNK_SIZE (1024*2) static byte samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ -static ASAP_State asap; /* asap codec state */ +static ASAP_State asap IBSS_ATTR; /* asap codec state */ /* this is the codec entry point */ enum codec_status codec_main(enum codec_entry_call_reason reason) @@ -76,7 +76,7 @@ /* Sample depth is 16 bit little endian */ ci->configure(DSP_SET_SAMPLE_DEPTH, 16); /* Stereo or Mono output ? */ - if(asap.module_info.channels ==1) + if(asap.module_info->channels ==1) { ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); bytesPerSample = 2; @@ -89,8 +89,8 @@ /* reset eleapsed */ ci->set_elapsed(0); - song = asap.module_info.default_song; - duration = asap.module_info.durations[song]; + song = asap.module_info->default_song; + duration = asap.module_info->durations[song]; if (duration < 0) duration = 180 * 1000; Index: apps/codecs/nsf.c =================================================================== --- apps/codecs/nsf.c (revision 29863) +++ apps/codecs/nsf.c (working copy) @@ -31,18 +31,20 @@ /* arm doesn't benefit from IRAM? */ #ifdef CPU_ARM +/* #undef ICODE_ATTR #define ICODE_ATTR #undef IDATA_ATTR #define IDATA_ATTR -#else +*/ +//#else #define ICODE_INSTEAD_OF_INLINE #endif /* Maximum number of bytes to process in one iteration */ #define WAV_CHUNK_SIZE (1024*2) -static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR; +static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR MEM_ALIGN_ATTR; #define ZEROMEMORY(addr,size) memset(addr,0,size) @@ -181,15 +183,15 @@ 0x062,0x04E,0x042,0x032} }; -const uint8_t DUTY_CYCLE_TABLE[4] = {2,4,8,12}; +const uint8_t DUTY_CYCLE_TABLE[4] ICONST_ATTR = {2,4,8,12}; -const uint8_t LENGTH_COUNTER_TABLE[0x20] = { +const uint8_t LENGTH_COUNTER_TABLE[0x20] ICONST_ATTR = { 0x0A,0xFE,0x14,0x02,0x28,0x04,0x50,0x06,0xA0,0x08,0x3C,0x0A,0x0E,0x0C,0x1A, 0x0E,0x0C,0x10,0x18,0x12,0x30,0x14,0x60,0x16,0xC0,0x18,0x48,0x1A,0x10,0x1C, 0x20,0x1E }; -const uint16_t NOISE_FREQ_TABLE[0x10] = { +const uint16_t NOISE_FREQ_TABLE[0x10] ICONST_ATTR = { 0x004,0x008,0x010,0x020,0x040,0x060,0x080,0x0A0,0x0CA,0x0FE,0x17C,0x1FC, 0x2FA,0x3F8,0x7F2,0xFE4 }; @@ -589,7 +591,7 @@ int32_t nPopCount; }; -int16_t FDS_nOutputTable_L[4][0x21][0x40]; +int16_t FDS_nOutputTable_L[4][0x21][0x40] IBSS_ATTR MEM_ALIGN_ATTR; struct FME07Wave { @@ -610,7 +612,7 @@ int32_t nMixL; }; -int16_t FME07_nOutputTable_L[0x10] IDATA_ATTR; +int16_t FME07_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR; struct N106Wave { @@ -650,7 +652,7 @@ int32_t nMixL[8]; }; -int16_t N106_nOutputTable_L[0x10][0x10]; +int16_t N106_nOutputTable_L[0x10][0x10] IBSS_ATTR MEM_ALIGN_ATTR; struct VRC6PulseWave { @@ -675,7 +677,7 @@ }; -int16_t VRC6Pulse_nOutputTable_L[0x10] IDATA_ATTR; +int16_t VRC6Pulse_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR; struct VRC6SawWave { @@ -697,7 +699,7 @@ }; -int16_t VRC6Saw_nOutputTable_L[0x20] IDATA_ATTR; +int16_t VRC6Saw_nOutputTable_L[0x20] IDATA_ATTR MEM_ALIGN_ATTR; struct Wave_Squares { @@ -735,7 +737,7 @@ int32_t nMixL; }; -int16_t Squares_nOutputTable_L[0x10][0x10] IDATA_ATTR; +int16_t Squares_nOutputTable_L[0x10][0x10] IDATA_ATTR MEM_ALIGN_ATTR; struct Wave_TND { @@ -1161,16 +1163,16 @@ * Memory */ /* RAM: 0x0000 - 0x07FF */ -uint8_t pRAM[0x800] IDATA_ATTR; +uint8_t pRAM[0x800] IDATA_ATTR MEM_ALIGN_ATTR; /* SRAM: 0x6000 - 0x7FFF (non-FDS only) */ -uint8_t pSRAM[0x2000]; +uint8_t pSRAM[0x2000] IBSS_ATTR MEM_ALIGN_ATTR; /* ExRAM: 0x5C00 - 0x5FF5 (MMC5 only) * Also holds NSF player code (at 0x5000 - 0x500F) */ -uint8_t pExRAM[0x1000]; +uint8_t pExRAM[0x1000] IBSS_ATTR MEM_ALIGN_ATTR; /* Full ROM buffer */ uint8_t* pROM_Full IDATA_ATTR; -uint16_t main_nOutputTable_L[0x8000]; +uint16_t main_nOutputTable_L[0x8000] MEM_ALIGN_ATTR; uint8_t* pROM[10] IDATA_ATTR;/* ROM banks (point to areas in pROM_Full) */ /* 0x8000 - 0xFFFF */ @@ -1188,8 +1190,8 @@ typedef uint8_t ( *ReadProc)(uint16_t); typedef void ( *WriteProc)(uint16_t,uint8_t); -ReadProc ReadMemory[0x10] IDATA_ATTR; -WriteProc WriteMemory[0x10] IDATA_ATTR; +ReadProc ReadMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR; +WriteProc WriteMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR; /* * 6502 Registers / Mode @@ -3541,7 +3543,7 @@ /* Lookup Tables */ /* the number of CPU cycles used for each instruction */ -static const uint8_t CPU_Cycles[0x100] = { +static const uint8_t CPU_Cycles[0x100] ICONST_ATTR = { 7,6,0,8,3,3,5,5,3,2,2,2,4,4,6,6, 2,5,0,8,4,4,6,6,2,4,2,7,4,4,7,7, 6,6,0,8,3,3,5,5,4,2,2,2,4,4,6,6, @@ -3560,7 +3562,7 @@ 2,5,0,8,4,4,6,6,2,4,2,7,4,4,7,7 }; /* the status of the NZ flags for the given value */ -static const uint8_t NZTable[0x100] = { +static const uint8_t NZTable[0x100] ICONST_ATTR = { Z_FLAG,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, Index: apps/codecs/libasap/anylang.h =================================================================== --- apps/codecs/libasap/anylang.h (revision 29863) +++ apps/codecs/libasap/anylang.h (working copy) @@ -24,6 +24,8 @@ #ifndef _ANYLANG_H_ #define _ANYLANG_H_ +#include "codecs.h" + #if defined(JAVA) || defined(CSHARP) || defined(JAVASCRIPT) || defined(ACTIONSCRIPT) #define FALSE false @@ -55,7 +57,7 @@ #define VOIDPTR void * #define UBYTE(data) (data) #define SBYTE(data) (signed char) (data) -#define CONST_ARRAY(type, name) static const type name[] = { +#define CONST_ARRAY(type, name) static const type name[] ICONST_ATTR = { #define END_CONST_ARRAY } #define ZERO_ARRAY(array) memset(array, 0, sizeof(array)) #define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ Index: apps/codecs/libasap/asap.c =================================================================== --- apps/codecs/libasap/asap.c (revision 29863) +++ apps/codecs/libasap/asap.c (working copy) @@ -23,6 +23,9 @@ #include "asap_internal.h" +static byte s_memory[65536]; +static ASAP_ModuleInfo s_module_info; + #ifdef ASAP_ONLY_INFO #define GET_PLAYER(name) NULL @@ -35,7 +38,7 @@ { switch (addr & 0xff1f) { case 0xd014: - return ast _ module_info.ntsc ? 0xf : 1; + return ast _ module_info->ntsc ? 0xf : 1; case 0xd20a: case 0xd21a: return PokeySound_GetRandom(ast, addr, ast _ cycle); @@ -91,7 +94,7 @@ else ast _ cycle = ast _ next_scanline_cycle + 106; } - else if ((addr & 0xff00) == ast _ module_info.covox_addr) { + else if ((addr & 0xff00) == ast _ module_info->covox_addr) { V(PokeyState PTR, pst); addr &= 3; if (addr == 0 || addr == 3) @@ -1379,8 +1382,11 @@ P(ASAP_State PTR, ast), P(STRING, filename), P(CONST BYTEARRAY, module), P(int, module_len))) { + /* Set up ast */ + ast _ memory = s_memory; + ast _ module_info = &s_module_info; ast _ silence_cycles = 0; - return parse_file(ast, ADDRESSOF ast _ module_info, filename, module, module_len); + return parse_file(ast, ast _ module_info, filename, module, module_len); } FUNC(void, ASAP_DetectSilence, (P(ASAP_State PTR, ast), P(int, seconds))) @@ -1416,7 +1422,7 @@ ast _ current_duration = duration; ast _ blocks_played = 0; ast _ silence_cycles_counter = ast _ silence_cycles; - ast _ extra_pokey_mask = ast _ module_info.channels > 1 ? 0x10 : 0; + ast _ extra_pokey_mask = ast _ module_info->channels > 1 ? 0x10 : 0; ast _ consol = 8; ast _ covox[0] = CAST(byte) 0x80; ast _ covox[1] = CAST(byte) 0x80; @@ -1433,9 +1439,9 @@ ast _ timer2_cycle = NEVER; ast _ timer4_cycle = NEVER; ast _ irqst = 0xff; - switch (ast _ module_info.type) { + switch (ast _ module_info->type) { case ASAP_TYPE_SAP_B: - call_6502_init(ast, ast _ module_info.init, song, 0, 0); + call_6502_init(ast, ast _ module_info->init, song, 0, 0); break; case ASAP_TYPE_SAP_C: #ifndef ASAP_ONLY_SAP @@ -1444,8 +1450,8 @@ case ASAP_TYPE_CMR: case ASAP_TYPE_CMS: #endif - call_6502_init(ast, ast _ module_info.player + 3, 0x70, ast _ module_info.music, ast _ module_info.music >> 8); - call_6502_init(ast, ast _ module_info.player + 3, 0x00, song, 0); + call_6502_init(ast, ast _ module_info->player + 3, 0x70, ast _ module_info->music, ast _ module_info->music >> 8); + call_6502_init(ast, ast _ module_info->player + 3, 0x00, song, 0); break; case ASAP_TYPE_SAP_D: case ASAP_TYPE_SAP_S: @@ -1453,23 +1459,23 @@ ast _ cpu_x = 0x00; ast _ cpu_y = 0x00; ast _ cpu_s = 0xff; - ast _ cpu_pc = ast _ module_info.init; + ast _ cpu_pc = ast _ module_info->init; break; #ifndef ASAP_ONLY_SAP case ASAP_TYPE_DLT: - call_6502_init(ast, ast _ module_info.player + 0x100, 0x00, 0x00, ast _ module_info.song_pos[song]); + call_6502_init(ast, ast _ module_info->player + 0x100, 0x00, 0x00, ast _ module_info->song_pos[song]); break; case ASAP_TYPE_MPT: - call_6502_init(ast, ast _ module_info.player, 0x00, ast _ module_info.music >> 8, ast _ module_info.music); - call_6502_init(ast, ast _ module_info.player, 0x02, ast _ module_info.song_pos[song], 0); + call_6502_init(ast, ast _ module_info->player, 0x00, ast _ module_info->music >> 8, ast _ module_info->music); + call_6502_init(ast, ast _ module_info->player, 0x02, ast _ module_info->song_pos[song], 0); break; case ASAP_TYPE_RMT: - call_6502_init(ast, ast _ module_info.player, ast _ module_info.song_pos[song], ast _ module_info.music, ast _ module_info.music >> 8); + call_6502_init(ast, ast _ module_info->player, ast _ module_info->song_pos[song], ast _ module_info->music, ast _ module_info->music >> 8); break; case ASAP_TYPE_TMC: case ASAP_TYPE_TM2: - call_6502_init(ast, ast _ module_info.player, 0x70, ast _ module_info.music >> 8, ast _ module_info.music); - call_6502_init(ast, ast _ module_info.player, 0x00, song, 0); + call_6502_init(ast, ast _ module_info->player, 0x70, ast _ module_info->music >> 8, ast _ module_info->music); + call_6502_init(ast, ast _ module_info->player, 0x00, song, 0); ast _ tmc_per_frame_counter = 1; break; #endif @@ -1485,11 +1491,11 @@ FUNC(abool, call_6502_player, (P(ASAP_State PTR, ast))) { - V(int, player) = ast _ module_info.player; + V(int, player) = ast _ module_info->player; PokeySound_StartFrame(ast); - switch (ast _ module_info.type) { + switch (ast _ module_info->type) { case ASAP_TYPE_SAP_B: - call_6502(ast, player, ast _ module_info.fastplay); + call_6502(ast, player, ast _ module_info->fastplay); break; case ASAP_TYPE_SAP_C: #ifndef ASAP_ONLY_SAP @@ -1498,7 +1504,7 @@ case ASAP_TYPE_CMR: case ASAP_TYPE_CMS: #endif - call_6502(ast, player + 6, ast _ module_info.fastplay); + call_6502(ast, player + 6, ast _ module_info->fastplay); break; case ASAP_TYPE_SAP_D: if (player >= 0) { @@ -1525,10 +1531,10 @@ dPutByte(RETURN_FROM_PLAYER_ADDR + 5, 0x40); /* RTI */ ast _ cpu_pc = player; } - Cpu_RunScanlines(ast, ast _ module_info.fastplay); + Cpu_RunScanlines(ast, ast _ module_info->fastplay); break; case ASAP_TYPE_SAP_S: - Cpu_RunScanlines(ast, ast _ module_info.fastplay); + Cpu_RunScanlines(ast, ast _ module_info->fastplay); { V(int, i) = dGetByte(0x45) - 1; dPutByte(0x45, i); @@ -1538,28 +1544,28 @@ break; #ifndef ASAP_ONLY_SAP case ASAP_TYPE_DLT: - call_6502(ast, player + 0x103, ast _ module_info.fastplay); + call_6502(ast, player + 0x103, ast _ module_info->fastplay); break; case ASAP_TYPE_MPT: case ASAP_TYPE_RMT: case ASAP_TYPE_TM2: - call_6502(ast, player + 3, ast _ module_info.fastplay); + call_6502(ast, player + 3, ast _ module_info->fastplay); break; case ASAP_TYPE_TMC: if (--ast _ tmc_per_frame_counter <= 0) { ast _ tmc_per_frame_counter = ast _ tmc_per_frame; - call_6502(ast, player + 3, ast _ module_info.fastplay); + call_6502(ast, player + 3, ast _ module_info->fastplay); } else - call_6502(ast, player + 6, ast _ module_info.fastplay); + call_6502(ast, player + 6, ast _ module_info->fastplay); break; #endif } - PokeySound_EndFrame(ast, ast _ module_info.fastplay * 114); + PokeySound_EndFrame(ast, ast _ module_info->fastplay * 114); if (ast _ silence_cycles > 0) { if (PokeySound_IsSilent(ADDRESSOF ast _ base_pokey) && PokeySound_IsSilent(ADDRESSOF ast _ extra_pokey)) { - ast _ silence_cycles_counter -= ast _ module_info.fastplay * 114; + ast _ silence_cycles_counter -= ast _ module_info->fastplay * 114; if (ast _ silence_cycles_counter <= 0) return FALSE; } @@ -1606,7 +1612,7 @@ P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(ASAP_SampleFormat, format))) { V(int, use_16bit) = format != ASAP_FORMAT_U8 ? 1 : 0; - V(int, block_size) = ast _ module_info.channels << use_16bit; + V(int, block_size) = ast _ module_info->channels << use_16bit; V(int, bytes_per_second) = ASAP_SAMPLE_RATE * block_size; V(int, total_blocks) = milliseconds_to_blocks(ast _ current_duration); V(int, n_bytes) = (total_blocks - ast _ blocks_played) * block_size; @@ -1629,7 +1635,7 @@ buffer[19] = 0; buffer[20] = 1; buffer[21] = 0; - buffer[22] = CAST(byte) ast _ module_info.channels; + buffer[22] = CAST(byte) ast _ module_info->channels; buffer[23] = 0; serialize_int(buffer, 24, ASAP_SAMPLE_RATE); serialize_int(buffer, 28, bytes_per_second); @@ -1656,7 +1662,7 @@ #ifdef ACTIONSCRIPT block_shift = 0; #else - block_shift = (ast _ module_info.channels - 1) + (format != ASAP_FORMAT_U8 ? 1 : 0); + block_shift = (ast _ module_info->channels - 1) + (format != ASAP_FORMAT_U8 ? 1 : 0); #endif buffer_blocks = buffer_len >> block_shift; if (ast _ current_duration > 0) { Index: apps/codecs/libasap/asap_internal.h =================================================================== --- apps/codecs/libasap/asap_internal.h (revision 29863) +++ apps/codecs/libasap/asap_internal.h (working copy) @@ -109,7 +109,7 @@ #define PutByte(addr, data) do { if (((addr) & 0xf900) == 0xd000) ASAP_PutByte(ast, addr, data); else dPutByte(addr, data); } while (FALSE) #define RMW_GetByte(dest, addr) do { if (((addr) >> 8) == 0xd2) { dest = ASAP_GetByte(ast, addr); ast _ cycle--; ASAP_PutByte(ast, addr, dest); ast _ cycle++; } else dest = dGetByte(addr); } while (FALSE) -#define ASAP_MAIN_CLOCK(ast) ((ast) _ module_info.ntsc ? 1789772 : 1773447) +#define ASAP_MAIN_CLOCK(ast) ((ast) _ module_info->ntsc ? 1789772 : 1773447) #define CYCLE_TO_SAMPLE(cycle) TO_INT(((cycle) * ASAP_SAMPLE_RATE + ast _ sample_offset) / ASAP_MAIN_CLOCK(ast)) #endif /* _ASAP_INTERNAL_H_ */ Index: apps/codecs/libasap/acpu.c =================================================================== --- apps/codecs/libasap/acpu.c (revision 29863) +++ apps/codecs/libasap/acpu.c (working copy) @@ -286,7 +286,7 @@ cycle = ast _ cycle; if (cycle >= ast _ nearest_event_cycle) { if (cycle >= ast _ next_scanline_cycle) { - if (++ast _ scanline_number == (ast _ module_info.ntsc ? 262 : 312)) + if (++ast _ scanline_number == (ast _ module_info->ntsc ? 262 : 312)) ast _ scanline_number = 0; ast _ cycle = cycle += 9; ast _ next_scanline_cycle += 114; @@ -337,7 +337,7 @@ case 0xb2: case 0xd2: case 0xf2: - ast _ scanline_number = (ast _ scanline_number + scanlines - 1) % (ast _ module_info.ntsc ? 262 : 312); + ast _ scanline_number = (ast _ scanline_number + scanlines - 1) % (ast _ module_info->ntsc ? 262 : 312); scanlines = 1; ast _ cycle = cycle_limit; break; Index: apps/codecs/libasap/asap.h =================================================================== --- apps/codecs/libasap/asap.h (revision 29863) +++ apps/codecs/libasap/asap.h (working copy) @@ -179,7 +179,7 @@ int samples; int iir_acc_left; int iir_acc_right; - ASAP_ModuleInfo module_info; + ASAP_ModuleInfo *module_info; int tmc_per_frame; int tmc_per_frame_counter; int current_song; @@ -189,7 +189,7 @@ int silence_cycles_counter; byte poly9_lookup[511]; byte poly17_lookup[16385]; - byte memory[65536]; + byte *memory; } ASAP_State; /* Parses the string in the "mm:ss.xxx" format Index: apps/codecs/libspc/spc_codec.h =================================================================== --- apps/codecs/libspc/spc_codec.h (revision 29863) +++ apps/codecs/libspc/spc_codec.h (working copy) @@ -71,7 +71,7 @@ #define SPC_NOECHO 0 #elif defined (CPU_PP) && SPC_DUAL_CORE /* Cache BRR waves */ - #define SPC_BRRCACHE 1 + #define SPC_BRRCACHE 1 /* Disable gaussian interpolation */ #define SPC_NOINTERP 1 @@ -90,7 +90,7 @@ #endif #ifdef CPU_ARM - +/* #if CONFIG_CPU != PP5002 #undef ICODE_ATTR #define ICODE_ATTR @@ -104,7 +104,7 @@ #undef IBSS_ATTR #define IBSS_ATTR #endif - +*/ #if SPC_DUAL_CORE #undef SHAREDBSS_ATTR #define SHAREDBSS_ATTR __attribute__ ((section(".ibss"))) Index: apps/codecs/libspc/spc_dsp.c =================================================================== --- apps/codecs/libspc/spc_dsp.c (revision 29863) +++ apps/codecs/libspc/spc_dsp.c (working copy) @@ -767,7 +767,7 @@ #if !SPC_NOINTERP /* Interleved gauss table (to improve cache coherency). */ /* gauss [i * 2 + j] = normal_gauss [(1 - j) * 256 + i] */ - static short const gauss [512] = + static short const gauss [512] ICONST_ATTR = { 370,1305, 366,1305, 362,1304, 358,1304, 354,1304, 351,1304, 347,1304, 343,1303, 339,1303, 336,1303, 332,1302, 328,1302, 325,1301, 321,1300, 318,1300, 314,1299,