Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonic the Hedgehog 1 and 2, audio and game progression issues #10

Open
TwoSpacesSG opened this issue Sep 24, 2024 · 15 comments
Open

Sonic the Hedgehog 1 and 2, audio and game progression issues #10

TwoSpacesSG opened this issue Sep 24, 2024 · 15 comments
Labels
bug Something isn't working

Comments

@TwoSpacesSG
Copy link

TwoSpacesSG commented Sep 24, 2024

Sonic 1 (Parts 1 and 2), high-end versions

  • Various gameplay elements rely on the unlocked framerate being capped by the phone's CPU, however freej2me's framerate limiter lowers the framerate of the game in addition to limiting it. Examples of things needing to be limited are Sonic's invincibility frames, moving objects (platforms, moving spikes), the animation of the big ring at the end of the stage when you have 50 rings or more (can be achieved in Green Hill 1 rather easily on easy difficulty mode). Some versions like Sony Ericsson 240x320 don't have any unlocked FPS stuff, but most do.
  • After the music tracks' intro plays out, the main loop does not start. Edit: Fixed now.
  • The invincibility music has the position marker jump around for some reason. There's an invincibility powerup at the very beginning of Green Hill 3 (in Part 1) hidden in a tree reachable with a jump. Edit: Fixed now.
  • The Nokia 208x208 version softlocks with looping music when all lives are lost and the game over screen pops up. Edit: Fixed now.
  • The Nokia 320x240 version uses some kind of key layout not yet in the settings list. Wontfix?
  • The text is misaligned on the "Select language" and "You got a high score" screens. Edit: Fixed now.
  • The Nokia 360x640 version of Part 1 exhibits lag issues.
  • The Panasonic VS3 preinstalled version has "SCR" displayed on blank commands for some reason.

Sonic 2 (Dash! and Crash!), high-end versions

  • Beating a stage softlocks the game. This is likely audio-related. Edit: Fixed now.
  • Like with Sonic 1, the main music loop in the stage does not start after the intro plays. Edit: Fixed now.
  • There are performance issues in Mystic Cave (in Crash!). I should check whether this is actually an emulation bug. Edit: Fixed now.

Sonic 1 Part 1, low-end versions

  • The OTT for the main Green Hill loop does not play. Edit: Fixed now.
  • In the Nokia versions in Marble 2, the transformation on the falling lava is broken.

Sonic Advance

  • The K800i version freezes shortly into the game upon playing a sound effect (at least on Windows). This is a recent regression. Edit: Fixed now.
  • Motorola V8 version has issues with music playback. Edit: Fixed now.
@AShiningRay AShiningRay added the bug Something isn't working label Sep 25, 2024
@AShiningRay
Copy link
Collaborator

AShiningRay commented Sep 25, 2024

Another great report. Thanks for the contribution!

Audio is definitely a pain point in FreeJ2ME at this time. So much so, that running it on Java 22 makes the whole subsystem a lot more performant and reliable than Java 8, not sure why yet... that may very well be why those Sonic 2 jars are softlocking, although i'll have to test these at some point to be sure.

As for the framerate cap, that's a troublesome one too, as FreeJ2ME-Plus just got a commit vastly improving the cap a while ago, but said cap only really helps with smoothness, the overall inner working is the same, just much improved. Right now, i don't see how a different frame cap could be implemented in a way that fixes those issues you've experienced, although i also need to test this one myself to see what's happening and hopefully how and why it's happening.

@TwoSpacesSG
Copy link
Author

One more into the pile of Sega Sonic games, Sonic Advance (Sony Ericsson K800i) has an issue on FreeJ2ME-Plus in which the music stops when you get an extra life by getting 100 rings in a stage (maybe the same effect can be achieved by finding a power-up with Sonic's face on it, not sure). I believe normally the stage music should resume. Otherwise though it works exactly as it should from the looks of it, not that I know this game well.

@AShiningRay
Copy link
Collaborator

Yep, it should, i played this one on my G6608 (dead since last year) quite a few years ago, and even there it resumed after the 1-up midi cue stopped.

I guess i should get a J2ME phone of some kind, even if just to have something other than emulators to test...

@AShiningRay
Copy link
Collaborator

AShiningRay commented Sep 28, 2024

Okay, now going back to Sonic Part One now that i had some time to run it...

  • Various gameplay elements rely on the unlocked framerate being capped by the phone's CPU, however freej2me's framerate limiter lowers the framerate of the game in addition to limiting it. Examples of things needing to be limited are Sonic's invincibility frames, moving objects (platforms, moving spikes), the animation of the big ring at the end of the stage when you have 50 rings or more (can be achieved in Green Hill 1 rather easily on easy difficulty mode). Some versions like Sony Ericsson 240x320 don't have any unlocked FPS stuff, but most do.

That's a quirk that'll be complicated to "simulate", as FreeJ2ME doesn't emulate any hardware per se, your device is running those J2ME apps almost natively besides some abstractions and extra classes here and there. AFAIK no J2ME does that, KEMulator doesn't even get to the menu depending on the version, and J2ME Loader also displays that same issue with animations, although audio does work fine there.

  • After the music tracks' intro plays out, the main loop does not start.

  • The invincibility music has the position marker jump around for some reason. There's an invincibility powerup at the very beginning of Green Hill 3 (in Part 1) hidden in a tree reachable with a jump.

This might actually be related in some way to Shadow Shoot and Puyo Pop Fever DX, i went in a bit more detail about them on their own Issue (#12).

@TwoSpacesSG
Copy link
Author

That's a quirk that'll be complicated to "simulate", as FreeJ2ME doesn't emulate any hardware per se, your device is running those J2ME apps almost natively besides some abstractions and extra classes here and there. AFAIK no J2ME does that, KEMulator doesn't even get to the menu depending on the version, and FreeJ2ME also displays that same issue with animations, although audio does work fine there.

I don't know which KEmulator version you're trying, but KEmulator 0.9.7 and nnmod supported this game fine the last time I checked. Maybe this is an issue on 0.9.8 or 1.0.3 which have various bugs sadly.

But I brought up these KEmulator versions as an example because you will be able to easily understand what I mean once you do try it (or alternatively I think J2ME Loader behaves in a similar way to KEmulators as well, even though it has different sound issues in Sonic 1). Limiting the FPS to something like 60 in those only provides a framerate limiting effect to that FPS value, but in FreeJ2ME, limiting the FPS to 60 also bumps it down to something like 30 or maybe even less. It's an effect that you can see in other games that have explicitly capped FPS (off the top of my head - Disney-Pixar WALL-E), while in other games such as Bounce Tales it works correctly.

I'm really sorry for comparing Freej2me to other projects which sometimes don't even have an open source license. It's not in order to berate yours, but simply to bring up an example of something working. I used KEmulator a lot prior to the opening of this fork.

@AShiningRay
Copy link
Collaborator

I don't know which KEmulator version you're trying, but KEmulator 0.9.7 and nnmod supported this game fine the last time I checked. Maybe this is an issue on 0.9.8 or 1.0.3 which have various bugs sadly.

Latest kemulator nnmod, although it's on an arch-based linux distro + OpenJDK 8 (so that it can be compared to FreeJ2ME on the same underlying JVM), maybe that's why it happens, but kemulator simply freezes at the "Sonic Team Presents" screen.

As for J2ME Loader, on my Android 14 device, trying to limit it to 60fps has no effect and it goes right back to "unlimited" the next time i open the app settings or the fps limit menu up again, which means the animations are still too fast, almost like FreeJ2ME... now if i limit it to less than 50fps (which seems to be the highest framerate it'll actually limit to), then it works, but it's choppier than FreeJ2ME, including the end stage's spinning ring... that happens no matter the renderer, be it software, hardware, gl, etc.

Not saying FreeJ2ME is perfect, just that other simulators seem to have the same problem and it might not be their fault in this case, just like Rayman Raving Rabbid's weird input handling code that probably exploited device quirks at the time.

I'm really sorry for comparing Freej2me to other projects which sometimes don't even have an open source license. It's not in order to berate yours, but simply to bring up an example of something working. I used KEmulator a lot prior to the opening of this fork.

Eh, that's a good thing, as i said before, FreeJ2ME still needs a TON of work. I don't think i'll be able to fix all that much by myself (i'd rather work on the UI side of things to make this more accessible and friendlier to the user), but the more docs we have on this one's compatibility issues, the better.

@AShiningRay
Copy link
Collaborator

Alright, just got around to test Sonic 2 Crash, and the issue here is exactly what i expected it to be: FreeJ2ME's tendency to freeze when audio cues are loaded and played in certain JVMs, especially older ones. In OpenJDK8 here, it's rather easy to freeze the game when completing stages, while in OpenJDK11 to 22, it's pretty much perfect and i got to Mystic cave to Metropolis Zone 2 no problem... i wonder what makes FreeJ2ME behave this way on older JVMs though...

@TwoSpacesSG
Copy link
Author

Gonna comment on the topic of Sonic platformers by Sega again. Sonic Advance (K800i) has a regression in which the game freezes shortly into the gameplay, which might be sound effect related, though nothing shows up in the log.

@TwoSpacesSG
Copy link
Author

Thank you very much for fixing the performance issue in Sonic 2 Crash.

@AShiningRay
Copy link
Collaborator

AShiningRay commented Dec 9, 2024

Sonic 1 Part 1, low-end versions

* The OTT for the main Green Hill loop does not play.

* In the Nokia versions in Marble 2, the transformation on the falling lava is broken.

OTT should be fixed now (beebdd4). As for the transformation, i have a feeling it's a similar issue to Fantasy Zone.

Edit:

Sonic 1 (Parts 1 and 2), high-end versions

* The invincibility music has the position marker jump around for some reason. There's an invincibility powerup at the very beginning of Green Hill 3 (in Part 1) hidden in a tree reachable with a jump.

* The Nokia 208x208 version softlocks with looping music when all lives are lost and the game over screen pops up.

Fixed too (f375963)

Edit again:

Sonic Advance, high-end versions

* The K800i version freezes shortly into the game upon playing a sound effect (at least on Windows). This is a recent regression.

Fixed too... (either f375963 or d59812f, maybe due to both)

Actually, this one, and any other jar that exhibited the same issue, which includes K800i versions of multiple games which use wav in conjunction with midi extensively

Yet another edit:

Sonic 1 (Parts 1 and 2), high-end versions

* The text is misaligned on the "Select language" and "You got a high score" screens.

Also fixed (199aece)

@TwoSpacesSG
Copy link
Author

Thank you so much for the fixes. Two issues remain on the ever shrinking and growing list:

  • Sonic 1 Part 1 low-end, lava drops look glitched, at least i assume they look proper on real hardware.
  • In the Motorola V8 version of Sonic Advance by Sega (and actually Sonic Racing by Gameloft) there are issues with music not playing. Maybe this might be a wontfix, dunno, something tells me that Sega and Gameloft did something stupid to get it working on those Motorolas specifically.

@TwoSpacesSG
Copy link
Author

TwoSpacesSG commented Jan 21, 2025

I tried Sonic Advance for Motorola V8 again, and I don't notice this previously reported issue (Sonic Racing still has it, but that's for another report). However I have noticed two new issues with Sonic 1 (high-end), therefore the list is now looking like this:

  • Sonic 1 Part 1 low-end (Nokia), lava drops look glitched, at least i assume they look proper on real hardware.
  • In the 360x640 version of Sonic 1 Part 1 high-end, there is noticeable lag when Sonic runs, but not when he jumps.
  • In the newly preserved Panasonic VS3 preinstalled version of Sonic 1, which works fine otherwise, the blank commands have "SCR" written on them for some reason.

@TwoSpacesSG
Copy link
Author

TwoSpacesSG commented Jan 23, 2025

I played a bit of Sonic 2 Crash recently and noticed 2 issues, first is that there's a regression where Mystic Cave is really laggy again, and second (this is also an issue in Sonic 2 Dash), the fade-out on the stage music when you enter the boss arena comes in late, and it ends up fading out the boss theme instead, so you fight the boss in silence. Updating the list once again:

  • Sonic 1 Part 1 low-end (Nokia), lava drops look glitched, at least I assume they look proper on real hardware.
  • Lag issues in Sonic 1 Part 1 high-end (Nokia 360x640) and Sonic 2 Crash high-end (SE K800). See below
  • In the newly preserved Panasonic VS3 preinstalled version of Sonic 1, which works fine otherwise, the blank commands have "SCR" written on them for some reason.
  • When going into boss arenas in Sonic 2 Dash and Sonic 2 Crash high-end (easiest to test is Death Egg Zone in Crash), it fades out the boss theme shortly after it begins, instead of the stage theme.

@AShiningRay
Copy link
Collaborator

In regards to K800i Sonic 2 Crash's performance (probably applies to nokia 360x640 as well), cannot replicate, it should actually be running faster on recent builds.

Image

That's my desktop at home and not my laptop as i'm on my brief lunch break, but that E5 2680v3 should have about the same single-core performance as my laptop's i5 8250U. As it stands, locking the CPU to 1.2GHz max on power saving mode is still more than enough to keep it at its intended framerate, with FreeJ2ME barely using a single core there.

Unless the large cache is what's helping my desktop's CPU, i don't see why it could have regressed so much on recent builds that use faster DataBuffer manipulations for a few more drawing operations (those where they make sense).

Aside from the incorrect BGM fadeout and Marble Zone's lava drops which are confirmed, the others require some deeper investigation... although the command issue seems rather easy to "fix", as it's just cosmetic.

@TwoSpacesSG
Copy link
Author

Oh I see what the issue is with the lag in both of those, it only happens when the heap is set to 32mb (-Xmx32M), meanwhile when it's set to 64mb, then the issue is not present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants