/
kernal.asm
6111 lines (5735 loc) · 206 KB
/
kernal.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
; da65 V2.13.2 - (C) Copyright 2000-2009, Ullrich von Bassewitz
; Created: 2011-06-07 21:53:11
; Input file: kernal.901486-06.bin
; Page: 1
;
; assemble command:
; cl65 --start-addr 0xe000 -t none thisfile.a65 -o outputfile.bin
;
;
; IMPORTANT!
; if this isn't defined, the kernal is assembled for PAL
;
; uncomment for NTSC
NTSC = 1
.setcpu "6502"
L0014 := $0014
L0079 := $0079
L028F := $028F
L0314 := $0314
L0316 := $0316
L0318 := $0318
L031A := $031A
L031C := $031C
L031E := $031E
L0320 := $0320
L0322 := $0322
L0324 := $0324
L0326 := $0326
L0328 := $0328
L032A := $032A
L032C := $032C
L0330 := $0330
L0332 := $0332
L0DA3 := $0DA3
L1D3B := $1D3B
L2026 := $2026
L2A2A := $2A2A
L3256 := $3256
L414F := $414F
L4154 := $4154
L4243 := $4243
L435A := $435A
L4552 := $4552
L4C50 := $4C50
L4E4F := $4E4F
L5245 := $5245
L5246 := $5246
L5942 := $5942
L91CC := $91CC
LA000 := $A000
LA002 := $A002
LC000 := $C000
LC002 := $C002
LC408 := $C408
LC437 := $C437
LC474 := $C474
LC52A := $C52A
LC533 := $C533
LC644 := $C644
LC663 := $C663
LC677 := $C677
LC67A := $C67A
LC68E := $C68E
LCB1E := $CB1E
LCD8A := $CD8A
LCD9E := $CD9E
LCEFD := $CEFD
LCF08 := $CF08
LD6A3 := $D6A3
LD79E := $D79E
LD7F7 := $D7F7
LD849 := $D849
LD850 := $D850
LD853 := $D853
LD867 := $D867
LD8D7 := $D8D7
LDA28 := $DA28
LDAB9 := $DAB9
LDAD4 := $DAD4
LDB07 := $DB07
LDB0F := $DB0F
LDBA2 := $DBA2
LDBC7 := $DBC7
LDBCA := $DBCA
LDBD4 := $DBD4
LDC0C := $DC0C
LDC2B := $DC2B
LDCCC := $DCCC
LDDCD := $DDCD
LDFB4 := $DFB4
.byte $0F
.byte $DC
lda $61
cmp #$88
bcc LE00B
LE008: jsr LDAD4
LE00B: jsr LDCCC
lda $07
clc
adc #$81
beq LE008
sec
sbc #$01
pha
ldx #$05
LE01B: lda $69,x
ldy $61,x
sta $61,x
sty $69,x
dex
bpl LE01B
lda $56
sta $70
jsr LD853
jsr LDFB4
lda #$C4
ldy #$DF
jsr LE056
lda #$00
sta $6F
pla
jsr LDAB9
rts
LE040: sta $71
sty $72
jsr LDBCA
lda #$57
jsr LDA28
jsr LE05A
lda #$57
ldy #$00
jmp LDA28
LE056: sta $71
sty $72
LE05A: jsr LDBC7
.byte $B1
LE05E: adc ($85),y
.byte $67
ldy $71
iny
tya
bne LE069
inc $72
LE069: sta $71
ldy $72
LE06D: jsr LDA28
lda $71
ldy $72
clc
adc #$05
bcc LE07A
iny
LE07A: sta $71
sty $72
jsr LD867
lda #$5C
ldy #$00
dec $67
bne LE06D
rts
tya
and $44,x
.byte $7A
brk
pla
plp
lda ($46),y
brk
jsr LDC2B
bmi LE0D0
bne LE0BB
jsr LFFF3
stx $22
sty $23
ldy #$04
lda ($22),y
sta $62
iny
lda ($22),y
sta $64
ldy #$08
lda ($22),y
sta $63
iny
lda ($22),y
sta $65
jmp LE0E0
LE0BB: lda #$8B
ldy #$00
jsr LDBA2
lda #$8A
ldy #$E0
jsr LDA28
lda #$8F
ldy #$E0
jsr LD867
LE0D0: ldx $65
lda $62
sta $65
stx $62
ldx $63
lda $64
sta $63
stx $64
LE0E0: lda #$00
sta $66
lda $61
sta $70
lda #$80
sta $61
jsr LD8D7
ldx #$8B
ldy #$00
LE0F3: jmp LDBD4
;--------------------------------------
BIOERROR:
;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.
;
LE0F6: cmp #$F0
bne LE101
sty $38
stx $37
jmp LC663
LE101: tax
bne LE106
ldx #$1E
LE106: jmp LC437
;--------------------------------------
BCHOUT:
;output character
; This routine uses the KERNAL rutine CHROUT to output the character in
; (A) to an available output channel. A test is made for a possible I/O error.
;
LE109: jsr LFFD2
bcs LE0F6
rts
;--------------------------------------
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.
jsr LFFCF
bcs LE0F6
rts
;--------------------------------------
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.;
;
jsr LFFC9
bcs LE0F6
rts
;-------------------------------------
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.
;
jsr LFFC6
bcs LE0F6
rts
;--------------------------------------
BGETIN:
;get one 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.
jsr LFFE4
bcs LE0F6
rts
;--------------------------------------
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.
;
jsr $CD8A
jsr $D7F7
lda #$E1
pha
lda #$43
pha
lda $030F
pha
lda $030C
ldx $030D
ldy $030E
plp
jmp (L0014)
php
sta $030C
stx $030D
sty $030E
pla
sta $030F
rts
;--------------------------------------
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.
;
jsr LE1D1
ldx $2D
ldy $2E
lda #$2B
jsr LFFD8
bcs LE0F6
rts
;--------------------------------------
VERFYT:
;perform save/load
; This routine is essentially the same for both LOAD and VERIFY. The entry
; point determines 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.
;
lda #$01 ;flag verify
bit a:$A9 ;mask, will execute lda #$01 if address $e168
sta $0A ;store in VRECK, LOAD/VERIFY flag
jsr LE1D1 ;get LOAD/VERIFY parameters from text
lda $0A ;get VRECK
ldx $2B ;TXTTAB, start of BASIC
ldy $2C
jsr LFFD5 ;execute LOAD, KERNAL routine
bcs LE1CE ;if carry set, handle error
lda $0A ;test VRECK for LOAD or VERIFY
beq LE195 ;do LOAD
LE17B: ldx #$1C ;set error $1C, VERIFY error
jsr LFFB7 ;do READST, get status I/O word
and #$10 ;%00010000, test for mismatch
beq LE187 ;data match, continue
jmp LC437 ;data mismatch, do error
LE187: lda $7A ;<TXTPTR
cmp #$02
beq LE194
lda #$64 ;set address to text OK
ldy #$C3 ;at $a364
jmp LCB1E ;output string in (A/Y)
LE194: rts
LE195: jsr LFFB7 ;do READST, get status I/O for LOAD
and #$BF ;%10111111, test all but EOI
beq LE1A1 ;nope, no errors
ldx #$1D ;set error $1D, LOAD error
jmp LC437 ;do error
LE1A1: lda $7B ;>TXTPTR
cmp #$02
bne LE1B5
LE1A7: stx $2D ;set VARTAB, start of variables
sty $2E
lda #$76 ;set address to text READY
ldy #$C3 ;at $C376
jsr LCB1E ;output string in (A/Y)
jmp LC52A ;do CLR and restart BASIC
LE1B5: jsr LC68E ;reset TXTPTR
jmp LE800
;--------------------------------------
OPENT:
;perform open
; This routine extracts paramerters from text and performs the OPEN
; routine in KERNAL. A test is made for I/O errors.
;
jsr LE216
jsr LFFC0
bcs LE1CE
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.
;
jsr LE216
lda $49
jsr LFFC3
bcc LE194
LE1CE: jmp LE0F6
;--------------------------------------
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, and a new JiffyDOS
; routine is called at $xxxx. It jumps to $xxxx where the original SETLFS
; is performed, but also makes a test to find the first serial device number,
; and pokes it into FA. Then tests are made if any of the parameters were
; given. If so, these are set up as wanted.
LE1D1: lda #$00
jsr LFFBD
ldx #$01
ldy #$00
jsr LF7BD ; SETFLS, and device number in new JiffyDOS routine
jsr LE203
jsr LE254
jsr LE203
jsr LE1FD
ldy #$00
stx $49
jsr LFFBA
jsr LE203
jsr LE1FD
txa
tay
ldx $49
jmp LFFBA
;--------------------------------------
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).
;
LE1FD: jsr LE20B
jmp LD79E
;--------------------------------------
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.
;
LE203: jsr L0079
bne LE20A
pla
pla
LE20A: rts
;--------------------------------------
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 followed by a terminator. If so, exit
; and do SYNTAX error.
;
LE20B: jsr LCEFD
LE20E: jsr L0079
bne LE20A
jmp LCF08
;--------------------------------------
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.A
;
LE216: lda #$00
jsr LFFBD
jsr LE20E
jsr LD79E
stx $49
txa
ldx #$01
LE226: ldy #$00
jsr LFFBA
jsr LE203
jsr LE1FD
stx $4A
ldy #$00
lda $49
cpx #$03
bcc LE23C
dey
LE23C: jsr LFFBA
jsr LE203
jsr LE1FD
txa
tay
ldx $4A
lda $49
jsr LFFBA
jsr LE203
jsr LE20B
LE254: jsr LCD9E
LE257: jsr LD6A3
ldx $22
ldy $23
jmp LFFBD
;--------------------------------------
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.
;
lda #$DD
ldy #$E2
jsr LD867
;--------------------------------------
SIN:
;perform SIN
;
LE268: jsr LDC0C
lda #$E2
ldy #$E2
ldx $6E
jsr LDB07
jsr LDC0C
jsr LDCCC
lda #$00
sta $6F
jsr LD853
lda #$E7
ldy #$E2
jsr LD850
lda $66
pha
bpl LE29A
jsr LD849
lda $66
bmi LE29D
lda $12
eor #$FF
sta $12
LE29A: jsr LDFB4
LE29D: lda #$E7
ldy #$E2
jsr LD867
pla
bpl LE2AA
jsr LDFB4
LE2AA: lda #$EC
ldy #$E2
jmp LE040
;--------------------------------------
TAN:
;perform TAN
;
jsr LDBCA
lda #$00
sta $12
jsr LE268
ldx #$4E
ldy #$00
jsr LE0F3
lda #$57
ldy #$00
jsr LDBA2
lda #$00
sta $66
lda $12
jsr LE2D9
lda #$4E
ldy #$00
jmp LDB0F
LE2D9: pha
jmp LE29A
;--------------------------------------
; table of trigonometry constants
;
sta ($49,x)
.byte $0F
.byte $DA
ldx #$83
eor #$0F
.byte $DA
ldx #$7F
brk
brk
brk
brk
ora $84
inc $1A
and $861B
plp
.byte $07
.byte $FB
sed
.byte $87
sta $8968,y
ora ($87,x)
.byte $23
and $DF,x
sbc ($86,x)
lda $5D
.byte $E7
plp
.byte $83
eor #$0F
.byte $DA
.byte $A2
;END OF TRIG CONSTANT TABLE
;--------------------------------------
ATN:
;perform ATN
;
lda $66
pha
bpl LE313
jsr LDFB4
LE313: lda $61
pha
cmp #$81
bcc LE321
lda #$BC
ldy #$D9
jsr LDB0F
LE321: lda #$3B
ldy #$E3
jsr LE040
pla
cmp #$81
bcc LE334
lda #$DD
ldy #$E2
jsr LD850
LE334: pla
bpl LE33A
jmp LDFB4
LE33A: rts
;--------------------------------------
;ATNCON: table of ATN constants
.byte $0B
ror $B3,x
.byte $83
lda $79D3,x
asl $A6F4,x
sbc $7B,x
.byte $83
.byte $FC
bcs LE35B
.byte $7C
.byte $0C
.byte $1F
.byte $67
dex
.byte $7C
dec $CB53,x
cmp ($7D,x)
.byte $14
.byte $64
bvs LE3A6
.byte $7D
LE35B: .byte $B7
nop
eor ($7A),y
adc $3063,x
dey
ror $927E,x
.byte $44
sta $7E3A,y
jmp L91CC
.byte $C7
.byte $7F
tax
tax
tax
.byte $13
sta ($00,x)
brk
brk
brk
;END OF ATN CONSTANT TABLE
;--------------------------------------
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.
;
LE378: jsr LE480 ; initialize JiffyDOS commands and function keys
jsr LE3A4 ; Initialize BASIC
jsr LE404 ; output power-up message
ldx #$FB ; reset stack
txs
jmp LC474 ; BASIC_START ; print 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.
;
LE387: inc $7A
LE389: bne LE38D
LE38B: inc $7B
LE38D: lda LEA60
cmp #$3A
bcs LE39E
cmp #$20
beq LE387
sec
sbc #$30
sec
sbc #$D0
LE39E: 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.
;
.byte $80
.byte $4F
.byte $C7
.byte $52
cli
;END OF RNDSEED
;--------------------------------------
INITCZ:
;initialize BASIC RAM
;This routine sets the USR jump instruction to point to ?ILLIGAL 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.
LE3A4: lda #$4C ; put opcode for JMP at $54
LE3A6: sta $54
sta $00 ; USRPOK, set USR JMP instruction
lda #$48
ldy #$D2 ; vector to $D248, ?ILLEGAL QUANTITY
sta $01
sty $02
lda #$91 ; vector to $D391
ldy #$D3
sta $05 ; store in ADRAY2
sty $06
lda #$AA ; vector to D1AA
ldy #$D1
sta $03
sty $04 ; store in ADRAY1
ldx #$1C ; copy the CHRGET and RNDSED to RAM
LE3C4: lda LE387,x ; source address
sta $73,x ; destination address
dex ; next byte
bpl LE3C4 ; til ready
lda #$03
sta $53 ; store #3 in FOUR6, garbage collection
lda #$00
sta $68 ; init BITS, fac#1 overflow
sta $13
sta $18 ; init LASTPT
ldx #$01
stx $01FD
stx $01FC
ldx #$19
stx $16 ; TEMPPT, pointer to descriptor stack
sec ; set carry to indicate read mode
jsr LFF9C ; read MEMBOT
stx $2B ; set TXTTAB, bottom of RAM
sty $2C
sec ; read mode
jsr LFF99 ; read MEMTOP
stx $37 ; set MEMSIZ, top of RAM
sty $38
stx $33 ; set FRETOP = MEMTOP
sty $34
ldy #$00
tya
sta ($2B),y ; store zero at start of BASIC
inc $2B ; increment TXTTAB to next memory position
bne LE403 ; skip MSB
inc $2C
LE403: 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.
LE404: lda $2B
ldy $2C
jsr LC408
lda #<POWER_UP_MESSAGE_TEXT
ldy #>POWER_UP_MESSAGE_TEXT ; pointer to first string displayed
jsr LCB1E
lda $37
sec
sbc $2B
tax
lda $38
sbc $2C
jsr LDDCD
lda #<POWER_UP_MESSAGE
ldy #>POWER_UP_MESSAGE ; pointer to 'BYTES FREE'
jsr LCB1E
jmp LC644
;--------------------------------------
;VECTORS
;
LE44F: .word $F7E6 ; IERROR vector, print BASIC error message
.word $C483 ; IMAIN vector, BASIC warm start
.word $EAF2 ; ICRNCH vector, tokenize BASIC
.word $C71A ; IQPLOP vector, list BASIC text
.word $C7E4 ; IGONE vector, BASIC character dispatch
.word $CE86 ; IEVAL vector, evaluate BASIC token
;--------------------------------------
INIT_JIFFY_COMMANDS:
; This routine transfers the vectors $0300-$030b to set up the
; JiffyDOS commands.
;
LE45B: ldx #$0B
LE45D: lda LE44F,x
sta $0300,x
dex
bpl LE45D
rts
;--------------------------------------
POWER_UP_MESSAGE:
;
.byte " BYTES FREE",$0d,0
POWER_UP_MESSAGE_TEXT:
.byte " IFFYDOS 2012 CMD ETC",$0d,0
.res 8 ; FREE
;--------------------------------------
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 6502
; BRK instruction, or STOP/RESTORE being pressed. It outputs the
; READY prompt via the IERROR vector at $0300. The original IERROR
; vector points to $e38b, but JiffyDOS uses the error routine as
; an input to check new commands. If the error code, in (X) is larger
; than $80, then only the READY text will be displayed.
;
LE467: jsr $FFCC ; CLRCHN, close all I/O channels
lda #$00
sta $13 ; input prompt flag
jsr $C67A ; do CLR
cli ; enable IRQ
BASIC_READY:
ldx #$80 ; error code $80
jmp ($0300) ; perform error, JiffyDOS @ JIFFY_IERROR
IERROR_OLD:
LE47E: txa
bmi READY ; larger than $80
jmp $C43A ; nope, print error
READY: jmp $C474 ; print READY
;--------------------------------------
INIT_JIFFY_COMMANDS_AND_FKEYS:
; This routine initialises the JiffyDOS commands by jumping
; to $e453 where the $0300-vectors are set up. Then it sets
; up the vectors at $b0 to point to the funktionkey table.
; The entry at $e4c2 disables the funktionkeys after a @f
; command.
;
LE480: jsr LE45B ; init JiffyDOS command vectors
lda #$0A ; set up JiffyDOS function key vector
sta $B0
lda #$F7
sta $B1
LE48B: inx
stx $9B ; AKTFLT, activate/deactivate function keys
rts
LE48F: lda #$6F ; $6F=command channel
jsr LF199 ; prepare for input
jsr LFFCF ; input byte from command channel
cmp #$35 ; equal to $35
rts
;.res 6 ; FREE
;--------------------------------------
BRING_SERIAL_DATA_LINE_HIGH:
;bring the serial bus data line high.
;routine
;
LE4A0: lda $912C
and #$DF
sta $912C
rts
;--------------------------------------
BRING_SERIAL_DATA_LINE_LOW:
;bring the serial bus data line low.
;
LE4A9: lda $912C
ora #$20
sta $912C
rts
;--------------------------------------
CHECK_SERIAL_STABLE:
;make sure the byte that is being read from $911F (serial port) is the same
;as the value the port is currently reading. After verifying it stable, CLK is
;shifted into the carry and DATA into bit 0.
;
LE4B2: lda $911F
cmp $911F
bne LE4B2
lsr a
rts
LE4C1: txa
bne LE4CC
lda $C3
sta $AE
lda $C4
sta $AF
LE4CC: jmp LF66A
;--------------------------------------
JIFFY_TEST_DEVICE:
; The following routine tests if a device is present. On entry (X)
; holds the device to be tested. Open to the device is performed,
; and afterwards the statusword can be read for result.
;
LE4CF: stx $BA ; store .X in FA
LE4D1: tya
pha
jsr JIFFY_OPEN_COMMAND_CHANNEL ; open 15,x,15
jsr LF825 ; set command channel 15 as output
php
jsr LF391 ; close command channel
plp
pla
tay
ldx $BA
rts
.res 21 ; FREE
;--------------------------------------
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.
sta $a9 ; RINONE, check for start bit
lda #$01
sta $ab ; RIPRTY, RS232 input parity
rts
;--------------------------------------
RESET_CHARACTER_COLOR:
; 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.
;
lda $0286 ; get COLOR
sta ($F3),y ; and store in current screen position
rts
;--------------------------------------
IOBASE:
;get I/O address
; from Kernal location $FFF3 returns the base I/O location in X/Y
LE500: ldx #$10
ldy #$91
rts
;--------------------------------------
SCREEN:
; returns the size of the screen. columns-1 in .X, rows-1 in .Y
;
LE505: ldx #$16
ldy #$17
rts
;--------------------------------------
PLOT:
;put/get row and column
LE50A: bcs LE513
LE50C: stx $D6