How to add animations in the FG

Discussion in 'Tutorials Archive' started by FireRat, May 21, 2011.

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

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    Hi guys. I have seen many hacks trying to create entirely new levels, but these are...


    not too much detailed I think, because have not palcycles, deform, animation, and other things


    For that, and because Selbi is creating a tool for deform the BG, I'm creating this guide


    Note: It's just a basic guide, that explains how to animate the FG, by timming. For the rest,


    you must learn by yourself.


    Ok, I want add these mushroms, to my FG in my hack,


    [​IMG]


    (You can download these images here)


    (also, note that the image size must be a multiple of 8, like 8x16, 16x32, 16x16)


    Into this:


    [​IMG]


    So, how to add this? I'll explain here


    First, we'll try to add the first frame. So, go to SonMapEd; before anything, unload all other loaded things, go to Settings > Tile Rendering >


    and set the line that will be used.


    Now, go to File > Load Data File > Load Seccondary palette lines, and select the zone's palette. You will get this:


    [​IMG]


    We're going to add the first frame. Go to File > Load From Image > Import Sprite Sheet, and then select the first


    mushroom frame. Load, and save that uncompressed as Mush1.bin in ArtUnc.


    Now, we need create the image's maps, into the level. Maybe like this


    [​IMG]


    To do that, open the level with sonmaped, and insert 4 tiles in the start of the tileset (CTRL + I, in the first one), and write the numbers


    1234 in these 4 first tiles. Now, to the block. Go to the block selector and do other more (CTRL + I, in the first one), and map it, depending


    of the tiles position added in sonmaped (don't forget the pal line). In this case, may be this:


    [​IMG]


    Now, just add that block in some chunk.


    Save, build and test, you just will see numbers, instead of mushrooms. We need do the Animation script. So, open your


    main ASM file, and go to Aniart_Load. It's the subrutine that loads the FG animations. We'll create the animation script


    here. So, go to Aniart_GHZ.


    The uncompressed art is hard to load, so, before work with that, we can install this subroutine, somewhere (Thanks GF64)




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


    ; Subroutine to load uncompressed art


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


    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||


    LoadUncArt:


    lea ($C00000), a1 ;Mover VDP Control a "a1"


    LoadArt_Loop:


    move.l (a2)+, (a1) ;$xxxxxxxx <- linea a procesar


    move.l (a2)+, (a1)


    move.l (a2)+, (a1)


    move.l (a2)+, (a1)


    move.l (a2)+, (a1)


    move.l (a2)+, (a1)


    move.l (a2)+, (a1)


    move.l (a2)+, (a1)


    dbf d0, LoadArt_Loop ;Repetir los pasos del d0


    rts


    ;===============================================================================


    =====



    So, in aniart_ghz, we want that routine loads the mushrooms art.


    after the label, add this



    jsr AniArt_GHZ_Mushrooms



    Ok, now we need to calculate the VRAM position. Well, I think that a macro used


    for the public S1 Hacking Studio will help here.


    Install this macro too, somewhere



    vram macro
    if (narg=1)


    move.l #($40000000+((\1&$3FFF)<<16)+((\1&$C000)>>14)),($C00004).l


    else


    move.l #($40000000+((\1&$3FFF)<<16)+((\1&$C000)>>14)),\2


    endc


    endm



    Do you remember that we added the 4 tiles in the first possible locations? So, the VRAM


    location to be used is $20.


    So before the label Aniart_GHZ, put this



    Aniart_GHZ_Mushrooms:
    vram $20



    To make the art be loaded in the LoadUncArt subroutine, add this after that:



    lea (UncMush1),a2



    Now, the subroutine needs the file size (hex) / 2. On this animation, the total is $3



    move.w #3,d0



    This is now ok, so call the LoadUncArt subroutine, and return.



    jsr LoadUncArt
    rts



    And now, we just need to add the tiles's file



    UncMush1:
    incbin 'artunc\mush1.bin'



    Save, build and test... You will se how the first frame is loaded correctly.


    [​IMG]


    Now, we need the other ones. Repeat the SonMapEd's steps to add the other images as Mush2.bin and Mush3.bin into Artunc (include them too), and go to Aniart_GHZ_Mushrooms


    Replace that with this, and your animation will be done.



    Aniart_GHZ_Mushrooms:
    vram $20 ;VRAM Location


    lea (Uncflows1),a2 ;Tiles


    move.w #3,d0 ;Size


    jsr LoadUncArt ;Process that


    cmpi.b #$10,($FFFFFFB3).w ;Timer 1 elapsed?


    bcs AniArt_AHZ_Return ;If not, branch


    vram $20 ;VRAM Location


    lea (Uncflows2),a2 ;Tiles


    move.w #3,d0 ;Size


    jsr LoadUncArt ;Process that


    cmpi.b #$10,($FFFFFFB4).w ;Timer 2 elapsed?


    bcs AniArt_AHZ_Return_2 ;If not, branch


    vram $20 ;VRAM Location


    lea (Uncflows1),a2 ;Tiles


    move.w #3,d0 ;Size


    jsr LoadUncArt ;Process that


    cmpi.b #$10,($FFFFFFB5).w ;Timer 3 elapsed?


    bcs AniArt_AHZ_Return_3 ;If not, branch


    vram $20 ;VRAM Location


    lea (Uncflows3),a2 ;Tiles


    move.w #3,d0 ;Size


    jsr LoadUncArt ;Process that


    cmpi.b #$10,($FFFFFFB6).w ;Timer 4 elapsed?


    bcs AniArt_AHZ_Return_4 ;If not, branch


    clr.b ($FFFFFFB3).w ;Clear Timer 1


    clr.w ($FFFFFFB4).w ;Clear Timer 2 and 3


    clr.b ($FFFFFFB6).w ;Clear Timer 4


    rts


    AniArt_AHZ_Return:


    add.b #1,($FFFFFFB3).w ;Add to Timer 1


    rts ;Return


    AniArt_AHZ_Return_2:


    add.b #1,($FFFFFFB4).w ;Add to Timer 2


    rts ;Return


    AniArt_AHZ_Return_3:


    add.b #1,($FFFFFFB5).w ;Add to Timer 3


    rts ;Return


    AniArt_AHZ_Return_4:


    add.b #1,($FFFFFFB6).w ;Add to Timer 4


    rts ;Return



    That's all. Enjoy!!


    EDIT: For who didn't understand the thing with VRAM correctly:


    You need take a slot. For example, $2. $2 * $20 = $40. Other Example, $3A0. $3A0 * $20 = $7400.


    Is <slot>*$20.


    And, for see possible slots, I recommend GensKMod
     
    Last edited by a moderator: May 21, 2011
  2. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    While I'm finding this guide very useful and well explained, you should also explain how to calculate the VRAM locations for the tiles we want to animate. Not bad, though! You're impressing me more each day, Trox!


    Keep up the good work. =)
     
  3. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    Edited =)
     
  4. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    You could also note it's exactly the same to load fake parallax art, excepted you have to use plane coordinates instead of a counter/timer (or both if relevant, of course).
     
  5. EMK-20218

    EMK-20218 The Fuss Maker Exiled

    Joined:
    Aug 8, 2008
    Messages:
    1,067
    Location:
    Jardim Capelinha, São Paulo
    Good to know it. Both informations are all in my needs. You definitely win, Trox. This guide is very nicely explained! :)
     
    Last edited by a moderator: May 22, 2011
  6. PsychoSk8r

    PsychoSk8r HighKnights Member

    Joined:
    Aug 9, 2007
    Messages:
    271
    Location:
    Birmingham, UK
    Very good job on this guide. =P
     
Thread Status:
Not open for further replies.