Working on a 3DS Port

[/spoiler]
[color=#00b300]
Introduction[/color]

Hello everybody, i recently started working on a port for 3DS of EasyRPG, a player for games wrote with RPG Maker 2000/2003.
At the moment the interpreter is in an early stage of development but runs quite smooth on both O3DS and N3DS.
BGM Audio is supported only in .wav format and sounds are available only in .wav/.ogg format.

[color=#00b300]Can i help you working on this?[/color]

  • Developers : If you have C/C++ knowledges you can take a look to the issues in my repository and try to work on them ( https://github.com/Rinnegatamante/easyrpg-player-3ds/issues ). If you need libraries already compiled (since it has a lot of dependencies) just send me a PM and i’ll give you prebuilded libs.
  • Testers : I also need some betatesters to test modifications i make to the interpreter constantly. If you want to test it, you can find a download at the end of this post with informations about what i currently need to be tested.

[color=#00b300]Can i play “INSERT NAME HERE” game with this?[/color]

As i said before, this is in an early stage of development and the link you can find at the end of his topic IS NOT FOR GAMING PURPOSES. You’ll not receive any kind of support by me trying to fix errors to play a game you want to play.

[color=#00b300]Test Build[/color]

What i currently need to be tested is the sound engine i’m writing and the svchax execution, so i need to know:

  1. Your firmware and console (O3DS/N3DS)
  2. Debug console what says if a crash/freeze occurs (take in mind that the interpreter is slow to load stuffs so just wait a bit before concluding it’s a freeze).
  3. If you reach the main menu, i need to know if the sounds are playing fine.
  4. Since this build uses svchax, i need to know how many tries you made to start it (since svchax can fail and you’ll have a system freeze).

Download Test Build (with old 3dsx): http://rinnegatamante.it/easyrpg_player.rar
Updated 3dsx file: http://gbatemp.net/attachments/easyrpg-player-rar.44166/
GitHub Repository: https://github.com/Rinnegatamante/easyrpg-player-3ds

Hello.
That 3ds branch is horribly outdated and needs a rebase to get on par with the current Player development but otherwise it’s a good base. EDIT: My 3ds branch is now rebased on 0.4.1

You can also use Windows if you have msys installed. Msys provides autotools, make and other build tools that are required. For building you can use the 3ds Makefile in builds/3ds

SDL2 is not required for the 3DS because there is no proper port for SDL2. SDL is a wrapper around video, input and audio. Video and input is easy to solve but we have no idea about the audio. Audio will be probably most of the work to get working because games can come in lots of sound formats (WAV (PCM, ADPCM, Mono, Stereo…), MP3, Midi)
I guess you can use openal_audio (in the Player repo) as a reference. It uses libsndfile to process all audio files except MIDI and MP3. For MIDI and MP3 we are currently working on solutions that can be easily integrated also for 3DS if you figure out how to do audio with 3ds. :smiley:

Cross compiling the dependencies is not really rocket science and works the same for all platforms.

The devkitpro wiki has useful information about cross compiling libraries. The libpng way works for almost all platforms. You only have to also pass the arguments “-march=armv6k -mtune=mpcore -mfloat-abi=hard” otherwise you get strange “VFP register argument” errors.

For a minimal build you need at least: iconv (for liblcf), liblcf, libpng, zlib, freetype, pixman, SDL replacements for 3ds (pick any ^^).

What I can offer to you is that we provide all dependencies for the libraries. Then you can directly work on the Player without worrying about porting the libraries. This is no big deal for us because we already offer libraries for Wii, Android, OSX and others. So we are experienced in doing this ;).

[quote=“Ghabry”]Hello.
That 3ds branch is horribly outdated and needs a rebase to get on par with the current Player development but otherwise it’s a good base. EDIT: My 3ds branch is now rebased on 0.4.1

You can also use Windows if you have msys installed. Msys provides autotools, make and other build tools that are required. For building you can use the 3ds Makefile in builds/3ds

SDL2 is not required for the 3DS because there is no proper port for SDL2. SDL is a wrapper around video, input and audio. Video and input is easy to solve but we have no idea about the audio. Audio will be probably most of the work to get working because games can come in lots of sound formats (WAV (PCM, ADPCM, Mono, Stereo…), MP3, Midi)
I guess you can use openal_audio (in the Player repo) as a reference. It uses libsndfile to process all audio files except MIDI and MP3. For MIDI and MP3 we are currently working on solutions that can be easily integrated also for 3DS if you figure out how to do audio with 3ds. :smiley:

Cross compiling the dependencies is not really rocket science and works the same for all platforms.

The devkitpro wiki has useful information about cross compiling libraries. The libpng way works for almost all platforms. You only have to also pass the arguments “-march=armv6k -mtune=mpcore -mfloat-abi=hard” otherwise you get strange “VFP register argument” errors.

For a minimal build you need at least: iconv (for liblcf), liblcf, libpng, zlib, freetype, pixman, SDL replacements for 3ds (pick any ^^).

What I can offer to you is that we provide all dependencies for the libraries. Then you can directly work on the Player without worrying about porting the libraries. This is no big deal for us because we already offer libraries for Wii, Android, OSX and others. So we are experienced in doing this ;).[/quote]

It could be awesome to have dependencies already compiled. As for the system crash, do you have any idea what could cause the problem? (Maybe some race condition for secondary threads or similar or a RAM allocation problem)

Here are PORTLIBS for easyrpg: Download
I assume you know how to deal with them because you already ported many apps to 3ds ^^.

For the 3ds port the only files you will need to touch (in my branch) are: src/3ds_ui.[cpp,h] and builds/3ds/Makefile

Then it should “just work” when you set the PORTLIBS variable correctly. Though I didn’t try it. Tell me when you get any linker errors in the end of the compile step.

It crashed during startup and only on real hardware, not in Citra :/. Maybe we fixed it already because the startup code of the Player changed during the last months.
And you need a target application with lots of space. The new youtube app is the best location because it has 10 MB :slight_smile:

Noticed right now that Makefile uses hardware floating points. vorbisfile has problem with this setting so i need portlibs compiled with mfloat-abi=softfp.

EDIT: I also have some linking problem:

linking easyrpg-player.elf c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_io.ao): In function `nothing()': ucnv_io.cpp:(.text+0x5a0): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnvmbcs.ao): In function `nothing()': ucnvmbcs.cpp:(.text+0x5678): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ustr_cnv.ao): In function `nothing()': ustr_cnv.cpp:(.text+0x0): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(putil.ao): In function `nothing()': putil.cpp:(.text+0x26c): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(umutex.ao): In function `nothing()': umutex.cpp:(.text+0x0): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucln_cmn.ao): In function `nothing()': ucln_cmn.cpp:(.text+0x0): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(udata.ao): In function `nothing()': udata.cpp:(.text+0x710): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(unistr.ao): In function `nothing()': unistr.cpp:(.text+0x16c): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicui18n.a(csdetect.ao): In function `nothing()': csdetect.cpp:(.text+0xa68): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicui18n.a(ucln_in.ao): In function `nothing()': ucln_in.cpp:(.text+0x38): multiple definition of `nothing()' c:/Users/Alessio/Desktop/easyrpg-player-3ds/easyrpg-player-3ds/lib\libicuuc.a(ucnv_bld.ao):ucnv_bld.cpp:(.text+0x590): first defined here c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/bin/ld.exe: cannot find -lpixman-arm-neon c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/bin/ld.exe: cannot find -lexpat

What does “has problems” mean?

It decode OGG audiobuffer in a wrong way giving you a distorted output (that’s why my lua interpreter uses softfp for floating points).

P.S. I edited the previous message with some linking errors i got.

You can remove -lexpat and -lpixman-arm-neon they are optional.
I tred to fix the linker Errors in ICU. I don’t think soft fp is the way to go. This will waste CPU cycles everywhere. We heavily depend on floating point in our code.

Updated the portlibs. Same link as above: easyrpg.org/downloads/easyrpg_ … bs.tar.bz2
I added the integer implementation of libvorbis “tremor”. Just replace the “-lvorbis” with “-lvorbisidec”, maybe it works?

Ok, compiled successfully but still same system crash it looks like. (I’ve tested it on NH1.1B fw 4.5 (personally) and NH2.6 fw 10.6 with Youtube app as target (tested by ihaveamac)).

Looks like on NH2.6 it also shows some glitchy pixels on the left side of the top screen and app also stucks on a red screen on bottom screen (it’s probably something related to payload debug).

Test in Citra if you get Invalid read/write errors in the console. If yes it will not work.
Also the homebrew Needs for some reason ca. 30 seconds to boot up.
When you see a easyrpg_log.txt in the game directory something was executed.

Got it to work on real HW, problem was caused by missing services init (gfxInitDefault, hidInit etc). Going to trying to improve a bit performances now :smiley:

Cool when you think the port is good enough for sharing (no rush ^^) I would be happy about the source code. Then we can provide nightly builds via our Jenkins Service. We already do this for other special platforms like the Wii.

Looks like the framerate is really good even on O3DS (moving on world map is like 60 fps i think).
Anyway i’m going to start a repository on my Github account for progresses about this and i’ll use this thread to update you about any big progress i make.

I got only ~15 FPS when running EasyRPG the last time. Maybe my Rendering logic was wrong because I had no experience with 3DS ^^

The default button mapping (in my branch) maps “Toggle FPS” to the L trigger. This should render a FPS Counter on the Screen. Would be interested in the real number :smiley:

By pressing L trigger i only get a grey rect on top-left part of the screen <.<

Uhm yeah, this sounds like a Problem with the transparency oO.

This is usually caused by an incorrect “DynamicFormat” Setting:
github.com/Ghabry/easyrpg-playe … ui.cpp#L50

The other versions use the following:
github.com/EasyRPG/Player/blob/ … i.cpp#L479

So NoAlpha instead of Alpha. Maybe it helps…

And the SetFormat call afterwards looks also different. The sdl_ui uses:
So the SetFormat call is porbably just wrong ^^

Bitmap::SetFormat(Bitmap::ChooseFormat(format));

Even if i use NoAlpha and the same SetFormat used by sdl_ui, i get the same grey rect. Could it be related to something like the fps counter is spammed on the texture and then is like if it gets printed more then once in a frame and so it just increase alpha value?

Strange. We use 100% software Rendering so I don’t see a reason why this Fails on the 3ds but nowhere else. Very strange.

Uhm, then do it the hacky way. If you have a working console just output “real_fps” before the “UpdateTitle” call in Graphics::Update

Uploaded the repository here just to let you know: github.com/Rinnegatamante/easyr … ree/master .
Going to do that hacky test.

Mmmhhh it says 16 but i’m quite sure it’s running at higher framerate (or at least, to me it looks playable).