Advertisement
Erik557

optimization ii/ii

Nov 10th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Block500:
  2.  
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4. ;;Sprite Morph v2 (For Manual Custom Block Inserter)
  5. ;;By Erik557
  6. ;;Description: Turns a sprite into another one.
  7. ;;It has configurable settings.
  8. ;;NOTE: Needs NMSTL
  9. ;;DESIGNED FOR SA-1
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. ;BlockXXX:
  12.  
  13. !MorphType = 0      ;Explained below
  14.  
  15.                     ;If morph type is 0:
  16. !SpriteType = 0     ;0 = Normal; 1 = Custom
  17.                     ;
  18.                     ;If morph type is 1:
  19.                     ;0 = Normal to custom; 1 = Custom to normal
  20.  
  21.  
  22. !SprNum = $0A       ;Sprite number
  23. !SprMorph = $15     ;Morph Result
  24.  
  25.  
  26. !Sound = $10        ;SFX
  27. !SFXBank = $7DF9    ;SFX Bank
  28.  
  29. ;Don't touch these.
  30.  
  31. !Slots = 22         ;Sprite Slots
  32. !Status = $3242
  33. !Extra = $400040
  34.  
  35.  
  36. if !SpriteType == 1
  37.     !SprRAM = $400083
  38. else
  39.     !SprRAM = $3200
  40. endif
  41.  
  42.  
  43. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  44.  
  45. .SpriteVert
  46. .SpriteHoriz
  47.     LDA !SprRAM,x           ;\
  48.     CMP #!SprNum            ; | Check if the correct sprite is stteping into the block
  49.     BNE Ret                 ;/
  50.  
  51.     LDA !Status,x           ;\
  52.     CMP #$08                ; | We don't want a dead sprite to be morphed, do we?
  53.     BCC Ret                 ;/
  54.  
  55.     LDA !Extra,x            ;\
  56.     AND #$08                ; |
  57. if !SpriteType == 1         ; |
  58.     BEQ Ret                 ; | Check for correct sprite type
  59. else                        ; |
  60.     BNE Ret                 ; |
  61. endif                       ;/
  62.  
  63. .PlayerBelow
  64. .PlayerAbove
  65. .PlayerSides
  66. .PlayerTopCorner
  67. .PlayerBodyInside
  68. .PlayerHeadInside
  69. .CapeTouch
  70. .FireballTouch
  71. Ret:
  72.     RTL
  73.  
  74. MorphIt:
  75.     STZ !Status,x
  76.  
  77.     LDA #!Sound
  78.     STA !SFXBank
  79.  
  80.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  81.     ;;Manual Spawn Routine
  82.     ;;Adapted from %spawn_sprite() GPS routine.
  83.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  84.         PHX                     ; Preserve X
  85.         LDX #!Slots-1           ;\
  86.     -   LDA !Status,x           ; |
  87.         BEQ .yes                ; |Check for open slots
  88.         DEX                     ; |
  89.         BPL -                   ; |
  90.         BRA .no                 ;/ Return if no slots open
  91. .yes    LDA #!SprMorph          ;\ Spawn sprite
  92.         STA !SprRAM,x           ;/
  93.         JSL $07F7D2             ;\ Reset sprite tables
  94.         if !SpriteType == 1     ; |
  95.             JSL $0187A7         ;/ Custom ones too
  96.             LDA #$08            ;\ Set extra bits
  97.             STA !Extra,x        ;/
  98.         endif                  
  99.         LDA #$01                ;\  Set status to alive
  100.         STA !Status,x           ;/
  101.         TXA                    
  102.         PLX                     ; Restore X
  103.  
  104.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  105.     ;;Fix sprite position
  106.     ;;Adapted from %move_spawn_to_sprite() GPS routine.
  107.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  108.         PHY
  109.         TAY
  110.         LDA $3216,x
  111.         STA $3216,y
  112.         LDA $3258,x
  113.         STA $3258,y
  114.         LDA $322C,x
  115.         STA $322C,y
  116.         LDA $326E,x
  117.         STA $326E,y
  118.         PLY
  119.  
  120.  
  121.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122.     ;;Smoke Routine
  123.     ;;Adapted from %create_smoke() GPS routine.
  124.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  125.         PHX                     ; Preserve X
  126.         PHP                     ; Preserve processor status/flags
  127.         SEP #$30                ; Set processor 8-bit mode
  128.         LDX #$03                ;\
  129. .loop   LDA $77C0,x             ; | Check for smoke sprite number
  130.         BNE .next               ;/
  131.  
  132.         INC $77C0,x             ; Increase sprite number
  133.         LDA #$1B                ;\ Set smoke timer
  134.         STA $77CC,x             ;/
  135.  
  136.         LDA $3216               ;\
  137.         AND #$F0                ; | Set Y-Pos
  138.         STA $77C4,x             ;/
  139.         LDA $322C               ;\
  140.         AND #$F0                ; | Set X-Pos
  141.         STA $77C8,x             ;/
  142.         BRA .ret
  143.  
  144. .next   DEX                     ;\ Check next slot
  145.         BPL .loop               ;/
  146.  
  147. .ret    PLP                     ; Restore processor status/flags
  148. .no     PLX
  149.         RTL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement