srctree

Johan parent fd3a5130 b0351811 a66ddee8
Merge pull request #353 from johnor/ppu-unused-nametable-fetches

Add unused fetches at the end of visible and pre-render scanlines
core/src/ppu.cpp added: 13, removed: 4, total 9
@@ -418,6 +418,13 @@ void Ppu::fetch() {
break;
}
};
} else if (cycle() == 337 || cycle() == 339) {
// Unused fetches. Uses the same nametable address as will be fetched
// at the beginning of the next scanline (tile 3 since tile 1 and 2
// were fetched already in the end of this scanline).
const uint16_t nametable_address =
get_nametable_address(registers_->vram_addr);
registers_->name_table_latch = mmu_->read_byte(nametable_address);
}
}
 
 
core/test/src/test_ppu.cpp added: 13, removed: 4, total 9
@@ -537,9 +537,10 @@ TEST_F(PpuTest, visible_scanline) {
EXPECT_EQ(expected, registers);
 
// Finally cycle 337-340.
// Two nametable fetches (TODO: not implemented).
// Two unused nametable fetches.
expected.scanline = 1;
expected.cycle = 0;
EXPECT_CALL(mmu, read_byte(0x2000 + 2)).Times(2).WillRepeatedly(Return(2));
for (int i = 337; i <= 340; ++i) {
ppu->execute();
}
@@ -674,9 +675,10 @@ TEST_F(PpuTest, pre_render_scanline) {
EXPECT_EQ(expected, registers);
 
// Finally cycle 337-340.
// Two unused nametable fetches (not implemented).
// Two unused nametable fetches.
expected.scanline = 0;
expected.cycle = 0;
EXPECT_CALL(mmu, read_byte(0x2000 + 2)).Times(2).WillRepeatedly(Return(2));
for (int i = 337; i <= 340; ++i) {
ppu->execute();
}