Submit initial patch from FS#12176. Adds support for several new game music formats...
[kugel-rb.git] / apps / codecs / libgme / opl_apu.h
blob3f5a751976bf30233133999fba9ab55e8a35de39
1 #ifndef OPL_APU_H
2 #define OPL_APU_H
4 #include "blargg_common.h"
5 #include "blargg_source.h"
6 #include "blip_buffer.h"
8 #include "emu8950.h"
9 #include "emu2413.h"
11 enum opl_type_t { type_opll = 0x10, type_msxmusic = 0x11, type_smsfmunit = 0x12,
12 type_vrc7 = 0x13, type_msxaudio = 0x21 };
14 enum { opl_osc_count = 1 };
16 struct Opl_Apu {
17 struct Blip_Buffer* output_;
18 enum opl_type_t type_;
20 blip_time_t next_time;
21 int last_amp;
22 int addr;
24 long clock_;
25 long rate_;
26 blip_time_t period_;
28 struct Blip_Synth synth;
30 // OPL chips
31 struct Y8950 opl;
32 OPLL opll;
34 unsigned char regs[ 0x100 ];
35 unsigned char opl_memory[ 32768 ];
38 blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type );
40 void Opl_reset( struct Opl_Apu* this );
41 static inline void Opl_volume( struct Opl_Apu* this, double v ) { Synth_volume( &this->synth, 1.0 / (4096 * 6) * v ); }
43 static inline void Opl_osc_output( struct Opl_Apu* this, int i, struct Blip_Buffer* buf )
45 #if defined(ROCKBOX)
46 (void) i;
47 #endif
48 assert( (unsigned) i < opl_osc_count );
49 this->output_ = buf;
52 static inline void Opl_set_output( struct Opl_Apu* this, struct Blip_Buffer* buf ) { Opl_osc_output( this, 0, buf ); }
53 void Opl_end_frame( struct Opl_Apu* this, blip_time_t ) ICODE_ATTR;
55 static inline void Opl_write_addr( struct Opl_Apu* this, int data ) { this->addr = data; }
56 void Opl_write_data( struct Opl_Apu* this, blip_time_t, int data ) ICODE_ATTR;
58 int Opl_read( struct Opl_Apu* this, blip_time_t, int port ) ICODE_ATTR;
60 static inline bool Opl_supported( void ) { return true; }
62 #endif