This commit is contained in:
william 2024-05-04 21:38:09 -04:00
parent ae76160f11
commit 4ac584f633
1 changed files with 24 additions and 0 deletions

View File

@ -19,7 +19,31 @@ void ppu_init(PPU *ppu, byte *registers_ram, byte *oam_dma_register) {
ppu->odd_frame = false; ppu->odd_frame = false;
} }
long frame = 0;
int x, y = 0;
void ppu_cycle(PPU *ppu) { void ppu_cycle(PPU *ppu) {
int frame_width = 341;
int frame_height = 262;
bool rendering_enabled = ppu_read_flag(ppu, PPU_REGISTER_MASK, PPU_MASK_SHOW_BG | PPU_MASK_SHOW_SP);
if (rendering_enabled && ppu->odd_frame) {
// With rendering enabled, the odd frames are shorter
// TODO: and doing the last cycle of the last dummy nametable fetch there instead
frame_width = 339;
frame_height = 261;
}
x++;
if (x >= frame_width) {
x = 0;
y++;
}
if (y >= frame_height) {
y = 0;
frame++;
ppu->odd_frame = !ppu->odd_frame;
}
} }
bool ppu_read_flag(PPU *ppu, size_t reg, byte mask) { bool ppu_read_flag(PPU *ppu, size_t reg, byte mask) {