2013-10-20 20:47:47 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2024-02-23 17:55:00 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
|
2013-10-20 20:47:47 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
2013-11-01 15:02:08 +01:00
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
2013-10-20 20:47:47 +02:00
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
2016-01-02 22:03:09 +01:00
|
|
|
text_insert_newlines: ; esi = ASCIIZ string
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
xor edx, edx ; number of lines of text
|
|
|
|
cmp byte[esi], 0
|
|
|
|
je .done
|
2013-11-01 15:02:08 +01:00
|
|
|
.next_line:
|
2016-01-01 22:01:59 +01:00
|
|
|
xor ebx, ebx
|
|
|
|
mov ecx, [textbox_width]
|
|
|
|
inc ecx
|
2013-11-01 15:02:08 +01:00
|
|
|
.more:
|
2016-01-01 22:01:59 +01:00
|
|
|
dec ecx
|
|
|
|
jz .end_of_line
|
2016-10-15 15:44:06 +02:00
|
|
|
.next_byte:
|
2016-01-01 22:01:59 +01:00
|
|
|
lodsb ; get one character of the string
|
|
|
|
test al, al ; end of string?
|
|
|
|
jz .almost_done
|
|
|
|
cmp al, ' ' ; it's a space! remember its position
|
|
|
|
je .space
|
|
|
|
cmp al, 13 ; we already inserted a newline once, make it a space again
|
|
|
|
je .soft_nl
|
|
|
|
cmp al, 10 ; it's a newline, continue onto the next line
|
2016-10-15 15:44:06 +02:00
|
|
|
je .newline
|
|
|
|
and al, 0xc0 ; Is it a multi byte UTF8 char?
|
|
|
|
cmp al, 0x80
|
|
|
|
je .next_byte
|
|
|
|
jmp .more
|
|
|
|
.newline:
|
2016-01-01 22:01:59 +01:00
|
|
|
inc edx
|
|
|
|
jmp .next_line
|
2013-11-01 15:02:08 +01:00
|
|
|
.soft_nl:
|
2016-01-01 22:01:59 +01:00
|
|
|
mov byte[esi-1], ' '
|
2013-11-01 15:02:08 +01:00
|
|
|
.space:
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ebx, esi ; last detected space
|
|
|
|
jmp .more
|
2013-11-01 15:02:08 +01:00
|
|
|
.end_of_line:
|
2016-01-01 22:01:59 +01:00
|
|
|
inc edx
|
|
|
|
test ebx, ebx ; did we detect any spaces on this line?
|
|
|
|
jz .next_line ; no: just continue onto the next line
|
|
|
|
mov byte[ebx-1], 13 ; yes: replace last space on line with a soft newline
|
|
|
|
mov esi, ebx ; and continue parsing just after last space
|
|
|
|
jmp .next_line ;
|
2013-11-01 15:02:08 +01:00
|
|
|
.almost_done:
|
2016-01-01 22:01:59 +01:00
|
|
|
dec esi
|
2013-11-01 15:02:08 +01:00
|
|
|
.done:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
ret
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-02 22:03:09 +01:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
;----------------------------------
|
|
|
|
; scan untill next line is reached
|
|
|
|
;
|
2013-11-01 15:02:08 +01:00
|
|
|
; When you set the direction flag before calling, you can also scan for previous line!
|
2014-03-09 22:57:21 +01:00
|
|
|
; IN: esi
|
|
|
|
; OUT: esi
|
|
|
|
;----------------------------------
|
2013-11-01 15:02:08 +01:00
|
|
|
text_nextline:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ecx, [textbox_width]
|
2013-11-01 15:02:08 +01:00
|
|
|
.loop:
|
2016-01-01 22:01:59 +01:00
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .done
|
|
|
|
cmp al, 10
|
|
|
|
je .done
|
|
|
|
cmp al, 13
|
|
|
|
je .done
|
2016-10-15 15:44:06 +02:00
|
|
|
and al, 0xc0
|
|
|
|
cmp al, 0x80
|
|
|
|
je .loop ; This byte is the second, third or fourth byte of a multi-byte UTF8 char
|
2016-01-01 22:01:59 +01:00
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
2013-11-01 15:02:08 +01:00
|
|
|
.done:
|
2016-01-01 22:01:59 +01:00
|
|
|
ret
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
;----------------------------------
|
|
|
|
; print string
|
|
|
|
;
|
|
|
|
; IN: esi = ptr to string
|
|
|
|
; bl = char which marks end of string
|
|
|
|
; OUT: esi = ptr to end of str
|
|
|
|
;----------------------------------
|
|
|
|
print_string:
|
2013-10-20 20:47:47 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push eax
|
2014-03-09 22:57:21 +01:00
|
|
|
.loop:
|
2016-01-01 22:01:59 +01:00
|
|
|
lodsb
|
|
|
|
cmp al, bl
|
|
|
|
je .done
|
|
|
|
cmp al, 13
|
|
|
|
je .loop
|
|
|
|
test al, al
|
|
|
|
jz .done
|
|
|
|
call print_char
|
|
|
|
jmp .loop
|
2013-10-20 20:47:47 +02:00
|
|
|
.done:
|
2016-01-01 22:01:59 +01:00
|
|
|
pop eax
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
ret
|
2013-10-20 20:47:47 +02:00
|
|
|
|
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
;----------------------------------
|
|
|
|
; print ASCIIZ string
|
|
|
|
;
|
|
|
|
; IN: esi = ptr to ASCIIZ string
|
|
|
|
; OUT: esi = ptr to end of str
|
|
|
|
;----------------------------------
|
|
|
|
print_asciiz:
|
2013-10-20 20:47:47 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push eax
|
2013-10-20 20:47:47 +02:00
|
|
|
.loop:
|
2016-01-01 22:01:59 +01:00
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .done
|
|
|
|
call print_char
|
|
|
|
jmp .loop
|
2013-10-20 20:47:47 +02:00
|
|
|
.done:
|
2016-01-01 22:01:59 +01:00
|
|
|
pop eax
|
2013-10-20 20:47:47 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
ret
|
2013-10-20 20:47:47 +02:00
|
|
|
|
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
;----------------------------------
|
|
|
|
; print character
|
|
|
|
;
|
|
|
|
; IN: al = char to print
|
|
|
|
; OUT: /
|
|
|
|
;----------------------------------
|
|
|
|
print_char:
|
2013-10-20 20:47:47 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push esi edi
|
|
|
|
mov esi, [window_print]
|
|
|
|
mov edi, [esi + window.text_write]
|
|
|
|
stosb
|
|
|
|
cmp edi, [esi + window.text_end]
|
|
|
|
jae .uh_ow
|
|
|
|
mov [esi + window.text_write], edi
|
2013-11-01 15:02:08 +01:00
|
|
|
.continue:
|
2016-01-01 22:01:59 +01:00
|
|
|
or [esi + window.flags], FLAG_UPDATED
|
|
|
|
pop edi esi
|
2013-10-20 20:47:47 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
ret
|
2013-10-20 20:47:47 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
.uh_ow:
|
2016-01-01 22:01:59 +01:00
|
|
|
pusha
|
|
|
|
mov edi, [esi + window.text_start]
|
|
|
|
mov [esi + window.text_print], edi
|
|
|
|
lea esi, [edi + TEXT_BUFFERSIZE/2]
|
|
|
|
call text_nextline
|
|
|
|
mov ecx, TEXT_BUFFERSIZE/8
|
|
|
|
rep movsd
|
|
|
|
mov esi, edi
|
|
|
|
call text_insert_newlines
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ebx, [window_print]
|
|
|
|
mov [ebx + window.text_lines], edx
|
|
|
|
mov [ebx + window.text_scanned], esi
|
|
|
|
mov [ebx + window.text_write], esi
|
|
|
|
mov [ebx + window.text_line_print], 0
|
|
|
|
popa
|
2013-10-20 20:47:47 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
jmp .continue
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-26 18:18:14 +02:00
|
|
|
;-----------------------------------------------
|
|
|
|
; Draw text of the current window to the screen
|
|
|
|
;
|
|
|
|
; IN: /
|
|
|
|
; OUT: /
|
|
|
|
;-----------------------------------------------
|
2013-11-01 15:02:08 +01:00
|
|
|
draw_channel_text:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edi, [window_active]
|
|
|
|
and [edi + window.flags], not FLAG_UPDATED ; clear the 'window is updated' flag
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
; Scan new text for newlines
|
2016-01-01 22:01:59 +01:00
|
|
|
mov esi, [edi + window.text_scanned]
|
|
|
|
call text_insert_newlines
|
|
|
|
add [edi + window.text_lines], edx
|
|
|
|
mov [edi + window.text_scanned], esi
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2014-03-08 18:31:33 +01:00
|
|
|
; Is scrollbar at lowest position?
|
2016-01-01 22:01:59 +01:00
|
|
|
test [edi + window.flags], FLAG_SCROLL_LOW
|
2016-01-02 22:03:09 +01:00
|
|
|
jnz .yesscroll ; Yes
|
|
|
|
cmp [scroll2.all_redraw], 1 ; No
|
2016-01-01 22:01:59 +01:00
|
|
|
jnz .noscroll
|
|
|
|
mov edx, [textbox_height]
|
|
|
|
add edx, [edi + window.text_line_print]
|
2014-04-13 12:19:01 +02:00
|
|
|
cmp edx, [edi + window.text_lines]
|
2016-01-01 22:01:59 +01:00
|
|
|
jl .noscroll
|
2014-03-08 18:31:33 +01:00
|
|
|
.yesscroll:
|
|
|
|
; Scrollbar was at lowest position, scroll down automatically when new text arrived.
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edx, [edi + window.text_lines]
|
|
|
|
sub edx, [textbox_height]
|
2016-01-26 01:43:09 +01:00
|
|
|
jg @f
|
|
|
|
mov [edi + window.text_line_print], 0
|
|
|
|
jmp .noscroll ; There are less lines of text than fit into the window, dont scroll..
|
|
|
|
@@:
|
2016-01-01 22:01:59 +01:00
|
|
|
sub edx, [edi + window.text_line_print]
|
|
|
|
je .noscroll ; We are already at the bottom pos, dont scroll..
|
|
|
|
.scroll_to_pos: ; edx = number of lines to go up/down (flags must indicate direction)
|
|
|
|
pushf
|
|
|
|
add [edi + window.text_line_print], edx
|
|
|
|
mov esi, [edi + window.text_print]
|
|
|
|
popf
|
2016-01-26 01:43:09 +01:00
|
|
|
jg .loop_forward
|
2016-01-01 22:01:59 +01:00
|
|
|
std ; set direction flag so we can scan backwards
|
|
|
|
dec esi
|
|
|
|
dec esi ; move our cursor just in front of newline, for scanning backwards
|
2013-11-01 15:02:08 +01:00
|
|
|
.loop_backward:
|
2016-01-01 22:01:59 +01:00
|
|
|
call text_nextline
|
|
|
|
inc edx
|
|
|
|
jnz .loop_backward
|
|
|
|
inc esi
|
|
|
|
inc esi ; move the cursor just after last newline
|
|
|
|
cld
|
|
|
|
jmp .ok
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
.loop_forward:
|
2016-01-01 22:01:59 +01:00
|
|
|
call text_nextline
|
|
|
|
dec edx
|
|
|
|
jnz .loop_forward
|
2013-11-01 15:02:08 +01:00
|
|
|
.ok:
|
2016-01-01 22:01:59 +01:00
|
|
|
mov [edi + window.text_print], esi
|
2013-11-01 15:02:08 +01:00
|
|
|
.noscroll:
|
|
|
|
|
2014-03-09 17:07:08 +01:00
|
|
|
; Update and draw scrollbar when nescessary
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edx, [edi + window.text_lines]
|
|
|
|
cmp edx, [textbox_height]
|
|
|
|
jbe .scroll_done
|
2014-03-09 17:07:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mov [scroll2.max_area], edx
|
|
|
|
mov eax, [edi + window.text_line_print]
|
|
|
|
mov [scroll2.position], eax
|
2014-03-09 17:07:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push dword scroll2 ; redraw scrollbar
|
|
|
|
call [scrollbar_draw]
|
|
|
|
mov [scroll2.all_redraw], 0 ; next time, dont redraw it completely
|
2014-03-09 17:07:08 +01:00
|
|
|
.scroll_done:
|
|
|
|
|
2014-03-08 18:31:33 +01:00
|
|
|
; Calculate start offset coordinates (align text to bottom)
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ebx, [textbox_height]
|
|
|
|
sub ebx, [edi + window.text_lines]
|
|
|
|
jb .no_offset
|
|
|
|
imul ebx, FONT_HEIGHT
|
|
|
|
push [edi + window.text_start]
|
|
|
|
pop [edi + window.text_print]
|
|
|
|
jmp .draw_text
|
2014-03-08 18:31:33 +01:00
|
|
|
.no_offset:
|
2016-01-01 22:01:59 +01:00
|
|
|
xor ebx, ebx
|
2014-03-08 18:31:33 +01:00
|
|
|
.draw_text:
|
2016-01-02 22:03:09 +01:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; Prepare to actually draw some text
|
2016-01-02 22:03:09 +01:00
|
|
|
add ebx, TEXT_X shl 16 + TEXT_Y ; text coordinates
|
|
|
|
mov ecx, [colors.work_text] ; default text color
|
|
|
|
or ecx, 0x30000000
|
|
|
|
mov edx, [edi + window.text_print] ; start of text to print
|
|
|
|
|
|
|
|
; Scan backwards on line for color escape codes
|
|
|
|
mov esi, edx
|
|
|
|
push edx
|
|
|
|
std
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
cmp al, 0 ; end of text
|
|
|
|
je @f
|
|
|
|
cmp al, 10 ; hard newline
|
|
|
|
je @f
|
|
|
|
cmp al, 3 ; mIRC escape code
|
|
|
|
jne @b
|
|
|
|
|
|
|
|
cld
|
|
|
|
lea edx, [esi+2]
|
|
|
|
call dec_to_esi
|
|
|
|
jz @f
|
|
|
|
mov ecx, [irc_colors + 4*esi]
|
|
|
|
or ecx, 0x30000000 ; UTF-8 text
|
|
|
|
|
|
|
|
cmp byte[edx], ',' ; background color?
|
|
|
|
jne @f
|
|
|
|
inc edx
|
|
|
|
call dec_to_esi
|
|
|
|
jz @f
|
|
|
|
mov edi, [irc_colors + 4*esi]
|
|
|
|
or ecx, 0x40000000 ; enable background color
|
|
|
|
@@:
|
|
|
|
cld
|
|
|
|
|
|
|
|
pop edx
|
|
|
|
mov eax, [textbox_height] ; max number of lines to draw
|
2013-10-20 20:47:47 +02:00
|
|
|
.drawloop:
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp byte[edx], 0
|
|
|
|
je .end_of_text
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
; Clear one row of characters
|
2016-01-01 22:01:59 +01:00
|
|
|
pusha
|
|
|
|
mov cx, bx
|
|
|
|
shl ecx, 16
|
|
|
|
mov cx, FONT_HEIGHT
|
|
|
|
mov ebx, TEXT_X shl 16
|
|
|
|
mov bx, word[textbox_width]
|
|
|
|
imul bx, FONT_WIDTH
|
|
|
|
mov edx, [colors.work]
|
2016-01-02 22:03:09 +01:00
|
|
|
mcall 13 ; draw rectangle
|
2016-01-01 22:01:59 +01:00
|
|
|
popa
|
|
|
|
|
2016-01-02 22:03:09 +01:00
|
|
|
push eax
|
2013-11-01 15:02:08 +01:00
|
|
|
.line:
|
2024-02-23 17:55:00 +01:00
|
|
|
cmp byte[edx], 0x20
|
|
|
|
jae .printable
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp byte[edx], 0
|
|
|
|
je .end_of_text
|
|
|
|
cmp byte[edx], 13
|
|
|
|
je .newline_soft
|
|
|
|
cmp byte[edx], 10
|
|
|
|
je .newline_hard
|
|
|
|
|
2016-01-02 22:03:09 +01:00
|
|
|
cmp byte[edx], 3 ; escape code for mIRC colors
|
2016-01-01 22:01:59 +01:00
|
|
|
jne .no_colors
|
|
|
|
inc edx
|
|
|
|
call dec_to_esi
|
2024-02-23 17:55:00 +01:00
|
|
|
jz .line
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ecx, [irc_colors + 4*esi]
|
2016-01-02 22:03:09 +01:00
|
|
|
or ecx, 0x30000000
|
2016-01-01 22:01:59 +01:00
|
|
|
|
2016-01-02 22:03:09 +01:00
|
|
|
cmp byte[edx], ',' ; background color?
|
2024-02-23 17:55:00 +01:00
|
|
|
jne .line
|
2016-01-01 22:01:59 +01:00
|
|
|
inc edx
|
|
|
|
call dec_to_esi
|
2024-02-23 17:55:00 +01:00
|
|
|
jz .line
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edi, [irc_colors + 4*esi]
|
|
|
|
or ecx, 0x40000000
|
2013-11-01 15:02:08 +01:00
|
|
|
.no_colors:
|
2013-10-20 20:47:47 +02:00
|
|
|
|
2024-02-23 17:55:00 +01:00
|
|
|
; Some non-printable, just skip it
|
|
|
|
inc edx
|
|
|
|
jmp .line
|
|
|
|
|
2021-07-26 18:18:14 +02:00
|
|
|
;-------------------------------------------
|
|
|
|
; Count characters until 0, 10, 13 or 3 byte
|
2016-01-02 22:03:09 +01:00
|
|
|
|
2024-02-23 17:55:00 +01:00
|
|
|
.printable:
|
2021-07-26 18:18:14 +02:00
|
|
|
push edx
|
|
|
|
xor esi, esi
|
|
|
|
dec esi
|
|
|
|
.next_char:
|
|
|
|
inc esi
|
|
|
|
cmp esi, [textbox_width]
|
|
|
|
je .cnt_done
|
2016-01-02 22:03:09 +01:00
|
|
|
mov al, byte[edx]
|
2024-02-23 17:55:00 +01:00
|
|
|
cmp al, 0x20
|
|
|
|
jb .cnt_done
|
2021-07-26 18:18:14 +02:00
|
|
|
|
|
|
|
inc edx
|
2016-01-02 22:03:09 +01:00
|
|
|
test al, 10000000b
|
2021-07-26 18:18:14 +02:00
|
|
|
jz .next_char ; 1 byte wide
|
|
|
|
|
2022-05-31 20:31:22 +02:00
|
|
|
add edx, 3
|
2016-01-02 22:03:09 +01:00
|
|
|
and al, 11111000b
|
|
|
|
cmp al, 11110000b
|
2021-07-26 18:18:14 +02:00
|
|
|
je .next_char ; 4 bytes wide
|
|
|
|
|
|
|
|
dec edx
|
2016-01-02 22:03:09 +01:00
|
|
|
and al, 11110000b
|
|
|
|
cmp al, 11100000b
|
2021-07-26 18:18:14 +02:00
|
|
|
je .next_char ; 3 bytes wide
|
|
|
|
dec edx ; 2 bytes wide
|
|
|
|
jmp .next_char
|
|
|
|
.cnt_done:
|
|
|
|
mov eax, edx
|
|
|
|
pop edx
|
|
|
|
push eax
|
|
|
|
mcall 4 ; draw text
|
|
|
|
pop edx ; next start ptr
|
|
|
|
|
|
|
|
cmp esi, [textbox_width]
|
|
|
|
je .line_full
|
|
|
|
imul esi, FONT_WIDTH shl 16
|
|
|
|
add ebx, esi
|
|
|
|
jmp .line
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
.newline_hard:
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ecx, [colors.work_text]
|
2016-01-02 22:03:09 +01:00
|
|
|
or ecx, 0x30000000
|
2013-11-01 15:02:08 +01:00
|
|
|
.newline_soft:
|
2016-01-01 22:01:59 +01:00
|
|
|
inc edx
|
2013-11-01 15:02:08 +01:00
|
|
|
.line_full:
|
2016-01-01 22:01:59 +01:00
|
|
|
and ebx, 0x0000ffff
|
|
|
|
add ebx, TEXT_X shl 16 + FONT_HEIGHT
|
2016-01-02 22:03:09 +01:00
|
|
|
pop eax
|
2016-01-01 22:01:59 +01:00
|
|
|
dec eax
|
|
|
|
jnz .drawloop
|
2014-03-08 18:31:33 +01:00
|
|
|
.end_of_text:
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
ret
|
2013-10-20 20:47:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
dec_to_esi:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
xor esi, esi
|
2013-11-01 15:02:08 +01:00
|
|
|
.loop:
|
2016-01-01 22:01:59 +01:00
|
|
|
movzx eax, byte[edx]
|
|
|
|
sub al, '0'
|
|
|
|
jb .done
|
|
|
|
cmp al, 9
|
|
|
|
ja .done
|
|
|
|
inc edx
|
|
|
|
lea esi, [esi*4 + esi] ; esi * 5
|
|
|
|
lea esi, [esi*2 + eax] ; esi * 2 + eax
|
|
|
|
jmp .loop
|
2013-11-01 15:02:08 +01:00
|
|
|
.done:
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp esi, 16
|
|
|
|
jae .fail
|
|
|
|
ret
|
2013-10-20 20:47:47 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
.fail:
|
2016-01-01 22:01:59 +01:00
|
|
|
xor esi, esi
|
|
|
|
ret
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
print_timestamp:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
pusha
|
|
|
|
mcall 3 ; get system time
|
|
|
|
mov ebx, eax
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mov al, '['
|
|
|
|
call print_char
|
|
|
|
mov ecx, TIMESTAMP
|
2013-11-01 15:02:08 +01:00
|
|
|
.loop:
|
2016-01-01 22:01:59 +01:00
|
|
|
mov al, bl
|
|
|
|
shr al, 4
|
|
|
|
add al, '0'
|
|
|
|
call print_char
|
|
|
|
|
|
|
|
mov al, bl
|
|
|
|
and al, 0x0f
|
|
|
|
add al, '0'
|
|
|
|
call print_char
|
|
|
|
|
|
|
|
dec ecx
|
|
|
|
jz .done
|
|
|
|
|
|
|
|
mov al, ':'
|
|
|
|
call print_char
|
|
|
|
shr ebx, 8
|
|
|
|
jmp .loop
|
2013-11-01 15:02:08 +01:00
|
|
|
.done:
|
2016-01-01 22:01:59 +01:00
|
|
|
mov al, ']'
|
|
|
|
call print_char
|
|
|
|
mov al, ' '
|
|
|
|
call print_char
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
popa
|
|
|
|
ret
|
2013-11-01 15:02:08 +01:00
|
|
|
end if
|