Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;=======================================================================================================
- ; This patch installs a custom sprite handler in the unused sprite slots.
- ; To make the sprite work correctly make sure to tweak its priperties as in the CFG file! (with Tweaker)
- ; You can even replace normal sprites with this method, not sure why would you though.
- ;=======================================================================================================
- ; By Erik557
- ;=======================================================================================================
- org $01E2B0 ; In case you're using this for something (you probably aren't), change it to org $01FFBF
- InitCustom:
- JSL InitHandler ; Jumps to the actual INIT handler in the new bank
- RTS
- MainCustom:
- autoclean JSL MainHandler ; Jumps to the actual MAIN handler in the new bank
- RTS
- ;step 2: point to the handlers
- org $0181A1 ;\
- dw InitCustom ; | Sprite 12
- org $0185F0 ; |
- dw MainCustom ;/
- org $0181E9 ;\
- dw InitCustom ; | Sprite 36
- org $018638 ; |
- dw MainCustom ;/
- org $01824F ;\
- dw InitCustom ; | Sprite 69
- org $01869E ; |
- dw MainCustom ;/
- org $018287 ;\
- dw InitCustom ; | Sprite 85
- org $0186D6 ; |
- dw MainCustom ;/
- org $01828D ;\
- dw InitCustom ; | Sprite 88
- org $0186DC ; | (winged cage, uncomment if you plan to use this)
- dw MainCustom ;/
- org $0182A9 ;\
- dw InitCustom ; | Sprite 96
- org $0186F8 ; | (chargin' chuck, but it's a clone)
- dw MainCustom ;/
- freecode
- InitHandler:
- PHB ;\
- PHK ; | Setup data bank
- PLB ;/
- LDA $9E,x ; Pretty shitty code pointer (unlike the Bank 3 handler, this one can't be optimized)
- CMP #$36 ;\ Sprite 36
- BEQ .Sprite36 ;/
- CMP #$69 ;\ Sprite 69
- BEQ .Sprite69 ;/
- CMP #$85 ; and so on...
- BEQ .Sprite85
- CMP #$88 ;\ If you commented sprite 88 in the above code, comment this one too.
- BEQ .Sprite88 ;/
- CMP #$96
- BEQ .Sprite96
- JSR InitSprite12 ; Sprite 12
- .Return
- PLB ; Retrieve data bank
- RTL
- .Sprite36
- JSR InitSprite36
- BRA .Return
- .Sprite69
- JSR InitSprite69
- BRA .Return
- .Sprite85
- JSR InitSprite85
- BRA .Return
- .Sprite88
- JSR InitSprite88
- BRA .Return
- .Sprite96
- JSR InitSprite96
- BRA .Return
- MainHandler:
- PHB ;\
- PHK ; | Setup data bank
- PLB ;/
- LDA $9E,x ; This is the same as the above.
- CMP #$36
- BEQ .Sprite36
- CMP #$69
- BEQ .Sprite69
- CMP #$85
- BEQ .Sprite85
- CMP #$88 ;\ If you commented sprite 88 in the above code, comment this one too.
- BEQ .Sprite88 ;/
- CMP #$96
- BEQ .Sprite96
- JSR MainSprite12
- .Return
- PLB ; Retrieve data bank
- RTL
- .Sprite36
- JSR MainSprite36
- BRA .Return
- .Sprite69
- JSR MainSprite69
- BRA .Return
- .Sprite85
- JSR MainSprite85
- BRA .Return
- .Sprite88
- JSR MainSprite88
- BRA .Return
- .Sprite96
- JSR MainSprite96
- BRA .Return
- incsrc SpriteCode.asm ; This is the actual sprite code file.
- =======================================================================================================================
- ;========================================================================
- ; The sprite code runs here.
- ; You should put the actual sprite code in here.
- ; Shared subroutines can be JSL'd to, I included imamelia's patch for it.
- ;========================================================================
- ; I included an example sprite, a venus fire plant.
- ;========================================================================
- incsrc subroutinedefs.asm
- ; Init sprite routines.
- InitSprite12:
- RTS
- InitSprite36:
- LDA $E4,x
- CLC
- ADC #$08
- STA $E4,x
- DEC $D8,x
- LDA $D8,x
- CMP #$FF
- BNE +
- DEC $14D4,x
- + RTS
- InitSprite69:
- RTS
- InitSprite85:
- RTS
- InitSprite88:
- RTS
- InitSprite96:
- RTS
- ; Main sprite routines.
- MainSprite12:
- RTS
- MainSprite36:
- LDA $1594,x
- BNE .LABEL24
- LDA $64
- PHA
- LDA $15D0,x
- BNE .LABEL23
- LDA #$10
- STA $64
- .LABEL23
- JSR .SUB_GFX
- PLA
- STA $64
- .LABEL24
- JSL !SubOffscreenX3
- LDA $9D
- BNE .RETURN27
- LDA $1594,x
- BNE .LABEL25
- JSL $01803A
- .LABEL25
- JSR SUB_GET_X_DIFF
- JSR SUB_GET_Y_DIFF
- LDA $C2,x
- AND #$03
- TAY
- LDA $1540,x
- BEQ .LABEL28
- PHY
- CPY #$02
- BNE .NO_FIRE
- JSR SUB_FIRE_THROW
- .NO_FIRE
- PLY
- LDA .Y_SPEED,y
- STA $AA,x
- JSL $01801A
- .RETURN27
- RTS
- .LABEL28
- LDA $C2,x
- AND #$03
- STA $00
- BNE .LABEL29
- JSR SUB_HORZ_POS1
- LDA $0F
- CLC
- ADC #$1B
- CMP #$37
- LDA #$01
- STA $1594,x
- BCC .LABEL30
- .LABEL29
- STZ $1594,x
- LDY $00
- LDA .TIME_IN_POS,y
- STA $1540,x
- INC $C2,x
- .LABEL30
- RTS
- .Y_SPEED
- db $00,$F0,$00,$10
- .TIME_IN_POS
- db $20,$68,$20,$48
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; graphics routine
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .TILEMAP
- db $CE,$80,$CE,$80
- .VERT_DISP
- db $10,$00,$10,$00
- .PROPERTIES
- db $08,$08,$08,$88
- .SUB_GFX
- JSL !GetDrawInfo
- LDA $151C,x
- ASL A
- STA $03
- LDA $157C,x
- AND #$01
- STA $02
- PHX
- LDX #$01
- .LOOP_START
- PHX
- TXA
- ORA $03
- PHA
- LDA $00
- STA $0300,y
- PLX
- LDA $01
- CLC
- ADC .VERT_DISP,x
- STA $0301,y
- LDA .TILEMAP,x
- STA $0302,y
- LDA .PROPERTIES,x
- LDX $02
- BNE .NO_FLIP
- ORA #$40
- .NO_FLIP
- ORA #$20
- STA $0303,y
- TYA
- LSR #2
- TAX
- LDA #$02
- STA $0460,x
- PLX
- INY #4
- DEX
- BPL .LOOP_START
- PLX
- LDY #$FF
- LDA #$01
- JSL $01B7B3
- RTS
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; fire spit routine
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- SUB_FIRE_THROW:
- LDA $15A0,x
- ORA $186C,x
- BNE .LABEL6
- .ONE_SHOT
- LDA $1540,x
- CMP #$34
- BEQ .SPIT
- RTS
- .SPIT
- LDY #$E8
- LDA $157C,x
- AND #$01
- BNE .LABEL9
- LDY #$18
- .LABEL9
- STY $00
- LDY #$07
- .LABEL8
- LDA $170B,y
- BEQ .LABEL7
- DEY
- BPL .LABEL8
- RTS
- .LABEL7
- LDA #$02
- STA $170B,y
- LDA $E4,x
- CLC
- ADC #$05
- STA $171F,y
- LDA $14E0,x
- ADC #$00
- STA $1733,y
- LDA $D8,x
- CLC
- ADC #$05
- STA $1715,y
- LDA $14D4,x
- ADC #$00
- STA $1729,y
- PHX
- LDA $151C,x
- ASL #2
- ORA $157C,x
- TAX
- LDA .Y_FIRE,x
- STA $173D,y
- PLX
- PHX
- LDA $157C,x
- TAX
- LDA .X_FIRE,x
- STA $1747,y
- PLX
- .LABEL6
- RTS
- .Y_FIRE
- db $0C,$0C,$06,$06,$F4,$F4,$FA,$FA
- .X_FIRE
- db $0C,$F4,$10,$F0
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; difference in y position
- ; sets 151C if mario is above plant
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- SUB_GET_Y_DIFF:
- LDY #$00
- LDA $D3
- PHA
- CLC
- ADC #$10
- STA $D3
- LDA $D4
- PHA
- ADC #$00
- STA $D4
- LDA $D3
- SEC
- SBC $D8,x
- STA $0E
- LDA $D4
- SBC $14D4,x
- BPL .LABEL14
- INY
- .LABEL14
- TYA
- STA $151C,x
- PLA
- STA $D4
- PLA
- STA $D3
- RTS
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; difference in x position
- ; sets 157C to 00 through 03 depending on the relative position of mario to the plant
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- SUB_GET_X_DIFF:
- LDY #$00
- LDA $D1
- SEC
- SBC $E4,x
- STA $0F
- LDA $D2
- SBC $14E0,x
- BPL .TO_RIGHT
- .TO_LEFT
- INY
- LDA $0F
- CMP #$B0
- BCS .SET_VAL
- INY #2
- BRA .SET_VAL
- .TO_RIGHT
- LDA $0F
- CMP #$50
- BCC .SET_VAL
- INY
- INY
- .SET_VAL
- TYA
- STA $157C,x
- RTS
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; AD30 - horizontal mario/sprite check
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- SUB_HORZ_POS1:
- LDY #$00
- LDA $D1
- SEC
- SBC $E4,x
- STA $0F
- LDA $D2
- SBC $14E0,x
- BPL .TO_RIGHT2
- INY
- .TO_RIGHT2
- RTS
- MainSprite69:
- RTS
- MainSprite85:
- RTS
- MainSprite88:
- RTS
- MainSprite96:
- RTS
- print "Sprite code found at $",pc
- print " ",bytes," bytes used."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement