| 1 |
#ifndef _I5E01_APU_H_ |
| 2 |
#define _I5E01_APU_H_ |
| 3 |
#include "5e01_dmc.h" |
| 4 |
|
| 5 |
namespace xgm |
| 6 |
{ |
| 7 |
/** Upper half of APU **/ |
| 8 |
class I5E01_APU |
| 9 |
{ |
| 10 |
public: |
| 11 |
enum |
| 12 |
{ |
| 13 |
OPT_UNMUTE_ON_RESET=0, |
| 14 |
OPT_PHASE_REFRESH, |
| 15 |
OPT_NONLINEAR_MIXER, |
| 16 |
OPT_DUTY_SWAP, |
| 17 |
OPT_NEGATE_SWEEP_INIT, |
| 18 |
OPT_END }; |
| 19 |
|
| 20 |
enum |
| 21 |
{ SQR0_MASK = 1, SQR1_MASK = 2, }; |
| 22 |
|
| 23 |
public: |
| 24 |
int option[OPT_END]; // 各種オプション |
| 25 |
int mask; |
| 26 |
int sm[2][2]; |
| 27 |
|
| 28 |
unsigned int gclock; |
| 29 |
unsigned char reg[0x20]; |
| 30 |
double rate, clock; |
| 31 |
|
| 32 |
int square_table[32]; // nonlinear mixer |
| 33 |
int square_linear; // linear mix approximation |
| 34 |
|
| 35 |
int scounter[2]; // frequency divider |
| 36 |
int sphase[2]; // phase counter |
| 37 |
|
| 38 |
int duty[2]; |
| 39 |
int volume[2]; |
| 40 |
int freq[2]; |
| 41 |
int sfreq[2]; |
| 42 |
|
| 43 |
bool sweep_enable[2]; |
| 44 |
bool sweep_mode[2]; |
| 45 |
bool sweep_write[2]; |
| 46 |
int sweep_div_period[2]; |
| 47 |
int sweep_div[2]; |
| 48 |
int sweep_amount[2]; |
| 49 |
|
| 50 |
bool envelope_disable[2]; |
| 51 |
bool envelope_loop[2]; |
| 52 |
bool envelope_write[2]; |
| 53 |
int envelope_div_period[2]; |
| 54 |
int envelope_div[2]; |
| 55 |
int envelope_counter[2]; |
| 56 |
|
| 57 |
int length_counter[2]; |
| 58 |
|
| 59 |
bool enable[2]; |
| 60 |
|
| 61 |
void sweep_sqr (int ch); // calculates target sweep frequency |
| 62 |
int calc_sqr (int ch, unsigned int clocks); |
| 63 |
|
| 64 |
public: |
| 65 |
int out[2]; |
| 66 |
I5E01_APU (); |
| 67 |
~I5E01_APU (); |
| 68 |
|
| 69 |
// // !! fetch frequency directly instead of through GetTrackInfo() |
| 70 |
double GetFrequencyPulse1() const; |
| 71 |
double GetFrequencyPulse2() const; |
| 72 |
|
| 73 |
void FrameSequence(int s); |
| 74 |
|
| 75 |
void Reset (); |
| 76 |
void Tick (unsigned int clocks); |
| 77 |
unsigned int Render (int b[2]); |
| 78 |
bool Read (unsigned int adr, unsigned int & val, unsigned int id=0); |
| 79 |
bool Write (unsigned int adr, unsigned int val, unsigned int id=0); |
| 80 |
void SetRate (double rate); |
| 81 |
void SetClock (double clock); |
| 82 |
void SetOption (int id, int b); |
| 83 |
void SetMask(int m){ mask = m; } |
| 84 |
void SetStereoMix (int trk, short mixl, short mixr); |
| 85 |
}; |
| 86 |
|
| 87 |
} // namespace |
| 88 |
|
| 89 |
#endif |