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

View file

@ -8,8 +8,9 @@ Mapper000::Mapper000(const Header& header, std::ifstream& ifs) :
Mapper(header)
{
LOG_CORE_INFO("Allocating PRG ROM");
PRG_ROM = std::vector<Byte>(0x4000);
ifs.read((char*)PRG_ROM.data(), 0x4000);
prgBanks = header.PrgROM;
PRG_ROM = std::vector<Byte>(0x4000 * prgBanks);
ifs.read((char*)PRG_ROM.data(), 0x4000 * prgBanks);
LOG_CORE_INFO("Allocating CHR ROM");
CHR_ROM = std::vector<Byte>(0x2000);
@ -20,7 +21,7 @@ Byte Mapper000::ReadCPU(Word addr)
{
if (0x8000 <= addr && addr <= 0xFFFF)
{
return PRG_ROM[addr & 0x03FFF];
return PRG_ROM[addr & (prgBanks * 0x4000 - 1)];
}
return 0x00;

View file

@ -16,4 +16,7 @@ public:
virtual Byte ReadPPU(Word addr) override;
virtual void WriteCPU(Word addr, Byte val) override;
virtual void WritePPU(Word addr, Byte val) override;
private:
Byte prgBanks = 0;
};