2 // Virtual AY-3-8910 Emulator
5 // (C) 2018 Underground Software
15 // User visible registers
16 uint16_t period[3]; // Channel A-C period
17 int16_t volume[3]; // Channel A-C volume (non-envelope mode)
18 bool envEnable[3]; // Channel A-C envelope enable
19 bool toneEnable[3]; // Channel A-C tone enable
20 bool noiseEnable[3]; // Channel A-C noise enable
21 uint16_t noisePeriod; // Noise period (5 bits * 16)
22 uint32_t envPeriod; // Envelope period (16 bits * 256)
23 bool envAttack; // Envelope Attack bit
24 bool envAlternate; // Envelope Alternate bit
25 bool envHold; // Envelope Hold bit
27 uint16_t count[3]; // Channel A-C current count
28 bool state[3]; // Channel A-C current state
29 uint16_t noiseCount; // Noise current count
30 bool noiseState; // Noise state
31 uint32_t envCount[3]; // Envelope current count
32 int16_t envDirection[3];// Envelope direction (rising, 0, or falling)
33 uint32_t prng; // Psuedo RNG (17 bits)
34 uint8_t regLatch; // Register latch (written by 6522VIA)
35 uint8_t data; // Data lines (written by 6522VIA)
36 uint8_t id; // Chip ID (optional)
40 void WriteControl(uint8_t);
41 void WriteData(uint8_t);
42 void SetRegister(void);
43 uint16_t GetSample(void);
47 // Maximum volume that can be generated by one voice
48 static float maxVolume;
49 // Normalized volumes (zero to one) for AY-3-8910 output, in 16 steps
50 static float normalizedVolume[16];
54 extern bool logAYInternal;