lgblgblgb / xemu

Emulations (running on Linux/Unix/Windows/macOS, utilizing SDL2) of some - mainly - 8 bit machines, including the Commodore LCD, Commodore 65, and the MEGA65 as well.
https://github.com/lgblgblgb/xemu/wiki
GNU General Public License v2.0
207 stars 32 forks source link

Fix for issue #353 RRB is drawing outside top border #412

Closed RetroCogs closed 2 months ago

RetroCogs commented 2 months ago

Ok, so when vic4_render_char_raster is called it starts at CHARGEN_Y_START but this value can be < BORDER_Y_TOP, the fix here is to skip a line and fill with BORDER_COLOR if the requested line < BORDER_Y_TOP.

lgblgblgb commented 2 months ago

That's really interesting. I have the suspect that the problem should be handled in vic4_render_scanline(), so vic4_render_char_raster() should be not even called in a case like our problematic one. As that function already should handle that, here:

// Top and bottom borders
if (ycounter < BORDER_Y_TOP || ycounter >= BORDER_Y_BOTTOM || !REG_DISPLAYENABLE) {
    for (int i = 0; i < TEXTURE_WIDTH; i++)
        *(current_pixel++) = palette[REG_BORDER_COLOR];
}

However this would take a bigger investigation, and your commit can provide an easy-and-fast fix till that, thank you!