FUZER           EQU     01AH
KARLAP          EQU     066H
KEYCSAT         EQU     069H
SPECIAL         EQU     00BH
SZET            MACRO   VSZAM,ERTEK
                LD      B,1
                LD      C,VSZAM
                LD      D,ERTEK
                EXOS    010H
                ENDM
OPEN            MACRO   CSAT,STRING
                LD      A,CSAT
                LD      DE,STRING
                EXOS    1
                ENDM
GETCHAR         MACRO   CSAT
                LD      A,CSAT
                EXOS    5
                ENDM
BLKOUT          MACRO   CSAT,PUFF,HOSSZ
                LD      A,CSAT
                LD      DE,PUFF
                LD      BC,HOSSZ
                EXOS    8
                ENDM
L000C           EQU     0000CH
L0015           EQU     00015H
L0017           EQU     00017H
L0023           EQU     00023H
L002F           EQU     0002FH
L0038           EQU     00038H
L0056           EQU     00056H
L005A           EQU     0005AH
L0079           EQU     00079H
L0138           EQU     00138H
                LD      SP,UJSTACK
                EI
                JR      KEZD
IRQ             BIT     5,D
                RET     Z
                LD      A,000H
                LD      (L0056),A
                LD      A,0C9H
                LD      (L0038),A
                CALL    CSIKOK
                LD      A,0F5H
                LD      (L0038),A
                LD      A,0B7H
                LD      (L0056),A
                RET
KEZD            SZET    016H,0
                SZET    017H,0
                SZET    018H,026H
                SZET    019H,082H
                SZET    04FH,0B9H
                OPEN    KARLAP,VIDEO
                SZET    016H,1
                SZET    017H,2
                SZET    018H,02AH
                SZET    019H,3
                OPEN    1,VIDEO
                OPEN    KEYCSAT,KEYBOARD
                SZET    6,0
                SZET    10,2
                SZET    11,10
                SZET    01AH,0
                SZET    4,KARLAP
                LD      A,001H
                LD      B,001H
                LD      C,001H
                LD      D,003H
                LD      E,001H
                EXOS    SPECIAL
                LD      A,0FFH
                OUT     (0B2H),A
                LD      HL,LB900
                LD      DE,L0015
                ADD     HL,DE
                CALL    L02BA
                CALL    CSIKOK
                LD      DE,(L02D7)
                LD      HL,L0493
                LD      B,01BH
LLL1            PUSH    BC
                LD      A,(HL)
                LD      B,054H
LLL2            LD      (DE),A
                INC     DE
                DJNZ    LLL2
                POP     BC
                INC     HL
                DJNZ    LLL1
                BLKOUT  1,L0436,L005A
                LD      HL,L04AE
                LD      DE,LBEBD
                LD      BC,L0023
                LDIR
L01ED           BLKOUT  KARLAP,L0490,3
                LD      A,KARLAP
                LD      B,001H
                LD      C,001H
                LD      D,018H
                LD      E,004H
                EXOS    SPECIAL
                LD      B,001H
                SZET    020H,014H
                CALL    IRQKI
                LD      DE,DIR
                EXOS    FUZER
                CALL    IRQBE
                BLKOUT  KARLAP,L02D3,2
                GETCHAR KARLAP
                LD      A,B
                CP      026H
                JR      NC,L022B
                LD      A,026H
L022B           LD      B,025H
                SUB     B
                LD      (L02D5),A
                GETCHAR 1
                CALL    L02AB
                CALL    L0290
KEYCIK          EI
                GETCHAR KEYCSAT
                EI
                LD      A,B
                CP      00DH
                JP      Z,STARTOL
                CP      020H
                JP      Z,STARTOL
                CP      0B0H
                JR      Z,L0267
                CP      0B4H
                JR      Z,L027A
                CP      0B1H
                JR      Z,JOYUP
                CP      0B5H
                JR      Z,JOYDOWN
                CP      01BH
                JP      Z,ESCAPE
                CP      064H
                JR      Z,L01ED
                JR      KEYCIK
L0267           CALL    L026C
                JR      KEYCIK
L026C           LD      A,(L02D6)
                CP      002H
                RET     C
                DEC     A
L0273           CALL    L029C
                CALL    L02AB
                RET
L027A           CALL    L027F
                JR      KEYCIK
L027F           LD      A,(L02D5)
                LD      B,A
                LD      A,(L02D6)
                CP      B
                RET     NC
                INC     A
                JR      L0273
JOYUP           CALL    L0290
                JR      KEYCIK
L0290           LD      A,001H
                JR      L0273
JOYDOWN         LD      A,(L02D5)
                CALL    L0273
                JR      KEYCIK
L029C           LD      (L02D6),A
                LD      B,001H
                LD      C,A
                LD      A,KARLAP
                LD      D,018H
                LD      E,004H
                EXOS    SPECIAL
                RET
L02AB           LD      HL,LB900
                LD      DE,L0079
                ADD     HL,DE
                LD      (HL),00CH
                DEC     HL
                LD      (HL),0F6H
                DEC     HL
                DEC     HL
                DEC     HL
L02BA           LD      A,(HL)
                DEC     HL
                PUSH    AF
                RLCA
                RLCA
                OR      0FCH
                OUT     (0B1H),A
                POP     AF
                AND     03FH
                OR      040H
                LD      (L02D8),A
                LD      A,(HL)
                LD      (L02D7),A
                LD      HL,(L02D7)
                RET
L02D3           DEFB    01BH,03FH
L02D5           DEFB    000H
L02D6           DEFB    000H
L02D7           DEFB    000H
L02D8           DEFB    000H
CSIKOK          BLKOUT  1,CSPUFFER,10
                LD      A,(L0339)
                LD      HL,L0338
                LD      DE,L0339
                LD      BC,L0017
                LDDR
                LD      (L0322),A
                LD      DE,L0138
                XOR     A
                LD      HL,(L035A)
                INC     HL
                LD      (L035A),HL
                SBC     HL,DE
                RET     NZ
                LD      HL,0
                LD      (L035A),HL
                LD      B,010H
L030A           PUSH    BC
                LD      A,(L0359)
                LD      HL,L0358
                LD      DE,L0359
                LD      BC,L002F
                LDDR
                LD      (L032A),A
                POP     BC
                DJNZ    L030A
                RET
CSPUFFER        DEFB    01BH,043H
L0322           DEFS    8
L032A           DEFB    028H,068H,0A1H
                DEFB    071H,0B9H,06BH
                DEFB    0EBH,0FBH,0FBH
                DEFB    0EBH,06BH,0B9H
                DEFB    071H,0A1H
L0338           DEFB    068H
L0339           DEFB    028H,010H,090H
                DEFB    002H,082H,012H
                DEFB    05AH,013H,053H
                DEFB    053H,013H,05AH
                DEFB    012H,082H,002H
                DEFB    090H,010H,004H
                DEFB    014H,094H,006H
                DEFB    0A6H,0FEH,0B7H
                DEFB    0F7H,0F7H,0B7H
                DEFB    0FEH,0A6H,006H
                DEFB    094H
L0358           DEFB    014H
L0359           DEFB    004H
L035A           DEFB    000H,000H
IRQBE           LD      HL,IRQ
                JR      IRQKAP
IRQKI           LD      HL,0
IRQKAP          DI
                LD      (0BFEDH),HL
                EI
                RET
STARTOL         LD      HL,(L02D7)
                LD      DE,MPUFF
                LD      BC,12
                LDIR
ESCAPE          XOR     A
                LD      B,12
                LD      HL,L040D
                LD      DE,L041D
TOROL           LD      (HL),A
                LD      (DE),A
                INC     HL
                INC     DE
                DJNZ    TOROL
                LD      HL,MPUFF
                LD      DE,L040D
                LD      B,009H
ELLEN           LD      A,(HL)
                CP      020H
                JR      Z,SZVEGE
                LD      (DE),A
                INC     HL
                INC     DE
                DJNZ    ELLEN
SZVEGE          LD      A,(L0404)
                CP      020H
                JR      Z,NEMKIT
                LD      A,"."
                LD      (DE),A
                INC     DE
                LD (LOADER+1),DE
                LD      HL,L0404
                LD      BC,3
                LDIR
NEMKIT          LD      HL,L040D
                LD      DE,L041D
                LD      BC,12
                LDIR
                CALL    IRQKI
                CALL LOADER
                LD      DE,LOAD
                EXOS    FUZER
                LD      DE,CHDIR
                EXOS    FUZER
                AND     A
                JP      Z,L01ED
                LD      DE,BRD
                EXOS    FUZER
BASICBA         LD      DE,BASIC
                EXOS    FUZER
                LD      DE,WP
                EXOS    FUZER
LOADER          LD HL,0
                LD A,(HL)
                CP "T"
                RET NZ
                INC HL
                LD A,(HL)
                CP "O"
                RET NZ
                INC HL
                LD A,(HL)
                CP "M"
                RET NZ
                LD BC,0C00H
                LD DE,FILENAME
                PUSH DE
                LD HL,L040D
LOAD0           INC DE
                LD A,(HL)
                AND A
                JR Z,LOAD1
                LD (DE),A
                INC HL
                INC C
                DJNZ LOAD0
LOAD1           POP DE
                LD A,C
                LD (DE),A
                PUSH DE
                LD C,10H
                EXOS 0
                LD A,-1
                OUT (0B2H),A
                LD DE,DTL
                LD A,1
                EXOS 1
                LD A,1
                LD DE,FEJPUFF
                PUSH DE
                EXOS 29D
                EXOS 22D
                POP IX
                LD L,(IX+2)
                LD H,(IX+3)
                AND A
                EX DE,HL
                SBC HL,DE
                DEC H
                JP M BASICBA
                SET 7,H
                PUSH HL
                EX DE,HL
                LD A,1
                EXOS 30D
                LD A,1
                EXOS 3
                LD A,0FBH
                OUT (0B3H),A
                DEC A
                OUT (0B2H),A
                LD A,0FDH
                OUT (0B1H),A
                LD HL,TOMO
                LD DE,60H
                LD BC,60H
                LDIR
                POP HL
                POP DE
                LD (DTLCIM),HL
                LD A,1
                EXOS 1
                LD A,0C3H
                LD HL,DTROB
                LD (28H),A
                LD (29H),HL
                LD SP,100H
                LD DE,100H
                JP 60H
FEJPUFF         DEFS 16D
DTL             DEFB 3,"DTL"
FILENAME        DEFS 13
EDITOR          DEFB    007H
                DEFM    "EDITOR"
VIDEO           DEFB    6
                DEFM    "VIDEO:"
KEYBOARD        DEFB    9
                DEFM    "KEYBOARD:"
DIR             DEFB    003H
                DEFM    "DIR"
MPUFF           DEFS    9
L0404           DEFS    3
LOAD            DEFB    17
                DEFM    "LOAD "
L040D           DEFS    12
CHDIR           DEFB    15
                DEFM    "CD "
L041D           DEFS    12
BRD             DEFB    3
                DEFM    "BRD"
BASIC           DEFB    5
                DEFM    "BASIC"
WP              DEFB    2
                DEFM    "WP"
L0436           DEFB    01BH,049H,008H
                DEFB    01BH,041H,0D0H
                DEFB    000H,04CH,000H
                DEFB    01BH,073H,01BH
                DEFB    049H,008H
                DEFB    "FILE.TOM TOLTO"
                DEFB    01BH,049H
                DEFB    008H,01BH,041H
                DEFB    0D8H,000H,050H
                DEFB    000H,01BH,049H
                DEFB    00AH,050H,01BH
                DEFB    049H,00BH,052H
                DEFB    01BH,049H,00CH
                DEFB    04FH,01BH,049H
                DEFB    00DH,047H,01BH
                DEFB    049H,00EH,052H
                DEFB    01BH,049H,00FH
                DEFB    041H,01BH,049H
                DEFB    009H,04DH,020H
                DEFB    01BH,049H,00AH
                DEFB    04CH,01BH,049H
                DEFB    00BH,04FH,01BH
                DEFB    049H,00CH,041H
                DEFB    01BH,049H,00DH
                DEFB    044H,01BH,049H
                DEFB    00EH,045H,01BH
                DEFB    049H,00FH,052H
L0490           DEFB    01AH,01BH,06FH
L0493           DEFB    000H,000H,0C0H
                DEFB    0C0H,00CH,00CH
                DEFB    0CCH,0CCH,030H
                DEFB    030H,0F0H,0F0H
                DEFB    03CH,0FCH,03CH
                DEFB    0F0H,0F0H,030H
                DEFB    030H,0CCH,0CCH
                DEFB    00CH,00CH,0C0H
                DEFB    0C0H,000H,000H
L04AE           DEFB    03CH,045H,053H
                DEFB    043H,03EH,02DH
                DEFB    051H,055H,049H
                DEFB    054H,020H,020H
                DEFB    03CH,044H,03EH
                DEFB    02DH,044H,049H
                DEFB    052H,020H,020H
                DEFB    020H,020H,020H
                DEFB    020H,020H,080H
                DEFB    020H,0B1H,0B9H
                DEFB    0B9H,0B1H,020H
                DEFB    0D0H,0C7H
TOMO EQU $
                .PHASE 60H
                CALL BYTEROB
                JP 100H
BYTEROB         JP BROBB
SZEGTAR         EQU 20H
DTROB           LD HL,SZEGTAR
                DI
                LD BC,4AFH
DTROB1          INC C
                INI
                JR NZ DTROB1
                LD A,-1
                OUT (0B2H),A
DTLCIM          EQU $+1
                CALL 0
                LD A,(SZEGTAR+2)
                OUT (0B2H),A
                RET
BROBB   push de ;celcim
                LD A,1
                EXOS 5
                LD L,B
                LD A,1
                EXOS 5
                LD C,L
                POP DE
                PUSH BC
                PUSH DE
        ld hl,0
        and a
        sbc hl,bc
        ex de,hl
        push de
        ld a,1
        exos 6
        pop hl
        ld a,(hl)
        inc hl    ;forras
        EX AF,AF'
 ;      ld hl,forras
        pop de
 ;      ld de,cel
        pop bc
        dec bc
 ;      ld bc,hossz
cik     EX AF,AF'
        cp (hl)
        jr nz,sima
                EX AF,AF'
        inc hl
        push bc
        ld b,(hl)
        inc hl
        ld a,(hl)
rak     ld (de),a
        inc de
        djnz rak
        pop bc
        dec bc
        dec bc
        jr tov
SIMA    EX AF,AF'
        ld a,(hl)
        ld (de),a
        inc de
tov     inc hl
        dec bc
        ld a,b
        or c
        jr nz,cik
TOMOVEG RET
        .DEPHASE
VEGE            NOP
UJSTACK         EQU     $+40
LB900           EQU     0B900H
LBEBD           EQU     0BEBDH
LBFED           EQU     0BFEDH
