Sonic 1 disassembly

Discussion in 'Engineering & Reverse Engineering' started by Hivebrain, Jun 8, 2005.

Thread Status:
Not open for further replies.
  1. Hivebrain

    Hivebrain

    Administrator
    2,863
    18
    18
    53.4N, 1.5W
    HiveView
    I've finally released the June 2005 version of my Sonic 1 disassembly.

    New stuff:
    - Most of the subroutines are labelled
    - Many things have been commented
    - This version compiles a lot faster
    - Compressed data is automatically decompressed (recompression is not automatic by default because it's very slow)
    - Some parts of the ASM are separated into _ANIM, _INC and _MAPS folders
    - The compiled ROM is automatically padded to be a "power of 2" in length (I.e. $80000, $100000, $200000)

    IDB, for use with IDA Pro:

    http://sonicology.hacking-cult.org/S1idb_June05.rar

    Split ASM:

    http://sonicology.hacking-cult.org/S1asm_June05.rar
     
  2. Sonic 65

    Sonic 65

    Tech Member
    I love you. This is going to help me out so much it's...funny?
     
  3. Tweaker

    Tweaker

    Misfit
    12,389
    1
    0
    Hivebrain wins.

    I'll be digging through this baby. =P

    Did you find anything interesting, Hivebrain? Any unused stuff, etc.
     
  4. Hivebrain

    Hivebrain

    Administrator
    2,863
    18
    18
    53.4N, 1.5W
    HiveView
    Yes, there are a few unused bits of code:

    MoveDemo_Record - for recording demos.

    Just after locret_132D2 - subroutine that squashes Sonic and stops him moving. This was possibly used when Sonic runs into a wall at speed, although there's no way of knowing for certain.

    FloorLog_Unk - records something to do with collision. I don't know what.

    Just after nullsub_2 - limits Sonic's speed in the special stage.
     
  5. Sonic 65

    Sonic 65

    Tech Member
    Do these pieces of code actually work? By that, I mean can they can be used through a jump with their full intended effect? If so, one could easily make a demo recording system or implement the squashing system.
     
  6. Hivebrain

    Hivebrain

    Administrator
    2,863
    18
    18
    53.4N, 1.5W
    HiveView
    The demo recorder was first enabled by drx, in a hack which wrote the demo to the RAM. I used the recorder in Sonic 1 Plus, writing the demo to the SRAM.

    I tested the squashing system, and I seem to remember it making the game virtually unplayable, although it was a while ago and I can't remember exactly what happened.

    The special stage speed limiter has no discernable effect on gameplay.
     
  7. ICEknight

    ICEknight

    Researcher Researcher
    Have you tried swapping it with the spindash function? Both things might be related, as Sonic is "sunk" a little into the ground when he turns into a ball.


    Perhaps it could be an old incomplete spindash charge?

    EDIT:
    And about this:
    Code (Text):
    1. ;; ---------------------------------------------------------------------------
    2. ; Unused sound/music subroutine
    3. ; ---------------------------------------------------------------------------
    4.  
    5. PlaySound_Unk:
    6.   move.b   d0,($FFFFF00C).w
    7.   rts
    Could this be the routine to play a sound/music and then fade back to the music that was playing previously, like happens with the 1-up sound?
     
  8. Tweaker

    Tweaker

    Misfit
    12,389
    1
    0
    It's possible. Have you tried activating it and seeing what it does?
     
  9. Aurochs

    Aurochs

    Единый, могучий Советский Союз! Tech Member
    2,343
    0
    0
    Whatever catches my fancy
    That can be downloaded here if you're interested.

    Hey, is anybody still working on the S2 disassembly? If so, when can the next release be expected?
     
  10. fuzzbuzz

    fuzzbuzz

    Tech Member
    625
    0
    0
    Here
    Many Many Programming/hacking tools...
    ROM:00001126 PalToCRAM:

    That is actually the Horizonal Interrupt routine. Might want to change that.

    $B10 is the Vertial Interrupt

    I'll update this as I find more.
     
  11. Hivebrain

    Hivebrain

    Administrator
    2,863
    18
    18
    53.4N, 1.5W
    HiveView
    Thanks. The subroutine does transfer pallets from the RAM to CRAM, but I see it does other things as well.

    What exactly are the vertical and horizontal interrupts?
     
  12. fuzzbuzz

    fuzzbuzz

    Tech Member
    625
    0
    0
    Here
    Many Many Programming/hacking tools...
    Those interrupts are called at least once every frame. The H interrupt can be called every x number of lines, as specified by VDP register $0A. That value will be counted down, and every x number of scan lines, the H interrupt will be triggered.

    The point of these interrupts? To have important code be executed whenever they are triggered, which happens to be at least once every frame.

    The updating of the sound is done in the V/H interrupts, it's one of those things that can't wait to be called just once during the game loop.

    ..I hope that made sense.
     
  13. LocalH

    LocalH

    roxoring your soxors Tech Member
    3,284
    4
    18
    wouldn't you like to know
    Super Guitar Hero II
    Vints hit on line $E0, if I'm not mistaken. This explains the small bit of garbage at the very bottom of the screen (outside the normal overscan of a TV set), and it's also where the palette is reset for the next frame (meaning that, if you have water that changes the backdrop, the water color will go away on line $E0).

    If I'm not mistaken, I'm pretty sure that all of the game except for the actual core logic runs on the interrupts, since you can overclock it and the game itself stays stable, even in 2P with the mid-frame VDP hits. Water definitely runs in Hint, since it needs to change the palette mid-frame. The code that handles setting up the VDP for each player in 2P is also Hint code, obviously.

    The Z80 has it's own Vint, I forget what line it triggers on, but since the Z80 traditionally handles the YM only (except for S1, which runs only the DAC off the Z80, IIRC), it doesn't matter what line it hits on.

    Edit: Gah, I'm used to talking about S2, so ignore the shit about 2P. Still, the rest is accurate.
     
Thread Status:
Not open for further replies.