add functions KolibriOnButton, SetWindowCaption,

clean code

git-svn-id: svn://kolibrios.org@8165 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2020-11-09 09:25:04 +00:00
parent 6dee931fa9
commit 3c2325ba4a
5 changed files with 187 additions and 149 deletions

View File

@ -20,9 +20,28 @@ bool KolibriOnStart(TStartData &kos_start, TThreadData th)
void KolibriOnPaint(void) void KolibriOnPaint(void)
{ {
DrawButton(2,0xB0B0B0, 10,10,50,20); DrawButton(1,0xB0B0B0, 10,10,50,20);
DrawText(15, 15, 0, string); DrawText(15, 15, 0, string);
DrawButton(2,0xff0000, 10,40,50,20);
DrawButton(3,0x00ff00, 70,10,50,20);
DrawButton(4,0x0000ff, 70,40,50,20);
} }
void KolibriOnButton(long id, TThreadData th)
{
switch(id){
case 2:
SetWindowCaption("Red");
break;
case 3:
SetWindowCaption("Green");
break;
case 4:
SetWindowCaption("Blue");
//break;
};
}
/*
bool KolibriOnClose(TThreadData th) bool KolibriOnClose(TThreadData th)
{ {
return true; return true;
@ -37,3 +56,4 @@ void KolibriOnKeyPress(TThreadData th)
GetKey(); GetKey();
} }
void KolibriOnMouse(TThreadData th) {} void KolibriOnMouse(TThreadData th) {}
*/

View File

@ -1,10 +1,14 @@
kos32-bcc -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -I..\..\..\bcc32\include window.cpp kos32-bcc -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -I..\..\..\bcc32\include window.cpp
echo STACKSIZE equ 102400 \n HEAPSIZE equ 102400 \n include "..\..\..\proc32.inc" \ninclude "..\..\..\bcc32\include\kos_start.inc" \n include "..\..\..\bcc32\include\kos_func.inc" \n include "..\..\..\bcc32\include\kos_heap.inc" > kos_make.inc echo STACKSIZE equ 102400> kos_make.inc
echo HEAPSIZE equ 102400>> kos_make.inc
echo include "..\..\..\bcc32\include\kos_start.inc">> kos_make.inc
echo include "..\..\..\bcc32\include\kos_func.inc">> kos_make.inc
echo include "..\..\..\bcc32\include\kos_heap.inc">> kos_make.inc
echo include "kos_make.inc" > f_window.asm echo include "kos_make.inc" > f_window.asm
t2fasm < window.asm >> f_window.asm t2fasm < window.asm >> f_window.asm
fasm f_window.asm window.kex fasm f_window.asm window.kex
kpack window.kex if exist window.kex kpack window.kex
del kos_make.inc if exist window.kex del kos_make.inc
pause pause

View File

@ -55,7 +55,7 @@ namespace Kolibri // All kolibri functions, types and data are nested in the (
//_ if (frame) is negative do nothing. //_ if (frame) is negative do nothing.
void MoveWindow(const int window_rect[/* 4 */]); // Move and resize current window. void MoveWindow(const int window_rect[/* 4 */]); // Move and resize current window.
void Abort(); // Abnormally terminate a program. void ExitDebug(); // Abnormally terminate a program.
void ExitProcess(); // Exit from the process, don't call any destructors of global varyables void ExitProcess(); // Exit from the process, don't call any destructors of global varyables
void ExitThread(); // Exit from the current thread void ExitThread(); // Exit from the current thread
void ExitThread(TThreadData thread_data); void ExitThread(TThreadData thread_data);
@ -135,6 +135,7 @@ namespace Kolibri // All kolibri functions, types and data are nested in the (
//_ of the stack if (stack_end) is zero or (stack_size) is not zero, in this case stack //_ of the stack if (stack_end) is zero or (stack_size) is not zero, in this case stack
//_ will be deleted automaticaly from dynamic memory at the finish of the thread. //_ will be deleted automaticaly from dynamic memory at the finish of the thread.
void DrawText(short x, short y, int color, const char* string); void DrawText(short x, short y, int color, const char* string);
void SetWindowCaption(const char* caption);
} }
// Function, defined outside. // Function, defined outside.
@ -146,6 +147,7 @@ int KolibriOnIdle(Kolibri::TThreadData thread_data); // Return the time to
void KolibriOnSize(int window_rect[/* 4 */], Kolibri::TThreadData thread_data); // When the window is resized. void KolibriOnSize(int window_rect[/* 4 */], Kolibri::TThreadData thread_data); // When the window is resized.
void KolibriOnKeyPress(Kolibri::TThreadData thread_data); // When user press a key. void KolibriOnKeyPress(Kolibri::TThreadData thread_data); // When user press a key.
void KolibriOnMouse(Kolibri::TThreadData thread_data); // When user move a mouse. void KolibriOnMouse(Kolibri::TThreadData thread_data); // When user move a mouse.
void KolibriOnButton(long id, Kolibri::TThreadData th);
#ifdef __KOLIBRI__ #ifdef __KOLIBRI__

View File

@ -79,7 +79,7 @@ macro Kolibri_Put_MovEaxVal_Ret address,val
proc @Kolibri@Main$qv proc @Kolibri@Main$qv
and esp,not 3 and esp,not 3
sub esp,1024 sub esp,1024
mov eax,9 mov eax,SF_THREAD_INFO
mov ebx,esp mov ebx,esp
mov ecx,-1 mov ecx,-1
int 0x40 int 0x40
@ -97,14 +97,14 @@ end if
cld cld
mov edi,@Kolibri@_ThreadTable mov edi,@Kolibri@_ThreadTable
mov ecx,256 mov ecx,256
rep stos dword [edi] rep stosd
mov esi,@Kolibri@GetPid$qv mov esi,@Kolibri@GetPid$qv
mov edi,@Kolibri@_ThreadSavedBegProc mov edi,@Kolibri@_ThreadSavedBegProc
movs dword [edi],[esi] movsd
movs dword [edi],[esi] movsd
mov esi,@Kolibri@GetThreadData$qv mov esi,@Kolibri@GetThreadData$qv
movs dword [edi],[esi] movsd
movs dword [edi],[esi] movsd
Kolibri_Put_MovEaxVal_Ret @Kolibri@GetPid$qv,edx Kolibri_Put_MovEaxVal_Ret @Kolibri@GetPid$qv,edx
if defined KolibriHeapInit if defined KolibriHeapInit
mov ecx,esp mov ecx,esp
@ -142,7 +142,7 @@ proc @Kolibri@ThreadMain$qpvt1
sub esp,KOLIBRI_THREAD_DATA_LEN*4 sub esp,KOLIBRI_THREAD_DATA_LEN*4
mov [esp],ebx mov [esp],ebx
mov [esp+4],ebp mov [esp+4],ebp
mov eax,40 mov eax,SF_SET_EVENTS_MASK
mov ebx,0x27 mov ebx,0x27
int 0x40 int 0x40
mov ebx,esp mov ebx,esp
@ -166,11 +166,13 @@ end if
jmp .main_end jmp .main_end
.main_close_first: .main_close_first:
btr dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],31 btr dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],31
if defined @@KolibriOnClose$qppv
push esp push esp
call @@KolibriOnClose$qppv call @@KolibriOnClose$qppv
pop ecx pop ecx
test al,al test al,al
jnz .main_end jnz .main_end
end if
.main_test_close_first: .main_test_close_first:
cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0 cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0
jl .main_close_first jl .main_close_first
@ -181,7 +183,7 @@ end if
.main_paint_msg: .main_paint_msg:
or dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],3 or dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],3
sub esp,1024 sub esp,1024
mov eax,9 mov eax,SF_THREAD_INFO
mov ebx,esp mov ebx,esp
mov ecx,-1 mov ecx,-1
int 0x40 int 0x40
@ -197,6 +199,7 @@ end if
.main_size: .main_size:
mov [esp+KOLIBRI_THREAD_DATA_LAST_SX*4],ecx mov [esp+KOLIBRI_THREAD_DATA_LAST_SX*4],ecx
mov [esp+KOLIBRI_THREAD_DATA_LAST_SY*4],edx mov [esp+KOLIBRI_THREAD_DATA_LAST_SY*4],edx
if defined @@KolibriOnSize$qpippv
push edx push edx
push ecx push ecx
push ebx push ebx
@ -207,6 +210,7 @@ end if
push edx push edx
call @@KolibriOnSize$qpippv call @@KolibriOnSize$qpippv
add esp,24 add esp,24
end if
test dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],3 test dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],3
jz .main_cycle jz .main_cycle
.main_paint: .main_paint:
@ -217,7 +221,7 @@ end if
call @Kolibri@Redraw$qippv call @Kolibri@Redraw$qippv
add esp,8 add esp,8
.main_cycle: .main_cycle:
mov eax,11 mov eax,SF_CHECK_EVENT
.main_message: .main_message:
cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0 cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0
jl .main_close jl .main_close
@ -226,49 +230,79 @@ end if
jnz .main_on_message jnz .main_on_message
cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0 cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0
jne .main_paint jne .main_paint
if defined @@KolibriOnIdle$qppv
push esp push esp
call @@KolibriOnIdle$qppv call @@KolibriOnIdle$qppv
pop ecx pop ecx
else
or eax,-1
end if
test eax,eax test eax,eax
jz .main_cycle jz .main_cycle
jl .main_wait_message jl .main_wait_message
mov ebx,eax mov ebx,eax
mov eax,23 mov eax,SF_WAIT_EVENT_TIMEOUT
jmp .main_message jmp .main_message
.main_wait_message: .main_wait_message:
mov eax,10 mov eax,SF_WAIT_EVENT
jmp .main_message jmp .main_message
if defined @@KolibriOnKeyPress$qppv
.main_key_press: .main_key_press:
push esp push esp
call @@KolibriOnKeyPress$qppv call @@KolibriOnKeyPress$qppv
pop ecx pop ecx
jmp .main_cycle jmp .main_cycle
end if
if defined @@KolibriOnMouse$qppv
.main_mouse: .main_mouse:
push esp push esp
call @@KolibriOnMouse$qppv call @@KolibriOnMouse$qppv
pop ecx pop ecx
jmp .main_cycle jmp .main_cycle
end if
align 4
.main_on_message: .main_on_message:
dec eax dec eax
jz .main_paint_msg jz .main_paint_msg
dec eax dec eax
if defined @@KolibriOnKeyPress$qppv
jz .main_key_press jz .main_key_press
else
jz .main_cycle
end if
cmp eax,4 cmp eax,4
if defined @@KolibriOnMouse$qppv
jz .main_mouse jz .main_mouse
else
jz .main_cycle
end if
dec eax dec eax
jnz .main_cycle jnz .main_cycle
align 4
.main_button: .main_button:
mov eax,17 mov eax,SF_GET_BUTTON
int 0x40 int 0x40
test al,al shr eax,8
jnz .main_cycle cmp eax,1
je .main_close
if defined @@KolibriOnButton$qlppv
push esp
push eax
call @@KolibriOnButton$qlppv
add esp,8
end if
jmp .main_cycle
.main_close: .main_close:
btr dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],31 btr dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],31
if defined @@KolibriOnClose$qppv
push esp push esp
call @@KolibriOnClose$qppv call @@KolibriOnClose$qppv
pop ecx pop ecx
test al,al test al,al
jz .main_button jz .main_button
end if
.main_end: .main_end:
mov ebx,esp mov ebx,esp
lock dec dword [@Kolibri@_ThreadNumber] lock dec dword [@Kolibri@_ThreadNumber]
@ -290,7 +324,7 @@ end if
mov ebx,1 mov ebx,1
jmp .main_end_wait jmp .main_end_wait
.main_end_wait_loop: .main_end_wait_loop:
mov eax,5 mov eax,SF_SLEEP
int 0x40 int 0x40
shl ebx,1 shl ebx,1
cmp ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT cmp ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT
@ -344,13 +378,13 @@ proc @Kolibri@Redraw$qippv
.redraw_begin: .redraw_begin:
push ebx esi edi push ebx esi edi
and dword [ebp+KOLIBRI_THREAD_DATA_FLAG*4],0xFFFFFFFC and dword [ebp+KOLIBRI_THREAD_DATA_FLAG*4],0xFFFFFFFC
mov eax,12 mov eax,SF_REDRAW
mov ebx,1 mov ebx,SSF_BEGIN_DRAW
int 0x40 int 0x40
test dl,2 test dl,2
jz .redraw_picture jz .redraw_picture
mov eax,48 mov eax,SF_STYLE_SETTINGS
mov ebx,4 mov ebx,SSF_GET_SKIN_HEIGHT
int 0x40 int 0x40
mov ebx,[ebp+KOLIBRI_THREAD_DATA_X*4] mov ebx,[ebp+KOLIBRI_THREAD_DATA_X*4]
add ebx,2*5-1 add ebx,2*5-1
@ -364,8 +398,8 @@ proc @Kolibri@Redraw$qippv
.redraw_picture: .redraw_picture:
call @@KolibriOnPaint$qv call @@KolibriOnPaint$qv
.redraw_end_draw: .redraw_end_draw:
mov eax,12 mov eax,SF_REDRAW
mov ebx,2 mov ebx,SSF_END_DRAW
int 0x40 int 0x40
pop edi esi ebx ebp pop edi esi ebx ebp
ret ret
@ -377,29 +411,32 @@ proc @Kolibri@MoveWindow$qxpxi uses ebx esi
mov ecx,[eax+4] mov ecx,[eax+4]
mov edx,[eax+8] mov edx,[eax+8]
mov esi,[eax+12] mov esi,[eax+12]
mov eax,67 mov eax,SF_CHANGE_WINDOW
int 0x40 int 0x40
ret ret
endp endp
;proc @Kolibri@Abort$qv proc @Kolibri@ExitDebug$qv
; push dword [@Kolibri@DebugPrefix] push dword [@Kolibri@DebugPrefix]
; call @Kolibri@DebugPutString$qpxc call @Kolibri@DebugPutString$qpxc
; mov dword [esp],Kolibri_abort_string mov dword [esp],Kolibri_debug_string
; call @Kolibri@DebugPutString$qpxc call @Kolibri@DebugPutString$qpxc
; pop ecx pop ecx
jmp @Kolibri@ExitProcess$qv
endp
proc @Kolibri@ExitProcess$qv proc @Kolibri@ExitProcess$qv
lock bts dword [@Kolibri@_ExitProcessNow],0 lock bts dword [@Kolibri@_ExitProcessNow],0
jc .exit_process_wait jc .exit_process_wait
sub esp,1024 sub esp,1024
mov eax,9 mov eax,SF_THREAD_INFO
mov ebx,esp mov ebx,esp
mov ecx,-1 mov ecx,-1
int 0x40 int 0x40
mov esi,eax mov esi,eax
mov edi,[esp+30] mov edi,[esp+30]
.exit_process_loop: .exit_process_loop:
mov eax,9 mov eax,SF_THREAD_INFO
mov ebx,esp mov ebx,esp
mov ecx,esi mov ecx,esi
int 0x40 int 0x40
@ -422,8 +459,8 @@ proc @Kolibri@ExitProcess$qv
jz .exit_process_continue jz .exit_process_continue
cmp ebx,[eax+KOLIBRI_THREAD_DATA_PID*4] cmp ebx,[eax+KOLIBRI_THREAD_DATA_PID*4]
jnz .exit_process_next jnz .exit_process_next
mov eax,18 mov eax,SF_SYSTEM
mov ebx,2 mov ebx,SSF_TERMINATE_THREAD
mov ecx,esi mov ecx,esi
int 0x40 int 0x40
.exit_process_continue: .exit_process_continue:
@ -440,7 +477,7 @@ end if
or eax,-1 or eax,-1
int 0x40 int 0x40
.exit_process_wait: .exit_process_wait:
mov eax,5 mov eax,SF_SLEEP
mov ebx,1 mov ebx,1
.exit_process_wait_loop: .exit_process_wait_loop:
cmp dword [@Kolibri@_ExitProcessNow],0 cmp dword [@Kolibri@_ExitProcessNow],0
@ -466,32 +503,24 @@ proc @Kolibri@ReturnMessageLoop$qppv,@Kolibri@ThreadMain$qpvt1
endp endp
proc @Kolibri@Delay$qui uses ebx proc @Kolibri@Delay$qui uses ebx
mov eax,5 mov eax,SF_SLEEP
mov ebx,[esp+8] mov ebx,[esp+8]
int 0x40 int 0x40
ret ret
endp endp
proc @Kolibri@Clock$qv uses ebx proc @Kolibri@Clock$qv uses ebx
mov eax,26 mov eax,SF_SYSTEM_GET
mov ebx,9 mov ebx,SSF_TIME_COUNT
int 0x40
ret
endp
proc @Kolibri@GetPackedTime$qv
mov eax,3
int 0x40 int 0x40
ret ret
endp endp
proc @Kolibri@DrawButton$qllllll uses ebx esi proc @Kolibri@DrawButton$qllllll uses ebx esi
mov eax,8 mov eax,SF_DEFINE_BUTTON
mov ebx,[esp+12+8] mov ebx,[esp+12-2+8]
shl ebx,16
mov bx,[esp+20+8] mov bx,[esp+20+8]
mov ecx,[esp+16+8] mov ecx,[esp+16-2+8]
shl ecx,16
mov cx,[esp+24+8] mov cx,[esp+24+8]
mov edx,[esp+4+8] mov edx,[esp+4+8]
mov esi,[esp+8+8] mov esi,[esp+8+8]
@ -499,8 +528,14 @@ proc @Kolibri@DrawButton$qllllll uses ebx esi
ret ret
endp endp
proc @Kolibri@GetPackedTime$qv
mov eax,SF_GET_SYS_TIME
int 0x40
ret
endp
proc @Kolibri@GetTime$qpi proc @Kolibri@GetTime$qpi
mov eax,3 mov eax,SF_GET_SYS_TIME
int 0x40 int 0x40
mov edx,[esp+4] mov edx,[esp+4]
movzx ecx,al movzx ecx,al
@ -526,13 +561,13 @@ proc @Kolibri@GetTime$qpi
endp endp
proc @Kolibri@GetPackedDate$qv proc @Kolibri@GetPackedDate$qv
mov eax,29 mov eax,SF_GET_SYS_DATE
int 0x40 int 0x40
ret ret
endp endp
proc @Kolibri@GetDate$qpi proc @Kolibri@GetDate$qpi
mov eax,29 mov eax,SF_GET_SYS_DATE
int 0x40 int 0x40
mov edx,[esp+4] mov edx,[esp+4]
movzx ecx,al movzx ecx,al
@ -558,8 +593,8 @@ proc @Kolibri@GetDate$qpi
endp endp
proc @Kolibri@ReadCommonColors$qpui uses ebx proc @Kolibri@ReadCommonColors$qpui uses ebx
mov eax,48 mov eax,SF_STYLE_SETTINGS
mov ebx,3 mov ebx,SSF_GET_COLORS
mov ecx,[esp+8] mov ecx,[esp+8]
mov edx,40 mov edx,40
int 0x40 int 0x40
@ -567,7 +602,7 @@ proc @Kolibri@ReadCommonColors$qpui uses ebx
endp endp
proc @Kolibri@DrawText$qssipxc uses ebx proc @Kolibri@DrawText$qssipxc uses ebx
mov eax,4 mov eax,SF_DRAW_TEXT
mov ebx,[esp+8-2] mov ebx,[esp+8-2]
mov bx,[esp+12] mov bx,[esp+12]
mov ecx,[esp+16] mov ecx,[esp+16]
@ -577,9 +612,17 @@ proc @Kolibri@DrawText$qssipxc uses ebx
ret ret
endp endp
proc @Kolibri@SetWindowCaption$qpxc uses ebx
mov eax,SF_SET_CAPTION
mov ebx,2
mov ecx,[esp+8]
int 0x40
ret
endp
proc @Kolibri@GetProcessInfo$qpuipct1t1piui uses ebx esi edi proc @Kolibri@GetProcessInfo$qpuipct1t1piui uses ebx esi edi
sub esp,1024 sub esp,1024
mov eax,9 mov eax,SF_THREAD_INFO
mov ebx,esp mov ebx,esp
mov ecx,[1024+12+24+esp] mov ecx,[1024+12+24+esp]
int 0x40 int 0x40
@ -594,9 +637,9 @@ proc @Kolibri@GetProcessInfo$qpuipct1t1piui uses ebx esi edi
jz .get_proc_info_no_name jz .get_proc_info_no_name
lea esi,[esp+10] lea esi,[esp+10]
cld cld
movs dword [edi],[esi] movsd
movs dword [edi],[esi] movsd
movs dword [edi],[esi] movsd
mov byte [edi],0 mov byte [edi],0
xor edi,edi xor edi,edi
.get_proc_info_no_name: .get_proc_info_no_name:
@ -616,10 +659,10 @@ proc @Kolibri@GetProcessInfo$qpuipct1t1piui uses ebx esi edi
jz .get_proc_info_no_rect jz .get_proc_info_no_rect
lea esi,[esp+34] lea esi,[esp+34]
cld cld
movs dword [edi],[esi] movsd
movs dword [edi],[esi] movsd
movs dword [edi],[esi] movsd
movs dword [edi],[esi] movsd
xor edi,edi xor edi,edi
.get_proc_info_no_rect: .get_proc_info_no_rect:
add esp,1024 add esp,1024
@ -628,7 +671,7 @@ endp
proc @Kolibri@GetPid$qv uses ebx proc @Kolibri@GetPid$qv uses ebx
sub esp,1024 sub esp,1024
mov eax,9 mov eax,SF_THREAD_INFO
mov ebx,esp mov ebx,esp
mov ecx,-1 mov ecx,-1
int 0x40 int 0x40
@ -659,10 +702,12 @@ Kolibri_HashInt:
ret ret
endp endp
if defined @Kolibri@_HashByte$qui | defined @Kolibri@_HashWord$qui | defined @Kolibri@_HashDword$qui
Kolibri_hash_int_val0: Kolibri_hash_int_val0:
dd 0xA82F94C5 dd 0xA82F94C5
Kolibri_hash_int_val1: Kolibri_hash_int_val1:
dd 0x9193780B dd 0x9193780B
end if
proc @Kolibri@GetThreadData$qv proc @Kolibri@GetThreadData$qv
call @Kolibri@GetPid$qv call @Kolibri@GetPid$qv
@ -695,7 +740,7 @@ proc @Kolibri@GetThreadData$qui
ret ret
.get_thread_data_wait: .get_thread_data_wait:
push eax ebx push eax ebx
mov eax,5 mov eax,SF_SLEEP
mov ebx,1 mov ebx,1
.get_thread_data_wait_loop: .get_thread_data_wait_loop:
int 0x40 int 0x40
@ -712,14 +757,14 @@ proc @Kolibri@GetThreadData$qui
endp endp
proc @Kolibri@_GetSkinHeader$qv uses ebx proc @Kolibri@_GetSkinHeader$qv uses ebx
mov eax,48 mov eax,SF_STYLE_SETTINGS
mov ebx,4 mov ebx,SSF_GET_SKIN_HEIGHT
int 0x40 int 0x40
ret ret
endp endp
proc @Kolibri@GetScreenSize$qrust1 proc @Kolibri@GetScreenSize$qrust1
mov eax,14 mov eax,SF_GET_SCREEN_SIZE
int 0x40 int 0x40
mov ecx,[esp+8] mov ecx,[esp+8]
mov word [ecx],ax mov word [ecx],ax
@ -736,7 +781,7 @@ proc Kolibri_MutexLockNoWait
endp endp
proc Kolibri_MutexLockWait uses ebx proc Kolibri_MutexLockWait uses ebx
mov eax,5 mov eax,SF_SLEEP
xor ebx,ebx xor ebx,ebx
.lock_wait_cycle: .lock_wait_cycle:
int 0x40 int 0x40
@ -751,18 +796,18 @@ proc Kolibri_MutexLockWaitTime
jng .MutexLockWait jng .MutexLockWait
push ebx edx push ebx edx
mov edx,[esp+20] mov edx,[esp+20]
mov eax,26 mov eax,SF_SYSTEM_GET
mov ebx,9 mov ebx,SSF_TIME_COUNT
int 0x40 int 0x40
add edx,eax add edx,eax
.lock_wait_time_cycle: .lock_wait_time_cycle:
mov eax,5 mov eax,SF_SLEEP
xor ebx,ebx xor ebx,ebx
int 0x40 int 0x40
shl byte [ecx],1 shl byte [ecx],1
jnz .lock_wait_time_ret_true jnz .lock_wait_time_ret_true
mov eax,26 mov eax,SF_SYSTEM_GET
mov ebx,9 mov ebx,SSF_TIME_COUNT
int 0x40 int 0x40
cmp eax,edx cmp eax,edx
js .lock_wait_time_cycle js .lock_wait_time_cycle
@ -810,7 +855,7 @@ proc @Kolibri@UnLock$qp14Kolibri@TMutex
.unlock_pause: .unlock_pause:
mov byte [ecx],0x40 mov byte [ecx],0x40
push ebx push ebx
mov eax,5 mov eax,SF_SLEEP
xor ebx,ebx xor ebx,ebx
int 0x40 int 0x40
pop ebx pop ebx
@ -838,7 +883,7 @@ proc Kolibri_MutexLockRec
mov dword [esp],Kolibri_try_lock_rec_overflow_string mov dword [esp],Kolibri_try_lock_rec_overflow_string
call @Kolibri@DebugPutString$qpxc call @Kolibri@DebugPutString$qpxc
pop ecx pop ecx
jmp @Kolibri@Abort$qv jmp @Kolibri@ExitDebug$qv
endp endp
proc @Kolibri@TryLock$qp16Kolibri@TRecMutexui proc @Kolibri@TryLock$qp16Kolibri@TRecMutexui
@ -878,7 +923,7 @@ proc @Kolibri@UnLock$qp16Kolibri@TRecMutexui
.unlock_rec_pause: .unlock_rec_pause:
mov byte [ecx],0x20 mov byte [ecx],0x20
push ebx push ebx
mov eax,5 mov eax,SF_SLEEP
xor ebx,ebx xor ebx,ebx
int 0x40 int 0x40
pop ebx pop ebx
@ -889,7 +934,7 @@ proc @Kolibri@UnLock$qp16Kolibri@TRecMutexui
mov dword [esp],Kolibri_unlock_rec_notlocked_string mov dword [esp],Kolibri_unlock_rec_notlocked_string
call @Kolibri@DebugPutString$qpxc call @Kolibri@DebugPutString$qpxc
pop ecx pop ecx
jmp @Kolibri@Abort$qv jmp @Kolibri@ExitDebug$qv
endp endp
proc @Kolibri@DebugPutChar$qc proc @Kolibri@DebugPutChar$qc
@ -900,23 +945,22 @@ proc @Kolibri@DebugPutChar$qc
cmp cl,10 cmp cl,10
jz .debug_put_char_enter jz .debug_put_char_enter
.debug_put_char_after_cmp: .debug_put_char_after_cmp:
mov eax,63 mov eax,SF_BOARD
mov ebx,1 mov ebx,SSF_DEBUG_WRITE
int 0x40 int 0x40
pop ebx pop ebx
.debug_put_char_ret: .debug_put_char_ret:
ret ret
.debug_put_char_enter: .debug_put_char_enter:
mov cl,13 mov cl,13
mov eax,63 mov eax,SF_BOARD
mov ebx,1 mov ebx,SSF_DEBUG_WRITE
int 0x40 int 0x40
mov cl,10 mov cl,10
jmp .debug_put_char_after_cmp jmp .debug_put_char_after_cmp
endp endp
proc @Kolibri@DebugPutString$qpxc proc @Kolibri@DebugPutString$qpxc uses esi
push esi
push dword 0 push dword 0
mov esi,dword [esp+12] mov esi,dword [esp+12]
jmp .debug_put_string_test jmp .debug_put_string_test
@ -929,32 +973,32 @@ proc @Kolibri@DebugPutString$qpxc
or al,[esi] or al,[esi]
test al,al test al,al
jnz .debug_put_string_loop jnz .debug_put_string_loop
pop ecx esi pop ecx
ret ret
endp endp
proc @Kolibri@GetKey$qv proc @Kolibri@GetKey$qv
mov eax,2 mov eax,SF_GET_KEY
int 0x40 int 0x40
test al,al test al,al
jnz .get_key_eof jnz .get_key_eof
movzx eax,ah movzx eax,ah
ret ret
.get_key_eof: .get_key_eof:
mov eax,-1 mov eax,SF_TERMINATE_PROCESS
ret ret
endp endp
proc @Kolibri@GetMouseButton$qv uses ebx proc @Kolibri@GetMouseButton$qv uses ebx
mov eax,37 mov eax,SF_MOUSE_GET
mov ebx,2 mov ebx,SSF_BUTTON
int 0x40 int 0x40
ret ret
endp endp
proc @Kolibri@GetMousePosition$qrst1o uses ebx proc @Kolibri@GetMousePosition$qrst1o uses ebx
mov eax,37 mov eax,SF_MOUSE_GET
xor ebx,ebx xor ebx,ebx ;SSF_SCREEN_POSITION
cmp byte [esp+16],0 cmp byte [esp+16],0
jnz .get_mouse_pos_absolute jnz .get_mouse_pos_absolute
inc ebx inc ebx
@ -1010,7 +1054,7 @@ end if
mov dword [edx+8],ebx mov dword [edx+8],ebx
mov dword [edx+4],ecx mov dword [edx+4],ecx
mov dword [edx],Kolibri_ThreadFinish mov dword [edx],Kolibri_ThreadFinish
mov eax,51 mov eax,SF_CREATE_THREAD
mov ebx,1 mov ebx,1
mov ecx,@Kolibri@ThreadMain$qpvt1 mov ecx,@Kolibri@ThreadMain$qpvt1
int 0x40 int 0x40
@ -1034,23 +1078,23 @@ end if
cld cld
mov esi,@Kolibri@_ThreadSavedBegProc mov esi,@Kolibri@_ThreadSavedBegProc
mov edi,@Kolibri@GetPid$qv mov edi,@Kolibri@GetPid$qv
movs dword [edi],[esi] movsd
movs dword [edi],[esi] movsd
mov edi,@Kolibri@GetThreadData$qv mov edi,@Kolibri@GetThreadData$qv
movs dword [edi],[esi] movsd
movs dword [edi],[esi] movsd
mov eax,0x90909090 mov eax,0x90909090
mov edi,@Kolibri@_ThreadSavedBegProc mov edi,@Kolibri@_ThreadSavedBegProc
stos dword [edi] stosd
stos dword [edi] stosd
stos dword [edi] stosd
stos dword [edi] stosd
pop edi esi pop edi esi
jmp .create_thread_fill_stack jmp .create_thread_fill_stack
endp endp
proc @Kolibri@_FileAccess$qpv uses ebx proc @Kolibri@_FileAccess$qpv uses ebx
mov eax,70 mov eax,SF_FILE
mov ebx,[esp+8] mov ebx,[esp+8]
int 0x40 int 0x40
mov ecx,[esp+8] mov ecx,[esp+8]
@ -1058,12 +1102,20 @@ proc @Kolibri@_FileAccess$qpv uses ebx
ret ret
endp endp
Kolibri_abort_string: if defined Kolibri_debug_string
Kolibri_debug_string:
db 'Abnormal program termination.',10,0 db 'Abnormal program termination.',10,0
end if
if defined Kolibri_MutexLockRec
Kolibri_try_lock_rec_overflow_string: Kolibri_try_lock_rec_overflow_string:
db 'Recursive mutex lock count overflow.',10,0 db 'Recursive mutex lock count overflow.',10,0
end if
if defined @Kolibri@UnLock$qp16Kolibri@TRecMutexui
Kolibri_unlock_rec_notlocked_string: Kolibri_unlock_rec_notlocked_string:
db 'Recursive mutex unlock error.',10,0 db 'Recursive mutex unlock error.',10,0
end if
include "kos_lib.inc" include "kos_lib.inc"

View File

@ -8,6 +8,9 @@ org 0
dd U_END+STACKSIZE dd U_END+STACKSIZE
dd @Kolibri@CommandLine,0 dd @Kolibri@CommandLine,0
include "..\..\..\KOSfuncs.inc"
include "..\..\..\proc32.inc"
ptr equ ptr equ
offset equ offset equ
short equ short equ
@ -40,46 +43,3 @@ macro segment name {}
macro endseg name {} macro endseg name {}
macro usedef [link]
{
common
if ~link eq
virtual at 0
forward
dd link
common
end virtual
end if
}
macro define_f x,[link]
{
common
if x eq
else if used x
x:
usedef link
}
macro enddef [link]
{
common
usedef link
end if
}
macro newdef x,[link]
{
common
end if
if x eq
else if used x
x:
usedef link
}
macro nextdef x
{
x:
}