/
sprite_killer_box.asm
153 lines (129 loc) · 2.62 KB
/
sprite_killer_box.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
;;
;
; Sprite killer box
;
; This invisible sprite will kill any sprite is comes in contact with.
;
; Version 1.1 by Darolac
;
; -Added the option to kill sprites on the same line of the sprite.
; -Converted to PIXI
; -Optimized the code.
;;
!Line = 0 ; if this is anything other than 0, this sprite will kill other sprites on the same line.
!Vert = #$0010 ; vertical proximity to the sprite that will make the sprite dissapear. Only used when !Line is set.
print "MAIN ", pc
PHB ; \
PHK ; | main sprite function, just calls local subroutine
PLB ; |
JSR KillSpr_Start ; |
PLB ; |
print "INIT ", pc
RTL ; /
;;;;;;;;;;;;;;
Skip:
RTS
KillSpr_Start:
LDA !14C8,x
EOR #$08
ORA $9D ; Lock Flag
BNE Skip
%SubOffScreen()
BCS Skip
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if !Line = 0
JSL $03B69F ; Get Sprite Clipping A.
else
LDA !D8,x ; Store sprite position on scratch RAM
ADC #$08
STA $00
LDA !14D4,x
ADC #$00
STA $01
endif
LDX #!SprSize
---
DEX
BPL +
LDX $15E9|!Base2
RTS
+
CPX $15E9|!Base2
BEQ ---
LDA !14C8,x
CMP #$08
BCC ---
if !Line = 0
JSL $03B6E5 ; Get Sprite Clipping B.
JSL $03B72B ; Check for contact.
BCC --- ; No Contact, go back.
else
LDA !14D4,x
XBA
LDA !D8,x
REP #$20
SEC
SBC $00
BPL +
EOR #$FFFF
INC
+
CMP !Vert
SEP #$20
BCS ---
JSL $03B6E5
endif
LDA $02 ; $02 - Clipping width
LSR
CLC
ADC $00 ; $00 - Clipping X displacement low
STA $00
LDA #$00
ADC $08 ; $08 - Clipping X displacement, high
XBA
LDA $00
REP #$20
SEC
SBC.w #$0008
PHA
SEC
SBC $1A
CMP.w #$0100
PLA
SEP #$20
BCS .offscreen
STA $0C
LDA $03 ; $03 - Clipping height
LSR
CLC
ADC $01 ; $01 - Clipping Y displacement low
STA $01
LDA #$00
ADC $09 ; $09 - Clipping Y displacement, high
XBA
LDA $01
REP #$20
SEC
SBC.w #$0008
PHA
SEC
SBC $1C
CMP.w #$0100
PLA
SEP #$20
BCS .offscreen
LDY $1863|!Base2 ; Get smoke sprite index.
STA $17C4|!Base2,y ; Y position
LDA #$01
STA $17C0|!Base2,y ; Smoke sprite type (smoke)
LDA $0C
STA $17C8|!Base2,y ; Smoke X position
LDA #20
STA $17CC|!Base2,y ; Timer
LDA #$25
STA $1DFC|!Base2 ; Sound effect (Yoshi stomps)
.offscreen
STZ !14C8,x
+++
LDX $15E9|!Base2
RTS