MON EQU 0
FCBLOKK EQU #66
CELFCB EQU #97
UTVONAL EQU #96
SPECIAL EQU #0B
KEYCSAT EQU #69
DEFCHAN EQU 4
FONTCSAT EQU 2
PANCSAT EQU 3
EKEPCSAT EQU 4
EDITCSAT EQU 5
ESC EQU #1B
^Z EQU #1A
EOF EQU #E4
FLAGEDIT EQU 32
SZERKESZ EQU #14
FISH EQU #C010
EXOS MACRO @P1
 RST 30H
 DEFB @P1
 ENDM
KARKI MACRO @CSAT,@CHAR
 LD A,@CSAT
 LD B,@CHAR
 EXOS 7
 ENDM
KARBE MACRO @CSAT
 LD A,@CSAT
 EXOS 5
 ENDM
OPEN MACRO @CSAT,@NEV
 LD A,@CSAT
 LD DE,@NEV
 EXOS 1
 ENDM
SZET MACRO @VALT,@ERTEK
 LD B,1
 LD C,@VALT
 LD D,@ERTEK
 EXOS #10
 ENDM
BLOUT MACRO @CSAT,@PUFF,@HOSSZ
 LD A,@CSAT            
 LD DE,@PUFF
 LD BC,@HOSSZ
 EXOS 8
 ENDM
TAPOGAT MACRO @STRING
 LD DE,@STRING
 EXOS #1A
 ENDM
 ORG #100
 ENT $
 LD SP,MYSTACK
 EI
 LD C,0FEH
 EXOS 25
 OPEN KEYCSAT,KEYBOARD
 SZET 10,2
 SZET 11,20
 LD HL,FONTKEP
 CALL MEGNYIT
 LD HL,EDITKEP
 CALL MEGNYIT
 LD BC,31DH
 LD HL,EDITADAT
 CALL NYITCIK
 OPEN EDITCSAT,EDITOR
 LD HL,PANEL
 CALL MEGNYIT
 BLOUT,PANCSAT,PANCOLS,10
 LD A,PANCSAT
 LD B,4
 EXOS SPECIAL
 LD IY,KURZOR
 LD A,-1
 OUT (0B3H),A
 DEC A
 OUT (#B2),A
 DEC A
 OUT (#B1),A
 LD A,PANCSAT
 LD B,3
 EXOS SPECIAL
 LD (PANCIM),DE
 LD A,EKEPCSAT
 LD BC,101H
 LD DE,#517
 EXOS SPECIAL
 SZET FLAGEDIT,SZERKESZT
 SZET DEFCHAN,EDITCSAT
 CALL PANELBE
DIREL CALL KERET
 CALL FISHDIR
 LD IY,KURZOR
 LD A,1
 LD (IY),A
 LD (IY+1),A
 DEC A
 LD (IY+3),A
 CALL BERAK
 CALL VILAGIT
JOYCIK LD L,0
 LD BC,#902
KEMPC PUSH BC
 LD A,KEYCSAT
 EXOS SPECIAL
 LD A,L
 OR C
 LD L,A
 POP BC
 DEC C
 JP P,KEMPC
 HALT
 HALT
 HALT
 HALT
 HALT
 LD B,5
 LD HL,JOYTAB
JOY1 RRA
 JR NC,JOY2
 LD A,(HL)
 INC HL
 LD H,(HL)
 LD L,A
 CALL JUMP
 JR JOYCIK
JOY2 INC HL
 INC HL
 DJNZ JOY1
 LD A,KEYCSAT
 EXOS 9
 LD A,C
 AND A
 JR NZ,JOYCIK
 KARBE KEYCSAT
 LD A,B
 LD HL,KEYTAB
 LD DE,JUMPTAB
 LD B,KEYTABH
KEYCIK CP (HL)
 JR Z,UGRIK
 INC HL
 INC DE
 INC DE
 DJNZ KEYCIK
 JR JOYCIK
UGRIK EX DE,HL
 LD E,(HL)
 INC HL
 LD D,(HL)
 EX DE,HL
JUMP JP (HL)
INS CALL KIJELOL
 CALL DOWN
 JP JOYCIK
GYOK TAPOGAT GYOKER
 CALL FATHIBA
 JP DIREL
HIDDV LD A,(HIDDEN+1)
 XOR 2
 LD (HIDDEN+1),A
 JP DIREL
FCBINI LD HL,FCBLOKK
 LD (HL),-1
 INC HL
 LD B,7
 CALL FCBINI1
 LD B,12
 LD A,"?"
 CALL FCBINI2
 LD B,29
FCBINI1 XOR A
FCBINI2 LD (HL),A
 INC HL
 DJNZ FCBINI2
 RET
FISHIBA PUSH AF
 LD A,-1
 OUT (#B3),A
 DEC A
 OUT (#B2),A
 POP AF
 JP FATHIBA
FISHDIR TAPOGAT FISHVEREM
 LD A,-1
 OUT (#B2),A
 PUSH DE
 POP IY
 LD A,(IY-#5E)
 OUT (#B3),A
 CALL FCBINI
 LD A,4
 LD HL,UTVONAL
 LD DE,FCBLOKK
 LD BC,CELFCB
 CALL FISH
 JP NZ,FISHIBA
 EXX
 LD DE,DIRCIM
 XOR A
 LD (TETELSZ),A
 EXX
 CALL MASOL
FISH1 LD A,5
 CALL FISH
 JR NZ,FISH2
 CALL MASOL
 JR FISH1
FISH2 LD IY,KURZOR
 LD A,(IY+2)
 AND A
 LD A,#CF
 JP Z,FISHIBA
 LD A,-1
 OUT (#B3),A
 DEC A
 OUT (#B2),A
 RET
MASOL LD A,(CELFCB+#13)
HIDDEN AND #E
 RET NZ
 EXX
 LD HL,CELFCB+8
 LD BC,8
 LDIR
 LD A," "
 LD (DE),A
 INC DE
 LD C,5
 LDIR
 LD C,15
 ADD HL,BC
 LDI
 LDI
 LDI
 LD A,(TETELSZ)
 INC A
 LD (TETELSZ),A
 EXX
 RET
UNPACK
*INCLUDE UPACK.GEN
ESCAPE IF MON=1
 CALL 18H
 ELSE
 JP SYSTEM
 ENDC
TUZEL POP HL
 CALL BETOLT
 CALL FATHIBA
 JP DIREL
BASICBA EQU ESCAPE
RIGHT LD A,(IY)
 CP 37
 RET NC
 CP (IY+2)
 RET Z
 ADD A,18
 PUSH AF
 CALL VILAGIT
 POP AF
 CP (IY+2)
 JR C,RIGHT1
 LD A,(IY+2)
RIGHT1 LD (IY),A
 JR NC,LEFT1
 LD A,18
 ADD A,(IY+1)
 JR LEFT1
LEFT LD A,(IY)
 CP 1
 RET Z
 SUB 18
 RET Z
 PUSH AF
 CALL VILAGIT
 POP AF
 JR NC,LEFT11
 LD A,1
LEFT11 LD (IY),A
 JR C,LEFT1
 LD A,(IY+1)
 SUB 18
LEFT1 LD (IY+1),A
 CALL VILAGIT
 RET
UP LD A,1
 CP (IY)
 JR NZ,UP1
 CP (IY+1)
 RET Z
 CALL VILAGIT
 DEC (IY+1)
 CALL BERAK
 JR UP2
UP1 CALL VILAGIT
 DEC (IY)
 DEC (IY+1)
UP2 CALL VILAGIT
 RET
DOWN LD A,54
 CP (IY)
 JR NZ,DOWN1
 LD A,(IY+1)
 CP (IY+2)
 RET NC
 CALL VILAGIT
DSROLL LD A,(IY+1)
 PUSH AF
 SUB 52
 LD (IY+1),A
 CALL BERAK
 POP AF
 LD (IY+1),A
 JR DOWN2
DOWN1 CALL VILAGIT
 LD A,(IY+2)
 CP (IY+1)
 JR Z,UP2
 INC (IY)
DOWN2 INC (IY+1)
 JR UP2
HIBA AND A
 RET Z
 LD HL,HIBAPUFF
 LD DE,HIBAPUFF+1
 LD BC,#3F
 PUSH BC
 PUSH DE
 PUSH HL
 LD (HL),0
 LDIR
 POP DE
 EXOS 28
 POP DE
 POP BC
 LD A,EDITCSAT
 EXOS 8
 RET
FATHIBA AND A
 RET Z
 CALL HIBA
SYSTEM BLOUT EDITCSAT UJSOR,2
 KARBE EDITCSAT
 LD A,B
 CP ":"
 JR NZ,SYSTEM
 LD HL,HIBAPUFF
 LD B,0
SYSCIK0 LD (HL),B
 KARBE EDITCSAT
 INC HL
 LD A,B
 CP 0DH
 JR NZ,SYSCIK0
SYSHIV LD B,-1
 XOR A
SYSHIV0 DEC HL
 INC B
 CP (HL)
 JR NZ,SYSHIV0
 LD (HL),B
 EX DE,HL
 EXOS 1AH
 PUSH AF
 CALL HIBA
 POP AF
 OR A
 JR NZ,SYSTEM
 KARBE EDITCSAT
 JP DIREL
KURCIM LD A,(IY)
 DEC A
 LD B,0
KURC1 INC B
 SUB 18
 JR NC,KURC1
 ADD A,19
 PUSH AF
 LD A,-13
KURC2 ADD A,13
 DJNZ KURC2
 LD HL,(PANCIM)
 LD C,A
 ADD HL,BC
 POP AF
 LD C,40
KURC3 ADD HL,BC
 DEC A
 JR NZ,KURC3
 INC HL
 RET
KIJELOL CALL KURCIM
 LD C,40H
 CALL UJSZIN
 LD HL,DIRCIM
 LD B,(IY+1)
 LD DE,17
BEAZO ADD HL,DE
 DJNZ BEAZO
 DEC HL
 DEC HL
 DEC HL
 DEC HL
 LD A,(HL)
 AND A
 JR Z,BEAZON1
 LD (HL),0
 DEC (IY+3)
 RET
BEAZON1 INC (IY+3)
 LD A,(IY+3)
 LD (HL),A
 RET
VILAGIT CALL KURCIM
 ld c,80h
 CALL UJSZIN
 CALL ALULIR
 RET
UJSZIN LD B,12
VIL4 LD A,(HL)
 XOR c
 LD (HL),A
 INC HL
 DJNZ VIL4
 RET
BINBCD LD E,(HL)
 INC HL
 LD D,(HL)
 INC HL
 LD C,(HL)
 INC HL
 LD B,20
 EXX
 LD HL,1
 LD D,H
 LD E,H
 LD B,H
 LD C,H
 EXX
BINBCD1 RR C
 RR D
 RR E
 EXX
 JR NC,HEERTEK
 LD A,E
 ADD A,L
 DAA
 LD E,A
 LD A,D
 ADC A,H
 DAA
 LD D,A
 LD A,C
 ADC A,B
 DAA
 LD C,A
HEERTEK LD A,L
 ADD A,A
 DAA
 LD L,A
 LD A,H
 ADC A,A
 DAA
 LD H,A
 LD A,B
 ADC A,A
 DAA
 LD B,A
 EXX
 DJNZ BINBCD1
 RET
SZAMRAK LD (HL),A
 XOR A
 RRD
 LD C,A
 LD A,B
 ADD A,(HL)
 LD (HL),A
 INC HL
 LD A,C
 ADD A,B
 LD (HL),A
 INC HL
 RET
ALULIR LD HL,HIBAPUFF
 LD DE,HIBAPUFF+1
 LD (HL)," "
 LD BC,40
 LDIR
 CALL FILECIM
 LD DE,HIBAPUFF+6
 LD BC,12
 LDIR
 INC DE
 INC DE
 INC DE
 BIT 4,(HL)
 JR Z,MERETJEL
 LD HL,DIRECTORY
 LD C,11
 LDIR
 JR ALULRA
MERETJEL INC HL
 INC HL
 CALL HATJEGY
 LD HL,BYTES
 LD C,5
 LDIR
ALULRA LD HL,(PANCIM)
 LD BC,20*40
 ADD HL,BC
 LD DE,HIBAPUFF
 LD B,40
VIL7 LD A,(DE)
 SUB 20h
 LD (HL),A
 INC HL
 INC DE
 DJNZ VIL7
 RET
HATJEGY PUSH DE
 CALL BINBCD
 EXX
 POP HL
 PUSH HL
 LD B,30H
 LD A,C
 CALL SZAMRAK
 LD A,D
 CALL SZAMRAK
 LD A,E
 CALL SZAMRAK
 POP DE
 CALL CSINOSIT
 INC DE
 RET
CSINOSIT LD B,6
 LD C,"0"
CSINOS1 LD A,(DE)
 CP C
 JR NZ,CSINOS2
 LD A," "
 LD (DE),A
 INC DE
 DJNZ CSINOS1
 LD A,C
 DEC DE
 LD (DE),A
 INC DE
 RET
CSINOS2 INC DE
 DJNZ CSINOS2
 RET
FILECIM LD A,(IY+1)
FILECIM0 LD BC,17
 LD HL,DIRCIM-17
FILECIM1 ADD HL,BC
 DEC A
 JR NZ,FILECIM1
 RET
VESEZ LD A,(HL)
 CP " "
 JR Z,VESEZ1
 INC C
 LD (DE),A
 INC DE
VESEZ1 INC HL
 DJNZ VESEZ
 RET
NEVEZO CALL FILECIM
 LD BC,#800
 LD DE,LOADNEV
 CALL VESEZ
 LD A,C
 AND A
 LD A,#EE
 RET Z
 INC HL
 LD A,(HL)
 CP " "
 JR Z,BETOLT4
 LD A,"."
 LD (DE),A
 INC DE
 INC C
 LD B,3
 CALL VESEZ
BETOLT4 LD A,C
 LD (DTFNEV),A
 ADD A,3
 LD (CHDIR),A
 ADD A,2
 LD (LOAD),A
 LD HL,LOADNEV
 PUSH HL
 PUSH BC
 LD DE,DTFNEV+1
 LDIR
 POP BC
 POP HL
 LD DE,CDNEV
 LDIR
 XOR A
 RET
BETOLT CALL NEVEZO
 AND A
 RET NZ
 CALL FILECIM
 LD BC,12
 ADD HL,BC
 BIT 4,(HL)
 JR Z,FTOLT
 TAPOGAT CHDIR
 RET
FTOLT CALL DTFTOLT
 TAPOGAT LOAD
 RET
MEGNYIT LD BC,416H
 CALL NYITCIK
 OPEN (HL),VIDEO
 RET
NYITCIK PUSH BC
 LD B,1
 LD D,(HL)
 EXOS 16
 INC HL
 POP BC
 INC C
 DJNZ NYITCIK
 RET
PANELBE LD A,PANCSAT
 LD BC,101H
 LD E,C
 LD D,22
 EXOS SPECIAL
 LD A,FONTCSAT
 LD B,3
 EXOS SPECIAL
 LD L,B
 LD A,C
 ADD A,#40
 JR NC,FONT0
 INC D
 INC L
FONT0 AND #C0
 LD E,A
 LD H,0
 RLA
 RL L
 RL H
 RLA
 RL L
 RL H
 PUSH HL
 PUSH DE
 LD HL,#F4A0
 LD C,64
 LD B,C
 XOR A
FONT1 LD (DE),A
 INC DE
 DJNZ FONT1
 CALL FRAZ
 LD A,B
 LD B,C
FONT2 LD (DE),A
 INC DE
 DJNZ FONT2
 POP DE
 LD HL,CSIKOK
 INC DE
 LD A,9
CSIKCIK LD BC,8
 LDIR
 EX DE,HL
 LD C,64-8
 ADD HL,BC
 EX DE,HL
 DEC A
 JR NZ,CSIKCIK
 LD HL,#F910
 LD A,21
 POP BC
SZEP1 INC HL
 SET 1,(HL)
 INC HL
 INC HL
 SET 6,(HL)
 SET 7,(HL)
 INC HL
 INC HL
 INC HL
FONTCIM PUSH BC
 LD (HL),C
 INC HL
 LD (HL),B
 INC HL
 EX DE,HL
 LD HL,COLORS
 LD BC,8
 LDIR
 EX DE,HL
 POP BC
 DEC A
 JR NZ,SZEP1
 RET
FRAZ LD A,#1F
 CALL FRAZ1
 XOR A
 CALL FRAZ1
 CALL FRAZ2
 LD A,#17
FRAZ1 LD (FRAZ4),A
 CALL FRAZ2
FRAZ2 LD B,C
FRAZ3 LD A,(HL)
 OR A
FRAZ4 NOP
 LD (DE),A
 INC DE
 INC HL
 DJNZ FRAZ3
 ADD HL,BC
 RET
KERET LD HL,(PANCIM)
 LD DE,#C1C5
 LD C,#C3
 LD A,#C8
 CALL SORCLS
 LD DE,#C7C7
 LD C,D
 LD B,18
 XOR A
KERET1 PUSH BC
 CALL SORCLS
 POP BC
 DJNZ KERET1
 LD DE,#C2C6
 LD C,#C4
 LD A,#C8
 CALL SORCLS
 LD D,H
 LD E,L
 INC DE
 LD (HL),0
 LD BC,39
 LDIR
 LD HL,MENUSOR
 LD BC,40
 LDIR
 RET
REKESZ LD B,12
REKCIK LD (HL),A
 INC HL
 DJNZ REKCIK
 RET
SORCLS LD (HL),D
 INC HL
 CALL REKESZ
 LD (HL),E
 INC HL
 CALL REKESZ
 LD (HL),E
 INC HL
 CALL REKESZ
 LD (HL),C
 INC HL
 RET
;IY+1=AKTFILE,IY+2=TETELSZAM
BERAK LD IX,DIRCIM-17
 LD DE,17
 LD B,(IY+1)
 LD C,B
KEZDET ADD IX,DE
 DJNZ KEZDET
 LD HL,(PANCIM)
 LD E,41
 ADD HL,DE
 EX DE,HL
 LD HL,#1203
 LD A,(IY+2)
 SUB C
 INC A
SZEP2 SUB H
 JR C,SZEP3
 LD B,H
 CALL RAK1
 DEC L
 JR NZ,SZEP2
 RET
SZEP3 ADD A,H
 RET Z
 LD B,A
RAK1 PUSH AF
RAK2 PUSH DE
RAK3 PUSH BC
 LD B,12
 LD A,(IX+13)
 LD C,A
 AND A
 JR Z,RAK4
 LD C,40H
RAK4 LD A,(IX)
 SUB 20H
 OR C
 LD (DE),A
 INC IX
 INC DE
 DJNZ RAK4
 LD C,28
 EX DE,HL
 ADD HL,BC
 EX DE,HL
 LD C,5
 ADD IX,BC
 POP BC
 DJNZ RAK3
 POP DE
 LD C,13
 EX DE,HL
 ADD HL,BC
 EX DE,HL
 POP AF
 RET
*INCLUDE DTFTOLT.GEN
PACK
*INCLUDE PACK.GEN
FONTKEP DEFB 0,0,10,64,FONTCSAT
EDITKEP DEFB 0,0,40,5,EKEPCSAT
EDITADAT DEFB EKEPCSAT,KEYCSAT,1
PANEL DEFB 0,0,40,22,PANCSAT
COLORS DEFB 4,#36,#36,1,4,#C3,#C3,4
KEYTAB DEFB #A8,#A9,ESC
 DEFM "\HhPpUu"
KEYTABH EQU $-KEYTAB
JUMPTAB DEFW INS,INS,ESCAPE
 DEFW GYOK,HIDDV,HIDDV,PACK,PACK,UNPACK,UNPACK
JOYTAB DEFW RIGHT,LEFT,DOWN,UP,TUZEL
GYOKER DEFB 4
 DEFM "CD \  "
SZULO DEFB 5
 DEFM "CD .."
DTFNEV DEFS 13
CHDIR DEFB 0
 DEFM "CD "
CDNEV DEFS 12
LOAD DEFB 0
 DEFM "LOAD "
LOADNEV DEFS 12
FISHVERE DEFB 6
 DEFM "EXDOS"
 DEFB #FD
WP DEFB 2
 DEFM "WP"
DIRECTORY DEFM "<DIRECTORY>
BYTES DEFM "BYTES"
MENUSOR DEFB 32,32,"H"+128
 DEFM "idden   "
 DEFB "E"+128,"s"+128,"c"+128,32,32,"I"+128,"n"+128,"s"+128
 DEFB 32,32
 DEFB "\"+128,32,32,32
 DEFB "P"+128
 DEFM "ack   "
 DEFB "U"+128
 DEFM "npack  "
VIDEO DEFB 6
 DEFM "VIDEO:"
DIR DEFB 3
 DEFM "DIR"
KEYBOARD DEFB 9
 DEFM "KEYBOARD:"
EDITOR DEFB 7
 DEFM "EDITOR:"
KURZOR DEFB 0
AKTFILE DEFB 0
TETELSZ DEFB 0
INSSZAM DEFB 0
PANCIM DEFW 0
PANCOLS DEFB ESC,"C",#E0,6,#E0,#D6,0,0,0,0
UJSOR DEFB #D,":"
CSIKOK DEFB 0,#24,0,#24,0,#24,#24,0,0,#24,0,#24,0,#24,#24,0
 DEFB #3F,#27,#FC,#E4,#FF,#FF,#24,#FF,#20,#20,4,4,0,0,#24,0
 DEFB #20,#20,4,4,0,0,#24,0,#20,#20,4,4,0,0,#24,0
 DEFB #27,#3F,#E4,#FC,#FF,#FF,#24,#FF,#24,0,#24,0,#24,0,#24,0
 DEFB #24,0,#24,0,#24,0,#24,0
DIRCIM EQU $
HIBAPUFF EQU DIRCIM+17*256
BTAB EQU ((HIBAPUFF+#180)/256)*256
RENDTAB EQU BTAB+#100
REND EQU RENDTAB+#200
SZAMTAB EQU REND+#100
SZAMTABV EQU SZAMTAB+#200
MYSTACK EQU SZAMTABV+#80
