Jump to content

  •  

  • Photo

    Some help with slopes


    • This topic is locked This topic is locked
    14 replies to this topic

    #1 Zana

    Zana

      Grumpy Bunneh

    • Member
    • 77 posts
    • Gender:Female
    • Location:Madrid
    • Interests:General Retro Computing, Pixel Art, Chip Music, YTPMVing.

    Posted 05 January 2011 - 01:56 AM

    First, sorryfor this really, really dumb doubt i have

    Second... i have been working a few days on a Canabalt "port" for the Genesis using the S1 engine (it has all the elements for the basic gameplay), and i finally got the running animation working using the tutorial here...

    the problem is that yes, it works and all, but when i get into a slope, the game crashes with an ilegal instruction error of some sorts

    here's the build i made for testing: http://www.mediafire...vqgw43duo9bup9n

    and yes, while the original game has no slopes, i want to know what's wrong with the code, so help would be really appreciated

    oh, and here's the animation script in case i screwed something up



    SonAni_Walk: dc.b $FF, $58, $59, $5A, $5B, $5C, $5D, $5E, $5F, $60, $61, $62, $63, $64, $65, $66, $FF
    SonAni_Run: dc.b $FF, $58, $59, $5A, $5B, $5C, $5D, $5E, $5F, $60, $61, $62, $63, $64, $65, $66, $FF
    SonAni_Roll: dc.b $FE, $2E, $2F, $30, $31, $32, $FF, $FF
    SonAni_Roll2: dc.b $FE, $2E, $2F, $32, $30, $31, $32, $FF
    SonAni_Push: dc.b $FD, $45, $46, $47, $48, $FF, $FF, $FF
    SonAni_Wait: dc.b $17, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2, 2, 3, 4, $FE, 2, 0
    SonAni_Balance: dc.b $1F, $3A, $3B, $FF
    SonAni_LookUp: dc.b $3F, 5, $FF, 0
    SonAni_Duck: dc.b $3F, $39, $FF, 0
    SonAni_Warp1: dc.b $3F, $33, $FF, 0
    SonAni_Warp2: dc.b $3F, $34, $FF, 0
    SonAni_Warp3: dc.b $3F, $35, $FF, 0
    SonAni_Warp4: dc.b $3F, $36, $FF, 0
    SonAni_Stop: dc.b 7, $37, $38, $FF
    SonAni_Float1: dc.b 7, $3C, $3F, $FF
    SonAni_Float2: dc.b 7, $3C, $3D, $53, $3E, $54, $FF, 0
    SonAni_Spring: dc.b $2F, $40, $FD, 0
    SonAni_LZHang: dc.b 4, $41, $42, $FF
    SonAni_Leap1: dc.b $F, $43, $43, $43, $FE, 1
    SonAni_Leap2: dc.b $F, $43, $44, $FE, 1, 0
    SonAni_Surf: dc.b $3F, $49, $FF, 0
    SonAni_Bubble: dc.b $B, $56, $56, $A, $B, $FD, 0, 0
    SonAni_Death1: dc.b $20, $4B, $FF, 0
    SonAni_Drown: dc.b $2F, $4C, $FF, 0
    SonAni_Death2: dc.b 3, $4D, $FF, 0
    SonAni_Shrink: dc.b 3, $4E, $4F, $50, $51, $52, 0, $FE, 1, 0
    SonAni_Hurt: dc.b 3, $55, $FF, 0
    SonAni_LZSlide: dc.b 7, $55, $57, $FF
    SonAni_Blank: dc.b $77, 0, $FD, 0
    SonAni_Float3: dc.b 3, $3C, $3D, $53, $3E, $54, $FF, 0
    SonAni_Float4: dc.b 3, $3C, $FD, 0


    running and walking are the same, but i do not need different animations for it... so, did i messed something up with that file? is it due the animation, or other unknown reason
    • 0

    #2 SpirituInsanum

    SpirituInsanum

      6 Chaos Emeralds

    • Pro User
    • 642 posts
    • Gender:Male

    Posted 05 January 2011 - 02:11 AM

    Hard to tell without knowing what's in the art/maps/dplc, but from what I see here, you have 15 frames in your walking animation.

    So in order to know, the question is: do you also have 15 frames for 45°, 15 frames for 90° and 15 frames for 135° as well?

    If so, are they placed right after the walking animation?

    And otherwise do you want/need to have different frames for slopes?

    Edited by SpirituInsanum, 05 January 2011 - 02:22 AM.

    • 0

    #3 Zana

    Zana

      Grumpy Bunneh

    • Member
    • 77 posts
    • Gender:Female
    • Location:Madrid
    • Interests:General Retro Computing, Pixel Art, Chip Music, YTPMVing.

    Posted 05 January 2011 - 09:27 AM

    Hard to tell without knowing what's in the art/maps/dplc, but from what I see here, you have 15 frames in your walking animation.

    So in order to know, the question is: do you also have 15 frames for 45°, 15 frames for 90° and 15 frames for 135° as well?

    If so, are they placed right after the walking animation?

    And otherwise do you want/need to have different frames for slopes?


    No, i did not on that build, i already have them, but when i bulit it before and tried it out, it did not, so, the problem is because it tries to find missing diagonal frames then?

    OK then, thanks a lot, i will hopefully have all the sprite art working tomorrow
    • 0

    #4 TheEchidna

    TheEchidna

      6 Chaos Emeralds

    • Exile
    • 536 posts
    • Gender:Not Telling

    Posted 05 January 2011 - 10:14 AM

    Well, the error is in the index of the ROM. So it could have no relationship with the animation stuff, this can have something to do with the object's positioning. Or some of your data is overwriting the object positioning stuff due to some bad sprite code, I think. Did you tried to restore the Sonic object's routine to his defaults?
    • 0

    #5 Zana

    Zana

      Grumpy Bunneh

    • Member
    • 77 posts
    • Gender:Female
    • Location:Madrid
    • Interests:General Retro Computing, Pixel Art, Chip Music, YTPMVing.

    Posted 05 January 2011 - 10:34 AM

    Well, the error is in the index of the ROM. So it could have no relationship with the animation stuff, this can have something to do with the object's positioning. Or some of your data is overwriting the object positioning stuff due to some bad sprite code, I think. Did you tried to restore the Sonic object's routine to his defaults?



    You mean restoring the default animation script in case it crashes anyway when on a slope?

    I might try, yes, i could have replaced Sonic's sprites instead of creating new ones if i could move the sprite's order, but it looks like SonMapEd hates my keyboard, so yeah, i might have overwritten something while adding the 15 frames ... tho even with this, this is even better than what i thought i would get anyway

    EDIT: Replaced Sonic.ASM with the original of the disassembly and it works, slopes, loops, everything... so i might finally add the angle mappings?

    Edited by CaptainZana, 05 January 2011 - 10:39 AM.

    • 0

    #6 TheEchidna

    TheEchidna

      6 Chaos Emeralds

    • Exile
    • 536 posts
    • Gender:Not Telling

    Posted 05 January 2011 - 10:37 AM

    Well, the error is in the index of the ROM. So it could have no relationship with the animation stuff, this can have something to do with the object's positioning. Or some of your data is overwriting the object positioning stuff due to some bad sprite code, I think. Did you tried to restore the Sonic object's routine to his defaults?



    You mean restoring the default animation script in case it crashes anyway when on a slope?

    I might try, yes, i could have replaced Sonic's sprites instead of creating new ones if i could move the sprite's order, but it looks like SonMapEd hates my keyboard, so yeah, i might have overwritten something while adding the 15 frames ... tho even with this, this is even better than what i thought i would get anyway

    I'll build something when i have some spare time and i'll see

    No, I mean if you tried to restore the object 01's routine to his defaults for check if this Illegal Instruction isn't happening because of some edits you could have made there.
    • 0

    #7 Zana

    Zana

      Grumpy Bunneh

    • Member
    • 77 posts
    • Gender:Female
    • Location:Madrid
    • Interests:General Retro Computing, Pixel Art, Chip Music, YTPMVing.

    Posted 05 January 2011 - 10:41 AM

    No, I mean if you tried to restore the object 01's routine to his defaults for check if this Illegal Instruction isn't happening because of some edits you could have made there.


    I never touched nothing about "object o1" i just edited the mappings, plcs and Sonic.ASM on anim, restoring sonic.asm to its defaults makes the game work perfectly, tho the sega sound is scrambled at the end
    • 0

    #8 Zana

    Zana

      Grumpy Bunneh

    • Member
    • 77 posts
    • Gender:Female
    • Location:Madrid
    • Interests:General Retro Computing, Pixel Art, Chip Music, YTPMVing.

    Posted 05 January 2011 - 02:04 PM

    Sorry, Double Post

    I got the animations fixed, and all the sprites are now included, but for some reason, they do not display propely, the 45 degree sprite is displayed as a 135 and vice versa, and i have not figured where the standing reference is so i can change it to $58, which is its new location until i delete all of sonic's original artwork

    any clues with that?

    EDIT: Here's the rom and the sonic animation script

    http://www.mediafire...rr888cmlbqq12ob

    SonAni_Walk:	dc.b $FF, $59, $5A, $5B, $5C, $5D, $5E, $5F, $60, $61, $62, $63, $64, $65, $66, $67, $68 $FF
    SonAni_Run: dc.b $FF, $59, $5A, $5B, $5C, $5D, $5E, $5F, $60, $61, $62, $63, $64, $65, $66, $67, $68 $FF
    SonAni_Roll: dc.b $FE, $2E, $2F, $30, $31, $32, $FF, $FF
    SonAni_Roll2: dc.b $FE, $2E, $2F, $32, $30, $31, $32, $FF
    SonAni_Push: dc.b $FD, $45, $46, $47, $48, $FF, $FF, $FF
    SonAni_Wait: dc.b $17, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2, 2, 3, 4, $FE, 2, 0
    SonAni_Balance: dc.b $1F, $3A, $3B, $FF
    SonAni_LookUp: dc.b $3F, 5, $FF, 0
    SonAni_Duck: dc.b $3F, $39, $FF, 0
    SonAni_Warp1: dc.b $3F, $33, $FF, 0
    SonAni_Warp2: dc.b $3F, $34, $FF, 0
    SonAni_Warp3: dc.b $3F, $35, $FF, 0
    SonAni_Warp4: dc.b $3F, $36, $FF, 0
    SonAni_Stop: dc.b 7, $37, $38, $FF
    SonAni_Float1: dc.b 7, $3C, $3F, $FF
    SonAni_Float2: dc.b 7, $3C, $3D, $53, $3E, $54, $FF, 0
    SonAni_Spring: dc.b $2F, $40, $FD, 0
    SonAni_LZHang: dc.b 4, $41, $42, $FF
    SonAni_Leap1: dc.b $F, $43, $43, $43, $FE, 1
    SonAni_Leap2: dc.b $F, $43, $44, $FE, 1, 0
    SonAni_Surf: dc.b $3F, $49, $FF, 0
    SonAni_Bubble: dc.b $B, $56, $56, $A, $B, $FD, 0, 0
    SonAni_Death1: dc.b $20, $4B, $FF, 0
    SonAni_Drown: dc.b $2F, $4C, $FF, 0
    SonAni_Death2: dc.b 3, $4D, $FF, 0
    SonAni_Shrink: dc.b 3, $4E, $4F, $50, $51, $52, 0, $FE, 1, 0
    SonAni_Hurt: dc.b 3, $55, $FF, 0
    SonAni_LZSlide: dc.b 7, $55, $57, $FF
    SonAni_Blank: dc.b $77, 0, $FD, 0
    SonAni_Float3: dc.b 3, $3C, $3D, $53, $3E, $54, $FF, 0
    SonAni_Float4: dc.b 3, $3C, $FD, 0
    even


    I'm starting to think that something's wrong here...

    Edited by CaptainZana, 05 January 2011 - 02:52 PM.

    • 0

    #9 SpirituInsanum

    SpirituInsanum

      6 Chaos Emeralds

    • Pro User
    • 642 posts
    • Gender:Male

    Posted 05 January 2011 - 05:10 PM

    Logically, what should be happening now is that your animation should look fine on flat ground and broken on angles, which has to be fixed in the game's program.

    Now, you have to modify the routine that chooses the frame to display depending on angles. In Hivebrain's disassembly, it's in SAnim_WalkRun, and in the SVN disassembly, it's in "sonic animate.asm" under "@walkrunroll".

    At one point, you can read this:
                    lsr.b   #4,d0           ; divide angle by $10
    andi.b #6,d0 ; angle must be 0, 2, 4 or 6

    This is the part of the code telling there are 4 possible angles, your 4 sets of 15 frames (of course modifying this part you could have more or less angles, but it isn't the point). But the right frame is selected a little later: under "lea (SonAni_Walk).l,a1 ; use walking animation", you can read what's selecting the frame depending on the angle:
                    move.b  d0,d1 ; > this copies d0 to d1 ; here d0=0, 2, 4 or 6 (it's the angle as shown before)
    lsr.b #1,d1 ; > this divides d1 by 2
    add.b d1,d0 ; > this adds d1 to d0, so at this point d0 equals 3/2 of its original value, ie 0, 3, 6 or 9

    @running: ; > if you're running, the previous part is skipped, so if running, d0 still equals 0, 2, 4 or 6
    add.b d0,d0 ; > finally here, d0 is multiplied by 2, so it will be equal to 0, 6, 12 or 18 if you're walking, and 0, 4, 8 or 12 if you're running
    move.b d0,d3 ; > this saves d0 to d3 because d0 will be used in the meantime
    ; (....) a few lines unrelated, then:
    add.b d3,obFrame(a0) ; note: obFrame(a0) is $1A(a0) ; modify frame number > Finally, this is the part that adds the value calculated above to the frame number on flat ground.

    These are the lines you'll have to modify. The point here is to make it so d3 equals 0, 15, 30 or 45 so the game loads the right frame depending on the angle. So you only have to modify the code accordingly.

    One easy way to do this is to divide the original d0 by 2, and multiply it by 15.
    • 0

    #10 MarkeyJester

    MarkeyJester

      Driving The Last Spike

    • Pro User
    • 1846 posts
    • Gender:Male

    Posted 05 January 2011 - 06:33 PM

    It's basically what "SpirituInsanum" said really, a common case of mathematical mnemonics used to alter code and align it correctly in a way that it works for any ID at any time. God I love seeing cleverly thought out code, I really do!

    Also, 10 frames for walking? Wow, I can see someone's getting some smoothly flowing animation in their game, can't wait to see it =P
    • 0

    #11 Zana

    Zana

      Grumpy Bunneh

    • Member
    • 77 posts
    • Gender:Female
    • Location:Madrid
    • Interests:General Retro Computing, Pixel Art, Chip Music, YTPMVing.

    Posted 05 January 2011 - 07:13 PM

    Logically, what should be happening now is that your animation should look fine on flat ground and broken on angles, which has to be fixed in the game's program.

    Now, you have to modify the routine that chooses the frame to display depending on angles. In Hivebrain's disassembly, it's in SAnim_WalkRun, and in the SVN disassembly, it's in "sonic animate.asm" under "@walkrunroll".

    At one point, you can read this:

                    lsr.b   #4,d0           ; divide angle by $10
    andi.b #6,d0 ; angle must be 0, 2, 4 or 6

    This is the part of the code telling there are 4 possible angles, your 4 sets of 15 frames (of course modifying this part you could have more or less angles, but it isn't the point). But the right frame is selected a little later: under "lea (SonAni_Walk).l,a1 ; use walking animation", you can read what's selecting the frame depending on the angle:
                    move.b  d0,d1 ; > this copies d0 to d1 ; here d0=0, 2, 4 or 6 (it's the angle as shown before)
    lsr.b #1,d1 ; > this divides d1 by 2
    add.b d1,d0 ; > this adds d1 to d0, so at this point d0 equals 3/2 of its original value, ie 0, 3, 6 or 9

    @running: ; > if you're running, the previous part is skipped, so if running, d0 still equals 0, 2, 4 or 6
    add.b d0,d0 ; > finally here, d0 is multiplied by 2, so it will be equal to 0, 6, 12 or 18 if you're walking, and 0, 4, 8 or 12 if you're running
    move.b d0,d3 ; > this saves d0 to d3 because d0 will be used in the meantime
    ; (....) a few lines unrelated, then:
    add.b d3,obFrame(a0) ; note: obFrame(a0) is $1A(a0) ; modify frame number > Finally, this is the part that adds the value calculated above to the frame number on flat ground.

    These are the lines you'll have to modify. The point here is to make it so d3 equals 0, 15, 30 or 45 so the game loads the right frame depending on the angle. So you only have to modify the code accordingly.

    One easy way to do this is to divide the original d0 by 2, and multiply it by 15.


    There's no "SAnim_WalkRun" so i suppose it is on one of the asm files, but on what one?


    It's basically what "SpirituInsanum" said really, a common case of mathematical mnemonics used to alter code and align it correctly in a way that it works for any ID at any time. God I love seeing cleverly thought out code, I really do!

    Also, 10 frames for walking? Wow, I can see someone's getting some smoothly flowing animation in their game, can't wait to see it =P


    Well, i can pm you when i make major progress on this hack (ie, builds that i make while not posting example builds for this kind of threads)

    And about you love that well tought code, i would love too if i understand a third part of what you know of ASM, i guess i'll love it when i spend more time looking at the files and all of that, anyway, enjoy that build

    Edited by CaptainZana, 05 January 2011 - 07:22 PM.

    • 0

    #12 SpirituInsanum

    SpirituInsanum

      6 Chaos Emeralds

    • Pro User
    • 642 posts
    • Gender:Male

    Posted 05 January 2011 - 07:25 PM

    >> ...and "in the SVN disassembly, it's in "sonic animate.asm" under "@walkrunroll".

    Should be there.
    • 0

    #13 Zana

    Zana

      Grumpy Bunneh

    • Member
    • 77 posts
    • Gender:Female
    • Location:Madrid
    • Interests:General Retro Computing, Pixel Art, Chip Music, YTPMVing.

    Posted 05 January 2011 - 07:28 PM

    >> ...and "in the SVN disassembly, it's in "sonic animate.asm" under "@walkrunroll".

    Should be there.



    I use the 2005 Dissasmbly, that's why i do not find it
    • 0

    #14 SpirituInsanum

    SpirituInsanum

      6 Chaos Emeralds

    • Pro User
    • 642 posts
    • Gender:Male

    Posted 05 January 2011 - 08:31 PM

    Then there's a "SAnim_WalkRun" routine, this is a copy-paste of the routine in the 2005 disassembly:


    SAnim_WalkRun: ; XREF: SAnim_Do
    subq.b #1,$1E(a0) ; subtract 1 from frame duration
    bpl.s SAnim_Delay ; if time remains, branch
    addq.b #1,d0 ; is animation walking/running?
    bne.w SAnim_RollJump ; if not, branch
    moveq #0,d1
    move.b $26(a0),d0 ; get Sonic's angle
    move.b $22(a0),d2
    andi.b #1,d2 ; is Sonic mirrored horizontally?
    bne.s loc_13A70 ; if yes, branch
    not.b d0 ; reverse angle

    loc_13A70:
    addi.b #$10,d0 ; add $10 to angle
    bpl.s loc_13A78 ; if angle is $0-$7F, branch
    moveq #3,d1

    loc_13A78:
    andi.b #$FC,1(a0)
    eor.b d1,d2
    or.b d2,1(a0)
    btst #5,$22(a0)
    bne.w SAnim_Push
    lsr.b #4,d0 ; divide angle by $10
    andi.b #6,d0 ; angle must be 0, 2, 4 or 6
    move.w $14(a0),d2 ; get Sonic's speed
    bpl.s loc_13A9C
    neg.w d2

    loc_13A9C:
    lea (SonAni_Run).l,a1 ; use running animation
    cmpi.w #$600,d2 ; is Sonic at running speed?
    bcc.s loc_13AB4 ; if yes, branch
    lea (SonAni_Walk).l,a1 ; use walking animation
    move.b d0,d1
    lsr.b #1,d1
    add.b d1,d0

    loc_13AB4:
    add.b d0,d0
    move.b d0,d3
    neg.w d2
    addi.w #$800,d2
    bpl.s loc_13AC2
    moveq #0,d2

    loc_13AC2:
    lsr.w #8,d2
    move.b d2,$1E(a0) ; modify frame duration
    bsr.w SAnim_Do2
    add.b d3,$1A(a0) ; modify frame number
    rts
    ; ===========================================================================


    Anyway, if you can't find it, search "SonAni_Run", it's only twice in the whole disassembly, one of them being the animation pointer, and the other one this routine.
    • 0

    #15 Zana

    Zana

      Grumpy Bunneh

    • Member
    • 77 posts
    • Gender:Female
    • Location:Madrid
    • Interests:General Retro Computing, Pixel Art, Chip Music, YTPMVing.

    Posted 05 January 2011 - 08:54 PM

    Then there's a "SAnim_WalkRun" routine, this is a copy-paste of the routine in the 2005 disassembly:



    SAnim_WalkRun: ; XREF: SAnim_Do
    subq.b #1,$1E(a0) ; subtract 1 from frame duration
    bpl.s SAnim_Delay ; if time remains, branch
    addq.b #1,d0 ; is animation walking/running?
    bne.w SAnim_RollJump ; if not, branch
    moveq #0,d1
    move.b $26(a0),d0 ; get Sonic's angle
    move.b $22(a0),d2
    andi.b #1,d2 ; is Sonic mirrored horizontally?
    bne.s loc_13A70 ; if yes, branch
    not.b d0 ; reverse angle

    loc_13A70:
    addi.b #$10,d0 ; add $10 to angle
    bpl.s loc_13A78 ; if angle is $0-$7F, branch
    moveq #3,d1

    loc_13A78:
    andi.b #$FC,1(a0)
    eor.b d1,d2
    or.b d2,1(a0)
    btst #5,$22(a0)
    bne.w SAnim_Push
    lsr.b #4,d0 ; divide angle by $10
    andi.b #6,d0 ; angle must be 0, 2, 4 or 6
    move.w $14(a0),d2 ; get Sonic's speed
    bpl.s loc_13A9C
    neg.w d2

    loc_13A9C:
    lea (SonAni_Run).l,a1 ; use running animation
    cmpi.w #$600,d2 ; is Sonic at running speed?
    bcc.s loc_13AB4 ; if yes, branch
    lea (SonAni_Walk).l,a1 ; use walking animation
    move.b d0,d1
    lsr.b #1,d1
    add.b d1,d0

    loc_13AB4:
    add.b d0,d0
    move.b d0,d3
    neg.w d2
    addi.w #$800,d2
    bpl.s loc_13AC2
    moveq #0,d2

    loc_13AC2:
    lsr.w #8,d2
    move.b d2,$1E(a0) ; modify frame duration
    bsr.w SAnim_Do2
    add.b d3,$1A(a0) ; modify frame number
    rts
    ; ===========================================================================


    Anyway, if you can't find it, search "SonAni_Run", it's only twice in the whole disassembly, one of them being the animation pointer, and the other one this routine.


    OOH, it is the Sonic.asm of the root? you could have started there

    BTW: i will try to replace as many tiles as i can in the sonic mapping, the other script shall be modified for those changes?

    Edited by CaptainZana, 05 January 2011 - 08:56 PM.

    • 0




    0 user(s) are reading this topic

    0 members, 0 guests, 0 anonymous users