More PPU code
This commit is contained in:
parent
db3b744ab2
commit
2278082cbb
14
src/Ppu.cpp
14
src/Ppu.cpp
@ -6,7 +6,7 @@
|
||||
|
||||
namespace nes {
|
||||
|
||||
Ppu::Ppu(): _column{}, _scanline{} {
|
||||
Ppu::Ppu(): _column{}, _scanline{}, _status{} {
|
||||
_frameBuffer = std::make_unique<Pixel[]>(SCREEN_WIDTH*SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
@ -32,11 +32,19 @@ namespace nes {
|
||||
}
|
||||
|
||||
void Ppu::write(uint16_t address, uint8_t value) {
|
||||
|
||||
switch (address) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t Ppu::read(uint16_t address) {
|
||||
return 0;
|
||||
switch (address) {
|
||||
case Status:
|
||||
uint8_t value = _status.value & 0xE0;
|
||||
_status.verticalBlank = 0;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
void Ppu::setPixel(uint16_t row, uint16_t column, Pixel pixel) {
|
||||
|
||||
22
src/Ppu.h
22
src/Ppu.h
@ -23,6 +23,27 @@ namespace nes {
|
||||
static constexpr uint16_t SCREEN_WIDTH = 256;
|
||||
static constexpr uint16_t SCREEN_HEIGHT = 240;
|
||||
|
||||
enum ControlAddress: uint16_t {
|
||||
Control = 0x0000,
|
||||
Mask = 0x0001,
|
||||
Status = 0x0002,
|
||||
OamAddress = 0x0003,
|
||||
OamData = 0x0004,
|
||||
Scroll = 0x0005,
|
||||
PpuAddress = 0x0006,
|
||||
PpuData = 0x0007
|
||||
};
|
||||
|
||||
union StatusRegister {
|
||||
struct {
|
||||
uint8_t unused: 5;
|
||||
uint8_t spriteOverflow: 1;
|
||||
uint8_t spriteZeroHit: 1;
|
||||
uint8_t verticalBlank: 1;
|
||||
};
|
||||
uint8_t value;
|
||||
};
|
||||
|
||||
public:
|
||||
Ppu();
|
||||
void tick();
|
||||
@ -36,6 +57,7 @@ namespace nes {
|
||||
private:
|
||||
int16_t _column;
|
||||
int16_t _scanline;
|
||||
StatusRegister _status;
|
||||
std::unique_ptr<Pixel[]> _frameBuffer;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user