added ppu register access
This commit is contained in:
parent
19d138fb5f
commit
7c0957325f
7 changed files with 113 additions and 19 deletions
|
@ -33,15 +33,15 @@ struct Bus* createBus()
|
|||
}
|
||||
memset(bus->ram, 0x00, 0x18);
|
||||
|
||||
// Create and insert cartridge
|
||||
bus->cartridge = createCartridge(bus, "roms/nestest.nes");
|
||||
|
||||
// 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");
|
||||
|
||||
printf("Reset vector: $%x\n", ((Word)readCartridge(bus->cartridge, 0xFFFD) << 8) | (readCartridge(bus->cartridge, 0xFFFC)));
|
||||
|
||||
return bus;
|
||||
|
@ -49,9 +49,9 @@ struct Bus* createBus()
|
|||
|
||||
void destroyBus(struct Bus* bus)
|
||||
{
|
||||
destroyCartridge(bus->cartridge);
|
||||
destroyPPU(bus->ppu);
|
||||
destroyCPU(bus->cpu);
|
||||
destroyCartridge(bus->cartridge);
|
||||
|
||||
free(bus->io);
|
||||
free(bus->ram);
|
||||
|
@ -67,6 +67,10 @@ Byte readBus(struct Bus* bus, Word addr)
|
|||
{
|
||||
val = bus->ram[addr & 0x7FF];
|
||||
}
|
||||
else if (0x2000 <= addr && addr < 0x4000)
|
||||
{
|
||||
val = ppuRead(bus->ppu, addr & 0x2007);
|
||||
}
|
||||
else if (0x4000 <= addr && addr <= 0x4017) // I/O space
|
||||
{
|
||||
val = bus->io[addr - 0x4000];
|
||||
|
@ -91,6 +95,10 @@ void writeBus(struct Bus* bus, Word addr, Byte val)
|
|||
{
|
||||
bus->ram[addr & 0x7FF] = val;
|
||||
}
|
||||
else if (0x2000 <= addr && addr < 0x4000)
|
||||
{
|
||||
ppuWrite(bus->ppu, addr & 0x2007, val);
|
||||
}
|
||||
else if (0x4000 <= addr && addr <= 0x4017) // I/O space
|
||||
{
|
||||
bus->io[addr - 0x4000] = val;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue