added ppu

This commit is contained in:
Lauchmelder 2021-10-23 19:30:02 +02:00
parent 1af2c37b70
commit 19d138fb5f
6 changed files with 216 additions and 3 deletions

View file

@ -4,6 +4,7 @@
#include <memory.h>
#include "cpu.h"
#include "ppu.h"
#include "cartridge.h"
struct Bus* createBus()
@ -35,6 +36,9 @@ struct Bus* createBus()
// Create CPU and attach it
bus->cpu = createCPU(bus);
// Create PPU and attack it
bus->ppu = createPPU(bus);
// Create and insert cartridge
bus->cartridge = createCartridge(bus, "roms/nestest.nes");
@ -46,6 +50,7 @@ struct Bus* createBus()
void destroyBus(struct Bus* bus)
{
destroyCartridge(bus->cartridge);
destroyPPU(bus->ppu);
destroyCPU(bus->cpu);
free(bus->io);
@ -104,5 +109,8 @@ void writeBus(struct Bus* bus, Word addr, Byte val)
void tick(struct Bus* bus)
{
tickInstr(bus->cpu);
for (int i = 0; i < 3; i++)
tickPPU(bus->ppu);
tickCPU(bus->cpu);
}