Skip to content

Update vga.js - #1622

Open
Godlance wants to merge 1 commit into
copy:masterfrom
Godlance:master
Open

Update vga.js#1622
Godlance wants to merge 1 commit into
copy:masterfrom
Godlance:master

Conversation

@Godlance

Copy link
Copy Markdown

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_buffer ignores svga_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 byte 0 of svga_memory always,
which ignores svga_offset that port1CF_write sets from VBE_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_memory and 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 from 0 gets a display that silently freezes on
whatever was last drawn at offset 0 while the program keeps rendering correctly into the buffer v86 no longer looks at.

2026-08-21_11-23_1

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:

// XXX: Slow, should be ported to rust, but it doesn't have access to vga256_palette
// XXX: Doesn't take svga_offset into account

This PR fixes the second XXX.

I've tested it with Master of Orion 2 and display freeze is fully resolved.

2026-08-21_11-19

This will help any 90s era game that uses page flipping.

fix: prevent image freezes caused by svga_offset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant