-
Notifications
You must be signed in to change notification settings - Fork 78
/
c64disasm_mn.txt
4769 lines (4581 loc) · 208 KB
/
c64disasm_mn.txt
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
- Commented Commodore 64 KERNAL Disassembly (Magnus Nyman)
-
- The comments have been taken from
- JIFFYDOS version 6.01/version 6.02 by Magnus Nyman (Harlekin/FairLight)
-
- The original comments were meant for the JiffyDOS KERNAL, so it had to be
- adapted for the regular KERNAL (901227-03, $FF80 = 3). Therefore, some serial
- code and all tape code is missing comments.
-
- Converted, formatted and adapted by Michael Steil <[email protected]>
-
- Corrections (typos, formatting, content) welcome at:
- https://github.com/mist64/c64ref
-
------------------------------------------------------------
-
# This plain text file is formatted so that it can be automatically
# parsed in order to create cross-references etc.
# * Lines starting with "-" is top-level information. The first line
# is the title. Lines starting with "--" are separators.
# * Lines starting with "#" are internal comments.
# * Lines starting with ".," indicate code to be disassembled.
# * Lines starting with ".:" indicate bytes to be dumped.
# * Comments start at the 33rd column.
# * 32 leading spaces and "***" indicate a heading. (Please leave one
# line blank above every heading.)
# * Otherwise, 32 leading spaces indicate an overflow comment.
# The encoding is UTF-8.
*** BIOERR: HANDLE I/O ERROR IN BASIC
This routine is called whenever BASIC wishes to call one
of the KERNAL I/O routines. It is also used to handle I/O
errors in BASIC.
.,E0F9 C9 F0 CMP #$F0 test error
.,E0FB D0 07 BNE $E104
.,E0FD 84 38 STY $38 MEMSIZ, highest address in BASIC
.,E0FF 86 37 STX $37
.,E101 4C 63 A6 JMP $A663 do CLR without aborting I/O
.,E104 AA TAX put error flag i (X)
.,E105 D0 02 BNE $E109 if error code $00, then set error code $1e
.,E107 A2 1E LDX #$1E
.,E109 4C 37 A4 JMP $A437 do error
*** BCHOUT: OUTPUT CHARACTER
This routine uses the KERNAL routine CHROUT to output the
character in (A) to an available output channel. A test is
made for a possible I/O error.
.,E10C 20 D2 FF JSR $FFD2 output character in (A)
.,E10F B0 E8 BCS $E0F9 if carry set, handle I/O error
.,E111 60 RTS else return
*** BCHIN: INPUT CHARACTER
This routine uses the KERNAL routine CHRIN to input a
character to (A) from an available input channel. A test
is made for a possible I/O error.
.,E112 20 CF FF JSR $FFCF input character from CHRIN
.,E115 B0 E2 BCS $E0F9 if carry set, handle I/O error
.,E117 60 RTS else return
*** BCKOUT:SET UP FOR OUTPUT
This routine uses the KERNAL routine CHKOUT to open an
output channel, and tests for possible I/O error. On entry
(X) must hold the the logical file number as used in OPEN.
.,E118 20 AD E4 JSR $E4AD open output channel via CHKOUT
.,E11B B0 DC BCS $E0F9 if carry set, handle I/O error
.,E11D 60 RTS else return
*** BCKIN: SET UP FOR INPUT
This routine uses the KERNAL routine CHKIN to open an
input channel. A test as made for possible I/O error.
.,E11E 20 C6 FF JSR $FFC6 open input channel via CHKIN
.,E121 B0 D6 BCS $E0F9 if carry set, handle I/O error
.,E123 60 RTS else return
*** BGETIN: GET ONT CHARACTER
This routine uses the KERNAL routine GETIN to get a
character from the keyboard buffer into (A). A test is
made for possible I/O error.
.,E124 20 E4 FF JSR $FFE4 GETIN, get character from keyboard buffer
.,E127 B0 D0 BCS $E0F9 if carry set, handle I/O error
.,E129 60 RTS else return
*** SYS: PERFORM SYS
This routine enables machine language routines to be
executed from BASIC. The routine evaluates the address and
confirms that it is a numeric number. The return address
is set up, and the user routine is executed.
.,E12A 20 8A AD JSR $AD8A evaluate text & confirm numeric
.,E12D 20 F7 B7 JSR $B7F7 convert fac#1 to integer in LINNUM
.,E130 A9 E1 LDA #$E1 set return address on stack to $ea46
.,E132 48 PHA
.,E133 A9 46 LDA #$46
.,E135 48 PHA
.,E136 AD 0F 03 LDA $030F SPREG, user flag register
.,E139 48 PHA
.,E13A AD 0C 03 LDA $030C SAREG, user (A) register
.,E13D AE 0D 03 LDX $030D SXREG, user (X) register
.,E140 AC 0E 03 LDY $030E SYREG, user (Y) register
.,E143 28 PLP
.,E144 6C 14 00 JMP ($0014) execute user routine, exit with rts
.,E147 08 PHP
.,E148 8D 0C 03 STA $030C store in SAREG, user (A) register
.,E14B 8E 0D 03 STX $030D store in SXREG, user (X) register
.,E14E 8C 0E 03 STY $030E store in SYREG, user (Y) register
.,E151 68 PLA
.,E152 8D 0F 03 STA $030F store in SPREG, user flag register
.,E155 60 RTS back
*** SAVET: PERFORM SAVE
This routine is sets parameters for save, and calls the
save routine. The start and end addresses are obtained
from TXTTAB and VARTAB. Finally, a test is made if any
errors ocured.
.,E156 20 D4 E1 JSR $E1D4 get SAVE paramerters from text
.,E159 A6 2D LDX $2D VARTAB, start of variables
.,E15B A4 2E LDY $2E
.,E15D A9 2B LDA #$2B <TXTTAB, start of BASIC text
.,E15F 20 D8 FF JSR $FFD8 execute SAVE
.,E162 B0 95 BCS $E0F9 if carry is set, handle I/O errors
.,E164 60 RTS
*** VERFYT: PERFORM LOAD/SAVE
This routine is essentially the same for both LOAD and
VERIFY. The entry point determins which is performed, by
setting VERCK accordingly. The LOAD/VERIFY parameters,
filename, device etc. are obtained from text before the
KERNAL routine LOAD is called. A test is made for I/O
errors. At this point, the two functios are distiguished.
VERIFY reads the the status word and prints the message OK
or ?VERIFY error depending on the result of the test. LOAD
reads the I/O status word for a possible ?LOAD error, then
updates the pointers to text and variables, exiting via
CLR.
.,E165 A9 01 LDA #$01 flag verify
.:E167 2C .BYTE $2C mask
.,E168 A9 00 LDA #$00
.,E16A 85 0A STA $0A store in VRECK, LOAD/VERIFY flag
.,E16C 20 D4 E1 JSR $E1D4 get LOAD/VERIFY parameters from text
.,E16F A5 0A LDA $0A get VRECK
.,E171 A6 2B LDX $2B TXTTAB, start of BASIC
.,E173 A4 2C LDY $2C
.,E175 20 D5 FF JSR $FFD5 execute LOAD, KERNAL routine
.,E178 B0 57 BCS $E1D1 if carry set, handle error
.,E17A A5 0A LDA $0A test VRECK for LOAD or VERIFY
.,E17C F0 17 BEQ $E195 do LOAD
.,E17E A2 1C LDX #$1C set error $1c, VERIFY error
.,E180 20 B7 FF JSR $FFB7 do READST, get status I/O word
.,E183 29 10 AND #$10 %00010000, test for mismatch
.,E185 D0 17 BNE $E19E data mismatch, do error
.,E187 A5 7A LDA $7A <TXTPTR
.,E189 C9 02 CMP #$02
.,E18B F0 07 BEQ $E194
.,E18D A9 64 LDA #$64 set address to text OK
.,E18F A0 A3 LDY #$A3 at $a364
.,E191 4C 1E AB JMP $AB1E output string in (A/Y)
.,E194 60 RTS
.,E195 20 B7 FF JSR $FFB7 do READST, get status I/O for LOAD
.,E198 29 BF AND #$BF %10111111, test all but EOI
.,E19A F0 05 BEQ $E1A1 nope, no errors
.,E19C A2 1D LDX #$1D set error $1d, LOAD error
.,E19E 4C 37 A4 JMP $A437 do error
.,E1A1 A5 7B LDA $7B >TXTPTR
.,E1A3 C9 02 CMP #$02
.,E1A5 D0 0E BNE $E1B5
.,E1A7 86 2D STX $2D set VARTAB, start of variables
.,E1A9 84 2E STY $2E
.,E1AB A9 76 LDA #$76 set address to text READY
.,E1AD A0 A3 LDY #$A3 at $a376
.,E1AF 20 1E AB JSR $AB1E output string in (A/Y)
.,E1B2 4C 2A A5 JMP $A52A do CLR and restart BASIC
.,E1B5 20 8E A6 JSR $A68E reset TXTPTR
.,E1B8 20 33 A5 JSR $A533 rechain BASIC lines
.,E1BB 4C 77 A6 JMP $A677 do RESTORE and reset OLDTXT
*** OPENT: PERFORM OPEN
This routine extracts paramerters from text and performs
the OPEN routine in KERNAL. A test is made for I/O errors.
.,E1BE 20 19 E2 JSR $E219 get parameters from text
.,E1C1 20 C0 FF JSR $FFC0 execute OPEN
.,E1C4 B0 0B BCS $E1D1 if carry set, handle error
.,E1C6 60 RTS
*** CLOSET: PERFORM CLOSE
The parameters for CLOSE are obtained from text, and the
logical filenumber placed in (A), The KERNAL routine CLOSE
is performed, and a test is made for I/O errors.
.,E1C7 20 19 E2 JSR $E219 get parameters from text
.,E1CA A5 49 LDA $49 logical file number
.,E1CC 20 C3 FF JSR $FFC3 perform CLOSE
.,E1CF 90 C3 BCC $E194 if carry set, handle error, else return
.,E1D1 4C F9 E0 JMP $E0F9 jump to error routine
*** SLPARA: GET PARAMETERS FOR LOAD/SAVE
This routine gets the filename, devicenumber and secondary
address for LOAD/VERIFY and SAVE operations. The KERNAL
routines SETNAM and SETLFS are used to do this. Default
parameters are set up, then tests are made if any of the
parameters were given. If so, these are set up as wanted.
.,E1D4 A9 00 LDA #$00 clear length of filename
.,E1D6 20 BD FF JSR $FFBD SETNAM
.,E1D9 A2 01 LDX #$01 default FA, device number is #01
.,E1DB A0 00 LDY #$00 default SA, secondary address is #00
.,E1DD 20 BA FF JSR $FFBA SETLFS, and device number
.,E1E0 20 06 E2 JSR $E206 test if "end of line", if so end here
.,E1E3 20 57 E2 JSR $E257 set up given filename and perform SETNAM
.,E1E6 20 06 E2 JSR $E206 test if "end of line", if so end here
.,E1E9 20 00 E2 JSR $E200 check for comma, and input one byte, FA, to (X)
.,E1EC A0 00 LDY #$00
.,E1EE 86 49 STX $49
.,E1F0 20 BA FF JSR $FFBA perform new SETLFS with device number
.,E1F3 20 06 E2 JSR $E206 test if "end of line", if so end here
.,E1F6 20 00 E2 JSR $E200 check for comma, and input one byte, SA, to (X)
.,E1F9 8A TXA transfer (X) to (Y)
.,E1FA A8 TAY
.,E1FB A6 49 LDX $49 get FA
.,E1FD 4C BA FF JMP $FFBA perform SETLFS with both device number and secondary
address. Then exit
*** COMBYT: GET NEXT ONE-BYTE PARAMETER
This routine checks if the next character of text is a
comma, and then inputs the parameter following into (X).
.,E200 20 0E E2 JSR $E20E check for comma
.,E203 4C 9E B7 JMP $B79E input one byte parameter to (X)
*** DEFLT: CHECK DEFAULT PARAMETERS
This routine tests CHRGOT to see if a optional parameter
was included in the text. If it was, a normal exit is
performed via RTS. If not, the return address on the stack
is discarded, and the routine exits both this and the
calling routine.
.,E206 20 79 00 JSR $0079 get CHRGOT
.,E209 D0 02 BNE $E20D if last character is a character, do normal exit
.,E20B 68 PLA else, remove return address
.,E20C 68 PLA to exit this AND the calling routine.
.,E20D 60 RTS exit
*** CMMERR: CHECK FOR COMMA
This routine confirms that the next character in the text
is a comma. It also test that the comma is not immediately
ollowed by a terminator. If so, exit and do SYNTAX error.
.,E20E 20 FD AE JSR $AEFD confirm comma
.,E211 20 79 00 JSR $0079 get CHRGOT
.,E214 D0 F7 BNE $E20D else than null
.,E216 4C 08 AF JMP $AF08 execute SYNTAX error
*** OCPARA: GET PARAMETERS FOR OPEN/CLOSE
This routine gets the logical file number, device number,
secondary address and filename for OPEN/CLOSE. Initially
the default filename is set to null, and the device number
to #1. The logical filenumber is compulsory, and is
obtained from text and placed in <FORPNT. The other
parameters are optinal and are obtained if present. The
device number is stored in >FORPNT. The parameters are set
via the KERNAL routines SETNAM and SETLFS.
.,E219 A9 00 LDA #$00 default filename is null
.,E21B 20 BD FF JSR $FFBD SETNAM
.,E21E 20 11 E2 JSR $E211 confirm TXTPNT is no terminator, if so - error
.,E221 20 9E B7 JSR $B79E input one byte character to (X)
.,E224 86 49 STX $49 store logical filenumber in <FORPNT
.,E226 8A TXA set default parameters to
.,E227 A2 01 LDX #$01 device = #1
.,E229 A0 00 LDY #$00 secondary address = #0
.,E22B 20 BA FF JSR $FFBA SETLFS
.,E22E 20 06 E2 JSR $E206 test if "end of line", if so end here
.,E231 20 00 E2 JSR $E200 check for comma, and input FA, device number
.,E234 86 4A STX $4A store in >FORPNT
.,E236 A0 00 LDY #$00 secondary address = #0
.,E238 A5 49 LDA $49 logical file number from temp store
.,E23A E0 03 CPX #$03 test if serial devce
.,E23C 90 01 BCC $E23F nope
.,E23E 88 DEY if serial, set secondary address to $ff
.,E23F 20 BA FF JSR $FFBA SETLFS
.,E242 20 06 E2 JSR $E206 test if "end of line", if so end here
.,E245 20 00 E2 JSR $E200 check for comma, and input SA, secondary address
.,E248 8A TXA
.,E249 A8 TAY SA to (Y)
.,E24A A6 4A LDX $4A FA
.,E24C A5 49 LDA $49 LA
.,E24E 20 BA FF JSR $FFBA SETLFS
.,E251 20 06 E2 JSR $E206 test if "end of line", if so end here
.,E254 20 0E E2 JSR $E20E check for comma only
.,E257 20 9E AD JSR $AD9E evaluate expression in text
.,E25A 20 A3 B6 JSR $B6A3 do string housekeeping
.,E25D A6 22 LDX $22 pointers to given filename
.,E25F A4 23 LDY $23
.,E261 4C BD FF JMP $FFBD SETNAM and exit
*** COS: PERFORM COS
This routine manipulates the input COS to be calcuated
with SIN. COS(X) = SIN(X+pi/2), where X is in radians. We
use it as Fac#1=SIN(fac#1+pi/2), ie pi/2 is added to fac#1
and the following SIN is performed.
.,E264 A9 E0 LDA #$E0 set address to pi/2
.,E266 A0 E2 LDY #$E2 at $e2e0
.,E268 20 67 B8 JSR $B867 add fltp at (A/Y) to fac#1
*** SIN: PERFORM SIN
.,E26B 20 0C BC JSR $BC0C
.,E26E A9 E5 LDA #$E5
.,E270 A0 E2 LDY #$E2
.,E272 A6 6E LDX $6E
.,E274 20 07 BB JSR $BB07
.,E277 20 0C BC JSR $BC0C
.,E27A 20 CC BC JSR $BCCC
.,E27D A9 00 LDA #$00
.,E27F 85 6F STA $6F
.,E281 20 53 B8 JSR $B853
.,E284 A9 EA LDA #$EA
.,E286 A0 E2 LDY #$E2
.,E288 20 50 B8 JSR $B850
.,E28B A5 66 LDA $66
.,E28D 48 PHA
.,E28E 10 0D BPL $E29D
.,E290 20 49 B8 JSR $B849
.,E293 A5 66 LDA $66
.,E295 30 09 BMI $E2A0
.,E297 A5 12 LDA $12
.,E299 49 FF EOR #$FF
.,E29B 85 12 STA $12
.,E29D 20 B4 BF JSR $BFB4
.,E2A0 A9 EA LDA #$EA
.,E2A2 A0 E2 LDY #$E2
.,E2A4 20 67 B8 JSR $B867
.,E2A7 68 PLA
.,E2A8 10 03 BPL $E2AD
.,E2AA 20 B4 BF JSR $BFB4
.,E2AD A9 EF LDA #$EF
.,E2AF A0 E2 LDY #$E2
.,E2B1 4C 43 E0 JMP $E043
*** TAN: PERFORM TAN
.,E2B4 20 CA BB JSR $BBCA
.,E2B7 A9 00 LDA #$00
.,E2B9 85 12 STA $12
.,E2BB 20 6B E2 JSR $E26B
.,E2BE A2 4E LDX #$4E
.,E2C0 A0 00 LDY #$00
.,E2C2 20 F6 E0 JSR $E0F6
.,E2C5 A9 57 LDA #$57
.,E2C7 A0 00 LDY #$00
.,E2C9 20 A2 BB JSR $BBA2
.,E2CC A9 00 LDA #$00
.,E2CE 85 66 STA $66
.,E2D0 A5 12 LDA $12
.,E2D2 20 DC E2 JSR $E2DC
.,E2D5 A9 4E LDA #$4E
.,E2D7 A0 00 LDY #$00
.,E2D9 4C 0F BB JMP $BB0F
.,E2DC 48 PHA
.,E2DD 4C 9D E2 JMP $E29D
*** PI2: TABLE OF TRIGONOMETRY CONSTANTS
The following constants are held in 5 byte flpt for
trigonometry evaluation.
.:E2E0 81 49 0F DA A2 ; 1.570796327 (pi/2)
.:E2E5 83 49 0F DA A2 ; 6.28318531 (pi*2)
.:E2EA 7F 00 00 00 00 ; 0.25
.:E2EF 05 ; 5 (one byte counter for SIN series)
.:E2F0 84 E6 1A 2D 1B ; -14.3813907 (SIN constant 1)
.:E2F5 86 28 07 FB F8 ; 42.0077971 (SIN constant 2)
.:E2FA 87 99 68 89 01 ; -76.7041703 (SIN constant 3)
.:E2FF 87 23 35 DF E1 ; 81.6052237 (SIN constant 4)
.:E304 86 A5 5D E7 28 ; -41.3417021 (SIN constant 5)
.:E309 83 49 0F DA A2 ; 6.28318531 (SIN constant 6, pi*2)
*** ATN: PERFORM ATN
.,E30E A5 66 LDA $66
.,E310 48 PHA
.,E311 10 03 BPL $E316
.,E313 20 B4 BF JSR $BFB4
.,E316 A5 61 LDA $61
.,E318 48 PHA
.,E319 C9 81 CMP #$81
.,E31B 90 07 BCC $E324
.,E31D A9 BC LDA #$BC
.,E31F A0 B9 LDY #$B9
.,E321 20 0F BB JSR $BB0F
.,E324 A9 3E LDA #$3E
.,E326 A0 E3 LDY #$E3
.,E328 20 43 E0 JSR $E043
.,E32B 68 PLA
.,E32C C9 81 CMP #$81
.,E32E 90 07 BCC $E337
.,E330 A9 E0 LDA #$E0
.,E332 A0 E2 LDY #$E2
.,E334 20 50 B8 JSR $B850
.,E337 68 PLA
.,E338 10 03 BPL $E33D
.,E33A 4C B4 BF JMP $BFB4
.,E33D 60 RTS
*** ATNCON: TABLE OF ATN CONSTANTS
The table holds a 1 byte counter and the folloeing 5 byte
flpt constants.
.:E33E 0B ; 13 (one byte counter for ATN series)
.:E33F 76 B3 83 BD D3 ; -0.000684793912 (ATN constant 1)
.:E344 79 1E F4 A6 F5 ; 0.00485094216 (ATN constant 2)
.:E349 7B 83 FC B0 10 ; -0.161117018 (ATN constant 3)
.:E34E 7C 0C 1F 67 CA ; 0.034209638 (ATN constant 5)
.:E353 7C DE 53 CB C1 ; -0.0542791328 (ATN constant 6)
.:E358 7D 14 64 70 4C ; 0.0724571965 (ATN constant 7)
.:E35D 7D B7 EA 51 7A ; -0.0898023954 (ATN constant 8)
.:E362 7D 63 30 88 7E ; 0.110932413 (ATN constant 9)
.:E367 7E 92 44 99 3A ; -0.14283908 (ATN constant 10)
.:E36C 7E 4C CC 91 C7 ; 0.19999912 (ATN constant 11)
.:E371 7F AA AA AA 13 ; -0.333333316 (ATN constant 12)
.:E376 81 00 00 00 00 ; 1 (ATN constant 13)
*** BASSFT: BASIC WARM START
This is the BASIC warm start routine that is vectored at
the very start of the BASIC ROM. The routine is called by
the 6510 BRK instruction, or STOP/RESTORE being pressed.
It outputs the READY prompt via the IERROR vector at
$0300. If the error code, in (X) is larger than $80, then
only the READY text will be displayed.
.,E37B 20 CC FF JSR $FFCC CLRCHN, close all I/O channels
.,E37E A9 00 LDA #$00
.,E380 85 13 STA $13 input prompt flag
.,E382 20 7A A6 JSR $A67A do CLR
.,E385 58 CLI enable IRQ
.,E386 A2 80 LDX #$80 error code #$80
.,E388 6C 00 03 JMP ($0300) perform error
.,E38B 8A TXA error number
.,E38C 30 03 BMI $E391 larger than $80
.,E38E 4C 3A A4 JMP $A43A nope, print error
.,E391 4C 74 A4 JMP $A474 print READY
*** INIT: BASIC COLD START
This is the BASIC cold start routine that is vectored at
the very start of the BASIC ROM. BASIC vectors and
variables are set up, and power-up message is output, and
BASIC is restarted.
.,E394 20 53 E4 JSR $E453
.,E397 20 BF E3 JSR $E3BF Initialize BASIC
.,E39A 20 22 E4 JSR $E422 output power-up message
.,E39D A2 FB LDX #$FB reset stack
.,E39F 9A TXS
.,E3A0 D0 E4 BNE $E386 output READY, and restart BASIC
*** INITAT: CHRGET FOR ZEROPAGE
This is the CHRGET routine which is transferred to RAM
starting at $0073 on power-up or reset.
.,E3A2 E6 7A INC $7A increment <TXTPTR
.,E3A4 D0 02 BNE $E3A8 skip high byte
.,E3A6 E6 7B INC $7B increment >TXTPTR
.,E3A8 AD 60 EA LDA $EA60 CHRGOT entry, read TXTPTR
.,E3AB C9 3A CMP #$3A colon (terminator), sets (Z)
.,E3AD B0 0A BCS $E3B9
.,E3AF C9 20 CMP #$20 space, get next character
.,E3B1 F0 EF BEQ $E3A2
.,E3B3 38 SEC
.,E3B4 E9 30 SBC #$30 zero
.,E3B6 38 SEC
.,E3B7 E9 D0 SBC #$D0
.,E3B9 60 RTS
*** RNDSED: RANDOM SEED FOR ZEROPAGE
This is the initial value of the seed for the random
number function. It is copied into RAM from $008b-$008f.
Its fltp value is 0.811635157.
.:E3BA 80 4F C7 52 58
*** INITCZ: INITIALISE BASIC RAM
This routine sets the USR jump instruction to point to
?ILLEGAL QUANTITY error, sets ADRAY1 and ADRAY2, copies
CHRGET and RNDSED to zeropage, sets up the start and end
locations for BASIC text and sets the first text byte to
zero.
.,E3BF A9 4C LDA #$4C ; opcode for JMP
.,E3C1 85 54 STA $54 ; store in JMPER
.,E3C3 8D 10 03 STA $0310 ; USRPOK, set USR JMP instruction
.,E3C6 A9 48 LDA #$48
.,E3C8 A0 B2 LDY #$B2 ; vector to $b248, ?ILLEGAL QUANTITY
.,E3CA 8D 11 03 STA $0311
.,E3CD 8C 12 03 STY $0312 ; store in USRADD
.,E3D0 A9 91 LDA #$91
.,E3D2 A0 B3 LDY #$B3 ; vector to $b391
.,E3D4 85 05 STA $05
.,E3D6 84 06 STY $06 ; store in ADRAY2
.,E3D8 A9 AA LDA #$AA
.,E3DA A0 B1 LDY #$B1 ; vector to $b1aa
.,E3DC 85 03 STA $03
.,E3DE 84 04 STY $04 ; store in ADRAY1
.,E3E0 A2 1C LDX #$1C ; copy the CHRGET routine and RNDSED to RAM
.,E3E2 BD A2 E3 LDA $E3A2,X ; source address
.,E3E5 95 73 STA $73,X ; destination address
.,E3E7 CA DEX ; next byte
.,E3E8 10 F8 BPL $E3E2 ; till ready
.,E3EA A9 03 LDA #$03
.,E3EC 85 53 STA $53 ; store #3 in FOUR6, garbage collection
.,E3EE A9 00 LDA #$00
.,E3F0 85 68 STA $68 ; init BITS, fac#1 overflow
.,E3F2 85 13 STA $13 ; init input prompt flag
.,E3F4 85 18 STA $18 ; init LASTPT
.,E3F6 A2 01 LDX #$01
.,E3F8 8E FD 01 STX $01FD
.,E3FB 8E FC 01 STX $01FC
.,E3FE A2 19 LDX #$19
.,E400 86 16 STX $16 ; TEMPPT, pointer to descriptor stack
.,E402 38 SEC ; set carry to indicate read mode
.,E403 20 9C FF JSR $FF9C ; read MEMBOT
.,E406 86 2B STX $2B ; set TXTTAB, bottom of RAM
.,E408 84 2C STY $2C
.,E40A 38 SEC ; set carry to indicate read mode
.,E40B 20 99 FF JSR $FF99 ; read MEMTOP
.,E40E 86 37 STX $37 ; set MEMSIZ, top of RAM
.,E410 84 38 STY $38
.,E412 86 33 STX $33 ; set FRETOP = MEMTOP
.,E414 84 34 STY $34
.,E416 A0 00 LDY #$00
.,E418 98 TYA
.,E419 91 2B STA ($2B),Y ; store zero at start of BASIC
.,E41B E6 2B INC $2B ; increment TXTTAB to next memory position
.,E41D D0 02 BNE $E421 ; skip msb
.,E41F E6 2C INC $2C
.,E421 60 RTS ; return
*** INITMS: OUTPUT POWER-UP MESSAGE
This routine outputs the startup message. It then
calcuates the number of BASIC bytes free by subatracting
the TXTTAB from MEMSIZ, and outputs this number. The
routine exits via NEW.
.,E422 A5 2B LDA $2B read TXTTAB, start of BASIC
.,E424 A4 2C LDY $2C
.,E426 20 08 A4 JSR $A408 check for memory overlap
.,E429 A9 73 LDA #$73 $e473, startup message
.,E42B A0 E4 LDY #$E4
.,E42D 20 1E AB JSR $AB1E output (A/Y)
.,E430 A5 37 LDA $37 MEMSIZ, highest address in BASIC
.,E432 38 SEC prepare for substract
.,E433 E5 2B SBC $2B substract TXTTAB
.,E435 AA TAX move to (X)
.,E436 A5 38 LDA $38 and highbyte
.,E438 E5 2C SBC $2C
.,E43A 20 CD BD JSR $BDCD output number in (A/X)
.,E43D A9 60 LDA #$60 $e460
.,E43F A0 E4 LDY #$E4 pointer to 'BASIC BYTES FREE'
.,E441 20 1E AB JSR $AB1E output (A/Y)
.,E444 4C 44 A6 JMP $A644 perform NEW
*** VECTORS
This table contains jump vectors that are transfered to
$0300-$030b.
.:E447 8B E3 IERROR VEC, print basic error message ($e38b)
.:E449 83 A4 IMAIN VECTOR, basic warm start ($a483)
.:E44B 7C A5 ICRNCH VECTOR, tokenise basic text ($a57c)
.:E44D 1A A7 IQPLOP VECTOR, list basic text ($a7a1)
.:E44F E4 A7 IGONE VEXTOR, basic character dispatch ($a7e4)
.:E451 86 AE IEVAL VECTOR, evaluate basic token ($ae86)
*** INIT VECTORS
This routine transfers the vectors $0300-$030b.
.,E453 A2 0B LDX #$0B 6 vectors to be copied
.,E455 BD 47 E4 LDA $E447,X
.,E458 9D 00 03 STA $0300,X
.,E45B CA DEX next byte
.,E45C 10 F7 BPL $E455 ready
.,E45E 60 RTS return
*** WORDS: POWER UP MESSAGE
This is the power up message displayed on the screen when
the 'Commie' is switched on or reset. The strings are
seperated by a zero byte.
.:E45F 00 20 42 41 53 49 43 20 basic bytes free
.:E467 42 59 54 45 53 20 46 52
.:E46F 45 45 0D 00 93 0D 20 20
.:E473 93 0D 20 20 20 20 2A 2A (clr) **** commodore 64 basic v2 ****
.:E47B 2A 2A 20 43 4F 4D 4D 4F (cr) (cr) 64k ram system
.:E483 44 4F 52 45 20 36 34 20
.:E48B 42 41 53 49 43 20 56 32
.:E493 20 2A 2A 2A 2A 0D 0D 20
.:E49B 36 34 4B 20 52 41 4D 20
.:E4A3 53 59 53 54 45 4D 20 20
.:E4AB 00
.:E4AC 5C
*** PATCH FOR BASIC CHKOUT CALL
This is a short patch added for the KERNAL ROM to preserv
(A) when there was no error returned from BASIC calling
the CHKOUT routine. This corrects a bug in the early
versions of PRINT# and CMD.
.,E4AD 48 PHA temp store (A)
.,E4AE 20 C9 FF JSR $FFC9 CHKOUT
.,E4B1 AA TAX
.,E4B2 68 PLA retrieve (A)
.,E4B3 90 01 BCC $E4B6
.,E4B5 8A TXA
.,E4B6 60 RTS
.:E4B7 AA AA AA AA AA AA AA AA
.:E4BF AA AA AA AA AA AA AA AA
.:E4C7 AA AA AA AA AA AA AA AA
.:E4CF AA AA AA AA AA
*** RS232 PATCH
This patch has been added to the RS232 input routine in
KERNAL v.3. It initialises the RS232 parity byte, RIPRTY,
on reception of a start bit.
.,E4D3 85 A9 STA $A9 RINONE, check for start bit
.,E4D5 A9 01 LDA #$01
.,E4D7 85 AB STA $AB RIPRTY, RS232 input parity
.,E4D9 60 RTS
*** RESET CHARACTER COLOUR
This routine is a patch in KERNAL version 3 to fix a bug
with the colour code. The routine is called by 'clear a
screen line', and sets the character colour to COLOR.
.,E4DA AD 86 02 LDA $0286 get COLOR
.,E4DD 91 F3 STA ($F3),Y and store in current screen position
.,E4DF 60 RTS
*** PAUSE AFTER FINDING TAPE FILE
This routine continues tape loading without pressing C=
when a file was found.
.,E4E0 69 02 ADC #$02
.,E4E2 A4 91 LDY $91
.,E4E4 C8 INY
.,E4E5 D0 04 BNE $E4EB
.,E4E7 C5 A1 CMP $A1
.,E4E9 D0 F7 BNE $E4E2
.,E4EB 60 RTS
*** RS232 TIMING TABLE - PAL
Timingtable for RS232 NMI for use with PAL machines. This
table contains the prescaler values for setting up the
RS232 baudrates. The table containe 10 entries which
corresponds to one of the fixed RS232 rates, starting with
lowest (50 baud) and finishing with the highest (2400
baud). Since the clock frequency is different between NTSC
and PAL systems, there is another table for NTSC machines
at $fec2.
.:E4EC 19 26 50 baud
.:E4EE 44 19 75 baud
.:E4F0 1A 11 110 baud
.:E4F2 E8 0D 134.5 baud
.:E4F4 70 0C 150 baud
.:E4F6 06 06 300 baud
.:E4F8 D1 02 600 baud
.:E4FA 37 01 1200 baud
.:E4FC AE 00 (1800) 2400 baud
.:E4FE 69 00 2400 baud
*** IOBASE: GET I/O ADDRESS
The KERNAL routine IOBASE ($fff3) jumps to this routine.
It returns the base address $dc00 in (X/Y)
.,E500 A2 00 LDX #$00 set (X/Y) to $dc00
.,E502 A0 DC LDY #$DC
.,E504 60 RTS
*** SCREEN: GET SCREEN SIZE
The KERNAL routine SCREEN ($ffed) jumps to this routine.
It returns the screen size; columns in (X) and rows in
(Y).
.,E505 A2 28 LDX #$28 40 columns
.,E507 A0 19 LDY #$19 25 rows
.,E509 60 RTS
*** PLOT: PUT/GET ROW AND COLUMN
The KERNAL routine PLOT ($fff0) jumps to this routine. The
option taken depends on the state of carry on entry. If it
is set, the column is placed in (Y) and the row placed in
(X). If carry is clear, the cursor position is read from
(X/Y) and the screen pointers are set.
.,E50A B0 07 BCS $E513 if carry set, jump
.,E50C 86 D6 STX $D6 store TBLX, current row
.,E50E 84 D3 STY $D3 store PNTR, current column
.,E510 20 6C E5 JSR $E56C set screen pointers
.,E513 A6 D6 LDX $D6 read TBLX
.,E515 A4 D3 LDY $D3 read PNTR
.,E517 60 RTS
*** CINT1: INITIALISE I/O
This routine is part of the KERNAL CINT init routine. I/O
default values are set, <shift+cbm> keys are disabled, and
cursor is switched off. The vector to the keyboard table
is set up, and the length of the keyboardbuffer is set to
10 characters. The cursor color is set to lightblue, and
the key-repeat parameters are set up.
.,E518 20 A0 E5 JSR $E5A0 set I/O defaults
.,E51B A9 00 LDA #$00
.,E51D 8D 91 02 STA $0291 disable <SHIFT + CBM> by writing zero into MODE
.,E520 85 CF STA $CF the cursor blink flag, set BLNON on
.,E522 A9 48 LDA #$48
.,E524 8D 8F 02 STA $028F
.,E527 A9 EB LDA #$EB set the KEYLOG vector to point at $eb48
.,E529 8D 90 02 STA $0290
.,E52C A9 0A LDA #$0A set max number of character is keyboard buffer to 10
.,E52E 8D 89 02 STA $0289 XMAX
.,E531 8D 8C 02 STA $028C How many 1/60 of a second to wait before key is repeated.
Used togeather with $028b
.,E534 A9 0E LDA #$0E set character colour to light blue
.,E536 8D 86 02 STA $0286 COLOR
.,E539 A9 04 LDA #$04 How many $028c before a new entry is
.,E53B 8D 8B 02 STA $028B put in the keyboard buffer, KOUNT
.,E53E A9 0C LDA #$0C
.,E540 85 CD STA $CD store in BLCNT, cursor toggle timer
.,E542 85 CC STA $CC store in BLNSW, cursor enable
*** CLEAR SCREEN
This routine sets up the screen line link table ($d9 -
$f2), LDTB1, which is used to point out the address to the
screen. The later part of the routine performs the screen
clear, line by line, starting at the bottom line. It
continues to the next routine which is used to home the
cursor.
.,E544 AD 88 02 LDA $0288 get HIBASE, top of screen memory
.,E547 09 80 ORA #$80 fool around
.,E549 A8 TAY
.,E54A A9 00 LDA #$00
.,E54C AA TAX
.,E54D 94 D9 STY $D9,X store in screen line link table, LDTB1
.,E54F 18 CLC
.,E550 69 28 ADC #$28 add #40 to next line
.,E552 90 01 BCC $E555
.,E554 C8 INY inc page number
.,E555 E8 INX next
.,E556 E0 1A CPX #$1A till all 26?? is done
.,E558 D0 F3 BNE $E54D
.,E55A A9 FF LDA #$FF
.,E55C 95 D9 STA $D9,X last pointer is $ff
.,E55E A2 18 LDX #$18 start clear screen with line $18 (bottom line)
.,E560 20 FF E9 JSR $E9FF erase line (X)
.,E563 CA DEX next
.,E564 10 FA BPL $E560 till screen is empty
*** HOME CURSOR
This routine puts the cursor in the top left corner by
writing its column and line to zero.
.,E566 A0 00 LDY #$00
.,E568 84 D3 STY $D3 write to PNTR, cursor column
.,E56A 84 D6 STY $D6 write to TBLX, line number
*** SET SCREEN POINTERS
This routine positions the cursor on the screen and sets
up the screen pointers. On entry, TBLX must hold the line
number, and PNTR the column number of the cursor position.
.,E56C A6 D6 LDX $D6 read TBLX
.,E56E A5 D3 LDA $D3 read PNTR
.,E570 B4 D9 LDY $D9,X read value from screen line link table, LDTB1
.,E572 30 08 BMI $E57C heavy calcuations??? jump when ready
.,E574 18 CLC
.,E575 69 28 ADC #$28
.,E577 85 D3 STA $D3 PNTR
.,E579 CA DEX
.,E57A 10 F4 BPL $E570
.,E57C 20 F0 E9 JSR $E9F0 set start of line (X)
.,E57F A9 27 LDA #$27
.,E581 E8 INX
.,E582 B4 D9 LDY $D9,X LDTB1
.,E584 30 06 BMI $E58C
.,E586 18 CLC
.,E587 69 28 ADC #$28
.,E589 E8 INX
.,E58A 10 F6 BPL $E582
.,E58C 85 D5 STA $D5 store in LMNX, physical screen line length
.,E58E 4C 24 EA JMP $EA24 sync color pointer
.,E591 E4 C9 CPX $C9 read LXSP, chech cursor at start of input
.,E593 F0 03 BEQ $E598
.,E595 4C ED E6 JMP $E6ED retreat cursor
.,E598 60 RTS
.,E599 EA NOP A free byte!!!
*** SET I/O DEFAULTS
The default output device is set to 3 (screen), and the
default input device is set to 0 (keyboard). The VIC chip
registers are set from the video chip setup table. The
cursor is then set to the home position.
.,E59A 20 A0 E5 JSR $E5A0 set I/O defaults
.,E59D 4C 66 E5 JMP $E566 home cursor and exit routine
.,E5A0 A9 03 LDA #$03
.,E5A2 85 9A STA $9A DFLTO, default output device - screen
.,E5A4 A9 00 LDA #$00
.,E5A6 85 99 STA $99 DFLTN, default input device - keyboard
.,E5A8 A2 2F LDX #$2F
.,E5AA BD B8 EC LDA $ECB8,X VIC chip setup table
.,E5AD 9D FF CF STA $CFFF,X VIC chip I/O registers
.,E5B0 CA DEX next
.,E5B1 D0 F7 BNE $E5AA till ready
.,E5B3 60 RTS
*** LP2: GET CHARACTER FROM KEYBOARD BUFFER
It is assumed that there is at leaset one character in the
keyboard buffer. This character is obtained and the rest
of the queue is moved up one by one to overwrite it. On
exit, the character is in (A).
.,E5B4 AC 77 02 LDY $0277 read KEYD, first character in keyboard buffer queue
.,E5B7 A2 00 LDX #$00
.,E5B9 BD 78 02 LDA $0278,X overwrite with next in queue
.,E5BC 9D 77 02 STA $0277,X
.,E5BF E8 INX
.,E5C0 E4 C6 CPX $C6 compare with NDX, number of characters in queue
.,E5C2 D0 F5 BNE $E5B9 till all characters are moved
.,E5C4 C6 C6 DEC $C6 decrement NDX
.,E5C6 98 TYA transfer read character to (A)
.,E5C7 58 CLI enable interrupt
.,E5C8 18 CLC
.,E5C9 60 RTS
*** INPUT FROM KEYBOARD
This routine uses the previous routine to get characters
from the keyboard buffer. Each character is output to the
screen, unless it is <shift/RUN>. If so, the contents of
the keyboard buffer is replaced with LOAD <CR> RUN <CR>.
The routine ends when a carriage routine is encountered.
.,E5CA 20 16 E7 JSR $E716 output to screen
.,E5CD A5 C6 LDA $C6 read NDX, number of characters in keyboard queue
.,E5CF 85 CC STA $CC BLNSW, cursor blink enable
.,E5D1 8D 92 02 STA $0292 AUTODN, auto scroll down flag
.,E5D4 F0 F7 BEQ $E5CD loop till key is pressed
.,E5D6 78 SEI disable interrupt
.,E5D7 A5 CF LDA $CF BLNON, last cursor blink (on/off)
.,E5D9 F0 0C BEQ $E5E7
.,E5DB A5 CE LDA $CE GDBLN, character under cursor
.,E5DD AE 87 02 LDX $0287 GDCOL, background color under cursor
.,E5E0 A0 00 LDY #$00
.,E5E2 84 CF STY $CF clear BLNON
.,E5E4 20 13 EA JSR $EA13 print to screen
.,E5E7 20 B4 E5 JSR $E5B4 Get character from keyboard buffer
.,E5EA C9 83 CMP #$83 test if <shift/RUN> is pressed
.,E5EC D0 10 BNE $E5FE nope
.,E5EE A2 09 LDX #$09 transfer 'LOAD <CR> RUN <CR>' to keyboard buffer
.,E5F0 78 SEI
.,E5F1 86 C6 STX $C6 store #9 in NDX, characters in buffer
.,E5F3 BD E6 EC LDA $ECE6,X 'LOAD <CR> RUN <CR>' message in ROM
.,E5F6 9D 76 02 STA $0276,X store in keyboard buffer
.,E5F9 CA DEX
.,E5FA D0 F7 BNE $E5F3 all nine characters
.,E5FC F0 CF BEQ $E5CD allways jump
.,E5FE C9 0D CMP #$0D carriage return pressed?
.,E600 D0 C8 BNE $E5CA nope, go to start
.,E602 A4 D5 LDY $D5 get LNMX, screen line length
.,E604 84 D0 STY $D0 CRSV, flag input/get from keyboard
.,E606 B1 D1 LDA ($D1),Y PNT, screen address
.,E608 C9 20 CMP #$20 space?
.,E60A D0 03 BNE $E60F nope
.,E60C 88 DEY
.,E60D D0 F7 BNE $E606 next
.,E60F C8 INY
.,E610 84 C8 STY $C8 store in INDX, end of logical line for input
.,E612 A0 00 LDY #$00
.,E614 8C 92 02 STY $0292 AUTODN
.,E617 84 D3 STY $D3 PNTR, cursor column
.,E619 84 D4 STY $D4 QTSW, reset quoute mode
.,E61B A5 C9 LDA $C9 LXSP, corsor X/Y position
.,E61D 30 1B BMI $E63A
.,E61F A6 D6 LDX $D6 TBLX, cursor line number
.,E621 20 ED E6 JSR $E6ED retreat cursor
.,E624 E4 C9 CPX $C9 LXSP
.,E626 D0 12 BNE $E63A
.,E628 A5 CA LDA $CA
.,E62A 85 D3 STA $D3 PNTR
.,E62C C5 C8 CMP $C8 INDX
.,E62E 90 0A BCC $E63A
.,E630 B0 2B BCS $E65D
*** INPUT FROM SCREEN OR KEYBOARD
This routine is used by INPUT to input data from devices
not on the serial bus, ie. from screen or keyboard. On
entry (X) and (Y) registers are preserved. A test is made
to determine which device the input is to be from. If it
is the screen, then quotes and <RVS> are tested for and
the character is echoed on the screen. Keyboard inputs
make use of the previous routine.
.,E632 98 TYA preserve (X) and (Y) registers
.,E633 48 PHA
.,E634 8A TXA
.,E635 48 PHA
.,E636 A5 D0 LDA $D0 CRSW, INPUT/GET from keyboard or screen
.,E638 F0 93 BEQ $E5CD input from keyboard
.,E63A A4 D3 LDY $D3 PNTR, cursor column
.,E63C B1 D1 LDA ($D1),Y read from current screen address
.,E63E 85 D7 STA $D7 temp store
.,E640 29 3F AND #$3F
.,E642 06 D7 ASL $D7
.,E644 24 D7 BIT $D7
.,E646 10 02 BPL $E64A
.,E648 09 80 ORA #$80
.,E64A 90 04 BCC $E650
.,E64C A6 D4 LDX $D4 QTSW, editor in quotes mode
.,E64E D0 04 BNE $E654 yepp
.,E650 70 02 BVS $E654
.,E652 09 40 ORA #$40
.,E654 E6 D3 INC $D3 PNTR
.,E656 20 84 E6 JSR $E684 do quotes test
.,E659 C4 C8 CPY $C8 INDX, end of logical line for input
.,E65B D0 17 BNE $E674
.,E65D A9 00 LDA #$00
.,E65F 85 D0 STA $D0 CRSW
.,E661 A9 0D LDA #$0D
.,E663 A6 99 LDX $99 DFLTN, default input device
.,E665 E0 03 CPX #$03 screen
.,E667 F0 06 BEQ $E66F yes
.,E669 A6 9A LDX $9A DFLTO, default output device
.,E66B E0 03 CPX #$03 screen
.,E66D F0 03 BEQ $E672 yes
.,E66F 20 16 E7 JSR $E716 output to screen
.,E672 A9 0D LDA #$0D
.,E674 85 D7 STA $D7
.,E676 68 PLA
.,E677 AA TAX restore (X) and (Y) registers
.,E678 68 PLA
.,E679 A8 TAY
.,E67A A5 D7 LDA $D7
.,E67C C9 DE CMP #$DE
.,E67E D0 02 BNE $E682
.,E680 A9 FF LDA #$FF
.,E682 18 CLC
.,E683 60 RTS
*** QUOTES TSET
On entry, (A) holds the character to be tested. If (A)
holds ASCII quotes, then the quotes flag is toggled.
.,E684 C9 22 CMP #$22 ASCII quotes (")
.,E686 D0 08 BNE $E690 nope, return
.,E688 A5 D4 LDA $D4 QTSW, quotes mode flag
.,E68A 49 01 EOR #$01 toggle on/off
.,E68C 85 D4 STA $D4 store
.,E68E A9 22 LDA #$22 restore (A) to #$22
.,E690 60 RTS
*** SET UP SCREEN PRINT
The RVS flag is tested to see if reversed characters are
to be printed. If insert mode is on, the insert counter is
decremented by one. When in insert mode, all characters
will be displayd, ie. DEL RVS etc. The character colour is
placed in (X) and the character is printed to the scrren
and the cursor advanced.
.,E691 09 40 ORA #$40
.,E693 A6 C7 LDX $C7 test RVS, flag for reversed characters
.,E695 F0 02 BEQ $E699 nope
.,E697 09 80 ORA #$80 set bit 7 to reverse character
.,E699 A6 D8 LDX $D8 test INSRT, flag for insert mode
.,E69B F0 02 BEQ $E69F nope
.,E69D C6 D8 DEC $D8 decrement number of characters left to insert
.,E69F AE 86 02 LDX $0286 get COLOR, current character colour code
.,E6A2 20 13 EA JSR $EA13 print to screen
.,E6A5 20 B6 E6 JSR $E6B6 advance cursor
.,E6A8 68 PLA
.,E6A9 A8 TAY
.,E6AA A5 D8 LDA $D8 INSRT
.,E6AC F0 02 BEQ $E6B0
.,E6AE 46 D4 LSR $D4
.,E6B0 68 PLA
.,E6B1 AA TAX
.,E6B2 68 PLA
.,E6B3 18 CLC
.,E6B4 58 CLI
.,E6B5 60 RTS
*** ADVANCE CURSOR
The cursor is advanced one position on the screen. If this
puts it beyond the 40th column, then it is placed at the
beginning of the next line. If the length of that line is
less than 80, then this new line is linked to the previous
one. A space is opened if data already exists on the new
line. If the cursor has reached the bottom of the screen,
then the screen is scrolled down.
.,E6B6 20 B3 E8 JSR $E8B3 check line increment
.,E6B9 E6 D3 INC $D3 increment PNTR, cursor column on current line
.,E6BB A5 D5 LDA $D5 LNMX, physical screen line length
.,E6BD C5 D3 CMP $D3 compare to PNTR
.,E6BF B0 3F BCS $E700 not beyond end of line, exit
.,E6C1 C9 4F CMP #$4F $4f = 79
.,E6C3 F0 32 BEQ $E6F7 put cursor on new logical line
.,E6C5 AD 92 02 LDA $0292 AUTODN, auto scroll down flag
.,E6C8 F0 03 BEQ $E6CD auto scroll is on
.,E6CA 4C 67 E9 JMP $E967 open a space on the screen
.,E6CD A6 D6 LDX $D6 read TBLX, current line number
.,E6CF E0 19 CPX #$19 $19 = 25
.,E6D1 90 07 BCC $E6DA less than 25
.,E6D3 20 EA E8 JSR $E8EA scroll down
.,E6D6 C6 D6 DEC $D6 place cursor on line 24
.,E6D8 A6 D6 LDX $D6
.,E6DA 16 D9 ASL $D9,X clear bit7 in LDTB1 to indicate that it is line 2
.,E6DC 56 D9 LSR $D9,X in the logical line
.,E6DE E8 INX next line
.,E6DF B5 D9 LDA $D9,X set bit7 in LDTB1 to indicate that it is line 1
.,E6E1 09 80 ORA #$80 in the logical line
.,E6E3 95 D9 STA $D9,X
.,E6E5 CA DEX
.,E6E6 A5 D5 LDA $D5 add $28 (40) to LNMX to allow 80 characters
.,E6E8 18 CLC on the logical line
.,E6E9 69 28 ADC #$28
.,E6EB 85 D5 STA $D5
*** RETREAT CURSOR
The screen line link table is searched, and then the start
of line is set. The rest of the routine sets the cursor
onto the next line for the previous routine.
.,E6ED B5 D9 LDA $D9,X LDTB1, screen line link table
.,E6EF 30 03 BMI $E6F4 test bit7
.,E6F1 CA DEX next line
.,E6F2 D0 F9 BNE $E6ED till all are done
.,E6F4 4C F0 E9 JMP $E9F0 set start of line
.,E6F7 C6 D6 DEC $D6 decrement TBLX, cursor line
.,E6F9 20 7C E8 JSR $E87C goto next line
.,E6FC A9 00 LDA #$00
.,E6FE 85 D3 STA $D3 set PNTR, the cursor column, to zero