Refactor PPU and CPU classes by removing Clock dependency and updating constructors

This commit is contained in:
scawful
2025-01-18 00:12:12 -05:00
parent 70510ec0e9
commit 1c53ba24c5
7 changed files with 10 additions and 454 deletions

View File

@@ -36,8 +36,6 @@ static const int kBitDepthsPerMode[10][4] = {
static const int kSpriteSizes[8][2] = {{8, 16}, {8, 32}, {8, 64}, {16, 32},
{16, 64}, {32, 64}, {16, 32}, {16, 32}};
void Ppu::Update() {}
void Ppu::Reset() {
memset(vram, 0, sizeof(vram));
vram_pointer = 0;

View File

@@ -5,7 +5,6 @@
#include <cstdint>
#include <vector>
#include "app/emu/cpu/clock.h"
#include "app/emu/memory/memory.h"
#include "app/emu/video/ppu_registers.h"
#include "app/rom.h"
@@ -254,7 +253,7 @@ struct BackgroundLayer {
class Ppu : public SharedRom {
public:
// Initializes the PPU with the necessary resources and dependencies
Ppu(Memory& memory, Clock& clock) : memory_(memory), clock_(clock) {}
Ppu(Memory& memory) : memory_(memory) {}
// Initialize the frame buffer
void Init() {
@@ -262,13 +261,7 @@ class Ppu : public SharedRom {
pixelOutputFormat = 1;
}
// Resets the PPU to its initial state
void Reset();
// Runs the PPU for one frame.
void Update();
void UpdateClock(double delta_time) { clock_.UpdateClock(delta_time); }
void HandleFrameStart();
void RunLine(int line);
void HandlePixel(int x, int y);
@@ -433,7 +426,6 @@ class Ppu : public SharedRom {
uint16_t screen_brightness_ = 0x00;
Memory& memory_;
Clock& clock_;
Tilemap tilemap_;
BackgroundMode bg_mode_;