Emulator: Fix PPU clocks and LCD offsets

This commit is contained in:
Riyyi
2022-10-16 21:40:58 +02:00
parent c0c592c438
commit 5e6972e4da
2 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -43,9 +43,9 @@ void Loader::init()
{
destroy();
Emu::the().init(8000000);
Emu::the().init(4000000);
auto cpu = std::make_shared<CPU>(8000000);
auto cpu = std::make_shared<CPU>(4000000);
auto ppu = std::make_shared<PPU>(4000000);
Emu::the().addProcessingUnit("CPU", cpu);
+5 -5
View File
@@ -48,7 +48,7 @@ void PPU::update()
case State::OAMSearch:
// OAM logic goes here..
if (m_clocks_into_frame % 20 == 0) {
if (m_clocks_into_frame % 80 == 0) {
m_state = State::PixelTransfer;
}
break;
@@ -64,26 +64,26 @@ void PPU::update()
case State::HBlank:
// H-Blank logic goes here..
if (m_clocks_into_frame % (20 + 43 + 51) == 0) {
if (m_clocks_into_frame % (80 + 172 + 204) == 0) {
m_lcd_y_coordinate++;
if (m_lcd_y_coordinate == 144) {
m_state = State::VBlank;
}
else {
m_state = State::OAMSearch;
}
m_lcd_y_coordinate++;
}
break;
case State::VBlank:
// V-Blank logic goes here..
if (m_clocks_into_frame % (20 + 43 + 51) == 0) {
if (m_clocks_into_frame % (80 + 172 + 204) == 0) {
m_lcd_y_coordinate++;
if (m_lcd_y_coordinate == 154) {
m_lcd_y_coordinate = 0;
m_clocks_into_frame = 0;
m_state = State::OAMSearch;
}
m_lcd_y_coordinate++;
}
break;