mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-10 21:52:28 -05:00
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:
parent
d089e10403
commit
13cbade08a
68 changed files with 4113 additions and 4893 deletions
|
|
@ -12,16 +12,14 @@
|
|||
#include "sms_fm_apu.h"
|
||||
#include "sms_apu.h"
|
||||
#include "m3u_playlist.h"
|
||||
#include "track_filter.h"
|
||||
|
||||
typedef short sample_t;
|
||||
typedef struct Z80_Cpu Sgc_Cpu;
|
||||
|
||||
enum { buf_size = 2048 };
|
||||
|
||||
// SGC file header
|
||||
enum { header_size = 0xA0 };
|
||||
struct header_t
|
||||
{
|
||||
{
|
||||
char tag [4]; // "SGC\x1A"
|
||||
byte vers; // 0x01
|
||||
byte rate; // 0=NTSC 1=PAL
|
||||
|
|
@ -48,12 +46,11 @@ struct header_t
|
|||
static inline bool valid_tag( struct header_t* h )
|
||||
{
|
||||
return 0 == memcmp( h->tag, "SGC\x1A", 4 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static inline int effect_count( struct header_t* h ) { return h->last_effect ? h->last_effect - h->first_effect + 1 : 0; }
|
||||
|
||||
|
||||
struct Sgc_Emu {
|
||||
struct Sgc_Emu {
|
||||
bool fm_accessed;
|
||||
|
||||
cpu_time_t play_period;
|
||||
|
|
@ -65,40 +62,28 @@ struct Sgc_Emu {
|
|||
|
||||
// general
|
||||
int voice_count;
|
||||
int const* voice_types;
|
||||
int mute_mask_;
|
||||
int tempo;
|
||||
int gain;
|
||||
|
||||
long sample_rate;
|
||||
int sample_rate;
|
||||
|
||||
// track-specific
|
||||
volatile bool track_ended;
|
||||
int current_track;
|
||||
int track_count;
|
||||
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
|
||||
|
||||
// fading
|
||||
blargg_long fade_start;
|
||||
int fade_step;
|
||||
|
||||
// silence detection
|
||||
bool ignore_silence;
|
||||
int max_initial_silence;
|
||||
int silence_lookahead; // speed to run emulator when looking ahead for 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
|
||||
struct M3u_Playlist m3u;
|
||||
struct header_t header;
|
||||
|
||||
sample_t buf [buf_size];
|
||||
struct Stereo_Buffer stereo_buf;
|
||||
struct setup_t tfilter;
|
||||
struct Track_Filter track_filter;
|
||||
|
||||
struct Multi_Buffer stereo_buf;
|
||||
|
||||
struct Sms_Apu apu;
|
||||
struct Sms_Fm_Apu fm_apu;
|
||||
|
|
@ -106,12 +91,11 @@ struct Sgc_Emu {
|
|||
Sgc_Cpu cpu;
|
||||
|
||||
// large items
|
||||
struct header_t header;
|
||||
struct Rom_Data rom;
|
||||
byte vectors [page_size + page_padding];
|
||||
byte unmapped_write [0x4000];
|
||||
byte ram [0x2000 + page_padding];
|
||||
byte ram2 [0x4000 + page_padding];
|
||||
byte unmapped_write [0x4000];
|
||||
};
|
||||
|
||||
// Basic functionality (see Gme_File.h for file loading/track info functions)
|
||||
|
|
@ -119,41 +103,53 @@ struct Sgc_Emu {
|
|||
void Sgc_init( struct Sgc_Emu* this );
|
||||
|
||||
blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size );
|
||||
|
||||
|
||||
static inline int clock_rate( struct Sgc_Emu* this ) { return this->header.rate ? 3546893 : 3579545; }
|
||||
|
||||
// 0x2000 bytes
|
||||
static inline void set_coleco_bios( struct Sgc_Emu* this, void* p ) { this->coleco_bios = p; }
|
||||
|
||||
// Set output sample rate. Must be called only once before loading file.
|
||||
blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, long sample_rate );
|
||||
blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int sample_rate );
|
||||
|
||||
// Start a track, where 0 is the first track. Also clears warning string.
|
||||
blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track );
|
||||
|
||||
// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation
|
||||
// errors set warning string, and major errors also end track.
|
||||
blargg_err_t Sgc_play( struct Sgc_Emu* this, long count, sample_t* buf );
|
||||
blargg_err_t Sgc_play( struct Sgc_Emu* this, int count, sample_t* buf );
|
||||
|
||||
// Track status/control
|
||||
|
||||
// Number of milliseconds (1000 msec = 1 second) played since beginning of track
|
||||
long Track_tell( struct Sgc_Emu* this );
|
||||
int Track_tell( struct Sgc_Emu* this );
|
||||
|
||||
// Seek to new time in track. Seeking backwards or far forward can take a while.
|
||||
blargg_err_t Track_seek( struct Sgc_Emu* this, long msec );
|
||||
blargg_err_t Track_seek( struct Sgc_Emu* this, int msec );
|
||||
|
||||
// Skip n samples
|
||||
blargg_err_t Track_skip( struct Sgc_Emu* this, long n );
|
||||
blargg_err_t Track_skip( struct Sgc_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 Sgc_Emu* this, long start_msec, long length_msec );
|
||||
void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec );
|
||||
|
||||
// True if a track has reached its end
|
||||
static inline bool Track_ended( struct Sgc_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 Sgc_Emu* this, bool disable )
|
||||
{
|
||||
this->track_filter.silence_ignored_ = disable;
|
||||
}
|
||||
|
||||
// Get track length in milliseconds
|
||||
static inline long Track_get_length( struct Sgc_Emu* this, int n )
|
||||
static inline int Track_get_length( struct Sgc_Emu* this, int n )
|
||||
{
|
||||
long length = 120 * 1000; /* 2 minutes */
|
||||
int length = 120 * 1000; /* 2 minutes */
|
||||
if ( (this->m3u.size > 0) && (n < this->m3u.size) ) {
|
||||
struct entry_t* entry = &this->m3u.entries [n];
|
||||
length = entry->length;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue