don't click here

Sonic CD Quirks/Deconstruction

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

  1. Devon

    Devon

    La mer va embrassé moi et délivré moi lakay. Tech Member
    1,425
    1,744
    93
    your mom
    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. T̶h̶i̶s̶ ̶a̶c̶t̶u̶a̶l̶l̶y̶ ̶c̶a̶u̶s̶e̶s̶ ̶a̶ ̶b̶u̶g̶ ̶w̶i̶t̶h̶ ̶t̶r̶a̶c̶k̶ ̶1̶ ̶a̶n̶d̶ ̶8̶,̶ ̶b̶e̶c̶a̶u̶s̶e̶ ̶t̶h̶e̶ ̶r̶h̶y̶t̶h̶m̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶w̶a̶s̶ ̶a̶s̶s̶i̶g̶n̶e̶d̶ ̶t̶o̶ ̶u̶s̶e̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶8̶,̶ ̶w̶i̶t̶h̶ ̶s̶o̶n̶g̶ ̶t̶r̶a̶c̶k̶ ̶7̶ ̶u̶s̶i̶n̶g̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶8̶ ̶(̶I̶'̶l̶l̶ ̶e̶x̶p̶l̶a̶i̶n̶ ̶w̶h̶y̶ ̶i̶n̶ ̶t̶h̶e̶ ̶n̶e̶x̶t̶ ̶p̶o̶i̶n̶t̶)̶ ̶w̶h̶e̶n̶e̶v̶e̶r̶ ̶r̶h̶y̶t̶h̶m̶ ̶w̶a̶s̶ ̶n̶o̶t̶ ̶b̶e̶i̶n̶g̶ ̶u̶s̶e̶d̶.̶ ̶H̶o̶w̶e̶v̶e̶r̶,̶ ̶s̶i̶n̶c̶e̶ ̶t̶h̶e̶y̶ ̶f̶o̶r̶g̶o̶t̶ ̶t̶o̶ ̶t̶o̶t̶a̶l̶l̶y̶ ̶r̶e̶m̶o̶v̶e̶ ̶t̶h̶e̶ ̶r̶h̶y̶t̶h̶m̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶d̶a̶t̶a̶,̶ ̶t̶r̶a̶c̶k̶ ̶1̶ ̶u̶s̶e̶s̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶8̶,̶ ̶w̶h̶i̶l̶e̶ ̶t̶r̶a̶c̶k̶ ̶8̶ ̶a̶l̶s̶o̶ ̶g̶e̶t̶s̶ ̶a̶s̶s̶i̶g̶n̶e̶d̶ ̶t̶h̶a̶t̶ ̶c̶h̶a̶n̶n̶e̶l̶.̶ (EDIT: Disregard, was incorrect)
      • 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. O̶r̶i̶g̶i̶n̶a̶l̶l̶y̶,̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶r̶h̶y̶t̶h̶m̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶i̶n̶t̶a̶c̶t̶,̶ ̶t̶r̶a̶c̶k̶ ̶8̶ ̶w̶a̶s̶ ̶a̶s̶s̶i̶g̶n̶e̶d̶ ̶t̶o̶ ̶u̶s̶e̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶7̶ ̶(̶w̶h̶i̶c̶h̶ ̶i̶s̶ ̶w̶h̶y̶ ̶t̶r̶a̶c̶k̶ ̶7̶ ̶w̶a̶s̶ ̶a̶s̶s̶i̶g̶n̶e̶d̶ ̶t̶o̶ ̶u̶s̶e̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶8̶)̶,̶ ̶s̶o̶ ̶y̶o̶u̶'̶d̶ ̶h̶a̶v̶e̶ ̶t̶o̶ ̶b̶e̶ ̶c̶a̶r̶e̶f̶u̶l̶ ̶t̶o̶ ̶n̶o̶t̶ ̶l̶e̶t̶ ̶S̶F̶X̶ ̶a̶n̶d̶ ̶t̶r̶a̶c̶k̶ ̶8̶ ̶c̶l̶a̶s̶h̶.̶ ̶H̶o̶w̶e̶v̶e̶r̶,̶ ̶h̶e̶r̶e̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶r̶h̶y̶t̶h̶m̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶p̶a̶r̶t̶i̶a̶l̶l̶y̶ ̶r̶e̶m̶o̶v̶e̶d̶,̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶8̶ ̶n̶o̶ ̶l̶o̶n̶g̶e̶r̶ ̶c̶l̶a̶s̶h̶e̶s̶ ̶w̶i̶t̶h̶ ̶S̶F̶X̶,̶ ̶b̶u̶t̶ ̶l̶i̶k̶e̶ ̶I̶ ̶s̶a̶i̶d̶ ̶i̶n̶ ̶t̶h̶e̶ ̶o̶t̶h̶e̶r̶ ̶p̶o̶i̶n̶t̶,̶ ̶i̶t̶ ̶c̶l̶a̶s̶h̶e̶s̶ ̶w̶i̶t̶h̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶1̶,̶ ̶i̶n̶s̶t̶e̶a̶d̶,̶ ̶w̶h̶i̶c̶h̶ ̶i̶s̶ ̶a̶r̶g̶u̶a̶b̶l̶y̶ ̶w̶o̶r̶s̶e̶.̶ ̶I̶n̶ ̶t̶h̶e̶ ̶e̶n̶d̶,̶ ̶n̶o̶ ̶m̶a̶t̶t̶e̶r̶ ̶w̶h̶a̶t̶,̶ ̶t̶r̶a̶c̶k̶ ̶8̶ ̶i̶s̶ ̶j̶u̶s̶t̶ ̶n̶o̶t̶ ̶r̶e̶a̶l̶l̶y̶ ̶s̶a̶f̶e̶ ̶t̶o̶ ̶u̶s̶e̶ ̶i̶n̶ ̶g̶a̶m̶e̶p̶l̶a̶y̶.̶ (EDIT: Disregard, was incorrect)
      • 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: May 29, 2023
    • Informative Informative x 9
    • 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

    La mer va embrassé moi et délivré moi lakay. Tech Member
    1,425
    1,744
    93
    your mom
    No.
     
    • Informative Informative x 2
    • List
  4. Devon

    Devon

    La mer va embrassé moi et délivré moi lakay. Tech Member
    1,425
    1,744
    93
    your mom
    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 6
    • Informative Informative x 5
    • List
  5. Devon

    Devon

    La mer va embrassé moi et délivré moi lakay. Tech Member
    1,425
    1,744
    93
    your mom
    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
    • Informative Informative x 3
    • Like Like x 2
    • List
  6. Chimes

    Chimes

    The One SSG-EG Maniac Member
    935
    644
    93
    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,364
    522
    93
    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. Chimes

    Chimes

    The One SSG-EG Maniac Member
    935
    644
    93
    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,364
    522
    93
    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 8
    • Like Like x 2
    • Useful Useful x 1
    • List
  11. Blue Spikeball

    Blue Spikeball

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

    Devon

    La mer va embrassé moi et délivré moi lakay. Tech Member
    1,425
    1,744
    93
    your mom
    You do in the original version of Sonic CD where it acts more like the peelout :V
     
  13. Blue Spikeball

    Blue Spikeball

    Member
    2,545
    1,078
    93
    Fair enough :V
     
  14. Yash

    Yash

    CHOCOLATE! Member
    777
    357
    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

    La mer va embrassé moi et délivré moi lakay. Tech Member
    1,425
    1,744
    93
    your mom
    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
    504
    368
    63
    Kazakhstan
    Sonic 2: Archives
    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

    La mer va embrassé moi et délivré moi lakay. Tech Member
    1,425
    1,744
    93
    your mom
    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
    • Like Like x 5
    • Informative Informative x 1
    • List
  19. Brainulator

    Brainulator

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

    Devon

    La mer va embrassé moi et délivré moi lakay. Tech Member
    1,425
    1,744
    93
    your mom
    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
    • Informative Informative x 8
    • List