Sonic CD Quirks (Sega CD Version)

Discussion in 'Engineering & Reverse Engineering' started by Devon, Jul 11, 2022.

  1. Devon

    Devon

    I am CRUSHING YOUR HEAD!!!! Tech Member
    685
    295
    63
    Y'know what? I think I can make a thread out of this. Let's start off with the following:

    • Files for the Sub CPU code for the ending FMVs have the wrong filenames (GOODEND.BIN is for the bad ending, BADEND.BIN is for the good ending, .MMD and .STM files are correct, though)
      Level 16x16 blocks are compressed in Nemesis, which is usually only meant for graphics compression, not metadata compression.
    • Level demo files are built from a slightly older version of the level codebase.
    • R11A uses direct addresses for player variables in LevelSizeLoad, and also takes out some leftover Sonic 1 code, while the other level files I've seen pass the player slot into a6 and retain said leftover Sonic 1 code.
    • FMV PCM streaming code has an issue where it'll not write the last 8 bytes in a packet, due to the very last PCM bank having a loop flag set, and them lazily not wanting to overwrite it, resulting in playback quality degradation. Their setup turned out to be unnecessary anyways, but they probably didn't know that, since PCM playback address wrapping back to the start of wave RAM when going past the end isn't officially documented.
    • Speaking of FMV PCM streaming, there's code for setting up a second channel. It's possible that stereo audio was planned, but scrapped. The second channel's registers are set to corrupt data and actually does sound, but its volume is set to 0, so nothing is actually played back from it.
    • Each music track gets their own Sub CPU command entry for playing it. Doubled actually. A set for normal playback, and another for the sound test.
    • Each level gets their own Sub CPU command for loading it. They all point to the same function, but the command ID is used for another table for loading in the appropriate data.
    • The "I'm outta here" and time warp timers are updated every V-BLANK, so even if the game is lagging, they update at a steady 50/60 Hz. This explains why the Taxman version appears to take longer to do a time warp sometimes, even though it really isn't.
    • The Gems Collection of the game has leftover symbol data that can give a glimpse into how files were structured. While levels did use some commonly shared code, they did copy and paste other files for more specific things like scrolling, object lists, data, etc. Even if there are some functions that should also be shared from one common file, they aren't, and this explains some of the weird minute differences between level files.
    • Title screen has 3 unused object functions that are broken.
      • The first sets a "bookmark" that the object manager will jump to in future calls for that object. There's another version that does that and exits the object, and this broken one is meant to set it and then return back to the object. It breaks because it overwrites a0, which was also used for the object slot pointer.
      • The second one is meant to update the object's address manually, but in the title screen, object addresses are stored as words (with the upper word being automatically set to 0x00FF, since it's all loaded in Genesis RAM), and in this function, it writes a longword.
      • The third is meant to delete an object, but it advances a0 as it erases data, so it desyncs the object manager loop.
    • SMPS-PCM issues that aren't really to do with Sonic CD to begin with:
      • The driver is based on the US BIOS' version, where they took out the rhythm channel in a half-assed manner. They didn't remove the slot in the variables region and they didn't take out the channel ID in the assignment array for song tracks. As a result, the proper slot and channel assignment for track 8 are unreferenced. This actually causes a bug with track 1 and 8, because the rhythm channel was assigned to use channel 8, with song track 7 using channel 8 (I'll explain why in the next point) whenever rhythm was not being used. However, since they forgot to totally remove the rhythm channel data, track 1 uses channel 8, while track 8 also gets assigned that channel.
      • SFX support is very lackluster. Channel overriding does not exist. What they did was allocate SFX to play on channel 7 and try not to have the music use that channel. Originally, with the rhythm channel intact, track 8 was assigned to use channel 7 (which is why track 7 was assigned to use channel 8), so you'd have to be careful to not let SFX and track 8 clash. However, here with the rhythm channel partially removed, channel 8 no longer clashes with SFX, but like I said in the other point, it clashes with channel 1, instead, which is arguably worse. In the end, no matter what, track 8 is just not really safe to use in gameplay.
      • The way that samples are being statically loaded into wave RAM if not set to be streamed can be problematic. A sample is defined in a table, and if you don't set it to be streamed, then you must define the location in wave RAM for it to be loaded into. The problem is that for samples that ARE being streamed, its location in wave RAM is automatically assigned based on the channel ID, and static samples do not take that into account.
      • For samples that are being streamed, the stream rate is fixed, in the sense that it fills up a designated wave RAM bank at $200 bytes per driver call, effectively making the maximum supported frequency around the native sample rate of the PCM chip. Playing samples faster than that will cause issues, as the streaming code won't be able to catch up in time.
    • In Wacky Workbench, they used a different codebase for the Sonic object. Most of the changes include handling the stage gimmicks and removing the extended camera. However, the spindash charge speed is also 50 instead of the standard 75. Right now, I have no clue why this is, though I do feel it might have to do with the disabled extended camera. It doesn't cause the charge to require a longer time, since that's based on a timer, and not the charge speed, though.
     
    Last edited: Jul 12, 2022
    • Informative Informative x 8
    • Like Like x 4
    • List
  2. Brainulator

    Brainulator

    Regular garden-variety member Member
    I'm curious about the Bata-Pyon enemy in Wacky Workbench: is its code a modified version of Splats's from the Sonic 1 prototype?
     
  3. Devon

    Devon

    I am CRUSHING YOUR HEAD!!!! Tech Member
    685
    295
    63
    No.
     
    • Informative Informative x 2
    • List
  4. Devon

    Devon

    I am CRUSHING YOUR HEAD!!!! Tech Member
    685
    295
    63
    Here's a fun little one in Wacky Workbench. So, in the prototype, the background was green, like this:

    [​IMG]

    Later on, they changed it to be more blue, like this:

    [​IMG]

    In this stage, there are sections where sections of electrical wiring or whatever it's supposed to be flashes to indicate that it's active. It also makes the background flash. When they changed the background colors, they did update the flashing color data, but they forgot to update the code that restores the background color after flashing. This is why one of the major background colors turns green, like this:

    [​IMG]

    From R61A:
    Code (Text):
    1. ROM:0020CD46                 lea     (palette+$7A).w,a3
    2.                              ...
    3. ROM:0020CD4E                 move.w  #$680,d2

    In this code, that $680 is the prototype color value. They forgot to change it to $A60.
     
    • Like Like x 5
    • Informative Informative x 3
    • List
  5. Devon

    Devon

    I am CRUSHING YOUR HEAD!!!! Tech Member
    685
    295
    63
    The existence of some prototype code and also the fact that in 510, the spindash charge speed was set to 50 everywhere tells me that they forgot to apply certain updates to Wacky Workbench's version of the Sonic object during development... whoops!
     
    Last edited: Jul 16, 2022
    • Like Like x 2
    • Informative Informative x 2
    • List
  6. Pobert-Eii

    Pobert-Eii

    Member
    75
    75
    18
    Fun fact: If you do a peel-out by Up+A, then redirect it to Down, you can convert it to a Spin Dash. Simple, right?
    Well, if you redirect it to Downright/Downleft, Sonic will begin sliding while crouching really fast. Press Upright/Upleft, and Sonic's peel out animation will play in place. This causes weird as fuck things to happen with the game's collision, but one example is in Palmtree Panic 1 where Sonic can end up inside the floor when this is done on the 3D corkscrew.

    I don't see this documented elsewhere, but it's a pretty funny trick to do in some stages because some stage hazards freak out over Sonic technically still peeling on them when he shouldn't.
     
  7. nineko

    nineko

    I am the Holy Cat Tech Member
    6,143
    384
    63
    italy
    Is that the trick used in the TAS to get inside the walls? They use it to skip Amy's cutscene in Collision Chaos 1, amongst other things.
     
    • Informative Informative x 1
    • List
  8. Pobert-Eii

    Pobert-Eii

    Member
    75
    75
    18
    What the... NO WAY, IT HAS A NAME?

    Yeah, that's the trick. I knew it was glitchy but I didn't know it was that busted.
     
  9. nineko

    nineko

    I am the Holy Cat Tech Member
    6,143
    384
    63
    italy
    I wouldn't say that it has an official name, people at TASvideos like to invent names for convenience, I'm sure you know about the Backwards Long Jump (BLJ) in Super Mario 64, for example.
     
  10. saxman

    saxman

    Oldbie Tech Member
    Anyone who uses a button other than C in a Sonic game is doing it wrong.
    :colbert:
     
    • Agree Agree x 4
    • Like Like x 1
    • Useful Useful x 1
    • List
  11. Blue Spikeball

    Blue Spikeball

    Member
    1,581
    528
    93
    Who revs up the spindash with a single face button? :eyebrow:
     
  12. Devon

    Devon

    I am CRUSHING YOUR HEAD!!!! Tech Member
    685
    295
    63
    You do in the original version of Sonic CD where it acts more like the peelout :V
     
  13. Blue Spikeball

    Blue Spikeball

    Member
    1,581
    528
    93
    Fair enough :V
     
  14. Yash

    Yash

    CHOCOLATE! Member
    700
    274
    63
    When playing on actual Genesis hardware, I use the A button exclusively.

    Sorry to be a heathen.
     
  15. Blastfrog

    Blastfrog

    See ya starside. Member
    I've played Sonic on real hardware using an Atari 2600 joystick. That one has a single face button, so that's how it should be done. (kidding, the Atari joystick is a stiff pile of trash)

    Speaking of Sonic CD quirks, I wonder why they aligned his walking animation in such a way that his head doesn't bob? It causes his feet to become misaligned from the ground, not to mention it just looks kinda strange.
     
  16. Devon

    Devon

    I am CRUSHING YOUR HEAD!!!! Tech Member
    685
    295
    63
    The developers just decided to align Sonic's sprite mappings like that. Why they did it is beyond me. Speaking of bad sprite mappings:

    [​IMG]

    The GIF kinda sorta doesn't do it justice because of the lower frame rate, but angled peelout sprites aren't aligned properly, making it shift back and forth like that everyframe.
     
    Last edited: Jul 18, 2022
  17. Nik Pi

    Nik Pi

    Member
    With all this strange things- I have a question:
    WHY IN SOME GAME PLACES SONIC USES A S1 PROTO PALETTE?!?
    And, I hasn't problems if it in all game, but, NO, it uses on time travels, water, and Special Stages! Why? Maybe, it's also has a stranges with code, like in WWZ?
    Possibly, feedback between developers was too bad, if they uses a DIFFERENTcolour palettes... in one stage...
     
  18. Devon

    Devon

    I am CRUSHING YOUR HEAD!!!! Tech Member
    685
    295
    63
    Special stages do not use the prototype Sonic 1 palette. They look closer to Mania Sonic's palette.

    [​IMG]

    [​IMG]

    Unless, you were talking about the special stage RESULTS with the mini Sonic icon, which indeed does use it.

    [​IMG]

    [​IMG]

    By water, if you mean this palette in the 510 prototype:

    [​IMG]

    Then, that's actually just the Sonic 1 title screen palette being used (First few entries in the palette table were brought over, probably out of laziness).

    [​IMG]

    Other than that, I really couldn't tell you why other than maybe the possibility that's the palette they were using when they were drawing the sprites, and just applied it to anywhere that wasn't a stage/didn't have a preexisting Sonic palette. It was also used in the "M.C. Sonic" easter egg.

    [​IMG]

    [​IMG]

    And the Backup RAM management menu

    [​IMG]

    [​IMG]

    And of course, the warp sequence

    [​IMG]

    [​IMG]

    Another weird quirk is that in here, the black got turned into a green.

    The "thank you for your playing" screen does use final Sonic 1 palette (with the darkest red turned into black, though).

    [​IMG]

    [​IMG]
     
    Last edited: Jul 18, 2022
  19. Brainulator

    Brainulator

    Regular garden-variety member Member
    • Informative Informative x 1
    • List
  20. Devon

    Devon

    I am CRUSHING YOUR HEAD!!!! Tech Member
    685
    295
    63
    So, the way that the special stage's countdown timer is sped up when you are in the water is rather odd. Lemme explain.

    Here's the timer update function:
    [​IMG]

    Ignoring time attack mode, every 20 "frames" (the special stages in NTSC run at 20 FPS, so really it's 60 frames, but for simplicity's sake, I will refer to frames in terms of 20 FPS, and not 60), it counts down a second. After that, it checks a separate counter. That counter, if set to a nonzero value, forces the game to count down a second for every frame that the counter is active. Where is this counter set up at? The water splash object, and it's slightly tied to how it animates.

    [​IMG]

    The water splash runs in 2 stages. When you first enter the water, it makes a large splash and that animation lasts 14 frames. The object's timer is set accordingly so that it continues on after the animation is over, but you might also notice that "timerSpeedUp" is set to... 10 frames. This means that there's a small time frame where it's not speeding up the countdown. Pay attention to this clip:

    [​IMG]

    As you can see, it does exactly that. So, that's the first stage of the water splash animation. After that one it goes into a loop of small splashes.

    [​IMG]

    Every time the animation loops, "timerSpeedUp" gets set to 2 frames, so that's how it's slightly tied to the water splash animation. What's kinda interesting, though is that the small water splash animation lasts 3 frames, and yet the speed up counter is being set to 2 frames. It effectively countdowns 2 seconds every 3 frames.

    Back to the timer update function, I should also mention that the regular stage countdown still runs alongside the speed up counter, so in some instances, it could countdown 3 seconds in a 3 frame span.

    I also took a look at what the 2011 remake did, and it does actually attempt to recreate that weird jolt in the countdown speedup, as shown in the GIF above. What it does in that, though, is that it sets a timer for 40 frames (this time in terms of 60 FPS), and it forces a second to be counted down every other frame as long as that timer's value is greater than 20, or has been counted down to 0.

    [​IMG]
     
    Last edited: Aug 14, 2022 at 5:25 AM
    • Informative Informative x 6
    • List