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

Make picopolis work #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Make picopolis work #28

wants to merge 3 commits into from

Conversation

mibus
Copy link
Contributor

@mibus mibus commented Mar 27, 2021

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).

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.
// (assumes zero draw time, so this can be improved)
int32_t fps = machine.code().require60fps() ? 60 : 30;
SDL_Delay(1000.0/fps);
}
Copy link
Contributor

@phcoder phcoder Jul 23, 2022

Choose a reason for hiding this comment

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

Libretro cores should use no delay. Instead they are synced in frontend on produced frames and audio samples

Copy link
Owner

Choose a reason for hiding this comment

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

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?

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.

None yet

3 participants