Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sonic_Homing:
  2.  
  3.         ; Registers
  4.         ; a1    -   Object pointer
  5.         ; d1    -   Iteration count
  6.        
  7.         ; Setup registers
  8.         lea (v_objspace).w,a1               ; Point to the first object (Sonic)
  9.         lea $40(a1),a1                      ; Skip to next object since we don't want to count Sonic in.
  10.         moveq #$7E,d1                       ; Set max. number of iterations to 0x7E
  11.         moveq #0,d0                         ; Set object number to 0
  12.        
  13. Sonic_Homing_Loop:
  14.  
  15.         ; Read object index
  16.         move.b (a1),d0                      ; Load the object number from RAM.
  17.         beq.s Sonic_Homing_Loop_Next        ; If it's 0, skip to next object.
  18.        
  19.         ; Check if the object is an enemy
  20.         move.b obColType(a1),d0
  21.         andi.b #$C0,d0
  22.         bne.s Sonic_Homing_Loop_Next        ; If not, it's not an enemy, skip.
  23.        
  24.         ; Calculate distance to object.
  25.         move.b #0,(a1)                      ; Destroy object?
  26.        
  27. Sonic_Homing_Loop_Next:
  28.         lea $40(a1),a1                      ; Skip to next object. Decrement loop iteration
  29.         dbf d1,Sonic_Homing_Loop            ; and continue.
  30.         rts                                 ; Done!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement