Wednesday, December 17, 2008

What Does Speed Hack Mean

In Daedalus, SpeedHack mainly refer to the technoligy to avoid busy wait (http://en.wikipedia.org/wiki/Busy_wait). In the real N64 machine, RSP, GPU, DMA will do the work parallelly with CPU. Busy Wait is used to wait for other component completes their work. However in daedalus, we emulate almost everything serail. Busy wait is nothing expect slow down the emulation.

The technoligy used in Daedalus is skip these busy wait. The hardest thing is how to detect different types of busy wait.

The detection is divided into two parse. When we find a Jump instruction that jump to itself's address, we will mark this instruction as SpeedHack. Then when we processing the delay slot, we will decide how to handle it.

So far we can only detect the "loop to self" type of busy wait. So far we can detect the following different types of busy wait.

0x80242e54 0x1000ffff B --> 0x80242e54
0x80242e58 0x00000000 NOP

0x80026054 0x08009815 J 0x80026054 ?
0x80026058 0x00000000 NOP

0x7f0d01e8 0x5443ffff BNEL v0 != v1 --> 0x7f0d01e8
0x7f0d01ec 0x24420004 ADDIU v0 = v0 + 0x0004

0x7f14a08c 0x5464ffff BNEL v1 != a0 --> 0x7f14a08c
0x7f14a090 0x24630001 ADDIU v1 = v1 + 0x0001

0x800006a4 0x1450ffff BNE v0 != s0 --> 0x800006a4
0x800006a8 0x00000000 NOP

0x8011ec14 0x0623ffff BGEZL s1 >= 0 --> 0x8011ec14
0x8011ec18 0x2631ffff ADDIU s1 = s1 + 0xffff


The first 2 types are very common. They are busy wait until the event happen. We can safely ignore the acutal code but skip to the next event. (most time, it is VBlank Interrupt.)

The other 3 types are not so common. I will leave them as it is. If we find they are very common, we can implement specific code to handle.

No comments: