1
0
Fork 0
forked from len0rd/rockbox

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

@ -10,6 +10,7 @@
#include "nes_cpu.h"
#include "nsfe_info.h"
#include "m3u_playlist.h"
#include "track_filter.h"
#ifndef NSF_EMU_APU_ONLY
#include "nes_namco_apu.h"
@ -17,11 +18,11 @@
#include "nes_fme7_apu.h"
#include "nes_fds_apu.h"
#include "nes_mmc5_apu.h"
#include "nes_vrc7_apu.h"
#ifndef NSF_EMU_NO_VRC7
#include "nes_vrc7_apu.h"
#endif
#endif
typedef short sample_t;
// Sound chip flags
enum {
vrc6_flag = 1 << 0,
@ -50,8 +51,7 @@ enum { fdsram_size = 0x6000 };
enum { fdsram_offset = 0x2000 + page_size + 8 };
enum { sram_addr = 0x6000 };
enum { unmapped_size= page_size + 8 };
enum { buf_size = 2048 };
enum { max_voices = 32 };
// NSF file header
enum { header_size = 0x80 };
@ -82,37 +82,21 @@ struct Nsf_Emu {
int play_extra;
int play_delay;
struct registers_t saved_state; // of interrupted init routine
int track_count;
// general
int max_initial_silence;
int voice_count;
int voice_types [32];
int mute_mask_;
int tempo;
int gain;
long sample_rate;
int sample_rate;
// track-specific
int track_count;
int current_track;
blargg_long out_time; // number of samples played since start of track
blargg_long emu_time; // number of samples emulator has generated since start of track
bool emu_track_ended_; // emulator has reached end of track
volatile bool track_ended;
// fading
blargg_long fade_start;
int fade_step;
// silence detection
int silence_lookahead; // speed to run emulator when looking ahead for silence
bool ignore_silence;
long silence_time; // number of samples where most recent silence began
long silence_count; // number of samples of silence to play before using buf
long buf_remain; // number of samples left in silence buffer
long clock_rate__;
int clock_rate__;
unsigned buf_changed_count;
// M3u Playlist
@ -127,7 +111,9 @@ struct Nsf_Emu {
struct Nes_Namco_Apu namco;
struct Nes_Vrc6_Apu vrc6;
struct Nes_Fme7_Apu fme7;
struct Nes_Vrc7_Apu vrc7;
#ifndef NSF_EMU_NO_VRC7
struct Nes_Vrc7_Apu vrc7;
#endif
#endif
struct Nes_Cpu cpu;
@ -136,13 +122,15 @@ struct Nsf_Emu {
// Header for currently loaded file
struct header_t header;
struct Stereo_Buffer stereo_buf;
struct setup_t tfilter;
struct Track_Filter track_filter;
struct Multi_Buffer stereo_buf;
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];
};
@ -150,18 +138,18 @@ struct Nsf_Emu {
// Basic functionality (see Gme_File.h for file loading/track info functions)
void Nsf_init( struct Nsf_Emu* this );
blargg_err_t Nsf_load( struct Nsf_Emu* this, void* data, long size );
blargg_err_t Nsf_load_mem( struct Nsf_Emu* this, void* data, long size );
blargg_err_t Nsf_post_load( struct Nsf_Emu* this );
// Set output sample rate. Must be called only once before loading file.
blargg_err_t Nsf_set_sample_rate( struct Nsf_Emu* this, long sample_rate );
blargg_err_t Nsf_set_sample_rate( struct Nsf_Emu* this, int sample_rate );
// Start a track, where 0 is the first track. Also clears warning string.
blargg_err_t Nsf_start_track( struct Nsf_Emu* this , int );
// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation
// errors set warning string, and major errors also end track.
blargg_err_t Nsf_play( struct Nsf_Emu* this, long count, sample_t* buf );
blargg_err_t Nsf_play( struct Nsf_Emu* this, int count, sample_t* buf );
void Nsf_clear_playlist( struct Nsf_Emu* this );
void Nsf_disable_playlist( struct Nsf_Emu* this, bool b ); // use clear_playlist()
@ -169,20 +157,32 @@ void Nsf_disable_playlist( struct Nsf_Emu* this, bool b ); // use clear_playlist
// Track status/control
// Number of milliseconds (1000 msec = 1 second) played since beginning of track
long Track_tell( struct Nsf_Emu* this );
int Track_tell( struct Nsf_Emu* this );
// Seek to new time in track. Seeking backwards or far forward can take a while.
blargg_err_t Track_seek( struct Nsf_Emu* this, long msec );
blargg_err_t Track_seek( struct Nsf_Emu* this, int msec );
// Skip n samples
blargg_err_t Track_skip( struct Nsf_Emu* this, long n );
blargg_err_t Track_skip( struct Nsf_Emu* this, int n );
// Set start time and length of track fade out. Once fade ends track_ended() returns
// true. Fade time can be changed while track is playing.
void Track_set_fade( struct Nsf_Emu* this, long start_msec, long length_msec );
void Track_set_fade( struct Nsf_Emu* this, int start_msec, int length_msec );
// True if a track has reached its end
static inline bool Track_ended( struct Nsf_Emu* this )
{
return track_ended( &this->track_filter );
}
// Disables automatic end-of-track detection and skipping of silence at beginning
static inline void Track_ignore_silence( struct Nsf_Emu* this, bool disable )
{
this->track_filter.silence_ignored_ = disable;
}
// Get track length in milliseconds
long Track_length( struct Nsf_Emu* this, int n );
int Track_length( struct Nsf_Emu* this, int n );
// Sound customization
@ -217,28 +217,28 @@ bool run_cpu_until( struct Nsf_Emu* this, nes_time_t end );
// Sets clocks between calls to play routine to p + 1/2 clock
static inline void set_play_period( struct Nsf_Emu* this, int p ) { this->play_period = p; }
// Time play routine will next be called
static inline nes_time_t play_time( struct Nsf_Emu* this ) { return this->next_play; }
// Emulates to at least time t. Might emulate a few clocks extra.
void run_until( struct Nsf_Emu* this, nes_time_t t );
// Runs cpu to at least time t and returns false, or returns true
// if it encounters illegal instruction (halt).
bool run_cpu_until( struct Nsf_Emu* this, nes_time_t t );
// cpu calls through to these to access memory (except instructions)
int read_mem( struct Nsf_Emu* this, addr_t );
void write_mem( struct Nsf_Emu* this, addr_t, int );
// Address of play routine
static inline addr_t play_addr( struct Nsf_Emu* this ) { return get_addr( this->header.play_addr ); }
// Same as run_until, except emulation stops for any event (routine returned,
// play routine called, illegal instruction).
void run_once( struct Nsf_Emu* this, nes_time_t );
// Reads byte as cpu would when executing code. Only works for RAM/ROM,
// NOT I/O like sound chips.
int read_code( struct Nsf_Emu* this, addr_t addr );
@ -248,12 +248,14 @@ static inline byte* sram( struct Nsf_Emu* this ) { return this->high_
static inline byte* unmapped_code( struct Nsf_Emu* this ) { return &this->high_ram [sram_size]; }
#ifndef NSF_EMU_APU_ONLY
static inline int fds_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & fds_flag; }
static inline int vrc6_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & vrc6_flag; }
static inline int vrc7_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & vrc7_flag; }
static inline int mmc5_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & mmc5_flag; }
static inline int namco_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & namco_flag; }
static inline int fme7_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & fme7_flag; }
static inline int fds_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & fds_flag; }
static inline int vrc6_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & vrc6_flag; }
#ifndef NSF_EMU_NO_VRC7
static inline int vrc7_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & vrc7_flag; }
#endif
static inline int mmc5_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & mmc5_flag; }
static inline int namco_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & namco_flag; }
static inline int fme7_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & fme7_flag; }
#endif
#endif