Skip to content

Commit

Permalink
Read LY directly from io_registers in PPU (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
kremi151 committed Aug 15, 2020
1 parent b1ad0a8 commit 575fc96
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/source/emulator/io_registers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ u8 &io_registers::getSCY() {
return *(hwIO + FB_REG_OFFSET_SCY);
}

u8 &io_registers::getLY() {
return *(hwIO + FB_REG_OFFSET_LY);
}

u8 &io_registers::getBGP() {
return *(hwIO + FB_REG_OFFSET_BGP);
}
Expand Down
1 change: 1 addition & 0 deletions core/source/emulator/io_registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace FunkyBoy {
u8 &getLCDC();
u8 &getSCX();
u8 &getSCY();
u8 &getLY();
u8 &getBGP();
u8 &getOBP0();
u8 &getOBP1();
Expand Down
4 changes: 2 additions & 2 deletions core/source/emulator/ppu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ ret_code PPU::doClocks(u8 clocks) {
// See https://gbdev.gg8.se/wiki/articles/Video_Display#VRAM_Tile_Data
// See http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf (pages 22-27)

auto lcdc = memory->read8BitsAt(FB_REG_LCDC);
auto lcdc = ioRegisters.getLCDC();
if (!__fb_lcdc_isOn(lcdc)) {
ioRegisters.updateLCD(false, gpuMode /* TODO: Correct* */, 0x00);
return FB_RET_SUCCESS; // TODO: Correct?
}

ret_code result = FB_RET_SUCCESS;
auto ly = memory->read8BitsAt(FB_REG_LY);
auto ly = ioRegisters.getLY();

modeClocks += clocks;
switch (gpuMode) {
Expand Down

0 comments on commit 575fc96

Please sign in to comment.