Make picopolis work#28
Open
mibus wants to merge 3 commits into
Open
Conversation
This passes a callback from the Game View to the Lua bridge, so that flip can call back in to SDL. While there's some overlap with ::render(), the latter has some better knowledge (like whether the game is paused) which makes it hard to share the code directly with ::flip(). While here, rearrange the init code a little so that things are all started before the game's Lua code is first loaded; Picopolis calls flip() immediately rather than waiting for _init or _update.
These are implemented by some games (e.g. Picopolis) as function pointers, so their existence and destination can change at each call. _init must exist immediately so is not handled the same way. (Note that this means hasUpdate etc may be out-of-date in these cases; they aren't currently used AFAICT so it might be better to just remove them - a call will be ignored if it doesn't exist!)
SDL_RenderPresent() is SDL2-only, so now it should work with SDL 1.2 too.
phcoder
reviewed
Jul 23, 2022
| // (assumes zero draw time, so this can be improved) | ||
| int32_t fps = machine.code().require60fps() ? 60 : 30; | ||
| SDL_Delay(1000.0/fps); | ||
| } |
Contributor
There was a problem hiding this comment.
Libretro cores should use no delay. Instead they are synced in frontend on produced frames and audio samples
Owner
There was a problem hiding this comment.
Yes, in general the flip() function is a poor design choice because the running loop should be controlled by the caller instead that letting the code itself doing quirky things.
I guess the solution would be a quick return and a synchronization through a variable on backend which are not synched and just wait for the next frame on others?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I wanted to try out Picopolis - https://www.lexaloffle.com/bbs/?tid=29590 - and these patches are enough to begin playing.
The two commits implement flip() [using a function pointer and data pointer, not unlike glib-style userdata callbacks] and re-fetch _update() and friends from Lua (since Picopolis has _update and _draw as function pointers).