-
Notifications
You must be signed in to change notification settings - Fork 0
/
miner4.a
7905 lines (7021 loc) · 212 KB
/
miner4.a
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;
; miner4.a ($5580)
;
; Execution starts at 'miner4EntryPoint'
!src "constants.a"
; constants
; memory locations
* = $5580
; ***************************************************************************************
;
; start up
;
; ***************************************************************************************
startUp
; output 8 line feeds
ldx #8 ;
lda #10 ;
-
jsr OSWRCH ;
dex ;
bne - ;
; wait for key press
lda #$81 ;
ldx #$ff ;
ldy #$00 ;
jsr OSBYTE ;
jmp continue ;
; [the code that follow is the four digit code entry - now unused, code continues at 'initialize']
!byte $60 ; RTS [UNUSED]
; $5597
; VDU 19,3,3,0,0,0,0,0,0 - set palette colour 3 set to green
ldx #0 ; loop counter
-
lda setPaletteMessage,x ;
jsr OSWRCH ;
inx ;
cpx #setPaletteMessageEnd - setPaletteMessage ;
bne - ;
; output 6 zeros
lda #0 ;
ldx #6 ;
-
jsr OSWRCH ;
dex ;
bne - ;
lda #31 ; }
jsr OSWRCH ; }
lda #11 ; } VDU 31, 11, 7 i.e. TAB(11,7)
jsr OSWRCH ; }
lda #7 ; }
jsr OSWRCH ; }
lda #charSPACE ;
ldx #$14 ; loop counter
-
jsr OSWRCH ;
dex ; output 20 spaces
bne - ;
; press return to stop message
ldx #0 ;
-
lda pressReturnToStopMessage,x ;
inx ;
jsr OSWRCH ;
cpx #pressReturnToStopMessageEnd - pressReturnToStopMessage ;
bne - ;
showEnterCodeMessageAndWaitForReturn
jsr showEnterCodeAtCell ;
ldy #$ff ;
ldx #$b6 ;
lda #$81 ;
jsr OSBYTE ;
cpy #$ff ;
bne showEnterCodeMessageAndWaitForReturn ;
showBoxes
lda #%11111111 ;
ldx #8 ;
-
sta softCharacterDefinitions - 1,x ; store 255 at $0c00-$0c07
dex ;
bne - ;
; make a box character
sta $0c08 ; %11111111 at $0c08
sta $0c0f ; and $0c0f
lda #%10000001 ;
ldx #6 ;
-
sta $0c08,x ;
dex ;
bne - ;
; make a filled in box
lda #%00000000 ;
sta $0c10 ;
sta $0c17 ;
lda #%01111110 ;
ldx #6 ;
-
sta $0c10,x ;
dex ;
bne - ;
lda #31 ; VDU 31,8,10
jsr OSWRCH ;
lda #8 ;
jsr OSWRCH ;
lda #10 ;
jsr OSWRCH ;
ldx #0 ; loop counter
-
lda #charSPACE ; VDU 32
jsr OSWRCH ;
lda #17 ; VDU 17,X = COLOUR X
jsr OSWRCH ;
txa ;
jsr OSWRCH ;
lda #$80 ; Show box character
jsr OSWRCH ;
inx ;
cpx #4 ;
bne - ;
; show 7 spaces
lda #$20 ;
ldx #7 ; loop counter
-
jsr OSWRCH ;
dex ;
bne - ;
; four copies of space and filled box
ldx #4 ; loop counter
-
lda #charSPACE ;
jsr OSWRCH ;
lda #$81 ; show filled in box
jsr OSWRCH ;
dex ;
bne - ;
; show 2 spaces
lda #$20 ;
jsr OSWRCH ;
jsr OSWRCH ;
; TAB(9,12)
lda #31 ;
jsr OSWRCH ;
lda #9 ;
jsr OSWRCH ;
lda #12 ;
jsr OSWRCH ;
; show '1 2 3 4 '
ldx #'1' ;
-
txa ;
jsr OSWRCH ;
inx ;
lda #charSPACE ;
jsr OSWRCH ;
cpx #'5' ;
bne - ;
; Show 'Code' message
ldx #0 ;
-
lda codeMessage,x ;
jsr OSWRCH ;
inx ;
cpx #codeMessageEnd - codeMessage ;
bne - ;
; show four of: filled box and space
ldx #0 ;
-
lda #$81 ;
jsr OSWRCH ;
lda #charSPACE ;
jsr OSWRCH ;
inx ;
cpx #4 ;
bne - ;
; Show 7 spaces
lda #charSPACE ;
ldx #7 ;
-
jsr OSWRCH ;
dex ;
bne - ;
jsr waitForRETURN ;
lda #0 ;
sta $71 ;
ldx #0 ;
-
lda positionShift,x ;
jsr OSWRCH ;
inx ;
cpx #positionShiftExtendedEnd - positionShift ;
bne - ;
lda #0 ;
ldx #4 ;
-
sta entryCode - 1,x ; store zeros in entry code
dex ;
bne - ;
checkNumberKeys
lda #0 ;
sta $70 ;
checkKeys
ldy #$ff ; }
ldx $70 ; }
lda keyArray,x ; }
tax ; } check if a number key 1-4 is pressed
lda #$81 ; }
jsr OSBYTE ; }
cpy #$ff ; }
beq numberKeyPressed ; if (number key pressed) then branch
ldy #$ff ; }
ldx #$b6 ; }
lda #$81 ; } check if RETURN is pressed
jsr OSBYTE ; }
cpy #$ff ; }
beq returnPressed ; if (RETURN pressed) then branch forward
inc $70 ;
lda $70 ;
cmp #4 ;
beq checkNumberKeys ;
jmp checkKeys ;
; ***************************************************************************************
numberKeyPressed
lda #18 ; GCOL 0,number of key
jsr OSWRCH ;
lda #0 ;
jsr OSWRCH ;
lda $70 ;
jsr OSWRCH ;
lda #$82 ; show character 130
jsr OSWRCH ;
; check for release of key pressed
-
ldy #$ff ;
ldx $70 ;
lda keyArray,x ;
tax ;
lda #$81 ;
jsr OSBYTE ; check for key pressed
cpy #$ff ;
beq - ; if (number key still pressed) then branch back
ldx $71 ;
lda $70 ;
sta entryCode,x ;
jsr updateCursor ;
lda #charSPACE ;
jsr OSWRCH ;
inc $71 ;
lda $71 ;
cmp #4 ;
bne checkNumberKeys ;
; output eight backspaces
ldx #8 ;
lda #8 ;
-
jsr OSWRCH ;
dex ;
bne - ;
lda #0 ;
sta $71 ;
jmp checkNumberKeys ;
!byte $60 ; RTS [UNUSED]
; ***************************************************************************************
returnPressed
lda #15 ; }
ldx #1 ; } *FX 15,1 - flush keyboard buffer
ldy #0 ; }
jsr OSBYTE ; }
lda #4 ;
jsr OSWRCH ; VDU 4
jmp continue ;
; ***************************************************************************************
updateCursor
ldx #0 ; loop counter
-
lda positionShift,x ;
jsr OSWRCH ; set cursor position
inx ;
cpx #positionShiftEnd - positionShift ;
bne - ;
; output seven spaces
lda #charSPACE ;
ldx #7 ;
-
jsr OSWRCH ;
dex ;
bne - ;
lda #31 ; TAB(24 + 2*(($71 + 1) & 3), 12)
jsr OSWRCH ;
lda $71 ;
clc ;
adc #1 ;
and #3 ;
asl ;
clc ;
adc #24 ;
jsr OSWRCH ;
lda #12 ;
jsr OSWRCH ;
lda #$5e ; display the up arrow
jsr OSWRCH ;
lda #5 ; VDU 5
jmp OSWRCH ;
; ***************************************************************************************
; Enter code at cell
showEnterCodeAtCell
ldx #0
-
lda enterCodeAtCell,x
jsr OSWRCH
inx
cpx #enterCodeAtCellEnd - enterCodeAtCell
bne -
; get and show a random code
lda timeClockB + 4 ; read byte of clock time
sta addition ; as a source of randomness
lda countdownIntervalTimer + 4 ; read byte of countdown interval timer
sta counter ; as a second source of randomness
lda addition ;
-
cmp #19 ;
bcc + ; if (less than 19) then branch
sec ;
sbc #18 ; take off 18
jmp - ; loop back
+
sta addition ;
clc ;
adc #'A' ; add 'A' to get a character 'A' to 'R'
jsr OSWRCH ;
lda counter ;
-
cmp #20 ;
bcc + ; if (less than 20) then branch
sec ;
sbc #20 ; take off 20
jmp - ;
+
sta counter ; store result
cmp #10 ;
bcs showTensDigit ; if (ten or more) then branch
showDigitAndSpace
clc ;
adc #'0' ; add '0' to digit to get ASCII code
jsr OSWRCH ; display digit
lda #charSPACE ;
jmp OSWRCH ; display a space
showTensDigit
tax ;
lda #'1' ;
jsr OSWRCH ; display '1'
txa ;
sec ;
sbc #10 ; subtract 10 to get the units digit
jmp showDigitAndSpace ; show the units
; ***************************************************************************************
moveAndPrintSpaces
; VDU 31,10,19 - move cursor position
lda #31 ; }
jsr OSWRCH ; }
lda #10 ; } TAB(10, 19)
jsr OSWRCH ; }
lda #19 ; }
jsr OSWRCH ; }
; print thirty spaces
lda #charSPACE ;
ldx #30 ;
-
jsr OSWRCH ;
dex ;
bne - ;
jmp miner3EntryPoint ;
!byte $00, $00, $00, $00, $00 ; [UNUSED]
; initial values for locations $00 to $9F
zeroPageDefaults
!pseudopc $0000 {
; tune frequencies
!byte $23, $1f, $1d, $1a, $17, $1d, $17, $17, $16, $1a, $16, $16, $17, $1d, $17, $17
!byte $23, $1f, $1d, $1a, $17, $1d, $17, $17, $16, $1a, $16, $16, $17, $17, $17, $23
!byte $1f, $1d, $1a, $17, $1d, $17, $17, $16, $1a, $16, $16, $17, $1d, $17, $17, $23
!byte $1f, $1d, $1a, $17, $1d, $17, $11, $13, $17, $1d, $17, $13, $13, $13, $00, $00
; $0040 - called when a switch is hit
triggerSwitch
lda #1 ;
sta switchTriggered ;
lda vduTextCursorXPosition ;
rts ;
!byte $00, $00, $00, $08, $05, $ff, $09, $fd ; [UNUSED]
; $0050
switchMessage2
!byte $1f, $13, $01 ; TAB(19, 1)
switchClearCentreMessage
!byte $20, $20, $0a, $08, $08 ; two spaces and move down and back
switchClearCentreMessageEnd
switchMessage2End
!byte $00, $00, $00, $00, $00, $00, $00, $00 ; [UNUSED]
; $0060
switchMessage
!byte $99 ; the switched switch sprite
!byte 31, 21, 12 ; TAB(21, 12)
!byte charSPACE ; space
!byte 10, 8, charSPACE ; another space below. This removes a section of wall.
switchMessageEnd
!byte $00, $00, $00, $00, $00, $00, $00, $00 ; [UNUSED]
; $0070 [UNUSED]
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
; $0090
zeroScore
; clear the score (6 digits in 3 BCD bytes)
lda #0 ;
tax ;
-
sta score, x ;
inx ;
cpx #3 ;
bne - ;
jmp miner3EntryPoint ;
!byte $ff, $00 ; [UNUSED]
}
zeroPageDefaultsEnd
; [UNUSED]
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
; 8 poses of willy: 4 walking right and four walking left
; $0500
minerWilly
!pseudopc $0500 {
willyRight0
; right0
!byte $00, $33, $77, $33, $33, $33, $11, $33, $66, $ee, $cc, $44, $ee, $cc, $88, $cc
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $77, $77, $ff, $ff, $33, $77, $66, $77, $ee, $ee, $77, $bb, $cc, $66, $ee, $77
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
; right1
!byte $00, $00, $11, $00, $00, $00, $00, $00, $11, $ff, $ff, $dd, $ff, $ff, $66, $ff
!byte $88, $88, $00, $00, $88, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $11, $11, $11, $11, $00, $00, $00, $00, $bb, $bb, $bb, $dd, $ff, $66, $66, $77
!byte $88, $88, $88, $88, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
; right2
willyRight2
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $33, $77, $33, $33, $33, $11, $33
!byte $66, $ee, $cc, $44, $ee, $cc, $88, $cc, $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $77, $77, $ff, $ff, $33, $77, $66, $77
!byte $ee, $ee, $77, $bb, $cc, $66, $ee, $77, $00, $00, $00, $00, $00, $00, $00, $00
; right3
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $11, $00, $00, $00, $00, $00
!byte $11, $ff, $ff, $dd, $ff, $ff, $66, $ff, $88, $88, $00, $00, $88, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $11, $33, $77, $66, $00, $11, $33, $33
!byte $ff, $ff, $ff, $ff, $ff, $dd, $00, $88, $88, $cc, $ee, $66, $88, $aa, $ee, $44
; $0600
willyLeft0
; left0
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $66, $77, $33, $22, $77, $33, $11, $33, $00, $cc, $ee, $cc, $cc, $cc, $88, $cc
!byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $77, $77, $ee, $dd, $33, $66, $77, $ee, $ee, $ee, $ff, $ff, $cc, $ee, $66, $ee
; left1
!byte $00, $00, $00, $00, $00, $00, $00, $00, $11, $11, $00, $00, $11, $00, $00, $00
!byte $88, $ff, $ff, $bb, $ff, $ff, $66, $ff, $00, $00, $88, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $11, $11, $11, $11, $00, $00, $00, $00
!byte $dd, $dd, $dd, $bb, $ff, $66, $66, $ee, $88, $88, $88, $88, $00, $00, $00, $00
; left2
!byte $00, $00, $00, $00, $00, $00, $00, $00, $66, $77, $33, $22, $77, $33, $11, $33
!byte $00, $cc, $ee, $cc, $cc, $cc, $88, $cc, $00, $00, $00, $00, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00, $77, $77, $ee, $dd, $33, $66, $77, $ee
!byte $ee, $ee, $ff, $ff, $cc, $ee, $66, $ee, $00, $00, $00, $00, $00, $00, $00, $00
; left3
!byte $11, $11, $00, $00, $11, $00, $00, $00, $88, $ff, $ff, $bb, $ff, $ff, $66, $ff
!byte $00, $00, $88, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
!byte $11, $33, $77, $66, $11, $55, $77, $22, $ff, $ff, $ff, $ff, $ff, $bb, $00, $11
!byte $88, $cc, $ee, $66, $00, $88, $cc, $cc, $00, $00, $00, $00, $00, $00, $00, $00
}
minerWillyEnd
; Small caps flowery "MANIC MINER (C)" graphic
titleStart
!byte $00, $00, $00, $03, $04, $04, $04, $03, $07, $03, $06, $0c, $98, $30, $60, $c0
!byte $8e, $9c, $bc, $ec, $cc, $0c, $0c, $1e, $00, $0e, $1b, $31, $31, $7f, $60, $f1
!byte $00, $0e, $07, $87, $86, $c6, $c6, $ef, $00, $3d, $18, $98, $d8, $78, $38, $19
!byte $00, $e1, $c3, $c6, $c6, $c6, $c3, $e1, $00, $f0, $18, $00, $00, $00, $18, $f0
!byte $00, $01, $01, $00, $00, $00, $00, $00, $fe, $0f, $2d, $cc, $0c, $0c, $0c, $1e
!byte $1e, $3c, $ec, $cc, $0c, $0c, $0c, $1e, $00, $f7, $63, $63, $63, $63, $63, $f7
!byte $00, $1e, $8c, $cc, $6c, $3c, $1c, $8c, $00, $ff, $63, $68, $78, $68, $63, $ff
!byte $00, $7f, $30, $30, $3f, $31, $30, $78, $00, $80, $c0, $c0, $80, $80, $c8, $70
!byte $3c, $42, $99, $a1, $a1, $99, $42, $3c, $00, $00, $00, $00, $00, $00, $00, $00
titleEnd
!pseudopc $0790 {
; A Penrose triangle as encoded PLOT statements
penroseTriangle
!byte $fe, $01 ; GCOL 0,1
!byte $04, $19, $a0 ; MOVE 25, 160
!byte $05, $7d, $75 ; DRAW 125, 117 [could be a MOVE]
!byte $55, $19, $ad ; TRI 25, 173
!byte $55, $70, $87 ; TRI 112, 135
!byte $04, $7d, $75 ; MOVE 125, 117
!byte $05, $70, $87 ; DRAW 112, 135 [could be a MOVE]
!byte $55, $7d, $c6 ; TRI 125, 198
!byte $55, $70, $c0 ; TRI 112, 192
!byte $fe, $02 ; GCOL 0,2
!byte $04, $7d, $75 ; MOVE 125, 117
!byte $05, $89, $81 ; DRAW 137, 129 [could be a MOVE]
!byte $55, $7d, $c6 ; TRI 125, 198
!byte $55, $89, $d9 ; TRI 137, 217
!byte $04, $89, $d9 ; MOVE 137, 217 [redundant]
!byte $05, $7d, $c6 ; DRAW 125, 198 [could be a MOVE]
!byte $55, $38, $ad ; TRI 56, 173
!byte $55, $44, $a7 ; TRI 68, 167
!byte $fe, $03 ; GCOL 0,3
!byte $04, $70, $bf ; MOVE 112, 191
!byte $05, $70, $94 ; DRAW 112, 148
!byte $05, $44, $a7 ; DRAW 68, 167
!byte $05, $7d, $c6 ; DRAW 125, 198
!byte $05, $7d, $75 ; DRAW 125, 117
!byte $05, $19, $a0 ; DRAW 25, 160
!byte $05, $19, $ad ; DRAW 25, 173
!byte $05, $7d, $e5 ; DRAW 125, 229
!byte $05, $89, $d9 ; DRAW 137, 217
!byte $05, $89, $81 ; DRAW 137, 129
!byte $05, $7d, $75 ; DRAW 125, 117
!byte $04, $89, $d9 ; MOVE 137, 217
!byte $05, $38, $ad ; DRAW 56, 173
!byte $05, $70, $94 ; DRAW 112, 148 [partly overdraws existing line]
!byte $05, $70, $87 ; DRAW 112, 135
!byte $05, $19, $ad ; DRAW 25, 173
!byte $ff ; TERMINATOR
}
lda #$ff ; [UNUSED]
sta willyIsOnGround ; [UNUSED]
jmp $1ce8 ; [UNUSED]
!byte $00 ; [UNUSED]
!pseudopc $2c98 {
; ***************************************************************************************
getLevelDataByte
lda $2a28 ; [address is overwritten before use]
rts ;
; ***************************************************************************************
level18Thing
jsr drawFooterTextOrReturn ;
jmp afterLevel18Thing ;
; ***************************************************************************************
decodeSingleItemData
lda #0 ;
sta keyPositionCounter ;
lda #>(levelSingleItemDefinitions - 1) ;
sta getLevelDataByte + 2 ;
lda currentLevel ;
cmp #18 ;
beq level18Thing ;
afterLevel18Thing
lda #0 ;
sta decodeLevelByte ;
lda #<(levelSingleItemDefinitions - 1) ;
sta getLevelDataByte + 1 ;
skipToTerminator
jsr incrementLevelDataPointer ;
jsr getLevelDataByte ;
cmp #$ff ; level separator
beq + ;
jmp skipToTerminator ;
+
inc decodeLevelByte ; increment level counter
lda decodeLevelByte ;
cmp currentLevel ;
bne skipToTerminator ; if (not current room) then branch back (find next level separator)
jsr incrementLevelDataPointer ;
jsr getLevelDataByte ;
sta singleItemType ;
lda singleItemType ;
and #$3f ;
sta singleItemSpriteOffset ; singleItemSpriteOffset = bottom 6 bits
lda singleItemType ;
and #$c0 ;
clc ;
rol ;
rol ;
rol ;
sta singleItemType ;
inc singleItemType ; singleItemType = (top two bits / 64) + 1
lda #$f0 ;
sta singleItemSprite ; singleItemSprite = $f0
jsr setSingleOffsetX5 ; singleItemOffsetX = 5, type++
ldx #0 ;
jmp decodeNextSingleItem ;
; $2d00
; ***************************************************************************************
drawExtraSpikes
lda currentLevel ;
cmp #8 ; }
beq drawSpecialSpikes ; } special thinner spikes on
cmp #12 ; } the ceiling of levels 8 and 12
beq drawSpecialSpikes ; }
ldx #0 ; swap characters back
jmp swapPagesC00andA00 ;
; ***************************************************************************************
drawSpecialSpikes
lda #17 ; }
jsr OSWRCH ; }
lda #3 ; } COLOUR 3
jsr OSWRCH ; }
lda #31 ; }
jsr OSWRCH ; }
lda #6 ; }
jsr OSWRCH ; } TAB(6,1)
lda #1 ; }
jsr OSWRCH ; }
lda #$ec ; }
jsr OSWRCH ; } VDU &EC (spike)
lda #9 ;
ldx #0 ; loop counter
-
inx ;
jsr OSWRCH ; output seven forward spaces
cpx #7 ;
bne - ;
lda #$ec ; }
jsr OSWRCH ; } VDU &EC (second spike)
ldx #0 ; swap characters back
jmp swapPagesC00andA00 ;
; ***************************************************************************************
setSingleItemOffset15Command
jsr setSingleItemOffset15 ;
jmp decodeNextSingleItem ;
; ***************************************************************************************
setSingleItemNextTypeCommand
jsr setSingleOffsetX5 ;
lda singleItemSprite ;
sec ;
adc singleItemSpriteOffset ; add 1 + sprite offset to current sprite
sta singleItemSprite ;
jmp decodeNextSingleItem ;
; ***************************************************************************************
toggleAlternativeSingleItemSprite
jsr setSingleOffsetX5 ; X offset 5, type++
ldx #0 ;
jsr swapPagesC00andA00 ; swap pages
lda #$eb ; regular single item character code
sta singleItemSprite ;
jmp decodeNextSingleItem ;
; ***************************************************************************************
decodeNextSingleItem
jsr incrementLevelDataPointer ;
jsr getLevelDataByte ;
sta decodeLevelByte ;
cmp #$ff ;
beq drawExtraSpikes ; if (command 255) then branch (we are finished
; with this loop. Finally we draw the special
; spikes for level 8 and 12).
cmp #$fe ;
beq setSingleItemOffset15Command ; if (command 254) then set X offset to 15
cmp #$fd ;
beq setSingleItemNextTypeCommand ; if (command 253) then type += offset; set X offset to 5
dec singleItemType ;
lda decodeLevelByte ;
and #$f0 ; top nybble contains the X position
clc ;
ror ;
ror ;
ror ;
ror ;
sta singleItemX ;
lda decodeLevelByte ;
and #$0f ; bottom nybble contains the Y position
sta singleItemY ;
lda #31 ; TAB
jsr OSWRCH ;
lda singleItemX ;
clc ;
adc singleItemOffsetX ;
jsr OSWRCH ; X pos
lda singleItemY ;
clc ;
adc #1 ;
jsr OSWRCH ; Y pos
lda #17 ;
jsr OSWRCH ;
lda #2 ; COLOUR 2
jsr OSWRCH ;
lda singleItemSprite ;
cmp #$ee ;
beq drawSpiderAndThread ; if (spider) then branch
cmp #$f0 ;
beq handleKey ; if (key) then branch
cmp #$eb ;
bne handleColour1SingleItem ; if (colour 1 item) then branch
drawSingleItem
lda singleItemSprite ;
jsr OSWRCH ;
lda singleItemType ;
cmp #$ff ;
beq toggleAlternativeSingleItemSprite ;
jmp decodeNextSingleItem ;
; ***************************************************************************************
handleKey
lda #17 ;
jsr OSWRCH ;
lda #3 ; COLOUR 3
jsr OSWRCH ;
jmp recordKey ;
; ***************************************************************************************
handleColour1SingleItem
lda #17 ;
jsr OSWRCH ;
lda #1 ; COLOUR 1
jsr OSWRCH ;
jmp drawSingleItem ;
; ***************************************************************************************
setSingleItemOffset15
lda #$15 ;
sta singleItemOffsetX ;
rts ;
; ***************************************************************************************
setSingleOffsetX5
lda #5 ;
sta singleItemOffsetX ;
rts ;
singleItemSprite
!byte $ea ;
decodeLevelByte
!byte $ea ;
singleItemX
!byte $ea ;
singleItemY
!byte $ea ;
singleItemOffsetX
!byte $ea ;
singleItemType
!byte $ea ;
singleItemSpriteOffset
!byte $ea ;
; ***************************************************************************************
swapPagesC00andA00
lda softCharacterDefinitions,x ;
tay ;
lda $0a00,x ;
sta softCharacterDefinitions,x ;
tya ;
sta $0a00,x ;
inx ;
cpx #$ff ;
bne swapPagesC00andA00 ;
rts ;
; $2e18
; ***************************************************************************************
incrementLevelDataPointer
lda getLevelDataByte + 1 ;
clc ;
adc #1 ;
sta getLevelDataByte + 1 ;
lda getLevelDataByte + 2 ;
adc #0 ;
sta getLevelDataByte + 2 ;
rts
; ***************************************************************************************
drawSpiderAndThread
jsr incrementLevelDataPointer ;
jsr getLevelDataByte ;
sta decodeLevelByte ;
; draw line of vertical thread
ldx #0 ; loop counter
threadLoop
cpx decodeLevelByte ;
beq drawSpider ; if (length of thread reached) then branch
lda #$f5 ; draw vertical thread
jsr OSWRCH ;
lda #$0a ; move down one character
jsr OSWRCH ;
lda #$08 ;
jsr OSWRCH ; and back one character
inx ;
jmp threadLoop ;
; ***************************************************************************************
drawSpider
lda #$ee ; spider at end of thread
jsr OSWRCH ;
jmp decodeNextSingleItem ;
; ***************************************************************************************
recordKey
lda keyPositionCounter ;
cmp #keyPositionsEnd - keyPositions ; only store five keys (don't go beyond the end of the buffer)
bcc + ;
jmp drawSingleItem ;
+
lda singleItemX ;
clc ;
adc singleItemOffsetX ;
ldy keyPositionCounter ;
sta keyPositions,y ; store key position x
iny ;
lda singleItemY ;
clc ;
adc #1 ;
sta keyPositions,y ; store key position y
inc keyPositionCounter ;
inc keyPositionCounter ;
jmp drawSingleItem ;
keyPositions
!byte $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea
keyPositionsEnd
keyPositionCounter
!byte $0f ;
tempKeyIndex
!byte $16 ;
keyColourCounter
!byte $ea ;
; ***************************************************************************************
colourCycleKeys
lda #0 ;
tax ;
cycleKeyLoop
inc keyColourCounter ;
lda #31 ;
jsr OSWRCH ;
lda keyPositions,x ;
jsr OSWRCH ;
inx ;
lda keyPositions,x ;
jsr OSWRCH ;
inx ;
stx tempKeyIndex ;
lda #135 ;
jsr OSBYTE ; read character from screen
cpx #$90 ;
beq animateKey ; if (key present) then branch (animate key)
postAnimateKey
ldx tempKeyIndex ;
txa ;
cmp keyPositionCounter ;
bcs return12 ;
lda keyPositionCounter ;
lsr ;
and #1 ;
cmp #0 ;
beq + ;
jmp cycleKeyLoop ;
+
inc keyColourCounter ;
jmp cycleKeyLoop ;
return12
rts ;
animateKey
lda #17 ;
jsr OSWRCH ; COLOUR
lda keyColourCounter ;
and #3 ;
cmp #0 ;
beq handleColour0 ; COLOUR 1,2,3
setKeyColour
jsr OSWRCH ;
lda #$90 ; draw key
jsr OSWRCH ;
jmp postAnimateKey ;
handleColour0
lda #3 ; COLOUR 3
jmp setKeyColour ;
readRoomNameCharacter
lda $ffff,x ;
rts ;
drawRoomName
lda #<levelTitles ;
sta readRoomNameCharacter + 1 ;
lda #>levelTitles ;
sta readRoomNameCharacter + 2 ;
lda #0 ;
sta roomNumberReached ;
lda #31 ;
jsr OSWRCH ;
lda #4 ; TAB(4,17)
jsr OSWRCH ;
lda #17 ;
jsr OSWRCH ;
; print 32 spaces