N64 Emulator by GliGli

Show us your projects you made with libXenon
User avatar
tuxuser
Administrator
Administrator
Posts: 301
Joined: Sat Feb 19, 2011 4:53 pm
Location: Germany
Contact:

N64 Emulator by GliGli

Post by tuxuser » Fri Feb 25, 2011 10:37 am

By proxy I post some stuff from GliGli here about the current status of the N64 Emulator. Its copied from his blog.

Friday, 7 January 2011
I have already made quite a few improvements to my mupen64 port since the video.

About half an hour after making it, I fixed almost all the missing screens/skies and the clipped mario by adjusting the Z buffer range (previous range was 0..1, now it is -1..1).

I then improved N64 gfx combiners emulation (combiners are sort of early primitive pixel shaders). I use 360 pixel shaders to emulate them. At first it was really slow because I used many switches and loops in it and it seems doing that in a pixel shader isn't such a good idea. I got everything back to playable speeds by using mainly 3 techniques:

    * a color lookup table to emulate combiner 'source' (ie vertex color/texture color/constant/...)
    * a math formula that handles all the possible cases for the combiner operation (ie mul/add/sub/...)
    * having different pixel shaders (one fast that can only do simple things, one intermediate, and one slow that emulates everything) and switching between then when needed.

So now gfx emulation is quite fast but the emu still runs slowly when it emulates floating point intensive scenes like the mario head demo at the begininng of SM64 so I start looking at how mupen64 emulates floating point operations, I quickly discovered that the whole floating point unit was running in interpreter mode, oops!
A few #define later the emu was up to 50% faster.

Next I had an idea: why not try to get the X360 GPU to render my current frame in background instead of actively waiting for it to finish rendering.
Usually you do this:

/* resolve (and clear) */
Xe_Resolve(xe);
/* wait for render finish */
Xe_Sync(xe);


Now I do this:

/* resolve (and clear) */
Xe_Resolve(xe);
/* begin rendering in background */
Xe_Execute(xe);


and then I call Xe_Sync() at the last time right before beginning my next frame
I got a huge speed boost with this, Super Mario 64 now runs at around 100fps ingame !
Thursday, 27 January 2011
During the last weeks, I worked a bit on improving my mupen64 port, here are the things I did.

As SM64 started to work well, I switched to the Zelda rom for my testing, it is a much more complex game to emulate graphics wise, so obviously it was completely buggy and painfully slow on the first run. The biggest problem was that unlike SM64, most of the rendering was done with my slowest pixel shader, and fixing the bugs would have made it even slower so I decided to do a complete rewrite of the shader. This time I designed it around something I just discovered: constant boolean registers, it allows flow control without a big performance hit. I took me a few tries to get it fast and accurate, but now that pixel shader is almost as fast as the old one on simple cases while being more accurate and much faster on complex cases. I also made my old shader as accurate as I could, it is now used for some rare cases the new one can't emulate. With a few more fixes to libxenon and the emulator (implementing 2D rendering for example), this makes Zelda reasonably fast and playable.

Next game was Mario Kart 64, this time it was fast and looking good on the first try, but crashed after a few races with some 'out of memory' message. It turns out something very important was missing from the libxenon 3D driver: a way to free what you allocate ! (texures/vertex buffers/...) So I replaced the very basic GFX memory allocator with some malloc-like one I found in libxenon sourcecode, and modified the emulator texture cache to actually free old textures when needed.

I think it's time for a new video so here it is :) :) :)

[align=center][youtube]http://www.youtube.com/watch?v=TvC41ku5FFA[/youtube][/align]
Tuesday, 28 June 2011
Sorry for the lack of updates, I was busy with other stuff for some months.

As you can see on my github, ( https://github.com/gligli/libxenon/commits/master ), I think libXenon has improved a lot lately, with lots of stuff added from Xell (NAND access, lwip & network code,...), a new ELF loader, a unified ATA driver (that can access both HDD and DVD), the return of opendir/readdir/... functions and many bug fixes and smaller improvements in almost all drivers.

The reason for many of those changes is to be able to make most of Xell a regular libXenon app: Xell would be splitted into 2 stages, one stage which recovers from exploit and then decompresses and launches a second stage, which is a libXenon ELF. To maintain backwards compatibility, both stages would have to fit in the 256KB limit for a Xell binary.

Last but not least, I'm working on mupen64-360, my Wii64 port these days, I already added sound and done some optimisations to try to get more speed.
I multithreaded a good part of sound processing so it's done almost for free, and in fact anything that isn't multithreaded (RSP emulation) was already running in my version from january. I might be able to multithread RSP too, it would probably give a nice speed boost :)
I also redone the port of the Wii64 dynarec, I did my first port from the ps3 branch and it seems it wasn't up to date with the trunk speed-wise. Now it's using Wii64 1.1 code. I also changed the way stores were handled in the dynarec, trying to generate more code and rely less on a (slow) generic C function to do the job.
By the way, source code is now available on my github ( https://github.com/gligli/mupen64-360 ). Anybody that can compile it can try it, but please don't distribute binaries ! It's not a good idea at all to release unofficial versions of a work in progess of someone else code so I hope You can be responsible on this.

Here's a new video showing the progress on Mario64, jerkiness is due to the video capture card, trust me that game runs smooth :)

[align=center][youtube]http://www.youtube.com/watch?v=w3o41LvZ71w[/youtube][/align]
Last edited by tuxuser on Thu Jun 30, 2011 5:40 pm, edited 1 time in total.
I have no idea what I am doing but atleast I am trying

Chrisoldinho

Re: N64 Emulator by GliGli

Post by Chrisoldinho » Sat Feb 26, 2011 7:25 pm

i cant wait to see the end product. i have been following the blog with the updates, excellent work so far :)

User avatar
tuxuser
Administrator
Administrator
Posts: 301
Joined: Sat Feb 19, 2011 4:53 pm
Location: Germany
Contact:

Re: N64 Emulator by GliGli

Post by tuxuser » Thu Jun 30, 2011 5:40 pm

Update in first post :)
I have no idea what I am doing but atleast I am trying

Doerek

Re: N64 Emulator by GliGli

Post by Doerek » Thu Jun 30, 2011 9:25 pm

Thank you, Tuxuser for keeping us up2date

MagicSeb

Re: N64 Emulator by GliGli

Post by MagicSeb » Sat Jul 23, 2011 2:20 pm

I have built the latest modifications made by gligli

The emulation is much faster now, watch the u-tube video.great work gligli !

[youtube]http://www.youtube.com/watch?v=bIW3RxIyuwA[/youtube]
[youtube]http://www.youtube.com/watch?v=Vpt1RsoCIIc[/youtube]

If you want to test mupen64-360, compile it

sjuut
User
User
Posts: 4
Joined: Fri Jul 22, 2011 3:45 pm

Re: N64 Emulator by GliGli

Post by sjuut » Sun Jul 24, 2011 4:35 pm

I tried compiling the source, I get the following error message:

[ucode1.cpp]
cc1plus: error: invalid option argument '-Ofast'
cc1plus: error: unrecognized command line option "-fno-tree-slp-vectorize"
make[1]: *** [ucode1.o] Error 1
make: *** [build] Error 2

and if I remove those arguments, I get a lot of different errors.

Can someone point me in the right direction?
Thanks!

User avatar
tuxuser
Administrator
Administrator
Posts: 301
Joined: Sat Feb 19, 2011 4:53 pm
Location: Germany
Contact:

Re: N64 Emulator by GliGli

Post by tuxuser » Sun Jul 24, 2011 9:23 pm

In the Makefile replace '-Ofast' with '-O2' and make sure you got the latest toolchain installed by typing

Code: Select all

xenon-gcc --version
It has to show Version 4.6.0
I have no idea what I am doing but atleast I am trying

sjuut
User
User
Posts: 4
Joined: Fri Jul 22, 2011 3:45 pm

Re: N64 Emulator by GliGli

Post by sjuut » Sun Jul 24, 2011 11:07 pm

Thanks for the quick reply! I got that answer in the irc channel too, thank you all for being so supportive.

This is very frustrating! Sorry if I sound like a n00b;

Im trying to update my toolchain, with no luck.
first, I followed the PDF guide 'how to set up toolchain', and after following all instructions correctly, my xenon-gcc version will show 4.4.0.

Then I cloned GliGlis git, did the same commands ./build-toolchain toolchain and libxenon..

and I'm still stuck at the older version..  ! I can see that gcc-4.6.0 is downloaded, but somehow it never overwrites 4.4.0.. the build.log does not show anything strange. In desperation I even overwritten the free60-git files with gligli's files (same folder structure), but to no avail.

Someone please explain!

:EDIT:
Nevermind, I fixed it!
gcc couldn't find mpc, I downloaded and installed it manually. Now I do have xenon-gcc 4.6.0, and I could compile mupen64-360.
Thanks !
Last edited by sjuut on Mon Jul 25, 2011 2:01 pm, edited 1 time in total.

checo

Re: N64 Emulator by GliGli

Post by checo » Wed Aug 03, 2011 4:38 am

sjuut. How to install the new compiler? I followed the setup guide for your pc libxenon programming and everything went well but I have many problems installing the new compiler :(.

PD. sorry if not well understood but the Spanish translated with google.

Sonic-NKT

Re: N64 Emulator by GliGli

Post by Sonic-NKT » Thu Aug 04, 2011 7:45 pm

would love to see some videos of other games emulated than mario.
wouldnt mind recording them myself, but i currently cant compile 360 stuff.

MagicSeb

Re: N64 Emulator by GliGli

Post by MagicSeb » Fri Aug 05, 2011 9:48 pm


maxaille

Re: N64 Emulator by GliGli

Post by maxaille » Sat Aug 13, 2011 10:18 pm

I have this error when compiling under mingw:
make[1]: /cygdrive/c/Users/max/Desktop/minGW/mupen364/Makefile: No such file or directory
make[1]: *** No rule to make target `/cygdrive/c/Users/max/Desktop/minGW/mupen364/Makefile'.  Stop.
make: *** [build] Error 2

BUILD FAILED (exit value 2, total time: 451ms)
Ubuntu (virtual), I can not compile gcc-4.6.0 / 1 with various errors ...
So if anyone can help me or send me binaries....
Thanks

chemone

Re: N64 Emulator by GliGli

Post by chemone » Wed Aug 24, 2011 4:17 am

I can compile it, but, in wich folder i must to put my rom to load it?  Thanks and sorry for my bad english.

Telemaque

Re: N64 Emulator by GliGli

Post by Telemaque » Wed Aug 24, 2011 12:36 pm

Salut MagicSeb,

Que j'ai hâte, trop dur d'attendre !

@+++ et Bon Courage !
;)

Nitrous360

Re: N64 Emulator by GliGli

Post by Nitrous360 » Wed Sep 07, 2011 4:28 pm

This emu is looking amazing!  ;D  I had no idea there was an N64 emu in development, let alone looking this polished! I cant wait for a release!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests