Closed MrHuu closed 4 years ago
3DS port was still an experiment, that is why the Makefile has not been adapted yet to recent structure changes (e.g. removing xmp support). SDL on 3DS is a bit hacky and unfortunately incomplete, i was never able to get it to look correctly. I had done some internal changes as well, but to no avail. You are right about the slowness in some scenes, this can be seen on PSP as well and is some engine limitation (e.g. redrawing too much, tight loops, etc.). This is noticeable in episode selection screen as well.
I've been looking into this before.. unfortunately i lost the source i was working on. But i'm on the right track now.. i think..
At least i got the first frame to display correct, after which it goes blank. It's a start.
@MrHuu: great :+1:, do you remember if you changed SDL code or OJ code back then?
I've only looked at the OJ side thus far. I did look trough the SDL code.
OJ seems to heavily rely on the usage of HWPALETTE's with it's SDL_PHYSPAL and LOGPAL functions.
These don't seem to work properly on the 3DS. Not implemented or functional.
All SDL 3DS rendering is done, then copied to libctru which displays it. Does this mean we have no valid HWSURFACE and HWPALETTE?
It seems like it. Judging on the first images, we've lost the full logical palette. No greyscale at all.
When SDL_DOUBLEBUF is enabled, only the logical (greyscale) palette is shown. The menu is greyscale but the plasma is rendered correct, same as the sky effect in-game and the planet in the arrival scene.
The one frame drawn correct, was before 'WhiteInPaletteEffect' was called. With SDL_DOUBLEBUF enabled.
For debugging I have disabled the palette effects, so it is easier to see actual changes. You seem right about the lack of hardware palette, I will again dig into the SDL port. It should be possible without hardware palette when using software surfaces, but there might be a bug somewhere.
Btw. double buffering is not needed, but you can observe the same, when you just use the HWSURFACE.
I have fixed it in the SDL port. Video: https://p.f4ke.de/oNeWqX6f93-OJ-3DS-test.webm Only needed change was telling SDL it had this capability... :grin: https://github.com/carstene1ns/devkitPro-SDL/commit/9942ec10beb0fa15f6f47aed4030f5d4dce9dac6?w=1#diff-e5c3e0072788ffbca23421fc0b9332a8R410
It would have taken me a long time to figure that part out! Thank you so much. This not only benefits OJ, but every HWPALETTE dependent code.
I was able to compile SDL with the changes, and OJ is working fine now!
One strange thing, when i run it through citra the planet arrival scenes are showing up fine. However, on a real new3DS they're not shown. It goes straight to the game after the loading message.
Thanks for looking into this again!
As a token of appreciation, here are some assets.
A transparent icon doesn't work well, so i created these. This actually looks nice on my 3DS. Although a .cia build crashes for me.
https://github.com/MrHuu/openjazz/commit/fabaac35b633d25d8b62063db3ad2b72e6cee251 This is my makefile, to use the assets and create a cia build.
Edit: Replaced the assets, for community created content. Looks nice.
I like them, however, I do not want to use original artwork, because it is still copyrighted. There is some fanart at least which might be used instead, since they could be licensed for inclusion in OJ, e.g.: 1, 2.
About .cia builds: I am not experienced with them, but we also provide some for EasyRPG Player. There should not really be differences code-wise, so crash reason can be debugged.
Ok, crash reason was found, debugging with rosalina is really a breeze. I will update the 3ds branch soon.
Edit: https://github.com/AlisterT/openjazz/commit/7b1fe7137c50d257515495d7c7d31e51d86b80cd
Somehow GDB encounters an error connecting to my 3ds.. makes debugging quite hard for me. Can i ask you which software you're using to debug?
I love to be able to be able to debug more efficently.
Would be nice to have the exact error message.
I do it as follows:
arm-none-eabi-gdb
Thanks a bunch again! After the big 'crash' where i lost most code i was working on, i somehow started to use gdb-multiarch. Which doesn't recognize arm-none-eabi correct.
With a recent luma, you're able to force debug on the next launch. This way you don't have to be quick, if an application crashes on boot. Like we've encounterd here.
When i try to do it mannually on boot, the screens are not initialized and you have to find the debug menu on a black screen, atleast for 3dsx.
A few things which needs to be adressed for a proper 3ds port:
I'll also update the assets on my git, i kind of worried the audio sample may be copywrited also.. my apologies.
Redefine the default controls
3DS SDL port has the feature, that all buttons have also keycodes. I need to make sure to just use the joystick api and disable keyboard.
To my understanding the dpad binds to the arrow keys, and the circlepad to joystick.
So maybe disable joystick and bind the circlepad to the arrow keys. Like nop90 explained:
SDL_N3DSKeyBind(KEY_CPAD_UP|KEY_CSTICK_UP, SDLK_UP); SDL_N3DSKeyBind(KEY_CPAD_DOWN|KEY_CSTICK_DOWN, SDLK_DOWN); SDL_N3DSKeyBind(KEY_CPAD_LEFT|KEY_CSTICK_LEFT, SDLK_LEFT); SDL_N3DSKeyBind(KEY_CPAD_RIGHT|KEY_CSTICK_RIGHT, SDLK_RIGHT);
Ideally, I should add hat support to 3DS SDL (or add d-pad as buttons), but for now I just inverted the logic: https://github.com/AlisterT/openjazz/commit/e1c3379b0f6c611e6a06752cba2445a258bf9c65 This uses the joystick api for all (o3ds) buttons and keyboard for the d-pad. Changing keyboard settings is disabled.
When i tried to run a .3dsx compiled from the latest 3ds branch, OpenJazz failed to find the gamefiles. It now looks for the gamefiles (datapath) in the root of the 'OpenJazz' folder, instead of 'OpenJazz/Data'.
Is this the intended behavior?
Otherwise:
Wait.. network? Didn't expect that one! What an amazing feature from OJ, does this also work multi-platform (once finished)?
While i'm already having tons of fun with OJ in it's current state. I'll eagerly await your future updates. Your patch to the SDL lib has been merged, and it's proven to work wonderfully.
For now, i think this particular issue can be closed. Since is definitely fixed.
@carstene1ns You're doing an amazing job, keep it up!
I need to investigate the slowness in menu and planet arrival scenes, but this particular issue is solved. Thanks!
With a few minor changes i was able to compile OpenJazz for the 3DS. Disabled XMP and included psmplug, miniz and SDL (DevkitPRO).
Everything is working great on my New3DS. Music / scenes / gameplay at 60fps. Old3DS is running a few frames behind.
However, the colors are way off, as shown in the screenshots below.
The 3DS target was added some time ago, was it working correctly at some point?
I also noticed some other issues. At the end of the level, the countdown for the remaining time takes forever. It's really slow. Could this indicate some timing issues, also affecting rendering?
Or doesn't SDL for 3DS handle the SDL_LOGPAL / SDL_PHYSPAL right? As far as i understand the these flags are only available if the HWPALETTE is set. Which doesn't seem to be the case. Setting it doesn't make any difference tho.
Huge thanks to Alister for this port, and also thanks to carstene1ns for maintaining it.