add memory namespace, update comments
This commit is contained in:
@@ -15,12 +15,32 @@ namespace app {
|
||||
namespace emu {
|
||||
namespace audio {
|
||||
|
||||
using namespace memory;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
const int kApuClockSpeed = 1024000; // 1.024 MHz
|
||||
const int apuSampleRate = 32000; // 32 KHz
|
||||
const int apuClocksPerSample = 64; // 64 clocks per sample
|
||||
|
||||
/**
|
||||
* @class Apu
|
||||
* @brief The Apu class represents the Audio Processing Unit (APU) of a system.
|
||||
*
|
||||
* The Apu class is responsible for generating audio samples and managing the
|
||||
* APU state. It interacts with the Memory, AudioRam, and Clock classes to
|
||||
* read/write data and update the clock. The class also implements the Observer
|
||||
* interface to receive notifications from the system.
|
||||
*
|
||||
* @par IPL ROM Info
|
||||
* 64 kilobytes of RAM are mapped across the 16-bit memory space of the SPC-700.
|
||||
* Some regions of this space are overlaid with special hardware functions.
|
||||
*
|
||||
* Range Note
|
||||
* @par Range Note
|
||||
* $0000-00EF Zero Page RAM
|
||||
* $00F0-00FF Sound CPU Registers
|
||||
* $0100-01FF Stack Page RAM
|
||||
@@ -31,13 +51,7 @@ namespace audio {
|
||||
* underlying RAM can always be written to, and the high bit of the Control
|
||||
* register $F1 can be cleared to unmap the IPL ROM and allow read access to
|
||||
* this RAM.
|
||||
*
|
||||
*/
|
||||
|
||||
const int kApuClockSpeed = 1024000; // 1.024 MHz
|
||||
const int apuSampleRate = 32000; // 32 KHz
|
||||
const int apuClocksPerSample = 64; // 64 clocks per sample
|
||||
|
||||
class Apu : public Observer {
|
||||
public:
|
||||
Apu(MemoryImpl &memory, AudioRam &aram, Clock &clock)
|
||||
|
||||
@@ -16,7 +16,6 @@ using SampleFetcher = std::function<uint8_t(uint16_t)>;
|
||||
using SamplePusher = std::function<void(int16_t)>;
|
||||
|
||||
/**
|
||||
*
|
||||
* The S-DSP is a digital signal processor generating the sound data.
|
||||
*
|
||||
* A DSP register can be selected with $F2, after which it can be read or
|
||||
@@ -35,21 +34,19 @@ using SamplePusher = std::function<void(int16_t)>;
|
||||
* There are 8 voices, numbered 0 to 7.
|
||||
* Each voice X has 10 registers in the range $X0-$X9.
|
||||
*
|
||||
* Name Address Bits Notes
|
||||
* VOL (L) $X0 SVVV VVVV Left channel volume, signed.
|
||||
* VOL (R) $X1 SVVV VVVV Right channel volume, signed.
|
||||
* P (L) $X2 LLLL LLLL Low 8 bits of sample pitch.
|
||||
* P (H) $X3 --HH HHHH High 6 bits of sample pitch.
|
||||
* SCRN $X4 SSSS SSSS Selects a sample source entry from the
|
||||
* directory ADSR (1) $X5 EDDD AAAA ADSR enable (E), decay rate (D),
|
||||
* attack rate (A).
|
||||
* ADSR (2) $X6 SSSR RRRR Sustain level (S), release rate (R).
|
||||
* GAIN $X7 0VVV VVVV 1MMV VVVV Mode (M), value (V).
|
||||
* ENVX $X8 0VVV VVVV Reads current 7-bit value of ADSR/GAIN
|
||||
* envelope.
|
||||
* OUTX $X9 SVVV VVVV Reads signed 8-bit value of current
|
||||
* sample wave multiplied by ENVX, before applying VOL.
|
||||
*
|
||||
* | Name | Address | Bits | Notes |
|
||||
* |---------|---------|-----------|--------------------------------------------------------|
|
||||
* | VOL (L) | $X0 | SVVV VVVV | Left channel volume, signed. |
|
||||
* | VOL (R) | $X1 | SVVV VVVV | Right channel volume, signed. |
|
||||
* | P (L) | $X2 | LLLL LLLL | Low 8 bits of sample pitch. |
|
||||
* | P (H) | $X3 | --HH HHHH | High 6 bits of sample pitch. |
|
||||
* | SCRN | $X4 | SSSS SSSS | Selects a sample source entry from the directory. |
|
||||
* | ADSR (1)| $X5 | EDDD AAAA | ADSR enable (E), decay rate (D), attack rate (A). |
|
||||
* | ADSR (2)| $X6 | SSSR RRRR | Sustain level (S), release rate (R). |
|
||||
* | GAIN | $X7 | 0VVV VVVV 1MMV VVVV | Mode (M), value (V). |
|
||||
* | ENVX | $X8 | 0VVV VVVV | Reads current 7-bit value of ADSR/GAIN envelope. |
|
||||
* | OUTX | $X9 | SVVV VVVV | Reads signed 8-bit value of current sample wave |
|
||||
* | | | | multiplied by ENVX, before applying VOL. |
|
||||
*/
|
||||
|
||||
class DigitalSignalProcessor {
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace app {
|
||||
namespace emu {
|
||||
namespace audio {
|
||||
|
||||
/**
|
||||
* @brief AudioRam is an interface for the Audio RAM used by the SPC700.
|
||||
*/
|
||||
class AudioRam {
|
||||
public:
|
||||
virtual ~AudioRam() = default;
|
||||
@@ -20,6 +23,9 @@ class AudioRam {
|
||||
virtual void write(uint16_t address, uint8_t value) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief AudioRamImpl is an implementation of the AudioRam interface.
|
||||
*/
|
||||
class AudioRamImpl : public AudioRam {
|
||||
static const int ARAM_SIZE = 0x10000;
|
||||
std::vector<uint8_t> ram = std::vector<uint8_t>(ARAM_SIZE, 0);
|
||||
@@ -41,6 +47,17 @@ class AudioRamImpl : public AudioRam {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Spc700
|
||||
* @brief The Spc700 class represents the SPC700 processor.
|
||||
*
|
||||
* The Spc700 class provides the functionality to execute instructions, read and
|
||||
* write memory, and handle various addressing modes. It also contains registers
|
||||
* and flags specific to the SPC700.
|
||||
*
|
||||
* @note This class assumes the existence of an `AudioRam` object for memory
|
||||
* access.
|
||||
*/
|
||||
class Spc700 {
|
||||
private:
|
||||
AudioRam& aram_;
|
||||
|
||||
Reference in New Issue
Block a user