Okay this is a follow up to the coding question in "Quick Theoretical" (which is now locked). I've tried to expand on my coding by having different animations move the object in different directions. Here is the VERY long routine (I know there is likely a more practical way to code all this, but this was the best I could think of): Routine04: lea ($FFFFD000).w,a1 btst #0,$22(a1) bne.w Routine04_Rev move.w ($FFFFD008).w,8(a0) move.w ($FFFFD00C).w,$C(a0) move.b ($FFFFD022).w,$22(a0) andi.b #1,$22(a0) lea Ani_Punch(pc),a1 ; load animation script jsr AnimateSprite ; process animation cmpi.b #$01,$1A(a0) ; animation frame? bne.s Obj_Blob_Pos2 add.w #$10,8(a0) jmp Obj_Blob_Pos8 Obj_Blob_Pos2: cmpi.b #$02,$1A(a0) ; animation frame? bne.s Obj_Blob_Pos3 add.w #$20,8(a0) jmp Obj_Blob_Pos8 Obj_Blob_Pos3: cmpi.b #$03,$1A(a0) ; animation frame ? bne.s Obj_Blob_Pos4 add.w #$30,8(a0) jmp Obj_Blob_Pos8 Obj_Blob_Pos4: cmpi.b #$04,$1A(a0) ; animation frame ? bne.s Obj_Blob_Pos5 add.w #$40,8(a0) jmp Obj_Blob_Pos8 Obj_Blob_Pos5: cmpi.b #$05,$1A(a0) ; animation frame ? bne.s Obj_Blob_Pos6 add.w #$50,8(a0) jmp Obj_Blob_Pos8 Obj_Blob_Pos6: cmpi.b #$06,$1A(a0) ; animation frame ? bne.s Obj_Blob_Pos7 add.w #$60,8(a0) jmp Obj_Blob_Pos8 Obj_Blob_Pos7: cmpi.b #$07,$1A(a0) ; animation frame? bne.s Obj_Blob_Pos88 add.w #$70,8(a0) jmp Obj_Blob_Pos8 Obj_Blob_Pos88: cmpi.b #$08,$1A(a0) ; animation frame? bne.s Obj_Blob_Pos8 add.w #$80,8(a0) Obj_Blob_Pos8: move.w #$40,$20(a0) cmpi.b #$08,$1A(a0) ; is the frame at 08? bne.s R04_Display ; if not, branch addq.b #$02,$24(a0) ; increase routine counter R04_Display: jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor bra.w DisplaySprite ; save object for display Routine06: lea ($FFFFD000).w,a1 btst #0,$22(a1) bne.w Routine06_Rev move.w ($FFFFD008).w,8(a0) move.w ($FFFFD00C).w,$C(a0) move.b ($FFFFD022).w,$22(a0) andi.b #1,$22(a0) tst.b $1E(a0) ; has the frame duration reached 0? bne.s R06_Animate ; if not, branch subq.b #$02,$1B(a0) ; move back two spaces (AnimateSprite will move forwards once) beq.w R06_Delete ; if it has moved back to 00, this is the speed, so branch R06_Animate: lea Ani_Punch(pc),a1 ; load animation script jsr AnimateSprite ; process animation cmpi.b #$01,$1A(a0) ; animation frame? bne.s Obj_Blob_Pos206 add.w #$10,8(a0) jmp Obj_Blob_Pos806 Obj_Blob_Pos206: cmpi.b #$02,$1A(a0) ; animation frame? bne.s Obj_Blob_Pos306 add.w #$20,8(a0) jmp Obj_Blob_Pos806 Obj_Blob_Pos306: cmpi.b #$03,$1A(a0) ; animation frame ? bne.s Obj_Blob_Pos406 add.w #$30,8(a0) jmp Obj_Blob_Pos806 Obj_Blob_Pos406: cmpi.b #$04,$1A(a0) ; animation frame? bne.s Obj_Blob_Pos506 add.w #$40,8(a0) jmp Obj_Blob_Pos806 Obj_Blob_Pos506: cmpi.b #$05,$1A(a0) ; animation frame ? bne.s Obj_Blob_Pos606 add.w #$50,8(a0) jmp Obj_Blob_Pos806 Obj_Blob_Pos606: cmpi.b #$06,$1A(a0) ; animation frame ? bne.s Obj_Blob_Pos706 add.w #$60,8(a0) jmp Obj_Blob_Pos806 Obj_Blob_Pos706: cmpi.b #$07,$1A(a0) ; animation frame? bne.s Obj_Blob_Pos8806 add.w #$70,8(a0) jmp Obj_Blob_Pos806 Obj_Blob_Pos8806: cmpi.b #$08,$1A(a0) ; animation frame? bne.s Obj_Blob_Pos806 add.w #$80,8(a0) Obj_Blob_Pos806: jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor bra.w DisplaySprite ; save object for display R06_Delete: bra.w DeleteObject ; delete the object jmp Obj_Blob_Pos Routine04_Rev: move.w ($FFFFD008).w,8(a0) move.w ($FFFFD00C).w,$C(a0) move.b ($FFFFD022).w,$22(a0) andi.b #1,$22(a0) lea Ani_Punch(pc),a1 ; load animation script jsr AnimateSprite ; process animation neg.w $10(a0) cmpi.b #$01,$1A(a0) ; does monitor contain Sonic? bne.s Obj_Blob_PosRev2 sub.w #$10,8(a0) jmp Obj_Blob_PosRev8 Obj_Blob_PosRev2: cmpi.b #$02,$1A(a0) ; does monitor contain Eggman? bne.s Obj_Blob_PosRev3 sub.w #$20,8(a0) jmp Obj_Blob_PosRev8 Obj_Blob_PosRev3: cmpi.b #$03,$1A(a0) ; does monitor contain ? bne.s Obj_Blob_PosRev4 sub.w #$30,8(a0) jmp Obj_Blob_PosRev8 Obj_Blob_PosRev4: cmpi.b #$04,$1A(a0) ; does monitor contain ? bne.s Obj_Blob_PosRev5 sub.w #$40,8(a0) jmp Obj_Blob_PosRev8 Obj_Blob_PosRev5: cmpi.b #$05,$1A(a0) ; does monitor contain ? bne.s Obj_Blob_PosRev6 sub.w #$50,8(a0) jmp Obj_Blob_PosRev8 Obj_Blob_PosRev6: cmpi.b #$06,$1A(a0) ; does monitor contain ? bne.s Obj_Blob_PosRev7 sub.w #$60,8(a0) jmp Obj_Blob_PosRev8 Obj_Blob_PosRev7: cmpi.b #$07,$1A(a0) ; does monitor contain S? bne.s Obj_Blob_PosRev88 sub.w #$70,8(a0) jmp Obj_Blob_PosRev8 Obj_Blob_PosRev88: cmpi.b #$08,$1A(a0) ; does monitor contain S? bne.s Obj_Blob_PosRev8 sub.w #$80,8(a0) Obj_Blob_PosRev8: move.w #$40,$20(a0) cmpi.b #$08,$1A(a0) ; is the frame at 08? bne.s R04_Display_Rev ; if not, branch addq.b #$02,$24(a0) ; increase routine counter R04_Display_Rev: jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor bra.w DisplaySprite ; save object for display Routine06_Rev: move.w ($FFFFD008).w,8(a0) move.w ($FFFFD00C).w,$C(a0) move.b ($FFFFD022).w,$22(a0) andi.b #1,$22(a0) tst.b $1E(a0) ; has the frame duration reached 0? bne.s R06_Animate_Rev ; if not, branch subq.b #$02,$1B(a0) ; move back two spaces (AnimateSprite will move forwards once) beq.w R06_Delete_Rev ; if it has moved back to 00, this is the speed, so branch R06_Animate_Rev: lea Ani_Punch(pc),a1 ; load animation script jsr AnimateSprite ; process animation neg.w $10(a0) cmpi.b #$01,$1A(a0) ; animation frame? bne.s Obj_Blob_PosRev62 sub.w #$10,8(a0) jmp Obj_Blob_PosRev68 Obj_Blob_PosRev62: cmpi.b #$02,$1A(a0) ; animation frame? bne.s Obj_Blob_PosRev63 sub.w #$20,8(a0) jmp Obj_Blob_PosRev68 Obj_Blob_PosRev63: cmpi.b #$03,$1A(a0) ; animation frame ? bne.s Obj_Blob_PosRev64 sub.w #$30,8(a0) jmp Obj_Blob_PosRev68 Obj_Blob_PosRev64: cmpi.b #$04,$1A(a0) ; animation frame ? bne.s Obj_Blob_PosRev65 sub.w #$40,8(a0) jmp Obj_Blob_PosRev68 Obj_Blob_PosRev65: cmpi.b #$05,$1A(a0) ; animation frame ? bne.s Obj_Blob_PosRev66 sub.w #$50,8(a0) jmp Obj_Blob_PosRev68 Obj_Blob_PosRev66: cmpi.b #$06,$1A(a0) ; animation frame ? bne.s Obj_Blob_PosRev67 sub.w #$60,8(a0) jmp Obj_Blob_PosRev68 Obj_Blob_PosRev67: cmpi.b #$07,$1A(a0) ; animation frame? bne.s Obj_Blob_PosRev688 sub.w #$70,8(a0) jmp Obj_Blob_PosRev68 Obj_Blob_PosRev688: cmpi.b #$08,$1A(a0) ; animation frame? bne.s Obj_Blob_PosRev68 sub.w #$80,8(a0) Obj_Blob_PosRev68: jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor bra.w DisplaySprite ; save object for display R06_Delete_Rev: bra.w DeleteObject ; delete the object jmp Obj_Blob_Pos Downward04: lea ($FFFFD000).w,a1 btst #0,$22(a1) bne.w Downward04_Rev move.w ($FFFFD008).w,8(a0) move.w ($FFFFD00C).w,$C(a0) move.b ($FFFFD022).w,$22(a0) andi.b #1,$22(a0) lea Ani_Punch(pc),a1 ; load animation script jsr AnimateSprite ; process animation cmpi.b #$01,$1B(a0) ; animation frame? bne.s Downward_Blob_Pos2 add.w #$10,$C(a0) jmp Downward_Blob_Pos8 Downward_Blob_Pos2: cmpi.b #$02,$1B(a0) ; animation frame? bne.s Downward_Blob_Pos3 add.w #$20,$C(a0) jmp Downward_Blob_Pos8 Downward_Blob_Pos3: cmpi.b #$03,$1B(a0) ; animation frame ? bne.s Downward_Blob_Pos4 add.w #$30,$C(a0) jmp Downward_Blob_Pos8 Downward_Blob_Pos4: cmpi.b #$04,$1B(a0) ; animation frame ? bne.s Downward_Blob_Pos5 add.w #$40,$C(a0) jmp Downward_Blob_Pos8 Downward_Blob_Pos5: cmpi.b #$05,$1B(a0) ; animation frame ? bne.s Downward_Blob_Pos6 add.w #$50,$C(a0) jmp Downward_Blob_Pos8 Downward_Blob_Pos6: cmpi.b #$06,$1B(a0) ; animation frame ? bne.s Downward_Blob_Pos7 add.w #$60,$C(a0) jmp Downward_Blob_Pos8 Downward_Blob_Pos7: cmpi.b #$07,$1B(a0) ; animation frame? bne.s Downward_Blob_Pos8 add.w #$70,$C(a0) jmp Downward_Blob_Pos8 Downward_Blob_Pos88: cmpi.b #$08,$1B(a0) ; animation frame? bne.s Downward_Blob_Pos8 add.w #$80,$C(a0) Downward_Blob_Pos8: move.w #$40,$20(a0) cmpi.b #$00,$1B(a0) ; is the frame at 00? bne.s D04_Display ; if not, branch addq.b #$02,$24(a0) ; increase Downward counter D04_Display: jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor bra.w DisplaySprite ; save object for display Downward06: lea ($FFFFD000).w,a1 btst #0,$22(a1) bne.w Downward06_Rev move.w ($FFFFD008).w,8(a0) move.w ($FFFFD00C).w,$C(a0) move.b ($FFFFD022).w,$22(a0) andi.b #1,$22(a0) tst.b $1E(a0) ; has the frame duration reached 0? bne.s D06_Animate ; if not, branch subq.b #$02,$1B(a0) ; move back two spaces (AnimateSprite will move forwards once) beq.w D06_Delete ; if it has moved back to 00, this is the speed, so branch D06_Animate: lea Ani_Punch(pc),a1 ; load animation script jsr AnimateSprite ; process animation cmpi.b #$01,$1B(a0) ; animation frame? bne.s Downward_Blob_Pos206 add.w #$10,$C(a0) jmp Downward_Blob_Pos806 Downward_Blob_Pos206: cmpi.b #$02,$1B(a0) ; animation frame? bne.s Downward_Blob_Pos306 add.w #$20,$C(a0) jmp Downward_Blob_Pos806 Downward_Blob_Pos306: cmpi.b #$03,$1B(a0) ; animation frame ? bne.s Downward_Blob_Pos406 add.w #$30,$C(a0) jmp Downward_Blob_Pos806 Downward_Blob_Pos406: cmpi.b #$04,$1B(a0) ; animation frame ? bne.s Downward_Blob_Pos506 add.w #$40,$C(a0) jmp Downward_Blob_Pos806 Downward_Blob_Pos506: cmpi.b #$05,$1B(a0) ; animation frame ? bne.s Downward_Blob_Pos606 add.w #$50,$C(a0) jmp Downward_Blob_Pos806 Downward_Blob_Pos606: cmpi.b #$06,$1B(a0) ; animation frame ? bne.s Downward_Blob_Pos706 add.w #$60,$C(a0) jmp Downward_Blob_Pos806 Downward_Blob_Pos706: cmpi.b #$07,$1B(a0) ; animation frame? bne.s Downward_Blob_Pos806 add.w #$70,$C(a0) jmp Downward_Blob_Pos806 Downward_Blob_Pos8806: cmpi.b #$08,$1B(a0) ; animation frame? bne.s Downward_Blob_Pos806 add.w #$80,$C(a0) Downward_Blob_Pos806: jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor bra.w DisplaySprite ; save object for display D06_Delete: bra.w DeleteObject ; delete the object jmp Obj_Blob_Pos Downward04_Rev: move.w ($FFFFD008).w,8(a0) move.w ($FFFFD00C).w,$C(a0) move.b ($FFFFD022).w,$22(a0) andi.b #1,$22(a0) lea Ani_Punch(pc),a1 ; load animation script jsr AnimateSprite ; process animation neg.w $10(a0) cmpi.b #$0A,$1B(a0) ; animation frame? bne.s Downward_Blob_PosRev2 add.w #$10,$C(a0) jmp Downward_Blob_PosRev8 Downward_Blob_PosRev2: cmpi.b #$0B,$1B(a0) ; animation frame? bne.s Downward_Blob_PosRev3 add.w #$20,$C(a0) jmp Downward_Blob_PosRev8 Downward_Blob_PosRev3: cmpi.b #$0C,$1B(a0) ; animation frame ? bne.s Downward_Blob_PosRev4 add.w #$30,$C(a0) jmp Downward_Blob_PosRev8 Downward_Blob_PosRev4: cmpi.b #$0D,$1B(a0) ; animation frame ? bne.s Downward_Blob_PosRev5 add.w #$40,$C(a0) jmp Downward_Blob_PosRev8 Downward_Blob_PosRev5: cmpi.b #$0E,$1B(a0) ; animation frame ? bne.s Downward_Blob_PosRev6 add.w #$50,$C(a0) jmp Downward_Blob_PosRev8 Downward_Blob_PosRev6: cmpi.b #$0F,$1B(a0) ; animation frame ? bne.s Downward_Blob_PosRev7 add.w #$60,$C(a0) jmp Downward_Blob_PosRev8 Downward_Blob_PosRev7: cmpi.b #$10,$1B(a0) ; animation frame? bne.s Downward_Blob_PosRev88 add.w #$70,$C(a0) jmp Downward_Blob_PosRev8 Downward_Blob_PosRev88: cmpi.b #$11,$1B(a0) ; animation frame? bne.s Downward_Blob_PosRev8 add.w #$80,$C(a0) Downward_Blob_PosRev8: move.w #$40,$20(a0) cmpi.b #$10,$1B(a0) ; is the frame at 10? bne.s D04_Display_Rev ; if not, branch addq.b #$02,$24(a0) ; increase Downward counter D04_Display_Rev: jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor bra.w DisplaySprite ; save object for display Downward06_Rev: move.w ($FFFFD008).w,8(a0) move.w ($FFFFD00C).w,$C(a0) move.b ($FFFFD022).w,$22(a0) andi.b #1,$22(a0) tst.b $1E(a0) ; has the frame duration reached 0? bne.s D06_Animate_Rev ; if not, branch subq.b #$02,$1B(a0) ; move back two spaces (AnimateSprite will move forwards once) beq.w D06_Delete_Rev ; if it has moved back to 00, this is the speed, so branch D06_Animate_Rev: lea Ani_Punch(pc),a1 ; load animation script jsr AnimateSprite ; process animation neg.w $10(a0) cmpi.b #$0A,$1B(a0) ; animation frame A? bne.s Downward_Blob_PosRev62 add.w #$10,$C(a0) jmp Downward_Blob_PosRev68 Downward_Blob_PosRev62: cmpi.b #$0B,$1B(a0) ; animation B? bne.s Downward_Blob_PosRev63 add.w #$20,$C(a0) jmp Downward_Blob_PosRev68 Downward_Blob_PosRev63: cmpi.b #$0C,$1B(a0) ; animation frame C ? bne.s Downward_Blob_PosRev64 add.w #$30,$C(a0) jmp Downward_Blob_PosRev68 Downward_Blob_PosRev64: cmpi.b #$0D,$1B(a0) ; animation frame D ? bne.s Downward_Blob_PosRev65 add.w #$40,$C(a0) jmp Downward_Blob_PosRev68 Downward_Blob_PosRev65: cmpi.b #$0E,$1B(a0) ; animation frame E ? bne.s Downward_Blob_PosRev66 add.w #$50,$C(a0) jmp Downward_Blob_PosRev68 Downward_Blob_PosRev66: cmpi.b #$0F,$1B(a0) ; animation frame F ? bne.s Downward_Blob_PosRev67 add.w #$60,$C(a0) jmp Downward_Blob_PosRev68 Downward_Blob_PosRev67: cmpi.b #$10,$1B(a0) ; animation 10? bne.s Downward_Blob_PosRev68 add.w #$80,$C(a0) Downward_Blob_PosRev68: jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor bra.w DisplaySprite ; save object for display D06_Delete_Rev: bra.w DeleteObject ; delete the object Obj_Blob_Pos: nop Obj_Blob_Destroy: clr.b ($FFFFFFA4).w ; clear punch flag jmp DeleteObject rts Ani_Punch: dc.w PunchLeft-Ani_Punch dc.w PunchDown-Ani_Punch PunchLeft: dc.b 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, $FD, 0 PunchDown: dc.b 1, 9, $A, $B, $C, $D, $E, $F, $10, $FD, 0 even Basically it has a horizontal and vertical routine that tell the object's animation to go forward then reverse and the object to move according to it. It works fine for the PunchLeft animation: The PunchDown animation works for the forward transition: But then moves back to starting place for the last frame: And then runs back in the PunchLeft animation: Any idea why the routine is screwing the downward pattern up?
Try using this: PunchLeft: dc.b 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, $FF even PunchDown: dc.b 1, 9, $A, $B, $C, $D, $E, $F, $10, $FF even Last I checked, $FD is to change animation, and using even to separate animations will help prevent the overlap. Otherwise, it's like saying "This animation is 1,2,3, and use animation 2's 4,5,6," all at once. EDIT (2): And, if you must use $FD, try this, so PunchDown will redirect back to itself in ID, rather than to the first animation "0," which is PuchLeft. Code: PunchLeft: dc.b 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, $FD, 0 even PunchDown: dc.b 1, 9, $A, $B, $C, $D, $E, $F, $10, $FD, 1 even
First of all, thanx very much for taking the time to look at that enormous piece of coding. Well that's made one fix, it's no longer snapping into the forward punch animation. For some reason though, it still won't reverse the downward animation, it just keeps doing the forward motion over and over or, if tweaked, just sticks at the last frame and eventually freezes the game.
Well, try making your PunchRight and PunchUp animations have the same finish of "$FD, 3" (next line) "even" and "$FD, 4" (next line) "even". I would fix it for you, but you didn't include that in your ASM post here. As far as I know, just test different codes, and look at Sonic's animation file for references on how those worked out. EDIT: To reverse the animation afterwards, just go from the last frame and copy in reverse the numbers to the left of it? EDIT AGAIN: Like this: Code: PunchDown: dc.b 1, 9, $A, $B, $C, $D, $E, $F, $10, $F, $E, $D, $A $FD, 1 even
The code to reverse isn't a separate animation, the coding is all there. I have a routine there to make the animation reverse it's frames when it reaches a certain point. The downward coding is Downward04 to run and Downward06 to reverse back.
I just edited that post twice, the second animation making the animation play, then play in reverse. You needed to make the frames go up to $F, then back to $A. Unless 1 is the start, then you'd use this: PunchDown: dc.b 1, 9, $A, $B, $C, $D, $E, $F, $10, $F, $E, $D, $A, 9, 1, $FD, 1 evenEDIT: Of course, this is to make the animation responsible for reversing, rather than the pointers.
If the animations are just to play, reverse, and then be done, make all the "$FD, (whatever-this-is)" into $FF. This will make it stop playing once it has finished the animation. Like this: PunchLeft: dc.b 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, $FF even PunchDown: dc.b 1, 9, $A, $B, $C, $D, $E, $F, $10, $FF even EDIT: Oops, I used the code from before the anim' fix. This is with it: PunchDown: dc.b 1, 9, $A, $B, $C, $D, $E, $F, $10, $F, $E, $D, $B, $A, 9, 1, $FF evenor Code: PunchDown: dc.b 1, 9, $A, $B, $C, $D, $E, $F, $10, $F, $E, $D, $B, $A, $FF even
That....in hindsight would have been a lot simpler, yes. *facepalms in my stupidity* The reason it was reversed through routine rather than animation originally was because the object was supposed to be far more advanced. It was going to retract according to hitting badniks and walls as well as it's frame count (think Bionic Commando or Ristar) but I never got nearly advanced enough to do such a thing. I feel I should at least get the basic thing running before I try that. At least I can downsize the amount of code a good deal with this method. Thank you very much for this fix. It's humiliating to think how long I've been stuck on this.