Advertisement
Guest User

Untitled

a guest
Jun 15th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Sprite_10310:
  2. Obj17:
  3.     moveq    #0,d0
  4.     move.b    routine(a0),d0
  5.     move.w    Obj17_Index(pc,d0.w),d1
  6.     jmp    Obj17_Index(pc,d1.w)
  7. ; ===========================================================================
  8. ; off_1031E:
  9. Obj17_Index:    offsetTable
  10.         offsetTableEntry.w Obj17_Init        ; 00 Load object art and mappings
  11.         offsetTableEntry.w Obj17_Idle        ; 02
  12.         offsetTableEntry.w Obj17_Touched       ; 04
  13.         offsetTableEntry.w Obj17_Align       ; 06
  14.         offsetTableEntry.w Obj17_Charge      ; 08
  15.         offsetTableEntry.w Obj17_Delay       ; 0A
  16. ; ===========================================================================
  17. ; loc_10324: Obj17_Main:
  18. Obj17_Init:
  19.     ;addq.b    #2,routine(a0)
  20.     move.l    #Obj17_MapUnc,mappings(a0)
  21.     move.w    #make_art_tile(ArtTile_ArtNem_Pole,1,0),art_tile(a0)
  22.     move.b    #4,render_flags(a0)
  23.     move.b    #3,priority(a0)
  24.     move.b    #8,width_pixels(a0)
  25.     move.w    x_pos(a0),$3C(a0) ;store x and y spawn positions
  26.     move.w    y_pos(a0),$3E(a0) ;''
  27.  
  28. Obj17_Reset:
  29.     move.b    #$02,routine(a0)              ; advance to next routine (for next frame)
  30.     move.b    #$40|$0F,collision_flags(a0)
  31.  
  32. ;---------------------------------------------
  33. ;Obj17_Idle
  34. ;---------------------------------------------
  35.  
  36. Obj17_Idle:
  37.     move.l  #$FFFFFF80,d2               ; prepare subtraction/and value
  38.     move.w  $3C(a0),d0              ; load object's original X spawn position
  39.     and.w   d2,d0                   ; wrap to nearest object load block
  40.     move.w  (Camera_X_pos).w,d1         ; load screen's X position
  41.     add.w   d2,d1                   ; move left a load block (include block to left of screen)
  42.     and.w   d2,d1                   ; wrap to nearest object load block
  43.     sub.w   d1,d0                   ; subtract from object's X spawn position
  44.     cmpi.w  #$0300-$80,d0               ; is the object still within the load area? (-$80 to +$2FF relative to screen)
  45.     bhi.w   DeleteObject                ; if not, branch to delete the object (it's gone out of range)
  46.     bra.w   DisplaySprite               ; save object to priority list for display
  47.  
  48. ; ---------------------------------------------------------------------------
  49. ; Object 17 - 04 - Sonic touched the cannon
  50. ; ---------------------------------------------------------------------------
  51.  
  52. Obj17_Touched:
  53.         sf.b  $20(a0)                   ; clear touch/collision response
  54.         move.b  #$81,($FFFFB02A).w          ; force lock Sonic (no physics, control, gravity etc)
  55.         lea  ($FFFFB000).w,a1           ; load Sonic's object RAM slot
  56.         ;move.b AniIDSonAni_Roll,$1C(a1); set Sonic's animation to rolling. Sonic will enter his pushing animation if I leave this in though...
  57.         moveq   #$00,d0                 ; clear d0
  58.         move.l  d0,x_vel(a1)                ; clear Sonic's X and Y speed
  59.         move.w  d0,inertia(a1)              ; clear Sonic's ground speed
  60.         move.b  $22(a0),d0              ; load object's status
  61.         andi.b  #%00000001,d0               ; get only the mirror (left/right facing) status
  62.         ori.b   #%00000110,d0               ; set Sonic's "in-air" and "roll" status bits
  63.         move.b  d0,$22(a1)              ; set Sonic's direction/status correctly
  64.         sf.b    $3C(a1)                 ; clear "height cap" flag (prevent release jump buttons effect)
  65.         move.b  #$02,$24(a1)                ; ensure Sonic is in normal control mode
  66.         addq.b  #$02,$24(a0)                ; advance to next routine (for next frame)
  67.  
  68. ; ---------------------------------------------------------------------------
  69. ; Object 17 - 06 - aligning Sonic towards centre of cannon
  70. ; ---------------------------------------------------------------------------
  71.  
  72. Obj17_Align:
  73.         lea ($FFFFB000).w,a1            ; load Sonic's object RAM slot
  74.         move.w  x_pos(a1),d1                ; load Sonic's X and Y positions
  75.         move.w  y_pos(a1),d2                ; ''
  76.         sub.w   x_pos(a0),d1                ; subtract cannon's X and Y to get the distance
  77.         sub.w   y_pos(a0),d2                ; ''
  78.         move.w  d1,d0                   ; check if Sonic is at object on X and Y already
  79.         or.w    d2,d0                   ; ''
  80.         beq.s   Obj17_AlignFinish           ; if so, branch
  81.         jsr     CalcAngle               ; get the angle Sonic is from the cannon (00 - FF inside d0)
  82.         jsr     CalcSine                ; get the sine/cosine (X and Y) using the angle in d0
  83.         ext.l   d1                  ; sign extend to long-word
  84.         ext.l   d0                  ; ''
  85.         asl.l   #$08,d1                 ; multiply X and Y to x10000
  86.         asl.l   #$08,d0                 ; ''
  87.         sub.l   d1,x_pos(a1)                ; move Sonic towards the object on X
  88.         sub.l   d0,y_pos(a1)                ; move Sonic towards the object on Y
  89.         bra.w   Obj17_Idle              ; continue for deletion check and display
  90.  
  91. Obj17_AlignFinish:
  92.         addq.b  #$02,$24(a0)                ; advance to next routine (for next frame)
  93.         move.b  #$10,$3B(a0)                ; set charge timer
  94.         move.w  #SndID_DoorSlam,d0              ; play charge/lock SFX
  95.         jsr (PlaySound).l           ; ''
  96.  
  97. ; ---------------------------------------------------------------------------
  98. ; Object 17 - 08 - charging and firing the cannon
  99. ; ---------------------------------------------------------------------------
  100.  
  101. Obj17_Charge:
  102.         subq.w  #$01,x_pos(a0)              ; move cannon down
  103.         addq.w  #$01,y_pos(a0)              ; move cannon left
  104.         btst.b  #$00,$22(a0)                ; is object facing right?
  105.         beq.s   Obj17_ChargeRight           ; if so, branch
  106.         addq.w  #$01+1,$08(a0)              ; move cannon right instead
  107.  
  108. Obj17_ChargeRight:
  109.         subq.b  #$01,$3B(a0)                ; minus 1 from charge timer
  110.         bcc.w   Obj17_Idle              ; if not finished, branch
  111.         move.w  $3C(a0),x_pos(a0)               ; restore cannon's X position
  112.         move.w  $3E(a0),y_pos(a0)               ; restore cannon's Y position
  113.         move.l  #$0C00F400,($FFFFB010).w        ; set Sonic's X and Y speeds (up and right)
  114.         btst.b  #$00,$22(a0)                ; is the cannon facing right?
  115.         beq.s   Obj17_ReleaseRight          ; if so, branch
  116.         neg.w   ($FFFFB010).w               ; reverse Sonic's X speed
  117.  
  118. Obj17_ReleaseRight:
  119.         sf.b  ($FFFFB02A).w             ; release Sonic
  120.         move.b  #$60,$3B(a0)                ; set delay time before allowing cannon to activate again
  121.         addq.b  #$02,$24(a0)                ; increase routine counter
  122.         move.w  #SndID_Teleport,d0              ; play release SFX
  123.         jsr (PlaySound).l           ; ''
  124.  
  125. ; ---------------------------------------------------------------------------
  126. ; Object 17 - 0A - delaying to give Sonic time to shoot away from object
  127. ; ---------------------------------------------------------------------------
  128.  
  129. Obj17_Delay:
  130.         subq.b  #$01,$3B(a0)                ; minus 1 from delay timer
  131.         bcc.w   Obj17_Idle              ; if not finished, branch
  132.         bra.w   Obj17_Reset             ; branch to reset routine counter and collision/touch
  133.  
  134.  
  135. ; ===========================================================================
  136. ; loc_1044A:
  137. Obj17_Display:
  138.     bra.w    DisplaySprite
  139. ; ===========================================================================
  140. ; ===========================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement