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