Advertisement
TheBlad768

S3K Shields to S1

Sep 3rd, 2018
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ---------------------------------------------------------------------------
  2. ; Elemental shields from S3K to S1.
  3. ; Ported by TheBlad768 (2018).
  4. ; ---------------------------------------------------------------------------
  5.  
  6. ; Object variables
  7. obSlot_Shields:                 equ $38                 ; Set current object slot in object pointers
  8. obVRAM_Shields:                 = ($A820/$20)           ; Set VRAM address
  9. obVRAM_LightningShields_Spark:  = $AC00                 ; Set VRAM address
  10. ; ---------------------------------------------------------------------------
  11.  
  12. ; Universal object variables
  13. obRender:               equ 1   ; .b
  14. obGfx:                  equ 2   ; .w
  15. obMap:                  equ 4   ; .l
  16. obX:                    equ 8   ; .w.l
  17. obScreenY:              equ $A  ; .w
  18. obY:                        equ $C  ; .w.l
  19. obVelX:                 equ $10 ; .w
  20. obVelY:                 equ $12 ; .w
  21. obInertia:              equ $14 ; .w
  22. obHeight:               equ $16 ; .b
  23. obWidth:                equ $17 ; .b
  24. obPriority:             equ $18 ; .b
  25. obActWid:               equ $19 ; .b
  26. obFrame:                equ $1A ; .b
  27. obAniFrame:             equ $1B ; .b
  28. obAnim:                 equ $1C ; .b
  29. obTimeFrame:            equ $1E ; .b
  30. obColType:              equ $20 ; .b
  31. obColProp:              equ $21 ; .b
  32. obStatus:               equ $22 ; .b
  33. obRoutine:              equ $24 ; .b
  34. ob2ndRout:              equ $25 ; .b
  35. obAngle:                    equ $26 ; .b.w
  36. obSubtype:              equ $28 ; .b.w
  37.  
  38. ; Dynamic object variables
  39. obDPLC_Address:         equ $2A ; .l
  40. obArt_Address:          equ $2E ; .l
  41. obVRAM_Art:         equ $32 ; .w
  42. obLastLoadedDPLC:       equ $34 ; .b
  43. obLoadShield:           equ $35 ; .b
  44. obSaveShield:               equ $36 ; .w
  45. ;obNull                 equ $38 ; .w
  46. ;obNull                 equ $3A ; .w
  47. ;obNull                 equ $3C ; .w
  48. ;obNull                     equ $3E ; .w
  49. ; ---------------------------------------------------------------------------
  50.  
  51. ; Player Status Variables
  52. Status_Facing:          equ 0
  53. Status_InAir:               equ 1
  54. Status_Roll:                equ 2
  55. Status_OnObj:           equ 3
  56. Status_RollJump:            equ 4
  57. Status_Push:                equ 5
  58. Status_Underwater:      equ 6
  59. ; ---------------------------------------------------------------------------
  60.  
  61. ; Player status_secondary variables
  62. Status_Shield:          equ 0
  63. Status_Invincible:          equ 1
  64. Status_BlueShield:      equ 2
  65.  
  66. Status_FireShield:          equ 4
  67. Status_LtngShield:      equ 5
  68. Status_BublShield:      equ 6
  69. ; ---------------------------------------------------------------------------
  70.  
  71. ; Sonic/objects variables
  72. status_secondary:           equ $2B ; Sonic
  73. double_jump_flag:       equ $2F ; Sonic
  74. shield_reaction:            equ $2F ; Objects   ; bit 3 = bounces off shield, bit 4 = negated by fire shield, bit 5 = negated by lightning shield, bit 6 = negated by bubble shield
  75. ; ---------------------------------------------------------------------------
  76.  
  77. ; RAM
  78. v_Shield:               equ $FFFFD180   ; pointer
  79. v_player:                   equ $FFFFD000   ; main character
  80. v_tracksonic:               equ $FFFFCB00
  81. v_trackpos:             equ $FFFFF7A8
  82. v_pal_water_dup:            equ $FFFFFA00
  83. v_pal_water:                equ $FFFFFA80
  84. H_scroll_frame_offset:      equ $FFFFFF94   ; w
  85. ; ---------------------------------------------------------------------------
  86.  
  87. ; Macros
  88. offsetTable macro *
  89. \* EQU *
  90. current_offset_table = \*
  91.     endm
  92. offsetTableEntry macro ptr
  93.     dc.\0 ptr-current_offset_table
  94.     endm
  95.  
  96. ; =============== S U B R O U T I N E =======================================
  97.  
  98. Obj_LoadShield:
  99.         lea (v_player).w,a2
  100.         moveq   #0,d0
  101.         move.b  obRoutine(a0),d0
  102.         move.w  LoadShield_Index(pc,d0.w),d0
  103.         jmp LoadShield_Index(pc,d0.w)
  104. ; ---------------------------------------------------------------------------
  105.  
  106. LoadShield_Index: offsetTable
  107.         offsetTableEntry.w LoadShield_Init                              ; 0
  108. LoadInstaShield_Index
  109.         offsetTableEntry.w Obj_InstaShield_Main                     ; 2
  110. LoadInvincibility_Index
  111.         offsetTableEntry.w Obj_Invincibility_Init                           ; 4
  112.         offsetTableEntry.w Obj_Invincibility_Main                       ; 6
  113. LoadInvincibility2_Index
  114.         offsetTableEntry.w Obj_Invincibility_Main2                      ; 8
  115. LoadBlueShield_Index
  116.         offsetTableEntry.w Obj_BlueShield_Main                          ; A
  117. LoadFireShield_Index
  118.         offsetTableEntry.w Obj_FireShield_Main                          ; C
  119. LoadFireShield_Dissipate_Index
  120.         offsetTableEntry.w Obj_FireShield_Dissipate                     ; E
  121.         offsetTableEntry.w Obj_FireShield_Dissipate_Main                ; 10
  122. LoadLightningShield_Index
  123.         offsetTableEntry.w Obj_LightningShield_LoadArt                  ; 12
  124.         offsetTableEntry.w Obj_LightningShield_Main                 ; 14
  125.         offsetTableEntry.w Obj_LightningShield_DestroyUnderwater2       ; 16
  126. LoadLightningShield_Spark_Index
  127.         offsetTableEntry.w Obj_LightningShield_Spark                    ; 18
  128.         offsetTableEntry.w Obj_LightningShield_Spark_Delete             ; 1A
  129. LoadBubbleShield_Index
  130.         offsetTableEntry.w Obj_BubbleShield_ResetAir                    ; 1C
  131.         offsetTableEntry.w Obj_BubbleShield_Main                        ; 1E
  132. ; ---------------------------------------------------------------------------
  133.  
  134. LoadShield_DataIndex: offsetTable
  135.         offsetTableEntry.w InstaShield_DataIndex                        ; 0
  136.         offsetTableEntry.w Invincibility_DataIndex                      ; 2
  137.         offsetTableEntry.w BlueShield_DataIndex                         ; 4
  138.         offsetTableEntry.w InstaShield_DataIndex                        ; 6
  139.         offsetTableEntry.w FireShield_DataIndex                         ; 8
  140.         offsetTableEntry.w LightningShield_DataIndex                    ; A
  141.         offsetTableEntry.w BubbleShield_DataIndex                       ; C
  142. InstaShield_DataIndex:
  143.         dc.l Map_InstaShield,DPLC_InstaShield,(LoadInstaShield_Index-LoadShield_Index)<<24|ArtUnc_InstaShield
  144. Invincibility_DataIndex:
  145.         dc.l Map_Invincibility,0,(LoadInvincibility_Index-LoadShield_Index)<<24
  146. BlueShield_DataIndex:
  147.         dc.l Map_BlueShield,DPLC_BlueShield,(LoadBlueShield_Index-LoadShield_Index)<<24|ArtUnc_BlueShield
  148. FireShield_DataIndex:
  149.         dc.l Map_FireShield,DPLC_FireShield,(LoadFireShield_Index-LoadShield_Index)<<24|ArtUnc_FireShield
  150. LightningShield_DataIndex:
  151.         dc.l Map_LightningShield,DPLC_LightningShield,(LoadLightningShield_Index-LoadShield_Index)<<24|ArtUnc_LightningShield
  152. BubbleShield_DataIndex:
  153.         dc.l Map_BubbleShield,DPLC_BubbleShield,(LoadBubbleShield_Index-LoadShield_Index)<<24|ArtUnc_BubbleShield
  154. ; ---------------------------------------------------------------------------
  155.  
  156. LoadShield_Init:
  157.         move.b  obLoadShield(a0),d0
  158.         add.w   d0,d0
  159.         move.w  #obVRAM_Shields,obGfx(a0)                           ; Set VRAM
  160.         move.w  #obVRAM_Shields*$20,obVRAM_Art(a0)              ; Set VRAM*20
  161.         lea LoadShield_DataIndex(pc),a1
  162.         adda.w  (a1,d0.w),a1                                            ; Get address
  163.         move.l  (a1)+,obMap(a0)                                     ; Set current mapping
  164.         move.l  (a1)+,obDPLC_Address(a0)                                ; Set current DPLC mapping
  165.         move.b  (a1),obRoutine(a0)                                  ; Set current object routine
  166.         move.l  (a1)+,d0                                                ; Get uncompressed art address ; XXFFFFFF - XX routine, FFFFFF - Art address
  167.         andi.l  #$FFFFFF,d0                                         ; Fix XXFFFFFF to 00FFFFFF
  168.         move.l  d0,obArt_Address(a0)                                    ; Set current uncompressed art address
  169.         move.b  #4,obRender(a0)
  170.         move.b  #1,obPriority(a0)
  171.         move.b  #$18,obWidth(a0)
  172.         move.b  #$18,obActWid(a0)
  173.         move.b  #$18,obHeight(a0)
  174.         btst    #7,(v_player+obGfx).w
  175.         beq.s   @3
  176.         bset    #7,obGfx(a0)
  177. @3      move.w  #1,obAnim(a0)
  178.         move.b  #-1,obLastLoadedDPLC(a0)
  179.  
  180. LoadShield_Locret:
  181.         rts
  182.  
  183. ; =============== S U B R O U T I N E =======================================
  184.  
  185. Obj_InstaShield_Main:
  186.         btst    #Status_Invincible,status_secondary(a2)                     ; first, does Sonic have invincibility?
  187.         bne.s   LoadShield_Locret                                   ; If so, return
  188.         move.w  obX(a2),obX(a0)                                     ; Inherit player's obX
  189.         move.w  obY(a2),obY(a0)                                     ; Inherit player's obY
  190.         move.b  obStatus(a2),obStatus(a0)                               ; Inherit status
  191.         andi.b  #1,obStatus(a0)                                     ; Limit inheritance to 'orientation' bit
  192.         andi.w  #$7FFF,obGfx(a0)
  193.         tst.w   obGfx(a2)
  194.         bpl.s   @1
  195.         ori.w   #$8000,obGfx(a0)
  196. @1      lea (Ani_InstaShield).l,a1
  197.         jsr (AnimateSprite).l
  198.         cmpi.b  #7,obFrame(a0)                                      ; Has it reached then end of its animation?
  199.         bne.s   @2                                                  ; If not, branch
  200.         tst.b   double_jump_flag(a2)                                        ; Is it in its attacking state?
  201.         beq.s   @2                                                  ; If not, branch
  202.         move.b  #2,double_jump_flag(a2)                             ; Mark attack as over
  203. @2      tst.b   obFrame(a0)                                             ; Is this the first frame?
  204.         beq.s   @3                                                  ; If so, branch and load the DPLC for this and the next few frames
  205.         cmpi.b  #3,obFrame(a0)                                      ; Is this the third frame?
  206.         bne.s   @4                                                  ; If not, branch as we don't need to load another DPLC yet
  207. @3      bsr.w   PLCLoad_Shields
  208. @4      jmp (DisplaySprite).l
  209.  
  210. ; =============== S U B R O U T I N E =======================================
  211.  
  212. Obj_Invincibility_Init:
  213.         addq.b  #2,obRoutine(a0)
  214.         move.l  #ArtUnc_Invincibility,d1                                ; Load art source
  215.         move.w  #obVRAM_Shields*$20,d2                              ; Load art destination
  216.         move.w  #(ArtUnc_Invincibility_end-ArtUnc_Invincibility)/2,d3       ; Size of art (in words)
  217.         jsr (QueueDMATransfer).l
  218.         movea.l a0,a1
  219.         moveq   #0,d1
  220.         move.b  d1,obAnim(a0)
  221.         moveq   #3-1,d0
  222.  
  223. @loop   lea $40(a1),a1
  224.         move.b  #obSlot_Shields,(a1)
  225.         move.l  obMap(a0),obMap(a1)
  226.         move.w  obGfx(a0),obGfx(a1)
  227.         move.b  obRender(a0),obRender(a1)
  228.         move.b  obPriority(a0),obPriority(a1)
  229.         move.b  obWidth(a0),obWidth(a1)
  230.         move.b  obActWid(a0),obActWid(a1)
  231.         move.b  obHeight(a0),obHeight(a1)
  232.         move.b  #(LoadInvincibility2_Index-LoadShield_Index),obRoutine(a1)
  233.         addq.w  #1,d1
  234.         move.b  d1,obAnim(a1)
  235.         dbf d0,@loop
  236.  
  237. Obj_Invincibility_Main:
  238.         btst    #Status_Invincible,status_secondary(a2)                     ; first, does Sonic have invincibility?
  239.         bne.s   Obj_Invincibility_CopyPos                               ; if yes, branch
  240.         move.b  obSaveShield(a0),obLoadShield(a0)
  241.         bra.w   Obj_Shield_Destroy3
  242. ; ---------------------------------------------------------------------------
  243.  
  244. Obj_Invincibility_Main2:
  245.         btst    #Status_Invincible,status_secondary(a2)                     ; first, does Sonic have invincibility?
  246.         beq.w   Obj_LightningShield_Spark_Delete                        ; if not, branch
  247.  
  248. Obj_Invincibility_CopyPos:
  249.         move.w  (v_trackpos).w,d0
  250.         move.b  obAnim(a0),d1
  251.         lsl.b   #3,d1
  252.         move.b  d1,d2
  253.         add.b   d1,d1
  254.         add.b   d2,d1
  255.         addq.b  #4,d1
  256.         sub.b   d1,d0
  257.         move.b  $37(a0),d1
  258.         sub.b   d1,d0
  259.         addq.b  #4,d1
  260.         cmpi.b  #$18,d1
  261.         bcs.s   @1
  262.         moveq   #0,d1
  263. @1      move.b  d1,$37(a0)
  264.         lea (v_tracksonic).w,a1
  265.         lea (a1,d0.w),a1
  266.         move.w  (a1)+,obX(a0)
  267.         move.w  (a1)+,obY(a0)
  268.         move.b  (v_player+obStatus).w,obStatus(a0)
  269.         lea (Ani_Invincibility).l,a1
  270.         jsr (AnimateSprite).l
  271.         jmp (DisplaySprite).l
  272.  
  273. ; =============== S U B R O U T I N E =======================================
  274.  
  275. Obj_BlueShield_Main:
  276.         btst    #Status_Invincible,status_secondary(a2)                     ; first, does Sonic have invincibility?
  277.         bne.w   LoadShield_Locret                                   ; If so, return
  278.         btst    #Status_Shield,status_secondary(a2)                         ; Should the player still have a shield?
  279.         beq.w   Obj_Shield_Destroy                                  ; If not, change to Insta-Shield
  280.         move.w  obX(a2),obX(a0)
  281.         move.w  obY(a2),obY(a0)
  282.         move.b  obStatus(a2),obStatus(a0)                               ; Inherit status
  283.         andi.b  #1,obStatus(a0)                                     ; Limit inheritance to 'orientation' bit
  284.         andi.w  #$7FFF,obGfx(a0)
  285.         tst.w   obGfx(a2)
  286.         bpl.s   @1
  287.         ori.w   #$8000,obGfx(a0)
  288. @1      lea (Ani_BlueShield).l,a1
  289.         jsr (AnimateSprite).l
  290.         bsr.w   PLCLoad_Shields
  291.         jmp (DisplaySprite).l
  292.  
  293. ; =============== S U B R O U T I N E =======================================
  294.  
  295. Obj_FireShield_Main:
  296.         btst    #Status_Invincible,status_secondary(a2)                     ; first, does Sonic have invincibility?
  297.         bne.w   LoadShield_Locret                                   ; If so, return
  298.         cmpi.b  #$1C,obAnim(a2)                                     ; Is player in their 'blank' animation?
  299.         beq.w   LoadShield_Locret                                   ; If so, do not display and do not update variables
  300.         btst    #Status_Shield,status_secondary(a2)                         ; Should the player still have a shield?
  301.         beq.s   Obj_Shield_Destroy                                  ; If not, change to Insta-Shield
  302.         btst    #Status_Underwater,obStatus(a2)                         ; Is player underwater?
  303.         bne.s   Obj_FireShield_DestroyUnderwater                        ; If so, branch
  304.         move.w  obX(a2),obX(a0)
  305.         move.w  obY(a2),obY(a0)
  306.         tst.b   obAnim(a0)                                              ; Is shield in its 'dashing' state?
  307.         bne.s   @1                                                  ; If so, do not update orientation or allow changing of the priority obGfx bit
  308.         move.b  obStatus(a2),obStatus(a0)                               ; Inherit status
  309.         andi.b  #1,obStatus(a0)                                     ; Limit inheritance to 'orientation' bit
  310.         andi.w  #$7FFF,obGfx(a0)
  311.         tst.w   obGfx(a2)
  312.         bpl.s   @1
  313.         ori.w   #$8000,obGfx(a0)
  314. @1      lea (Ani_FireShield).l,a1
  315.         jsr (AnimateSprite).l
  316.         move.b  #1,obPriority(a0)                                       ; Layer shield over player sprite
  317.         cmpi.b  #$F,obFrame(a0)                                     ; Are these the frames that display in front of the player?
  318.         blo.s       @2                                                  ; If so, branch
  319.         move.b  #4,obPriority(a0)                                       ; If not, layer shield behind player sprite
  320. @2      bsr.w   PLCLoad_Shields
  321.         jmp (DisplaySprite).l
  322. ; ---------------------------------------------------------------------------
  323.  
  324. Obj_Shield_Destroy:
  325.         andi.b  #$8E,status_secondary(a2)                               ; Sets Status_Shield, Status_FireShield, Status_LtngShield, and Status_BublShield to 0
  326.  
  327. Obj_Shield_Destroy2:
  328.         clr.b   obLoadShield(a0)
  329.  
  330. Obj_Shield_Destroy3:
  331.         clr.b   obRoutine(a0)
  332.  
  333. Obj_FireShield_Destroy_Locret:
  334.         rts
  335. ; ---------------------------------------------------------------------------
  336.  
  337. Obj_FireShield_DestroyUnderwater:
  338.         andi.b  #$8E,status_secondary(a2)                               ; Sets Status_Shield, Status_FireShield, Status_LtngShield, and Status_BublShield to 0
  339.         jsr (SingleObjLoad).l                                           ; Set up for a new object
  340.         bne.s   @1                                                  ; If that can't happen, branch
  341.         move.b  #obSlot_Shields,(a1)                                    ; Create dissipate object
  342.         move.b  #(LoadFireShield_Dissipate_Index-LoadShield_Index),obRoutine(a1)
  343.         move.w  obX(a0),obX(a1)                                     ; Put it at shields' x_pos
  344.         move.w  obY(a0),obY(a1)                                     ; Put it at shields' y_pos
  345. @1      bra.s   Obj_Shield_Destroy
  346.  
  347. ; =============== S U B R O U T I N E =======================================
  348.  
  349. Obj_LightningShield_LoadArt:
  350.         addq.b  #2,obRoutine(a0)
  351.         move.l  #ArtUnc_Obj_Lightning_Shield_Sparks,d1              ; Load art source
  352.         move.w  #obVRAM_LightningShields_Spark,d2                   ; Load art destination
  353.         move.w  #(ArtUnc_Obj_Lightning_Shield_Sparks_end-ArtUnc_Obj_Lightning_Shield_Sparks)/2,d3   ; Size of art (in words)
  354.         jsr (QueueDMATransfer).l
  355.  
  356. Obj_LightningShield_Main:
  357.         btst    #Status_Invincible,status_secondary(a2)                     ; first, does Sonic have invincibility?
  358.         bne.s   Obj_FireShield_Destroy_Locret                           ; If so, return
  359.         cmpi.b  #$1C,obAnim(a2)                                     ; Is player in their 'blank' animation?
  360.         beq.s   Obj_FireShield_Destroy_Locret                           ; If so, do not display and do not update variables
  361.         btst    #Status_Shield,status_secondary(a2)                         ; Should the player still have a shield?
  362.         beq.s   Obj_Shield_Destroy                                  ; If not, change to Insta-Shield
  363.         btst    #Status_Underwater,obStatus(a2)                         ; Is player underwater?
  364.         bne.s   Obj_LightningShield_DestroyUnderwater                   ; If so, branch
  365.         move.w  obX(a2),obX(a0)
  366.         move.w  obY(a2),obY(a0)
  367.         move.b  obStatus(a2),obStatus(a0)                               ; Inherit status
  368.         andi.b  #1,obStatus(a0)                                     ; Limit inheritance to 'orientation' bit
  369.         andi.w  #$7FFF,obGfx(a0)
  370.         tst.w   obGfx(a2)
  371.         bpl.s   @1
  372.         ori.w   #$8000,obGfx(a0)
  373. @1      tst.b   obAnim(a0)                                              ; Is shield in its 'double jump' state?
  374.         beq.s   @2                                                  ; Is not, branch and display
  375.         bsr.w   Obj_LightningShield_Create_Spark                        ; Create sparks
  376.         clr.b   obAnim(a0)                                              ; Once done, return to non-'double jump' state
  377. @2      lea (Ani_LightningShield).l,a1
  378.         jsr (AnimateSprite).l
  379.         move.b  #1,obPriority(a0)                                       ; Layer shield over player sprite
  380.         cmpi.b  #$E,obFrame(a0)                                     ; Are these the frames that display in front of the player?
  381.         blo.s       @3                                                  ; If so, branch
  382.         move.b  #4,obPriority(a0)                                       ; If not, layer shield behind player sprite
  383. @3      bsr.w   PLCLoad_Shields
  384.         jmp (DisplaySprite).l
  385.  
  386. ; =============== S U B R O U T I N E =======================================
  387.  
  388. Obj_LightningShield_DestroyUnderwater:
  389.         addq.b  #2,obRoutine(a0)
  390.         andi.b  #$8E,status_secondary(a2)                               ; Sets Status_Shield, Status_FireShield, Status_LtngShield, and Status_BublShield to 0
  391.  
  392.         ; Flashes the underwater palette white
  393.         lea (v_pal_water).w,a1
  394.         lea (v_pal_water_dup).w,a2
  395.         move.w  #($80/4)-1,d0                                       ; Size of Water_palette/4-1
  396.  
  397. @loop   move.l  (a1),(a2)+                                          ; Backup palette entries
  398.         move.l  #$0EEE0EEE,(a1)+                                    ; Overwrite palette entries with white
  399.         dbf d0,@loop                                                ; Loop until entire thing is overwritten
  400.  
  401.         move.w  #0,-64(a1)                                          ; Set the first colour in the third palette line to black
  402.         move.b  #3,obAniFrame(a0)
  403.         rts
  404. ; ---------------------------------------------------------------------------
  405.  
  406. Obj_LightningShield_DestroyUnderwater2:
  407.         subq.b  #1,obAniFrame(a0)                                   ; Is it time to end the white flash?
  408.         bpl.s   locret_198BC                                            ; If not, return
  409.         bsr.w   Obj_Shield_Destroy2                                 ; Replace the Lightning Shield with the Insta-Shield
  410.         lea (v_pal_water_dup).w,a1
  411.         lea (v_pal_water).w,a2
  412.         move.w  #($80/4)-1,d0                                       ; Size of Water_palette/4-1
  413.  
  414. @loop   move.l  (a1)+,(a2)+                                         ; Restore backed-up underwater palette
  415.         dbf d0,@loop                                                ; Loop until entire thing is restored
  416.  
  417. locret_198BC:
  418.         rts
  419. ; ---------------------------------------------------------------------------
  420.  
  421. SparkVelocities:
  422.         dc.w -$200, -$200
  423.         dc.w $200, -$200
  424.         dc.w -$200, $200
  425.         dc.w $200, $200
  426.  
  427. ; =============== S U B R O U T I N E =======================================
  428.  
  429. Obj_LightningShield_Create_Spark:
  430.         lea SparkVelocities(pc),a2
  431.         moveq   #4-1,d1
  432.  
  433. @loop   jsr (SingleObjLoad).l                                           ; Find free object slot
  434.         bne.s   Obj_LightningShield_Create_Spark_Locret             ; If one can't be found, return
  435.         move.b  #obSlot_Shields,(a1)                                    ; Make new object a Spark
  436.         move.b  #(LoadLightningShield_Spark_Index-LoadShield_Index),obRoutine(a1)
  437.         move.w  obX(a0),obX(a1)                                     ; (Spark) Inherit obX from source object (Lightning Shield, Hyper Sonic Stars)
  438.         move.w  obY(a0),obY(a1)                                     ; (Spark) Inherit obY from source object (Lightning Shield, Hyper Sonic Stars)
  439.         move.l  obMap(a0),obMap(a1)                                 ; (Spark) Inherit obMap from source object (Lightning Shield, Hyper Sonic Stars)
  440.         move.w  obGfx(a0),obGfx(a1)                                 ; (Spark) Inherit obGfx from source object (Lightning Shield, Hyper Sonic Stars)
  441.         move.b  #4,obRender(a1)
  442.         move.b  #1,obPriority(a1)
  443.         move.b  #8,obWidth(a1)
  444.         move.b  #8,obActWid(a1)
  445.         move.b  #8,obHeight(a1)
  446.         move.b  #1,obAnim(a1)
  447.         move.l  (a2)+,obVelX(a1)                                        ; (Spark) Give xy_vel (unique to each of the four Sparks)
  448.         dbf d1,@loop
  449.  
  450. Obj_LightningShield_Create_Spark_Locret:
  451.         rts
  452.  
  453. ; =============== S U B R O U T I N E =======================================
  454.  
  455. Obj_LightningShield_Spark:
  456.         jsr (SpeedToPos).l
  457.         addi.w  #$18,obVelY(a0)
  458.         lea (Ani_LightningShield).l,a1
  459.         jsr (AnimateSprite).l
  460.         jmp (DisplaySprite).l
  461. ; ---------------------------------------------------------------------------
  462.  
  463. Obj_LightningShield_Spark_Delete:
  464.         jmp (DeleteObject).l
  465.  
  466. ; =============== S U B R O U T I N E =======================================
  467.  
  468. Obj_BubbleShield_ResetAir:
  469.         addq.b  #2,obRoutine(a0)
  470.         jsr (ResumeMusic).l                                         ; Reset air remaining
  471.  
  472. Obj_BubbleShield_Main:
  473.         btst    #Status_Invincible,status_secondary(a2)                     ; first, does Sonic have invincibility?
  474.         bne.s   Obj_LightningShield_Create_Spark_Locret             ; If so, return
  475.         cmpi.b  #$1C,obAnim(a2)                                     ; Is player in their 'blank' animation?
  476.         beq.s   Obj_LightningShield_Create_Spark_Locret             ; If so, do not display and do not update variables
  477.         btst    #Status_Shield,status_secondary(a2)                         ; Should the player still have a shield?
  478.         beq.w   Obj_Shield_Destroy                                  ; If not, change to Insta-Shield
  479.         move.w  obX(a2),obX(a0)
  480.         move.w  obY(a2),obY(a0)
  481.         move.b  obStatus(a2),obStatus(a0)                               ; Inherit status
  482.         andi.b  #1,obStatus(a0)                                     ; Limit inheritance to 'orientation' bit
  483.         andi.w  #$7FFF,obGfx(a0)
  484.         tst.w   obGfx(a2)
  485.         bpl.s   @1
  486.         ori.w   #$8000,obGfx(a0)
  487. @1      lea (Ani_BubbleShield).l,a1
  488.         jsr (AnimateSprite).l
  489.         bsr.s   PLCLoad_Shields
  490.         jmp (DisplaySprite).l
  491.  
  492. ; =============== S U B R O U T I N E =======================================
  493.  
  494. Obj_FireShield_Dissipate:
  495.         addq.b  #2,obRoutine(a0)
  496.         move.l  #Map_obj27,obMap(a0)
  497.         move.w  #$5A0,obGfx(a0)
  498.         move.b  #4,obRender(a0)
  499.         move.b  #5,obPriority(a0)
  500.         move.b  #$C,obHeight(a0)
  501.         move.b  #$C,obWidth(a0)
  502.         move.b  #$C,obActWid(a0)
  503.         move.b  #3,obTimeFrame(a0)
  504.         move.b  #1,obFrame(a0)
  505.  
  506. Obj_FireShield_Dissipate_Main:
  507.         jsr (SpeedToPos).l
  508.         subq.b  #1,obTimeFrame(a0)
  509.         bpl.s   @1
  510.         move.b  #3,obTimeFrame(a0)
  511.         addq.b  #1,obFrame(a0)
  512.         cmpi.b  #5,obFrame(a0)
  513.         beq.w   Obj_LightningShield_Spark_Delete
  514. @1      jmp (DisplaySprite).l
  515.  
  516. ; =============== S U B R O U T I N E =======================================
  517.  
  518. PLCLoad_Shields:
  519.         moveq   #0,d0
  520.         move.b  obFrame(a0),d0
  521.         cmp.b   obLastLoadedDPLC(a0),d0
  522.         beq.s   PLCLoad_Shields_Locret
  523.         move.b  d0,obLastLoadedDPLC(a0)
  524.         movea.l obDPLC_Address(a0),a2
  525.         add.w   d0,d0
  526.         adda.w  (a2,d0.w),a2
  527.         move.w  (a2)+,d5
  528.         subq.w  #1,d5
  529.         bmi.s   PLCLoad_Shields_Locret
  530.         move.w  obVRAM_Art(a0),d4
  531.  
  532. PLCLoad_Shields_ReadEntry:
  533.         moveq   #0,d1
  534.         move.w  (a2)+,d1
  535.         move.w  d1,d3
  536.         lsr.w   #8,d3
  537.         andi.w  #$F0,d3
  538.         addi.w  #$10,d3
  539.         andi.w  #$FFF,d1
  540.         lsl.l   #5,d1
  541.         add.l   obArt_Address(a0),d1
  542.         move.w  d4,d2
  543.         add.w   d3,d4
  544.         add.w   d3,d4
  545.         jsr (QueueDMATransfer).l
  546.         dbf d5,PLCLoad_Shields_ReadEntry
  547.  
  548. PLCLoad_Shields_Locret:
  549.         rts
  550.  
  551. ; =============== S U B R O U T I N E =======================================
  552.  
  553. Reset_Player_Position_Array:
  554.         lea (v_tracksonic).w,a1
  555.         move.w  #$3F,d0
  556. @1      move.w  obX(a0),(a1)+
  557.         move.w  obY(a0),(a1)+
  558.         dbf d0,@1
  559.         move.w  #0,(v_trackpos).w
  560.         rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement