Advertisement
Guest User

Untitled

a guest
Jun 17th, 2020
81
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_Hang2,$1C(a1); set Sonic's animation to hanging
  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   #%0000010,d0                ; set Sonic's "in-air" 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. ; Now to make it just place Sonic at the cannon's location...
  71. ; Everything commented out that's not a branch to a subroutine was for the
  72. ; previous "gradual align" behaviour.
  73. ;
  74. ; This works now, but the object is deleted when you go off screen.
  75. ; ---------------------------------------------------------------------------
  76.  
  77. Obj17_Align:
  78.         lea ($FFFFB000).w,a1            ; load Sonic's object RAM slot
  79.         ;move.w x_pos(a1),d1                ; load Sonic's X and Y positions
  80.         ;move.w y_pos(a1),d2                ; ''
  81.         ;sub.w  x_pos(a0),d1                ; subtract cannon's X and Y to get the distance
  82.         ;sub.w  y_pos(a0),d2                ; ''
  83.         ;move.w d1,d0                   ; check if Sonic is at object on X and Y already
  84.         ;or.w   d2,d0                   ; ''       
  85.         move.w  x_pos(a0),x_pos(a1)
  86.         move.w  y_pos(a0),y_pos(a1)
  87.         ;cmp.l   a1,a0
  88.         bra.s   Obj17_AlignFinish           ; if so, branch
  89.         ;jsr        CalcAngle               ; get the angle Sonic is from the cannon (00 - FF inside d0)
  90.         ;jsr        CalcSine                ; get the sine/cosine (X and Y) using the angle in d0
  91.         ;ext.l  d1                  ; sign extend to long-word
  92.         ;ext.l  d0                  ; ''
  93.         ;asl.l  #$08,d1                 ; multiply X and Y to x10000
  94.         ;asl.l  #$08,d0                 ; ''
  95.         ;sub.l  d1,x_pos(a1)                ; move Sonic towards the object on X
  96.         ;sub.l  d0,y_pos(a1)                ; move Sonic towards the object on Y       
  97.         bra.w   Obj17_Idle              ; continue for deletion check and display
  98.  
  99. Obj17_AlignFinish:
  100.         addq.b  #$02,$24(a0)                ; advance to next routine (for next frame)
  101.         move.b  #$10,$3B(a0)                ; set charge timer
  102.         move.w  #SndID_DoorSlam,d0              ; play charge/lock SFX
  103.         jsr (PlaySound).l           ; ''
  104.  
  105. ; ---------------------------------------------------------------------------
  106. ; Object 17 - 08 - charging and firing the cannon
  107. ; ---------------------------------------------------------------------------
  108.  
  109. Obj17_Charge:
  110.         ;subq.w #$01,x_pos(a0)              ; move cannon down
  111.         ;addq.w #$01,y_pos(a0)              ; move cannon left
  112.         btst.b  #$00,$22(a0)                ; is object facing right?
  113.         beq.s   Obj17_ChargeRight           ; if so, branch
  114.         addq.w  #$01+1,$08(a0)              ; move cannon right instead
  115.  
  116. Obj17_ChargeRight:
  117.         subq.b  #$01,$3B(a0)                ; minus 1 from charge timer
  118.         bcc.w   Obj17_Idle              ; if not finished, branch
  119.         move.w  $3C(a0),x_pos(a0)               ; restore cannon's X position
  120.         move.w  $3E(a0),y_pos(a0)               ; restore cannon's Y position
  121.         move.l  #$00000400,($FFFFB010).w        ; set Sonic's X and Y speeds (up and right)
  122.         btst.b  #$00,$22(a0)                ; is the cannon facing right?
  123.         beq.s   Obj17_ReleaseRight          ; if so, branch
  124.         neg.w   ($FFFFB010).w               ; reverse Sonic's X speed
  125.  
  126. Obj17_ReleaseRight:
  127.         move.b  #AniIDSonAni_Spring,$FFFFB01C
  128.         sf.b  ($FFFFB02A).w             ; release Sonic
  129.         move.b  #$60,$3B(a0)                ; set delay time before allowing cannon to activate again
  130.         addq.b  #$02,$24(a0)                ; increase routine counter
  131.         move.w  #SndID_Spring,d0                ; play release SFX
  132.         jsr (PlaySound).l           ; ''
  133.  
  134. ; ---------------------------------------------------------------------------
  135. ; Object 17 - 0A - delaying to give Sonic time to shoot away from object
  136. ; ---------------------------------------------------------------------------
  137.  
  138. Obj17_Delay:
  139.         subq.b  #$01,$3B(a0)                ; minus 1 from delay timer
  140.         bcc.w   Obj17_Idle              ; if not finished, branch
  141.         bra.w   Obj17_Reset             ; branch to reset routine counter and collision/touch
  142.  
  143.  
  144. ; ===========================================================================
  145. ; loc_1044A:
  146. Obj17_Display:
  147.     bra.w    DisplaySprite
  148. ; ===========================================================================
  149. ; ===========================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement