 ORG 32768
 TP_INT: EQU 01H
 TP_STR: EQU 02H
 TP: EQU 021H
 TP_END: EQU 020H
 SEC: EQU 0FFF4H
 TICK: EQU 0FFF5H
 SCANEXPR: EQU 001DH
 OFFSET: EQU 0D0H
 XI_TAB: EQU $
 DEFW INTER
 DEFB OFFSET
 DEFB 27
 DEFW EXQLST
 DEFW TXTLST
 DEFW SYNTLST
 XF_TAB: DEFW 0
 DEFB OFFSET
 DEFB 38
 DEFW FEX_LST
 DEFW FTXT_LST
 DEFW FSYN_LST
 FEX_LST: EQU $
 DEFW E_GETIT
 DEFW E_PF1
 DEFW E_PF2
 DEFW E_PF3
 DEFW E_PF4
 DEFW E_PF5
 DEFW E_PF6
 DEFW E_PF7
 DEFW E_PF8
 DEFW E_S_PF1
 DEFW E_S_PF2
 DEFW E_S_PF3
 DEFW E_S_PF4
 DEFW E_S_PF5
 DEFW E_S_PF6
 DEFW E_S_PF7
 DEFW E_S_PF8
 DEFW E_C_PF1
 DEFW E_C_PF2
 DEFW E_C_PF3
 DEFW E_C_PF4
 DEFW E_C_PF5
 DEFW E_C_PF6
 DEFW E_C_PF7
 DEFW E_C_PF8
 DEFW E_S_C_PF1
 DEFW E_S_C_PF2
 DEFW E_S_C_PF3
 DEFW E_S_C_PF4
 DEFW E_S_C_PF5
 DEFW E_S_C_PF6
 DEFW E_S_C_PF7
 DEFW E_S_C_PF8
 DEFW E_KEY_NR
 DEFW E_TRUE
 DEFW E_FALSE
 DEFW E_MAX
 DEFW E_MIN
 FTXT_LST: EQU $
 DEFB 128
 DEFM "GETITEM"
 DEFB 129
 DEFM "PF1"
 DEFB 130
 DEFM "PF2"
 DEFB 131
 DEFM "PF3"
 DEFB 132
 DEFM "PF4"
 DEFB 133
 DEFM "PF5"
 DEFB 134
 DEFM "PF6"
 DEFB 135
 DEFM "PF7"
 DEFB 136
 DEFM "PF8"
 DEFB 137
 DEFM "S_PF1"
 DEFB 138
 DEFM "S_PF2"
 DEFB 139
 DEFM "S_PF3"
 DEFB 140
 DEFM "S_PF4"
 DEFB 141
 DEFM "S_PF5"
 DEFB 142
 DEFM "S_PF6"
 DEFB 143
 DEFM "S_PF7"
 DEFB 144
 DEFM "S_PF8"
 DEFB 145
 DEFM "C_PF1"
 DEFB 146
 DEFM "C_PF2"
 DEFB 147
 DEFM "C_PF3"
 DEFB 148
 DEFM "C_PF4"
 DEFB 149
 DEFM "C_PF5"
 DEFB 150
 DEFM "C_PF6"
 DEFB 151
 DEFM "C_PF7"
 DEFB 152
 DEFM "C_PF8"
 DEFB 153
 DEFM "S_C_PF1"
 DEFB 154
 DEFM "S_C_PF2"
 DEFB 155
 DEFM "S_C_PF3"
 DEFB 156
 DEFM "S_C_PF4"
 DEFB 157
 DEFM "S_C_PF5"
 DEFB 158
 DEFM "S_C_PF6"
 DEFB 159
 DEFM "S_C_PF7"
 DEFB 160
 DEFM "S_C_PF8"
 DEFB 161
 DEFM "KEY_NR"
 DEFB 162
 DEFM "TRUE"
 DEFB 163
 DEFM "FALSE"
 DEFB 164
 DEFM "MAX"
 DEFB 165
 DEFM "MIN"
 DEFB 255
 FSYN_LST: EQU $
 DEFB 128
 DEFB TP_STR
 DEFB TP_STR
 DEFB TP_INT+TP_END
 DEFB 129
 DEFB TP
 DEFB 130
 DEFB TP
 DEFB 131
 DEFB TP
 DEFB 132
 DEFB TP
 DEFB 133
 DEFB TP
 DEFB 134
 DEFB TP
 DEFB 135
 DEFB TP
 DEFB 136
 DEFB TP
 DEFB 137
 DEFB TP
 DEFB 138
 DEFB TP
 DEFB 139
 DEFB TP
 DEFB 140
 DEFB TP
 DEFB 141
 DEFB TP
 DEFB 142
 DEFB TP
 DEFB 143
 DEFB TP
 DEFB 144
 DEFB TP
 DEFB 145
 DEFB TP
 DEFB 146
 DEFB TP
 DEFB 147
 DEFB TP
 DEFB 148
 DEFB TP
 DEFB 149
 DEFB TP
 DEFB 150
 DEFB TP
 DEFB 151
 DEFB TP
 DEFB 152
 DEFB TP
 DEFB 153
 DEFB TP
 DEFB 154
 DEFB TP
 DEFB 155
 DEFB TP
 DEFB 156
 DEFB TP
 DEFB 157
 DEFB TP
 DEFB 158
 DEFB TP
 DEFB 159
 DEFB TP
 DEFB 160
 DEFB TP
 DEFB 161
 DEFB TP
 DEFB 162
 DEFB TP
 DEFB 163
 DEFB TP
 DEFB 164
 DEFB TP_INT
 DEFB TP_INT
 DEFB TP_INT+TP_END
 DEFB 165
 DEFB TP_INT
 DEFB TP_INT
 DEFB TP_INT+TP_END
 DEFB 255
 EXQLST: EQU $
 DEFW E_PROC
 DEFW E_WAIT
 DEFW E_CLS
 DEFW E_HOME
 DEFW E_UP
 DEFW E_DOWN
 DEFW E_LEFT
 DEFW E_RIGHT
 DEFW E_HRCLR
 DEFW E_ERROR
 DEFW E_EXIT
 DEFW E_COL
 DEFW E_LINE
 DEFW E_RESET
 DEFW E_DESTROY
 DEFW E_CLICK
 DEFW E_NOCLICK
 DEFW E_CTRLC
 DEFW E_NOCTRLC
 DEFW E_PROC
 DEFW E_INIT
 DEFW E_ZERO
 DEFW E_DI
 DEFW E_EI
 DEFW E_CLKOFF
 DEFW E_CLKON
 DEFW E_HALT
 EXQEND: EQU $
 TXTLST: EQU $
 DEFB 080H
 DEFM "PROCEDURE"
 DEFB 081H
 DEFM "WAIT"
 DEFB 082H
 DEFM "CLS"
 DEFB 083H
 DEFM "HOME"
 DEFB 084H
 DEFM "UP"
 DEFB 085H
 DEFM "DOWN"
 DEFB 086H
 DEFM "LEFT"
 DEFB 087H
 DEFM "RIGHT"
 DEFB 088H
 DEFM "HRCLR"
 DEFB 089H
 DEFM "ERROR"
 DEFB 08AH
 DEFM "EXIT"
 DEFB 08BH
 DEFM "COL"
 DEFB 08CH
 DEFM "LINE"
 DEFB 08DH
 DEFM "RESET"
 DEFB 08EH
 DEFM "DESTROY"
 DEFB 08FH
 DEFM "CLICK"
 DEFB 090H
 DEFM "NO CLICK"
 DEFB 091H
 DEFM "CTRLC"
 DEFB 092H
 DEFM "NO CTRLC"
 DEFB 093H
 DEFM "DO"
 DEFB 094H
 DEFM "INIT"
 DEFB 095H
 DEFM "ZERO"
 DEFB 096H
 DEFM "DI"
 DEFB 097H
 DEFM "EI"
 DEFB 098H
 DEFM "CLOCK OFF"
 DEFB 099H
 DEFM "CLOCK ON"
 DEFB 09AH
 DEFM "HALT"
 DEFB 0FFH
 SYNTLST: EQU $
 DEFW S_PROC
 DEFW S_WAIT
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW YES
 DEFW NO
 DEFW YES
 DEFW YES
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW YES
 DEFW S_INIT
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 DEFW NO
 S_WAIT: EQU $
 S_PROC: EQU $
 YES: EQU $
 LD B,1
 JP SCANEXPR
 E_PROC: EQU $
 RST 020H
 RET
 E_WAIT: EQU $
 RST 020H
 XOR A
 LD (TICK),A
 LD A,(SEC)
 LD C,A
 WAIT: EQU $
 LD A,H
 OR L
 RET Z
 LD A,(SEC)
 CP C
 JR Z,WAIT
 LD C,A
 DEC HL
 JR WAIT
 E_GETIT: EQU $
 POP HL
 LD IX,0
 ADD IX,SP
 PUSH DE
 EX DE,HL
 CALL GETSLEN
 LD HL,3
 XOR A
 SBC HL,BC
 JR NC,BLNK
 CALL GETSADR
 LD A,(HL)
 INC HL
 LD H,(HL)
 LD L,A
 XOR A
 SBC HL,DE
 JR C,BLNK
 CALL GETSADR
 INC HL
 INC HL
 GETIT_L: EQU $
 DEC DE
 LD A,E
 OR D
 LD C,(HL)
 LD B,0
 INC HL
 JR Z,FND_ITEM
 ADD HL,BC
 JR GETIT_L
 FND_ITEM: EQU $
 CALL PUTSADR
 CALL PUTSLEN
 JR STRRET
 BLNK: EQU $
 LD BC,0
 CALL PUTSLEN
 STRRET: EQU $
 POP DE
 RST 028H
 GETSLEN: EQU $
 LD C,(IX+4)
 LD B,(IX+5)
 RET
 GETSADR: EQU $
 LD L,(IX+2)
 LD H,(IX+3)
 RET
 PUTSLEN: EQU $
 LD (IX+4),C
 LD (IX+5),B
 RET
 PUTSADR: EQU $
 LD (IX+2),L
 LD (IX+3),H
 RET
 E_CLS: XOR A
 LD (31744),A
 LD HL,31744
 PUSH DE
 LD DE,31745
 LD BC,1023
 LDIR
 POP DE
 E_HOME: XOR A
 LD (65362),A
 LD (65363),A
 RET
 E_UP: LD HL,65363
 DEC (HL)
 JR CHECK2
 E_DOWN: LD HL,65363
 INC (HL)
 JR CHECK2
 E_LEFT: LD HL,65362
 DEC (HL)
 JR CHECK
 E_RIGHT: LD HL,65362
 INC (HL)
 CHECK: LD A,39
 IN2: CP (HL)
 JR NC,STOP
 LD (HL),A
 STOP: RET
 CHECK2: LD A,23
 JR IN2
 E_HRCLR: PUSH DE
 LD BC,1
 LD HL,NUL
 LD DE,0
 CALL 32765
 LD HL,0
 LD BC,16*1024
 CALL 32765
 POP DE
 RET
 NUL: EQU $
 DEFB 0
 PARAM: EQU $
 DEFB 0
 E_ERROR: RST 020H
 LD A,L
 JP 18
 E_EXIT: LD HL,(XI_TAB)
 LD (65405),HL
 LD HL,(XF_TAB)
 LD (65407),HL
 LD HL,877
 LD (65460),HL
 RET
 E_COL: RST 020H
 LD A,L
 LD HL,65362
 LD (HL),A
 JR CHECK
 E_LINE: RST 020H
 LD A,L
 LD HL,65363
 LD (HL),A
 JR CHECK2
 E_RESET: RST 0
 E_DESTROY: LD A,R
 LD (65535),A
 LD DE,65534
 LD HL,65535
 LDDR
 NO: RET
 E_CLICK: LD HL,65502
 SET 1,(HL)
 RET
 E_NOCLICK: LD HL,65502
 RES 1,(HL)
 RET
 E_CTRLC: LD HL,65502
 RES 0,(HL)
 RET
 E_NOCTRLC: LD HL,65502
 SET 0,(HL)
 RET
 E_PF1: LD L,192
 JR RETURN
 E_PF2: LD L,193
 JR RETURN
 E_PF3: LD L,194
 JR RETURN
 E_PF4: LD L,195
 JR RETURN
 E_PF5: LD L,196
 JR RETURN
 E_PF6: LD L,197
 JR RETURN
 E_PF7: LD L,198
 JR RETURN
 E_PF8: LD L,199
 JR RETURN
 E_S_PF1: LD L,208
 JR RETURN
 E_S_PF2: LD L,209
 JR RETURN
 E_S_PF3: LD L,210
 JR RETURN
 E_S_PF4: LD L,211
 JR RETURN
 E_S_PF5: LD L,212
 JR RETURN
 E_S_PF6: LD L,213
 JR RETURN
 E_S_PF7: LD L,214
 JR RETURN
 E_S_PF8: LD L,215
 JR RETURN
 E_C_PF1: LD L,224
 JR RETURN
 E_C_PF2: LD L,225
 JR RETURN
 E_C_PF3: LD L,226
 JR RETURN
 E_C_PF4: LD L,227
 JR RETURN
 E_C_PF5: LD L,228
 JR RETURN
 E_C_PF6: LD L,229
 JR RETURN
 E_C_PF7: LD L,230
 JR RETURN
 E_C_PF8: LD L,231
 RETURN: LD H,0
 PUSH HL
 RST 40
 E_S_C_PF1: LD L,240
 JR RETURN
 E_S_C_PF2: LD L,241
 JR RETURN
 E_S_C_PF3: LD L,242
 JR RETURN
 E_S_C_PF4: LD L,243
 JR RETURN
 E_S_C_PF5: LD L,244
 JR RETURN
 E_S_C_PF6: LD L,245
 JR RETURN
 E_S_C_PF7: LD L,246
 JR RETURN
 E_S_C_PF8: LD L,247
 JR RETURN
 E_KEY_NR: LD A,(65506)
 AND A
 JR Z,E_KEY_NR
 LD A,(65507)
 LD L,A
 XOR A
 LD (65506),A
 JR RETURN
 S_INIT: EQU $
 CALL TAL
 RET C
 LD A,227
 SCF
 RET NZ
 LDI
 DEC HL
 RST 24
 TAL: LD B,1
 CALL 29
 RET C
 LD A,(HL)
 XOR 44
 RET
 E_INIT: EQU $
 RST 32
 INC DE
 LD A,L
 AND 3
 LD C,A
 XOR A
 LD B,4
 PARAMETER: SLA A
 SLA A
 OR C
 DJNZ PARAMETER
 PUSH DE
 LD HL,PARAM
 LD (HL),A
 LD BC,1
 LD DE,0
 CALL 32765
 LD HL,0
 LD BC,15357
 CALL 32765
 POP DE
 RST 32
 LD A,L
 OUT (7),A
 RET
 E_TRUE: LD HL,0FFFFH
 PUSH HL
 RST 40
 E_FALSE: LD HL,0
 PUSH HL
 RST 40
 E_ZERO: CALL 68
 INC HL
 INC HL
 XOR A
 LD (HL),A
 INC HL
 LD (HL),A
 RET
 E_MAX: POP HL
 POP BC
 PUSH HL
 SBC HL,BC
 CALL ACARRY
 JR C,RETBC
 RST 40
 E_MIN: POP HL
 POP BC
 PUSH HL
 SBC HL,BC
 CALL ACARRY
 JR NC,RETBC
 RST 40
 RETBC: POP HL
 PUSH BC
 RST 40
 ACARRY: POP IX
 POP HL
 PUSH HL
 BIT 7,H
 CALL NZ,CCARRY
 BIT 7,B
 CALL NZ,CCARRY
 JP (IX)
 CCARRY: CCF
 RET
 E_DI: DI
 RET
 E_EI: EI
 RET
 E_CLKOFF: LD HL,65521
 LD A,(HL)
 LD (DSAVE),A
 XOR A
 LD (HL),A
 RET
 E_CLKON: LD HL,65521
 LD A,(HL)
 CP 0
 RET NZ
 LD A,(DSAVE)
 CP 0
 JR NZ,NO_INC
 INC A
 NO_INC: LD (HL),A
 RET
 DSAVE: DEFB 1
 E_HALT: HALT
 RET
 INTER: PUSH AF
 PUSH HL
 IN A,(34)
 LD HL,65315
 CP 20
 JR NZ,ZX
 SET 1,(HL)
 ZX: CP 14
 JR NZ,XZ
 RES 1,(HL)
 XZ: PUSH AF
 LD HL,65502
 BIT 1,(HL)
 JR Z,NO_CLICK
 IN A,(5)
 NO_CLICK: POP AF
 LD (65507),A
 BIT 0,(HL)
 JR NZ,NO_CC
 CP 3
 JR NZ,NO_CC
 LD HL,(65413)
 LD A,L
 OR H
 JR Z,NO_CC
 SET 0,(HL)
 NO_CC: LD A,128
 LD (65506),A
 POP HL
 POP AF
 EI
 RETI
