added latch to ppu

This commit is contained in:
Lauchmelder 2022-02-28 17:14:32 +01:00
parent 7e50290634
commit 2b00f1ecb2
No known key found for this signature in database
GPG key ID: C2403C69D78F011D
2 changed files with 54 additions and 12 deletions

View file

@ -4,6 +4,9 @@
class Bus;
/**
* @brief The PPU of the NES.
*/
class PPU
{
friend class PPUWatcher;
@ -11,18 +14,49 @@ class PPU
public:
PPU(Bus* bus);
/**
* @brief Powerup PPU.
* Internal state corresponds to powerup state
*/
void Powerup();
/**
* @brief Powerup PPU.
* Internal state corresponds to reset state
*/
void Reset();
/**
* @brief Tick PPU forward once.
*/
void Tick();
/**
* @brief Read from memory mapped PPU regs.
*/
Byte ReadRegister(Byte id);
/**
* @brief Write to memory mapped PPU regs.
*/
void WriteRegister(Byte id, Byte val);
/**
* @brief Check whether the PPU finished rendering a frame.
* Returns true if the VBlankStart cycle was hit previously. The function resets
* the boolearn when it is called
*/
inline bool IsFrameDone() { bool returnVal = isFrameDone; isFrameDone = false; return returnVal; }
private:
/**
* @brief Wraps Bus::ReadPPU.
*/
Byte Read(Word addr);
/**
* @brief Wraps Bus::WritePPU.
*/
void Write(Word addr, Byte val);
private: // Registers
@ -81,8 +115,10 @@ private: // Registers
Address ppuaddr;
// Current x, y position the PPU operates on
uint16_t x, y;
Byte addressLatch = 0;
Byte latch = 0;
bool addressLatch = false;
private:
bool isFrameDone = false;