-
Notifications
You must be signed in to change notification settings - Fork 0
/
devaid.asm
2925 lines (2312 loc) · 92.8 KB
/
devaid.asm
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
;***********************************************************************************;
;***********************************************************************************;
;
; Developer's Aid for VIC-20
; Hacked together by ops 2019-2020
; Based on Programmer's Aid cartridge and
; The almost completely commented Programmer's Aid ROM disassembly. v1.0
; By Simon Rowe <[email protected]>.
; C'mon - Machine Code Monitor for Commodore VIC-20 - v1.0
; (c)2001 Aleksi Eeben (email: [email protected])
; over5 - a c64/vic20 remote access solution.
; Copyright (c) 1995, 1996, 2000, 2002 Daniel Kahlin <[email protected]>
; All rights reserved.
;***********************************************************************************;
;***********************************************************************************;
;
#include "version.inc"
; BASIC zero page
LISTQUO = $0f ; list in quote mod.
LINNUM = $14 ; temporary integer
INDEX = $22 ; misc temp byte
TXTTAB = $2B ; start of memory
VARTAB = $2D ; start of variables
ARYTAB = $2F ; end of variables
CURLIN = $39 ; current line number
MEMSIZ = $37 ; end of memory
VARNAM = $45 ; current variable name
VARPNT = $47 ; current variable address
TMPPTR = $5F ; temporary pointer
CHRGET = $73 ; increment and scan memory, BASIC byte get
CHRGOT = $79 ; scan memory, BASIC byte get
; KERNAL zero page
STATUS = $90 ; st
VERCK = $93 ; load/verify flag
DEVNUM = $BA ; current device number
FNADR = $BB ; file name pointer
LSTX = $C5 ; last key pressed
NDX = $C6 ; keyboard buffer length/index
RVS = $C7 ; reverse flag
SFDX = $CB ; which key
BLNSW = $CC ; cursor enable
CDBLN = $CE ; character under cursor
BLNON = $CF ; cursor blink phase
PNT = $D1 ; current screen line pointer
PNTR = $D3 ; cursor column
QTSW = $D4 ; cursor quote flag
LNMX = $D5 ; current screen line length
TBLX = $D6 ; cursor row
INSRT = $D8 ; insert count
LDTB1 = $D9 ; screen line link table
USER = $F3 ; colour RAM pointer
STACK = $0100 ; bottom of the stack page
BUF = $0200 ; input buffer
KEYD = $0277 ; keyboard buffer
MEMHIGH = $0283 ; OS top of memory low byte
COLOR = $0286 ; current colour code
GDCOL = $0287 ; colour under cursor
HIBASE = $0288 ; screen memory page
SHFLAG = $028D ; keyboard shift/control flag
KEYLOG = $028F ; keyboard decode logic pointer
AUTODN = $0292 ; screen scrolling flag, $00 = enabled
TBUFFR = $033C ; to $03FB - cassette buffer
; VIA registers
VIA1PA1 = $9111 ; VIA 1 DRA
; BASIC entrypoints
WARMST = $C002 ; BASIC warm start entry point
RESLST = $C09E ; BASIC keywords
MEMERR = $C435 ; do out of memory error then warm start
READY = $C474 ; do warm start
LNKPRG = $C533 ; rebuild BASIC line chaining
CRNCH = $C579 ; crunch BASIC token vector
CRNCH2 = $C57C ; crunch BASIC token
FINLIN = $C613 ; search BASIC for temporary integer line number
CLR = $C659 ; perform clr
DECBIN = $C96B ; get fixed-point number into temporary integer
PRCRLF = $CAD7 ; print CR/LF
FRMEVL = $CD9E ; evaluate expression
PRTSTR = $CB1E ; print null terminated string
COMCHK = $CEFD ; scan for ","
RETVP = $D185 ; return variable
ILQUAN = $D248 ; do illegal quantity error
MAKFP = $D391 ; convert fixed integer .A.Y to float FAC1
DELST = $D6A3 ; evaluate string
LODFAC = $DBA2 ; unpack memory (.A.Y) into FAC1
PRTFIX = $DDCD ; print .X.A as unsigned integer
FLTASC = $DDDD ; convert FAC1 to ASCII string result in (.A.Y)
PARSL = $E1D1 ; get parameters for LOAD/SAVE
CGIMAG = $E387 ; character get subroutine for zero page
INITBA = $E3A4
; KERNAL entrypoints
INITVCTRS = $E45B
FREMSG = $E404
INITSK = $E518 ; initialize hardware
HOME = $E581 ; home cursor
MOVLIN = $EA56 ; shift screen line up/down
LINPTR = $EA7E ; set start of line .X
CLRALINE = $EA8D ; clear screen line .X
COLORSYN = $EAB2 ; calculate pointer to colour RAM
SETKEYS = $EBDC ; evaluate SHIFT/CTRL/C= keys
LDTB2 = $EDFD ; low byte screen line addresses
FUDTIM = $F734 ; increment real time clock
FRESTOR = $FD52 ; restore default I/O vectors
INITMEM = $fd8d ; initialise and test RAM
INITVIA = $FDF9 ; initialize I/O registers
_RTI = $FF56 ; restore registers and exit interrupt
SECOND = $FF93
TKSA = $FF96
ACPTR = $FFA5
CIOUT = $FFA8
UNTLK = $FFAB
UNLSN = $FFAE
LISTEN = $FFB1
TALK = $FFB4
SETLFS = $FFBA
OPEN = $FFC0
CLOSE = $FFC3
CHKIN = $FFC6
CLRCHN = $FFCC
CHRIN = $FFCF
CHROUT = $FFD2 ; output character to channel (via vector)
LOAD = $FFD5 ; load RAM from a device (via vector)
STOP = $FFE1 ; scan the stop key
;***********************************************************************************;
;
; BASIC keyword token values
TK_TO = $A4 ; TO token
TK_MINUS = $AB ; - token
TK_GO = $CB ; GO token
TK_PI = $FF ; PI token
KEYTBLSZ = 120 ; 12 keys * 10 bytes
MODE = $7F ; command mode, $01 = AUTO, $02 = TRACE, $03 = STEP
AUTONXT = $83 ; AUTO next line number
RENNXT = $85 ; RENUMBER next line number
CHNGFLG = $02CC ; find/change flag, $00 = FIND, $01 = CHANGE
AUTOINC = $03E2 ; AUTO increment
TRACELN = $03E4 ; to $03F1 - TRACE/STEP line numbers
;***********************************************************************************;
;***********************************************************************************;
;
; Programmers' Aid ROM start
* = $a000-2
.WORD $a000 ; Load address
.WORD dainit
.WORD PANMI
.BYT "A0",$C3,$C2,$CD ; A0CBM
;***********************************************************************************;
;
; NMI handler
PANMI
BIT VIA1PA1 ; test VIA 1 DRA, clear CA1 interrupt
JSR FUDTIM ; increment real time clock
JSR STOP ; scan the stop key
BEQ L7053 ; branch if [STOP]
JMP _RTI ; restore registers and exit interrupt
L7053 JSR FRESTOR ; restore default I/O vectors
JSR INITVIA ; initialize I/O registers
JSR INITSK ; initialize hardware
LDA #$00 ; clear .A
STA $02CA
JSR INITKEYLOG
JMP (WARMST) ; BASIC warm start entry point
;***********************************************************************************;
;
; initialize keyboard decode handler vector
INITKEYLOG
LDA #<KEYBDEC ; keyboard decode handler low byte
STA KEYLOG ; set keyboard decode logic pointer low byte
LDA #>KEYBDEC ; keyboard decode handler high byte
STA KEYLOG+1 ; set keyboard decode logic pointer high byte
RTS
;***********************************************************************************;
;
; initialize variables
INITVAR
LDA #10
STA AUTOINC ; set AUTO increment low byte
LDA #$00
STA AUTOINC+1 ; set AUTO increment high byte
STA RENNXT+1 ; set RENUMBER next line number high byte
STA MODE ; clear command mode
STA AUTONXT+1 ; clear AUTO next line number high byte
LDA #100
STA RENNXT ; set RENUMBER next line number low byte
STA AUTONXT ; set AUTO next line number low byte
RTS
;***********************************************************************************;
;
; parse parameters for AUTO/RENUMBER
PARSEAR
JSR CHRGET ; increment and scan memory
BEQ L70D7 ; exit if no more chrs
BCS L70BE ; if not numeric do syntax error then warm start
JSR DECBIN ; get fixed-point number into temporary integer
PHA ; save next character in command
LDA LINNUM+1 ; get start line number high byte
LDX LINNUM ; get start line number low byte
STA RENNXT+1 ; set RENUMBER next line number high byte
STX RENNXT ; set RENUMBER next line number low byte
STA AUTONXT+1 ; set AUTO next line number high byte
STX AUTONXT ; set AUTO next line number low byte
PLA ; restore next character in command
BEQ L70D7 ; exit if no more chrs
CMP #',' ; compare with ","
BEQ L70C1 ; if "," then parse interval
L70BE JMP $CF08 ; otherwise do syntax error then warm start
L70C1 JSR CHRGET ; increment and scan memory
BCS L70BE ; if not numeric do syntax error then warm start
JSR DECBIN ; get fixed-point number into temporary integer
PHA ; save next character in command
LDA LINNUM+1 ; get interval high byte
LDX LINNUM ; get interval low byte
STA AUTOINC+1 ; set AUTO increment high byte
STX AUTOINC ; set AUTO increment low byte
PLA ; restore next character in command
BNE L70BE ; if more chrs do syntax error then warm start
L70D7 RTS
;***********************************************************************************;
;
; add increment to AUTO next line number
ADDINC
CLC
LDA AUTONXT ; get AUTO next line number low byte
ADC AUTOINC ; add AUTO increment low byte
STA AUTONXT ; set AUTO next line number low byte
LDA AUTONXT+1 ; get AUTO next line number high byte
ADC AUTOINC+1 ; add AUTO increment high byte
STA AUTONXT+1 ; set AUTO next line number high byte
BCS L70EB ; branch if > 65535 ($FFFF)
CMP #$FA ; compare with 64000 ($FA00)
L70EB RTS
;***********************************************************************************;
;
; perform RENUMBER
L70EC JSR INITVAR ; initialize variables
JSR PARSEAR ; parse parameters for AUTO/RENUMBER
JSR CPYWORD ; copy word in zero page
.BYT TXTTAB,TMPPTR ; copy start of memory to temporary pointer
L70F7 JSR READPTR ; read through temporary pointer
BNE L70FF
JMP L7134
L70FF JSR ADDINC ; add increment to AUTO next line number
BCC L70F7 ; branch if < 64000
JMP RANGERR ; do out of range error then warm start
;***********************************************************************************;
;
; set immediate mode and do BASIC warm start
DOREADY
LDA #$FF ; current line high byte to -1, indicates immediate mode
STA CURLIN+1 ; set current line number high byte
JMP READY ; do warm start
;***********************************************************************************;
;
;
L710E LDA RENNXT ; get RENUMBER next line number low byte
STA AUTONXT ; set AUTO next line number low byte
LDA RENNXT+1 ; get RENUMBER next line number high byte
STA AUTONXT+1 ; set AUTO next line number high byte
JSR CPYWORD ; copy word in zero page
.BYT TXTTAB,TMPPTR ; copy start of memory to temporary pointer
L711B LDY #$03
LDA AUTONXT+1 ; get AUTO next line number high byte
STA (TMPPTR),Y
DEY
LDA AUTONXT ; set AUTO next line number high byte
STA (TMPPTR),Y
JSR ADDINC ; add increment to AUTO next line number
JSR READPTR ; read through temporary pointer
BNE L711B
JSR $C659 ; reset execute pointer and do CLR
JMP DOREADY ; set immediate mode and do BASIC warm start
;***********************************************************************************;
;
;
L7134 JSR STOSTRT ; store address of start of memory in temporary pointer
L7137 JSR READPTR ; read through temporary pointer
BEQ L710E
LDY #$04
STY $0F
L7140 LDA (TMPPTR),Y
L7142 BEQ L7137
CMP #$22 ; compare with "
BNE L7150
LDA $0F
EOR #$FF
STA $0F
BNE L7162
L7150 BIT $0F
BMI L7162
CMP #$8F
BEQ L7137
LDX #$06
L715A CMP L72B4-1,X
BEQ L7174
DEX
BNE L715A
L7162 INY
BNE L7140
;***********************************************************************************;
;
; read through temporary pointer
;
; Read from the address pointed to by TMPPTR, plus 1, return byte in .A
READPTR
LDY #$00 ; clear index
LDA (TMPPTR),Y ; get address low byte
TAX ; copy to .X
INY ; increment index
LDA (TMPPTR),Y ; get address high byte
STX TMPPTR ; set address low byte
STA TMPPTR+1 ; set address high byte
LDA (TMPPTR),Y ; get data byte from (TMPPTR+1)
RTS
;***********************************************************************************;
;
;
L7174 CLC
TYA
ADC TMPPTR
STA CHRGOT+1 ; save BASIC execute pointer low byte
STA $5A
LDX TMPPTR+1
BCC L7181
INX
L7181 STX CHRGOT+2 ; save BASIC execute pointer high byte
STX $5B
JSR CHRGET ; increment and scan memory
BCC L7194 ; branch if numeric character
CMP #TK_MINUS ; compare with token for "-"
BEQ L71C4
CMP #TK_TO ; compare with token for "TO"
BNE L7162
BEQ L71C4 ; branch always
L7194 JSR DECBIN ; get fixed-point number into temporary integer
JSR L71DC
JSR CPYWORD ; copy word in zero page
.BYT $5A,CHRGOT+1
LDX #$00
LDY #$00
L71A3 LDA STACK+1,X
BEQ L71B7
PHA
JSR CHRGET ; increment and scan memory
BCC L71B1 ; branch if numeric
JSR L7223
L71B1 PLA
STA (CHRGOT+1),Y ; set BASIC byte
INX
BNE L71A3
L71B7 JSR CHRGET ; increment and scan memory
L71BA JSR CHRGOT ; scan memory
BCS L71C4 ; branch if not numeric character
JSR L728D
BEQ L71BA
L71C4 TAX
SEC
LDA CHRGOT+1 ; get BASIC execute pointer low byte
SBC TMPPTR
TAY
TXA
CMP #',' ; compare with ","
BEQ L7174
CMP #TK_MINUS ; compare with token for "-"
BEQ L7174
CMP #TK_TO ; compare with token for "TO"
BEQ L7174
TAX
JMP L7142
;***********************************************************************************;
;
;
L71DC LDA RENNXT ; get RENUMBER next line number low byte
LDX RENNXT+1 ; get RENUMBER next line number high byte
STA AUTONXT ; set AUTO next line number low byte
STX AUTONXT+1 ; set AUTO next line number high byte
JSR CPYWORD ; copy word in zero page
.BYT TXTTAB,$24
L71E9 LDY #$03
LDA ($24),Y
CMP LINNUM+1
BNE L7209
DEY
LDA ($24),Y
CMP LINNUM
BNE L7209
;***********************************************************************************;
;
;
L71F8 LDA AUTONXT+1 ; get AUTO next line number high byte
LDX AUTONXT ; get AUTO next line number low byte
L71FC STA $62
STX $63
LDX #$90 ; set exponent to 16d bits
SEC ; set integer is +ve flag
JSR $DC49 ; set exponent = .X, clear mantissa 4 and 3 and normalise FAC1
JMP FLTASC ; convert FAC1 to ASCII string result in (.A.Y)
L7209 JSR ADDINC ; add increment to AUTO next line number
LDY #$01
LDA ($24),Y
BNE L7218
LDA #>$FA00-1
LDX #<$FA00-1
BNE L71FC ; branch always
L7218 TAX
DEY ; clear .Y
LDA ($24),Y
STX $25
STA $24
JMP L71E9
;***********************************************************************************;
;
;
L7223 STX $8A ; save .X
LDX VARTAB ; get start of variables low byte
LDY VARTAB+1 ; get start of variables high byte
STX $58
STY $59
INX
BNE L7231
INY
L7231 CPX MEMSIZ ; compare with end of memory low byte
TYA
SBC $38
BCC L723B
JMP MEMERR ; do out of memory error then warm start
L723B STY VARTAB+1 ; set start of variables high byte
STX VARTAB ; set start of variables low byte
LDY #$01
LDX #$00
L7243 LDA ($58,X)
STA ($58),Y
LDA $58
BNE L724D
DEC $59
L724D DEC $58
LDA $58
CMP CHRGOT+1 ; compare with BASIC execute pointer low byte
LDA $59
SBC CHRGOT+2 ; subtract save BASIC execute pointer high byte
BCS L7243
L7259 PHP ; save flags
JSR CPYWORD ; copy word in zero page
.BYT TMPPTR,$5A
PLP ; restore flags
LDY #$01
L7262 LDA ($5A),Y
BNE L726A
LDX $8A ; restore .X
DEY
RTS
L726A TAX
DEY
LDA ($5A),Y
TAY
BCS L7277
INY
BNE L727B
INX
BNE L727B
L7277 BNE L727A
DEX
L727A DEY
L727B TYA
LDY #$00
STA ($5A),Y
PHA
TXA
INY
STA ($5A),Y
STA $5B
PLA
STA $5A
JMP L7262
;***********************************************************************************;
;
;
L728D LDA VARTAB ; get start of variables low byte
BNE L7293
DEC VARTAB+1 ; decrement start of variables high byte
L7293 DEC VARTAB ; decrement start of variables low byte
JSR CPYWORD ; copy word in zero page
.BYT CHRGOT+1,$58
LDY #$01
LDX #$00
L729E LDA ($58),Y
STA ($58,X)
INC $58
BNE L72A8
INC $59
L72A8 LDA $58
CMP VARTAB ; compare with start of variables low byte
LDA $59
SBC VARTAB+1 ; subtract start of variables high byte
BCC L729E
BCS L7259 ; branch always
L72B4 .BYT $9B,$8A,$A7,$89,$8D,$CB
;***********************************************************************************;
;
; do out of range error then warm start
RANGERR
JSR INITVAR ; initialize variables
LDA #<RANGSTR ; set "?OUT OF RANGE" pointer low byte
LDY #>RANGSTR ; set "?OUT OF RANGE" pointer high byte
JSR PRTSTR ; print null terminated string
JMP $C462 ; print " ERROR" and do warm start
RANGSTR
.BYT "?OUT OF RANGE",$00
;***********************************************************************************;
;
; copy a word stored are one zero page address to another.
; The source and destination are defined in the two bytes that follow the jump to
; this routine, e.g.
;
; JSR CPYWORD
; .BYT $11,$22
;
; copies the word at $11,$12 to $22,$23
CPYWORD
CLC
PLA ; pull return address low byte
STA $87 ; set parameter adress low byte
ADC #$02 ; add two to skip parameters that follow the JSR
TAX ; copy new return address low byte
PLA ; pull return address high byte
STA $88 ; set parameter adress high byte
ADC #$00 ; add carry
PHA ; push back onto stack
TXA ; restore return address low byte
PHA ; push back onto stack
LDY #$01 ; return address points to last byte of JSR
LDA ($87),Y ; get source zero page address
TAX ; copy to .X
INY ; increment index
LDA ($87),Y ; get destination zero page address
TAY ; copy to .Y
LDA $00,X ; get low byte from source zero page address
STA $0000,Y ; set low byte of destination zero page address
LDA $01,X ; get high byte from source zero page address
STA $0001,Y ; set high byte of destination zero page address
RTS
;***********************************************************************************;
;
; store address of start of memory in temporary pointer
STOSTRT
LDA #TXTTAB ; start of memory pointer low byte
STA TMPPTR ; set temporary pointer low byte
LDX #$00 ; page zero
STX TMPPTR+1 ; set temporary pointer high byte
RTS
;***********************************************************************************;
;
; patch CHRGOT, display banner and initialize variables
DOPATCH
LDX #$07 ; length of patch
L7303 LDA L7315-1,X ; get patch code
STA CHRGOT+2,X ; store in CHRGOT routine
DEX ; decrement index
BNE L7303 ; loop until done
LDA #<BANNER ; get banner string address low byte
LDY #>BANNER ; get banner string address high byte
JSR PRTSTR ; print null terminated string
JMP INITVAR ; initialize variables
; patch to CHARGOT routine
L7315 JMP L731C ; replacement character get subroutine
.BYT $00 ; ?? dead code ??
JMP L7344 ; ?? dead code ??
;***********************************************************************************;
;
; replacement character get subroutine
L731C PHA ; save BASIC byte
STX $8A
LDA CHRGOT+2 ; get BASIC execute pointer high byte
CMP #>BUF ; compare with input buffer high byte
BNE L732B ; if not immediate mode ???
LDA CHRGOT+1 ; get BASIC execute pointer low byte
BEQ L734F ; beginning of input buffer
BNE L732F ; branch always
L732B LDA CHRGOT+1 ; get BASIC execute pointer low byte
STA $89
L732F LDA MODE ; get command mode
BEQ L733D ; continue if no mode set
CMP #$01 ; compare mode with AUTO
BNE L733A ; branch if not AUTO
JMP L7815 ; ??? do AUTO ???
L733A JMP L761E ; ??? do TRACE/STEP ???
L733D LDX $8A
PLA ; restore BASIC byte
CMP #':' ; compare with ":"
BCS L734E ; exit if >=
L7344 CMP #' ' ; compare with " "
BNE L734B ; not [SPACE], clear Cb if numeric and retirn
JMP CHRGET ; increment and scan memory
L734B JMP $E398 ; clear carry if byte = "0"-"9" and return
L734E RTS
L734F TSX ; copy stack pointer
LDA STACK+3,X ; get high byte of return address
CMP #$C4 ; compare with $C4xx
BNE L732F
; called from MAIN2
LDY #$00 ; clear .Y
STY $0B ; clear keyword index
L735B LDX #$FF ; set index to end of input buffer then ..
L735D INX ; increment index
LDA BUF,X ; get a byte from the input buffer
BMI L732F ; ?? token ??
CMP #' ' ; compare with " "
BEQ L735D ; repeat while [SPACE]
L7367 LDA KEYWDS,Y ; get byte from keyword table
BEQ L732F ; end of keywords
EOR BUF,X ; XOR with byte in input buffer
BNE L7375 ; not equal, check for end of keyword
INY ; increment table index
INX ; increment buffer index
BPL L7367 ; repeat for next, branch always
L7375 CMP #$80 ; just b7 different
BEQ L7383 ; keyword matches
L7379 INY ; increment table index
LDA KEYWDS-1,Y ; get byte from keyword table
BPL L7379 ; repeat until end of keyword
INC $0B ; increment keyword index
BNE L735B ; repeat for next keyword, branch always
L7383 INC CHRGOT+1 ; increment BASIC execute pointer low byte
DEX ; decrement buffer index
BNE L7383 ; repeat until pointer advanced to consume keyword
LDX $0B ; get keyword index
CPX #$02 ; compare with "STEP"
BMI L7390
PLA ; dump BASIC byte
PLA ; dump return address low byte
L7390 PLA ; dump return address high byte
LDA L73EE,X ; get command high byte
PHA ; push on to stack
LDA L73FE,X ; get command low byte
PHA ; push on to stack
SEI ; disable interrupts
JSR INITKEYLOG
CLI ; enable interrupts
RTS ; invoke command
;***********************************************************************************;
;
; BASIC keywords. Each word has b7 set in its last character as an end marker.
KEYWDS
.BYT "RU",'N'+$80 ; RUN
.BYT "AUT",'O'+$80 ; AUTO
.BYT "STE",'P'+$80 ; STEP
.BYT "TRAC",'E'+$80 ; TRACE
.BYT "OF",'F'+$80 ; OFF
.BYT "RENUMBE",'R'+$80 ; RENUMBER
.BYT "DELET",'E'+$80 ; DELETE
.BYT "HEL",'P'+$80 ; HELP
.BYT "FIN",'D'+$80 ; FIND
.BYT "DUM",'P'+$80 ; DUMP
.BYT "PRO",'G'+$80 ; PROG
.BYT "EDI",'T'+$80 ; EDIT
.BYT "CHANG",'E'+$80 ; CHANGE
.BYT "KE",'Y'+$80 ; KEY
.BYT "MERG",'E'+$80 ; MERGE
.BYT "KIL",'L'+$80 ; KILL
; extensions
.BYT "CMO",'N'+$80 ; CMON
.BYT "OL",'D'+$80 ; OLD
.BYT "O5SN",'D'+$80 ; O5SND
.BYT "O5RC",'V'+$80 ; O5RCV
.BYT "DIRECTOR",'Y'+$80 ; DIRECTORY
.BYT "DISKCM",'D'+$80 ; DISKCMD
.BYT $00
;***********************************************************************************;
;
; Action addresses for commands. These are called by pushing the address onto the
; stack and doing an RTS so the actual address - 1 needs to be pushed.
L73EE .BYT >L740E-1 ; perform RUN (MSB)
.BYT >L7808-1 ; perform AUTO (MSB)
.BYT >L7617-1 ; perform STEP (MSB)
.BYT >L7614-1 ; perform TRACE (MSB)
.BYT >L7611-1 ; perform OFF (MSB)
.BYT >L70EC-1 ; perform RENUMBER (MSB)
.BYT >L76CF-1 ; perform DELETE (MSB)
.BYT >L7780-1 ; perform HELP (MSB)
.BYT >L742B-1 ; perform FIND (MSB)
.BYT >L7861-1 ; perform DUMP (MSB)
.BYT >L7BB1-1 ; perform PROG (MSB)
.BYT >L7BBE-1 ; perform EDIT (MSB)
.BYT >L7423-1 ; perform CHANGE (MSB)
.BYT >L7943-1 ; perform KEY (MSB)
.BYT >L7E0E-1 ; perform MERGE (MSB)
.BYT >L7A31-1 ; perform KILL (MSB)
; extensions
.BYT >PERFORM_CMON-1 ; perform CMON (MSB)
.BYT >PERFORM_OLD-1 ; perform OLD (MSB)
.BYT >PERFORM_O5SND-1 ; perform O5SND (MSB)
.BYT >PERFORM_O5RCV-1 ; perform O5RCV (MSB)
.BYT >PERFORM_DIRECTORY-1 ; perform DIRECTORY (MSB)
.BYT >PERFORM_DISKCMD-1 ; perform DISKCMD (MSB)
L73FE .BYT <L740E-1 ; perform RUN (LSB)
.BYT <L7808-1 ; perform AUTO (LSB)
.BYT <L7617-1 ; perform STEP (LSB)
.BYT <L7614-1 ; perform TRACE (LSB)
.BYT <L7611-1 ; perform OFF (LSB)
.BYT <L70EC-1 ; perform RENUMBER (LSB)
.BYT <L76CF-1 ; perform DELETE (LSB)
.BYT <L7780-1 ; perform HELP (LSB)
.BYT <L742B-1 ; perform FIND (LSB)
.BYT <L7861-1 ; perform DUMP (LSB)
.BYT <L7BB1-1 ; perform PROG (LSB)
.BYT <L7BBE-1 ; perform EDIT (LSB)
.BYT <L7423-1 ; perform CHANGE (LSB)
.BYT <L7943-1 ; perform KEY (LSB)
.BYT <L7E0E-1 ; perform MERGE (LSB)
.BYT <L7A31-1 ; perform KILL (LSB)
; extensions
.BYT <PERFORM_CMON-1 ; perform CMON (LSB)
.BYT <PERFORM_OLD-1 ; perform OLD (LSB)
.BYT <PERFORM_O5SND-1 ; perform O5SND (LSB)
.BYT <PERFORM_O5RCV-1 ; perform O5RCV (LSB)
.BYT <PERFORM_DIRECTORY-1 ; perform DIRECTORY (LSB)
.BYT <PERFORM_DISKCMD-1 ; perform DISKCMD (LSB)
;***********************************************************************************;
;
; perform RUN
L740E LDX #$0E ; 7 line numbers
LDA #$FF ; inactive row indicator
L7412 STA TRACELN-1,X ; set TRACE/STEP line number
DEX ; decrement index
BNE L7412 ; repeat for all lines
LDX #$00 ; clear .X
STX CHRGOT+1 ; clear BASIC execute pointer low byte
PHA
JMP L733D
JMP DOREADY ; ?? dead code ??
;***********************************************************************************;
;
; perform CHANGE
L7423 LDX #$01 ; CHANGE
STX CHNGFLG ; set find/change flag
DEX ; clear .X
BEQ L7430 ; branch always
;***********************************************************************************;
;
; perform FIND
L742B LDX #$00 ; FIND
STX CHNGFLG ; set find/change flag
L7430 STX $03E0
STX $02CD
STX $02CE
JSR CHRGET ; increment and scan memory
TAX ; copy byte to set flags
BEQ L7457 ; branch if no more chrs
CMP #',' ; compare with ","
BEQ L7457
CMP #$22 ; compare with "
BEQ L7450
JSR CRNCH ; crunch BASIC token
JSR CHRGET ; increment and scan memory
JMP L7460
L7450 DEC $03E0
JSR CHRGET ; increment and scan memory
TAX ; copy byte to set flags
L7457 BEQ L74AF ; if no more chrs do syntax error then warm start
CMP #$22 ; compare with "
BEQ L74AF ; if " do syntax error then warm start
DEC $02CD
L7460 LDA CHRGOT+1 ; get BASIC execute pointer low byte
STA $0F
LDA CHNGFLG ; get find/change flag
BEQ L74B2 ; branch if FIND
L7469 JSR CHRGET ; increment and scan memory
INC $02CD
TAX ; copy byte to set flags
BEQ L74AF ; if no more chrs do syntax error then warm start
CMP #',' ; compare with ","
BNE L7469
JSR CHRGET ; increment and scan memory
TAX ; copy byte to set flags
BEQ L74BF ; branch if no more chrs
CMP #',' ; compare with ","
BEQ L74A9
CMP #$22 ; compare with "
BNE L7492
LDA $03E0
BEQ L74AF ; do syntax error then warm start
DEC $02CE
JSR CHRGET ; increment and scan memory
JMP L7497
L7492 LDA $03E0
BNE L74AF ; do syntax error then warm start
L7497 LDA CHRGOT+1 ; get BASIC execute pointer low byte
STA $02CF
L749C JSR CHRGET ; increment and scan memory
INC $02CE
TAX ; copy byte to set flags
BEQ L74BF ; branch if no more chrs
CMP #',' ; compare with ","
BNE L749C
L74A9 JSR CHRGET ; increment and scan memory
JMP L74BF
L74AF JMP $CF08 ; do syntax error then warm start