Sonic 1 J2ME General Hacking Thread

Discussion in 'Discussion & Q&A' started by Kilo, Apr 29, 2020.

  1. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    In case you are unaware, Sonic 1 J2ME is a port of the original Sonic the Hedgehog for mobile phones from 2005. It's actually what the 2006 'Sonic Genesis' GBA port is based on. Over the past month, some users such as @HyperPolygon64 @AURORA☆FIELDS and @CuckyDev along with I and others have been researching how it all works. As of April 29th, everything is still fairly new, and our decompilation is heavily obfuscated and unbuildable. However, now as interest is starting to wane, I figured it'd be appropriate to make this thread to renew interest. This version of Sonic 1 is very easy to modify because the graphics are literally just PNGs and the music, MIDI. We're working towards making a cleaned up decompilation, so code and level modifications can be achieved too.

    Here are a couple of resources to help you start with S1 J2ME hacking.
    Decompilation Github Page
    Discord Community
    KEmulator 1.0.3 (Provided by LilShootDawg)
    FernFlower Java Decompiler
    An original JAR of the game (Essentially a ROM) has been provided as well, I made sure to talk to Lazlo about this and it should be fine, legally.

    Feel free to also use this thread for discussion and showcasing what you've been able to do with S1 J2ME as well!~
     

    Attached Files:

    Last edited: Apr 30, 2020
    Monitor and rika_chou like this.
  2. DeltaWooloo

    DeltaWooloo The noob next door Member

    Joined:
    Aug 7, 2019
    Messages:
    373
    Is there no possibilities of changing the level design?
     
  3. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Not yet. We don't understand the layout's file format, but once we do, there'll supposedly be a fork of SonLVL made.
     
  4. Tanman Tanner

    Tanman Tanner Well-Known Member Member

    Joined:
    Dec 23, 2016
    Messages:
    116
    Location:
    Buffalo, New York
    I'm assuming by that the fact the music is in midi format is that you can simply swap out music tracks with other midi files, but I have a feeling there's a catch: does the midi file have to fit within a specific size constraint and be formatted a certain way?
     
    ProjectFM likes this.
  5. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    As far as we can tell, there are no limits at all. As long as it's a MIDI, it works. Anything we've thrown at it plays out properly.

    However, there is a catch with the PNGs. You can only use 256 color (or less) images, or else you lose transparency. As well, you can extend the sizes of images that only use 1 frame (Like the Sega logo) but multiframe sprites (Like Sonic) are not the case. We're still working to figure out how to edit the sizes of frames and whatnot, so stick around for that. Hopefully we can make an animation tool or something afterwards.
     
    Last edited: Apr 30, 2020
    Tanman Tanner likes this.
  6. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    New commit to the decomp, the first one since April. Rolled back the class decompiles because the obfuscation was too much to handle. They'll have to be decompiled more carefully by paying attention to the bytecode. Also added Part 2, but because it was made by a different developer from Part 1 (iFone made Part 1, glu made Part 2), the highest resolution available was 208x208. Hopefully the next major commit will at least be buildable.
     
  7. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Thanks to the research of Leia Ivon Flame over at the Sonic Java ME Hacking Server, we now know what BMD files are! They're the chunk files. This was discovered while she was also working on a new level editor for us called "SON_ME". Here's a bit of a look. Please note that the chunks aren't exactly being read properly, but it's just about there.
    [​IMG][​IMG][​IMG]
    It's impressive how she figured this out so quickly too. With the BMD files being loaded up in a matter of about an hour and a half. It's my theory that BMD stands for "Background Meta Data". Let me know what you think!~
     
  8. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Update: SON_ME can now load level layouts. And as for these graphical corruptions; it's because tile attributes like flipping are contained in external BLT files that determine those attributes.
    [​IMG]
     
    ProjectFM likes this.
  9. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Final update for tonight, objects now load. Currently, they just display their IDs, no fancy graphics.
    unknown-1.png
     
    Ravenfreak and ProjectFM like this.
  10. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Updates on file names. Comparing bytes to Sonic 1 MD, I've found the following equivalents (Based on Hivebrain file names;
    scdtblwk.scd = collide/carray_n.bin
    scddirtbl.blt = collide/anglemap.bin (With $100 other bytes that I'm still trying to track)
    zone1.blt = collide/ghz.bin (And same for other zones)

    All that's left in terms of figuring out these files are the Map L files (Looked into them and they consist of seemingly only 0 or 1), and those $100 bytes on scddirtbl.

    For those curious about the naming of scdtblwk and scddirtbl, those are abbreviations for their functions, according to Kaz on Discord, they mean "Sonic Collision Detection Table Work" and "Sonic Collision Detection Direction Table". Note in Naka terms, direction means angle.

    It's both shocking and intriguing how much data was actually directly copied from Sonic 1's source, considering the quality of the port in action. It makes me curious what went wrong down the road to porting this.

    Really looking forward to this decomp being complete, and it excites me how many discoveries and information is popping up on Sonic 1 J2ME, these past few days.

    Oh yeah- and SON_ME can write data now, instead of merely reading it.[​IMG]
     
    vladikcomper and MarkeyJester like this.
  11. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Thanks to @MarkeyJester providing the original assets to us, Sonic 1 J2ME now has it's first custom level! Straight from Pana Der Hejhog. Background's a little screwy since we don't know how to edit those just yet. But still, this is huge!~
    [​IMG]
     
  12. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    SON_ME is recieving a rewrite from Game Maker Studio 2 to Godot. Now with more research and understanding of S1J2ME's formats!
    unknown.png
    As you can see, those buggy tiles are now gone~
    All this is again, thanks to the work of Leia Ivon Flame.
    On my front I've been working to de-obfuscate some of the java files. The process is slow but it's happening.
    unknown-1.png
    unknown-2.png
     
  13. Leia Ivon Flame

    Leia Ivon Flame Newcomer Trialist

    Joined:
    Jun 13, 2020
    Messages:
    1
    just leting you all know i literally only started this re implementation of the viewer/editor today (about 6-8 hours ago btw) this is the Todo list at the moment along with a few latter ideas.

    ToDo
    • Make Chunks a single sprite.
    • Add ability to load from external files.
    • Add Basic UI.
    • get a big json file saying what objects are called as well as pointing to graphics so the editor can display them okay.
    • Add Collision Tileset viewer.
    • Display collisions on map viewer.
    • Add Basic Layout Manipulation. (likely in its own mode)
    • Add Basic Chunk Manipulation. (likely in its own mode)
    • Add Basic Object Manipulation. (likely in its own mode)
    • Add Basic Collision Editor. (likely in its own mode)
    • Add Basic Saving and Loading.
    • Add Sonic 1 Mega Drive support for conversion between formats allowing easy mod conversion..

    possible
    • Sprite Resizing (without altering code, need to work out if some files are what we think they are.).
    • A Tilemap maker allowing you to copy in your art assets and it will remake them into tilemaps (for level data, unsure about things like objects as of now)
    • Sonic2 Crash and Bash J2ME port support (would require a lot of work but got a good chunk documented).
    • Making the editor modlure and adding lots of 2d games to it, some sonic games some not.
      I've got a lot of games documented for lots of systems but haven't built editors for most, it would be nice to have them all in one program to reuse code and UI systems.
     
    Kilo, ProjectFM and DeltaWooloo like this.
  14. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Small note. While in the Mega Drive version of Sonic 1, SBZ3 is technically LZ4 and FZ is the true SBZ3; in J2ME, SBZ3 does use the SBZ3 ID and FZ is actually SBZ4.
    Example here
    upload_2020-9-9_7-3-40.png

    Aside from that though, it does use the same internal zone order.
    upload_2020-9-9_7-7-28.png
     
  15. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Presenting my J2ME project for SHC 2020: Sonic Mania J2ME
    upload_2020-9-10_11-15-6.png upload_2020-9-10_11-14-29.png upload_2020-9-10_11-16-18.png
    This project is to be the hack to demonstrate the community's evolution and the skills built as time goes. As well as a demonstration of my skills with Java.
    As established, currently we're only at graphics, music, and text mods, and so Sonic Mania J2ME reflects that.

    Also to promote Mania J2ME, I got an artist by the name of MeloSoni12 to make some art for me, and I gave it a few edits (Which was permitted)
    [​IMG]
    [​IMG]
     
  16. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Big step! We've got our first fully commented and documented function in the decomp!
    upload_2020-9-11_17-18-18.png
     
  17. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    And you already managed to make a typo, "gme" over :U

    jk, keep up the great work, I wish I could help but I can't Java :(
     
  18. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    At least the screw up is only in the comments :p
    Appreciate the thought though! Thankfully, if you do want to help you actually don't need much skill with Java, at least not at the moment. Really any understanding of high level languages would help. Currently, we've just been tracking down variables and giving them names (i.e 'l' is chsEmrlds, 'A' is lives, etc, etc)
     
  19. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    I've also started work on my own hacking suite for S1 J2ME, called SonMicro
    Right now it's pretty simple, and I still have lots to learn about C++, but it's coming along
    upload_2020-9-12_7-41-44.png

    EDIT: I scrapped the WINAPI C++ program in favor of... Unity.
    It's just a lot easier for me to understand.
    unknown.png
     
    Last edited: Sep 13, 2020
    ProjectFM likes this.
  20. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    Now that does look like something I can help with. What I do best is data manipulation, which might be largely useless since you can directly use PNGs and MIDIs, but there might be some sort of converter that is still needed?