# Phoinix, the free Gameboy emulator for PalmOS by Bodo Wenzel
Sitemap: |
--- | ---
Home (downloads) |
F. A. Q. |
Compatibility of... |
free cartridges |
commercial cartridges |
How to... |
use the emulator |
convert cartridges |
make cartridges run |
get in touch |
About... |
the history |
the future |
the playability testing |
skipping frames |
some accessories |
limits and extensions |
Thank you for the cookies |
This site is kindly hosted by | # About skipping frames Because the request for frame skipping comes often I sat down some hours and reflected on it. Here are my thoughts, and HJ is investigating Liberty in more detail. Additionally there is a quick'n'dirty test version of Phoinix which was only distributed via the mailing list for developers, so get your subscription ;-) On this page: - Some theory - Some real life values ### Some theory: OK, let's start. There's a lot of mathematics in here, but nothing more than the four basic arithmetical operations and solving equations. If you can't follow, write it down yourself and try to fill in the missing steps. Here are the symbols used:
Symbol | Meaning
--- | ---
f | frame skip factor ("every fth frame")
Ttotal(f) | total time for an actual run with frame skip factor f
n | number of frames in Ttotal
Temulate | time to emulate the machine code of one frame
Trender | time to render and show one frame
e |
| Trender |
emulation ratio = |  |
| Temulate |
a(f) |
| Ttotal(1)
acceleration ratio = |
| Ttotal(f)
r(f) |
| a(f)
frame rate ratio = |
| f
We can surely assume that the time to emulate the machine code a Gameboy executes in one frame Temulate is fixed, independent of rendering and showing the frame. Similarly, the time needed to render and show the frame Trender is fixed, too. The values both vary with the game used, depending on the actual machine code, but while running it is assumed to be nearly constant. So the total time for an actual run Ttotal is:
| n |
Ttotal(f) = n * Temulate + |  | * Trender
| f |
The first thing we see is that even if we set the frame skip to infinite, we can't be faster than:
| n |
Ttotal(infinite) | = n * Temulate + |  | * Trender
| infinite |
| = n * Temulate + | 0 | * Trender
| = n * Temulate |
Secondly, after inserting the transformed formula of the ratio e we have:
| n |
Ttotal(f) | = n * Temulate + |  | * Temulate * e
| f |
| e |
| = n * Temulate * (1 + |  | )
| f |
We calculate the ratio of accelaration a(f) for a frame skip factor f compared to the non-skipping run by:
| Ttotal(1)
a(f) | = |
| Ttotal(f)
| e |
| n * Temulate * (1 + |  | )
| 1 |
| = |
| e |
| n * Temulate * (1 + |  | )
| f |
| 1 + e
| = |
| e |
| 1 + |  |
| f |
Now let's see how fast we can be with some theoretical values for the frame skip factor f and the emulation ratio e. As the formula clearly shows, there is no proportional relationship between the frame skip factor and the emulation acceleration:
frame skip factor | f | 1 | 2 | 3 | 4 | 5 | 10 | 20 | infinite
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
e = 10 (incredibly fast emulation)
acceleration | a | 1.00 | 1.83 | 2.54 | 3.14 | 3.67 | 5.50 | 7.33 | 11.00
frame rate | r | 1.00 | 0.92 | 0.85 | 0.79 | 0.73 | 0.55 | 0.37 | 0.00
e = 2 (fast emulation)
acceleration | a | 1.00 | 1.50 | 1.80 | 2.00 | 2.14 | 2.50 | 2.73 | 3.00
frame rate | r | 1.00 | 0.75 | 0.60 | 0.50 | 0.43 | 0.25 | 0.14 | 0.00
e = 1 (assumed average ratio)
acceleration | a | 1.00 | 1.33 | 1.50 | 1.60 | 1.67 | 1.82 | 1.90 | 2.00
frame rate | r | 1.00 | 0.67 | 0.50 | 0.40 | 0.33 | 0.18 | 0.10 | 0.00
e = 0.5 (fast rendering)
acceleration | a | 1.00 | 1.20 | 1.29 | 1.33 | 1.36 | 1.43 | 1.46 | 1.50
frame rate | r | 1.00 | 0.60 | 0.43 | 0.33 | 0.27 | 0.14 | 0.07 | 0.00
e = 0.1 (incredibly fast rendering)
acceleration | a | 1.00 | 1.05 | 1.06 | 1.07 | 1.08 | 1.09 | 1.09 | 1.10
frame rate | r | 1.00 | 0.53 | 0.35 | 0.27 | 0.22 | 0.11 | 0.05 | 0.00
If we transform the equation for the accelaration ratio a(f), we can calculate the emulation ratio e if a(f) is given:
| 1 + e |
a(f) | = |  |
| e |
| 1 + |  |
| f |
| a(f) |
a(f) + e * |  | = | 1 + e |
| f |
| a(f) |
a(f) - 1 | = | e * (1 - |  | )
| f |
| a(f) - 1 |
e | = |  |
| a(f) |
| 1 - |  |
| f |
### Some real life values: Now that we know how to calculate things, let's take a look at some real life values. All times are taken on my old Palm III with no overclocking, comparable to 12 MHz due to its wait states.
Phoinix v.1.1fs (special test version), measured Ttotal(1) and Ttotal(2):
Game | Ttotal(1) | Ttotal(2) | a(2) | e | a(infinite) | r(2) | emulation speed gain | frame rate loss
--- | --- | --- | --- | --- | --- | --- | --- | ---
Dr.Mario | 4:04 | 2:57 | 1.39 | 1.22 | 2.28 | 0.69 | 39% | 31%
R-Type II | 9:30 | 8:40 | 1.10 | 0.21 | 1.22 | 0.55 | 10% | 45%
SQRXZ | 13:20 | 11:53 | 1.12 | 0.28 | 1.28 | 0.56 | 12% | 44%
StarFisher | 3:35 | 2:54 | 1.24 | 0.62 | 1.64 | 0.62 | 24% | 38%
Tetris | 4:13 | 2:59 | 1.41 | 1.41 | 2.47 | 0.71 | 41% | 29%
Hm, the competitor shouldn't stand aside :-D
Liberty v.1.3b2, measured Ttotal(1) and Ttotal(2):
Game | Ttotal(1) | Ttotal(2) | a(2) | e | a(infinite) | r(2) | emulation speed gain | frame rate loss
--- | --- | --- | --- | --- | --- | --- | --- | ---
Dr.Mario | 5:22 | 3:57 | 1.36 | 1.12 | 2.06 | 0.68 | 36% | 32%
R-Type II | 10:58 | 7:55 | 1.23 | 1.25 | 2.23 | 0.69 | 23% | 31%
SQRXZ | 12:19 | 10:43 | 1.14 | 0.35 | 1.35 | 0.57 | 14% | 43%
StarFisher | 2:47 | 2:16 | 1.23 | 0.59 | 1.58 | 0.61 | 23% | 39%
Tetris | 5:17 | 3:52 | 1.37 | 1.16 | 2.13 | 0.68 | 37% | 32%
So my assumptions about realistic emulation ratios e were quite right: depending on the machine code to execute it's a 0.2 to 1.5 range. With these values, I made some curves and their asymptotes at a(infinite): How do you read this diagram? OK, let's assume the game has an emulation rate e = 0.7, meaning that Trender is 70% of Temulate. This is the dark green curve. First you're careful and choose a frame skip factor of f = 2. Put your finger on the "2" at the horizontal axis and move up to the dark green curve. Then you go left to the vertical axis and find... a = 1.25! This says that the game will be accelerated to 125%, 25% more than before. The frame rate is getting down a bit, calculated by 125% / 2 = 63%, quite acceptable. Now you plan to accelerate a lot, and you choose a frame skip factor of f = 5. This time you'll find a = 1.50! The game will be accelerated to 150%, 50% more than without frame skipping. But the frame rate is getting down much more, despite the acceleration. Just calculate 150% / 5 = 30%: only three tenth of the non-skipping frame rate! The decision is yours ;-)
palm.gb_emu@gmx.de