Skip to content

Fix graphical vga mode scaling on loading states#1576

Merged
copy merged 3 commits into
copy:masterfrom
JoeOsborn:fix-vga-text-scale-on-restore
Jun 9, 2026
Merged

Fix graphical vga mode scaling on loading states#1576
copy merged 3 commits into
copy:masterfrom
JoeOsborn:fix-vga-text-scale-on-restore

Conversation

@JoeOsborn

Copy link
Copy Markdown
Contributor

I encountered an issue similar to the one described in PR 1123. While using VGA text mode, if I made a save state during text mode and started a fullscreen game that was at a different resolution, then when I loaded the state the canvas size (notably its actual size, not its style) would still be set to a smaller value. This is because the number of rows and columns did not actually change, so the text mode display was not refreshed. I fixed this by adding a force parameter to the involved functions to give a way to ensure that the settings were refreshed even if it seemed locally to the screen code like a no-op.

@copy

copy commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Threading a boolean flag through a bunch of functions doesn't look like a very readable solution. Can you try to find something nicer?

@JoeOsborn

Copy link
Copy Markdown
Contributor Author

Would you prefer having restore first call set_size_text/ set_size_graphical with zeroes or ones, and then call them shortly afterwards again with the real values? Or some explicit reset method on Screen to be called at the beginning of a restore? Another idea is to remove the optimizations where Screen checks that the new values differ from the old ones.

@JoeOsborn

Copy link
Copy Markdown
Contributor Author

I just filed a different bug about graphical text mode, #1579 , and if it is related to initialization somehow maybe the solution is connected to this issue also (but the patch in this PR does not fix it on its own). @chschnell any thoughts? Sorry for the double-ping but I realized you weren't addressed on this PR.

@copy

copy commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Would you prefer having restore first call set_size_text/ set_size_graphical with zeroes or ones, and then call them shortly afterwards again with the real values? Or some explicit reset method on Screen to be called at the beginning of a restore? Another idea is to remove the optimizations where Screen checks that the new values differ from the old ones.

It seems that set_size_graphical_text and set_size_text do things other than just changing the size, so I'd move their body to another function that does all the actual invalidation, and then the set_size functions only implement the check, change the size and call the invalidation function.

@JoeOsborn

Copy link
Copy Markdown
Contributor Author

So I did something slightly different, instead adding a method to invalidate the screen's internal state. I tried to do as you suggested first but it looked like I'd need to duplicate some logic around what exact calls needed to be made during set_state. Instead this roughly matches how the graphical state is invalidated during a state load in graphical mode.

@JoeOsborn

Copy link
Copy Markdown
Contributor Author

Oh, and I'm also happy to combine these into one commit and force push a cleaner history after review but I wanted to give you a chance to review commit-by-commit first.

@JoeOsborn JoeOsborn force-pushed the fix-vga-text-scale-on-restore branch from 7f35971 to 71336ba Compare June 8, 2026 20:12
@copy copy merged commit 7082c55 into copy:master Jun 9, 2026
3 checks passed
@copy

copy commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Thanks! Squashed and merged.

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.

2 participants