forked from softdorothy/GliderPRO
-
Notifications
You must be signed in to change notification settings - Fork 9
/
PORTING.txt
50 lines (38 loc) · 2.41 KB
/
PORTING.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Some comments on porting the Aerofoil codebase to other platforms:
The codebase is split up into some modular libraries, mostly for discipline.
They could be static-linked, it doesn't really matter.
There are a few system-specific aspects:
GpApp has a SoundSync_Win32.cpp file, which is used to synchronize sound
priorities and interrupts. This system is a bit cheesy and could work
other ways.
Basically, when PlayPrioritySound is called, we need to figure out which
of the sound channels either has a sound already playing in it, or has a
lower-priority sound, so SoundSync_ReadAll reads all of the priorities and
returns them. Once a channel is selected, anything currently playing in
the channel is interrupted and the sound queue is flushed, guaranteeing
that no other thread will modify that channel's priority. Then, the main
thread clears the priority (since the callback may have been aborted),
inserts a new priority, and starts playing. If a sound finishes, then the
priority is simply cleared.
This could be done with a mutex instead, but x64 has appropriate memory
semantics to just do it with atomic operations instead.
The audio driver is expected to use a buffer submission model. When a
channel finishes playing a sound, the audio thread should call
NotifyBufferFinished on the callback object specified by
SetAudioChannelContext. If the sound is stopped, it should still call
NotifyBufferFinished. The "Stop" method is NOT a pause, it permanently
aborts the playing sound.
The display driver is a bit unusual in that it's responsible for calling
the main game function. This is because Glider PRO was written for a
fixed 60Hz system and it produces a display frame every time that it's
ticked, so the display driver is responsible for timing.
The display driver properties contain 2 callbacks: A render function and a
tick function. The render function will update and render surfaces and
draw them. The tick function will advance the game by 1 frame and will
not call any rendering functions, except for creating draw surfaces.
Aerofoil uses fibers on Windows. Some platforms may not support true
fibers because they implement security features that limit the ability of
a thread stack to jump to a different memory region. In those cases, you
can use 2 threads and use wake-up events to alternate them instead, since
Aerofoil doesn't do anything that requires that the switched-to fiber is
executing on the same thread.