| 1 |
#ifndef _NES_N106_H_ |
| 2 |
#define _NES_N106_H_ |
| 3 |
|
| 4 |
namespace xgm { |
| 5 |
|
| 6 |
|
| 7 |
class NES_N106 |
| 8 |
{ |
| 9 |
public: |
| 10 |
enum |
| 11 |
{ |
| 12 |
OPT_SERIAL = 0, |
| 13 |
OPT_PHASE_READ_ONLY = 1, |
| 14 |
OPT_LIMIT_WAVELENGTH = 2, |
| 15 |
OPT_END |
| 16 |
}; |
| 17 |
|
| 18 |
protected: |
| 19 |
double rate, clock; |
| 20 |
int mask; |
| 21 |
int sm[2][8]; // stereo mix |
| 22 |
int fout[8]; // current output |
| 23 |
int option[OPT_END]; |
| 24 |
|
| 25 |
bool master_disable; |
| 26 |
unsigned int reg[0x80]; // all state is contained here |
| 27 |
unsigned int reg_select; |
| 28 |
bool reg_advance; |
| 29 |
int tick_channel; |
| 30 |
int tick_clock; |
| 31 |
int render_channel; |
| 32 |
int render_clock; |
| 33 |
int render_subclock; |
| 34 |
|
| 35 |
// convenience functions to interact with regs |
| 36 |
inline unsigned int get_phase (int channel); |
| 37 |
inline unsigned int get_freq (int channel); |
| 38 |
inline unsigned int get_off (int channel); |
| 39 |
inline unsigned int get_len (int channel); |
| 40 |
inline int get_vol (int channel); |
| 41 |
inline int get_sample (unsigned int index); |
| 42 |
inline int get_channels (); |
| 43 |
// for storing back the phase after modifying |
| 44 |
inline void set_phase (unsigned int phase, int channel); |
| 45 |
|
| 46 |
public: |
| 47 |
NES_N106 (); |
| 48 |
~NES_N106 (); |
| 49 |
|
| 50 |
void Reset (); |
| 51 |
void Tick (unsigned int clocks); |
| 52 |
unsigned int Render (int b[2]); |
| 53 |
bool Write (unsigned int adr, unsigned int val, unsigned int id=0); |
| 54 |
bool Read (unsigned int adr, unsigned int & val, unsigned int id=0); |
| 55 |
void SetRate (double); |
| 56 |
void SetClock (double); |
| 57 |
void SetOption (int, int); |
| 58 |
void SetMask (int m); |
| 59 |
void SetStereoMix (int trk, short mixl, short mixr); |
| 60 |
}; |
| 61 |
|
| 62 |
} // namespace xgm |
| 63 |
|
| 64 |
#endif |