Modified APU Registers

Adding Internal APU Registers
Adding write & read functions
This commit is contained in:
Melefo
2020-01-28 16:57:37 +01:00
parent 213cf83925
commit 3dde99bf72
2 changed files with 167 additions and 9 deletions
+73 -9
View File
@@ -5,30 +5,37 @@
#ifndef COMSQUARE_APU_HPP
#define COMSQUARE_APU_HPP
#include <memory>
#include "../Memory/IMemory.hpp"
namespace ComSquare::APU
{
struct Registers {
//! @brief The Accumulator register
unsigned char a;
//! @brief The X index register
unsigned char x;
uint8_t x;
//! @brief The Y index register
unsigned char y;
//! @brief The YA register
union {
struct {
//! @brief The Accumulator register
uint8_t a;
//! @brief The Y Index register
uint8_t y;
};
uint16_t ya;
};
//! @brief The Stack pointer register
unsigned char sp;
uint8_t sp;
//! @brief The Program counter register
union {
struct {
unsigned char pch;
unsigned char pcl;
uint8_t pcl;
uint8_t pch;
};
unsigned short pc;
uint16_t pc;
};
//! @brief Program Status Word register
@@ -52,9 +59,66 @@ namespace ComSquare::APU
};
};
struct InternalRegisters
{
//! @brief An undocumented register
uint8_t unknown;
//! @brief Control Register register
uint8_t ctrlreg;
//! @brief DSP Register Address register
uint8_t dspregAddr;
//! @brief DSP Register data register
uint8_t dspregData;
//! @brief Port 0 register
uint8_t port0;
//! @brief Port 1 register
uint8_t port1;
//! @brief Port 2 register
uint8_t port2;
//! @brief Port 3 register
uint8_t port3;
//! @brief Regular Memory register
uint8_t regmem1;
//! @brief Another Regular Memory register
uint8_t regmem2;
//! @brief Timer-0 register
uint8_t timer0;
//! @brief Timer-1 register
uint8_t timer1;
//! @brief Timer-2 register
uint8_t timer2;
//! @brief Counter-0 register
uint8_t counter0;
//! @brief Counter-1 register
uint8_t counter1;
//! @brief Counter-2 register
uint8_t counter2;
};
class APU : IMemory {
private:
Registers _registers;
InternalRegisters _internalRegisters{};
public:
//! @brief Read from the internal APU register.
//! @param addr The address to read from. The address 0xF0 should refer to the first byte of the register.
//! @throw InvalidAddress will be thrown if the address is more than $FF (the number of register).
//! @return Return the value of the register.
uint8_t read(uint24_t addr) override;
//! @brief Write data to the internal APY register.
//! @param addr The address to write to. The address 0xF0 should refer to the first byte of register.
//! @param data The new value of the register.
//! @throw InvalidAddress will be thrown if the address is more than $FF (the number of register).
void write(uint24_t addr, uint8_t data) override;
bool update();
};
}