2012-04-03 00:47:28 +00:00
|
|
|
struct Registers {
|
|
|
|
struct SoundBias {
|
|
|
|
uint10 level;
|
|
|
|
uint2 amplitude;
|
|
|
|
} bias;
|
2012-04-07 08:17:49 +00:00
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
uint clock;
|
2012-04-03 00:47:28 +00:00
|
|
|
} regs;
|
2012-04-06 04:29:50 +00:00
|
|
|
|
|
|
|
struct Sweep {
|
|
|
|
uint3 shift;
|
|
|
|
uint1 direction;
|
|
|
|
uint3 frequency;
|
|
|
|
|
|
|
|
uint1 enable;
|
|
|
|
uint1 negate;
|
|
|
|
uint3 period;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Envelope {
|
|
|
|
uint3 frequency;
|
|
|
|
uint1 direction;
|
|
|
|
uint4 volume;
|
|
|
|
|
|
|
|
uint3 period;
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto dacEnable() const -> bool { return volume || direction; }
|
2012-04-06 04:29:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Square {
|
|
|
|
Envelope envelope;
|
|
|
|
uint1 enable;
|
|
|
|
uint6 length;
|
|
|
|
uint2 duty;
|
|
|
|
uint11 frequency;
|
|
|
|
uint1 counter;
|
|
|
|
uint1 initialize;
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
int shadowfrequency;
|
2012-04-06 04:29:50 +00:00
|
|
|
uint1 signal;
|
|
|
|
uint4 output;
|
2015-11-16 08:38:05 +00:00
|
|
|
uint period;
|
2012-04-06 04:29:50 +00:00
|
|
|
uint3 phase;
|
|
|
|
uint4 volume;
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto run() -> void;
|
|
|
|
auto clocklength() -> void;
|
|
|
|
auto clockenvelope() -> void;
|
2012-04-06 04:29:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Square1 : Square {
|
|
|
|
Sweep sweep;
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto runsweep(bool update) -> void;
|
|
|
|
auto clocksweep() -> void;
|
|
|
|
auto read(uint addr) const -> uint8;
|
|
|
|
auto write(uint addr, uint8 byte) -> void;
|
|
|
|
auto power() -> void;
|
2012-04-06 04:29:50 +00:00
|
|
|
} square1;
|
|
|
|
|
|
|
|
struct Square2 : Square {
|
2015-11-16 08:38:05 +00:00
|
|
|
auto read(uint addr) const -> uint8;
|
|
|
|
auto write(uint addr, uint8 byte) -> void;
|
|
|
|
auto power() -> void;
|
2012-04-06 04:29:50 +00:00
|
|
|
} square2;
|
|
|
|
|
|
|
|
struct Wave {
|
|
|
|
uint1 mode;
|
|
|
|
uint1 bank;
|
|
|
|
uint1 dacenable;
|
|
|
|
uint8 length;
|
|
|
|
uint3 volume;
|
|
|
|
uint11 frequency;
|
|
|
|
uint1 counter;
|
|
|
|
uint1 initialize;
|
|
|
|
uint4 pattern[32];
|
|
|
|
|
|
|
|
uint1 enable;
|
|
|
|
uint4 output;
|
|
|
|
uint4 patternaddr;
|
|
|
|
uint1 patternbank;
|
|
|
|
uint4 patternsample;
|
2015-11-16 08:38:05 +00:00
|
|
|
uint period;
|
|
|
|
|
|
|
|
auto run() -> void;
|
|
|
|
auto clocklength() -> void;
|
|
|
|
auto read(uint addr) const -> uint8;
|
|
|
|
auto write(uint addr, uint8 byte) -> void;
|
|
|
|
auto readram(uint addr) const -> uint8;
|
|
|
|
auto writeram(uint addr, uint8 byte) -> void;
|
|
|
|
auto power() -> void;
|
2012-04-06 04:29:50 +00:00
|
|
|
} wave;
|
|
|
|
|
|
|
|
struct Noise {
|
|
|
|
Envelope envelope;
|
|
|
|
uint6 length;
|
|
|
|
uint3 divisor;
|
|
|
|
uint1 narrowlfsr;
|
|
|
|
uint4 frequency;
|
|
|
|
uint1 counter;
|
|
|
|
uint1 initialize;
|
|
|
|
|
|
|
|
uint1 enable;
|
|
|
|
uint15 lfsr;
|
|
|
|
uint4 output;
|
2015-11-16 08:38:05 +00:00
|
|
|
uint period;
|
2012-04-06 04:29:50 +00:00
|
|
|
uint4 volume;
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto divider() const -> uint;
|
|
|
|
auto run() -> void;
|
|
|
|
auto clocklength() -> void;
|
|
|
|
auto clockenvelope() -> void;
|
|
|
|
auto read(uint addr) const -> uint8;
|
|
|
|
auto write(uint addr, uint8 byte) -> void;
|
|
|
|
auto power() -> void;
|
2012-04-06 04:29:50 +00:00
|
|
|
} noise;
|
|
|
|
|
|
|
|
struct Sequencer {
|
2012-04-09 06:19:32 +00:00
|
|
|
uint2 volume;
|
2012-04-06 04:29:50 +00:00
|
|
|
uint3 lvolume;
|
|
|
|
uint3 rvolume;
|
|
|
|
uint1 lenable[4];
|
|
|
|
uint1 renable[4];
|
|
|
|
uint1 masterenable;
|
|
|
|
|
2013-12-10 12:12:54 +00:00
|
|
|
uint12 base;
|
2012-04-06 04:29:50 +00:00
|
|
|
uint3 step;
|
|
|
|
int16 lsample;
|
|
|
|
int16 rsample;
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto read(uint addr) const -> uint8;
|
|
|
|
auto write(uint addr, uint8 byte) -> void;
|
|
|
|
auto power() -> void;
|
2012-04-06 04:29:50 +00:00
|
|
|
} sequencer;
|
2012-04-07 08:17:49 +00:00
|
|
|
|
|
|
|
struct FIFO {
|
|
|
|
int8 sample[32];
|
2012-04-09 06:19:32 +00:00
|
|
|
int8 output;
|
|
|
|
|
2012-04-07 08:17:49 +00:00
|
|
|
uint5 rdoffset;
|
|
|
|
uint5 wroffset;
|
|
|
|
uint6 size;
|
|
|
|
|
2012-04-09 06:19:32 +00:00
|
|
|
uint1 volume; //0 = 50%, 1 = 100%
|
|
|
|
uint1 lenable;
|
|
|
|
uint1 renable;
|
|
|
|
uint1 timer;
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto read() -> void;
|
|
|
|
auto write(int8 byte) -> void;
|
|
|
|
auto reset() -> void;
|
|
|
|
auto power() -> void;
|
2012-04-09 06:19:32 +00:00
|
|
|
} fifo[2];
|