This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
forked from historicalsource/defender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SAMEXAP7.SRC
executable file
·382 lines (382 loc) · 9.96 KB
/
SAMEXAP7.SRC
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
NLIST
INCLUDE PHR6.SRC
LIST
TTL D E F E N D E R 1.0 SAMEXAP7.SRC
*****************************************************
*
* SAM EXPLOSIONS AND APPEARANCES
*
* ASSEMBLE WITH PHRED
*****************************************************
SETDP $A0
*
* EXPLOSION/APPEAR VECTORS
*
ORG APVCT
JMP APST APPEAR START
JMP EXST EXPLOSION START
JMP EXPU EXPANDED UPDATE
*
* APPEAR START
* X=OBJECT POINTER
*
APST PSHS U,Y,D
LDD OPICT,X GET OBJECT PICTURE
PSHS D SAVE IT
LDD NULOBV GET NULL OBJECT PICTURE
STD OPICT,X REPLACE OBJECT PICTURE WITH NU
STX OPTR ADD OBJECT TO LIST
LDD OX16,X GET 16 BIT X COORDINATE
SUBD BGL FIND SCREEN POSITION
CMPD #$2600 CHECK IF ON SCREEN
BHI APST5 OFF SCREEN?, ABORT APPEAR
* GET RAM ALLOCATION
LDY LSEXPL GET LAST EXPLOSION RAM ALLOCAT
BEQ APST3 ZERO?, INITIALIZE RAM ALLOCATI
APST2 LEAY RAMSIZ,Y ADVANCE TO NEXT RAM ALLOCATION
CMPY #RAMEND CHECK FOR END
BNE APST4 NO?, CONTINUE SEARCH
APST3 LDY #RAMALS RESET TO START
APST4 CMPY LSEXPL CHECK FOR ALL APPEARS
BNE APST6 NO?, CONTINUE SEARCH
APST5 PULS D GET OBJECT PICTURE
STD OPICT,X RESTORE IT
BRA APST8 ABORT APPREAR, QUIT
APST6 LDA RSIZE,Y CHECK FOR APPEAR
BMI APST2 YES?, TRY NEXT ALLOCATION
*
BEQ APST7 OLD EXPLOSION COMPLETED?
JSR EERASE NO?, ERASE OLD IMAGE
APST7 LDA STATUS CHECK IF IN GAME
BITA #$80
BNE APST7A NO?, SKIP SOUND
LDD APSNDV PLAY APPEAR SOUND
JSR SNDLDV
APST7A LDA OTYP,X SET HYPER NOT FLAG
ORA #2
STA OTYP,X
LDD #$AF00 INTIALIZE SIZE
STD RSIZE,Y
PULS D SET OBJECT PICTURE
STD OBDESC,Y
LEAU RAMSIZ,Y INITIALIZE ERASE TABLE START
STU ERASES,Y
STX OBJPTR,Y SAVE OBJECT POINTER
APST8 PULS D,Y,U,PC
*
* EXPLOSION START
* X=OBJECT POINTER
*
EXST PSHS U,Y,D
* GET RAM ALLOCATION
LDD OX16,X GET 16 BIT X COORDINATE
SUBD BGL FIND SCREEN POSITION
CMPA #$26 CHECK IF OFF SCREEN
BHI EXST8 YES?, QUIT
STD XSTART SAVE RELATIVE X COORDINATE
LDY LSEXPL GET LAST EXPLOSION RAM ALLOCAT
BEQ EXST2 ZERO?, INITIALIZE RAM ALLOCATI
EXST1 LEAY RAMSIZ,Y ADVANCE TO NEXT RAM ALLOCATION
CMPY #RAMEND CHECK FOR END
BNE EXST3 NO?, CONTINUE SEARCH
EXST2 LDY #RAMALS RESET TO START
EXST3 CMPY LSEXPL CHECK FOR ALL APPEARS
BEQ EXST8 YES?, QUIT
EXST4 LDA RSIZE,Y CHECK FOR APPEAR
BMI EXST1 YES?, TRY NEXT ALLOCATION
*
BEQ EXST5 OLD EXPLOSION COMPLETED?
JSR EERASE NO?, ERASE OLD IMAGE
EXST5 STY LSEXPL SAVE LAST EXPLOSION RAM ALLOCA
LDD #$100 INITIALIZE SIZE
STD RSIZE,Y
LDD OPICT,X SAVE OBJECT PICTURE
STD OBDESC,Y
LEAU RAMSIZ,Y INITIALIZE ERASE TABLE START
STU ERASES,Y
LDD XSTART GET RELATIVE X COORD
ASLB
ROLA
ASLB
ROLA
LDB OY16,X GET OBJECT Y COORDINATE
STD TOPLFT,Y INITIALIZE TOP LEFT
* CHECK FOR VALID CENTER
SUBD CENTMP FIND OFFSET
LDU OBDESC,Y GET OBJECT PICTURE
ADDA ,U CHECK IF WITHIN PICTURE WIDTH
BHS EXST6 NO?, MAKE NEW CENTER
ADDB 1,U CHECK IF WITHIN PICTURE HEIGHT
BHS EXST6 NO?, MAKE NEW CENTER
LDD CENTMP GET CENTER
BRA EXST7 USE IT
EXST6 LDD ,U GET PICTURE WIDTH, HEIGHT
LSRA DIVIDE BY 2
LSRB
ADDD TOPLFT,Y ADD TO TOP LEFT
EXST7 STD CENTER,Y SAVE EXPLOSION CENTER
EXST8 PULS D,Y,U,PC
*
*
* EXPANDED EXPLOSION/APPEAR UPDATE ROUTINE
*
EXPU LDY #RAMALS GET START OF RAM BLOCKS
EXPU1 LDA STATUS CHECK SYSTEM STATUS
BITA #4
BEQ EXPU2 IN PLAY?, CONTINUE EXPLOSION/A
LDA RSIZE,Y CHECK IF EXPLOSION OR APPEAR
BMI EXPU6 APPEAR?, KILL IT
LDD #0 KILL EXPLOSION
STD RSIZE,Y
JMP EXPU9 NEXT OBJECT
EXPU2 LDD RSIZE,Y CHECK SIZE
LBEQ EXPU9 DEAD?, SKIP TO NEXT
BMI EXPU4 APPEAR?, SKIP TO APPEAR UPDATE
* EXPLOSION UPDATE
ADDD #$AA INCREASE SIZE
STD RSIZE,Y
CMPA #$30 CHECK IF FINISHED
BLS EXPU3 NO?, CONTINUE EXPLOSION
JSR EERASE ERASE OBJECT
LDD #0 KILL EXPLOSION
STD RSIZE,Y
BRA EXPU9 NEXT OBJECT
EXPU3 LDD BGL SCROLL TOP LEXT AND CENTER
ANDB #$C0
PSHS D
LDD BGLX
ANDB #$C0
SUBD ,S++
ASLB
ROLA
ASLB
ROLA
PSHS A
LDA CENTER,Y
ADDA ,S
STA CENTER,Y
LDA TOPLFT,Y
ADDA ,S+
STA TOPLFT,Y
BRA EXPU8
* APPEAR UPDATE
EXPU4 SUBD #$100 DECREASE SIZE
STD RSIZE,Y
BPL EXPU6 FINISHED APPEARING?, KILL APPEAR
EXPU5 LDX OBJPTR,Y GET OBJECT POINTER
LDD OX16,X GET 16 BIT X COORDINATE
SUBD BGL FIND SCREEN POSITION
ADDA #$C CHECK IF NEAR SCREEN
BITA #$C0
BEQ EXPU7 ON SCREEN?, CONTINUE
EXPU6 LDD #0 ZERO SIZE
STD RSIZE,Y
LDD OBDESC,Y GET OBJECT PICTURE, KILL APPEAR
LDX OBJPTR,Y GET OBJECT POINTER
STD OPICT,X RESTORE OLD OBJECT PICTURE
LDA OTYP,X CLEAR HYPER NOT FLAG
ANDA #$FD
STA OTYP,X
JSR EERASE ERASE OBJECT
BRA EXPU9 NEXT OBJECT
EXPU7 SUBA #$C
ASLB
ROLA
ASLB
ROLA
LDB OY16,X GET OBJECT Y COORDINATE
STD TOPLFT,Y SET TOP LEFT
LDB #$DA COMPUTE PHONEY CENTER
MUL
ASLA
LDU OBDESC,Y
LDB ,U
MUL
LDB 1,U
LSRB
ADDD TOPLFT,Y ADD TO TOP LEFT
STD CENTER,Y SET CENTER OF APPEAR
EXPU8 JSR EERASE ERASE EXPANDED OBJECT
JSR EWRITE WRITE EXPANDED OBJECT
EXPU9 LEAY RAMSIZ,Y NEXT RAM ALLOCATION
CMPY #RAMEND CHECK FOR END
LBNE EXPU1 NO?, CONTINUE
RTS
*****************************************************
*
* EXPANDED ERASE ROUTINE
*
EERASE PSHS X,D
LDD #0 ZERO ACCUMULATOR A
LEAX RAMSIZ,Y GET ERASE TABLE END
STX DATPTR SAVE ERASE TABLE END
LDX ERASES,Y GET ERASE TABLE START
CMPX DATPTR CHECK FOR NO BLOCKS
BEQ EERAS2 YES?, QUIT
EERAS1 STD [,X++] ERASE BLOCK
CMPX DATPTR CHECK IF FINISHED
BNE EERAS1 NO, ERASE NEXT BLOCK
STX ERASES,Y SET ERASE TABLE START TO SAME
EERAS2 PULS D,X,PC
*
* EXPANDED WRITE ROUTINE
*
EWRITE PSHS U,Y,X,D
STY BLKADD SAVE BLOCK ADDRESS
LDA RSIZE,Y GET SIZE
ANDA #$7F REMOVE APPEAR/EXPLOSION FLAG
STA SIZE
LEAU RAMSIZ,Y GET ERASE TABLE END
CLR FLAVOR ZERO FLAVOR
LDX OBDESC,Y GET OBJECT DESCRIPTER ADDRESS
LDD 2,X GET DATA ADDRESS
STD DATPTR INITIALIZE DATA POINTER
LDD ,X GET OBJECT WIDTH,LENGTH
STA WIDTHC INITIALIZE OBJECT WIDTH COUNTE
STB LENGTC INITIALIZE OBJECT LENGTH COUNT
BITB #1 CHECK ODD/EVEN
BNE EXPN2
LDX #NEXCOL EVEN
BRA EXPN3
EXPN2 LDX #ODD ODD
EXPN3 STX ODDEVN
LDD CENTER,Y GET EXPANSION CENTER
SUBD TOPLFT,Y SUBTRACT TOP LEFT ADDRESS
STA XOFF SAVE X OFFSET
LSRB DIVIDE Y OFFSET BY TWO
STB YOFF SAVE Y OFFSET
ROL FLAVOR SAVE FLAVOR
LDA SIZE GET SIZE
LDB XOFF GET X OFFSET
MUL MULTIPLY
STD XSTART SAVE X OFFSET * SIZE
LDB CENTER,Y GET X COMPONENT OF CENTER
CLRA
SUBD XSTART SUBTRACT X OFFSET * SIZE
STD XSTART SAVE X STARTING POSITION
EXPN4 TSTA CHECK IF ON SCREEN
BEQ EXPN5 YES?, CONTINUE
LDD DATPTR GET DATA POINTER
ADDB LENGTC SKIP FIRST COLUMN
ADCA #0
STD DATPTR SAVE DATA POINTER
DEC WIDTHC DECREMENT WIDTH COUNTER
LBEQ DONE NOT ON SCREEN?, QUIT
LDD XSTART GET X STARTING POSITION
ADDB SIZE ADVANCE X TO NEXT STARTING POS
ADCA #0
STD XSTART SAVE X STARTING POSITION
BRA EXPN4
EXPN5 CMPB #$98 CHECK IF OFF SCREEN
LBHI DONE YES?, QUIT
LDA SIZE GET SIZE
ASLA MULTIPLY BY 2
STA DSIZE SAVE DOUBLE SIZE
LDB YOFF GET Y OFFSET
MUL MULTIPLY
STD YSTART SAVE Y OFFSET * DOUBLE SIZE
LDB CENTER+1,Y GET Y COMPONENT OF CENTER
CLRA
SUBD YSTART SUBTRACT Y OFFSET * SIZE
SUBB FLAVOR SUBTRACT FLAVOR
ADCA #0
CLR YSKIP ZERO Y SKIP COUNTER
EXPN6 TSTA CHECK IF ON SCREEN
BNE EXPN7 NOT YET?, FIND FIRST Y BLOCK
CMPB #$2A CHECK IF IN SCANNER
BHS EXPN8 NO?, CONTINUE
EXPN7 INC YSKIP ADVANCE Y SKIP COUNTER
DEC LENGTC DECREMENT LENGTH COUNTER TWICE
DEC LENGTC
LBLE DONE NOT ON SCREEN?, QUIT
ADDB DSIZE ADVANCE Y TO NEXT STARTING POS
ADCA #0
BRA EXPN6
EXPN8 STD YSTART SAVE Y STARTING POSITION
LDA LENGTC GET LENGTH COUNTER
ANDA #$FE TRUNCATE ODD/EVEN
LDX #STARTS GET STARTING POINT TABLE ADDRE
LDX A,X GET STARTING POINT
STX VSTART SAVE STARTING ADDRESS
LDX DATPTR GET DATA POINTER
ASL YSKIP DOUBLE Y SKIP COUNTER
LDA XSTART+1 GET X SCREEN POSITION
* MAIN LOOP
EXPN9 LDB YSKIP GET Y SKIP
ABX ADD TO DATA POINTER
LDB YSTART+1 GET Y SCREEN POSITION
JMP [VSTART] JUMP TO WRITING
STRTEF STD ,--U SAVE ON ERASE TABLE
LDY ,X++ GET DATA BLOCK
STY [,U] WRITE TO SCREEN
ADDB DSIZE MOVE POINTER DOWN
BCS EXPN10 OFF SCREEN?, QUIT THIS COLUMN
STRTCD STD ,--U SAVE ON ERASE TABLE
LDY ,X++ GET DATA BLOCK
STY [,U] WRITE TO SCREEN
ADDB DSIZE MOVE POINTER DOWN
BCS EXPN11 OFF SCREEN?, QUIT THIS COLUMN
STRTAB STD ,--U SAVE ON ERASE TABLE
LDY ,X++ GET DATA BLOCK
STY [,U] WRITE TO SCREEN
ADDB DSIZE MOVE POINTER DOWN
BCS EXPN12 OFF SCREEN?, QUIT THIS COLUMN
STRT89 STD ,--U SAVE ON ERASE TABLE
LDY ,X++ GET DATA BLOCK
STY [,U] WRITE TO SCREEN
ADDB DSIZE MOVE POINTER DOWN
BCS EXPN13 OFF SCREEN?, QUIT THIS COLUMN
STRT67 STD ,--U SAVE ON ERASE TABLE
LDY ,X++ GET DATA BLOCK
STY [,U] WRITE TO SCREEN
ADDB DSIZE MOVE POINTER DOWN
BCS EXPN14 OFF SCREEN?, QUIT THIS COLUMN
STRT45 STD ,--U SAVE ON ERASE TABLE
LDY ,X++ GET DATA BLOCK
STY [,U] WRITE TO SCREEN
ADDB DSIZE MOVE POINTER DOWN
BCS EXPN15 OFF SCREEN?, QUIT THIS COLUMN
STRT23 STD ,--U SAVE ON ERASE TABLE
LDY ,X++ GET DATA BLOCK
STY [,U] WRITE TO SCREEN
ADDB DSIZE MOVE POINTER DOWN
BCS EXPN16 OFF SCREEN?, QUIT THIS COLUMN
STRT01 JMP [ODDEVN] ODD?, WRITE MORE, EVEN?, NEXT
ODD BCS EXPN17 OFF SCREEN?, INCREMENT DATA PO
STD ,--U SAVE ON ERASE TABLE
LDB ,X+ GET DATA BYTE
STB [,U] WRITE TO SCREEN
BRA NEXCOL
EXPN10 LEAX 12,X SKIP DATA POINTER PAST BELOW S
JMP [ODDEVN] ODD?, INCREMENT DATA POINTER,
EXPN11 LEAX 10,X SKIP DATA POINTER PAST BELOW S
JMP [ODDEVN] ODD?, INCREMENT DATA POINTER,
EXPN12 LEAX 8,X SKIP DATA POINTER PAST BELOW S
JMP [ODDEVN] ODD?, INCREMENT DATA POINTER,
EXPN13 LEAX 6,X SKIP DATA POINTER PAST BELOW S
JMP [ODDEVN] ODD?, INCREMENT DATA POINTER,
EXPN14 LEAX 4,X SKIP DATA POINTER PAST BELOW S
JMP [ODDEVN] ODD?, INCREMENT DATA POINTER,
EXPN15 LEAX 2,X SKIP DATA POINTER PAST BELOW S
JMP [ODDEVN] ODD?, INCREMENT DATA POINTER,
EXPN16 JMP [ODDEVN] ODD?, INCREMENT DATA POINTER,
EXPN17 LEAX 1,X SKIP DATA POINTER PAST BOTTOM
NEXCOL DEC WIDTHC DECREMENT WIDTH COUNTER
BEQ DONE END OF OBJECT?, QUIT
ADDA SIZE NEXT COLUMN
BCS DONE WAY OFF SCREEN?, QUIT
CMPA #$98 CHECK IF OFF SCREEN
LBLS EXPN9 NO?, NEXT COLUMN
DONE LDX BLKADD GET BLOCK ADDRESS
STU ERASES,X SAVE ERASE TABLE START
LDD CENTER,X GET CENTER BLOCK ADDRESS
CMPA #$98 CHECK IF OFF SCREEN
BHI DONE1 YES?, DO NOT ERASE
SUBB FLAVOR SUBTRACT FLAVOR
LDX #0 ERASE CENTER BLOCK
STX D,X
DONE1 PULS D,X,Y,U,PC RESTORE REGISTERS, QUIT
* STARTING POINT TABLE
STARTS FDB STRT01,STRT23,STRT45,STRT67
FDB STRT89,STRTAB,STRTCD,STRTEF
END