X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvay8910.h;fp=src%2Fvay8910.h;h=4eb0fe94957fbbbb12ecd50d17c2bde3af9c37fb;hb=66a747c7d92af86ebdfaf136cf5506a7ab714fd0;hp=0000000000000000000000000000000000000000;hpb=6bdd378e27a9bbf3a074e9c33c61195c8fcfef1c;p=apple2 diff --git a/src/vay8910.h b/src/vay8910.h new file mode 100644 index 0000000..4eb0fe9 --- /dev/null +++ b/src/vay8910.h @@ -0,0 +1,57 @@ +// +// Virtual AY-3-8910 Emulator +// +// by James Hammons +// (C) 2018 Underground Software +// + +#ifndef VAY8910_H +#define VAY8910_H + +#include + +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 +