--- /dev/null
+//
+// Virtual AY-3-8910 Emulator
+//
+// by James Hammons
+// (C) 2018 Underground Software
+//
+
+#ifndef VAY8910_H
+#define VAY8910_H
+
+#include <stdint.h>
+
+struct VAY_3_8910
+{
+ // User visible registers
+ uint16_t period[3]; // Channel A-C period
+ int16_t volume[3]; // Channel A-C volume (non-envelope mode)
+ bool envEnable[3]; // Channel A-C envelope enable
+ bool toneEnable[3]; // Channel A-C tone enable
+ bool noiseEnable[3]; // Channel A-C noise enable
+ uint16_t noisePeriod; // Noise period (5 bits * 16)
+ uint32_t envPeriod; // Envelope period (16 bits * 256)
+ bool envAttack; // Envelope Attack bit
+ bool envAlternate; // Envelope Alternate bit
+ bool envHold; // Envelope Hold bit
+ // Internal registers
+ uint16_t count[3]; // Channel A-C current count
+ bool state[3]; // Channel A-C current state
+ uint16_t noiseCount; // Noise current count
+ bool noiseState; // Noise state
+ uint32_t envCount[3]; // Envelope current count
+ int16_t envDirection[3];// Envelope direction (rising, 0, or falling)
+ uint32_t prng; // Psuedo RNG (17 bits)
+ uint8_t regLatch; // Register latch (written by 6522VIA)
+ uint8_t data; // Data lines (written by 6522VIA)
+ uint8_t id; // Chip ID (optional)
+
+ VAY_3_8910();
+ void Reset(void);
+ void WriteControl(uint8_t);
+ void WriteData(uint8_t);
+ void SetRegister(void);
+ uint16_t GetSample(void);
+
+ // Class variables
+
+ // Maximum volume that can be generated by one voice
+ static float maxVolume;
+ // Normalized volumes (zero to one) for AY-3-8910 output, in 16 steps
+ static float normalizedVolume[16];
+};
+
+// Exported variables
+extern bool logAYInternal;
+
+#endif // VAY8910_H
+