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