Animation Function

Prime

Animation Function

Post by Prime »

Animation Function By Richard Rutledge(Prime)
Just to be clear _ObjectDirection = 0 west,1 = east x2 because I'm using a 2byte word value for animation
I've seen a lot of c64 programmers handle this extremely bad so i'll show how i handle this.
Next i'll show how to handle jump physics (side note groepaz showed in C how to handle this so I adapted his code into 6502)
If any Question write here or pm me as I want everyone to have a good grasp on my code and how programming works.
Another programmer friend(Shaun B)recommended I comment the code to help new programmers(he understands it but new coders need things explained(sorry I assumed intermediate programming level guys my bad,Sometimes we forget the tasks how we started I apologize for that.)
I'm off to bed but i'll comment when I return friends.




.byte FrameEndMarker = $ff



Do_HandleAnimation
lda _ObjectIDPtr,y
asl
tay
lda ObjectIDFrameTab,y
sta _TmpPtr
iny
lda ObjectIDFrameTab,y
sta _TmpPtr+1
lda _ObjectState,x
asl
tay
lda (_TmpPtr),y
sta _ObjectPtr
iny
lda (_TmpPtr),y
sta _ObjectPtr+1
lda _ObjectDirection,x
asl
tay
lda (_ObjectPtr),y
sta _TmpPtr
iny
lda (_ObjectPtr),y
sta _TmpPtr+1
lda _ObjectFrameTic,x
beq ObjectAnimationExit
dec _ObjectFrameTic,x
bne ObjectAnimationExit
ldy _ObjectFrameOffset,x
lda (_TmpPtr),y
cmp #FrameEndMarker
bne ObjectAnimationCont
RecycleObjectAnimation
lda #0
sta _ObjectFrameOffset,x
ObjectAnimationCont
lda (_TmpPtr),y
sta _ObjectFrameTic,x
iny
lda (_TmpPtr),y
sta _ObjectCurrentFrame+0,x
iny
lda (_TmpPtr),y
sta _ObjectCurrentFrame+1,x
iny
sty _ObjectFrameOffset,x
ObjectAnimationExit
rts





ObjectIDFrameTab
word NemoFrameStructure


NemoFrameStructure
word NemoIdle ;0
word NemoWalk ;1
word NemoJump ;2


NemoIdle
word NemoIdleWest
word NemoIdleEast
NemoWalk
word NemoWalkWest
word NemoWalkEast
;NemoJump
;word NemoJumpEast
;word NemoJumpWest




NemoIdleEast
byte 140,$81,$80,15,$83,$82,15,$81,$80,15,$83,$82,15,$81,$80,$ff
NemoIdleWest
byte 140,$91,$90,15,$93,$92,15,$91,$90,15,$93,$92,15,$91,$90,$ff
NemoWalkEast
byte 15,$85,$84,15,$87,$86,15,$89,$88,15,$8b,$8a,15,$8d,$8c,$ff
NemoWalkWest
byte 15,$95,$94,15,$97,$96,15,$99,$98,15,$9b,$9a,15,$9d,$9c,$ff


NemoJumpEast
byte $fe,$91,$90,$fe,$91,$90,$ff
NemoJumpWest
byte $fe,$93,$92,$fe,$93,$92,$ff


Who is online

Users browsing this forum: No registered users and 2 guests