-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.i
496 lines (474 loc) · 8.12 KB
/
functions.i
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;< Spudster's Revenge - a Play in 3 acts <
;> by Brian Mastrobuono ([email protected]) >
;< copyright 2002-2013 GNU GPL licensed, use as you wish as long as <
;> your changes in source form are made public >
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; best viewed with vim :set ts=4 (www.vim.org)
;
;#######################################################
; SUBROUTINES/FUNCTIONS
;#######################################################
arrow_create
lda #127
sta arrow_y ; height
jsr Random ;
; anda #%01111111 ; mask off 1st bit == positive numbers only
sta arrow_x ; set random x coord
rts
; display score, once per frame ...
show_score
ldu #score
lda #-10
ldb #-100
jsr Print_Str_d
rts
;
show_highscore
ldu #highscore
lda #100
ldb #-100
jsr Print_Str_d
rts
;
inc_score
ldd dec_score ; decimal score stored as a reference
addd #1
std dec_score
lda #1
ldx #score
jsr Add_Score_a
lda level ; level
ldb #50 ; 50
mul ; times
cmpd dec_score ; if register > memory branch
bgt nope
inc level
nope
rts
;
check_if_score
jsr Read_Btns
lda Vec_Button_1_1
beq no_score
jsr inc_score
lda #10
sta mollystate
sta spudstate
no_score
rts
;
level_up
inc level
; add more stuff to increase game speed?
rts
;
draw_arrow
lda #127
jsr set_scale
lda arrow_y
ldb arrow_x
jsr Moveto_d
ldx #Arrow
jsr Draw_VLc
rts
;
arrow_in_bounds
; start of arrow bounds checking
; x test
lda arrow_x
cmpa #-127
bne x_ok
bsr arrow_create
x_ok
; y test
lda arrow_y
bpl y_ok
bsr arrow_create
y_ok
rts
; end of arrow bounds checking
draw_post
lda #127
jsr set_scale
ldd #0
jsr Moveto_d
jsr Intensity_3F
ldx #Post
jsr Draw_VLp
rts
;
draw_molly
lda #83
jsr set_scale
ldx #Molly
jsr Draw_VLp
rts
;
draw_mollysface
; TODO
; include bow animation?
lda #127
jsr set_scale
ldx #MollysFace
lda mollystate ; if state !=1
beq nothumpedface ; branch
ldx #MollysFaceHum
nothumpedface
jsr Draw_VLp
rts
;
draw_mollyslegs
ldx #MollysLegs
lda mollystate ; if state !=1
beq nothumpeds ; branch
ldx #MollysLegsHum
dec mollystate
nothumpeds
lda #83
jsr set_scale
jsr Draw_VLp
rts
;
draw_spud
lda #127
jsr set_scale
jsr Reset0Int
lda spud_ypos
ldb spud_xpos
jsr Moveto_d
ldx #Spud
lda spudstate ; if state !=1
beq nothumpedspud ; branch
ldx #SpudHump
nothumpedspud
jsr Draw_VLp
rts
;
draw_spudslegs ; wip
lda #127
jsr set_scale
ldx #SpudsLegsWalk1
lda spud_xpos
anda #%000000001 ; mask 1 bit testing for odd number ...
bne walk1
ldx #SpudsLegsWalk2
walk1
lda spudstate ; if state !=1
beq nothumping ; branch
ldx #SpudsLegsHum
dec spudstate
nothumping
jsr Draw_VLp
rts
;
sound_update
; TODO
rts
;
move_arrow
dec arrow_x
dec arrow_y
rts
;
button_push
rts
;
joystick_crap
jsr Joy_Digital
lda Vec_Joy_1_X
beq done_moving ;end
bmi going_left
;
going_right
lda spud_xpos
cmpa #55
bge done_moving ; if >= 52 don't move.
lda spud_xpos
adda #3
sta spud_xpos
bra done_moving
;
going_left
lda spud_xpos
cmpa #-127
beq done_moving
lda spud_xpos
suba #3
sta spud_xpos
bra done_moving
done_moving
rts
;
; Lost a guy ...
got_hit
dec spuds_left
lda #127
sta count
inc spudstate
;play sound
; ldx #ploop
; stx sfx_pointer
; lda #$01
; sta sfx_status
;
loopy
; jsr sfx_doframe
jsr Wait_Recal
lda #127
jsr set_scale
jsr Intensity_5F
lda #30
ldb #-27
jsr Moveto_d
ldx #letter_O
jsr Draw_VLp
jsr Reset0Ref
lda #30
ldb #40
jsr Moveto_d
ldx #letter_W
jsr Draw_VLp
jsr Reset0Ref
; lda #-10
; ldb #96
; std Vec_Text_HW
; ldu #owstr
; lda #0
; ldb #36
; jsr Print_Str_d
; shrink spud
lda #127
jsr set_scale
lda spud_ypos
ldb spud_xpos
jsr Moveto_d
lda count
jsr set_scale
ldx #SpudDead
jsr Draw_VLp
; jsr Reset0Ref
lda count
jsr set_scale
; lda spud_ypos
; ldb spud_xpos
; jsr Moveto_d
ldx #SpudsLegsWalk2
jsr Draw_VLp
dec count
dec count
dec count
dec count
dec count
dec count
bmi deadcont
bne loopy ; loop
deadcont
lda #20 ; reload counter
sta count
deadStar
jsr Wait_Recal
lda #127
jsr set_scale
lda spud_ypos
ldb spud_xpos
jsr Moveto_d
jsr Intensity_3F
lda #127
jsr set_scale
ldx #SpudDeadFinal
jsr Draw_VLp
dec count
bne deadStar
; reset spud position
lda spud_start
sta spud_xpos
rts
;
gameoverloop
jsr Wait_Recal
jsr Intensity_3F
ldu #gameoverstr
lda #10
ldb #206
jsr Print_Str_d
jsr show_score
ldx #score ; update highscore if needed
ldu #highscore
jsr New_High_Score
ldu #highscorestr
lda #127
ldb #206
jsr Print_Str_d ; print highscore label
jsr show_highscore
ldx #lolscore
ldu #score
jsr Compare_Score
cmpa #0
beq lol
ldb $FF ; pause a little before taking button input
jsr Delay_b
jsr Read_Btns
lda Vec_Button_1_1
ora Vec_Button_1_2
ora Vec_Button_1_3
ora Vec_Button_1_4
lbne restart
bra gameoverloop
;
lol
ldu #lolstring
lda #10
ldb #206
jsr Print_Str_d
lda #127
jsr set_scale
ldx #lolgraphic
jsr Draw_VLp
bra lol
rts
;
titlescreen
lda #0
jsr Read_Btns_Mask
lda Vec_Button_1_1
bne main
lda Vec_Button_1_2
beq no_btn_psh
lda Vec_Button_1_3
beq no_btn_psh
lda Vec_Button_1_4
beq no_btn_psh
jmp hidden_msg ; all 3 buttons pushed
;
no_btn_psh
clra
clrb
jsr Wait_Recal
jsr Intensity_5F
ldu #titlestring
lda #$30
ldb #-$70
jsr Print_Str_d
;
;; start variable intensity routine NEED 2 FIX
lda brightdir ; Load variable saying which
bne up ; direction we're going & test
down
dec intlevel ; load the 'level' of bright
lda intlevel
cmpa #MINBRIGHT ;compare it to our threshhold
beq changedir2up ; if yes:
bra finish_pulse
;
up
inc intlevel
lda intlevel
cmpa #MAXBRIGHT
beq changedir2down
bra finish_pulse
;
changedir2up
lda #1
sta brightdir
bra finish_pulse
;
changedir2down
lda #0
sta brightdir
;
finish_pulse
lda intlevel
jsr Intensity_a ; set intensity here
; end intensity routine
ldu #startstring
lda #-50
ldb #-110
jsr Print_Str_d
bra titlescreen ; if not pushed ... loop
rts
;
play_song
ldb #1 ;movqi: #1 -> R:b
stx current_song ;movhi: R:x -> _current_song
sta brightdir ; direction 0 down 1 up
jsr Do_Sound
rts ; return from function
;
setup
lda #1 ; enable joystick 1's x axis, disable all others.
sta Vec_Joy_Mux_1_X
ldx #highscore
jsr Clear_Score ; Bios routine yay
lda #10
sta intlevel ; intensity level
lda #0 ; disable for Joy Mux's
sta Vec_Joy_Mux_1_Y
sta Vec_Joy_Mux_2_X
sta Vec_Joy_Mux_2_Y
jsr Joy_Digital ; set joymode, not analog.
lda #0
; jsr vox_init
;jsr Read_Btns ; no idea why this is here.
;jsr Wait_Recal
rts ; return from function
;
start
lda #3
sta spuds_left
ldx #score
jsr Clear_Score
lda #0
sta spudstate
sta mollystate
ldd #0
std dec_score
lda #1
sta level
ldx #time_frames ; setting initial frame counter
lda a,x
sta currentframe ; ^^
lda #-127
sta spud_start
sta spud_xpos
lda #20
sta spud_ypos
rts
; show hidden msg requires reset to escape
hidden_msg
jsr Intensity_3F
jsr Wait_Recal
ldu #hidden1str
lda #0
ldb #-60
jsr Print_Str_d
ldu #hidden2str
lda #-20
ldb #-76
jsr Print_Str_d
bra hidden_msg ; no escape
;
;start_one_vectrex_round
; ldb #200 ;movqi: #200 -> R:b
; tfr b,dp ; set dp to b (dp is direct page reg)
; pshs y ; save y register to HW stack
; ldu current_song ;movhi: _current_song -> R:u
; jsr Init_Music_chk
; puls y ; restore y register
; jsr Wait_Recal ; wait_recal
; jsr Do_Sound ; do_sound
; rts ; return from function
guys_left ; display number of 'guys' left
jsr Intensity_3F
lda #-10 ; fix
ldb #65 ; change
std coord
lda #$69
ldb spuds_left
ldx coord
jsr Print_Ships
rts
;
set_scale ;scales to content of reg A
sta $D004 ; VIA t1 cnt lo register.
rts