Sonic CD 0.02 Disassembly

Discussion in 'Showroom' started by segaloco, Dec 28, 2019.

  1. segaloco

    segaloco Newcomer Member

    Joined:
    Jul 16, 2008
    Messages:
    6
    Location:
    WA
    Wew I haven't posted in a while. Yo, so I'm working on a disassembly of Sonic CD 0.02. I've got most of the files including R11A done, just a matter of commenting and identifying what's left, comparing against the other level MMDs, and then splitting it all out into files.

    Figured I'd make a thread about it for the time being, also just to have a place to post discoveries. Speaking of which, there is some junk data towards the end of the rom with the previous iteration of the level complete object:

    Code:
    ; obj_LevelEnd - Level end marker (Pre-YouSay)
    ;
    ; Routines
    ;   00 - Init  - Object is initialized and set to monitor state
    ;   01 - Col   - Object position checked relative to Sonic
    ;            If exceeded, execute level end routine
    ;   02 - Exec  - Execute level end routine, count down $2A(a0)
    ;            Sonic can move about the screen for $2A(a0) counts
    ;   03 - Count - Perform the $2A(a0) countdown then lock controls
    ;            and run Sonic off right side of screen
    ;   04 - Ret   - Level end routine return loop. Triggers level end if
    ;            counters are expended.
    ;
    ; Custom Variables
    ;   2A - Count for Sonic to remain movable on screen
    ;   2B - Time for Sonic to run offscreen
    ;
    ; Imports
    ;
    ;   sub_Sonica6 -> Points a6 at the player character ram bank
    ;
    
    obj_LevelEnd:
           moveq   #0,d0
           move.b   obRoutine(a0),d0
           move.w   ind_LevelEnd(pc,d0.w),d0
           jsr   ind_LevelEnd(pc,d0.w)
           rts
    
    
       ind_LevelEnd:
           dc.w LevelEnd_Init-ind_LevelEnd
           dc.w LevelEnd_Col-ind_LevelEnd
           dc.w LevelEnd_Exec-ind_LevelEnd
           dc.w LevelEnd_Count-ind_LevelEnd
           dc.w LevelEnd_Ret-ind_LevelEnd
    
    ; ---------------------------------------------------------------------------
    
    
    LevelEnd_Init:
           addq.b   #2,obRoutine(a0)   ; Trigger collision checking state
           ori.b   #4,obRender(a0)
           move.b   #4,obPriority(a0)
    
    ; ---------------------------------------------------------------------------
    LevelEnd_Col:   jsr   sub_Sonica6       ; a6 -> Player
           move.w   obX(a0),d0       ; Check Sonic's position
           cmp.w   obX(a6),d0       ; Relative to X coordinate
           bcc.s   @return           ; If carry set, Sonic has passed
    
           move.w   (v_limitright2).w,(v_limitleft2).w   ; Prevent moving left
           move.b   #$3C,$2A(a0)       ; Time to wait on screen
           move.b   #$B4,$2B(a0)       ; Time for Sonic to run off-screen
           move.b   #$F0,$2B(a0)
           addq.b   #2,obRoutine(a0)   ; Trigger waiting state
    @return:   rts
    
    
    ; ---------------------------------------------------------------------------
    
    
    LevelEnd_Exec:
           subq.b   #1,$2A(a0)
           bne.s   LevelEnd_Count       ; Let Sonic run around for a bit
           addq.b   #2,obRoutine(a0)   ; Trigger run off state
    
    LevelEnd_Count:   subq.b   #1,$2B(a0)
           bne.s   LevelEnd_Ret
    
           bset   #0,(f_lockctrl).w   ; Lock controls
           move.b   #0,obAnim(a0)
           move.w   #$808,(v_jpadhold2).w   ; Make Sonic run right
           addq.b   #2,obRoutine(a0)   ; Trigger run off wait
    LevelEnd_Ret:   subq.b   #1,$2B(a0)
           bne.s   @return
    
           move.w   #2,(f_restart).l   ; Trigger level cycle
    @return:   rts
    
    Going to hopefully be putting together a release of what I have done so far, I've got all the IDBs and just need to work them down into something a little easier on the eyes.
     
    Mikel, jubbalub, MCTravisYT and 10 others like this.
  2. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    292
    Location:
    Wolverhampton UK
    Hiya I was wondering if there is a release of this?