        MAIN "",134

        Box
BOX     LD A,(IX+4)
        CALL SETV

        BIT 0,(IX+6)
        JR Z,NOH

        LD A,(IX+3)
        PUSH AF
        XOR A
        LD (IX+3),A
        LD A,(IX+5)
        CALL SETV
        POP AF
        LD (IX+3),A

NOH     LD D,(IX+0)
        LD E,(IX+1)
        LD (de+1),DE
        CALL RASCH

        LD DE,Okno_Sp
        BIT 0,(IX+6)
        JR Z,NOSS

NOSS    LD DE,Okno_SS
        CALL RST16
        LD DE,Okno_Sp+8
        LD B,(IX+2)
WL1     CALL RST16
        DJNZ WL1
        LD DE,Okno_Sp+16
        CALL RST16

        LD B,(IX+3)
        INC B
WL3     PUSH BC
        LD DE,Okno_Sp+24
        PUSH DE
de      LD DE,0
        INC E
        LD (de+1),DE
        CALL RASCH
        POP DE
        CALL RST16
        LD DE,Okno_Sp+32
        LD B,(IX+2)
WL2     CALL RST16
        DJNZ WL2
        LD DE,Okno_Sp+40
        CALL RST16
        POP BC
        DJNZ WL3
        LD D,(IX+0)
        LD E,(IX+1)
        LD A,(IX+3)
        ADD A,E
        INC A
        LD E,A
        CALL RASCH
        LD DE,Okno_Sp+48
        CALL RST16
        LD DE,Okno_Sp+56
        LD B,(IX+2)
WL4     CALL RST16
        DJNZ WL4
        LD DE,Okno_Sp+64
        CALL RST16

        BIT 0,(IX+6)
        JR Z,NOSP

        LD D,(IX+0)
        LD E,(IX+1)
        INC E
        CALL RASCH
        LD B,(IX+2)
        LD DE,Okno_S
        CALL RST16

        LD DE,Okno_S+8
WL8     CALL RST16
        DJNZ WL8

        LD DE,Okno_S+16
        CALL RST16
NOSP    RET 

RST16   PUSH HL
        PUSH DE
        DUP 8
        LD A,(DE)
        LD (HL),A
        INC DE
        INC H
        EDUP 
        POP DE
        POP HL
        INC L
        RET 

Okno_S  DEFB %10000000
        DEFB %10000000
        DEFB %10000000
        DEFB %10000000
        DEFB %10000000
        DEFB %10000000
        DEFB %11111111
        DEFB %10000000

        DEFB %00000000
        DEFB %00000000
        DEFB %00000000
        DEFB %00000000
        DEFB %00000000
        DEFB %00000000
        DEFB %11111111
        DEFB %00000000

        DEFB %00000001
        DEFB %00000001
        DEFB %00000001
        DEFB %00000001
        DEFB %00000001
        DEFB %00000001
        DEFB %11111111
        DEFB %00000001

Okno_SS DEFB %00000000
        DEFB %11111111
        DEFB %10000000
        DEFB %10000000
        DEFB %10000000
        DEFB %10000000
        DEFB %10000000
        DEFB %10000000

Okno_Sp DB %00000000
        DEFB %01111111
        DEFB %01100000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000

        DB %00000000
        DB %11111111
        DEFB %00000000
        DB %00000000
        DB %00000000
        DB %00000000
        DB %00000000
        DB %00000000

        DB %00000000
        DEFB %11111110
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010

        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000

        DB %00000000
        DB %00000000
        DB %00000000
        DB %00000000
        DB %00000000
        DB %00000000
        DB %00000000
        DB %00000000

        DEFB %00000010
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010

        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01000000
        DEFB %01111111
        DB %00000000

        DB %00000000
        DB %00000000
        DB %00000000
        DB %00000000
        DB %00000000
        DEFB %00000000
        DB %11111111
        DB %00000000

        DB %00000010
        DB %00000010
        DB %00000010
        DEFB %00000010
        DEFB %00000010
        DEFB %00000010
        DB %11111110
        DB %00000000

; HL - adress on screen
; C  - length of SPACE-text

PR_52   LD HL,(xyprn)
pr_52   LD A,C
        LD (lnprn),A
        AND A
        RET Z
        LD B,'FONT52
        PUSH IX
        LD HX,8
Loop_1  PUSH HL
        LD LX,0
lnprn   EQU $-1
        LD DE,SPACE

Cont    LD A,(DE)
        INC DE
        LD C,A
        LD A,(BC)
        OR (HL)
        LD (HL),A

        DEC LX
        JP Z,Exi

        LD A,(DE)
        INC DE
        LD C,A
        LD A,(BC)
        LD C,A
        XOR A
        DUP 3
        SLA C
        RLA 
        EDUP 
        OR (HL)
        LD (HL),A
        INC L
        LD A,(HL)
        OR C
        LD (HL),A

        DEC LX
        JR Z,Exi

        LD A,(DE)
        INC DE
        LD C,A
        LD A,(BC)
        RRA 
        RRA 
        OR (HL)
        LD (HL),A

        DEC LX
        JR Z,Exi

        LD A,(DE)
        INC DE
        LD C,A
        LD A,(BC)
        LD C,A
        XOR A
        SLA C
        RLA 
        OR (HL)
        LD (HL),A
        INC L
        LD A,(HL)
        OR C
        LD (HL),A

        DEC LX
        JR Z,Exi

        LD A,(DE)
        INC DE
        LD C,A
        LD A,(BC)
        LD C,0
        RRA 
        RRA 
        RRA 
        RR C
        RRA 
        RR C
        OR (HL)
        LD (HL),A
        INC L
        LD A,(HL)
        OR C
        LD (HL),A

        DEC LX
        JR Z,Exi

        LD A,(DE)
        INC DE
        LD C,A
        LD A,(BC)
        RRA 
        OR (HL)
        LD (HL),A

        DEC LX
        JR Z,Exi

        LD A,(DE)
        INC DE
        LD C,A
        LD A,(BC)
        LD C,A
        XOR A
        SLA C
        RLA 
        SLA C
        RLA 
        OR (HL)
        LD (HL),A
        INC L
        LD A,(HL)
        OR C
        LD (HL),A

        DEC LX
        JR Z,Exi

        LD A,(DE)
        INC DE
        LD C,A
        LD A,(BC)
        RRA 
        RRA 
        RRA 
        OR (HL)
        LD (HL),A

        DEC LX
        JR Z,Exi
        INC L
        JP Cont

Exi     POP HL
        CALL INC_Y
        INC B
        DEC HX
        JP NZ,Loop_1
        POP IX
        RET 

SPACE   DEFS 52

PRINT   LD D,(IX+0)
        INC D
        LD E,(IX+1)
;       INC E
        CALL RASCH
        LD (xyprn),HL

        LD HL,HEAD0D
        LD (OBROB+1),HL

        LD HL,0
xyprn   EQU $-2

        LD L,(IX+8)
        LD H,(IX+9)
Jp1     LD DE,SPACE
        LD C,0
Lp3     LD A,(HL)
        INC HL
        AND A
        JP Z,PR_52
        CP #0D
OBROB   JP Z,F0D
        CP #0F
        JR Z,F0F
        LD (DE),A
        INC DE
        INC C
        JR Lp3

F0F     PUSH HL
        LD HL,(xyprn)
        LD B,(IX+2)
        LD A,%11111111
f0f     LD (HL),A
        INC L
        DJNZ f0f
        POP HL
        JR Jp1

HEAD0D  PUSH HL
        LD HL,(xyprn)
        INC H
        INC H
        INC H
        INC H
        CALL pr_52
        LD HL,F0D
        LD (OBROB+1),HL
        JR ZZ

F0D     PUSH HL
        LD HL,(xyprn)
        CALL pr_52
ZZ      LD HL,(xyprn)
        LD A,H
        ADD A,7
        LD H,A
        CALL INC_Y
        LD (xyprn),HL
        POP HL
        JR Jp1

