| e8555c89 Andy McCall |
1 |
#ifndef SCC_HH |
| 2 |
#define SCC_HH |
| 3 |
|
| 4 |
#include "ResampledSoundDevice.hh" |
| 5 |
|
| 6 |
#include "Clock.hh" |
| 7 |
#include "SimpleDebuggable.hh" |
| 8 |
|
| 9 |
#include <array> |
| 10 |
#include <cstdint> |
| 11 |
|
| 12 |
namespace openmsx { |
| 13 |
|
| 14 |
class SCC final : public ResampledSoundDevice |
| 15 |
{ |
| 16 |
public: |
| 17 |
enum class Mode : uint8_t {Real, Compatible, Plus}; |
| 18 |
|
| 19 |
SCC(const std::string& name, const DeviceConfig& config, |
| 20 |
EmuTime time, Mode mode = Mode::Real); |
| 21 |
~SCC(); |
| 22 |
|
| 23 |
|
| 24 |
void powerUp(EmuTime time); |
| 25 |
void reset(EmuTime time); |
| 26 |
[[nodiscard]] uint8_t readMem(uint8_t address,EmuTime time); |
| 27 |
[[nodiscard]] uint8_t peekMem(uint8_t address,EmuTime time) const; |
| 28 |
void writeMem(uint8_t address, uint8_t value, EmuTime time); |
| 29 |
void setMode(Mode newMode); |
| 30 |
|
| 31 |
|
| 32 |
[[nodiscard]] const std::array<std::array<int8_t, 32>, 5>& getWaveData() const { return wave; } |
| 33 |
|
| 34 |
template<typename Archive> |
| 35 |
void serialize(Archive& ar, unsigned version); |
| 36 |
|
| 37 |
private: |
| 38 |
|
| 39 |
[[nodiscard]] float getAmplificationFactorImpl() const override; |
| 40 |
void generateChannels(std::span<float*> bufs, unsigned num) override; |
| 41 |
|
| 42 |
[[nodiscard]] uint8_t readWave(unsigned channel, unsigned address, EmuTime time) const; |
| 43 |
void writeWave(unsigned channel, unsigned address, uint8_t value); |
| 44 |
void setDeformReg(uint8_t value, EmuTime time); |
| 45 |
void setDeformRegHelper(uint8_t value); |
| 46 |
void setFreqVol(unsigned address, uint8_t value, EmuTime time); |
| 47 |
[[nodiscard]] uint8_t getFreqVol(unsigned address) const; |
| 48 |
|
| 49 |
private: |
| 50 |
static constexpr int CLOCK_FREQ = 3579545; |
| 51 |
|
| 52 |
struct Debuggable final : SimpleDebuggable { |
| 53 |
Debuggable(MSXMotherBoard& motherBoard, const std::string& name); |
| 54 |
[[nodiscard]] uint8_t read(unsigned address, EmuTime time) override; |
| 55 |
void write(unsigned address, uint8_t value, EmuTime time) override; |
| 56 |
} debuggable; |
| 57 |
|
| 58 |
Clock<CLOCK_FREQ> deformTimer; |
| 59 |
Mode currentMode; |
| 60 |
|
| 61 |
std::array<std::array<int8_t, 32>, 5> wave; |
| 62 |
std::array<std::array<float, 32>, 5> volAdjustedWave; |
| 63 |
std::array<unsigned, 5> incr; |
| 64 |
std::array<unsigned, 5> count; |
| 65 |
std::array<unsigned, 5> pos; |
| 66 |
std::array<unsigned, 5> period; |
| 67 |
std::array<unsigned, 5> orgPeriod; |
| 68 |
std::array<float, 5> out; |
| 69 |
std::array<uint8_t, 5> volume; |
| 70 |
uint8_t ch_enable; |
| 71 |
|
| 72 |
uint8_t deformValue; |
| 73 |
std::array<bool, 5> rotate; |
| 74 |
std::array<bool, 5> readOnly; |
| 75 |
}; |
| 76 |
|
| 77 |
} |
| 78 |
|
| 79 |
#endif |