Advertisement
Erik557

Untitled

Dec 28th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;; Foliage the Para-Plant
  3. ;; For Morton's Empire
  4. ;;;;;;;;;;;;;;;;;;;;;;;;;
  5.  
  6.  
  7. ;;; INIT Routine wrapper
  8. print "INIT ",pc
  9.     STZ $C2,x           ; Clear pointers RAM
  10.    
  11.     LDA #$FF            ;\ Set timer
  12.     STA $1540,x         ;/
  13. RTL
  14.  
  15. ;;; Main Routine wrapper
  16. print "MAIN ",pc
  17.     PHB
  18.     PHK
  19.     PLB
  20.     JSR MainRt
  21.     PLB
  22. RTL
  23.  
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  25. ;;Main routine
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27.  
  28. MainRt:
  29.     JSR SubGFX
  30.    
  31.     LDA $14C8,x         ;\ Return if status ain't normal
  32.     CMP #$08            ; |
  33.     BNE Return1         ;/
  34.     LDA $9D             ;\ If sprites locked, return
  35.     BNE Return1         ;/
  36.  
  37.     LDA $C2,x           ;\ Set pointers
  38.     JSL $0086DF         ;/ 
  39.    
  40. ;pointers:
  41.     dw FaceMario        ; State 0: Mario faces the plant in a fght pose
  42.     dw Rise             ; State 1: Rising (fireballs and go up??)
  43.     ;dw CallGenerators  ; tell the shooters to do something?? (maybe i can combine them into 1 state)
  44.     ;dw Hit             ; State 2(3): Hit
  45.     ;dw Angry           ; Hypothetical State 3(4), where it makes another action after X hits
  46.     ;dw Ded             ; State 3/4/5: Dead
  47.  
  48. Return1:
  49.     RTS
  50. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  51. ;;State 0: Facing Mario
  52. FaceMario:
  53. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  54.  
  55. YSpd:       db $FA,$F0
  56.  
  57.     LDA $19             ;\ Preserve powerup
  58.     PHA                 ;/
  59.  
  60.     LDA $1540,x         ;\ Return if facing time is over
  61.     BEQ .over           ;/
  62.  
  63.     LDA #$01            ;\ Temporarily store powerup
  64.     STA $19             ;/
  65.  
  66. .loop
  67.     STZ $7B             ;\ Lock player
  68.     STZ $7D             ;/
  69.  
  70.     LDA #$32            ;\ Set the player pose
  71.     STA $13E0           ;/
  72.  
  73.     LDA YSpd            ;\ Set slow Y speed
  74.     STA $AA,x           ;/
  75.     JSL $01802A
  76.  
  77.     LDA $1540,x
  78.     BPL .loop
  79.  
  80.     LDA YSpd            ;\ Set fast Y speed
  81.     INX                 ; |
  82.     STA $AA,x           ;/
  83.     JSL $01802A
  84.    
  85.     PLA                 ;\ Restore powerup
  86.     STA $19             ;/
  87.  
  88. .over
  89.     INC $C2,x           ; Continue
  90.     RTS
  91. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  92. ;;State 1: Rising
  93. Rise:
  94. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  95.    
  96.     RTS
  97.    
  98. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  99. ;;Graphics routine
  100. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  101.  
  102. SubGFX:
  103.     JSR GetDrawInfo
  104.  
  105.     LDA $00             ; set x position of the tile
  106.     STA $0300,y
  107.  
  108.     LDA $01             ; set y position of the tile
  109.     STA $0301,y
  110.  
  111.     LDA #$00
  112.     STA $0302,y
  113.  
  114.     LDA $15F6,x         ; get sprite palette info
  115.     ORA $64             ; add in the priority bits from the level settings
  116.     STA $0303,y         ; set properties
  117.  
  118.     LDY #$02            ; #$02 means the tiles are 16x16
  119.     LDA #$00            ; This means we drew one tile
  120.     JSL $01B7B3
  121.     RTS
  122.  
  123.  
  124. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  125. ;;Misc routines
  126. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  127.  
  128. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  129. ; $B760 - graphics routine helper - shared
  130. ; sets off screen flags and sets index to OAM
  131. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  132.  
  133.         ;org $03B75C
  134.  
  135. TABLE1:              db $0C,$1C
  136. TABLE2:              db $01,$02
  137.  
  138. GetDrawInfo:       STZ $186C,x             ; reset sprite offscreen flag, vertical
  139.         STZ $15A0,x             ; reset sprite offscreen flag, horizontal
  140.         LDA $E4,x               ; \
  141.         CMP $1A                 ;  | set horizontal offscreen if necessary
  142.         LDA $14E0,x             ;  |
  143.         SBC $1B                 ;  |
  144.         BEQ ON_SCREEN_X         ;  |
  145.         INC $15A0,x             ; /
  146.  
  147. ON_SCREEN_X:         LDA $14E0,x             ; \
  148.         XBA      ;  |
  149.         LDA $E4,x               ;  |
  150.         REP #$20                ;  |
  151.         SEC      ;  |
  152.         SBC $1A                 ;  | mark sprite INVALID if far enough off screen
  153.         CLC      ;  |
  154.         ADC.w #$0040            ;  |
  155.         CMP.w #$0180            ;  |
  156.         SEP #$20                ;  |
  157.         ROL A                   ;  |
  158.         AND #$01                ;  |
  159.         STA $15C4,x             ; /
  160.         BNE INVALID             ;
  161.        
  162.         LDY #$00                ; \ set up LOOP:
  163.         LDA $1662,x             ;  |
  164.         AND #$20                ;  | if not smushed (1662 & 0x20), go through LOOP twice
  165.         BEQ ON_SCREEN_LOOP      ;  | else, go through LOOP once
  166.         INY      ; /
  167. ON_SCREEN_LOOP:      LDA $D8,x               ; \
  168.         CLC      ;  | set vertical offscreen if necessary
  169.         ADC TABLE1,y            ;  |
  170.         PHP      ;  |
  171.         CMP $1C                 ;  | (vert screen boundry)
  172.         ROL $00                 ;  |
  173.         PLP      ;  |
  174.         LDA $14D4,x             ;  |
  175.         ADC #$00                ;  |
  176.         LSR $00                 ;  |
  177.         SBC $1D                 ;  |
  178.         BEQ ON_SCREEN_Y         ;  |
  179.         LDA $186C,x             ;  | (vert offscreen)
  180.         ORA TABLE2,y            ;  |
  181.         STA $186C,x             ;  |
  182. ON_SCREEN_Y:         DEY         ;  |
  183.         BPL ON_SCREEN_LOOP      ; /
  184.  
  185.         LDY $15EA,x             ; get offset to sprite OAM
  186.         LDA $E4,x               ; \
  187.         SEC      ;  |
  188.         SBC $1A                 ;  | $00 = sprite x position relative to screen boarder
  189.         STA $00                 ; /
  190.         LDA $D8,x               ; \
  191.         SEC      ;  |
  192.         SBC $1C                 ;  | $01 = sprite y position relative to screen boarder
  193.         STA $01                 ; /
  194.         RTS      ; RETURN
  195.  
  196. INVALID:             PLA         ; \ RETURN from *main gfx routine* subroutine...
  197.         PLA      ;  |    ...(not just this subroutine)
  198.         RTS      ; /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement