| 1 | #ifndef __VB_VSU_H |
| 2 | #define __VB_VSU_H |
| 3 | |
| 4 | #include "../include/blip/Blip_Buffer.h" |
| 5 | |
| 6 | class VSU |
| 7 | { |
| 8 | public: |
| 9 | |
| 10 | VSU(Blip_Buffer *bb_l, Blip_Buffer *bb_r) MDFN_COLD; |
| 11 | ~VSU() MDFN_COLD; |
| 12 | |
| 13 | void Power(void) MDFN_COLD; |
| 14 | |
| 15 | void Write(int32 timestamp, uint32 A, uint8 V); |
| 16 | |
| 17 | void EndFrame(int32 timestamp); |
| 18 | |
| 19 | int StateAction(StateMem *sm, int load, int data_only); |
| 20 | |
| 21 | uint8 PeekWave(const unsigned int which, uint32 Address); |
| 22 | void PokeWave(const unsigned int which, uint32 Address, uint8 value); |
| 23 | |
| 24 | uint8 PeekModWave(uint32 Address); |
| 25 | void PokeModWave(uint32 Address, uint8 value); |
| 26 | |
| 27 | private: |
| 28 | |
| 29 | void CalcCurrentOutput(int ch, int &left, int &right); |
| 30 | |
| 31 | void Update(int32 timestamp); |
| 32 | |
| 33 | uint8 IntlControl[6]; |
| 34 | uint8 LeftLevel[6]; |
| 35 | uint8 RightLevel[6]; |
| 36 | uint16 Frequency[6]; |
| 37 | uint16 EnvControl[6]; // Channel 5/6 extra functionality tacked on too. |
| 38 | |
| 39 | uint8 RAMAddress[6]; |
| 40 | |
| 41 | uint8 SweepControl; |
| 42 | |
| 43 | uint8 WaveData[5][0x20]; |
| 44 | |
| 45 | uint8 ModData[0x20]; |
| 46 | |
| 47 | // |
| 48 | // |
| 49 | // |
| 50 | int32 EffFreq[6]; |
| 51 | int32 Envelope[6]; |
| 52 | |
| 53 | int32 WavePos[6]; |
| 54 | int32 ModWavePos; |
| 55 | |
| 56 | int32 LatcherClockDivider[6]; |
| 57 | |
| 58 | int32 FreqCounter[6]; |
| 59 | int32 IntervalCounter[6]; |
| 60 | int32 EnvelopeCounter[6]; |
| 61 | int32 SweepModCounter; |
| 62 | |
| 63 | int32 EffectsClockDivider[6]; |
| 64 | int32 IntervalClockDivider[6]; |
| 65 | int32 EnvelopeClockDivider[6]; |
| 66 | int32 SweepModClockDivider; |
| 67 | |
| 68 | int32 NoiseLatcherClockDivider; |
| 69 | uint32 NoiseLatcher; |
| 70 | |
| 71 | uint32 lfsr; |
| 72 | |
| 73 | int32 last_output[6][2]; |
| 74 | int32 last_ts; |
| 75 | |
| 76 | Blip_Buffer *sbuf[2]; |
| 77 | Blip_Synth<blip_good_quality, 1024> Synth; |
| 78 | Blip_Synth<blip_med_quality, 1024> NoiseSynth; |
| 79 | }; |
| 80 | |
| 81 | #endif |