Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

override some scale settings; finer-grained SDL init #2007

Merged
merged 1 commit into from
Oct 6, 2022
Merged

override some scale settings; finer-grained SDL init #2007

merged 1 commit into from
Oct 6, 2022

Conversation

dhorlick
Copy link

Problem

TIC-80's uiScale currently defaults to 4. This turns out to be a poor choice for everybody's favorite maybe-still-supported platform, the PocketC.H.I.P., which lacks a screen large enough to accommodate it.

For whatever reason (maybe issue 1904?), recent TIC-80 builds also perform very badly at scale 4 on the PocketC.H.I.P., taking more than a minute to start up and then missing many keystrokes.

misframed

I recorded the image above after twice failing to "exit". Note that the cursor is not visible.

Additionally, sound is currently broken for TIC-80 on the PocketC.H.I.P. (but not for other SDL2 applications.) That is not a big problem by itself, but will complicate the implementation of a screen-framing fix slightly.

Solution

A sophisticated user can circumvent the screen-framing problem on PocketC.H.I.P. by explicitly reconfiguring uiScale to a lower value. This pull request seeks to address the problem (and indirectly, also the worst of the performance issues) for all PocketC.H.I.P. users by conditionally overriding the uiScale setting, without prompting. Here's how:

  1. Attempt to check the screen bounds with SDL2 on startup. If they are reported, wait until defaults have been applied and file configuration has been loaded. Then, if screen bounds were reported, determine whether the prescribed uiScale would fit. If they would not, reduce uiScreen to the largest agreeable value. Note that the user will still be permitted to specify any scale they want (without a fail-safe) from the command line.
  2. Currently, TIC-80 attempts to initialize all SDL2 subsystems in tandem. Because the sound is broken, this initialization technically fails. That failure seems to compromise SDL2's ability (at least immediately) to report on screen bounds. The workaround is to initialize SDL2 subsystems separately. If the video subsystem fails to initialize, report the problem and quit immediately, because there's no chance TIC-80 will be able to perform productive work. If the sound (or joystick) subsystem fails to initialize, report the problem but keep going.

I have tested this successfully on Ubuntu 20.04.4 and of course on the PocketC.H.I.P., whose new effective default uiScale of 2 is still somewhat slow, but no longer accompanied by lots of missed keystrokes.

I expect most systems should see no change from this pull request, but I can imagine a few others (smartwatches, LED boards, etc.) for which it might be useful.

Feel free to repurpose code from this pull request if that would be more convenient than merging all of it.

@dhorlick
Copy link
Author

dhorlick commented Sep 4, 2022

Looks like there isn’t any interest in this. Will close next week if there hasn’t been any activity.

@asiekierka
Copy link
Contributor

This is a good PR! @nesbox The world of various ARM handhelds is one worth supporting.

@nesbox
Copy link
Owner

nesbox commented Sep 9, 2022

I'm now distracted by another project, this weekend I'll try to review and merge.
Sorry for the inactivity, I hope to be back on TIC-80 soon.

@dhorlick
Copy link
Author

No worries, we all can relate!

Thanks, everybody.

Copy link
Owner

@nesbox nesbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge it, sorry for so long code review.

@nesbox nesbox merged commit 7f4ad78 into nesbox:main Oct 6, 2022
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.

3 participants