
#ifndef YMZ294_SERIAL_H
#define YMZ294_SERIAL_H

#include <Arduino.h>

#define SSG_CHANNELS_PER_CHIP  3

extern void setupSSG();

class SSG_CPU_Interface {
  protected:
    byte writePin; // Arduino pin # for SSG Write Enable pin
    byte registers[14]; // Carbon-copy of YMZ294 internal register value
  private:
    void write(unsigned int);
  public:
    SSG_CPU_Interface(byte);
    void begin();
    void setByte(byte, byte);
};

class SSG : public SSG_CPU_Interface {
  public:
    SSG(byte);
    void begin();
    void setTonePeriod(byte, unsigned int);
    void setNoisePeriod(byte);
    void setMixer(byte, boolean, boolean = false);
    void allMixerOff();
    void setVolume(byte, byte);
    void setVolume(byte);
    void setEnvelopePeriod(unsigned int);
    void startEnvelope(byte);
    void startEnvelope();
};

#endif // YMZ294_SERIAL_H

