Update vga.js - #1622
Conversation
fix: prevent image freezes caused by svga_offset
|
From your description, it's not clear to me that this game actually uses the wraparound behavior. I have pushed an alternative fix that clamps instead (like the other bpps). Could you test that this fixed the issue? |
Yeah, sorry for taking so long.
I was using a release version of libv86.js instead of compiling one with your changes, sorry. After compiling and testing I can assure that your fix works just as well, thank you! |
|
Thanks for diagnosing the issue and testing! |
fix: prevent image freezes caused by svga_offset
This PR fixes a screen freeze in some svga dependant games.
The SVGA 8bpp fast path in
screen_fill_bufferignoressvga_offset, causing permanent display freezes with page-flipped double buffering.VGAScreen.prototype.screen_fill_buffer's fast path for 8bpp SVGA modes reads the displayed frame starting at byte0ofsvga_memoryalways, which ignoressvga_offsetthatport1CF_writesets fromVBE_DISPI_INDEX_X_OFFSET/VBE_DISPI_INDEX_Y_OFFSET.This is the standard VBE "Set Display Start" call that real VESA-aware software uses for page-flipped double buffering, it renders the next frame into a back buffer elsewhere in
svga_memoryand then flips the display-start offset to it instead of copying pixels.Since this fast path always paints from offset
0, any program that flips the display start away from0gets a display that silently freezes on whatever was last drawn at offset0while the program keeps rendering correctly into the buffer v86 no longer looks at.Given that there is no error, it was really hard to debug from my side.
The existing code already has a comment to this fact:
This PR fixes the second XXX.
I've tested it with Master of Orion 2 and display freeze is fully resolved.
This will help any 90s era game that uses page flipping.
Edit: Formatting.