Emulator: Fix pixel FIFO x-coordinate offset

This commit is contained in:
Riyyi
2022-10-17 15:51:16 +02:00
parent adb290a7c7
commit 00ceacaf52
2 changed files with 6 additions and 11 deletions
+5 -11
View File
@@ -49,9 +49,8 @@ void PPU::update()
// OAM logic goes here..
if (m_clocks_into_frame % 80 == 0) {
// Clear FIFOs
m_pixel_fifo.background = {};
m_pixel_fifo.oam = {};
// Reset FIFO
m_pixel_fifo = {};
m_state = State::PixelTransfer;
}
@@ -83,9 +82,7 @@ void PPU::update()
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;
resetFrame();
}
}
@@ -160,7 +157,8 @@ void PPU::pixelFifo()
// Read the tile map index
uint16_t offset = (((m_viewport_y + m_lcd_y_coordinate) / TILE_HEIGHT) * 32)
+ ((m_viewport_x + m_lcd_x_coordinate) / TILE_WIDTH);
+ ((m_viewport_x + m_pixel_fifo.x_coordinate) / TILE_WIDTH);
m_pixel_fifo.x_coordinate += 8;
m_pixel_fifo.tile_index = Emu::the().readMemory(bg_tile_map_address + offset) & 0xff;
// Set the tile line we're currently on
@@ -305,8 +303,4 @@ void PPU::resetFrame()
m_clocks_into_frame = 0;
m_lcd_x_coordinate = 0;
m_lcd_y_coordinate = 0;
// Clear FIFOs
m_pixel_fifo.background = {};
m_pixel_fifo.oam = {};
}
+1
View File
@@ -64,6 +64,7 @@ public:
State state = State::TileIndex;
bool step = false;
uint8_t x_coordinate = 0;
uint8_t tile_index = 0;
uint8_t tile_line = 0;
uint8_t pixels_lsb = 0;