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