RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Would you like to play Nokia (J2ME) games on Retropie?

    Scheduled Pinned Locked Moved Ideas and Development
    sdlemulatorawesome
    304 Posts 22 Posters 146.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • HexH
      Hex
      last edited by

      Here is a OpenFX/JavaFX demo that i managed to get working on Pi zero. Needs root access to write to Framebuffer but works none the lesss.

      alt text

      Sent from 20,000 leagues under the sea.

      Powersaver Emulation station : https://github.com/hex007/EmulationStation
      ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

      recompileR 1 Reply Last reply Reply Quote 1
      • recompileR
        recompile @Hex
        last edited by

        @hex Perfect!

        I'll get to porting MicroEmulator from Swing to JavaFX. See if you can work out a process to get that JavaFX test you have working on the Raspbain Retropie build for the pi2/3.

        1 Reply Last reply Reply Quote 0
        • HexH
          Hex
          last edited by Hex

          @recompile I ran it on zero. It would definitely run on 2/3. give me half an hour.

          EDIT : You can get the proper sources from here https://github.com/tisoft/microemu
          and binaries for openFX from https://chriswhocodes.com/

          Sent from 20,000 leagues under the sea.

          Powersaver Emulation station : https://github.com/hex007/EmulationStation
          ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

          recompileR 1 Reply Last reply Reply Quote 0
          • recompileR
            recompile @Hex
            last edited by recompile

            @hex I don't know what you mean by "proper sources", but I don't have any interest in starting that process over again. I've made quite a few changes already, and I'd rather not move backward.

            I couldn't get my JavaFX test to run using the binaries from chriswhocodes.com on my pi 3 using Oracle's JVM. Are you using OpenJDK?

            Ed: I installed OpenJDK and copied the binaries over. That didn't work either, so I switched back to Oracle (update-alternatives --config java) and it magically worked.

            Very strange. I have no explanation.

            1 Reply Last reply Reply Quote 0
            • HexH
              Hex
              last edited by

              @recompile at the end of the day that is what matters. As for the proper sources, the repository has proper directory structure, feel free to check it out. I didnt mean to imply that you should switch to that codebase.

              The binaries on the website are arm6 and Pi3 is arm7. That might have caused some issues. I am planning on compiling from source so i have a arm7 binary. That way it can be tested on both architectures.

              Sent from 20,000 leagues under the sea.

              Powersaver Emulation station : https://github.com/hex007/EmulationStation
              ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

              recompileR 1 Reply Last reply Reply Quote 0
              • recompileR
                recompile @Hex
                last edited by

                @hex As it turns out, the structure is identical to the sources on Google code and sourceforge. (I suspect that the code is identical as well) I removed the 'java' subdirectories for convenience as the entire project is in just one language.

                "The binaries on the website are arm6 and Pi3 is arm7." Good to know. Still, as long as it's working I can test it.

                1 Reply Last reply Reply Quote 0
                • HexH
                  Hex
                  last edited by Hex

                  I think we can change the openfx runtime framework "jfxrt.jar" for a better one later for performance.

                  I shall till then start working on getting the button mapping transformed.

                  Shall we create a github repo for managing the code ? You can host it on your profile or I can have it on my profile with the other as a contributor. Let me know what you think.

                  EDIT : Mapper file in microemu/microemu-javase-swing/src/org/microemu/device/j2se/J2SEButtonDefaultKeyCodes.java#76

                  Sent from 20,000 leagues under the sea.

                  Powersaver Emulation station : https://github.com/hex007/EmulationStation
                  ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                  recompileR 1 Reply Last reply Reply Quote 0
                  • recompileR
                    recompile @Hex
                    last edited by

                    @hex I wouldn't bother with that. I'm going to move all the mappings to config files. One for a default config, and one per-game. (We won't be building anything in the swing branch anyway once we've moved to JavaFX.)

                    If you want to work on key mappings, figure out what you want the format to look like. Be sure to include display resolution as some games won't work, or won't work correctly, if the display is the wrong size.

                    I'm working on it now, thought it may take a few days to get running. (Fortunately, I think we can simplify the code rather dramatically.) Once I have a working JavaFX build, we can put it up on github or wherever.

                    1 Reply Last reply Reply Quote 0
                    • HexH
                      Hex
                      last edited by Hex

                      @recompile I shall get on the design stuff.

                      Regarding the mapping, I was thinking the following

                      Start , Select -> Soft 1,2
                      Dpad -> Dpad and hence (2468)
                      A - > 5
                      B -> 9
                      X -> 2
                      Y -> 7
                      L -> 1
                      R -> 3

                      Most games should work with this config. problematic would be those using 0,*,#

                      Regarding the resolution, If game is in portrait mode then y = Height, Landscape mode x=width.
                      microemu has a scale (2x, 3x, 4x) output feature so we can leverage that.

                      Sent from 20,000 leagues under the sea.

                      Powersaver Emulation station : https://github.com/hex007/EmulationStation
                      ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                      recompileR 1 Reply Last reply Reply Quote 0
                      • recompileR
                        recompile @Hex
                        last edited by

                        @hex I think I'm done with this project. It's just not going to happen.

                        I gave up porting MicroEmulator. It's ridiculously over-complicated. I figured it would be easier to just write the thing from scratch, so I did.

                        MicroEmulator, for all its absurdity, works very simply. It implements javax.microedition.* and uses the reflection API to read the manifest, load the application, and call the startApp method.

                        Simple, right? So that's exactly what I did. Granted, while my implementation of javax.microedition was minimal, it was good enough to get a few games to run for a while. Happy with my progress, and the significantly simpler code base, I added a JavaFx UI and some code to handle all the image drawing. That's when everything fell apart.

                        See, JavaFx doesn't like when you try to modify things from outside a JavaFx thread. Naturally, games will want to do this very thing. Short of a lot of very slow pixel-by-pixel image operations (yes, really) and some tricky message passing, a pure JavaFx solution was out.

                        Big deal, right? Just re-implement all the graphics stuff in AWT and use SwingFXUtils. It's simple and mostly solves the problem.

                        A test shows that the AWT works on the pi, you just can't display anything. So I gave it a try with a sample application. Unfortunately, SwingFXUtils is not available to us on the pi. It's like we're a niche market that Oracle doesn't care about.

                        So I'm out. It was an interesting distraction, but it's looking like a fool's errand.

                        All is not lost, however. For anyone interested in playing a few games that didn't previously work in MicroEmulator due to one problem or another, I have the last MicroEmulator build I made.

                        http://drichardson-shared.s3.amazonaws.com/microemu-2017.zip

                        You can even play Doom II RPG if you use the slowdown feature. It's not a total loss.

                        1 Reply Last reply Reply Quote 1
                        • HexH
                          Hex
                          last edited by

                          @recompile Thats sad. Its great that you were able to improve on the base emulator.

                          So if we can get swing to work without x11, will it help?

                          Sent from 20,000 leagues under the sea.

                          Powersaver Emulation station : https://github.com/hex007/EmulationStation
                          ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                          recompileR 1 Reply Last reply Reply Quote 0
                          • recompileR
                            recompile @Hex
                            last edited by

                            @hex If we could get Swing to work without X11, we're pretty much done. However, I don't see how that could possibly be accomplished.

                            1 Reply Last reply Reply Quote 0
                            • HexH
                              Hex
                              last edited by

                              @recompile Would it be possible to run Swing in headless mode, capture the screen and use SDL to output it?

                              Sent from 20,000 leagues under the sea.

                              Powersaver Emulation station : https://github.com/hex007/EmulationStation
                              ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                              recompileR 1 Reply Last reply Reply Quote 0
                              • recompileR
                                recompile @Hex
                                last edited by

                                @hex Not to my knowledge. Again, we lack Java SDL bindings. If you can get it to work, great, but I have no confidence.

                                1 Reply Last reply Reply Quote 0
                                • HexH
                                  Hex
                                  last edited by

                                  @recompile I am guessing you have tried this https://sourceforge.net/projects/sdljava/

                                  Sent from 20,000 leagues under the sea.

                                  Powersaver Emulation station : https://github.com/hex007/EmulationStation
                                  ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                                  1 Reply Last reply Reply Quote 0
                                  • markwkiddM
                                    markwkidd
                                    last edited by markwkidd

                                    10 years ago, the Lightweight Java Gaming Library was in my opinion, a great library. It provided access to OpenGL among a few other things. It's still actively but I am completely ignorant of the current state of Java or LWJGL these days. I thought maybe it could help though :)

                                    https://github.com/LWJGL

                                    Edit: My aging mind was mixing up SDL with OpenGL. Sorry, not relevant!

                                    1 Reply Last reply Reply Quote 0
                                    • markwkiddM
                                      markwkidd
                                      last edited by markwkidd

                                      edit: nevermind

                                      1 Reply Last reply Reply Quote 0
                                      • recompileR
                                        recompile
                                        last edited by

                                        I guess I'm not done...

                                        ShadoWalker

                                        Doom RPG

                                        So I converted everything to AWT, as I had a lot of work that would have gone wasted otherwise. I figured that someone might want a new J2ME "emulator" either to tinker with the source or just to play their old games. Out of curiosity, I wondered if the JavaFx bit would be as slow as I thought.

                                        While the JavaFx version plays fine on the desktop, it's absolutely awful on my pi 3. It's okay for turn-based games like Doom RPG and Orcs and Elves, but games like ShadoWalker are just too slow to be fun.

                                        Give it a try if you want.

                                        FreeJ2ME - JavaFx

                                        You'll need the JavaFx binaries (see Hex's post above) and Oracle's JDK. Run as root from the command line, e.g.:
                                        java -jar freej2me_javafx.jar file:/home/pi/RetroPie/roms/j2me/ShadoWalker.jar 240 320

                                        Q and E for soft 1 and 2, numbers, arrow keys, wasd (depending on the game). Mouse for touch screen (for games like Doom II RPG). M to quit. Experiment with display sizes if a game isn't working correctly (128x128, 176x208, 240x320 are common, 360x640 for some later games, notably Doom II RPG)

                                        Yes, the controls are stupid and there isn't any controller support. This was just a test, after all. It's not like it runs fast enough to be fun anyway. I offer it here for novelty only.

                                        Maybe it'll work okay on the pi 4, should it ever appear.

                                        1 Reply Last reply Reply Quote 3
                                        • HexH
                                          Hex
                                          last edited by

                                          @recompile Excellent work. I will give it a try. How is that old phones were better at doing this. Since this is technically not an emulator, more like an interface I was under the impression that performance would be least of the worries. Is it the graphics conversion that makes it slow?

                                          Sent from 20,000 leagues under the sea.

                                          Powersaver Emulation station : https://github.com/hex007/EmulationStation
                                          ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                                          recompileR 1 Reply Last reply Reply Quote 0
                                          • pjftP
                                            pjft
                                            last edited by

                                            Out of curiosity, when you're running it and run topin a separate SSH session, what's the bottleneck? CPU? Memory? Something else?

                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.