Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;-----------------------------------------------------------------------------
  2. ;                        Working with messages
  3. ; in: esi->ASCIIZ message
  4. PutMessageNoDraw:
  5.         mov     edx,[MessagesPos]
  6.     .M:
  7.         lea     edi,[Messages+edx]
  8.     .L:
  9.         lodsb
  10.         cmp     al,0
  11.         jz      .Done
  12.         call    TestScroll
  13.         cmp     al,10
  14.         jz      .NewLine
  15.         cmp     al,'%'
  16.         jnz     @F
  17.         cmp     dword [esp],Z1
  18.         jnz     .Format
  19.     @@:
  20.         stosb
  21.         inc     edx
  22.         jmp     .L
  23.  
  24.     .NewLine:
  25.         push    edx
  26.         mov     ecx,MSG_WIDTH
  27.         xor     eax,eax
  28.         xchg    eax,edx
  29.         div     ecx
  30.         xchg    eax,edx
  31.         pop     edx
  32.         test    eax,eax
  33.         jz      .M
  34.         sub     edx,eax
  35.         add     edx,ecx
  36.         jmp     .M
  37.  
  38.     .Done:
  39. if 0
  40.         cmp     byte [esi-2],10
  41.         jz      .Exit
  42.         call    TestScroll
  43. if 1
  44.         push    edx
  45.         mov     ecx,MSG_WIDTH
  46.         xor     eax,eax
  47.         xchg    eax,edx
  48.         div     ecx
  49.         xchg    eax,edx
  50.         pop     edx
  51.         test    eax,eax
  52.         jz      .Exit
  53.         sub     edx,eax
  54.         add     edx,ecx
  55. end if
  56. end if
  57.     .Exit:
  58.         mov     [MessagesPos],edx
  59.         ret
  60.  
  61.         ; at this moment all format specs must be %<digit>X
  62.     .Format:
  63.         lodsb   ; get <digit>
  64.         sub     al,'0'
  65.         movzx   ecx,al
  66.         lodsb
  67.         pop     eax
  68.         pop     ebp
  69.         push    eax
  70.         ; write number in ebp with ecx digits
  71.         dec     ecx
  72.         shl     ecx,2
  73.  
  74.     .WriteNibble:
  75.         push    ecx
  76.         call    TestScroll
  77.         pop     ecx
  78.         mov     eax,ebp
  79.         shr     eax,cl
  80.         and     al,0xF
  81.         cmp     al,10
  82.         sbb     al,69h
  83.         das
  84.         stosb
  85.         inc     edx
  86.         sub     ecx,4
  87.         jns     .WriteNibble
  88.         jmp     .L
  89.  
  90. TestScroll:
  91.         cmp     edx,MSG_WIDTH*MSG_HEIGHT
  92.         jnz     .Ret
  93.         push    esi
  94.         mov     edi,Messages
  95.         lea     esi,[edi+MSG_WIDTH]
  96.         mov     ecx,(MSG_HEIGHT-1)*MSG_WIDTH/4
  97.         rep     movsd
  98.         push    eax
  99.         mov     al,' '
  100.         push    edi
  101.         push    MSG_WIDTH
  102.         pop     ecx
  103.         sub     edx,ecx
  104.         rep     stosb
  105.         pop     edi
  106.         pop     eax
  107.         pop     esi
  108.     .Ret:
  109.         ret
  110.  
  111. MSG_WIDTH               = DATA_WIDTH
  112. MSG_HEIGHT              = 14                    ; in text lines
  113.  
  114. NewLine db      10,0
  115. Prompt  db      '> ',0
  116.  
  117. uglobal
  118. MessagesPos     dd ?
  119. Messages        rb MSG_HEIGHT*MSG_WIDTH
  120. endg