don't click here

Sonic 3 And Knuckles Ghosts Hack Trailer

Discussion in 'Engineering & Reverse Engineering' started by Cokie, Dec 28, 2023.

  1. Cokie

    Cokie

    C. Okie Member
    76
    22
    8
    I'm super excited to share a hack I did to sonic 3 and knuckles that places the SOZ2 ghosts in every level. Here is the trailer video:



    Here is how I did it:

    Get a clean and newest Sonic 3 & Knuckles disassembly from https://github.com/sonicretro/skdisasm

    open sonic3k.asm

    1.) First we want to Always Load The Ghost object regardless of the level
    and act. so in Obj_TitleCardWait2 change:

    Find AnPal_Load.

    Change:


    loc_2D86E:
    tst.b $44(a0)
    bne.s loc_2D8DC
    cmpi.w #$801,(Current_zone_and_act).w
    bne.s loc_2D88A
    jsr (Create_New_Sprite).l
    bne.s loc_2D88A
    move.l #Obj_SOZ_Ghosts,(a1) ; If new level is Sandopolis 2, then load the ghosts

    To


    loc_2D86E:
    tst.b $44(a0)
    bne loc_2D8DC

    ; LOAD GHOST REGARDLESS OF STAGE
    jsr (Create_New_Sprite).l
    bne.s loc_2D88A
    move.l #Obj_SOZ_Ghosts,(a1)

    2.) Second we want to make AnPal_Load always animate the pallete
    as if it is soz2. This is important because soz 2 pallete animation
    routine effects _unkF7C3. Which is CRITIAL FOR THE GHOSTS OBJECT
    CODE TO FUNCTION CORECTLY.

    Change

    AnPal_Load:
    bsr.w SuperHyper_PalCycle
    moveq #0,d2
    moveq #0,d0
    move.w (Current_zone_and_act).w,d0
    ror.b #1,d0
    lsr.w #6,d0
    move.w OffsAnPal(pc,d0.w),d0
    jmp OffsAnPal(pc,d0.w)

    To:

    AnPal_Load:
    bsr.w SuperHyper_PalCycle
    moveq #0,d2
    moveq #0,d0
    move.w (Current_zone_and_act).w,d0

    ;ALWAYS JUST TREAT STAGE AS IF SOZ2 FOR PALLETE ROUTINE
    move.w #$0801,d0

    ror.b #1,d0
    lsr.w #6,d0
    move.w OffsAnPal(pc,d0.w),d0
    jmp OffsAnPal(pc,d0.w)

    3.) Third , we want to change the ghosts object code so that Last_star_post_hit
    is 1, in order so that the ghosts appear immediately. Last_star_post_hit is used
    in ghosts object code to determine for the ghosts to "appear". I will explain this
    more in another article. For now, chage ghosts code so that it begins setting Last_star_post_hit
    to 1

    Obj_SOZ_Ghosts:
    move.b #1,(Last_star_post_hit).w
    move.l #loc_8F0CA,(a0)
    move.w #$120,$10(a0)
    move.w #$A0,$14(a0)

    You are all set now run build ( ie buildS3Complete.bat or which ever )

    Technically the Obj_SOZGhostCapsule object and its art object aren't even needed. In fact, I have tried a build removing them completely, set the correct variables in SOZ2, and the ghosts STILL appear and work.
     
    Last edited by a moderator: Dec 28, 2023