diff --git a/src/app/emu/ppu.cc b/src/app/emu/ppu.cc new file mode 100644 index 00000000..604ba491 --- /dev/null +++ b/src/app/emu/ppu.cc @@ -0,0 +1,78 @@ +#include "app/emu/ppu.h" + +#include +#include +#include + +#include "app/emu/mem.h" + +namespace yaze { +namespace app { +namespace emu { + +PPU::PPU(Memory& memory) : memory_(memory) {} + +void PPU::Init() { + // Initialize registers + // ... +} + +void PPU::RenderScanline() { + // Render background layers + // ... + + // Render sprites + // ... +} + +void PPU::Run(int cycles) { + // ... +} + +uint8_t PPU::ReadRegister(uint16_t address) { + // ... +} + +void PPU::WriteRegister(uint16_t address, uint8_t value) { + // ... +} + +const std::vector& PPU::GetFrameBuffer() const { + // ... +} + +void PPU::UpdateModeSettings() { + // ... +} + +void PPU::RenderBackground(int layer) { + // ... +} + +void PPU::RenderSprites() { + // ... +} + +uint32_t PPU::GetPaletteColor(uint8_t colorIndex) { + // ... +} + +uint8_t PPU::ReadVRAM(uint16_t address) { + // ... +} + +void PPU::WriteVRAM(uint16_t address, uint8_t value) { + // ... +} + +uint8_t PPU::ReadOAM(uint16_t address) { + // ... +} + +void PPU::WriteOAM(uint16_t address, uint8_t value) { + // ... +} + +} // namespace emu +} // namespace app +} // namespace yaze diff --git a/src/app/emu/ppu.h b/src/app/emu/ppu.h new file mode 100644 index 00000000..d9adcd4b --- /dev/null +++ b/src/app/emu/ppu.h @@ -0,0 +1,73 @@ +#ifndef YAZE_APP_EMU_PPU_H +#define YAZE_APP_EMU_PPU_H + +#include +#include + +#include "app/emu/mem.h" + +namespace yaze { +namespace app { +namespace emu { + +class PPU { + public: + // Initializes the PPU with the necessary resources and dependencies + PPU(Memory &memory); + + void Init(); + + // Resets the PPU to its initial state + void Reset(); + + // Runs the PPU for a specified number of clock cycles + void Run(int cycles); + + // Reads a byte from the specified PPU register + uint8_t ReadRegister(uint16_t address); + + // Writes a byte to the specified PPU register + void WriteRegister(uint16_t address, uint8_t value); + + // Renders a scanline of the screen + void RenderScanline(); + + // Returns the pixel data for the current frame + const std::vector &GetFrameBuffer() const; + + private: + // Internal methods to handle PPU rendering and operations + + // Updates internal state based on PPU register settings + void UpdateModeSettings(); + + // Renders a background layer + void RenderBackground(int layer); + + // Renders sprites (also known as objects) + void RenderSprites(); + + // Retrieves a pixel color from the palette + uint32_t GetPaletteColor(uint8_t colorIndex); + + // Handles VRAM (Video RAM) reads and writes + uint8_t ReadVRAM(uint16_t address); + void WriteVRAM(uint16_t address, uint8_t value); + + // Handles OAM (Object Attribute Memory) reads and writes + uint8_t ReadOAM(uint16_t address); + void WriteOAM(uint16_t address, uint8_t value); + + // Other internal methods for handling PPU functionality + + // Member variables to store internal PPU state and resources + Memory &memory_; + std::vector frameBuffer_; + // Other state variables (registers, counters, mode settings, etc.) +}; + +} // namespace emu +} // namespace app +} // namespace yaze + +#endif // YAZE_APP_EMU_PPU_H \ No newline at end of file