-
Notifications
You must be signed in to change notification settings - Fork 2
/
bullets.s
240 lines (220 loc) · 3.82 KB
/
bullets.s
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
; Double Action Blaster Guys
;
; Copyright 2012-2014 NovaSquirrel
;
; This software is provided 'as-is', without any express or implied
; warranty. In no event will the authors be held liable for any damages
; arising from the use of this software.
;
; Permission is granted to anyone to use this software for any purpose,
; including commercial applications, and to alter it and redistribute it
; freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must not
; claim that you wrote the original software. If you use this software
; in a product, an acknowledgment in the product documentation would be
; appreciated but is not required.
; 2. Altered source versions must be plainly marked as such, and must not be
; misrepresented as being the original software.
; 3. This notice may not be removed or altered from any source distribution.
;
.proc RunBullets
lda #0
sta 0 ; current bullet counter
tax ; clear bullet map out first
: sta BulletMap+0,x
sta BulletMap+8,x
sta BulletMap+16,x
sta BulletMap+24,x
sta BulletMap+32,x
sta BulletMap+40,x
sta BulletMap+48,x
sta BulletMap+56,x
inx
cpx #8
bne :-
ldy OamPtr
BulletLoop:
ldx 0
lda BulletF,x
jpl SkipBullet
lda BulletPXL,x
add BulletVXL,x
sta BulletPXL,x
lda BulletPX,x
adc BulletVX,x
sta BulletPX,x
lda BulletPYL,x
add BulletVYL,x
sta BulletPYL,x
lda BulletPY,x
adc BulletVY,x
sta BulletPY,x
sty TempVal+1
; write to bullet map: 00yyyxxx
lda BulletPY,x
lsr
lsr
and #%111000
sta 1 ; Y is used for both versions
lda BulletPX,x
alr #%11100000
sta 2
lsr ; ALR already takes care of the first shift
lsr
lsr
lsr
ora 1
tay
lda #1
sta BulletMap,y
lda 2
add #7
and #%01110000
cmp 2
bne :+ ; most of the time the second write isn't needed, so avoid it when possible
lsr ; / 32 pixels (right side)
lsr
lsr
lsr
ora 1
tay
lda #1
sta BulletMap,y
:
; now do the bottom half to be extra sure
lda BulletPY,x
add #7
lsr
lsr
and #%111000
sta 1
lda BulletPX,x
add #4
lsr ; / 32 pixels (bottom
lsr
lsr
lsr
lsr
ora 1
tay
lda #1
sta BulletMap,y
; check against level stuff
lda BulletPX,x
add #4
lsr
lsr
lsr
lsr
sta 1
lda BulletPY,x
and #$f0
ora 1
tay
lda LevelBuf,y
cmp #METATILE_MIRROR
bne NoBounce
lda BulletVX,x
eor #255
add #1
sta BulletVX,x
lda BulletLife,x
add #12
sta BulletLife,x
jsr rand_8_safe
sta BulletVYL,x
jsr rand_8_safe
and #1
sub #1
sta BulletVY,x
NoBounce:
lda BulletF,x
and #15
cmp #12 ; bomb
bne :++
lda BulletLife,x
cmp #1
bne :++
lda 0
pha
lda BulletPX,x
sta 0
lda BulletPY,x
sta 1
lda #14
ldy IsFightMode
beq :+
lda #30
:
jsr CreateExplosion
pla
sta 0
:
ldy TempVal+1
; lda BulletF,x
; and #15
; cmp #11 ; FHBG block
; bne :+
; lda BulletVYL,x
; add #$80
; sta BulletVYL,x
; bne :+
; inc BulletVY,x
; :
lda BulletPY,x
sta OAM_YPOS+(4*0),y
lda #0
sta OAM_ATTR+(4*0),y
lda BulletF,x ; if second biggest bit is off, it's an enemy bullet and set color accordingly
and #%01000000
bne :+
lda #1
sta OAM_ATTR+(4*0),y
: lda BulletF,x
and #15
ora #$30
sta OAM_TILE+(4*0),y
lda BulletPX,x
sub ScrollX+1
sta OAM_XPOS+(4*0),y
dec BulletLife,x
bne :+
lda #0
sta BulletF,x
:
.repeat 4
iny
.endrep
SkipBullet:
inc 0
lda 0
cmp #BulletLen
jne BulletLoop
lda #0
sta OAM_YPOS+(4*0),y
sta OAM_ATTR+(4*0),y
sta OAM_TILE+(4*0),y
sta OAM_XPOS+(4*0),y
sty OamPtr
rts
.endproc
.proc FindFreeBulletY ; carry set = success?
pha
ldy #0
: lda BulletF,y
bpl Found
iny
cpy #BulletLen
bne :-
NotFound:
pla
clc
rts
Found:
lda #0
sta BulletVY,y
pla
sec
rts
.endproc