comparison src/Input/console/Nsfe_Emu.h @ 0:13389e613d67 trunk

[svn] - initial import of audacious-plugins tree (lots to do)
author nenolod
date Mon, 18 Sep 2006 01:11:49 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13389e613d67
1
2 // Nintendo Entertainment System (NES) NSFE-format game music file emulator
3
4 // Game_Music_Emu 0.3.0
5
6 #ifndef NSFE_EMU_H
7 #define NSFE_EMU_H
8
9 #include "blargg_common.h"
10 #include "Nsf_Emu.h"
11
12 // to do: eliminate dependence on bloated std vector
13 #include <vector>
14
15 class Nsfe_Info {
16 public:
17 struct header_t
18 {
19 char tag [4]; // 'N', 'S', 'F', 'E'
20 };
21 BOOST_STATIC_ASSERT( sizeof (header_t) == 4 );
22
23 // Load NSFE info and optionally load file into Nsf_Emu
24 blargg_err_t load_file( const char* path, Nsf_Emu* = 0 );
25
26 // Load NSFE info and optionally load file into Nsf_Emu
27 blargg_err_t load( Data_Reader&, Nsf_Emu* = 0 );
28
29 // Load NSFE info and optionally load file into Nsf_Emu
30 blargg_err_t load( header_t const&, Data_Reader&, Nsf_Emu* = 0 );
31
32 // Information about current file
33 struct info_t : Nsf_Emu::header_t
34 {
35 // These (longer) fields hide those in Nsf_Emu::header_t
36 char game [256];
37 char author [256];
38 char copyright [256];
39 char ripper [256];
40 };
41 const info_t& info() const { return info_; }
42
43 // All track indicies are 0-based
44
45 // Name of track [i], or "" if none available
46 const char* track_name( unsigned i ) const;
47
48 // Duration of track [i] in milliseconds, negative if endless, or 0 if none available
49 long track_time( unsigned i ) const;
50
51 // Optional playlist consisting of track indicies
52 int playlist_size() const { return playlist.size(); }
53 int playlist_entry( int i ) const { return playlist [i]; }
54
55 // If true and playlist is present in NSFE file, remap track numbers using it
56 void enable_playlist( bool = true );
57
58 public:
59 Nsfe_Info();
60 ~Nsfe_Info();
61 int track_count() const { return info_.track_count; }
62 private:
63 std::vector<char> track_name_data;
64 std::vector<const char*> track_names;
65 std::vector<unsigned char> playlist;
66 std::vector<long> track_times;
67 int track_count_;
68 info_t info_;
69 bool playlist_enabled;
70
71 int remap_track( int i ) const;
72 friend class Nsfe_Emu;
73 };
74
75 class Nsfe_Emu : public Nsf_Emu, public Nsfe_Info {
76 public:
77 // See Nsf_Emu.h for further information
78
79 Nsfe_Emu( double gain = 1.4 ) : Nsf_Emu( gain ) { }
80
81 typedef Nsfe_Info::header_t header_t;
82
83 // Load NSFE data
84 blargg_err_t load( Emu_Reader& r ) { return Nsfe_Info::load( r, this ); }
85
86 // Load NSFE using already-loaded header and remaining data
87 blargg_err_t load( header_t const& h, Emu_Reader& r ) { return Nsfe_Info::load( h, r, this ); }
88
89 public:
90 Nsf_Emu::track_count;
91 Nsf_Emu::load_file;
92 void start_track( int );
93 void enable_playlist( bool = true );
94 };
95
96 inline void Nsfe_Emu::enable_playlist( bool b )
97 {
98 Nsfe_Info::enable_playlist( b );
99 set_track_count( info().track_count );
100 }
101
102 #endif
103