What's new

Porting Mupen64Plus to Android

OP
paulscode

paulscode

New member
While I'm getting those problems worked out with Pelya's SDL port, I think I'll use the n64oid SDL port. It isn't complete, but it is at least enough to allow me to set up the project and work on a few components.
 
OP
paulscode

paulscode

New member
I solved both issues with Pelya's SDL port (Pelya was really helpful). I am ready to start putting the project together now (after all that initial research and analysis, I can finally get to some actual programming!)
 
OP
paulscode

paulscode

New member
I was stumped for a few days by a problem where the native libs wouldn't rebuild after changes were made to the source code. Turned out to be a simple setting in Eclipse that needed to be applied. I've set up a simple OpenGL ES project and verified that I can make changes and they do in fact update the deployed .apk package. Anyway, I'm back on track now.

Upon closer examination of the n64oid project, it's not going to be all that helpful to me afterall. It is not set up as an NDK project, so I can't just start with it and plug in the new source code. Actually, I have no idea how the author was even building this project at all - he has to have been using some other development environment I am not aware of.

So anyway, my next step I think will be to port n64oid to the Android NDK so it can be built from within Eclipse. Starting with n64oid will allow me to focus just on the make files and globals. Once I get that working, I can apply what I learn to my modified version 1.99.4 + ARM dynarec + OpenGL ES graphics plug-in.
 
Last edited:
OP
paulscode

paulscode

New member
I am slowly making progress getting n64oid ported to the NDK and Pelya's SDL. The main problem I had was the fact that Pelya's project assumes a single application module, which is not the case for a program with multiple plug-in modules. My initial thought was just to put everything into a single .so library, but of course that resulted in multiple redefinition errors. I've been playing around with the Android.mk files, and managed to get all the modules separated and built into shared libraries. Everything compiles fine with no errors, and it installs and runs. However, the front-end does not yet connect to the core, so the app immediately shuts down. Still, it is encouraging to see the logcat output:

Code:
12-03 20:22:30.185: INFO/System.out(20928): libSDL: setting envvar LANGUAGE to 'en_US'
12-03 20:22:30.185: INFO/System.out(20928): libSDL: accelerometer start required: false
12-03 20:22:30.185: INFO/libSDL(20928): Calling SDL_main("roms/mario.n64")
12-03 20:22:30.185: INFO/libSDL(20928): param 0 = "roms/mario.n64"
12-03 20:22:30.185: VERBOSE/libnav(20928):  __  __                         __   _  _   ____  _             
12-03 20:22:30.185: VERBOSE/libnav(20928): |  \/  |_   _ _ __   ___ _ __  / /_ | || | |  _ \| |_   _ ___ 
12-03 20:22:30.193: VERBOSE/libnav(20928): | |\/| | | | | '_ \ / _ \ '_ \| '_ \| || |_| |_) | | | | / __|  
12-03 20:22:30.193: VERBOSE/libnav(20928): | |  | | |_| | |_) |  __/ | | | (_) |__   _|  __/| | |_| \__ \  
12-03 20:22:30.193: VERBOSE/libnav(20928): |_|  |_|\__,_| .__/ \___|_| |_|\___/   |_| |_|   |_|\__,_|___/  
12-03 20:22:30.193: VERBOSE/libnav(20928):              |_|         http://code.google.com/p/mupen64plus/  
12-03 20:22:30.193: VERBOSE/libnav(20928): Mupen64Plus Console User-Interface Version 1.99.1
12-03 20:22:30.193: VERBOSE/libnav(20928): AttachCoreLib unsuccessful, returning 2.
12-03 20:22:30.302: INFO/AndroidRuntime(20928): AndroidRuntime onExit calling exit(0)
12-03 20:22:30.342: INFO/ActivityManager(1259): Process paulscode.android.mupen64plus (pid 20928) has died.
 

Rotkaeqpchen

New member
@paulscode

THANK YOU VERY MUCH for working on this project! I was hoping so much that someone will provide a cool N64 emulator!

Please let us know when we can test this :)
 
OP
paulscode

paulscode

New member
All n64oid modules connect and talk to each other now. Logcat output is looking better:

Code:
12-04 14:14:27.830: INFO/System.out(2130): libSDL: setting envvar LANGUAGE to 'en_US'
12-04 14:14:27.830: INFO/System.out(2130): libSDL: accelerometer start required: false
12-04 14:14:27.830: INFO/libSDL(2130): Calling SDL_main("mupen64plus --corelib   ...EDIT...  )
12-04 14:14:27.830: INFO/libSDL(2130): param 0 = "mupen64plus"
12-04 14:14:27.830: INFO/libSDL(2130): param 1 = "--corelib"
12-04 14:14:27.830: INFO/libSDL(2130): param 2 = "/data/data/paulscode.android.mupen64plus/lib/libcore.so"
12-04 14:14:27.830: INFO/libSDL(2130): param 3 = "--rsp"
12-04 14:14:27.830: INFO/libSDL(2130): param 4 = "/data/data/paulscode.android.mupen64plus/lib/librsp-hle.so"
12-04 14:14:27.830: INFO/libSDL(2130): param 5 = "--audio"
12-04 14:14:27.830: INFO/libSDL(2130): param 6 = "/data/data/paulscode.android.mupen64plus/lib/libaudio-sdl.so"
12-04 14:14:27.830: INFO/libSDL(2130): param 7 = "roms/mario.n64"
12-04 14:14:27.830: VERBOSE/front-end(2130):  __  __                         __   _  _   ____  _             
12-04 14:14:27.830: VERBOSE/front-end(2130): |  \/  |_   _ _ __   ___ _ __  / /_ | || | |  _ \| |_   _ ___ 
12-04 14:14:27.830: VERBOSE/front-end(2130): | |\/| | | | | '_ \ / _ \ '_ \| '_ \| || |_| |_) | | | | / __|  
12-04 14:14:27.830: VERBOSE/front-end(2130): | |  | | |_| | |_) |  __/ | | | (_) |__   _|  __/| | |_| \__ \  
12-04 14:14:27.830: VERBOSE/front-end(2130): |_|  |_|\__,_| .__/ \___|_| |_|\___/   |_| |_|   |_|\__,_|___/  
12-04 14:14:27.830: VERBOSE/front-end(2130):              |_|         http://code.google.com/p/mupen64plus/  
12-04 14:14:27.830: VERBOSE/front-end(2130): Mupen64Plus Console User-Interface Version 1.99.1
12-04 14:14:27.830: VERBOSE/front-end(2130): Parsing arg 1: --corelib
12-04 14:14:27.830: VERBOSE/front-end(2130): Parsing arg 3: --rsp
12-04 14:14:27.830: VERBOSE/front-end(2130): Parsing arg 4: /data/data/paulscode.android.mupen64plus/lib/librsp-hle.so
12-04 14:14:27.830: VERBOSE/front-end(2130): Parsing arg 5: --audio
12-04 14:14:27.830: VERBOSE/front-end(2130): Parsing arg 6: /data/data/paulscode.android.mupen64plus/lib/libaudio-sdl.so
12-04 14:14:27.830: VERBOSE/front-end(2130): Parsing arg 7: roms/mario.n64
12-04 14:14:27.861: VERBOSE/front-end(2130): Core Warning: Couldn't open configuration file  ...EDIT...  .  Using defaults.
12-04 14:14:29.416: VERBOSE/front-end(2130): Core: Goodname: Super Mario 64 (U) [!]
12-04 14:14:29.416: VERBOSE/front-end(2130): Core: Name: SUPER MARIO 64
12-04 14:14:29.416: VERBOSE/front-end(2130): Core: MD5: 20B854B239203BAF6C961B850A4A51A2
12-04 14:14:29.416: VERBOSE/front-end(2130): Core: CRC: 635a2bff 8b022326
12-04 14:14:29.416: VERBOSE/front-end(2130): Core: Imagetype: .v64 (byteswapped)
12-04 14:14:29.416: VERBOSE/front-end(2130): Core: Rom size: 8388608 bytes (or 8 Mb or 64 Megabits)
12-04 14:14:29.416: VERBOSE/front-end(2130): Core: Version: 1444
12-04 14:14:29.416: VERBOSE/front-end(2130): Core: Manufacturer: Nintendo
12-04 14:14:29.416: VERBOSE/front-end(2130): Core: Country: USA
12-04 14:14:29.432: VERBOSE/front-end(2130): Core Warning: No video plugin attached.  There will be no video output.
12-04 14:14:29.432: VERBOSE/front-end(2130): Core Warning: No input plugin attached.  You won't be able to control the game.
12-04 14:14:29.713: VERBOSE/front-end(2130): Audio: Initializing SDL audio subsystem...
12-04 14:14:29.713: INFO/libSDL(2130): ANDROIDAUD_OpenAudio(): app requested audio bytespersample 2 freq 44100 channels 2 samples 4096
12-04 14:14:29.760: INFO/libSDL(2130): ANDROIDAUD_OpenAudio(): app opened audio bytespersample 2 freq 44100 channels 2 bufsize 16384
12-04 14:14:30.119: VERBOSE/front-end(2130): Core: Starting R4300 emulator: Cached Interpreter
12-04 14:14:31.314: INFO/libSDL(2130): ANDROIDAUD_OpenAudio(): app requested audio bytespersample 2 freq 44100 channels 2 samples 4096
12-04 14:14:31.322: INFO/libSDL(2130): ANDROIDAUD_OpenAudio(): app opened audio bytespersample 2 freq 44100 channels 2 bufsize 16384

Going with Pelya's SDL port has paid off too -- mupen64plus sdl-audio plug-in successfully connects to the audio device, meaning I've advanced beyond n64oid's original capability (if anyone wants to continue n64oid development using Pelya's SDL, let me know and I can help you set up the project).

Now that I have the makefiles and globals set up the way I want them, I'm ready to trash n64oid. My next step will be to port the 1.99.4 sources and Ari64's ARM dynarec.
 
Last edited:

Rotkaeqpchen

New member
Thats going really fast! Wow!

I am a bit confused, are you working on, on this project and release an apk when its playable? Of course this will take a while, but will you finish and publish this project?

Thanks! Can't wait to play Mario64 :)
 
OP
paulscode

paulscode

New member
Thats going really fast! Wow!
It helps to build on work that other people have done - the pace will slow down once I've incorporated all the big pieces and have to start focusing development on the missing components, debugging, and speed optimizations.

I am a bit confused, are you working on, on this project and release an apk when its playable? Of course this will take a while, but will you finish and publish this project?
Yes, I will continue working on this project until I either hit a dead-end or reach the point where I need testers. What I meant is, I will post the .apk here for testing, rather than deploying it through the Android market (reason being I wouldn't want to put anything on the Android market until I'm sure it is stable and not going to blow up anyone's phone)
:ranting: ...-- (( :whistling

--EDIT-- For further clarification, in case anyone was confused by my comment "I'm ready to trash n64oid": My Mupen64Plus port to Android is not going to be based on n64oid, nor will it bear the name "n64oid". I simply used the n64oid source code to help me set up the project. As I mentioned, I'm happy to collaborate with anyone else who happens to be working on n64oid, but my project is going to be based on Mupen64Plus 1.99.4 (and updated to later versions as they are released).
 
Last edited:
OP
paulscode

paulscode

New member
I finished the "upgrade" to 1.99.4. I'm now ready to begin porting the ARM dynarec (finally!)

Logcat output is improving:
Code:
12-05 11:05:10.740: INFO/System.out(2256): libSDL: setting envvar LANGUAGE to 'en_US'
12-05 11:05:10.740: INFO/System.out(2256): libSDL: accelerometer start required: false
12-05 11:05:10.740: INFO/libSDL(2256): Calling SDL_main("mupen64plus roms/mario.n64")
12-05 11:05:10.740: INFO/libSDL(2256): param 0 = "mupen64plus"
12-05 11:05:10.740: INFO/libSDL(2256): param 1 = "roms/mario.n64"
12-05 11:05:10.740: VERBOSE/front-end(2256):  __  __                         __   _  _   ____  _             
12-05 11:05:10.740: VERBOSE/front-end(2256): |  \/  |_   _ _ __   ___ _ __  / /_ | || | |  _ \| |_   _ ___ 
12-05 11:05:10.740: VERBOSE/front-end(2256): | |\/| | | | | '_ \ / _ \ '_ \| '_ \| || |_| |_) | | | | / __|  
12-05 11:05:10.740: VERBOSE/front-end(2256): | |  | | |_| | |_) |  __/ | | | (_) |__   _|  __/| | |_| \__ \  
12-05 11:05:10.740: VERBOSE/front-end(2256): |_|  |_|\__,_| .__/ \___|_| |_|\___/   |_| |_|   |_|\__,_|___/  
12-05 11:05:10.740: VERBOSE/front-end(2256):              |_|         http://code.google.com/p/mupen64plus/  
12-05 11:05:10.740: VERBOSE/front-end(2256): Mupen64Plus Console User-Interface Version 1.99.4
12-05 11:05:12.544: VERBOSE/front-end(2256): Core: Goodname: Super Mario 64 (U) [!]
12-05 11:05:12.544: VERBOSE/front-end(2256): Core: Name: SUPER MARIO 64
12-05 11:05:12.544: VERBOSE/front-end(2256): Core: MD5: 20B854B239203BAF6C961B850A4A51A2
12-05 11:05:12.544: VERBOSE/front-end(2256): Core: CRC: 635a2bff 8b022326
12-05 11:05:12.544: VERBOSE/front-end(2256): Core: Imagetype: .v64 (byteswapped)
12-05 11:05:12.544: VERBOSE/front-end(2256): Core: Rom size: 8388608 bytes (or 8 Mb or 64 Megabits)
12-05 11:05:12.544: VERBOSE/front-end(2256): Core: Version: 1444
12-05 11:05:12.544: VERBOSE/front-end(2256): Core: Manufacturer: Nintendo
12-05 11:05:12.544: VERBOSE/front-end(2256): Core: Country: USA
12-05 11:05:12.560: VERBOSE/front-end(2256): UI-console: using Video plugin: <dummy>
12-05 11:05:12.560: VERBOSE/front-end(2256): UI-console: using Audio plugin: 'Mupen64Plus SDL Audio Plugin' v1.99.4
12-05 11:05:12.560: VERBOSE/front-end(2256): UI-console: using Input plugin: <dummy>
12-05 11:05:12.560: VERBOSE/front-end(2256): UI-console: using RSP plugin: 'Hacktarux/Azimer High-Level Emulation RSP Plugin' v1.99.4
12-05 11:05:12.560: VERBOSE/front-end(2256): Core Warning: No video plugin attached.  There will be no video output.
12-05 11:05:12.560: VERBOSE/front-end(2256): Core Warning: No input plugin attached.  You won't be able to control the game.
12-05 11:05:12.795: VERBOSE/front-end(2256): Audio: Initializing SDL audio subsystem...
12-05 11:05:12.795: INFO/libSDL(2256): ANDROIDAUD_OpenAudio(): app requested audio bytespersample 2 freq 44100 channels 2 samples 2048
12-05 11:05:12.841: INFO/libSDL(2256): ANDROIDAUD_OpenAudio(): app opened audio bytespersample 2 freq 44100 channels 2 bufsize 8192
12-05 11:05:13.216: VERBOSE/front-end(2256): Core: Starting R4300 emulator: Cached Interpreter
12-05 11:05:14.272: INFO/libSDL(2256): ANDROIDAUD_OpenAudio(): app requested audio bytespersample 2 freq 44100 channels 2 samples 2048
12-05 11:05:14.279: INFO/libSDL(2256): ANDROIDAUD_OpenAudio(): app opened audio bytespersample 2 freq 44100 channels 2 bufsize 8192
 
Last edited:
OP
paulscode

paulscode

New member
So, I have some good news, some bad news, and some really bad news.

The good news is I finished adding in the ARM dynarec to version 1.99.4 (just the c code, and it is yet untested).

The bad news is that the NDK will not compile assembly. The compiler throws a stack of "bad instruction" errors. After some research into the issue, it seems that I need a program called the "Keil RealView Microcontroller Development Kit". Apparently, one must compile the assembly in this program into a library that the NDK can link with.

The really bad news is this program costs around $2,500. If I were a rich man, no problem, but unfortunately I am not. I'm looking into the possibility of any other program that can perform the same function for less cash (preferably free). Another option would be to find someone who owns the software and can compile the assembly for me (I'll be asking around on various forums).

In the mean time, unfortunately, this project is at a standstill.
 

Richard42

Emulator Developer
This isn't a big problem. In Hacktarux and my dynarecs there is very little inline assembly code. I don't know about Ari64's because I haven't looked at the source that finely, but I also doubt it has much asm. This post:

http://osdir.com/ml/android-ndk/2010-10/msg00235.html

suggests that the problem is with the format of the ASM code. If you convert it to GNU-style, gas or gcc should compile it with no problem. Assuming that the amount of inline asm is small, it shouldn't be a big deal.
 
OP
paulscode

paulscode

New member
I suppose it would be worth not paying the two grand to see if I can learn how to port assembly code from whatever style it is now to GNU style. Or maybe I can see if I can find someone with more experience who enjoys that sort of thing..
 

Ari64

New member
There is no inline assembly code. The only assembly code is in the file new_dynarec/linkage_arm.s. Nothing special is needed to compile this. Compile it with gcc.
 

Rotkaeqpchen

New member
I love following your progress and reading about things I cannot understand, and I'm looking forward to a great emulator for Android and wish you good luck in making progress and getting closer to a really cool emulator. :)
 

Remote

Active member
Moderator
Progress and status updates are always interesting to read about so keep posting!
 
OP
paulscode

paulscode

New member
There is no inline assembly code. The only assembly code is in the file new_dynarec/linkage_arm.s. Nothing special is needed to compile this. Compile it with gcc.
Right, I do understand that the assembly is in linkage_arm.s (since I had to set up the Android.mk file and that is the file generating all the errors when I run the build function). Granted, I don't have much of a clue about assembly code, but I would assume that just like the c code, this has to be compiled with a particular toolchain to run on the Android OS (i.e. it needs to be built by the NDK or other development tool which can utilize that toolchain, not just from my PC's terminal with gcc). I am still new to Android development, though (this being my first large Android project), and assembly code is just gibberish to me until I study up on the subject, so feel free to correct me if my understanding on all this is distorted.
 
Last edited:

Chaoz

New member
Not trying to hijack your thread, but where can I find the Ari64 dynarec code? I have plenty of NDK experience, can have a look at it.

Edit: Found it -- I'll have a look at it this evening
 
Last edited:
OP
paulscode

paulscode

New member
Not trying to hijack your thread, but where can I find the Ari64 dynarec code? I have plenty of NDK experience, can have a look at it.

Totally not hijacking at all, I appreciate the offer to help. The latest version of Ari64's dynarec is bundled in here. The assembly file in question is located at r4300/new_dynarec/linkage_arm.s. There are also .s files for x86 and x86_64, but I am less interested in those at the moment. Obviously, this is not an NDK project. I can send you my project for reference if you need it (the linkage_arm.s file is the same in both, I haven't changed it).
 

Top