[Scummvm-devel] OSystem API?
Max Horn
max at quendi.de
Fri Aug 1 09:52:20 CEST 2003
Am Freitag, 01.08.03 um 16:16 Uhr schrieb David Given:
> I'm having a look at OSystem for the intent port. In particular, I'm
> looking
> at the mutex functions, and set_timer, and have some questions.
>
> Is set_timer's callback supposed to be asychronous? Or is the callback
> only
> supposed to be executed when ScummVM is delayed?
set_timer is used by common/timer.cpp. It is used to power the Timer
class, which in turn is used to do all sorts of things. It can work
async (via a thread as in the SDL implementation), but it's also OK to
invoke it in sync (as e.g. the PalmOS backend does).
> How does the GP32 port work, that doesn't implement set_timer()?
No idea, but AFAIK the GP32 code in CVS doesn't work correctly anyway,
or so (it's not up-to-date), but I am not sure.
> What are the mutexes used for?
Well, what are mutexes (aka locks) ever used for? :-) You need them
when you use multiple threads (see set_timer and create_thread) to
protect critical sections, avoid race conditions, etc..
> Some ports (the GP32, the Dreamcast) don't implement these, either.
This is because a port which has no real preemptive threads doesn't
need mutexes either. So if "Intent" support real threads, implement
set_timer and create_thread using those; any system I've ever seen
which provides preemptive thread also provides some kind of
mutex/lock/critical section ability.
> How much of the OSystem API is actually needed? Is the subset
> implemented by OSystem_NULL all I really need?
Well, of course OSystem is a abstract virtual class, and you'll have to
provide all the pure virtual methods in your subclass. The event /
graphics function are obviously needed. Roughly, I think those are
absolutely required:
init_size
get_height
get_width
set_palette
copy_rect
update_screen
get_msecs
delay_msecs (-> if you don't have preemptive threads, this is a place
where you could invoke timers / "threads")
set_sound_proc (well you might be able to do w/o this, but it's
possible that with the current code this will cause a buffer overflow.
Trial & error...)
clear_sound_proc
create_thread (-> this is only used in mpu401.cpp, my ultimate goal is
to get rid of it)
all mutex methds if you use preemptive threads
quit
These should be implemented, too (w/o them playing will be no fun, but
for initial testing, you can do without):
show_mouse
set_mouse_pos
set_mouse_cursor
property (-> this is used for various things, like switching between
fullscreen/windowed mode, querying some attributes etc.)
For the GUI only:
all overlay methods
those are "optional" (games will run w/o them but some feature may not
work):
set_shake_pos
move_screen
warp_mouse
play_cdrom
stop_cdrom
update_cdrom
Hope that helps,
Max
More information about the Scummvm-devel
mailing list