implemented background tile fetching
This commit is contained in:
parent
f4e6198a99
commit
e7b78f281f
9 changed files with 474 additions and 131 deletions
60
src/PPU.hpp
60
src/PPU.hpp
|
@ -4,6 +4,44 @@
|
|||
|
||||
class Bus;
|
||||
|
||||
enum class ScanlineType
|
||||
{
|
||||
PreRender,
|
||||
Visible,
|
||||
PostRender,
|
||||
VBlank
|
||||
};
|
||||
|
||||
enum class CycleType
|
||||
{
|
||||
Idle,
|
||||
Fetching,
|
||||
SpriteFetching,
|
||||
PreFetching,
|
||||
UnknownFetching
|
||||
};
|
||||
|
||||
enum class FetchingPhase
|
||||
{
|
||||
NametableByte,
|
||||
AttributeTableByte,
|
||||
PatternTableLo,
|
||||
PatternTableHi
|
||||
};
|
||||
|
||||
union VRAMAddress
|
||||
{
|
||||
struct
|
||||
{
|
||||
Byte CoarseX : 5;
|
||||
Byte CoarseY : 5;
|
||||
Byte NametableSel : 2;
|
||||
Byte FineY : 3;
|
||||
};
|
||||
|
||||
Word Raw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The PPU of the NES.
|
||||
*/
|
||||
|
@ -59,6 +97,9 @@ private:
|
|||
*/
|
||||
void Write(Word addr, Byte val);
|
||||
|
||||
void UpdateState();
|
||||
void PerformRenderAction();
|
||||
|
||||
private: // Registers
|
||||
|
||||
union
|
||||
|
@ -115,12 +156,25 @@ private: // Registers
|
|||
|
||||
Address ppuaddr;
|
||||
|
||||
// Current x, y position the PPU operates on
|
||||
uint16_t x, y;
|
||||
Byte latch = 0;
|
||||
VRAMAddress current{ 0 };
|
||||
VRAMAddress temporary{ 0 };
|
||||
uint16_t fineX;
|
||||
bool addressLatch = false;
|
||||
|
||||
Byte latch = 0;
|
||||
|
||||
Word x, y;
|
||||
Byte nametableByte = 0x00;
|
||||
Byte attributeTableByte = 0x00;
|
||||
Byte patternTableLo = 0x00;
|
||||
Byte patternTableHi = 0x00;
|
||||
|
||||
private:
|
||||
ScanlineType scanlineType;
|
||||
CycleType cycleType;
|
||||
FetchingPhase fetchPhase;
|
||||
|
||||
uint8_t memoryAccessLatch = 0;
|
||||
bool isFrameDone = false;
|
||||
Bus* bus;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue