player_walking_1:
.byte $00,$32,%00000000,$00
.byte $00,$33,%00000000,$08
.byte $08,$34,%00000000,$00
.byte $08,$35,%00000000,$08
player_walking_2:
.byte $00,$36,%00000000,$00
.byte $00,$37,%00000000,$08
.byte $08,$38,%00000000,$00
.byte $08,$39,%00000000,$08
etc...
player_walk_animation:
.byte $04 ; number of frames
.word player_walking_1, player_walking_2, player_walking_3, player_walking_4
This is getting more advanced so once you have worked out the above, the next step it to store the attributes as arrays.
So
Code: Select all
Frame_X .byte $00,$08,$00,$08,$00,$08,$00,$08
Frame_Tile .byte $32,$33,$34,$35,$36,$37,$38,$39
Frame_Atrribute .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
Frame_Y .byte $00,$00,$08,$08,$00,$00,$08,$08
Then you put Frame in X
Code: Select all
lda Frame_X,x
sta Dest,y
lda Frame_Tile,x
sta Dest+1,y
lda Frame_Attribute,x
sta Dest+2,y
lda Frame_Y,x
sta Dest+3,y
tya
clc
adc #4 ; move to next sprite slot
tay
; while still frame left, get next frame index and loop
You then stack N animations in the main tables. Then your Walk animation either becomes a list of frames, or if you know you only want a range then you have
Start,End
So you keep a frame index in RAM, load it with Start, inc it each time until it hits End, then reset it to start.
Putting the data stripped in this way is a pain, but if you upgrade to Tass64 (which works on Mac Intel and PPC ) over CA65 you can start to do things like
Code: Select all
My_Animations := (($00,$32,%00000000,$00),($00,$33,%00000000,$08),($08,$34,%00000000,$00),($08,$35,%00000000,$08),($00,$36,%00000000,$00)....)
PlayerWalkEnd = len(My_Animations)
You can add addition animations with
My_Animations ..= ( anims )
Then you do
Frame_X .byte My_Animations[:0]
Frame_Tile .byte My_Animations[:1]
Frame_Atrribute .byte My_Animations[:2]
Frame_Y .byte My_Animations[:3]
PlayerWalk .byte $04,$00,PlayerWalkEnd ; frames,start,end
Word to the wise.
Don't hard code tile numbers, it is going to cause your a lot of pain latter on when you need to move things, and you will need to move things
Also they are not very readable
Code: Select all
kTileIndex .block
PlayerHead .block
L = $34
R = $35
.bend
PlayerLegWalk
f1 .block
L = $36
R = $37
.bend
.bend
Yes its a lot more typing, but then in 3 months when you need to change an animation how much more sense does
Frame_Tile .byte $32,$33,PlayerHead.(L,R),PlayerLegWalk.f1.(L,R),$37,$38,$39 make?