1) Optimize redrawing
2) Clearing of source code

git-svn-id: svn://kolibrios.org@2234 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2011-09-23 04:14:41 +00:00
parent 132b516d92
commit 63531bfca1
4 changed files with 283 additions and 292 deletions

View File

@ -23,272 +23,254 @@ include 'debug.inc'
purge newline purge newline
MAXSTRINGS = 16 MAXSTRINGS = 16
TMP = 80*(MAXSTRINGS+1) TMP = 80*(MAXSTRINGS+1)
;------------------------------------------------------------------------------
START: ; start of execution START: ; start of execution
mov edi, filename mov edi,filename
cmp byte [edi], 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:
; allow user to see messages written before start ; allow user to see messages written before start
; mov ecx,4096 ; mov ecx,4096
; flush: ;flush:
; mov eax,63 ; mcall 63,2
; mov ebx,2 ; loop flush
; mcall
; loop flush mov ecx,TMP
xor eax,eax
mov ecx, TMP mov edi,[targ]
xor eax, eax rep stosb
mov edi, [targ]
rep stosb
mov [tmp1],'x'
mov [tmp2],'x'
mov eax,14
mcall
and eax,0xffff0000
sub eax,399 shl 16
add eax,399
mov [xstart],eax
mov eax,48
mov ebx,3
mov ecx,sc
mov edx,sizeof.system_colors
mcall
if WRITE_LOG
mov esi, filename
call CreateFile
end if
red:
call draw_window
mov [tmp1],'x'
mov [tmp2],'x'
mcall 14
and eax,0xffff0000
sub eax,399 shl 16
add eax,399
mov [xstart],eax
mcall 48,3,sc,sizeof.system_colors
if WRITE_LOG
mov esi,filename
call CreateFile
end if
;------------------------------------------------------------------------------
red:
call draw_window
;------------------------------------------------------------------------------
still: still:
mcall 23,1 ; wait here for event
cmp eax,1 ; redraw request ?
je red
mov eax,23 ; wait here for event cmp eax,2 ; key in buffer ?
mov ebx,1 je key
mcall
cmp eax,1 ; redraw request ? cmp eax,3 ; button in buffer ?
je red je button
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
mov eax,63 mcall 63,2
mov ebx,2 cmp ebx,1
mcall jne still
cmp ebx,1 new_data:
jne still if WRITE_LOG
pusha
mov [tmp],al
mov edx,tmp
mov ecx,1
mov esi,filename
.write_to_logfile:
call WriteToFile
cmp eax,5
jne @f
mov esi,filename
mov [filepos],0
call CreateFile
jnc .write_to_logfile
@@:
inc [filepos]
popa
end if
mov ebp,[targ]
.no4:
cmp al,13
jne no13
and [ebp-8],dword 0
jmp new_check
;------------------------------------------
no13:
cmp al,10
jne no10
and [ebp-8],dword 0
inc dword [ebp-4]
cmp [ebp-4],dword MAXSTRINGS
jbe .noypos
mov [ebp-4],dword MAXSTRINGS
lea esi,[ebp+80]
mov edi,ebp
mov ecx,80*(MAXSTRINGS)
cld
rep movsb
new_data: mov esi,[ebp-4]
if WRITE_LOG imul esi,80
pusha add esi,[ebp-8]
mov [tmp], al add esi,ebp
mov edx, tmp mov ecx,80
mov ecx, 1 xor al,al
mov esi, filename rep stosb
.write_to_logfile: .noypos:
call WriteToFile mov [targ],text2
cmp eax, 5 and [krnl_cnt],0
jne @f jmp new_check
mov esi, filename ;------------------------------------------
mov [filepos], 0 no10:
call CreateFile cmp ebp,text1
jnc .write_to_logfile je add2
@@: mov ecx,[krnl_cnt]
inc [filepos] cmp al,[krnl_msg+ecx]
popa jne .noknl
end if inc [krnl_cnt]
cmp [krnl_cnt],4
mov ebp,[targ] jne new_check
.no4: mov [targ],text1
cmp al,13 .noknl:
jne no13 mov ebp,[targ]
and dword[ebp-8],0 jecxz .add
jmp new_check push eax
no13: mov esi,krnl_msg
cmp al,10 .l1:
jne no10 lodsb
and dword[ebp-8],0 call add_char
inc dword[ebp-4] loop .l1
cmp dword[ebp-4],MAXSTRINGS pop eax
jbe .noypos .add:
mov dword[ebp-4],MAXSTRINGS and [krnl_cnt],0
lea esi,[ebp+80] add2:
mov edi,ebp call add_char
mov ecx,80*(MAXSTRINGS)
cld
rep movsb
mov esi,[ebp-4]
imul esi,80
add esi,[ebp-8]
add esi,ebp
mov ecx,80
xor al,al
rep stosb
.noypos:
mov [targ],text2
and [krnl_cnt],0
jmp new_check
no10:
cmp ebp,text1
je add2
mov ecx,[krnl_cnt]
cmp al,[krnl_msg+ecx]
jne .noknl
inc [krnl_cnt]
cmp [krnl_cnt],4
jne new_check
mov [targ],text1
.noknl:
mov ebp,[targ]
jecxz .add
push eax
mov esi,krnl_msg
.l1:
lodsb
call add_char
loop .l1
pop eax
.add:
and [krnl_cnt],0
add2:
call add_char
new_check:
mov eax,63
mov ebx,2
mcall
cmp ebx,1
je new_data
call draw_window
jmp still
key: ; key
mov al,2 ; just read it and ignore
mcall
cmp ah,' '
je button.noclose
jmp still
button: ; button
mov al,17 ; get id
mcall
cmp ah,1 ; button id=1 ?
jne .noclose
or eax,-1 ; close this program
mcall
.noclose:
xor [vmode],1
jmp red
new_check:
mcall 63,2
cmp ebx,1
je new_data
call draw_text
jmp still
;------------------------------------------------------------------------------
key:
mcall 2
cmp ah,' '
je button.noclose
jmp still
;------------------------------------------------------------------------------
button:
mcall 17 ; get id
cmp ah,1 ; button id=1 ?
jne .noclose
or eax,-1 ; close this program
mcall
.noclose:
xor [vmode],1
jmp red
;------------------------------------------------------------------------------
add_char: add_char:
push esi push esi
mov esi,[ebp-4] mov esi,[ebp-4]
imul esi,80 imul esi,80
add esi,[ebp-8] add esi,[ebp-8]
mov [ebp+esi],al mov [ebp+esi],al
inc dword[ebp-8] inc dword[ebp-8]
cmp dword[ebp-8],80 cmp dword[ebp-8],80
jb .ok jb .ok
mov dword[ebp-8],79 mov dword[ebp-8],79
.ok: .ok:
pop esi pop esi
ret ret
;------------------------------------------------------------------------------
; ********************************************* ; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ******** ; ******* WINDOW DEFINITIONS AND DRAW ********
; ********************************************* ; *********************************************
draw_window: draw_window:
mcall 12,1 ; 1, start of draw
mov eax,12 ; function 12:tell os about windowdraw xor eax,eax ; function 0 : define and draw window
mov ebx,1 ; 1, start of draw mov ecx,MAXSTRINGS*10+45 ; [y start] *65536 + [y size]
mcall mov edx,[sc.work] ; color of work area RRGGBB,8->color gl
or edx,0x13000000
; DRAW WINDOW xor esi,esi
xor eax,eax ; function 0 : define and draw window mcall ,[xstart],,,,title
; mov ebx,50*65536+400 ; [x start] *65536 + [x size] mov ebx,296 shl 16+5*6
mov ebx,[xstart] mcall 8,,<5,12>,3,[sc.work]
mov ecx,MAXSTRINGS*10+45 ; [y start] *65536 + [y size] mov edx,[vmode]
mov edx,[sc.work] ; color of work area RRGGBB,8->color gl lea edx,[edx*4+duk]
or edx,0x13000000 mcall 4,<300,8>,,,4
mov edi,title ; WINDOW LABEL call draw_text
mcall mcall 12,2 ; 2, end of draw
ret
mov ecx,4 ;------------------------------------------------------------------------------
mov esi,[sc.work] draw_text:
mov ebx,296 shl 16+5*6 mov ebx,15*65536+30 ; draw info text with function 4
mov edx,3;+1 shl 30 mov ecx,[sc.work_text]
mcall 8,,<5,12> or ecx,0x40000000
mov edx,[vmode] mov edi,[sc.work]
lea edx,[edx*4+duk] mov edx,text1
mcall 4,<300,8>,,,4 cmp [vmode],0
je .kern
mov ebx,15*65536+33 ; draw info text with function 4 mov edx,text2
mov ecx,[sc.work_text] .kern:
mov edx,text1 push ebx ecx edx
cmp [vmode],0 mcall 9,procinfo,-1
je .kern mov eax,[ebx+42]
mov edx,text2 xor edx,edx
.kern: mov ebx,6
mov esi,80 div ebx
mov eax,4 pop edx ecx ebx
newline: mov esi,80
mcall cmp eax,esi
add ebx,10 ja @f
add edx,80 mov esi,eax
cmp [edx],byte 'x' @@:
jne newline cmp esi,5
mov eax,12 ; function 12:tell os about windowdraw ja @f
mov ebx,2 ; 2, end of draw mov esi,5
mcall @@:
sub esi,4
ret mov eax,4
newline:
mcall
add ebx,10
add edx,80
cmp [edx],byte 'x'
jne newline
ret
;------------------------------------------------------------------------------
if WRITE_LOG if WRITE_LOG
;******************************************** ;********************************************
;* input: esi = pointer to the file name * ;* input: esi = pointer to the file name *
;******************************************** ;********************************************
CreateFile: CreateFile:
pusha pusha
mov dword [InfoStructure], 2 ; create file mov dword [InfoStructure],2 ; create file
mov dword [InfoStructure+4], 0 ; reserved mov dword [InfoStructure+4],0 ; reserved
mov dword [InfoStructure+8], 0 ; reserved mov dword [InfoStructure+8],0 ; reserved
mov dword [InfoStructure+12], 0 ; 0 bytes to write (just create) mov dword [InfoStructure+12],0 ; 0 bytes to write (just create)
mov dword [InfoStructure+16], 0 ; NULL data pointer (no data) mov dword [InfoStructure+16],0 ; NULL data pointer (no data)
mov dword [InfoStructure+20], 0 ; reserved mov dword [InfoStructure+20],0 ; reserved
mov dword [InfoStructure+21], esi ; pointer to the file name mov dword [InfoStructure+21],esi ; pointer to the file name
mcall 70, InfoStructure mcall 70, InfoStructure
test eax, eax test eax,eax
jz .out jz .out
stc stc
.out: .out:
popa popa
ret ret
;------------------------------------------------
;******************************************** ;********************************************
;* input: esi = pointer to the file name * ;* input: esi = pointer to the file name *
;* edx = pointer to data buffer * ;* edx = pointer to data buffer *
@ -296,42 +278,38 @@ CreateFile:
;******************************************** ;********************************************
WriteToFile: WriteToFile:
push ebx push ebx
mov dword [InfoStructure], 3 ; write to file mov dword [InfoStructure],3 ; write to file
mov eax, [filepos] mov eax, [filepos]
mov dword [InfoStructure+4], eax ; lower position addr mov dword [InfoStructure+4],eax ; lower position addr
mov dword [InfoStructure+8], 0 ; upper position addr (0 for FAT) mov dword [InfoStructure+8],0 ; upper position addr (0 for FAT)
mov dword [InfoStructure+12], ecx ; number of bytes to write mov dword [InfoStructure+12],ecx ; number of bytes to write
mov dword [InfoStructure+16], edx ; pointer to data buffer mov dword [InfoStructure+16],edx ; pointer to data buffer
mov dword [InfoStructure+20], 0 ; reserved mov dword [InfoStructure+20],0 ; reserved
mov dword [InfoStructure+21], esi ; pointer to the file name mov dword [InfoStructure+21],esi ; pointer to the file name
mcall 70, InfoStructure mcall 70, InfoStructure
clc clc
test eax, eax test eax,eax
jz .out jz .out
stc stc
.out: .out:
pop ebx pop ebx
ret ret
;--------------------------------------------------
InfoStructure: InfoStructure:
dd 0x0 ; subfunction number dd 0x0 ; subfunction number
dd 0x0 ; position in the file in bytes dd 0x0 ; position in the file in bytes
dd 0x0 ; upper part of the position address dd 0x0 ; upper part of the position address
dd 0x0 ; number of bytes to read dd 0x0 ; number of bytes to read
dd 0x0 ; pointer to the buffer to write data dd 0x0 ; pointer to the buffer to write data
db 0 db 0
dd 0 ; pointer to the filename dd 0 ; pointer to the filename
filepos dd 0 filepos dd 0
default_filename db '/sys/boardlog.txt',0 default_filename db '/sys/boardlog.txt',0
tmp db 0 tmp db 0
end if end if
;------------------------------------------------------------------------------
krnl_msg db 'K : ' krnl_msg db 'K : '
duk db 'KernUser' duk db 'KernUser'
@ -340,33 +318,43 @@ duk db 'KernUser'
; 11,11 > 0,-1 ; 11,11 > 0,-1
; 5,11 > 0,-1 ; 5,11 > 0,-1
if lang eq ru if lang eq ru
title db '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0 title db '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0
else if lang eq en else if lang eq en
title db 'General debug & message board',0 title db 'General debug & message board',0
else else
title db 'Allgemeines debug- & nachrichtenboard',0 title db 'Allgemeines debug- & nachrichtenboard',0
end if end if
krnl_cnt dd 0 krnl_cnt dd 0
vmode dd 1 vmode dd 1
targ dd text2 targ dd text2
;------------------------------------------------------------------------------
I_END: I_END:
offs dd ? ;------------------------------------------------------------------------------
flag rb 1 offs dd ?
rd 2 flag rb 1
; x1pos dd ? rd 2
; y1pos dd ? ;x1pos dd ?
text1 rb 80*(MAXSTRINGS+1) ;y1pos dd ?
tmp1 db ? text1 rb 80*(MAXSTRINGS+1)
rd 2 tmp1 db ?
; x2pos dd ? rd 2
; y2pos dd ? ;x2pos dd ?
text2 rb 80*(MAXSTRINGS+1) ;y2pos dd ?
tmp2 db ? text2 rb 80*(MAXSTRINGS+1)
xstart dd ? tmp2 db ?
sc system_colors xstart dd ?
sc system_colors
i_end: i_end:
filename rb 256 filename rb 256
;------------------------------------------------------------------------------
align 4 align 4
stackbuf rb 2000h procinfo:
rb 1024
;------------------------------------------------------------------------------
align 4
stackbuf rb 2000h
;------------------------------------------------------------------------------
mem: mem:

View File

@ -1,5 +1,6 @@
@erase lang.inc @erase lang.inc
@echo lang fix en >lang.inc @echo lang fix en >lang.inc
@fasm board.asm board @fasm board.asm board
@kpack board
@erase lang.inc @erase lang.inc
@pause @pause

View File

@ -1,5 +1,6 @@
@erase lang.inc @erase lang.inc
@echo lang fix ge >lang.inc @echo lang fix ge >lang.inc
@fasm board.asm board @fasm board.asm board
@kpack board
@erase lang.inc @erase lang.inc
@pause @pause

View File

@ -1,5 +1,6 @@
@erase lang.inc @erase lang.inc
@echo lang fix ru >lang.inc @echo lang fix ru >lang.inc
@fasm board.asm board @fasm board.asm board
@kpack board
@erase lang.inc @erase lang.inc
@pause @pause