basic ppu background rendering

This commit is contained in:
Lauchmelder 2022-03-03 17:29:56 +01:00
parent f9f401c6c0
commit aef80e42fb
No known key found for this signature in database
GPG key ID: C2403C69D78F011D
21 changed files with 468 additions and 41 deletions

61
src/APU.cpp Normal file
View file

@ -0,0 +1,61 @@
#include "APU.hpp"
#include "Bus.hpp"
APU::APU(Bus* bus) :
bus(bus)
{
}
void APU::Powerup()
{
mode = false;
disableInterrupt = false;
}
void APU::Reset()
{
// Nothing for now
}
void APU::Tick()
{
if (cycles == 0)
sequencer = 0;
else
cycles--;
if (!APUActionLatch)
{
APUActionLatch = !APUActionLatch;
return;
}
if (sequencer == 14914 || sequencer == 14915)
{
if(!mode && !disableInterrupt)
bus->IRQ();
if (sequencer == 14915)
sequencer = 0;
}
sequencer++;
APUActionLatch = !APUActionLatch;
}
void APU::WriteRegister(Word addr, Byte val)
{
switch (addr)
{
case 0x4017:
{
mode = ((val & 0x80) == 0x80);
disableInterrupt = ((val & 0x40) == 0x40);
cycles = 3;
if (!APUActionLatch)
cycles++;
} break;
}
}