Adding PPU stub class
This commit is contained in:
parent
d3401cd3af
commit
4abf87e278
@ -16,7 +16,7 @@ add_executable(nes
|
||||
src/Mapper/Mapper.cpp
|
||||
src/Mapper/Mapper.h
|
||||
src/Mapper/Mapper0.cpp
|
||||
src/Mapper/Mapper0.h)
|
||||
src/Mapper/Mapper0.h src/Ppu.cpp src/Ppu.h)
|
||||
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
target_link_libraries(nes PRIVATE SDL2::SDL2)
|
||||
@ -29,7 +29,10 @@ namespace nes {
|
||||
|
||||
size_t ticks = 0;
|
||||
while (ticks <= 15000) {
|
||||
_ppu->tick();
|
||||
if(ticks % 3 == 0) {
|
||||
_cpu->tick();
|
||||
}
|
||||
ticks++;
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
|
||||
#include "Cpu.h"
|
||||
#include "Cartridge.h"
|
||||
#include "Ppu.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
@ -22,6 +24,7 @@ namespace nes {
|
||||
|
||||
private:
|
||||
std::unique_ptr<Cpu> _cpu;
|
||||
std::shared_ptr<Ppu> _ppu;
|
||||
std::shared_ptr<Cartridge> _cartridge;
|
||||
};
|
||||
|
||||
|
||||
26
src/Ppu.cpp
Normal file
26
src/Ppu.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by selim on 8/22/23.
|
||||
//
|
||||
|
||||
#include "Ppu.h"
|
||||
|
||||
namespace nes {
|
||||
|
||||
Ppu::Ppu(): _column{}, _scanline{} {
|
||||
|
||||
}
|
||||
|
||||
void Ppu::tick() {
|
||||
|
||||
|
||||
_column++;
|
||||
if(_column >= 341) {
|
||||
_column = 0;
|
||||
_scanline++;
|
||||
|
||||
if(_scanline >= 261) {
|
||||
_scanline = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user