Insta - Shield in Sonic 1 ?

Discussion in 'Discussion and Q&A Archive' started by VegaLTE, Feb 11, 2013.

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

    VegaLTE Newcomer Trialist

    Joined:
    Feb 11, 2013
    Messages:
    9
    Hello.^o^ I just want to enjoy "Sonic Hacking" and joined this site :D But there is problem.

    Like add spin dash course, I've also to set like this.

    Obj01_MdNormal:
            bsr.w    Sonic_InstaShield    < -- (I added)
            bsr.w    Sonic_Jump
            bsr.w    Sonic_SlopeResist
            bsr.w    Sonic_Move
            bsr.w    Sonic_Roll
            bsr.w    Sonic_LevelBound
            jsr    SpeedToPos
            bsr.w    Sonic_AnglePos
            bsr.w    Sonic_SlopeRepel
            rts    
    ; ===========================================================================

    And.. What next ? I don't have any code.o_0 I've looked SSRG or Soinc Retro, but no exist about add Insta-Shield like Spindash or Jumpdash.
     
  2. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    You could always download an S3K disassembly then take the code from there.
     
  3. Spanner

    Spanner The Tool Member

    Joined:
    Aug 9, 2007
    Messages:
    2,570
    You have added a branch to a piece of code that you don't even have? Are you expecting us to give you everything on a plate?

    As redhotsonic has said, look at the disassembly, try and find the code and alter it to suit Sonic 1.
     
  4. VegaLTE

    VegaLTE Newcomer Trialist

    Joined:
    Feb 11, 2013
    Messages:
    9
    Hmm..okay.. If that's the case, I found "Sonic_InstaAndShieldMoves" code. I changed named to InstaShield and paste it.

    ; End of function Sonic_JumpHeight

     

    Sonic_InstaShield: <---(Changed name, copy from Sonic3k.asm and paste it.)

     

            tst.b    $40(a0)

            beq.s    loc_118EA

            move.w    #-$400,d1

            btst    #6,$2A(a0)

            beq.s    loc_118D2

            move.w    #-$200,d1

     

    loc_118D2:

            cmp.w    $1A(a0),d1

            ble.w    loc_11900

            move.b    ($FFFFF602).w,d0

            andi.b    #$70,d0

            bne.s    locret_118E8

            move.w    d1,$1A(a0)

     

    locret_118E8:

            rts

    ; ---------------------------------------------------------------------------

     

    loc_118EA:

            tst.b    $3D(a0)

            bne.s    locret_118FE

            cmpi.w    #-$FC0,$1A(a0)

            bge.s    locret_118FE

            move.w    #-$FC0,$1A(a0)

     

    locret_118FE:

     

            rts

    ; ---------------------------------------------------------------------------

     

    loc_11900:

            tst.b    $2F(a0)

            bne.w    locret_11A14

            move.b    ($FFFFF603).w,d0

            andi.b    #$70,d0

            beq.w    locret_11A14

            bclr    #4,$2A(a0)

            tst.b    ($FFFFFE19).w

            beq.s    loc_1192C

            bmi.w    loc_11A96

            move.b    #1,$2F(a0)

            rts

    ; ---------------------------------------------------------------------------

     

    loc_1192C:

            btst    #1,$2B(a0)

            bne.w    locret_11A14

            btst    #4,$2B(a0)

            beq.s    loc_1197A

            move.b    #1,($FFFFCD08).w

            move.b    #1,$2F(a0)

            move.w    #$800,d0

            btst    #0,$2A(a0)

            beq.s    loc_11958

            neg.w    d0

     

    loc_11958:

            move.w    d0,$18(a0)

            move.w    d0,$1C(a0)

            move.w    #0,$1A(a0)

            move.w    #$2000,($FFFFEE24).w

            bsr.w    Reset_Player_Position_Array

            move.w    #$43,d0

            jmp    (Play_Sound_2).l

    ; ---------------------------------------------------------------------------

     

    loc_1197A:

            btst    #5,$2B(a0)

            beq.s    loc_119A2

            move.b    #1,($FFFFCD08).w

            move.b    #1,$2F(a0)

            move.w    #-$580,$1A(a0)

            clr.b    $40(a0)

            move.w    #$45,d0

            jmp    (Play_Sound_2).l

    ; ---------------------------------------------------------------------------

     

    loc_119A2:

            btst    #6,$2B(a0)

            beq.s    loc_119D2

            move.b    #1,($FFFFCD08).w

            move.b    #1,$2F(a0)

            move.w    #0,$18(a0)

            move.w    #0,$1C(a0)

            move.w    #$800,$1A(a0)

            move.w    #$44,d0

            jmp    (Play_Sound_2).l

    ; ---------------------------------------------------------------------------

     

    loc_119D2:

            cmpi.b    #7,($FFFFFFB1).w

            bcc.s    loc_119E8

            cmpi.b    #7,($FFFFFFB0).w

            bcs.s    loc_119F6

            tst.b    ($FFFFFFBA).w

            bne.s    loc_119F6

     

    loc_119E8:

            cmpi.w    #$32,($FFFFFE20).w

            bcs.s    loc_119F6

            tst.b    ($FFFFFE1E).w

            bne.s    loc_11A16

     

    loc_119F6:

     

            btst    #0,$2B(a0)

            bne.s    locret_11A14

            move.b    #1,($FFFFCD08).w

            move.b    #1,$2F(a0)

            move.w    #$42,d0

            jmp    (Play_Sound_2).l

    ; ---------------------------------------------------------------------------

     

    locret_11A14:

     

            rts

    ; ---------------------------------------------------------------------------

     

    loc_11A16:

            move.b    #1,($FFFFF65F).w

            move.b    #$F,($FFFFF65E).w

            move.w    #$3C,($FFFFF670).w

            move.l    #Map_SuperSonic,$C(a0)

            move.b    #$81,$2E(a0)

            move.b    #$1F,$20(a0)

            cmpi.b    #7,($FFFFFFB1).w

            bcs.s    loc_11A5C

            move.b    #-1,($FFFFFE19).w

            move.l    #Obj_HyperSonic_19348,($FFFFCD7C).w

            move.l    #Obj_HyperSonicKnux_Trail,($FFFFCBC0).w

            bra.s    loc_11A6A

    ; ---------------------------------------------------------------------------

     

    loc_11A5C:

            move.b    #1,($FFFFFE19).w

            move.l    #Obj_SuperSonicKnux_Stars,($FFFFCBC0).w

     

    loc_11A6A:

            move.w    #$A00,(a4)

            move.w    #$30,2(a4)

            move.w    #$100,4(a4)

            move.b    #0,$35(a0)

            bset    #1,$2B(a0)

            moveq    #-$61,d0

            jsr    (Play_Sound_2).l

            moveq    #$2C,d0

            jmp    (Play_Sound).l

    ; ---------------------------------------------------------------------------

     

    loc_11A96:

            bsr.w    sub_104EA

            move.w    #$2000,($FFFFEE24).w

            bsr.w    Reset_Player_Position_Array

            move.b    #1,$2F(a0)

            move.b    #1,($FFFFCD9C).w

            moveq    #-$4A,d0

            jsr    (Play_Sound_2).l

            move.b    ($FFFFF602).w,d0

            andi.w    #$F,d0

            beq.s    loc_11AE0

            cmpi.b    #$B,d0

            bcc.s    loc_11AE0

            lsl.w    #2,d0

            lea    loc_11AF6+4(pc,d0.w),a1

            move.w    (a1)+,d0

            move.w    d0,$18(a0)

            move.w    d0,$1C(a0)

            move.w    (a1)+,d0

            move.w    d0,$1A(a0)

            rts

    ; ---------------------------------------------------------------------------

     

    loc_11AE0:

     

            move.w    #$800,d0

            btst    #0,$2A(a0)

            beq.s    loc_11AEE

            neg.w    d0

     

    loc_11AEE:

            move.w    d0,$18(a0)

            move.w    d0,$1C(a0)

     

    loc_11AF6:

            move.w    #0,$1A(a0)

            rts

    ; End of function Sonic_InstaShield

     

    But It doesn't working. o_o;; (Of course I know S3K format and S1 format are different.)

     

    If insert Spindash code, It works (but not perfect Spindash you know) and make rom, But Instashield can't make rom either.
     
  5. SuperEgg

    SuperEgg I'm a guy that knows that you know that I know Member

    Joined:
    Oct 17, 2009
    Messages:
    Location:
    THE BEST GOD DAMN STATE OF TEXAS
    Because....

    A. Half of those things don't exist in Sonic 1.

    B. Constants are completely different between Sonic 1 to Sonic 3K. Hell, Even between Sonic 2 to S3K.

    C. RAM addresses are no longer the same as well.

    If you thought that simply porting the code over and plugging it straight into Sonic 1 was going to work, sweet god, you're not going to make it past Day 1. Along with back porting the code, you always have to make it usable to the game you are porting it to. That's why straight porting Spin Dash into Sonic 1 from Sonic 2 won't work, unless you are using the old Nemesis disasm, which nobody does, so......
     
  6. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    SuperEgg here is 100% correct. How do I know? Becuase I learned the hard way; it's the same story with porting Knuckles to Sonic 2 from the KiS2 (Knuckles in Sonic 2) disassembly, and even more so if you port the S3K Priority Manager beforehand.
     
  7. VegaLTE

    VegaLTE Newcomer Trialist

    Joined:
    Feb 11, 2013
    Messages:
    9
    So what am I supposed to do?
     
  8. SuperEgg

    SuperEgg I'm a guy that knows that you know that I know Member

    Joined:
    Oct 17, 2009
    Messages:
    Location:
    THE BEST GOD DAMN STATE OF TEXAS
    Well....

    1. understand the code you are working with, that generally helps.

    2. Understand the variables you are working with. As in, you're actually going to have to learn what $26 means.

    3. Know about the RAM addresses. See if there is a Sonic 1 equivalent.

    4. Stop bitching  and whining. I told you exactly what to do before. Hell, the instructions I gave you were self explanatory, assuming you understand the code.(See #1)

    5. ?????

    6. Profit.
     
  9. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Instashield itself is really simple.

    You could for example do it this way: In the jumping routine, if the doublejump flag isn't set, you have to set a counter when a/b/c is pressed, when that counter finishes, set the doublejump flag (to tell the game instashield isn't active anymore), reset both the counter and flag when Sonic touches the ground, a platform, a spring, etc. Then modify the TouchResponse routine so when the counter is above 0, Sonic is not hurt and the enemy/monitor is destroyed from further (modify touch radius).

    There are other ways to do it of course, it's just an example. That's all really easy stuff if you think about it carefully.

    Then, you have to add an object, that object has to copy Sonic's position and display a sprite (the visible instashield) when the counter is running. This might be the tricky part because to have the animated s3 instashield, you'll have to load the art dynamically, most likely where the shield's art is, which means you'll also have to modify the shield to load art dynamically.

    I first tried to copy it from s3 as well, but couldn't understand what some flags were meant to be, so I did my own instead. To be honest, it really isn't too difficult and it's a good way to learn some useful asm stuff.
     
    Last edited by a moderator: Feb 14, 2013
  10. VegaLTE

    VegaLTE Newcomer Trialist

    Joined:
    Feb 11, 2013
    Messages:
    9
    Okay I will try it. Thanks
     
Thread Status:
Not open for further replies.