; part of the GUI for BGE for version 3.12


; HL <- адрес строчки
; HL -> значение ,флаг c - ошибка

ASCII_gui   ; Convertion from ASCII to DEC number in HL
        push de
        push bc
        dec hl
1        inc hl
         ld a,(hl)
         cp " "
        jr z,1B
         call .conve_
         pop bc
         pop de
         ld hl,0
        ret c
         ld hl,(.sum)
        ret


.conve_
         ld b,5
2        ld a,(hl)
         cp "0"
        jr c,3F
         cp "0"+10
        jr nc,3F
         inc hl
        djnz 2B

3        dec hl
         ld a,5
         sub b
         ld c,a
         scf
        ret z

         ld a,(hl)
         sub "0"
         dec hl
         ld e,a
         ld d,0
         ld (.sum),de
         dec c
        ret z
         ld e,10
         call .con_
         ld e,100
         call .con_
         ld de,1000
         call .con_
        ld de,10000
         call .con_
        ret

.con_     ld a,(hl)
          dec hl
          sub "0"
         jr z,4F
          ld b,a
          push hl
          ld hl,0
.sum   EQU $-2
1         add hl,de
         djnz 1B
3         ld (.sum),hl
          pop hl
4         dec c
         ret nz
          pop af   ; удаляем адрес возврата
          or a
         ret









