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:
    34
    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,796
    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:
    34
    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. Ralakimia

    Ralakimia Pour your misery down on me Member

    Joined:
    Aug 26, 2013
    Messages:
    988
    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:
    34
    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 Hey there! Bet you didn't find me around Member

    Joined:
    Aug 7, 2019
    Messages:
    57
    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:
    34
    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
  11. Trickster

    Trickster Previously called Megalomania Member

    Joined:
    Aug 22, 2018
    Messages:
    81
    Location:
    Brazil Bad Future
    [​IMG]
    upload_2019-10-28_21-44-19.png


    Which one is better? This background is supposed to look like a beautiful morning.

    The first one gives a better feeling of a "calm and breezy morning", but I still love how realistically gorgeous the palette looks in the second one.
     

    Attached Files:

    Bluestreak and ProjectFM like this.
  12. Aier

    Aier "Aieru Dotsuto" Member

    Joined:
    Nov 10, 2018
    Messages:
    39
    Location:
    Gensokyo's Boundaries
    Mornings tend to be orange-ish, so I''d say the second one, but you should make it a bit more orange, purple doesn't look very good with it.

    Also Hi, I have appeared again
     
    Trickster likes this.
  13. Ralakimia

    Ralakimia Pour your misery down on me Member

    Joined:
    Aug 26, 2013
    Messages:
    988
    Assuming the foreground is going to be similar to how your previous works have been, while the second one pops out more and looks overall better, I feel the first one fits better as a background, having a lower contrast and all, so it would clash less with the foreground.
     
  14. Trickster

    Trickster Previously called Megalomania Member

    Joined:
    Aug 22, 2018
    Messages:
    81
    Location:
    Brazil Bad Future
    Don't worry about it. Everything is going to have the same lighting of the background.
    So, I love to make my stuff pop out, as well as I loved both of your feedbacks.
    thanks. I choose the second now. ^u^

    upload_2019-10-28_22-23-8.png
     
  15. MarkeyJester

    MarkeyJester ! % # @ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,796
    You should go with the first one. The low contrast gives it depth, in reality, objects further away tend to fade to the colour of the sky due to the gasses in the air.
     
  16. Trickster

    Trickster Previously called Megalomania Member

    Joined:
    Aug 22, 2018
    Messages:
    81
    Location:
    Brazil Bad Future
    Here's what I did.
    I was able to split the color of the foreground grass with the trees of the background!
    Now the background trees are much more blue!
    upload_2019-10-31_17-36-13.png
    (ignore white sky cuz I'm changing it)

    And also, I did this. I kinda "extended" the grass, making the stripes to go over the shadow.
    upload_2019-10-31_17-39-17.png

    So, what do you think about those changes? Did they made the art better, or worse?
     
    ProjectFM likes this.
  17. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    299
    Location:
    Buffalo, NY, USA
    I really like the stripes in the shadows. As for the background, it's hard to evaluate wether it clashes or not with the foreground when not combined, or in motion.

    Edit: Shouldn't these be in the General Project/Screenshot thread?
     
    Clownacy and Trickster like this.
  18. Aier

    Aier "Aieru Dotsuto" Member

    Joined:
    Nov 10, 2018
    Messages:
    39
    Location:
    Gensokyo's Boundaries
    A few weeks back into the scene and I need to ask question, lol.
    This time it's about Background Deformation, I need help to adapt EHZ flowers deformation to my code, thing is, I'm not sure how to do it without messing things up.

    Code:
        move.l    d0,d1
        add.l    d0,d0
        add.l    d1,d0
    
        move.w    #($B4)/12-1,d1 ; $B4 bytes
    -    move.w    d4,(a1)+
        move.w    d3,(a1)+
        move.w    d4,(a1)+
        move.w    d3,(a1)+
        move.w    d4,(a1)+
        move.w    d3,(a1)+
        swap    d3
        add.l    d0,d3
        swap    d3
        dbf    d1,-
    This is the code (I think) that makes the deformation occur in EHZ.
    I need to adapt it to my code since every row I write (except the first one) looks like this:

    Code:
    ; ===============================================================
    Mountains:
            move.l    d0,(a1)+
            dbf    d1,Mountains
            move.w    (Camera_X_pos).w,d0
            neg.w    d0
            asr.w    #$04,d0
            moveq    #$00032-1,d1
    ;================================================================
    From what I know of EHZ code is that this line:
    Code:
       move.w    #($B4)/12-1,d1 ; $B4 bytes
    Sets how many scalines to write, in this case 12 is $C in hex => $B4/$C = $F scalines to write. d3 would be FG related and that's all I know, can someone please help me with this? I have the strange feeling that this isn't all the code of EHZ flowers deformation...

    EDIT:: Issue Solved, I had to use GHZ deformation to make it work, but I still want to know what this does and how it works.
     
    Last edited: Nov 7, 2019
    Trickster likes this.
  19. Ralakimia

    Ralakimia Pour your misery down on me Member

    Joined:
    Aug 26, 2013
    Messages:
    988
    The EHZ deformation code there looks to be how it handles scrolling the field of flowers. It sets the position of 15 sections of 3 scanlines ($B4 is the total number of bytes being written, there are 6 word length writes, so, $C bytes per section), while continually adding a delta value to make it scroll faster as it goes down.
     
    Trickster and Aier like this.
  20. Nat The Porcupine

    Nat The Porcupine Active Member Member

    Joined:
    Jun 23, 2017
    Messages:
    30
    Location:
    Harrisburg, Pennsylvania (USA)
    Well, it's been quite some time since I needed to ask something here, but I have encountered something during some experimentation that has left me truly stumped for about the past month or so & I'm hoping that some people that are way more familiar with the way Sonic 1 works than I am are able to help me figure this out.

    Some of you may recall that one of the very first posts I ever made on here was a CalcAngle optimization & while most of that code ended up being a bust, there was a particular aspect of it that I wanted to give another go: using half-quadrant adjustments to eliminate a pair of branches. I revised the subroutine's code to include this adjustment a few months back & this is what I came up with:
    Code:
    ; ---------------------------------------------------------------------------
    ; Subroutine calculate an angle
    ; Modified by Nat The Porcupine (after multiple failed attempts)
    ; Fixed suboptimal branch sizes & reduced branching overall
    
    ; input:
    ;    d1 = x-axis distance
    ;    d2 = y-axis distance
    
    ; output:
    ;    d0 = angle
    ;    d2 = trashed (safe to do in Sonic 1 by default, but be mindful of it)
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    CalcAngle:
            movem.l    d3-d4,-(sp)
            moveq    #0,d3
            moveq    #0,d4
            move.w    d1,d3
            move.w    d2,d4
            or.w    d3,d4
            beq.s    CalcAngle_Zero                ; special case when both x and y are zero
            move.w    d2,d4
            moveq    #0,d2                        ; d2 will now be used for octant adjustment flags
            
            tst.w    d3
            bpl.s    loc_2CC2
            neg.w    d3                            ; absolute value of d3
            addq.b    #4,d2                        ; sets the 'x-distance is negative' flag
            
    loc_2CC2:
            tst.w    d4
            bpl.s    loc_2CCA
            neg.w    d4                            ; absolute value of d4
            addq.b    #2,d2                        ; sets the 'y-distance is negative' flag
    
    loc_2CCA:
            cmp.w    d3,d4
            bhs.s    loc_2CDC                    ; if |y| >= |x|
            lsl.l    #8,d4
            divu.w    d3,d4
            moveq    #0,d0
            move.b    Angle_Data(pc,d4.w),d0        ; get the angle value
            bra.s    loc_2CE6
    ; ===========================================================================
    
    loc_2CDC:
            addq.b    #1,d2                        ; sets the 'y is greater than x' flag
            lsl.l    #8,d3
            divu.w    d4,d3
            moveq    #$40,d0
            sub.b    Angle_Data(pc,d3.w),d0        ; get the angle value
    
    loc_2CE6:
            move.b    Octant_Adjust(pc,d2.w),d2    ; get the octant adjustment value
            eor.b    d2,d0                        ; place the angle in the appropriate octant
            movem.l    (sp)+,d3-d4
            rts   
    ; ===========================================================================
    
    CalcAngle_Zero:
            moveq    #$40,d0
            movem.l    (sp)+,d3-d4
            rts   
    ; End of function CalcAngle
    
    ; ===========================================================================
    
    ; This table is used to place the angle in the appropriate octant (half-quadrant)
    Octant_Adjust:
            dc.b %00111111        ; x+,y+,|x|>|y|
            dc.b %00000000        ; x+,y+,|x|<|y|
            dc.b %11000000        ; x+,y-,|x|>|y|
            dc.b %11111111        ; x+,y-,|x|<|y|
            dc.b %01000000        ; x-,y+,|x|>|y|
            dc.b %01111111        ; x-,y+,|x|<|y|
            dc.b %10111111        ; x-,y-,|x|>|y|
            dc.b %10000000        ; x-,y-,|x|<|y|
            even
            
    ; ===========================================================================
    
    Angle_Data:    incbin    "misc\angles.bin"
            even
            
    ; ===========================================================================
    Now, in reality, this code change doesn't exactly yield quite the cycle savings I was hoping for originally, but that's beside the point of this post. Unlike my last attempt at this, this code works properly in every spot you'd expect it to except for one: the Labyrinth Zone water tunnels no longer work properly.

    Normally, the water tunnels will guide Sonic through on a path that's far enough away from the walls that he won't run into them on his way through, allowing him to be smoothly transported from one end to the other like so:
    [​IMG]

    However, replacing the default CalcAngle routine with my version appears to completely break this pathing behavior, which leads to this nonsense where you get pressed into the wall & you can only get out of it by pressing down which can lead to some... unfortunate situations:
    [​IMG]

    What's most baffling about this to me personally is that, looking at the code for the tunnels, CalcAngle is referenced nowhere during its execution & seems to be totally unrelated to how it goes about moving Sonic within the tunnel. So my question is this: How & why is the functionality of this set-piece breaking in this manner after making changes to a subroutine that is seemingly unrelated to its programming? I've been investigating this on & off since I first encountered it & I feel as though I am no closer to finding an answer than when I started looking into it, so if anyone has any insight as to what the cause might be or, better yet, has a way to fix it that doesn't just involve outright reverting the routine and forgetting this ever happened, I would really appreciate it.
     
    ProjectFM, Samey and Trickster like this.