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