; part of the GUI for BGE


; HL <- адрес строчки
; HL -> значение

ASCII_gui
        PUSH HL
        PUSH HL
        XOR A
        LD DE,#FFFF
        CPIR 
        DEC HL
        POP DE
        SBC HL,DE
        LD A,L
        LD (ln_g),A

        POP HL
        LD B,0
        LD C,A
        ADD HL,BC
        DEC HL

        LD B,A
djnz1_  LD A,(HL)
        CP " "
        JR NZ,Ex1
        DEC HL
        LD A,0
ln_g    EQU $-1
        DEC A
        LD (ln_g),A
        DJNZ djnz1_

Ex1     PUSH HL
        POP IX

; Convertion from ASCII to DEC number in HL

        LD A,(IX+0)
        SUB "0"
        CP 10
        JP NC,scf_gui
        LD H,0
        LD L,A
        LD (sum),HL

        LD A,(ln_g)
        DEC A
        LD (ln_g),A
        AND A
        JP Z,ExiAS
        LD BC,10
        LD A,(IX-1)
        CP " "
        JP Z,ExiAS
        SUB "0"
        CP 10
        JP NC,scf_gui
        LD D,0
        LD E,A
        CALL MUL16
        LD DE,0
sum     EQU $-2
        ADD HL,DE
        LD (sum),HL

        LD A,(ln_g)
        DEC A
        LD (ln_g),A
        AND A
        JR Z,ExiAS
        LD BC,100
        LD A,(IX-2)
        CP " "
        JP Z,ExiAS
        SUB "0"
        CP 10
        JP NC,scf_gui
        LD D,0
        LD E,A
        CALL MUL16
        LD DE,(sum)
        ADD HL,DE
        LD (sum),HL

        LD A,(ln_g)
        DEC A
        LD (ln_g),A
        AND A
        JR Z,ExiAS
        LD BC,1000
        LD A,(IX-3)
        CP " "
        JP Z,ExiAS
        SUB "0"
        CP 10
        JP NC,scf_gui
        LD D,0
        LD E,A
        CALL MUL16
        LD DE,(sum)
        ADD HL,DE
        LD (sum),HL

        LD A,(ln_g)
        DEC A
        LD (ln_g),A
        AND A
        JR Z,ExiAS
        LD BC,10000
        LD A,(IX-4)
        CP " "
        JP Z,ExiAS
        SUB "0"
        CP 10
        JP NC,scf_gui
        LD D,0
        LD E,A
        CALL MUL16
        LD DE,(sum)
        ADD HL,DE
        LD (sum),HL
ExiAS   LD HL,(sum)
        XOR A
        RET 

