PDA

View Full Version : Daedalus R8 WIP News (Nintendo 64 emulator for the PSP)



skater9269
August 17th, 2006, 01:16
Strmnnrmn posted this over at his blog:


Unexpected optmisations

One of the things that I find most rewarding about programming is when you discover an unexpected improvement or optimisation by accident. You can spend weeks carefully tuning and optimising code, only to stumble across a glaring inefficiency in your code which you've never spotted before. One quick change and your application is suddenly noticably faster.

In my daily job I rely heavily on debuggers and profilers to discover bottlenecks in the working on the Xbox, Microsoft provided some excellent performance analysis tools (I see they've finally released PIX for Windows). These days I tend to use AQtime as I'm PC based (it's also one of the few profilers I've found that can handle the size of our libraries at work without grinding to a shuddering halt.)

Without these kind of tools it's a lot tougher profiling on the PSP. Over the past few months I've built a number of custom profiling tools into Daedalus to help me figure out where all the time is going, but the numbers I get out tend to be quite vague, and there's usually quite a large margin of error. I think this explains why the unexpected optimisation I've just found went undiscovered for so long.

A couple of days ago I was browsing the ps2dev forums and came across this post. I was about to back out after a quick scan, when I noticed this comment from Soatome:

PeterM wrote:
but one waits for the vblank
...and that's sceCtrlReadBufferPositive (which you're using) you should use sceCtrlPeekBufferPositive instead.

That's when I realised that when Daedalus was emulating a rom, it was stalling for a frame every time the rom read the status of the pad*. In other words by changing one line of code in Daedalus from

sceCtrlReadBufferPositive
to
sceCtrlPeekBufferPositive

I could get on average an instant 1fps speedup across all roms. What's more, I knew some roms read from the pad multiple times each frame, so they would see an even great speedup.

Frustratingly I had to wait a couple of days before I could try this out. As I mentioned earlier I'm in the process up moving over to a new PC, and I had just moved Perforce over but hadn't set up the pspsdk, which required Cygwin. Daedalus requires libpng and zlib so I had to download and build them too. Then I had to set up Psplink, PuTTY and a whole host of other tools. You get the picture...

Last night I finally managed to get a new build together with the updated code, and the results were every bit as good as I'd expected. In some cases I had to restart the rom just to make sure I wasn't mistaken. I know most of you just want to see some numbers, so here's a few of my observations:

Mario now runs at at steady 15fps in most places, and around 20fps indoors etc (it reaches over 35fps in the main menu, and close to 30 in some scenes.) Zelda now runs at around 8fps in game, and up to 20fps in certain places. The 'nintendo' logo at the start runs at over 90fps The MarioKart Nintendo logo now runs at 30fps, and the main menu (with the flag) runs at a solid 15fps. In game it's a comfortable 12fps. Starfox runs at around 15fps - the intro runs at 25-30fps. Quest64 runs at 20fps.

So all in all it's a pretty amazing improvement for a single-line change. Having said that, I think it would be a mistake to assume that this is an instant fix that will suddenly make everything fully-playable. Although some of the framerates I list above are excellent - faster than an native n64 even - not all roms show this improvement. Don't assume that all roms now run at 15+fps (because they don't.) There's still a lot more work to do to get from a sluggish 8fps to a more playable 15fps (in Zelda for instance). I still need to save a lot more cycles in order to support other features such as sound.

Because this change makes such a big improvement I'm going to try and get another release out sooner rather than later. I don't like releasing builds too often as I think each revision should something worthwhile, but I think this qualifies There are a couple of other optimisations I want to get in this build, so while it might be ready this weekend, sometime early next week is more likely. The new features I had planned for this build will have to wait until R9.

As always, I'll keep you posted.

-StrmnNrmn

*This actually reminds me of a funny story from one of the Xbox games I was working on. We were investigating a sudden slowdown that had been appeared a few days previously. Somehow I realised that the framerate doubled when you unplugged all the controllers. As it turned out someone was accidentally reinitialising the USB hub every frame, and removing the all controllers prevented this from happening.

Awesome info for Nintendo 64 Emulation Fans.

BelmontSlayer
August 17th, 2006, 03:45
Here is the entire post...This is an awsome breakthrough!

Unexpected optmisations

One of the things that I find most rewarding about programming is when you discover an unexpected improvement or optimisation by accident. You can spend weeks carefully tuning and optimising code, only to stumble across a glaring inefficiency in your code which you've never spotted before. One quick change and your application is suddenly noticably faster.

In my daily job I rely heavily on debuggers and profilers to discover bottlenecks in the working on the Xbox, Microsoft provided some excellent performance analysis tools (I see they've finally released PIX for Windows). These days I tend to use AQtime as I'm PC based (it's also one of the few profilers I've found that can handle the size of our libraries at work without grinding to a shuddering halt.)

Without these kind of tools it's a lot tougher profiling on the PSP. Over the past few months I've built a number of custom profiling tools into Daedalus to help me figure out where all the time is going, but the numbers I get out tend to be quite vague, and there's usually quite a large margin of error. I think this explains why the unexpected optimisation I've just found went undiscovered for so long.

A couple of days ago I was browsing the ps2dev forums and came across this post. I was about to back out after a quick scan, when I noticed this comment from Soatome:


PeterM wrote:
but one waits for the vblank


...and that's sceCtrlReadBufferPositive (which you're using)
you should use sceCtrlPeekBufferPositive instead.



That's when I realised that when Daedalus was emulating a rom, it was stalling for a frame every time the rom read the status of the pad*. In other words by changing one line of code in Daedalus from


sceCtrlReadBufferPositive


to


sceCtrlPeekBufferPositive


I could get on average an instant 1fps speedup across all roms. What's more, I knew some roms read from the pad multiple times each frame, so they would see an even great speedup.

Frustratingly I had to wait a couple of days before I could try this out. As I mentioned earlier I'm in the process up moving over to a new PC, and I had just moved Perforce over but hadn't set up the pspsdk, which required Cygwin. Daedalus requires libpng and zlib so I had to download and build them too. Then I had to set up Psplink, PuTTY and a whole host of other tools. You get the picture...

Last night I finally managed to get a new build together with the updated code, and the results were every bit as good as I'd expected. In some cases I had to restart the rom just to make sure I wasn't mistaken. I know most of you just want to see some numbers, so here's a few of my observations:

Mario now runs at at steady 15fps in most places, and around 20fps indoors etc (it reaches over 35fps in the main menu, and close to 30 in some scenes.) Zelda now runs at around 8fps in game, and up to 20fps in certain places. The 'nintendo' logo at the start runs at over 90fps :D The MarioKart Nintendo logo now runs at 30fps, and the main menu (with the flag) runs at a solid 15fps. In game it's a comfortable 12fps. Starfox runs at around 15fps - the intro runs at 25-30fps. Quest64 runs at 20fps.

So all in all it's a pretty amazing improvement for a single-line change. Having said that, I think it would be a mistake to assume that this is an instant fix that will suddenly make everything fully-playable. Although some of the framerates I list above are excellent - faster than an native n64 even - not all roms show this improvement. Don't assume that all roms now run at 15+fps (because they don't.) There's still a lot more work to do to get from a sluggish 8fps to a more playable 15fps (in Zelda for instance). I still need to save a lot more cycles in order to support other features such as sound.

Because this change makes such a big improvement I'm going to try and get another release out sooner rather than later. I don't like releasing builds too often as I think each revision should something worthwhile, but I think this qualifies :) There are a couple of other optimisations I want to get in this build, so while it might be ready this weekend, sometime early next week is more likely. The new features I had planned for this build will have to wait until R9.

As always, I'll keep you posted.

-StrmnNrmn

*This actually reminds me of a funny story from one of the Xbox games I was working on. We were investigating a sudden slowdown that had been appeared a few days previously. Somehow I realised that the framerate doubled when you unplugged all the controllers. As it turned out someone was accidentally reinitialising the USB hub every frame, and removing the all controllers prevented this from happening.

Video_freak
August 17th, 2006, 04:55
Yes! This is awesome news! R8 is going to be even more kick ass then R7. :eek:

irondirgible
August 17th, 2006, 05:10
holy crap, holy crap, holy crap...

Awesome! I code a bit too, and its amazing how one little thing can have such a large effect.

ACID
August 17th, 2006, 06:37
Great catch keep up the great work.
Thaks belmontslayer for the info.

Kramer
August 17th, 2006, 07:12
woah he says zelda is running 8 fps in game thats a pretty big speedup from 4-5 fps

ACID
August 17th, 2006, 07:14
It is i hope he stops sleeping and just consentrates on this emu. LOL just kiding but it is great improvement.

BL4Z3D247
August 17th, 2006, 07:23
i think he should throw a menu in R8 seeing how he just got another breakthrough so soon, instead of waiting for R9 to do it...that's just my opinion though, i just think it's a bit of a hastle doing a hard power off to exit/switch roms...either way all is greatly appreciated StrmnNrmn :D

V3N0M
August 17th, 2006, 07:28
Great work! I really can't believe how much progress StrmnNrmn has made. I really do think this emu will be far better than anyone expected. I really admire your work great job.

Uruz 6
August 17th, 2006, 08:38
Great news :)

D0N
August 17th, 2006, 09:30
Excellent news! Keep it up StrmnNrmn!

Malksta
August 17th, 2006, 15:56
Kick ass News! Cant wait for R8 :D
StrmnNrmn is a God :)

Broonale
August 17th, 2006, 15:58
Awesome!

Some of the best coding hits you from nowhere!

QueadlunnRau
August 17th, 2006, 16:01
Mang this sounds G"R8"!!!

Cannot wait for your future releases ... :drool Zelda

Viper Snake
August 17th, 2006, 16:02
Man Starfox seemed really fast in R7, but it never got up 15fps ingame! I can't wait to see R8! StrmnNrmn you truely are 1337! :P

Video_freak
August 17th, 2006, 16:03
Mang this sounds G"R8"!!!

Cannot wait for your future releases ... :drool Zelda
I like the gR8 idea. lol
excellent news StrmnNrmn :)

jimmi
August 17th, 2006, 16:21
man you are the best ! my n64 can be relived ... i just dug out my n64 and pluged it in .. kokiriki village in zelda brings a tear to my eye...

kcajblue
August 17th, 2006, 16:35
This is awesome news! I cant wait for the release for R8!:D

SSaxdude
August 17th, 2006, 16:38
He stated before that he won't quit on the emu until it runs most popular games at full speed!
Keep up the great work, I see tons of great progress that you're making.

Kramer
August 17th, 2006, 16:46
He stated before that he won't quit on the emu until it runs most popular games at full speed!
Keep up the great work, I see tons of great progress that you're making.

well Zelda was the most popular game on n64 so if he gets that running at about 30 fps he will be god.

ACID
August 17th, 2006, 16:49
I agree with that Kramer

AtariFreek
August 17th, 2006, 17:24
OMFG! NICE! WOOHOO, AMAZING, GREAT Job! I Can't Wait For The Next Build! Infact, After, When R9 Is Released, If You Get ANOTHER Soeed Improvement Then BAM, We'll Be Playin' Ocarina Of Time At 15FPS.

.:}<3\/!}\{:.
August 17th, 2006, 17:35
great news, well awesome how one little change changes alot, it's the teaching how one little raindrop will eventurually go through a rock.
so dont stop, never give!!!!!!!

djakku
August 17th, 2006, 17:54
to read or to peek, that was the question!
Awesome new, keep it up StrmnNrmn !

ACID
August 17th, 2006, 17:59
StrmnNrmn if you pull this off you will be imortalise in the seen.

S34MU5
August 17th, 2006, 18:14
KKKKKKKKKKKANT WAIT
im startin to get annoid with how slow mario is but it will be amazin!

mcvader
August 17th, 2006, 18:17
Wow, I hope there's more bugs like this to be found we'll be at full speed in no time.

He said nothing of Goldeneye tho, Damn I can't wait till that works, all the other top 5 N64 titles do.

steven1980cad
August 17th, 2006, 18:44
This is great news, sometimes the little things (missing or incorrect) make the big difference.

Looking forward to playing mario at good speed.

Good work, StrmnNrmn

felonyr301
August 17th, 2006, 20:04
good news and yes just a little small guy can pack a punch lol good to hear something about zelda and yes i agree with you man until you get more speed or as you said free up more cycles then you should implement sound but if you do should be on the ME engine cant say that enough lol.

alleyal202
August 17th, 2006, 20:08
Can anyone tell me have they got goldeneye working yet on any release and if so could u tell me which on works?

tallica
August 17th, 2006, 20:09
StrmnNrmn amazes me he hust keeps making it faster and faster.

samthegreat68
August 17th, 2006, 20:29
awesome R8's gonna be the bomb

CrAzY_fLiP3
August 17th, 2006, 20:36
Mang this sounds G"R8"!!!

Cannot wait for your future releases ... :drool Zelda

:dribble dribble slobber: majora's mask and OoT on psp.. :D great find strmnnrmn. looking forward to R8

calebg
August 17th, 2006, 21:03
SOMEBODY ON PSP UPDATES PUT IN THE CODE AND MADE HIS PRE R8 IT DOES RUN FASTER AND IN MARIO IN THE STAR SELECT SCREEN IT GOES TO 70 FPS


24. » daedalus EBOOT

eboot of daedalus recompiled with sceCtrlPeekBufferPositive.

OBS.: no zip support, no png support since zlib and lib png is missing in my environment.

frameskip = 1
http://rapidshare.de/files/29775959/daedalus_fs.zip.html

no frameskip
http://rapidshare.de/files/29776529/daedalus_nofs.zip.html

JD/
August 17th, 2006, 21:08
Dang I dont know what to say about this StrmnNrmn you keep amazing me with every release without fail your N64 emu owns I cant wait for R8 :D.

Alucard
August 17th, 2006, 21:14
For some reason I thought that the N64 functioned differently from other Systems. I could be totally wrong here. But my questions is, is the N64 full frame rate 60? For some reason I felt I remembered it was 30.

mcvader
August 17th, 2006, 21:32
For some reason I thought that the N64 functioned differently from other Systems. I could be totally wrong here. But my questions is, is the N64 full frame rate 60? For some reason I felt I remembered it was 30.

It was (supposed to be) 60fps but the only game i know of that achived this was f-zero.

JD/
August 17th, 2006, 22:19
omd that new optimisation is seriously fast! :D

Video_freak
August 17th, 2006, 22:21
Dang I dont know what to say about this StrmnNrmn you keep amazing me with every release without fail your N64 emu owns I cant wait for R8 :D.
Ahmen to that JD! :)

SpacemanSpiff
August 17th, 2006, 22:32
I think someone mislabeled the pre-release files. I downloaded the non-frameskip version but it pretty obviously has frameskipping.
EDIT: I'm tried out the version labeled frameskip and it definitely doesn't have frameskipping. So they got it backwards.

Lodis
August 17th, 2006, 22:48
Kick ass News! Cant wait for R8 :D
StrmnNrmn is a God :)


No he isn't, he is just a great hard working coder :)

JD/
August 17th, 2006, 23:13
No he isn't, he is just a great hard working coder :)
Very true :D

Malksta
August 17th, 2006, 23:19
LIES!, he is a god :p

JD/
August 17th, 2006, 23:23
LIES!, he is a god :p
lol

irondirgible
August 17th, 2006, 23:30
...and you shall have no other gods before me...

Hmm... if I don't pray to God, he will smite me, but if I don't pray to StrmnNrmn I'll never get to play N64 full speed on my PSP...Decisions, decisions

gslop
August 17th, 2006, 23:30
:eek:

Xiro
August 17th, 2006, 23:32
am i the only one having trouble with the frameskip version of the recompiled daedalus (the link is the the non-frameskip one, they were messed up)

Hungry Horace
August 18th, 2006, 00:09
oh oh oohh quick! something about the N64!! i had better post something!!


sorry.... but i have much respect for the people behind this emulator, and what it will mean to show such an emu working on the PSP, but the number of nintendo fan-boys who post any-old-rubbish (usually 1 line or less) on every little WIP update (never mind the releases!) really hacks me off!


dont take this personally anyone who has posted, i'm just bitter and twisted.



edit:

and dont get me started on the whole "god" thing.... as a devout atheist i have a lot to say on the topic ;)

felonyr301
August 18th, 2006, 00:13
is the pre release safe?

Malksta
August 18th, 2006, 00:28
Yep its safe, pretty good speeds too :/

irondirgible
August 18th, 2006, 00:30
The pre-release does work, but to me it didn't feel like
anything was actually changed (although I only tried Mario 64 and Mario Kart 64). Super Mario 64 played the same as it did on R7. I got those amazing 30+ framerates people have described, but they were only on the screen were your course objectives were displayed. During actual gameplay the fps was still about 10. If you really want to try it, it is safe to do so, but i'd wait for the real R8 to come out.

Video_freak
August 18th, 2006, 00:30
Yep its safe, pretty good speeds too :/
That's cool. I don't mind waiting for the release so...

remansano
August 18th, 2006, 00:33
Great news, thanks dude

felonyr301
August 18th, 2006, 01:41
ill wait so ill be in a bigger suprise on the speed instead of just a minor update.

gsmumbo
August 18th, 2006, 02:01
wow. just tried the pre r8 with star fox... just wow. at times 17 fps. it was so close to full speed i actually think it was at full speed. if there was no fluctuation from 17 to 5 and back to 17, it would be perfect. lol

Video_freak
August 18th, 2006, 02:03
wow. just tried the pre r8 with star fox... just wow. at times 17 fps. it was so close to full speed i actually think it was at full speed. if there was no fluctuation from 17 to 5 and back to 17, it would be perfect. lol
That's awesomenews! Thanks gsmumbo for trying it and confirming. ;)

gsmumbo
August 18th, 2006, 02:14
No problem. I'm about to try Banjo Kazooie. Super Smash stil gets stuck at the first fight screen(after character select). :(

Banjo varies but the cutscene is goin around 12-16 fps. occassionally down to 6, but its still good. have to get past this longggg cutscene to see how the game plays. (Update: got past the cutscene and it only plays around 2 fps. well star fox was good news. lol)

aries2k4
August 18th, 2006, 02:57
Sounds good. this emu seem like its coming along real nice.
Keep up the good work

siulmagic
August 18th, 2006, 03:32
yes it is the versions are rongly named the one that says is frameskip is not,and the one that says nofs is the one with frame skip one

mlcurly16
August 18th, 2006, 03:38
I'd love to donate some cash to this guy :)

oblivioner
August 18th, 2006, 22:14
One of the games I want to play with this is Killer Instinct, has anyone got it working and how pls, it just hangs at the beginning for me :(

And I won't miss the chance to say how incredible this emu is, thanks for the hard work!

Zion
August 19th, 2006, 13:25
StrmnNrrmn is our hero :D

This project is avancing further and faster than anyone could of imagined.