Basic Questions and Answers Thread

Discussion in 'Discussion & Q&A' started by Malevolence, Jul 7, 2009.

  1. Samey

    Samey Le Bored Hedgie Member

    Joined:
    May 3, 2017
    Messages:
    32
    Thanks! Now to get rid of the unused broken code

    Also I haven't actually did the speedshoes yet, it kinda slipped my mind. Will work on that now!

    edit:
    Thats all done now, took a little bit to get it sorted together, but it all works now. :)
     
    Last edited: Sep 25, 2019
  2. Renegade

    Renegade What a beautiful Duwang Member

    Joined:
    Nov 20, 2016
    Messages:
    77
    Oh great. I'm asking for help again, what a grand return.
    Anyway, after giving up on all my god-awful Sonic 1 hacks, I'm trying to move to Sonic 2 due to how much more of a pleasant experience it's been when I've tried hacking it.

    You already know what I'm about to ask.

    Here's the errors I got with the flamewing driver:
    > > >s2.sounddriver.asm(4472): error: macro double defined
    > > > startBank
    > > > endm
    > > >s2.sounddriver.asm(4482): error: macro double defined
    > > > finishBank
    > > > endm
    > > >Sound/s2/SFX/Sound26.asm(12) smpsModSet(3): error: range overflow
    > > > dc.b $01+1,$01,$10,$FF+1
    > > >Sound/s2/SFX/Sound3C.asm(21) smpsModSet(3): error: range overflow
    > > > dc.b $01+1,$02,$05,$FF+1
    > > >Sound/s2/SFX/Sound3E.asm(13) smpsModSet(3): error: range overflow
    > > > dc.b $03+1,$01,$09,$FF+1
    > > >Sound/s2/SFX/Sound43.asm(21) smpsModSet(3): error: range overflow
    > > > dc.b $06+1,$01,$03,$FF+1
    > > >Sound/s2/SFX/Sound56.asm(12) smpsModSet(3): error: range overflow
    > > > dc.b $01+1,$01,$1E,$FF+1
    > > >Sound/s2/SFX/Sound5F.asm(19) smpsModSet(3): error: range overflow
    > > > dc.b $01+1,$01,$11,$FF+1
    > > >Sound/s2/SFX/Sound5F.asm(31) smpsModSet(3): error: range overflow
    > > > dc.b $01+1,$02,$05,$FF+1
    > > >Sound/s2/Music/DEZ.asm(114) smpsModSet(3): error: range overflow
    > > > dc.b $10+1,$01,$FF,$FF+1
    > > >Sound/s2/Music/DEZ.asm(116) smpsModSet(3): error: range overflow
    > > > dc.b $00+1,$01,$10,$FF+1
    > > >Sound/s2/Music/DEZ.asm(120) smpsModSet(3): error: range overflow
    > > > dc.b $10+1,$01,$FE,$FF+1
    > > >Sound/s2/Music/DEZ.asm(160) smpsModSet(3): error: range overflow
    > > > dc.b $06+1,$02,$FE,$FF+1
    > > >Sound/s2/Music/DEZ.asm(164) smpsModSet(3): error: range overflow
    > > > dc.b $06+1,$01,$01,$FF+1
    > > >Sound/s2/Music/DEZ.asm(166) smpsModSet(3): error: range overflow
    > > > dc.b $00+1,$01,$FA,$FF+1
    > > >Sound/s2/Music/DEZ.asm(170) smpsModSet(3): error: range overflow
    > > > dc.b $00+1,$01,$01,$FF+1
    > > >Sound/s2/Music/DEZ.asm(175) smpsModSet(3): error: range overflow
    > > > dc.b $00+1,$01,$FD,$FF+1
    > > >Sound/s2/Music/DEZ.asm(179) smpsModSet(3): error: range overflow
    > > > dc.b $00+1,$01,$FC,$FF+1
    > > >Sound/s2/Music/DEZ.asm(184) smpsModSet(3): error: range overflow
    > > > dc.b $00+1,$01,$FD,$FF+1
    > > >Sound/s2/Music/DEZ.asm(188) smpsModSet(3): error: range overflow
    > > > dc.b $06+1,$01,$01,$FF+1

    I have no idea what I'm doing wrong.
    Every time I follow a guide for this, I do it wrong.
    Since I couldn't code if my life depended on it, I'm asking for help here again.
    Any help would be appreciated, I'm about ready to give up permanently.
     
  3. MarkeyJester

    MarkeyJester ! % # @ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,768
    OK, the first two "startBank" and "finishBank" (sidenote; why camel case damn it )=<) these two exist twice. One is inside "s2.sounddriver.asm", but the other one might be somewhere else, perhaps in one of the "macro" source files, have a look and delete one of them.

    The remaining ones are the case of overflowing a byte. You have a "dc.b" which requires that all elements are a byte each, on the very end you have "$FF+1" on a few of them. FF + 1 = 100. $100 will not fit inside a byte. I know what it's meant to do, the byte is meant to be $00, but the assembler doesn't assume that as it has no idea of your intentions. Put brackets around these, and place &$FF on the end of them, for example "$FF+1" becomes "($FF+1)&$FF".
     
    ProjectFM likes this.
  4. Renegade

    Renegade What a beautiful Duwang Member

    Joined:
    Nov 20, 2016
    Messages:
    77
    I followed your advice, and it fixed those errors, but created:
    > > >s2.constants.asm(751): error: You have too many SndPtrs. MusID__End ($34) can't exceed SndID__First ($1).
    > > > fatal "You have too many SndPtrs. MusID__End ($\{MusID__End}) can't exceed SndID__First ($\{SndID__First})."

    Am I meant to comment out these lines?
    if MOMPASS == 2
    if MusID__End > SndID__First
    fatal "You have too many SndPtrs. MusID__End ($\{MusID__End}) can't exceed SndID__First ($\{SndID__First})."
    endif
    endif
    Because if I do it just gives me "symbol undefined" and "addressing mode not allowed" errors for things that seem to be completely unrelated.

    EDIT: The errors it gives me, for anyone curious.
    > > >s2.constants.asm(859): error: symbol undefined
    > > > zCommandIndex
    > > > offset := zCommandIndex
    > > >s2.constants.asm(864): error: symbol undefined
    > > > CmdPtr_StopSFX
    > > > MusID_StopSFX = id(CmdPtr_StopSFX) ; F8
    > > >s2.constants.asm(865): error: symbol undefined
    > > > CmdPtr_FadeOut
    > > > MusID_FadeOut = id(CmdPtr_FadeOut) ; F9
    > > >s2.constants.asm(866): error: symbol undefined
    > > > CmdPtr_SegaSound
    > > > SndID_SegaSound = id(CmdPtr_SegaSound) ; FA
    > > >s2.constants.asm(867): error: symbol undefined
    > > > CmdPtr_SpeedUp
    > > > MusID_SpeedUp = id(CmdPtr_SpeedUp) ; FB
    > > >s2.constants.asm(868): error: symbol undefined
    > > > CmdPtr_SlowDown
    > > > MusID_SlowDown = id(CmdPtr_SlowDown) ; FC
    > > >s2.constants.asm(869): error: symbol undefined
    > > > CmdPtr_Stop
    > > > MusID_Stop = id(CmdPtr_Stop) ; FD
    > > >s2.constants.asm(870): error: symbol undefined
    > > > CmdPtr__End
    > > > CmdID__End = id(CmdPtr__End) ; FE
    > > >s2.asm(1127): error: symbol undefined
    > > > zAbsVar
    > > > lea (Z80_RAM+zAbsVar).l,a1 ; $A01B80
    > > >s2.asm(1127): error: addressing mode not allowed here
    > > > lea (Z80_RAM+zAbsVar).l,a1 ; $A01B80
    > > >s2.asm(1128): error: symbol undefined
    > > > zAbsVar
    > > > cmpi.b #$80,zAbsVar.QueueToPlay-zAbsVar(a1) ; If this (zReadyFlag) isn't $80, the driver is processing a previous sound request.
    > > >s2.asm(1128): error: symbol undefined
    > > > zAbsVar.QueueToPlay
    > > > cmpi.b #$80,zAbsVar.QueueToPlay-zAbsVar(a1) ; If this (zReadyFlag) isn't $80, the driver is processing a previous sound request.
    > > >s2.asm(1128): error: addressing mode not allowed here
    > > > cmpi.b #$80,zAbsVar.QueueToPlay-zAbsVar(a1) ; If this (zReadyFlag) isn't $80, the driver is processing a previous sound request.
    > > >s2.asm(1146): error: symbol undefined
    > > > zAbsVar
    > > > move.b d1,zAbsVar.StopMusic-zAbsVar(a1)
    > > >s2.asm(1146): error: symbol undefined
    > > > zAbsVar.StopMusic
    > > > move.b d1,zAbsVar.StopMusic-zAbsVar(a1)
    > > >s2.asm(1146): error: addressing mode not allowed here
    > > > move.b d1,zAbsVar.StopMusic-zAbsVar(a1)
    > > >s2.asm(1151): error: symbol undefined
    > > > zAbsVar
    > > > move.b d0,zAbsVar.QueueToPlay-zAbsVar(a1)
    > > >s2.asm(1151): error: symbol undefined
    > > > zAbsVar.QueueToPlay
    > > > move.b d0,zAbsVar.QueueToPlay-zAbsVar(a1)
    > > >s2.asm(1151): error: addressing mode not allowed here
    > > > move.b d0,zAbsVar.QueueToPlay-zAbsVar(a1)
    > > >s2.asm(1158): error: symbol undefined
    > > > zAbsVar
    > > > tst.b zAbsVar.SFXToPlay-zAbsVar(a1,d1.w) ; FFE1 (SFX_to_play) goes to 1B89 (zSFXToPlay).
    > > >s2.asm(1158): error: symbol undefined
    > > > zAbsVar.SFXToPlay
    > > > tst.b zAbsVar.SFXToPlay-zAbsVar(a1,d1.w) ; FFE1 (SFX_to_play) goes to 1B89 (zSFXToPlay).
    > > >s2.asm(1158): error: addressing mode not allowed here
    > > > tst.b zAbsVar.SFXToPlay-zAbsVar(a1,d1.w) ; FFE1 (SFX_to_play) goes to 1B89 (zSFXToPlay).
    > > >s2.asm(1161): error: symbol undefined
    > > > zAbsVar
    > > > move.b d0,zAbsVar.SFXToPlay-zAbsVar(a1,d1.w)
    > > >s2.asm(1161): error: symbol undefined
    > > > zAbsVar.SFXToPlay
    > > > move.b d0,zAbsVar.SFXToPlay-zAbsVar(a1,d1.w)
    > > >s2.asm(1161): error: addressing mode not allowed here
    > > > move.b d0,zAbsVar.SFXToPlay-zAbsVar(a1,d1.w)
    > > >s2.asm(13046): error: addressing mode not allowed on 68000
    > > > move.l word_A656(pc,d0.w),d1
    > > >s2.asm(13046): error: addressing mode not allowed here
    > > > move.l word_A656(pc,d0.w),d1
    > > >s2.asm(13098): error: addressing mode not allowed on 68000
    > > > move.l word_A766(pc,d0.w),d1
    > > >s2.asm(13098): error: addressing mode not allowed here
    > > > move.l word_A766(pc,d0.w),d1
    > > >s2.asm(52096): error: addressing mode not allowed on 68000
    > > > lea Obj70_Positions(pc,d1.w),a1
    > > >s2.asm(52096): error: addressing mode not allowed here
    > > > lea Obj70_Positions(pc,d1.w),a1
    > > >s2.asm(88594): error: symbol undefined
    > > > zPalModeByte
    > > > sne (Z80_RAM+zPalModeByte).l ; set if PAL
    > > >s2.asm(88594): error: addressing mode not allowed here
    > > > sne (Z80_RAM+zPalModeByte).l ; set if PAL
     
    Last edited: Sep 28, 2019
  5. Samey

    Samey Le Bored Hedgie Member

    Joined:
    May 3, 2017
    Messages:
    32
    A very quick question, as I cannot find the answer myself.
    Where in Eggman's code does it handle him being hit by Sonic?

    I've searched for a while and haven't found it. I'm specifically looking through the GHZ boss code. .,.
    Edit: Sorry, needed to clarify. Hivebrain disassembly
     
    Last edited: Sep 28, 2019
  6. Novedicus

    Novedicus Pour your misery down on me Member

    Joined:
    Aug 26, 2013
    Messages:
    938
    It all happens in Touch_Enemy. Eggman's collision ID is set so that when Sonic collides with him, he acts like an enemy. What makes the object act like a boss object is when the "collision property" variable is set to be nonzero ( $21(aN) ), which acts as the hit counter.

    I went ahead and documented Touch_Enemy a little more to give you a better understanding of how it behaves:
    Code:
    Touch_Enemy:                ; XREF: Touch_ChkValue
            tst.b    ($FFFFFE2D).w    ; is Sonic invincible?
            bne.s    loc_1AF40    ; if yes, branch
            cmpi.b    #2,$1C(a0)    ; is Sonic rolling?
            bne.w    Touch_ChkHurt    ; if not, branch
    
    loc_1AF40:
            tst.b    $21(a1)        ; Is the hit count zero?
            beq.s    Touch_KillEnemy    ; If so, it's just a regular enemy
            neg.w    $10(a0)        ; Make Sonic bounce away
            neg.w    $12(a0)
            asr    $10(a0)
            asr    $12(a0)
            move.b    #0,$20(a1)    ; Make the boss non-collideable (which triggers the boss to start flashing for a bit
                        ; The flashing code is handled within the boss object code.
                        ; There, it also resets the collision ID so that the boss can be hit again)
            subq.b    #1,$21(a1)    ; Decrement hit count
            bne.s    locret_1AF68    ; If it hasn't gone down to 0, branch
            bset    #7,$22(a1)    ; Mark the boss as "defeated"
    
    locret_1AF68:
            rts    
    The first hit count check pretty much also explains why if a boss object's hit count is 0 and for some reason it's set to be collideable, it'll behave like a badnik when it gets hit again.

    Here's how the GHZ boss handles flashing and such at Obj3D_ShipStart. It's been documented better here as well:
    Code:
            tst.b    $22(a0)            ; Has the boss been defeated?
            bmi.s    loc_1784C        ; If so, start handling the defeat
            tst.b    $20(a0)            ; Was the boss hit?
            bne.s    locret_1784A        ; If not, branch
            tst.b    $3E(a0)            ; Has it already started flashing?
            bne.s    Obj3D_ShipFlash        ; If so, continue to flash
            move.b    #$20,$3E(a0)        ; Set number of times for ship to flash
            move.w    #$AC,d0
            jsr    (PlaySound_Special).l     ; Play boss damage sound
    
    Obj3D_ShipFlash:
            lea    ($FFFFFB22).w,a1    ; Load at 2nd palette line, 2nd entry
            moveq    #0,d0            ; Move 0 (black) to d0
            tst.w    (a1)            ; Is the color already black?
            bne.s    loc_1783C        ; If not, branch
            move.w    #$EEE,d0        ; Move 0EEE (white) to d0
    
    loc_1783C:
            move.w    d0,(a1)            ; Store color
            subq.b    #1,$3E(a0)        ; Decrement flash counter
            bne.s    locret_1784A        ; If it hasn't run out, branch
            move.b    #$F,$20(a0)        ; Reset collision ID
    
    locret_1784A:
            rts  
    ; ===========================================================================
    
    loc_1784C:                    ; XREF: loc_177E6
            moveq    #100,d0            ; Add 100 points
            bsr.w    AddPoints
            move.b    #8,$25(a0)        ; Go to the "defeated" routine next
            move.w    #$B3,$3C(a0)        ; Set number of frames to wait while the boss explodes
            rts    
     
    Last edited: Sep 28, 2019
    Pacca, Samey and MarkeyJester like this.
  7. Samey

    Samey Le Bored Hedgie Member

    Joined:
    May 3, 2017
    Messages:
    32
    Once again, many thanks! :)

    Edit: Ok, so while trying to make Eggman invincible before the wrecking ball appears
    For some reason his face just doesnt want to work.


    edit 2: Dont mind me, I'm figuring it out, slowly.

    Edit3: Got it so his face works fine now.
    The problem is whenever he gets hit, if he's facing left, it'll be delayed until he turns right (????)

    I don't even know where to begin with that.
     
    Last edited: Sep 29, 2019
  8. Cofahi

    Cofahi Newcomer Trialist

    Joined:
    Dec 14, 2018
    Messages:
    8
    I have ported Knuckles to Sonic 1, but it doesn't
    climb the walls properly. What am I doing wrong?
    Code:
    ; =============== S U B    R O U T    I N E =======================================
    
    
    Knuckles_GlideControl:                  ; ...
    
    ; FUNCTION CHUNK AT 00315C40 SIZE 0000003C BYTES
    
            move.b    $29(a0),d0
            beq.s    return_3156B8
            cmp.b    #2,d0
            beq.w    Knuckles_FallingFromGlide
            cmp.b    #3,d0
            beq.w    Knuckles_Sliding
            cmp.b    #4,d0
            beq.w    Knuckles_Climbing_Wall
            cmp.b    #5,d0
            beq.w    Knuckles_Climbing_Up
    
    Knuckles_NormalGlide:
            move.b    #$A,$16(a0)
            move.b    #$A,$17(a0)
            bsr.w    Knuckles_DoLevelCollision2
            btst    #5,($FFFFF7AC).w
            bne.w    Knuckles_BeginClimb
            move.b    #$13,$16(a0)
            move.b    #9,$17(a0)
            btst    #1,($FFFFF7AC).w
            beq.s    Knuckles_BeginSlide
            move.b    ($FFFFF602).w,d0
            and.b    #$70,d0
            bne.s    loc_31574C
            move.b    #2,$29(a0)
            move.b    #$A,$1C(a0)
            bclr    #0,$22(a0)
            tst.w    $10(a0)
            bpl.s    loc_315736
            bset    #0,$22(a0)
    
    loc_315736:                      ; ...
            asr    $10(a0)
            asr    $10(a0)
            move.b    #$13,$16(a0)
            move.b    #9,$17(a0)
            rts
    ; ---------------------------------------------------------------------------
    
    loc_31574C:                      ; ...
            bra.w    sub_315C7C
    ; ---------------------------------------------------------------------------
    
    Knuckles_BeginSlide:                  ; ...
            bclr    #0,$22(a0)
            tst.w    $10(a0)
            bpl.s    loc_315762
            bset    #0,$22(a0)
    
    loc_315762:                      ; ...
            move.b    $26(a0),d0
            add.b    #$20,d0
            and.b    #$C0,d0
            beq.s    loc_315780
            move.w    $14(a0),$10(a0)
            move.w    #0,$12(a0)
            bra.w    Knuckles_ResetOnFloor_Part2
    ; ---------------------------------------------------------------------------
    
    loc_315780:                      ; ...
            move.b    #3,$29(a0)
            move.b    #$61,$1A(a0)
            move.b    #$7F,$1E(a0)
            move.b    #0,$1B(a0)
            cmp.b    #$C,$28(a0)
            bcs.s    return_3157AC
            move.b    #6,($FFFFD124).w
            move.b    #$15,($FFFFD11A).w
    
    return_3157AC:                      ; ...
            rts
    ; ---------------------------------------------------------------------------
    
    Knuckles_BeginClimb:                  ; ...
            tst.b    ($FFFFF7AD).w
            bmi.w    loc_31587A
            move.b    $1F(a0),d0
            add.b    #$40,d0
            bpl.s    loc_3157D8
            bset    #0,$22(a0)
            jsr    loc_14FD6
            or.w    d0,d1
            bne.s    Knuckles_FallFromGlide
            addq.w    #1,8(a0)
            bra.s    loc_3157E8
    ; ---------------------------------------------------------------------------
    
    loc_3157D8:                      ; ...
            bclr    #0,$22(a0)
            jsr    sub_14E50
            or.w    d0,d1
            bne.w    loc_31586A
    
    loc_3157E8:                      ; ...
            move.b    #$13,$16(a0)
            move.b    #9,$17(a0)
            tst.b    ($FFFFFE19).w
            beq.s    loc_315804
            cmp.w    #$480,$14(a0)
            bcs.s    loc_315804
            nop
    
    loc_315804:                      ; ...
            move.w    #0,$14(a0)
            move.w    #0,$10(a0)
            move.w    #0,$12(a0)
            move.b    #4,$29(a0)
            move.b    #$70,$1A(a0)
            move.b    #$7F,$1E(a0)
            move.b    #0,$1B(a0)
            move.b    #3,$1F(a0)
            move.w    8(a0),$A(a0)
            rts
    ; ---------------------------------------------------------------------------
    
    Knuckles_FallFromGlide:                  ; ...
            move.w    8(a0),d3
            move.b    $16(a0),d0
            ext.w    d0
            sub.w    d0,d3
            subq.w    #1,d3
    
    loc_31584A:                      ; ...
            move.w    $C(a0),d2
            sub.w    #$B,d2
            jsr    ObjHitFloor2
            tst.w    d1
            bmi.s    loc_31587A
            cmp.w    #$C,d1
            bcc.s    loc_31587A
            add.w    d1,$C(a0)
            bra.w    loc_3157E8
    ; ---------------------------------------------------------------------------
    
    loc_31586A:                      ; ...
            move.w    8(a0),d3
            move.b    $16(a0),d0
            ext.w    d0
            add.w    d0,d3
            addq.w    #1,d3
            bra.s    loc_31584A
    ; ---------------------------------------------------------------------------
    
    loc_31587A:                      ; ...
            move.b    #2,$29(a0)
            move.b    #$A,$1C(a0)
            move.b    #$13,$16(a0)
            move.b    #9,$17(a0)
            bset    #1,($FFFFF7AC).w
            rts
    ; ---------------------------------------------------------------------------
    
    Knuckles_FallingFromGlide:              ; ...
            bsr.w    Knuckles_ChgJumpDir
            add.w    #$38,$12(a0)
            btst    #6,$22(a0)
            beq.s    loc_3158B2
            sub.w    #$28,$12(a0)
    
    loc_3158B2:                      ; ...
            bsr.w    Knuckles_DoLevelCollision2
            btst    #1,($FFFFF7AC).w
            bne.s    return_315900
            move.w    #0,$14(a0)
            move.w    #0,$10(a0)
            move.w    #0,$12(a0)
            move.b    $16(a0),d0
            sub.b    #$13,d0
            ext.w    d0
            add.w    d0,$C(a0)
            move.b    $26(a0),d0
            add.b    #$20,d0
            and.b    #$C0,d0
            beq.s    loc_3158F0
            bra.w    Knuckles_ResetOnFloor_Part2
    ; ---------------------------------------------------------------------------
    
    loc_3158F0:                      ; ...
            bsr.w    Knuckles_ResetOnFloor_Part2
            move.w    #$F,$2E(a0)
            move.b    #$C,$1C(a0)
    
    return_315900:                      ; ...
            rts
    ; ---------------------------------------------------------------------------
    
    Knuckles_Sliding:                  ; ...
            move.b    ($FFFFF602).w,d0
            and.b    #$70,d0
            beq.s    loc_315926
            tst.w    $10(a0)
            bpl.s    loc_31591E
            add.w    #$20,$10(a0)
            bmi.s    loc_31591C
            bra.s    loc_315926
    ; ---------------------------------------------------------------------------
    
    loc_31591C:                      ; ...
            bra.s    loc_315958
    ; ---------------------------------------------------------------------------
    
    loc_31591E:                      ; ...
            sub.w    #$20,$10(a0)
            bpl.s    loc_315958
    
    loc_315926:                      ; ...
            move.w  #0,$14(a0)
                    move.w  #0,$10(a0)
                    move.w  #0,$12(a0)
    ;               move.b  $16(a0),d0
    ;               sub.b   #$13,d0
    ;               ext.w   d0
    ;               add.w   d0,$C(a0
                    subi.w  #9,$C(a0)                       ; This fixes Knuckles getting stuck in the ground
                    bsr.w   Knuckles_ResetOnFloor_Part2
                    move.w  #$F,$2E(a0)
                    move.b  #$B,$1C(a0)
                    rts
    ; ---------------------------------------------------------------------------
    
    loc_315958:                      ; ...
            move.b    #$A,$16(a0)
            move.b    #$A,$17(a0)
            bsr.w    Knuckles_DoLevelCollision2
            jsr    Sonic_HitFloor
            cmp.w    #$E,d1
            bge.s    loc_315988
            add.w    d1,$C(a0)
            move.b    d3,$26(a0)
            move.b    #$13,$16(a0)
            move.b    #9,$17(a0)
            rts
    ; ---------------------------------------------------------------------------
    
    loc_315988:                      ; ...
            move.b    #2,$29(a0)
            move.b    #$A,$1C(a0)
            move.b    #$13,$16(a0)
            move.b    #9,$17(a0)
            bset    #1,($FFFFF7AC).w
            rts
    ; ---------------------------------------------------------------------------
    
    Knuckles_Climbing_Wall:                  ; ...
            tst.b    ($FFFFF7AD).w
            bmi.w    loc_315BAE
            move.w    8(a0),d0
            cmp.w    $A(a0),d0
            bne.w    loc_315BAE
            btst    #3,$22(a0)
            bne.w    loc_315BAE
            move.w    #0,$14(a0)
            move.w    #0,$10(a0)
            move.w    #0,$12(a0)                  ; ...
            move.b    #$A,$16(a0)
            move.b    #$A,$17(a0)
            moveq    #0,d1
            btst    #0,($FFFFF602).w
            beq.w    loc_315A76
            move.w    $C(a0),d2
            sub.w    #$B,d2
            bsr.w    sub_315C22
            cmp.w    #4,d1
            bge.w    Knuckles_ClimbUp      ; Climb onto the floor above you
            tst.w    d1
            bne.w    loc_315B30
            move.w    $C(a0),d2
            subq.w    #8,d2
            move.w    8(a0),d3
            bsr.w    sub_3192E6          ; Doesn't exist in S2
            tst.w    d1
            bpl.s    loc_315A46
            sub.w    d1,$C(a0)
            moveq    #1,d1
            bra.w    loc_315B04
    ; ---------------------------------------------------------------------------
    
    loc_315A46:                      ; ...
            subq.w    #1,$C(a0)
            tst.b    ($FFFFFE19).w
            beq.s    loc_315A54
            subq.w    #1,$C(a0)
    
    loc_315A54:                      ; ...
            moveq    #1,d1
            move.w    ($FFFFEECC).w,d0
            cmp.w    #-$100,d0
            beq.w    loc_315B04
            add.w    #$10,d0
            cmp.w    $C(a0),d0
            ble.w    loc_315B04
            move.w    d0,$C(a0)
            bra.w    loc_315B04
    ; ---------------------------------------------------------------------------
    
    loc_315A76:                      ; ...
            btst    #1,($FFFFF602).w
            beq.w    loc_315B04
            cmp.b    #$76,$1A(a0)
            bne.s    loc_315AA2
            move.b    #$70,$1A(a0)
            addq.w    #3,$C(a0)
            subq.w    #3,8(a0)
            btst    #0,$22(a0)
            beq.s    loc_315AA2
            addq.w    #6,8(a0)
    
    loc_315AA2:                      ; ...
            move.w    $C(a0),d2
            add.w    #$B,d2
            bsr.w    sub_315C22
            tst.w    d1
            bne.w    loc_315BAE
        
            move.w    $C(a0),d2
            add.w    #9,d2
            move.w    8(a0),d3
            bsr.w    sub_318FF6
            tst.w    d1
            bpl.s    loc_315AF4
            add.w    d1,$C(a0)
            move.b    ($FFFFF768).w,$26(a0)
            move.w    #0,$14(a0)
            move.w    #0,$10(a0)
            move.w    #0,$12(a0)
            bsr.w    Knuckles_ResetOnFloor_Part2
            move.b    #5,$1C(a0)
            rts
    ; ---------------------------------------------------------------------------
    
    loc_315AF4:                      ; ...
            addq.w    #1,$C(a0)
            tst.b    ($FFFFFE19).w
            beq.s    loc_315B02
            addq.w    #1,$C(a0)
    
    loc_315B02:                      ; ...
            moveq    #-1,d1
    
    loc_315B04:                      ; ...
            tst.w    d1
            beq.s    loc_315B30
            subq.b    #1,$1F(a0)
            bpl.s    loc_315B30
            move.b    #3,$1F(a0)
            add.b    $1A(a0),d1
            cmp.b    #$B7,d1
            bcc.s    loc_315B22
            move.b    #$BC,d1
    
    loc_315B22:                      ; ...
            cmp.b    #$BC,d1
            bls.s    loc_315B2C
            move.b    #$B7,d1
    
    loc_315B2C:                      ; ...
            move.b    d1,$1A(a0)
    
    loc_315B30:                      ; ...
            move.b    #$20,$1E(a0)
            move.b    #0,$1B(a0)
            move.b    #$13,$16(a0)
            move.b    #9,$17(a0)
            move.w    ($FFFFF602).w,d0
            and.w    #$70,d0
            beq.s    return_315B94
            move.w    #$FC80,$12(a0)
            move.w    #$400,$10(a0)
            bchg    #0,$22(a0)
            bne.s    loc_315B6A
            neg.w    $10(a0)
    
    loc_315B6A:                      ; ...
            bset    #1,$22(a0)
            move.b    #1,$3C(a0)
            move.b    #$E,$16(a0)
            move.b    #7,$17(a0)
            move.b    #2,$1C(a0)
            bset    #2,$22(a0)
            move.b    #0,$29(a0)
    
    return_315B94:                      ; ...
            rts
    ; ---------------------------------------------------------------------------
    
    Knuckles_ClimbUp:                  ; ...
            move.b    #5,$29(a0)          ; Climb up to    the floor above    you
            cmp.b    #$76,$1A(a0)
            beq.s    return_315BAC
            move.b    #0,$1F(a0)
            bsr.s    sub_315BDA
    
    return_315BAC:                      ; ...
            rts
    ; ---------------------------------------------------------------------------
    
    loc_315BAE:                      ; ...
            move.b    #2,$29(a0)
            move.w    #$0A0A,$1C(a0)
            move.b    #$60,$1A(a0)
            move.b    #7,$1E(a0)
            move.b    #1,$1B(a0)
            move.b    #$13,$16(a0)
            move.b    #9,$17(a0)
            rts
    ; End of function Knuckles_GlideControl
    
    
    ; =============== S U B    R O U T    I N E =======================================
    
    
    sub_315BDA:                      ; ...
            moveq    #0,d0
            move.b    $1F(a0),d0
            lea    word_315C12(pc,d0.w),a1
            move.b    (a1)+,$1A(a0)
            move.b    (a1)+,d0
            ext.w    d0
            btst    #0,$22(a0)
            beq.s    loc_315BF6
            neg.w    d0
    
    loc_315BF6:                      ; ...
            add.w    d0,8(a0)
            move.b    (a1)+,d1
            ext.w    d1
            add.w    d1,$C(a0)
            move.b    (a1)+,$1E(a0)
            addq.b    #4,$1F(a0)
            move.b    #0,$1B(a0)
            rts
    ; End of function sub_315BDA
    
    ; ---------------------------------------------------------------------------
    word_315C12:    dc.w $7603,$FD06,$7708,$F606,$5eF8,$F406,$D208,$FB06; 0    ; ...
    
    ; =============== S U B    R O U T    I N E =======================================
    
    
    sub_315C22:                      ; ...
    
    ; FUNCTION CHUNK AT 00319208 SIZE 00000020 BYTES
    ; FUNCTION CHUNK AT 003193D2 SIZE 00000024 BYTES
    
        
            btst    #0,$22(a0)
            bne.s    loc_315C36
            move.w    8(a0),d3
            bra.w    loc_319208
    ; ---------------------------------------------------------------------------
    
    loc_315C36:                      ; ...
            move.w    8(a0),d3
            subq.w    #1,d3
            bra.w    loc_3193D2
    ; End of function sub_315C22
    
    ; ---------------------------------------------------------------------------
    ; START    OF FUNCTION CHUNK FOR Knuckles_GlideControl
    
    Knuckles_Climbing_Up:                  ; ...
            tst.b    $1E(a0)
            bne.s    return_315C7A
            bsr.w    sub_315BDA
            cmp.b    #$10,$1F(a0)
            bne.s    return_315C7A
            move.w    #0,$14(a0)
            move.w    #0,$10(a0)
            move.w    #0,$12(a0)
            btst    #0,$22(a0)
            beq.s    loc_315C70
            subq.w    #1,8(a0)
    
    loc_315C70:                      ; ...
            bsr.w    Knuckles_ResetOnFloor_Part2
            move.b    #5,$1C(a0)
    
    return_315C7A:                      ; ...
            rts
    ; END OF FUNCTION CHUNK    FOR Knuckles_GlideControl
    
    ; =============== S U B    R O U T    I N E =======================================
    
    
    sub_315C7C:                      ; ...
            move.b    #$20,$1E(a0)
            move.b    #0,$1B(a0)
            move.w    #$0909,$1C(a0)
            bclr    #5,$22(a0)
            bclr    #0,$22(a0)
            moveq    #0,d0
            move.b    $1F(a0),d0
            add.b    #$10,d0
            lsr.w    #5,d0
            move.b    byte_315CC2(pc,d0.w),d1
            move.b    d1,$1A(a0)
            cmp.b    #$C4,d1
            bne.s    return_315CC0
            bset    #0,$22(a0)
            move.b    #$54,$1A(a0)
    
    return_315CC0:                      ; ...
            rts
    ; End of function sub_315C7C
    
    ; ---------------------------------------------------------------------------
    byte_315CC2:    dc.b $54,$55,$56,$57,$58,$57,$56,$55; 0    ; ...
    
    ; =============== S U B    R O U T    I N E =======================================
    
    
    Knuckles_GlideSpeedControl:              ; ...
            cmp.b    #1,$29(a0)
            bne.w    loc_315D88
            move.w    $14(a0),d0
            cmp.w    #$400,d0
            bcc.s    loc_315CE2
            addq.w    #8,d0
            bra.s    loc_315CFC
    ; ---------------------------------------------------------------------------
    
    loc_315CE2:                      ; ...
            cmp.w    #$1800,d0
            bcc.s    loc_315CFC
            move.b    $1F(a0),d1
            and.b    #$7F,d1
            bne.s    loc_315CFC
            addq.w    #4,d0
            tst.b    ($FFFFFE19).w
            beq.s    loc_315CFC
            addq.w    #8,d0
    
    loc_315CFC:                      ; ...
            move.w    d0,$14(a0)
            move.b    $1F(a0),d0
            btst    #2,($FFFFF602).w
            beq.s    loc_315D1C
            cmp.b    #$80,d0
            beq.s    loc_315D1C
            tst.b    d0
            bpl.s    loc_315D18
            neg.b    d0
    
    loc_315D18:                      ; ...
            addq.b    #2,d0
            bra.s    loc_315D3A
    ; ---------------------------------------------------------------------------
    
    loc_315D1C:                      ; ...
            btst    #3,($FFFFF602).w
            beq.s    loc_315D30
            tst.b    d0
            beq.s    loc_315D30
            bmi.s    loc_315D2C
            neg.b    d0
    
    loc_315D2C:                      ; ...
            addq.b    #2,d0
            bra.s    loc_315D3A
    ; ---------------------------------------------------------------------------
    
    loc_315D30:                      ; ...
            move.b    d0,d1
            and.b    #$7F,d1
            beq.s    loc_315D3A
            addq.b    #2,d0
    
    loc_315D3A:                      ; ...
            move.b    d0,$1F(a0)
            move.b    $1F(a0),d0
            jsr    CalcSine
            muls.w    $14(a0),d1
            asr.l    #8,d1
            move.w    d1,$10(a0)
            cmp.w    #$80,$12(a0)
            blt.s    loc_315D62
            sub.w    #$20,$12(a0)
            bra.s    loc_315D68
    ; ---------------------------------------------------------------------------
    
    loc_315D62:                      ; ...
            add.w    #$20,$12(a0)
    
    loc_315D68:                      ; ...
            move.w    ($FFFFEECC).w,d0
            cmp.w    #$FF00,d0
            beq.w    loc_315D88
            add.w    #$10,d0
            cmp.w    $C(a0),d0
            ble.w    loc_315D88
            asr    $10(a0)
            asr    $14(a0)
    
    loc_315D88:                      ; ...
            cmp.w    #$60,($FFFFEED8).w
            beq.s    return_315D9A
            bcc.s    loc_315D96
            addq.w    #4,($FFFFEED8).w
    
    loc_315D96:                      ; ...
            subq.w    #2,($FFFFEED8).w
    
    return_315D9A:                      ; ...
            rts
    ; End of function Knuckles_GlideSpeedControl
    
     
  9. MGHACKS

    MGHACKS November 9th 2019 is something... Member

    Joined:
    Aug 7, 2019
    Messages:
    27
    Another question?
    Screenshot 2019-10-12 at 09.50.06.png
    What's this?

    This mess flickers when I'm running through a lot of obstacles in SBZ Act 2. I feel like this has to do with the 68k processor and the memory. Any fixes, please?

    And I'm using the 2005 disassembly and this happened on Fusion emulator.
     
  10. Samey

    Samey Le Bored Hedgie Member

    Joined:
    May 3, 2017
    Messages:
    32
    If I remember right, thats caused from the moniters in the floor collision.
    They were actually supposed to be the Invisible Solid Eggman objects and I guess it just never really was fixed.

    You just need to go into SonLVL and change the object to the Eggman object one. Don't worry about the subtypes tho, as I remember those are actually correct.



    Theres a whole bunch in SBZ so its best to look around the level map for any odd moniters that are stuck inside walls.
    One helpful hint is that they all have Static as the screen (instead of something like a 1up)
     
    Last edited: Oct 12, 2019 at 10:42 AM