Index: apps/codecs/libgme/nsfe_info.c =================================================================== --- apps/codecs/libgme/nsfe_info.c (Revision 30283) +++ apps/codecs/libgme/nsfe_info.c (Arbeitskopie) @@ -225,7 +225,7 @@ if ( (offset + chunk_size) > size ) return eof_error; - RETURN_ERR( Rom_load( &nsf_emu->rom, (char*) data + offset, chunk_size, 0, 0, 0 ) ); + RETURN_ERR( Rom_load( nsf_emu->rom, (char*) data + offset, chunk_size, 0, 0, 0 ) ); RETURN_ERR( Nsf_post_load( nsf_emu ) ); offset += chunk_size; } Index: apps/codecs/libgme/nsf_emu.c =================================================================== --- apps/codecs/libgme/nsf_emu.c (Revision 30284) +++ apps/codecs/libgme/nsf_emu.c (Arbeitskopie) @@ -47,16 +47,51 @@ static int pcm_read( void* emu, addr_t addr ) { - return *Cpu_get_code( &((struct Nsf_Emu*) emu)->cpu, addr ); + return *Cpu_get_code( ((struct Nsf_Emu*) emu)->cpu, addr ); } +#ifndef NSF_EMU_APU_ONLY +static struct Nes_Fds_Apu sg_fds ; +static struct Nes_Mmc5_Apu sg_mmc5 ; +static struct Nes_Namco_Apu sg_namco ; +static struct Nes_Vrc6_Apu sg_vrc6 ; +static struct Nes_Fme7_Apu sg_fme7 ; +static struct Nes_Vrc7_Apu sg_vrc7 ; +#endif +static struct Nes_Cpu sg_cpu IBSS_ATTR; +static struct Nes_Apu sg_apu IBSS_ATTR; + +static struct Rom_Data sg_rom; + +static sample_t sg_buf[buf_size] IBSS_ATTR; +static byte sg_high_ram[fdsram_size + fdsram_offset] IBSS_ATTR; +static byte sg_low_ram [low_ram_size] IBSS_ATTR; + void Nsf_init( struct Nsf_Emu* this ) { this->sample_rate = 0; this->mute_mask_ = 0; this->tempo = (int)(FP_ONE_TEMPO); this->gain = (int)(FP_ONE_GAIN); - + +#ifndef NSF_EMU_APU_ONLY + // link Apus's + this->fds = &sg_fds; + this->mmc5 = &sg_mmc5; + this->namco = &sg_namco; + this->vrc6 = &sg_vrc6; + this->fme7 = &sg_fme7; + this->vrc7 = &sg_vrc7; +#endif + this->cpu = &sg_cpu; + this->apu = &sg_apu; + + this->rom = &sg_rom; + + this->buf = sg_buf; + this->high_ram = sg_high_ram; + this->low_ram = sg_low_ram; + // defaults this->max_initial_silence = 2; this->ignore_silence = false; @@ -69,15 +104,15 @@ clear_track_vars( this ); // Init rom - Rom_init( &this->rom, 0x1000 ); + Rom_init( this->rom, 0x1000 ); // Init & clear nsfe info Info_init( &this->info ); Info_unload( &this->info ); // TODO: extremely hacky! - Cpu_init( &this->cpu ); - Apu_init( &this->apu ); - Apu_dmc_reader( &this->apu, pcm_read, this ); + Cpu_init( this->cpu ); + Apu_init( this->apu ); + Apu_dmc_reader( this->apu, pcm_read, this ); } // Setup @@ -100,7 +135,7 @@ { if ( vrc6_enabled( this ) ) { - Vrc6_init( &this->vrc6 ); + Vrc6_init( this->vrc6 ); adjusted_gain = (adjusted_gain*3) / 4; this->voice_count += vrc6_osc_count; @@ -108,7 +143,7 @@ if ( fme7_enabled( this ) ) { - Fme7_init( &this->fme7 ); + Fme7_init( this->fme7 ); adjusted_gain = (adjusted_gain*3) / 4; this->voice_count += fme7_osc_count; @@ -116,7 +151,7 @@ if ( mmc5_enabled( this ) ) { - Mmc5_init( &this->mmc5 ); + Mmc5_init( this->mmc5 ); adjusted_gain = (adjusted_gain*3) / 4; this->voice_count += mmc5_osc_count; @@ -124,7 +159,7 @@ if ( fds_enabled( this ) ) { - Fds_init( &this->fds ); + Fds_init( this->fds ); adjusted_gain = (adjusted_gain*3) / 4; this->voice_count += fds_osc_count ; @@ -132,7 +167,7 @@ if ( namco_enabled( this ) ) { - Namco_init( &this->namco ); + Namco_init( this->namco ); adjusted_gain = (adjusted_gain*3) / 4; this->voice_count += namco_osc_count; @@ -141,8 +176,8 @@ if ( vrc7_enabled( this ) ) { #ifndef NSF_EMU_NO_VRC7 - Vrc7_init( &this->vrc7 ); - Vrc7_set_rate( &this->vrc7, this->sample_rate ); + Vrc7_init( this->vrc7 ); + Vrc7_set_rate( this->vrc7, this->sample_rate ); #endif adjusted_gain = (adjusted_gain*3) / 4; @@ -150,19 +185,19 @@ this->voice_count += vrc7_osc_count; } - if ( vrc7_enabled( this ) ) Vrc7_volume( &this->vrc7, adjusted_gain ); - if ( namco_enabled( this ) ) Namco_volume( &this->namco, adjusted_gain ); - if ( vrc6_enabled( this ) ) Vrc6_volume( &this->vrc6, adjusted_gain ); - if ( fme7_enabled( this ) ) Fme7_volume( &this->fme7, adjusted_gain ); - if ( mmc5_enabled( this ) ) Apu_volume( &this->mmc5.apu, adjusted_gain ); - if ( fds_enabled( this ) ) Fds_volume( &this->fds, adjusted_gain ); + if ( vrc7_enabled( this ) ) Vrc7_volume( this->vrc7, adjusted_gain ); + if ( namco_enabled( this ) ) Namco_volume( this->namco, adjusted_gain ); + if ( vrc6_enabled( this ) ) Vrc6_volume( this->vrc6, adjusted_gain ); + if ( fme7_enabled( this ) ) Fme7_volume( this->fme7, adjusted_gain ); + if ( mmc5_enabled( this ) ) Apu_volume( &this->mmc5->apu, adjusted_gain ); + if ( fds_enabled( this ) ) Fds_volume( this->fds, adjusted_gain ); } #endif if ( adjusted_gain > this->gain ) adjusted_gain = this->gain; - Apu_volume( &this->apu, adjusted_gain ); + Apu_volume( this->apu, adjusted_gain ); return 0; } @@ -241,7 +276,7 @@ if ( !memcmp( data, "NESM\x1A", 5 ) ) { Nsf_disable_playlist( this, true ); - RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) ); + RETURN_ERR( Rom_load( this->rom, data, size, header_size, &this->header, 0 ) ); return Nsf_post_load( this ); } @@ -263,7 +298,7 @@ /* if ( load_addr < (fds_enabled() ? sram_addr : rom_addr) ) warning( "Load address is too low" ); */ - Rom_set_addr( &this->rom, load_addr % this->rom.bank_size ); + Rom_set_addr( this->rom, load_addr % this->rom->bank_size ); /* if ( header_.vers != 1 ) warning( "Unknown file version" ); */ @@ -305,10 +340,10 @@ void write_bank( struct Nsf_Emu* this, int bank, int data ) { // Find bank in ROM - int offset = mask_addr( data * this->rom.bank_size, this->rom.mask ); + int offset = mask_addr( data * this->rom->bank_size, this->rom->mask ); /* if ( offset >= rom.size() ) warning( "invalid bank" ); */ - void const* rom_data = Rom_at_addr( &this->rom, offset ); + void const* rom_data = Rom_at_addr( this->rom, offset ); #ifndef NSF_EMU_APU_ONLY if ( bank < bank_count - fds_banks && fds_enabled( this ) ) @@ -321,21 +356,21 @@ out = fdsram( this ); bank -= fds_banks; } - memcpy( &out [bank * this->rom.bank_size], rom_data, this->rom.bank_size ); + memcpy( &out [bank * this->rom->bank_size], rom_data, this->rom->bank_size ); return; } #endif if ( bank >= fds_banks ) - Cpu_map_code( &this->cpu, (bank + 6) * this->rom.bank_size, this->rom.bank_size, rom_data, false ); + Cpu_map_code( this->cpu, (bank + 6) * this->rom->bank_size, this->rom->bank_size, rom_data, false ); } void map_memory( struct Nsf_Emu* this ) { // Map standard things - Cpu_reset( &this->cpu, unmapped_code( this ) ); - Cpu_map_code( &this->cpu, 0, 0x2000, this->low_ram, low_ram_size ); // mirrored four times - Cpu_map_code( &this->cpu, sram_addr, sram_size, sram( this ), 0 ); + Cpu_reset( this->cpu, unmapped_code( this ) ); + Cpu_map_code( this->cpu, 0, 0x2000, this->low_ram, low_ram_size ); // mirrored four times + Cpu_map_code( this->cpu, sram_addr, sram_size, sram( this ), 0 ); // Determine initial banks byte banks [bank_count]; @@ -349,8 +384,8 @@ else { // No initial banks, so assign them based on load_addr - int i, first_bank = (get_addr( this->header.load_addr ) - sram_addr) / this->rom.bank_size; - unsigned total_banks = this->rom.size / this->rom.bank_size; + int i, first_bank = (get_addr( this->header.load_addr ) - sram_addr) / this->rom->bank_size; + unsigned total_banks = this->rom->size / this->rom->bank_size; for ( i = bank_count; --i >= 0; ) { int bank = i - first_bank; @@ -367,7 +402,7 @@ // Map FDS RAM if ( fds_enabled( this ) ) - Cpu_map_code( &this->cpu, rom_addr, fdsram_size, fdsram( this ), 0 ); + Cpu_map_code( this->cpu, rom_addr, fdsram_size, fdsram( this ), 0 ); } static void set_voice( struct Nsf_Emu* this, int i, struct Blip_Buffer* buf, struct Blip_Buffer* left, struct Blip_Buffer* right) @@ -379,7 +414,7 @@ if ( i < apu_osc_count ) { - Apu_osc_output( &this->apu, i, buf ); + Apu_osc_output( this->apu, i, buf ); return; } i -= apu_osc_count; @@ -388,37 +423,37 @@ { if ( vrc6_enabled( this ) && (i -= vrc6_osc_count) < 0 ) { - Vrc6_osc_output( &this->vrc6, i + vrc6_osc_count, buf ); + Vrc6_osc_output( this->vrc6, i + vrc6_osc_count, buf ); return; } if ( fme7_enabled( this ) && (i -= fme7_osc_count) < 0 ) { - Fme7_osc_output( &this->fme7, i + fme7_osc_count, buf ); + Fme7_osc_output( this->fme7, i + fme7_osc_count, buf ); return; } if ( mmc5_enabled( this ) && (i -= mmc5_osc_count) < 0 ) { - Mmc5_set_output( &this->mmc5, i + mmc5_osc_count, buf ); + Mmc5_set_output( this->mmc5, i + mmc5_osc_count, buf ); return; } if ( fds_enabled( this ) && (i -= fds_osc_count) < 0 ) { - Fds_set_output( &this->fds, i + fds_osc_count, buf ); + Fds_set_output( this->fds, i + fds_osc_count, buf ); return; } if ( namco_enabled( this ) && (i -= namco_osc_count) < 0 ) { - Namco_osc_output( &this->namco, i + namco_osc_count, buf ); + Namco_osc_output( this->namco, i + namco_osc_count, buf ); return; } if ( vrc7_enabled( this ) && (i -= vrc7_osc_count) < 0 ) { - Vrc7_set_output( &this->vrc7, i + vrc7_osc_count, buf ); + Vrc7_set_output( this->vrc7, i + vrc7_osc_count, buf ); return; } } @@ -485,24 +520,24 @@ set_play_period( this, (int) ((play_period( &this->header ) * FP_ONE_TEMPO) / t) ); - Apu_set_tempo( &this->apu, t ); + Apu_set_tempo( this->apu, t ); #ifndef NSF_EMU_APU_ONLY if ( fds_enabled( this ) ) - Fds_set_tempo( &this->fds, t ); + Fds_set_tempo( this->fds, t ); #endif } inline void push_byte( struct Nsf_Emu* this, int b ) { - this->low_ram [0x100 + this->cpu.r.sp--] = b; + this->low_ram [0x100 + this->cpu->r.sp--] = b; } // Jumps to routine, given pointer to address in file header. Pushes idle_addr // as return address, NOT old PC. static void jsr_then_stop( struct Nsf_Emu* this, byte const addr [] ) { - this->cpu.r.pc = get_addr( addr ); + this->cpu->r.pc = get_addr( addr ); push_byte( this, (idle_addr - 1) >> 8 ); push_byte( this, (idle_addr - 1) ); } @@ -512,15 +547,15 @@ #ifndef NSF_EMU_APU_ONLY { if ( namco_enabled( this ) && addr == namco_data_reg_addr ) - return Namco_read_data( &this->namco ); + return Namco_read_data( this->namco ); if ( fds_enabled( this ) && (unsigned) (addr - fds_io_addr) < fds_io_size ) - return Fds_read( &this->fds, Cpu_time( &this->cpu ), addr ); + return Fds_read( this->fds, Cpu_time( this->cpu ), addr ); if ( mmc5_enabled( this ) ) { int i = addr - 0x5C00; if ( (unsigned) i < mmc5_exram_size ) - return this->mmc5.exram [i]; + return this->mmc5->exram [i]; int m = addr - 0x5205; if ( (unsigned) m < 2 ) @@ -555,10 +590,10 @@ { #ifndef NSF_EMU_APU_ONLY { - nes_time_t time = Cpu_time( &this->cpu ); + nes_time_t time = Cpu_time( this->cpu ); if ( fds_enabled( this) && (unsigned) (addr - fds_io_addr) < fds_io_size ) { - Fds_write( &this->fds, time, addr, data ); + Fds_write( this->fds, time, addr, data ); return; } @@ -566,13 +601,13 @@ { if ( addr == namco_addr_reg_addr ) { - Namco_write_addr( &this->namco, data ); + Namco_write_addr( this->namco, data ); return; } if ( addr == namco_data_reg_addr ) { - Namco_write_data( &this->namco, time, data ); + Namco_write_data( this->namco, time, data ); return; } } @@ -583,7 +618,7 @@ int osc = (unsigned) (addr - vrc6_base_addr) / vrc6_addr_step; if ( (unsigned) osc < vrc6_osc_count && (unsigned) reg < vrc6_reg_count ) { - Vrc6_write_osc( &this->vrc6, time, osc, reg, data ); + Vrc6_write_osc( this->vrc6, time, osc, reg, data ); return; } } @@ -593,11 +628,11 @@ switch ( addr & fme7_addr_mask ) { case fme7_latch_addr: - Fme7_write_latch( &this->fme7, data ); + Fme7_write_latch( this->fme7, data ); return; case fme7_data_addr: - Fme7_write_data( &this->fme7, time, data ); + Fme7_write_data( this->fme7, time, data ); return; } } @@ -606,7 +641,7 @@ { if ( (unsigned) (addr - mmc5_regs_addr) < mmc5_regs_size ) { - Mmc5_write_register( &this->mmc5, time, addr, data ); + Mmc5_write_register( this->mmc5, time, addr, data ); return; } @@ -620,7 +655,7 @@ int i = addr - 0x5C00; if ( (unsigned) i < mmc5_exram_size ) { - this->mmc5.exram [i] = data; + this->mmc5->exram [i] = data; return; } } @@ -629,13 +664,13 @@ { if ( addr == 0x9010 ) { - Vrc7_write_reg( &this->vrc7, data ); + Vrc7_write_reg( this->vrc7, data ); return; } if ( (unsigned) (addr - 0x9028) <= 0x08 ) { - Vrc7_write_data( &this->vrc7, time, data ); + Vrc7_write_data( this->vrc7, time, data ); return; } } @@ -687,15 +722,15 @@ { this->mmc5_mul [0] = 0; this->mmc5_mul [1] = 0; - memset( this->mmc5.exram, 0, mmc5_exram_size ); + memset( this->mmc5->exram, 0, mmc5_exram_size ); } - if ( fds_enabled( this ) ) Fds_reset( &this->fds ); - if ( namco_enabled( this ) ) Namco_reset( &this->namco ); - if ( vrc6_enabled( this ) ) Vrc6_reset( &this->vrc6 ); - if ( fme7_enabled( this ) ) Fme7_reset( &this->fme7 ); - if ( mmc5_enabled( this ) ) Apu_reset( &this->mmc5.apu, false, 0 ); - if ( vrc7_enabled( this ) ) Vrc7_reset( &this->vrc7 ); + if ( fds_enabled( this ) ) Fds_reset( this->fds ); + if ( namco_enabled( this ) ) Namco_reset( this->namco ); + if ( vrc6_enabled( this ) ) Vrc6_reset( this->vrc6 ); + if ( fme7_enabled( this ) ) Fme7_reset( this->fme7 ); + if ( mmc5_enabled( this ) ) Apu_reset( &this->mmc5->apu, false, 0 ); + if ( vrc7_enabled( this ) ) Vrc7_reset( this->vrc7 ); #endif int speed_flags = 0; @@ -703,9 +738,9 @@ speed_flags = this->header.speed_flags; #endif - Apu_reset( &this->apu, pal_only( &this->header ), (speed_flags & 0x20) ? 0x3F : 0 ); - Apu_write_register( &this->apu, 0, 0x4015, 0x0F ); - Apu_write_register( &this->apu, 0, 0x4017, (speed_flags & 0x10) ? 0x80 : 0 ); + Apu_reset( this->apu, pal_only( &this->header ), (speed_flags & 0x20) ? 0x3F : 0 ); + Apu_write_register( this->apu, 0, 0x4015, 0x0F ); + Apu_write_register( this->apu, 0, 0x4017, (speed_flags & 0x10) ? 0x80 : 0 ); memset( unmapped_code( this ), halt_opcode, unmapped_size ); memset( this->low_ram, 0, low_ram_size ); @@ -721,11 +756,11 @@ this->saved_state.pc = idle_addr; // Setup for call to init routine - this->cpu.r.a = track; - this->cpu.r.x = pal_only( &this->header ); - this->cpu.r.sp = 0xFF; + this->cpu->r.a = track; + this->cpu->r.x = pal_only( &this->header ); + this->cpu->r.sp = 0xFF; jsr_then_stop( this, this->header.init_addr ); - /* if ( this->cpu.r.pc < get_addr( header.load_addr ) ) + /* if ( this->cpu->r.pc < get_addr( header.load_addr ) ) warning( "Init address < load address" ); */ this->emu_track_ended_ = false; @@ -758,10 +793,10 @@ { // Halt instruction encountered - if ( this->cpu.r.pc != idle_addr ) + if ( this->cpu->r.pc != idle_addr ) { // special_event( "illegal instruction" ); - Cpu_set_time( &this->cpu, this->cpu.end_time ); + Cpu_set_time( this->cpu, this->cpu->end_time ); return; } @@ -771,19 +806,19 @@ if ( this->saved_state.pc == idle_addr ) { // nothing to run - nes_time_t t = this->cpu.end_time; - if ( Cpu_time( &this->cpu ) < t ) - Cpu_set_time( &this->cpu, t ); + nes_time_t t = this->cpu->end_time; + if ( Cpu_time( this->cpu ) < t ) + Cpu_set_time( this->cpu, t ); } else { // continue init routine that was interrupted by play routine - this->cpu.r = this->saved_state; + this->cpu->r = this->saved_state; this->saved_state.pc = idle_addr; } } - if ( Cpu_time( &this->cpu ) >= this->next_play ) + if ( Cpu_time( this->cpu ) >= this->next_play ) { // Calculate time of next call to play routine this->play_extra ^= 1; // extra clock every other call @@ -793,10 +828,10 @@ if ( this->play_delay && !--this->play_delay ) { // Save state if init routine is still running - if ( this->cpu.r.pc != idle_addr ) + if ( this->cpu->r.pc != idle_addr ) { check( this->saved_state.pc == idle_addr ); - this->saved_state = this->cpu.r; + this->saved_state = this->cpu->r; // special_event( "play called during init" ); } @@ -807,15 +842,15 @@ void run_until( struct Nsf_Emu* this, nes_time_t end ) { - while ( Cpu_time( &this->cpu ) < end ) + while ( Cpu_time( this->cpu ) < end ) run_once( this, end ); } static void end_frame( struct Nsf_Emu* this, nes_time_t end ) { - if ( Cpu_time( &this->cpu ) < end ) + if ( Cpu_time( this->cpu ) < end ) run_until( this, end ); - Cpu_adjust_time( &this->cpu, -end ); + Cpu_adjust_time( this->cpu, -end ); // Localize to new time frame this->next_play -= end; @@ -823,15 +858,15 @@ if ( this->next_play < 0 ) this->next_play = 0; - Apu_end_frame( &this->apu, end ); + Apu_end_frame( this->apu, end ); #ifndef NSF_EMU_APU_ONLY - if ( fds_enabled( this ) ) Fds_end_frame( &this->fds, end ); - if ( fme7_enabled( this ) ) Fme7_end_frame( &this->fme7, end ); - if ( mmc5_enabled( this ) ) Apu_end_frame( &this->mmc5.apu, end ); - if ( namco_enabled( this ) ) Namco_end_frame( &this->namco, end ); - if ( vrc6_enabled( this ) ) Vrc6_end_frame( &this->vrc6, end ); - if ( vrc7_enabled( this ) ) Vrc7_end_frame( &this->vrc7, end ); + if ( fds_enabled( this ) ) Fds_end_frame( this->fds, end ); + if ( fme7_enabled( this ) ) Fme7_end_frame( this->fme7, end ); + if ( mmc5_enabled( this ) ) Apu_end_frame( &this->mmc5->apu, end ); + if ( namco_enabled( this ) ) Namco_end_frame( this->namco, end ); + if ( vrc6_enabled( this ) ) Vrc6_end_frame( this->vrc6, end ); + if ( vrc7_enabled( this ) ) Vrc7_end_frame( this->vrc7, end ); #endif } Index: apps/codecs/libgme/emu2413.c =================================================================== --- apps/codecs/libgme/emu2413.c (Revision 30283) +++ apps/codecs/libgme/emu2413.c (Arbeitskopie) @@ -175,43 +175,43 @@ static e_uint32 rate = 3354932; /* WaveTable for each envelope amp */ -static e_uint16 fullsintable[PG_WIDTH]; -static e_uint16 halfsintable[PG_WIDTH]; +static e_uint16 fullsintable[PG_WIDTH] IBSS_ATTR; +static e_uint16 halfsintable[PG_WIDTH] IBSS_ATTR; static e_uint16 *waveform[2] = { fullsintable, halfsintable }; /* LFO Table */ -static e_int32 pmtable[PM_PG_WIDTH]; -static e_int32 amtable[AM_PG_WIDTH]; +static e_int32 pmtable[PM_PG_WIDTH] IBSS_ATTR; +static e_int32 amtable[AM_PG_WIDTH] IBSS_ATTR; /* Phase delta for LFO */ static e_uint32 pm_dphase; static e_uint32 am_dphase; /* dB to Liner table */ -static e_int16 DB2LIN_TABLE[(DB_MUTE + DB_MUTE) * 2]; +static e_int16 DB2LIN_TABLE[(DB_MUTE + DB_MUTE) * 2] IBSS_ATTR; /* Liner to Log curve conversion table (for Attack rate). */ -static e_uint16 AR_ADJUST_TABLE[1 << EG_BITS]; +static e_uint16 AR_ADJUST_TABLE[1 << EG_BITS] IBSS_ATTR; /* Empty voice data */ -static OPLL_PATCH null_patch = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static OPLL_PATCH null_patch IBSS_ATTR = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* Basic voice Data */ -static OPLL_PATCH default_patch[OPLL_TONE_NUM][(16 + 3) * 2]; +static OPLL_PATCH default_patch[OPLL_TONE_NUM][(16 + 3) * 2] IBSS_ATTR; /* Definition of envelope mode */ enum OPLL_EG_STATE { READY, ATTACK, DECAY, SUSHOLD, SUSTINE, RELEASE, SETTLE, FINISH }; /* Phase incr table for Attack */ -static e_uint32 dphaseARTable[16][16]; +static e_uint32 dphaseARTable[16][16] IBSS_ATTR; /* Phase incr table for Decay and Release */ -static e_uint32 dphaseDRTable[16][16]; +static e_uint32 dphaseDRTable[16][16] IBSS_ATTR; /* KSL + TL Table */ e_uint8 tllTable[16][8][1 << TL_BITS][4]; -static e_int32 rksTable[2][8][2]; +static e_int32 rksTable[2][8][2] IBSS_ATTR; /* We may not have too much SRAM in rockbox */ #if !defined(ROCKBOX) @@ -678,7 +678,7 @@ INLINE static void UPDATE_PG(OPLL_SLOT * slot) { - static const e_uint32 mltable[16] = + static const e_uint32 mltable[16] ICONST_ATTR = { 1, 1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2, 6 * 2, 7 * 2, 8 * 2, 9 * 2, 10 * 2, 10 * 2, 12 * 2, 12 * 2, 15 * 2, 15 * 2 }; slot->dphase = RATE_ADJUST (((slot->fnum * mltable[slot->patch->ML]) << slot->block) >> (20 - DP_BITS)); @@ -1168,6 +1168,8 @@ /* Update AM, PM unit */ static void +update_ampm (OPLL * opll) ICODE_ATTR; +static void update_ampm (OPLL * opll) { opll->pm_phase = (opll->pm_phase + pm_dphase) & (PM_DP_WIDTH - 1); @@ -1192,6 +1194,8 @@ /* Update Noise unit */ static void +update_noise (OPLL * opll) ICODE_ATTR; +static void update_noise (OPLL * opll) { if(opll->noise_seed&1) opll->noise_seed ^= 0x8003020; @@ -1200,6 +1204,8 @@ /* EG */ static void +calc_envelope (OPLL_SLOT * slot, e_int32 lfo) ICODE_ATTR; +static void calc_envelope (OPLL_SLOT * slot, e_int32 lfo) { #define S2E(x) (SL2EG((e_int32)(x/SL_STEP))<<(EG_DP_BITS-EG_BITS)) @@ -1422,6 +1428,8 @@ } static e_int16 +calc (OPLL * opll) ICODE_ATTR; +static e_int16 calc (OPLL * opll) { e_int32 i; Index: apps/codecs/libgme/nsf_emu.h =================================================================== --- apps/codecs/libgme/nsf_emu.h (Revision 30284) +++ apps/codecs/libgme/nsf_emu.h (Arbeitskopie) @@ -122,29 +122,29 @@ #ifndef NSF_EMU_APU_ONLY byte mmc5_mul [2]; - struct Nes_Fds_Apu fds; - struct Nes_Mmc5_Apu mmc5; - struct Nes_Namco_Apu namco; - struct Nes_Vrc6_Apu vrc6; - struct Nes_Fme7_Apu fme7; - struct Nes_Vrc7_Apu vrc7; + struct Nes_Fds_Apu *fds; + struct Nes_Mmc5_Apu *mmc5; + struct Nes_Namco_Apu *namco; + struct Nes_Vrc6_Apu *vrc6; + struct Nes_Fme7_Apu *fme7; + struct Nes_Vrc7_Apu *vrc7; #endif - struct Nes_Cpu cpu; - struct Nes_Apu apu; + struct Nes_Cpu *cpu; + struct Nes_Apu *apu; // Header for currently loaded file struct header_t header; struct Stereo_Buffer stereo_buf; - struct Rom_Data rom; + struct Rom_Data *rom; // Extended nsf info struct Nsfe_Info info; - sample_t buf [buf_size]; - byte high_ram[fdsram_size + fdsram_offset]; - byte low_ram [low_ram_size]; + sample_t *buf;// [buf_size]; + byte *high_ram;//[fdsram_size + fdsram_offset]; + byte *low_ram;// [low_ram_size]; }; // Basic functionality (see Gme_File.h for file loading/track info functions) Index: apps/codecs/libgme/emu2413.h =================================================================== --- apps/codecs/libgme/emu2413.h (Revision 30284) +++ apps/codecs/libgme/emu2413.h (Arbeitskopie) @@ -119,40 +119,40 @@ } OPLL ; /* Create Object */ -EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ; -EMU2413_API void OPLL_delete(OPLL *) ; +EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ICODE_ATTR; +EMU2413_API void OPLL_delete(OPLL *) ICODE_ATTR; /* Setup */ -EMU2413_API void OPLL_reset(OPLL *) ; -EMU2413_API void OPLL_reset_patch(OPLL *, e_int32) ; -EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ; -EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ; -EMU2413_API void OPLL_set_pan(OPLL *, e_uint32 ch, e_uint32 pan); -EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute); -EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *); +EMU2413_API void OPLL_reset(OPLL *) ICODE_ATTR; +EMU2413_API void OPLL_reset_patch(OPLL *, e_int32) ICODE_ATTR; +EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ICODE_ATTR; +EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ICODE_ATTR; +EMU2413_API void OPLL_set_pan(OPLL *, e_uint32 ch, e_uint32 pan) ICODE_ATTR; +EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute) ICODE_ATTR; +EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *) ICODE_ATTR; /* Port/Register access */ -EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val); -EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val); -EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port); +EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val) ICODE_ATTR; +EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val) ICODE_ATTR; +EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port) ICODE_ATTR; /* Synthsize */ -EMU2413_API e_int16 OPLL_calc(OPLL *) ; -EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ; -EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ; +EMU2413_API e_int16 OPLL_calc(OPLL *) ICODE_ATTR; +EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ICODE_ATTR; +EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ICODE_ATTR; /* Misc */ -EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ; -EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ; -EMU2413_API void OPLL_forceRefresh(OPLL *) ; +EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ICODE_ATTR; +EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ICODE_ATTR; +EMU2413_API void OPLL_forceRefresh(OPLL *) ICODE_ATTR; /* Utility */ EMU2413_API void OPLL_dump2patch(const e_uint8 *dump, OPLL_PATCH *patch) ; EMU2413_API void OPLL_patch2dump(const OPLL_PATCH *patch, e_uint8 *dump) ; -EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ; +EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ICODE_ATTR; /* Channel Mask */ -EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ; -EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ; +EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ICODE_ATTR; +EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ICODE_ATTR; #define dump2patch OPLL_dump2patch Index: apps/codecs/libgme/nsf_cpu.c =================================================================== --- apps/codecs/libgme/nsf_cpu.c (Revision 30283) +++ apps/codecs/libgme/nsf_cpu.c (Arbeitskopie) @@ -34,11 +34,11 @@ int result = this->low_ram [addr & (low_ram_size-1)]; // also handles wrap-around if ( addr & 0xE000 ) { - result = *Cpu_get_code( &this->cpu, addr ); + result = *Cpu_get_code( this->cpu, addr ); if ( addr < sram_addr ) { if ( addr == apu_status_addr ) - result = Apu_read_status( &this->apu, Cpu_time( &this->cpu ) ); + result = Apu_read_status( this->apu, Cpu_time( this->cpu ) ); else result = cpu_read( this, addr ); } @@ -72,7 +72,7 @@ } else if ( (unsigned) (addr - apu_io_addr) < apu_io_size ) { - Apu_write_register( &this->apu, Cpu_time( &this->cpu ), addr, data ); + Apu_write_register( this->apu, Cpu_time( this->cpu ), addr, data ); } else { @@ -105,7 +105,7 @@ #define CPU_BEGIN \ bool run_cpu_until( struct Nsf_Emu* this, nes_time_t end ) \ { \ - struct Nes_Cpu* cpu = &this->cpu; \ + struct Nes_Cpu* cpu = this->cpu; \ Cpu_set_end_time( cpu, end ); \ if ( *Cpu_get_code( cpu, cpu->r.pc ) != halt_opcode ) \ { Index: apps/codecs/nsf.c =================================================================== --- apps/codecs/nsf.c (Revision 30284) +++ apps/codecs/nsf.c (Arbeitskopie) @@ -11,7 +11,7 @@ /* Maximum number of bytes to process in one iteration */ #define CHUNK_SIZE (1024*2) -static int16_t samples[CHUNK_SIZE] IBSS_ATTR; +static int16_t samples[CHUNK_SIZE]; static struct Nsf_Emu nsf_emu; /****************** rockbox interface ******************/