Board: text scroll fix

git-svn-id: svn://kolibrios.org@5925 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2015-11-22 01:06:00 +00:00
parent c4763a7d71
commit 025c153c07

View File

@ -3,45 +3,46 @@
; See f63 ; See f63
; Compile with FASM for KolibriOS ; Compile with FASM for KolibriOS
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
include 'lang.inc' use32
WRITE_LOG equ 1 org 0
P_LEN equ 11
;------------------------------------------------------------------------------
use32
org 0x0
db 'MENUET01' db 'MENUET01'
dd 0x01 dd 1
dd START dd START
dd I_END dd I_END
dd mem dd mem
dd mem dd mem
dd filename, 0x0 dd filename
dd 0
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
include 'lang.inc'
include '../../../macros.inc' include '../../../macros.inc'
include '../../../debug.inc' include '../../../debug.inc'
purge newline purge newline
MAXSTRINGS = 45 MAXSTRINGS = 45
TMP = 80*(MAXSTRINGS+1)
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
START: START:
call CheckUnique call CheckUnique
mov edi, filename mov edi, filename
cmp [edi], byte 0 cmp [edi], byte 0
jnz param jnz param
mov esi, default_filename mov esi, default_filename
@@: @@:
lodsb lodsb
stosb stosb
test al,al test al,al
jnz @b jnz @b
param: param:
mov ecx, TMP mov ecx, (MAXSTRINGS+1)*20
xor eax, eax mov edi, text1
mov edi, [targ] mov eax, ' '
rep stosb rep stosd
mov [tmp1], 'x' mov ecx, (MAXSTRINGS+1)*20
mov [tmp2], 'x' mov edi, text2
rep stosd
mov byte [tmp1], 'x'
mov byte [tmp2], 'x'
mcall 14 mcall 14
and eax, 0xffff0000 and eax, 0xffff0000
@ -54,13 +55,13 @@ TMP = 80*(MAXSTRINGS+1)
call CreateFile call CreateFile
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
red: red:
call draw_window call draw_window
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
still: still:
cmp [buffer_length], 0 cmp [buffer_length], 0
je @f je @f
call write_buffer call write_buffer
@@: @@:
mcall 23, 50 ; wait here for event mcall 23, 50 ; wait here for event
cmp eax, 1 ; redraw request ? cmp eax, 1 ; redraw request ?
je red je red
@ -79,23 +80,23 @@ new_data:
cmp [buffer_length], 255 cmp [buffer_length], 255
jne @f jne @f
call write_buffer call write_buffer
@@: @@:
movzx ebx, byte[buffer_length] movzx ebx, byte[buffer_length]
mov [ebx+tmp], al mov [ebx+tmp], al
inc [buffer_length] inc [buffer_length]
mov ebp, [targ] mov ebp, [targ]
.no4: cmp al, 10
jz new_line
cmp al, 13 cmp al, 13
jne no13 jz new_check
and [ebp-8], dword 0 jmp char
jmp new_check
;------------------------------------------ ;------------------------------------------
write_buffer: write_buffer:
pusha pusha
mov edx, tmp mov edx, tmp
movzx ecx, byte[buffer_length] ;1 movzx ecx, byte[buffer_length]
mov esi, filename mov esi, filename
.write_to_logfile: .write_to_logfile:
call WriteToFile call WriteToFile
cmp eax, 5 cmp eax, 5
jne @f jne @f
@ -111,9 +112,7 @@ write_buffer:
popa popa
ret ret
;------------------------------------------ ;------------------------------------------
no13: new_line:
cmp al, 10
jne no10
and [ebp-8], dword 0 and [ebp-8], dword 0
inc dword [ebp-4] inc dword [ebp-4]
cmp [ebp-4], dword MAXSTRINGS cmp [ebp-4], dword MAXSTRINGS
@ -121,23 +120,23 @@ no13:
mov [ebp-4], dword MAXSTRINGS mov [ebp-4], dword MAXSTRINGS
lea esi, [ebp+80] lea esi, [ebp+80]
mov edi, ebp mov edi, ebp
mov ecx, 80*(MAXSTRINGS) mov ecx, 20*(MAXSTRINGS)
cld cld
rep movsb rep movsd
mov esi, [ebp-4] mov esi, [ebp-4]
imul esi, 80 imul esi, 80
add esi, [ebp-8] add esi, [ebp-8]
add esi, ebp add esi, ebp
mov ecx, 80 mov ecx, 20
mov al ,' ' mov eax, ' '
rep stosb rep stosd
.noypos: .noypos:
mov [targ],text2 mov [targ],text2
and [krnl_cnt],0 and [krnl_cnt],0
jmp new_check jmp new_check
;------------------------------------------ ;------------------------------------------
no10: char:
cmp ebp, text1 cmp ebp, text1
je add2 je add2
mov ecx, [krnl_cnt] mov ecx, [krnl_cnt]
@ -147,17 +146,17 @@ no10:
cmp [krnl_cnt], 4 cmp [krnl_cnt], 4
jne new_check jne new_check
mov [targ], text1 mov [targ], text1
.noknl: .noknl:
mov ebp, [targ] mov ebp, [targ]
jecxz .add jecxz .add
push eax push eax
mov esi, krnl_msg mov esi, krnl_msg
.l1: .l1:
lodsb lodsb
call add_char call add_char
loop .l1 loop .l1
pop eax pop eax
.add: .add:
and [krnl_cnt], 0 and [krnl_cnt], 0
add2: add2:
call add_char call add_char
@ -181,7 +180,7 @@ button:
jne .noclose jne .noclose
or eax, -1 ; close this program or eax, -1 ; close this program
mcall mcall
.noclose: .noclose:
xor [vmode], 1 xor [vmode], 1
jmp red jmp red
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -198,7 +197,7 @@ add_char:
.ok: .ok:
pop esi pop esi
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
;************************ WINDOW DEFINITIONS AND DRAW ************************ ;************************ WINDOW DEFINITIONS AND DRAW ************************
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -218,9 +217,9 @@ draw_window:
mcall 8,,<4,13>,3,[sc.btn_face] mcall 8,,<4,13>,3,[sc.btn_face]
mov edx, [vmode] mov edx, [vmode]
lea edx, [edx*4+duk] lea edx, [edx*4+duk]
mov ecx, 0x80 mov ecx, 0x80
shr ecx, 24 shr ecx, 24
add ecx, [sc.btn_text] add ecx, [sc.btn_text]
mcall 4,<300,7>,,,4 mcall 4,<300,7>,,,4
call draw_text call draw_text
mcall 12, 2 ; 2, end of draw mcall 12, 2 ; 2, end of draw
@ -235,7 +234,7 @@ draw_text:
cmp [vmode], 0 cmp [vmode], 0
je .kern je .kern
mov edx, text2 mov edx, text2
.kern: .kern:
push ebx ecx edx push ebx ecx edx
mcall 9, procinfo,-1 mcall 9, procinfo,-1
mov eax, [ebx+42] mov eax, [ebx+42]
@ -278,7 +277,7 @@ CreateFile:
test eax, eax test eax, eax
jz .out jz .out
stc stc
.out: .out:
popa popa
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -301,8 +300,8 @@ WriteToFile:
test eax, eax test eax, eax
jz .out jz .out
stc stc
.out: .out:
pop ebx pop ebx
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -314,15 +313,15 @@ StrCmp:
repe cmpsb repe cmpsb
ja .a_greater_b ja .a_greater_b
jb .a_less_b jb .a_less_b
.equal: .equal:
mov eax, 0 mov eax, 0
jmp .end jmp .end
.a_less_b: .a_less_b:
mov eax, 1 mov eax, 1
jmp .end jmp .end
.a_greater_b: .a_greater_b:
mov eax, -1 mov eax, -1
.end: .end:
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -346,38 +345,38 @@ ToLower:
;* else continue normally ;* else continue normally
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
CheckUnique: CheckUnique:
.get_thread_info: .get_thread_info:
mov ebx, procinfo mov ebx, procinfo
mov ecx, -1 mov ecx, -1
mcall 9 mcall 9
.get_pid: ; check_buffer .get_pid: ; check_buffer
mov [process_count], eax mov [process_count], eax
mov eax, [ebx+process_information.PID] mov eax, [ebx+process_information.PID]
mov [pid_tid], eax mov [pid_tid], eax
mov ecx, 2 mov ecx, 2
.check_threads: .check_threads:
cmp ecx, [process_count] cmp ecx, [process_count]
ja .leave_check ja .leave_check
mov eax, 9 mov eax, 9
mcall mcall
.check_slot_free: .check_slot_free:
cmp dword [ebx+process_information.slot_state], 9 cmp dword [ebx+process_information.slot_state], 9
je .next_thread je .next_thread
.check_pid: .check_pid:
mov eax, [pid_tid] mov eax, [pid_tid]
cmp [ebx+process_information.PID], eax cmp [ebx+process_information.PID], eax
je .next_thread je .next_thread
.get_proc_name: .get_proc_name:
lea edi, [ebx+process_information.process_name] lea edi, [ebx+process_information.process_name]
push ecx push ecx
mov ecx, my_name_size-1 mov ecx, my_name_size-1
.lower_case: .lower_case:
call ToLower call ToLower
lea esi, [my_name] lea esi, [my_name]
mov ecx, my_name_size mov ecx, my_name_size
@ -386,35 +385,22 @@ CheckUnique:
cmp eax, 0 cmp eax, 0
je .close_program je .close_program
.next_thread: .next_thread:
inc ecx inc ecx
jmp .check_threads jmp .check_threads
.close_program: .close_program:
; restore and active window of previous thread ; restore and active window of previous thread
mcall 18, 3 mcall 18, 3
mov eax, -1 mov eax, -1
mcall mcall
.leave_check: .leave_check:
ret ret
;------------------------------------------------------------------------------
; DATA
;------------------------------------------------------------------------------
;*********************************** DATA ************************************
;------------------------------------------------------------------------------
align 4
InfoStructure:
dd 0x0 ; subfunction number
dd 0x0 ; position in the file in bytes
dd 0x0 ; upper part of the position address
dd 0x0 ; number of bytes to read
dd 0x0 ; pointer to the buffer to write data
db 0x0
dd 0x0 ; pointer to the filename
filepos dd 0x0
default_filename db '/sys/boardlog.txt',0
;------------------------------------------------------------------------------
if lang eq ru if lang eq ru
title db '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0 title db '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0
else if lang eq it else if lang eq it
@ -424,40 +410,46 @@ else if lang eq ge
else else
title db 'General debug & message board',0 title db 'General debug & message board',0
end if end if
;------------------------------------------------------------------------------
default_filename db '/sys/boardlog.txt',0
krnl_msg db 'K : ' krnl_msg db 'K : '
duk db 'KernUser' duk db 'KernUser'
krnl_cnt dd 0
vmode dd 1
targ dd text2
my_name db 'board',0 my_name db 'board',0
my_name_size = $-my_name my_name_size = $-my_name
process_count dd 0x0
pid_tid dd 0x0 align 4
;------------------------------------------------------------------------------ vmode dd 1
targ dd text2
I_END: I_END:
;------------------------------------------------------------------------------
offs dd ? InfoStructure:
flag rb 1 dd ? ; subfunction number
rd 2 dd ? ; position in the file in bytes
text1 rb 80*(MAXSTRINGS+1) dd ? ; upper part of the position address
tmp1 db ? dd ? ; number of bytes to read
rd 2 dd ? ; pointer to the buffer to write data
text2 rb 80*(MAXSTRINGS+1) db ?
tmp2 db ? dd ? ; pointer to the filename
buffer_length rb 3
process_count dd ?
krnl_cnt dd ?
pid_tid dd ?
filepos dd ?
xstart dd ? xstart dd ?
sc sys_colors_new sc sys_colors_new
i_end:
buffer_length rb 1 rd 2
;------------------------------------------------------------------------------ text1 rb 80*(MAXSTRINGS+1)
tmp1 dd ?
rd 2
text2 rb 80*(MAXSTRINGS+1)
tmp2 dd ?
tmp rb 256 tmp rb 256
filename rb 256 filename rb 256
;------------------------------------------------------------------------------ procinfo rb 1024
align 4
procinfo:
rb 1024
;------------------------------------------------------------------------------
align 4
stackbuf rb 2000h stackbuf rb 2000h
;------------------------------------------------------------------------------ mem:
mem: