CE42    ASM 
;**	CAOS 4.2 ROM E		**
 
	ORG	0E000H
 
	JP	BYE	;Tasten-RESET
	JP	BEXP1	;BASIC-
	JP	BEXP2	;Expansionen
	JP	BEXP3
	DW	TOKTAB
BASIO	JP	BASPV
 
	DW	7F7FH
	DB	'BASIC',0
	CALL	BASON
	JP	0C00DH
 
	DW	7F7FH
	DB	'REBASIC',0
	CALL	BASON
	JP	0C08CH
 
BASON	;BASIC-ROM auftauen
	IN	A,88H
	OR	80H
	OUT	88H
	LD	A,(IX+4)
	OR	60H	;Segment 3
	OUT	86H
	LD	(IX+4),A
	RET
 
;CRT-Treiber
 
PADR0	LD	DE,(CURSO)
PADR1	LD	HL,(WINON)
	ADD	HL,DE
	SLA	H
	SLA	H
	SLA	H
	;
PADR	PUSH	AF		;**34**
	LD	A,L	;Spalte
	LD	L,H	;Pixelzeile
	CP	28H
	JR	NC,IAD2	;zu gro~
	OR	80H
	LD	H,A	;HL=Pixeladr.
	POP	AF
	AND	A	;CY=0
	RET
	;
IAD2	POP	AF
	SCF		;CY=1
	RET
 
TCIF	;Test Cursor im Fenster	 **33**
	LD	A,(WINLG)
	DEC	A
	SUB	E	;Cursor-Spalte
	RET	C
	LD	A,(WINLG+1)
	DEC	A
	SUB	D	;Cursor-Zeile
	RET
 
DABR	PUSH	AF		;**32**
	CALL	TCIF
	JR	C,IAD2
	LD	A,(WINON)
	ADD	E	;Cursor-Spalte
	PUSH	DE
	LD	E,A	;absolut
	LD	A,(WINON+1)
	ADD	D	;Cursor-Zeile
	ADD	A
	ADD	A
	ADD	A	;*8
	LD	L,A	;Pixelzeile
	LD	H,0
	LD	D,H	;D=0
	ADD	HL,HL
	ADD	HL,HL	;*4
	ADD	HL,DE	;*5, zus. *40
	LD	DE,(VRAM)
	LD	E,A
	ADD	HL,DE
	POP	DE
	POP	AF
	AND	A
	RET
 
ESC81	;Farbe compeln (V<=>H)
	PUSH	AF
	AND	0C0H
	LD	C,A	;Bit 6,7
	POP	AF
	PUSH	AF
	AND	7	;hFarbe
	RLCA
	RLCA
	RLCA
	OR	C
	LD	C,A
	POP	AF
	RRCA
	RRCA
	RRCA
	AND	7	;vFarbe
	OR	C
	RET
 
WPIX	;Zeichen auf Grafikbildschirm
	;sichtbar machen, PE: DE,A
	PUSH	HL
	PUSH	DE
	PUSH	BC
	PUSH	AF
	LD	HL,(WINON)
	ADD	HL,DE
	EX	DE,HL	;DE:Absolut-Curs
	LD	HL,CCTL0
	ADD	A
	JR	NC,WPIX1
	LD	L,0AAH	;CCTL2
WPIX1	SUB	40H
	JR	C,WPIX2	;0..1F o.80..9F
	CP	80H
	JR	C,WPIX3	;20.40 o.A0..C0
WPIX2	ADD	40H
	INC	L	;um 1 CCTL
	INC	L	;h|her
WPIX3	LD	C,M
	INC	L	;BC=(CCTL)
	LD	B,M
	ADD	A	;*2
	LD	L,A
	LD	H,0
	ADD	HL,HL	;*4
	ADD	HL,BC	;*8
	LD	A,E	;Absolutspalte
	CP	28H
	JR	NC,POPS4;au~erhalb
	OR	80H
	LD	B,D
	LD	D,A
	LD	A,B	;A:=:D
	ADD	A
	ADD	A
	ADD	A	;*8
	LD	E,A	;DE=Pixadr.
	LD	A,(STBT)
	BIT	2,A	;invers?
	JR	Z,WPIX5
	LD	C,A	;ja, per
	LD	B,8	;Schleife
	PUSH	DE	;zeichnen
WPIX4	LD	A,M
	CPL		;(Hier kein
	LD	(DE),A	;Test auf
	INC	HL	;Schreiben
	INC	DE	;Pixel aus!)
	DJNZ	WPIX4	;8*
	LD	A,C
	RRCA
	JR	WPIX6
 
WPIX5	RRCA		;Schreiben Pix?
	JR	C,WPIX7
	PUSH	DE	;ja
	LDI		;sehr schnell
	LDI		;per LDI
	LDI
	LDI
	LDI
	LDI
	LDI
	LDI
WPIX6	POP	DE
WPIX7	RRCA		;Schreiben Farb?
	JR	C,POPS4
	LD	A,(IX+1);ja
	LD	H,A
	XOR	2
	DI
	OUT	84H	;Farbebene
	LD	A,(COLOR)
	LD	(DE),A	;sehr schnell
	INC	DE	;ohne Schleife
	LD	(DE),A
	INC	DE	;alles im DI
	LD	(DE),A
	INC	DE
	LD	(DE),A
	INC	DE
	LD	(DE),A
	INC	DE
	LD	(DE),A
	INC	DE
	LD	(DE),A
	INC	DE
	LD	(DE),A
	LD	A,H
	OUT	84H,A
	EI
POPS4	POP	AF
	POP	BC
	POP	DE
	POP	HL
	RET
 
MOVELN	;Rolle Fenster f}r Scrolling
	PUSH	HL
	PUSH	DE
	PUSH	BC
	PUSH	AF
	EX	AF,AF'
	PUSH	AF
	LD	A,C	;BC:Pixelzeilen
	EX	AF,AF'
	LD	A,(WINLG) ;Spalten
MOLN1	PUSH	HL
	PUSH	DE
MOLN2	LDI		;zeichenweise
	LDI
	LDI
	LDI
	LDI
	LDI
	LDI
	LDI
	JP	PE,MOLN2
	POP	DE
	POP	HL
	INC	H	;neue Spalte
	INC	D
	EX	AF,AF'
	LD	C,A
	EX	AF,AF'
	DEC	A	;Spaltenz{hler
	JR	NZ,MOLN1
	EX	AF,AF'
	POP	AF
	EX	AF,AF'
	JR	POPS4
 
PCHR	;CRT-Grundprogramm
	LD	DE,(CURSO)
	LD	HL,STBT
	BIT	4,M	;ESC aktiv?
	JR	Z,PCHR3
CRT1	RES	4,M
	CP	'0'
	RET	C
	CP	'9'+1
	JR	NC,PCHR1
	SUB	'0'
	JR	PCHR2
	;
PCHR1	CP	'A'
	RET	C
	RES	5,A
	CP	'Z'+1
	RET	NC
	SUB	'A'-0AH
PCHR2	LD	HL,L3SIZ;Tabelle
	CP	M	;lang genug?
	RET	NC
	ADD	A	;*2
	LD	HL,(L3TAB) ;klar zum
	JR	PCHR4	;Ansprung
	;
PCHR3	CP	20H	;Steuerfunktion?
	JR	NC,PCHR5
	BIT	3,M	;darstellen?
	JR	NZ,PCHR5
	ADD	A	;*2
	LD	HL,(CTAB)
PCHR4	LD	C,A
	LD	B,0
	ADD	HL,BC
	LD	A,M
	INC	HL
	LD	H,M
	LD	L,A
JPHL	JP	(HL)	;anspringen
 
ESC0	LD	A,E	;Tabulator
	AND	0F8H	;8er Step
	ADD	8
	LD	E,A
	JR	CUR1
	;
PCHR5	CALL	DABR
	RET	C	;au~erhalb
	LD	M,A	;ASCII eintragen
	CALL	WPIX	;darstellen
CUR	INC	E
CUR1	LD	A,(WINLG)
	DEC	A
	CP	E
	RET	NC
NL	LD	E,0	;NL f}r 1E
CUD	INC	D
	LD	A,(WINLG+1)
	CP	D
	RET	NZ
	LD	HL,(WEND)
	JP	(HL)	;PAGE o. SCROLL
 
HCOPY	LD	HL,(HCADR) ;ShCLR
	JP	(HL)
 
CUL	LD	A,E
	AND	A
	JR	Z,CUL1
	DEC	E
	RET
 
CUL1	LD	A,D
	AND	A
	RET	Z
	DEC	D
CEL	LD	A,(WINLG)
	DEC	A
	LD	E,A
	RET
 
CUU	LD	A,D
	AND	A
	RET	Z
	DEC	D
	RET
 
PAGE	LD	HL,HOMEPG ;ShCUU
WADR	LD	(WEND),HL
	RET
 
SCROL	LD	HL,SCRLPG ;ShCUD
	JR	WADR
 
CLR	CALL	CUL
DEL	PUSH	DE	;Cursor retten
	CALL	DABR
	LD	A,M
	AND	A	;Ende?
	JR	Z,POPDE
	PUSH	HL	;VRAM
DEL1	PUSH	DE	;Cursor
	INC	E	;n{chste Spalte
	CALL	DABR	;raus?
	JR	NC,DEL2
	LD	E,0	;ja, wie NL
	INC	D
	CALL	DABR	;raus?
	JR	C,DEL3	;ja-wie Ende
DEL2	LD	A,M
	AND	A	;Ende?
	JR	Z,DEL3
	LD	B,D
	LD	C,E	;BC:=DE
	POP	DE	;DE=links davon
	EX	(SP),HL	;HL=VRAM links
	LD	M,A	;eintragen
	CALL	WPIX	;zeichnen
	LD	D,B
	LD	E,C	;DE:=BC
	JR	DEL1	;von vorn
 
DEL3	POP	DE
	POP	HL
	LD	M,0
	LD	A,' '
	CALL	WPIX
POPDE	POP	DE
	RET
 
INS	PUSH	DE	;Cursor
	LD	A,' '
	CALL	DABR
INS1	LD	B,M	;VRAM
	LD	M,A	;neues Zeichen
	CALL	WPIX	;zeichnen
	LD	A,B
	AND	A	;Dummy?
	JR	Z,INS2
	INC	E	;CUR
	CALL	DABR	;raus?
	JR	NC,INS1
	LD	E,0	;wie NL
	INC	D
	CALL	DABR	;raus?
	JR	NC,INS1
INS2	POP	DE	;wenn ja Schlu~
	RET
 
CLS	LD	A,(WINLG+1) ;ShHOME
	LD	D,0
CLS1	PUSH	AF
	CALL	CLLN
	POP	AF
	INC	D
	DEC	A
	JR	NZ,CLS1	;A Zeilen
HOMEPG	LD	D,0
CBL	LD	E,0
	RET
 
CLLINE	;L|schen einer Zeile
	;HL: Adr. C: L{nge, A: Byte
	LD	B,C
CLL1	LD	D,L	;L retten
	LD	M,A	;zeichenweise
	INC	L	;ohne Schleife
	LD	M,A
	INC	L
	LD	M,A
	INC	L
	LD	M,A
	INC	L
	LD	M,A
	INC	L
	LD	M,A
	INC	L
	LD	M,A
	INC	L
	LD	M,A
	LD	L,D	;L holen
	INC	H
	DJNZ	CLL1
	RET
 
SCRLPG	LD	A,(WINLG) ;Spalten
	LD	C,A
	LD	B,0
	LD	A,(WINLG+1) ;Zeilen
	DEC	A	;nur 1 Zeile?
	JR	Z,SCRL3	;nur CLLN
	PUSH	DE
	PUSH	AF
	LD	DE,0	;Cursor li/oben
	CALL	DABR
	EX	DE,HL
SCRL1	LD	HL,40	;1 Zeile tiefer
	ADD	HL,DE
	PUSH	HL
	PUSH	BC
	LDIR		;im VRAM eine
	POP	BC	;Zeile rollen
	POP	DE
	DEC	A
	JR	NZ,SCRL1;A*
	POP	AF
	ADD	A
	ADD	A
	ADD	A	;*8: Pixelzeile
	LD	C,A
	LD	DE,0
	LD	B,D
	CALL	PADR1
	EX	DE,HL	;DE=PixAdr.
	LD	L,8	;H war 0
	ADD	HL,DE
	LD	A,(STBT)
	RRA
	RRA		;Schreiben Farb?
	JR	C,SCRL2
	PUSH	AF
	CALL	FARBEA
	CALL	MOVELN
	CALL	FARBEA
	POP	AF
SCRL2	RLA		;Schreiben Pix?
	CALL	NC,MOVELN
	POP	DE
SCRL3	DEC	D
	;
CLLN	LD	E,0	;ShDEL
	CALL	DABR	;Au~erhalb?
	RET	C	;(Selbstschutz)
	LD	A,(WINLG)
	LD	B,A	;Spalten
	LD	C,A
	XOR	A
CLLN1	LD	M,A	;VRAM l|schen
	INC	HL
	DJNZ	CLLN1
	CALL	PADR1
	RET	C
	PUSH	DE
	LD	A,(STBT)
	RRCA		;Schreiben Pix?
	LD	E,A	;nach E merken
	JR	C,CLLN2
	XOR	A
	PUSH	HL
	CALL	CLLINE	;Pixel
	POP	HL
CLLN2	RRC	E	;Schreiben Farb?
	JR	C,CLLN3
	CALL	FARBEA
	LD	A,(COLOR)
	CALL	CLLINE	;Farbe
	CALL	FARBEA
CLLN3	POP	DE
	RET
 
FARBEA	LD	A,(IX+1);wie ESC9
	XOR	2
	DI
	LD	(IX+1),A
	OUT	84H
	EI
	RET
 
BEEP	LD	BC,0A0FH;CHR(7)
	LD	HL,30H
	PUSH	DE
	LD	E,H	;E=0
	CALL	TON2
	LD	A,1EH
	CALL	WAIT
	LD	A,3
	OUT	8CH
	LD	A,10H
	POP	DE
	JP	WAIT
 
CLIK	LD	HL,30H
	PUSH	DE
	LD	E,H	;E=0
	CALL	TON2
	POP	DE
	RET
 
ESC8	LD	HL,COLOR;Farbtausch
	LD	A,M
	CALL	ESC81
LDMA	LD	M,A		;**28**
	RET
 
LDAM	LD	A,M		;**29**
	RET
 
CLICK	LD	A,(IX+8);ShINS
	XOR	20H
	LD	(IX+8),A
NOT	RET
 
ESC	LD	HL,STBT	;ShSTOP
	SET	4,M
	RET
 
CRT	PUSH	HL		;**00**
	PUSH	DE
	PUSH	BC
	PUSH	AF
	CALL	PCHR
	LD	(CURSO),DE
	POP	AF
	POP	BC
	POP	DE
	POP	HL
	RET
 
;KBD-Treiber
 
ISRC3	;ISR CTC Kanal 3 (Tastatur)
	EI
	PUSH	AF
	LD	A,23H	;DI,ZG256,Res
	OUT	8FH	;CTC K3
	LD	(IX+13),0 ;Zeichen tot
	JR	TST4
 
ISRPB	;ISR PIO Kanal B (Tastatur)
	PUSH	AF
	IN	A,8FH	;gemessene
	PUSH	AF	;Zeit retten
	LD	A,0A7H	;EI,ZG256,Res
	OUT	8FH,A
	LD	A,8FH	;Zeitkonstante
	OUT	8FH
	POP	AF
	EI
	OR	A	;doppelt
	JR	Z,TST4
	CP	14H	;gemoppelt
	JR	C,TST4
	CP	78H	;zu kurz
	JR	NC,TST4	;(z.B.St|rung)
	CP	65H	;Diskriminator
	JR	NC,TST3
	ADD	0BEH	;Stop-Bit?
	JR	C,TST3
	PUSH	HL
	PUSH	DE
	LD	A,(IX+12)
	RRA		;7bit-Scancode
	XOR	1	;Startbit neg.
	LD	L,(IX+14)
	LD	H,(IX+15)
	LD	D,0
	LD	E,A
	ADD	HL,DE	;Pos. in KTAB
	LD	A,M	;ASCII holen
	POP	DE
	POP	HL
	BIT	7,(IX+8);CAPS aktiv?
	JR	NZ,TST2	;1=nein
	CP	40H
	JR	C,TST2
	CP	80H
	JR	NC,TST2
	XOR	20H	;Klein<=>Gro~
TST2	CP	(IX+13)	;= letzter Code?
	JR	NZ,TST6
	PUSH	AF	;ja
	LD	A,(COUNT)
	CP	(IX+10)	;FastRepeat?
	JR	C,TST5	;ja
	POP	AF	;nein
	INC	(IX+10)	;Zeit abwarten
	JR	TST4
 
TST3	RR 	(IX+12)	;Bit rechts
TST4	IN	A,89H	;einschieben
	OUT	89H	;und PIO-Logik
	POP	AF	;freigeben
	RETI
 
TST5	POP	AF
	JR	TST7
 
TST6	LD	(IX+10),0 ;neuer Code
	CP	16H	;CAPS?
	JR	Z,TST8
TST7	LD	(IX+13),A ;eintragen
	SET	0,(IX+8);g}ltig machen
	JR	TST4
 
TST8	LD	A,(IX+8);CAPS-Programm
	XOR	80H
	LD	(IX+8),A
	LD	A,16H
	JR	TST7
 
KBDS	;Abfrage ohne Quittung	 **0C**
	OR	A
	BIT	0,(IX+8);Code g}ltig?
	RET	Z
	LD	A,(IX+13)
	SCF		;wenn ja
	RET
 
KBDZ	;Abfrage mit Quittung	 **0E**
	CALL	KBDS
	RET	NC
	RES	0,(IX+8)
	RET
 
BRKT	;Test auf BRK-Anforderung**2A**
	CALL	KBDS
	RET	NC
	CP	3
	SCF
	RET	Z
	AND	A
	RET
 
;SWITCH und JUMP
 
	DW	7F7FH
	DB	'SWITCH',1
	LD	D,E
	CALL	MODU
	LD	A,L
	CALL	AHSPC	;Platz
	LD	A,H
	CALL	AHSPC	;Kennbyte
	LD	A,D
	CALL	AHEX	;Steuerbyte
	JP	CRLF
 
MODU	;Lesen und Schalten	 **26**
	LD	H,0B8H	;H(ModulStSp)
	LD	C,80H	;I/O-Adr.
	LD	B,L
	CP	2	;Parameter?
	JR	NC,MODU1
	LD	D,M	;Nur lesen
RSTRB	IN	H,(C)
	RET
 
MODU1	LD	M,D	;eintragen
	LD	A,L
	CP	5	;interne Module?
	JR	C,MODU2
	OUT	(C),D	;Senden Steuerb.
	JR	RSTRB
 
MODU6	AND	0F5H	;f}r RAM0
	BIT	0,D
	JR	Z,OUT88
	SET	1,A
	BIT	1,D
	JR	Z,OUT88
	SET	3,A
	JR	OUT88
 
MODU2	CP	4	;RAM4?
	JR	C,MODU3
	LD	A,(IX+4)
	AND	0FCH
	BIT	0,D
	JR	Z,SRAM4
	SET	0,A
	BIT	1,D
	JR	Z,SRAM4
	SET	1,A
SRAM4	LD	(IX+4),A
	OUT	86H
	JR	STBFF
 
MODU3	CP	3	;RAM8?
	JR	C,MODU4
	IN	A,89H
	AND	9FH
	BIT	0,D
	JR	Z,SRAM8	;RAM8 aus
	SET	5,A	;RAM8 ein
	BIT	1,D	;Schreibschutz?
	JR	Z,SRAM8
	SET	6,A	;aus
SRAM8	OUT	89H
	LD	A,(IX+1)
	OR	10H
	BIT	2,D	;RAM8-Segment?
	JR	NZ,SSEG8
	XOR	10H	;(nicht vorbe-
SSEG8	OUT	84H	;reitet f}r
	LD	(IX+1),A;256k-Variante)
	JR	STBFF
 
MODU4	CP	2	;BASIC-ROMC?
	JR	C,MODU5
	IN	A,88H	;(keine Ebenen-
	BIT	0,D	;Umschaltung!)
	RES	7,A	;aus
	JR	Z,OUT88
	SET	7,A	;ein
OUT88	OUT	88H
STBFF	LD	H,0FFH	;Kennbyte
	RET
 
MODU5	CP	1	;IRM?
	IN	A,88H
	JP	C,MODU6	;RAM0
	BIT	0,D
	RES	2,A
	JR	Z,OUT88
	SET	2,A
	JR	OUT88
 
	DW	7F7FH
	DB	'JUMP',1
	LD	A,L
JUMP	LD	B,A		;**27**
	LD	C,80H
	IN	A,(C)
	INC	A	;Kennbyte FF?
	JP	Z,ERRM	;ja-Fehler
	LD	A,0FFH	;Ausgabe FF
	LD	H,0B8H
	LD	L,B
	LD	M,A	;Eintrag
	DI
	OUT	(C),A
	IN	A,88H
	AND	7EH
	JP	BJUMP	;in IRM
 
 
;TAPE-Treiber
 
ISRI1	DI
	IN	A,88H
	OR	40H	;Motor ein
	AND	0DFH	;LED aus
ISRO1	OUT	88H
	EI
	LD	HL,(WEND)
	LD	(ZWEND),HL
	CALL	NOUT	;kein Drucker!
	LD	(ZOTAB),HL
	CALL	PAGE	;Page Mode
TOFF	LD	A,3	;Ton aus
	OUT	8CH	;CTC0
	OUT	8DH	;CTC1
	RES	1,(IX+8)
	JR	CSRO2
 
CSRO	;Abschlu~ Bandausgabe	 **09**
	LD	(IX+2),0FEH
	CALL	MBO
CSROI	LD	HL,(ZOTAB) ;intern
	LD	(OUTAB),HL
	LD	HL,(ZWEND) ;gro~es
	LD	(WEND),HL  ;R}cksetzen
	LD	HL,0B780H
	XOR	A
CSRO1	DEC	L	;KassPuff
	LD	M,A	;l|schen
	JR	NZ,CSRO1
	IN	A,88H
	AND	9FH	;Motor,LED aus
	OUT	88H
	CALL	CRLF
	RES	0,(IX+8)
CSRO2	BIT	3,(IX+1);HiRes?
	JR	Z,CSRO3
	IN	A,89H	;nein-
	SET	7,A	;Blinken ein
	OUT	89H
CSRO3	BIT	1,(IX+8);neuer Ton?
	JR	NZ,CSRO3;Ende abwarten
	LD	A,47H	;CTC2 auf
	OUT	8EH	;Blinken
	LD	A,0CH	;stellen
	OUT	8EH
	RET
 
ISRO	;Init. Bandausgabe	 **08**
	DI
	IN	A,88H
	OR	60H	;Motor,LED ein
	CALL	ISRO1
	LD	(IX+2),0
	LD	BC,1000H
	;
MBO	;Ausgabe 1 Block	 **01**
	INC	(IX+2)
	DI
	LD	A,87H	;EI,ZG16,Res
	OUT	8DH
	LD	A,2FH	;Vorton
	OUT	8DH
	EI
	LD	D,A	;D=2Fh
	LD	E,A	;E=2Fh
MBO1	CALL	BITOUT
	CPI
	JP	PE,MBO1	;BC mal
	CALL	ZTON	;Trennzeichen
	LD	A,(IX+2)
	CALL	BYTOT	;Blocknummer
	LD	L,(IX+5)
	LD	H,(IX+6)
	LD	B,80H
BLKOT	LD	A,M
	CALL	BYTOT	;Datenbyte
	LD	A,C
	ADD	M	;Pr}fsumme
	LD	C,A	;nebenher
	INC	HL
	DJNZ	BLKOT
	CALL	BYTOT	;und ausgeben
	LD	A,D
	CALL	HBITOT	;noch ein
	LD	E,L	;Knacks
	LD	D,H
	LD	A,3	;CTC stoppen
	OUT	8DH
	RET
 
BYTOT	;Ausgabe eines Bytes
	PUSH	BC
	LD	C,A
	LD	B,8
BYTOUT	RRC	C	;mit Bit0
	LD	E,17H	;beginnend
	CALL	NC,BITOUT
	LD	E,2FH	;Zeitkonstanten
	CALL	C,BITOUT
	DJNZ	BYTOUT	;8*
	POP	BC
ZTON	LD	E,5DH	;ZK Trennz.
BITOUT	CALL	HBITOT	;Aufrufen und
HBITOT	LD	(IX),D	;reinlaufen
HBIT1	LD	A,(IX)	;Warten auf
	AND	A	;Interrupt
	JR	NZ,HBIT1
	LD	D,E
	RET
 
ISRI	;Init. Bandeingabe	 **0A**
	CALL	ISRI1
	;
MBI	;Einlesen 1 Block	 **05**
	LD	A,83H	;EI
	OUT	8AH	;an PIO A
	PUSH	HL
	PUSH	DE
MBI1	LD	B,16H
	LD	(IX+13),0 ;Pr}fsumme=0
MBI2	CALL	STOP1
	JR	C,MBI1
	CP	0BAH
	CALL	LEDOO
	JR	C,MBI1	;16h korrekte
	DJNZ	MBI2	;Schwingungen
MBI3	LD	B,2	;erkennen
MBI4	XOR	A
	LD	C,A
	LD	(IX),A
	CALL	STOP21	;2 halbe Trenn-
	CP	5DH	;zeichen er-
	JR	NC,MBI3	;kennen
	DJNZ	MBI4
	CALL	BYTIN	;Blocknummer
	JR	C,MBI5	;St|rung
	LD	(IX+2),A
	LD	B,80H
	LD	L,(IX+5)
	LD	H,(IX+6)
BLKIN	CALL	BYTIN	;Datenbyte
	JR	C,MBI5	;St|rung
	LD	M,A
	LD	A,(IX+13)
	ADD	M	;aufsummieren
	LD	(IX+13),A
	INC	HL
	DJNZ	BLKIN
	CALL	BYTIN	;Pr}fsumme
	JR	C,MBI5	;St|rung
	SUB	(IX+13)	;gleich?
	ADD	0FFH	;CY:=/Z
MBI5	POP	DE
	POP	HL
	DI
	LD	A,3	;DI an PIO A
	OUT	8AH
	EI
LEDOO	IN	A,88H	;LED ein/aus
	SET	5,A	;je nach CY
	JR	NC,MBI6
	RES	5,A
MBI6	OUT	88H
	RET
 
ISRC1	;ISR CTC Kanal 1 (Kassette-Out)
	PUSH	AF
	LD	A,87H
	OUT	8DH
	LD	A,(IX)	;Uergabezelle
	OUT	8DH
	LD	(IX),0	;Quittierung
	JR	ISR1E
 
ISRPA	;ISR PIO Kanal A (Kassette-In)
	PUSH	AF
	IN	A,8EH
	LD	(IX),A	;Uebergabezelle
	LD	A,7
	OUT	8EH
	LD	A,0A3H
	OUT	8EH
ISR1E	POP	AF
INTEND	EI
	RETI
 
STOP1	LD	(IX),0	;1 Bit einlesen
STOP11	IN	A,88H	;PIO-Logik
	OUT	88H	;freigeben
	LD	A,(IX)	;Warten auf
	OR	A	;Interrupt
	JR	Z,STOP11
	LD	C,A
	LD	(IX),0
STOP21	IN	A,88H	;dto.
	OUT	88H,A
	LD	A,(IX)
	OR	A
	JR	Z,STOP21
	ADD	C	;beide 'Zeiten'
	RET		;addieren
 
BYTIN	;Einlesen eines Bytes
	;PA: A:Byte, CY=1: St|rung
	LD	DE,800H
TRN1	CALL	STOP1
	JR	C,TRN2
	CP	0BAH	;zu intolerant
	RET	C
TRN2	CCF
	RR 	E	;Bit einschieben
	DEC	D
	JR	NZ,TRN1	;8*
	CALL	STOP1	;Trennzeichen
	LD	A,E	;mit CY-
	RET		;R}ckmeldung
 
;BASIC:
 
BEXP1	;BASIC-Exp 1
	LD	A,B
	SUB	9
	JR	C,SNERR1
	CP	27
	JR	NC,SNERR1	;>26
	RLCA		;*2
	LD	C,A
	LD	B,0
	EX	DE,HL
	LD	HL,TOKJP+8
	JP	0C8B7H	;R}cksprung
 
BEXP2	;BASIC-Exp 2
	LD	A,M
	CP	0DFH
	RET	C		;<DFH
	CP	0E3H
	RET	NC		;>E2H
	CP	0E1H	;AT?
	JP	Z,PRAT
	LD	A,(3FDH)
	AND	A	;PRINT-Erw.?
	JR	NZ,SNERR1
	INC	A
	LD	(3FDH),A
PREX1	PUSH	HL
	LD	HL,COLOR
	CALL	IRMRD
	POP	HL
	LD	(37EH),A ;Farbe merken
	LD	A,M
	CP	0DFH	;INK?
	JR	Z,PRINK
	CP	0E2H	;COLOR?
	JP	Z,PRCOL
	CALL	0C8BDH
	CALL	PAPER
PREX2	LD	A,M
	CP	';'
	JR	Z,PREX5
	JR	SNERR1
 
PRCOL	CALL	0C8BDH
	CALL	BCOLOR
	JR	PREX2
 
SNERR1	JP	0C348H	;SN-ERROR
 
PRINK	CALL	0C8BDH
	CALL	INK
	LD	A,M
	CP	';'
	JR	Z,PREX5
	CALL	0C8CCH	;Komma?
	DB	','
	CP	0E0H	;PAPER?
	JR	NZ,SNERR1
	CALL	0C8BDH
	CALL	PAPER
	CALL	0C8CCH
	DB	';'
PREX3	CALL	0CB03H
	LD	A,(37EH)  ;Farbe
	PUSH	HL
	LD	HL,COLOR
	CALL	IRMWR	  ;eintragen
	POP	HL
	POP	BC
	RET
PREX4	PUSH	BC
	JR	PREX1
PREX5	CALL	0C8BDH
	JR	PREX3
 
BEXP3	;BASIC-Exp 3
	LD	A,C
	CP	62H
	JP	Z,VPEEK
	CP	6EH
	JP	Z,PTEST
	CP	7CH
	JP	Z,CSRLN
	CP	76H
	JP	Z,VGET
	SUB	3EH
	JR	C,SNERR1
	CP	7
	JR	NC,SNERR1
	EX	DE,HL
	LD	BC,TOKJP ;Tokentab.
	POP	HL
	LD	L,A
	ADD	HL,BC
	LD	C,M
	INC	HL
	LD	H,M
	LD	L,C
	PUSH	HL	;Routine
	EX	DE,HL	;anspringen
	RET
 
STRING	;String vervielf{ltigen
	CALL	0C8CCH
	DB	'('	;Klammer auf?
	CALL	0D421H
	PUSH	AF
	CALL	0C8D6H	;Komma?
	CALL	0CD3AH
	CALL	0C8DBH	;Klammer zu?
	POP	AF
	PUSH	HL
	PUSH	AF
	CALL	0D330H
	INC	HL
	INC	HL
	LD	E,M
	INC	HL
	LD	D,M
	POP	BC
	PUSH	BC
	PUSH	AF
	PUSH	DE
	LD	C,A
	XOR	A
	CP	C
	JR	Z,STR2
	CP	B
	JR	Z,STR2
	LD	A,C
	DEC	B
	JR	Z,STR2
STR1	ADD	C
	JR	C,STR5
	DJNZ	STR1
STR2	LD	B,A
	LD	C,0
	PUSH	BC
	CALL	0D1E1H	;Str.-Arithm.
	POP	BC
	POP	BC
	PUSH	BC
	CALL	0D17EH
	POP	HL
	EX	(SP),HL
	LD	A,H
	POP	HL
	EX	(SP),HL
	LD	L,A
	INC	H
STR3	DEC	H
	PUSH	HL
	PUSH	BC
	JR	Z,STR4
	CALL	0D2F2H
	POP	BC
	POP	HL
	JR	STR3
STR4	POP	BC
	POP	HL
	POP	DE
	CALL	0D302H
	JP	0D1A9H
STR5	LD	E,1CH	;ST-
	JP	0C356H	;ERROR
 
RENUM	;neu nummerieren
	PUSH	HL
	LD	HL,10
	LD	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0C4BBH	;n{chste Zeile
	JP	NC,0C44DH ;UL-ERROR
	POP	DE
	PUSH	AF
	PUSH	BC
	CALL	0C4BEH
	JP	NC,0C44DH ;UL-ERROR
	POP	BC
	JP	0C450H	;einsortieren
 
PAUSE	;Programm unterbrechen
	CALL	0C8BEH
	JR	NZ,PAUS2
PAUS1	CALL	KBDS
	JR	NC,PAUS1
	CP	3	;BRK?
	RET	Z
	CP	0AH	;CUU?
	JR	NZ,PAUS1
	JP	0DDE4H	;Eingabe ASCII
PAUS2	CALL	0D421H
	LD	C,A
PAUS3	LD	A,10H	;96 sek.
	LD	E,14H	;WAIT
	CALL	0F015H	;PV5
	PUSH	BC
	CALL	KBDS
	POP	BC
	JR	NC,PAUS4
	CP	3	;BRK?
	RET	Z
	CP	0AH	;CUU?
	JR	NZ,PAUS4
	JP	0DDE4H	;Eingabe ASCII
PAUS4	DEC	C
	JR	NZ,PAUS3
	RET
 
BBEEP	;Signalton
	LD	B,1	;ohne Angabe 1x
	CALL	0C8BEH
	JR	Z,BBP1
	CALL	0D421H
	LD	B,A	;Anzahl
BBP1	LD	A,7	;Beep
	LD	E,0	;CRT
	CALL	0F015H	;PV5
	DJNZ	BBP1
	RET
 
WINDOW	;Fenster einstellen
	CALL	0C8BEH
	JR	Z,WINDOW1
	PUSH	HL
	CALL	0D421H
	EX	(SP),HL	    ;in
	LD	HL,WNDFN+90 ;Fenster 9
	CALL	IRMWR	    ;erstellen
	INC	HL
	EX	(SP),HL
	CALL	0C8D6H
	CALL	0D421H
	EX	(SP),HL
	CALL	IRMWR
	INC	HL
	EX	(SP),HL
	CALL	0C8D6H
	CALL	0D421H
	EX	(SP),HL
	CALL	IRMWR
	EX	(SP),HL
	CALL	0C8D6H
	CALL	0D421H
	EX	(SP),HL
	LD	D,A
	CALL	0F018H	;IRMON
	CP	28H
	JR	NC,WINERR
	LD	A,(WNDFN+92)
	LD	E,A
	CP	28H
	JR	NC,WINERR
	LD	A,D
	SUB	E
	JR	C,WINERR
	INC	A
	LD	(WINLG),A
	LD	A,E
	LD	(WINON),A
	LD	A,(WNDFN+91)
	CP	20H
	JR	NC,WINERR
	LD	D,A
	LD	A,(WNDFN+90)
	CP	20H
	JR	NC,WINERR
	LD	E,A
	LD	A,D
	SUB	E
	JR	C,WINERR
	INC	A
	LD	(WINLG+1),A
	LD	A,E
	LD	(WINON+1),A
	JR	WINDOW2
WINDOW1	PUSH	HL
	CALL	0F018H	;IRMON
	LD	HL,100H
	LD	(WINON),HL
	LD	HL,1E28H
	LD	(WINLG),HL
WINDOW2	LD	HL,0
	LD	(CURSO),HL
	CALL	0F01BH	;IRMOF
	POP	HL
	RET
WINERR	CALL	0F01BH	;IRMOF
	JR	SNERR2
 
BLOAD	;MC-Programm laden
	PUSH	HL
	LD	HL,ARGN
	XOR	A
	CALL	IRMWR	;ARGN=0
	POP	HL
	LD	E,10H	;LOAD
	JP	0F015H	;PV5
 
VPEEK	CALL	0CDE1H
	EX	(SP),HL
	LD	DE,0CDF3H ;RET-Adr.
	PUSH	DE
	CALL	0C96FH
	PUSH	HL
	LD	HL,8000H;IRM-Offset
	ADD	HL,DE
	JR	C,VPK	;Error
	LD	A,0BFH
	CP	H
VPK	JR	C,SNERR2
	CALL	IRMRD
	POP	HL
	JP	0D3E9H
 
SNERR2	JP	0C348H	;SN-ERROR
 
VPOKE	;in IRM schreiben
	CALL	0C96CH
	PUSH	DE
	CALL	0C8D6H
	CALL	0D421H
	EX	(SP),HL
	LD	DE,8000H;IRM-Offset
	ADD	HL,DE
	JR	C,VPK	;Error
	LD	D,A
	LD	A,0BFH
	CP	H
	JR	C,VPK	;nur bis BFFFH
	LD	A,D
	CALL	IRMWR	;schreiben
	POP	HL
	RET
 
BORDER	;schaltet RAM-8!
	CALL	0D421H
	RRCA
	RRCA
	RRCA
	AND	60H	;Auswahl
	LD	C,A
	LD	B,9FH	;Maske
	JP	TONB
 
PRAT	;PRINT AT
	LD	A,(3FDH)
	BIT	1,A
	SET	1,A
	LD	(3FDH),A
	JR	NZ,SNERR2
	PUSH	DE
	PUSH	HL
	CALL	0F018H	;IRMON
	LD	HL,WINON
	LD	(WNDFN+90),HL
	LD	DE,WNDFN+80
	LD	BC,6	;Fenster
	LDIR		;retten
	LD	HL,0	;Fenster gro~
	LD	(WINON),HL
	LD	HL,2028H
	LD	(WINLG),HL
	CALL	0F01BH	;IRMOF
	POP	HL
	CALL	LOCAT
	CALL	0C8DBH
	CALL	0C8CCH
	DB	';'
	LD	A,M
	CP	0DFH
	JR	C,PRAT2	;<DFH
	CP	0E3H
	JR	NC,PRAT2;>E2H
	CALL	PREX4	;INK,PAPER,COLOR
PRAT1	PUSH	HL
	CALL	0F018H	;IRMON
	LD	HL,WNDFN+80
	LD	DE,WINON
	LD	BC,6	;Fenster
	LDIR		;regenerieren
	CALL	0F01BH	;IRMOF
	POP	HL
	POP	DE
	POP	BC
	RET
PRAT2	CALL	0CB03H
	JR	PRAT1
 
SNERR3	JP	0C348H	;SN-ERROR
 
INK	CALL	0D421H
	CP	32
	JR	NC,SNERR3
	SLA	A
	SLA	A
	SLA	A
	LD	D,A
	PUSH	HL
	LD	HL,COLOR
	CALL	IRMRD
	POP	HL
	AND	7
	JR	COL2
 
PAPER	CALL	0D421H
COL1	CP	8
	JR	NC,SNERR3
	LD	D,A
	PUSH	HL
	LD	HL,COLOR
	CALL	IRMRD
	POP	HL
	AND	0F8H
COL2	OR	D
	PUSH	HL
	LD	HL,COLOR
	CALL	IRMWR	;neuer Farbwert
	POP	HL
	RET
 
BCOLOR	CALL	0C8BEH
	JR	Z,SNERR3
	CALL	INK	;Vordergrund
	CALL	0C8BEH
	RET	Z
	CALL	0C8D6H
	JR	PAPER	;Hintergrund
	RET
 
LOCAT	;Cursor positionieren
	CALL	0C8BDH
	CALL	0C8CCH
	DB	'('
LOCATE	CALL	0D421H
	LD	D,A
	PUSH	HL
	LD	HL,WINLG+1
	CALL	IRMRD
	POP	HL
	DEC	A
	CP	D
	JR	C,SNERR3
	CALL	0C8D6H
	PUSH	DE
	CALL	0D421H
	POP	DE
	LD	C,A
	PUSH	HL
	LD	HL,WINLG
	CALL	IRMRD
	POP	HL
	DEC	A
	CP	C
	JR	C,SNERR3
	LD	A,C
	PUSH	HL
	LD	HL,CURSO
	CALL	IRMWR
	LD	A,D
	INC	HL
LOC1	CALL	IRMWR
	POP	HL
	RET
 
INKEY	;Eingabe ein Zeichen
	PUSH	HL
	CALL	KBDS
	JR	NC,INKEY3
	LD	A,1
	CALL	0D17BH
	CALL	0DDE4H	;Eingabe ASCII
INKEY1	LD	HL,(3C2H)
	LD	M,A
INKEY2	JP	0D1A9H
INKEY3	XOR	A
	CALL	0D17BH
	JR	INKEY2
 
SOUND	;Tonausgabe
	CALL	0D421H
	PUSH	HL
	LD	HL,ARG1
	LD	B,4	;4 Argumente
SOUND1	CALL	IRMWR
	INC	HL
	EX	(SP),HL
	DEC	B
	JR	Z,SOUND2
	PUSH	BC
	CALL	0C8D6H
	CALL	0D421H
	POP	BC
	EX	(SP),HL
	JR	SOUND1
SOUND2	CALL	0C8BEH
	JR	Z,SOUND3
	CALL	0C8D6H
	CALL	0D421H
	EX	(SP),HL
	CALL	IRMWR
	INC	HL
	EX	(SP),HL
	CALL	0C8BEH
	JR	Z,SOUND3
	CALL	0C8D6H
	CALL	0D421H
	EX	(SP),HL
	CALL	IRMWR
	EX	(SP),HL
SOUND3	LD	E,35H	;TON
	POP	BC
	JP	0F015H	;PV5
 
PSET	;Punkt setzen
	LD	B,1	;setzen
POINT	PUSH	BC
	CALL	0C96CH
	PUSH	HL
	LD	A,E
	LD	HL,HOR
	CALL	IRMWR
	LD	A,D
	INC	HL
	CALL	IRMWR
	EX	(SP),HL
	CALL	0C8D6H
	CALL	0D421H
	EX	(SP),HL
	INC	HL
	CALL	IRMWR
	POP	HL
	CALL	GFARB
	LD	E,30H	;PUSE
	POP	BC
	DEC	B
	JR	Z,POINT2
	DEC	E	;PUDE
POINT2	CALL	0F015H	;PV1
	JP	C,SNERR2
	RET
 
PRESET	;Punkt l|schen
	LD	B,0	;l|schen
	JR	POINT
 
GFARB	CALL	0C8BEH
	RET	Z
	CALL	0C8D6H
	CALL	0D421H
	PUSH	HL
	LD	HL,FARB	;Grafik-Farbe
	RLA
	RLA
	RLA
	JP	LOC1	;in IRM schreib.
 
INSTR	;String1 in String2 suchen
	CALL	0CD36H	;Klammer auf?
	CALL	0C8D6H
	PUSH	HL
	CALL	0D330H
	JR	Z,INSTR4
	LD	B,A
	INC	HL
	INC	HL
	LD	E,M
	INC	HL
	LD	D,M
	POP	HL
	PUSH	DE
	PUSH	BC
	CALL	0CD3AH
	CALL	0C8DBH	;Klammer zu?
	POP	BC
	POP	DE
	PUSH	HL
	PUSH	DE
	PUSH	BC
	CALL	0D330H
	JR	Z,INSTR4
	INC	HL
	INC	HL
	LD	C,M
	INC	HL
	LD	H,M
	LD	L,C
	POP	BC
	LD	C,A
	POP	DE
	PUSH	HL
INSTR0	PUSH	BC
	PUSH	DE
	LD	A,(DE)
INSTR1	CP	M
	JR	Z,INSTR5
	INC	HL
	DEC	C
	JR	NZ,INSTR1
INSTR2	XOR	A
	POP	HL
	POP	HL
	POP	HL
INSTR3	LD	DE,0CDF3H ;RET-Adr.
	PUSH	DE
	JP	0D0C0H
INSTR4	JP	0C967H	;FC-ERROR
INSTR5	INC	HL
	PUSH	HL
	DEC	HL
INSTR6	INC	HL
	DEC	C
	JR	Z,INSTR7
	INC	DE
	DEC	B
	JR	Z,INSTR8
	LD	A,(DE)
	CP	M
	JR	Z,INSTR6
	POP	HL
	POP	DE
	POP	BC
	DEC	C
	JR	INSTR0
INSTR7	INC	DE
	DEC	B
	POP	HL
	JR	NZ,INSTR2
	JR	INSTR9
INSTR8	POP	HL
INSTR9	POP	DE
	POP	DE
	POP	DE
	AND	A
	SBC	HL,DE
	LD	A,L
	JR	INSTR3
 
IRMWR	LD	E,28H	;LDMA
	JR	JPV5
 
IRMRD	LD	E,29H	;LDAM
	JR	JPV5
 
BKEY	;F-Taste belegen
	CALL	0D421H
	AND	A
	JR	Z,SNERR4
	CP	0DH	;F1...F12
	JR	NC,SNERR4
	LD	E,39H	;KEY
JPV5	JP	0F015H	;PV5
 
KEYLIST	;F-Tasten auflisten
	LD	E,3AH	;KEYLI
	JR	JPV5
 
SWITCH	;Module schalten
	CALL	0D421H
	PUSH	AF
	CALL	0C8D6H
	CALL	0D421H
	LD	D,A	;Steuerbyte
	POP	AF
	PUSH	HL
	LD	L,A	;Steckplatz
	LD	A,2	;schalten
	LD	E,26H	;MODU
	CALL	0F015H	;PV5
	POP	HL
	RET
 
PTEST	CALL	0CDE1H
	EX	(SP),HL
	LD	DE,0CDF3H ;RET-Adr.
	PUSH	DE
	CALL	0C96FH
	PUSH	HL
	LD	A,E	;nur
	LD	HL,HOR	;X-Koordinate
	CALL	IRMWR	;eintragen
	LD	A,D
	INC	HL
	CALL	IRMWR
	LD	E,2FH	;PUDE
	CALL	0F015H	;PV5
	LD	B,0
	JR	Z,PTST1	;war gel|scht
	INC	HL
	INC	HL
	CALL	IRMWR
	LD	E,30H	;PUSE
	CALL	0F015H	;PV5
	LD	B,1
PTST1	LD	A,B	;R}ckgabewert
	POP	HL
	JP	0D3E9H
 
SNERR4	JP	0C348H	;SN-ERROR
 
CLOSE	;Kanal schlie~en
	LD	C,0
	LD	A,M
	CP	'I'	;Eingabe?
	JR	Z,CLOS1
	INC	C
	CP	'O'	;Ausgabe?
	JR	NZ,SNERR4
CLOS1	PUSH	BC
	INC	HL
	LD	A,M
	CP	'#'
CLOS2	JR	NZ,SNERR4
	INC	HL
	CALL	0D421H
	AND	3	;4 Ger{te
	POP	BC
	RET	Z	;Console
	PUSH	HL
	RLA		;*2
	ADD	C	;Ein-/Ausgabe
	PUSH	AF
	DEC	A
	LD	B,0
	SCF
CLOS3	RL	B	;Bit platzieren
	DEC	A
	JR	NZ,CLOS3
	LD	HL,307H ;E/A-Flag
	LD	A,M
	XOR	B	;negieren
	LD	M,A
	POP	AF
	POP	HL
	SET	6,A	;close
	PUSH	DE
	LD	E,A
	LD	D,3
	CALL	BASIO
	POP	DE
	RET
 
RANDOM	;Zufallsgenerator
	LD	A,R
	LD	(31DH),A
	RET
 
OPEN	;Kanal |ffnen
	LD	A,M
	INC	HL
	CP	'I'	;Eingabe?
	JR	Z,OPEN1
	CP	'O'	;Ausgabe?
	JR	NZ,CLOS2
	CALL	0DE25H
	CALL	0DDC8H
	RET	Z
	LD	A,0D5H
	CALL	0DCB2H
	LD	HL,3EAH	;Druckpuffer
	XOR	A
	CALL	0DDD5H
	POP	HL
	RET
OPEN1	CALL	0DE5FH	;Eingabe
	LD	A,(309H);IN-Index
	AND	3
	RET	Z
	LD	A,0D5H
	CALL	0DCB2H
	LD	HL,3EAH	;Druckuffer
	CALL	0DDE4H	;Eingabe ASCII
	POP	HL
	RET
 
BLINE	;Linie zeichnen
	LD	BC,43EH	;4 Par.,LINE
	JR	GRAPH
 
CIRCLE	;Kreis zeichnen
	LD	BC,33FH	;3 Par.,CIRCLE
GRAPH	PUSH	BC
	CALL	0C96CH
	POP	BC
	PUSH	BC
	PUSH	HL
	LD	HL,ARG1
GRAPH1	LD	A,E
	CALL	IRMWR
	INC	HL
	LD	A,D
	CALL	IRMWR
	INC	HL
	DEC	B
	JR	Z,GRAPH2
	EX	(SP),HL
	PUSH	BC
	CALL	0C8D6H
	CALL	0C96CH
	POP	BC
	EX	(SP),HL
	JR	GRAPH1
GRAPH2	POP	HL
	CALL	GFARB
	POP	DE
	JP	0F015H	;PV5
 
CSRLN	;akt. Zeile holen
	CALL	0CDE1H
	EX	(SP),HL
	LD	DE,0CDF3H ;RET-Adr.
	PUSH	DE
	CALL	0D424H
	PUSH	HL
	AND	A
	LD	A,0
	JR	NZ,CSRLN1
	LD	HL,WINON+1
	CALL	IRMRD
CSRLN1	LD	B,A
	LD	HL,CURSO+1
	CALL	IRMRD
	ADD	B	;akt. Zeile
	POP	HL
	JP	0D3E9H
 
VGET	;Zeichen von Bildschirm lesen
	EX	(SP),HL
	LD	A,1
	CALL	0D17BH
	CALL	0F018H	;IRMON
	LD	DE,(CURSO)
	CALL	DABR
	LD	A,M
	CALL	0F01BH	;IRMOF
	JP	INKEY1	;als Zeichen
			;zur}ckgeben
 
L3TB	;ESC-Tabelle
	DW	ESC0	;Tabulator
	DW	ESC1	;Anz0	Zugr0
	DW	ESC2	;1	1
	DW	ESC3	;0	1
	DW	ESC4	;1	0
	DW	ESC5	;MODUL
	DW	ESC6	;SYSTEM
	DW	ESC7	;PixInvers o/o
	DW	ESC8	;ColSwap o/o
	DW	ESC9	;Farbebene o/o
	DW	ESCA	;HiRes o/o
 
	DS	0FH	;frei
 
	END
А@Аt(Аp6АnTop of Text: End of Text: Start of MC: ASM-Offset : хЫ€ц$У€сЙхЫ€жЫУ€сЙНMА~#НDАфЙEDASНMА!"@"p$|ю	END
А@Аt(Аp6АnTop of Text: End of Text: Start of MC: ASM-Offset : хЫ€ц$У€сЙхЫ€жЫУ€сЙНMА~#НDАфЙEDASНMА!"@"p$|ю