Rev 8184 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8129 | IgorA | 1 | ;const int |
8170 | IgorA | 2 | KOLIBRI_BORDER_SIZE = 4; |
8129 | IgorA | 3 | ;const int |
8170 | IgorA | 4 | KOLIBRI_HEADER_SIZE = 20; |
8129 | IgorA | 5 | |
6 | ;const int |
||
8133 | IgorA | 7 | KOLIBRI_THREAD_DATA_USER = 0; // Thread data begin from the user dword |
8129 | IgorA | 8 | ;const int |
8133 | IgorA | 9 | KOLIBRI_THREAD_DATA_ST_BEGIN = 1; // Stack beginning follows after the user dword |
8129 | IgorA | 10 | ;const int |
8133 | IgorA | 11 | KOLIBRI_THREAD_DATA_NEXT = 2; |
8129 | IgorA | 12 | ;const int |
8133 | IgorA | 13 | KOLIBRI_THREAD_DATA_PID = 3; |
8129 | IgorA | 14 | ;const int |
8133 | IgorA | 15 | KOLIBRI_THREAD_DATA_FLAG = 4; |
8129 | IgorA | 16 | ;const int |
8133 | IgorA | 17 | KOLIBRI_THREAD_DATA_X = 5; |
8129 | IgorA | 18 | ;const int |
8133 | IgorA | 19 | KOLIBRI_THREAD_DATA_Y = 6; |
8129 | IgorA | 20 | ;const int |
8133 | IgorA | 21 | KOLIBRI_THREAD_DATA_C_WINDOW = 7; |
8129 | IgorA | 22 | ;const int |
8133 | IgorA | 23 | KOLIBRI_THREAD_DATA_C_HEADER = 8; |
8129 | IgorA | 24 | ;const int |
8133 | IgorA | 25 | KOLIBRI_THREAD_DATA_C_BORDER = 9; |
8129 | IgorA | 26 | ;const int |
8133 | IgorA | 27 | KOLIBRI_THREAD_DATA_C_TITLE = 10; |
8129 | IgorA | 28 | ;const int |
8133 | IgorA | 29 | KOLIBRI_THREAD_DATA_TITLE = 11; |
8129 | IgorA | 30 | ;const int |
8133 | IgorA | 31 | KOLIBRI_THREAD_DATA_PICTURE = 12; |
8129 | IgorA | 32 | ;const int |
8133 | IgorA | 33 | KOLIBRI_THREAD_DATA_SZ_PICT = 13; |
8129 | IgorA | 34 | ;const int |
8133 | IgorA | 35 | KOLIBRI_THREAD_DATA_LAST_SX = 14; |
8129 | IgorA | 36 | ;const int |
8133 | IgorA | 37 | KOLIBRI_THREAD_DATA_LAST_SY = 15; |
8129 | IgorA | 38 | ;const int |
8133 | IgorA | 39 | KOLIBRI_THREAD_DATA_LEN = 16; |
8129 | IgorA | 40 | |
41 | ;const int |
||
8170 | IgorA | 42 | KOLIBRI_MUTEX_MAX_TIME_WAIT = 20; |
8129 | IgorA | 43 | |
44 | ;/*** |
||
45 | |||
46 | macro segment name |
||
47 | { |
||
48 | segment name |
||
49 | if name eq _init_ | name eq _INIT_ |
||
8170 | IgorA | 50 | Kolibri_SegmentInit: |
8129 | IgorA | 51 | else if name eq _exit_ | name eq _EXIT_ |
8170 | IgorA | 52 | Kolibri_SegmentExit: |
8129 | IgorA | 53 | end if |
54 | } |
||
55 | |||
56 | macro endseg name |
||
57 | { |
||
58 | if name eq _init_ | name eq _INIT_ |
||
8170 | IgorA | 59 | Kolibri_SegmentInitEnd: |
8129 | IgorA | 60 | else if name eq _exit_ | name eq _EXIT_ |
8170 | IgorA | 61 | Kolibri_SegmentExitEnd: |
8129 | IgorA | 62 | end if |
63 | endseg name |
||
64 | } |
||
65 | |||
8170 | IgorA | 66 | macro Kolibri_Put_MovEaxVal_Ret address,val |
8129 | IgorA | 67 | { |
68 | mov byte [address],0xB8 |
||
69 | mov dword [address+4],0xC089C300 |
||
70 | mov dword [address+1],val |
||
71 | } |
||
72 | |||
73 | proc @Kolibri@Main$qv |
||
74 | and esp,not 3 |
||
75 | sub esp,1024 |
||
8170 | IgorA | 76 | mov eax,SF_THREAD_INFO |
8129 | IgorA | 77 | mov ebx,esp |
78 | mov ecx,-1 |
||
79 | int 0x40 |
||
80 | mov ebx,[esp+26] |
||
81 | mov edx,[esp+30] |
||
82 | lea eax,[ebx-0x20] |
||
83 | add esp,1024 |
||
84 | cmp esp,eax |
||
85 | cmova esp,eax |
||
86 | and esp,not 3 |
||
87 | if defined @Kolibri@CommandLine |
||
88 | mov byte [@Kolibri@CommandLine+256], 0 |
||
89 | end if |
||
90 | xor eax,eax |
||
91 | cld |
||
92 | mov edi,@Kolibri@_ThreadTable |
||
93 | mov ecx,256 |
||
8170 | IgorA | 94 | rep stosd |
8129 | IgorA | 95 | mov esi,@Kolibri@GetPid$qv |
96 | mov edi,@Kolibri@_ThreadSavedBegProc |
||
8170 | IgorA | 97 | movsd |
98 | movsd |
||
8129 | IgorA | 99 | mov esi,@Kolibri@GetThreadData$qv |
8170 | IgorA | 100 | movsd |
101 | movsd |
||
102 | Kolibri_Put_MovEaxVal_Ret @Kolibri@GetPid$qv,edx |
||
103 | if defined KolibriHeapInit |
||
8199 | IgorA | 104 | call KolibriHeapInit ; Initialize a dynamic heap |
105 | end if |
||
8129 | IgorA | 106 | xor eax,eax |
107 | push eax |
||
108 | push eax |
||
109 | call @Kolibri@ThreadMain$qpvt1 |
||
110 | .ThreadFinish: |
||
111 | add esp,8 |
||
8170 | IgorA | 112 | if defined KolibriHeapFreeAndThreadFinish |
8129 | IgorA | 113 | test eax,eax |
114 | jz .ThreadFinish_end |
||
115 | push dword @Kolibri@_ExitProcessNow |
||
116 | push eax |
||
8170 | IgorA | 117 | call KolibriHeapFreeAndThreadFinish ; Free the given memory and finish the thread, |
8129 | IgorA | 118 | end if ; should exit process if second argument points to not zero. |
119 | .ThreadFinish_end: |
||
120 | or eax,-1 |
||
121 | int 0x40 |
||
122 | endp |
||
123 | |||
124 | proc @Kolibri@ThreadMain$qpvt1 |
||
125 | xchg ebx,[esp+4] |
||
126 | xchg ebp,[esp+8] |
||
127 | push esi edi |
||
8133 | IgorA | 128 | sub esp,KOLIBRI_THREAD_DATA_LEN*4 |
8129 | IgorA | 129 | mov [esp],ebx |
130 | mov [esp+4],ebp |
||
8170 | IgorA | 131 | mov eax,SF_SET_EVENTS_MASK |
8129 | IgorA | 132 | mov ebx,0x27 |
133 | int 0x40 |
||
134 | mov ebx,esp |
||
135 | cmp byte [@Kolibri@_ThreadSavedBegProc],0x90 |
||
136 | jz .main_else_first_check |
||
8170 | IgorA | 137 | Kolibri_Put_MovEaxVal_Ret @Kolibri@GetThreadData$qv,esp |
138 | if defined Kolibri_SegmentInit & defined Kolibri_SegmentInitEnd |
||
139 | push Kolibri_SegmentInitEnd |
||
140 | push Kolibri_SegmentInit |
||
8129 | IgorA | 141 | jmp .main_after_first_check |
142 | end if |
||
143 | .main_else_first_check: |
||
144 | xor eax,eax |
||
145 | push eax eax |
||
146 | .main_after_first_check: |
||
147 | push ebx |
||
148 | call @@Kolibri@_CallStart$qppvpvt2 |
||
149 | add esp,12 |
||
150 | test al,al |
||
151 | jnz .main_test_close_first |
||
152 | jmp .main_end |
||
153 | .main_close_first: |
||
8133 | IgorA | 154 | btr dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],31 |
8170 | IgorA | 155 | if defined @@KolibriOnClose$qppv |
8129 | IgorA | 156 | push esp |
8133 | IgorA | 157 | call @@KolibriOnClose$qppv |
8129 | IgorA | 158 | pop ecx |
159 | test al,al |
||
160 | jnz .main_end |
||
8170 | IgorA | 161 | end if |
8129 | IgorA | 162 | .main_test_close_first: |
8133 | IgorA | 163 | cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0 |
8129 | IgorA | 164 | jl .main_close_first |
165 | push esp |
||
166 | push dword 1 |
||
167 | call @Kolibri@Redraw$qippv |
||
168 | add esp,8 |
||
169 | .main_paint_msg: |
||
8133 | IgorA | 170 | or dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],3 |
8129 | IgorA | 171 | sub esp,1024 |
8170 | IgorA | 172 | mov eax,SF_THREAD_INFO |
8129 | IgorA | 173 | mov ebx,esp |
174 | mov ecx,-1 |
||
175 | int 0x40 |
||
176 | mov eax,[esp+34] |
||
177 | mov ebx,[esp+38] |
||
178 | mov ecx,[esp+42] |
||
179 | mov edx,[esp+46] |
||
180 | add esp,1024 |
||
8133 | IgorA | 181 | cmp ecx,[esp+KOLIBRI_THREAD_DATA_LAST_SX*4] |
8129 | IgorA | 182 | jnz .main_size |
8133 | IgorA | 183 | cmp edx,[esp+KOLIBRI_THREAD_DATA_LAST_SY*4] |
8129 | IgorA | 184 | jz .main_paint |
185 | .main_size: |
||
8133 | IgorA | 186 | mov [esp+KOLIBRI_THREAD_DATA_LAST_SX*4],ecx |
187 | mov [esp+KOLIBRI_THREAD_DATA_LAST_SY*4],edx |
||
8170 | IgorA | 188 | if defined @@KolibriOnSize$qpippv |
8129 | IgorA | 189 | push edx |
190 | push ecx |
||
191 | push ebx |
||
192 | push eax |
||
193 | lea ecx,[esp+16] |
||
194 | mov edx,esp |
||
195 | push ecx |
||
196 | push edx |
||
8133 | IgorA | 197 | call @@KolibriOnSize$qpippv |
8129 | IgorA | 198 | add esp,24 |
8170 | IgorA | 199 | end if |
8133 | IgorA | 200 | test dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],3 |
8129 | IgorA | 201 | jz .main_cycle |
202 | .main_paint: |
||
8133 | IgorA | 203 | cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0 |
8129 | IgorA | 204 | jl .main_close |
205 | push esp |
||
206 | push dword 0 |
||
207 | call @Kolibri@Redraw$qippv |
||
208 | add esp,8 |
||
209 | .main_cycle: |
||
8170 | IgorA | 210 | mov eax,SF_CHECK_EVENT |
8129 | IgorA | 211 | .main_message: |
8133 | IgorA | 212 | cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0 |
8129 | IgorA | 213 | jl .main_close |
214 | int 0x40 |
||
215 | test eax,eax |
||
216 | jnz .main_on_message |
||
8133 | IgorA | 217 | cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0 |
8129 | IgorA | 218 | jne .main_paint |
8170 | IgorA | 219 | if defined @@KolibriOnIdle$qppv |
8129 | IgorA | 220 | push esp |
8133 | IgorA | 221 | call @@KolibriOnIdle$qppv |
8129 | IgorA | 222 | pop ecx |
8170 | IgorA | 223 | else |
224 | or eax,-1 |
||
225 | end if |
||
8129 | IgorA | 226 | test eax,eax |
227 | jz .main_cycle |
||
228 | jl .main_wait_message |
||
229 | mov ebx,eax |
||
8170 | IgorA | 230 | mov eax,SF_WAIT_EVENT_TIMEOUT |
8129 | IgorA | 231 | jmp .main_message |
232 | .main_wait_message: |
||
8170 | IgorA | 233 | mov eax,SF_WAIT_EVENT |
8129 | IgorA | 234 | jmp .main_message |
8170 | IgorA | 235 | if defined @@KolibriOnKeyPress$qppv |
8129 | IgorA | 236 | .main_key_press: |
237 | push esp |
||
8133 | IgorA | 238 | call @@KolibriOnKeyPress$qppv |
8129 | IgorA | 239 | pop ecx |
240 | jmp .main_cycle |
||
8170 | IgorA | 241 | end if |
242 | if defined @@KolibriOnMouse$qppv |
||
8129 | IgorA | 243 | .main_mouse: |
244 | push esp |
||
8133 | IgorA | 245 | call @@KolibriOnMouse$qppv |
8129 | IgorA | 246 | pop ecx |
247 | jmp .main_cycle |
||
8170 | IgorA | 248 | end if |
249 | |||
250 | align 4 |
||
8129 | IgorA | 251 | .main_on_message: |
252 | dec eax |
||
253 | jz .main_paint_msg |
||
254 | dec eax |
||
8170 | IgorA | 255 | if defined @@KolibriOnKeyPress$qppv |
8129 | IgorA | 256 | jz .main_key_press |
8170 | IgorA | 257 | else |
258 | jz .main_cycle |
||
259 | end if |
||
8129 | IgorA | 260 | cmp eax,4 |
8170 | IgorA | 261 | if defined @@KolibriOnMouse$qppv |
8129 | IgorA | 262 | jz .main_mouse |
8170 | IgorA | 263 | else |
264 | jz .main_cycle |
||
265 | end if |
||
8129 | IgorA | 266 | dec eax |
267 | jnz .main_cycle |
||
8170 | IgorA | 268 | |
269 | align 4 |
||
8129 | IgorA | 270 | .main_button: |
8170 | IgorA | 271 | mov eax,SF_GET_BUTTON |
8129 | IgorA | 272 | int 0x40 |
8170 | IgorA | 273 | shr eax,8 |
274 | cmp eax,1 |
||
275 | je .main_close |
||
276 | if defined @@KolibriOnButton$qlppv |
||
277 | push esp |
||
278 | push eax |
||
279 | call @@KolibriOnButton$qlppv |
||
280 | add esp,8 |
||
281 | end if |
||
282 | jmp .main_cycle |
||
8129 | IgorA | 283 | .main_close: |
8133 | IgorA | 284 | btr dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],31 |
8170 | IgorA | 285 | if defined @@KolibriOnClose$qppv |
8129 | IgorA | 286 | push esp |
8133 | IgorA | 287 | call @@KolibriOnClose$qppv |
8129 | IgorA | 288 | pop ecx |
289 | test al,al |
||
290 | jz .main_button |
||
8170 | IgorA | 291 | end if |
8129 | IgorA | 292 | .main_end: |
293 | mov ebx,esp |
||
294 | lock dec dword [@Kolibri@_ThreadNumber] |
||
8170 | IgorA | 295 | if defined Kolibri_SegmentExit & defined Kolibri_SegmentExitEnd |
8129 | IgorA | 296 | jnz .main_else_last_check |
8170 | IgorA | 297 | push Kolibri_SegmentExitEnd |
298 | push Kolibri_SegmentExit |
||
8129 | IgorA | 299 | jmp .main_after_last_check |
300 | end if |
||
301 | .main_else_last_check: |
||
302 | xor eax,eax |
||
303 | push eax |
||
304 | push eax |
||
305 | .main_after_last_check: |
||
306 | push ebx |
||
307 | call @@Kolibri@_RemoveThreadData$qppvpvt2 |
||
308 | add esp,12 |
||
309 | lock inc dword [@Kolibri@_ThreadScanCount+4] |
||
310 | mov ebx,1 |
||
311 | jmp .main_end_wait |
||
312 | .main_end_wait_loop: |
||
8170 | IgorA | 313 | mov eax,SF_SLEEP |
8129 | IgorA | 314 | int 0x40 |
315 | shl ebx,1 |
||
8170 | IgorA | 316 | cmp ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT |
8129 | IgorA | 317 | jna .main_end_wait |
8170 | IgorA | 318 | mov ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT |
8129 | IgorA | 319 | .main_end_wait: |
320 | cmp dword [@Kolibri@_ExitProcessNow],0 |
||
321 | jnz @Kolibri@ExitProcess$qv |
||
322 | cmp dword [@Kolibri@_ThreadScanCount],0 |
||
323 | jnz .main_end_wait_loop |
||
324 | lock dec dword [@Kolibri@_ThreadScanCount+4] |
||
325 | mov ebp,[esp+4] |
||
326 | mov ebx,[esp] |
||
8133 | IgorA | 327 | add esp,KOLIBRI_THREAD_DATA_LEN*4 |
8129 | IgorA | 328 | mov eax,ebp |
329 | pop edi esi |
||
330 | xchg ebp,[esp+8] |
||
331 | xchg ebx,[esp+4] |
||
332 | ret |
||
333 | endp |
||
334 | |||
335 | macro call func |
||
336 | { |
||
337 | if func eq __chkstk |
||
338 | sub esp,eax |
||
339 | else |
||
340 | call func |
||
341 | end if |
||
342 | } |
||
343 | |||
344 | proc @Kolibri@Redraw$qippv |
||
345 | push ebp |
||
346 | mov ebp,[esp+12] |
||
8133 | IgorA | 347 | mov edx,[ebp+KOLIBRI_THREAD_DATA_FLAG*4] |
8129 | IgorA | 348 | cmp dword [esp+8],0 |
349 | jl .redraw_only_inv |
||
350 | jz .redraw_no_frame |
||
351 | or dl,2 |
||
352 | .redraw_no_frame: |
||
353 | bt edx,30 |
||
354 | jnc .redraw_begin |
||
355 | or dl,1 |
||
8133 | IgorA | 356 | mov [ebp+KOLIBRI_THREAD_DATA_FLAG*4],edx |
8129 | IgorA | 357 | jmp .redraw_end |
358 | .redraw_only_inv: |
||
359 | test dl,3 |
||
360 | jnz .redraw_no_frame |
||
361 | .redraw_end: |
||
362 | pop ebp |
||
363 | ret |
||
364 | .redraw_begin: |
||
365 | push ebx esi edi |
||
8133 | IgorA | 366 | and dword [ebp+KOLIBRI_THREAD_DATA_FLAG*4],0xFFFFFFFC |
8129 | IgorA | 367 | test dl,2 |
368 | jz .redraw_picture |
||
8170 | IgorA | 369 | mov eax,SF_REDRAW |
370 | mov ebx,SSF_BEGIN_DRAW |
||
8129 | IgorA | 371 | int 0x40 |
372 | xor eax,eax |
||
8133 | IgorA | 373 | mov ebx,[ebp+KOLIBRI_THREAD_DATA_X*4] |
374 | mov ecx,[ebp+KOLIBRI_THREAD_DATA_Y*4] |
||
375 | mov edx,[ebp+KOLIBRI_THREAD_DATA_C_WINDOW*4] |
||
376 | mov esi,[ebp+KOLIBRI_THREAD_DATA_C_HEADER*4] |
||
377 | mov edi,[ebp+KOLIBRI_THREAD_DATA_C_BORDER*4] |
||
8129 | IgorA | 378 | int 0x40 |
8133 | IgorA | 379 | mov edx,[ebp+KOLIBRI_THREAD_DATA_TITLE*4] |
8129 | IgorA | 380 | test edx,edx |
381 | jz .window_defined |
||
382 | mov edi,edx |
||
383 | mov ecx,0xFFFFFFFF |
||
384 | xor al,al |
||
385 | cld |
||
386 | repnz scas byte [edi] |
||
387 | not ecx |
||
388 | mov esi,ecx |
||
389 | dec esi |
||
390 | jz .window_defined |
||
8170 | IgorA | 391 | mov eax,SF_DRAW_TEXT |
8129 | IgorA | 392 | mov ebx,0x00070007 |
8133 | IgorA | 393 | mov ecx,[ebp+KOLIBRI_THREAD_DATA_C_TITLE*4] |
8129 | IgorA | 394 | int 0x40 |
395 | .window_defined: |
||
396 | .redraw_picture: |
||
8170 | IgorA | 397 | mov eax,SF_REDRAW |
398 | mov ebx,SSF_END_DRAW |
||
8129 | IgorA | 399 | int 0x40 |
8133 | IgorA | 400 | mov esi,[ebp+KOLIBRI_THREAD_DATA_PICTURE*4] |
8129 | IgorA | 401 | test esi,esi |
402 | jz .redraw_end_draw |
||
8133 | IgorA | 403 | mov ecx,[ebp+KOLIBRI_THREAD_DATA_SZ_PICT*4] |
8129 | IgorA | 404 | jecxz .redraw_end_draw |
8133 | IgorA | 405 | mov al,byte [ebp+KOLIBRI_THREAD_DATA_C_WINDOW*4+3] |
8129 | IgorA | 406 | and al,15 |
8170 | IgorA | 407 | mov edx,KOLIBRI_BORDER_SIZE*65536+KOLIBRI_HEADER_SIZE |
8129 | IgorA | 408 | cmp al,3 |
409 | jnz .redraw_no_skin |
||
8170 | IgorA | 410 | mov eax,SF_STYLE_SETTINGS |
411 | mov ebx,SSF_GET_SKIN_HEIGHT |
||
8129 | IgorA | 412 | int 0x40 |
413 | mov dx,ax |
||
414 | .redraw_no_skin: |
||
8170 | IgorA | 415 | mov eax,SF_PUT_IMAGE |
8129 | IgorA | 416 | mov ebx,esi |
417 | int 0x40 |
||
418 | .redraw_end_draw: |
||
419 | pop edi esi ebx ebp |
||
420 | ret |
||
421 | endp |
||
422 | |||
423 | proc @Kolibri@MoveWindow$qxpxi uses ebx esi |
||
424 | mov eax,[esp+12] |
||
425 | mov ebx,[eax] |
||
426 | mov ecx,[eax+4] |
||
427 | mov edx,[eax+8] |
||
428 | mov esi,[eax+12] |
||
8170 | IgorA | 429 | mov eax,SF_CHANGE_WINDOW |
8129 | IgorA | 430 | int 0x40 |
431 | ret |
||
432 | endp |
||
433 | |||
8170 | IgorA | 434 | proc @Kolibri@ExitDebug$qv |
435 | push dword [@Kolibri@DebugPrefix] |
||
436 | call @Kolibri@DebugPutString$qpxc |
||
437 | mov dword [esp],Kolibri_debug_string |
||
438 | call @Kolibri@DebugPutString$qpxc |
||
439 | pop ecx |
||
440 | jmp @Kolibri@ExitProcess$qv |
||
441 | endp |
||
442 | |||
8129 | IgorA | 443 | proc @Kolibri@ExitProcess$qv |
444 | lock bts dword [@Kolibri@_ExitProcessNow],0 |
||
445 | jc .exit_process_wait |
||
446 | sub esp,1024 |
||
8170 | IgorA | 447 | mov eax,SF_THREAD_INFO |
8129 | IgorA | 448 | mov ebx,esp |
449 | mov ecx,-1 |
||
450 | int 0x40 |
||
451 | mov esi,eax |
||
452 | mov edi,[esp+30] |
||
453 | .exit_process_loop: |
||
8170 | IgorA | 454 | mov eax,SF_THREAD_INFO |
8129 | IgorA | 455 | mov ebx,esp |
456 | mov ecx,esi |
||
457 | int 0x40 |
||
458 | mov eax,[esp+30] |
||
459 | cmp eax,edi |
||
460 | jz .exit_process_continue |
||
461 | mov ebx,eax |
||
462 | or bl,15 |
||
463 | inc ebx |
||
464 | jz .exit_process_continue |
||
465 | mov ebx,eax |
||
8170 | IgorA | 466 | call Kolibri_HashInt |
8129 | IgorA | 467 | movzx eax,al |
468 | mov eax,dword [@Kolibri@_ThreadTable+eax*4] |
||
469 | jmp .exit_process_test |
||
470 | .exit_process_next: |
||
8133 | IgorA | 471 | mov eax,dword [eax+KOLIBRI_THREAD_DATA_NEXT*4] |
8129 | IgorA | 472 | .exit_process_test: |
473 | test eax,eax |
||
474 | jz .exit_process_continue |
||
8133 | IgorA | 475 | cmp ebx,[eax+KOLIBRI_THREAD_DATA_PID*4] |
8129 | IgorA | 476 | jnz .exit_process_next |
8170 | IgorA | 477 | mov eax,SF_SYSTEM |
478 | mov ebx,SSF_TERMINATE_THREAD |
||
8129 | IgorA | 479 | mov ecx,esi |
480 | int 0x40 |
||
481 | .exit_process_continue: |
||
482 | dec esi |
||
483 | jnl .exit_process_loop |
||
484 | add esp,1024 |
||
485 | mov dword [@Kolibri@_ExitProcessNow],-1 |
||
486 | if defined EMULATOR |
||
487 | int3 |
||
488 | call 0x76543210 |
||
489 | end if |
||
490 | .exit_process_end: |
||
491 | mov dword [@Kolibri@_ThreadMutex],0 |
||
492 | or eax,-1 |
||
493 | int 0x40 |
||
494 | .exit_process_wait: |
||
8170 | IgorA | 495 | mov eax,SF_SLEEP |
8129 | IgorA | 496 | mov ebx,1 |
497 | .exit_process_wait_loop: |
||
498 | cmp dword [@Kolibri@_ExitProcessNow],0 |
||
499 | jl .exit_process_end |
||
500 | int 0x40 |
||
501 | shl ebx,1 |
||
8170 | IgorA | 502 | cmp ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT |
8129 | IgorA | 503 | jna .exit_process_wait_loop |
8170 | IgorA | 504 | mov ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT |
8129 | IgorA | 505 | jmp .exit_process_wait_loop |
506 | endp |
||
507 | |||
508 | proc @Kolibri@ExitThread$qppv,@Kolibri@ThreadMain$qpvt1 |
||
509 | mov esp,[esp+4] |
||
8170 | IgorA | 510 | jmp Kolibri_main_end |
8129 | IgorA | 511 | endp |
512 | |||
513 | proc @Kolibri@ReturnMessageLoop$qppv,@Kolibri@ThreadMain$qpvt1 |
||
514 | mov esp,[esp+4] |
||
8133 | IgorA | 515 | bt dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],30 |
8170 | IgorA | 516 | jc Kolibri_main_end |
517 | jmp Kolibri_main_cycle |
||
8129 | IgorA | 518 | endp |
519 | |||
520 | proc @Kolibri@Delay$qui uses ebx |
||
8170 | IgorA | 521 | mov eax,SF_SLEEP |
8129 | IgorA | 522 | mov ebx,[esp+8] |
523 | int 0x40 |
||
524 | ret |
||
525 | endp |
||
526 | |||
527 | proc @Kolibri@Clock$qv uses ebx |
||
8170 | IgorA | 528 | mov eax,SF_SYSTEM_GET |
529 | mov ebx,SSF_TIME_COUNT |
||
8129 | IgorA | 530 | int 0x40 |
531 | ret |
||
532 | endp |
||
533 | |||
8170 | IgorA | 534 | proc @Kolibri@DrawButton$qllllll uses ebx esi |
535 | mov eax,SF_DEFINE_BUTTON |
||
536 | mov ebx,[esp+12-2+8] |
||
537 | mov bx,[esp+20+8] |
||
538 | mov ecx,[esp+16-2+8] |
||
539 | mov cx,[esp+24+8] |
||
540 | mov edx,[esp+4+8] |
||
541 | mov esi,[esp+8+8] |
||
542 | int 0x40 |
||
543 | ret |
||
544 | endp |
||
545 | |||
8129 | IgorA | 546 | proc @Kolibri@GetPackedTime$qv |
8170 | IgorA | 547 | mov eax,SF_GET_SYS_TIME |
8129 | IgorA | 548 | int 0x40 |
549 | ret |
||
550 | endp |
||
551 | |||
552 | proc @Kolibri@GetTime$qpi |
||
8170 | IgorA | 553 | mov eax,SF_GET_SYS_TIME |
8129 | IgorA | 554 | int 0x40 |
555 | mov edx,[esp+4] |
||
556 | movzx ecx,al |
||
557 | shr ecx,4 |
||
558 | and al,0x0F |
||
559 | imul ecx,10 |
||
560 | add cl,al |
||
561 | mov dword [edx+8],ecx |
||
562 | mov cl,ah |
||
563 | shr ecx,4 |
||
564 | and ah,0x0F |
||
565 | imul ecx,10 |
||
566 | add cl,ah |
||
567 | mov dword [edx+4],ecx |
||
568 | bswap eax |
||
569 | mov cl,ah |
||
570 | shr ecx,4 |
||
571 | and ah,0x0F |
||
572 | imul ecx,10 |
||
573 | add cl,ah |
||
574 | mov dword [edx],ecx |
||
575 | ret |
||
576 | endp |
||
577 | |||
578 | proc @Kolibri@GetPackedDate$qv |
||
8170 | IgorA | 579 | mov eax,SF_GET_SYS_DATE |
8129 | IgorA | 580 | int 0x40 |
581 | ret |
||
582 | endp |
||
583 | |||
584 | proc @Kolibri@GetDate$qpi |
||
8170 | IgorA | 585 | mov eax,SF_GET_SYS_DATE |
8129 | IgorA | 586 | int 0x40 |
587 | mov edx,[esp+4] |
||
588 | movzx ecx,al |
||
589 | shr ecx,4 |
||
590 | and al,0x0F |
||
591 | imul ecx,10 |
||
592 | add cl,al |
||
593 | mov dword [edx+4],ecx |
||
594 | mov cl,ah |
||
595 | shr ecx,4 |
||
596 | and ah,0x0F |
||
597 | imul ecx,10 |
||
598 | add cl,ah |
||
599 | mov dword [edx],ecx |
||
600 | bswap eax |
||
601 | mov cl,ah |
||
602 | shr ecx,4 |
||
603 | and ah,0x0F |
||
604 | imul ecx,10 |
||
605 | add cl,ah |
||
606 | mov dword [edx+8],ecx |
||
607 | ret |
||
608 | endp |
||
609 | |||
610 | proc @Kolibri@ReadCommonColors$qpui uses ebx |
||
8170 | IgorA | 611 | mov eax,SF_STYLE_SETTINGS |
612 | mov ebx,SSF_GET_COLORS |
||
8129 | IgorA | 613 | mov ecx,[esp+8] |
614 | mov edx,40 |
||
615 | int 0x40 |
||
616 | ret |
||
617 | endp |
||
618 | |||
8133 | IgorA | 619 | proc @Kolibri@DrawText$qssipxc uses ebx |
8170 | IgorA | 620 | mov eax,SF_DRAW_TEXT |
8133 | IgorA | 621 | mov ebx,[esp+8-2] |
622 | mov bx,[esp+12] |
||
623 | mov ecx,[esp+16] |
||
624 | or ecx,0x80000000 |
||
625 | mov edx,[esp+20] |
||
626 | int 0x40 |
||
627 | ret |
||
628 | endp |
||
629 | |||
8170 | IgorA | 630 | proc @Kolibri@SetWindowCaption$qpxc uses ebx |
631 | mov eax,SF_SET_CAPTION |
||
632 | mov ebx,2 |
||
633 | mov ecx,[esp+8] |
||
634 | int 0x40 |
||
635 | ret |
||
636 | endp |
||
637 | |||
8129 | IgorA | 638 | proc @Kolibri@GetProcessInfo$qpuipct1t1piui uses ebx esi edi |
639 | sub esp,1024 |
||
8170 | IgorA | 640 | mov eax,SF_THREAD_INFO |
8129 | IgorA | 641 | mov ebx,esp |
642 | mov ecx,[1024+12+24+esp] |
||
643 | int 0x40 |
||
644 | xor edi,edi |
||
645 | or edi,[1024+12+4+esp] |
||
646 | jz .get_proc_info_no_usecpu |
||
647 | mov ecx,[esp] |
||
648 | mov [edi],ecx |
||
649 | xor edi,edi |
||
650 | .get_proc_info_no_usecpu: |
||
651 | or edi,[1024+12+8+esp] |
||
652 | jz .get_proc_info_no_name |
||
653 | lea esi,[esp+10] |
||
654 | cld |
||
8170 | IgorA | 655 | movsd |
656 | movsd |
||
657 | movsd |
||
8129 | IgorA | 658 | mov byte [edi],0 |
659 | xor edi,edi |
||
660 | .get_proc_info_no_name: |
||
661 | or edi,[1024+12+12+esp] |
||
662 | jz .get_proc_info_no_mem |
||
663 | mov ecx,[esp+26] |
||
664 | mov [edi],ecx |
||
665 | xor edi,edi |
||
666 | .get_proc_info_no_mem: |
||
667 | or edi,[1024+12+16+esp] |
||
668 | jz .get_proc_info_no_pid |
||
669 | mov ecx,[esp+30] |
||
670 | mov [edi],ecx |
||
671 | xor edi,edi |
||
672 | .get_proc_info_no_pid: |
||
673 | or edi,[1024+12+20+esp] |
||
674 | jz .get_proc_info_no_rect |
||
675 | lea esi,[esp+34] |
||
676 | cld |
||
8170 | IgorA | 677 | movsd |
678 | movsd |
||
679 | movsd |
||
680 | movsd |
||
8129 | IgorA | 681 | xor edi,edi |
682 | .get_proc_info_no_rect: |
||
683 | add esp,1024 |
||
684 | ret |
||
685 | endp |
||
686 | |||
687 | proc @Kolibri@GetPid$qv uses ebx |
||
688 | sub esp,1024 |
||
8170 | IgorA | 689 | mov eax,SF_THREAD_INFO |
8129 | IgorA | 690 | mov ebx,esp |
691 | mov ecx,-1 |
||
692 | int 0x40 |
||
693 | mov eax,[esp+30] |
||
694 | add esp,1024 |
||
695 | ret |
||
696 | endp |
||
697 | |||
698 | proc @Kolibri@GetPid$qppv |
||
699 | mov ecx,[esp+4] |
||
8133 | IgorA | 700 | mov eax,[ecx+KOLIBRI_THREAD_DATA_PID*4] |
8129 | IgorA | 701 | ret |
702 | endp |
||
703 | |||
704 | proc @Kolibri@_HashByte$qui |
||
705 | @Kolibri@_HashWord$qui: |
||
706 | @Kolibri@_HashDword$qui: |
||
707 | mov eax,[esp+4] |
||
8170 | IgorA | 708 | Kolibri_HashInt: |
709 | mul dword [Kolibri_hash_int_val0] |
||
8129 | IgorA | 710 | xor eax,edx |
711 | bswap eax |
||
8170 | IgorA | 712 | mul dword [Kolibri_hash_int_val1] |
8129 | IgorA | 713 | shrd eax,edx,14 |
714 | bswap eax |
||
715 | lea eax,[eax+4*eax] |
||
716 | ror eax,9 |
||
717 | ret |
||
718 | endp |
||
719 | |||
8170 | IgorA | 720 | if defined @Kolibri@_HashByte$qui | defined @Kolibri@_HashWord$qui | defined @Kolibri@_HashDword$qui |
721 | Kolibri_hash_int_val0: |
||
8129 | IgorA | 722 | dd 0xA82F94C5 |
8170 | IgorA | 723 | Kolibri_hash_int_val1: |
8129 | IgorA | 724 | dd 0x9193780B |
8170 | IgorA | 725 | end if |
8129 | IgorA | 726 | |
727 | proc @Kolibri@GetThreadData$qv |
||
728 | call @Kolibri@GetPid$qv |
||
729 | push eax |
||
730 | call @Kolibri@GetThreadData$qui |
||
731 | pop ecx |
||
732 | ret |
||
733 | endp |
||
734 | |||
735 | proc @Kolibri@GetThreadData$qui |
||
736 | mov eax,[esp+4] |
||
8170 | IgorA | 737 | call Kolibri_HashInt |
8129 | IgorA | 738 | movzx eax,al |
739 | cmp dword [@Kolibri@_ThreadScanCount+4],0 |
||
740 | jnz .get_thread_data_wait |
||
741 | .get_thread_data_nowait: |
||
742 | lock inc dword [@Kolibri@_ThreadScanCount] |
||
743 | mov eax,dword [@Kolibri@_ThreadTable+eax*4] |
||
744 | mov ecx,[esp+4] |
||
745 | jmp .get_thread_data_test |
||
746 | .get_thread_data_loop: |
||
8133 | IgorA | 747 | mov eax,dword [eax+KOLIBRI_THREAD_DATA_NEXT*4] |
8129 | IgorA | 748 | .get_thread_data_test: |
749 | test eax,eax |
||
750 | jz .get_thread_data_end |
||
8133 | IgorA | 751 | cmp ecx,[eax+KOLIBRI_THREAD_DATA_PID*4] |
8129 | IgorA | 752 | jnz .get_thread_data_loop |
753 | .get_thread_data_end: |
||
754 | lock dec dword [@Kolibri@_ThreadScanCount] |
||
755 | ret |
||
756 | .get_thread_data_wait: |
||
757 | push eax ebx |
||
8170 | IgorA | 758 | mov eax,SF_SLEEP |
8129 | IgorA | 759 | mov ebx,1 |
760 | .get_thread_data_wait_loop: |
||
761 | int 0x40 |
||
762 | cmp dword [@Kolibri@_ThreadScanCount+4],0 |
||
763 | jz .get_thread_data_wait_end |
||
764 | shl ebx,1 |
||
8170 | IgorA | 765 | cmp ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT |
8129 | IgorA | 766 | jna .get_thread_data_wait_loop |
8170 | IgorA | 767 | mov ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT |
8129 | IgorA | 768 | jmp .get_thread_data_wait_loop |
769 | .get_thread_data_wait_end: |
||
770 | pop ebx eax |
||
771 | jmp .get_thread_data_nowait |
||
772 | endp |
||
773 | |||
774 | proc @Kolibri@_GetSkinHeader$qv uses ebx |
||
8170 | IgorA | 775 | mov eax,SF_STYLE_SETTINGS |
776 | mov ebx,SSF_GET_SKIN_HEIGHT |
||
8129 | IgorA | 777 | int 0x40 |
778 | ret |
||
779 | endp |
||
780 | |||
781 | proc @Kolibri@GetScreenSize$qrust1 |
||
8170 | IgorA | 782 | mov eax,SF_GET_SCREEN_SIZE |
8129 | IgorA | 783 | int 0x40 |
784 | mov ecx,[esp+8] |
||
785 | mov word [ecx],ax |
||
786 | mov ecx,[esp+4] |
||
787 | shr eax,16 |
||
788 | mov word [ecx],ax |
||
789 | ret |
||
790 | endp |
||
791 | |||
8170 | IgorA | 792 | proc Kolibri_MutexLockNoWait |
8129 | IgorA | 793 | pop eax |
794 | xor al,al |
||
795 | ret |
||
796 | endp |
||
797 | |||
8170 | IgorA | 798 | proc Kolibri_MutexLockWait uses ebx |
799 | mov eax,SF_SLEEP |
||
8129 | IgorA | 800 | xor ebx,ebx |
801 | .lock_wait_cycle: |
||
802 | int 0x40 |
||
803 | shl byte [ecx],1 |
||
804 | jz .lock_wait_cycle |
||
805 | mov al,1 |
||
806 | ret |
||
807 | endp |
||
808 | |||
8170 | IgorA | 809 | proc Kolibri_MutexLockWaitTime |
8129 | IgorA | 810 | cmp dword [esp+12],0 |
811 | jng .MutexLockWait |
||
812 | push ebx edx |
||
813 | mov edx,[esp+20] |
||
8170 | IgorA | 814 | mov eax,SF_SYSTEM_GET |
815 | mov ebx,SSF_TIME_COUNT |
||
8129 | IgorA | 816 | int 0x40 |
817 | add edx,eax |
||
818 | .lock_wait_time_cycle: |
||
8170 | IgorA | 819 | mov eax,SF_SLEEP |
8129 | IgorA | 820 | xor ebx,ebx |
821 | int 0x40 |
||
822 | shl byte [ecx],1 |
||
823 | jnz .lock_wait_time_ret_true |
||
8170 | IgorA | 824 | mov eax,SF_SYSTEM_GET |
825 | mov ebx,SSF_TIME_COUNT |
||
8129 | IgorA | 826 | int 0x40 |
827 | cmp eax,edx |
||
828 | js .lock_wait_time_cycle |
||
829 | pop edx ebx eax |
||
830 | xor al,al |
||
831 | ret |
||
832 | .lock_wait_time_ret_true: |
||
833 | pop edx ebx |
||
834 | mov al,1 |
||
835 | ret |
||
836 | endp |
||
837 | |||
8170 | IgorA | 838 | proc Kolibri_MutexLock |
8129 | IgorA | 839 | shl byte [ecx],1 |
840 | jnz .lock_first |
||
841 | call eax |
||
842 | .lock_first: |
||
843 | mov al,1 |
||
844 | ret |
||
845 | endp |
||
846 | |||
847 | proc @Kolibri@TryLock$qp14Kolibri@TMutex |
||
8170 | IgorA | 848 | mov eax,Kolibri_MutexLockNoWait |
8129 | IgorA | 849 | mov ecx,[esp+4] |
8170 | IgorA | 850 | jmp Kolibri_MutexLock |
8129 | IgorA | 851 | endp |
852 | |||
853 | proc @Kolibri@Lock$qp14Kolibri@TMutex |
||
8170 | IgorA | 854 | mov eax,Kolibri_MutexLockWait |
8129 | IgorA | 855 | mov ecx,[esp+4] |
8170 | IgorA | 856 | jmp Kolibri_MutexLock |
8129 | IgorA | 857 | endp |
858 | |||
859 | proc @Kolibri@LockTime$qp14Kolibri@TMutexi |
||
8170 | IgorA | 860 | mov eax,Kolibri_MutexLockWaitTime |
8129 | IgorA | 861 | mov ecx,[esp+4] |
8170 | IgorA | 862 | jmp Kolibri_MutexLock |
8129 | IgorA | 863 | endp |
864 | |||
865 | proc @Kolibri@UnLock$qp14Kolibri@TMutex |
||
866 | mov ecx,[esp+4] |
||
867 | shr byte [ecx],1 |
||
868 | jz .unlock_pause |
||
869 | ret |
||
870 | .unlock_pause: |
||
871 | mov byte [ecx],0x40 |
||
872 | push ebx |
||
8170 | IgorA | 873 | mov eax,SF_SLEEP |
8129 | IgorA | 874 | xor ebx,ebx |
875 | int 0x40 |
||
876 | pop ebx |
||
877 | ret |
||
878 | endp |
||
879 | |||
8170 | IgorA | 880 | proc Kolibri_MutexLockRec |
8129 | IgorA | 881 | shl byte [ecx],1 |
882 | jng .lock_first |
||
883 | cmp dword [ecx+4],edx |
||
884 | jz .lock_rec_self |
||
885 | call eax |
||
886 | .lock_rec_first: |
||
887 | mov al,1 |
||
888 | mov dword [ecx+4],edx |
||
889 | ret |
||
890 | .lock_rec_self: |
||
891 | mov al,1 |
||
892 | add dword [ecx],0x100 |
||
893 | jc .lock_rec_overflow |
||
894 | ret |
||
895 | .lock_rec_overflow: |
||
896 | push dword [@Kolibri@DebugPrefix] |
||
897 | call @Kolibri@DebugPutString$qpxc |
||
8170 | IgorA | 898 | mov dword [esp],Kolibri_try_lock_rec_overflow_string |
8129 | IgorA | 899 | call @Kolibri@DebugPutString$qpxc |
900 | pop ecx |
||
8170 | IgorA | 901 | jmp @Kolibri@ExitDebug$qv |
8129 | IgorA | 902 | endp |
903 | |||
904 | proc @Kolibri@TryLock$qp16Kolibri@TRecMutexui |
||
8170 | IgorA | 905 | mov eax,Kolibri_MutexLockNoWait |
8129 | IgorA | 906 | mov ecx,[esp+4] |
907 | mov edx,[esp+8] |
||
8170 | IgorA | 908 | jmp Kolibri_MutexLockRec |
8129 | IgorA | 909 | endp |
910 | |||
911 | proc @Kolibri@Lock$qp16Kolibri@TRecMutexui |
||
8170 | IgorA | 912 | mov eax,Kolibri_MutexLockWait |
8129 | IgorA | 913 | mov ecx,[esp+4] |
914 | mov edx,[esp+8] |
||
8170 | IgorA | 915 | jmp Kolibri_MutexLockRec |
8129 | IgorA | 916 | endp |
917 | |||
918 | proc @Kolibri@LockTime$qp16Kolibri@TRecMutexiui |
||
8170 | IgorA | 919 | mov eax,Kolibri_MutexLockWaitTime |
8129 | IgorA | 920 | mov ecx,[esp+4] |
921 | mov edx,[esp+12] |
||
8170 | IgorA | 922 | jmp Kolibri_MutexLockRec |
8129 | IgorA | 923 | endp |
924 | |||
925 | proc @Kolibri@UnLock$qp16Kolibri@TRecMutexui |
||
926 | mov ecx,[esp+4] |
||
927 | mov edx,[esp+8] |
||
928 | cmp dword [ecx+4],edx |
||
929 | jnz .unlock_rec_notlocked |
||
930 | sub dword [ecx],0x100 |
||
931 | jnc .unlock_rec_end |
||
932 | add dword [ecx],0x100 |
||
933 | shl byte [ecx],1 |
||
934 | shr byte [ecx],2 |
||
935 | jng .unlock_rec_pause |
||
936 | .unlock_rec_end: |
||
937 | ret |
||
938 | .unlock_rec_pause: |
||
939 | mov byte [ecx],0x20 |
||
940 | push ebx |
||
8170 | IgorA | 941 | mov eax,SF_SLEEP |
8129 | IgorA | 942 | xor ebx,ebx |
943 | int 0x40 |
||
944 | pop ebx |
||
945 | ret |
||
946 | .unlock_rec_notlocked: |
||
947 | push dword [@Kolibri@DebugPrefix] |
||
948 | call @Kolibri@DebugPutString$qpxc |
||
8170 | IgorA | 949 | mov dword [esp],Kolibri_unlock_rec_notlocked_string |
8129 | IgorA | 950 | call @Kolibri@DebugPutString$qpxc |
951 | pop ecx |
||
8170 | IgorA | 952 | jmp @Kolibri@ExitDebug$qv |
8129 | IgorA | 953 | endp |
954 | |||
955 | proc @Kolibri@DebugPutChar$qc |
||
956 | mov cl,byte [esp+4] |
||
957 | cmp cl,13 |
||
958 | jz .debug_put_char_ret |
||
959 | push ebx |
||
960 | cmp cl,10 |
||
961 | jz .debug_put_char_enter |
||
962 | .debug_put_char_after_cmp: |
||
8170 | IgorA | 963 | mov eax,SF_BOARD |
964 | mov ebx,SSF_DEBUG_WRITE |
||
8129 | IgorA | 965 | int 0x40 |
966 | pop ebx |
||
967 | .debug_put_char_ret: |
||
968 | ret |
||
969 | .debug_put_char_enter: |
||
970 | mov cl,13 |
||
8170 | IgorA | 971 | mov eax,SF_BOARD |
972 | mov ebx,SSF_DEBUG_WRITE |
||
8129 | IgorA | 973 | int 0x40 |
974 | mov cl,10 |
||
975 | jmp .debug_put_char_after_cmp |
||
976 | endp |
||
977 | |||
8170 | IgorA | 978 | proc @Kolibri@DebugPutString$qpxc uses esi |
8129 | IgorA | 979 | push dword 0 |
980 | mov esi,dword [esp+12] |
||
981 | jmp .debug_put_string_test |
||
982 | .debug_put_string_loop: |
||
983 | mov dword [esp],eax |
||
984 | call @Kolibri@DebugPutChar$qc |
||
985 | inc esi |
||
986 | .debug_put_string_test: |
||
987 | xor eax,eax |
||
988 | or al,[esi] |
||
989 | test al,al |
||
990 | jnz .debug_put_string_loop |
||
8170 | IgorA | 991 | pop ecx |
8129 | IgorA | 992 | ret |
993 | endp |
||
994 | |||
995 | proc @Kolibri@GetKey$qv |
||
8170 | IgorA | 996 | mov eax,SF_GET_KEY |
8129 | IgorA | 997 | int 0x40 |
998 | test al,al |
||
999 | jnz .get_key_eof |
||
1000 | movzx eax,ah |
||
1001 | ret |
||
1002 | .get_key_eof: |
||
8170 | IgorA | 1003 | mov eax,SF_TERMINATE_PROCESS |
8129 | IgorA | 1004 | ret |
1005 | endp |
||
1006 | |||
1007 | proc @Kolibri@GetMouseButton$qv uses ebx |
||
8170 | IgorA | 1008 | mov eax,SF_MOUSE_GET |
1009 | mov ebx,SSF_BUTTON |
||
8129 | IgorA | 1010 | int 0x40 |
1011 | ret |
||
1012 | endp |
||
1013 | |||
1014 | proc @Kolibri@GetMousePosition$qrst1o uses ebx |
||
8170 | IgorA | 1015 | mov eax,SF_MOUSE_GET |
1016 | xor ebx,ebx ;SSF_SCREEN_POSITION |
||
8129 | IgorA | 1017 | cmp byte [esp+16],0 |
1018 | jnz .get_mouse_pos_absolute |
||
1019 | inc ebx |
||
1020 | .get_mouse_pos_absolute: |
||
1021 | int 0x40 |
||
1022 | mov ecx,[esp+12] |
||
1023 | mov word [ecx],ax |
||
1024 | mov ecx,[esp+8] |
||
1025 | shr eax,16 |
||
1026 | mov word [ecx],ax |
||
1027 | ret |
||
1028 | endp |
||
1029 | |||
1030 | proc @Kolibri@WasThreadCreated$qv |
||
1031 | cmp byte [@Kolibri@_ThreadSavedBegProc],0x90 |
||
1032 | setz al |
||
1033 | ret |
||
1034 | endp |
||
1035 | |||
1036 | proc @Kolibri@CreateThread$qpvuit1 |
||
1037 | push ebx |
||
1038 | mov edx,[esp+16] |
||
1039 | mov ebx,[esp+12] |
||
1040 | test edx,edx |
||
1041 | jnz .create_thread_after_new |
||
8170 | IgorA | 1042 | if defined KolibriHeapAlloc |
8129 | IgorA | 1043 | cmp ebx,4096 |
1044 | jnb .create_thread_alloc |
||
1045 | mov ebx,STACKSIZE |
||
1046 | .create_thread_alloc: |
||
1047 | push ebx |
||
8170 | IgorA | 1048 | call KolibriHeapAlloc ; Create new dynamic memory of the given size |
8129 | IgorA | 1049 | pop ecx |
1050 | test eax,eax |
||
1051 | jnz .create_thread_mem_created |
||
1052 | end if |
||
1053 | or eax,-1 |
||
1054 | jmp .create_thread_end |
||
1055 | .create_thread_mem_created: |
||
1056 | lea edx,[eax+ebx] |
||
1057 | .create_thread_after_new: |
||
1058 | neg ebx |
||
1059 | jz .create_thread_test_first |
||
1060 | add ebx,edx |
||
1061 | .create_thread_test_first: |
||
1062 | cmp byte [@Kolibri@_ThreadSavedBegProc],0x90 |
||
1063 | jnz .create_thread_init |
||
1064 | .create_thread_fill_stack: |
||
1065 | lock inc dword [@Kolibri@_ThreadNumber] |
||
1066 | and edx,not 3 |
||
1067 | sub edx,12 |
||
1068 | mov ecx,[esp+8] |
||
1069 | mov dword [edx+8],ebx |
||
1070 | mov dword [edx+4],ecx |
||
8170 | IgorA | 1071 | mov dword [edx],Kolibri_ThreadFinish |
1072 | mov eax,SF_CREATE_THREAD |
||
8129 | IgorA | 1073 | mov ebx,1 |
1074 | mov ecx,@Kolibri@ThreadMain$qpvt1 |
||
1075 | int 0x40 |
||
1076 | mov ebx,eax |
||
1077 | or bl,15 |
||
1078 | inc ebx |
||
1079 | jnz .create_thread_end |
||
1080 | lock dec dword [@Kolibri@_ThreadNumber] |
||
8170 | IgorA | 1081 | if defined KolibriHeapFree |
8129 | IgorA | 1082 | or ebx,[edx+8] |
1083 | jz .create_thread_end |
||
1084 | push ebx |
||
8170 | IgorA | 1085 | call KolibriHeapFree ; Delete the given dynamic memory |
8129 | IgorA | 1086 | pop ecx |
1087 | end if |
||
1088 | .create_thread_end: |
||
1089 | pop ebx |
||
1090 | ret |
||
1091 | .create_thread_init: |
||
1092 | push esi edi |
||
1093 | cld |
||
1094 | mov esi,@Kolibri@_ThreadSavedBegProc |
||
1095 | mov edi,@Kolibri@GetPid$qv |
||
8170 | IgorA | 1096 | movsd |
1097 | movsd |
||
8129 | IgorA | 1098 | mov edi,@Kolibri@GetThreadData$qv |
8170 | IgorA | 1099 | movsd |
1100 | movsd |
||
8129 | IgorA | 1101 | mov eax,0x90909090 |
1102 | mov edi,@Kolibri@_ThreadSavedBegProc |
||
8170 | IgorA | 1103 | stosd |
1104 | stosd |
||
1105 | stosd |
||
1106 | stosd |
||
8129 | IgorA | 1107 | pop edi esi |
1108 | jmp .create_thread_fill_stack |
||
1109 | endp |
||
1110 | |||
8184 | IgorA | 1111 | proc @Kolibri@_FileAccess$qp21Kolibri@FileInfoBlock uses ebx |
8170 | IgorA | 1112 | mov eax,SF_FILE |
8129 | IgorA | 1113 | mov ebx,[esp+8] |
1114 | int 0x40 |
||
1115 | mov ecx,[esp+8] |
||
1116 | mov [ecx],ebx |
||
1117 | ret |
||
1118 | endp |
||
1119 | |||
8170 | IgorA | 1120 | if defined Kolibri_debug_string |
1121 | Kolibri_debug_string: |
||
8129 | IgorA | 1122 | db 'Abnormal program termination.',10,0 |
8170 | IgorA | 1123 | end if |
1124 | |||
1125 | if defined Kolibri_MutexLockRec |
||
1126 | Kolibri_try_lock_rec_overflow_string: |
||
8129 | IgorA | 1127 | db 'Recursive mutex lock count overflow.',10,0 |
8170 | IgorA | 1128 | end if |
1129 | |||
1130 | if defined @Kolibri@UnLock$qp16Kolibri@TRecMutexui |
||
1131 | Kolibri_unlock_rec_notlocked_string: |
||
8129 | IgorA | 1132 | db 'Recursive mutex unlock error.',10,0 |
8170 | IgorA | 1133 | end if |
8129 | IgorA | 1134 | |
1135 | include "kos_lib.inc" |
||
1136 | |||
1137 | ;/**/ |
||
1138 |