-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdarktower.lst
5979 lines (5977 loc) · 294 KB
/
darktower.lst
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
1
2 ; *** Chapter 0 page 0
3
0:0:00 000:28 4 S000 ldx 0
0:0:01 001:21 5 tma
0:0:03 003:71 6 a9aac
0:0:07 007:BE 7 br S03E
0:0:0F 00F:61 8 S00F tcmiy 8
0:0:1F 01F:40 9 tcy 0
0:0:3F 03F:9B 10 br S01B
0:0:3E 03E:60 11 S03E tcmiy 0
12
13 ;
14 ; Rotate the drum to the position targeted in 4/0
15 ; Current position is in 0/0
16 ;
0:0:3D 03D:28 17 S03D ldx 0
0:0:3B 03B:40 18 tcy 0
0:0:37 037:21 19 tma
0:0:2F 02F:29 20 ldx 4
0:0:1E 01E:00 21 mnea
0:0:3C 03C:B3 22 br S033
0:0:39 039:0F 23 retn
24
0:0:33 033:18 25 S033 ldp 1
0:0:27 027:C0 26 call L040
0:0:0E 00E:2D 27 ldx 5
0:0:1D 01D:40 28 tcy 0
0:0:3A 03A:21 29 tma
0:0:35 035:2C 30 ldx 1
0:0:2B 02B:01 31 alem
0:0:16 016:98 32 br S018
0:0:2C 02C:80 33 br S000
0:0:18 018:00 34 S018 mnea
0:0:30 030:9C 35 br S01C
0:0:21 021:2B 36 ldx 6
0:0:02 002:21 37 tma
0:0:05 005:2A 38 ldx 2
0:0:0B 00B:01 39 alem
0:0:17 017:9C 40 br S01C
0:0:2E 02E:80 41 br S000
0:0:1C 01C:28 42 S01C ldx 0
0:0:38 038:21 43 tma
0:0:31 031:71 44 a9aac
0:0:23 023:8F 45 br S00F
0:0:06 006:3E 46 imac
0:0:0D 00D:27 47 tam
0:0:1B 01B:2B 48 S01B ldx 6
0:0:36 036:21 49 tma
0:0:2D 02D:06 50 amaac
0:0:1A 01A:91 51 br S011
0:0:34 034:2A 52 ldx 2
0:0:29 029:27 53 tam
0:0:12 012:2D 54 ldx 5
0:0:24 024:21 55 tma
0:0:08 008:A6 56 br S026
0:0:11 011:2A 57 S011 ldx 2
0:0:22 022:27 58 tam
0:0:04 004:2D 59 ldx 5
0:0:09 009:3E 60 imac
0:0:13 013:8A 61 br S00A
0:0:26 026:06 62 S026 amaac
0:0:0C 00C:8A 63 br S00A
0:0:19 019:2C 64 ldx 1
0:0:32 032:27 65 tam
0:0:25 025:BD 66 br S03D
0:0:0A 00A:2A 67 S00A ldx 2
0:0:15 015:67 68 tcmiy 14
0:0:2A 02A:2C 69 ldx 1
0:0:14 014:40 70 tcy 0
0:0:28 028:6F 71 tcmiy 15
0:0:10 010:BD 72 br S03D
0:0:20 020:00 73 mnea
74
75 ; *** Chapter 0 page 1
76
0:1:00 040:41 77 L040 tcy 8 ; Select the Rotation Sensor
0:1:01 041:0D 78 setr
0:1:03 043:49 79 tcy 9 ; Select the Motor
0:1:07 047:0D 80 setr
0:1:0F 04F:2B 81 ldx 6
0:1:1F 05F:40 82 tcy 0
0:1:3F 07F:60 83 tcmiy 0
0:1:3E 07E:2D 84 ldx 5
0:1:3D 07D:40 85 tcy 0
0:1:3B 07B:60 86 tcmiy 0
0:1:37 077:08 87 S077 tka
0:1:2F 06F:77 88 dan
0:1:1E 05E:8E 89 br S04E
0:1:3C 07C:B7 90 br S077
0:1:39 079:2B 91 S079 ldx 6
0:1:33 073:6F 92 tcmiy 15
0:1:27 067:B1 93 br S071
0:1:0E 04E:4A 94 S04E tcy 5
0:1:1D 05D:23 95 tya
0:1:3A 07A:41 96 tcy 8
0:1:35 075:04 97 S075 dyn
0:1:2B 06B:B5 98 br S075
0:1:16 056:77 99 dan
0:1:2C 06C:B5 100 br S075
0:1:18 058:2B 101 ldx 6
0:1:30 070:40 102 tcy 0
0:1:21 061:3E 103 imac
0:1:02 042:8B 104 br S04B
0:1:05 045:B8 105 br S078
0:1:0B 04B:27 106 S04B tam
0:1:17 057:2D 107 ldx 5
0:1:2E 06E:3E 108 imac
0:1:1C 05C:B9 109 br S079
0:1:38 078:27 110 S078 tam
0:1:31 071:08 111 S071 tka
0:1:23 063:77 112 dan
0:1:06 046:8E 113 br S04E
0:1:0D 04D:41 114 tcy 8
0:1:1B 05B:0C 115 rstr
0:1:36 076:49 116 tcy 9
0:1:2D 06D:0C 117 rstr
0:1:1A 05A:0F 118 retn
119
120 ;
121 ; RANDOM routine continues
122 ;
0:1:34 074:21 123 S074 tma ; Pick up value at 3/0, 3/1, 3/2
0:1:29 069:29 124 ldx 4
0:1:12 052:06 125 amaac ; Add 4/0, 4/1, 4/2 to it
0:1:24 064:D5 126 call S055 ; Increment 6/0, 6/1, 6/2 if carry
0:1:08 048:2D 127 ldx 5
0:1:11 051:06 128 amaac ; Add 5/0, 5/1, 5/2 to it
0:1:22 062:D5 129 call S055 ; Increment 6/0, 6/1, 6/2 if carry
0:1:04 044:2B 130 ldx 6
0:1:09 049:06 131 amaac ; Add 6/0, 6/1, 6/2 to it
0:1:13 053:D5 132 call S055 ; Increment 6/0, 6/1, 6/2 if carry
0:1:26 066:2E 133 ldx 3
0:1:0C 04C:25 134 tamiyc ; Store it at 3/0, 3/1, 3/2 then increment Y
0:1:19 059:5C 135 ynec 3 ; We done doing 0-2?
0:1:32 072:B4 136 br S074 ; Nope, do the next column
0:1:25 065:44 137 tcy 2
0:1:0A 04A:0F 138 retn
139
0:1:15 055:05 140 S055 iyc
0:1:2A 06A:2B 141 ldx 6
0:1:14 054:03 142 xma
0:1:28 068:70 143 iac
0:1:10 050:1E 144 ldp 7
0:1:20 060:94 145 br L1D4 ; xma, dyn, retn
146
147 ; *** Chapter 0 page 2
148
149 ;
150 ; Using the R output in A, scan the K inputs to find a key pressed
151 ;
152 ; For some reason the R output we're looking at is stored in 6/13 with the high-order bit set.
153 ;
0:2:00 080:4B 154 S080 tcy 13
0:2:01 081:27 155 tam ; Save the R output we're using at 6/13
0:2:03 083:7E 156 a8aac ; Toggle high-order bit
0:2:07 087:9F 157 br S09F ; There should have been a carry due to the way it's stored
0:2:0F 08F:7E 158 a8aac ; Nope, add 8 again to get it back (?)
0:2:1F 09F:20 159 S09F tay
0:2:3F 0BF:0D 160 setr ; Set R output addressed by Y
0:2:3E 0BE:08 161 tka ; Pick up K inputs from keyboard
0:2:3D 0BD:0C 162 rstr ; Reset R output addressed by Y
0:2:3B 0BB:47 163 tcy 14
0:2:37 0B7:03 164 xma ; Exchange 6/14 and results of TKA - Look at the last read?
165
0:2:2F 0AF:38 166 tbit1 0 ; Keyboard row 1 - Dark Tower/Frontier/Inventory - set? (3/7/11)
0:2:1E 09E:AE 167 br S0AE ; Add 3 to accumulator
168
0:2:3C 0BC:3B 169 tbit1 3 ; Keyboard row 2 - Tomb-Ruin/Move/Sanctuary-Citadel - set? (2/6/10)
0:2:39 0B9:9C 170 br S09C ; Add 2 to accumulator
171
0:2:33 0B3:39 172 tbit1 2 ; Keyboard row 3 - Haggle/Bazaar/Clear - set? (1/5/9)
0:2:27 0A7:B8 173 br S0B8 ; Add 1 to accumulator
174
0:2:0E 08E:3A 175 tbit1 1 ; Keyboard row 4 - Yes-Buy/Repeat/No-End - set? (0/4/8)
0:2:1D 09D:B1 176 br S0B1 ; Add nothing to accumulator
177
178 ;
179 ; No keys were detected, fall through
180 ;
0:2:3A 0BA:7C 181 a4aac ; Nothing was read? - A = 4
0:2:35 0B5:27 182 tam ; Save results at 6/14
183 ;
184 ; Entry point for keyboard read routine. Loop through the R output and scan the K inputs at S080
185 ;
0:2:2B 0AB:4B 186 READKBD tcy 13
0:2:16 096:07 187 dman ; Pick up the last R output we looked at and subtract one
0:2:2C 0AC:B0 188 br S0B0 ; We're not done scanning
0:2:18 098:85 189 br S085
0:2:30 0B0:20 190 S0B0 tay
0:2:21 0A1:5E 191 ynec 7
0:2:02 082:80 192 br S080 ; Go back and scan the next R output
193
0:2:05 085:47 194 S085 tcy 14
0:2:0B 08B:21 195 tma ; Load 6/14
0:2:17 097:B1 196 br S0B1
197
0:2:2E 0AE:70 198 S0AE iac
0:2:1C 09C:70 199 S09C iac
0:2:38 0B8:70 200 S0B8 iac
0:2:31 0B1:4F 201 S0B1 tcy 15
0:2:23 0A3:03 202 xma ; Swap 6/15 with results
0:2:06 086:00 203 mnea ; Compare this result to the last result
0:2:0D 08D:8A 204 br S08A ; Go back to prompt routine if they're different
205
0:2:1B 09B:20 206 tay
0:2:36 0B6:53 207 ynec 12
0:2:2D 0AD:91 208 br S091
0:2:1A 09A:4B 209 tcy 13
0:2:34 0B4:33 210 sbit 3 ; Set 6/13 bit 3
0:2:29 0A9:43 211 tcy 12
0:2:12 092:38 212 tbit1 0 ; 6/12 bit 0 set?
0:2:24 0A4:8A 213 br S08A ; Go back to prompt routine
0:2:08 088:89 214 br S089 ; Success, return?
215
0:2:11 091:43 216 S091 tcy 12
0:2:22 0A2:38 217 tbit1 0 ; 6/12 bit 0 set?
0:2:04 084:99 218 br S099
219
0:2:09 089:7F 220 S089 cla
0:2:13 093:77 221 dan
0:2:26 0A6:15 222 ldp 10
0:2:0C 08C:A2 223 br L2A2 ; TDO, pick up value in 6/15 to Y and return
224
0:2:19 099:4B 225 S099 tcy 13
0:2:32 0B2:3B 226 tbit1 3 ; 6/13 bit 3 set?
0:2:25 0A5:AA 227 br S0AA
0:2:0A 08A:1E 228 S08A ldp 7
0:2:15 095:86 229 br L1C6 ; Jump back into prompt routine and refresh the LEDs some more
230
0:2:2A 0AA:1C 231 S0AA ldp 3
0:2:14 094:0B 232 tpc
0:2:28 0A8:18 233 ldp 1
0:2:10 090:EC 234 call PLYTICK
0:2:20 0A0:89 235 br S089
236
237
238 ; *** Chapter 0 page 3
239
240 ;********************************************************************************
241 ; RANDOM
242 ;
243 ; Generate a random number based on the seed at 3/0-2 and 4/0-2
244 ; 5/0-2 and 6/0-2 are overwritten.
245 ;
246 ; Return value in A (0-F); Y=2
247 ;
248 ; The formula is:
249 ;
250 ; 3/0 * 2 -> 4/0 * 2 -> 5/1
251 ; 3/1 * 2 -> 4/1 * 2 -> 5/2
252 ; 3/2 * 2 -> 4/2
253 ; 3/0 + 4/0 + 5/0 + 6/0 -> 3/0 using 6/0 as carry
254 ; 3/1 + 4/1 + 5/1 + 6/1 -> 3/1 using 6/1 as carry
255 ; 3/2 + 4/2 + 5/2 + 6/2 -> 3/2 using 6/2 as carry
256 ;
257 ; Example: 3/0 = 0; 3/1 = 1; 3/2 = 2
258 ; 4/0 = 0; 4/1 = 0
259 ;
260 ; Results: 0 1 2 Y=2; A=A
261 ; -----
262 ; 3|0 3 A
263 ; 4|0 2 4
264 ; 5|0 0 4
265 ; 6|0 0 0
266 ;********************************************************************************
0:3:00 0C0:2D 267 RANDOM ldx 5
0:3:01 0C1:D5 268 call S0D5 ; Clear 5/0-2
0:3:03 0C3:2B 269 ldx 6
0:3:07 0C7:D5 270 call S0D5 ; Clear 6/0-2
0:3:0F 0CF:2E 271 ldx 3
0:3:1F 0DF:40 272 tcy 0
0:3:3F 0FF:21 273 tma ; Pick up value at 3/0 (Starting value)
0:3:3E 0FE:06 274 amaac ; Double it
0:3:3D 0FD:89 275 br S0C9 ; Branch if it overflowed
0:3:3B 0FB:29 276 ldx 4
0:3:37 0F7:27 277 tam ; Save it at 4/0
0:3:2F 0EF:06 278 S0EF amaac ; Double it
0:3:1E 0DE:A9 279 br S0E9 ; Branch if it overflowed
0:3:3C 0FC:2D 280 ldx 5
0:3:39 0F9:48 281 tcy 1
0:3:33 0F3:27 282 tam ; Save doubled value at 5/1
0:3:27 0E7:2E 283 S0E7 ldx 3
0:3:0E 0CE:21 284 tma ; Pick up value at 3/1 (Starting value)
0:3:1D 0DD:06 285 amaac ; Double it
0:3:3A 0FA:A3 286 br S0E3 ; Branch if it overflowed
0:3:35 0F5:29 287 ldx 4
0:3:2B 0EB:27 288 tam ; Save doubled value at 4/1
0:3:16 0D6:06 289 S0D6 amaac ; Double it
0:3:2C 0EC:2D 290 ldx 5
0:3:18 0D8:44 291 tcy 2
0:3:30 0F0:27 292 tam ; Save it at 5/2
0:3:21 0E1:2E 293 ldx 3
0:3:02 0C2:21 294 tma ; Pick up value at 3/2 (Starting value)
0:3:05 0C5:06 295 amaac ; Double it
0:3:0B 0CB:29 296 ldx 4
0:3:17 0D7:27 297 tam ; Save it at 4/2
0:3:2E 0EE:2E 298 ldx 3
0:3:1C 0DC:40 299 tcy 0
0:3:38 0F8:18 300 ldp 1
0:3:31 0F1:B4 301 br S074 ; Out of room here...
302
0:3:23 0E3:29 303 S0E3 ldx 4 ; 3/1 doubling caused an overflow...
0:3:06 0C6:25 304 tamiyc ; Save doubled value at 4/1
0:3:0D 0CD:2B 305 ldx 6
0:3:1B 0DB:3E 306 imac
0:3:36 0F6:24 307 tamdyn ; Add one to 6/2
0:3:2D 0ED:29 308 ldx 4
0:3:1A 0DA:21 309 tma ; Pick up 4/1
0:3:34 0F4:96 310 br S0D6 ; Go back and deal with the next digit
0:3:29 0E9:2D 311 S0E9 ldx 5
0:3:12 0D2:48 312 tcy 1
0:3:24 0E4:25 313 tamiyc
0:3:08 0C8:2B 314 ldx 6
0:3:11 0D1:3E 315 imac
0:3:22 0E2:24 316 tamdyn
0:3:04 0C4:A7 317 br S0E7
0:3:09 0C9:29 318 S0C9 ldx 4 ; 3/0 doubling caused an overflow
0:3:13 0D3:25 319 tamiyc ; Save doubled value at 4/0
0:3:26 0E6:2B 320 ldx 6
0:3:0C 0CC:68 321 tcmiy 1 ; Store a 1 at 6/1
0:3:19 0D9:64 322 tcmiy 2 ; Store a 2 at 6/2
0:3:32 0F2:29 323 ldx 4
0:3:25 0E5:40 324 tcy 0
0:3:0A 0CA:AF 325 br S0EF ; Go back and deal with the next digit
326
0:3:15 0D5:40 327 S0D5 tcy 0
0:3:2A 0EA:60 328 tcmiy 0
0:3:14 0D4:60 329 tcmiy 0
0:3:28 0E8:60 330 tcmiy 0
0:3:10 0D0:0F 331 retn
332
0:3:20 0E0:00 333 mnea
334
335 ; *** Chapter 0 page 4
336
337 ;********************************************************************************
338 ; AD2B10
339 ;
340 ; Perform Base 10 arithmetic on values in scratchpad RAM 4/1-2 and 5/1-2
341 ;
342 ; Add the two-digit base 10 number encoded in 4/1 and 4/2 to the two-digit
343 ; base 10 number encoded in 5/1 and 5/2 giving a three-digit base-10 number
344 ; encoded in 5/0-2.
345 ;
346 ; For example: 0 1 2 (x means doesn't matter--overwritten)
347 ; 4 x 1 9
348 ; 5 x 2 2
349 ;
350 ; Returns: 0 1 2
351 ; 4 0 1 9
352 ; 5 0 4 1
353 ;********************************************************************************
0:4:00 100:2D 354 AD2B10 ldx 5
0:4:01 101:40 355 tcy 0
0:4:03 103:60 356 tcmiy 0 ; 5/0 = 0
0:4:07 107:29 357 L107 ldx 4
0:4:0F 10F:40 358 tcy 0
0:4:1F 11F:60 359 tcmiy 0 ; 4/0 = 0
0:4:3F 13F:7F 360 SUMB10 cla ; SUMB10 - don't initialize 100s digit
0:4:3E 13E:44 361 tcy 2 ; Start at 4/2 with A=0
362 ;
363 ; Perform (4/Y + 5/Y) mod 10
364 ;
0:4:3D 13D:29 365 S13D ldx 4
0:4:3B 13B:06 366 amaac
0:4:37 137:2D 367 ldx 5
0:4:2F 12F:06 368 amaac ; A = 4/Y + 5/Y (Y = 2-0)
0:4:1E 11E:9D 369 br S11D ; Overflow?
0:4:3C 13C:7A 370 a6aac ; Add 6 to Accumulator - (do a MOD 10 operation; is the result >= 10?)
0:4:39 139:BA 371 br S13A ; Yes
372
0:4:33 133:79 373 a10aac ; Add 10 to Accumulator - (effectively back out the A6AAC operation)
0:4:27 127:26 374 tamza ; Save to 5/Y (Y = 2-0)
0:4:0E 10E:AB 375 br S12B
0:4:1D 11D:7A 376 S11D a6aac
0:4:3A 13A:26 377 S13A tamza
0:4:35 135:70 378 iac
0:4:2B 12B:04 379 S12B dyn
0:4:16 116:BD 380 br S13D
0:4:2C 12C:40 381 tcy 0
0:4:18 118:0F 382 retn
383
384 ;
385 ; Generate a random number between 17 and 32 - used to give a base Brigand count
386 ;
0:4:30 130:1C 387 L130 ldp 3
0:4:21 121:C0 388 call RANDOM ; Get a random number in ACC
0:4:02 102:29 389 ldx 4
0:4:05 105:48 390 tcy 1
0:4:0B 10B:60 391 tcmiy 0 ; 4/1 = 0
0:4:17 117:29 392 ldx 4
0:4:2E 12E:24 393 tamdyn ; 4/2 = ACC
0:4:1C 11C:2D 394 ldx 5
0:4:38 138:60 395 tcmiy 0 ; 5/1 = 0
0:4:31 131:60 396 tcmiy 0 ; 5/2 = 0
0:4:23 123:12 397 ldp 4
0:4:06 106:C0 398 call AD2B10 ; Copy random number to 5/2 via addition (?!)
0:4:0D 10D:29 399 ldx 4
0:4:1B 11B:48 400 tcy 1
0:4:36 136:68 401 tcmiy 1 ; 4/1 = 1
0:4:2D 12D:6E 402 tcmiy 7 ; 4/2 = 7
0:4:1A 11A:12 403 ldp 4
0:4:34 134:80 404 br AD2B10 ; Add 17 and return
405
406 ;
407 ; Generate a random number between 9 and 16. Used by Santuary to calculate
408 ; how much food or gold to provide the player.
409 ;
0:4:29 129:1C 410 L129 ldp 3
0:4:12 112:C0 411 call RANDOM
0:4:24 124:29 412 ldx 4
0:4:08 108:24 413 tamdyn ; 4/2 = ACC
0:4:11 111:60 414 tcmiy 0 ; 4/1 = 0
0:4:22 122:37 415 rbit 3 ; Limit 4/2 to 0-7
0:4:04 104:2D 416 ldx 5
0:4:09 109:48 417 tcy 1
0:4:13 113:60 418 tcmiy 0 ; 5/1 = 0
0:4:26 126:69 419 tcmiy 9 ; 5/2 = 9
0:4:0C 10C:C0 420 call AD2B10
0:4:19 119:18 421 ldp 1
0:4:32 132:0B 422 tpc
0:4:25 125:13 423 ldp 12
0:4:0A 10A:A7 424 br CPY5TO4 ; Be neat about it and copy the amount up to the top of the formula
425
426 ;
427 ; Add 16 to 5/1-2
428 ;
0:4:15 115:29 429 ADD16 ldx 4
0:4:2A 12A:48 430 tcy 1
0:4:14 114:68 431 tcmiy 1 ; 4/1 = 16
0:4:28 128:66 432 tcmiy 6
0:4:10 110:12 433 ldp 4
0:4:20 120:80 434 br AD2B10
435
436 ; *** Chapter 0 page 5
437
438 ;********************************************************************************
439 ; DSPRSLT
440 ;
441 ; Display the results of an encounter or inventory
442 ; Called after encounter as well as when Repeat button is hit
443 ;
444 ; Note about status flags. The tests assume the bit being set means
445 ; the inventory doesn't need to be shown. Cleared means display the
446 ; current status.
447 ;********************************************************************************
0:5:00 140:29 448 DSPRSLT ldx 4
0:5:01 141:4B 449 tcy 13
0:5:03 143:38 450 tbit1 0 ; Warrior count change during encounter
0:5:07 147:B3 451 br S173
452 ;
453 ; Display Warrior count
454 ;
0:5:0F 14F:48 455 tcy 1 ; Switch drum to Warrior/Food/Beast position
0:5:1F 15F:11 456 ldp 8
0:5:3F 17F:D5 457 call ROTDRUM
0:5:3E 17E:18 458 ldp 1
0:5:3D 17D:0B 459 tpc
0:5:3B 17B:16 460 ldp 6
0:5:37 177:F2 461 call CPY2TO5 ; Copy the warrior count for current player to 5/1 and 5/2
0:5:2F 16F:11 462 ldp 8
0:5:1E 15E:E4 463 call BUF2DSP ; Update display buffer with contents of 5/1 and 5/2
0:5:3C 17C:19 464 ldp 9
0:5:39 179:C1 465 call L241 ; Light top window and update display from display buffer???
466
0:5:33 173:29 467 S173 ldx 4
0:5:27 167:4B 468 tcy 13
0:5:0E 14E:3A 469 tbit1 1 ; Food change during encounter
0:5:1D 15D:97 470 br S157
471 ;
472 ; Display Food
473 ;
0:5:3A 17A:48 474 tcy 1 ; Switch drum to Warrior/Food/Beast position
0:5:35 175:11 475 ldp 8
0:5:2B 16B:D5 476 call ROTDRUM
0:5:16 156:18 477 ldp 1
0:5:2C 16C:0B 478 tpc
0:5:18 158:13 479 ldp 12
0:5:30 170:EC 480 call CPY1TO5 ; Copy the gold amount for current player to 5/1 and 5/2
0:5:21 161:11 481 ldp 8
0:5:02 142:E4 482 call BUF2DSP ; Update display buffer with contents of 5/1 and 5/2
0:5:05 145:19 483 ldp 9
0:5:0B 14B:DF 484 call L25F
485
0:5:17 157:29 486 S157 ldx 4
0:5:2E 16E:4B 487 tcy 13
0:5:1C 15C:3B 488 tbit1 3 ; Beast found during encounter
0:5:38 178:92 489 br S152
490 ;
491 ; Display Beast
492 ;
0:5:31 171:2C 493 ldx 1
0:5:23 163:4C 494 tcy 3
0:5:06 146:38 495 tbit1 0 ; Check inventory for Beast
0:5:0D 14D:B6 496 br S176
0:5:1B 15B:92 497 br S152
0:5:36 176:48 498 S176 tcy 1 ; Switch drum to Warrior/Food/Beast position
0:5:2D 16D:11 499 ldp 8
0:5:1A 15A:D5 500 call ROTDRUM
0:5:34 174:19 501 ldp 9
0:5:29 169:FD 502 call LTLWRCL ; Light lower window
503
0:5:12 152:29 504 S152 ldx 4
0:5:24 164:47 505 tcy 14
0:5:08 148:38 506 tbit1 0 ; Scout found during encounter
0:5:11 151:95 507 br S155
508 ;
509 ; Display Scout
510 ;
0:5:22 162:2C 511 ldx 1
0:5:04 144:4C 512 tcy 3
0:5:09 149:3B 513 tbit1 3 ; Check inventory for Scout
0:5:13 153:8C 514 br S14C
0:5:26 166:95 515 br S155
0:5:0C 14C:44 516 S14C tcy 2 ; Switch drum to Scout/Healer/Gold position
0:5:19 159:11 517 ldp 8
0:5:32 172:D5 518 call ROTDRUM
0:5:25 165:19 519 ldp 9
0:5:0A 14A:C0 520 call LTTOPCL ; Light Scout and clear display
521
0:5:15 155:29 522 S155 ldx 4
0:5:2A 16A:47 523 tcy 14
0:5:14 154:16 524 ldp 6
0:5:28 168:3A 525 tbit1 1 ; Healer found during encounter?
0:5:10 150:B7 526 br L1B7
0:5:20 160:80 527 br S180
528
529
530 ; *** Chapter 0 page 6
531
532 ;
533 ; Display Healer
534 ;
0:6:00 180:2C 535 S180 ldx 1
0:6:01 181:4C 536 tcy 3
0:6:03 183:3A 537 tbit1 1 ; Check inventory for Healer
0:6:07 187:9F 538 br S19F
0:6:0F 18F:B7 539 br L1B7
0:6:1F 19F:44 540 S19F tcy 2 ; Switch drum to Scout/Healer/Gold position
0:6:3F 1BF:11 541 ldp 8
0:6:3E 1BE:D5 542 call ROTDRUM
0:6:3D 1BD:19 543 ldp 9
0:6:3B 1BB:CF 544 call LTMIDCL ; Light Healer and clear display
545
0:6:37 1B7:29 546 L1B7 ldx 4
0:6:2F 1AF:4B 547 tcy 13
0:6:1E 19E:39 548 tbit1 2 ; Gold found during encounter?
0:6:3C 1BC:B0 549 br S1B0
550 ;
551 ; Display Gold
552 ;
0:6:39 1B9:44 553 tcy 2 ; Switch drum to Scout/Healer/Gold position
0:6:33 1B3:11 554 ldp 8
0:6:27 1A7:D5 555 call ROTDRUM
0:6:0E 18E:18 556 ldp 1
0:6:1D 19D:0B 557 tpc
0:6:3A 1BA:13 558 ldp 12
0:6:35 1B5:D7 559 call CPY0TO5
0:6:2B 1AB:11 560 ldp 8
0:6:16 196:E4 561 call BUF2DSP ; Update display buffer with contents of 5/1 and 5/2
0:6:2C 1AC:19 562 ldp 9
0:6:18 198:FB 563 call L27B ; Light bottom window and update display from display buffer???
564
0:6:30 1B0:29 565 S1B0 ldx 4
0:6:21 1A1:4F 566 tcy 15
0:6:02 182:38 567 tbit1 0 ; Gold Key found during encounter?
0:6:05 185:B6 568 br S1B6
569 ;
570 ; Display Gold Key
571 ;
0:6:0B 18B:2A 572 ldx 2
0:6:17 197:4C 573 tcy 3
0:6:2E 1AE:3B 574 tbit1 3 ; Check inventory for Gold Key
0:6:1C 19C:B1 575 br S1B1
0:6:38 1B8:B6 576 br S1B6
0:6:31 1B1:4C 577 S1B1 tcy 3 ; Switch drum to Gold Key/Silver Key/Brass Key
0:6:23 1A3:11 578 ldp 8
0:6:06 186:D5 579 call ROTDRUM
0:6:0D 18D:19 580 ldp 9
0:6:1B 19B:C0 581 call LTTOPCL ; Light Gold Key and clear display
582
0:6:36 1B6:29 583 S1B6 ldx 4
0:6:2D 1AD:47 584 tcy 14
0:6:1A 19A:3B 585 tbit1 3 ; Silver Key found during encounter?
0:6:34 1B4:8C 586 br S18C
587 ;
588 ; Display Silver Key
589 ;
0:6:29 1A9:2A 590 ldx 2
0:6:12 192:4C 591 tcy 3
0:6:24 1A4:39 592 tbit1 2 ; Check inventory for Silver Key
0:6:08 188:A2 593 br S1A2
0:6:11 191:8C 594 br S18C
0:6:22 1A2:4C 595 S1A2 tcy 3 ; Switch drum to Gold Key/Silver Key/Brass Key
0:6:04 184:11 596 ldp 8
0:6:09 189:D5 597 call ROTDRUM
0:6:13 193:19 598 ldp 9
0:6:26 1A6:CF 599 call LTMIDCL ; Light Silver Key and clear display
600
0:6:0C 18C:29 601 S18C ldx 4
0:6:19 199:47 602 tcy 14
0:6:32 1B2:1E 603 ldp 7
0:6:25 1A5:39 604 tbit1 2 ; Brass Key found during encounter?
0:6:0A 18A:9F 605 br L1DF
606 ;
607 ; Display Brass Key
608 ;
0:6:15 195:2A 609 ldx 2
0:6:2A 1AA:4C 610 tcy 3
0:6:14 194:3A 611 tbit1 1 ; Check inventory for Brass Key
0:6:28 1A8:80 612 br L1C0
0:6:10 190:9F 613 br L1DF
0:6:20 1A0:00 614 mnea
615
616 ; *** Chapter 0 page 7
617
0:7:00 1C0:4C 618 L1C0 tcy 3 ; Switch drum to Gold Key/Silver Key/Brass Key
0:7:01 1C1:11 619 ldp 8
0:7:03 1C3:D5 620 call ROTDRUM
0:7:07 1C7:19 621 ldp 9
0:7:0F 1CF:FD 622 call LTLWRCL ; Light lower window
623
0:7:1F 1DF:29 624 L1DF ldx 4
0:7:3F 1FF:4F 625 tcy 15
0:7:3E 1FE:3A 626 tbit1 1 ; Sword resulting from encounter?
0:7:3D 1FD:BA 627 br S1FA
628 ;
629 ; Display Sword if in inventory
630 ;
0:7:3B 1FB:2C 631 ldx 1
0:7:37 1F7:4C 632 tcy 3
0:7:2F 1EF:39 633 tbit1 2 ; Check inventory for Sword
0:7:1E 1DE:B9 634 br S1F9
0:7:3C 1FC:BA 635 br S1FA
0:7:39 1F9:42 636 S1F9 tcy 4 ; Switch drum to Dragon/Sword/Pegasus
0:7:33 1F3:11 637 ldp 8
0:7:27 1E7:D5 638 call ROTDRUM
0:7:0E 1CE:19 639 ldp 9
0:7:1D 1DD:CF 640 call LTMIDCL ; Light Sword and clear display
641 ;
642 ; Display Pegasus?
643 ;
644 ; Note, Pegasus isn't an inventory item so there is no check for it
645 ;
0:7:3A 1FA:29 646 S1FA ldx 4
0:7:35 1F5:4F 647 tcy 15
0:7:2B 1EB:39 648 tbit1 2 ; Pegasus resulting from encounter?
0:7:16 1D6:85 649 br S1C5
650
0:7:2C 1EC:42 651 tcy 4 ; Switch drum to Dragon/Sword/Pegasus
0:7:18 1D8:11 652 ldp 8
0:7:30 1F0:D5 653 call ROTDRUM
0:7:21 1E1:19 654 ldp 9
0:7:02 1C2:FD 655 call LTLWRCL ; Light lower window
0:7:05 1C5:0F 656 S1C5 retn
657
658 ;********************************************************************************
659 ; PROMPT - Prompt user for input
660 ;
661 ; Update display with contents of 7/14 and 7/15, flash and wait for keypress
662 ;
663 ; Return key pressed in Y:
664 ; 0 = Yes/Buy 6 = Move
665 ; 1 = Haggle 7 = Frontier
666 ; 2 = Tomb/Ruin 8 = No/End
667 ; 3 = Dark Tower 9 = Clear
668 ; 4 = Repeat 10 = Sanctuary/Citadel
669 ; 5 = Bazaar 11 = Inventory
670 ;********************************************************************************
0:7:0B 1CB:2B 671 PROMPT ldx 6
0:7:17 1D7:43 672 tcy 12
0:7:2E 1EE:30 673 sbit 0
0:7:1C 1DC:35 674 rbit 2 ; Don't update LEDs immediately (?)
0:7:38 1F8:2B 675 L1F8 ldx 6
0:7:31 1F1:4B 676 tcy 13
0:7:23 1E3:37 677 rbit 3
678
0:7:06 1C6:15 679 L1C6 ldp 10
0:7:0D 1CD:C0 680 call REFRLED
0:7:1B 1DB:15 681 ldp 10
0:7:36 1F6:C0 682 call REFRLED
0:7:2D 1ED:15 683 ldp 10
0:7:1A 1DA:C0 684 call REFRLED
0:7:34 1F4:2E 685 ldx 3
0:7:29 1E9:44 686 tcy 2
0:7:12 1D2:21 687 tma
0:7:24 1E4:76 688 a7aac
0:7:08 1C8:CA 689 call S1CA
0:7:11 1D1:27 690 tam
691 ;
692 ; Set things up before reading the keyboard
693 ;
0:7:22 1E2:2B 694 ldx 6
0:7:04 1C4:4B 695 tcy 13
0:7:09 1C9:35 696 rbit 2
0:7:13 1D3:32 697 sbit 1
0:7:26 1E6:30 698 sbit 0
0:7:0C 1CC:47 699 tcy 14
0:7:19 1D9:60 700 tcmiy 0
0:7:32 1F2:14 701 ldp 2
0:7:25 1E5:AB 702 br READKBD
703
0:7:0A 1CA:24 704 S1CA tamdyn
0:7:15 1D5:3E 705 imac
0:7:2A 1EA:0F 706 retn
707
0:7:14 1D4:03 708 L1D4 xma
0:7:28 1E8:04 709 dyn
0:7:10 1D0:0F 710 retn
711
0:7:20 1E0:00 712 mnea
713
714 ; *** Chapter 0 page 8
715
716 ;
717 ; Rotate the player RAM buffer so the next player is in the first
718 ; position
719 ;
0:8:00 200:28 720 L200 ldx 0 ; Rotate 0/1-12 left three times
0:8:01 201:F0 721 call S230
0:8:03 203:F0 722 call S230
0:8:07 207:F0 723 call S230
0:8:0F 20F:2C 724 ldx 1 ; Rotate 1/1-12 left three times
0:8:1F 21F:F0 725 call S230
0:8:3F 23F:F0 726 call S230
0:8:3E 23E:F0 727 call S230
0:8:3D 23D:2A 728 ldx 2 ; Rotate 2/1-12 left three times
0:8:3B 23B:F0 729 call S230
0:8:37 237:F0 730 call S230
0:8:2F 22F:F0 731 call S230
732
0:8:1E 21E:2E 733 ldx 3
0:8:3C 23C:4D 734 tcy 11
0:8:39 239:21 735 tma ; Pick up the current player from 3/11
0:8:33 233:7D 736 a12aac ; Add 12 to generate an overflow if we're on player 4
0:8:27 227:9D 737 br S21D ; Overflow, it's P0 right now
0:8:0E 20E:7C 738 a4aac ; Add 4 to get us back to where we should be
739
0:8:1D 21D:70 740 S21D iac ; Next player...
0:8:3A 23A:27 741 tam ; Update current player at 3/11
0:8:35 235:49 742 tcy 9
0:8:2B 22B:01 743 alem ; Check that we're not exceeding the total number of players playing
0:8:16 216:98 744 br S218 ; We're done
0:8:2C 22C:80 745 br L200 ; Oops. Do another rotation
746
0:8:18 218:0F 747 S218 retn
748
749 ;
750 ; Rotate the current register file words 1-12 left one word
751 ;
0:8:30 230:43 752 S230 tcy 12 ; Start at 12
0:8:21 221:21 753 tma ; Get a copy of what's at the current position
0:8:02 202:04 754 dyn ; Move pointer left
0:8:05 205:03 755 S205 xma ; Swap
0:8:0B 20B:04 756 dyn ; Move pointer left
0:8:17 217:50 757 ynec 0 ; Are we pointing at zero?
0:8:2E 22E:85 758 br S205 ; Nope, do it again
0:8:1C 21C:43 759 tcy 12 ; Final step, copy what was at 1
0:8:38 238:27 760 tam ; To 12
0:8:31 231:0F 761 retn
762
763 ;********************************************************************************
764 ; RND0TO2 - Return a random value from 0 to 2 in A
765 ;
766 ; 11 - 15 - A = 2
767 ; 6 - 10 - A = 1
768 ; 0 - 5 - A = 0
769 ;********************************************************************************
0:8:23 223:1C 770 RND0TO2 ldp 3
0:8:06 206:C0 771 call RANDOM
0:8:0D 20D:48 772 L20D tcy 1
0:8:1B 21B:72 773 S21B a5aac
0:8:36 236:B4 774 br S234
0:8:2D 22D:04 775 dyn
0:8:1A 21A:9B 776 br S21B
0:8:34 234:23 777 S234 tya
0:8:29 229:70 778 iac
0:8:12 212:0F 779 retn
780
781 ;********************************************************************************
782 ; BUF2DSP - Load 5/1 and 5/2 into the display buffer 7/14 and 7/15 respectively
783 ;********************************************************************************
0:8:24 224:2D 784 BUF2DSP ldx 5
0:8:08 208:48 785 tcy 1
0:8:11 211:21 786 tma
0:8:22 222:2F 787 ldx 7
0:8:04 204:47 788 tcy 14
0:8:09 209:27 789 tam
0:8:13 213:2D 790 ldx 5
0:8:26 226:44 791 tcy 2
0:8:0C 20C:21 792 tma
0:8:19 219:2F 793 ldx 7
0:8:32 232:4F 794 tcy 15
0:8:25 225:27 795 tam
0:8:0A 20A:0F 796 retn
797
798 ;********************************************************************************
799 ; ROTDRUM - Rotate the drum to the position specified in Y
800 ;********************************************************************************
0:8:15 215:23 801 ROTDRUM tya
0:8:2A 22A:29 802 ldx 4
0:8:14 214:40 803 tcy 0
0:8:28 228:27 804 tam
0:8:10 210:10 805 ldp 0
0:8:20 220:BD 806 br S03D
807
808 ; *** Chapter 0 page 9
809
810 ;********************************************************************************
811 ; LTTOPCL - Clear display and light top lamp
812 ;********************************************************************************
0:9:00 240:DA 813 LTTOPCL call S25A ; Load blanks into 7/14-15
0:9:01 241:C8 814 L241 call S248 ; Set for immediate update of LEDS (6/12 bit 2 set)
0:9:03 243:4E 815 tcy 7 ; Select upper lamp
0:9:07 247:AF 816 br S26F
817
818 ;********************************************************************************
819 ; LTMIDCL - Clear display and light middle lamp
820 ;********************************************************************************
0:9:0F 24F:DA 821 LTMIDCL call S25A ; Load blanks into 7/14-15
0:9:1F 25F:C8 822 L25F call S248 ; Set for immediate update of LEDS (6/12 bit 2 set)
0:9:3F 27F:46 823 tcy 6 ; Select middle lamp
0:9:3E 27E:AF 824 br S26F
825
826 ;********************************************************************************
827 ; LTLWRCL - Clear display and light lower lamp
828 ;********************************************************************************
0:9:3D 27D:DA 829 LTLWRCL call S25A ; Load blanks into 7/14-15
0:9:3B 27B:C8 830 L27B call S248 ; Set for immediate update of LEDS (6/12 bit 2 set)
0:9:37 277:4A 831 tcy 5 ; Select lower lamp
832
833 ;
834 ; Light the lamp referenced in Y, beep, update the LEDs and loop over REFRLED
835 ;
0:9:2F 26F:0D 836 S26F setr ; Light the selected lamp
0:9:1E 25E:1C 837 ldp 3
0:9:3C 27C:0B 838 tpc
0:9:39 279:1B 839 ldp 13
0:9:33 273:C9 840 call PLYBEEP
0:9:27 267:2B 841 L267 ldx 6
0:9:0E 24E:43 842 tcy 12
0:9:1D 25D:31 843 sbit 2 ; 6/12 bit 2 set - Immediate update of LEDs
844 ;
845 ; Call REFRLED $BF (191) times
846 ;
0:9:3A 27A:2B 847 ldx 6
0:9:35 275:40 848 tcy 0
0:9:2B 26B:6F 849 tcmiy 15 ; 6/0 = 15
0:9:16 256:6D 850 tcmiy 11 ; 6/1 = 11
0:9:2C 26C:27 851 S26C tam ; 6/2 = A
0:9:18 258:15 852 ldp 10
0:9:30 270:C0 853 call REFRLED
0:9:21 261:2B 854 ldx 6
0:9:02 242:40 855 tcy 0
0:9:05 245:07 856 dman ; Acc = 6/0 - 1
0:9:0B 24B:AC 857 br S26C ; Update 6/0 and loop
0:9:17 257:25 858 tamiyc ; Acc has overflowed; update 6/0 and focus on 6/1
0:9:2E 26E:07 859 dman ; Decrement 6/1
0:9:1C 25C:AC 860 br S26C ; Update 6/1 and loop
861 ;
862 ; We've called REFRLED enough times; turn off the lamps
863 ;
0:9:38 278:0A 864 tdo
0:9:31 271:4E 865 tcy 7 ; Select Upper lamp
0:9:23 263:0C 866 rstr ; Turn it off
0:9:06 246:46 867 tcy 6 ; Select Middle lamp
0:9:0D 24D:0C 868 rstr ; Turn it off
0:9:1B 25B:4A 869 tcy 5 ; Select Lower lamp
0:9:36 276:0C 870 rstr ; Turn it off
871
0:9:2D 26D:0F 872 retn
873 ;
874 ; Load blanks into display buffer (7/14-15)
875 ;
0:9:1A 25A:2F 876 S25A ldx 7
0:9:34 274:47 877 tcy 14
0:9:29 269:6F 878 tcmiy 15 ; 7/14 = 15 (" ")
0:9:12 252:6F 879 tcmiy 15 ; 7/15 = 15 (" ")
0:9:24 264:0F 880 retn
881 ;
882 ; Set for immediate update of LEDs on call to REFRLED (6/12 bit 2 set)
883 ;
0:9:08 248:2B 884 S248 ldx 6
0:9:11 251:43 885 tcy 12
0:9:22 262:31 886 sbit 2
0:9:04 244:0F 887 retn
888
889 ;********************************************************************************
890 ; CPYBRIG - Copy the current brigand count (3/12-13) to 5/1-2 for base 10 math
891 ;********************************************************************************
0:9:09 249:2E 892 CPYBRIG ldx 3
0:9:13 253:43 893 tcy 12
0:9:26 266:21 894 tma
0:9:0C 24C:2D 895 ldx 5
0:9:19 259:48 896 tcy 1
0:9:32 272:27 897 tam
0:9:25 265:2E 898 ldx 3
0:9:0A 24A:4B 899 tcy 13
0:9:15 255:21 900 tma
0:9:2A 26A:2D 901 ldx 5
0:9:14 254:44 902 tcy 2
0:9:28 268:27 903 tam
0:9:10 250:0F 904 retn
905
0:9:20 260:00 906 mnea
907
908 ; *** Chapter 0 page 10
909
910 ;********************************************************************************
911 ; REFRLED
912 ;
913 ; Refresh the contents of the LEDs either with new data or handle flashing
914 ;
915 ;********************************************************************************
0:A:00 280:2B 916 REFRLED ldx 6
0:A:01 281:43 917 tcy 12
0:A:03 283:39 918 tbit1 2 ; 6/12 Bit 2 - Immediate update of LEDs. Bypass flashing.
0:A:07 287:A1 919 br S2A1
920 ;
921 ; Decrement countdown timer in 7/12-13. When it expires, it checks what's currently displayed
922 ; in the LED segments (6/12 Bit 1). If it's reset, it does a TDO and clears the display. It then
923 ; toggles the bit.
924 ;
0:A:0F 28F:2F 925 ldx 7
0:A:1F 29F:4B 926 tcy 13
0:A:3F 2BF:07 927 dman
0:A:3E 2BE:AB 928 br S2AB
0:A:3D 2BD:24 929 tamdyn ; 7/13 = 7/13 - 1
0:A:3B 2BB:07 930 dman ; A = 7/12 - 1
0:A:37 2B7:AB 931 br S2AB
932 ;
933 ; Countdown has expired. Acc has 15 (" ") in it due to underflow. If 6/12 bit 1 is reset, the
934 ; display has data in it. Blank the display with a TDO. In either case, toggle 6/12 bit 1.
935 ;
0:A:2F 2AF:68 936 tcmiy 1 ; Reset 7/12 - $1F
0:A:1E 29E:2B 937 ldx 6
0:A:3C 2BC:43 938 tcy 12
0:A:39 2B9:3A 939 tbit1 1 ; 6/12 Bit 1 - Display currently blank
0:A:33 2B3:BA 940 br S2BA
0:A:27 2A7:32 941 sbit 1 ; Set 6/12 Bit 1 - Display now blank
0:A:0E 28E:0A 942 tdo ; Transfer Accumulator to O outputs - Clear display (Load 15 [" "] into LED)
0:A:1D 29D:9A 943 br S29A
0:A:3A 2BA:36 944 S2BA rbit 1 ; Clear 6/12 Bit 1 - Display now not blank
0:A:35 2B5:A1 945 br S2A1
946
0:A:2B 2AB:27 947 S2AB tam
0:A:16 296:2B 948 ldx 6
0:A:2C 2AC:43 949 tcy 12
0:A:18 298:3A 950 tbit1 1 ; Is display currently blank (6/12 Bit 1 set)?
0:A:30 2B0:9A 951 br S29A ; Bit 1 is set. Skip update and just delay
952 ;
953 ; Update the LED segments with the contents of 7/14-15
954 ;
0:A:21 2A1:21 955 S2A1 tma ; Load 6/12
0:A:02 282:20 956 tay ; Save it...
0:A:05 285:7E 957 a8aac ; Toggle 6/12 bit 3
0:A:0B 28B:AE 958 br S2AE ; It's now clear; we want the Status Latch set to 1
0:A:17 297:20 959 tay ; It's now set; we want the Status Latch set to 0
0:A:2E 2AE:02 960 S2AE ynea ; Update Status Latch to select correct LED segment based on prior steps
0:A:1C 29C:43 961 tcy 12
0:A:38 2B8:27 962 tam ; Update 6/12 with the new state of 6/12 Bit 3
0:A:31 2B1:2F 963 ldx 7
0:A:23 2A3:47 964 tcy 14 ; Select 7/14
0:A:06 286:7E 965 a8aac ; Flip bit 3 of Accumulator BACK to test it (from the earlier work on 6/12)
0:A:0D 28D:B6 966 br S2B6 ; There was a carry, we have the right segment (Bit 3 was set)
0:A:1B 29B:4F 967 tcy 15 ; Switch to 7/15 (Bit 3 was clear)
0:A:36 2B6:21 968 S2B6 tma ; Pick up value in the referenced LED display buffer
0:A:2D 2AD:0A 969 tdo ; Transfer Accumulator to O outputs - Update the LED display
970
971 ;
972 ; Display has been updated; delay for 255 loops and return
973 ;
0:A:1A 29A:4F 974 S29A tcy 15
0:A:34 2B4:23 975 tya
0:A:29 2A9:04 976 S2A9 dyn
0:A:12 292:A9 977 br S2A9
0:A:24 2A4:77 978 dan
0:A:08 288:A9 979 br S2A9
0:A:11 291:0F 980 retn
981 ;
982 ; Used by read keyboard routine
983 ;
0:A:22 2A2:0A 984 L2A2 tdo
0:A:04 284:2B 985 ldx 6
0:A:09 289:4F 986 tcy 15
0:A:13 293:22 987 tmy
0:A:26 2A6:0F 988 retn
989 ;
990 ; Copy 5/2-0 to 7/2-0
991 ;
0:A:0C 28C:44 992 L28C tcy 2
0:A:19 299:2D 993 S299 ldx 5
0:A:32 2B2:21 994 tma
0:A:25 2A5:2F 995 ldx 7
0:A:0A 28A:24 996 tamdyn
0:A:15 295:99 997 br S299
0:A:2A 2AA:0F 998 retn
999 ;
1000 ; This code looks to be unused... Odd. There's also a chunk of code