Rev 766 | Rev 769 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ha | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
||
709 | diamond | 3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. |
431 | serge | 4 | ;; PROGRAMMING: |
5 | ;; Ivan Poddubny |
||
6 | ;; Marat Zakiyanov (Mario79) |
||
7 | ;; VaStaNi |
||
8 | ;; Trans |
||
9 | ;; Mihail Semenyako (mike.dld) |
||
10 | ;; Sergey Kuzmin (Wildwest) |
||
11 | ;; Andrey Halyavin (halyavin) |
||
12 | ;; Mihail Lisovin (Mihasik) |
||
13 | ;; Andrey Ignatiev (andrew_programmer) |
||
14 | ;; NoName |
||
15 | ;; Evgeny Grechnikov (Diamond) |
||
16 | ;; Iliya Mihailov (Ghost) |
||
17 | ;; Sergey Semyonov (Serge) |
||
18 | ;; Johnny_B |
||
543 | spraid | 19 | ;; SPraid (simba) |
1 | ha | 20 | ;; |
431 | serge | 21 | ;; Data in this file was originally part of MenuetOS project which is |
22 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
||
23 | ;; part of KolibriOS project under the terms of GNU GPL. |
||
1 | ha | 24 | ;; |
431 | serge | 25 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
26 | ;; PROGRAMMING: |
||
1 | ha | 27 | ;; |
431 | serge | 28 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
29 | ;; - main os coding/design |
||
30 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
||
31 | ;; Felix Kaiser, info@felix-kaiser.de |
||
32 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
||
33 | ;; quickcode@mail.ru |
||
34 | ;; Alexey, kgaz@crosswinds.net |
||
35 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
||
36 | ;; kristol@nic.fi |
||
37 | ;; Mike Hibbett, mikeh@oceanfree.net |
||
38 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
||
39 | ;; Jarek Pelczar, jarekp3@wp.pl |
||
1 | ha | 40 | ;; |
431 | serge | 41 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
42 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
||
43 | ;; consequences of using it or for whether it serves any particular purpose or |
||
44 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
||
45 | ;; License (the "GPL") for full details. |
||
46 | ; |
||
47 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
||
48 | ;; but only under the conditions described in the GPL. A copy of this license |
||
49 | ;; is supposed to have been given to you along with KolibriOS so you can know |
||
50 | ;; your rights and responsibilities. It should be in a file named COPYING. |
||
51 | ;; Among other things, the copyright notice and this notice must be preserved |
||
52 | ;; on all copies. |
||
53 | ;; |
||
1 | ha | 54 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
426 | mikedld | 55 | |
56 | include 'macros.inc' |
||
57 | |||
425 | victor | 58 | $Revision: 767 $ |
426 | mikedld | 59 | |
593 | mikedld | 60 | |
566 | serge | 61 | USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices |
62 | |||
164 | serge | 63 | include "proc32.inc" |
7 | me_root | 64 | include "kglobals.inc" |
1 | ha | 65 | include "lang.inc" |
66 | |||
164 | serge | 67 | include "const.inc" |
742 | Rus | 68 | max_processes equ 255 |
69 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
||
1 | ha | 70 | |
164 | serge | 71 | |
742 | Rus | 72 | os_stack equ (os_data_l-gdts) ; GDTs |
465 | serge | 73 | os_code equ (os_code_l-gdts) |
74 | graph_data equ (3+graph_data_l-gdts) |
||
742 | Rus | 75 | tss0 equ (tss0_l-gdts) |
465 | serge | 76 | app_code equ (3+app_code_l-gdts) |
77 | app_data equ (3+app_data_l-gdts) |
||
586 | serge | 78 | pci_code_sel equ (pci_code_32-gdts) |
79 | pci_data_sel equ (pci_data_32-gdts) |
||
1 | ha | 80 | |
81 | |||
82 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
83 | ;; |
||
84 | ;; Included files: |
||
85 | ;; |
||
86 | ;; Kernel16.inc |
||
87 | ;; - Booteng.inc English text for bootup |
||
88 | ;; - Bootcode.inc Hardware setup |
||
89 | ;; - Pci16.inc PCI functions |
||
90 | ;; |
||
91 | ;; Kernel32.inc |
||
92 | ;; - Sys32.inc Process management |
||
93 | ;; - Shutdown.inc Shutdown and restart |
||
94 | ;; - Fat32.inc Read / write hd |
||
95 | ;; - Vesa12.inc Vesa 1.2 driver |
||
96 | ;; - Vesa20.inc Vesa 2.0 driver |
||
97 | ;; - Vga.inc VGA driver |
||
98 | ;; - Stack.inc Network interface |
||
99 | ;; - Mouse.inc Mouse pointer |
||
100 | ;; - Scincode.inc Window skinning |
||
101 | ;; - Pci32.inc PCI functions |
||
102 | ;; |
||
103 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
104 | |||
105 | |||
106 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
107 | ;; ;; |
||
108 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
||
109 | ;; ;; |
||
110 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
111 | |||
112 | use16 |
||
742 | Rus | 113 | org 0x0 |
114 | jmp start_of_code |
||
1 | ha | 115 | |
641 | diamond | 116 | version db 'Kolibri OS version 0.7.1.0 ',13,10,13,10,0 |
1 | ha | 117 | |
465 | serge | 118 | include "boot/bootstr.inc" ; language-independent boot messages |
1 | ha | 119 | include "boot/preboot.inc" |
120 | |||
465 | serge | 121 | if lang eq en |
122 | include "boot/booteng.inc" ; english system boot messages |
||
123 | else if lang eq ru |
||
124 | include "boot/bootru.inc" ; russian system boot messages |
||
742 | Rus | 125 | include "boot/ru.inc" ; Russian font |
465 | serge | 126 | else if lang eq et |
127 | include "boot/bootet.inc" ; estonian system boot messages |
||
742 | Rus | 128 | include "boot/et.inc" ; Estonian font |
465 | serge | 129 | else |
130 | include "boot/bootge.inc" ; german system boot messages |
||
131 | end if |
||
1 | ha | 132 | |
465 | serge | 133 | include "boot/bootcode.inc" ; 16 bit system boot code |
134 | include "bus/pci/pci16.inc" |
||
709 | diamond | 135 | include "detect/biosdisk.inc" |
1 | ha | 136 | |
137 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
138 | ;; ;; |
||
139 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
||
140 | ;; ;; |
||
141 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
142 | |||
143 | |||
144 | ; CR0 Flags - Protected mode and Paging |
||
145 | |||
742 | Rus | 146 | mov ecx, CR0_PE |
1 | ha | 147 | |
148 | ; Enabling 32 bit protected mode |
||
149 | |||
742 | Rus | 150 | sidt [cs:old_ints_h] |
1 | ha | 151 | |
742 | Rus | 152 | cli ; disable all irqs |
153 | cld |
||
154 | mov al,255 ; mask all irqs |
||
155 | out 0xa1,al |
||
156 | out 0x21,al |
||
157 | l.5: in al, 0x64 ; Enable A20 |
||
158 | test al, 2 |
||
159 | jnz l.5 |
||
160 | mov al, 0xD1 |
||
161 | out 0x64, al |
||
162 | l.6: in al, 0x64 |
||
163 | test al, 2 |
||
164 | jnz l.6 |
||
165 | mov al, 0xDF |
||
166 | out 0x60, al |
||
167 | l.7: in al, 0x64 |
||
168 | test al, 2 |
||
169 | jnz l.7 |
||
170 | mov al, 0xFF |
||
171 | out 0x64, al |
||
465 | serge | 172 | |
742 | Rus | 173 | lgdt [cs:tmp_gdt] ; Load GDT |
174 | mov eax, cr0 ; protected mode |
||
175 | or eax, ecx |
||
176 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
||
177 | mov cr0, eax |
||
178 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
||
1 | ha | 179 | |
465 | serge | 180 | align 8 |
181 | tmp_gdt: |
||
1 | ha | 182 | |
742 | Rus | 183 | dw 23 |
184 | dd tmp_gdt+0x10000 |
||
185 | dw 0 |
||
183 | diamond | 186 | |
742 | Rus | 187 | dw 0xffff |
188 | dw 0x0000 |
||
189 | db 0x00 |
||
190 | dw 11011111b *256 +10011010b |
||
191 | db 0x00 |
||
375 | Ghost | 192 | |
742 | Rus | 193 | dw 0xffff |
194 | dw 0x0000 |
||
195 | db 0x00 |
||
196 | dw 11011111b *256 +10010010b |
||
197 | db 0x00 |
||
1 | ha | 198 | |
465 | serge | 199 | include "data16.inc" |
1 | ha | 200 | |
465 | serge | 201 | use32 |
202 | org $+0x10000 |
||
1 | ha | 203 | |
465 | serge | 204 | align 4 |
205 | B32: |
||
742 | Rus | 206 | mov ax,os_stack ; Selector for os |
207 | mov ds,ax |
||
208 | mov es,ax |
||
209 | mov fs,ax |
||
210 | mov gs,ax |
||
211 | mov ss,ax |
||
212 | mov esp,0x3ec00 ; Set stack |
||
1 | ha | 213 | |
465 | serge | 214 | ; CLEAR 0x280000 - HEAP_BASE |
1 | ha | 215 | |
742 | Rus | 216 | xor eax,eax |
217 | mov edi,0x280000 |
||
218 | mov ecx,(HEAP_BASE-OS_BASE-0x280000) / 4 |
||
219 | cld |
||
220 | rep stosd |
||
1 | ha | 221 | |
742 | Rus | 222 | mov edi,0x40000 |
223 | mov ecx,(0x90000-0x40000)/4 |
||
224 | rep stosd |
||
1 | ha | 225 | |
465 | serge | 226 | ; CLEAR KERNEL UNDEFINED GLOBALS |
742 | Rus | 227 | mov edi, endofcode-OS_BASE |
228 | mov ecx, (uglobals_size/4)+4 |
||
229 | rep stosd |
||
1 | ha | 230 | |
465 | serge | 231 | ; SAVE & CLEAR 0-0xffff |
1 | ha | 232 | |
742 | Rus | 233 | xor esi, esi |
234 | mov edi,0x2F0000 |
||
235 | mov ecx,0x10000 / 4 |
||
236 | rep movsd |
||
237 | xor edi, edi |
||
238 | mov ecx,0x10000 / 4 |
||
239 | rep stosd |
||
429 | serge | 240 | |
742 | Rus | 241 | call test_cpu |
242 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
||
424 | spraid | 243 | |
742 | Rus | 244 | call init_BIOS32 |
465 | serge | 245 | ; MEMORY MODEL |
742 | Rus | 246 | call mem_test |
247 | call init_mem |
||
248 | call init_page_map |
||
1 | ha | 249 | |
465 | serge | 250 | ; ENABLE PAGING |
1 | ha | 251 | |
742 | Rus | 252 | mov eax, sys_pgdir-OS_BASE |
253 | mov cr3, eax |
||
1 | ha | 254 | |
742 | Rus | 255 | mov eax,cr0 |
256 | or eax,CR0_PG+CR0_WP |
||
257 | mov cr0,eax |
||
1 | ha | 258 | |
742 | Rus | 259 | lgdt [gdts] |
260 | jmp pword os_code:high_code |
||
1 | ha | 261 | |
513 | serge | 262 | align 4 |
742 | Rus | 263 | bios32_entry dd ? |
264 | tmp_page_tabs dd ? |
||
586 | serge | 265 | |
498 | diamond | 266 | use16 |
267 | org $-0x10000 |
||
268 | include "boot/shutdown.inc" ; shutdown or restart |
||
269 | org $+0x10000 |
||
270 | use32 |
||
271 | |||
465 | serge | 272 | __DEBUG__ fix 1 |
273 | __DEBUG_LEVEL__ fix 1 |
||
274 | include 'init.inc' |
||
380 | serge | 275 | |
465 | serge | 276 | org OS_BASE+$ |
1 | ha | 277 | |
465 | serge | 278 | align 4 |
279 | high_code: |
||
742 | Rus | 280 | mov ax,os_stack |
281 | mov bx,app_data |
||
282 | mov ss,ax |
||
283 | add esp, OS_BASE |
||
1 | ha | 284 | |
742 | Rus | 285 | mov ds,bx |
286 | mov es,bx |
||
287 | mov fs,bx |
||
288 | mov gs,bx |
||
1 | ha | 289 | |
742 | Rus | 290 | bt [cpu_caps], CAPS_PGE |
291 | jnc @F |
||
1 | ha | 292 | |
742 | Rus | 293 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
519 | serge | 294 | |
742 | Rus | 295 | mov ebx, cr4 |
296 | or ebx, CR4_PGE |
||
297 | mov cr4, ebx |
||
519 | serge | 298 | @@: |
742 | Rus | 299 | xor eax, eax |
300 | mov dword [sys_pgdir], eax |
||
301 | mov dword [sys_pgdir+4], eax |
||
519 | serge | 302 | |
742 | Rus | 303 | mov eax, cr3 |
304 | mov cr3, eax ; flush TLB |
||
465 | serge | 305 | |
1 | ha | 306 | ; SAVE REAL MODE VARIABLES |
742 | Rus | 307 | mov ax, [BOOT_VAR + 0x9031] |
308 | mov [IDEContrRegsBaseAddr], ax |
||
76 | mario79 | 309 | ; --------------- APM --------------------- |
465 | serge | 310 | |
311 | ; init selectors |
||
742 | Rus | 312 | mov ebx, [BOOT_VAR+0x9040] ; offset of APM entry point |
465 | serge | 313 | movzx eax, word [BOOT_VAR+0x9050] ; real-mode segment base address of |
742 | Rus | 314 | ; protected-mode 32-bit code segment |
465 | serge | 315 | movzx ecx, word [BOOT_VAR+0x9052] ; real-mode segment base address of |
742 | Rus | 316 | ; protected-mode 16-bit code segment |
465 | serge | 317 | movzx edx, word [BOOT_VAR+0x9054] ; real-mode segment base address of |
742 | Rus | 318 | ; protected-mode 16-bit data segment |
465 | serge | 319 | |
320 | shl eax, 4 |
||
321 | mov [dword apm_code_32 + 2], ax |
||
322 | shr eax, 16 |
||
323 | mov [dword apm_code_32 + 4], al |
||
324 | |||
325 | shl ecx, 4 |
||
326 | mov [dword apm_code_16 + 2], cx |
||
327 | shr ecx, 16 |
||
328 | mov [dword apm_code_16 + 4], cl |
||
329 | |||
330 | shl edx, 4 |
||
331 | mov [dword apm_data_16 + 2], dx |
||
332 | shr edx, 16 |
||
333 | mov [dword apm_data_16 + 4], dl |
||
334 | |||
335 | mov dword[apm_entry], ebx |
||
76 | mario79 | 336 | mov word [apm_entry + 4], apm_code_32 - gdts |
337 | |||
465 | serge | 338 | mov eax, [BOOT_VAR + 0x9044] ; version & flags |
76 | mario79 | 339 | mov [apm_vf], eax |
340 | ; ----------------------------------------- |
||
465 | serge | 341 | ; movzx eax,byte [BOOT_VAR+0x9010] ; mouse port |
1 | ha | 342 | ; mov [0xF604],byte 1 ;al |
742 | Rus | 343 | mov al, [BOOT_VAR+0x901F] ; DMA access |
344 | mov [allow_dma_access], al |
||
345 | mov al,[BOOT_VAR+0x9000] ; bpp |
||
346 | mov [ScreenBPP],al |
||
753 | serge | 347 | |
759 | Rus | 348 | xchg bx, bx |
753 | serge | 349 | |
742 | Rus | 350 | movzx eax,word [BOOT_VAR+0x900A] ; X max |
351 | dec eax |
||
759 | Rus | 352 | mov [Screen_Max_X],eax |
742 | Rus | 353 | mov [screen_workarea.right],eax |
354 | movzx eax,word [BOOT_VAR+0x900C] ; Y max |
||
355 | dec eax |
||
759 | Rus | 356 | mov [Screen_Max_Y],eax |
742 | Rus | 357 | mov [screen_workarea.bottom],eax |
358 | movzx eax,word [BOOT_VAR+0x9008] ; screen mode |
||
359 | mov [SCR_MODE],eax |
||
360 | mov eax,[BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
||
361 | mov [BANK_SWITCH],eax |
||
362 | mov [BytesPerScanLine],word 640*4 ; Bytes PerScanLine |
||
363 | cmp [SCR_MODE],word 0x13 ; 320x200 |
||
364 | je @f |
||
365 | cmp [SCR_MODE],word 0x12 ; VGA 640x480 |
||
366 | je @f |
||
367 | mov ax,[BOOT_VAR+0x9001] ; for other modes |
||
368 | mov [BytesPerScanLine],ax |
||
465 | serge | 369 | @@: |
742 | Rus | 370 | mov esi, BOOT_VAR+0x9080 |
371 | movzx ecx, byte [esi-1] |
||
372 | mov [NumBiosDisks], ecx |
||
373 | mov edi, BiosDisksData |
||
374 | rep movsd |
||
1 | ha | 375 | |
376 | ; GRAPHICS ADDRESSES |
||
377 | |||
742 | Rus | 378 | mov byte [BOOT_VAR+0x901e],0x0 |
379 | mov eax,[BOOT_VAR+0x9018] |
||
380 | mov [LFBAddress],eax |
||
1 | ha | 381 | |
742 | Rus | 382 | cmp [SCR_MODE],word 0100000000000000b |
383 | jge setvesa20 |
||
384 | cmp [SCR_MODE],word 0x13 |
||
385 | je v20ga32 |
||
386 | mov [PUTPIXEL],dword Vesa12_putpixel24 ; Vesa 1.2 |
||
387 | mov [GETPIXEL],dword Vesa12_getpixel24 |
||
388 | cmp [ScreenBPP],byte 24 |
||
389 | jz ga24 |
||
390 | mov [PUTPIXEL],dword Vesa12_putpixel32 |
||
391 | mov [GETPIXEL],dword Vesa12_getpixel32 |
||
1 | ha | 392 | ga24: |
742 | Rus | 393 | jmp v20ga24 |
1 | ha | 394 | setvesa20: |
742 | Rus | 395 | mov [PUTPIXEL],dword Vesa20_putpixel24 ; Vesa 2.0 |
396 | mov [GETPIXEL],dword Vesa20_getpixel24 |
||
397 | cmp [ScreenBPP],byte 24 |
||
398 | jz v20ga24 |
||
1 | ha | 399 | v20ga32: |
742 | Rus | 400 | mov [PUTPIXEL],dword Vesa20_putpixel32 |
401 | mov [GETPIXEL],dword Vesa20_getpixel32 |
||
1 | ha | 402 | v20ga24: |
742 | Rus | 403 | cmp [SCR_MODE],word 0x12 ; 16 C VGA 640x480 |
404 | jne no_mode_0x12 |
||
405 | mov [PUTPIXEL],dword VGA_putpixel |
||
406 | mov [GETPIXEL],dword Vesa20_getpixel32 |
||
1 | ha | 407 | no_mode_0x12: |
408 | |||
375 | Ghost | 409 | ; -------- Fast System Call init ---------- |
378 | serge | 410 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
742 | Rus | 411 | bt [cpu_caps], CAPS_SEP |
412 | jnc .SEnP ; SysEnter not Present |
||
413 | xor edx, edx |
||
414 | mov ecx, MSR_SYSENTER_CS |
||
415 | mov eax, os_code |
||
416 | wrmsr |
||
417 | mov ecx, MSR_SYSENTER_ESP |
||
434 | diamond | 418 | ; mov eax, sysenter_stack ; Check it |
742 | Rus | 419 | xor eax, eax |
420 | wrmsr |
||
421 | mov ecx, MSR_SYSENTER_EIP |
||
422 | mov eax, sysenter_entry |
||
423 | wrmsr |
||
375 | Ghost | 424 | .SEnP: |
378 | serge | 425 | ; AMD SYSCALL/SYSRET |
742 | Rus | 426 | cmp byte[cpu_vendor], 'A' |
427 | jne .noSYSCALL |
||
428 | mov eax, 0x80000001 |
||
429 | cpuid |
||
430 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
||
431 | jz .noSYSCALL |
||
432 | mov ecx, MSR_AMD_EFER |
||
433 | rdmsr |
||
434 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
||
435 | wrmsr |
||
164 | serge | 436 | |
375 | Ghost | 437 | ; !!!! It`s dirty hack, fix it !!! |
438 | ; Bits of EDX : |
||
439 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
||
440 | ; and the contents of this field, plus 8, are copied into the SS register. |
||
441 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
||
442 | ; and the contents of this field, plus 8, are copied into the SS register. |
||
443 | |||
742 | Rus | 444 | ; mov edx, (os_code + 16) * 65536 + os_code |
445 | mov edx, 0x1B0008 |
||
375 | Ghost | 446 | |
742 | Rus | 447 | mov eax, syscall_entry |
448 | mov ecx, MSR_AMD_STAR |
||
449 | wrmsr |
||
375 | Ghost | 450 | .noSYSCALL: |
451 | ; ----------------------------------------- |
||
452 | |||
465 | serge | 453 | ; LOAD IDT |
378 | serge | 454 | |
742 | Rus | 455 | call build_interrupt_table |
456 | lidt [idtreg] |
||
378 | serge | 457 | |
742 | Rus | 458 | call init_kernel_heap |
459 | stdcall kernel_alloc, RING0_STACK_SIZE+512 |
||
460 | mov [os_stack_seg], eax |
||
164 | serge | 461 | |
742 | Rus | 462 | lea esp, [eax+RING0_STACK_SIZE] |
164 | serge | 463 | |
742 | Rus | 464 | mov [tss._ss0], os_stack |
465 | mov [tss._esp0], esp |
||
466 | mov [tss._esp], esp |
||
467 | mov [tss._cs],os_code |
||
468 | mov [tss._ss],os_stack |
||
469 | mov [tss._ds],app_data |
||
470 | mov [tss._es],app_data |
||
471 | mov [tss._fs],app_data |
||
472 | mov [tss._gs],app_data |
||
473 | mov [tss._io],128 |
||
465 | serge | 474 | ;Add IO access table - bit array of permitted ports |
742 | Rus | 475 | mov edi, tss._io_map_0 |
476 | xor eax, eax |
||
477 | not eax |
||
478 | mov ecx, 8192/4 |
||
479 | rep stosd ; access to 4096*8=65536 ports |
||
164 | serge | 480 | |
742 | Rus | 481 | mov ax,tss0 |
482 | ltr ax |
||
378 | serge | 483 | |
742 | Rus | 484 | mov [LFBSize], 0x800000 |
485 | call init_LFB |
||
486 | call init_fpu |
||
487 | call init_malloc |
||
276 | serge | 488 | |
742 | Rus | 489 | stdcall alloc_kernel_space, 0x51000 |
490 | mov [default_io_map], eax |
||
465 | serge | 491 | |
742 | Rus | 492 | add eax, 0x2000 |
493 | mov [ipc_tmp], eax |
||
494 | mov ebx, 0x1000 |
||
164 | serge | 495 | |
742 | Rus | 496 | add eax, 0x40000 |
497 | mov [proc_mem_map], eax |
||
164 | serge | 498 | |
742 | Rus | 499 | add eax, 0x8000 |
500 | mov [proc_mem_pdir], eax |
||
164 | serge | 501 | |
742 | Rus | 502 | add eax, ebx |
503 | mov [proc_mem_tab], eax |
||
164 | serge | 504 | |
742 | Rus | 505 | add eax, ebx |
506 | mov [tmp_task_pdir], eax |
||
164 | serge | 507 | |
742 | Rus | 508 | add eax, ebx |
509 | mov [tmp_task_ptab], eax |
||
164 | serge | 510 | |
742 | Rus | 511 | add eax, ebx |
512 | mov [ipc_pdir], eax |
||
164 | serge | 513 | |
742 | Rus | 514 | add eax, ebx |
515 | mov [ipc_ptab], eax |
||
164 | serge | 516 | |
742 | Rus | 517 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
518 | (unpack.lc+unpack.lp)))*4 |
||
712 | serge | 519 | |
742 | Rus | 520 | mov [unpack.p], eax |
709 | diamond | 521 | |
742 | Rus | 522 | call init_events |
523 | mov eax, srv.fd-SRV_FD_OFFSET |
||
524 | mov [srv.fd], eax |
||
525 | mov [srv.bk], eax |
||
278 | serge | 526 | |
742 | Rus | 527 | mov edi, irq_tab |
528 | xor eax, eax |
||
529 | mov ecx, 16 |
||
530 | rep stosd |
||
164 | serge | 531 | |
41 | mikedld | 532 | ;Set base of graphic segment to linear address of LFB |
742 | Rus | 533 | mov eax,[LFBAddress] ; set for gs |
534 | mov [graph_data_l+2],ax |
||
535 | shr eax,16 |
||
536 | mov [graph_data_l+4],al |
||
537 | mov [graph_data_l+7],ah |
||
1 | ha | 538 | |
742 | Rus | 539 | mov [CURRENT_TASK],dword 1 |
540 | mov [TASK_COUNT],dword 1 |
||
541 | mov [TASK_BASE],dword TASK_DATA |
||
542 | mov [current_slot], SLOT_BASE+256 |
||
429 | serge | 543 | |
469 | serge | 544 | ; set background |
742 | Rus | 545 | xor eax,eax |
546 | inc eax |
||
547 | mov [BgrDrawMode],eax |
||
548 | mov [BgrDataWidth],eax |
||
549 | mov [BgrDataHeight],eax |
||
550 | mov [mem_BACKGROUND],4095 |
||
551 | stdcall kernel_alloc, [mem_BACKGROUND] |
||
552 | mov [img_background], eax |
||
469 | serge | 553 | |
742 | Rus | 554 | mov [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE |
469 | serge | 555 | |
709 | diamond | 556 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
557 | |||
742 | Rus | 558 | call rerouteirqs |
709 | diamond | 559 | |
560 | ; Initialize system V86 machine |
||
742 | Rus | 561 | call init_sys_v86 |
709 | diamond | 562 | |
725 | diamond | 563 | ; TIMER SET TO 1/100 S |
564 | |||
742 | Rus | 565 | mov al,0x34 ; set to 100Hz |
566 | out 0x43,al |
||
567 | mov al,0x9b ; lsb 1193180 / 1193 |
||
568 | out 0x40,al |
||
569 | mov al,0x2e ; msb |
||
570 | out 0x40,al |
||
725 | diamond | 571 | |
572 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
||
573 | ; they are used: when partitions are scanned, hd_read relies on timer |
||
742 | Rus | 574 | mov al, 0xFE |
575 | out 0x21, al |
||
576 | mov al, 0x3F |
||
577 | out 0xA1, al |
||
725 | diamond | 578 | |
256 | diamond | 579 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
580 | include 'detect/disks.inc' |
||
581 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
582 | |||
521 | diamond | 583 | call Parser_params |
584 | |||
1 | ha | 585 | ; READ RAMDISK IMAGE FROM HD |
586 | |||
587 | ;!!!!!!!!!!!!!!!!!!!!!!! |
||
588 | include 'boot/rdload.inc' |
||
589 | ;!!!!!!!!!!!!!!!!!!!!!!! |
||
590 | ; mov [dma_hdd],1 |
||
591 | ; CALCULATE FAT CHAIN FOR RAMDISK |
||
592 | |||
742 | Rus | 593 | call calculatefatchain |
1 | ha | 594 | |
595 | ; LOAD VMODE DRIVER |
||
596 | |||
597 | ;!!!!!!!!!!!!!!!!!!!!!!! |
||
598 | include 'vmodeld.inc' |
||
599 | ;!!!!!!!!!!!!!!!!!!!!!!! |
||
600 | |||
509 | diamond | 601 | mov ax,[OS_BASE+0x10000+bx_from_load] |
535 | spraid | 602 | cmp ax,'r1' ; if using not ram disk, then load librares and parameters {SPraid.simba} |
488 | spraid | 603 | je no_lib_load |
604 | ; LOADING LIBRARES |
||
742 | Rus | 605 | stdcall dll.Load,@IMPORT ; loading librares for kernel (.obj files) |
606 | call load_file_parse_table ; prepare file parse table |
||
607 | call set_kernel_conf ; configure devices and gui |
||
488 | spraid | 608 | no_lib_load: |
609 | |||
1 | ha | 610 | ; LOAD FONTS I and II |
611 | |||
742 | Rus | 612 | stdcall read_file, char, FONT_I, 0, 2304 |
613 | stdcall read_file, char2, FONT_II, 0, 2560 |
||
490 | serge | 614 | |
742 | Rus | 615 | mov esi,boot_fonts |
616 | call boot_log |
||
1 | ha | 617 | |
618 | ; PRINT AMOUNT OF MEMORY |
||
742 | Rus | 619 | mov esi, boot_memdetect |
620 | call boot_log |
||
1 | ha | 621 | |
742 | Rus | 622 | movzx ecx, word [boot_y] |
623 | or ecx, (10+29*6) shl 16 ; "Determining amount of memory" |
||
624 | sub ecx, 10 |
||
625 | mov edx, 0xFFFFFF |
||
626 | mov ebx, [MEM_AMOUNT] |
||
627 | shr ebx, 20 |
||
628 | mov edi, 1 |
||
629 | mov eax, 0x00040000 |
||
630 | call display_number_force |
||
41 | mikedld | 631 | |
465 | serge | 632 | ; BUILD SCHEDULER |
633 | |||
742 | Rus | 634 | call build_scheduler ; sys32.inc |
465 | serge | 635 | |
742 | Rus | 636 | mov esi,boot_devices |
637 | call boot_log |
||
567 | serge | 638 | |
742 | Rus | 639 | mov [pci_access_enabled],1 |
567 | serge | 640 | |
742 | Rus | 641 | call detect_devices |
642 | stdcall load_driver, szPS2MDriver |
||
1 | ha | 643 | |
644 | ; SET MOUSE |
||
645 | |||
742 | Rus | 646 | mov esi,boot_setmouse |
647 | call boot_log |
||
648 | call setmouse |
||
1 | ha | 649 | |
214 | serge | 650 | |
1 | ha | 651 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
652 | |||
742 | Rus | 653 | mov esi,boot_windefs |
654 | call boot_log |
||
655 | call setwindowdefaults |
||
1 | ha | 656 | |
657 | ; SET BACKGROUND DEFAULTS |
||
658 | |||
742 | Rus | 659 | mov esi,boot_bgr |
660 | call boot_log |
||
661 | call init_background |
||
662 | call calculatebackground |
||
1 | ha | 663 | |
664 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
||
665 | |||
742 | Rus | 666 | mov esi,boot_resirqports |
667 | call boot_log |
||
668 | call reserve_irqs_ports |
||
1 | ha | 669 | |
670 | ; SET PORTS FOR IRQ HANDLERS |
||
671 | |||
742 | Rus | 672 | mov esi,boot_setrports |
673 | call boot_log |
||
674 | call setirqreadports |
||
1 | ha | 675 | |
676 | ; SET UP OS TASK |
||
677 | |||
742 | Rus | 678 | mov esi,boot_setostask |
679 | call boot_log |
||
214 | serge | 680 | |
742 | Rus | 681 | xor eax, eax |
682 | mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data |
||
683 | mov dword [SLOT_BASE+APPDATA.fpu_handler], eax |
||
684 | mov dword [SLOT_BASE+APPDATA.sse_handler], eax |
||
164 | serge | 685 | |
742 | Rus | 686 | ; name for OS/IDLE process |
281 | serge | 687 | |
742 | Rus | 688 | mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' |
689 | mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' |
||
690 | mov edi, [os_stack_seg] |
||
691 | mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi |
||
692 | add edi, 0x2000-512 |
||
693 | mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi |
||
694 | mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi ; just for case |
||
695 | mov dword [SLOT_BASE+256+APPDATA.io_map],\ |
||
696 | (tss._io_map_0-OS_BASE+PG_MAP) |
||
697 | mov dword [SLOT_BASE+256+APPDATA.io_map+4],\ |
||
698 | (tss._io_map_1-OS_BASE+PG_MAP) |
||
357 | serge | 699 | |
742 | Rus | 700 | mov esi, fpu_data |
701 | mov ecx, 512/4 |
||
702 | cld |
||
703 | rep movsd |
||
357 | serge | 704 | |
742 | Rus | 705 | mov dword [SLOT_BASE+256+APPDATA.fpu_handler], eax |
706 | mov dword [SLOT_BASE+256+APPDATA.sse_handler], eax |
||
214 | serge | 707 | |
742 | Rus | 708 | mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET |
709 | mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx |
||
710 | mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx |
||
281 | serge | 711 | |
742 | Rus | 712 | mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path |
521 | diamond | 713 | |
742 | Rus | 714 | ; task list |
715 | mov [CURRENT_TASK],dword 1 |
||
716 | mov [TASK_COUNT],dword 1 |
||
717 | mov [current_slot], SLOT_BASE+256 |
||
718 | mov [TASK_BASE],dword TASK_DATA |
||
719 | mov [TASK_DATA+TASKDATA.wnd_number], 1 ; on screen number |
||
720 | mov [TASK_DATA+TASKDATA.pid], 1 ; process id number |
||
721 | mov [TASK_DATA+TASKDATA.mem_start], 0 ; process base address |
||
1 | ha | 722 | |
742 | Rus | 723 | call init_cursors |
724 | mov eax, [def_cursor] |
||
725 | mov [SLOT_BASE+APPDATA.cursor],eax |
||
726 | mov [SLOT_BASE+APPDATA.cursor+256],eax |
||
281 | serge | 727 | |
465 | serge | 728 | ; READ TSC / SECOND |
281 | serge | 729 | |
742 | Rus | 730 | mov esi,boot_tsc |
731 | call boot_log |
||
732 | cli |
||
733 | call _rdtsc |
||
734 | mov ecx,eax |
||
735 | mov esi,250 ; wait 1/4 a second |
||
736 | call delay_ms |
||
737 | call _rdtsc |
||
738 | sti |
||
739 | sub eax,ecx |
||
740 | shl eax,2 |
||
741 | mov [CPU_FREQ],eax ; save tsc / sec |
||
742 | mov ebx, 1000000 |
||
743 | div ebx |
||
744 | mov [stall_mcs], eax |
||
1 | ha | 745 | |
746 | ; SET VARIABLES |
||
747 | |||
742 | Rus | 748 | call set_variables |
1 | ha | 749 | |
750 | ; STACK AND FDC |
||
751 | |||
742 | Rus | 752 | call stack_init |
753 | call fdc_init |
||
1 | ha | 754 | |
755 | ; PALETTE FOR 320x200 and 640x480 16 col |
||
756 | |||
742 | Rus | 757 | cmp [SCR_MODE],word 0x12 |
758 | jne no_pal_vga |
||
759 | mov esi,boot_pal_vga |
||
760 | call boot_log |
||
761 | call paletteVGA |
||
1 | ha | 762 | no_pal_vga: |
763 | |||
742 | Rus | 764 | cmp [SCR_MODE],word 0x13 |
765 | jne no_pal_ega |
||
766 | mov esi,boot_pal_ega |
||
767 | call boot_log |
||
768 | call palette320x200 |
||
1 | ha | 769 | no_pal_ega: |
770 | |||
771 | ; LOAD DEFAULT SKIN |
||
772 | |||
742 | Rus | 773 | call load_default_skin |
1 | ha | 774 | |
465 | serge | 775 | ;protect io permission map |
776 | |||
742 | Rus | 777 | mov esi, [default_io_map] |
778 | stdcall map_page,esi,(tss._io_map_0-OS_BASE), PG_MAP |
||
779 | add esi, 0x1000 |
||
780 | stdcall map_page,esi,(tss._io_map_1-OS_BASE), PG_MAP |
||
465 | serge | 781 | |
742 | Rus | 782 | stdcall map_page,tss._io_map_0,\ |
783 | (tss._io_map_0-OS_BASE), PG_MAP |
||
784 | stdcall map_page,tss._io_map_1,\ |
||
785 | (tss._io_map_1-OS_BASE), PG_MAP |
||
465 | serge | 786 | |
512 | spraid | 787 | mov ax,[OS_BASE+0x10000+bx_from_load] |
535 | spraid | 788 | cmp ax,'r1' ; if not rused ram disk - load network configuration from files {SPraid.simba} |
512 | spraid | 789 | je no_st_network |
742 | Rus | 790 | call set_network_conf |
512 | spraid | 791 | no_st_network: |
792 | |||
1 | ha | 793 | ; LOAD FIRST APPLICATION |
742 | Rus | 794 | cli |
501 | serge | 795 | |
742 | Rus | 796 | cmp byte [BOOT_VAR+0x9030],1 |
797 | jne no_load_vrr_m |
||
237 | serge | 798 | |
742 | Rus | 799 | mov ebp, vrr_m |
800 | call fs_execute_from_sysdir |
||
488 | spraid | 801 | |
742 | Rus | 802 | cmp eax,2 ; if vrr_m app found (PID=2) |
803 | je first_app_found |
||
41 | mikedld | 804 | |
237 | serge | 805 | no_load_vrr_m: |
488 | spraid | 806 | |
742 | Rus | 807 | mov ebp, firstapp |
808 | call fs_execute_from_sysdir |
||
488 | spraid | 809 | |
742 | Rus | 810 | cmp eax,2 ; continue if a process has been loaded |
811 | je first_app_found |
||
501 | serge | 812 | |
742 | Rus | 813 | mov esi, boot_failed |
814 | call boot_log |
||
653 | diamond | 815 | |
742 | Rus | 816 | mov eax, 0xDEADBEEF ; otherwise halt |
817 | hlt |
||
501 | serge | 818 | |
237 | serge | 819 | first_app_found: |
501 | serge | 820 | |
742 | Rus | 821 | cli |
1 | ha | 822 | |
742 | Rus | 823 | ;mov [TASK_COUNT],dword 2 |
824 | mov [CURRENT_TASK],dword 1 ; set OS task fisrt |
||
1 | ha | 825 | |
21 | poddubny | 826 | ; SET KEYBOARD PARAMETERS |
742 | Rus | 827 | mov al, 0xf6 ; reset keyboard, scan enabled |
828 | call kb_write |
||
1 | ha | 829 | |
742 | Rus | 830 | ; wait until 8042 is ready |
831 | xor ecx,ecx |
||
265 | diamond | 832 | @@: |
742 | Rus | 833 | in al,64h |
834 | and al,00000010b |
||
835 | loopnz @b |
||
1 | ha | 836 | |
837 | ; mov al, 0xED ; svetodiody - only for testing! |
||
838 | ; call kb_write |
||
839 | ; call kb_read |
||
840 | ; mov al, 111b |
||
841 | ; call kb_write |
||
842 | ; call kb_read |
||
41 | mikedld | 843 | |
742 | Rus | 844 | mov al, 0xF3 ; set repeat rate & delay |
845 | call kb_write |
||
265 | diamond | 846 | ; call kb_read |
742 | Rus | 847 | mov al, 0 ; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
848 | call kb_write |
||
265 | diamond | 849 | ; call kb_read |
1 | ha | 850 | ;// mike.dld [ |
742 | Rus | 851 | call set_lights |
1 | ha | 852 | ;// mike.dld ] |
853 | |||
21 | poddubny | 854 | ; START MULTITASKING |
1 | ha | 855 | |
767 | diamond | 856 | if preboot_blogesc |
857 | mov esi, boot_tasking |
||
858 | call boot_log |
||
859 | .bll1: in al, 0x60 ; wait for ESC key press |
||
860 | cmp al, 129 |
||
861 | jne .bll1 |
||
862 | end if |
||
863 | |||
465 | serge | 864 | ; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled |
21 | poddubny | 865 | |
1 | ha | 866 | ; UNMASK ALL IRQ'S |
867 | |||
742 | Rus | 868 | mov esi,boot_allirqs |
869 | call boot_log |
||
41 | mikedld | 870 | |
742 | Rus | 871 | cli ;guarantee forbidance of interrupts. |
872 | mov al,0 ; unmask all irq's |
||
873 | out 0xA1,al |
||
874 | out 0x21,al |
||
1 | ha | 875 | |
742 | Rus | 876 | mov ecx,32 |
1 | ha | 877 | |
878 | ready_for_irqs: |
||
879 | |||
742 | Rus | 880 | mov al,0x20 ; ready for irqs |
881 | out 0x20,al |
||
882 | out 0xa0,al |
||
1 | ha | 883 | |
742 | Rus | 884 | loop ready_for_irqs ; flush the queue |
1 | ha | 885 | |
742 | Rus | 886 | stdcall attach_int_handler, dword 1, irq1 |
164 | serge | 887 | |
1 | ha | 888 | ; mov [dma_hdd],1 |
742 | Rus | 889 | cmp [IDEContrRegsBaseAddr], 0 |
890 | setnz [dma_hdd] |
||
891 | mov [timer_ticks_enable],1 ; for cd driver |
||
1 | ha | 892 | |
465 | serge | 893 | ; stdcall init_uart_service, DRV_ENTRY |
894 | |||
742 | Rus | 895 | sti |
896 | call change_task |
||
465 | serge | 897 | |
742 | Rus | 898 | jmp osloop |
465 | serge | 899 | |
725 | diamond | 900 | ; jmp $ ; wait here for timer to take control |
1 | ha | 901 | |
742 | Rus | 902 | ; Fly :) |
1 | ha | 903 | |
465 | serge | 904 | include 'unpacker.inc' |
905 | include 'fdo.inc' |
||
906 | |||
907 | align 4 |
||
908 | boot_log: |
||
742 | Rus | 909 | pushad |
465 | serge | 910 | |
742 | Rus | 911 | mov ebx,10*65536 |
912 | mov bx,word [boot_y] |
||
913 | add [boot_y],dword 10 |
||
914 | mov ecx,0x80ffffff ; ASCIIZ string with white color |
||
915 | mov edx,esi |
||
916 | mov edi,1 |
||
917 | call dtext |
||
465 | serge | 918 | |
742 | Rus | 919 | mov [novesachecksum],1000 |
920 | call checkVga_N13 |
||
465 | serge | 921 | |
764 | Rus | 922 | popad |
465 | serge | 923 | |
742 | Rus | 924 | ret |
465 | serge | 925 | |
926 | |||
1 | ha | 927 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
928 | ; ; |
||
33 | mario79 | 929 | ; MAIN OS LOOP START ; |
1 | ha | 930 | ; ; |
931 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
932 | align 32 |
||
933 | osloop: |
||
742 | Rus | 934 | call [draw_pointer] |
935 | call checkbuttons |
||
936 | call checkwindows |
||
49 | mikedld | 937 | ; call check_window_move_request |
742 | Rus | 938 | call checkmisc |
939 | call checkVga_N13 |
||
940 | call stack_handler |
||
941 | call checkidle |
||
942 | call check_fdd_motor_status |
||
943 | call check_ATAPI_device_event |
||
944 | jmp osloop |
||
33 | mario79 | 945 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
946 | ; ; |
||
947 | ; MAIN OS LOOP END ; |
||
948 | ; ; |
||
949 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1 | ha | 950 | |
951 | checkidle: |
||
742 | Rus | 952 | pushad |
1 | ha | 953 | |
742 | Rus | 954 | cmp [check_idle_semaphore],0 |
955 | jne no_idle_state |
||
1 | ha | 956 | |
742 | Rus | 957 | call change_task |
958 | mov eax,[idlemem] |
||
959 | mov ebx,[timer_ticks] ;[0xfdf0] |
||
960 | cmp eax,ebx |
||
961 | jnz idle_exit |
||
962 | call _rdtsc |
||
963 | mov ecx,eax |
||
1 | ha | 964 | idle_loop: |
742 | Rus | 965 | hlt |
966 | cmp [check_idle_semaphore],0 |
||
967 | jne idle_loop_exit |
||
968 | mov eax,[timer_ticks] ;[0xfdf0] |
||
969 | cmp ebx,eax |
||
970 | jz idle_loop |
||
1 | ha | 971 | idle_loop_exit: |
742 | Rus | 972 | mov [idlemem],eax |
973 | call _rdtsc |
||
974 | sub eax,ecx |
||
975 | mov ebx,[idleuse] |
||
976 | add ebx,eax |
||
977 | mov [idleuse],ebx |
||
1 | ha | 978 | |
742 | Rus | 979 | popad |
980 | ret |
||
1 | ha | 981 | |
982 | idle_exit: |
||
983 | |||
742 | Rus | 984 | mov ebx,[timer_ticks] ;[0xfdf0] |
985 | mov [idlemem],ebx |
||
986 | call change_task |
||
1 | ha | 987 | |
742 | Rus | 988 | popad |
989 | ret |
||
1 | ha | 990 | |
991 | no_idle_state: |
||
992 | |||
742 | Rus | 993 | dec [check_idle_semaphore] |
1 | ha | 994 | |
742 | Rus | 995 | mov ebx,[timer_ticks] ;[0xfdf0] |
996 | mov [idlemem],ebx |
||
997 | call change_task |
||
1 | ha | 998 | |
742 | Rus | 999 | popad |
1000 | ret |
||
1 | ha | 1001 | |
1002 | uglobal |
||
742 | Rus | 1003 | idlemem dd 0x0 |
1004 | idleuse dd 0x0 |
||
1005 | idleusesec dd 0x0 |
||
1006 | check_idle_semaphore dd 0x0 |
||
1 | ha | 1007 | endg |
1008 | |||
1009 | |||
1010 | |||
1011 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1012 | ; ; |
||
1013 | ; INCLUDED SYSTEM FILES ; |
||
1014 | ; ; |
||
1015 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1016 | |||
1017 | |||
7 | me_root | 1018 | include "kernel32.inc" |
1 | ha | 1019 | |
1020 | |||
1021 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1022 | ; ; |
||
1023 | ; KERNEL FUNCTIONS ; |
||
1024 | ; ; |
||
1025 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1026 | |||
1027 | reserve_irqs_ports: |
||
1028 | |||
742 | Rus | 1029 | pushad |
1 | ha | 1030 | |
742 | Rus | 1031 | mov [irq_owner+4*0], 1 ; timer |
1032 | mov [irq_owner+4*1], 1 ; keyboard |
||
1033 | mov [irq_owner+4*5], 1 ; sound blaster |
||
1034 | mov [irq_owner+4*6], 1 ; floppy diskette |
||
1035 | mov [irq_owner+4*13], 1 ; math co-pros |
||
1036 | mov [irq_owner+4*14], 1 ; ide I |
||
1037 | mov [irq_owner+4*15], 1 ; ide II |
||
465 | serge | 1038 | |
671 | Ghost | 1039 | ; RESERVE PORTS |
742 | Rus | 1040 | mov edi,1 ; 0x00-0x2d |
1041 | mov [RESERVED_PORTS],edi |
||
1042 | shl edi,4 |
||
1043 | mov [RESERVED_PORTS+edi+0],dword 1 |
||
1044 | mov [RESERVED_PORTS+edi+4],dword 0x0 |
||
1045 | mov [RESERVED_PORTS+edi+8],dword 0x2d |
||
269 | serge | 1046 | |
742 | Rus | 1047 | inc dword [RESERVED_PORTS] ; 0x30-0x4d |
1048 | mov edi,[RESERVED_PORTS] |
||
1049 | shl edi,4 |
||
1050 | mov [RESERVED_PORTS+edi+0],dword 1 |
||
1051 | mov [RESERVED_PORTS+edi+4],dword 0x30 |
||
1052 | mov [RESERVED_PORTS+edi+8],dword 0x4d |
||
269 | serge | 1053 | |
742 | Rus | 1054 | inc dword [RESERVED_PORTS] ; 0x50-0xdf |
1055 | mov edi,[RESERVED_PORTS] |
||
1056 | shl edi,4 |
||
1057 | mov [RESERVED_PORTS+edi+0],dword 1 |
||
1058 | mov [RESERVED_PORTS+edi+4],dword 0x50 |
||
1059 | mov [RESERVED_PORTS+edi+8],dword 0xdf |
||
233 | serge | 1060 | |
742 | Rus | 1061 | inc dword [RESERVED_PORTS] ; 0xe5-0xff |
1062 | mov edi,[RESERVED_PORTS] |
||
1063 | shl edi,4 |
||
1064 | mov [RESERVED_PORTS+edi+0],dword 1 |
||
1065 | mov [RESERVED_PORTS+edi+4],dword 0xe5 |
||
1066 | mov [RESERVED_PORTS+edi+8],dword 0xff |
||
233 | serge | 1067 | |
742 | Rus | 1068 | popad |
1069 | ret |
||
1 | ha | 1070 | |
1071 | iglobal |
||
742 | Rus | 1072 | mouseirqtable db 12 ; ps2 |
1073 | db 4 ; com1 |
||
1074 | db 3 ; com2 |
||
1 | ha | 1075 | endg |
1076 | |||
1077 | setirqreadports: |
||
1078 | |||
742 | Rus | 1079 | mov [irq12read+0],dword 0x60 + 0x01000000 ; read port 0x60 , byte |
1080 | mov [irq12read+4],dword 0 ; end of port list |
||
1081 | mov [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte |
||
1082 | mov [irq04read+4],dword 0 ; end of port list |
||
1083 | mov [irq03read+0],dword 0x2f8 + 0x01000000 ; read port 0x2f8 , byte |
||
1084 | mov [irq03read+4],dword 0 ; end of port list |
||
1 | ha | 1085 | |
742 | Rus | 1086 | ret |
1 | ha | 1087 | |
1088 | iglobal |
||
1089 | process_number dd 0x1 |
||
1090 | endg |
||
1091 | |||
1092 | set_variables: |
||
1093 | |||
742 | Rus | 1094 | mov ecx,0x100 ; flush port 0x60 |
1095 | .fl60: in al,0x60 |
||
1096 | loop .fl60 |
||
1097 | mov [MOUSE_BUFF_COUNT],byte 0 ; mouse buffer |
||
1098 | mov [KEY_COUNT],byte 0 ; keyboard buffer |
||
1099 | mov [BTN_COUNT],byte 0 ; button buffer |
||
381 | serge | 1100 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1 | ha | 1101 | |
742 | Rus | 1102 | push eax |
1103 | mov ax,[BOOT_VAR+0x900c] |
||
1104 | shr ax,1 |
||
1105 | shl eax,16 |
||
1106 | mov ax,[BOOT_VAR+0x900A] |
||
1107 | shr ax,1 |
||
1108 | mov [MOUSE_X],eax |
||
1109 | pop eax |
||
41 | mikedld | 1110 | |
742 | Rus | 1111 | mov byte [SB16_Status],0 ; Minazzi Paolo |
1112 | mov [BTN_ADDR],dword BUTTON_INFO ; address of button list |
||
1 | ha | 1113 | |
1114 | ;!! IP 04.02.2005: |
||
742 | Rus | 1115 | mov [next_usage_update], 100 |
1116 | mov byte [DONT_SWITCH], 0 ; change task if possible |
||
1 | ha | 1117 | |
742 | Rus | 1118 | ret |
1 | ha | 1119 | |
1120 | ;* mouse centered - start code- Mario79 |
||
1121 | mouse_centered: |
||
742 | Rus | 1122 | push eax |
759 | Rus | 1123 | mov eax,[Screen_Max_X] |
742 | Rus | 1124 | shr eax,1 |
1125 | mov [MOUSE_X],ax |
||
759 | Rus | 1126 | mov eax,[Screen_Max_Y] |
742 | Rus | 1127 | shr eax,1 |
1128 | mov [MOUSE_Y],ax |
||
1129 | pop eax |
||
1130 | ret |
||
1 | ha | 1131 | ;* mouse centered - end code- Mario79 |
1132 | |||
1133 | align 4 |
||
1134 | |||
1135 | sys_outport: |
||
1136 | |||
742 | Rus | 1137 | mov edi,ebx ; separate flag for read / write |
1 | ha | 1138 | and ebx,65535 |
1139 | |||
381 | serge | 1140 | mov ecx,[RESERVED_PORTS] |
1 | ha | 1141 | test ecx,ecx |
1142 | jne sopl8 |
||
1143 | mov [esp+36],dword 1 |
||
1144 | ret |
||
1145 | |||
1146 | sopl8: |
||
379 | serge | 1147 | mov edx,[TASK_BASE] |
1 | ha | 1148 | mov edx,[edx+0x4] |
1149 | and ebx,65535 |
||
1150 | cld |
||
1151 | sopl1: |
||
1152 | |||
1153 | mov esi,ecx |
||
1154 | shl esi,4 |
||
381 | serge | 1155 | add esi,RESERVED_PORTS |
1 | ha | 1156 | cmp edx,[esi+0] |
1157 | jne sopl2 |
||
1158 | cmp ebx,[esi+4] |
||
742 | Rus | 1159 | jb sopl2 |
1 | ha | 1160 | cmp ebx,[esi+8] |
742 | Rus | 1161 | jg sopl2 |
1 | ha | 1162 | jmp sopl3 |
1163 | |||
1164 | sopl2: |
||
1165 | |||
1166 | dec ecx |
||
1167 | jnz sopl1 |
||
1168 | mov [esp+36],dword 1 |
||
1169 | ret |
||
1170 | |||
1171 | sopl3: |
||
1172 | |||
1173 | test edi,0x80000000 ; read ? |
||
1174 | jnz sopl4 |
||
1175 | |||
742 | Rus | 1176 | mov dx,bx ; write |
1 | ha | 1177 | out dx,al |
1178 | mov [esp+36],dword 0 |
||
1179 | ret |
||
1180 | |||
1181 | sopl4: |
||
1182 | |||
742 | Rus | 1183 | mov dx,bx ; read |
1184 | in al,dx |
||
1 | ha | 1185 | and eax,0xff |
1186 | mov [esp+36],dword 0 |
||
1187 | mov [esp+24],eax |
||
1188 | ret |
||
1189 | |||
1190 | |||
1191 | |||
1192 | align 4 |
||
1193 | sys_sb16: |
||
1194 | |||
1195 | cmp word [sb16],word 0 |
||
1196 | jnz sb16l1 |
||
1197 | mov [esp+36],dword 1 |
||
1198 | ret |
||
1199 | sb16l1: |
||
1200 | mov [esp+36],dword 0 |
||
1201 | cmp eax,1 ; set volume - main |
||
1202 | jnz sb16l2 |
||
1203 | mov dx,word [sb16] |
||
1204 | add dx,4 |
||
1205 | mov al,0x22 |
||
1206 | out dx,al |
||
1207 | mov esi,1 |
||
1208 | call delay_ms |
||
1209 | mov eax,ebx |
||
1210 | inc edx |
||
1211 | out dx,al |
||
1212 | ret |
||
1213 | sb16l2: |
||
1214 | |||
1215 | cmp eax,2 ; set volume - cd |
||
1216 | jnz sb16l3 |
||
1217 | mov dx,word [sb16] |
||
1218 | add dx,4 |
||
1219 | mov al,0x28 |
||
1220 | out dx,al |
||
1221 | mov esi,1 |
||
1222 | call delay_ms |
||
1223 | mov eax,ebx |
||
1224 | add edx,1 |
||
1225 | out dx,al |
||
1226 | ret |
||
1227 | sb16l3: |
||
1228 | mov [esp+36],dword 2 |
||
1229 | ret |
||
1230 | |||
1231 | |||
1232 | align 4 |
||
1233 | |||
1234 | sys_sb16II: |
||
1235 | |||
1236 | cmp word [sb16],word 0 |
||
1237 | jnz IIsb16l1 |
||
1238 | mov [esp+36],dword 1 |
||
1239 | ret |
||
1240 | IIsb16l1: |
||
1241 | |||
1242 | cmp eax,1 ; set volume - main |
||
1243 | jnz IIsb16l2 |
||
1244 | ; L |
||
1245 | mov dx,word [sb16] |
||
1246 | add dx,4 |
||
1247 | mov al,0x30 |
||
1248 | out dx,al |
||
1249 | mov eax,ebx |
||
1250 | inc edx |
||
1251 | out dx,al |
||
1252 | ; R |
||
1253 | mov dx,word [sb16] |
||
1254 | add dx,4 |
||
1255 | mov al,0x31 |
||
1256 | out dx,al |
||
1257 | mov eax,ebx |
||
1258 | inc edx |
||
1259 | out dx,al |
||
1260 | mov [esp+36],dword 0 |
||
1261 | ret |
||
1262 | IIsb16l2: |
||
1263 | |||
1264 | cmp eax,2 ; set volume - cd |
||
1265 | jnz IIsb16l3 |
||
1266 | ; L |
||
1267 | mov dx,word [sb16] |
||
1268 | add dx,4 |
||
1269 | mov al,0x36 |
||
1270 | out dx,al |
||
1271 | mov eax,ebx |
||
1272 | inc edx |
||
1273 | out dx,al |
||
1274 | ; R |
||
1275 | mov dx,word [sb16] |
||
1276 | add dx,4 |
||
1277 | mov al,0x37 |
||
1278 | out dx,al |
||
1279 | mov eax,ebx |
||
1280 | inc edx |
||
1281 | out dx,al |
||
1282 | mov [esp+36],dword 0 |
||
1283 | ret |
||
1284 | IIsb16l3: |
||
1285 | |||
1286 | mov [esp+36],dword 2 |
||
1287 | ret |
||
1288 | |||
1289 | |||
1290 | display_number: |
||
1291 | |||
1292 | ; eax = print type, al=0 -> ebx is number |
||
1293 | ; al=1 -> ebx is pointer |
||
1294 | ; ah=0 -> display decimal |
||
1295 | ; ah=1 -> display hexadecimal |
||
1296 | ; ah=2 -> display binary |
||
1297 | ; eax bits 16-21 = number of digits to display (0-32) |
||
1298 | ; eax bits 22-31 = reserved |
||
1299 | ; |
||
1300 | ; ebx = number or pointer |
||
1301 | ; ecx = x shl 16 + y |
||
1302 | ; edx = color |
||
655 | mario79 | 1303 | xor edi, edi |
211 | serge | 1304 | display_number_force: |
652 | mario79 | 1305 | push eax |
655 | mario79 | 1306 | and eax,0x3fffffff |
1307 | cmp eax,0xffff ; length > 0 ? |
||
1308 | pop eax |
||
1 | ha | 1309 | jge cont_displ |
1310 | ret |
||
1311 | cont_displ: |
||
652 | mario79 | 1312 | push eax |
655 | mario79 | 1313 | and eax,0x3fffffff |
1314 | cmp eax,61*0x10000 ; length <= 60 ? |
||
1315 | pop eax |
||
75 | diamond | 1316 | jb cont_displ2 |
1 | ha | 1317 | ret |
1318 | cont_displ2: |
||
1319 | |||
1320 | pushad |
||
1321 | |||
655 | mario79 | 1322 | cmp al,1 ; ecx is a pointer ? |
1 | ha | 1323 | jne displnl1 |
655 | mario79 | 1324 | mov ebp,ebx |
1325 | add ebp,4 |
||
1326 | mov ebp,[ebp+std_application_base_address] |
||
139 | diamond | 1327 | mov ebx,[ebx+std_application_base_address] |
1 | ha | 1328 | displnl1: |
1329 | sub esp,64 |
||
1330 | |||
655 | mario79 | 1331 | cmp ah,0 ; DECIMAL |
1 | ha | 1332 | jne no_display_desnum |
1333 | shr eax,16 |
||
655 | mario79 | 1334 | and eax,0xC03f |
652 | mario79 | 1335 | ; and eax,0x3f |
1336 | push eax |
||
75 | diamond | 1337 | and eax,0x3f |
1 | ha | 1338 | mov edi,esp |
194 | diamond | 1339 | add edi,4+64-1 |
1 | ha | 1340 | mov ecx,eax |
1341 | mov eax,ebx |
||
1342 | mov ebx,10 |
||
1343 | d_desnum: |
||
1344 | xor edx,edx |
||
655 | mario79 | 1345 | call division_64_bits |
1 | ha | 1346 | div ebx |
1347 | add dl,48 |
||
1348 | mov [edi],dl |
||
1349 | dec edi |
||
1350 | loop d_desnum |
||
1351 | pop eax |
||
652 | mario79 | 1352 | call normalize_number |
1 | ha | 1353 | call draw_num_text |
1354 | add esp,64 |
||
1355 | popad |
||
1356 | ret |
||
1357 | no_display_desnum: |
||
1358 | |||
655 | mario79 | 1359 | cmp ah,0x01 ; HEXADECIMAL |
1 | ha | 1360 | jne no_display_hexnum |
1361 | shr eax,16 |
||
655 | mario79 | 1362 | and eax,0xC03f |
652 | mario79 | 1363 | ; and eax,0x3f |
1364 | push eax |
||
75 | diamond | 1365 | and eax,0x3f |
1 | ha | 1366 | mov edi,esp |
194 | diamond | 1367 | add edi,4+64-1 |
1 | ha | 1368 | mov ecx,eax |
1369 | mov eax,ebx |
||
1370 | mov ebx,16 |
||
1371 | d_hexnum: |
||
1372 | xor edx,edx |
||
655 | mario79 | 1373 | call division_64_bits |
1 | ha | 1374 | div ebx |
1375 | add edx,hexletters |
||
1376 | mov dl,[edx] |
||
1377 | mov [edi],dl |
||
1378 | dec edi |
||
1379 | loop d_hexnum |
||
1380 | pop eax |
||
652 | mario79 | 1381 | call normalize_number |
1 | ha | 1382 | call draw_num_text |
1383 | add esp,64 |
||
1384 | popad |
||
1385 | ret |
||
1386 | no_display_hexnum: |
||
1387 | |||
655 | mario79 | 1388 | cmp ah,0x02 ; BINARY |
1 | ha | 1389 | jne no_display_binnum |
1390 | shr eax,16 |
||
655 | mario79 | 1391 | and eax,0xC03f |
652 | mario79 | 1392 | ; and eax,0x3f |
1393 | push eax |
||
75 | diamond | 1394 | and eax,0x3f |
1 | ha | 1395 | mov edi,esp |
194 | diamond | 1396 | add edi,4+64-1 |
1 | ha | 1397 | mov ecx,eax |
1398 | mov eax,ebx |
||
1399 | mov ebx,2 |
||
1400 | d_binnum: |
||
1401 | xor edx,edx |
||
655 | mario79 | 1402 | call division_64_bits |
1 | ha | 1403 | div ebx |
1404 | add dl,48 |
||
1405 | mov [edi],dl |
||
1406 | dec edi |
||
1407 | loop d_binnum |
||
1408 | pop eax |
||
652 | mario79 | 1409 | call normalize_number |
1 | ha | 1410 | call draw_num_text |
1411 | add esp,64 |
||
1412 | popad |
||
1413 | ret |
||
1414 | no_display_binnum: |
||
1415 | |||
1416 | add esp,64 |
||
1417 | popad |
||
1418 | ret |
||
1419 | |||
652 | mario79 | 1420 | normalize_number: |
1421 | test ah,0x80 |
||
1422 | jz .continue |
||
1423 | mov ecx,48 |
||
1424 | and eax,0x3f |
||
1425 | @@: |
||
1426 | inc edi |
||
1427 | cmp [edi],cl |
||
1428 | jne .continue |
||
1429 | dec eax |
||
1430 | cmp eax,1 |
||
665 | diamond | 1431 | ja @r |
1432 | mov al,1 |
||
652 | mario79 | 1433 | .continue: |
1434 | and eax,0x3f |
||
1435 | ret |
||
1 | ha | 1436 | |
655 | mario79 | 1437 | division_64_bits: |
1438 | test [esp+1+4],byte 0x40 |
||
1439 | jz .continue |
||
1440 | push eax |
||
1441 | mov eax,ebp |
||
1442 | div ebx |
||
1443 | mov ebp,eax |
||
1444 | pop eax |
||
1445 | .continue: |
||
1446 | ret |
||
652 | mario79 | 1447 | |
1 | ha | 1448 | draw_num_text: |
684 | diamond | 1449 | mov esi,eax |
1450 | mov edx,64+4 |
||
1451 | sub edx,eax |
||
1452 | add edx,esp |
||
1453 | mov ebx,[esp+64+32-8+4] |
||
1454 | ; add window start x & y |
||
1455 | mov ecx,[TASK_BASE] |
||
465 | serge | 1456 | |
1457 | mov edi,[CURRENT_TASK] |
||
1458 | shl edi,8 |
||
1459 | |||
684 | diamond | 1460 | mov eax,[ecx-twdw+WDATA.box.left] |
1461 | add eax,[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
1462 | shl eax,16 |
||
1463 | add eax,[ecx-twdw+WDATA.box.top] |
||
1464 | add eax,[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
1465 | add ebx,eax |
||
1466 | mov ecx,[esp+64+32-12+4] |
||
742 | Rus | 1467 | and ecx, not 0x80000000 ; force counted string |
1468 | mov eax, [esp+64+8] ; background color (if given) |
||
1469 | mov edi, [esp+64+4] |
||
139 | diamond | 1470 | jmp dtext |
1 | ha | 1471 | |
1472 | align 4 |
||
1473 | |||
1474 | sys_setup: |
||
1475 | |||
1476 | ; 1=roland mpu midi base , base io address |
||
1477 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1478 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1479 | ; 4=sb16 base , base io address |
||
1480 | ; 5=system language, 1eng 2fi 3ger 4rus |
||
1481 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1482 | ; 8=fat32 partition in hd |
||
1483 | ; 9 |
||
1484 | ; 10 = sound dma channel |
||
1485 | ; 11 = enable lba read |
||
1486 | ; 12 = enable pci access |
||
1487 | |||
1488 | |||
1489 | mov [esp+36],dword 0 |
||
742 | Rus | 1490 | cmp eax,1 ; MIDI |
1 | ha | 1491 | jnz nsyse1 |
1492 | cmp ebx,0x100 |
||
1493 | jb nsyse1 |
||
1494 | mov edx,65535 |
||
1495 | cmp edx,ebx |
||
1496 | jb nsyse1 |
||
1497 | mov [midi_base],bx |
||
1498 | mov word [mididp],bx |
||
1499 | inc bx |
||
1500 | mov word [midisp],bx |
||
1501 | ret |
||
1502 | |||
283 | diamond | 1503 | iglobal |
1 | ha | 1504 | midi_base dw 0 |
283 | diamond | 1505 | endg |
1 | ha | 1506 | |
1507 | nsyse1: |
||
1508 | |||
742 | Rus | 1509 | cmp eax,2 ; KEYBOARD |
1 | ha | 1510 | jnz nsyse2 |
1511 | cmp ebx,1 |
||
1512 | jnz kbnobase |
||
379 | serge | 1513 | mov edi,[TASK_BASE] |
115 | poddubny | 1514 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1515 | mov eax,ecx |
1516 | mov ebx,keymap |
||
1517 | mov ecx,128 |
||
1518 | call memmove |
||
1519 | ret |
||
1520 | kbnobase: |
||
1521 | cmp ebx,2 |
||
1522 | jnz kbnoshift |
||
379 | serge | 1523 | mov edi,[TASK_BASE] |
115 | poddubny | 1524 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1525 | mov eax,ecx |
1526 | mov ebx,keymap_shift |
||
1527 | mov ecx,128 |
||
1528 | call memmove |
||
1529 | ret |
||
1530 | kbnoshift: |
||
1531 | cmp ebx,3 |
||
1532 | jne kbnoalt |
||
379 | serge | 1533 | mov edi,[TASK_BASE] |
115 | poddubny | 1534 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1535 | mov eax,ecx |
1536 | mov ebx,keymap_alt |
||
1537 | mov ecx,128 |
||
1538 | call memmove |
||
1539 | ret |
||
1540 | kbnoalt: |
||
1541 | cmp ebx,9 |
||
1542 | jnz kbnocountry |
||
1543 | mov word [keyboard],cx |
||
1544 | ret |
||
1545 | kbnocountry: |
||
1546 | mov [esp+36],dword 1 |
||
1547 | ret |
||
1548 | nsyse2: |
||
742 | Rus | 1549 | cmp eax,3 ; CD |
1 | ha | 1550 | jnz nsyse3 |
75 | diamond | 1551 | test ebx,ebx |
1552 | jz nosesl |
||
1553 | cmp ebx, 4 |
||
1554 | ja nosesl |
||
1 | ha | 1555 | mov [cd_base],bl |
1556 | cmp ebx,1 |
||
1557 | jnz noprma |
||
1558 | mov [cdbase],0x1f0 |
||
1559 | mov [cdid],0xa0 |
||
1560 | noprma: |
||
1561 | cmp ebx,2 |
||
1562 | jnz noprsl |
||
1563 | mov [cdbase],0x1f0 |
||
1564 | mov [cdid],0xb0 |
||
1565 | noprsl: |
||
1566 | cmp ebx,3 |
||
1567 | jnz nosema |
||
1568 | mov [cdbase],0x170 |
||
1569 | mov [cdid],0xa0 |
||
1570 | nosema: |
||
1571 | cmp ebx,4 |
||
1572 | jnz nosesl |
||
1573 | mov [cdbase],0x170 |
||
1574 | mov [cdid],0xb0 |
||
1575 | nosesl: |
||
1576 | ret |
||
1577 | |||
1578 | cd_base db 0 |
||
1579 | |||
1580 | nsyse3: |
||
1581 | |||
742 | Rus | 1582 | cmp eax,4 ; SB |
1 | ha | 1583 | jnz nsyse4 |
1584 | cmp ebx,0x100 |
||
1585 | jb nsyse4 |
||
1586 | mov edx,65535 |
||
1587 | cmp edx,ebx |
||
1588 | jb nsyse4 |
||
1589 | mov word [sb16],bx |
||
1590 | ret |
||
1591 | nsyse4: |
||
1592 | |||
742 | Rus | 1593 | cmp eax,5 ; SYSTEM LANGUAGE |
1 | ha | 1594 | jnz nsyse5 |
1595 | mov [syslang],ebx |
||
1596 | ret |
||
1597 | nsyse5: |
||
1598 | |||
742 | Rus | 1599 | cmp eax,7 ; HD BASE |
1 | ha | 1600 | jne nsyse7 |
75 | diamond | 1601 | test ebx,ebx |
1602 | jz nosethd |
||
1603 | cmp ebx,4 |
||
1604 | ja nosethd |
||
1 | ha | 1605 | mov [hd_base],bl |
1606 | cmp ebx,1 |
||
1607 | jnz noprmahd |
||
1608 | mov [hdbase],0x1f0 |
||
1609 | mov [hdid],0x0 |
||
1610 | mov [hdpos],1 |
||
1611 | ; call set_FAT32_variables |
||
1612 | noprmahd: |
||
1613 | cmp ebx,2 |
||
1614 | jnz noprslhd |
||
1615 | mov [hdbase],0x1f0 |
||
1616 | mov [hdid],0x10 |
||
1617 | mov [hdpos],2 |
||
1618 | ; call set_FAT32_variables |
||
1619 | noprslhd: |
||
1620 | cmp ebx,3 |
||
1621 | jnz nosemahd |
||
1622 | mov [hdbase],0x170 |
||
1623 | mov [hdid],0x0 |
||
1624 | mov [hdpos],3 |
||
1625 | ; call set_FAT32_variables |
||
1626 | nosemahd: |
||
1627 | cmp ebx,4 |
||
1628 | jnz noseslhd |
||
1629 | mov [hdbase],0x170 |
||
1630 | mov [hdid],0x10 |
||
1631 | mov [hdpos],4 |
||
1632 | ; call set_FAT32_variables |
||
1633 | noseslhd: |
||
1634 | call reserve_hd1 |
||
321 | diamond | 1635 | call reserve_hd_channel |
1636 | call free_hd_channel |
||
742 | Rus | 1637 | mov [hd1_status],0 ; free |
75 | diamond | 1638 | nosethd: |
1 | ha | 1639 | ret |
1640 | |||
283 | diamond | 1641 | iglobal |
1 | ha | 1642 | hd_base db 0 |
283 | diamond | 1643 | endg |
1 | ha | 1644 | |
1645 | nsyse7: |
||
1646 | |||
742 | Rus | 1647 | cmp eax,8 ; HD PARTITION |
1 | ha | 1648 | jne nsyse8 |
1649 | mov [fat32part],ebx |
||
1650 | ; call set_FAT32_variables |
||
1651 | call reserve_hd1 |
||
321 | diamond | 1652 | call reserve_hd_channel |
1653 | call free_hd_channel |
||
1 | ha | 1654 | pusha |
1655 | call choice_necessity_partition_1 |
||
1656 | popa |
||
742 | Rus | 1657 | mov [hd1_status],0 ; free |
1 | ha | 1658 | ret |
1659 | nsyse8: |
||
1660 | |||
742 | Rus | 1661 | cmp eax,10 ; SOUND DMA CHANNEL |
1 | ha | 1662 | jne no_set_sound_dma |
75 | diamond | 1663 | cmp ebx,3 |
1664 | ja sys_setup_err |
||
1 | ha | 1665 | mov [sound_dma],ebx |
1666 | ret |
||
1667 | no_set_sound_dma: |
||
1668 | |||
742 | Rus | 1669 | cmp eax,11 ; ENABLE LBA READ |
1 | ha | 1670 | jne no_set_lba_read |
1671 | and ebx,1 |
||
1672 | mov [lba_read_enabled],ebx |
||
1673 | ret |
||
1674 | no_set_lba_read: |
||
1675 | |||
742 | Rus | 1676 | cmp eax,12 ; ENABLE PCI ACCESS |
1 | ha | 1677 | jne no_set_pci_access |
1678 | and ebx,1 |
||
1679 | mov [pci_access_enabled],ebx |
||
1680 | ret |
||
1681 | no_set_pci_access: |
||
1682 | |||
1683 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
1684 | include 'vmodeint.inc' |
||
1685 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
1686 | |||
75 | diamond | 1687 | sys_setup_err: |
1 | ha | 1688 | mov [esp+36],dword -1 |
1689 | ret |
||
1690 | |||
1691 | align 4 |
||
1692 | |||
1693 | sys_getsetup: |
||
1694 | |||
1695 | ; 1=roland mpu midi base , base io address |
||
1696 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1697 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1698 | ; 4=sb16 base , base io address |
||
1699 | ; 5=system language, 1eng 2fi 3ger 4rus |
||
1700 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1701 | ; 8=fat32 partition in hd |
||
1702 | ; 9=get hs timer tic |
||
1703 | |||
1704 | cmp eax,1 |
||
1705 | jne ngsyse1 |
||
1706 | movzx eax,[midi_base] |
||
1707 | mov [esp+36],eax |
||
1708 | ret |
||
1709 | ngsyse1: |
||
1710 | |||
1711 | cmp eax,2 |
||
1712 | jne ngsyse2 |
||
1713 | cmp ebx,1 |
||
1714 | jnz kbnobaseret |
||
379 | serge | 1715 | mov edi,[TASK_BASE] |
115 | poddubny | 1716 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1717 | mov ebx,ecx |
1718 | mov eax,keymap |
||
1719 | mov ecx,128 |
||
1720 | call memmove |
||
1721 | ret |
||
1722 | kbnobaseret: |
||
1723 | cmp ebx,2 |
||
1724 | jnz kbnoshiftret |
||
379 | serge | 1725 | mov edi,[TASK_BASE] |
115 | poddubny | 1726 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1727 | mov ebx,ecx |
1728 | mov eax,keymap_shift |
||
1729 | mov ecx,128 |
||
1730 | call memmove |
||
1731 | ret |
||
1732 | kbnoshiftret: |
||
1733 | cmp ebx,3 |
||
1734 | jne kbnoaltret |
||
379 | serge | 1735 | mov edi,[TASK_BASE] |
115 | poddubny | 1736 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1737 | mov ebx,ecx |
1738 | mov eax,keymap_alt |
||
1739 | mov ecx,128 |
||
1740 | call memmove |
||
1741 | ret |
||
1742 | kbnoaltret: |
||
1743 | cmp ebx,9 |
||
1744 | jnz ngsyse2 |
||
1745 | movzx eax,word [keyboard] |
||
1746 | mov [esp+36],eax |
||
1747 | ret |
||
1748 | ngsyse2: |
||
1749 | |||
1750 | cmp eax,3 |
||
1751 | jnz ngsyse3 |
||
1752 | movzx eax,[cd_base] |
||
1753 | mov [esp+36],eax |
||
1754 | ret |
||
1755 | ngsyse3: |
||
1756 | |||
1757 | cmp eax,4 |
||
1758 | jne ngsyse4 |
||
1759 | mov eax,[sb16] |
||
1760 | mov [esp+36],eax |
||
1761 | ret |
||
1762 | ngsyse4: |
||
1763 | |||
1764 | cmp eax,5 |
||
1765 | jnz ngsyse5 |
||
1766 | mov eax,[syslang] |
||
1767 | mov [esp+36],eax |
||
1768 | ret |
||
1769 | ngsyse5: |
||
1770 | cmp eax,7 |
||
1771 | jnz ngsyse7 |
||
1772 | movzx eax,[hd_base] |
||
1773 | mov [esp+36],eax |
||
1774 | ret |
||
1775 | ngsyse7: |
||
1776 | cmp eax,8 |
||
1777 | jnz ngsyse8 |
||
1778 | mov eax,[fat32part] |
||
1779 | mov [esp+36],eax |
||
1780 | ret |
||
1781 | ngsyse8: |
||
1782 | cmp eax,9 |
||
1783 | jne ngsyse9 |
||
1784 | mov eax,[timer_ticks] ;[0xfdf0] |
||
1785 | mov [esp+36],eax |
||
1786 | ret |
||
1787 | ngsyse9: |
||
1788 | cmp eax,10 |
||
1789 | jnz ngsyse10 |
||
1790 | mov eax,[sound_dma] |
||
1791 | mov [esp+36],eax |
||
1792 | ret |
||
1793 | ngsyse10: |
||
1794 | cmp eax,11 |
||
1795 | jnz ngsyse11 |
||
1796 | mov eax,[lba_read_enabled] |
||
1797 | mov [esp+36],eax |
||
1798 | ret |
||
1799 | ngsyse11: |
||
1800 | cmp eax,12 |
||
1801 | jnz ngsyse12 |
||
1802 | mov eax,[pci_access_enabled] |
||
1803 | mov [esp+36],eax |
||
1804 | ret |
||
1805 | ngsyse12: |
||
1806 | mov [esp+36],dword 1 |
||
1807 | ret |
||
1808 | |||
479 | kastigar | 1809 | get_timer_ticks: |
1810 | mov eax,[timer_ticks] |
||
1811 | ret |
||
1812 | |||
283 | diamond | 1813 | iglobal |
1 | ha | 1814 | align 4 |
221 | serge | 1815 | mousefn dd msscreen, mswin, msbutton, msset |
742 | Rus | 1816 | dd app_load_cursor |
1817 | dd app_set_cursor |
||
1818 | dd app_delete_cursor |
||
1819 | dd msz |
||
283 | diamond | 1820 | endg |
1 | ha | 1821 | |
1822 | readmousepos: |
||
1823 | |||
1824 | ; eax=0 screen relative |
||
1825 | ; eax=1 window relative |
||
1826 | ; eax=2 buttons pressed |
||
221 | serge | 1827 | ; eax=3 set mouse pos ; reserved |
1828 | ; eax=4 load cursor |
||
1829 | ; eax=5 set cursor |
||
1830 | ; eax=6 delete cursor ; reserved |
||
479 | kastigar | 1831 | ; eax=7 get mouse_z |
1 | ha | 1832 | |
742 | Rus | 1833 | cmp eax, 7 |
1834 | ja msset |
||
1835 | jmp [mousefn+eax*4] |
||
221 | serge | 1836 | msscreen: |
742 | Rus | 1837 | mov eax,[MOUSE_X] |
1838 | shl eax,16 |
||
1839 | mov ax,[MOUSE_Y] |
||
1840 | mov [esp+36],eax |
||
1841 | ret |
||
221 | serge | 1842 | mswin: |
742 | Rus | 1843 | mov eax,[MOUSE_X] |
1844 | shl eax,16 |
||
1845 | mov ax,[MOUSE_Y] |
||
1846 | mov esi,[TASK_BASE] |
||
1847 | mov bx, word [esi-twdw+WDATA.box.left] |
||
1848 | shl ebx,16 |
||
1849 | mov bx, word [esi-twdw+WDATA.box.top] |
||
1850 | sub eax,ebx |
||
1 | ha | 1851 | |
742 | Rus | 1852 | mov edi,[CURRENT_TASK] |
1853 | shl edi,8 |
||
1854 | sub ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
1855 | rol eax,16 |
||
1856 | sub ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
1857 | rol eax,16 |
||
1858 | mov [esp+36],eax |
||
1859 | ret |
||
221 | serge | 1860 | msbutton: |
742 | Rus | 1861 | movzx eax,byte [BTN_DOWN] |
1862 | mov [esp+36],eax |
||
1863 | ret |
||
479 | kastigar | 1864 | msz: |
742 | Rus | 1865 | mov edi, [TASK_COUNT] |
1866 | movzx edi, word [WIN_POS + edi*2] |
||
1867 | cmp edi, [CURRENT_TASK] |
||
1868 | jne @f |
||
1869 | mov ax,[MOUSE_SCROLL_H] |
||
1870 | shl eax,16 |
||
1871 | mov ax,[MOUSE_SCROLL_V] |
||
1872 | mov [esp+36],eax |
||
1873 | mov [MOUSE_SCROLL_H],word 0 |
||
1874 | mov [MOUSE_SCROLL_V],word 0 |
||
1875 | ret |
||
479 | kastigar | 1876 | @@: |
742 | Rus | 1877 | mov [esp+36],dword 0 |
1878 | ret |
||
221 | serge | 1879 | msset: |
742 | Rus | 1880 | ret |
164 | serge | 1881 | |
221 | serge | 1882 | app_load_cursor: |
465 | serge | 1883 | ; add ebx, new_app_base |
742 | Rus | 1884 | cmp ebx, OS_BASE |
1885 | jae msset |
||
1886 | stdcall load_cursor, ebx, ecx |
||
1887 | mov [esp+36], eax |
||
1888 | ret |
||
164 | serge | 1889 | |
221 | serge | 1890 | app_set_cursor: |
742 | Rus | 1891 | stdcall set_cursor, ebx |
1892 | mov [esp+36], eax |
||
1893 | ret |
||
1 | ha | 1894 | |
233 | serge | 1895 | app_delete_cursor: |
742 | Rus | 1896 | stdcall delete_cursor, ebx |
1897 | mov [esp+36], eax |
||
1898 | ret |
||
1 | ha | 1899 | |
1900 | is_input: |
||
1901 | |||
1902 | push edx |
||
742 | Rus | 1903 | mov dx,word [midisp] |
1904 | in al,dx |
||
1905 | and al,0x80 |
||
1906 | pop edx |
||
1 | ha | 1907 | ret |
1908 | |||
1909 | is_output: |
||
1910 | |||
1911 | push edx |
||
742 | Rus | 1912 | mov dx,word [midisp] |
1913 | in al,dx |
||
1914 | and al,0x40 |
||
1915 | pop edx |
||
1 | ha | 1916 | ret |
1917 | |||
1918 | |||
1919 | get_mpu_in: |
||
1920 | |||
1921 | push edx |
||
742 | Rus | 1922 | mov dx,word [mididp] |
1923 | in al,dx |
||
1924 | pop edx |
||
1 | ha | 1925 | ret |
1926 | |||
1927 | |||
1928 | put_mpu_out: |
||
1929 | |||
1930 | push edx |
||
742 | Rus | 1931 | mov dx,word [mididp] |
1932 | out dx,al |
||
1933 | pop edx |
||
1 | ha | 1934 | ret |
1935 | |||
1936 | |||
1937 | setuart: |
||
1938 | |||
1939 | su1: |
||
1940 | call is_output |
||
742 | Rus | 1941 | cmp al,0 |
1942 | jnz su1 |
||
1943 | mov dx,word [midisp] |
||
1944 | mov al,0xff |
||
1945 | out dx,al |
||
1 | ha | 1946 | su2: |
742 | Rus | 1947 | mov dx,word [midisp] |
1948 | mov al,0xff |
||
1949 | out dx,al |
||
1 | ha | 1950 | call is_input |
742 | Rus | 1951 | cmp al,0 |
1952 | jnz su2 |
||
1 | ha | 1953 | call get_mpu_in |
742 | Rus | 1954 | cmp al,0xfe |
1955 | jnz su2 |
||
1 | ha | 1956 | su3: |
1957 | call is_output |
||
742 | Rus | 1958 | cmp al,0 |
1959 | jnz su3 |
||
1960 | mov dx,word [midisp] |
||
1961 | mov al,0x3f |
||
1962 | out dx,al |
||
1 | ha | 1963 | |
1964 | ret |
||
1965 | |||
1966 | |||
1967 | align 4 |
||
1968 | |||
1969 | sys_midi: |
||
1970 | |||
1971 | cmp [mididp],0 |
||
1972 | jnz sm0 |
||
1973 | mov [esp+36],dword 1 |
||
1974 | ret |
||
1975 | sm0: |
||
1976 | |||
1977 | cmp eax,1 |
||
1978 | mov [esp+36],dword 0 |
||
1979 | jnz smn1 |
||
1980 | call setuart |
||
1981 | ret |
||
1982 | smn1: |
||
1983 | |||
1984 | cmp eax,2 |
||
1985 | jnz smn2 |
||
1986 | sm10: |
||
1987 | call get_mpu_in |
||
1988 | call is_output |
||
1989 | test al,al |
||
1990 | jnz sm10 |
||
1991 | mov al,bl |
||
1992 | call put_mpu_out |
||
1993 | ret |
||
1994 | smn2: |
||
1995 | |||
1996 | ret |
||
1997 | |||
1998 | |||
1999 | detect_devices: |
||
2000 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
2001 | include 'detect/commouse.inc' |
||
479 | kastigar | 2002 | ;include 'detect/ps2mouse.inc' |
1 | ha | 2003 | ;include 'detect/dev_fd.inc' |
2004 | ;include 'detect/dev_hdcd.inc' |
||
2005 | ;include 'detect/sear_par.inc' |
||
2006 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
2007 | ret |
||
2008 | |||
2009 | |||
2010 | sys_end: |
||
2011 | |||
379 | serge | 2012 | mov eax,[TASK_BASE] |
115 | poddubny | 2013 | mov [eax+TASKDATA.state], 3 ; terminate this program |
41 | mikedld | 2014 | |
742 | Rus | 2015 | waitterm: ; wait here for termination |
684 | diamond | 2016 | mov ebx,100 |
1 | ha | 2017 | call delay_hs |
2018 | jmp waitterm |
||
2019 | |||
75 | diamond | 2020 | iglobal |
170 | serge | 2021 | align 4 |
75 | diamond | 2022 | sys_system_table: |
759 | Rus | 2023 | dd exit_for_anyone ; 1 = obsolete |
742 | Rus | 2024 | dd sysfn_terminate ; 2 = terminate thread |
2025 | dd sysfn_activate ; 3 = activate window |
||
2026 | dd sysfn_getidletime ; 4 = get idle time |
||
2027 | dd sysfn_getcpuclock ; 5 = get cpu clock |
||
2028 | dd sysfn_saveramdisk ; 6 = save ramdisk |
||
2029 | dd sysfn_getactive ; 7 = get active window |
||
2030 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
||
748 | heavyiron | 2031 | dd sysfn_shutdown ; 9 = shutdown with parameter |
742 | Rus | 2032 | dd sysfn_minimize ; 10 = minimize window |
2033 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
||
2034 | dd sysfn_lastkey ; 12 = get last pressed key |
||
2035 | dd sysfn_getversion ; 13 = get kernel version |
||
2036 | dd sysfn_waitretrace ; 14 = wait retrace |
||
2037 | dd sysfn_centermouse ; 15 = center mouse cursor |
||
2038 | dd sysfn_getfreemem ; 16 = get free memory size |
||
2039 | dd sysfn_getallmem ; 17 = get total memory size |
||
2040 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
||
2041 | ; instead of slot |
||
2042 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
||
2043 | dd sysfn_meminfo ; 20 = get extended memory info |
||
2044 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
||
2045 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
||
75 | diamond | 2046 | sysfn_num = ($ - sys_system_table)/4 |
2047 | endg |
||
2048 | |||
1 | ha | 2049 | sys_system: |
742 | Rus | 2050 | dec ebx |
2051 | cmp ebx, sysfn_num |
||
2052 | jae @f |
||
2053 | jmp dword [sys_system_table + ebx*4] |
||
75 | diamond | 2054 | @@: |
742 | Rus | 2055 | ret |
1 | ha | 2056 | |
214 | serge | 2057 | |
759 | Rus | 2058 | sysfn_shutdown: ; 18.9 = system shutdown |
748 | heavyiron | 2059 | cmp ecx,1 |
2060 | jl exit_for_anyone |
||
2061 | cmp ecx,4 |
||
2062 | jg exit_for_anyone |
||
2063 | mov [BOOT_VAR+0x9030],cl |
||
2064 | |||
379 | serge | 2065 | mov eax,[TASK_COUNT] |
709 | diamond | 2066 | mov [SYS_SHUTDOWN],al |
1 | ha | 2067 | mov [shutdown_processes],eax |
684 | diamond | 2068 | and dword [esp+32], 0 |
748 | heavyiron | 2069 | exit_for_anyone: |
1 | ha | 2070 | ret |
2071 | uglobal |
||
2072 | shutdown_processes: dd 0x0 |
||
2073 | endg |
||
2074 | |||
742 | Rus | 2075 | sysfn_terminate: ; 18.2 = TERMINATE |
684 | diamond | 2076 | cmp ecx,2 |
1 | ha | 2077 | jb noprocessterminate |
379 | serge | 2078 | mov edx,[TASK_COUNT] |
684 | diamond | 2079 | cmp ecx,edx |
75 | diamond | 2080 | ja noprocessterminate |
379 | serge | 2081 | mov eax,[TASK_COUNT] |
684 | diamond | 2082 | shl ecx,5 |
2083 | mov edx,[ecx+CURRENT_TASK+TASKDATA.pid] |
||
2084 | add ecx,CURRENT_TASK+TASKDATA.state |
||
2085 | cmp byte [ecx], 9 |
||
75 | diamond | 2086 | jz noprocessterminate |
41 | mikedld | 2087 | |
1 | ha | 2088 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
742 | Rus | 2089 | mov [ecx],byte 3 ; clear possible i40's |
1 | ha | 2090 | ;call MEM_Heap_UnLock |
2091 | |||
2092 | cmp edx,[application_table_status] ; clear app table stat |
||
2093 | jne noatsc |
||
2094 | mov [application_table_status],0 |
||
2095 | noatsc: |
||
75 | diamond | 2096 | noprocessterminate: |
1 | ha | 2097 | ret |
2098 | |||
85 | halyavin | 2099 | sysfn_terminate2: |
2100 | ;lock application_table_status mutex |
||
164 | serge | 2101 | .table_status: |
85 | halyavin | 2102 | cli |
2103 | cmp [application_table_status],0 |
||
742 | Rus | 2104 | je .stf |
85 | halyavin | 2105 | sti |
2106 | call change_task |
||
2107 | jmp .table_status |
||
2108 | .stf: |
||
2109 | call set_application_table_status |
||
684 | diamond | 2110 | mov eax,ecx |
85 | halyavin | 2111 | call pid_to_slot |
2112 | test eax,eax |
||
742 | Rus | 2113 | jz .not_found |
684 | diamond | 2114 | mov ecx,eax |
85 | halyavin | 2115 | cli |
2116 | call sysfn_terminate |
||
2117 | mov [application_table_status],0 |
||
2118 | sti |
||
684 | diamond | 2119 | and dword [esp+32],0 |
85 | halyavin | 2120 | ret |
2121 | .not_found: |
||
2122 | mov [application_table_status],0 |
||
742 | Rus | 2123 | or dword [esp+32],-1 |
85 | halyavin | 2124 | ret |
2125 | |||
742 | Rus | 2126 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
684 | diamond | 2127 | cmp ecx,2 |
105 | poddubny | 2128 | jb .nowindowactivate |
684 | diamond | 2129 | cmp ecx,[TASK_COUNT] |
105 | poddubny | 2130 | ja .nowindowactivate |
2131 | |||
2132 | mov [window_minimize], 2 ; restore window if minimized |
||
2133 | |||
684 | diamond | 2134 | movzx esi, word [WIN_STACK + ecx*2] |
379 | serge | 2135 | cmp esi, [TASK_COUNT] |
105 | poddubny | 2136 | je .nowindowactivate ; already active |
2137 | |||
684 | diamond | 2138 | mov edi, ecx |
105 | poddubny | 2139 | shl edi, 5 |
2140 | add edi, window_data |
||
684 | diamond | 2141 | movzx esi, word [WIN_STACK + ecx * 2] |
380 | serge | 2142 | lea esi, [WIN_POS + esi * 2] |
105 | poddubny | 2143 | call waredraw |
2144 | .nowindowactivate: |
||
1 | ha | 2145 | ret |
41 | mikedld | 2146 | |
742 | Rus | 2147 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
1 | ha | 2148 | mov eax,[idleusesec] |
684 | diamond | 2149 | mov [esp+32], eax |
1 | ha | 2150 | ret |
2151 | |||
742 | Rus | 2152 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
381 | serge | 2153 | mov eax,[CPU_FREQ] |
684 | diamond | 2154 | mov [esp+32], eax |
1 | ha | 2155 | ret |
2156 | |||
2157 | ; SAVE ramdisk to /hd/1/menuet.img |
||
2158 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
2159 | include 'blkdev/rdsave.inc' |
||
2160 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
75 | diamond | 2161 | |
742 | Rus | 2162 | sysfn_getactive: ; 18.7 = get active window |
379 | serge | 2163 | mov eax, [TASK_COUNT] |
380 | serge | 2164 | movzx eax, word [WIN_POS + eax*2] |
684 | diamond | 2165 | mov [esp+32],eax |
1 | ha | 2166 | ret |
75 | diamond | 2167 | |
742 | Rus | 2168 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
684 | diamond | 2169 | cmp ecx,1 |
1 | ha | 2170 | jne nogetsoundflag |
2171 | movzx eax,byte [sound_flag] ; get sound_flag |
||
684 | diamond | 2172 | mov [esp+32],eax |
1 | ha | 2173 | ret |
2174 | nogetsoundflag: |
||
684 | diamond | 2175 | cmp ecx,2 |
1 | ha | 2176 | jnz nosoundflag |
75 | diamond | 2177 | xor byte [sound_flag], 1 |
2178 | nosoundflag: |
||
41 | mikedld | 2179 | ret |
75 | diamond | 2180 | |
742 | Rus | 2181 | sysfn_minimize: ; 18.10 = minimize window |
1 | ha | 2182 | mov [window_minimize],1 |
2183 | ret |
||
75 | diamond | 2184 | |
742 | Rus | 2185 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
684 | diamond | 2186 | cmp ecx,1 |
1 | ha | 2187 | jnz full_table |
2188 | small_table: |
||
2189 | call for_all_tables |
||
75 | diamond | 2190 | mov ecx,10 |
1 | ha | 2191 | cld |
2192 | rep movsb |
||
2193 | ret |
||
2194 | for_all_tables: |
||
684 | diamond | 2195 | mov edi,edx |
381 | serge | 2196 | mov esi,DRIVE_DATA |
1 | ha | 2197 | ret |
2198 | full_table: |
||
684 | diamond | 2199 | cmp ecx,2 |
1 | ha | 2200 | jnz exit_for_anyone |
2201 | call for_all_tables |
||
75 | diamond | 2202 | mov ecx,16384 |
1 | ha | 2203 | cld |
2204 | rep movsd |
||
2205 | ret |
||
75 | diamond | 2206 | |
742 | Rus | 2207 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2208 | and dword [esp+32], 0 |
||
2209 | ret |
||
75 | diamond | 2210 | |
742 | Rus | 2211 | sysfn_getversion: ; 18.13 = get kernel ID and version |
684 | diamond | 2212 | mov edi,ebx |
1 | ha | 2213 | mov esi,version_inf |
2214 | mov ecx,version_end-version_inf |
||
2215 | rep movsb |
||
2216 | ret |
||
75 | diamond | 2217 | |
2218 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
||
41 | mikedld | 2219 | ;wait retrace functions |
2220 | sys_wait_retrace: |
||
2221 | mov edx,0x3da |
||
2222 | WaitRetrace_loop: |
||
2223 | in al,dx |
||
2224 | test al,1000b |
||
2225 | jz WaitRetrace_loop |
||
684 | diamond | 2226 | and [esp+32],dword 0 |
1 | ha | 2227 | ret |
75 | diamond | 2228 | |
742 | Rus | 2229 | sysfn_centermouse: ; 18.15 = mouse centered |
1 | ha | 2230 | call mouse_centered |
684 | diamond | 2231 | and [esp+32],dword 0 |
1 | ha | 2232 | ret |
75 | diamond | 2233 | |
120 | mario79 | 2234 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
684 | diamond | 2235 | cmp ecx,0 ; get mouse speed factor |
120 | mario79 | 2236 | jnz .set_mouse_acceleration |
164 | serge | 2237 | xor eax,eax |
120 | mario79 | 2238 | mov ax,[mouse_speed_factor] |
684 | diamond | 2239 | mov [esp+32],eax |
120 | mario79 | 2240 | ret |
2241 | .set_mouse_acceleration: |
||
684 | diamond | 2242 | cmp ecx,1 ; set mouse speed factor |
120 | mario79 | 2243 | jnz .get_mouse_delay |
684 | diamond | 2244 | mov [mouse_speed_factor],dx |
120 | mario79 | 2245 | ret |
2246 | .get_mouse_delay: |
||
684 | diamond | 2247 | cmp ecx,2 ; get mouse delay |
120 | mario79 | 2248 | jnz .set_mouse_delay |
2249 | mov eax,[mouse_delay] |
||
684 | diamond | 2250 | mov [esp+32],eax |
120 | mario79 | 2251 | ret |
2252 | .set_mouse_delay: |
||
684 | diamond | 2253 | cmp ecx,3 ; set mouse delay |
120 | mario79 | 2254 | jnz .set_pointer_position |
684 | diamond | 2255 | mov [mouse_delay],edx |
120 | mario79 | 2256 | ret |
2257 | .set_pointer_position: |
||
684 | diamond | 2258 | cmp ecx,4 ; set mouse pointer position |
621 | mario79 | 2259 | jnz .set_mouse_button |
684 | diamond | 2260 | mov [MOUSE_Y],dx ;y |
2261 | ror edx,16 |
||
2262 | mov [MOUSE_X],dx ;x |
||
2263 | rol edx,16 |
||
621 | mario79 | 2264 | ret |
2265 | .set_mouse_button: |
||
684 | diamond | 2266 | cmp ecx,5 ; set mouse button features |
621 | mario79 | 2267 | jnz .end |
684 | diamond | 2268 | mov [BTN_DOWN],dl |
621 | mario79 | 2269 | mov [mouse_active],1 |
120 | mario79 | 2270 | .end: |
2271 | ret |
||
2272 | |||
75 | diamond | 2273 | sysfn_getfreemem: |
170 | serge | 2274 | mov eax, [pg_data.pages_free] |
2275 | shl eax, 2 |
||
684 | diamond | 2276 | mov [esp+32],eax |
1 | ha | 2277 | ret |
75 | diamond | 2278 | |
2279 | sysfn_getallmem: |
||
170 | serge | 2280 | mov eax,[MEM_AMOUNT] |
2281 | shr eax, 10 |
||
684 | diamond | 2282 | mov [esp+32],eax |
32 | halyavin | 2283 | ret |
2284 | |||
608 | alver | 2285 | ; // Alver, 2007-22-08 // { |
2286 | sysfn_pid_to_slot: |
||
684 | diamond | 2287 | mov eax, ecx |
608 | alver | 2288 | call pid_to_slot |
684 | diamond | 2289 | mov [esp+32], eax |
608 | alver | 2290 | ret |
2291 | |||
2292 | sysfn_min_rest_window: |
||
2293 | pushad |
||
742 | Rus | 2294 | mov eax, edx ; ebx - operating |
684 | diamond | 2295 | shr ecx, 1 |
608 | alver | 2296 | jnc @f |
2297 | call pid_to_slot |
||
2298 | @@: |
||
742 | Rus | 2299 | or eax, eax ; eax - number of slot |
608 | alver | 2300 | jz .error |
742 | Rus | 2301 | cmp eax, 255 ; varify maximal slot number |
608 | alver | 2302 | ja .error |
684 | diamond | 2303 | movzx eax, word [WIN_STACK + eax*2] |
2304 | shr ecx, 1 |
||
608 | alver | 2305 | jc .restore |
2306 | ; .minimize: |
||
2307 | call minimize_window |
||
2308 | jmp .exit |
||
2309 | .restore: |
||
2310 | call restore_minimized_window |
||
2311 | .exit: |
||
2312 | popad |
||
2313 | xor eax, eax |
||
684 | diamond | 2314 | mov [esp+32], eax |
608 | alver | 2315 | ret |
2316 | .error: |
||
2317 | popad |
||
2318 | xor eax, eax |
||
2319 | dec eax |
||
684 | diamond | 2320 | mov [esp+32], eax |
608 | alver | 2321 | ret |
2322 | ; } \\ Alver, 2007-22-08 \\ |
||
2323 | |||
41 | mikedld | 2324 | uglobal |
2325 | ;// mike.dld, 2006-29-01 [ |
||
2326 | screen_workarea RECT |
||
2327 | ;// mike.dld, 2006-29-01 ] |
||
1 | ha | 2328 | window_minimize db 0 |
742 | Rus | 2329 | sound_flag db 0 |
41 | mikedld | 2330 | endg |
1 | ha | 2331 | |
41 | mikedld | 2332 | iglobal |
2333 | version_inf: |
||
641 | diamond | 2334 | db 0,7,1,0 ; version 0.7.1.0 |
41 | mikedld | 2335 | db UID_KOLIBRI |
540 | victor | 2336 | dd __REV__ |
41 | mikedld | 2337 | version_end: |
2338 | endg |
||
1 | ha | 2339 | |
41 | mikedld | 2340 | UID_NONE=0 |
742 | Rus | 2341 | UID_MENUETOS=1 ;official |
2342 | UID_KOLIBRI=2 ;russian |
||
1 | ha | 2343 | |
2344 | sys_cachetodiskette: |
||
671 | Ghost | 2345 | cmp ebx, 1 |
2346 | jne .no_floppy_a_save |
||
2347 | mov [flp_number], 1 |
||
2348 | jmp .save_image_on_floppy |
||
2349 | .no_floppy_a_save: |
||
2350 | cmp ebx, 2 |
||
2351 | jne .no_floppy_b_save |
||
2352 | mov [flp_number], 2 |
||
2353 | .save_image_on_floppy: |
||
2354 | call save_image |
||
2355 | mov [esp + 32], dword 0 |
||
2356 | cmp [FDC_Status], 0 |
||
2357 | je .yes_floppy_save |
||
2358 | .no_floppy_b_save: |
||
2359 | mov [esp + 32], dword 1 |
||
2360 | .yes_floppy_save: |
||
2361 | ret |
||
1 | ha | 2362 | |
2363 | uglobal |
||
2364 | ; bgrchanged dd 0x0 |
||
546 | diamond | 2365 | bgrlock db 0 |
2366 | bgrlockpid dd 0 |
||
1 | ha | 2367 | endg |
2368 | |||
2369 | sys_background: |
||
2370 | |||
742 | Rus | 2371 | cmp ebx,1 ; BACKGROUND SIZE |
1 | ha | 2372 | jnz nosb1 |
2373 | cmp ecx,0 |
||
742 | Rus | 2374 | je sbgrr |
684 | diamond | 2375 | cmp edx,0 |
742 | Rus | 2376 | je sbgrr |
546 | diamond | 2377 | @@: |
742 | Rus | 2378 | mov al, 1 |
2379 | xchg [bgrlock], al |
||
2380 | test al, al |
||
2381 | jz @f |
||
2382 | call change_task |
||
2383 | jmp @b |
||
546 | diamond | 2384 | @@: |
684 | diamond | 2385 | mov [BgrDataWidth],ecx |
2386 | mov [BgrDataHeight],edx |
||
1 | ha | 2387 | ; mov [bgrchanged],1 |
469 | serge | 2388 | |
2389 | pushad |
||
2390 | ; return memory for old background |
||
2391 | stdcall kernel_free, [img_background] |
||
2392 | ; calculate RAW size |
||
2393 | xor eax,eax |
||
2394 | inc eax |
||
527 | diamond | 2395 | cmp [BgrDataWidth],eax |
469 | serge | 2396 | jae @f |
527 | diamond | 2397 | mov [BgrDataWidth],eax |
469 | serge | 2398 | @@: |
527 | diamond | 2399 | cmp [BgrDataHeight],eax |
469 | serge | 2400 | jae @f |
527 | diamond | 2401 | mov [BgrDataHeight],eax |
469 | serge | 2402 | @@: |
527 | diamond | 2403 | mov eax,[BgrDataWidth] |
2404 | imul eax,[BgrDataHeight] |
||
2405 | lea eax,[eax*3] |
||
469 | serge | 2406 | mov [mem_BACKGROUND],eax |
2407 | ; get memory for new background |
||
546 | diamond | 2408 | stdcall kernel_alloc, eax |
469 | serge | 2409 | test eax, eax |
2410 | jz .exit_mem |
||
2411 | mov [img_background], eax |
||
2412 | .exit_mem: |
||
2413 | popad |
||
742 | Rus | 2414 | mov [bgrlock], 0 |
469 | serge | 2415 | |
1 | ha | 2416 | sbgrr: |
2417 | ret |
||
469 | serge | 2418 | |
1 | ha | 2419 | nosb1: |
2420 | |||
742 | Rus | 2421 | cmp ebx,2 ; SET PIXEL |
1 | ha | 2422 | jnz nosb2 |
684 | diamond | 2423 | cmp ecx,[mem_BACKGROUND] |
2424 | jae nosb2 |
||
469 | serge | 2425 | mov eax,[img_background] |
684 | diamond | 2426 | mov ebx,[eax+ecx] |
2427 | and ebx,0xFF000000 ;255*256*256*256 |
||
2428 | and edx,0x00FFFFFF ;255*256*256+255*256+255 |
||
2429 | add edx,ebx |
||
2430 | mov [eax+ecx],edx |
||
1 | ha | 2431 | ; mov [bgrchanged],1 |
2432 | ret |
||
2433 | nosb2: |
||
2434 | |||
742 | Rus | 2435 | cmp ebx,3 ; DRAW BACKGROUND |
1 | ha | 2436 | jnz nosb3 |
2437 | draw_background_temp: |
||
2438 | ; cmp [bgrchanged],1 ;0 |
||
2439 | ; je nosb31 |
||
2440 | ;draw_background_temp: |
||
2441 | ; mov [bgrchanged],1 ;0 |
||
76 | mario79 | 2442 | mov [background_defined], 1 |
709 | diamond | 2443 | call force_redraw_background |
2444 | mov [REDRAW_BACKGROUND], byte 2 |
||
1 | ha | 2445 | nosb31: |
2446 | ret |
||
2447 | nosb3: |
||
2448 | |||
742 | Rus | 2449 | cmp ebx,4 ; TILED / STRETCHED |
1 | ha | 2450 | jnz nosb4 |
684 | diamond | 2451 | cmp ecx,[BgrDrawMode] |
742 | Rus | 2452 | je nosb41 |
684 | diamond | 2453 | mov [BgrDrawMode],ecx |
1 | ha | 2454 | ; mov [bgrchanged],1 |
2455 | nosb41: |
||
2456 | ret |
||
2457 | nosb4: |
||
2458 | |||
742 | Rus | 2459 | cmp ebx,5 ; BLOCK MOVE TO BGR |
1 | ha | 2460 | jnz nosb5 |
2461 | ; bughere |
||
684 | diamond | 2462 | mov eax, ecx |
2463 | mov ebx, edx |
||
469 | serge | 2464 | add ebx, [img_background] ;IMG_BACKGROUND |
684 | diamond | 2465 | mov ecx, esi |
1 | ha | 2466 | call memmove |
2467 | .fin: |
||
2468 | ret |
||
2469 | nosb5: |
||
479 | kastigar | 2470 | |
742 | Rus | 2471 | cmp ebx, 6 |
2472 | jnz nosb6 |
||
546 | diamond | 2473 | @@: |
742 | Rus | 2474 | mov al, 1 |
2475 | xchg [bgrlock], al |
||
2476 | test al, al |
||
2477 | jz @f |
||
2478 | call change_task |
||
2479 | jmp @b |
||
546 | diamond | 2480 | @@: |
742 | Rus | 2481 | mov eax, [CURRENT_TASK] |
2482 | mov [bgrlockpid], eax |
||
2483 | stdcall user_alloc, [mem_BACKGROUND] |
||
2484 | mov [esp+32], eax |
||
2485 | test eax, eax |
||
2486 | jz .nomem |
||
2487 | mov ebx, eax |
||
2488 | shr ebx, 12 |
||
2489 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
||
2490 | mov esi, [img_background] |
||
2491 | shr esi, 12 |
||
2492 | mov ecx, [mem_BACKGROUND] |
||
2493 | add ecx, 0xFFF |
||
2494 | shr ecx, 12 |
||
546 | diamond | 2495 | .z: |
742 | Rus | 2496 | mov eax, [page_tabs+ebx*4] |
2497 | test al, 1 |
||
2498 | jz @f |
||
2499 | call free_page |
||
546 | diamond | 2500 | @@: |
742 | Rus | 2501 | mov eax, [page_tabs+esi*4] |
2502 | or al, PG_UW |
||
2503 | mov [page_tabs+ebx*4], eax |
||
2504 | mov eax, ebx |
||
2505 | shl eax, 12 |
||
2506 | invlpg [eax] |
||
2507 | inc ebx |
||
2508 | inc esi |
||
2509 | loop .z |
||
2510 | ret |
||
546 | diamond | 2511 | .nomem: |
742 | Rus | 2512 | and [bgrlockpid], 0 |
2513 | mov [bgrlock], 0 |
||
546 | diamond | 2514 | nosb6: |
742 | Rus | 2515 | cmp ebx, 7 |
2516 | jnz nosb7 |
||
2517 | cmp [bgrlock], 0 |
||
2518 | jz .err |
||
2519 | mov eax, [CURRENT_TASK] |
||
2520 | cmp [bgrlockpid], eax |
||
2521 | jnz .err |
||
2522 | mov eax, ecx |
||
2523 | mov ebx, ecx |
||
2524 | shr eax, 12 |
||
2525 | mov ecx, [page_tabs+(eax-1)*4] |
||
2526 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
||
2527 | jz .err |
||
2528 | jnp .err |
||
2529 | push eax |
||
2530 | shr ecx, 12 |
||
546 | diamond | 2531 | @@: |
742 | Rus | 2532 | and dword [page_tabs+eax*4], 0 |
2533 | mov edx, eax |
||
2534 | shl edx, 12 |
||
2535 | invlpg [edx] |
||
2536 | inc eax |
||
2537 | loop @b |
||
2538 | pop eax |
||
2539 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
||
2540 | stdcall user_free, ebx |
||
2541 | mov [esp+32], eax |
||
2542 | and [bgrlockpid], 0 |
||
2543 | mov [bgrlock], 0 |
||
2544 | ret |
||
546 | diamond | 2545 | .err: |
742 | Rus | 2546 | and dword [esp+32], 0 |
2547 | ret |
||
546 | diamond | 2548 | |
2549 | nosb7: |
||
1 | ha | 2550 | ret |
2551 | |||
709 | diamond | 2552 | force_redraw_background: |
2553 | mov [draw_data+32 + RECT.left],dword 0 |
||
2554 | mov [draw_data+32 + RECT.top],dword 0 |
||
2555 | push eax ebx |
||
753 | serge | 2556 | mov eax,[Screen_Max_X] |
2557 | mov ebx,[Screen_Max_Y] |
||
709 | diamond | 2558 | mov [draw_data+32 + RECT.right],eax |
2559 | mov [draw_data+32 + RECT.bottom],ebx |
||
2560 | pop ebx eax |
||
2561 | mov byte [REDRAW_BACKGROUND], 1 |
||
2562 | ret |
||
479 | kastigar | 2563 | |
1 | ha | 2564 | align 4 |
2565 | |||
2566 | sys_getbackground: |
||
2567 | |||
742 | Rus | 2568 | cmp eax,1 ; SIZE |
1 | ha | 2569 | jnz nogb1 |
527 | diamond | 2570 | mov eax,[BgrDataWidth] |
1 | ha | 2571 | shl eax,16 |
531 | diamond | 2572 | mov ax,[BgrDataHeight] |
1 | ha | 2573 | mov [esp+36],eax |
2574 | ret |
||
2575 | nogb1: |
||
2576 | |||
742 | Rus | 2577 | cmp eax,2 ; PIXEL |
1 | ha | 2578 | jnz nogb2 |
469 | serge | 2579 | ; mov edx,0x160000-16 |
2580 | ; cmp edx,ebx |
||
2581 | ; jbe nogb2 |
||
2582 | ; mov eax, [ebx+IMG_BACKGROUND] |
||
2583 | mov eax,[img_background] |
||
2584 | mov eax,[ebx+eax] |
||
2585 | |||
1 | ha | 2586 | and eax, 0xFFFFFF |
2587 | mov [esp+36],eax |
||
2588 | ret |
||
2589 | nogb2: |
||
2590 | |||
742 | Rus | 2591 | cmp eax,4 ; TILED / STRETCHED |
1 | ha | 2592 | jnz nogb4 |
527 | diamond | 2593 | mov eax,[BgrDrawMode] |
1 | ha | 2594 | nogb4: |
2595 | mov [esp+36],eax |
||
2596 | ret |
||
2597 | |||
2598 | |||
2599 | align 4 |
||
2600 | |||
2601 | sys_getkey: |
||
671 | Ghost | 2602 | mov [esp + 32],dword 1 |
2603 | ; test main buffer |
||
742 | Rus | 2604 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
671 | Ghost | 2605 | movzx ecx, word [WIN_STACK + ebx * 2] |
2606 | mov edx, [TASK_COUNT] |
||
2607 | cmp ecx, edx |
||
2608 | jne .finish |
||
2609 | cmp [KEY_COUNT], byte 0 |
||
2610 | je .finish |
||
2611 | movzx eax, byte [KEY_BUFF] |
||
2612 | shl eax, 8 |
||
2613 | push eax |
||
2614 | dec byte [KEY_COUNT] |
||
2615 | and byte [KEY_COUNT], 127 |
||
2616 | movzx ecx, byte [KEY_COUNT] |
||
2617 | add ecx, 2 |
||
2618 | mov eax, KEY_BUFF + 1 |
||
2619 | mov ebx, KEY_BUFF |
||
2620 | call memmove |
||
2621 | pop eax |
||
92 | diamond | 2622 | .ret_eax: |
671 | Ghost | 2623 | mov [esp + 32], eax |
2624 | ret |
||
2625 | .finish: |
||
92 | diamond | 2626 | ; test hotkeys buffer |
671 | Ghost | 2627 | mov ecx, hotkey_buffer |
92 | diamond | 2628 | @@: |
671 | Ghost | 2629 | cmp [ecx], ebx |
2630 | jz .found |
||
2631 | add ecx, 8 |
||
2632 | cmp ecx, hotkey_buffer + 120 * 8 |
||
2633 | jb @b |
||
2634 | ret |
||
92 | diamond | 2635 | .found: |
671 | Ghost | 2636 | mov ax, [ecx + 6] |
2637 | shl eax, 16 |
||
2638 | mov ah, [ecx + 4] |
||
2639 | mov al, 2 |
||
2640 | and dword [ecx + 4], 0 |
||
2641 | and dword [ecx], 0 |
||
2642 | jmp .ret_eax |
||
1 | ha | 2643 | |
2644 | align 4 |
||
2645 | |||
2646 | sys_getbutton: |
||
2647 | |||
742 | Rus | 2648 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
671 | Ghost | 2649 | mov [esp + 32], dword 1 |
2650 | movzx ecx, word [WIN_STACK + ebx * 2] |
||
2651 | mov edx, [TASK_COUNT] ; less than 256 processes |
||
2652 | cmp ecx, edx |
||
2653 | jne .exit |
||
2654 | movzx eax, byte [BTN_COUNT] |
||
2655 | test eax, eax |
||
2656 | jz .exit |
||
2657 | mov eax, [BTN_BUFF] |
||
2658 | shl eax, 8 |
||
2659 | mov [BTN_COUNT], byte 0 |
||
2660 | mov [esp + 32], eax |
||
2661 | .exit: |
||
2662 | ret |
||
1 | ha | 2663 | |
2664 | |||
2665 | align 4 |
||
2666 | |||
2667 | sys_cpuusage: |
||
2668 | |||
2669 | ; RETURN: |
||
2670 | ; |
||
2671 | ; +00 dword process cpu usage |
||
2672 | ; +04 word position in windowing stack |
||
2673 | ; +06 word windowing stack value at current position (cpu nro) |
||
2674 | ; +10 12 bytes name |
||
2675 | ; +22 dword start in mem |
||
2676 | ; +26 dword used mem |
||
2677 | ; +30 dword PID , process idenfification number |
||
2678 | ; |
||
2679 | |||
742 | Rus | 2680 | cmp ecx,-1 ; who am I ? |
684 | diamond | 2681 | jne .no_who_am_i |
2682 | mov ecx,[CURRENT_TASK] |
||
2683 | .no_who_am_i: |
||
742 | Rus | 2684 | cmp ecx, max_processes |
2685 | ja .nofillbuf |
||
1 | ha | 2686 | |
684 | diamond | 2687 | ; +4: word: position of the window of thread in the window stack |
742 | Rus | 2688 | mov ax, [WIN_STACK + ecx * 2] |
2689 | mov [ebx+4], ax |
||
684 | diamond | 2690 | ; +6: word: number of the thread slot, which window has in the window stack |
2691 | ; position ecx (has no relation to the specific thread) |
||
742 | Rus | 2692 | mov ax, [WIN_POS + ecx * 2] |
2693 | mov [ebx+6], ax |
||
1 | ha | 2694 | |
742 | Rus | 2695 | shl ecx, 5 |
1 | ha | 2696 | |
684 | diamond | 2697 | ; +0: dword: memory usage |
742 | Rus | 2698 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
2699 | mov [ebx], eax |
||
684 | diamond | 2700 | ; +10: 11 bytes: name of the process |
742 | Rus | 2701 | push ecx |
2702 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
||
2703 | add ebx, 10 |
||
2704 | mov ecx, 11 |
||
2705 | call memmove |
||
2706 | pop ecx |
||
1 | ha | 2707 | |
684 | diamond | 2708 | ; +22: address of the process in memory |
2709 | ; +26: size of used memory - 1 |
||
742 | Rus | 2710 | push edi |
2711 | lea edi, [ebx+12] |
||
2712 | xor eax, eax |
||
2713 | mov edx, 0x100000*16 |
||
2714 | cmp ecx, 1 shl 5 |
||
2715 | je .os_mem |
||
2716 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
||
2717 | mov eax, std_application_base_address |
||
684 | diamond | 2718 | .os_mem: |
742 | Rus | 2719 | stosd |
2720 | lea eax, [edx-1] |
||
2721 | stosd |
||
1 | ha | 2722 | |
684 | diamond | 2723 | ; +30: PID/TID |
742 | Rus | 2724 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
2725 | stosd |
||
1 | ha | 2726 | |
2727 | ; window position and size |
||
742 | Rus | 2728 | push esi |
2729 | lea esi, [ecx + window_data + WDATA.box] |
||
2730 | movsd |
||
2731 | movsd |
||
2732 | movsd |
||
2733 | movsd |
||
1 | ha | 2734 | |
2735 | ; Process state (+50) |
||
742 | Rus | 2736 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
2737 | stosd |
||
1 | ha | 2738 | |
138 | mikedld | 2739 | ; Window client area box |
742 | Rus | 2740 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
2741 | movsd |
||
2742 | movsd |
||
2743 | movsd |
||
2744 | movsd |
||
1 | ha | 2745 | |
164 | serge | 2746 | ; Window state |
742 | Rus | 2747 | mov al, [ecx+window_data+WDATA.fl_wstate] |
2748 | stosb |
||
164 | serge | 2749 | |
742 | Rus | 2750 | pop esi |
2751 | pop edi |
||
138 | mikedld | 2752 | |
684 | diamond | 2753 | .nofillbuf: |
1 | ha | 2754 | ; return number of processes |
2755 | |||
379 | serge | 2756 | mov eax,[TASK_COUNT] |
684 | diamond | 2757 | mov [esp+32],eax |
1 | ha | 2758 | ret |
2759 | |||
2760 | align 4 |
||
2761 | sys_clock: |
||
742 | Rus | 2762 | cli |
1 | ha | 2763 | ; Mikhail Lisovin xx Jan 2005 |
742 | Rus | 2764 | @@: mov al, 10 |
2765 | out 0x70, al |
||
2766 | in al, 0x71 |
||
2767 | test al, al |
||
2768 | jns @f |
||
2769 | mov esi, 1 |
||
2770 | call delay_ms |
||
2771 | jmp @b |
||
1 | ha | 2772 | @@: |
2773 | ; end Lisovin's fix |
||
2774 | |||
742 | Rus | 2775 | xor al,al ; seconds |
2776 | out 0x70,al |
||
2777 | in al,0x71 |
||
2778 | movzx ecx,al |
||
2779 | mov al,02 ; minutes |
||
2780 | shl ecx,16 |
||
2781 | out 0x70,al |
||
2782 | in al,0x71 |
||
2783 | movzx edx,al |
||
2784 | mov al,04 ; hours |
||
2785 | shl edx,8 |
||
2786 | out 0x70,al |
||
2787 | in al,0x71 |
||
2788 | add ecx,edx |
||
2789 | movzx edx,al |
||
2790 | add ecx,edx |
||
2791 | sti |
||
671 | Ghost | 2792 | mov [esp + 32], ecx |
742 | Rus | 2793 | ret |
1 | ha | 2794 | |
2795 | |||
2796 | align 4 |
||
2797 | |||
2798 | sys_date: |
||
2799 | |||
742 | Rus | 2800 | cli |
2801 | @@: mov al, 10 |
||
2802 | out 0x70, al |
||
2803 | in al, 0x71 |
||
2804 | test al, al |
||
2805 | jns @f |
||
2806 | mov esi, 1 |
||
2807 | call delay_ms |
||
2808 | jmp @b |
||
75 | diamond | 2809 | @@: |
2810 | |||
742 | Rus | 2811 | mov ch,0 |
2812 | mov al,7 ; date |
||
2813 | out 0x70,al |
||
2814 | in al,0x71 |
||
2815 | mov cl,al |
||
2816 | mov al,8 ; month |
||
2817 | shl ecx,16 |
||
2818 | out 0x70,al |
||
2819 | in al,0x71 |
||
2820 | mov ch,al |
||
2821 | mov al,9 ; year |
||
2822 | out 0x70,al |
||
2823 | in al,0x71 |
||
2824 | mov cl,al |
||
2825 | sti |
||
2826 | mov [esp+32], ecx |
||
2827 | ret |
||
1 | ha | 2828 | |
2829 | |||
2830 | ; redraw status |
||
2831 | |||
2832 | sys_redrawstat: |
||
671 | Ghost | 2833 | cmp ebx, 1 |
2834 | jne no_widgets_away |
||
2835 | ; buttons away |
||
2836 | mov ecx,[CURRENT_TASK] |
||
1 | ha | 2837 | sys_newba2: |
671 | Ghost | 2838 | mov edi,[BTN_ADDR] |
742 | Rus | 2839 | cmp [edi], dword 0 ; empty button list ? |
671 | Ghost | 2840 | je end_of_buttons_away |
2841 | movzx ebx, word [edi] |
||
2842 | inc ebx |
||
2843 | mov eax,edi |
||
1 | ha | 2844 | sys_newba: |
671 | Ghost | 2845 | dec ebx |
2846 | jz end_of_buttons_away |
||
1 | ha | 2847 | |
671 | Ghost | 2848 | add eax, 0x10 |
2849 | cmp cx, [eax] |
||
2850 | jnz sys_newba |
||
1 | ha | 2851 | |
671 | Ghost | 2852 | push eax ebx ecx |
2853 | mov ecx,ebx |
||
2854 | inc ecx |
||
2855 | shl ecx, 4 |
||
2856 | mov ebx, eax |
||
2857 | add eax, 0x10 |
||
2858 | call memmove |
||
2859 | dec dword [edi] |
||
2860 | pop ecx ebx eax |
||
1 | ha | 2861 | |
671 | Ghost | 2862 | jmp sys_newba2 |
1 | ha | 2863 | |
2864 | end_of_buttons_away: |
||
2865 | |||
671 | Ghost | 2866 | ret |
1 | ha | 2867 | |
2868 | no_widgets_away: |
||
2869 | |||
671 | Ghost | 2870 | cmp ebx, 2 |
2871 | jnz srl1 |
||
1 | ha | 2872 | |
671 | Ghost | 2873 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
2874 | add edx, draw_data - CURRENT_TASK |
||
2875 | mov [edx + RECT.left], 0 |
||
2876 | mov [edx + RECT.top], 0 |
||
759 | Rus | 2877 | mov eax, [Screen_Max_X] |
671 | Ghost | 2878 | mov [edx + RECT.right], eax |
759 | Rus | 2879 | mov eax, [Screen_Max_Y] |
671 | Ghost | 2880 | mov [edx + RECT.bottom], eax |
1 | ha | 2881 | |
671 | Ghost | 2882 | mov edi, [TASK_BASE] |
2883 | or [edi - twdw + WDATA.fl_wdrawn], 1 ; no new position & buttons from app |
||
2884 | call sys_window_mouse |
||
2885 | ret |
||
1 | ha | 2886 | |
2887 | srl1: |
||
671 | Ghost | 2888 | ret |
1 | ha | 2889 | |
2890 | |||
2891 | sys_drawwindow: |
||
2892 | |||
684 | diamond | 2893 | mov eax,edx |
2894 | shr eax,16+8 |
||
2895 | and eax,15 |
||
1 | ha | 2896 | |
684 | diamond | 2897 | ; cmp eax,0 ; type I - original style |
1 | ha | 2898 | jne nosyswI |
33 | mario79 | 2899 | inc [mouse_pause] |
36 | mario79 | 2900 | call [disable_mouse] |
1 | ha | 2901 | call sys_set_window |
36 | mario79 | 2902 | call [disable_mouse] |
1 | ha | 2903 | call drawwindow_I |
114 | mikedld | 2904 | ;dec [mouse_pause] |
2905 | ;call [draw_pointer] |
||
2906 | ;ret |
||
2907 | jmp draw_window_caption.2 |
||
1 | ha | 2908 | nosyswI: |
2909 | |||
742 | Rus | 2910 | cmp al,1 ; type II - only reserve area, no draw |
1 | ha | 2911 | jne nosyswII |
33 | mario79 | 2912 | inc [mouse_pause] |
36 | mario79 | 2913 | call [disable_mouse] |
1 | ha | 2914 | call sys_set_window |
36 | mario79 | 2915 | call [disable_mouse] |
1 | ha | 2916 | call sys_window_mouse |
33 | mario79 | 2917 | dec [mouse_pause] |
36 | mario79 | 2918 | call [draw_pointer] |
1 | ha | 2919 | ret |
2920 | nosyswII: |
||
2921 | |||
742 | Rus | 2922 | cmp al,2 ; type III - new style |
1 | ha | 2923 | jne nosyswIII |
33 | mario79 | 2924 | inc [mouse_pause] |
36 | mario79 | 2925 | call [disable_mouse] |
1 | ha | 2926 | call sys_set_window |
36 | mario79 | 2927 | call [disable_mouse] |
1 | ha | 2928 | call drawwindow_III |
114 | mikedld | 2929 | ;dec [mouse_pause] |
2930 | ;call [draw_pointer] |
||
2931 | ;ret |
||
2932 | jmp draw_window_caption.2 |
||
1 | ha | 2933 | nosyswIII: |
2934 | |||
742 | Rus | 2935 | cmp al,3 ; type IV - skinned window |
2936 | je draw_skin_window |
||
2937 | cmp al,4 ; type V - skinned window not sized! {not_sized_skin_window} |
||
549 | spraid | 2938 | jne nosyswV |
2939 | draw_skin_window: |
||
567 | serge | 2940 | |
569 | diamond | 2941 | inc [mouse_pause] |
2942 | call [disable_mouse] |
||
2943 | call sys_set_window |
||
2944 | call [disable_mouse] |
||
684 | diamond | 2945 | mov eax, [TASK_COUNT] |
2946 | movzx eax, word [WIN_POS + eax*2] |
||
2947 | cmp eax, [CURRENT_TASK] |
||
2948 | setz al |
||
2949 | movzx eax, al |
||
2950 | push eax |
||
36 | mario79 | 2951 | call drawwindow_IV |
114 | mikedld | 2952 | ;dec [mouse_pause] |
2953 | ;call [draw_pointer] |
||
2954 | ;ret |
||
2955 | jmp draw_window_caption.2 |
||
549 | spraid | 2956 | nosyswV: |
1 | ha | 2957 | |
2958 | ret |
||
2959 | |||
2960 | |||
114 | mikedld | 2961 | draw_window_caption: |
742 | Rus | 2962 | inc [mouse_pause] |
2963 | call [disable_mouse] |
||
114 | mikedld | 2964 | |
742 | Rus | 2965 | xor eax,eax |
2966 | mov edx,[TASK_COUNT] |
||
2967 | movzx edx,word[WIN_POS+edx*2] |
||
2968 | cmp edx,[CURRENT_TASK] |
||
2969 | jne @f |
||
2970 | inc eax |
||
2971 | @@: mov edx,[CURRENT_TASK] |
||
2972 | shl edx,5 |
||
2973 | add edx,window_data |
||
2974 | movzx ebx,[edx+WDATA.fl_wstyle] |
||
2975 | and bl,0x0F |
||
2976 | cmp bl,3 |
||
2977 | je .draw_caption_style_3 ;{for 3 and 4 style write caption} |
||
2978 | cmp bl,4 |
||
2979 | je .draw_caption_style_3 |
||
567 | serge | 2980 | |
742 | Rus | 2981 | jmp .not_style_3 |
549 | spraid | 2982 | .draw_caption_style_3: |
114 | mikedld | 2983 | |
742 | Rus | 2984 | push edx |
2985 | call drawwindow_IV_caption |
||
2986 | add esp,4 |
||
2987 | jmp .2 |
||
114 | mikedld | 2988 | |
2989 | .not_style_3: |
||
742 | Rus | 2990 | cmp bl,2 |
2991 | jne .not_style_2 |
||
114 | mikedld | 2992 | |
742 | Rus | 2993 | call drawwindow_III_caption |
2994 | jmp .2 |
||
114 | mikedld | 2995 | |
2996 | .not_style_2: |
||
742 | Rus | 2997 | cmp bl,0 |
2998 | jne .2 |
||
114 | mikedld | 2999 | |
742 | Rus | 3000 | call drawwindow_I_caption |
114 | mikedld | 3001 | |
3002 | ;-------------------------------------------------------------- |
||
742 | Rus | 3003 | .2: ;jmp @f |
3004 | mov edi,[CURRENT_TASK] |
||
3005 | shl edi,5 |
||
3006 | test [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION |
||
3007 | jz @f |
||
3008 | mov edx,[edi*8+SLOT_BASE+APPDATA.wnd_caption] |
||
3009 | or edx,edx |
||
3010 | jz @f |
||
114 | mikedld | 3011 | |
742 | Rus | 3012 | movzx eax,[edi+window_data+WDATA.fl_wstyle] |
3013 | and al,0x0F |
||
3014 | cmp al,3 |
||
3015 | je .skinned |
||
3016 | cmp al,4 |
||
3017 | je .skinned |
||
567 | serge | 3018 | |
742 | Rus | 3019 | jmp .not_skinned |
567 | serge | 3020 | .skinned: |
742 | Rus | 3021 | mov ebp,[edi+window_data+WDATA.box.left-2] |
3022 | mov bp,word[edi+window_data+WDATA.box.top] |
||
3023 | movzx eax,word[edi+window_data+WDATA.box.width] |
||
3024 | sub ax,[_skinmargins.left] |
||
3025 | sub ax,[_skinmargins.right] |
||
3026 | push edx |
||
3027 | cwde |
||
3028 | cdq |
||
3029 | mov ebx,6 |
||
3030 | idiv ebx |
||
3031 | pop edx |
||
3032 | or eax,eax |
||
3033 | js @f |
||
3034 | mov esi,eax |
||
3035 | mov ebx,dword[_skinmargins.left-2] |
||
3036 | mov bx,word[_skinh] |
||
3037 | sub bx,[_skinmargins.bottom] |
||
3038 | sub bx,[_skinmargins.top] |
||
3039 | sar bx,1 |
||
3040 | adc bx,0 |
||
3041 | add bx,[_skinmargins.top] |
||
3042 | add bx,-3 |
||
3043 | add ebx,ebp |
||
3044 | jmp .dodraw |
||
114 | mikedld | 3045 | |
3046 | .not_skinned: |
||
742 | Rus | 3047 | cmp al,1 |
3048 | je @f |
||
114 | mikedld | 3049 | |
742 | Rus | 3050 | mov ebp,[edi+window_data+WDATA.box.left-2] |
3051 | mov bp,word[edi+window_data+WDATA.box.top] |
||
3052 | movzx eax,word[edi+window_data+WDATA.box.width] |
||
3053 | sub eax,16 |
||
3054 | push edx |
||
3055 | cwde |
||
3056 | cdq |
||
3057 | mov ebx,6 |
||
3058 | idiv ebx |
||
3059 | pop edx |
||
3060 | or eax,eax |
||
3061 | js @f |
||
3062 | mov esi,eax |
||
3063 | mov ebx,0x00080007 |
||
3064 | add ebx,ebp |
||
139 | diamond | 3065 | .dodraw: |
742 | Rus | 3066 | mov ecx,[common_colours+16];0x00FFFFFF |
3067 | or ecx, 0x80000000 |
||
3068 | xor edi,edi |
||
3069 | call dtext |
||
114 | mikedld | 3070 | |
3071 | @@: |
||
3072 | ;-------------------------------------------------------------- |
||
742 | Rus | 3073 | dec [mouse_pause] |
3074 | call [draw_pointer] |
||
3075 | ret |
||
114 | mikedld | 3076 | |
3077 | iglobal |
||
3078 | align 4 |
||
3079 | window_topleft dd \ |
||
549 | spraid | 3080 | 1, 21,\ ;type 0 |
742 | Rus | 3081 | 0, 0,\ ;type 1 |
3082 | 5, 20,\ ;type 2 |
||
3083 | 5, ?,\ ;type 3 {set by skin} |
||
3084 | 5, ? ;type 4 {set by skin} |
||
114 | mikedld | 3085 | endg |
3086 | |||
3087 | set_window_clientbox: |
||
742 | Rus | 3088 | push eax ecx edi |
114 | mikedld | 3089 | |
742 | Rus | 3090 | mov eax,[_skinh] |
3091 | mov [window_topleft+4*7],eax |
||
3092 | mov [window_topleft+4*9],eax |
||
114 | mikedld | 3093 | |
742 | Rus | 3094 | mov ecx,edi |
3095 | sub edi,window_data |
||
3096 | shl edi,3 |
||
3097 | test [ecx+WDATA.fl_wstyle],WSTYLE_CLIENTRELATIVE |
||
3098 | jz @f |
||
114 | mikedld | 3099 | |
742 | Rus | 3100 | movzx eax,[ecx+WDATA.fl_wstyle] |
3101 | and eax,0x0F |
||
3102 | mov eax,[eax*8+window_topleft+0] |
||
3103 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax |
||
3104 | shl eax,1 |
||
3105 | neg eax |
||
3106 | add eax,[ecx+WDATA.box.width] |
||
3107 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax |
||
114 | mikedld | 3108 | |
742 | Rus | 3109 | movzx eax,[ecx+WDATA.fl_wstyle] |
3110 | and eax,0x0F |
||
3111 | push [eax*8+window_topleft+0] |
||
3112 | mov eax,[eax*8+window_topleft+4] |
||
3113 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax |
||
3114 | neg eax |
||
3115 | sub eax,[esp] |
||
3116 | add eax,[ecx+WDATA.box.height] |
||
3117 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax |
||
3118 | add esp,4 |
||
114 | mikedld | 3119 | |
742 | Rus | 3120 | pop edi ecx eax |
3121 | ret |
||
114 | mikedld | 3122 | @@: |
742 | Rus | 3123 | xor eax,eax |
3124 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax |
||
3125 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax |
||
3126 | mov eax,[ecx+WDATA.box.width] |
||
3127 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax |
||
3128 | mov eax,[ecx+WDATA.box.height] |
||
3129 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax |
||
114 | mikedld | 3130 | |
742 | Rus | 3131 | pop edi ecx eax |
3132 | ret |
||
114 | mikedld | 3133 | |
1 | ha | 3134 | sys_set_window: |
3135 | |||
684 | diamond | 3136 | mov eax,[CURRENT_TASK] |
3137 | shl eax,5 |
||
3138 | add eax,window_data |
||
1 | ha | 3139 | |
3140 | ; colors |
||
684 | diamond | 3141 | mov [eax+WDATA.cl_workarea],edx |
3142 | mov [eax+WDATA.cl_titlebar],esi |
||
3143 | mov [eax+WDATA.cl_frames],edi |
||
1 | ha | 3144 | |
684 | diamond | 3145 | mov edi, eax |
3146 | |||
1 | ha | 3147 | ; check flag (?) |
186 | diamond | 3148 | test [edi+WDATA.fl_wdrawn],1 |
3149 | jnz newd |
||
1 | ha | 3150 | |
3151 | mov eax,[timer_ticks] ;[0xfdf0] |
||
3152 | add eax,100 |
||
3153 | mov [new_window_starting],eax |
||
3154 | |||
684 | diamond | 3155 | mov word[edi+WDATA.box.width],bx |
3156 | mov word[edi+WDATA.box.height],cx |
||
114 | mikedld | 3157 | sar ebx,16 |
684 | diamond | 3158 | sar ecx,16 |
3159 | mov word[edi+WDATA.box.left],bx |
||
3160 | mov word[edi+WDATA.box.top],cx |
||
1 | ha | 3161 | |
3162 | call check_window_position |
||
3163 | |||
164 | serge | 3164 | call set_window_clientbox |
1 | ha | 3165 | |
742 | Rus | 3166 | push ecx esi edi ; save for window fullscreen/resize |
114 | mikedld | 3167 | ;mov esi,edi |
3168 | |||
742 | Rus | 3169 | mov cl, [edi+WDATA.fl_wstyle] |
3170 | mov eax, [edi+WDATA.cl_frames] |
||
114 | mikedld | 3171 | |
1 | ha | 3172 | sub edi,window_data |
114 | mikedld | 3173 | shl edi,3 |
380 | serge | 3174 | add edi,SLOT_BASE |
114 | mikedld | 3175 | |
742 | Rus | 3176 | and cl,0x0F |
3177 | mov [edi+APPDATA.wnd_caption],0 |
||
3178 | cmp cl,3 |
||
3179 | je set_APPDATA_wnd_caption |
||
3180 | cmp cl,4 ; {SPraid.simba} |
||
3181 | je set_APPDATA_wnd_caption |
||
567 | serge | 3182 | |
742 | Rus | 3183 | jmp @f |
549 | spraid | 3184 | set_APPDATA_wnd_caption: |
742 | Rus | 3185 | mov [edi+APPDATA.wnd_caption],eax |
3186 | @@: mov esi,[esp+0] |
||
114 | mikedld | 3187 | |
115 | poddubny | 3188 | add edi, APPDATA.saved_box |
742 | Rus | 3189 | movsd |
3190 | movsd |
||
3191 | movsd |
||
3192 | movsd |
||
1 | ha | 3193 | pop edi esi ecx |
3194 | |||
742 | Rus | 3195 | mov esi, [CURRENT_TASK] |
3196 | movzx esi, word [WIN_STACK+esi*2] |
||
3197 | lea esi, [WIN_POS+esi*2] |
||
3198 | call waredraw |
||
569 | diamond | 3199 | |
684 | diamond | 3200 | ;;; mov ebx, 1 |
1 | ha | 3201 | ;;; call delay_hs |
115 | poddubny | 3202 | mov eax, [edi+WDATA.box.left] |
3203 | mov ebx, [edi+WDATA.box.top] |
||
3204 | mov ecx, [edi+WDATA.box.width] |
||
3205 | mov edx, [edi+WDATA.box.height] |
||
1 | ha | 3206 | add ecx, eax |
3207 | add edx, ebx |
||
3208 | call calculatescreen |
||
3209 | |||
742 | Rus | 3210 | mov [KEY_COUNT],byte 0 ; empty keyboard buffer |
3211 | mov [BTN_COUNT],byte 0 ; empty button buffer |
||
1 | ha | 3212 | |
3213 | newd: |
||
742 | Rus | 3214 | mov [edi+WDATA.fl_redraw],byte 0 ; no redraw |
1 | ha | 3215 | mov edx,edi |
3216 | |||
3217 | ret |
||
3218 | |||
114 | mikedld | 3219 | syscall_windowsettings: |
1 | ha | 3220 | |
114 | mikedld | 3221 | .set_window_caption: |
742 | Rus | 3222 | dec eax ; subfunction #1 - set window caption |
3223 | jnz .get_window_caption |
||
114 | mikedld | 3224 | |
742 | Rus | 3225 | ; NOTE: only window owner thread can set its caption, |
3226 | ; so there's no parameter for PID/TID |
||
114 | mikedld | 3227 | |
742 | Rus | 3228 | mov edi,[CURRENT_TASK] |
3229 | shl edi,5 |
||
114 | mikedld | 3230 | |
742 | Rus | 3231 | ; have to check if caption is within application memory limit |
3232 | ; check is trivial, and if application resizes its memory, |
||
3233 | ; caption still can become over bounds |
||
202 | diamond | 3234 | ; diamond, 31.10.2006: check removed because with new memory manager |
3235 | ; there can be valid data after APPDATA.mem_size bound |
||
380 | serge | 3236 | ; mov ecx,[edi*8+SLOT_BASE+APPDATA.mem_size] |
202 | diamond | 3237 | ; add ecx,255 ; max caption length |
3238 | ; cmp ebx,ecx |
||
3239 | ; ja .exit_fail |
||
114 | mikedld | 3240 | |
742 | Rus | 3241 | mov [edi*8+SLOT_BASE+APPDATA.wnd_caption],ebx |
3242 | or [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION |
||
114 | mikedld | 3243 | |
742 | Rus | 3244 | call draw_window_caption |
114 | mikedld | 3245 | |
742 | Rus | 3246 | xor eax,eax ; eax = 0 (success) |
3247 | ret |
||
114 | mikedld | 3248 | |
3249 | .get_window_caption: |
||
742 | Rus | 3250 | dec eax ; subfunction #2 - get window caption |
3251 | jnz .exit_fail |
||
114 | mikedld | 3252 | |
742 | Rus | 3253 | ; not implemented yet |
114 | mikedld | 3254 | |
3255 | .exit_fail: |
||
742 | Rus | 3256 | xor eax,eax |
3257 | inc eax ; eax = 1 (fail) |
||
3258 | ret |
||
114 | mikedld | 3259 | |
3260 | |||
1 | ha | 3261 | sys_window_move: |
3262 | |||
742 | Rus | 3263 | mov edi,[CURRENT_TASK] |
3264 | shl edi,5 |
||
3265 | add edi,window_data |
||
1 | ha | 3266 | |
742 | Rus | 3267 | test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED |
3268 | jnz .window_move_return |
||
1 | ha | 3269 | |
742 | Rus | 3270 | push dword [edi + WDATA.box.left] ; save old coordinates |
3271 | push dword [edi + WDATA.box.top] |
||
3272 | push dword [edi + WDATA.box.width] |
||
3273 | push dword [edi + WDATA.box.height] |
||
1 | ha | 3274 | |
742 | Rus | 3275 | cmp eax,-1 ; set new position and size |
3276 | je .no_x_reposition |
||
3277 | mov [edi + WDATA.box.left], eax |
||
49 | mikedld | 3278 | .no_x_reposition: |
742 | Rus | 3279 | cmp ebx,-1 |
3280 | je .no_y_reposition |
||
3281 | mov [edi + WDATA.box.top], ebx |
||
49 | mikedld | 3282 | .no_y_reposition: |
1 | ha | 3283 | |
742 | Rus | 3284 | test [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP |
3285 | jnz .no_y_resizing |
||
1 | ha | 3286 | |
742 | Rus | 3287 | cmp ecx,-1 |
3288 | je .no_x_resizing |
||
3289 | mov [edi + WDATA.box.width], ecx |
||
49 | mikedld | 3290 | .no_x_resizing: |
742 | Rus | 3291 | cmp edx,-1 |
3292 | je .no_y_resizing |
||
3293 | mov [edi + WDATA.box.height], edx |
||
49 | mikedld | 3294 | .no_y_resizing: |
1 | ha | 3295 | |
742 | Rus | 3296 | call check_window_position |
3297 | call set_window_clientbox |
||
1 | ha | 3298 | |
742 | Rus | 3299 | pushad ; save for window fullscreen/resize |
3300 | mov esi,edi |
||
3301 | sub edi,window_data |
||
3302 | shr edi,5 |
||
3303 | shl edi,8 |
||
3304 | add edi, SLOT_BASE + APPDATA.saved_box |
||
3305 | mov ecx,4 |
||
3306 | cld |
||
3307 | rep movsd |
||
3308 | popad |
||
49 | mikedld | 3309 | |
742 | Rus | 3310 | pushad ; calculcate screen at new position |
3311 | mov eax, [edi + WDATA.box.left] |
||
3312 | mov ebx, [edi + WDATA.box.top] |
||
3313 | mov ecx, [edi + WDATA.box.width] |
||
3314 | mov edx, [edi + WDATA.box.height] |
||
3315 | add ecx,eax |
||
3316 | add edx,ebx |
||
221 | serge | 3317 | |
742 | Rus | 3318 | call calculatescreen |
3319 | popad |
||
49 | mikedld | 3320 | |
742 | Rus | 3321 | pop edx ; calculcate screen at old position |
3322 | pop ecx |
||
3323 | pop ebx |
||
3324 | pop eax |
||
3325 | add ecx,eax |
||
3326 | add edx,ebx |
||
3327 | mov [dlx],eax ; save for drawlimits |
||
3328 | mov [dly],ebx |
||
3329 | mov [dlxe],ecx |
||
3330 | mov [dlye],edx |
||
3331 | call calculatescreen |
||
49 | mikedld | 3332 | |
742 | Rus | 3333 | mov [edi + WDATA.fl_redraw], 1 ; flag the process as redraw |
49 | mikedld | 3334 | |
742 | Rus | 3335 | mov eax,edi ; redraw screen at old position |
3336 | xor esi,esi |
||
3337 | call redrawscreen |
||
49 | mikedld | 3338 | |
742 | Rus | 3339 | mov [DONT_DRAW_MOUSE],byte 0 ; mouse pointer |
3340 | mov [MOUSE_BACKGROUND],byte 0 ; no mouse under |
||
3341 | mov [MOUSE_DOWN],byte 0 ; react to mouse up/down |
||
49 | mikedld | 3342 | |
742 | Rus | 3343 | call [draw_pointer] |
49 | mikedld | 3344 | |
742 | Rus | 3345 | mov [window_move_pr],0 |
49 | mikedld | 3346 | |
3347 | .window_move_return: |
||
3348 | |||
742 | Rus | 3349 | ret |
1 | ha | 3350 | |
3351 | uglobal |
||
3352 | window_move_pr dd 0x0 |
||
3353 | window_move_eax dd 0x0 |
||
3354 | window_move_ebx dd 0x0 |
||
3355 | window_move_ecx dd 0x0 |
||
3356 | window_move_edx dd 0x0 |
||
3357 | endg |
||
3358 | |||
3359 | ;ok - 100% work |
||
3360 | ;nt - not tested |
||
3361 | ;--------------------------------------------------------------------------------------------- |
||
3362 | ;eax |
||
3363 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
||
3364 | ;1 - change task. Ret nothing. Block. ok. |
||
3365 | ;2 - performance control |
||
3366 | ; ebx |
||
3367 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
||
3368 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
||
3369 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
||
3370 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
||
3371 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
||
3372 | ;eax |
||
3373 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
3374 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
3375 | ;--------------------------------------------------------------------------------------------- |
||
3376 | sys_sheduler: ;noname & halyavin |
||
3377 | cmp eax,0 |
||
3378 | je shed_counter |
||
3379 | cmp eax,2 |
||
3380 | je perf_control |
||
3381 | cmp eax,3 |
||
3382 | je rdmsr_instr |
||
3383 | cmp eax,4 |
||
3384 | je wrmsr_instr |
||
3385 | cmp eax,1 |
||
3386 | jne not_supported |
||
3387 | call change_task ;delay,0 |
||
3388 | ret |
||
3389 | shed_counter: |
||
3390 | mov eax,[context_counter] |
||
3391 | mov [esp+36],eax |
||
3392 | not_supported: |
||
3393 | ret |
||
3394 | perf_control: |
||
3395 | inc eax ;now eax=3 |
||
3396 | cmp ebx,eax |
||
3397 | je cache_disable |
||
3398 | dec eax |
||
3399 | cmp ebx,eax |
||
3400 | je cache_enable |
||
3401 | dec eax |
||
3402 | cmp ebx,eax |
||
3403 | je is_cache_enabled |
||
3404 | dec eax |
||
3405 | cmp ebx,eax |
||
3406 | je modify_pce |
||
3407 | ret |
||
3408 | |||
3409 | rdmsr_instr: |
||
3410 | ;now counter in ecx |
||
3411 | ;(edx:eax) esi:edi => edx:esi |
||
3412 | mov eax,esi |
||
3413 | rdmsr |
||
3414 | mov [esp+36],eax |
||
3415 | mov [esp+24],edx ;ret in ebx? |
||
3416 | ret |
||
3417 | |||
3418 | wrmsr_instr: |
||
3419 | ;now counter in ecx |
||
3420 | ;(edx:eax) esi:edi => edx:esi |
||
482 | Ghost | 3421 | ; Fast Call MSR can't be destroy |
3422 | ; Íî MSR_AMD_EFER ìîæíî èçìåíÿòü, ò.ê. â ýòîì ðåãèñòðå ëèø |
||
3423 | ; âêëþ÷àþòñÿ/âûêëþ÷àþòñÿ ðàñøèðåííûå âîçìîæíîñòè |
||
3424 | cmp ecx, MSR_SYSENTER_CS |
||
3425 | je @f |
||
3426 | cmp ecx, MSR_SYSENTER_ESP |
||
3427 | je @f |
||
3428 | cmp ecx, MSR_SYSENTER_EIP |
||
3429 | je @f |
||
3430 | cmp ecx, MSR_AMD_STAR |
||
3431 | je @f |
||
3432 | |||
3433 | mov eax, esi |
||
3434 | wrmsr |
||
742 | Rus | 3435 | ; mov [esp + 36], eax |
3436 | ; mov [esp + 24], edx ;ret in ebx? |
||
482 | Ghost | 3437 | @@: |
1 | ha | 3438 | ret |
3439 | |||
3440 | cache_disable: |
||
3441 | mov eax,cr0 |
||
3442 | or eax,01100000000000000000000000000000b |
||
3443 | mov cr0,eax |
||
3444 | wbinvd ;set MESI |
||
3445 | ret |
||
3446 | |||
3447 | cache_enable: |
||
3448 | mov eax,cr0 |
||
3449 | and eax,10011111111111111111111111111111b |
||
3450 | mov cr0,eax |
||
3451 | ret |
||
3452 | |||
3453 | is_cache_enabled: |
||
3454 | mov eax,cr0 |
||
3455 | mov ebx,eax |
||
3456 | and eax,01100000000000000000000000000000b |
||
3457 | jz cache_disabled |
||
3458 | mov [esp+36],ebx |
||
3459 | cache_disabled: |
||
3460 | mov dword [esp+36],eax ;0 |
||
3461 | ret |
||
3462 | |||
3463 | modify_pce: |
||
3464 | mov eax,cr4 |
||
3465 | ; mov ebx,0 |
||
3466 | ; or bx,100000000b ;pce |
||
3467 | ; xor eax,ebx ;invert pce |
||
17 | me_root | 3468 | bts eax,8 ;pce=cr4[8] |
1 | ha | 3469 | mov cr4,eax |
3470 | mov [esp+36],eax |
||
3471 | ret |
||
3472 | ;--------------------------------------------------------------------------------------------- |
||
3473 | |||
3474 | |||
3475 | ; check if pixel is allowed to be drawn |
||
3476 | |||
3477 | checkpixel: |
||
742 | Rus | 3478 | push eax edx |
1 | ha | 3479 | |
759 | Rus | 3480 | mov edx,[Screen_Max_X] ; screen x size |
742 | Rus | 3481 | inc edx |
3482 | imul edx, ebx |
||
3483 | mov dl, [eax+edx+display_data] ; lea eax, [...] |
||
1 | ha | 3484 | |
742 | Rus | 3485 | xor ecx, ecx |
3486 | mov eax, [CURRENT_TASK] |
||
3487 | cmp al, dl |
||
3488 | setne cl |
||
1 | ha | 3489 | |
742 | Rus | 3490 | pop edx eax |
3491 | ret |
||
1 | ha | 3492 | |
3493 | iglobal |
||
521 | diamond | 3494 | cpustring db 'CPU',0 |
1 | ha | 3495 | endg |
3496 | |||
67 | diamond | 3497 | uglobal |
742 | Rus | 3498 | background_defined db 0 ; diamond, 11.04.2006 |
67 | diamond | 3499 | endg |
1 | ha | 3500 | |
3501 | align 4 |
||
3502 | ; check misc |
||
3503 | |||
3504 | checkmisc: |
||
3505 | |||
3506 | cmp [ctrl_alt_del], 1 |
||
3507 | jne nocpustart |
||
501 | serge | 3508 | |
742 | Rus | 3509 | mov ebp, cpustring |
3510 | call fs_execute_from_sysdir |
||
501 | serge | 3511 | |
1 | ha | 3512 | mov [ctrl_alt_del], 0 |
465 | serge | 3513 | |
3514 | nocpustart: |
||
1 | ha | 3515 | cmp [mouse_active], 1 |
3516 | jne mouse_not_active |
||
3517 | mov [mouse_active], 0 |
||
3518 | xor edi, edi |
||
742 | Rus | 3519 | mov ecx, [TASK_COUNT] |
465 | serge | 3520 | set_mouse_event: |
1 | ha | 3521 | add edi, 256 |
742 | Rus | 3522 | or [edi+SLOT_BASE+APPDATA.event_mask], dword 100000b |
1 | ha | 3523 | loop set_mouse_event |
3524 | |||
465 | serge | 3525 | mouse_not_active: |
742 | Rus | 3526 | cmp [REDRAW_BACKGROUND],byte 0 ; background update ? |
3527 | jz nobackgr |
||
76 | mario79 | 3528 | cmp [background_defined], 0 |
742 | Rus | 3529 | jz nobackgr |
709 | diamond | 3530 | cmp [REDRAW_BACKGROUND], byte 2 |
3531 | jnz no_set_bgr_event |
||
473 | diamond | 3532 | xor edi, edi |
742 | Rus | 3533 | mov ecx, [TASK_COUNT] |
473 | diamond | 3534 | set_bgr_event: |
3535 | add edi, 256 |
||
742 | Rus | 3536 | or [edi+SLOT_BASE+APPDATA.event_mask], 16 |
473 | diamond | 3537 | loop set_bgr_event |
709 | diamond | 3538 | no_set_bgr_event: |
3539 | ; mov [draw_data+32 + RECT.left],dword 0 |
||
3540 | ; mov [draw_data+32 + RECT.top],dword 0 |
||
753 | serge | 3541 | ; mov eax,[Screen_Max_X] |
3542 | ; mov ebx,[Screen_Max_Y] |
||
709 | diamond | 3543 | ; mov [draw_data+32 + RECT.right],eax |
3544 | ; mov [draw_data+32 + RECT.bottom],ebx |
||
1 | ha | 3545 | call drawbackground |
381 | serge | 3546 | mov [REDRAW_BACKGROUND],byte 0 |
3547 | mov [MOUSE_BACKGROUND],byte 0 |
||
1 | ha | 3548 | |
465 | serge | 3549 | nobackgr: |
1 | ha | 3550 | |
3551 | ; system shutdown request |
||
3552 | |||
381 | serge | 3553 | cmp [SYS_SHUTDOWN],byte 0 |
742 | Rus | 3554 | je noshutdown |
1 | ha | 3555 | |
3556 | mov edx,[shutdown_processes] |
||
3557 | |||
381 | serge | 3558 | cmp [SYS_SHUTDOWN],dl |
1 | ha | 3559 | jne no_mark_system_shutdown |
3560 | |||
709 | diamond | 3561 | lea ecx,[edx-1] |
465 | serge | 3562 | mov edx,OS_BASE+0x3040 |
709 | diamond | 3563 | jecxz @f |
465 | serge | 3564 | markz: |
115 | poddubny | 3565 | mov [edx+TASKDATA.state],byte 3 |
1 | ha | 3566 | add edx,0x20 |
3567 | loop markz |
||
709 | diamond | 3568 | @@: |
1 | ha | 3569 | |
3570 | no_mark_system_shutdown: |
||
3571 | |||
3572 | call [disable_mouse] |
||
3573 | |||
381 | serge | 3574 | dec byte [SYS_SHUTDOWN] |
742 | Rus | 3575 | je system_shutdown |
1 | ha | 3576 | |
465 | serge | 3577 | noshutdown: |
1 | ha | 3578 | |
3579 | |||
742 | Rus | 3580 | mov eax,[TASK_COUNT] ; termination |
379 | serge | 3581 | mov ebx,TASK_DATA+TASKDATA.state |
1 | ha | 3582 | mov esi,1 |
3583 | |||
465 | serge | 3584 | newct: |
1 | ha | 3585 | mov cl,[ebx] |
3586 | cmp cl,byte 3 |
||
742 | Rus | 3587 | jz terminate |
1 | ha | 3588 | cmp cl,byte 4 |
742 | Rus | 3589 | jz terminate |
1 | ha | 3590 | |
3591 | add ebx,0x20 |
||
3592 | inc esi |
||
3593 | dec eax |
||
3594 | jnz newct |
||
3595 | ret |
||
3596 | |||
3597 | ; redraw screen |
||
3598 | |||
3599 | redrawscreen: |
||
3600 | |||
3601 | ; eax , if process window_data base is eax, do not set flag/limits |
||
3602 | |||
742 | Rus | 3603 | pushad |
3604 | push eax |
||
1 | ha | 3605 | |
684 | diamond | 3606 | ;;; mov ebx,2 |
1 | ha | 3607 | ;;; call delay_hs |
3608 | |||
742 | Rus | 3609 | ;mov ecx,0 ; redraw flags for apps |
3610 | xor ecx,ecx |
||
1 | ha | 3611 | newdw2: |
3612 | |||
742 | Rus | 3613 | inc ecx |
3614 | push ecx |
||
1 | ha | 3615 | |
742 | Rus | 3616 | mov eax,ecx |
3617 | shl eax,5 |
||
3618 | add eax,window_data |
||
1 | ha | 3619 | |
742 | Rus | 3620 | cmp eax,[esp+4] |
3621 | je not_this_task |
||
3622 | ; check if window in redraw area |
||
3623 | mov edi,eax |
||
1 | ha | 3624 | |
742 | Rus | 3625 | cmp ecx,1 ; limit for background |
3626 | jz bgli |
||
1 | ha | 3627 | |
742 | Rus | 3628 | mov eax, [edi + WDATA.box.left] |
3629 | mov ebx, [edi + WDATA.box.top] |
||
3630 | mov ecx, [edi + WDATA.box.width] |
||
3631 | mov edx, [edi + WDATA.box.height] |
||
3632 | add ecx,eax |
||
3633 | add edx,ebx |
||
1 | ha | 3634 | |
742 | Rus | 3635 | mov ecx,[dlye] ; ecx = area y end ebx = window y start |
3636 | cmp ecx,ebx |
||
3637 | jb ricino |
||
1 | ha | 3638 | |
742 | Rus | 3639 | mov ecx,[dlxe] ; ecx = area x end eax = window x start |
3640 | cmp ecx,eax |
||
3641 | jb ricino |
||
1 | ha | 3642 | |
742 | Rus | 3643 | mov eax, [edi + WDATA.box.left] |
3644 | mov ebx, [edi + WDATA.box.top] |
||
3645 | mov ecx, [edi + WDATA.box.width] |
||
3646 | mov edx, [edi + WDATA.box.height] |
||
3647 | add ecx, eax |
||
3648 | add edx, ebx |
||
164 | serge | 3649 | |
742 | Rus | 3650 | mov eax,[dly] ; eax = area y start edx = window y end |
3651 | cmp edx,eax |
||
3652 | jb ricino |
||
1 | ha | 3653 | |
742 | Rus | 3654 | mov eax,[dlx] ; eax = area x start ecx = window x end |
3655 | cmp ecx,eax |
||
3656 | jb ricino |
||
1 | ha | 3657 | |
742 | Rus | 3658 | bgli: |
1 | ha | 3659 | |
742 | Rus | 3660 | cmp ecx,1 |
3661 | jnz .az |
||
3662 | mov al,[REDRAW_BACKGROUND] |
||
3663 | cmp al,2 |
||
3664 | jz newdw8 |
||
3665 | test al,al |
||
3666 | jz .az |
||
3667 | lea eax,[edi+draw_data-window_data] |
||
3668 | mov ebx,[dlx] |
||
3669 | cmp ebx,[eax+RECT.left] |
||
3670 | jae @f |
||
3671 | mov [eax+RECT.left],ebx |
||
3672 | @@: |
||
3673 | mov ebx,[dly] |
||
3674 | cmp ebx,[eax+RECT.top] |
||
3675 | jae @f |
||
3676 | mov [eax+RECT.top],ebx |
||
3677 | @@: |
||
3678 | mov ebx,[dlxe] |
||
3679 | cmp ebx,[eax+RECT.right] |
||
3680 | jbe @f |
||
3681 | mov [eax+RECT.right],ebx |
||
3682 | @@: |
||
3683 | mov ebx,[dlye] |
||
3684 | cmp ebx,[eax+RECT.bottom] |
||
3685 | jbe @f |
||
3686 | mov [eax+RECT.bottom],ebx |
||
3687 | @@: |
||
3688 | jmp newdw8 |
||
3689 | .az: |
||
1 | ha | 3690 | |
742 | Rus | 3691 | mov eax,edi |
3692 | add eax,draw_data-window_data |
||
1 | ha | 3693 | |
742 | Rus | 3694 | mov ebx,[dlx] ; set limits |
3695 | mov [eax + RECT.left], ebx |
||
3696 | mov ebx,[dly] |
||
3697 | mov [eax + RECT.top], ebx |
||
3698 | mov ebx,[dlxe] |
||
3699 | mov [eax + RECT.right], ebx |
||
3700 | mov ebx,[dlye] |
||
3701 | mov [eax + RECT.bottom], ebx |
||
1 | ha | 3702 | |
742 | Rus | 3703 | sub eax,draw_data-window_data |
1 | ha | 3704 | |
742 | Rus | 3705 | cmp dword [esp],1 |
3706 | jne nobgrd |
||
3707 | mov byte [REDRAW_BACKGROUND], 1 |
||
1 | ha | 3708 | |
3709 | newdw8: |
||
3710 | nobgrd: |
||
3711 | |||
742 | Rus | 3712 | mov [eax + WDATA.fl_redraw],byte 1 ; mark as redraw |
1 | ha | 3713 | |
3714 | ricino: |
||
3715 | |||
3716 | not_this_task: |
||
3717 | |||
742 | Rus | 3718 | pop ecx |
1 | ha | 3719 | |
742 | Rus | 3720 | cmp ecx,[TASK_COUNT] |
3721 | jle newdw2 |
||
1 | ha | 3722 | |
742 | Rus | 3723 | pop eax |
3724 | popad |
||
1 | ha | 3725 | |
742 | Rus | 3726 | ret |
1 | ha | 3727 | |
3728 | calculatebackground: ; background |
||
3729 | |||
742 | Rus | 3730 | ; all black |
1 | ha | 3731 | |
742 | Rus | 3732 | mov edi, [img_background] ;IMG_BACKGROUND ; set background to black |
3733 | xor eax, eax |
||
3734 | mov ecx, 1023 ;0x0fff00 / 4 |
||
3735 | cld |
||
3736 | rep stosd |
||
1 | ha | 3737 | |
742 | Rus | 3738 | mov edi,display_data ; set os to use all pixels |
3739 | mov eax,0x01010101 |
||
3740 | mov ecx,1280*1024 / 4 |
||
3741 | rep stosd |
||
1 | ha | 3742 | |
742 | Rus | 3743 | mov byte [REDRAW_BACKGROUND], 0 ; do not draw background! |
1 | ha | 3744 | |
742 | Rus | 3745 | ret |
1 | ha | 3746 | |
3747 | uglobal |
||
742 | Rus | 3748 | imax dd 0x0 |
1 | ha | 3749 | endg |
3750 | |||
3751 | |||
3752 | |||
3753 | delay_ms: ; delay in 1/1000 sec |
||
3754 | |||
3755 | |||
742 | Rus | 3756 | push eax |
3757 | push ecx |
||
1 | ha | 3758 | |
742 | Rus | 3759 | mov ecx,esi |
3760 | ; |
||
3761 | imul ecx, 33941 |
||
3762 | shr ecx, 9 |
||
3763 | ; |
||
1 | ha | 3764 | |
742 | Rus | 3765 | in al,0x61 |
3766 | and al,0x10 |
||
3767 | mov ah,al |
||
3768 | cld |
||
1 | ha | 3769 | |
742 | Rus | 3770 | cnt1: in al,0x61 |
3771 | and al,0x10 |
||
3772 | cmp al,ah |
||
3773 | jz cnt1 |
||
1 | ha | 3774 | |
742 | Rus | 3775 | mov ah,al |
3776 | loop cnt1 |
||
1 | ha | 3777 | |
742 | Rus | 3778 | pop ecx |
3779 | pop eax |
||
1 | ha | 3780 | |
742 | Rus | 3781 | ret |
1 | ha | 3782 | |
3783 | |||
3784 | set_app_param: |
||
742 | Rus | 3785 | mov edi, [TASK_BASE] |
3786 | mov [edi + TASKDATA.event_mask], ebx |
||
3787 | ret |
||
1 | ha | 3788 | |
3789 | |||
3790 | |||
3791 | delay_hs: ; delay in 1/100 secs |
||
684 | diamond | 3792 | ; ebx = delay time |
742 | Rus | 3793 | push ecx |
3794 | push edx |
||
1 | ha | 3795 | |
742 | Rus | 3796 | mov edx,[timer_ticks] |
1 | ha | 3797 | |
3798 | newtic: |
||
742 | Rus | 3799 | mov ecx,[timer_ticks] |
3800 | sub ecx,edx |
||
3801 | cmp ecx,ebx |
||
3802 | jae zerodelay |
||
1 | ha | 3803 | |
742 | Rus | 3804 | call change_task |
1 | ha | 3805 | |
742 | Rus | 3806 | jmp newtic |
1 | ha | 3807 | |
3808 | zerodelay: |
||
742 | Rus | 3809 | pop edx |
3810 | pop ecx |
||
1 | ha | 3811 | |
742 | Rus | 3812 | ret |
1 | ha | 3813 | |
3814 | |||
3815 | memmove: ; memory move in bytes |
||
3816 | |||
3817 | ; eax = from |
||
3818 | ; ebx = to |
||
3819 | ; ecx = no of bytes |
||
3820 | test ecx, ecx |
||
3821 | jle .ret |
||
3822 | |||
3823 | |||
3824 | push esi edi ecx |
||
3825 | |||
3826 | mov edi, ebx |
||
3827 | mov esi, eax |
||
3828 | |||
3829 | test ecx, not 11b |
||
742 | Rus | 3830 | jz @f |
1 | ha | 3831 | |
3832 | push ecx |
||
3833 | shr ecx, 2 |
||
3834 | rep movsd |
||
3835 | pop ecx |
||
3836 | and ecx, 11b |
||
742 | Rus | 3837 | jz .finish |
1 | ha | 3838 | @@: |
3839 | rep movsb |
||
3840 | |||
3841 | .finish: |
||
3842 | pop ecx edi esi |
||
3843 | .ret: |
||
3844 | ret |
||
3845 | |||
3846 | |||
75 | diamond | 3847 | ; |
3848 | ;align 4 |
||
1 | ha | 3849 | ; |
75 | diamond | 3850 | ;read_floppy_file: |
1 | ha | 3851 | ; |
75 | diamond | 3852 | ;; as input |
3853 | ;; |
||
3854 | ;; eax pointer to file |
||
3855 | ;; ebx file lenght |
||
3856 | ;; ecx start 512 byte block number |
||
3857 | ;; edx number of blocks to read |
||
3858 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
||
3859 | ;; |
||
3860 | ;; |
||
3861 | ;; on return |
||
3862 | ;; |
||
3863 | ;; eax = 0 command succesful |
||
3864 | ;; 1 no fd base and/or partition defined |
||
3865 | ;; 2 yet unsupported FS |
||
3866 | ;; 3 unknown FS |
||
3867 | ;; 4 partition not defined at hd |
||
3868 | ;; 5 file not found |
||
3869 | ;; ebx = size of file |
||
1 | ha | 3870 | ; |
379 | serge | 3871 | ; mov edi,[TASK_BASE] |
75 | diamond | 3872 | ; add edi,0x10 |
3873 | ; add esi,[edi] |
||
3874 | ; add eax,[edi] |
||
1 | ha | 3875 | ; |
75 | diamond | 3876 | ; pushad |
3877 | ; mov edi,esi |
||
3878 | ; add edi,1024 |
||
3879 | ; mov esi,0x100000+19*512 |
||
3880 | ; sub ecx,1 |
||
3881 | ; shl ecx,9 |
||
3882 | ; add esi,ecx |
||
3883 | ; shl edx,9 |
||
3884 | ; mov ecx,edx |
||
3885 | ; cld |
||
3886 | ; rep movsb |
||
3887 | ; popad |
||
3888 | ; |
||
3889 | ; mov [esp+36],eax |
||
3890 | ; mov [esp+24],ebx |
||
3891 | ; ret |
||
1 | ha | 3892 | |
3893 | |||
3894 | |||
3895 | align 4 |
||
3896 | |||
3897 | sys_programirq: |
||
3898 | |||
765 | Rus | 3899 | mov eax, [TASK_BASE] |
3900 | add ebx, [eax + TASKDATA.mem_start] |
||
1 | ha | 3901 | |
765 | Rus | 3902 | cmp ecx, 16 |
75 | diamond | 3903 | jae .not_owner |
765 | Rus | 3904 | mov edi, [eax + TASKDATA.pid] |
3905 | cmp edi, [irq_owner + 4 * ecx] |
||
3906 | je .spril1 |
||
75 | diamond | 3907 | .not_owner: |
765 | Rus | 3908 | xor ecx, ecx |
3909 | jmp .end |
||
3910 | .spril1: |
||
1 | ha | 3911 | |
765 | Rus | 3912 | shl ecx, 6 |
3913 | mov esi, ebx |
||
3914 | lea edi, [irq00read + ecx] |
||
3915 | push 16 |
||
3916 | pop ecx |
||
3917 | |||
1 | ha | 3918 | cld |
3919 | rep movsd |
||
765 | Rus | 3920 | .end: |
3921 | mov [esp+32], ecx |
||
1 | ha | 3922 | ret |
3923 | |||
3924 | |||
3925 | align 4 |
||
3926 | |||
3927 | get_irq_data: |
||
760 | Rus | 3928 | movzx esi, bh ; save number of subfunction, if bh = 1, return data size, otherwise, read data |
3929 | xor bh, bh |
||
3930 | cmp ebx, 16 |
||
75 | diamond | 3931 | jae .not_owner |
760 | Rus | 3932 | mov edx, [4 * ebx + irq_owner] ; check for irq owner |
742 | Rus | 3933 | |
760 | Rus | 3934 | mov eax,[TASK_BASE] |
742 | Rus | 3935 | |
760 | Rus | 3936 | cmp edx,[eax+TASKDATA.pid] |
1 | ha | 3937 | je gidril1 |
75 | diamond | 3938 | .not_owner: |
760 | Rus | 3939 | xor edx, edx |
3940 | dec edx |
||
3941 | jmp gid1 |
||
1 | ha | 3942 | |
3943 | gidril1: |
||
3944 | |||
760 | Rus | 3945 | shl ebx, 12 |
3946 | lea eax, [ebx + IRQ_SAVE] ; calculate address of the beginning of buffer + 0x0 - data size |
||
3947 | mov edx, [eax] ; + 0x4 - data offset |
||
3948 | dec esi |
||
1 | ha | 3949 | jz gid1 |
760 | Rus | 3950 | test edx, edx ; check if buffer is empty |
3951 | jz gid1 |
||
1 | ha | 3952 | |
760 | Rus | 3953 | mov ebx, [eax + 0x4] |
3954 | mov edi, ecx |
||
742 | Rus | 3955 | |
760 | Rus | 3956 | mov ecx, 4000 ; buffer size, used frequently |
742 | Rus | 3957 | |
760 | Rus | 3958 | cmp ebx, ecx ; check for the end of buffer, if end of buffer, begin cycle again |
759 | Rus | 3959 | jb @f |
742 | Rus | 3960 | |
760 | Rus | 3961 | xor ebx, ebx |
759 | Rus | 3962 | |
3963 | @@: |
||
3964 | |||
760 | Rus | 3965 | lea esi, [ebx + edx] ; calculate data size and offset |
3966 | cld |
||
3967 | cmp esi, ecx ; if greater than the buffer size, begin cycle again |
||
3968 | jbe @f |
||
759 | Rus | 3969 | |
760 | Rus | 3970 | sub ecx, ebx |
3971 | sub edx, ecx |
||
759 | Rus | 3972 | |
760 | Rus | 3973 | lea esi, [eax + ebx + 0x10] |
3974 | rep movsb |
||
3975 | |||
3976 | xor ebx, ebx |
||
3977 | @@: |
||
3978 | lea esi, [eax + ebx + 0x10] |
||
3979 | mov ecx, edx |
||
3980 | add ebx, edx |
||
3981 | |||
3982 | rep movsb |
||
3983 | mov edx, [eax] |
||
3984 | mov [eax], ecx ; set data size to zero |
||
3985 | mov [eax + 0x4], ebx ; set data offset |
||
3986 | |||
1 | ha | 3987 | gid1: |
760 | Rus | 3988 | mov [esp+32], edx ; eax |
1 | ha | 3989 | ret |
3990 | |||
3991 | |||
3992 | set_io_access_rights: |
||
3993 | |||
3994 | pushad |
||
3995 | |||
465 | serge | 3996 | mov edi, tss._io_map_0 |
1 | ha | 3997 | |
465 | serge | 3998 | ; mov ecx,eax |
3999 | ; and ecx,7 ; offset in byte |
||
1 | ha | 4000 | |
465 | serge | 4001 | ; shr eax,3 ; number of byte |
4002 | ; add edi,eax |
||
1 | ha | 4003 | |
465 | serge | 4004 | ; mov ebx,1 |
4005 | ; shl ebx,cl |
||
1 | ha | 4006 | |
742 | Rus | 4007 | cmp ebp,0 ; enable access - ebp = 0 |
1 | ha | 4008 | jne siar1 |
4009 | |||
465 | serge | 4010 | ; not ebx |
4011 | ; and [edi],byte bl |
||
4012 | btr [edi], eax |
||
1 | ha | 4013 | |
4014 | popad |
||
4015 | |||
4016 | ret |
||
4017 | |||
465 | serge | 4018 | siar1: |
1 | ha | 4019 | |
465 | serge | 4020 | bts [edi], eax |
4021 | ; or [edi],byte bl ; disable access - ebp = 1 |
||
1 | ha | 4022 | |
4023 | popad |
||
4024 | |||
4025 | ret |
||
4026 | |||
4027 | r_f_port_area: |
||
4028 | |||
4029 | test eax, eax |
||
4030 | jnz free_port_area |
||
4031 | ; je r_port_area |
||
4032 | ; jmp free_port_area |
||
4033 | |||
4034 | ; r_port_area: |
||
4035 | |||
4036 | pushad |
||
4037 | |||
742 | Rus | 4038 | cmp ebx,ecx ; beginning > end ? |
75 | diamond | 4039 | ja rpal1 |
4040 | cmp ecx,65536 |
||
4041 | jae rpal1 |
||
381 | serge | 4042 | mov esi,[RESERVED_PORTS] |
742 | Rus | 4043 | test esi,esi ; no reserved areas ? |
1 | ha | 4044 | je rpal2 |
742 | Rus | 4045 | cmp esi,255 ; max reserved |
75 | diamond | 4046 | jae rpal1 |
465 | serge | 4047 | rpal3: |
1 | ha | 4048 | mov edi,esi |
4049 | shl edi,4 |
||
381 | serge | 4050 | add edi,RESERVED_PORTS |
1 | ha | 4051 | cmp ebx,[edi+8] |
75 | diamond | 4052 | ja rpal4 |
1 | ha | 4053 | cmp ecx,[edi+4] |
4054 | jae rpal1 |
||
4055 | ; jb rpal4 |
||
4056 | ; jmp rpal1 |
||
465 | serge | 4057 | rpal4: |
1 | ha | 4058 | |
4059 | dec esi |
||
4060 | jnz rpal3 |
||
4061 | jmp rpal2 |
||
4062 | rpal1: |
||
4063 | popad |
||
4064 | mov eax,1 |
||
4065 | ret |
||
4066 | |||
4067 | rpal2: |
||
4068 | popad |
||
4069 | |||
4070 | |||
4071 | ; enable port access at port IO map |
||
4072 | cli |
||
742 | Rus | 4073 | pushad ; start enable io map |
1 | ha | 4074 | |
4075 | cmp ecx,65536 ;16384 |
||
4076 | jae no_unmask_io ; jge |
||
4077 | |||
4078 | mov eax,ebx |
||
4079 | |||
4080 | new_port_access: |
||
4081 | |||
4082 | pushad |
||
4083 | |||
742 | Rus | 4084 | xor ebp,ebp ; enable - eax = port |
1 | ha | 4085 | call set_io_access_rights |
4086 | |||
4087 | popad |
||
4088 | |||
4089 | inc eax |
||
4090 | cmp eax,ecx |
||
4091 | jbe new_port_access |
||
4092 | |||
4093 | no_unmask_io: |
||
4094 | |||
742 | Rus | 4095 | popad ; end enable io map |
1 | ha | 4096 | sti |
4097 | |||
381 | serge | 4098 | mov edi,[RESERVED_PORTS] |
1 | ha | 4099 | add edi,1 |
381 | serge | 4100 | mov [RESERVED_PORTS],edi |
1 | ha | 4101 | shl edi,4 |
381 | serge | 4102 | add edi,RESERVED_PORTS |
379 | serge | 4103 | mov esi,[TASK_BASE] |
115 | poddubny | 4104 | mov esi,[esi+TASKDATA.pid] |
1 | ha | 4105 | mov [edi],esi |
4106 | mov [edi+4],ebx |
||
4107 | mov [edi+8],ecx |
||
4108 | |||
4109 | xor eax, eax |
||
4110 | ret |
||
4111 | |||
4112 | free_port_area: |
||
4113 | |||
4114 | pushad |
||
4115 | |||
381 | serge | 4116 | mov esi,[RESERVED_PORTS] ; no reserved areas ? |
75 | diamond | 4117 | test esi,esi |
1 | ha | 4118 | je frpal2 |
379 | serge | 4119 | mov edx,[TASK_BASE] |
115 | poddubny | 4120 | mov edx,[edx+TASKDATA.pid] |
1 | ha | 4121 | frpal3: |
4122 | mov edi,esi |
||
4123 | shl edi,4 |
||
381 | serge | 4124 | add edi,RESERVED_PORTS |
1 | ha | 4125 | cmp edx,[edi] |
4126 | jne frpal4 |
||
4127 | cmp ebx,[edi+4] |
||
4128 | jne frpal4 |
||
4129 | cmp ecx,[edi+8] |
||
4130 | jne frpal4 |
||
4131 | jmp frpal1 |
||
4132 | frpal4: |
||
4133 | dec esi |
||
4134 | jnz frpal3 |
||
4135 | frpal2: |
||
4136 | popad |
||
4137 | mov eax,1 |
||
4138 | ret |
||
4139 | frpal1: |
||
4140 | mov ecx,256 |
||
4141 | sub ecx,esi |
||
4142 | shl ecx,4 |
||
4143 | mov esi,edi |
||
4144 | add esi,16 |
||
4145 | cld |
||
4146 | rep movsb |
||
4147 | |||
381 | serge | 4148 | dec dword [RESERVED_PORTS] |
1 | ha | 4149 | |
4150 | popad |
||
4151 | |||
4152 | |||
4153 | ; disable port access at port IO map |
||
4154 | |||
742 | Rus | 4155 | pushad ; start disable io map |
1 | ha | 4156 | |
4157 | cmp ecx,65536 ;16384 |
||
4158 | jge no_mask_io |
||
4159 | |||
4160 | mov eax,ebx |
||
4161 | |||
4162 | new_port_access_disable: |
||
4163 | |||
4164 | pushad |
||
4165 | |||
742 | Rus | 4166 | mov ebp,1 ; disable - eax = port |
1 | ha | 4167 | call set_io_access_rights |
4168 | |||
4169 | popad |
||
4170 | |||
4171 | inc eax |
||
4172 | cmp eax,ecx |
||
4173 | jbe new_port_access_disable |
||
4174 | |||
4175 | no_mask_io: |
||
4176 | |||
742 | Rus | 4177 | popad ; end disable io map |
1 | ha | 4178 | |
4179 | xor eax, eax |
||
4180 | ret |
||
4181 | |||
4182 | |||
4183 | reserve_free_irq: |
||
4184 | |||
765 | Rus | 4185 | xor esi, esi |
4186 | inc esi |
||
4187 | cmp ecx, 16 |
||
4188 | jae ril1 |
||
1 | ha | 4189 | |
765 | Rus | 4190 | lea ecx, [irq_owner + 4 * ecx] |
4191 | mov edx, [ecx] |
||
4192 | mov eax, [TASK_BASE] |
||
4193 | mov edi, [eax + TASKDATA.pid] |
||
4194 | dec ebx |
||
4195 | jnz reserve_irq |
||
1 | ha | 4196 | |
765 | Rus | 4197 | cmp edx, edi |
4198 | jne ril1 |
||
4199 | dec esi |
||
4200 | mov [ecx], esi |
||
4201 | |||
4202 | jmp ril1 |
||
4203 | |||
1 | ha | 4204 | reserve_irq: |
4205 | |||
765 | Rus | 4206 | cmp dword [ecx], 0 |
4207 | jne ril1 |
||
1 | ha | 4208 | |
765 | Rus | 4209 | mov [ecx], edi |
4210 | dec esi |
||
1 | ha | 4211 | ril1: |
765 | Rus | 4212 | mov [esp+32], esi ; return in eax |
1 | ha | 4213 | ret |
4214 | |||
4215 | drawbackground: |
||
33 | mario79 | 4216 | inc [mouse_pause] |
381 | serge | 4217 | cmp [SCR_MODE],word 0x12 |
117 | mario79 | 4218 | je dbrv20 |
1 | ha | 4219 | dbrv12: |
381 | serge | 4220 | cmp [SCR_MODE],word 0100000000000000b |
1 | ha | 4221 | jge dbrv20 |
381 | serge | 4222 | cmp [SCR_MODE],word 0x13 |
1 | ha | 4223 | je dbrv20 |
4224 | call vesa12_drawbackground |
||
33 | mario79 | 4225 | dec [mouse_pause] |
36 | mario79 | 4226 | call [draw_pointer] |
1 | ha | 4227 | ret |
4228 | dbrv20: |
||
527 | diamond | 4229 | cmp [BgrDrawMode],dword 1 |
1 | ha | 4230 | jne bgrstr |
4231 | call vesa20_drawbackground_tiled |
||
33 | mario79 | 4232 | dec [mouse_pause] |
36 | mario79 | 4233 | call [draw_pointer] |
1 | ha | 4234 | ret |
4235 | bgrstr: |
||
4236 | call vesa20_drawbackground_stretch |
||
33 | mario79 | 4237 | dec [mouse_pause] |
36 | mario79 | 4238 | call [draw_pointer] |
1 | ha | 4239 | ret |
4240 | |||
75 | diamond | 4241 | align 4 |
1 | ha | 4242 | |
742 | Rus | 4243 | syscall_putimage: ; PutImage |
1 | ha | 4244 | sys_putimage: |
53 | mikedld | 4245 | test ecx,0x80008000 |
4246 | jnz .exit |
||
4247 | test ecx,0x0000FFFF |
||
4248 | jz .exit |
||
4249 | test ecx,0xFFFF0000 |
||
4250 | jnz @f |
||
4251 | .exit: |
||
4252 | ret |
||
4253 | @@: |
||
742 | Rus | 4254 | mov edi,[current_slot] |
4255 | add dx,word[edi+APPDATA.wnd_clientbox.top] |
||
4256 | rol edx,16 |
||
4257 | add dx,word[edi+APPDATA.wnd_clientbox.left] |
||
4258 | rol edx,16 |
||
114 | mikedld | 4259 | .forced: |
742 | Rus | 4260 | push ebp esi 0 |
4261 | mov ebp, putimage_get24bpp |
||
4262 | mov esi, putimage_init24bpp |
||
283 | diamond | 4263 | sys_putimage_bpp: |
4264 | ; call [disable_mouse] ; this will be done in xxx_putimage |
||
117 | mario79 | 4265 | ; mov eax, vga_putimage |
742 | Rus | 4266 | cmp [SCR_MODE], word 0x12 |
4267 | jz @f ;.doit |
||
4268 | mov eax, vesa12_putimage |
||
4269 | cmp [SCR_MODE], word 0100000000000000b |
||
4270 | jae @f |
||
4271 | cmp [SCR_MODE], word 0x13 |
||
4272 | jnz .doit |
||
75 | diamond | 4273 | @@: |
742 | Rus | 4274 | mov eax, vesa20_putimage |
75 | diamond | 4275 | .doit: |
742 | Rus | 4276 | inc [mouse_pause] |
4277 | call eax |
||
4278 | dec [mouse_pause] |
||
4279 | pop ebp esi ebp |
||
4280 | jmp [draw_pointer] |
||
1 | ha | 4281 | |
283 | diamond | 4282 | syscall_putimage_palette: |
742 | Rus | 4283 | mov edi, esi |
4284 | mov esi, edx |
||
4285 | mov edx, ecx |
||
4286 | mov ecx, ebx |
||
4287 | mov ebx, eax |
||
283 | diamond | 4288 | sys_putimage_palette: |
4289 | ; ebx = pointer to image |
||
4290 | ; ecx = [xsize]*65536 + [ysize] |
||
4291 | ; edx = [xstart]*65536 + [ystart] |
||
314 | diamond | 4292 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
283 | diamond | 4293 | ; edi = pointer to palette |
314 | diamond | 4294 | ; ebp = row delta |
742 | Rus | 4295 | mov eax, [CURRENT_TASK] |
4296 | shl eax, 8 |
||
4297 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
4298 | rol edx, 16 |
||
4299 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
4300 | rol edx, 16 |
||
283 | diamond | 4301 | .forced: |
742 | Rus | 4302 | push ebp esi ebp |
4303 | cmp esi, 8 |
||
4304 | jnz @f |
||
4305 | mov ebp, putimage_get8bpp |
||
4306 | mov esi, putimage_init8bpp |
||
4307 | jmp sys_putimage_bpp |
||
314 | diamond | 4308 | @@: |
742 | Rus | 4309 | cmp esi, 24 |
4310 | jnz @f |
||
4311 | mov ebp, putimage_get24bpp |
||
4312 | mov esi, putimage_init24bpp |
||
4313 | jmp sys_putimage_bpp |
||
314 | diamond | 4314 | @@: |
742 | Rus | 4315 | cmp esi, 32 |
4316 | jnz @f |
||
4317 | mov ebp, putimage_get32bpp |
||
4318 | mov esi, putimage_init32bpp |
||
4319 | jmp sys_putimage_bpp |
||
314 | diamond | 4320 | @@: |
742 | Rus | 4321 | pop ebp esi |
4322 | ret |
||
283 | diamond | 4323 | |
4324 | putimage_init24bpp: |
||
742 | Rus | 4325 | lea eax, [eax*3] |
283 | diamond | 4326 | putimage_init8bpp: |
742 | Rus | 4327 | ret |
283 | diamond | 4328 | |
4329 | putimage_get24bpp: |
||
742 | Rus | 4330 | mov eax, [esi] |
4331 | add esi, 3 |
||
4332 | ret 4 |
||
283 | diamond | 4333 | putimage_get8bpp: |
742 | Rus | 4334 | movzx eax, byte [esi] |
4335 | push edx |
||
4336 | mov edx, [esp+8] |
||
4337 | mov eax, [edx+eax*4] |
||
4338 | pop edx |
||
4339 | inc esi |
||
4340 | ret 4 |
||
283 | diamond | 4341 | |
314 | diamond | 4342 | putimage_init32bpp: |
742 | Rus | 4343 | shl eax, 2 |
4344 | ret |
||
314 | diamond | 4345 | putimage_get32bpp: |
742 | Rus | 4346 | lodsd |
4347 | ret 4 |
||
314 | diamond | 4348 | |
1 | ha | 4349 | ; eax x beginning |
4350 | ; ebx y beginning |
||
4351 | ; ecx x end |
||
283 | diamond | 4352 | ; edx y end |
1 | ha | 4353 | ; edi color |
4354 | |||
4355 | __sys_drawbar: |
||
742 | Rus | 4356 | mov esi,[current_slot] |
4357 | add eax,[esi+APPDATA.wnd_clientbox.left] |
||
4358 | add ecx,[esi+APPDATA.wnd_clientbox.left] |
||
4359 | add ebx,[esi+APPDATA.wnd_clientbox.top] |
||
4360 | add edx,[esi+APPDATA.wnd_clientbox.top] |
||
114 | mikedld | 4361 | .forced: |
33 | mario79 | 4362 | inc [mouse_pause] |
283 | diamond | 4363 | ; call [disable_mouse] |
381 | serge | 4364 | cmp [SCR_MODE],word 0x12 |
742 | Rus | 4365 | je dbv20 |
1 | ha | 4366 | sdbv20: |
381 | serge | 4367 | cmp [SCR_MODE],word 0100000000000000b |
1 | ha | 4368 | jge dbv20 |
381 | serge | 4369 | cmp [SCR_MODE],word 0x13 |
742 | Rus | 4370 | je dbv20 |
1 | ha | 4371 | call vesa12_drawbar |
33 | mario79 | 4372 | dec [mouse_pause] |
36 | mario79 | 4373 | call [draw_pointer] |
1 | ha | 4374 | ret |
4375 | dbv20: |
||
4376 | call vesa20_drawbar |
||
33 | mario79 | 4377 | dec [mouse_pause] |
36 | mario79 | 4378 | call [draw_pointer] |
1 | ha | 4379 | ret |
4380 | |||
4381 | |||
4382 | |||
4383 | kb_read: |
||
4384 | |||
742 | Rus | 4385 | push ecx edx |
1 | ha | 4386 | |
742 | Rus | 4387 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
1 | ha | 4388 | kr_loop: |
742 | Rus | 4389 | in al,0x64 |
4390 | test al,1 |
||
4391 | jnz kr_ready |
||
4392 | loop kr_loop |
||
4393 | mov ah,1 |
||
4394 | jmp kr_exit |
||
1 | ha | 4395 | kr_ready: |
742 | Rus | 4396 | push ecx |
4397 | mov ecx,32 |
||
1 | ha | 4398 | kr_delay: |
742 | Rus | 4399 | loop kr_delay |
4400 | pop ecx |
||
4401 | in al,0x60 |
||
4402 | xor ah,ah |
||
1 | ha | 4403 | kr_exit: |
4404 | |||
742 | Rus | 4405 | pop edx ecx |
1 | ha | 4406 | |
742 | Rus | 4407 | ret |
1 | ha | 4408 | |
4409 | |||
4410 | kb_write: |
||
4411 | |||
742 | Rus | 4412 | push ecx edx |
1 | ha | 4413 | |
742 | Rus | 4414 | mov dl,al |
265 | diamond | 4415 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4416 | ; kw_loop1: |
||
4417 | ; in al,0x64 |
||
4418 | ; test al,0x20 |
||
4419 | ; jz kw_ok1 |
||
4420 | ; loop kw_loop1 |
||
4421 | ; mov ah,1 |
||
4422 | ; jmp kw_exit |
||
4423 | ; kw_ok1: |
||
742 | Rus | 4424 | in al,0x60 |
4425 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
||
1 | ha | 4426 | kw_loop: |
742 | Rus | 4427 | in al,0x64 |
4428 | test al,2 |
||
4429 | jz kw_ok |
||
4430 | loop kw_loop |
||
4431 | mov ah,1 |
||
4432 | jmp kw_exit |
||
1 | ha | 4433 | kw_ok: |
742 | Rus | 4434 | mov al,dl |
4435 | out 0x60,al |
||
4436 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
||
1 | ha | 4437 | kw_loop3: |
742 | Rus | 4438 | in al,0x64 |
4439 | test al,2 |
||
4440 | jz kw_ok3 |
||
4441 | loop kw_loop3 |
||
4442 | mov ah,1 |
||
4443 | jmp kw_exit |
||
1 | ha | 4444 | kw_ok3: |
742 | Rus | 4445 | mov ah,8 |
1 | ha | 4446 | kw_loop4: |
742 | Rus | 4447 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
1 | ha | 4448 | kw_loop5: |
742 | Rus | 4449 | in al,0x64 |
4450 | test al,1 |
||
4451 | jnz kw_ok4 |
||
4452 | loop kw_loop5 |
||
4453 | dec ah |
||
4454 | jnz kw_loop4 |
||
1 | ha | 4455 | kw_ok4: |
742 | Rus | 4456 | xor ah,ah |
1 | ha | 4457 | kw_exit: |
4458 | |||
742 | Rus | 4459 | pop edx ecx |
1 | ha | 4460 | |
742 | Rus | 4461 | ret |
1 | ha | 4462 | |
4463 | |||
4464 | kb_cmd: |
||
4465 | |||
742 | Rus | 4466 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
1 | ha | 4467 | c_wait: |
742 | Rus | 4468 | in al,0x64 |
4469 | test al,2 |
||
4470 | jz c_send |
||
4471 | loop c_wait |
||
4472 | jmp c_error |
||
1 | ha | 4473 | c_send: |
742 | Rus | 4474 | mov al,bl |
4475 | out 0x64,al |
||
4476 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
||
1 | ha | 4477 | c_accept: |
742 | Rus | 4478 | in al,0x64 |
4479 | test al,2 |
||
4480 | jz c_ok |
||
4481 | loop c_accept |
||
1 | ha | 4482 | c_error: |
742 | Rus | 4483 | mov ah,1 |
4484 | jmp c_exit |
||
1 | ha | 4485 | c_ok: |
742 | Rus | 4486 | xor ah,ah |
1 | ha | 4487 | c_exit: |
742 | Rus | 4488 | ret |
1 | ha | 4489 | |
4490 | |||
4491 | setmouse: ; set mousepicture -pointer |
||
742 | Rus | 4492 | ; ps2 mouse enable |
1 | ha | 4493 | |
381 | serge | 4494 | mov [MOUSE_PICTURE],dword mousepointer |
1 | ha | 4495 | |
4496 | cli |
||
33 | mario79 | 4497 | ; mov bl,0xa8 ; enable mouse cmd |
4498 | ; call kb_cmd |
||
4499 | ; call kb_read ; read status |
||
4500 | ; mov bl,0x20 ; get command byte |
||
4501 | ; call kb_cmd |
||
4502 | ; call kb_read |
||
4503 | ; or al,3 ; enable interrupt |
||
4504 | ; mov bl,0x60 ; write command |
||
4505 | ; push eax |
||
4506 | ; call kb_cmd |
||
4507 | ; pop eax |
||
4508 | ; call kb_write |
||
4509 | ; mov bl,0xd4 ; for mouse |
||
4510 | ; call kb_cmd |
||
4511 | ; mov al,0xf4 ; enable mouse device |
||
4512 | ; call kb_write |
||
4513 | ; call kb_read ; read status return |
||
1 | ha | 4514 | |
4515 | ; com1 mouse enable |
||
4516 | |||
4517 | mov bx,0x3f8 ; combase |
||
4518 | |||
4519 | mov dx,bx |
||
4520 | add dx,3 |
||
4521 | mov al,0x80 |
||
4522 | out dx,al |
||
4523 | |||
4524 | mov dx,bx |
||
4525 | add dx,1 |
||
4526 | mov al,0 |
||
4527 | out dx,al |
||
4528 | |||
4529 | mov dx,bx |
||
4530 | add dx,0 |
||
742 | Rus | 4531 | mov al,0x30*2 ; 0x30 / 4 |
1 | ha | 4532 | out dx,al |
4533 | |||
4534 | mov dx,bx |
||
4535 | add dx,3 |
||
742 | Rus | 4536 | mov al,2 ; 3 |
1 | ha | 4537 | out dx,al |
4538 | |||
4539 | mov dx,bx |
||
4540 | add dx,4 |
||
4541 | mov al,0xb |
||
4542 | out dx,al |
||
4543 | |||
4544 | mov dx,bx |
||
4545 | add dx,1 |
||
4546 | mov al,1 |
||
4547 | out dx,al |
||
4548 | |||
4549 | |||
4550 | ; com2 mouse enable |
||
4551 | |||
4552 | mov bx,0x2f8 ; combase |
||
4553 | |||
4554 | mov dx,bx |
||
4555 | add dx,3 |
||
4556 | mov al,0x80 |
||
4557 | out dx,al |
||
4558 | |||
4559 | mov dx,bx |
||
4560 | add dx,1 |
||
4561 | mov al,0 |
||
4562 | out dx,al |
||
4563 | |||
4564 | mov dx,bx |
||
4565 | add dx,0 |
||
4566 | mov al,0x30*2 |
||
4567 | out dx,al |
||
4568 | |||
4569 | mov dx,bx |
||
4570 | add dx,3 |
||
4571 | mov al,2 |
||
4572 | out dx,al |
||
4573 | |||
4574 | mov dx,bx |
||
4575 | add dx,4 |
||
4576 | mov al,0xb |
||
4577 | out dx,al |
||
4578 | |||
4579 | mov dx,bx |
||
4580 | add dx,1 |
||
4581 | mov al,1 |
||
4582 | out dx,al |
||
4583 | |||
4584 | ret |
||
4585 | |||
4586 | |||
4587 | _rdtsc: |
||
164 | serge | 4588 | bt [cpu_caps], CAPS_TSC |
4589 | jnc ret_rdtsc |
||
1 | ha | 4590 | rdtsc |
4591 | ret |
||
4592 | ret_rdtsc: |
||
4593 | mov edx,0xffffffff |
||
4594 | mov eax,0xffffffff |
||
4595 | ret |
||
4596 | |||
4597 | rerouteirqs: |
||
4598 | |||
742 | Rus | 4599 | cli |
1 | ha | 4600 | |
742 | Rus | 4601 | mov al,0x11 ; icw4, edge triggered |
4602 | out 0x20,al |
||
4603 | call pic_delay |
||
4604 | out 0xA0,al |
||
4605 | call pic_delay |
||
1 | ha | 4606 | |
742 | Rus | 4607 | mov al,0x20 ; generate 0x20 + |
4608 | out 0x21,al |
||
4609 | call pic_delay |
||
4610 | mov al,0x28 ; generate 0x28 + |
||
4611 | out 0xA1,al |
||
4612 | call pic_delay |
||
1 | ha | 4613 | |
742 | Rus | 4614 | mov al,0x04 ; slave at irq2 |
4615 | out 0x21,al |
||
4616 | call pic_delay |
||
4617 | mov al,0x02 ; at irq9 |
||
4618 | out 0xA1,al |
||
4619 | call pic_delay |
||
1 | ha | 4620 | |
742 | Rus | 4621 | mov al,0x01 ; 8086 mode |
4622 | out 0x21,al |
||
4623 | call pic_delay |
||
4624 | out 0xA1,al |
||
4625 | call pic_delay |
||
1 | ha | 4626 | |
742 | Rus | 4627 | mov al,255 ; mask all irq's |
4628 | out 0xA1,al |
||
4629 | call pic_delay |
||
4630 | out 0x21,al |
||
4631 | call pic_delay |
||
1 | ha | 4632 | |
742 | Rus | 4633 | mov ecx,0x1000 |
4634 | cld |
||
4635 | picl1: call pic_delay |
||
4636 | loop picl1 |
||
1 | ha | 4637 | |
742 | Rus | 4638 | mov al,255 ; mask all irq's |
4639 | out 0xA1,al |
||
4640 | call pic_delay |
||
4641 | out 0x21,al |
||
4642 | call pic_delay |
||
1 | ha | 4643 | |
742 | Rus | 4644 | cli |
1 | ha | 4645 | |
742 | Rus | 4646 | ret |
1 | ha | 4647 | |
4648 | |||
4649 | pic_delay: |
||
4650 | |||
742 | Rus | 4651 | jmp pdl1 |
4652 | pdl1: ret |
||
1 | ha | 4653 | |
4654 | |||
4655 | sys_msg_board_str: |
||
4656 | |||
4657 | pushad |
||
4658 | @@: |
||
4659 | cmp [esi],byte 0 |
||
4660 | je @f |
||
4661 | mov eax,1 |
||
4662 | movzx ebx,byte [esi] |
||
4663 | call sys_msg_board |
||
4664 | inc esi |
||
4665 | jmp @b |
||
4666 | @@: |
||
4667 | popad |
||
4668 | ret |
||
4669 | |||
709 | diamond | 4670 | sys_msg_board_byte: |
4671 | ; in: al = byte to display |
||
4672 | ; out: nothing |
||
4673 | ; destroys: nothing |
||
742 | Rus | 4674 | pushad |
4675 | mov ecx, 2 |
||
4676 | shl eax, 24 |
||
4677 | jmp @f |
||
709 | diamond | 4678 | |
4679 | sys_msg_board_word: |
||
4680 | ; in: ax = word to display |
||
4681 | ; out: nothing |
||
4682 | ; destroys: nothing |
||
742 | Rus | 4683 | pushad |
4684 | mov ecx, 4 |
||
4685 | shl eax, 16 |
||
4686 | jmp @f |
||
709 | diamond | 4687 | |
4688 | sys_msg_board_dword: |
||
4689 | ; in: eax = dword to display |
||
4690 | ; out: nothing |
||
4691 | ; destroys: nothing |
||
742 | Rus | 4692 | pushad |
4693 | mov ecx, 8 |
||
709 | diamond | 4694 | @@: |
742 | Rus | 4695 | push ecx |
4696 | rol eax, 4 |
||
4697 | push eax |
||
4698 | and al, 0xF |
||
4699 | cmp al, 10 |
||
4700 | sbb al, 69h |
||
4701 | das |
||
4702 | mov bl, al |
||
4703 | xor eax, eax |
||
4704 | inc eax |
||
4705 | call sys_msg_board |
||
4706 | pop eax |
||
4707 | pop ecx |
||
4708 | loop @b |
||
4709 | popad |
||
4710 | ret |
||
709 | diamond | 4711 | |
1 | ha | 4712 | uglobal |
373 | mikedld | 4713 | msg_board_data: times 4096 db 0 |
1 | ha | 4714 | msg_board_count dd 0x0 |
4715 | endg |
||
4716 | |||
4717 | sys_msg_board: |
||
4718 | |||
4719 | ; eax=1 : write : bl byte to write |
||
4720 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
||
4721 | |||
671 | Ghost | 4722 | mov ecx, [msg_board_count] |
4723 | cmp eax, 1 |
||
4724 | jne .smbl1 |
||
1 | ha | 4725 | |
4726 | |||
671 | Ghost | 4727 | mov [msg_board_data+ecx],bl |
4728 | inc ecx |
||
4729 | and ecx, 4095 |
||
4730 | mov [msg_board_count], ecx |
||
4731 | mov [check_idle_semaphore], 5 |
||
4732 | ret |
||
4733 | .smbl1: |
||
4734 | cmp eax, 2 |
||
4735 | jne .smbl2 |
||
4736 | test ecx, ecx |
||
4737 | jz .smbl21 |
||
4738 | mov eax, msg_board_data+1 |
||
4739 | mov ebx, msg_board_data |
||
4740 | movzx edx, byte [ebx] |
||
4741 | call memmove |
||
4742 | dec [msg_board_count] |
||
4743 | mov [esp + 36], edx ;eax |
||
4744 | mov [esp + 24], dword 1 |
||
4745 | ret |
||
4746 | .smbl21: |
||
4747 | mov [esp+36], ecx |
||
4748 | mov [esp+24], ecx |
||
4749 | .smbl2: |
||
4750 | ret |
||
1 | ha | 4751 | |
4752 | |||
4753 | |||
4754 | sys_process_def: |
||
742 | Rus | 4755 | mov edi, [CURRENT_TASK] |
1 | ha | 4756 | |
742 | Rus | 4757 | dec eax ; 1 = set keyboard mode |
1 | ha | 4758 | jne no_set_keyboard_setup |
4759 | |||
4760 | shl edi,8 |
||
380 | serge | 4761 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode],bl |
1 | ha | 4762 | |
4763 | ret |
||
4764 | |||
4765 | no_set_keyboard_setup: |
||
4766 | |||
742 | Rus | 4767 | dec eax ; 2 = get keyboard mode |
1 | ha | 4768 | jne no_get_keyboard_setup |
4769 | |||
4770 | shl edi,8 |
||
380 | serge | 4771 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
1 | ha | 4772 | |
4773 | mov [esp+36],eax |
||
4774 | |||
4775 | ret |
||
4776 | |||
4777 | no_get_keyboard_setup: |
||
4778 | |||
742 | Rus | 4779 | dec eax ; 3 = get keyboard ctrl, alt, shift |
1 | ha | 4780 | jne no_get_keyboard_cas |
4781 | |||
4782 | ; xor eax,eax |
||
4783 | ; movzx eax,byte [shift] |
||
4784 | ; movzx ebx,byte [ctrl] |
||
4785 | ; shl ebx,2 |
||
4786 | ; add eax,ebx |
||
4787 | ; movzx ebx,byte [alt] |
||
4788 | ; shl ebx,3 |
||
4789 | ; add eax,ebx |
||
4790 | |||
4791 | ;// mike.dld [ |
||
4792 | mov eax, [kb_state] |
||
4793 | ;// mike.dld ] |
||
4794 | |||
4795 | mov [esp+36],eax |
||
4796 | |||
4797 | ret |
||
4798 | |||
4799 | no_get_keyboard_cas: |
||
4800 | |||
742 | Rus | 4801 | dec eax |
4802 | jnz no_add_keyboard_hotkey |
||
1 | ha | 4803 | |
742 | Rus | 4804 | mov eax, hotkey_list |
92 | diamond | 4805 | @@: |
742 | Rus | 4806 | cmp dword [eax+8], 0 |
4807 | jz .found_free |
||
4808 | add eax, 16 |
||
4809 | cmp eax, hotkey_list+16*256 |
||
4810 | jb @b |
||
4811 | mov dword [esp+36], 1 |
||
4812 | ret |
||
92 | diamond | 4813 | .found_free: |
742 | Rus | 4814 | mov [eax+8], edi |
4815 | mov [eax+4], ecx |
||
4816 | movzx ebx, bl |
||
4817 | lea ebx, [hotkey_scancodes+ebx*4] |
||
4818 | mov ecx, [ebx] |
||
4819 | mov [eax], ecx |
||
4820 | mov [ebx], eax |
||
4821 | mov [eax+12], ebx |
||
4822 | jecxz @f |
||
4823 | mov [ecx+12], eax |
||
92 | diamond | 4824 | @@: |
742 | Rus | 4825 | and dword [esp+36], 0 |
4826 | ret |
||
92 | diamond | 4827 | |
4828 | no_add_keyboard_hotkey: |
||
4829 | |||
742 | Rus | 4830 | dec eax |
4831 | jnz no_del_keyboard_hotkey |
||
92 | diamond | 4832 | |
742 | Rus | 4833 | movzx ebx, bl |
4834 | lea ebx, [hotkey_scancodes+ebx*4] |
||
4835 | mov eax, [ebx] |
||
92 | diamond | 4836 | .scan: |
742 | Rus | 4837 | test eax, eax |
4838 | jz .notfound |
||
4839 | cmp [eax+8], edi |
||
4840 | jnz .next |
||
4841 | cmp [eax+4], ecx |
||
4842 | jz .found |
||
92 | diamond | 4843 | .next: |
742 | Rus | 4844 | mov eax, [eax] |
4845 | jmp .scan |
||
92 | diamond | 4846 | .notfound: |
742 | Rus | 4847 | mov dword [esp+36], 1 |
4848 | ret |
||
92 | diamond | 4849 | .found: |
742 | Rus | 4850 | mov ecx, [eax] |
4851 | jecxz @f |
||
4852 | mov edx, [eax+12] |
||
4853 | mov [ecx+12], edx |
||
92 | diamond | 4854 | @@: |
742 | Rus | 4855 | mov ecx, [eax+12] |
4856 | mov edx, [eax] |
||
4857 | mov [ecx], edx |
||
4858 | xor edx, edx |
||
4859 | mov [eax+4], edx |
||
4860 | mov [eax+8], edx |
||
4861 | mov [eax+12], edx |
||
4862 | mov [eax], edx |
||
4863 | mov [esp+36], edx |
||
4864 | ret |
||
92 | diamond | 4865 | |
4866 | no_del_keyboard_hotkey: |
||
1 | ha | 4867 | ret |
4868 | |||
4869 | |||
4870 | align 4 |
||
4871 | |||
742 | Rus | 4872 | sys_gs: ; direct screen access |
1 | ha | 4873 | |
742 | Rus | 4874 | cmp eax,1 ; resolution |
1 | ha | 4875 | jne no_gs1 |
753 | serge | 4876 | mov eax,[Screen_Max_X] |
1 | ha | 4877 | shl eax,16 |
753 | serge | 4878 | mov ax,[Screen_Max_Y] |
1 | ha | 4879 | add eax,0x00010001 |
4880 | mov [esp+36],eax |
||
4881 | ret |
||
4882 | no_gs1: |
||
4883 | |||
742 | Rus | 4884 | cmp eax,2 ; bits per pixel |
1 | ha | 4885 | jne no_gs2 |
381 | serge | 4886 | movzx eax,byte [ScreenBPP] |
1 | ha | 4887 | mov [esp+36],eax |
4888 | ret |
||
4889 | no_gs2: |
||
4890 | |||
742 | Rus | 4891 | cmp eax,3 ; bytes per scanline |
1 | ha | 4892 | jne no_gs3 |
381 | serge | 4893 | mov eax,[BytesPerScanLine] |
1 | ha | 4894 | mov [esp+36],eax |
4895 | ret |
||
4896 | no_gs3: |
||
4897 | |||
4898 | mov [esp+36],dword -1 |
||
4899 | ret |
||
4900 | |||
4901 | |||
4902 | align 4 ; PCI functions |
||
4903 | |||
4904 | sys_pci: |
||
4905 | |||
4906 | call pci_api |
||
4907 | mov [esp+36],eax |
||
4908 | ret |
||
4909 | |||
4910 | |||
4911 | align 4 ; system functions |
||
4912 | |||
742 | Rus | 4913 | syscall_setpixel: ; SetPixel |
1 | ha | 4914 | |
742 | Rus | 4915 | mov eax, ebx |
4916 | mov ebx, ecx |
||
4917 | mov ecx, edx |
||
4918 | mov edx, [TASK_BASE] |
||
4919 | add eax, [edx-twdw+WDATA.box.left] |
||
4920 | add ebx, [edx-twdw+WDATA.box.top] |
||
4921 | mov edi, [current_slot] |
||
4922 | add eax, [edi+APPDATA.wnd_clientbox.left] |
||
4923 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
||
4924 | xor edi, edi ; no force |
||
684 | diamond | 4925 | ; mov edi, 1 |
742 | Rus | 4926 | call [disable_mouse] |
4927 | jmp [putpixel] |
||
1 | ha | 4928 | |
4929 | align 4 |
||
4930 | |||
742 | Rus | 4931 | syscall_writetext: ; WriteText |
1 | ha | 4932 | |
742 | Rus | 4933 | mov eax,[TASK_BASE] |
4934 | mov ebp,[eax-twdw+WDATA.box.left] |
||
4935 | push esi |
||
4936 | mov esi,[current_slot] |
||
4937 | add ebp,[esi+APPDATA.wnd_clientbox.left] |
||
4938 | shl ebp,16 |
||
4939 | add ebp,[eax-twdw+WDATA.box.top] |
||
4940 | add bp,word[esi+APPDATA.wnd_clientbox.top] |
||
4941 | pop esi |
||
4942 | add ebx,ebp |
||
4943 | mov eax,edi |
||
4944 | xor edi,edi |
||
4945 | jmp dtext |
||
1 | ha | 4946 | |
4947 | align 4 |
||
4948 | |||
742 | Rus | 4949 | syscall_openramdiskfile: ; OpenRamdiskFile |
1 | ha | 4950 | |
742 | Rus | 4951 | mov eax, ebx |
4952 | mov ebx, ecx |
||
4953 | mov ecx, edx |
||
4954 | mov edx, esi |
||
4955 | mov esi, 12 |
||
4956 | call fileread |
||
4957 | mov [esp+32], eax |
||
4958 | ret |
||
1 | ha | 4959 | |
4960 | align 4 |
||
4961 | |||
742 | Rus | 4962 | syscall_drawrect: ; DrawRect |
1 | ha | 4963 | |
671 | Ghost | 4964 | mov edi, edx ; color + gradient |
4965 | and edi, 0x80FFFFFF |
||
4966 | test bx, bx ; x.size |
||
4967 | je .drectr |
||
4968 | test cx, cx ; y.size |
||
4969 | je .drectr |
||
1 | ha | 4970 | |
671 | Ghost | 4971 | mov eax, ebx ; bad idea |
4972 | mov ebx, ecx |
||
1 | ha | 4973 | |
671 | Ghost | 4974 | movzx ecx, ax ; ecx - x.size |
4975 | shr eax, 16 ; eax - x.coord |
||
4976 | movzx edx, bx ; edx - y.size |
||
4977 | shr ebx, 16 ; ebx - y.coord |
||
4978 | mov esi, [current_slot] |
||
1 | ha | 4979 | |
671 | Ghost | 4980 | add eax, [esi + APPDATA.wnd_clientbox.left] |
4981 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
||
4982 | add ecx, eax |
||
4983 | add edx, ebx |
||
4984 | jmp [drawbar] |
||
4985 | .drectr: |
||
4986 | ret |
||
1 | ha | 4987 | |
4988 | align 4 |
||
742 | Rus | 4989 | syscall_getscreensize: ; GetScreenSize |
759 | Rus | 4990 | mov ax, [Screen_Max_X] |
671 | Ghost | 4991 | shl eax, 16 |
759 | Rus | 4992 | mov ax, [Screen_Max_Y] |
671 | Ghost | 4993 | mov [esp + 32], eax |
4994 | ret |
||
1 | ha | 4995 | |
671 | Ghost | 4996 | align 4 |
4997 | |||
742 | Rus | 4998 | syscall_cdaudio: ; CD |
1 | ha | 4999 | |
742 | Rus | 5000 | cmp eax, 4 |
5001 | jb .audio |
||
5002 | jz .eject |
||
5003 | cmp eax, 5 |
||
5004 | jnz .ret |
||
588 | diamond | 5005 | .load: |
742 | Rus | 5006 | call .reserve |
5007 | call LoadMedium |
||
5008 | call .free |
||
5009 | ret |
||
588 | diamond | 5010 | .eject: |
742 | Rus | 5011 | call .reserve |
5012 | call clear_CD_cache |
||
5013 | call allow_medium_removal |
||
5014 | call EjectMedium |
||
5015 | call .free |
||
5016 | ret |
||
588 | diamond | 5017 | .audio: |
1 | ha | 5018 | call sys_cd_audio |
5019 | mov [esp+36],eax |
||
588 | diamond | 5020 | .ret: |
1 | ha | 5021 | ret |
5022 | |||
588 | diamond | 5023 | .reserve: |
742 | Rus | 5024 | call reserve_cd |
5025 | mov eax, ebx |
||
5026 | shr eax, 1 |
||
5027 | and eax, 1 |
||
5028 | inc eax |
||
5029 | mov [ChannelNumber], ax |
||
5030 | mov eax, ebx |
||
5031 | and eax, 1 |
||
5032 | mov [DiskNumber], al |
||
5033 | call reserve_cd_channel |
||
5034 | and ebx, 3 |
||
5035 | inc ebx |
||
5036 | mov [cdpos], ebx |
||
5037 | add ebx, ebx |
||
5038 | mov cl, 8 |
||
5039 | sub cl, bl |
||
5040 | mov al, [DRIVE_DATA+1] |
||
5041 | shr al, cl |
||
5042 | test al, 2 |
||
5043 | jz .err |
||
5044 | ret |
||
588 | diamond | 5045 | .free: |
742 | Rus | 5046 | call free_cd_channel |
5047 | and [cd_status], 0 |
||
5048 | ret |
||
590 | diamond | 5049 | .err: |
742 | Rus | 5050 | call .free |
5051 | pop eax |
||
5052 | ret |
||
588 | diamond | 5053 | |
1 | ha | 5054 | align 4 |
5055 | |||
742 | Rus | 5056 | syscall_getpixel: ; GetPixel |
753 | serge | 5057 | mov ecx, [Screen_Max_X] |
1 | ha | 5058 | inc ecx |
671 | Ghost | 5059 | xor edx, edx |
5060 | mov eax, ebx |
||
1 | ha | 5061 | div ecx |
671 | Ghost | 5062 | mov ebx, edx |
5063 | xchg eax, ebx |
||
5064 | call dword [GETPIXEL] ; eax - x, ebx - y |
||
5065 | mov [esp + 32], ecx |
||
1 | ha | 5066 | ret |
5067 | |||
5068 | |||
5069 | align 4 |
||
5070 | |||
742 | Rus | 5071 | syscall_drawline: ; DrawLine |
1 | ha | 5072 | |
671 | Ghost | 5073 | mov edi, [TASK_BASE] |
752 | Lrz | 5074 | movzx eax, word[edi-twdw+WDATA.box.left] |
5075 | mov ebp, eax |
||
671 | Ghost | 5076 | mov esi, [current_slot] |
5077 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
||
752 | Lrz | 5078 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5079 | add ebp,ebx |
||
5080 | shl eax, 16 |
||
5081 | movzx ebx, word[edi-twdw+WDATA.box.top] |
||
671 | Ghost | 5082 | add eax, ebp |
752 | Lrz | 5083 | mov ebp, ebx |
671 | Ghost | 5084 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
752 | Lrz | 5085 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
759 | Rus | 5086 | add ebp, ecx |
752 | Lrz | 5087 | shl ebx, 16 |
671 | Ghost | 5088 | xor edi, edi |
752 | Lrz | 5089 | add ebx, ebp |
5090 | mov ecx, edx |
||
671 | Ghost | 5091 | jmp [draw_line] |
1 | ha | 5092 | |
5093 | align 4 |
||
5094 | |||
742 | Rus | 5095 | syscall_getirqowner: ; GetIrqOwner |
5096 | |||
5097 | cmp ebx,16 |
||
75 | diamond | 5098 | jae .err |
742 | Rus | 5099 | |
5100 | mov eax,[4 * ebx + irq_owner] |
||
5101 | mov [esp+32],eax |
||
5102 | |||
1 | ha | 5103 | ret |
75 | diamond | 5104 | .err: |
742 | Rus | 5105 | or dword [esp+32], -1 |
75 | diamond | 5106 | ret |
1 | ha | 5107 | |
5108 | align 4 |
||
5109 | |||
742 | Rus | 5110 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
1 | ha | 5111 | |
5112 | call r_f_port_area |
||
5113 | mov [esp+36],eax |
||
5114 | ret |
||
5115 | |||
5116 | align 4 |
||
5117 | |||
742 | Rus | 5118 | syscall_threads: ; CreateThreads |
1 | ha | 5119 | |
5120 | call sys_threads |
||
5121 | mov [esp+36],eax |
||
5122 | ret |
||
5123 | |||
5124 | align 4 |
||
5125 | |||
5126 | stack_driver_stat: |
||
5127 | |||
742 | Rus | 5128 | call app_stack_handler ; Stack status |
1 | ha | 5129 | |
5130 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
||
5131 | ; call change_task ; between sent packet |
||
5132 | |||
5133 | mov [esp+36],eax |
||
5134 | ret |
||
5135 | |||
5136 | align 4 |
||
5137 | |||
742 | Rus | 5138 | socket: ; Socket interface |
1 | ha | 5139 | call app_socket_handler |
5140 | |||
5141 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
||
5142 | ; call change_task ; between sent packet |
||
5143 | |||
5144 | mov [esp+36],eax |
||
5145 | mov [esp+24],ebx |
||
5146 | ret |
||
5147 | |||
5148 | align 4 |
||
5149 | |||
742 | Rus | 5150 | read_from_hd: ; Read from hd - fn not in use |
1 | ha | 5151 | |
379 | serge | 5152 | mov edi,[TASK_BASE] |
115 | poddubny | 5153 | add edi,TASKDATA.mem_start |
1 | ha | 5154 | add eax,[edi] |
5155 | add ecx,[edi] |
||
5156 | add edx,[edi] |
||
5157 | call file_read |
||
5158 | |||
5159 | mov [esp+36],eax |
||
5160 | mov [esp+24],ebx |
||
5161 | |||
5162 | ret |
||
5163 | |||
375 | Ghost | 5164 | paleholder: |
742 | Rus | 5165 | ret |
378 | serge | 5166 | |
757 | serge | 5167 | align 4 |
5168 | set_screen: |
||
759 | Rus | 5169 | cmp eax, [Screen_Max_X] |
5170 | jne .set |
||
709 | diamond | 5171 | |
759 | Rus | 5172 | cmp edx, [Screen_Max_Y] |
5173 | jne .set |
||
5174 | ret |
||
757 | serge | 5175 | .set: |
759 | Rus | 5176 | pushfd |
5177 | cli |
||
757 | serge | 5178 | |
759 | Rus | 5179 | mov [Screen_Max_X], eax |
5180 | mov [Screen_Max_Y], edx |
||
757 | serge | 5181 | |
759 | Rus | 5182 | mov [screen_workarea.right],eax |
5183 | mov [screen_workarea.bottom], edx |
||
5184 | inc eax |
||
5185 | shl eax, 2 ;32 bpp |
||
5186 | mov [BytesPerScanLine], eax |
||
5187 | push ebx |
||
5188 | push esi |
||
5189 | push edi |
||
5190 | call repos_windows |
||
5191 | mov eax, 0 |
||
5192 | mov ebx, 0 |
||
5193 | mov ecx, [Screen_Max_X] |
||
5194 | mov edx, [Screen_Max_Y] |
||
5195 | call calculatescreen |
||
5196 | pop edi |
||
5197 | pop esi |
||
5198 | pop ebx |
||
757 | serge | 5199 | |
759 | Rus | 5200 | popfd |
5201 | ret |
||
757 | serge | 5202 | |
76 | mario79 | 5203 | ; --------------- APM --------------------- |
5204 | apm_entry dp 0 |
||
742 | Rus | 5205 | apm_vf dd 0 |
1 | ha | 5206 | align 4 |
76 | mario79 | 5207 | sys_apm: |
5208 | cmp word [apm_vf], 0 ; Check APM BIOS enable |
||
5209 | jne @f |
||
742 | Rus | 5210 | or [esp + 56], byte 1 ; error |
5211 | mov [esp + 36], dword 8 ; 32-bit protected-mode interface not supported |
||
76 | mario79 | 5212 | ret |
164 | serge | 5213 | |
465 | serge | 5214 | @@: |
5215 | xchg eax, ecx |
||
76 | mario79 | 5216 | xchg ebx, ecx |
164 | serge | 5217 | |
76 | mario79 | 5218 | cmp al, 3 |
742 | Rus | 5219 | ja @f |
78 | diamond | 5220 | and [esp + 56], byte 0xfe ; emulate func 0..3 as func 0 |
76 | mario79 | 5221 | mov eax, [apm_vf] |
5222 | mov [esp + 36], eax |
||
5223 | shr eax, 16 |
||
5224 | mov [esp + 32], eax |
||
5225 | ret |
||
78 | diamond | 5226 | |
465 | serge | 5227 | @@: |
5228 | |||
5229 | mov esi, [master_tab+(OS_BASE shr 20)] |
||
5230 | xchg [master_tab], esi |
||
5231 | push esi |
||
5232 | mov edi, cr3 |
||
742 | Rus | 5233 | mov cr3, edi ;flush TLB |
465 | serge | 5234 | |
742 | Rus | 5235 | call pword [apm_entry] ; call APM BIOS |
465 | serge | 5236 | |
5237 | xchg eax, [esp] |
||
5238 | mov [master_tab], eax |
||
5239 | mov eax, cr3 |
||
5240 | mov cr3, eax |
||
5241 | pop eax |
||
5242 | |||
76 | mario79 | 5243 | mov [esp + 8 ], edi |
5244 | mov [esp + 12], esi |
||
5245 | mov [esp + 24], ebx |
||
5246 | mov [esp + 28], edx |
||
5247 | mov [esp + 32], ecx |
||
5248 | mov [esp + 36], eax |
||
5249 | setc al |
||
78 | diamond | 5250 | and [esp + 56], byte 0xfe |
742 | Rus | 5251 | or [esp + 56], al |
465 | serge | 5252 | |
5253 | |||
76 | mario79 | 5254 | ret |
5255 | ; ----------------------------------------- |
||
1 | ha | 5256 | |
76 | mario79 | 5257 | align 4 |
5258 | |||
742 | Rus | 5259 | undefined_syscall: ; Undefined system call |
671 | Ghost | 5260 | mov [esp + 32], dword -1 |
1 | ha | 5261 | ret |
5262 | |||
465 | serge | 5263 | align 4 |
742 | Rus | 5264 | system_shutdown: ; shut down the system |
1 | ha | 5265 | |
742 | Rus | 5266 | cmp byte [BOOT_VAR+0x9030], 1 |
5267 | jne @F |
||
5268 | ret |
||
465 | serge | 5269 | @@: |
742 | Rus | 5270 | call stop_all_services |
5271 | push 3 ; stop playing cd |
||
5272 | pop eax |
||
5273 | call sys_cd_audio |
||
1 | ha | 5274 | |
465 | serge | 5275 | yes_shutdown_param: |
742 | Rus | 5276 | cli |
1 | ha | 5277 | |
742 | Rus | 5278 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5279 | push 12 |
||
5280 | pop esi |
||
5281 | xor ebx,ebx |
||
5282 | or ecx,-1 |
||
5283 | mov edx, OS_BASE+0x70000 |
||
5284 | call fileread |
||
1 | ha | 5285 | |
742 | Rus | 5286 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5287 | mov edi,OS_BASE+0x40000 |
||
5288 | mov ecx,1000 |
||
5289 | rep movsb |
||
1 | ha | 5290 | |
742 | Rus | 5291 | mov esi,OS_BASE+0x2F0000 ; restore 0x0 - 0xffff |
5292 | mov edi, OS_BASE |
||
5293 | mov ecx,0x10000/4 |
||
5294 | cld |
||
5295 | rep movsd |
||
1 | ha | 5296 | |
742 | Rus | 5297 | call restorefatchain |
1 | ha | 5298 | |
742 | Rus | 5299 | mov al, 0xFF |
5300 | out 0x21, al |
||
5301 | out 0xA1, al |
||
1 | ha | 5302 | |
709 | diamond | 5303 | if 1 |
742 | Rus | 5304 | mov word [OS_BASE+0x467+0],pr_mode_exit |
5305 | mov word [OS_BASE+0x467+2],0x1000 |
||
1 | ha | 5306 | |
742 | Rus | 5307 | mov al,0x0F |
5308 | out 0x70,al |
||
5309 | mov al,0x05 |
||
5310 | out 0x71,al |
||
1 | ha | 5311 | |
742 | Rus | 5312 | mov al,0xFE |
5313 | out 0x64,al |
||
709 | diamond | 5314 | |
742 | Rus | 5315 | hlt |
1 | ha | 5316 | |
709 | diamond | 5317 | else |
742 | Rus | 5318 | cmp byte [OS_BASE + 0x9030], 2 |
5319 | jnz no_acpi_power_off |
||
1 | ha | 5320 | |
709 | diamond | 5321 | ; scan for RSDP |
5322 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
||
742 | Rus | 5323 | movzx eax, word [OS_BASE + 0x40E] |
5324 | shl eax, 4 |
||
5325 | jz @f |
||
5326 | mov ecx, 1024/16 |
||
5327 | call scan_rsdp |
||
5328 | jnc .rsdp_found |
||
709 | diamond | 5329 | @@: |
5330 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
||
742 | Rus | 5331 | mov eax, 0xE0000 |
5332 | mov ecx, 0x2000 |
||
5333 | call scan_rsdp |
||
5334 | jc no_acpi_power_off |
||
709 | diamond | 5335 | .rsdp_found: |
742 | Rus | 5336 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5337 | mov ebp, [ipc_tmp] |
||
5338 | stdcall map_page, ebp, esi, PG_MAP |
||
5339 | lea eax, [esi+1000h] |
||
5340 | lea edx, [ebp+1000h] |
||
5341 | stdcall map_page, edx, eax, PG_MAP |
||
5342 | and esi, 0xFFF |
||
5343 | add esi, ebp |
||
5344 | cmp dword [esi], 'RSDT' |
||
5345 | jnz no_acpi_power_off |
||
5346 | mov ecx, [esi+4] |
||
5347 | sub ecx, 24h |
||
5348 | jbe no_acpi_power_off |
||
5349 | shr ecx, 2 |
||
5350 | add esi, 24h |
||
709 | diamond | 5351 | .scan_fadt: |
742 | Rus | 5352 | lodsd |
5353 | mov ebx, eax |
||
5354 | lea eax, [ebp+2000h] |
||
5355 | stdcall map_page, eax, ebx, PG_MAP |
||
5356 | lea eax, [ebp+3000h] |
||
5357 | add ebx, 0x1000 |
||
5358 | stdcall map_page, eax, ebx, PG_MAP |
||
5359 | and ebx, 0xFFF |
||
5360 | lea ebx, [ebx+ebp+2000h] |
||
5361 | cmp dword [ebx], 'FACP' |
||
5362 | jz .fadt_found |
||
5363 | loop .scan_fadt |
||
5364 | jmp no_acpi_power_off |
||
709 | diamond | 5365 | .fadt_found: |
5366 | ; ebx is linear address of FADT |
||
742 | Rus | 5367 | mov edx, [ebx+48] |
5368 | test edx, edx |
||
5369 | jz .nosmi |
||
5370 | mov al, [ebx+52] |
||
5371 | out dx, al |
||
5372 | mov edx, [ebx+64] |
||
709 | diamond | 5373 | @@: |
742 | Rus | 5374 | in ax, dx |
5375 | test al, 1 |
||
5376 | jz @b |
||
709 | diamond | 5377 | .nosmi: |
742 | Rus | 5378 | mov edx, [ebx+64] |
5379 | in ax, dx |
||
5380 | and ax, 203h |
||
5381 | or ax, 3C00h |
||
5382 | out dx, ax |
||
5383 | mov edx, [ebx+68] |
||
5384 | test edx, edx |
||
5385 | jz @f |
||
5386 | in ax, dx |
||
5387 | and ax, 203h |
||
5388 | or ax, 3C00h |
||
5389 | out dx, ax |
||
709 | diamond | 5390 | @@: |
742 | Rus | 5391 | jmp $ |
709 | diamond | 5392 | |
5393 | |||
5394 | no_acpi_power_off: |
||
742 | Rus | 5395 | mov word [OS_BASE+0x467+0],pr_mode_exit |
5396 | mov word [OS_BASE+0x467+2],0x1000 |
||
709 | diamond | 5397 | |
742 | Rus | 5398 | mov al,0x0F |
5399 | out 0x70,al |
||
5400 | mov al,0x05 |
||
5401 | out 0x71,al |
||
709 | diamond | 5402 | |
742 | Rus | 5403 | mov al,0xFE |
5404 | out 0x64,al |
||
709 | diamond | 5405 | |
742 | Rus | 5406 | hlt |
709 | diamond | 5407 | |
5408 | scan_rsdp: |
||
742 | Rus | 5409 | add eax, OS_BASE |
709 | diamond | 5410 | .s: |
742 | Rus | 5411 | cmp dword [eax], 'RSD ' |
5412 | jnz .n |
||
5413 | cmp dword [eax+4], 'PTR ' |
||
5414 | jnz .n |
||
5415 | xor edx, edx |
||
5416 | xor esi, esi |
||
709 | diamond | 5417 | @@: |
742 | Rus | 5418 | add dl, [eax+esi] |
5419 | inc esi |
||
5420 | cmp esi, 20 |
||
5421 | jnz @b |
||
5422 | test dl, dl |
||
5423 | jz .ok |
||
709 | diamond | 5424 | .n: |
742 | Rus | 5425 | add eax, 10h |
5426 | loop .s |
||
5427 | stc |
||
709 | diamond | 5428 | .ok: |
742 | Rus | 5429 | ret |
709 | diamond | 5430 | end if |
5431 | |||
465 | serge | 5432 | include "data32.inc" |
1 | ha | 5433 | |
465 | serge | 5434 | __REV__ = __REV |
1 | ha | 5435 | |
5436 | uglobals_size = $ - endofcode |
||
41 | mikedld | 5437 | diff16 "end of kernel code",0,$=> |
426 | mikedld | 5438 |