Update libgme to Blargg's Game_Music_Emu 0.6-pre.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30397 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2011-08-31 19:19:49 +00:00
parent d089e10403
commit 13cbade08a
68 changed files with 4113 additions and 4893 deletions

View file

@ -1,6 +1,6 @@
// NES 2A03 APU sound chip emulator
// Nes_Snd_Emu 0.1.8
// Nes_Snd_Emu 0.2.0-pre
#ifndef NES_APU_H
#define NES_APU_H
@ -9,7 +9,7 @@
enum { apu_status_addr = 0x4015 };
enum { apu_osc_count = 5 };
enum { apu_no_irq = INT_MAX / 2 + 1 };
enum { apu_no_irq = INT_MAX/2 + 1 };
enum { apu_irq_waiting = 0 };
enum { apu_io_addr = 0x4000 };
@ -17,24 +17,16 @@ enum { apu_io_size = 0x18 };
struct apu_state_t;
struct Nes_Apu {
nes_time_t last_dmc_time;
int osc_enables;
struct Nes_Osc* oscs [apu_osc_count];
struct Nes_Square square1;
struct Nes_Square square2;
struct Nes_Noise noise;
struct Nes_Triangle triangle;
struct Nes_Dmc dmc;
struct Nes_Apu {
int tempo_;
nes_time_t last_time; // has been run until this time in current frame
nes_time_t last_dmc_time;
nes_time_t earliest_irq_;
nes_time_t next_irq;
int frame_period;
int frame_delay; // cycles until frame counter runs next
int frame; // current frame (0-3)
int osc_enables;
int frame_mode;
bool irq_flag;
@ -42,6 +34,13 @@ struct Nes_Apu {
void* irq_data;
Synth square_synth; // shared by squares
struct Nes_Osc* oscs [apu_osc_count];
struct Nes_Square square1;
struct Nes_Square square2;
struct Nes_Noise noise;
struct Nes_Triangle triangle;
struct Nes_Dmc dmc;
};
// Init Nes apu
@ -49,22 +48,22 @@ void Apu_init( struct Nes_Apu* this );
// Set buffer to generate all sound into, or disable sound if NULL
void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* );
// All time values are the number of cpu clock cycles relative to the
// beginning of the current time frame. Before resetting the cpu clock
// count, call end_frame( last_cpu_time ).
// Write to register (0x4000-0x4017, except 0x4014 and 0x4016)
void Apu_write_register( struct Nes_Apu* this, nes_time_t, addr_t, int data );
// Read from status register at 0x4015
int Apu_read_status( struct Nes_Apu* this, nes_time_t );
// Run all oscillators up to specified time, end current time frame, then
// start a new time frame at time 0. Time frames have no effect on emulation
// and each can be whatever length is convenient.
void Apu_end_frame( struct Nes_Apu* this, nes_time_t );
// Additional optional features (can be ignored without any problem)
// Reset internal frame counter, registers, and all oscillators.
@ -72,13 +71,13 @@ void Apu_end_frame( struct Nes_Apu* this, nes_time_t );
// Set the DMC oscillator's initial DAC value to initial_dmc_dac without
// any audible click.
void Apu_reset( struct Nes_Apu* this, bool pal_mode, int initial_dmc_dac );
// Adjust frame period
void Apu_set_tempo( struct Nes_Apu* this, int );
// Set overall volume (default is 1.0)
void Apu_volume( struct Nes_Apu* this, int );
// Run DMC until specified time, so that any DMC memory reads can be
// accounted for (i.e. inserting cpu wait states).
void Apu_run_until( struct Nes_Apu* this, nes_time_t );
@ -124,11 +123,13 @@ static inline nes_time_t Dmc_next_read_time( struct Nes_Dmc* this )
if ( this->osc.length_counter == 0 )
return apu_no_irq; // not reading
return this->apu->last_dmc_time + this->osc.delay + (long) (this->bits_remain - 1) * this->period;
return this->apu->last_dmc_time + this->osc.delay + (this->bits_remain - 1) * this->period;
}
// Time when next DMC memory read will occur
static inline nes_time_t Apu_next_dmc_read_time( struct Nes_Apu* this ) { return Dmc_next_read_time( &this->dmc ); }
void Apu_irq_changed( struct Nes_Apu* this );
// Experimental
void Apu_enable_nonlinear_( struct Nes_Apu* this, double sq, double tnd );
#endif