20 ;********* SUBROUTINEN1 **********
30 ;
40 ;
50 ;        KERNAL ROUTINEN
60 ;
70 SETLFS .DE $FFBA
80 SETNAM .DE $FFBD
90 OPEN   .DE $FFC0
100 CHKIN  .DE $FFC6
110 CHRIN  .DE $FFCF
120 CHROUT     .DE $FFD2
130 CLRCHN     .DE $FFCC
140 CHKOUT .DE $FFC9
150 GETIN  .DE $FFE4
160 ASCII1 .DE $CE00
170 ASCII2 .DE $CF00
180 AUSSPEICH  .DE $CD00
190 TEXTSPEICH  .DE $CC00
200 GETSPEICH  .DE $CB00
210 ANREDESPEI     .DE $CBA0
220 CLOSE      .DE $FFC3
230 IECIN      .DE $FFA5
240 CLALL      .DE $FFE7
250 CLRSCR     .DE $E544
260 TEXTTAB    .DE $B400
270 ;
280 ;****** PRGINIT1 ******
290 ;
300 ;**** ASCII (0-64) = 0-64 *
310 ;
320 PRGINIT1   LDX #$00
330  TXA
340 V1 STA ASCII1,X
350  INX
360  TXA
370  CPX #65
380  BNE V1
390 ;**** ASCII1 (65-90) = 97-122 ****
400  LDY #97
410  TYA
420 V2 STA ASCII1,X
430  INX
440  INY
450  TYA
460  CPX #91
470  BNE V2
480 ;**** ASCII1 (91-96) = 91-97 ****
490  TXA
500 V3 STA ASCII1,X
510  INX
520  TXA
530  CPX #97
540  BNE V3
550 ;**** ASCII1 (97-122) = 65-90 ****
560  LDY #65
570  TYA
580 V4  STA ASCII1,X
590  INX
600  INY
610  TYA
620  CPX #123
630  BNE V4
640 ;**** ASCII1 (123-192) =0 *
650  LDA #$00
660 V5 STA ASCII1,X
670  INX
680  CPX #193
690  BNE V5
700 ;**** ASCII1 (193-218) = 65-90 ***
710  LDY #65
720  TYA
730 V6 STA ASCII1,X
740  INX
750  INY
760  TYA
770  CPX #219
780  BNE V6
790 ;**** ASCII1 (219-155) =0 **
800  LDA #$00
810 V7 STA ASCII1,X
820  INX
830  BCC V7
840 ;**** DEL ZEICHEN ****
850            LDX #20
860            LDA #8
870  STA ASCII1,X
880 ;
890 ;**** ASCII2 ZEICHEN ***
900 ;
910  LDX #$00
920  LDA #$00
930 V88 STA ASCII2,X
940  INX
950            TXA
960  CPX #32
970  BNE V88
980 V8 LDA ASCII1,X
990  STA ASCII2,X
1000  INX
1010  CPX #127
1020  BNE V8
1030            LDA #20
1040  STA ASCII2,X
1050  LDX #8
1060  LDA #157
1070  STA ASCII2,X
1080  LDX #13
1090  TXA
1100            STA ASCII2,X
1110            LDX #$08
1120            LDA #20
1130            STA ASCII2,X
1140            LDA #133
1150 V9         TAX
1160            STA ASCII1,X
1170            INX
1180            TXA
1190            CPX #141
1200            BNE V9
1210            LDA #141
1220            TAX
1230            STA ASCII1,X
1240            LDA #20
1250            LDX #148
1260            STA ASCII1,X
1270            LDX #$A0
1280            LDA #32
1290            STA ASCII1,X
1300 ;
1310 ; ****  BILDSCHIRMPARAMETER ****
1320 ;
1330            LDA #$00
1340            STA $D020
1350            LDA #$00
1360            STA $D021
1370 ;          JSR $E544
1380            LDA #23
1390            STA $D018
1400            LDX #$00
1410            STX $08FF
1420            STX SYSFEHLER
1430            STX UIDFEHLER
1440            STX UIDNEWFLAG
1450            STX FEHLERFLAG
1460            STX LFFLAG
1470            STX NUFLAG
1480            STX WACHFLAG
1490            LDX #'.
1500            STX SYSNOFLAG
1510 ;
1520            LDX #$00
1530            LDA #$00
1540            STA *$C6
1550            LDY #28
1560            LDA #$00
1570            STA ($52),Y
1580            DEY
1590            STA ($52),Y
1600 GUESTFEST  LDA GUESTTEXT,X
1610            CMP #64
1620            BCC GUESTWTR1
1630            EOR #%00100000
1640 GUESTWTR1  STA ANREDESPEI,X
1650            BEQ INIT1END
1660            INX
1670            BNE GUESTFEST
1680            JMP INIT1END
1690 GUESTTEXT  .BY 13 13 'GAST =>' 00
1700 INIT1END   RTS
1710 ;
1720 ;  ****   RS-232 OEFFNEN  ****
1730 ;
1740 OPENRS232  LDA #2
1750             LDY #H,RSNAME
1760             LDX #L,RSNAME
1770  JSR SETNAM
1780            LDA #2
1790  LDX #2
1800  LDY #255
1810  JSR SETLFS
1820  JSR OPEN
1830 SETPUFFER  LDA #$00
1840            STA *$F7
1850            STA *$F9
1860            LDA #$C9
1870            STA *$F8
1880            LDA #$CA
1890            STA *$FA
1900            LDA $DD03
1910            ORA #32
1920            STA $DD03
1930            RTS
1940 RSNAME     .BY 38 33
1950 ;
1960 ; *******  GETIN RS-232 *******
1970 ;
1980 GETRS232   JSR CLRCHN
1990            LDX #2
2000            JSR CHKIN
2010            JSR GETIN
2020            AND #%01111111
2030  TAX
2040            LDA ASCII2,X
2050            BEQ GETRS232E
2060            JSR SCREENON
2070 GETRS232E  RTS
2080 ;
2090 ; *******  OUT RS-232  *******
2100 ;
2110 OUTRS232   PHA
2120            CMP #$00
2130            BNE OUTWEIT1
2140            PLA
2150            RTS
2160 OUTWEIT1   JSR CLRCHN
2170            LDX #2
2180            JSR CHKOUT
2190            PLA
2200            CMP #13
2210            BEQ OUTLF
2220 OUTCHRS    TAX
2230            LDA ASCII1,X
2240            JSR CHROUT
2250            CMP #10
2260            BEQ OUTCR
2270            RTS
2280 OUTLF      LDA LFFLAG
2290            BNE OUTCR
2300            LDA #10
2310            JMP OUTCHRS
2320 OUTCR      LDA #13
2330            JMP OUTCHRS
2340 ;
2350 ; *****  GETIN TASTATUR  *****
2360 ;
2370 GETTAST    JSR CLRCHN
2380            LDA #$00
2390            JSR GETIN
2400            BEQ TASTWEIT2
2410            JSR SCREENON
2420 TASTWEIT2  CMP #147
2430            BNE TASTWEIT1
2440            JSR CLRSCR
2450            LDA #$00
2460 TASTWEIT1  RTS
2470 ;
2480 ; *****  OUT BILDSCHIRM  *****
2490 ;
2500 OUTBILD    PHA
2510            CMP #$00
2520            BNE BILDWEIT
2530            PLA
2540            RTS
2550 BILDWEIT   JSR CLRCHN
2560            PLA
2570            JSR CHROUT
2580            RTS
2590 ;
2600 ;  *****  FLOPPY OEFFNEN  *****
2610 ;
2620 OPENFLOPPY JSR SETNAM
2630            LDA #$00
2640            STA DISKERRORF
2650            LDA FLOPPYFLAG
2660            CMP #9
2670            BNE OPENWTR1
2680            LDA FLOPPYAN
2690            BEQ OPENWTR1
2700            LDA #$08
2710            LDX #$09
2720            JMP OPENWTR2
2730 OPENWTR1   LDA #$08
2740            LDX #$08
2750 OPENWTR2   LDY #$08
2760            JSR SETLFS
2770            JSR OPEN
2780            BCC OPENOK
2790            STA DISKERRORF
2800 OPENOK     RTS
2810 ;
2820 ;  *****  CLOSE FLOPPY *****
2830 ;
2840 CLOSEFLOP  JSR CLRCHN
2850            LDA #$08
2860            JSR CLOSE
2870            RTS
2880 ;
2890 ;
2900 ; ******  CLOSE RS-232  ********
2910 ;
2920 CLOSERS232 JSR CLRCHN
2930            LDA #2
2940            JSR CLOSE
2950            RTS
2960 ;
2970 ;** GETIN 255 FLOPPY IN SPEICHER**
2980 ;
2990 GETFLOPPY  LDX #8
3000            JSR CHKIN
3010            LDY #$00
3020            STY *$90
3030 INFLOP1    JSR GETIN
3040            STA AUSSPEICH,Y
3050            INY
3060            BEQ SPEICHVOLL
3070            LDA *$90
3080            BEQ INFLOP1
3090            STY *$02
3100            JSR CLOSEFLOP
3110            RTS
3120 SPEICHVOLL STY *$02
3130            RTS
3140 ;
3150 ;**DISKFILE VON FLOPPY AUF RS-232*
3160 ;
3170 OUTFLOPPY  LDA DISKERRORF
3180            BNE OUTERROR1
3190            LDA FLOPPYAN
3200            BEQ NUR8
3210            LDA FLOPPYFLAG
3220            CMP #9
3230            BNE NUR8
3240            JMP ZUDISKSTAT
3250 NUR8       LDA #8
3260            STA FLOPPYFLAG
3270 ZUDISKSTAT JSR DISKSTAT1
3280            LDA TEXTSPEICH
3290            CMP #$30
3300            BEQ OUTFLOPPY1
3310            JSR OUTTEXT
3320 OUTERROR1  LDA #119
3330            JSR TEXT
3340            JMP EOF
3350 ;
3360 ;
3370 OUTFLOPPY1 JSR GETFLOPPY
3380 SCHL1WTR   LDY #$00
3390            STY $029D
3400            STY $029E
3410 SCHL1      LDA AUSSPEICH,Y
3420            JSR OUTBILD
3430            JSR PRTEST
3440            JSR OUTRS232
3450            TYA
3460            PHA
3470            JSR GETTAST
3480            AND #%00011111
3490            CMP #3
3500            BEQ ZUCTRLN
3510            CMP #14
3520            BEQ ZUCTRLN
3530            CMP #24
3540            BEQ STOP
3550            CMP #19
3560            BEQ WAITCRTLA
3570            JSR GETRS232
3580            AND #%00011111
3590            CMP #3
3600            BEQ ZUCTRLN
3610            CMP #14
3620            BEQ ZUCTRLN
3630            BNE RSCTRLCW1
3640 ZUCTRLN    PLA
3650            PHA
3660            JMP CTRLNEXT
3670 STOP       JMP ZUSTOP
3680 RSCTRLCW1  CMP #24
3690            BEQ STOP
3700            CMP #19
3710            BEQ WAITCRTLA
3720            BNE WAITINIT
3730 WAITCRTLA  JSR QZEITINIT
3740 WAITCRTL   JSR GETTAST
3750            AND #%00011111
3760            JSR CTRLZEITQ
3770            CMP #24
3780            BEQ STOP
3790            CMP #08
3800            BNE BDW2
3810            JSR BACKDOOR
3820 BDW2       CMP #17
3830            BEQ WAITINIT
3840            JSR GETRS232
3850            AND #%00011111
3860            CMP #08
3870            BNE BDW1
3880            JSR BACKDOOR
3890 BDW1       CMP #24
3900            BEQ STOP
3910            CMP #17
3920            BNE WAITCRTL
3930 WAITINIT   JSR FEHLERIN
3940 WAIT       JSR FEHLERC
3950            LDA $029E
3960            CMP $029D
3970            BEQ WAITEND
3980            SEC
3990            SBC #2
4000            CMP $029D
4010            BCC WAITEND
4020            LDA $02A1
4030            AND #%00000001
4040            BNE WAIT
4050 WAITEND    PLA
4060            TAY
4070            INY
4080            CPY *$02
4090            BEQ WTRFL1
4100            JMP SCHL1
4110 WTRFL1     LDA *$02
4120            BNE EOF
4130            JMP OUTFLOPPY1
4140 ZUSTOP     PLA
4150 EOF        LDA #$00
4160            STA $029D
4170            STA $029E
4180            JSR CLOSEFLOP
4190            RTS
4200 ;
4210 ;*TEXT VON RS-232 MIT ECHO HOLEN**
4220 ;
4230 GETTEXT    LDA #19
4240            STA *$40
4250 GETTEXTX   LDY #60
4260 GETTEXTY   STY *$3F
4270            LDY #00
4280            STY *$02
4290            JSR CURSOR
4300 WAITEIN    LDY *$3F
4310            JSR TIMEOUTIN
4320 WAITEIN1   JSR GETRS232
4330            BNE TEXTINJA
4340            JSR TIMEOUTEST
4350            LDX MENUEFLAG
4360            CPX #15
4370            BEQ GETWTR3
4380            LDX RESTFLAG
4390            BNE ZURETURN1
4400 GETWTR3    LDX TIMEOUT
4410            BNE GETWTR1
4420 ZURETURN1  JMP RETURN
4430 GETWTR1    JSR GETTAST
4440            BEQ WAITEIN1
4450 TEXTINJA   CMP #20
4460            BEQ DELETE
4470            CMP #148
4480            BEQ DELETE
4490            CMP #13
4500            BEQ RETURN
4510            CMP #141
4520            BEQ RETURN
4530            CMP #3
4540            BNE GETWTR2
4550            LDA #136
4560            EOR #%00100000
4570 GETWTR2    CMP #32
4580            BCC WAITEIN1
4590            JSR OUTBILD
4600            JSR CURSOR
4610            LDX NOECHO
4620            BNE GETECHO
4630            JSR OUTRS232
4640 GETECHO    LDY *$02
4650            STA GETSPEICH,Y
4660            INC *$02
4670            CPY *$40
4680            BNE WAITEIN
4690            JMP RETURN
4700 DELETE     LDY *$02
4710            BEQ WAITEIN1
4720            DEC *$02
4730            LDA #20
4740            JSR OUTBILD
4750            JSR OUTRS232
4760            JMP WAITEIN1
4770 RETURN     LDA #$00
4780            LDY *$02
4790            STA GETSPEICH,Y
4800            LDA #32
4810            JSR OUTBILD
4820            LDA #$00
4830            RTS
4840 ;SCREENON
4850 ;
4860 SCREENON   PHA
4870            LDA $D011
4880            ORA #16
4890            STA $D011
4900            LDA #$00
4910            STA SCREENSAVE
4920            PLA
4930            RTS
