;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
;
; Counting Timer Routine
;
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北

;120*13

        public  puttimer
        public  dectimer

        tc1     db      0
        tc2     db      0
        tc3     db      0
        tc4     db      0
        tc5     db      1
        tc6     db      0
        timerc  db      0

dectimer:
        cmp     tc1,0
        je      nn1
        dec     tc1
        jmp     endit
nn1:    mov     tc1,9
        cmp     tc2,0
        je      nn2
        dec     tc2
        jmp     endit
nn2:    mov     tc2,9
        cmp     tc3,0
        je      nn3
        dec     tc3
        jmp     endit
nn3:    mov     tc3,9
        cmp     tc4,0
        je      nn4
        dec     tc4
        jmp     endit
nn4:    mov     tc4,9
        cmp     tc5,0
        je      nn5
        dec     tc5
        jmp     endit
nn5:    mov     tc5,9
        cmp     tc6,0
        je      nn6
        dec     tc6
        jmp     endit
nn6:    mov     tc6,9
endit:  ret

puttimer:
        mov     edi,[esp+4]
        mov     eax,[esp+8]
        mov     timerc,al
        add     edi,320*175+25
        lea     esi,numbers
        mov     eax,0
        mov     ebp,0
        mov     al,tc6
        imul    eax,12
        call    putnumber      
        mov     eax,0
        mov     ebp,11*1
        mov     al,tc5
        imul    eax,12
        call    putnumber
        mov     eax,10
        mov     ebp,11*2
        imul    eax,12
        call    putnumber
        mov     eax,0
        mov     ebp,11*3  - 5
        mov     al,tc4
        imul    eax,12
        call    putnumber
        mov     eax,0
        mov     ebp,11*4  - 5
        mov     al,tc3
        imul    eax,12
        call    putnumber
        mov     eax,10
        mov     ebp,11*5  - 5
        imul    eax,12
        call    putnumber
        mov     eax,0
        mov     ebp,11*6  - 5 - 5
        mov     al,tc2
        imul    eax,12
        call    putnumber
        mov     eax,0
        mov     ebp,11*7  - 5 - 5
        mov     al,tc1
        imul    eax,12
        call    putnumber
        ret

putnumber:
        mov     bl,timerc
        mov     edx,13
ptloop0:mov     ecx,12
ptloop1:cmp     byte ptr [esi+eax],255
        jne     noput
        mov     byte ptr [edi+ebp],bl
noput:  inc     eax
        inc     ebp
        dec     ecx
        jnz     ptloop1
        add     eax,132-12
        add     ebp,320-12
        dec     edx
        jnz     ptloop0
        ret

        include asm\chinese.inc
