A question about asm and sprite!

Discussion in 'Discussion and Q&A Archive' started by Ashuro, Mar 18, 2015.

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

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Yes, hello again!
    I'm using the Selbi's jumpdash code, and i want to custom it a bite :)
    Like the Sonic 4/Sonic Unleashed series, i want to set an animation when sonic touch the monitor/enemy and he bounce up...
    Okay, let me explain:

    http://image.noelshack.com/fichiers/2015/12/1426666440-sans-titre.png
     

    Edit: i have try to look at the "Obj41" (Spring) bounce animation when touch the spring code (something like this) but i don't know how to put it in the jumpdash code.
     

    Obj41_BounceUp: ; XREF: Obj41_Up

                 addq.b #2,$24(a0)

                 addq.w #8,$C(a1)

                 move.w $30(a0),$12(a1) ; move Sonic upwards

                 bset #1,$22(a1)

                 bclr #3,$22(a1)

                 move.b #$10,$1C(a1) ; use "bouncing" animation

                 move.b #2,$24(a1)

                 bclr #3,$22(a0)

                 clr.b $25(a0)

                 move.w #$CC,d0

                 jsr (PlaySound_Special).l ; play spring sound

     

    Obj41_AniUp: ; XREF: Obj41_Index

                lea (Ani_obj41).l,a1

                bra.w AnimateSprite

     

    but i don't know how to put it in the jumpdash code.

    (thank you Selbi for jumpdash code)

    (sorry bad english)
     
    Last edited by a moderator: Mar 18, 2015
  2. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    In that spring code you see:

    move.b #$10,$1C(a1) ; use "bouncing" animationSo, copy that line into the BounceJD routine (provided you read the whole guide) after the check for the jumpdash flag. Then change the a1 into a0, since that's where Sonic is loaded into in TouchResponse.
    To give some explanation, the $1Cth byte within Sonic's $40-byte set (same for any other object, in fact) is the animation ID. The game has a built-in mechanism to show different sprites in a set order at a set speed. This simplifies a lot and can be very powerful if used appropriately.

    $10 just happens to be the respective animation ID for the Sonic going up. You can find and edit Sonic's animation scripts in _anim/Sonic.asm. The spring animation is here:

    SonAni_Spring: dc.b $2F, $40, $FD, 0The first byte is the time interval to pass before going to the next byte in frames. The second one is the actual sprite ID. Since the spring animation only has one unique sprite, that's all you'll see here. The last two bytes are a little peculiar; $F? flags tell the game to do some specific actions. $FF for example would tell the game simply repeat the animation over and over again. $FD, 0 on the other hand tells the game to jump to another animation ID. 0 Is the first one, so SonAni_Walk.
    Depending on how much you want to make your bounce-up animation differ from the the actual spring animation, you might want to add an entirely new entry to achieve more flexibility. That's what this system was made for anyway.
     
    Last edited by a moderator: Mar 18, 2015
  3. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Thank you Selbi!
    So the "solution" is to change (A1) to (A0) !

    I will learn more :)
     
Thread Status:
Not open for further replies.