PPU
This commit is contained in:
parent
ae76160f11
commit
4ac584f633
24
ppu/ppu.c
24
ppu/ppu.c
|
@ -19,7 +19,31 @@ void ppu_init(PPU *ppu, byte *registers_ram, byte *oam_dma_register) {
|
|||
ppu->odd_frame = false;
|
||||
}
|
||||
|
||||
long frame = 0;
|
||||
int x, y = 0;
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue