 CALL DTOM
 JP DIREL
DTOM CALL LAPOK
 CALL NEVBE
 LD B,(IY+3)
 LD A,B
 OR A
 JR NZ,PACK1
 CALL PP1
 LD B,1
 PUSH BC
 JR PACK3
PACK1 LD C,1
PACK2 PUSH BC
 CALL PP
PACK3 PUSH IY
 CALL PPP
 CALL FORRSZAM
PACK4 CALL OLVASAS
 PUSH AF
 LD A,H
 OR L
 JR Z,PACK5
 CALL KERESES
 CALL TOMOR
 CALL STATISZ
 CALL OPTIMUM
 BLOUT EDITCSAT,OK3,OK3H
 CALL TOMORIT
 POP AF
 CALL KIMENT
 EI
 CP EOF
 JR NZ,PACK4
 PUSH AF
PACK5 POP AF
 LD A,1
 EXOS 3
 CALL BALANCE
 POP IY
 POP BC
 INC C
 DJNZ PACK2
 LD A,6
 EXOS 3
 CALL OLAP
 RET
FORRME DEFS 3
CELME DEFS 3
NEVBE BLOUT EDITCSAT,FELKER,FELKERH
 LD HL,HIBAPUFF+1
NEVBE0 KARBE EDITCSAT
 LD (HL),B
 LD A,#D
 INC HL
 CP B
 JR NZ,NEVBE0
 LD DE,HIBAPUFF
 DEC HL
 DEC HL
 SBC HL,DE
 LD A,L
 LD (DE),A
 BLOUT EDITCSAT,CREATING,CREAH
 LD HL,HIBAPUFF
 LD C,(HL)
 INC C
 LD B,0
 INC HL
 EX DE,HL
 LD A,EDITCSAT
 EXOS 8
 LD A,6
 LD DE,HIBAPUFF
 EXOS 2
 CALL TOMHIBA
 BLOUT 6,ATTUS,6
 RET
FELKER DEFB #D
 DEFM "CELFILE NEVE ? "
 DEFB #D,#A
FELKERH EQU $-FELKER
BALANCE LD HL,CELME
 LD DE,eredm
 CALL HATJEGY
 BLOUT EDITCSAT,BALANC,BALANCH
 LD HL,(CELME)
 LD BC,(CELME+2)
 LD B,2
 XOR A
BALA1 RL L
 RL H
 RL C
 LD E,L
 LD D,H
 LD A,C
 RL L
 RL H
 RL C
 RL L
 RL H
 RL C
 ADD HL,DE
 ADC A,C
 LD C,A
 DJNZ BALA1
 LD DE,(FORRME)
 LD A,(FORRME+2)
 LD B,A
 EX AF,AF'
 XOR A
 EX AF,AF'
BALA2 SBC HL,DE
 LD a,C
 sBC a,B
 LD C,a
 JR C,BALA3
 EX AF,AF'
 INC A
 EX AF,AF'
 JR BALA2
BALA3 EX AF,AF'
 LD (SZAZA),A
 LD HL,SZAZA
 LD DE,SZAZM
 CALL HATJEGY
 BLOUT EDITCSAT,SZAZALEK,SZAZHO
 RET
SZAZA defs 3
SZAZALEK DEFM " ="
SZAZM defs 6
 DEFM " %"
 DEFB #D
SZAZHO equ $-SZAZALEK
BALANC DEFB #D
 DEFM "BALANCE: "
eredm DEFS 6
 DEFM " BYTES"
BALANCH EQU $-BALANC
FORRSZAM CALL FILECIM
 LD BC,14
 ADD HL,BC
 LD DE,FORRME
 LDI
 LDI
 LDI
 DEC HL
 DEC HL
 DEC HL
 LD DE,SOURSZ
 CALL HATJEGY
 BLOUT EDITCSAT,SOURCE,SOURCH
 RET
SOURCE DEFB #D
 DEFM "SOURCE BYTES: "
SOURSZ DEFS 6
SOURCH EQU $-SOURCE
CREATING DEFB #D
 DEFM "CREATING "
CREAH EQU $-CREATING
OK3 DEFB #D
 DEFM "OPTIMAL SYSTEM: "
OPTJEL DEFM "         "
OK3H EQU $-OK3
OLAP LD A,-1
 OUT (#B3),A
 DEC A
 OUT (#B2),A
 LD A,1
 EXOS 3
 LD A,6
 EXOS 3
 LD HL,(#22)
 LD C,L
 EXOS 25
 LD C,H
 EXOS 25
 RET
LAPOK EXOS 24
 CALL TOMHIBA
 LD L,C
 EXOS 24
 CALL TOMHIBA
 LD H,C
 LD (#22),HL
 LD A,H
 OUT (#B3),A
 LD A,L
 OUT (#B2),A
 RET
TOMHIBA OR A
 RET Z
 PUSH AF
 CALL OLAP
 POP AF
 CALL HIBA
 LD SP,MYSTACK
 EI
 JP DIREL
OPTIMUM LD IY,RSZTAB
 LD B,RSZSZAM
 LD HL,-1
 LD (TFHO),HL
 PUSH IY
OPT1 CALL HELYFOG
 LD DE,(TFHO)
 AND A
 SBC HL,DE
 JR NC,OPT2
 ADD HL,DE
 LD (TFHO),HL
 POP HL
 PUSH IY
OPT2 DJNZ OPT1
 POP HL
 DEC HL
 DEC HL
 DEC HL
 DEC HL
 LD (OPTREND),HL
 LD DE,OPTJEL
 LD B,4
OPT3 LD A,(HL)
 ADD A,#30
 LD (DE),A
 INC HL
 INC DE
 INC DE
 DJNZ OPT3
 RET
HELYF1 DEFW 0
HELYF2 DEFW 0
HELYFOG PUSH BC
 LD IX,SZAMTAB
 CALL OSSZEAD1
 LD (HELYF1),HL
 LD (HELYF2),BC
 INC IY
 CALL OSSZEAD1
 CALL OSSZEAD2
 INC IY
 CALL OSSZEAD1
 CALL OSSZEAD2
 INC IY
 PUSH IX
 POP DE
 LD HL,SZAMTAB
 AND A
 SBC HL,DE
 RR H
 RR L
 LD A,L
 CALL OSSZEAD3
 CALL OSSZEAD2
 INC IY
 LD HL,(HELYF1)
 LD DE,(HELYF2)
 LD B,3
 AND A
HELYFC RR D
 RR E
 RR H
 RR L
 DJNZ HELYFC
 POP BC
 RET
OSSZEAD1 LD B,(IY)
 LD A,1
OSSZE11 RLCA
 DJNZ OSSZE11
OSSZEAD3 LD B,A
 LD HL,0
OSSZE12 LD E,(IX)
 INC IX
 LD D,(IX)             
 INC IX
 ADD HL,DE
 DJNZ OSSZE12
 LD D,H
 LD E,L
 LD C,B
 ADD HL,HL
 JR NC,OSSZE13
 INC C
OSSZE13 LD A,(IY)
OSSZE14 ADD HL,DE
 JR NC,OSSZE15
 INC C
OSSZE15 DEC A
 JR NZ,OSSZE14
 RET
OSSZEAD2 LD DE,(HELYF1)
 ADD HL,DE
 JR NC,OSSZE21
 INC BC
OSSZE21 LD (HELYF1),HL
 LD HL,(HELYF2)
 ADD HL,BC
 LD (HELYF2),HL
 RET
KIMENT PUSH AF
 LD B,A
 LD A,6
 EXOS 7
 LD HL,REND
 LD BC,(RENDHOS)
 LD A,C
 AND A
 JR NZ,RENDMENT
 LD B,1
RENDMENT ADD HL,BC
 DEC HL
 LD DE,#A000
 DEC DE
 LDDR
 LD C,2
 LD HL,RENDHOS+1
 LDDR
 LD C,4
 LD HL,(OPTREND)
 INC HL
 INC HL
 INC HL
 LDDR
 LD A,(JELEM)
 LD (DE),A
 DEC DE
 LD C,2
 LD HL,FLHOSSZ+1
 LDDR
 EX DE,HL
 EXX
 PUSH HL
 EXX
 POP DE
 LD A,D
 SUB #A0
 LD (HL),A
 DEC HL
 LD (HL),E
 EX DE,HL
 AND A
 SBC HL,DE
 LD B,H
 LD C,L
 LD A,6
 EXOS 8
 CALL TOMHIBA
 INC HL
 LD DE,(CELME)
 ADD HL,DE
 LD (CELME),HL
 JR NC,kim
 LD HL,CELME+2
 INC (HL)
kim POP AF
 RET
TOMORIT LD BC,(BYTTH)
 LD DE,#B000
 EXX
 LD HL,#A000
 LD (HL),1
 EXX
 DI
TOMCIK LD A,(DE)
 LD (BYTE),A
 PUSH BC
 PUSH DE
 CALL BEAZON
 CALL KIAD
 POP DE
 INC DE
 POP BC
 PUSH AF
 DEC BC
 LD A,B
 OR C
 JR Z,TOMVEG
 POP AF
 JR TOMCIK
TOMVEG POP AF
 RET C
 EXX
URTOL CALL BITKI
 JR NC,URTOL
 EXX
 RET
BEAZON LD HL,REND
 LD DE,(OPTREND)
 EXX
 LD E,0
 EXX
BEALLC LD A,(DE)
 LD B,A
 EXX
 LD B,A
 XOR A
 LD D,A
 EXX
 INC A
BEALL1 RLA
 DJNZ BEALL1
 LD B,A
 LD A,(BYTE)
BEALL2 CP (HL)
 RET Z
 EXX
 INC D
 EXX
 INC HL
 DJNZ BEALL2
 EXX
 INC E
 EXX
 INC DE
 JR BEALLC
BITKI RL (HL)
 RET NC
 LD A,(HL)
 OUT (81H),A
 INC HL
 LD (HL),1
 RET
KIAD EXX
 RRC E
 RRC E
 RL E
 CALL BITKI
 RL E
 CALL BITKI
 LD A,8
 SUB B
 JR Z,KIRAK
ELOTOL RL D
 DEC A
 JR NZ,ELOTOL
KIRAK RL D
 CALL BITKI
 DJNZ KIRAK
 EXX
 RET
STATISZ LD HL,RENDTAB
 LD DE,RENDTAB+1
 LD BC,4FFH
 LD (HL),0
 LDIR
 LD DE,RENDTAB
 LD HL,#B000
 LD BC,(BYTTH)
SZAM1 LD E,(HL)
 EX DE,HL
 INC (HL)
 JR NZ,SZAM2
 INC H
 INC (HL)
 DEC H
SZAM2 EX DE,HL
 INC HL
 DEC BC
 LD A,B
 OR C
 JR NZ,SZAM1
 LD IX,REND
 LD IY,SZAMTAB
REND1 LD HL,RENDTAB
 LD A,-1
 EXX
 LD HL,0
 EXX
REND2 INC H
 LD D,(HL)
 DEC H
 CP D
 JR Z,REND4
 LD E,(HL)
 PUSH DE
 EXX
 POP DE
 AND A
 SBC HL,DE
 ADD HL,DE
 JR NC,REND3
 EX AF,AF'
 EX DE,HL
 EXX
 LD A,L
 EXX
 EX AF,AF'
REND3 EXX
REND4 INC L
 JR NZ,REND2
 EXX
 LD A,H
 OR L
 JR Z,REND5
 LD (IY),L
 INC IY
 LD (IY),H
 INC IY
 EXX
 EX AF,AF'
 LD L,A
 EX AF,AF'
 INC H
 LD (HL),-1
 LD (IX),L
 INC IX
 DJNZ REND1
REND5 PUSH IX
 POP HL
 LD A,L
 LD (RENDHOS),A
 RET
PP LD (IY+1),0
 LD A,C
 LD HL,DIRCIM-4
 LD DE,17
PCKO1 ADD HL,DE
 INC (IY+1)
 CP (HL)
 JR NZ,PCKO1
PP1 CALL NEVEZO
 CALL TOMHIBA
 RET
PPP LD HL,20
 LD (CELME),HL
 XOR A
 LD (CELME+2),A
 LD HL,DTFNEV
 LD D,H
 LD E,L
 LD A,1
 EXOS 1
 CALL TOMHIBA
 BLOUT EDITCSAT,KOMPR,KOMPH
 LD D,H
 LD E,L
 LD C,(HL)
 LD B,0
 PUSH BC
 INC DE
 LD A,EDITCSAT
 EXOS 8
 KARKI EDITCSAT,#D
 POP BC
 INC C
 EX DE,HL
 LD L,C
 LD A,6
 EXOS 8
 LD A,14
 SUB L
 RET Z
 LD L,A
PCKO5 LD B," "
 LD A,6
 EXOS 7
 CALL TOMHIBA
 DEC L
 JR NZ,PCKO5
 RET
ATTUS DEFM "ATTUS "
KOMPR DEFB #D
 DEFM "KOMPRESSING "
KOMPH EQU $-KOMPR
TARGETBE BLOUT EDITCSAT,TARGET,TARGHO
 KARBE EDITCSAT
 LD A,B
 res 5,a
 CP "A"
 JR C,TARGETBE
 CP "F"
 JR NC,TARGETBE
 LD (CELNEV+1),A
 RET
CELNEV DEFB 2
 DEFM "A:"
 DEFS 13
TARGET DEFB #D,#19
 DEFM "TARGET DRIVE ?"
 DEFB #D
TARGHO EQU $-TARGET
OLVASAS ld hl,RENDTAB
 ld de,RENDTAB+1
 ld bc,100h
 ld (hl),l
 ldir
 ld a,1
 ld de,#C000
 ld bc,#4000
 EXOS 6
 CP EOF
 CALL NZ,TOMHIBA
 PUSH AF
 LD A,D
 SUB #C0
 LD H,A
 LD L,E
 LD (FLHOSSZ),HL
 POP AF
 RET
KERESES ld BC,(FLHOSSZ)
 DI
 LD IX,#C000
 LD HL,BTAB
KUTAT LD L,(IX)
 INC (HL)
 LD A,(HL)
 OUT (81H),A
 JR NZ,KUTAT1
 DEC (HL)
KUTAT1 INC IX
 DEC BC
 LD A,B
 OR C
 JR NZ,KUTAT
 LD E,0
KUTAT2 LD L,0
 LD D,-1
KUTAT3 LD A,(HL)
 CP D
 JR NC,KUTAT4
 LD A,L
 OUT (81H),A
 LD E,A
 LD D,(HL)
 LD A,D
 AND A
 JR Z,JELKESZ
KUTAT4 INC L
 JR NZ,KUTAT3
JELKESZ LD A,E
 LD (JELEM),A
 RET
TOMOR LD BC,(FLHOSSZ)
 LD HL,#B000
 ld ix,#C000
 push bc
kov ld a,(JELEM)
 cp (ix)
 jr z,tom
 ld a,(ix)
 cp (ix+1)
 jr nz,ntom
 cp (ix+2)
 jr nz,ntom
 cp (ix+3)
 jr nz,ntom
tom ld d,0
 ld e,a
szamol ld a,d
 add a,1
 OUT (81H),A
 ld d,a
 jr c,sok
 pop bc
 dec bc
 ld a,b
 or c
 jr z,veget
 push bc
 inc ix
 ld a,(ix)
 cp e
 jr z,szamol
 jr tov
sok pop bc
 dec bc
 ld a,b
 or c
 jr z,veget
 push bc
 inc ix
tov ld a,(JELEM)
 ld (HL),A
 INC HL
 LD (HL),D
 INC HL
 LD (HL),E
 INC HL
 jr kov
ntom ld b,(ix)
 LD (HL),B
 INC HL
 inc ix
 pop bc
 dec bc
 ld a,b
 or c
 push bc
 jr nz,kov
 POP BC
 jr ZAR
veget ld a,(JELEM)
 LD (HL),A
 INC HL
 LD (HL),D
 INC HL
 LD (HL),E
 INC HL
ZAR LD A,H
 SUB #B0
 LD B,A
 LD C,L
 LD (BYTTH),BC
 RET
JELEM DEFB 0
BYTTH DEFW 0
FLHOSSZ DEFW 0
RENDHOS DEFW 0
BYTE DEFW 0
TFHO DEFW 0
OPTREND DEFW 0
RSZTAB DEFB 1,2,3,8,2,2,3,8
 DEFB 1,3,3,8,2,3,3,8
 DEFB 3,3,3,8,1,2,4,8
 DEFB 2,2,4,8,1,3,4,8
 DEFB 2,3,4,8,3,3,4,8
 DEFB 1,4,4,8,2,4,4,8
 DEFB 3,4,4,8,4,4,4,8
 DEFB 1,2,5,8,2,2,5,8
 DEFB 1,3,5,8,2,3,5,8
 DEFB 3,3,5,8,1,4,5,8
 DEFB 2,4,5,8,3,4,5,8
 DEFB 4,4,5,8,1,5,5,8
 DEFB 2,5,5,8,3,5,5,8
 DEFB 4,5,5,8,5,5,5,8
 DEFB 1,2,6,8,2,2,6,8
 DEFB 1,3,6,8,2,3,6,8
 DEFB 3,3,6,8,1,4,6,8
 DEFB 2,4,6,8,3,4,6,8
 DEFB 4,4,6,8,1,5,6,8
 DEFB 2,5,6,8,3,5,6,8
 DEFB 4,5,6,8,5,5,6,7
 DEFB 1,6,6,7,2,6,6,7
 DEFB 3,6,6,7,4,6,6,7
 DEFB 5,6,6,7,6,6,6,6
RSZSZAM EQU ($-RSZTAB)/4
