Rev 6593 | Rev 6817 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6593 | Rev 6800 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. |
4 | ;; PROGRAMMING: |
4 | ;; PROGRAMMING: |
5 | ;; Ivan Poddubny |
5 | ;; Ivan Poddubny |
6 | ;; Marat Zakiyanov (Mario79) |
6 | ;; Marat Zakiyanov (Mario79) |
7 | ;; VaStaNi |
7 | ;; VaStaNi |
8 | ;; Trans |
8 | ;; Trans |
9 | ;; Mihail Semenyako (mike.dld) |
9 | ;; Mihail Semenyako (mike.dld) |
10 | ;; Sergey Kuzmin (Wildwest) |
10 | ;; Sergey Kuzmin (Wildwest) |
11 | ;; Andrey Halyavin (halyavin) |
11 | ;; Andrey Halyavin (halyavin) |
12 | ;; Mihail Lisovin (Mihasik) |
12 | ;; Mihail Lisovin (Mihasik) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
14 | ;; NoName |
14 | ;; NoName |
15 | ;; Evgeny Grechnikov (Diamond) |
15 | ;; Evgeny Grechnikov (Diamond) |
16 | ;; Iliya Mihailov (Ghost) |
16 | ;; Iliya Mihailov (Ghost) |
17 | ;; Sergey Semyonov (Serge) |
17 | ;; Sergey Semyonov (Serge) |
18 | ;; Johnny_B |
18 | ;; Johnny_B |
19 | ;; SPraid (simba) |
19 | ;; SPraid (simba) |
20 | ;; Hidnplayr |
20 | ;; Hidnplayr |
21 | ;; Alexey Teplov ( |
21 | ;; Alexey Teplov ( |
22 | ;; Rus |
22 | ;; Rus |
23 | ;; Nable |
23 | ;; Nable |
24 | ;; shurf |
24 | ;; shurf |
25 | ;; Alver |
25 | ;; Alver |
26 | ;; Maxis |
26 | ;; Maxis |
27 | ;; Galkov |
27 | ;; Galkov |
28 | ;; CleverMouse |
28 | ;; CleverMouse |
29 | ;; tsdima |
29 | ;; tsdima |
30 | ;; turbanoff |
30 | ;; turbanoff |
31 | ;; Asper |
31 | ;; Asper |
32 | ;; art_zh |
32 | ;; art_zh |
33 | ;; |
33 | ;; |
34 | ;; Data in this file was originally part of MenuetOS project which is |
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 |
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. |
36 | ;; part of KolibriOS project under the terms of GNU GPL. |
37 | ;; |
37 | ;; |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
39 | ;; PROGRAMMING: |
39 | ;; PROGRAMMING: |
40 | ;; |
40 | ;; |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
42 | ;; - main os coding/design |
42 | ;; - main os coding/design |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
46 | ;; quickcode@mail.ru |
46 | ;; quickcode@mail.ru |
47 | ;; Alexey, kgaz@crosswinds.net |
47 | ;; Alexey, kgaz@crosswinds.net |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
49 | ;; kristol@nic.fi |
49 | ;; kristol@nic.fi |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
53 | ;; |
53 | ;; |
54 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
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 |
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 |
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 |
57 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
58 | ;; License (the "GPL") for full details. |
58 | ;; License (the "GPL") for full details. |
59 | ; |
59 | ; |
60 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
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 |
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 |
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. |
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 |
64 | ;; Among other things, the copyright notice and this notice must be preserved |
65 | ;; on all copies. |
65 | ;; on all copies. |
66 | ;; |
66 | ;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
68 | 68 | ||
69 | format binary as "mnt" |
69 | format binary as "mnt" |
70 | 70 | ||
71 | include 'macros.inc' |
71 | include 'macros.inc' |
72 | include 'struct.inc' |
72 | include 'struct.inc' |
73 | 73 | ||
74 | $Revision: 6593 $ |
74 | $Revision: 6800 $ |
75 | 75 | ||
76 | 76 | ||
77 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
77 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
78 | VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions |
78 | VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions |
79 | 79 | ||
80 | ; Enabling the next line will enable serial output console |
80 | ; Enabling the next line will enable serial output console |
81 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
81 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
82 | 82 | ||
83 | include "proc32.inc" |
83 | include "proc32.inc" |
84 | include "kglobals.inc" |
84 | include "kglobals.inc" |
85 | include "lang.inc" |
85 | include "lang.inc" |
86 | include "encoding.inc" |
86 | include "encoding.inc" |
87 | 87 | ||
88 | include "const.inc" |
88 | include "const.inc" |
89 | 89 | ||
90 | iglobal |
90 | iglobal |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
92 | debug_direct_print db 0 |
92 | debug_direct_print db 0 |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
94 | launcher_start db 1 |
94 | launcher_start db 1 |
95 | endg |
95 | endg |
96 | 96 | ||
97 | max_processes equ 255 |
97 | max_processes equ 255 |
98 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
98 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
99 | 99 | ||
100 | os_stack equ (os_data_l-gdts) ; GDTs |
100 | os_stack equ (os_data_l-gdts) ; GDTs |
101 | os_code equ (os_code_l-gdts) |
101 | os_code equ (os_code_l-gdts) |
102 | graph_data equ (3+graph_data_l-gdts) |
102 | graph_data equ (3+graph_data_l-gdts) |
103 | tss0 equ (tss0_l-gdts) |
103 | tss0 equ (tss0_l-gdts) |
104 | app_code equ (3+app_code_l-gdts) |
104 | app_code equ (3+app_code_l-gdts) |
105 | app_data equ (3+app_data_l-gdts) |
105 | app_data equ (3+app_data_l-gdts) |
106 | app_tls equ (3+tls_data_l-gdts) |
106 | app_tls equ (3+tls_data_l-gdts) |
107 | pci_code_sel equ (pci_code_32-gdts) |
107 | pci_code_sel equ (pci_code_32-gdts) |
108 | pci_data_sel equ (pci_data_32-gdts) |
108 | pci_data_sel equ (pci_data_32-gdts) |
109 | 109 | ||
110 | 110 | ||
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
112 | ;; |
112 | ;; |
113 | ;; Included files: |
113 | ;; Included files: |
114 | ;; |
114 | ;; |
115 | ;; Kernel16.inc |
115 | ;; Kernel16.inc |
116 | ;; - Booteng.inc English text for bootup |
116 | ;; - Booteng.inc English text for bootup |
117 | ;; - Bootcode.inc Hardware setup |
117 | ;; - Bootcode.inc Hardware setup |
118 | ;; - Pci16.inc PCI functions |
118 | ;; - Pci16.inc PCI functions |
119 | ;; |
119 | ;; |
120 | ;; Kernel32.inc |
120 | ;; Kernel32.inc |
121 | ;; - Sys32.inc Process management |
121 | ;; - Sys32.inc Process management |
122 | ;; - Shutdown.inc Shutdown and restart |
122 | ;; - Shutdown.inc Shutdown and restart |
123 | ;; - Fat32.inc Read / write hd |
123 | ;; - Fat32.inc Read / write hd |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
126 | ;; - Vga.inc VGA driver |
126 | ;; - Vga.inc VGA driver |
127 | ;; - Stack.inc Network interface |
127 | ;; - Stack.inc Network interface |
128 | ;; - Mouse.inc Mouse pointer |
128 | ;; - Mouse.inc Mouse pointer |
129 | ;; - Scincode.inc Window skinning |
129 | ;; - Scincode.inc Window skinning |
130 | ;; - Pci32.inc PCI functions |
130 | ;; - Pci32.inc PCI functions |
131 | ;; |
131 | ;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
133 | 133 | ||
134 | 134 | ||
135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
136 | ;; ;; |
136 | ;; ;; |
137 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
137 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
138 | ;; ;; |
138 | ;; ;; |
139 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
139 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
140 | 140 | ||
141 | use16 |
141 | use16 |
142 | org 0x0 |
142 | org 0x0 |
143 | jmp start_of_code |
143 | jmp start_of_code |
144 | 144 | ||
145 | if lang eq sp |
145 | if lang eq sp |
146 | include "kernelsp.inc" ; spanish kernel messages |
146 | include "kernelsp.inc" ; spanish kernel messages |
147 | else if lang eq et |
147 | else if lang eq et |
148 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
148 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
149 | else |
149 | else |
150 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
150 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
151 | end if |
151 | end if |
152 | 152 | ||
153 | include "boot/bootstr.inc" ; language-independent boot messages |
153 | include "boot/bootstr.inc" ; language-independent boot messages |
154 | include "boot/preboot.inc" |
154 | include "boot/preboot.inc" |
155 | 155 | ||
156 | if lang eq ge |
156 | if lang eq ge |
157 | include "boot/bootge.inc" ; german system boot messages |
157 | include "boot/bootge.inc" ; german system boot messages |
158 | else if lang eq sp |
158 | else if lang eq sp |
159 | include "boot/bootsp.inc" ; spanish system boot messages |
159 | include "boot/bootsp.inc" ; spanish system boot messages |
160 | else if lang eq ru |
160 | else if lang eq ru |
161 | include "boot/bootru.inc" ; russian system boot messages |
161 | include "boot/bootru.inc" ; russian system boot messages |
162 | include "boot/ru.inc" ; Russian font |
162 | include "boot/ru.inc" ; Russian font |
163 | else if lang eq et |
163 | else if lang eq et |
164 | include "boot/bootet.inc" ; estonian system boot messages |
164 | include "boot/bootet.inc" ; estonian system boot messages |
165 | include "boot/et.inc" ; Estonian font |
165 | include "boot/et.inc" ; Estonian font |
166 | else |
166 | else |
167 | include "boot/booten.inc" ; english system boot messages |
167 | include "boot/booten.inc" ; english system boot messages |
168 | end if |
168 | end if |
169 | 169 | ||
170 | include "boot/bootcode.inc" ; 16 bit system boot code |
170 | include "boot/bootcode.inc" ; 16 bit system boot code |
171 | include "bus/pci/pci16.inc" |
171 | include "bus/pci/pci16.inc" |
172 | include "detect/biosdisk.inc" |
172 | include "detect/biosdisk.inc" |
173 | 173 | ||
174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
175 | ;; ;; |
175 | ;; ;; |
176 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
176 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
177 | ;; ;; |
177 | ;; ;; |
178 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
178 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
179 | 179 | ||
180 | 180 | ||
181 | ; CR0 Flags - Protected mode and Paging |
181 | ; CR0 Flags - Protected mode and Paging |
182 | 182 | ||
183 | mov ecx, CR0_PE |
183 | mov ecx, CR0_PE |
184 | 184 | ||
185 | ; Enabling 32 bit protected mode |
185 | ; Enabling 32 bit protected mode |
186 | 186 | ||
187 | sidt [cs:old_ints_h] |
187 | sidt [cs:old_ints_h] |
188 | 188 | ||
189 | cli ; disable all irqs |
189 | cli ; disable all irqs |
190 | cld |
190 | cld |
191 | mov al, 255 ; mask all irqs |
191 | mov al, 255 ; mask all irqs |
192 | out 0xa1, al |
192 | out 0xa1, al |
193 | out 0x21, al |
193 | out 0x21, al |
194 | l.5: |
194 | l.5: |
195 | in al, 0x64 ; Enable A20 |
195 | in al, 0x64 ; Enable A20 |
196 | test al, 2 |
196 | test al, 2 |
197 | jnz l.5 |
197 | jnz l.5 |
198 | mov al, 0xD1 |
198 | mov al, 0xD1 |
199 | out 0x64, al |
199 | out 0x64, al |
200 | l.6: |
200 | l.6: |
201 | in al, 0x64 |
201 | in al, 0x64 |
202 | test al, 2 |
202 | test al, 2 |
203 | jnz l.6 |
203 | jnz l.6 |
204 | mov al, 0xDF |
204 | mov al, 0xDF |
205 | out 0x60, al |
205 | out 0x60, al |
206 | l.7: |
206 | l.7: |
207 | in al, 0x64 |
207 | in al, 0x64 |
208 | test al, 2 |
208 | test al, 2 |
209 | jnz l.7 |
209 | jnz l.7 |
210 | mov al, 0xFF |
210 | mov al, 0xFF |
211 | out 0x64, al |
211 | out 0x64, al |
212 | 212 | ||
213 | lgdt [cs:tmp_gdt] ; Load GDT |
213 | lgdt [cs:tmp_gdt] ; Load GDT |
214 | mov eax, cr0 ; protected mode |
214 | mov eax, cr0 ; protected mode |
215 | or eax, ecx |
215 | or eax, ecx |
216 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
216 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
217 | mov cr0, eax |
217 | mov cr0, eax |
218 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
218 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
219 | 219 | ||
220 | align 8 |
220 | align 8 |
221 | tmp_gdt: |
221 | tmp_gdt: |
222 | 222 | ||
223 | dw 23 |
223 | dw 23 |
224 | dd tmp_gdt+0x10000 |
224 | dd tmp_gdt+0x10000 |
225 | dw 0 |
225 | dw 0 |
226 | 226 | ||
227 | dw 0xffff |
227 | dw 0xffff |
228 | dw 0x0000 |
228 | dw 0x0000 |
229 | db 0x00 |
229 | db 0x00 |
230 | dw 11011111b *256 +10011010b |
230 | dw 11011111b *256 +10011010b |
231 | db 0x00 |
231 | db 0x00 |
232 | 232 | ||
233 | dw 0xffff |
233 | dw 0xffff |
234 | dw 0x0000 |
234 | dw 0x0000 |
235 | db 0x00 |
235 | db 0x00 |
236 | dw 11011111b *256 +10010010b |
236 | dw 11011111b *256 +10010010b |
237 | db 0x00 |
237 | db 0x00 |
238 | 238 | ||
239 | include "data16.inc" |
239 | include "data16.inc" |
240 | 240 | ||
241 | if ~ lang eq sp |
241 | if ~ lang eq sp |
242 | diff16 "end of bootcode",0,$+0x10000 |
242 | diff16 "end of bootcode",0,$+0x10000 |
243 | end if |
243 | end if |
244 | 244 | ||
245 | use32 |
245 | use32 |
246 | org $+0x10000 |
246 | org $+0x10000 |
247 | 247 | ||
248 | align 4 |
248 | align 4 |
249 | B32: |
249 | B32: |
250 | mov ax, os_stack ; Selector for os |
250 | mov ax, os_stack ; Selector for os |
251 | mov ds, ax |
251 | mov ds, ax |
252 | mov es, ax |
252 | mov es, ax |
253 | mov fs, ax |
253 | mov fs, ax |
254 | mov gs, ax |
254 | mov gs, ax |
255 | mov ss, ax |
255 | mov ss, ax |
256 | mov esp, TMP_STACK_TOP ; Set stack |
256 | mov esp, TMP_STACK_TOP ; Set stack |
257 | 257 | ||
258 | ; CLEAR 0x280000 - HEAP_BASE |
258 | ; CLEAR 0x280000 - HEAP_BASE |
259 | 259 | ||
260 | xor eax, eax |
260 | xor eax, eax |
261 | mov edi, CLEAN_ZONE |
261 | mov edi, CLEAN_ZONE |
262 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
262 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
263 | cld |
263 | cld |
264 | rep stosd |
264 | rep stosd |
265 | 265 | ||
266 | ; CLEAR KERNEL UNDEFINED GLOBALS |
266 | ; CLEAR KERNEL UNDEFINED GLOBALS |
267 | mov edi, endofcode-OS_BASE |
267 | mov edi, endofcode-OS_BASE |
268 | mov ecx, 0x90000 |
268 | mov ecx, 0x90000 |
269 | sub ecx, edi |
269 | sub ecx, edi |
270 | shr ecx, 2 |
270 | shr ecx, 2 |
271 | rep stosd |
271 | rep stosd |
272 | 272 | ||
273 | ; SAVE & CLEAR 0-0xffff |
273 | ; SAVE & CLEAR 0-0xffff |
274 | 274 | ||
275 | mov edi, 0x1000 |
275 | mov edi, 0x1000 |
276 | mov ecx, 0x8000 / 4 |
276 | mov ecx, 0x8000 / 4 |
277 | rep stosd |
277 | rep stosd |
278 | mov edi, 0xa000 |
278 | mov edi, 0xa000 |
279 | mov ecx, 0x6000 / 4 |
279 | mov ecx, 0x6000 / 4 |
280 | rep stosd |
280 | rep stosd |
281 | 281 | ||
282 | call test_cpu |
282 | call test_cpu |
283 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
283 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
284 | 284 | ||
285 | call check_acpi |
285 | call check_acpi |
286 | call init_hpet |
286 | call init_hpet |
287 | call init_BIOS32 |
287 | call init_BIOS32 |
288 | ; MEMORY MODEL |
288 | ; MEMORY MODEL |
289 | call mem_test |
289 | call mem_test |
290 | call init_mem |
290 | call init_mem |
291 | call init_page_map |
291 | call init_page_map |
292 | 292 | ||
293 | ; ENABLE PAGING |
293 | ; ENABLE PAGING |
294 | 294 | ||
295 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
295 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
296 | mov cr3, eax |
296 | mov cr3, eax |
297 | 297 | ||
298 | mov eax, cr0 |
298 | mov eax, cr0 |
299 | or eax, CR0_PG+CR0_WP |
299 | or eax, CR0_PG+CR0_WP |
300 | mov cr0, eax |
300 | mov cr0, eax |
301 | 301 | ||
302 | lgdt [gdts] |
302 | lgdt [gdts] |
303 | jmp pword os_code:high_code |
303 | jmp pword os_code:high_code |
304 | 304 | ||
305 | align 4 |
305 | align 4 |
306 | bios32_entry dd ? |
306 | bios32_entry dd ? |
307 | tmp_page_tabs dd ? |
307 | tmp_page_tabs dd ? |
308 | use16 |
308 | use16 |
309 | ap_init16: |
309 | ap_init16: |
310 | cli |
310 | cli |
311 | lgdt [cs:gdts_ap-ap_init16] |
311 | lgdt [cs:gdts_ap-ap_init16] |
312 | mov eax, [cs:cr3_ap-ap_init16] |
312 | mov eax, [cs:cr3_ap-ap_init16] |
313 | mov cr3, eax |
313 | mov cr3, eax |
314 | mov eax, [cs:cr4_ap-ap_init16] |
314 | mov eax, [cs:cr4_ap-ap_init16] |
315 | mov cr4, eax |
315 | mov cr4, eax |
316 | mov eax, CR0_PE+CR0_PG+CR0_WP |
316 | mov eax, CR0_PE+CR0_PG+CR0_WP |
317 | mov cr0, eax |
317 | mov cr0, eax |
318 | jmp pword os_code:ap_init_high |
318 | jmp pword os_code:ap_init_high |
319 | align 16 |
319 | align 16 |
320 | gdts_ap: |
320 | gdts_ap: |
321 | dw gdte-gdts-1 |
321 | dw gdte-gdts-1 |
322 | dd gdts |
322 | dd gdts |
323 | dw 0 |
323 | dw 0 |
324 | cr3_ap dd ? |
324 | cr3_ap dd ? |
325 | cr4_ap dd ? |
325 | cr4_ap dd ? |
326 | ap_init16_size = $ - ap_init16 |
326 | ap_init16_size = $ - ap_init16 |
327 | use32 |
327 | use32 |
328 | 328 | ||
329 | __DEBUG__ fix 1 |
329 | __DEBUG__ fix 1 |
330 | __DEBUG_LEVEL__ fix 1 |
330 | __DEBUG_LEVEL__ fix 1 |
331 | include 'init.inc' |
331 | include 'init.inc' |
332 | 332 | ||
333 | org OS_BASE+$ |
333 | org OS_BASE+$ |
334 | 334 | ||
335 | include 'fdo.inc' |
335 | include 'fdo.inc' |
336 | 336 | ||
337 | align 4 |
337 | align 4 |
338 | high_code: |
338 | high_code: |
339 | mov ax, os_stack |
339 | mov ax, os_stack |
340 | mov bx, app_data |
340 | mov bx, app_data |
341 | mov cx, app_tls |
341 | mov cx, app_tls |
342 | mov ss, ax |
342 | mov ss, ax |
343 | add esp, OS_BASE |
343 | add esp, OS_BASE |
344 | 344 | ||
345 | mov ds, bx |
345 | mov ds, bx |
346 | mov es, bx |
346 | mov es, bx |
347 | mov fs, cx |
347 | mov fs, cx |
348 | mov gs, bx |
348 | mov gs, bx |
349 | 349 | ||
350 | xor eax, eax |
350 | xor eax, eax |
351 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
351 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
352 | bt [cpu_caps], CAPS_PAT |
352 | bt [cpu_caps], CAPS_PAT |
353 | setc al |
353 | setc al |
354 | shl eax, 7 |
354 | shl eax, 7 |
355 | or ebx, eax |
355 | or ebx, eax |
356 | 356 | ||
357 | mov eax, PG_GLOBAL |
357 | mov eax, PG_GLOBAL |
358 | bt [cpu_caps], CAPS_PGE |
358 | bt [cpu_caps], CAPS_PGE |
359 | jnc @F |
359 | jnc @F |
360 | 360 | ||
361 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
361 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
362 | or ebx, eax |
362 | or ebx, eax |
363 | 363 | ||
364 | mov eax, cr4 |
364 | mov eax, cr4 |
365 | or eax, CR4_PGE |
365 | or eax, CR4_PGE |
366 | mov cr4, eax |
366 | mov cr4, eax |
367 | @@: |
367 | @@: |
368 | mov [pte_valid_mask], ebx |
368 | mov [pte_valid_mask], ebx |
369 | 369 | ||
370 | xor eax, eax |
370 | xor eax, eax |
371 | mov dword [sys_proc+PROC.pdt_0], eax |
371 | mov dword [sys_proc+PROC.pdt_0], eax |
372 | mov dword [sys_proc+PROC.pdt_0+4], eax |
372 | mov dword [sys_proc+PROC.pdt_0+4], eax |
373 | 373 | ||
374 | mov eax, cr3 |
374 | mov eax, cr3 |
375 | mov cr3, eax ; flush TLB |
375 | mov cr3, eax ; flush TLB |
376 | 376 | ||
377 | mov ecx, pg_data.mutex |
377 | mov ecx, pg_data.mutex |
378 | call mutex_init |
378 | call mutex_init |
379 | 379 | ||
380 | mov ecx, disk_list_mutex |
380 | mov ecx, disk_list_mutex |
381 | call mutex_init |
381 | call mutex_init |
382 | 382 | ||
383 | mov ecx, keyboard_list_mutex |
383 | mov ecx, keyboard_list_mutex |
384 | call mutex_init |
384 | call mutex_init |
385 | 385 | ||
386 | mov ecx, unpack_mutex |
386 | mov ecx, unpack_mutex |
387 | call mutex_init |
387 | call mutex_init |
388 | 388 | ||
389 | mov ecx, application_table_mutex |
389 | mov ecx, application_table_mutex |
390 | call mutex_init |
390 | call mutex_init |
391 | 391 | ||
392 | mov ecx, ide_mutex |
392 | mov ecx, ide_mutex |
393 | call mutex_init |
393 | call mutex_init |
394 | mov ecx, ide_channel1_mutex |
394 | mov ecx, ide_channel1_mutex |
395 | call mutex_init |
395 | call mutex_init |
396 | mov ecx, ide_channel2_mutex |
396 | mov ecx, ide_channel2_mutex |
397 | call mutex_init |
397 | call mutex_init |
398 | mov ecx, ide_channel3_mutex |
398 | mov ecx, ide_channel3_mutex |
399 | call mutex_init |
399 | call mutex_init |
400 | mov ecx, ide_channel4_mutex |
400 | mov ecx, ide_channel4_mutex |
401 | call mutex_init |
401 | call mutex_init |
402 | mov ecx, ide_channel5_mutex |
402 | mov ecx, ide_channel5_mutex |
403 | call mutex_init |
403 | call mutex_init |
404 | mov ecx, ide_channel6_mutex |
404 | mov ecx, ide_channel6_mutex |
405 | call mutex_init |
405 | call mutex_init |
406 | ;----------------------------------------------------------------------------- |
406 | ;----------------------------------------------------------------------------- |
407 | ; SAVE REAL MODE VARIABLES |
407 | ; SAVE REAL MODE VARIABLES |
408 | ;----------------------------------------------------------------------------- |
408 | ;----------------------------------------------------------------------------- |
409 | ; --------------- APM --------------------- |
409 | ; --------------- APM --------------------- |
410 | 410 | ||
411 | ; init selectors |
411 | ; init selectors |
412 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
412 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
413 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
413 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
414 | ; protected-mode 32-bit code segment |
414 | ; protected-mode 32-bit code segment |
415 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
415 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
416 | ; protected-mode 16-bit code segment |
416 | ; protected-mode 16-bit code segment |
417 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
417 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
418 | ; protected-mode 16-bit data segment |
418 | ; protected-mode 16-bit data segment |
419 | 419 | ||
420 | shl eax, 4 |
420 | shl eax, 4 |
421 | mov [dword apm_code_32 + 2], ax |
421 | mov [dword apm_code_32 + 2], ax |
422 | shr eax, 16 |
422 | shr eax, 16 |
423 | mov [dword apm_code_32 + 4], al |
423 | mov [dword apm_code_32 + 4], al |
424 | 424 | ||
425 | shl ecx, 4 |
425 | shl ecx, 4 |
426 | mov [dword apm_code_16 + 2], cx |
426 | mov [dword apm_code_16 + 2], cx |
427 | shr ecx, 16 |
427 | shr ecx, 16 |
428 | mov [dword apm_code_16 + 4], cl |
428 | mov [dword apm_code_16 + 4], cl |
429 | 429 | ||
430 | shl edx, 4 |
430 | shl edx, 4 |
431 | mov [dword apm_data_16 + 2], dx |
431 | mov [dword apm_data_16 + 2], dx |
432 | shr edx, 16 |
432 | shr edx, 16 |
433 | mov [dword apm_data_16 + 4], dl |
433 | mov [dword apm_data_16 + 4], dl |
434 | 434 | ||
435 | mov dword[apm_entry], ebx |
435 | mov dword[apm_entry], ebx |
436 | mov word [apm_entry + 4], apm_code_32 - gdts |
436 | mov word [apm_entry + 4], apm_code_32 - gdts |
437 | 437 | ||
438 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
438 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
439 | mov [apm_vf], eax |
439 | mov [apm_vf], eax |
440 | ; ----------------------------------------- |
440 | ; ----------------------------------------- |
441 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
441 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
442 | mov [allow_dma_access], al |
442 | mov [allow_dma_access], al |
443 | 443 | ||
444 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
444 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
445 | mov [debug_direct_print], al |
445 | mov [debug_direct_print], al |
446 | 446 | ||
447 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
447 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
448 | mov [launcher_start], al |
448 | mov [launcher_start], al |
449 | 449 | ||
450 | mov esi, BOOT_VARS+0x9080 |
450 | mov esi, BOOT_VARS+0x9080 |
451 | movzx ecx, byte [esi-1] |
451 | movzx ecx, byte [esi-1] |
452 | mov [NumBiosDisks], ecx |
452 | mov [NumBiosDisks], ecx |
453 | mov edi, BiosDisksData |
453 | mov edi, BiosDisksData |
454 | rep movsd |
454 | rep movsd |
455 | 455 | ||
456 | ; -------- Fast System Call init ---------- |
456 | ; -------- Fast System Call init ---------- |
457 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
457 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
458 | bt [cpu_caps], CAPS_SEP |
458 | bt [cpu_caps], CAPS_SEP |
459 | jnc .SEnP ; SysEnter not Present |
459 | jnc .SEnP ; SysEnter not Present |
460 | xor edx, edx |
460 | xor edx, edx |
461 | mov ecx, MSR_SYSENTER_CS |
461 | mov ecx, MSR_SYSENTER_CS |
462 | mov eax, os_code |
462 | mov eax, os_code |
463 | wrmsr |
463 | wrmsr |
464 | mov ecx, MSR_SYSENTER_ESP |
464 | mov ecx, MSR_SYSENTER_ESP |
465 | ; mov eax, sysenter_stack ; Check it |
465 | ; mov eax, sysenter_stack ; Check it |
466 | xor eax, eax |
466 | xor eax, eax |
467 | wrmsr |
467 | wrmsr |
468 | mov ecx, MSR_SYSENTER_EIP |
468 | mov ecx, MSR_SYSENTER_EIP |
469 | mov eax, sysenter_entry |
469 | mov eax, sysenter_entry |
470 | wrmsr |
470 | wrmsr |
471 | .SEnP: |
471 | .SEnP: |
472 | ; AMD SYSCALL/SYSRET |
472 | ; AMD SYSCALL/SYSRET |
473 | cmp byte[cpu_vendor], 'A' |
473 | cmp byte[cpu_vendor], 'A' |
474 | jne .noSYSCALL |
474 | jne .noSYSCALL |
475 | mov eax, 0x80000001 |
475 | mov eax, 0x80000001 |
476 | cpuid |
476 | cpuid |
477 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
477 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
478 | jz .noSYSCALL |
478 | jz .noSYSCALL |
479 | mov ecx, MSR_AMD_EFER |
479 | mov ecx, MSR_AMD_EFER |
480 | rdmsr |
480 | rdmsr |
481 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
481 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
482 | wrmsr |
482 | wrmsr |
483 | 483 | ||
484 | ; !!!! It`s dirty hack, fix it !!! |
484 | ; !!!! It`s dirty hack, fix it !!! |
485 | ; Bits of EDX : |
485 | ; Bits of EDX : |
486 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
486 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
487 | ; and the contents of this field, plus 8, are copied into the SS register. |
487 | ; and the contents of this field, plus 8, are copied into the SS register. |
488 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
488 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
489 | ; and the contents of this field, plus 8, are copied into the SS register. |
489 | ; and the contents of this field, plus 8, are copied into the SS register. |
490 | 490 | ||
491 | ; mov edx, (os_code + 16) * 65536 + os_code |
491 | ; mov edx, (os_code + 16) * 65536 + os_code |
492 | mov edx, 0x1B0008 |
492 | mov edx, 0x1B0008 |
493 | 493 | ||
494 | mov eax, syscall_entry |
494 | mov eax, syscall_entry |
495 | mov ecx, MSR_AMD_STAR |
495 | mov ecx, MSR_AMD_STAR |
496 | wrmsr |
496 | wrmsr |
497 | .noSYSCALL: |
497 | .noSYSCALL: |
498 | ; ----------------------------------------- |
498 | ; ----------------------------------------- |
499 | stdcall alloc_page |
499 | stdcall alloc_page |
500 | stdcall map_page, tss-0xF80, eax, PG_SWR |
500 | stdcall map_page, tss-0xF80, eax, PG_SWR |
501 | stdcall alloc_page |
501 | stdcall alloc_page |
502 | stdcall map_page, tss+0x80, eax, PG_SWR |
502 | stdcall map_page, tss+0x80, eax, PG_SWR |
503 | stdcall alloc_page |
503 | stdcall alloc_page |
504 | stdcall map_page, tss+0x1080, eax, PG_SWR |
504 | stdcall map_page, tss+0x1080, eax, PG_SWR |
505 | 505 | ||
506 | ; LOAD IDT |
506 | ; LOAD IDT |
507 | 507 | ||
508 | call build_interrupt_table ;lidt is executed |
508 | call build_interrupt_table ;lidt is executed |
509 | ;lidt [idtreg] |
509 | ;lidt [idtreg] |
510 | 510 | ||
511 | call init_kernel_heap |
511 | call init_kernel_heap |
512 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
512 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
513 | mov [os_stack_seg], eax |
513 | mov [os_stack_seg], eax |
514 | 514 | ||
515 | lea esp, [eax+RING0_STACK_SIZE] |
515 | lea esp, [eax+RING0_STACK_SIZE] |
516 | 516 | ||
517 | mov [tss._ss0], os_stack |
517 | mov [tss._ss0], os_stack |
518 | mov [tss._esp0], esp |
518 | mov [tss._esp0], esp |
519 | mov [tss._esp], esp |
519 | mov [tss._esp], esp |
520 | mov [tss._cs], os_code |
520 | mov [tss._cs], os_code |
521 | mov [tss._ss], os_stack |
521 | mov [tss._ss], os_stack |
522 | mov [tss._ds], app_data |
522 | mov [tss._ds], app_data |
523 | mov [tss._es], app_data |
523 | mov [tss._es], app_data |
524 | mov [tss._fs], app_data |
524 | mov [tss._fs], app_data |
525 | mov [tss._gs], app_data |
525 | mov [tss._gs], app_data |
526 | mov [tss._io], 128 |
526 | mov [tss._io], 128 |
527 | ;Add IO access table - bit array of permitted ports |
527 | ;Add IO access table - bit array of permitted ports |
528 | mov edi, tss._io_map_0 |
528 | mov edi, tss._io_map_0 |
529 | xor eax, eax |
529 | xor eax, eax |
530 | not eax |
530 | not eax |
531 | mov ecx, 8192/4 |
531 | mov ecx, 8192/4 |
532 | rep stosd ; access to 4096*8=65536 ports |
532 | rep stosd ; access to 4096*8=65536 ports |
533 | 533 | ||
534 | mov ax, tss0 |
534 | mov ax, tss0 |
535 | ltr ax |
535 | ltr ax |
536 | 536 | ||
537 | mov eax, sys_proc |
537 | mov eax, sys_proc |
538 | list_init eax |
538 | list_init eax |
539 | add eax, PROC.thr_list |
539 | add eax, PROC.thr_list |
540 | list_init eax |
540 | list_init eax |
541 | 541 | ||
542 | call init_video |
542 | call init_video |
543 | call init_mtrr |
543 | call init_mtrr |
544 | mov [LFBAddress], LFB_BASE |
544 | mov [LFBAddress], LFB_BASE |
545 | mov ecx, bios_fb |
545 | mov ecx, bios_fb |
546 | call set_framebuffer |
546 | call set_framebuffer |
547 | call init_fpu |
547 | call init_fpu |
548 | call init_malloc |
548 | call init_malloc |
549 | 549 | ||
550 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
550 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
551 | mov [default_io_map], eax |
551 | mov [default_io_map], eax |
552 | 552 | ||
553 | add eax, 0x2000 |
553 | add eax, 0x2000 |
554 | mov [ipc_tmp], eax |
554 | mov [ipc_tmp], eax |
555 | mov ebx, 0x1000 |
555 | mov ebx, 0x1000 |
556 | 556 | ||
557 | add eax, 0x40000 |
557 | add eax, 0x40000 |
558 | mov [proc_mem_map], eax |
558 | mov [proc_mem_map], eax |
559 | 559 | ||
560 | add eax, 0x8000 |
560 | add eax, 0x8000 |
561 | mov [proc_mem_pdir], eax |
561 | mov [proc_mem_pdir], eax |
562 | 562 | ||
563 | add eax, ebx |
563 | add eax, ebx |
564 | mov [proc_mem_tab], eax |
564 | mov [proc_mem_tab], eax |
565 | 565 | ||
566 | add eax, ebx |
566 | add eax, ebx |
567 | mov [tmp_task_ptab], eax |
567 | mov [tmp_task_ptab], eax |
568 | 568 | ||
569 | add eax, ebx |
569 | add eax, ebx |
570 | mov [ipc_pdir], eax |
570 | mov [ipc_pdir], eax |
571 | 571 | ||
572 | add eax, ebx |
572 | add eax, ebx |
573 | mov [ipc_ptab], eax |
573 | mov [ipc_ptab], eax |
574 | 574 | ||
575 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
575 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
576 | (unpack.lc+unpack.lp)))*4 |
576 | (unpack.lc+unpack.lp)))*4 |
577 | 577 | ||
578 | mov [unpack.p], eax |
578 | mov [unpack.p], eax |
579 | 579 | ||
580 | call init_events |
580 | call init_events |
581 | mov eax, srv.fd-SRV.fd |
581 | mov eax, srv.fd-SRV.fd |
582 | mov [srv.fd], eax |
582 | mov [srv.fd], eax |
583 | mov [srv.bk], eax |
583 | mov [srv.bk], eax |
584 | 584 | ||
585 | ;Set base of graphic segment to linear address of LFB |
585 | ;Set base of graphic segment to linear address of LFB |
586 | mov eax, [LFBAddress] ; set for gs |
586 | mov eax, [LFBAddress] ; set for gs |
587 | mov [graph_data_l+2], ax |
587 | mov [graph_data_l+2], ax |
588 | shr eax, 16 |
588 | shr eax, 16 |
589 | mov [graph_data_l+4], al |
589 | mov [graph_data_l+4], al |
590 | mov [graph_data_l+7], ah |
590 | mov [graph_data_l+7], ah |
591 | 591 | ||
592 | stdcall kernel_alloc, [_display.win_map_size] |
592 | stdcall kernel_alloc, [_display.win_map_size] |
593 | mov [_display.win_map], eax |
593 | mov [_display.win_map], eax |
594 | 594 | ||
595 | xor eax, eax |
595 | xor eax, eax |
596 | inc eax |
596 | inc eax |
597 | 597 | ||
598 | ; set background |
598 | ; set background |
599 | 599 | ||
600 | mov [BgrDrawMode], eax |
600 | mov [BgrDrawMode], eax |
601 | mov [BgrDataWidth], eax |
601 | mov [BgrDataWidth], eax |
602 | mov [BgrDataHeight], eax |
602 | mov [BgrDataHeight], eax |
603 | mov [mem_BACKGROUND], 4 |
603 | mov [mem_BACKGROUND], 4 |
604 | mov [img_background], static_background_data |
604 | mov [img_background], static_background_data |
605 | 605 | ||
606 | ; set clipboard |
606 | ; set clipboard |
607 | 607 | ||
608 | xor eax, eax |
608 | xor eax, eax |
609 | mov [clipboard_slots], eax |
609 | mov [clipboard_slots], eax |
610 | mov [clipboard_write_lock], eax |
610 | mov [clipboard_write_lock], eax |
611 | stdcall kernel_alloc, 4096 |
611 | stdcall kernel_alloc, 4096 |
612 | test eax, eax |
612 | test eax, eax |
613 | jnz @f |
613 | jnz @f |
614 | 614 | ||
615 | dec eax |
615 | dec eax |
616 | @@: |
616 | @@: |
617 | mov [clipboard_main_list], eax |
617 | mov [clipboard_main_list], eax |
618 | 618 | ||
619 | mov eax, [hpet_base] |
619 | mov eax, [hpet_base] |
620 | test eax, eax |
620 | test eax, eax |
621 | jz @F |
621 | jz @F |
622 | mov eax, [hpet_base] |
622 | mov eax, [hpet_base] |
623 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR |
623 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR |
624 | mov [hpet_base], eax |
624 | mov [hpet_base], eax |
625 | mov eax, [eax] |
625 | mov eax, [eax] |
626 | DEBUGF 1, "K : HPET caps %x\n", eax |
626 | DEBUGF 1, "K : HPET caps %x\n", eax |
627 | @@: |
627 | @@: |
628 | ; SET UP OS TASK |
628 | ; SET UP OS TASK |
629 | 629 | ||
630 | mov esi, boot_setostask |
630 | mov esi, boot_setostask |
631 | call boot_log |
631 | call boot_log |
632 | 632 | ||
633 | mov edi, sys_proc+PROC.heap_lock |
633 | mov edi, sys_proc+PROC.heap_lock |
634 | mov ecx, (PROC.ht_free-PROC.heap_lock)/4 |
634 | mov ecx, (PROC.ht_free-PROC.heap_lock)/4 |
635 | 635 | ||
636 | xor eax, eax |
636 | xor eax, eax |
637 | cld |
637 | cld |
638 | rep stosd |
638 | rep stosd |
639 | 639 | ||
640 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
640 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
641 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
641 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
642 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
642 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
643 | add edi, 8 |
643 | add edi, 8 |
644 | inc eax |
644 | inc eax |
645 | @@: |
645 | @@: |
646 | stosd |
646 | stosd |
647 | inc eax |
647 | inc eax |
648 | cmp eax, ecx |
648 | cmp eax, ecx |
649 | jbe @B |
649 | jbe @B |
650 | 650 | ||
651 | mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
651 | mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
652 | 652 | ||
653 | mov eax, -1 |
653 | mov eax, -1 |
654 | mov edi, thr_slot_map+4 |
654 | mov edi, thr_slot_map+4 |
655 | mov [edi-4], dword 0xFFFFFFF8 |
655 | mov [edi-4], dword 0xFFFFFFF8 |
656 | stosd |
656 | stosd |
657 | stosd |
657 | stosd |
658 | stosd |
658 | stosd |
659 | stosd |
659 | stosd |
660 | stosd |
660 | stosd |
661 | stosd |
661 | stosd |
662 | stosd |
662 | stosd |
663 | 663 | ||
664 | mov [current_process], sys_proc |
664 | mov [current_process], sys_proc |
665 | 665 | ||
666 | mov edx, SLOT_BASE+256*1 |
666 | mov edx, SLOT_BASE+256*1 |
667 | mov ebx, [os_stack_seg] |
667 | mov ebx, [os_stack_seg] |
668 | add ebx, 0x2000 |
668 | add ebx, 0x2000 |
669 | call setup_os_slot |
669 | call setup_os_slot |
670 | mov dword [edx], 'IDLE' |
670 | mov dword [edx], 'IDLE' |
671 | sub [edx+APPDATA.saved_esp], 4 |
671 | sub [edx+APPDATA.saved_esp], 4 |
672 | mov eax, [edx+APPDATA.saved_esp] |
672 | mov eax, [edx+APPDATA.saved_esp] |
673 | mov dword [eax], idle_thread |
673 | mov dword [eax], idle_thread |
674 | mov ecx, IDLE_PRIORITY |
674 | mov ecx, IDLE_PRIORITY |
675 | call scheduler_add_thread |
675 | call scheduler_add_thread |
676 | 676 | ||
677 | mov edx, SLOT_BASE+256*2 |
677 | mov edx, SLOT_BASE+256*2 |
678 | mov ebx, [os_stack_seg] |
678 | mov ebx, [os_stack_seg] |
679 | call setup_os_slot |
679 | call setup_os_slot |
680 | mov dword [edx], 'OS' |
680 | mov dword [edx], 'OS' |
681 | xor ecx, ecx |
681 | xor ecx, ecx |
682 | call scheduler_add_thread |
682 | call scheduler_add_thread |
683 | 683 | ||
684 | mov dword [CURRENT_TASK], 2 |
684 | mov dword [CURRENT_TASK], 2 |
685 | mov dword [TASK_COUNT], 2 |
685 | mov dword [TASK_COUNT], 2 |
686 | mov dword [current_slot], SLOT_BASE + 256*2 |
686 | mov dword [current_slot], SLOT_BASE + 256*2 |
687 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
687 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
688 | 688 | ||
689 | ; Move other CPUs to deep sleep, if it is useful |
689 | ; Move other CPUs to deep sleep, if it is useful |
690 | uglobal |
690 | uglobal |
691 | use_mwait_for_idle db 0 |
691 | use_mwait_for_idle db 0 |
692 | endg |
692 | endg |
693 | cmp [cpu_vendor+8], 'ntel' |
693 | cmp [cpu_vendor+8], 'ntel' |
694 | jnz .no_wake_cpus |
694 | jnz .no_wake_cpus |
695 | bt [cpu_caps+4], CAPS_MONITOR-32 |
695 | bt [cpu_caps+4], CAPS_MONITOR-32 |
696 | jnc .no_wake_cpus |
696 | jnc .no_wake_cpus |
697 | dbgstr 'using mwait for idle loop' |
697 | dbgstr 'using mwait for idle loop' |
698 | inc [use_mwait_for_idle] |
698 | inc [use_mwait_for_idle] |
699 | mov ebx, [cpu_count] |
699 | mov ebx, [cpu_count] |
700 | cmp ebx, 1 |
700 | cmp ebx, 1 |
701 | jbe .no_wake_cpus |
701 | jbe .no_wake_cpus |
702 | call create_trampoline_pgmap |
702 | call create_trampoline_pgmap |
703 | mov [cr3_ap+OS_BASE], eax |
703 | mov [cr3_ap+OS_BASE], eax |
704 | mov eax, cr4 |
704 | mov eax, cr4 |
705 | mov [cr4_ap+OS_BASE], eax |
705 | mov [cr4_ap+OS_BASE], eax |
706 | mov esi, OS_BASE + ap_init16 |
706 | mov esi, OS_BASE + ap_init16 |
707 | mov edi, OS_BASE + 8000h |
707 | mov edi, OS_BASE + 8000h |
708 | mov ecx, (ap_init16_size + 3) / 4 |
708 | mov ecx, (ap_init16_size + 3) / 4 |
709 | rep movsd |
709 | rep movsd |
710 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
710 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
711 | mov [LAPIC_BASE], eax |
711 | mov [LAPIC_BASE], eax |
712 | lea edi, [eax+300h] |
712 | lea edi, [eax+300h] |
713 | mov esi, smpt+4 |
713 | mov esi, smpt+4 |
714 | dec ebx |
714 | dec ebx |
715 | .wake_cpus_loop: |
715 | .wake_cpus_loop: |
716 | lodsd |
716 | lodsd |
717 | push esi |
717 | push esi |
718 | xor esi, esi |
718 | xor esi, esi |
719 | inc esi |
719 | inc esi |
720 | shl eax, 24 |
720 | shl eax, 24 |
721 | mov [edi+10h], eax |
721 | mov [edi+10h], eax |
722 | ; assert INIT IPI |
722 | ; assert INIT IPI |
723 | mov dword [edi], 0C500h |
723 | mov dword [edi], 0C500h |
724 | call delay_ms |
724 | call delay_ms |
725 | @@: |
725 | @@: |
726 | test dword [edi], 1000h |
726 | test dword [edi], 1000h |
727 | jnz @b |
727 | jnz @b |
728 | ; deassert INIT IPI |
728 | ; deassert INIT IPI |
729 | mov dword [edi], 8500h |
729 | mov dword [edi], 8500h |
730 | call delay_ms |
730 | call delay_ms |
731 | @@: |
731 | @@: |
732 | test dword [edi], 1000h |
732 | test dword [edi], 1000h |
733 | jnz @b |
733 | jnz @b |
734 | ; send STARTUP IPI |
734 | ; send STARTUP IPI |
735 | mov dword [edi], 600h + (8000h shr 12) |
735 | mov dword [edi], 600h + (8000h shr 12) |
736 | call delay_ms |
736 | call delay_ms |
737 | @@: |
737 | @@: |
738 | test dword [edi], 1000h |
738 | test dword [edi], 1000h |
739 | jnz @b |
739 | jnz @b |
740 | pop esi |
740 | pop esi |
741 | dec ebx |
741 | dec ebx |
742 | jnz .wake_cpus_loop |
742 | jnz .wake_cpus_loop |
743 | mov eax, [cpu_count] |
743 | mov eax, [cpu_count] |
744 | dec eax |
744 | dec eax |
745 | @@: |
745 | @@: |
746 | cmp [ap_initialized], eax |
746 | cmp [ap_initialized], eax |
747 | jnz @b |
747 | jnz @b |
748 | mov eax, [cr3_ap+OS_BASE] |
748 | mov eax, [cr3_ap+OS_BASE] |
749 | call free_page |
749 | call free_page |
750 | .no_wake_cpus: |
750 | .no_wake_cpus: |
751 | 751 | ||
752 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
752 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
753 | mov esi, boot_initirq |
753 | mov esi, boot_initirq |
754 | call boot_log |
754 | call boot_log |
755 | call init_irqs |
755 | call init_irqs |
756 | 756 | ||
757 | mov esi, boot_picinit |
757 | mov esi, boot_picinit |
758 | call boot_log |
758 | call boot_log |
759 | call PIC_init |
759 | call PIC_init |
760 | 760 | ||
761 | mov esi, boot_v86machine |
761 | mov esi, boot_v86machine |
762 | call boot_log |
762 | call boot_log |
763 | ; Initialize system V86 machine |
763 | ; Initialize system V86 machine |
764 | call init_sys_v86 |
764 | call init_sys_v86 |
765 | 765 | ||
766 | mov esi, boot_inittimer |
766 | mov esi, boot_inittimer |
767 | call boot_log |
767 | call boot_log |
768 | ; Initialize system timer (IRQ0) |
768 | ; Initialize system timer (IRQ0) |
769 | call PIT_init |
769 | call PIT_init |
770 | 770 | ||
771 | ; Register ramdisk file system |
771 | ; Register ramdisk file system |
772 | cmp [boot_dev+OS_BASE+0x10000], 1 |
772 | cmp [boot_dev+OS_BASE+0x10000], 1 |
773 | je @f |
773 | je @f |
774 | 774 | ||
775 | call register_ramdisk |
775 | call register_ramdisk |
776 | ;-------------------------------------- |
776 | ;-------------------------------------- |
777 | @@: |
777 | @@: |
778 | mov esi, boot_initapic |
778 | mov esi, boot_initapic |
779 | call boot_log |
779 | call boot_log |
780 | ; Try to Initialize APIC |
780 | ; Try to Initialize APIC |
781 | call APIC_init |
781 | call APIC_init |
782 | 782 | ||
783 | mov esi, boot_enableirq |
783 | mov esi, boot_enableirq |
784 | call boot_log |
784 | call boot_log |
785 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
785 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
786 | ; they are used: when partitions are scanned, hd_read relies on timer |
786 | ; they are used: when partitions are scanned, hd_read relies on timer |
787 | call unmask_timer |
787 | call unmask_timer |
788 | stdcall enable_irq, 2 ; @#$%! PIC |
788 | stdcall enable_irq, 2 ; @#$%! PIC |
789 | stdcall enable_irq, 13 ; co-processor |
789 | stdcall enable_irq, 13 ; co-processor |
790 | 790 | ||
791 | ; Setup serial output console (if enabled) |
791 | ; Setup serial output console (if enabled) |
792 | if defined debug_com_base |
792 | if defined debug_com_base |
793 | 793 | ||
794 | ; reserve port so nobody else will use it |
794 | ; reserve port so nobody else will use it |
795 | xor ebx, ebx |
795 | xor ebx, ebx |
796 | mov ecx, debug_com_base |
796 | mov ecx, debug_com_base |
797 | mov edx, debug_com_base+7 |
797 | mov edx, debug_com_base+7 |
798 | call r_f_port_area |
798 | call r_f_port_area |
799 | 799 | ||
800 | ; enable Divisor latch |
800 | ; enable Divisor latch |
801 | mov dx, debug_com_base+3 |
801 | mov dx, debug_com_base+3 |
802 | mov al, 1 shl 7 |
802 | mov al, 1 shl 7 |
803 | out dx, al |
803 | out dx, al |
804 | 804 | ||
805 | ; Set speed to 115200 baud (max speed) |
805 | ; Set speed to 115200 baud (max speed) |
806 | mov dx, debug_com_base |
806 | mov dx, debug_com_base |
807 | mov al, 0x01 |
807 | mov al, 0x01 |
808 | out dx, al |
808 | out dx, al |
809 | 809 | ||
810 | mov dx, debug_com_base+1 |
810 | mov dx, debug_com_base+1 |
811 | mov al, 0x00 |
811 | mov al, 0x00 |
812 | out dx, al |
812 | out dx, al |
813 | 813 | ||
814 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
814 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
815 | mov dx, debug_com_base+3 |
815 | mov dx, debug_com_base+3 |
816 | mov al, 3 |
816 | mov al, 3 |
817 | out dx, al |
817 | out dx, al |
818 | 818 | ||
819 | ; disable interrupts |
819 | ; disable interrupts |
820 | mov dx, debug_com_base+1 |
820 | mov dx, debug_com_base+1 |
821 | mov al, 0 |
821 | mov al, 0 |
822 | out dx, al |
822 | out dx, al |
823 | 823 | ||
824 | ; clear + enable fifo (64 bits) |
824 | ; clear + enable fifo (64 bits) |
825 | mov dx, debug_com_base+2 |
825 | mov dx, debug_com_base+2 |
826 | mov al, 0x7 + 1 shl 5 |
826 | mov al, 0x7 + 1 shl 5 |
827 | out dx, al |
827 | out dx, al |
828 | 828 | ||
829 | end if |
829 | end if |
830 | 830 | ||
831 | 831 | ||
832 | ;----------------------------------------------------------------------------- |
832 | ;----------------------------------------------------------------------------- |
833 | ; show SVN version of kernel on the message board |
833 | ; show SVN version of kernel on the message board |
834 | ;----------------------------------------------------------------------------- |
834 | ;----------------------------------------------------------------------------- |
835 | mov eax, [version_inf.rev] |
835 | mov eax, [version_inf.rev] |
836 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
836 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
837 | ;----------------------------------------------------------------------------- |
837 | ;----------------------------------------------------------------------------- |
838 | ; show CPU count on the message board |
838 | ; show CPU count on the message board |
839 | ;----------------------------------------------------------------------------- |
839 | ;----------------------------------------------------------------------------- |
840 | mov eax, [cpu_count] |
840 | mov eax, [cpu_count] |
841 | test eax, eax |
841 | test eax, eax |
842 | jnz @F |
842 | jnz @F |
843 | mov al, 1 ; at least one CPU |
843 | mov al, 1 ; at least one CPU |
844 | @@: |
844 | @@: |
845 | DEBUGF 1, "K : %d CPU detected\n", eax |
845 | DEBUGF 1, "K : %d CPU detected\n", eax |
846 | ;----------------------------------------------------------------------------- |
846 | ;----------------------------------------------------------------------------- |
847 | ; detect Floppy drives |
847 | ; detect Floppy drives |
848 | ;----------------------------------------------------------------------------- |
848 | ;----------------------------------------------------------------------------- |
849 | mov esi, boot_detectfloppy |
849 | mov esi, boot_detectfloppy |
850 | call boot_log |
850 | call boot_log |
851 | include 'detect/dev_fd.inc' |
851 | include 'detect/dev_fd.inc' |
852 | ;----------------------------------------------------------------------------- |
852 | ;----------------------------------------------------------------------------- |
853 | ; create pci-devices list |
853 | ; create pci-devices list |
854 | ;----------------------------------------------------------------------------- |
854 | ;----------------------------------------------------------------------------- |
855 | mov [pci_access_enabled], 1 |
855 | mov [pci_access_enabled], 1 |
856 | call pci_enum |
856 | call pci_enum |
857 | ;----------------------------------------------------------------------------- |
857 | ;----------------------------------------------------------------------------- |
858 | ; initialisation IDE ATA code |
858 | ; initialisation IDE ATA code |
859 | ;----------------------------------------------------------------------------- |
859 | ;----------------------------------------------------------------------------- |
860 | include 'detect/init_ata.inc' |
860 | include 'detect/init_ata.inc' |
861 | ;----------------------------------------------------------------------------- |
861 | ;----------------------------------------------------------------------------- |
862 | if 0 |
862 | if 0 |
863 | mov ax, [OS_BASE+0x10000+bx_from_load] |
863 | mov ax, [OS_BASE+0x10000+bx_from_load] |
864 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
864 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
865 | je no_lib_load |
865 | je no_lib_load |
866 | 866 | ||
867 | mov esi, boot_loadlibs |
867 | mov esi, boot_loadlibs |
868 | call boot_log |
868 | call boot_log |
869 | ; LOADING LIBRARES |
869 | ; LOADING LIBRARES |
870 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
870 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
871 | call load_file_parse_table ; prepare file parse table |
871 | call load_file_parse_table ; prepare file parse table |
872 | call set_kernel_conf ; configure devices and gui |
872 | call set_kernel_conf ; configure devices and gui |
873 | no_lib_load: |
873 | no_lib_load: |
874 | end if |
874 | end if |
875 | 875 | ||
876 | ; Display APIC status |
876 | ; Display APIC status |
877 | mov esi, boot_APIC_found |
877 | mov esi, boot_APIC_found |
878 | cmp [irq_mode], IRQ_APIC |
878 | cmp [irq_mode], IRQ_APIC |
879 | je @f |
879 | je @f |
880 | mov esi, boot_APIC_nfound |
880 | mov esi, boot_APIC_nfound |
881 | @@: |
881 | @@: |
882 | call boot_log |
882 | call boot_log |
883 | 883 | ||
884 | ; PRINT AMOUNT OF MEMORY |
884 | ; PRINT AMOUNT OF MEMORY |
885 | mov esi, boot_memdetect |
885 | mov esi, boot_memdetect |
886 | call boot_log |
886 | call boot_log |
887 | 887 | ||
888 | movzx ecx, word [boot_y] |
888 | movzx ecx, word [boot_y] |
889 | if lang eq ru |
889 | if lang eq ru |
890 | or ecx, (10+30*6) shl 16 |
890 | or ecx, (10+30*6) shl 16 |
891 | else if lang eq sp |
891 | else if lang eq sp |
892 | or ecx, (10+33*6) shl 16 |
892 | or ecx, (10+33*6) shl 16 |
893 | else |
893 | else |
894 | or ecx, (10+29*6) shl 16 |
894 | or ecx, (10+29*6) shl 16 |
895 | end if |
895 | end if |
896 | sub ecx, 10 |
896 | sub ecx, 10 |
897 | mov edx, 0xFFFFFF |
897 | mov edx, 0xFFFFFF |
898 | mov ebx, [MEM_AMOUNT] |
898 | mov ebx, [MEM_AMOUNT] |
899 | shr ebx, 20 |
899 | shr ebx, 20 |
900 | xor edi, edi |
900 | xor edi, edi |
901 | mov eax, 0x00040000 |
901 | mov eax, 0x00040000 |
902 | inc edi |
902 | inc edi |
903 | call display_number_force |
903 | call display_number_force |
904 | 904 | ||
905 | ; BUILD SCHEDULER |
905 | ; BUILD SCHEDULER |
906 | 906 | ||
907 | ; call build_scheduler; sys32.inc |
907 | ; call build_scheduler; sys32.inc |
908 | 908 | ||
909 | ; mov esi, boot_devices |
909 | ; mov esi, boot_devices |
910 | ; call boot_log |
910 | ; call boot_log |
911 | 911 | ||
912 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
912 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
913 | 913 | ||
914 | stdcall load_pe_driver, szVidintel, 0 |
914 | stdcall load_pe_driver, szVidintel, 0 |
915 | 915 | ||
916 | call usb_init |
916 | call usb_init |
917 | 917 | ||
918 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
918 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
919 | 919 | ||
920 | mov esi, boot_windefs |
920 | mov esi, boot_windefs |
921 | call boot_log |
921 | call boot_log |
922 | call set_window_defaults |
922 | call set_window_defaults |
923 | 923 | ||
924 | ; SET BACKGROUND DEFAULTS |
924 | ; SET BACKGROUND DEFAULTS |
925 | 925 | ||
926 | mov esi, boot_bgr |
926 | mov esi, boot_bgr |
927 | call boot_log |
927 | call boot_log |
928 | call init_background |
928 | call init_background |
929 | call calculatebackground |
929 | call calculatebackground |
930 | 930 | ||
931 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
931 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
932 | 932 | ||
933 | mov esi, boot_resirqports |
933 | mov esi, boot_resirqports |
934 | call boot_log |
934 | call boot_log |
935 | call reserve_irqs_ports |
935 | call reserve_irqs_ports |
936 | 936 | ||
937 | call init_display |
937 | call init_display |
938 | mov eax, [def_cursor] |
938 | mov eax, [def_cursor] |
939 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
939 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
940 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
940 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
941 | 941 | ||
942 | ; PRINT CPU FREQUENCY |
942 | ; PRINT CPU FREQUENCY |
943 | 943 | ||
944 | mov esi, boot_cpufreq |
944 | mov esi, boot_cpufreq |
945 | call boot_log |
945 | call boot_log |
946 | 946 | ||
947 | cli |
947 | cli |
948 | mov ebx, [hpet_base] |
948 | mov ebx, [hpet_base] |
949 | test ebx, ebx |
949 | test ebx, ebx |
950 | jz @F |
950 | jz @F |
951 | mov ebx, [ebx+0xF0] |
951 | mov ebx, [ebx+0xF0] |
952 | 952 | ||
953 | rdtsc |
953 | rdtsc |
954 | mov ecx, 1000 |
954 | mov ecx, 1000 |
955 | sub eax, [hpet_tsc_start] |
955 | sub eax, [hpet_tsc_start] |
956 | sbb edx, [hpet_tsc_start+4] |
956 | sbb edx, [hpet_tsc_start+4] |
957 | shld edx, eax, 10 |
957 | shld edx, eax, 10 |
958 | shl eax, 10 |
958 | shl eax, 10 |
959 | mov esi, eax |
959 | mov esi, eax |
960 | mov eax, edx |
960 | mov eax, edx |
961 | mul ecx |
961 | mul ecx |
962 | xchg eax, esi |
962 | xchg eax, esi |
963 | mul ecx |
963 | mul ecx |
964 | adc edx, esi |
964 | adc edx, esi |
965 | div ebx |
965 | div ebx |
966 | mul ecx |
966 | mul ecx |
967 | div [hpet_period] |
967 | div [hpet_period] |
968 | mul ecx |
968 | mul ecx |
969 | DEBUGF 1, "K : cpu frequency %u Hz\n", eax |
969 | DEBUGF 1, "K : cpu frequency %u Hz\n", eax |
970 | jmp .next |
970 | jmp .next |
971 | @@: |
971 | @@: |
972 | rdtsc |
972 | rdtsc |
973 | mov ecx, eax |
973 | mov ecx, eax |
974 | mov esi, 250 ; wait 1/4 a second |
974 | mov esi, 250 ; wait 1/4 a second |
975 | call delay_ms |
975 | call delay_ms |
976 | rdtsc |
976 | rdtsc |
977 | 977 | ||
978 | sub eax, ecx |
978 | sub eax, ecx |
979 | xor edx, edx |
979 | xor edx, edx |
980 | shld edx, eax, 2 |
980 | shld edx, eax, 2 |
981 | shl eax, 2 |
981 | shl eax, 2 |
982 | .next: |
982 | .next: |
983 | mov dword [cpu_freq], eax |
983 | mov dword [cpu_freq], eax |
984 | mov dword [cpu_freq+4], edx |
984 | mov dword [cpu_freq+4], edx |
985 | mov ebx, 1000000 |
985 | mov ebx, 1000000 |
986 | div ebx |
986 | div ebx |
987 | mov ebx, eax |
987 | mov ebx, eax |
988 | 988 | ||
989 | movzx ecx, word [boot_y] |
989 | movzx ecx, word [boot_y] |
990 | if lang eq ru |
990 | if lang eq ru |
991 | add ecx, (10+19*6) shl 16 - 10 |
991 | add ecx, (10+19*6) shl 16 - 10 |
992 | else if lang eq sp |
992 | else if lang eq sp |
993 | add ecx, (10+25*6) shl 16 - 10 |
993 | add ecx, (10+25*6) shl 16 - 10 |
994 | else |
994 | else |
995 | add ecx, (10+17*6) shl 16 - 10 |
995 | add ecx, (10+17*6) shl 16 - 10 |
996 | end if |
996 | end if |
997 | 997 | ||
998 | mov edx, 0xFFFFFF |
998 | mov edx, 0xFFFFFF |
999 | xor edi, edi |
999 | xor edi, edi |
1000 | mov eax, 0x00040000 |
1000 | mov eax, 0x00040000 |
1001 | inc edi |
1001 | inc edi |
1002 | call display_number_force |
1002 | call display_number_force |
1003 | 1003 | ||
1004 | ; SET VARIABLES |
1004 | ; SET VARIABLES |
1005 | 1005 | ||
1006 | call set_variables |
1006 | call set_variables |
1007 | 1007 | ||
1008 | ; STACK AND FDC |
1008 | ; STACK AND FDC |
1009 | 1009 | ||
1010 | call stack_init |
1010 | call stack_init |
1011 | call fdc_init |
1011 | call fdc_init |
1012 | 1012 | ||
1013 | ; PALETTE FOR 320x200 and 640x480 16 col |
1013 | ; PALETTE FOR 320x200 and 640x480 16 col |
1014 | 1014 | ||
1015 | cmp [SCR_MODE], word 0x12 |
1015 | cmp [SCR_MODE], word 0x12 |
1016 | jne no_pal_vga |
1016 | jne no_pal_vga |
1017 | mov esi, boot_pal_vga |
1017 | mov esi, boot_pal_vga |
1018 | call boot_log |
1018 | call boot_log |
1019 | call paletteVGA |
1019 | call paletteVGA |
1020 | no_pal_vga: |
1020 | no_pal_vga: |
1021 | 1021 | ||
1022 | cmp [SCR_MODE], word 0x13 |
1022 | cmp [SCR_MODE], word 0x13 |
1023 | jne no_pal_ega |
1023 | jne no_pal_ega |
1024 | mov esi, boot_pal_ega |
1024 | mov esi, boot_pal_ega |
1025 | call boot_log |
1025 | call boot_log |
1026 | call palette320x200 |
1026 | call palette320x200 |
1027 | no_pal_ega: |
1027 | no_pal_ega: |
1028 | 1028 | ||
1029 | ; LOAD DEFAULT SKIN |
1029 | ; LOAD DEFAULT SKIN |
1030 | 1030 | ||
1031 | call load_default_skin |
1031 | call load_default_skin |
1032 | 1032 | ||
1033 | ; Protect I/O permission map |
1033 | ; Protect I/O permission map |
1034 | 1034 | ||
1035 | mov esi, [default_io_map] |
1035 | mov esi, [default_io_map] |
1036 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1036 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1037 | add esi, 0x1000 |
1037 | add esi, 0x1000 |
1038 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1038 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1039 | 1039 | ||
1040 | stdcall map_page, tss._io_map_0, \ |
1040 | stdcall map_page, tss._io_map_0, \ |
1041 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1041 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1042 | stdcall map_page, tss._io_map_1, \ |
1042 | stdcall map_page, tss._io_map_1, \ |
1043 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1043 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1044 | 1044 | ||
1045 | ; SET KEYBOARD PARAMETERS |
1045 | ; SET KEYBOARD PARAMETERS |
1046 | mov al, 0xf6 ; reset keyboard, scan enabled |
1046 | mov al, 0xf6 ; reset keyboard, scan enabled |
1047 | call kb_write_wait_ack |
1047 | call kb_write_wait_ack |
1048 | test ah, ah |
1048 | test ah, ah |
1049 | jnz .no_keyboard |
1049 | jnz .no_keyboard |
1050 | 1050 | ||
1051 | iglobal |
1051 | iglobal |
1052 | align 4 |
1052 | align 4 |
1053 | ps2_keyboard_functions: |
1053 | ps2_keyboard_functions: |
1054 | dd .end - $ |
1054 | dd .end - $ |
1055 | dd 0 ; no close |
1055 | dd 0 ; no close |
1056 | dd ps2_set_lights |
1056 | dd ps2_set_lights |
1057 | .end: |
1057 | .end: |
1058 | endg |
1058 | endg |
1059 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1059 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1060 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1060 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1061 | ; call kb_write_wait_ack |
1061 | ; call kb_write_wait_ack |
1062 | ; mov al, 111b |
1062 | ; mov al, 111b |
1063 | ; call kb_write_wait_ack |
1063 | ; call kb_write_wait_ack |
1064 | 1064 | ||
1065 | mov al, 0xF3 ; set repeat rate & delay |
1065 | mov al, 0xF3 ; set repeat rate & delay |
1066 | call kb_write_wait_ack |
1066 | call kb_write_wait_ack |
1067 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1067 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1068 | call kb_write_wait_ack |
1068 | call kb_write_wait_ack |
1069 | ;// mike.dld [ |
1069 | ;// mike.dld [ |
1070 | call set_lights |
1070 | call set_lights |
1071 | ;// mike.dld ] |
1071 | ;// mike.dld ] |
1072 | stdcall attach_int_handler, 1, irq1, 0 |
1072 | stdcall attach_int_handler, 1, irq1, 0 |
1073 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1073 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1074 | .no_keyboard: |
1074 | .no_keyboard: |
1075 | 1075 | ||
1076 | ; Load PS/2 mouse driver |
1076 | ; Load PS/2 mouse driver |
1077 | 1077 | ||
1078 | stdcall load_pe_driver, szPS2MDriver, 0 |
1078 | stdcall load_pe_driver, szPS2MDriver, 0 |
1079 | 1079 | ||
1080 | mov esi, boot_setmouse |
1080 | mov esi, boot_setmouse |
1081 | call boot_log |
1081 | call boot_log |
1082 | call setmouse |
1082 | call setmouse |
1083 | 1083 | ||
1084 | ; LOAD FIRST APPLICATION |
1084 | ; LOAD FIRST APPLICATION |
1085 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1085 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1086 | jnz first_app_found |
1086 | jnz first_app_found |
1087 | 1087 | ||
1088 | cli |
1088 | cli |
1089 | mov ebp, firstapp |
1089 | mov ebp, firstapp |
1090 | call fs_execute_from_sysdir |
1090 | call fs_execute_from_sysdir |
1091 | test eax, eax |
1091 | test eax, eax |
1092 | jns first_app_found |
1092 | jns first_app_found |
1093 | 1093 | ||
1094 | mov esi, boot_failed |
1094 | mov esi, boot_failed |
1095 | call boot_log |
1095 | call boot_log |
1096 | 1096 | ||
1097 | mov eax, 0xDEADBEEF ; otherwise halt |
1097 | mov eax, 0xDEADBEEF ; otherwise halt |
1098 | hlt |
1098 | hlt |
1099 | 1099 | ||
1100 | first_app_found: |
1100 | first_app_found: |
1101 | 1101 | ||
1102 | ; START MULTITASKING |
1102 | ; START MULTITASKING |
1103 | 1103 | ||
1104 | ; A 'All set - press ESC to start' messages if need |
1104 | ; A 'All set - press ESC to start' messages if need |
1105 | if preboot_blogesc |
1105 | if preboot_blogesc |
1106 | mov esi, boot_tasking |
1106 | mov esi, boot_tasking |
1107 | call boot_log |
1107 | call boot_log |
1108 | .bll1: |
1108 | .bll1: |
1109 | in al, 0x60 ; wait for ESC key press |
1109 | in al, 0x60 ; wait for ESC key press |
1110 | cmp al, 129 |
1110 | cmp al, 129 |
1111 | jne .bll1 |
1111 | jne .bll1 |
1112 | end if |
1112 | end if |
1113 | 1113 | ||
1114 | mov [timer_ticks_enable], 1 ; for cd driver |
1114 | mov [timer_ticks_enable], 1 ; for cd driver |
1115 | 1115 | ||
1116 | sti |
1116 | sti |
1117 | 1117 | ||
1118 | call mtrr_validate |
1118 | call mtrr_validate |
1119 | 1119 | ||
1120 | jmp osloop |
1120 | jmp osloop |
1121 | 1121 | ||
1122 | 1122 | ||
1123 | ; Fly :) |
1123 | ; Fly :) |
1124 | 1124 | ||
1125 | uglobal |
1125 | uglobal |
1126 | align 4 |
1126 | align 4 |
1127 | ap_initialized dd 0 |
1127 | ap_initialized dd 0 |
1128 | endg |
1128 | endg |
1129 | 1129 | ||
1130 | ap_init_high: |
1130 | ap_init_high: |
1131 | mov ax, os_stack |
1131 | mov ax, os_stack |
1132 | mov bx, app_data |
1132 | mov bx, app_data |
1133 | mov cx, app_tls |
1133 | mov cx, app_tls |
1134 | mov ss, ax |
1134 | mov ss, ax |
1135 | mov ds, bx |
1135 | mov ds, bx |
1136 | mov es, bx |
1136 | mov es, bx |
1137 | mov fs, cx |
1137 | mov fs, cx |
1138 | mov gs, bx |
1138 | mov gs, bx |
1139 | xor esp, esp |
1139 | xor esp, esp |
1140 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1140 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1141 | mov cr3, eax |
1141 | mov cr3, eax |
1142 | lock inc [ap_initialized] |
1142 | lock inc [ap_initialized] |
1143 | jmp idle_loop |
1143 | jmp idle_loop |
1144 | 1144 | ||
1145 | 1145 | ||
1146 | include 'unpacker.inc' |
1146 | include 'unpacker.inc' |
1147 | 1147 | ||
1148 | align 4 |
1148 | align 4 |
1149 | boot_log: |
1149 | boot_log: |
1150 | pushad |
1150 | pushad |
1151 | 1151 | ||
1152 | mov ebx, 10*65536 |
1152 | mov ebx, 10*65536 |
1153 | mov bx, word [boot_y] |
1153 | mov bx, word [boot_y] |
1154 | add [boot_y], dword 10 |
1154 | add [boot_y], dword 10 |
1155 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1155 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1156 | xor edi, edi |
1156 | xor edi, edi |
1157 | mov edx, esi |
1157 | mov edx, esi |
1158 | inc edi |
1158 | inc edi |
1159 | call dtext |
1159 | call dtext |
1160 | 1160 | ||
1161 | mov [novesachecksum], 1000 |
1161 | mov [novesachecksum], 1000 |
1162 | call checkVga_N13 |
1162 | call checkVga_N13 |
1163 | 1163 | ||
1164 | popad |
1164 | popad |
1165 | 1165 | ||
1166 | ret |
1166 | ret |
1167 | 1167 | ||
1168 | ; in: edx -> APPDATA for OS/IDLE slot |
1168 | ; in: edx -> APPDATA for OS/IDLE slot |
1169 | ; in: ebx = stack base |
1169 | ; in: ebx = stack base |
1170 | proc setup_os_slot |
1170 | proc setup_os_slot |
1171 | xor eax, eax |
1171 | xor eax, eax |
1172 | mov ecx, 256/4 |
1172 | mov ecx, 256/4 |
1173 | mov edi, edx |
1173 | mov edi, edx |
1174 | rep stosd |
1174 | rep stosd |
1175 | 1175 | ||
1176 | mov eax, tss+0x80 |
1176 | mov eax, tss+0x80 |
1177 | call get_pg_addr |
1177 | call get_pg_addr |
1178 | inc eax |
1178 | inc eax |
1179 | mov [edx+APPDATA.io_map], eax |
1179 | mov [edx+APPDATA.io_map], eax |
1180 | mov eax, tss+0x1080 |
1180 | mov eax, tss+0x1080 |
1181 | call get_pg_addr |
1181 | call get_pg_addr |
1182 | inc eax |
1182 | inc eax |
1183 | mov [edx+APPDATA.io_map+4], eax |
1183 | mov [edx+APPDATA.io_map+4], eax |
1184 | 1184 | ||
1185 | mov dword [edx+APPDATA.pl0_stack], ebx |
1185 | mov dword [edx+APPDATA.pl0_stack], ebx |
1186 | lea edi, [ebx+0x2000-512] |
1186 | lea edi, [ebx+0x2000-512] |
1187 | mov dword [edx+APPDATA.fpu_state], edi |
1187 | mov dword [edx+APPDATA.fpu_state], edi |
1188 | mov dword [edx+APPDATA.saved_esp0], edi |
1188 | mov dword [edx+APPDATA.saved_esp0], edi |
1189 | mov dword [edx+APPDATA.saved_esp], edi |
1189 | mov dword [edx+APPDATA.saved_esp], edi |
1190 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1190 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1191 | 1191 | ||
1192 | mov esi, fpu_data |
1192 | mov esi, fpu_data |
1193 | mov ecx, 512/4 |
1193 | mov ecx, 512/4 |
1194 | cld |
1194 | cld |
1195 | rep movsd |
1195 | rep movsd |
1196 | 1196 | ||
1197 | lea eax, [edx+APP_OBJ_OFFSET] |
1197 | lea eax, [edx+APP_OBJ_OFFSET] |
1198 | mov dword [edx+APPDATA.fd_obj], eax |
1198 | mov dword [edx+APPDATA.fd_obj], eax |
1199 | mov dword [edx+APPDATA.bk_obj], eax |
1199 | mov dword [edx+APPDATA.bk_obj], eax |
1200 | 1200 | ||
1201 | mov dword [edx+APPDATA.cur_dir], sysdir_path-2 |
1201 | mov dword [edx+APPDATA.cur_dir], sysdir_path-2 |
1202 | 1202 | ||
1203 | mov [edx + APPDATA.process], sys_proc |
1203 | mov [edx + APPDATA.process], sys_proc |
1204 | 1204 | ||
1205 | lea ebx, [edx+APPDATA.list] |
1205 | lea ebx, [edx+APPDATA.list] |
1206 | lea ecx, [sys_proc+PROC.thr_list] |
1206 | lea ecx, [sys_proc+PROC.thr_list] |
1207 | list_add_tail ebx, ecx |
1207 | list_add_tail ebx, ecx |
1208 | 1208 | ||
1209 | mov eax, edx |
1209 | mov eax, edx |
1210 | shr eax, 3 |
1210 | shr eax, 3 |
1211 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1211 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1212 | mov [eax+TASKDATA.wnd_number], dh |
1212 | mov [eax+TASKDATA.wnd_number], dh |
1213 | mov byte [eax+TASKDATA.pid], dh |
1213 | mov byte [eax+TASKDATA.pid], dh |
1214 | 1214 | ||
1215 | ret |
1215 | ret |
1216 | endp |
1216 | endp |
1217 | 1217 | ||
1218 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1218 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1219 | ; ; |
1219 | ; ; |
1220 | ; MAIN OS LOOP START ; |
1220 | ; MAIN OS LOOP START ; |
1221 | ; ; |
1221 | ; ; |
1222 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1222 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1223 | align 32 |
1223 | align 32 |
1224 | osloop: |
1224 | osloop: |
1225 | mov edx, osloop_has_work? |
1225 | mov edx, osloop_has_work? |
1226 | xor ecx, ecx |
1226 | xor ecx, ecx |
1227 | call Wait_events |
1227 | call Wait_events |
1228 | xor eax, eax |
1228 | xor eax, eax |
1229 | xchg eax, [osloop_nonperiodic_work] |
1229 | xchg eax, [osloop_nonperiodic_work] |
1230 | test eax, eax |
1230 | test eax, eax |
1231 | jz .no_periodic |
1231 | jz .no_periodic |
1232 | 1232 | ||
1233 | call __sys_draw_pointer |
1233 | call __sys_draw_pointer |
1234 | call window_check_events |
1234 | call window_check_events |
1235 | call mouse_check_events |
1235 | call mouse_check_events |
1236 | call checkmisc |
1236 | call checkmisc |
1237 | call checkVga_N13 |
1237 | call checkVga_N13 |
1238 | ;-------------------------------------- |
1238 | ;-------------------------------------- |
1239 | .no_periodic: |
1239 | .no_periodic: |
1240 | call stack_handler |
1240 | call stack_handler |
1241 | call check_fdd_motor_status |
1241 | call check_fdd_motor_status |
1242 | call check_ATAPI_device_event |
1242 | call check_ATAPI_device_event |
1243 | call check_lights_state |
1243 | call check_lights_state |
1244 | call check_timers |
1244 | call check_timers |
1245 | 1245 | ||
1246 | jmp osloop |
1246 | jmp osloop |
1247 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1247 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1248 | ; ; |
1248 | ; ; |
1249 | ; MAIN OS LOOP END ; |
1249 | ; MAIN OS LOOP END ; |
1250 | ; ; |
1250 | ; ; |
1251 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1251 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1252 | proc osloop_has_work? |
1252 | proc osloop_has_work? |
1253 | cmp [osloop_nonperiodic_work], 0 |
1253 | cmp [osloop_nonperiodic_work], 0 |
1254 | jnz .yes |
1254 | jnz .yes |
1255 | call stack_handler_has_work? |
1255 | call stack_handler_has_work? |
1256 | jnz .yes |
1256 | jnz .yes |
1257 | call check_fdd_motor_status_has_work? |
1257 | call check_fdd_motor_status_has_work? |
1258 | jnz .yes |
1258 | jnz .yes |
1259 | call check_ATAPI_device_event_has_work? |
1259 | call check_ATAPI_device_event_has_work? |
1260 | jnz .yes |
1260 | jnz .yes |
1261 | call check_lights_state_has_work? |
1261 | call check_lights_state_has_work? |
1262 | jnz .yes |
1262 | jnz .yes |
1263 | call check_timers_has_work? |
1263 | call check_timers_has_work? |
1264 | jnz .yes |
1264 | jnz .yes |
1265 | .no: |
1265 | .no: |
1266 | xor eax, eax |
1266 | xor eax, eax |
1267 | ret |
1267 | ret |
1268 | .yes: |
1268 | .yes: |
1269 | xor eax, eax |
1269 | xor eax, eax |
1270 | inc eax |
1270 | inc eax |
1271 | ret |
1271 | ret |
1272 | endp |
1272 | endp |
1273 | 1273 | ||
1274 | proc wakeup_osloop |
1274 | proc wakeup_osloop |
1275 | mov [osloop_nonperiodic_work], 1 |
1275 | mov [osloop_nonperiodic_work], 1 |
1276 | ret |
1276 | ret |
1277 | endp |
1277 | endp |
1278 | 1278 | ||
1279 | uglobal |
1279 | uglobal |
1280 | align 4 |
1280 | align 4 |
1281 | osloop_nonperiodic_work dd ? |
1281 | osloop_nonperiodic_work dd ? |
1282 | endg |
1282 | endg |
1283 | 1283 | ||
1284 | uglobal |
1284 | uglobal |
1285 | align 64 |
1285 | align 64 |
1286 | idle_addr rb 64 |
1286 | idle_addr rb 64 |
1287 | endg |
1287 | endg |
1288 | 1288 | ||
1289 | idle_thread: |
1289 | idle_thread: |
1290 | sti |
1290 | sti |
1291 | 1291 | ||
1292 | ; The following code can be executed by all CPUs in the system. |
1292 | ; The following code can be executed by all CPUs in the system. |
1293 | ; All other parts of the kernel do not expect multi-CPU. |
1293 | ; All other parts of the kernel do not expect multi-CPU. |
1294 | ; Also, APs don't even have a stack here. |
1294 | ; Also, APs don't even have a stack here. |
1295 | ; Beware. Don't do anything here. Anything at all. |
1295 | ; Beware. Don't do anything here. Anything at all. |
1296 | idle_loop: |
1296 | idle_loop: |
1297 | cmp [use_mwait_for_idle], 0 |
1297 | cmp [use_mwait_for_idle], 0 |
1298 | jnz idle_loop_mwait |
1298 | jnz idle_loop_mwait |
1299 | 1299 | ||
1300 | idle_loop_hlt: |
1300 | idle_loop_hlt: |
1301 | hlt |
1301 | hlt |
1302 | jmp idle_loop_hlt |
1302 | jmp idle_loop_hlt |
1303 | 1303 | ||
1304 | idle_loop_mwait: |
1304 | idle_loop_mwait: |
1305 | mov eax, idle_addr |
1305 | mov eax, idle_addr |
1306 | xor ecx, ecx |
1306 | xor ecx, ecx |
1307 | xor edx, edx |
1307 | xor edx, edx |
1308 | monitor |
1308 | monitor |
1309 | xor ecx, ecx |
1309 | xor ecx, ecx |
1310 | mov eax, 20h ; or 10h |
1310 | mov eax, 20h ; or 10h |
1311 | mwait |
1311 | mwait |
1312 | jmp idle_loop_mwait |
1312 | jmp idle_loop_mwait |
1313 | 1313 | ||
1314 | 1314 | ||
1315 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1315 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1316 | ; ; |
1316 | ; ; |
1317 | ; INCLUDED SYSTEM FILES ; |
1317 | ; INCLUDED SYSTEM FILES ; |
1318 | ; ; |
1318 | ; ; |
1319 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1319 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1320 | 1320 | ||
1321 | 1321 | ||
1322 | include "kernel32.inc" |
1322 | include "kernel32.inc" |
1323 | 1323 | ||
1324 | 1324 | ||
1325 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1325 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1326 | ; ; |
1326 | ; ; |
1327 | ; KERNEL FUNCTIONS ; |
1327 | ; KERNEL FUNCTIONS ; |
1328 | ; ; |
1328 | ; ; |
1329 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1329 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1330 | 1330 | ||
1331 | reserve_irqs_ports: |
1331 | reserve_irqs_ports: |
1332 | 1332 | ||
1333 | 1333 | ||
1334 | ; RESERVE PORTS |
1334 | ; RESERVE PORTS |
1335 | mov eax, RESERVED_PORTS |
1335 | mov eax, RESERVED_PORTS |
1336 | mov ecx, 1 |
1336 | mov ecx, 1 |
1337 | 1337 | ||
1338 | mov [eax], dword 4 |
1338 | mov [eax], dword 4 |
1339 | 1339 | ||
1340 | mov [eax+16], ecx |
1340 | mov [eax+16], ecx |
1341 | mov [eax+16+4], dword 0 |
1341 | mov [eax+16+4], dword 0 |
1342 | mov [eax+16+8], dword 0x2D |
1342 | mov [eax+16+8], dword 0x2D |
1343 | 1343 | ||
1344 | mov [eax+32], ecx |
1344 | mov [eax+32], ecx |
1345 | mov [eax+32+4], dword 0x30 |
1345 | mov [eax+32+4], dword 0x30 |
1346 | mov [eax+32+8], dword 0x4D |
1346 | mov [eax+32+8], dword 0x4D |
1347 | 1347 | ||
1348 | mov [eax+48], ecx |
1348 | mov [eax+48], ecx |
1349 | mov [eax+48+4], dword 0x50 |
1349 | mov [eax+48+4], dword 0x50 |
1350 | mov [eax+48+8], dword 0xDF |
1350 | mov [eax+48+8], dword 0xDF |
1351 | 1351 | ||
1352 | mov [eax+64], ecx |
1352 | mov [eax+64], ecx |
1353 | mov [eax+64+4], dword 0xE5 |
1353 | mov [eax+64+4], dword 0xE5 |
1354 | mov [eax+64+8], dword 0xFF |
1354 | mov [eax+64+8], dword 0xFF |
1355 | 1355 | ||
1356 | ret |
1356 | ret |
1357 | 1357 | ||
1358 | 1358 | ||
1359 | iglobal |
1359 | iglobal |
1360 | process_number dd 0x2 |
1360 | process_number dd 0x2 |
1361 | endg |
1361 | endg |
1362 | 1362 | ||
1363 | set_variables: |
1363 | set_variables: |
1364 | 1364 | ||
1365 | mov ecx, 0x16 ; flush port 0x60 |
1365 | mov ecx, 0x16 ; flush port 0x60 |
1366 | .fl60: |
1366 | .fl60: |
1367 | in al, 0x60 |
1367 | in al, 0x60 |
1368 | loop .fl60 |
1368 | loop .fl60 |
1369 | push eax |
1369 | push eax |
1370 | 1370 | ||
1371 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1371 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1372 | shr ax, 1 |
1372 | shr ax, 1 |
1373 | shl eax, 16 |
1373 | shl eax, 16 |
1374 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1374 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1375 | shr ax, 1 |
1375 | shr ax, 1 |
1376 | mov [MOUSE_X], eax |
1376 | mov [MOUSE_X], eax |
1377 | call wakeup_osloop |
1377 | call wakeup_osloop |
1378 | 1378 | ||
1379 | xor eax, eax |
1379 | xor eax, eax |
1380 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1380 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1381 | 1381 | ||
1382 | mov byte [KEY_COUNT], al ; keyboard buffer |
1382 | mov byte [KEY_COUNT], al ; keyboard buffer |
1383 | mov byte [BTN_COUNT], al ; button buffer |
1383 | mov byte [BTN_COUNT], al ; button buffer |
1384 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1384 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1385 | 1385 | ||
1386 | pop eax |
1386 | pop eax |
1387 | ret |
1387 | ret |
1388 | 1388 | ||
1389 | align 4 |
1389 | align 4 |
1390 | ;input eax=43,bl-byte of output, ecx - number of port |
1390 | ;input eax=43,bl-byte of output, ecx - number of port |
1391 | sys_outport: |
1391 | sys_outport: |
1392 | 1392 | ||
1393 | mov edi, ecx ; separate flag for read / write |
1393 | mov edi, ecx ; separate flag for read / write |
1394 | and ecx, 65535 |
1394 | and ecx, 65535 |
1395 | 1395 | ||
1396 | mov eax, [RESERVED_PORTS] |
1396 | mov eax, [RESERVED_PORTS] |
1397 | test eax, eax |
1397 | test eax, eax |
1398 | jnz .sopl8 |
1398 | jnz .sopl8 |
1399 | inc eax |
1399 | inc eax |
1400 | mov [esp+32], eax |
1400 | mov [esp+32], eax |
1401 | ret |
1401 | ret |
1402 | 1402 | ||
1403 | .sopl8: |
1403 | .sopl8: |
1404 | mov edx, [TASK_BASE] |
1404 | mov edx, [TASK_BASE] |
1405 | mov edx, [edx+0x4] |
1405 | mov edx, [edx+0x4] |
1406 | ;and ecx,65535 |
1406 | ;and ecx,65535 |
1407 | ;cld - set on interrupt 0x40 |
1407 | ;cld - set on interrupt 0x40 |
1408 | .sopl1: |
1408 | .sopl1: |
1409 | 1409 | ||
1410 | mov esi, eax |
1410 | mov esi, eax |
1411 | shl esi, 4 |
1411 | shl esi, 4 |
1412 | add esi, RESERVED_PORTS |
1412 | add esi, RESERVED_PORTS |
1413 | cmp edx, [esi+0] |
1413 | cmp edx, [esi+0] |
1414 | jne .sopl2 |
1414 | jne .sopl2 |
1415 | cmp ecx, [esi+4] |
1415 | cmp ecx, [esi+4] |
1416 | jb .sopl2 |
1416 | jb .sopl2 |
1417 | cmp ecx, [esi+8] |
1417 | cmp ecx, [esi+8] |
1418 | jg .sopl2 |
1418 | jg .sopl2 |
1419 | .sopl3: |
1419 | .sopl3: |
1420 | 1420 | ||
1421 | test edi, 0x80000000; read ? |
1421 | test edi, 0x80000000; read ? |
1422 | jnz .sopl4 |
1422 | jnz .sopl4 |
1423 | 1423 | ||
1424 | mov eax, ebx |
1424 | mov eax, ebx |
1425 | mov dx, cx ; write |
1425 | mov dx, cx ; write |
1426 | out dx, al |
1426 | out dx, al |
1427 | and [esp+32], dword 0 |
1427 | and [esp+32], dword 0 |
1428 | ret |
1428 | ret |
1429 | 1429 | ||
1430 | .sopl2: |
1430 | .sopl2: |
1431 | 1431 | ||
1432 | dec eax |
1432 | dec eax |
1433 | jnz .sopl1 |
1433 | jnz .sopl1 |
1434 | inc eax |
1434 | inc eax |
1435 | mov [esp+32], eax |
1435 | mov [esp+32], eax |
1436 | ret |
1436 | ret |
1437 | 1437 | ||
1438 | 1438 | ||
1439 | .sopl4: |
1439 | .sopl4: |
1440 | 1440 | ||
1441 | mov dx, cx ; read |
1441 | mov dx, cx ; read |
1442 | in al, dx |
1442 | in al, dx |
1443 | and eax, 0xff |
1443 | and eax, 0xff |
1444 | and [esp+32], dword 0 |
1444 | and [esp+32], dword 0 |
1445 | mov [esp+20], eax |
1445 | mov [esp+20], eax |
1446 | ret |
1446 | ret |
1447 | 1447 | ||
1448 | display_number: |
1448 | display_number: |
1449 | ;It is not optimization |
1449 | ;It is not optimization |
1450 | mov eax, ebx |
1450 | mov eax, ebx |
1451 | mov ebx, ecx |
1451 | mov ebx, ecx |
1452 | mov ecx, edx |
1452 | mov ecx, edx |
1453 | mov edx, esi |
1453 | mov edx, esi |
1454 | mov esi, edi |
1454 | mov esi, edi |
1455 | ; eax = print type, al=0 -> ebx is number |
1455 | ; eax = print type, al=0 -> ebx is number |
1456 | ; al=1 -> ebx is pointer |
1456 | ; al=1 -> ebx is pointer |
1457 | ; ah=0 -> display decimal |
1457 | ; ah=0 -> display decimal |
1458 | ; ah=1 -> display hexadecimal |
1458 | ; ah=1 -> display hexadecimal |
1459 | ; ah=2 -> display binary |
1459 | ; ah=2 -> display binary |
1460 | ; eax bits 16-21 = number of digits to display (0-32) |
1460 | ; eax bits 16-21 = number of digits to display (0-32) |
1461 | ; eax bits 22-31 = reserved |
1461 | ; eax bits 22-31 = reserved |
1462 | ; |
1462 | ; |
1463 | ; ebx = number or pointer |
1463 | ; ebx = number or pointer |
1464 | ; ecx = x shl 16 + y |
1464 | ; ecx = x shl 16 + y |
1465 | ; edx = color |
1465 | ; edx = color |
1466 | xor edi, edi |
1466 | xor edi, edi |
1467 | display_number_force: |
1467 | display_number_force: |
1468 | push eax |
1468 | push eax |
1469 | and eax, 0x3fffffff |
1469 | and eax, 0x3fffffff |
1470 | cmp eax, 0xffff ; length > 0 ? |
1470 | cmp eax, 0xffff ; length > 0 ? |
1471 | pop eax |
1471 | pop eax |
1472 | jge cont_displ |
1472 | jge cont_displ |
1473 | ret |
1473 | ret |
1474 | cont_displ: |
1474 | cont_displ: |
1475 | push eax |
1475 | push eax |
1476 | and eax, 0x3fffffff |
1476 | and eax, 0x3fffffff |
1477 | cmp eax, 61*0x10000 ; length <= 60 ? |
1477 | cmp eax, 61*0x10000 ; length <= 60 ? |
1478 | pop eax |
1478 | pop eax |
1479 | jb cont_displ2 |
1479 | jb cont_displ2 |
1480 | ret |
1480 | ret |
1481 | cont_displ2: |
1481 | cont_displ2: |
1482 | 1482 | ||
1483 | pushad |
1483 | pushad |
1484 | 1484 | ||
1485 | cmp al, 1 ; ecx is a pointer ? |
1485 | cmp al, 1 ; ecx is a pointer ? |
1486 | jne displnl1 |
1486 | jne displnl1 |
1487 | mov ebp, ebx |
1487 | mov ebp, ebx |
1488 | add ebp, 4 |
1488 | add ebp, 4 |
1489 | mov ebp, [ebp+std_application_base_address] |
1489 | mov ebp, [ebp+std_application_base_address] |
1490 | mov ebx, [ebx+std_application_base_address] |
1490 | mov ebx, [ebx+std_application_base_address] |
1491 | displnl1: |
1491 | displnl1: |
1492 | sub esp, 64 |
1492 | sub esp, 64 |
1493 | 1493 | ||
1494 | test ah, ah ; DECIMAL |
1494 | test ah, ah ; DECIMAL |
1495 | jnz no_display_desnum |
1495 | jnz no_display_desnum |
1496 | shr eax, 16 |
1496 | shr eax, 16 |
1497 | and eax, 0xC03f |
1497 | and eax, 0xC03f |
1498 | ; and eax,0x3f |
1498 | ; and eax,0x3f |
1499 | push eax |
1499 | push eax |
1500 | and eax, 0x3f |
1500 | and eax, 0x3f |
1501 | mov edi, esp |
1501 | mov edi, esp |
1502 | add edi, 4+64-1 |
1502 | add edi, 4+64-1 |
1503 | mov ecx, eax |
1503 | mov ecx, eax |
1504 | mov eax, ebx |
1504 | mov eax, ebx |
1505 | mov ebx, 10 |
1505 | mov ebx, 10 |
1506 | d_desnum: |
1506 | d_desnum: |
1507 | xor edx, edx |
1507 | xor edx, edx |
1508 | call division_64_bits |
1508 | call division_64_bits |
1509 | div ebx |
1509 | div ebx |
1510 | add dl, 48 |
1510 | add dl, 48 |
1511 | mov [edi], dl |
1511 | mov [edi], dl |
1512 | dec edi |
1512 | dec edi |
1513 | loop d_desnum |
1513 | loop d_desnum |
1514 | pop eax |
1514 | pop eax |
1515 | call normalize_number |
1515 | call normalize_number |
1516 | call draw_num_text |
1516 | call draw_num_text |
1517 | add esp, 64 |
1517 | add esp, 64 |
1518 | popad |
1518 | popad |
1519 | ret |
1519 | ret |
1520 | no_display_desnum: |
1520 | no_display_desnum: |
1521 | 1521 | ||
1522 | cmp ah, 0x01 ; HEXADECIMAL |
1522 | cmp ah, 0x01 ; HEXADECIMAL |
1523 | jne no_display_hexnum |
1523 | jne no_display_hexnum |
1524 | shr eax, 16 |
1524 | shr eax, 16 |
1525 | and eax, 0xC03f |
1525 | and eax, 0xC03f |
1526 | ; and eax,0x3f |
1526 | ; and eax,0x3f |
1527 | push eax |
1527 | push eax |
1528 | and eax, 0x3f |
1528 | and eax, 0x3f |
1529 | mov edi, esp |
1529 | mov edi, esp |
1530 | add edi, 4+64-1 |
1530 | add edi, 4+64-1 |
1531 | mov ecx, eax |
1531 | mov ecx, eax |
1532 | mov eax, ebx |
1532 | mov eax, ebx |
1533 | mov ebx, 16 |
1533 | mov ebx, 16 |
1534 | d_hexnum: |
1534 | d_hexnum: |
1535 | xor edx, edx |
1535 | xor edx, edx |
1536 | call division_64_bits |
1536 | call division_64_bits |
1537 | div ebx |
1537 | div ebx |
1538 | hexletters = __fdo_hexdigits |
1538 | hexletters = __fdo_hexdigits |
1539 | add edx, hexletters |
1539 | add edx, hexletters |
1540 | mov dl, [edx] |
1540 | mov dl, [edx] |
1541 | mov [edi], dl |
1541 | mov [edi], dl |
1542 | dec edi |
1542 | dec edi |
1543 | loop d_hexnum |
1543 | loop d_hexnum |
1544 | pop eax |
1544 | pop eax |
1545 | call normalize_number |
1545 | call normalize_number |
1546 | call draw_num_text |
1546 | call draw_num_text |
1547 | add esp, 64 |
1547 | add esp, 64 |
1548 | popad |
1548 | popad |
1549 | ret |
1549 | ret |
1550 | no_display_hexnum: |
1550 | no_display_hexnum: |
1551 | 1551 | ||
1552 | cmp ah, 0x02 ; BINARY |
1552 | cmp ah, 0x02 ; BINARY |
1553 | jne no_display_binnum |
1553 | jne no_display_binnum |
1554 | shr eax, 16 |
1554 | shr eax, 16 |
1555 | and eax, 0xC03f |
1555 | and eax, 0xC03f |
1556 | ; and eax,0x3f |
1556 | ; and eax,0x3f |
1557 | push eax |
1557 | push eax |
1558 | and eax, 0x3f |
1558 | and eax, 0x3f |
1559 | mov edi, esp |
1559 | mov edi, esp |
1560 | add edi, 4+64-1 |
1560 | add edi, 4+64-1 |
1561 | mov ecx, eax |
1561 | mov ecx, eax |
1562 | mov eax, ebx |
1562 | mov eax, ebx |
1563 | mov ebx, 2 |
1563 | mov ebx, 2 |
1564 | d_binnum: |
1564 | d_binnum: |
1565 | xor edx, edx |
1565 | xor edx, edx |
1566 | call division_64_bits |
1566 | call division_64_bits |
1567 | div ebx |
1567 | div ebx |
1568 | add dl, 48 |
1568 | add dl, 48 |
1569 | mov [edi], dl |
1569 | mov [edi], dl |
1570 | dec edi |
1570 | dec edi |
1571 | loop d_binnum |
1571 | loop d_binnum |
1572 | pop eax |
1572 | pop eax |
1573 | call normalize_number |
1573 | call normalize_number |
1574 | call draw_num_text |
1574 | call draw_num_text |
1575 | add esp, 64 |
1575 | add esp, 64 |
1576 | popad |
1576 | popad |
1577 | ret |
1577 | ret |
1578 | no_display_binnum: |
1578 | no_display_binnum: |
1579 | 1579 | ||
1580 | add esp, 64 |
1580 | add esp, 64 |
1581 | popad |
1581 | popad |
1582 | ret |
1582 | ret |
1583 | 1583 | ||
1584 | normalize_number: |
1584 | normalize_number: |
1585 | test ah, 0x80 |
1585 | test ah, 0x80 |
1586 | jz .continue |
1586 | jz .continue |
1587 | mov ecx, 48 |
1587 | mov ecx, 48 |
1588 | and eax, 0x3f |
1588 | and eax, 0x3f |
1589 | @@: |
1589 | @@: |
1590 | inc edi |
1590 | inc edi |
1591 | cmp [edi], cl |
1591 | cmp [edi], cl |
1592 | jne .continue |
1592 | jne .continue |
1593 | dec eax |
1593 | dec eax |
1594 | cmp eax, 1 |
1594 | cmp eax, 1 |
1595 | ja @r |
1595 | ja @r |
1596 | mov al, 1 |
1596 | mov al, 1 |
1597 | .continue: |
1597 | .continue: |
1598 | and eax, 0x3f |
1598 | and eax, 0x3f |
1599 | ret |
1599 | ret |
1600 | 1600 | ||
1601 | division_64_bits: |
1601 | division_64_bits: |
1602 | test [esp+1+4], byte 0x40 |
1602 | test [esp+1+4], byte 0x40 |
1603 | jz .continue |
1603 | jz .continue |
1604 | push eax |
1604 | push eax |
1605 | mov eax, ebp |
1605 | mov eax, ebp |
1606 | div ebx |
1606 | div ebx |
1607 | mov ebp, eax |
1607 | mov ebp, eax |
1608 | pop eax |
1608 | pop eax |
1609 | .continue: |
1609 | .continue: |
1610 | ret |
1610 | ret |
1611 | 1611 | ||
1612 | draw_num_text: |
1612 | draw_num_text: |
1613 | mov esi, eax |
1613 | mov esi, eax |
1614 | mov edx, 64+4 |
1614 | mov edx, 64+4 |
1615 | sub edx, eax |
1615 | sub edx, eax |
1616 | add edx, esp |
1616 | add edx, esp |
1617 | mov ebx, [esp+64+32-8+4] |
1617 | mov ebx, [esp+64+32-8+4] |
1618 | ; add window start x & y |
1618 | ; add window start x & y |
1619 | mov ecx, [TASK_BASE] |
1619 | mov ecx, [TASK_BASE] |
1620 | 1620 | ||
1621 | mov edi, [CURRENT_TASK] |
1621 | mov edi, [CURRENT_TASK] |
1622 | shl edi, 8 |
1622 | shl edi, 8 |
1623 | 1623 | ||
1624 | mov eax, [ecx-twdw+WDATA.box.left] |
1624 | mov eax, [ecx-twdw+WDATA.box.left] |
1625 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1625 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1626 | shl eax, 16 |
1626 | shl eax, 16 |
1627 | add eax, [ecx-twdw+WDATA.box.top] |
1627 | add eax, [ecx-twdw+WDATA.box.top] |
1628 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1628 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1629 | add ebx, eax |
1629 | add ebx, eax |
1630 | mov ecx, [esp+64+32-12+4] |
1630 | mov ecx, [esp+64+32-12+4] |
1631 | mov eax, [esp+64+8] ; background color (if given) |
1631 | mov eax, [esp+64+8] ; background color (if given) |
1632 | mov edi, [esp+64+4] |
1632 | mov edi, [esp+64+4] |
1633 | and ecx, 5FFFFFFFh |
1633 | and ecx, 5FFFFFFFh |
1634 | bt ecx, 27 |
1634 | bt ecx, 27 |
1635 | jnc @f |
1635 | jnc @f |
1636 | mov edi, eax |
1636 | mov edi, eax |
1637 | @@: |
1637 | @@: |
1638 | jmp dtext |
1638 | jmp dtext |
1639 | ;----------------------------------------------------------------------------- |
1639 | ;----------------------------------------------------------------------------- |
1640 | iglobal |
1640 | iglobal |
1641 | midi_base dw 0 |
1641 | midi_base dw 0 |
1642 | endg |
1642 | endg |
1643 | ;----------------------------------------------------------------------------- |
1643 | ;----------------------------------------------------------------------------- |
1644 | align 4 |
1644 | align 4 |
1645 | sys_setup: |
1645 | sys_setup: |
1646 | ; 1 = roland mpu midi base , base io address |
1646 | ; 1 = roland mpu midi base , base io address |
1647 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1647 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1648 | ; 3 = not used |
1648 | ; 3 = not used |
1649 | ; 4 = not used |
1649 | ; 4 = not used |
1650 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1650 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1651 | ; 6 = not used |
1651 | ; 6 = not used |
1652 | ; 7 = not used |
1652 | ; 7 = not used |
1653 | ; 8 = not used |
1653 | ; 8 = not used |
1654 | ; 9 = not used |
1654 | ; 9 = not used |
1655 | ; 10 = not used |
1655 | ; 10 = not used |
1656 | ; 11 = enable lba read |
1656 | ; 11 = enable lba read |
1657 | ; 12 = enable pci access |
1657 | ; 12 = enable pci access |
1658 | ;----------------------------------------------------------------------------- |
1658 | ;----------------------------------------------------------------------------- |
1659 | and [esp+32], dword 0 |
1659 | and [esp+32], dword 0 |
1660 | ; F.21.1 - set MPU MIDI base port |
1660 | ; F.21.1 - set MPU MIDI base port |
1661 | dec ebx |
1661 | dec ebx |
1662 | jnz @f |
1662 | jnz @f |
1663 | 1663 | ||
1664 | cmp ecx, 0x100 |
1664 | cmp ecx, 0x100 |
1665 | jb @f |
1665 | jb @f |
1666 | 1666 | ||
1667 | mov esi, 65535 |
1667 | mov esi, 65535 |
1668 | cmp esi, ecx |
1668 | cmp esi, ecx |
1669 | jb @f |
1669 | jb @f |
1670 | 1670 | ||
1671 | mov [midi_base], cx |
1671 | mov [midi_base], cx |
1672 | mov word [mididp], cx |
1672 | mov word [mididp], cx |
1673 | inc cx |
1673 | inc cx |
1674 | mov word [midisp], cx |
1674 | mov word [midisp], cx |
1675 | ret |
1675 | ret |
1676 | ;-------------------------------------- |
1676 | ;-------------------------------------- |
1677 | @@: |
1677 | @@: |
1678 | ; F.21.2 - set keyboard layout |
1678 | ; F.21.2 - set keyboard layout |
1679 | dec ebx |
1679 | dec ebx |
1680 | jnz @f |
1680 | jnz @f |
1681 | 1681 | ||
1682 | mov edi, [TASK_BASE] |
1682 | mov edi, [TASK_BASE] |
1683 | mov eax, [edi+TASKDATA.mem_start] |
1683 | mov eax, [edi+TASKDATA.mem_start] |
1684 | add eax, edx |
1684 | add eax, edx |
1685 | ; 1 = normal layout |
1685 | ; 1 = normal layout |
1686 | dec ecx |
1686 | dec ecx |
1687 | jnz .shift |
1687 | jnz .shift |
1688 | 1688 | ||
1689 | mov ebx, keymap |
1689 | mov ebx, keymap |
1690 | mov ecx, 128 |
1690 | mov ecx, 128 |
1691 | call memmove |
1691 | call memmove |
1692 | ret |
1692 | ret |
1693 | ;-------------------------------------- |
1693 | ;-------------------------------------- |
1694 | .shift: |
1694 | .shift: |
1695 | ; 2 = layout at pressed Shift |
1695 | ; 2 = layout at pressed Shift |
1696 | dec ecx |
1696 | dec ecx |
1697 | jnz .alt |
1697 | jnz .alt |
1698 | 1698 | ||
1699 | mov ebx, keymap_shift |
1699 | mov ebx, keymap_shift |
1700 | mov ecx, 128 |
1700 | mov ecx, 128 |
1701 | call memmove |
1701 | call memmove |
1702 | ret |
1702 | ret |
1703 | ;-------------------------------------- |
1703 | ;-------------------------------------- |
1704 | .alt: |
1704 | .alt: |
1705 | ; 3 = layout at pressed Alt |
1705 | ; 3 = layout at pressed Alt |
1706 | dec ecx |
1706 | dec ecx |
1707 | jnz .country |
1707 | jnz .country |
1708 | 1708 | ||
1709 | mov ebx, keymap_alt |
1709 | mov ebx, keymap_alt |
1710 | mov ecx, 128 |
1710 | mov ecx, 128 |
1711 | call memmove |
1711 | call memmove |
1712 | ret |
1712 | ret |
1713 | ;-------------------------------------- |
1713 | ;-------------------------------------- |
1714 | .country: |
1714 | .country: |
1715 | ; country identifier |
1715 | ; country identifier |
1716 | sub ecx, 6 |
1716 | sub ecx, 6 |
1717 | jnz .error |
1717 | jnz .error |
1718 | 1718 | ||
1719 | mov word [keyboard], dx |
1719 | mov word [keyboard], dx |
1720 | ret |
1720 | ret |
1721 | ;-------------------------------------- |
1721 | ;-------------------------------------- |
1722 | @@: |
1722 | @@: |
1723 | ; F.21.5 - set system language |
1723 | ; F.21.5 - set system language |
1724 | sub ebx, 3 |
1724 | sub ebx, 3 |
1725 | jnz @f |
1725 | jnz @f |
1726 | 1726 | ||
1727 | mov [syslang], ecx |
1727 | mov [syslang], ecx |
1728 | ret |
1728 | ret |
1729 | ;-------------------------------------- |
1729 | ;-------------------------------------- |
1730 | @@: |
1730 | @@: |
1731 | ; F.21.11 - enable/disable low-level access to HD |
1731 | ; F.21.11 - enable/disable low-level access to HD |
1732 | and ecx, 1 |
1732 | and ecx, 1 |
1733 | sub ebx, 6 |
1733 | sub ebx, 6 |
1734 | jnz @f |
1734 | jnz @f |
1735 | 1735 | ||
1736 | mov [lba_read_enabled], ecx |
1736 | mov [lba_read_enabled], ecx |
1737 | ret |
1737 | ret |
1738 | ;-------------------------------------- |
1738 | ;-------------------------------------- |
1739 | @@: |
1739 | @@: |
1740 | ; F.21.12 - enable/disable low-level access to PCI |
1740 | ; F.21.12 - enable/disable low-level access to PCI |
1741 | dec ebx |
1741 | dec ebx |
1742 | jnz .error |
1742 | jnz .error |
1743 | 1743 | ||
1744 | mov [pci_access_enabled], ecx |
1744 | mov [pci_access_enabled], ecx |
1745 | ret |
1745 | ret |
1746 | ;-------------------------------------- |
1746 | ;-------------------------------------- |
1747 | .error: |
1747 | .error: |
1748 | or [esp+32], dword -1 |
1748 | or [esp+32], dword -1 |
1749 | ret |
1749 | ret |
1750 | ;----------------------------------------------------------------------------- |
1750 | ;----------------------------------------------------------------------------- |
1751 | align 4 |
1751 | align 4 |
1752 | sys_getsetup: |
1752 | sys_getsetup: |
1753 | ; 1 = roland mpu midi base , base io address |
1753 | ; 1 = roland mpu midi base , base io address |
1754 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1754 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1755 | ; 3 = not used |
1755 | ; 3 = not used |
1756 | ; 4 = not used |
1756 | ; 4 = not used |
1757 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1757 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1758 | ; 6 = not used |
1758 | ; 6 = not used |
1759 | ; 7 = not used |
1759 | ; 7 = not used |
1760 | ; 8 = not used |
1760 | ; 8 = not used |
1761 | ; 9 = get hs timer tic |
1761 | ; 9 = get hs timer tic |
1762 | ; 10 = not used |
1762 | ; 10 = not used |
1763 | ; 11 = get the state "lba read" |
1763 | ; 11 = get the state "lba read" |
1764 | ; 12 = get the state "pci access" |
1764 | ; 12 = get the state "pci access" |
1765 | ;----------------------------------------------------------------------------- |
1765 | ;----------------------------------------------------------------------------- |
1766 | ; F.26.1 - get MPU MIDI base port |
1766 | ; F.26.1 - get MPU MIDI base port |
1767 | dec ebx |
1767 | dec ebx |
1768 | jnz @f |
1768 | jnz @f |
1769 | 1769 | ||
1770 | movzx eax, [midi_base] |
1770 | movzx eax, [midi_base] |
1771 | mov [esp+32], eax |
1771 | mov [esp+32], eax |
1772 | ret |
1772 | ret |
1773 | ;-------------------------------------- |
1773 | ;-------------------------------------- |
1774 | @@: |
1774 | @@: |
1775 | ; F.26.2 - get keyboard layout |
1775 | ; F.26.2 - get keyboard layout |
1776 | dec ebx |
1776 | dec ebx |
1777 | jnz @f |
1777 | jnz @f |
1778 | 1778 | ||
1779 | mov edi, [TASK_BASE] |
1779 | mov edi, [TASK_BASE] |
1780 | mov ebx, [edi+TASKDATA.mem_start] |
1780 | mov ebx, [edi+TASKDATA.mem_start] |
1781 | add ebx, edx |
1781 | add ebx, edx |
1782 | ; 1 = normal layout |
1782 | ; 1 = normal layout |
1783 | dec ecx |
1783 | dec ecx |
1784 | jnz .shift |
1784 | jnz .shift |
1785 | 1785 | ||
1786 | mov eax, keymap |
1786 | mov eax, keymap |
1787 | mov ecx, 128 |
1787 | mov ecx, 128 |
1788 | call memmove |
1788 | call memmove |
1789 | ret |
1789 | ret |
1790 | ;-------------------------------------- |
1790 | ;-------------------------------------- |
1791 | .shift: |
1791 | .shift: |
1792 | ; 2 = layout with pressed Shift |
1792 | ; 2 = layout with pressed Shift |
1793 | dec ecx |
1793 | dec ecx |
1794 | jnz .alt |
1794 | jnz .alt |
1795 | 1795 | ||
1796 | mov eax, keymap_shift |
1796 | mov eax, keymap_shift |
1797 | mov ecx, 128 |
1797 | mov ecx, 128 |
1798 | call memmove |
1798 | call memmove |
1799 | ret |
1799 | ret |
1800 | ;-------------------------------------- |
1800 | ;-------------------------------------- |
1801 | .alt: |
1801 | .alt: |
1802 | ; 3 = layout with pressed Alt |
1802 | ; 3 = layout with pressed Alt |
1803 | dec ecx |
1803 | dec ecx |
1804 | jne .country |
1804 | jne .country |
1805 | 1805 | ||
1806 | mov eax, keymap_alt |
1806 | mov eax, keymap_alt |
1807 | mov ecx, 128 |
1807 | mov ecx, 128 |
1808 | call memmove |
1808 | call memmove |
1809 | ret |
1809 | ret |
1810 | ;-------------------------------------- |
1810 | ;-------------------------------------- |
1811 | .country: |
1811 | .country: |
1812 | ; 9 = country identifier |
1812 | ; 9 = country identifier |
1813 | sub ecx, 6 |
1813 | sub ecx, 6 |
1814 | jnz .error |
1814 | jnz .error |
1815 | 1815 | ||
1816 | movzx eax, word [keyboard] |
1816 | movzx eax, word [keyboard] |
1817 | mov [esp+32], eax |
1817 | mov [esp+32], eax |
1818 | ret |
1818 | ret |
1819 | ;-------------------------------------- |
1819 | ;-------------------------------------- |
1820 | @@: |
1820 | @@: |
1821 | ; F.26.5 - get system language |
1821 | ; F.26.5 - get system language |
1822 | sub ebx, 3 |
1822 | sub ebx, 3 |
1823 | jnz @f |
1823 | jnz @f |
1824 | 1824 | ||
1825 | mov eax, [syslang] |
1825 | mov eax, [syslang] |
1826 | mov [esp+32], eax |
1826 | mov [esp+32], eax |
1827 | ret |
1827 | ret |
1828 | ;-------------------------------------- |
1828 | ;-------------------------------------- |
1829 | @@: |
1829 | @@: |
1830 | ; F.26.9 - get the value of the time counter |
1830 | ; F.26.9 - get the value of the time counter |
1831 | sub ebx, 4 |
1831 | sub ebx, 4 |
1832 | jnz @f |
1832 | jnz @f |
1833 | 1833 | ||
1834 | mov eax, [timer_ticks] |
1834 | mov eax, [timer_ticks] |
1835 | mov [esp+32], eax |
1835 | mov [esp+32], eax |
1836 | ret |
1836 | ret |
1837 | ;-------------------------------------- |
1837 | ;-------------------------------------- |
1838 | @@: |
1838 | @@: |
1839 | ; F.26.10 - get the time from kernel launch in nanoseconds |
1839 | ; F.26.10 - get the time from kernel launch in nanoseconds |
1840 | sub ebx, 1 |
1840 | sub ebx, 1 |
1841 | jnz @f |
1841 | jnz @f |
1842 | 1842 | ||
1843 | call get_clock_ns |
1843 | call get_clock_ns |
1844 | mov [esp+24], edx |
1844 | mov [esp+24], edx |
1845 | mov [esp+32], eax |
1845 | mov [esp+32], eax |
1846 | ret |
1846 | ret |
1847 | ;-------------------------------------- |
1847 | ;-------------------------------------- |
1848 | @@: |
1848 | @@: |
1849 | ; F.26.11 - Find out whether low-level HD access is enabled |
1849 | ; F.26.11 - Find out whether low-level HD access is enabled |
1850 | sub ebx, 1 |
1850 | sub ebx, 1 |
1851 | jnz @f |
1851 | jnz @f |
1852 | 1852 | ||
1853 | mov eax, [lba_read_enabled] |
1853 | mov eax, [lba_read_enabled] |
1854 | mov [esp+32], eax |
1854 | mov [esp+32], eax |
1855 | ret |
1855 | ret |
1856 | ;-------------------------------------- |
1856 | ;-------------------------------------- |
1857 | @@: |
1857 | @@: |
1858 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1858 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1859 | dec ebx |
1859 | dec ebx |
1860 | jnz .error |
1860 | jnz .error |
1861 | 1861 | ||
1862 | mov eax, [pci_access_enabled] |
1862 | mov eax, [pci_access_enabled] |
1863 | mov [esp+32], eax |
1863 | mov [esp+32], eax |
1864 | ret |
1864 | ret |
1865 | ;-------------------------------------- |
1865 | ;-------------------------------------- |
1866 | .error: |
1866 | .error: |
1867 | or [esp+32], dword -1 |
1867 | or [esp+32], dword -1 |
1868 | ret |
1868 | ret |
1869 | ;----------------------------------------------------------------------------- |
1869 | ;----------------------------------------------------------------------------- |
1870 | get_timer_ticks: |
1870 | get_timer_ticks: |
1871 | mov eax, [timer_ticks] |
1871 | mov eax, [timer_ticks] |
1872 | ret |
1872 | ret |
1873 | ;----------------------------------------------------------------------------- |
1873 | ;----------------------------------------------------------------------------- |
1874 | iglobal |
- | |
1875 | align 4 |
- | |
1876 | mousefn dd msscreen |
- | |
1877 | dd mswin |
- | |
1878 | dd msbutton |
- | |
1879 | dd msbuttonExt |
- | |
1880 | dd app_load_cursor |
- | |
1881 | dd app_set_cursor |
- | |
1882 | dd app_delete_cursor |
- | |
1883 | dd msz |
- | |
1884 | endg |
- | |
1885 | ;----------------------------------------------------------------------------- |
- | |
1886 | readmousepos: |
1874 | readmousepos: |
1887 | - | ||
1888 | ; eax=0 screen relative |
1875 | ; eax=0 screen relative |
1889 | ; eax=1 window relative |
1876 | ; eax=1 window relative |
1890 | ; eax=2 buttons pressed |
1877 | ; eax=2 buttons pressed |
1891 | ; eax=3 buttons pressed ext |
1878 | ; eax=3 buttons pressed ext |
1892 | ; eax=4 load cursor |
1879 | ; eax=4 load cursor |
1893 | ; eax=5 set cursor |
1880 | ; eax=5 set cursor |
1894 | ; eax=6 delete cursor |
1881 | ; eax=6 delete cursor |
1895 | ; eax=7 get mouse_z |
1882 | ; eax=7 get mouse_z |
1896 | - | ||
- | 1883 | ; eax=8 load cursor unicode |
|
1897 | cmp ebx, 7 |
1884 | cmp ebx, 8 |
1898 | ja @f |
1885 | ja @f |
1899 | jmp [mousefn+ebx*4] |
1886 | jmp dword[.mousefn+ebx*4] |
- | 1887 | ||
- | 1888 | align 4 |
|
- | 1889 | .mousefn: |
|
- | 1890 | dd .msscreen |
|
- | 1891 | dd .mswin |
|
- | 1892 | dd .msbutton |
|
- | 1893 | dd .msbuttonExt |
|
- | 1894 | dd .app_load_cursor |
|
- | 1895 | dd .app_set_cursor |
|
- | 1896 | dd .app_delete_cursor |
|
- | 1897 | dd .msz |
|
- | 1898 | dd .loadCursorUni |
|
1900 | 1899 | ||
1901 | msscreen: |
1900 | .msscreen: |
1902 | mov eax, [MOUSE_X] |
1901 | mov eax, [MOUSE_X] |
1903 | shl eax, 16 |
1902 | shl eax, 16 |
1904 | mov ax, [MOUSE_Y] |
1903 | mov ax, [MOUSE_Y] |
1905 | mov [esp+36-4], eax |
1904 | mov [esp+36-4], eax |
1906 | @@: |
1905 | @@: |
1907 | ret |
1906 | ret |
1908 | 1907 | ||
1909 | mswin: |
1908 | .mswin: |
1910 | mov eax, [MOUSE_X] |
1909 | mov eax, [MOUSE_X] |
1911 | shl eax, 16 |
1910 | shl eax, 16 |
1912 | mov ax, [MOUSE_Y] |
1911 | mov ax, [MOUSE_Y] |
1913 | mov esi, [TASK_BASE] |
1912 | mov esi, [TASK_BASE] |
1914 | mov bx, word [esi-twdw+WDATA.box.left] |
1913 | mov bx, word [esi-twdw+WDATA.box.left] |
1915 | shl ebx, 16 |
1914 | shl ebx, 16 |
1916 | mov bx, word [esi-twdw+WDATA.box.top] |
1915 | mov bx, word [esi-twdw+WDATA.box.top] |
1917 | sub eax, ebx |
1916 | sub eax, ebx |
1918 | mov edi, [CURRENT_TASK] |
1917 | mov edi, [CURRENT_TASK] |
1919 | shl edi, 8 |
1918 | shl edi, 8 |
1920 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1919 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1921 | rol eax, 16 |
1920 | rol eax, 16 |
1922 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1921 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1923 | rol eax, 16 |
1922 | rol eax, 16 |
1924 | mov [esp+36-4], eax |
1923 | mov [esp+36-4], eax |
1925 | ret |
1924 | ret |
1926 | 1925 | ||
1927 | msbutton: |
1926 | .msbutton: |
1928 | movzx eax, byte [BTN_DOWN] |
1927 | movzx eax, byte [BTN_DOWN] |
1929 | mov [esp+36-4], eax |
1928 | mov [esp+36-4], eax |
1930 | ret |
1929 | ret |
1931 | 1930 | ||
1932 | msbuttonExt: |
1931 | .msbuttonExt: |
1933 | mov eax, [BTN_DOWN] |
1932 | mov eax, [BTN_DOWN] |
1934 | mov [esp+36-4], eax |
1933 | mov [esp+36-4], eax |
1935 | ret |
1934 | ret |
1936 | 1935 | ||
1937 | app_load_cursor: |
1936 | .app_load_cursor: |
1938 | cmp ecx, OS_BASE |
1937 | cmp ecx, OS_BASE |
1939 | jae @f |
1938 | jae @f |
1940 | stdcall load_cursor, ecx, edx |
1939 | stdcall load_cursor, ecx, edx |
1941 | mov [esp+36-4], eax |
1940 | mov [esp+36-4], eax |
1942 | @@: |
1941 | @@: |
1943 | ret |
1942 | ret |
- | 1943 | ||
- | 1944 | .loadCursorUni: |
|
- | 1945 | cmp ecx, OS_BASE |
|
- | 1946 | jae @b |
|
- | 1947 | push ecx edx |
|
- | 1948 | stdcall kernel_alloc, maxPathLength |
|
- | 1949 | mov edi, eax |
|
- | 1950 | pop eax esi |
|
- | 1951 | push edi |
|
- | 1952 | call getFullPath |
|
- | 1953 | pop ebp |
|
- | 1954 | test eax, eax |
|
- | 1955 | jz @f |
|
- | 1956 | stdcall load_cursor, ebp, LOAD_FROM_FILE |
|
- | 1957 | mov [esp+32], eax |
|
- | 1958 | @@: |
|
- | 1959 | stdcall kernel_free, ebp |
|
- | 1960 | ret |
|
1944 | 1961 | ||
1945 | app_set_cursor: |
1962 | .app_set_cursor: |
1946 | stdcall set_cursor, ecx |
1963 | stdcall set_cursor, ecx |
1947 | mov [esp+36-4], eax |
1964 | mov [esp+36-4], eax |
1948 | ret |
1965 | ret |
1949 | 1966 | ||
1950 | app_delete_cursor: |
1967 | .app_delete_cursor: |
1951 | stdcall delete_cursor, ecx |
1968 | stdcall delete_cursor, ecx |
1952 | mov [esp+36-4], eax |
1969 | mov [esp+36-4], eax |
1953 | ret |
1970 | ret |
1954 | 1971 | ||
1955 | msz: |
1972 | .msz: |
1956 | mov edi, [TASK_COUNT] |
1973 | mov edi, [TASK_COUNT] |
1957 | movzx edi, word [WIN_POS + edi*2] |
1974 | movzx edi, word [WIN_POS + edi*2] |
1958 | cmp edi, [CURRENT_TASK] |
1975 | cmp edi, [CURRENT_TASK] |
1959 | jne @f |
1976 | jne @f |
1960 | mov ax, [MOUSE_SCROLL_H] |
1977 | mov ax, [MOUSE_SCROLL_H] |
1961 | shl eax, 16 |
1978 | shl eax, 16 |
1962 | mov ax, [MOUSE_SCROLL_V] |
1979 | mov ax, [MOUSE_SCROLL_V] |
1963 | mov [esp+36-4], eax |
1980 | mov [esp+36-4], eax |
1964 | and [MOUSE_SCROLL_H], word 0 |
1981 | and [MOUSE_SCROLL_H], word 0 |
1965 | and [MOUSE_SCROLL_V], word 0 |
1982 | and [MOUSE_SCROLL_V], word 0 |
1966 | ret |
1983 | ret |
1967 | @@: |
1984 | @@: |
1968 | and [esp+36-4], dword 0 |
1985 | and [esp+36-4], dword 0 |
1969 | ret |
1986 | ret |
1970 | 1987 | ||
1971 | is_input: |
1988 | is_input: |
1972 | 1989 | ||
1973 | push edx |
1990 | push edx |
1974 | mov dx, word [midisp] |
1991 | mov dx, word [midisp] |
1975 | in al, dx |
1992 | in al, dx |
1976 | and al, 0x80 |
1993 | and al, 0x80 |
1977 | pop edx |
1994 | pop edx |
1978 | ret |
1995 | ret |
1979 | 1996 | ||
1980 | is_output: |
1997 | is_output: |
1981 | 1998 | ||
1982 | push edx |
1999 | push edx |
1983 | mov dx, word [midisp] |
2000 | mov dx, word [midisp] |
1984 | in al, dx |
2001 | in al, dx |
1985 | and al, 0x40 |
2002 | and al, 0x40 |
1986 | pop edx |
2003 | pop edx |
1987 | ret |
2004 | ret |
1988 | 2005 | ||
1989 | 2006 | ||
1990 | get_mpu_in: |
2007 | get_mpu_in: |
1991 | 2008 | ||
1992 | push edx |
2009 | push edx |
1993 | mov dx, word [mididp] |
2010 | mov dx, word [mididp] |
1994 | in al, dx |
2011 | in al, dx |
1995 | pop edx |
2012 | pop edx |
1996 | ret |
2013 | ret |
1997 | 2014 | ||
1998 | 2015 | ||
1999 | put_mpu_out: |
2016 | put_mpu_out: |
2000 | 2017 | ||
2001 | push edx |
2018 | push edx |
2002 | mov dx, word [mididp] |
2019 | mov dx, word [mididp] |
2003 | out dx, al |
2020 | out dx, al |
2004 | pop edx |
2021 | pop edx |
2005 | ret |
2022 | ret |
2006 | 2023 | ||
2007 | 2024 | ||
2008 | 2025 | ||
2009 | align 4 |
2026 | align 4 |
2010 | 2027 | ||
2011 | sys_midi: |
2028 | sys_midi: |
2012 | cmp [mididp], 0 |
2029 | cmp [mididp], 0 |
2013 | jnz sm0 |
2030 | jnz sm0 |
2014 | mov [esp+36], dword 1 |
2031 | mov [esp+36], dword 1 |
2015 | ret |
2032 | ret |
2016 | sm0: |
2033 | sm0: |
2017 | and [esp+36], dword 0 |
2034 | and [esp+36], dword 0 |
2018 | dec ebx |
2035 | dec ebx |
2019 | jnz smn1 |
2036 | jnz smn1 |
2020 | ; call setuart |
2037 | ; call setuart |
2021 | su1: |
2038 | su1: |
2022 | call is_output |
2039 | call is_output |
2023 | test al, al |
2040 | test al, al |
2024 | jnz su1 |
2041 | jnz su1 |
2025 | mov dx, word [midisp] |
2042 | mov dx, word [midisp] |
2026 | mov al, 0xff |
2043 | mov al, 0xff |
2027 | out dx, al |
2044 | out dx, al |
2028 | su2: |
2045 | su2: |
2029 | mov dx, word [midisp] |
2046 | mov dx, word [midisp] |
2030 | mov al, 0xff |
2047 | mov al, 0xff |
2031 | out dx, al |
2048 | out dx, al |
2032 | call is_input |
2049 | call is_input |
2033 | test al, al |
2050 | test al, al |
2034 | jnz su2 |
2051 | jnz su2 |
2035 | call get_mpu_in |
2052 | call get_mpu_in |
2036 | cmp al, 0xfe |
2053 | cmp al, 0xfe |
2037 | jnz su2 |
2054 | jnz su2 |
2038 | su3: |
2055 | su3: |
2039 | call is_output |
2056 | call is_output |
2040 | test al, al |
2057 | test al, al |
2041 | jnz su3 |
2058 | jnz su3 |
2042 | mov dx, word [midisp] |
2059 | mov dx, word [midisp] |
2043 | mov al, 0x3f |
2060 | mov al, 0x3f |
2044 | out dx, al |
2061 | out dx, al |
2045 | ret |
2062 | ret |
2046 | smn1: |
2063 | smn1: |
2047 | dec ebx |
2064 | dec ebx |
2048 | jnz smn2 |
2065 | jnz smn2 |
2049 | sm10: |
2066 | sm10: |
2050 | call get_mpu_in |
2067 | call get_mpu_in |
2051 | call is_output |
2068 | call is_output |
2052 | test al, al |
2069 | test al, al |
2053 | jnz sm10 |
2070 | jnz sm10 |
2054 | mov al, bl |
2071 | mov al, bl |
2055 | call put_mpu_out |
2072 | call put_mpu_out |
2056 | smn2: |
2073 | smn2: |
2057 | ret |
2074 | ret |
2058 | 2075 | ||
2059 | detect_devices: |
2076 | detect_devices: |
2060 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2077 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2061 | ;include 'detect/commouse.inc' |
2078 | ;include 'detect/commouse.inc' |
2062 | ;include 'detect/ps2mouse.inc' |
2079 | ;include 'detect/ps2mouse.inc' |
2063 | ;include 'detect/dev_fd.inc' |
2080 | ;include 'detect/dev_fd.inc' |
2064 | ;include 'detect/dev_hdcd.inc' |
2081 | ;include 'detect/dev_hdcd.inc' |
2065 | ;include 'detect/sear_par.inc' |
2082 | ;include 'detect/sear_par.inc' |
2066 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2083 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2067 | ret |
2084 | ret |
2068 | 2085 | ||
2069 | sys_end: |
2086 | sys_end: |
2070 | ;-------------------------------------- |
2087 | ;-------------------------------------- |
2071 | cmp [_display.select_cursor], 0 |
2088 | cmp [_display.select_cursor], 0 |
2072 | je @f |
2089 | je @f |
2073 | ; restore default cursor before killing |
2090 | ; restore default cursor before killing |
2074 | pusha |
2091 | pusha |
2075 | mov ecx, [current_slot] |
2092 | mov ecx, [current_slot] |
2076 | call restore_default_cursor_before_killing |
2093 | call restore_default_cursor_before_killing |
2077 | popa |
2094 | popa |
2078 | @@: |
2095 | @@: |
2079 | ;-------------------------------------- |
2096 | ;-------------------------------------- |
2080 | ; kill all sockets this process owns |
2097 | ; kill all sockets this process owns |
2081 | pusha |
2098 | pusha |
2082 | mov edx, [TASK_BASE] |
2099 | mov edx, [TASK_BASE] |
2083 | mov edx, [edx+TASKDATA.pid] |
2100 | mov edx, [edx+TASKDATA.pid] |
2084 | call socket_process_end |
2101 | call socket_process_end |
2085 | popa |
2102 | popa |
2086 | ;-------------------------------------- |
2103 | ;-------------------------------------- |
2087 | mov ecx, [current_slot] |
2104 | mov ecx, [current_slot] |
2088 | mov eax, [ecx+APPDATA.tls_base] |
2105 | mov eax, [ecx+APPDATA.tls_base] |
2089 | test eax, eax |
2106 | test eax, eax |
2090 | jz @F |
2107 | jz @F |
2091 | 2108 | ||
2092 | stdcall user_free, eax |
2109 | stdcall user_free, eax |
2093 | @@: |
2110 | @@: |
2094 | 2111 | ||
2095 | mov eax, [TASK_BASE] |
2112 | mov eax, [TASK_BASE] |
2096 | mov [eax+TASKDATA.state], TSTATE_ZOMBIE |
2113 | mov [eax+TASKDATA.state], TSTATE_ZOMBIE |
2097 | call wakeup_osloop |
2114 | call wakeup_osloop |
2098 | 2115 | ||
2099 | .waitterm: ; wait here for termination |
2116 | .waitterm: ; wait here for termination |
2100 | call change_task |
2117 | call change_task |
2101 | jmp .waitterm |
2118 | jmp .waitterm |
2102 | ;------------------------------------------------------------------------------ |
2119 | ;------------------------------------------------------------------------------ |
2103 | align 4 |
2120 | align 4 |
2104 | restore_default_cursor_before_killing: |
2121 | restore_default_cursor_before_killing: |
2105 | pushfd |
2122 | pushfd |
2106 | cli |
2123 | cli |
2107 | mov eax, [def_cursor] |
2124 | mov eax, [def_cursor] |
2108 | mov [ecx+APPDATA.cursor], eax |
2125 | mov [ecx+APPDATA.cursor], eax |
2109 | 2126 | ||
2110 | movzx eax, word [MOUSE_Y] |
2127 | movzx eax, word [MOUSE_Y] |
2111 | movzx ebx, word [MOUSE_X] |
2128 | movzx ebx, word [MOUSE_X] |
2112 | mov eax, [d_width_calc_area + eax*4] |
2129 | mov eax, [d_width_calc_area + eax*4] |
2113 | 2130 | ||
2114 | add eax, [_display.win_map] |
2131 | add eax, [_display.win_map] |
2115 | movzx edx, byte [ebx+eax] |
2132 | movzx edx, byte [ebx+eax] |
2116 | shl edx, 8 |
2133 | shl edx, 8 |
2117 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2134 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2118 | 2135 | ||
2119 | cmp esi, [current_cursor] |
2136 | cmp esi, [current_cursor] |
2120 | je @f |
2137 | je @f |
2121 | 2138 | ||
2122 | push esi |
2139 | push esi |
2123 | call [_display.select_cursor] |
2140 | call [_display.select_cursor] |
2124 | mov [current_cursor], esi |
2141 | mov [current_cursor], esi |
2125 | @@: |
2142 | @@: |
2126 | mov [redrawmouse_unconditional], 1 |
2143 | mov [redrawmouse_unconditional], 1 |
2127 | call wakeup_osloop |
2144 | call wakeup_osloop |
2128 | popfd |
2145 | popfd |
2129 | ret |
2146 | ret |
2130 | ;------------------------------------------------------------------------------ |
2147 | ;------------------------------------------------------------------------------ |
2131 | iglobal |
2148 | iglobal |
2132 | align 4 |
2149 | align 4 |
2133 | sys_system_table: |
2150 | sys_system_table: |
2134 | dd sysfn_deactivate ; 1 = deactivate window |
2151 | dd sysfn_deactivate ; 1 = deactivate window |
2135 | dd sysfn_terminate ; 2 = terminate thread |
2152 | dd sysfn_terminate ; 2 = terminate thread |
2136 | dd sysfn_activate ; 3 = activate window |
2153 | dd sysfn_activate ; 3 = activate window |
2137 | dd sysfn_getidletime ; 4 = get idle time |
2154 | dd sysfn_getidletime ; 4 = get idle time |
2138 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2155 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2139 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2156 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2140 | dd sysfn_getactive ; 7 = get active window |
2157 | dd sysfn_getactive ; 7 = get active window |
2141 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2158 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2142 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2159 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2143 | dd sysfn_minimize ; 10 = minimize window |
2160 | dd sysfn_minimize ; 10 = minimize window |
2144 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2161 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2145 | dd sysfn_lastkey ; 12 = get last pressed key |
2162 | dd sysfn_lastkey ; 12 = get last pressed key |
2146 | dd sysfn_getversion ; 13 = get kernel version |
2163 | dd sysfn_getversion ; 13 = get kernel version |
2147 | dd sysfn_waitretrace ; 14 = wait retrace |
2164 | dd sysfn_waitretrace ; 14 = wait retrace |
2148 | dd sysfn_centermouse ; 15 = center mouse cursor |
2165 | dd sysfn_centermouse ; 15 = center mouse cursor |
2149 | dd sysfn_getfreemem ; 16 = get free memory size |
2166 | dd sysfn_getfreemem ; 16 = get free memory size |
2150 | dd sysfn_getallmem ; 17 = get total memory size |
2167 | dd sysfn_getallmem ; 17 = get total memory size |
2151 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2168 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2152 | ; instead of slot |
2169 | ; instead of slot |
2153 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2170 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2154 | dd sysfn_meminfo ; 20 = get extended memory info |
2171 | dd sysfn_meminfo ; 20 = get extended memory info |
2155 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2172 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2156 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2173 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2157 | dd sysfn_min_windows ; 23 = minimize all windows |
2174 | dd sysfn_min_windows ; 23 = minimize all windows |
2158 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2175 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2159 | 2176 | ||
2160 | dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer |
2177 | dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer |
2161 | sysfn_num = ($ - sys_system_table)/4 |
2178 | sysfn_num = ($ - sys_system_table)/4 |
2162 | endg |
2179 | endg |
2163 | ;------------------------------------------------------------------------------ |
2180 | ;------------------------------------------------------------------------------ |
2164 | sys_system: |
2181 | sys_system: |
2165 | dec ebx |
2182 | dec ebx |
2166 | cmp ebx, sysfn_num |
2183 | cmp ebx, sysfn_num |
2167 | jae @f |
2184 | jae @f |
2168 | jmp dword [sys_system_table + ebx*4] |
2185 | jmp dword [sys_system_table + ebx*4] |
2169 | @@: |
2186 | @@: |
2170 | ret |
2187 | ret |
2171 | ;------------------------------------------------------------------------------ |
2188 | ;------------------------------------------------------------------------------ |
2172 | sysfn_shutdown: ; 18.9 = system shutdown |
2189 | sysfn_shutdown: ; 18.9 = system shutdown |
2173 | cmp ecx, 1 |
2190 | cmp ecx, 1 |
2174 | jl exit_for_anyone |
2191 | jl exit_for_anyone |
2175 | cmp ecx, 4 |
2192 | cmp ecx, 4 |
2176 | jg exit_for_anyone |
2193 | jg exit_for_anyone |
2177 | mov [BOOT_VARS+0x9030], cl |
2194 | mov [BOOT_VARS+0x9030], cl |
2178 | 2195 | ||
2179 | mov eax, [TASK_COUNT] |
2196 | mov eax, [TASK_COUNT] |
2180 | mov [SYS_SHUTDOWN], al |
2197 | mov [SYS_SHUTDOWN], al |
2181 | mov [shutdown_processes], eax |
2198 | mov [shutdown_processes], eax |
2182 | call wakeup_osloop |
2199 | call wakeup_osloop |
2183 | and dword [esp+32], 0 |
2200 | and dword [esp+32], 0 |
2184 | exit_for_anyone: |
2201 | exit_for_anyone: |
2185 | ret |
2202 | ret |
2186 | uglobal |
2203 | uglobal |
2187 | shutdown_processes: |
2204 | shutdown_processes: |
2188 | dd 0x0 |
2205 | dd 0x0 |
2189 | endg |
2206 | endg |
2190 | ;------------------------------------------------------------------------------ |
2207 | ;------------------------------------------------------------------------------ |
2191 | sysfn_terminate: ; 18.2 = TERMINATE |
2208 | sysfn_terminate: ; 18.2 = TERMINATE |
2192 | push ecx |
2209 | push ecx |
2193 | cmp ecx, 2 |
2210 | cmp ecx, 2 |
2194 | jb noprocessterminate |
2211 | jb noprocessterminate |
2195 | mov edx, [TASK_COUNT] |
2212 | mov edx, [TASK_COUNT] |
2196 | cmp ecx, edx |
2213 | cmp ecx, edx |
2197 | ja noprocessterminate |
2214 | ja noprocessterminate |
2198 | mov eax, [TASK_COUNT] |
2215 | mov eax, [TASK_COUNT] |
2199 | shl ecx, 5 |
2216 | shl ecx, 5 |
2200 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2217 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2201 | add ecx, CURRENT_TASK+TASKDATA.state |
2218 | add ecx, CURRENT_TASK+TASKDATA.state |
2202 | cmp byte [ecx], 9 |
2219 | cmp byte [ecx], 9 |
2203 | jz noprocessterminate |
2220 | jz noprocessterminate |
2204 | push ecx edx |
2221 | push ecx edx |
2205 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2222 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2206 | call request_terminate |
2223 | call request_terminate |
2207 | pop edx ecx |
2224 | pop edx ecx |
2208 | test eax, eax |
2225 | test eax, eax |
2209 | jz noprocessterminate |
2226 | jz noprocessterminate |
2210 | ;-------------------------------------- |
2227 | ;-------------------------------------- |
2211 | ; terminate all network sockets it used |
2228 | ; terminate all network sockets it used |
2212 | pusha |
2229 | pusha |
2213 | mov eax, edx |
2230 | mov eax, edx |
2214 | call socket_process_end |
2231 | call socket_process_end |
2215 | popa |
2232 | popa |
2216 | ;-------------------------------------- |
2233 | ;-------------------------------------- |
2217 | cmp [_display.select_cursor], 0 |
2234 | cmp [_display.select_cursor], 0 |
2218 | je .restore_end |
2235 | je .restore_end |
2219 | ; restore default cursor before killing |
2236 | ; restore default cursor before killing |
2220 | pusha |
2237 | pusha |
2221 | mov ecx, [esp+32] |
2238 | mov ecx, [esp+32] |
2222 | shl ecx, 8 |
2239 | shl ecx, 8 |
2223 | add ecx, SLOT_BASE |
2240 | add ecx, SLOT_BASE |
2224 | mov eax, [def_cursor] |
2241 | mov eax, [def_cursor] |
2225 | cmp [ecx+APPDATA.cursor], eax |
2242 | cmp [ecx+APPDATA.cursor], eax |
2226 | je @f |
2243 | je @f |
2227 | call restore_default_cursor_before_killing |
2244 | call restore_default_cursor_before_killing |
2228 | @@: |
2245 | @@: |
2229 | popa |
2246 | popa |
2230 | .restore_end: |
2247 | .restore_end: |
2231 | ;-------------------------------------- |
2248 | ;-------------------------------------- |
2232 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2249 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2233 | mov [ecx], byte 3; clear possible i40's |
2250 | mov [ecx], byte 3; clear possible i40's |
2234 | call wakeup_osloop |
2251 | call wakeup_osloop |
2235 | ;call MEM_Heap_UnLock |
2252 | ;call MEM_Heap_UnLock |
2236 | 2253 | ||
2237 | cmp edx, [application_table_owner]; clear app table stat |
2254 | cmp edx, [application_table_owner]; clear app table stat |
2238 | jne noatsc |
2255 | jne noatsc |
2239 | call unlock_application_table |
2256 | call unlock_application_table |
2240 | noatsc: |
2257 | noatsc: |
2241 | noprocessterminate: |
2258 | noprocessterminate: |
2242 | add esp, 4 |
2259 | add esp, 4 |
2243 | ret |
2260 | ret |
2244 | ;------------------------------------------------------------------------------ |
2261 | ;------------------------------------------------------------------------------ |
2245 | sysfn_terminate2: |
2262 | sysfn_terminate2: |
2246 | ;lock application_table_status mutex |
2263 | ;lock application_table_status mutex |
2247 | .table_status: |
2264 | .table_status: |
2248 | call lock_application_table |
2265 | call lock_application_table |
2249 | mov eax, ecx |
2266 | mov eax, ecx |
2250 | call pid_to_slot |
2267 | call pid_to_slot |
2251 | test eax, eax |
2268 | test eax, eax |
2252 | jz .not_found |
2269 | jz .not_found |
2253 | mov ecx, eax |
2270 | mov ecx, eax |
2254 | cli |
2271 | cli |
2255 | call sysfn_terminate |
2272 | call sysfn_terminate |
2256 | call unlock_application_table |
2273 | call unlock_application_table |
2257 | sti |
2274 | sti |
2258 | and dword [esp+32], 0 |
2275 | and dword [esp+32], 0 |
2259 | ret |
2276 | ret |
2260 | .not_found: |
2277 | .not_found: |
2261 | call unlock_application_table |
2278 | call unlock_application_table |
2262 | or dword [esp+32], -1 |
2279 | or dword [esp+32], -1 |
2263 | ret |
2280 | ret |
2264 | ;------------------------------------------------------------------------------ |
2281 | ;------------------------------------------------------------------------------ |
2265 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2282 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2266 | cmp ecx, 2 |
2283 | cmp ecx, 2 |
2267 | jb .nowindowdeactivate |
2284 | jb .nowindowdeactivate |
2268 | cmp ecx, [TASK_COUNT] |
2285 | cmp ecx, [TASK_COUNT] |
2269 | ja .nowindowdeactivate |
2286 | ja .nowindowdeactivate |
2270 | 2287 | ||
2271 | movzx esi, word [WIN_STACK + ecx*2] |
2288 | movzx esi, word [WIN_STACK + ecx*2] |
2272 | cmp esi, 1 |
2289 | cmp esi, 1 |
2273 | je .nowindowdeactivate ; already deactive |
2290 | je .nowindowdeactivate ; already deactive |
2274 | 2291 | ||
2275 | mov edi, ecx |
2292 | mov edi, ecx |
2276 | shl edi, 5 |
2293 | shl edi, 5 |
2277 | add edi, window_data |
2294 | add edi, window_data |
2278 | movzx esi, word [WIN_STACK + ecx * 2] |
2295 | movzx esi, word [WIN_STACK + ecx * 2] |
2279 | lea esi, [WIN_POS + esi * 2] |
2296 | lea esi, [WIN_POS + esi * 2] |
2280 | call window._.window_deactivate |
2297 | call window._.window_deactivate |
2281 | - | ||
2282 | call syscall_display_settings._.calculate_whole_screen |
2298 | call syscall_display_settings.calculateScreen |
2283 | call syscall_display_settings._.redraw_whole_screen |
2299 | call syscall_display_settings.redrawScreen |
2284 | .nowindowdeactivate: |
2300 | .nowindowdeactivate: |
2285 | ret |
2301 | ret |
2286 | ;------------------------------------------------------------------------------ |
2302 | ;------------------------------------------------------------------------------ |
2287 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2303 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2288 | cmp ecx, 2 |
2304 | cmp ecx, 2 |
2289 | jb .nowindowactivate |
2305 | jb .nowindowactivate |
2290 | cmp ecx, [TASK_COUNT] |
2306 | cmp ecx, [TASK_COUNT] |
2291 | ja .nowindowactivate |
2307 | ja .nowindowactivate |
2292 | ;------------------------------------- |
2308 | ;------------------------------------- |
2293 | @@: |
2309 | @@: |
2294 | ; If the window is captured and moved by the user, |
2310 | ; If the window is captured and moved by the user, |
2295 | ; then you can't change the position in window stack!!! |
2311 | ; then you can't change the position in window stack!!! |
2296 | mov al, [mouse.active_sys_window.action] |
2312 | mov al, [mouse.active_sys_window.action] |
2297 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2313 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2298 | test al, al |
2314 | test al, al |
2299 | jz @f |
2315 | jz @f |
2300 | call change_task |
2316 | call change_task |
2301 | jmp @b |
2317 | jmp @b |
2302 | @@: |
2318 | @@: |
2303 | ;------------------------------------- |
2319 | ;------------------------------------- |
2304 | mov [window_minimize], 2; restore window if minimized |
2320 | mov [window_minimize], 2; restore window if minimized |
2305 | call wakeup_osloop |
2321 | call wakeup_osloop |
2306 | 2322 | ||
2307 | movzx esi, word [WIN_STACK + ecx*2] |
2323 | movzx esi, word [WIN_STACK + ecx*2] |
2308 | cmp esi, [TASK_COUNT] |
2324 | cmp esi, [TASK_COUNT] |
2309 | je .nowindowactivate; already active |
2325 | je .nowindowactivate; already active |
2310 | 2326 | ||
2311 | mov edi, ecx |
2327 | mov edi, ecx |
2312 | shl edi, 5 |
2328 | shl edi, 5 |
2313 | add edi, window_data |
2329 | add edi, window_data |
2314 | movzx esi, word [WIN_STACK + ecx * 2] |
2330 | movzx esi, word [WIN_STACK + ecx * 2] |
2315 | lea esi, [WIN_POS + esi * 2] |
2331 | lea esi, [WIN_POS + esi * 2] |
2316 | call waredraw |
2332 | call waredraw |
2317 | .nowindowactivate: |
2333 | .nowindowactivate: |
2318 | ret |
2334 | ret |
2319 | ;------------------------------------------------------------------------------ |
2335 | ;------------------------------------------------------------------------------ |
2320 | align 4 |
2336 | align 4 |
2321 | sysfn_zmodif: |
2337 | sysfn_zmodif: |
2322 | ;18,25,1 - get z_modif |
2338 | ;18,25,1 - get z_modif |
2323 | ;18,25,2 - set z_modif |
2339 | ;18,25,2 - set z_modif |
2324 | ;edx = -1(for current task) or TID |
2340 | ;edx = -1(for current task) or TID |
2325 | ;esi(for 2) = new value z_modif |
2341 | ;esi(for 2) = new value z_modif |
2326 | ;return: |
2342 | ;return: |
2327 | ;1: eax = z_modif |
2343 | ;1: eax = z_modif |
2328 | ;2: eax=0(fail),1(success) for set z_modif |
2344 | ;2: eax=0(fail),1(success) for set z_modif |
2329 | 2345 | ||
2330 | cmp edx, -1 |
2346 | cmp edx, -1 |
2331 | jne @f |
2347 | jne @f |
2332 | mov edx, [CURRENT_TASK] |
2348 | mov edx, [CURRENT_TASK] |
2333 | @@: |
2349 | @@: |
2334 | cmp edx, [TASK_COUNT] |
2350 | cmp edx, [TASK_COUNT] |
2335 | ja .fail |
2351 | ja .fail |
2336 | cmp edx, 1 |
2352 | cmp edx, 1 |
2337 | je .fail |
2353 | je .fail |
2338 | 2354 | ||
2339 | mov eax, edx |
2355 | mov eax, edx |
2340 | shl edx, 5 |
2356 | shl edx, 5 |
2341 | 2357 | ||
2342 | cmp [edx + CURRENT_TASK + TASKDATA.state], 9 |
2358 | cmp [edx + CURRENT_TASK + TASKDATA.state], 9 |
2343 | je .fail |
2359 | je .fail |
2344 | 2360 | ||
2345 | cmp ecx, 1 |
2361 | cmp ecx, 1 |
2346 | jnz .set_zmod |
2362 | jnz .set_zmod |
2347 | 2363 | ||
2348 | mov al, [edx + window_data + WDATA.z_modif] |
2364 | mov al, [edx + window_data + WDATA.z_modif] |
2349 | jmp .exit |
2365 | jmp .exit |
2350 | 2366 | ||
2351 | .set_zmod: |
2367 | .set_zmod: |
2352 | cmp ecx, 2 |
2368 | cmp ecx, 2 |
2353 | jnz .fail |
2369 | jnz .fail |
2354 | 2370 | ||
2355 | mov ebx, esi |
2371 | mov ebx, esi |
2356 | mov esi, eax |
2372 | mov esi, eax |
2357 | 2373 | ||
2358 | cmp bl, ZPOS_ALWAYS_TOP |
2374 | cmp bl, ZPOS_ALWAYS_TOP |
2359 | jg .fail |
2375 | jg .fail |
2360 | 2376 | ||
2361 | mov [edx + window_data + WDATA.z_modif], bl |
2377 | mov [edx + window_data + WDATA.z_modif], bl |
2362 | 2378 | ||
2363 | mov eax, [edx + window_data + WDATA.box.left] |
2379 | mov eax, [edx + window_data + WDATA.box.left] |
2364 | mov ebx, [edx + window_data + WDATA.box.top] |
2380 | mov ebx, [edx + window_data + WDATA.box.top] |
2365 | mov ecx, [edx + window_data + WDATA.box.width] |
2381 | mov ecx, [edx + window_data + WDATA.box.width] |
2366 | mov edx, [edx + window_data + WDATA.box.height] |
2382 | mov edx, [edx + window_data + WDATA.box.height] |
2367 | add ecx, eax |
2383 | add ecx, eax |
2368 | add edx, ebx |
2384 | add edx, ebx |
2369 | call window._.set_screen |
2385 | call window._.set_screen |
2370 | call window._.set_top_wnd |
2386 | call window._.set_top_wnd |
2371 | call window._.redraw_top_wnd |
2387 | call window._.redraw_top_wnd |
2372 | 2388 | ||
2373 | shl esi, 5 |
2389 | shl esi, 5 |
2374 | mov [esi + window_data + WDATA.fl_redraw], 1 |
2390 | mov [esi + window_data + WDATA.fl_redraw], 1 |
2375 | 2391 | ||
2376 | 2392 | ||
2377 | mov eax, 1 |
2393 | mov eax, 1 |
2378 | jmp .exit |
2394 | jmp .exit |
2379 | .fail: |
2395 | .fail: |
2380 | xor eax, eax |
2396 | xor eax, eax |
2381 | .exit: |
2397 | .exit: |
2382 | mov [esp+32], eax |
2398 | mov [esp+32], eax |
2383 | ret |
2399 | ret |
2384 | 2400 | ||
2385 | ;------------------------------------------------------------------------------ |
2401 | ;------------------------------------------------------------------------------ |
2386 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2402 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2387 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2403 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2388 | mov [esp+32], eax |
2404 | mov [esp+32], eax |
2389 | ret |
2405 | ret |
2390 | ;------------------------------------------------------------------------------ |
2406 | ;------------------------------------------------------------------------------ |
2391 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2407 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2392 | mov eax, dword [cpu_freq] |
2408 | mov eax, dword [cpu_freq] |
2393 | mov [esp+32], eax |
2409 | mov [esp+32], eax |
2394 | ret |
2410 | ret |
2395 | ;------------------------------------------------------------------------------ |
2411 | ;------------------------------------------------------------------------------ |
2396 | get_cpu_freq: |
2412 | get_cpu_freq: |
2397 | mov eax, dword [cpu_freq] |
2413 | mov eax, dword [cpu_freq] |
2398 | mov edx, dword [cpu_freq+4] |
2414 | mov edx, dword [cpu_freq+4] |
2399 | ret |
2415 | ret |
2400 | ; SAVE ramdisk to /hd/1/menuet.img |
2416 | ; SAVE ramdisk to /hd/1/menuet.img |
2401 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2417 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2402 | include 'blkdev/rdsave.inc' |
2418 | include 'blkdev/rdsave.inc' |
2403 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2419 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2404 | ;------------------------------------------------------------------------------ |
2420 | ;------------------------------------------------------------------------------ |
2405 | align 4 |
2421 | align 4 |
2406 | sysfn_getactive: ; 18.7 = get active window |
2422 | sysfn_getactive: ; 18.7 = get active window |
2407 | mov eax, [TASK_COUNT] |
2423 | mov eax, [TASK_COUNT] |
2408 | movzx eax, word [WIN_POS + eax*2] |
2424 | movzx eax, word [WIN_POS + eax*2] |
2409 | mov [esp+32], eax |
2425 | mov [esp+32], eax |
2410 | ret |
2426 | ret |
2411 | ;------------------------------------------------------------------------------ |
2427 | ;------------------------------------------------------------------------------ |
2412 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2428 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2413 | ; cmp ecx,1 |
2429 | ; cmp ecx,1 |
2414 | dec ecx |
2430 | dec ecx |
2415 | jnz nogetsoundflag |
2431 | jnz nogetsoundflag |
2416 | movzx eax, byte [sound_flag]; get sound_flag |
2432 | movzx eax, byte [sound_flag]; get sound_flag |
2417 | mov [esp+32], eax |
2433 | mov [esp+32], eax |
2418 | ret |
2434 | ret |
2419 | nogetsoundflag: |
2435 | nogetsoundflag: |
2420 | ; cmp ecx,2 |
2436 | ; cmp ecx,2 |
2421 | dec ecx |
2437 | dec ecx |
2422 | jnz nosoundflag |
2438 | jnz nosoundflag |
2423 | xor byte [sound_flag], 1 |
2439 | xor byte [sound_flag], 1 |
2424 | nosoundflag: |
2440 | nosoundflag: |
2425 | ret |
2441 | ret |
2426 | ;------------------------------------------------------------------------------ |
2442 | ;------------------------------------------------------------------------------ |
2427 | sysfn_minimize: ; 18.10 = minimize window |
2443 | sysfn_minimize: ; 18.10 = minimize window |
2428 | mov [window_minimize], 1 |
2444 | mov [window_minimize], 1 |
2429 | call wakeup_osloop |
2445 | call wakeup_osloop |
2430 | ret |
2446 | ret |
2431 | ;------------------------------------------------------------------------------ |
2447 | ;------------------------------------------------------------------------------ |
2432 | align 4 |
2448 | align 4 |
2433 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2449 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2434 | dec ecx |
2450 | dec ecx |
2435 | jnz .exit |
2451 | jnz .exit |
2436 | .small_table: |
2452 | .small_table: |
2437 | mov edi, edx |
2453 | mov edi, edx |
2438 | mov esi, DRIVE_DATA |
2454 | mov esi, DRIVE_DATA |
2439 | mov ecx, DRIVE_DATA_SIZE ;10 |
2455 | mov ecx, DRIVE_DATA_SIZE ;10 |
2440 | cld |
2456 | cld |
2441 | rep movsb |
2457 | rep movsb |
2442 | .exit: |
2458 | .exit: |
2443 | ret |
2459 | ret |
2444 | ;------------------------------------------------------------------------------ |
2460 | ;------------------------------------------------------------------------------ |
2445 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2461 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2446 | and dword [esp+32], 0 |
2462 | and dword [esp+32], 0 |
2447 | ret |
2463 | ret |
2448 | ;------------------------------------------------------------------------------ |
2464 | ;------------------------------------------------------------------------------ |
2449 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2465 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2450 | mov edi, ecx |
2466 | mov edi, ecx |
2451 | mov esi, version_inf |
2467 | mov esi, version_inf |
2452 | mov ecx, version_end-version_inf |
2468 | mov ecx, version_end-version_inf |
2453 | rep movsb |
2469 | rep movsb |
2454 | ret |
2470 | ret |
2455 | ;------------------------------------------------------------------------------ |
2471 | ;------------------------------------------------------------------------------ |
2456 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2472 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2457 | ;wait retrace functions |
2473 | ;wait retrace functions |
2458 | sys_wait_retrace: |
2474 | sys_wait_retrace: |
2459 | mov edx, 0x3da |
2475 | mov edx, 0x3da |
2460 | WaitRetrace_loop: |
2476 | WaitRetrace_loop: |
2461 | in al, dx |
2477 | in al, dx |
2462 | test al, 1000b |
2478 | test al, 1000b |
2463 | jz WaitRetrace_loop |
2479 | jz WaitRetrace_loop |
2464 | and [esp+32], dword 0 |
2480 | and [esp+32], dword 0 |
2465 | ret |
2481 | ret |
2466 | ;------------------------------------------------------------------------------ |
2482 | ;------------------------------------------------------------------------------ |
2467 | align 4 |
2483 | align 4 |
2468 | sysfn_centermouse: ; 18.15 = mouse centered |
2484 | sysfn_centermouse: ; 18.15 = mouse centered |
2469 | mov eax, [_display.width] |
2485 | mov eax, [_display.width] |
2470 | shr eax, 1 |
2486 | shr eax, 1 |
2471 | mov [MOUSE_X], ax |
2487 | mov [MOUSE_X], ax |
2472 | mov eax, [_display.height] |
2488 | mov eax, [_display.height] |
2473 | shr eax, 1 |
2489 | shr eax, 1 |
2474 | mov [MOUSE_Y], ax |
2490 | mov [MOUSE_Y], ax |
2475 | call wakeup_osloop |
2491 | call wakeup_osloop |
2476 | xor eax, eax |
2492 | xor eax, eax |
2477 | and [esp+32], eax |
2493 | and [esp+32], eax |
2478 | ret |
2494 | ret |
2479 | ;------------------------------------------------------------------------------ |
2495 | ;------------------------------------------------------------------------------ |
2480 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2496 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2481 | cmp ecx, 8 |
2497 | cmp ecx, 8 |
2482 | jnc @f |
2498 | jnc @f |
2483 | jmp dword [.table+ecx*4] |
2499 | jmp dword [.table+ecx*4] |
2484 | .get_mouse_acceleration: |
2500 | .get_mouse_acceleration: |
2485 | xor eax, eax |
2501 | xor eax, eax |
2486 | mov ax, [mouse_speed_factor] |
2502 | mov ax, [mouse_speed_factor] |
2487 | mov [esp+32], eax |
2503 | mov [esp+32], eax |
2488 | ret |
2504 | ret |
2489 | .set_mouse_acceleration: |
2505 | .set_mouse_acceleration: |
2490 | mov [mouse_speed_factor], dx |
2506 | mov [mouse_speed_factor], dx |
2491 | ret |
2507 | ret |
2492 | .get_mouse_delay: |
2508 | .get_mouse_delay: |
2493 | xor eax, eax |
2509 | xor eax, eax |
2494 | mov al, [mouse_delay] |
2510 | mov al, [mouse_delay] |
2495 | mov [esp+32], eax |
2511 | mov [esp+32], eax |
2496 | ret |
2512 | ret |
2497 | .set_mouse_delay: |
2513 | .set_mouse_delay: |
2498 | mov [mouse_delay], dl |
2514 | mov [mouse_delay], dl |
2499 | @@: |
2515 | @@: |
2500 | ret |
2516 | ret |
2501 | .set_pointer_position: |
2517 | .set_pointer_position: |
2502 | cmp dx, word[_display.height] |
2518 | cmp dx, word[_display.height] |
2503 | jae @b |
2519 | jae @b |
2504 | rol edx, 16 |
2520 | rol edx, 16 |
2505 | cmp dx, word[_display.width] |
2521 | cmp dx, word[_display.width] |
2506 | jae @b |
2522 | jae @b |
2507 | mov [MOUSE_X], edx |
2523 | mov [MOUSE_X], edx |
2508 | mov [mouse_active], 1 |
2524 | mov [mouse_active], 1 |
2509 | jmp wakeup_osloop |
2525 | jmp wakeup_osloop |
2510 | .set_mouse_button: |
2526 | .set_mouse_button: |
2511 | mov [BTN_DOWN], edx |
2527 | mov [BTN_DOWN], edx |
2512 | mov [mouse_active], 1 |
2528 | mov [mouse_active], 1 |
2513 | jmp wakeup_osloop |
2529 | jmp wakeup_osloop |
2514 | .get_doubleclick_delay: |
2530 | .get_doubleclick_delay: |
2515 | xor eax, eax |
2531 | xor eax, eax |
2516 | mov al, [mouse_doubleclick_delay] |
2532 | mov al, [mouse_doubleclick_delay] |
2517 | mov [esp+32], eax |
2533 | mov [esp+32], eax |
2518 | ret |
2534 | ret |
2519 | .set_doubleclick_delay: |
2535 | .set_doubleclick_delay: |
2520 | mov [mouse_doubleclick_delay], dl |
2536 | mov [mouse_doubleclick_delay], dl |
2521 | ret |
2537 | ret |
2522 | align 4 |
2538 | align 4 |
2523 | .table: |
2539 | .table: |
2524 | dd .get_mouse_acceleration |
2540 | dd .get_mouse_acceleration |
2525 | dd .set_mouse_acceleration |
2541 | dd .set_mouse_acceleration |
2526 | dd .get_mouse_delay |
2542 | dd .get_mouse_delay |
2527 | dd .set_mouse_delay |
2543 | dd .set_mouse_delay |
2528 | dd .set_pointer_position |
2544 | dd .set_pointer_position |
2529 | dd .set_mouse_button |
2545 | dd .set_mouse_button |
2530 | dd .get_doubleclick_delay |
2546 | dd .get_doubleclick_delay |
2531 | dd .set_doubleclick_delay |
2547 | dd .set_doubleclick_delay |
2532 | ;------------------------------------------------------------------------------ |
2548 | ;------------------------------------------------------------------------------ |
2533 | sysfn_getfreemem: |
2549 | sysfn_getfreemem: |
2534 | mov eax, [pg_data.pages_free] |
2550 | mov eax, [pg_data.pages_free] |
2535 | shl eax, 2 |
2551 | shl eax, 2 |
2536 | mov [esp+32], eax |
2552 | mov [esp+32], eax |
2537 | ret |
2553 | ret |
2538 | ;------------------------------------------------------------------------------ |
2554 | ;------------------------------------------------------------------------------ |
2539 | sysfn_getallmem: |
2555 | sysfn_getallmem: |
2540 | mov eax, [MEM_AMOUNT] |
2556 | mov eax, [MEM_AMOUNT] |
2541 | shr eax, 10 |
2557 | shr eax, 10 |
2542 | mov [esp+32], eax |
2558 | mov [esp+32], eax |
2543 | ret |
2559 | ret |
2544 | ;------------------------------------------------------------------------------ |
2560 | ;------------------------------------------------------------------------------ |
2545 | sysfn_pid_to_slot: |
2561 | sysfn_pid_to_slot: |
2546 | mov eax, ecx |
2562 | mov eax, ecx |
2547 | call pid_to_slot |
2563 | call pid_to_slot |
2548 | mov [esp+32], eax |
2564 | mov [esp+32], eax |
2549 | ret |
2565 | ret |
2550 | ;------------------------------------------------------------------------------ |
2566 | ;------------------------------------------------------------------------------ |
2551 | sysfn_min_rest_window: |
2567 | sysfn_min_rest_window: |
2552 | pushad |
2568 | pushad |
2553 | mov eax, edx ; ebx - operating |
2569 | mov eax, edx ; ebx - operating |
2554 | shr ecx, 1 |
2570 | shr ecx, 1 |
2555 | jnc @f |
2571 | jnc @f |
2556 | call pid_to_slot |
2572 | call pid_to_slot |
2557 | @@: |
2573 | @@: |
2558 | or eax, eax ; eax - number of slot |
2574 | or eax, eax ; eax - number of slot |
2559 | jz .error |
2575 | jz .error |
2560 | cmp eax, 255 ; varify maximal slot number |
2576 | cmp eax, 255 ; varify maximal slot number |
2561 | ja .error |
2577 | ja .error |
2562 | movzx eax, word [WIN_STACK + eax*2] |
2578 | movzx eax, word [WIN_STACK + eax*2] |
2563 | shr ecx, 1 |
2579 | shr ecx, 1 |
2564 | jc .restore |
2580 | jc .restore |
2565 | ; .minimize: |
2581 | ; .minimize: |
2566 | call minimize_window |
2582 | call minimize_window |
2567 | jmp .exit |
2583 | jmp .exit |
2568 | .restore: |
2584 | .restore: |
2569 | call restore_minimized_window |
2585 | call restore_minimized_window |
2570 | .exit: |
2586 | .exit: |
2571 | popad |
2587 | popad |
2572 | xor eax, eax |
2588 | xor eax, eax |
2573 | mov [esp+32], eax |
2589 | mov [esp+32], eax |
2574 | ret |
2590 | ret |
2575 | .error: |
2591 | .error: |
2576 | popad |
2592 | popad |
2577 | xor eax, eax |
2593 | xor eax, eax |
2578 | dec eax |
2594 | dec eax |
2579 | mov [esp+32], eax |
2595 | mov [esp+32], eax |
2580 | ret |
2596 | ret |
2581 | ;------------------------------------------------------------------------------ |
2597 | ;------------------------------------------------------------------------------ |
2582 | sysfn_min_windows: |
2598 | sysfn_min_windows: |
2583 | call minimize_all_window |
2599 | call minimize_all_window |
2584 | mov [esp+32], eax |
2600 | mov [esp+32], eax |
2585 | call change_task |
2601 | call change_task |
2586 | ret |
2602 | ret |
2587 | ;------------------------------------------------------------------------------ |
2603 | ;------------------------------------------------------------------------------ |
2588 | sysfn_set_screen_sizes: |
2604 | sysfn_set_screen_sizes: |
2589 | cmp [SCR_MODE], word 0x13 |
2605 | cmp [SCR_MODE], word 0x13 |
2590 | jbe .exit |
2606 | jbe .exit |
2591 | 2607 | ||
2592 | cmp [_display.select_cursor], select_cursor |
2608 | cmp [_display.select_cursor], select_cursor |
2593 | jne .exit |
2609 | jne .exit |
2594 | 2610 | ||
2595 | cmp ecx, [display_width_standard] |
2611 | cmp ecx, [display_width_standard] |
2596 | ja .exit |
2612 | ja .exit |
2597 | 2613 | ||
2598 | cmp edx, [display_height_standard] |
2614 | cmp edx, [display_height_standard] |
2599 | ja .exit |
2615 | ja .exit |
2600 | 2616 | ||
2601 | pushfd |
2617 | pushfd |
2602 | cli |
2618 | cli |
2603 | mov eax, ecx |
2619 | mov eax, ecx |
2604 | mov ecx, [_display.lfb_pitch] |
2620 | mov ecx, [_display.lfb_pitch] |
2605 | mov [_display.width], eax |
2621 | mov [_display.width], eax |
2606 | dec eax |
2622 | dec eax |
2607 | mov [_display.height], edx |
2623 | mov [_display.height], edx |
2608 | dec edx |
2624 | dec edx |
2609 | ; eax - new Screen_Max_X |
2625 | ; eax - new Screen_Max_X |
2610 | ; edx - new Screen_Max_Y |
2626 | ; edx - new Screen_Max_Y |
2611 | mov [do_not_touch_winmap], 1 |
2627 | mov [do_not_touch_winmap], 1 |
2612 | call set_screen |
2628 | call set_screen |
2613 | mov [do_not_touch_winmap], 0 |
2629 | mov [do_not_touch_winmap], 0 |
2614 | popfd |
2630 | popfd |
2615 | call change_task |
2631 | call change_task |
2616 | .exit: |
2632 | .exit: |
2617 | ret |
2633 | ret |
2618 | ;------------------------------------------------------------------------------ |
2634 | ;------------------------------------------------------------------------------ |
2619 | uglobal |
2635 | uglobal |
2620 | screen_workarea RECT |
2636 | screen_workarea RECT |
2621 | display_width_standard dd 0 |
2637 | display_width_standard dd 0 |
2622 | display_height_standard dd 0 |
2638 | display_height_standard dd 0 |
2623 | do_not_touch_winmap db 0 |
2639 | do_not_touch_winmap db 0 |
2624 | window_minimize db 0 |
2640 | window_minimize db 0 |
2625 | sound_flag db 0 |
2641 | sound_flag db 0 |
2626 | 2642 | ||
2627 | endg |
2643 | endg |
2628 | 2644 | ||
2629 | UID_NONE=0 |
2645 | UID_NONE=0 |
2630 | UID_MENUETOS=1 ;official |
2646 | UID_MENUETOS=1 ;official |
2631 | UID_KOLIBRI=2 ;russian |
2647 | UID_KOLIBRI=2 ;russian |
2632 | 2648 | ||
2633 | iglobal |
2649 | iglobal |
2634 | version_inf: |
2650 | version_inf: |
2635 | db 0,7,7,0 ; version 0.7.7.0 |
2651 | db 0,7,7,0 ; version 0.7.7.0 |
2636 | db 0 |
2652 | db 0 |
2637 | .rev dd __REV__ |
2653 | .rev dd __REV__ |
2638 | version_end: |
2654 | version_end: |
2639 | endg |
2655 | endg |
2640 | ;------------------------------------------------------------------------------ |
2656 | ;------------------------------------------------------------------------------ |
2641 | align 4 |
2657 | align 4 |
2642 | sys_cachetodiskette: |
2658 | sys_cachetodiskette: |
2643 | cmp ebx, 1 |
2659 | cmp ebx, 1 |
2644 | jb .no_floppy_save |
2660 | jb .no_floppy_save |
2645 | cmp ebx, 2 |
2661 | cmp ebx, 2 |
2646 | ja .no_floppy_save |
2662 | ja .no_floppy_save |
2647 | call save_image |
2663 | call save_image |
2648 | mov [esp + 32], eax |
2664 | mov [esp + 32], eax |
2649 | ret |
2665 | ret |
2650 | .no_floppy_save: |
2666 | .no_floppy_save: |
2651 | mov [esp + 32], dword 1 |
2667 | mov [esp + 32], dword 1 |
2652 | ret |
2668 | ret |
2653 | ;------------------------------------------------------------------------------ |
2669 | ;------------------------------------------------------------------------------ |
2654 | uglobal |
2670 | uglobal |
2655 | ; bgrchanged dd 0x0 |
2671 | ; bgrchanged dd 0x0 |
2656 | align 4 |
2672 | align 4 |
2657 | bgrlockpid dd 0 |
2673 | bgrlockpid dd 0 |
2658 | bgrlock db 0 |
2674 | bgrlock db 0 |
2659 | endg |
2675 | endg |
2660 | ;------------------------------------------------------------------------------ |
2676 | ;------------------------------------------------------------------------------ |
2661 | align 4 |
2677 | align 4 |
2662 | sys_background: |
2678 | sys_background: |
2663 | cmp ebx, 1 ; BACKGROUND SIZE |
2679 | cmp ebx, 1 ; BACKGROUND SIZE |
2664 | jnz nosb1 |
2680 | jnz nosb1 |
2665 | test ecx, ecx |
2681 | test ecx, ecx |
2666 | jz sbgrr |
2682 | jz sbgrr |
2667 | 2683 | ||
2668 | test edx, edx |
2684 | test edx, edx |
2669 | jz sbgrr |
2685 | jz sbgrr |
2670 | ;-------------------------------------- |
2686 | ;-------------------------------------- |
2671 | align 4 |
2687 | align 4 |
2672 | @@: |
2688 | @@: |
2673 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2689 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2674 | bts dword [bgrlock], 0 |
2690 | bts dword [bgrlock], 0 |
2675 | jnc @f |
2691 | jnc @f |
2676 | call change_task |
2692 | call change_task |
2677 | jmp @b |
2693 | jmp @b |
2678 | ;-------------------------------------- |
2694 | ;-------------------------------------- |
2679 | align 4 |
2695 | align 4 |
2680 | @@: |
2696 | @@: |
2681 | mov [BgrDataWidth], ecx |
2697 | mov [BgrDataWidth], ecx |
2682 | mov [BgrDataHeight], edx |
2698 | mov [BgrDataHeight], edx |
2683 | ; mov [bgrchanged],1 |
2699 | ; mov [bgrchanged],1 |
2684 | 2700 | ||
2685 | pushad |
2701 | pushad |
2686 | ; return memory for old background |
2702 | ; return memory for old background |
2687 | mov eax, [img_background] |
2703 | mov eax, [img_background] |
2688 | cmp eax, static_background_data |
2704 | cmp eax, static_background_data |
2689 | jz @f |
2705 | jz @f |
2690 | stdcall kernel_free, eax |
2706 | stdcall kernel_free, eax |
2691 | ;-------------------------------------- |
2707 | ;-------------------------------------- |
2692 | align 4 |
2708 | align 4 |
2693 | @@: |
2709 | @@: |
2694 | ; calculate RAW size |
2710 | ; calculate RAW size |
2695 | xor eax, eax |
2711 | xor eax, eax |
2696 | inc eax |
2712 | inc eax |
2697 | cmp [BgrDataWidth], eax |
2713 | cmp [BgrDataWidth], eax |
2698 | jae @f |
2714 | jae @f |
2699 | mov [BgrDataWidth], eax |
2715 | mov [BgrDataWidth], eax |
2700 | ;-------------------------------------- |
2716 | ;-------------------------------------- |
2701 | align 4 |
2717 | align 4 |
2702 | @@: |
2718 | @@: |
2703 | cmp [BgrDataHeight], eax |
2719 | cmp [BgrDataHeight], eax |
2704 | jae @f |
2720 | jae @f |
2705 | mov [BgrDataHeight], eax |
2721 | mov [BgrDataHeight], eax |
2706 | ;-------------------------------------- |
2722 | ;-------------------------------------- |
2707 | align 4 |
2723 | align 4 |
2708 | @@: |
2724 | @@: |
2709 | mov eax, [BgrDataWidth] |
2725 | mov eax, [BgrDataWidth] |
2710 | imul eax, [BgrDataHeight] |
2726 | imul eax, [BgrDataHeight] |
2711 | lea eax, [eax*3] |
2727 | lea eax, [eax*3] |
2712 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2728 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2713 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2729 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2714 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2730 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2715 | shr eax, 12 |
2731 | shr eax, 12 |
2716 | inc eax |
2732 | inc eax |
2717 | shl eax, 12 |
2733 | shl eax, 12 |
2718 | mov [mem_BACKGROUND], eax |
2734 | mov [mem_BACKGROUND], eax |
2719 | ; get memory for new background |
2735 | ; get memory for new background |
2720 | stdcall kernel_alloc, eax |
2736 | stdcall kernel_alloc, eax |
2721 | test eax, eax |
2737 | test eax, eax |
2722 | jz .memfailed |
2738 | jz .memfailed |
2723 | mov [img_background], eax |
2739 | mov [img_background], eax |
2724 | jmp .exit |
2740 | jmp .exit |
2725 | ;-------------------------------------- |
2741 | ;-------------------------------------- |
2726 | align 4 |
2742 | align 4 |
2727 | .memfailed: |
2743 | .memfailed: |
2728 | ; revert to static monotone data |
2744 | ; revert to static monotone data |
2729 | mov [img_background], static_background_data |
2745 | mov [img_background], static_background_data |
2730 | xor eax, eax |
2746 | xor eax, eax |
2731 | inc eax |
2747 | inc eax |
2732 | mov [BgrDataWidth], eax |
2748 | mov [BgrDataWidth], eax |
2733 | mov [BgrDataHeight], eax |
2749 | mov [BgrDataHeight], eax |
2734 | mov [mem_BACKGROUND], 4 |
2750 | mov [mem_BACKGROUND], 4 |
2735 | ;-------------------------------------- |
2751 | ;-------------------------------------- |
2736 | align 4 |
2752 | align 4 |
2737 | .exit: |
2753 | .exit: |
2738 | popad |
2754 | popad |
2739 | mov [bgrlock], 0 |
2755 | mov [bgrlock], 0 |
2740 | ;-------------------------------------- |
2756 | ;-------------------------------------- |
2741 | align 4 |
2757 | align 4 |
2742 | sbgrr: |
2758 | sbgrr: |
2743 | ret |
2759 | ret |
2744 | ;------------------------------------------------------------------------------ |
2760 | ;------------------------------------------------------------------------------ |
2745 | align 4 |
2761 | align 4 |
2746 | nosb1: |
2762 | nosb1: |
2747 | cmp ebx, 2 ; SET PIXEL |
2763 | cmp ebx, 2 ; SET PIXEL |
2748 | jnz nosb2 |
2764 | jnz nosb2 |
2749 | 2765 | ||
2750 | mov eax, [img_background] |
2766 | mov eax, [img_background] |
2751 | test ecx, ecx |
2767 | test ecx, ecx |
2752 | jz @f |
2768 | jz @f |
2753 | cmp eax, static_background_data |
2769 | cmp eax, static_background_data |
2754 | jz .ret |
2770 | jz .ret |
2755 | ;-------------------------------------- |
2771 | ;-------------------------------------- |
2756 | align 4 |
2772 | align 4 |
2757 | @@: |
2773 | @@: |
2758 | mov ebx, [mem_BACKGROUND] |
2774 | mov ebx, [mem_BACKGROUND] |
2759 | add ebx, 4095 |
2775 | add ebx, 4095 |
2760 | and ebx, -4096 |
2776 | and ebx, -4096 |
2761 | sub ebx, 4 |
2777 | sub ebx, 4 |
2762 | cmp ecx, ebx |
2778 | cmp ecx, ebx |
2763 | ja .ret |
2779 | ja .ret |
2764 | 2780 | ||
2765 | mov ebx, [eax+ecx] |
2781 | mov ebx, [eax+ecx] |
2766 | and ebx, 0xFF000000;255*256*256*256 |
2782 | and ebx, 0xFF000000;255*256*256*256 |
2767 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2783 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2768 | add edx, ebx |
2784 | add edx, ebx |
2769 | mov [eax+ecx], edx |
2785 | mov [eax+ecx], edx |
2770 | ;-------------------------------------- |
2786 | ;-------------------------------------- |
2771 | align 4 |
2787 | align 4 |
2772 | .ret: |
2788 | .ret: |
2773 | ret |
2789 | ret |
2774 | ;------------------------------------------------------------------------------ |
2790 | ;------------------------------------------------------------------------------ |
2775 | align 4 |
2791 | align 4 |
2776 | nosb2: |
2792 | nosb2: |
2777 | cmp ebx, 3 ; DRAW BACKGROUND |
2793 | cmp ebx, 3 ; DRAW BACKGROUND |
2778 | jnz nosb3 |
2794 | jnz nosb3 |
2779 | ;-------------------------------------- |
2795 | ;-------------------------------------- |
2780 | align 4 |
2796 | align 4 |
2781 | draw_background_temp: |
2797 | draw_background_temp: |
2782 | mov [background_defined], 1 |
2798 | mov [background_defined], 1 |
2783 | call force_redraw_background |
2799 | call force_redraw_background |
2784 | ;-------------------------------------- |
2800 | ;-------------------------------------- |
2785 | align 4 |
2801 | align 4 |
2786 | nosb31: |
2802 | nosb31: |
2787 | ret |
2803 | ret |
2788 | ;------------------------------------------------------------------------------ |
2804 | ;------------------------------------------------------------------------------ |
2789 | align 4 |
2805 | align 4 |
2790 | nosb3: |
2806 | nosb3: |
2791 | cmp ebx, 4 ; TILED / STRETCHED |
2807 | cmp ebx, 4 ; TILED / STRETCHED |
2792 | jnz nosb4 |
2808 | jnz nosb4 |
2793 | cmp ecx, [BgrDrawMode] |
2809 | cmp ecx, [BgrDrawMode] |
2794 | je nosb41 |
2810 | je nosb41 |
2795 | mov [BgrDrawMode], ecx |
2811 | mov [BgrDrawMode], ecx |
2796 | ;-------------------------------------- |
2812 | ;-------------------------------------- |
2797 | align 4 |
2813 | align 4 |
2798 | nosb41: |
2814 | nosb41: |
2799 | ret |
2815 | ret |
2800 | ;------------------------------------------------------------------------------ |
2816 | ;------------------------------------------------------------------------------ |
2801 | align 4 |
2817 | align 4 |
2802 | nosb4: |
2818 | nosb4: |
2803 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2819 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2804 | jnz nosb5 |
2820 | jnz nosb5 |
2805 | cmp [img_background], static_background_data |
2821 | cmp [img_background], static_background_data |
2806 | jnz @f |
2822 | jnz @f |
2807 | test edx, edx |
2823 | test edx, edx |
2808 | jnz .fin |
2824 | jnz .fin |
2809 | cmp esi, 4 |
2825 | cmp esi, 4 |
2810 | ja .fin |
2826 | ja .fin |
2811 | ;-------------------------------------- |
2827 | ;-------------------------------------- |
2812 | align 4 |
2828 | align 4 |
2813 | @@: |
2829 | @@: |
2814 | ; bughere |
2830 | ; bughere |
2815 | mov eax, ecx |
2831 | mov eax, ecx |
2816 | mov ebx, edx |
2832 | mov ebx, edx |
2817 | add ebx, [img_background];IMG_BACKGROUND |
2833 | add ebx, [img_background];IMG_BACKGROUND |
2818 | mov ecx, esi |
2834 | mov ecx, esi |
2819 | call memmove |
2835 | call memmove |
2820 | ;-------------------------------------- |
2836 | ;-------------------------------------- |
2821 | align 4 |
2837 | align 4 |
2822 | .fin: |
2838 | .fin: |
2823 | ret |
2839 | ret |
2824 | ;------------------------------------------------------------------------------ |
2840 | ;------------------------------------------------------------------------------ |
2825 | align 4 |
2841 | align 4 |
2826 | nosb5: |
2842 | nosb5: |
2827 | cmp ebx, 6 |
2843 | cmp ebx, 6 |
2828 | jnz nosb6 |
2844 | jnz nosb6 |
2829 | ;-------------------------------------- |
2845 | ;-------------------------------------- |
2830 | align 4 |
2846 | align 4 |
2831 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2847 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2832 | @@: |
2848 | @@: |
2833 | bts dword [bgrlock], 0 |
2849 | bts dword [bgrlock], 0 |
2834 | jnc @f |
2850 | jnc @f |
2835 | call change_task |
2851 | call change_task |
2836 | jmp @b |
2852 | jmp @b |
2837 | ;-------------------------------------- |
2853 | ;-------------------------------------- |
2838 | align 4 |
2854 | align 4 |
2839 | @@: |
2855 | @@: |
2840 | mov eax, [CURRENT_TASK] |
2856 | mov eax, [CURRENT_TASK] |
2841 | mov [bgrlockpid], eax |
2857 | mov [bgrlockpid], eax |
2842 | cmp [img_background], static_background_data |
2858 | cmp [img_background], static_background_data |
2843 | jz .nomem |
2859 | jz .nomem |
2844 | stdcall user_alloc, [mem_BACKGROUND] |
2860 | stdcall user_alloc, [mem_BACKGROUND] |
2845 | mov [esp+32], eax |
2861 | mov [esp+32], eax |
2846 | test eax, eax |
2862 | test eax, eax |
2847 | jz .nomem |
2863 | jz .nomem |
2848 | mov ebx, eax |
2864 | mov ebx, eax |
2849 | shr ebx, 12 |
2865 | shr ebx, 12 |
2850 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2866 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2851 | mov esi, [img_background] |
2867 | mov esi, [img_background] |
2852 | shr esi, 12 |
2868 | shr esi, 12 |
2853 | mov ecx, [mem_BACKGROUND] |
2869 | mov ecx, [mem_BACKGROUND] |
2854 | add ecx, 0xFFF |
2870 | add ecx, 0xFFF |
2855 | shr ecx, 12 |
2871 | shr ecx, 12 |
2856 | ;-------------------------------------- |
2872 | ;-------------------------------------- |
2857 | align 4 |
2873 | align 4 |
2858 | .z: |
2874 | .z: |
2859 | mov eax, [page_tabs+ebx*4] |
2875 | mov eax, [page_tabs+ebx*4] |
2860 | test al, 1 |
2876 | test al, 1 |
2861 | jz @f |
2877 | jz @f |
2862 | call free_page |
2878 | call free_page |
2863 | ;-------------------------------------- |
2879 | ;-------------------------------------- |
2864 | align 4 |
2880 | align 4 |
2865 | @@: |
2881 | @@: |
2866 | mov eax, [page_tabs+esi*4] |
2882 | mov eax, [page_tabs+esi*4] |
2867 | or al, PG_UWR |
2883 | or al, PG_UWR |
2868 | mov [page_tabs+ebx*4], eax |
2884 | mov [page_tabs+ebx*4], eax |
2869 | mov eax, ebx |
2885 | mov eax, ebx |
2870 | shl eax, 12 |
2886 | shl eax, 12 |
2871 | invlpg [eax] |
2887 | invlpg [eax] |
2872 | inc ebx |
2888 | inc ebx |
2873 | inc esi |
2889 | inc esi |
2874 | loop .z |
2890 | loop .z |
2875 | ret |
2891 | ret |
2876 | ;-------------------------------------- |
2892 | ;-------------------------------------- |
2877 | align 4 |
2893 | align 4 |
2878 | .nomem: |
2894 | .nomem: |
2879 | and [bgrlockpid], 0 |
2895 | and [bgrlockpid], 0 |
2880 | mov [bgrlock], 0 |
2896 | mov [bgrlock], 0 |
2881 | ;------------------------------------------------------------------------------ |
2897 | ;------------------------------------------------------------------------------ |
2882 | align 4 |
2898 | align 4 |
2883 | nosb6: |
2899 | nosb6: |
2884 | cmp ebx, 7 |
2900 | cmp ebx, 7 |
2885 | jnz nosb7 |
2901 | jnz nosb7 |
2886 | cmp [bgrlock], 0 |
2902 | cmp [bgrlock], 0 |
2887 | jz .err |
2903 | jz .err |
2888 | mov eax, [CURRENT_TASK] |
2904 | mov eax, [CURRENT_TASK] |
2889 | cmp [bgrlockpid], eax |
2905 | cmp [bgrlockpid], eax |
2890 | jnz .err |
2906 | jnz .err |
2891 | mov eax, ecx |
2907 | mov eax, ecx |
2892 | mov ebx, ecx |
2908 | mov ebx, ecx |
2893 | shr eax, 12 |
2909 | shr eax, 12 |
2894 | mov ecx, [page_tabs+(eax-1)*4] |
2910 | mov ecx, [page_tabs+(eax-1)*4] |
2895 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2911 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2896 | jz .err |
2912 | jz .err |
2897 | jnp .err |
2913 | jnp .err |
2898 | push eax |
2914 | push eax |
2899 | shr ecx, 12 |
2915 | shr ecx, 12 |
2900 | dec ecx |
2916 | dec ecx |
2901 | ;-------------------------------------- |
2917 | ;-------------------------------------- |
2902 | align 4 |
2918 | align 4 |
2903 | @@: |
2919 | @@: |
2904 | and dword [page_tabs+eax*4], 0 |
2920 | and dword [page_tabs+eax*4], 0 |
2905 | mov edx, eax |
2921 | mov edx, eax |
2906 | shl edx, 12 |
2922 | shl edx, 12 |
2907 | push eax |
2923 | push eax |
2908 | invlpg [edx] |
2924 | invlpg [edx] |
2909 | pop eax |
2925 | pop eax |
2910 | inc eax |
2926 | inc eax |
2911 | loop @b |
2927 | loop @b |
2912 | pop eax |
2928 | pop eax |
2913 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2929 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2914 | stdcall user_free, ebx |
2930 | stdcall user_free, ebx |
2915 | mov [esp+32], eax |
2931 | mov [esp+32], eax |
2916 | and [bgrlockpid], 0 |
2932 | and [bgrlockpid], 0 |
2917 | mov [bgrlock], 0 |
2933 | mov [bgrlock], 0 |
2918 | ret |
2934 | ret |
2919 | ;-------------------------------------- |
2935 | ;-------------------------------------- |
2920 | align 4 |
2936 | align 4 |
2921 | .err: |
2937 | .err: |
2922 | and dword [esp+32], 0 |
2938 | and dword [esp+32], 0 |
2923 | ret |
2939 | ret |
2924 | ;------------------------------------------------------------------------------ |
2940 | ;------------------------------------------------------------------------------ |
2925 | align 4 |
2941 | align 4 |
2926 | nosb7: |
2942 | nosb7: |
2927 | cmp ebx, 8 |
2943 | cmp ebx, 8 |
2928 | jnz nosb8 |
2944 | jnz nosb8 |
2929 | 2945 | ||
2930 | mov ecx, [current_slot] |
2946 | mov ecx, [current_slot] |
2931 | xor eax, eax |
2947 | xor eax, eax |
2932 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2948 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2933 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2949 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2934 | xor eax, eax |
2950 | xor eax, eax |
2935 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2951 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2936 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2952 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2937 | ret |
2953 | ret |
2938 | ;------------------------------------------------------------------------------ |
2954 | ;------------------------------------------------------------------------------ |
2939 | align 4 |
2955 | align 4 |
2940 | nosb8: |
2956 | nosb8: |
2941 | cmp ebx, 9 |
2957 | cmp ebx, 9 |
2942 | jnz nosb9 |
2958 | jnz nosb9 |
2943 | ; ecx = [left]*65536 + [right] |
2959 | ; ecx = [left]*65536 + [right] |
2944 | ; edx = [top]*65536 + [bottom] |
2960 | ; edx = [top]*65536 + [bottom] |
2945 | mov eax, [_display.width] |
2961 | mov eax, [_display.width] |
2946 | mov ebx, [_display.height] |
2962 | mov ebx, [_display.height] |
2947 | ; check [right] |
2963 | ; check [right] |
2948 | cmp cx, ax |
2964 | cmp cx, ax |
2949 | jae .exit |
2965 | jae .exit |
2950 | ; check [left] |
2966 | ; check [left] |
2951 | ror ecx, 16 |
2967 | ror ecx, 16 |
2952 | cmp cx, ax |
2968 | cmp cx, ax |
2953 | jae .exit |
2969 | jae .exit |
2954 | ; check [bottom] |
2970 | ; check [bottom] |
2955 | cmp dx, bx |
2971 | cmp dx, bx |
2956 | jae .exit |
2972 | jae .exit |
2957 | ; check [top] |
2973 | ; check [top] |
2958 | ror edx, 16 |
2974 | ror edx, 16 |
2959 | cmp dx, bx |
2975 | cmp dx, bx |
2960 | jae .exit |
2976 | jae .exit |
2961 | 2977 | ||
2962 | movzx eax, cx ; [left] |
2978 | movzx eax, cx ; [left] |
2963 | movzx ebx, dx ; [top] |
2979 | movzx ebx, dx ; [top] |
2964 | 2980 | ||
2965 | shr ecx, 16 ; [right] |
2981 | shr ecx, 16 ; [right] |
2966 | shr edx, 16 ; [bottom] |
2982 | shr edx, 16 ; [bottom] |
2967 | 2983 | ||
2968 | mov [background_defined], 1 |
2984 | mov [background_defined], 1 |
2969 | 2985 | ||
2970 | mov [draw_data+32 + RECT.left], eax |
2986 | mov [draw_data+32 + RECT.left], eax |
2971 | mov [draw_data+32 + RECT.top], ebx |
2987 | mov [draw_data+32 + RECT.top], ebx |
2972 | 2988 | ||
2973 | mov [draw_data+32 + RECT.right], ecx |
2989 | mov [draw_data+32 + RECT.right], ecx |
2974 | mov [draw_data+32 + RECT.bottom], edx |
2990 | mov [draw_data+32 + RECT.bottom], edx |
2975 | 2991 | ||
2976 | inc [REDRAW_BACKGROUND] |
2992 | inc [REDRAW_BACKGROUND] |
2977 | call wakeup_osloop |
2993 | call wakeup_osloop |
2978 | ;-------------------------------------- |
2994 | ;-------------------------------------- |
2979 | align 4 |
2995 | align 4 |
2980 | .exit: |
2996 | .exit: |
2981 | ret |
2997 | ret |
2982 | ;------------------------------------------------------------------------------ |
2998 | ;------------------------------------------------------------------------------ |
2983 | align 4 |
2999 | align 4 |
2984 | nosb9: |
3000 | nosb9: |
2985 | ret |
3001 | ret |
2986 | ;------------------------------------------------------------------------------ |
3002 | ;------------------------------------------------------------------------------ |
2987 | align 4 |
3003 | align 4 |
2988 | uglobal |
3004 | uglobal |
2989 | BG_Rect_X_left_right dd 0x0 |
3005 | BG_Rect_X_left_right dd 0x0 |
2990 | BG_Rect_Y_top_bottom dd 0x0 |
3006 | BG_Rect_Y_top_bottom dd 0x0 |
2991 | endg |
3007 | endg |
2992 | ;------------------------------------------------------------------------------ |
3008 | ;------------------------------------------------------------------------------ |
2993 | align 4 |
3009 | align 4 |
2994 | force_redraw_background: |
3010 | force_redraw_background: |
2995 | and [draw_data+32 + RECT.left], 0 |
3011 | and [draw_data+32 + RECT.left], 0 |
2996 | and [draw_data+32 + RECT.top], 0 |
3012 | and [draw_data+32 + RECT.top], 0 |
2997 | push eax ebx |
3013 | push eax ebx |
2998 | mov eax, [_display.width] |
3014 | mov eax, [_display.width] |
2999 | mov ebx, [_display.height] |
3015 | mov ebx, [_display.height] |
3000 | dec eax |
3016 | dec eax |
3001 | dec ebx |
3017 | dec ebx |
3002 | mov [draw_data+32 + RECT.right], eax |
3018 | mov [draw_data+32 + RECT.right], eax |
3003 | mov [draw_data+32 + RECT.bottom], ebx |
3019 | mov [draw_data+32 + RECT.bottom], ebx |
3004 | pop ebx eax |
3020 | pop ebx eax |
3005 | inc [REDRAW_BACKGROUND] |
3021 | inc [REDRAW_BACKGROUND] |
3006 | call wakeup_osloop |
3022 | call wakeup_osloop |
3007 | ret |
3023 | ret |
3008 | ;------------------------------------------------------------------------------ |
3024 | ;------------------------------------------------------------------------------ |
3009 | align 4 |
3025 | align 4 |
3010 | sys_getbackground: |
3026 | sys_getbackground: |
3011 | ; cmp eax,1 ; SIZE |
3027 | ; cmp eax,1 ; SIZE |
3012 | dec ebx |
3028 | dec ebx |
3013 | jnz nogb1 |
3029 | jnz nogb1 |
3014 | mov eax, [BgrDataWidth] |
3030 | mov eax, [BgrDataWidth] |
3015 | shl eax, 16 |
3031 | shl eax, 16 |
3016 | mov ax, word [BgrDataHeight] |
3032 | mov ax, word [BgrDataHeight] |
3017 | mov [esp+32], eax |
3033 | mov [esp+32], eax |
3018 | ret |
3034 | ret |
3019 | ;------------------------------------------------------------------------------ |
3035 | ;------------------------------------------------------------------------------ |
3020 | align 4 |
3036 | align 4 |
3021 | nogb1: |
3037 | nogb1: |
3022 | ; cmp eax,2 ; PIXEL |
3038 | ; cmp eax,2 ; PIXEL |
3023 | dec ebx |
3039 | dec ebx |
3024 | jnz nogb2 |
3040 | jnz nogb2 |
3025 | 3041 | ||
3026 | mov eax, [img_background] |
3042 | mov eax, [img_background] |
3027 | test ecx, ecx |
3043 | test ecx, ecx |
3028 | jz @f |
3044 | jz @f |
3029 | cmp eax, static_background_data |
3045 | cmp eax, static_background_data |
3030 | jz .ret |
3046 | jz .ret |
3031 | ;-------------------------------------- |
3047 | ;-------------------------------------- |
3032 | align 4 |
3048 | align 4 |
3033 | @@: |
3049 | @@: |
3034 | mov ebx, [mem_BACKGROUND] |
3050 | mov ebx, [mem_BACKGROUND] |
3035 | add ebx, 4095 |
3051 | add ebx, 4095 |
3036 | and ebx, -4096 |
3052 | and ebx, -4096 |
3037 | sub ebx, 4 |
3053 | sub ebx, 4 |
3038 | cmp ecx, ebx |
3054 | cmp ecx, ebx |
3039 | ja .ret |
3055 | ja .ret |
3040 | 3056 | ||
3041 | mov eax, [ecx+eax] |
3057 | mov eax, [ecx+eax] |
3042 | 3058 | ||
3043 | and eax, 0xFFFFFF |
3059 | and eax, 0xFFFFFF |
3044 | mov [esp+32], eax |
3060 | mov [esp+32], eax |
3045 | ;-------------------------------------- |
3061 | ;-------------------------------------- |
3046 | align 4 |
3062 | align 4 |
3047 | .ret: |
3063 | .ret: |
3048 | ret |
3064 | ret |
3049 | ;------------------------------------------------------------------------------ |
3065 | ;------------------------------------------------------------------------------ |
3050 | align 4 |
3066 | align 4 |
3051 | nogb2: |
3067 | nogb2: |
3052 | 3068 | ||
3053 | ; cmp eax,4 ; TILED / STRETCHED |
3069 | ; cmp eax,4 ; TILED / STRETCHED |
3054 | dec ebx |
3070 | dec ebx |
3055 | dec ebx |
3071 | dec ebx |
3056 | jnz nogb4 |
3072 | jnz nogb4 |
3057 | mov eax, [BgrDrawMode] |
3073 | mov eax, [BgrDrawMode] |
3058 | ;-------------------------------------- |
3074 | ;-------------------------------------- |
3059 | align 4 |
3075 | align 4 |
3060 | nogb4: |
3076 | nogb4: |
3061 | mov [esp+32], eax |
3077 | mov [esp+32], eax |
3062 | ret |
3078 | ret |
3063 | ;------------------------------------------------------------------------------ |
3079 | ;------------------------------------------------------------------------------ |
3064 | align 4 |
3080 | align 4 |
3065 | sys_getkey: |
3081 | sys_getkey: |
3066 | mov [esp + 32], dword 1 |
3082 | mov [esp + 32], dword 1 |
3067 | ; test main buffer |
3083 | ; test main buffer |
3068 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3084 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3069 | movzx ecx, word [WIN_STACK + ebx * 2] |
3085 | movzx ecx, word [WIN_STACK + ebx * 2] |
3070 | mov edx, [TASK_COUNT] |
3086 | mov edx, [TASK_COUNT] |
3071 | cmp ecx, edx |
3087 | cmp ecx, edx |
3072 | jne .finish |
3088 | jne .finish |
3073 | cmp [KEY_COUNT], byte 0 |
3089 | cmp [KEY_COUNT], byte 0 |
3074 | je .finish |
3090 | je .finish |
3075 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3091 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3076 | shl eax, 8 |
3092 | shl eax, 8 |
3077 | mov al, byte [KEY_BUFF] |
3093 | mov al, byte [KEY_BUFF] |
3078 | shl eax, 8 |
3094 | shl eax, 8 |
3079 | push eax |
3095 | push eax |
3080 | dec byte [KEY_COUNT] |
3096 | dec byte [KEY_COUNT] |
3081 | and byte [KEY_COUNT], 127 |
3097 | and byte [KEY_COUNT], 127 |
3082 | movzx ecx, byte [KEY_COUNT] |
3098 | movzx ecx, byte [KEY_COUNT] |
3083 | add ecx, 2 |
3099 | add ecx, 2 |
3084 | mov eax, KEY_BUFF + 1 |
3100 | mov eax, KEY_BUFF + 1 |
3085 | mov ebx, KEY_BUFF |
3101 | mov ebx, KEY_BUFF |
3086 | call memmove |
3102 | call memmove |
3087 | add eax, 120 + 2 |
3103 | add eax, 120 + 2 |
3088 | add ebx, 120 + 2 |
3104 | add ebx, 120 + 2 |
3089 | call memmove |
3105 | call memmove |
3090 | pop eax |
3106 | pop eax |
3091 | ;-------------------------------------- |
3107 | ;-------------------------------------- |
3092 | align 4 |
3108 | align 4 |
3093 | .ret_eax: |
3109 | .ret_eax: |
3094 | mov [esp + 32], eax |
3110 | mov [esp + 32], eax |
3095 | ret |
3111 | ret |
3096 | ;-------------------------------------- |
3112 | ;-------------------------------------- |
3097 | align 4 |
3113 | align 4 |
3098 | .finish: |
3114 | .finish: |
3099 | ; test hotkeys buffer |
3115 | ; test hotkeys buffer |
3100 | mov ecx, hotkey_buffer |
3116 | mov ecx, hotkey_buffer |
3101 | ;-------------------------------------- |
3117 | ;-------------------------------------- |
3102 | align 4 |
3118 | align 4 |
3103 | @@: |
3119 | @@: |
3104 | cmp [ecx], ebx |
3120 | cmp [ecx], ebx |
3105 | jz .found |
3121 | jz .found |
3106 | add ecx, 8 |
3122 | add ecx, 8 |
3107 | cmp ecx, hotkey_buffer + 120 * 8 |
3123 | cmp ecx, hotkey_buffer + 120 * 8 |
3108 | jb @b |
3124 | jb @b |
3109 | ret |
3125 | ret |
3110 | ;-------------------------------------- |
3126 | ;-------------------------------------- |
3111 | align 4 |
3127 | align 4 |
3112 | .found: |
3128 | .found: |
3113 | mov ax, [ecx + 6] |
3129 | mov ax, [ecx + 6] |
3114 | shl eax, 16 |
3130 | shl eax, 16 |
3115 | mov ah, [ecx + 4] |
3131 | mov ah, [ecx + 4] |
3116 | mov al, 2 |
3132 | mov al, 2 |
3117 | and dword [ecx + 4], 0 |
3133 | and dword [ecx + 4], 0 |
3118 | and dword [ecx], 0 |
3134 | and dword [ecx], 0 |
3119 | jmp .ret_eax |
3135 | jmp .ret_eax |
3120 | ;------------------------------------------------------------------------------ |
3136 | ;------------------------------------------------------------------------------ |
3121 | align 4 |
3137 | align 4 |
3122 | sys_getbutton: |
3138 | sys_getbutton: |
3123 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3139 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3124 | mov [esp + 32], dword 1 |
3140 | mov [esp + 32], dword 1 |
3125 | movzx ecx, word [WIN_STACK + ebx * 2] |
3141 | movzx ecx, word [WIN_STACK + ebx * 2] |
3126 | mov edx, [TASK_COUNT] ; less than 256 processes |
3142 | mov edx, [TASK_COUNT] ; less than 256 processes |
3127 | cmp ecx, edx |
3143 | cmp ecx, edx |
3128 | jne .exit |
3144 | jne .exit |
3129 | movzx eax, byte [BTN_COUNT] |
3145 | movzx eax, byte [BTN_COUNT] |
3130 | test eax, eax |
3146 | test eax, eax |
3131 | jz .exit |
3147 | jz .exit |
3132 | mov eax, [BTN_BUFF] |
3148 | mov eax, [BTN_BUFF] |
3133 | and al, 0xFE ; delete left button bit |
3149 | and al, 0xFE ; delete left button bit |
3134 | mov [BTN_COUNT], byte 0 |
3150 | mov [BTN_COUNT], byte 0 |
3135 | mov [esp + 32], eax |
3151 | mov [esp + 32], eax |
3136 | ;-------------------------------------- |
3152 | ;-------------------------------------- |
3137 | align 4 |
3153 | align 4 |
3138 | .exit: |
3154 | .exit: |
3139 | ret |
3155 | ret |
3140 | ;------------------------------------------------------------------------------ |
3156 | ;------------------------------------------------------------------------------ |
3141 | align 4 |
3157 | align 4 |
3142 | sys_cpuusage: |
3158 | sys_cpuusage: |
3143 | 3159 | ||
3144 | ; RETURN: |
3160 | ; RETURN: |
3145 | ; |
3161 | ; |
3146 | ; +00 dword process cpu usage |
3162 | ; +00 dword process cpu usage |
3147 | ; +04 word position in windowing stack |
3163 | ; +04 word position in windowing stack |
3148 | ; +06 word windowing stack value at current position (cpu nro) |
3164 | ; +06 word windowing stack value at current position (cpu nro) |
3149 | ; +10 12 bytes name |
3165 | ; +10 12 bytes name |
3150 | ; +22 dword start in mem |
3166 | ; +22 dword start in mem |
3151 | ; +26 dword used mem |
3167 | ; +26 dword used mem |
3152 | ; +30 dword PID , process idenfification number |
3168 | ; +30 dword PID , process idenfification number |
3153 | ; |
3169 | ; |
3154 | 3170 | ||
3155 | cmp ecx, -1 ; who am I ? |
3171 | cmp ecx, -1 ; who am I ? |
3156 | jne .no_who_am_i |
3172 | jne .no_who_am_i |
3157 | mov ecx, [CURRENT_TASK] |
3173 | mov ecx, [CURRENT_TASK] |
3158 | .no_who_am_i: |
3174 | .no_who_am_i: |
3159 | cmp ecx, max_processes |
3175 | cmp ecx, max_processes |
3160 | ja .nofillbuf |
3176 | ja .nofillbuf |
3161 | 3177 | ||
3162 | ; +4: word: position of the window of thread in the window stack |
3178 | ; +4: word: position of the window of thread in the window stack |
3163 | mov ax, [WIN_STACK + ecx * 2] |
3179 | mov ax, [WIN_STACK + ecx * 2] |
3164 | mov [ebx+4], ax |
3180 | mov [ebx+4], ax |
3165 | ; +6: word: number of the thread slot, which window has in the window stack |
3181 | ; +6: word: number of the thread slot, which window has in the window stack |
3166 | ; position ecx (has no relation to the specific thread) |
3182 | ; position ecx (has no relation to the specific thread) |
3167 | mov ax, [WIN_POS + ecx * 2] |
3183 | mov ax, [WIN_POS + ecx * 2] |
3168 | mov [ebx+6], ax |
3184 | mov [ebx+6], ax |
3169 | 3185 | ||
3170 | shl ecx, 5 |
3186 | shl ecx, 5 |
3171 | 3187 | ||
3172 | ; +0: dword: memory usage |
3188 | ; +0: dword: memory usage |
3173 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3189 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3174 | mov [ebx], eax |
3190 | mov [ebx], eax |
3175 | ; +10: 11 bytes: name of the process |
3191 | ; +10: 11 bytes: name of the process |
3176 | push ecx |
3192 | push ecx |
3177 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3193 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3178 | add ebx, 10 |
3194 | add ebx, 10 |
3179 | mov ecx, 11 |
3195 | mov ecx, 11 |
3180 | call memmove |
3196 | call memmove |
3181 | pop ecx |
3197 | pop ecx |
3182 | 3198 | ||
3183 | ; +22: address of the process in memory |
3199 | ; +22: address of the process in memory |
3184 | ; +26: size of used memory - 1 |
3200 | ; +26: size of used memory - 1 |
3185 | push edi |
3201 | push edi |
3186 | lea edi, [ebx+12] |
3202 | lea edi, [ebx+12] |
3187 | xor eax, eax |
3203 | xor eax, eax |
3188 | mov edx, 0x100000*16 |
3204 | mov edx, 0x100000*16 |
3189 | cmp ecx, 1 shl 5 |
3205 | cmp ecx, 1 shl 5 |
3190 | je .os_mem |
3206 | je .os_mem |
3191 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3207 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3192 | mov edx, [edx+PROC.mem_used] |
3208 | mov edx, [edx+PROC.mem_used] |
3193 | mov eax, std_application_base_address |
3209 | mov eax, std_application_base_address |
3194 | .os_mem: |
3210 | .os_mem: |
3195 | stosd |
3211 | stosd |
3196 | lea eax, [edx-1] |
3212 | lea eax, [edx-1] |
3197 | stosd |
3213 | stosd |
3198 | 3214 | ||
3199 | ; +30: PID/TID |
3215 | ; +30: PID/TID |
3200 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3216 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3201 | stosd |
3217 | stosd |
3202 | 3218 | ||
3203 | ; window position and size |
3219 | ; window position and size |
3204 | push esi |
3220 | push esi |
3205 | lea esi, [ecx + window_data + WDATA.box] |
3221 | lea esi, [ecx + window_data + WDATA.box] |
3206 | movsd |
3222 | movsd |
3207 | movsd |
3223 | movsd |
3208 | movsd |
3224 | movsd |
3209 | movsd |
3225 | movsd |
3210 | 3226 | ||
3211 | ; Process state (+50) |
3227 | ; Process state (+50) |
3212 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3228 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3213 | stosd |
3229 | stosd |
3214 | 3230 | ||
3215 | ; Window client area box |
3231 | ; Window client area box |
3216 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3232 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3217 | movsd |
3233 | movsd |
3218 | movsd |
3234 | movsd |
3219 | movsd |
3235 | movsd |
3220 | movsd |
3236 | movsd |
3221 | 3237 | ||
3222 | ; Window state |
3238 | ; Window state |
3223 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3239 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3224 | stosb |
3240 | stosb |
3225 | 3241 | ||
3226 | ; Event mask (+71) |
3242 | ; Event mask (+71) |
3227 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3243 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3228 | stosd |
3244 | stosd |
3229 | 3245 | ||
3230 | ; Keyboard mode (+75) |
3246 | ; Keyboard mode (+75) |
3231 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3247 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3232 | stosb |
3248 | stosb |
3233 | 3249 | ||
3234 | pop esi |
3250 | pop esi |
3235 | pop edi |
3251 | pop edi |
3236 | 3252 | ||
3237 | .nofillbuf: |
3253 | .nofillbuf: |
3238 | ; return number of processes |
3254 | ; return number of processes |
3239 | 3255 | ||
3240 | mov eax, [TASK_COUNT] |
3256 | mov eax, [TASK_COUNT] |
3241 | mov [esp+32], eax |
3257 | mov [esp+32], eax |
3242 | ret |
3258 | ret |
3243 | 3259 | ||
3244 | align 4 |
3260 | align 4 |
3245 | sys_clock: |
3261 | sys_clock: |
3246 | cli |
3262 | cli |
3247 | ; Mikhail Lisovin xx Jan 2005 |
3263 | ; Mikhail Lisovin xx Jan 2005 |
3248 | @@: |
3264 | @@: |
3249 | mov al, 10 |
3265 | mov al, 10 |
3250 | out 0x70, al |
3266 | out 0x70, al |
3251 | in al, 0x71 |
3267 | in al, 0x71 |
3252 | test al, al |
3268 | test al, al |
3253 | jns @f |
3269 | jns @f |
3254 | mov esi, 1 |
3270 | mov esi, 1 |
3255 | call delay_ms |
3271 | call delay_ms |
3256 | jmp @b |
3272 | jmp @b |
3257 | @@: |
3273 | @@: |
3258 | ; end Lisovin's fix |
3274 | ; end Lisovin's fix |
3259 | 3275 | ||
3260 | xor al, al ; seconds |
3276 | xor al, al ; seconds |
3261 | out 0x70, al |
3277 | out 0x70, al |
3262 | in al, 0x71 |
3278 | in al, 0x71 |
3263 | movzx ecx, al |
3279 | movzx ecx, al |
3264 | mov al, 02 ; minutes |
3280 | mov al, 02 ; minutes |
3265 | shl ecx, 16 |
3281 | shl ecx, 16 |
3266 | out 0x70, al |
3282 | out 0x70, al |
3267 | in al, 0x71 |
3283 | in al, 0x71 |
3268 | movzx edx, al |
3284 | movzx edx, al |
3269 | mov al, 04 ; hours |
3285 | mov al, 04 ; hours |
3270 | shl edx, 8 |
3286 | shl edx, 8 |
3271 | out 0x70, al |
3287 | out 0x70, al |
3272 | in al, 0x71 |
3288 | in al, 0x71 |
3273 | add ecx, edx |
3289 | add ecx, edx |
3274 | movzx edx, al |
3290 | movzx edx, al |
3275 | add ecx, edx |
3291 | add ecx, edx |
3276 | sti |
3292 | sti |
3277 | mov [esp + 32], ecx |
3293 | mov [esp + 32], ecx |
3278 | ret |
3294 | ret |
3279 | 3295 | ||
3280 | 3296 | ||
3281 | align 4 |
3297 | align 4 |
3282 | 3298 | ||
3283 | sys_date: |
3299 | sys_date: |
3284 | 3300 | ||
3285 | cli |
3301 | cli |
3286 | @@: |
3302 | @@: |
3287 | mov al, 10 |
3303 | mov al, 10 |
3288 | out 0x70, al |
3304 | out 0x70, al |
3289 | in al, 0x71 |
3305 | in al, 0x71 |
3290 | test al, al |
3306 | test al, al |
3291 | jns @f |
3307 | jns @f |
3292 | mov esi, 1 |
3308 | mov esi, 1 |
3293 | call delay_ms |
3309 | call delay_ms |
3294 | jmp @b |
3310 | jmp @b |
3295 | @@: |
3311 | @@: |
3296 | 3312 | ||
3297 | mov ch, 0 |
3313 | mov ch, 0 |
3298 | mov al, 7 ; date |
3314 | mov al, 7 ; date |
3299 | out 0x70, al |
3315 | out 0x70, al |
3300 | in al, 0x71 |
3316 | in al, 0x71 |
3301 | mov cl, al |
3317 | mov cl, al |
3302 | mov al, 8 ; month |
3318 | mov al, 8 ; month |
3303 | shl ecx, 16 |
3319 | shl ecx, 16 |
3304 | out 0x70, al |
3320 | out 0x70, al |
3305 | in al, 0x71 |
3321 | in al, 0x71 |
3306 | mov ch, al |
3322 | mov ch, al |
3307 | mov al, 9 ; year |
3323 | mov al, 9 ; year |
3308 | out 0x70, al |
3324 | out 0x70, al |
3309 | in al, 0x71 |
3325 | in al, 0x71 |
3310 | mov cl, al |
3326 | mov cl, al |
3311 | sti |
3327 | sti |
3312 | mov [esp+32], ecx |
3328 | mov [esp+32], ecx |
3313 | ret |
3329 | ret |
3314 | 3330 | ||
3315 | 3331 | ||
3316 | ; redraw status |
3332 | ; redraw status |
3317 | 3333 | ||
3318 | sys_redrawstat: |
3334 | sys_redrawstat: |
3319 | cmp ebx, 1 |
3335 | cmp ebx, 1 |
3320 | jne no_widgets_away |
3336 | jne no_widgets_away |
3321 | ; buttons away |
3337 | ; buttons away |
3322 | mov ecx, [CURRENT_TASK] |
3338 | mov ecx, [CURRENT_TASK] |
3323 | sys_newba2: |
3339 | sys_newba2: |
3324 | mov edi, [BTN_ADDR] |
3340 | mov edi, [BTN_ADDR] |
3325 | cmp [edi], dword 0 ; empty button list ? |
3341 | cmp [edi], dword 0 ; empty button list ? |
3326 | je end_of_buttons_away |
3342 | je end_of_buttons_away |
3327 | movzx ebx, word [edi] |
3343 | movzx ebx, word [edi] |
3328 | inc ebx |
3344 | inc ebx |
3329 | mov eax, edi |
3345 | mov eax, edi |
3330 | sys_newba: |
3346 | sys_newba: |
3331 | dec ebx |
3347 | dec ebx |
3332 | jz end_of_buttons_away |
3348 | jz end_of_buttons_away |
3333 | 3349 | ||
3334 | add eax, 0x10 |
3350 | add eax, 0x10 |
3335 | cmp cx, [eax] |
3351 | cmp cx, [eax] |
3336 | jnz sys_newba |
3352 | jnz sys_newba |
3337 | 3353 | ||
3338 | push eax ebx ecx |
3354 | push eax ebx ecx |
3339 | mov ecx, ebx |
3355 | mov ecx, ebx |
3340 | inc ecx |
3356 | inc ecx |
3341 | shl ecx, 4 |
3357 | shl ecx, 4 |
3342 | mov ebx, eax |
3358 | mov ebx, eax |
3343 | add eax, 0x10 |
3359 | add eax, 0x10 |
3344 | call memmove |
3360 | call memmove |
3345 | dec dword [edi] |
3361 | dec dword [edi] |
3346 | pop ecx ebx eax |
3362 | pop ecx ebx eax |
3347 | 3363 | ||
3348 | jmp sys_newba2 |
3364 | jmp sys_newba2 |
3349 | 3365 | ||
3350 | end_of_buttons_away: |
3366 | end_of_buttons_away: |
3351 | 3367 | ||
3352 | ret |
3368 | ret |
3353 | 3369 | ||
3354 | no_widgets_away: |
3370 | no_widgets_away: |
3355 | 3371 | ||
3356 | cmp ebx, 2 |
3372 | cmp ebx, 2 |
3357 | jnz srl1 |
3373 | jnz srl1 |
3358 | 3374 | ||
3359 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3375 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3360 | add edx, draw_data - CURRENT_TASK |
3376 | add edx, draw_data - CURRENT_TASK |
3361 | mov [edx + RECT.left], 0 |
3377 | mov [edx + RECT.left], 0 |
3362 | mov [edx + RECT.top], 0 |
3378 | mov [edx + RECT.top], 0 |
3363 | mov eax, [_display.width] |
3379 | mov eax, [_display.width] |
3364 | dec eax |
3380 | dec eax |
3365 | mov [edx + RECT.right], eax |
3381 | mov [edx + RECT.right], eax |
3366 | mov eax, [_display.height] |
3382 | mov eax, [_display.height] |
3367 | dec eax |
3383 | dec eax |
3368 | mov [edx + RECT.bottom], eax |
3384 | mov [edx + RECT.bottom], eax |
3369 | 3385 | ||
3370 | srl1: |
3386 | srl1: |
3371 | ret |
3387 | ret |
3372 | 3388 | ||
3373 | ;ok - 100% work |
3389 | ;ok - 100% work |
3374 | ;nt - not tested |
3390 | ;nt - not tested |
3375 | ;--------------------------------------------------------------------------------------------- |
3391 | ;--------------------------------------------------------------------------------------------- |
3376 | ;eax |
3392 | ;eax |
3377 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3393 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3378 | ;1 - change task. Ret nothing. Block. ok. |
3394 | ;1 - change task. Ret nothing. Block. ok. |
3379 | ;2 - performance control |
3395 | ;2 - performance control |
3380 | ; ebx |
3396 | ; ebx |
3381 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3397 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3382 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3398 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3383 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3399 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3384 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3400 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3385 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3401 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3386 | ;eax |
3402 | ;eax |
3387 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3403 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3388 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3404 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3389 | ;--------------------------------------------------------------------------------------------- |
3405 | ;--------------------------------------------------------------------------------------------- |
3390 | iglobal |
3406 | iglobal |
3391 | align 4 |
3407 | align 4 |
3392 | sheduler: |
3408 | sheduler: |
3393 | dd sys_sheduler.00 |
3409 | dd sys_sheduler.00 |
3394 | dd change_task |
3410 | dd change_task |
3395 | dd sys_sheduler.02 |
3411 | dd sys_sheduler.02 |
3396 | dd sys_sheduler.03 |
3412 | dd sys_sheduler.03 |
3397 | dd sys_sheduler.04 |
3413 | dd sys_sheduler.04 |
3398 | endg |
3414 | endg |
3399 | sys_sheduler: |
3415 | sys_sheduler: |
3400 | ;rewritten by |
3416 | ;rewritten by |
3401 | jmp dword [sheduler+ebx*4] |
3417 | jmp dword [sheduler+ebx*4] |
3402 | ;.shed_counter: |
3418 | ;.shed_counter: |
3403 | .00: |
3419 | .00: |
3404 | mov eax, [context_counter] |
3420 | mov eax, [context_counter] |
3405 | mov [esp+32], eax |
3421 | mov [esp+32], eax |
3406 | ret |
3422 | ret |
3407 | 3423 | ||
3408 | .02: |
3424 | .02: |
3409 | ;.perf_control: |
3425 | ;.perf_control: |
3410 | inc ebx ;before ebx=2, ebx=3 |
3426 | inc ebx ;before ebx=2, ebx=3 |
3411 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3427 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3412 | jz cache_disable |
3428 | jz cache_disable |
3413 | 3429 | ||
3414 | dec ebx ;ebx=2 |
3430 | dec ebx ;ebx=2 |
3415 | cmp ebx, ecx ; |
3431 | cmp ebx, ecx ; |
3416 | jz cache_enable ;if ecx=2 and ebx=2 |
3432 | jz cache_enable ;if ecx=2 and ebx=2 |
3417 | 3433 | ||
3418 | dec ebx ;ebx=1 |
3434 | dec ebx ;ebx=1 |
3419 | cmp ebx, ecx |
3435 | cmp ebx, ecx |
3420 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3436 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3421 | 3437 | ||
3422 | dec ebx |
3438 | dec ebx |
3423 | test ebx, ecx ;ebx=0 and ecx=0 |
3439 | test ebx, ecx ;ebx=0 and ecx=0 |
3424 | jz modify_pce ;if ecx=0 |
3440 | jz modify_pce ;if ecx=0 |
3425 | 3441 | ||
3426 | ret |
3442 | ret |
3427 | 3443 | ||
3428 | .03: |
3444 | .03: |
3429 | ;.rdmsr_instr: |
3445 | ;.rdmsr_instr: |
3430 | ;now counter in ecx |
3446 | ;now counter in ecx |
3431 | ;(edx:eax) esi:edi => edx:esi |
3447 | ;(edx:eax) esi:edi => edx:esi |
3432 | mov eax, esi |
3448 | mov eax, esi |
3433 | mov ecx, edx |
3449 | mov ecx, edx |
3434 | rdmsr |
3450 | rdmsr |
3435 | mov [esp+32], eax |
3451 | mov [esp+32], eax |
3436 | mov [esp+20], edx ;ret in ebx? |
3452 | mov [esp+20], edx ;ret in ebx? |
3437 | ret |
3453 | ret |
3438 | 3454 | ||
3439 | .04: |
3455 | .04: |
3440 | ;.wrmsr_instr: |
3456 | ;.wrmsr_instr: |
3441 | ;now counter in ecx |
3457 | ;now counter in ecx |
3442 | ;(edx:eax) esi:edi => edx:esi |
3458 | ;(edx:eax) esi:edi => edx:esi |
3443 | ; Fast Call MSR can't be destroy |
3459 | ; Fast Call MSR can't be destroy |
3444 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3460 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3445 | ; включаются/выключаются расширенные возможности |
3461 | ; включаются/выключаются расширенные возможности |
3446 | cmp edx, MSR_SYSENTER_CS |
3462 | cmp edx, MSR_SYSENTER_CS |
3447 | je @f |
3463 | je @f |
3448 | cmp edx, MSR_SYSENTER_ESP |
3464 | cmp edx, MSR_SYSENTER_ESP |
3449 | je @f |
3465 | je @f |
3450 | cmp edx, MSR_SYSENTER_EIP |
3466 | cmp edx, MSR_SYSENTER_EIP |
3451 | je @f |
3467 | je @f |
3452 | cmp edx, MSR_AMD_STAR |
3468 | cmp edx, MSR_AMD_STAR |
3453 | je @f |
3469 | je @f |
3454 | 3470 | ||
3455 | mov eax, esi |
3471 | mov eax, esi |
3456 | mov ecx, edx |
3472 | mov ecx, edx |
3457 | wrmsr |
3473 | wrmsr |
3458 | ; mov [esp + 32], eax |
3474 | ; mov [esp + 32], eax |
3459 | ; mov [esp + 20], edx ;ret in ebx? |
3475 | ; mov [esp + 20], edx ;ret in ebx? |
3460 | @@: |
3476 | @@: |
3461 | ret |
3477 | ret |
3462 | 3478 | ||
3463 | cache_disable: |
3479 | cache_disable: |
3464 | mov eax, cr0 |
3480 | mov eax, cr0 |
3465 | or eax, 01100000000000000000000000000000b |
3481 | or eax, 01100000000000000000000000000000b |
3466 | mov cr0, eax |
3482 | mov cr0, eax |
3467 | wbinvd ;set MESI |
3483 | wbinvd ;set MESI |
3468 | ret |
3484 | ret |
3469 | 3485 | ||
3470 | cache_enable: |
3486 | cache_enable: |
3471 | mov eax, cr0 |
3487 | mov eax, cr0 |
3472 | and eax, 10011111111111111111111111111111b |
3488 | and eax, 10011111111111111111111111111111b |
3473 | mov cr0, eax |
3489 | mov cr0, eax |
3474 | ret |
3490 | ret |
3475 | 3491 | ||
3476 | is_cache_enabled: |
3492 | is_cache_enabled: |
3477 | mov eax, cr0 |
3493 | mov eax, cr0 |
3478 | mov ebx, eax |
3494 | mov ebx, eax |
3479 | and eax, 01100000000000000000000000000000b |
3495 | and eax, 01100000000000000000000000000000b |
3480 | jz cache_disabled |
3496 | jz cache_disabled |
3481 | mov [esp+32], ebx |
3497 | mov [esp+32], ebx |
3482 | cache_disabled: |
3498 | cache_disabled: |
3483 | mov dword [esp+32], eax;0 |
3499 | mov dword [esp+32], eax;0 |
3484 | ret |
3500 | ret |
3485 | 3501 | ||
3486 | modify_pce: |
3502 | modify_pce: |
3487 | mov eax, cr4 |
3503 | mov eax, cr4 |
3488 | ; mov ebx,0 |
3504 | ; mov ebx,0 |
3489 | ; or bx,100000000b ;pce |
3505 | ; or bx,100000000b ;pce |
3490 | ; xor eax,ebx ;invert pce |
3506 | ; xor eax,ebx ;invert pce |
3491 | bts eax, 8;pce=cr4[8] |
3507 | bts eax, 8;pce=cr4[8] |
3492 | mov cr4, eax |
3508 | mov cr4, eax |
3493 | mov [esp+32], eax |
3509 | mov [esp+32], eax |
3494 | ret |
3510 | ret |
3495 | ;--------------------------------------------------------------------------------------------- |
3511 | ;--------------------------------------------------------------------------------------------- |
3496 | 3512 | ||
3497 | 3513 | ||
3498 | iglobal |
3514 | iglobal |
3499 | cpustring db 'CPU',0 |
3515 | cpustring db 'CPU',0 |
3500 | endg |
3516 | endg |
3501 | 3517 | ||
3502 | uglobal |
3518 | uglobal |
3503 | background_defined db 0 ; diamond, 11.04.2006 |
3519 | background_defined db 0 ; diamond, 11.04.2006 |
3504 | endg |
3520 | endg |
3505 | ;----------------------------------------------------------------------------- |
3521 | ;----------------------------------------------------------------------------- |
3506 | align 4 |
3522 | align 4 |
3507 | checkmisc: |
3523 | checkmisc: |
3508 | cmp [ctrl_alt_del], 1 |
3524 | cmp [ctrl_alt_del], 1 |
3509 | jne nocpustart |
3525 | jne nocpustart |
3510 | 3526 | ||
3511 | mov ebp, cpustring |
3527 | mov ebp, cpustring |
3512 | call fs_execute_from_sysdir |
3528 | call fs_execute_from_sysdir |
3513 | 3529 | ||
3514 | mov [ctrl_alt_del], 0 |
3530 | mov [ctrl_alt_del], 0 |
3515 | ;-------------------------------------- |
3531 | ;-------------------------------------- |
3516 | align 4 |
3532 | align 4 |
3517 | nocpustart: |
3533 | nocpustart: |
3518 | cmp [mouse_active], 1 |
3534 | cmp [mouse_active], 1 |
3519 | jne mouse_not_active |
3535 | jne mouse_not_active |
3520 | mov [mouse_active], 0 |
3536 | mov [mouse_active], 0 |
3521 | 3537 | ||
3522 | xor edi, edi |
3538 | xor edi, edi |
3523 | mov ebx, CURRENT_TASK |
3539 | mov ebx, CURRENT_TASK |
3524 | 3540 | ||
3525 | mov ecx, [TASK_COUNT] |
3541 | mov ecx, [TASK_COUNT] |
3526 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3542 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3527 | shl eax, 8 |
3543 | shl eax, 8 |
3528 | push eax |
3544 | push eax |
3529 | 3545 | ||
3530 | movzx eax, word [MOUSE_X] |
3546 | movzx eax, word [MOUSE_X] |
3531 | movzx edx, word [MOUSE_Y] |
3547 | movzx edx, word [MOUSE_Y] |
3532 | ;-------------------------------------- |
3548 | ;-------------------------------------- |
3533 | align 4 |
3549 | align 4 |
3534 | .set_mouse_event: |
3550 | .set_mouse_event: |
3535 | add edi, 256 |
3551 | add edi, 256 |
3536 | add ebx, 32 |
3552 | add ebx, 32 |
3537 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3553 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3538 | jz .pos_filter |
3554 | jz .pos_filter |
3539 | 3555 | ||
3540 | cmp edi, [esp] ; skip if filtration active |
3556 | cmp edi, [esp] ; skip if filtration active |
3541 | jne .skip |
3557 | jne .skip |
3542 | ;-------------------------------------- |
3558 | ;-------------------------------------- |
3543 | align 4 |
3559 | align 4 |
3544 | .pos_filter: |
3560 | .pos_filter: |
3545 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3561 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3546 | jz .set |
3562 | jz .set |
3547 | 3563 | ||
3548 | mov esi, [ebx-twdw+WDATA.box.left] |
3564 | mov esi, [ebx-twdw+WDATA.box.left] |
3549 | cmp eax, esi |
3565 | cmp eax, esi |
3550 | jb .skip |
3566 | jb .skip |
3551 | add esi, [ebx-twdw+WDATA.box.width] |
3567 | add esi, [ebx-twdw+WDATA.box.width] |
3552 | cmp eax, esi |
3568 | cmp eax, esi |
3553 | ja .skip |
3569 | ja .skip |
3554 | 3570 | ||
3555 | mov esi, [ebx-twdw+WDATA.box.top] |
3571 | mov esi, [ebx-twdw+WDATA.box.top] |
3556 | cmp edx, esi |
3572 | cmp edx, esi |
3557 | jb .skip |
3573 | jb .skip |
3558 | add esi, [ebx-twdw+WDATA.box.height] |
3574 | add esi, [ebx-twdw+WDATA.box.height] |
3559 | cmp edx, esi |
3575 | cmp edx, esi |
3560 | ja .skip |
3576 | ja .skip |
3561 | ;-------------------------------------- |
3577 | ;-------------------------------------- |
3562 | align 4 |
3578 | align 4 |
3563 | .set: |
3579 | .set: |
3564 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3580 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3565 | ;-------------------------------------- |
3581 | ;-------------------------------------- |
3566 | align 4 |
3582 | align 4 |
3567 | .skip: |
3583 | .skip: |
3568 | loop .set_mouse_event |
3584 | loop .set_mouse_event |
3569 | 3585 | ||
3570 | pop eax |
3586 | pop eax |
3571 | ;-------------------------------------- |
3587 | ;-------------------------------------- |
3572 | align 4 |
3588 | align 4 |
3573 | mouse_not_active: |
3589 | mouse_not_active: |
3574 | cmp [REDRAW_BACKGROUND], 0 ; background update ? |
3590 | cmp [REDRAW_BACKGROUND], 0 ; background update ? |
3575 | jz nobackgr |
3591 | jz nobackgr |
3576 | 3592 | ||
3577 | cmp [background_defined], 0 |
3593 | cmp [background_defined], 0 |
3578 | jz nobackgr |
3594 | jz nobackgr |
3579 | ;-------------------------------------- |
3595 | ;-------------------------------------- |
3580 | align 4 |
3596 | align 4 |
3581 | backgr: |
3597 | backgr: |
3582 | mov eax, [draw_data+32 + RECT.left] |
3598 | mov eax, [draw_data+32 + RECT.left] |
3583 | shl eax, 16 |
3599 | shl eax, 16 |
3584 | add eax, [draw_data+32 + RECT.right] |
3600 | add eax, [draw_data+32 + RECT.right] |
3585 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3601 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3586 | 3602 | ||
3587 | mov eax, [draw_data+32 + RECT.top] |
3603 | mov eax, [draw_data+32 + RECT.top] |
3588 | shl eax, 16 |
3604 | shl eax, 16 |
3589 | add eax, [draw_data+32 + RECT.bottom] |
3605 | add eax, [draw_data+32 + RECT.bottom] |
3590 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3606 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3591 | 3607 | ||
3592 | call drawbackground |
3608 | call drawbackground |
3593 | ; DEBUGF 1, "K : drawbackground\n" |
3609 | ; DEBUGF 1, "K : drawbackground\n" |
3594 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3610 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3595 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3611 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3596 | ;--------- set event 5 start ---------- |
3612 | ;--------- set event 5 start ---------- |
3597 | push ecx edi |
3613 | push ecx edi |
3598 | xor edi, edi |
3614 | xor edi, edi |
3599 | mov ecx, [TASK_COUNT] |
3615 | mov ecx, [TASK_COUNT] |
3600 | ;-------------------------------------- |
3616 | ;-------------------------------------- |
3601 | align 4 |
3617 | align 4 |
3602 | set_bgr_event: |
3618 | set_bgr_event: |
3603 | add edi, 256 |
3619 | add edi, 256 |
3604 | mov eax, [BG_Rect_X_left_right] |
3620 | mov eax, [BG_Rect_X_left_right] |
3605 | mov edx, [BG_Rect_Y_top_bottom] |
3621 | mov edx, [BG_Rect_Y_top_bottom] |
3606 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3622 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3607 | jz .set |
3623 | jz .set |
3608 | .join: |
3624 | .join: |
3609 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3625 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3610 | jae @f |
3626 | jae @f |
3611 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3627 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3612 | @@: |
3628 | @@: |
3613 | shr eax, 16 |
3629 | shr eax, 16 |
3614 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3630 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3615 | jbe @f |
3631 | jbe @f |
3616 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3632 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3617 | @@: |
3633 | @@: |
3618 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3634 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3619 | jae @f |
3635 | jae @f |
3620 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3636 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3621 | @@: |
3637 | @@: |
3622 | shr edx, 16 |
3638 | shr edx, 16 |
3623 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3639 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3624 | jbe @f |
3640 | jbe @f |
3625 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3641 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3626 | @@: |
3642 | @@: |
3627 | jmp .common |
3643 | jmp .common |
3628 | .set: |
3644 | .set: |
3629 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3645 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3630 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3646 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3631 | .common: |
3647 | .common: |
3632 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3648 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3633 | loop set_bgr_event |
3649 | loop set_bgr_event |
3634 | pop edi ecx |
3650 | pop edi ecx |
3635 | ;--------- set event 5 stop ----------- |
3651 | ;--------- set event 5 stop ----------- |
3636 | dec [REDRAW_BACKGROUND] ; got new update request? |
3652 | dec [REDRAW_BACKGROUND] ; got new update request? |
3637 | jnz backgr |
3653 | jnz backgr |
3638 | 3654 | ||
3639 | xor eax, eax |
3655 | xor eax, eax |
3640 | mov [draw_data+32 + RECT.left], eax |
3656 | mov [draw_data+32 + RECT.left], eax |
3641 | mov [draw_data+32 + RECT.top], eax |
3657 | mov [draw_data+32 + RECT.top], eax |
3642 | mov [draw_data+32 + RECT.right], eax |
3658 | mov [draw_data+32 + RECT.right], eax |
3643 | mov [draw_data+32 + RECT.bottom], eax |
3659 | mov [draw_data+32 + RECT.bottom], eax |
3644 | ;-------------------------------------- |
3660 | ;-------------------------------------- |
3645 | align 4 |
3661 | align 4 |
3646 | nobackgr: |
3662 | nobackgr: |
3647 | ; system shutdown request |
3663 | ; system shutdown request |
3648 | cmp [SYS_SHUTDOWN], byte 0 |
3664 | cmp [SYS_SHUTDOWN], byte 0 |
3649 | je noshutdown |
3665 | je noshutdown |
3650 | 3666 | ||
3651 | mov edx, [shutdown_processes] |
3667 | mov edx, [shutdown_processes] |
3652 | 3668 | ||
3653 | cmp [SYS_SHUTDOWN], dl |
3669 | cmp [SYS_SHUTDOWN], dl |
3654 | jne noshutdown |
3670 | jne noshutdown |
3655 | 3671 | ||
3656 | lea ecx, [edx-1] |
3672 | lea ecx, [edx-1] |
3657 | mov edx, OS_BASE+0x3040 |
3673 | mov edx, OS_BASE+0x3040 |
3658 | jecxz no_mark_system_shutdown |
3674 | jecxz no_mark_system_shutdown |
3659 | ;-------------------------------------- |
3675 | ;-------------------------------------- |
3660 | align 4 |
3676 | align 4 |
3661 | markz: |
3677 | markz: |
3662 | push ecx edx |
3678 | push ecx edx |
3663 | cmp [edx+TASKDATA.state], TSTATE_FREE |
3679 | cmp [edx+TASKDATA.state], TSTATE_FREE |
3664 | jz .nokill |
3680 | jz .nokill |
3665 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3681 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3666 | cmp [edx+APPDATA.process], sys_proc |
3682 | cmp [edx+APPDATA.process], sys_proc |
3667 | jz .nokill |
3683 | jz .nokill |
3668 | call request_terminate |
3684 | call request_terminate |
3669 | jmp .common |
3685 | jmp .common |
3670 | .nokill: |
3686 | .nokill: |
3671 | dec byte [SYS_SHUTDOWN] |
3687 | dec byte [SYS_SHUTDOWN] |
3672 | xor eax, eax |
3688 | xor eax, eax |
3673 | .common: |
3689 | .common: |
3674 | pop edx ecx |
3690 | pop edx ecx |
3675 | test eax, eax |
3691 | test eax, eax |
3676 | jz @f |
3692 | jz @f |
3677 | mov [edx+TASKDATA.state], TSTATE_ZOMBIE |
3693 | mov [edx+TASKDATA.state], TSTATE_ZOMBIE |
3678 | @@: |
3694 | @@: |
3679 | add edx, 0x20 |
3695 | add edx, 0x20 |
3680 | loop markz |
3696 | loop markz |
3681 | call wakeup_osloop |
3697 | call wakeup_osloop |
3682 | ;-------------------------------------- |
3698 | ;-------------------------------------- |
3683 | align 4 |
3699 | align 4 |
3684 | @@: |
3700 | @@: |
3685 | no_mark_system_shutdown: |
3701 | no_mark_system_shutdown: |
3686 | dec byte [SYS_SHUTDOWN] |
3702 | dec byte [SYS_SHUTDOWN] |
3687 | je system_shutdown |
3703 | je system_shutdown |
3688 | ;-------------------------------------- |
3704 | ;-------------------------------------- |
3689 | align 4 |
3705 | align 4 |
3690 | noshutdown: |
3706 | noshutdown: |
3691 | mov eax, [TASK_COUNT] ; termination |
3707 | mov eax, [TASK_COUNT] ; termination |
3692 | mov ebx, TASK_DATA+TASKDATA.state |
3708 | mov ebx, TASK_DATA+TASKDATA.state |
3693 | mov esi, 1 |
3709 | mov esi, 1 |
3694 | ;-------------------------------------- |
3710 | ;-------------------------------------- |
3695 | align 4 |
3711 | align 4 |
3696 | newct: |
3712 | newct: |
3697 | mov cl, [ebx] |
3713 | mov cl, [ebx] |
3698 | cmp cl, byte 3 |
3714 | cmp cl, byte 3 |
3699 | jz .terminate |
3715 | jz .terminate |
3700 | 3716 | ||
3701 | cmp cl, byte 4 |
3717 | cmp cl, byte 4 |
3702 | jnz .noterminate |
3718 | jnz .noterminate |
3703 | .terminate: |
3719 | .terminate: |
3704 | pushad |
3720 | pushad |
3705 | mov ecx, eax |
3721 | mov ecx, eax |
3706 | shl ecx, 8 |
3722 | shl ecx, 8 |
3707 | add ecx, SLOT_BASE |
3723 | add ecx, SLOT_BASE |
3708 | call restore_default_cursor_before_killing |
3724 | call restore_default_cursor_before_killing |
3709 | popad |
3725 | popad |
3710 | 3726 | ||
3711 | pushad |
3727 | pushad |
3712 | call terminate |
3728 | call terminate |
3713 | popad |
3729 | popad |
3714 | cmp byte [SYS_SHUTDOWN], 0 |
3730 | cmp byte [SYS_SHUTDOWN], 0 |
3715 | jz .noterminate |
3731 | jz .noterminate |
3716 | dec byte [SYS_SHUTDOWN] |
3732 | dec byte [SYS_SHUTDOWN] |
3717 | je system_shutdown |
3733 | je system_shutdown |
3718 | 3734 | ||
3719 | .noterminate: |
3735 | .noterminate: |
3720 | add ebx, 0x20 |
3736 | add ebx, 0x20 |
3721 | inc esi |
3737 | inc esi |
3722 | dec eax |
3738 | dec eax |
3723 | jnz newct |
3739 | jnz newct |
3724 | ret |
3740 | ret |
3725 | ;----------------------------------------------------------------------------- |
3741 | ;----------------------------------------------------------------------------- |
3726 | align 4 |
3742 | align 4 |
3727 | redrawscreen: |
3743 | redrawscreen: |
3728 | ; eax , if process window_data base is eax, do not set flag/limits |
3744 | ; eax , if process window_data base is eax, do not set flag/limits |
3729 | 3745 | ||
3730 | pushad |
3746 | pushad |
3731 | push eax |
3747 | push eax |
3732 | 3748 | ||
3733 | ;;; mov ebx,2 |
3749 | ;;; mov ebx,2 |
3734 | ;;; call delay_hs |
3750 | ;;; call delay_hs |
3735 | 3751 | ||
3736 | ;mov ecx,0 ; redraw flags for apps |
3752 | ;mov ecx,0 ; redraw flags for apps |
3737 | xor ecx, ecx |
3753 | xor ecx, ecx |
3738 | ;-------------------------------------- |
3754 | ;-------------------------------------- |
3739 | align 4 |
3755 | align 4 |
3740 | newdw2: |
3756 | newdw2: |
3741 | inc ecx |
3757 | inc ecx |
3742 | push ecx |
3758 | push ecx |
3743 | 3759 | ||
3744 | mov eax, ecx |
3760 | mov eax, ecx |
3745 | shl eax, 5 |
3761 | shl eax, 5 |
3746 | add eax, window_data |
3762 | add eax, window_data |
3747 | 3763 | ||
3748 | cmp eax, [esp+4] |
3764 | cmp eax, [esp+4] |
3749 | je not_this_task |
3765 | je not_this_task |
3750 | ; check if window in redraw area |
3766 | ; check if window in redraw area |
3751 | mov edi, eax |
3767 | mov edi, eax |
3752 | 3768 | ||
3753 | cmp ecx, 1 ; limit for background |
3769 | cmp ecx, 1 ; limit for background |
3754 | jz bgli |
3770 | jz bgli |
3755 | 3771 | ||
3756 | mov eax, [esp+4] ;if upper in z-position - no redraw |
3772 | mov eax, [esp+4] ;if upper in z-position - no redraw |
3757 | test eax, eax |
3773 | test eax, eax |
3758 | jz @f |
3774 | jz @f |
3759 | mov al, [eax + WDATA.z_modif] |
3775 | mov al, [eax + WDATA.z_modif] |
3760 | cmp [edi + WDATA.z_modif], al |
3776 | cmp [edi + WDATA.z_modif], al |
3761 | jg ricino |
3777 | jg ricino |
3762 | @@: |
3778 | @@: |
3763 | 3779 | ||
3764 | mov eax, [edi + WDATA.box.left] |
3780 | mov eax, [edi + WDATA.box.left] |
3765 | mov ebx, [edi + WDATA.box.top] |
3781 | mov ebx, [edi + WDATA.box.top] |
3766 | 3782 | ||
3767 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3783 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3768 | cmp ecx, ebx |
3784 | cmp ecx, ebx |
3769 | jb ricino |
3785 | jb ricino |
3770 | 3786 | ||
3771 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3787 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3772 | cmp ecx, eax |
3788 | cmp ecx, eax |
3773 | jb ricino |
3789 | jb ricino |
3774 | 3790 | ||
3775 | mov eax, [edi + WDATA.box.left] |
3791 | mov eax, [edi + WDATA.box.left] |
3776 | mov ebx, [edi + WDATA.box.top] |
3792 | mov ebx, [edi + WDATA.box.top] |
3777 | mov ecx, [edi + WDATA.box.width] |
3793 | mov ecx, [edi + WDATA.box.width] |
3778 | mov edx, [edi + WDATA.box.height] |
3794 | mov edx, [edi + WDATA.box.height] |
3779 | add ecx, eax |
3795 | add ecx, eax |
3780 | add edx, ebx |
3796 | add edx, ebx |
3781 | 3797 | ||
3782 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3798 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3783 | cmp edx, eax |
3799 | cmp edx, eax |
3784 | jb ricino |
3800 | jb ricino |
3785 | 3801 | ||
3786 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3802 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3787 | cmp ecx, eax |
3803 | cmp ecx, eax |
3788 | jb ricino |
3804 | jb ricino |
3789 | ;-------------------------------------- |
3805 | ;-------------------------------------- |
3790 | align 4 |
3806 | align 4 |
3791 | bgli: |
3807 | bgli: |
3792 | cmp dword[esp], 1 |
3808 | cmp dword[esp], 1 |
3793 | jnz .az |
3809 | jnz .az |
3794 | 3810 | ||
3795 | cmp [REDRAW_BACKGROUND], 0 |
3811 | cmp [REDRAW_BACKGROUND], 0 |
3796 | jz .az |
3812 | jz .az |
3797 | 3813 | ||
3798 | mov dl, 0 |
3814 | mov dl, 0 |
3799 | lea eax, [edi+draw_data-window_data] |
3815 | lea eax, [edi+draw_data-window_data] |
3800 | mov ebx, [draw_limits.left] |
3816 | mov ebx, [draw_limits.left] |
3801 | cmp ebx, [eax+RECT.left] |
3817 | cmp ebx, [eax+RECT.left] |
3802 | jae @f |
3818 | jae @f |
3803 | 3819 | ||
3804 | mov [eax+RECT.left], ebx |
3820 | mov [eax+RECT.left], ebx |
3805 | mov dl, 1 |
3821 | mov dl, 1 |
3806 | ;-------------------------------------- |
3822 | ;-------------------------------------- |
3807 | align 4 |
3823 | align 4 |
3808 | @@: |
3824 | @@: |
3809 | mov ebx, [draw_limits.top] |
3825 | mov ebx, [draw_limits.top] |
3810 | cmp ebx, [eax+RECT.top] |
3826 | cmp ebx, [eax+RECT.top] |
3811 | jae @f |
3827 | jae @f |
3812 | 3828 | ||
3813 | mov [eax+RECT.top], ebx |
3829 | mov [eax+RECT.top], ebx |
3814 | mov dl, 1 |
3830 | mov dl, 1 |
3815 | ;-------------------------------------- |
3831 | ;-------------------------------------- |
3816 | align 4 |
3832 | align 4 |
3817 | @@: |
3833 | @@: |
3818 | mov ebx, [draw_limits.right] |
3834 | mov ebx, [draw_limits.right] |
3819 | cmp ebx, [eax+RECT.right] |
3835 | cmp ebx, [eax+RECT.right] |
3820 | jbe @f |
3836 | jbe @f |
3821 | 3837 | ||
3822 | mov [eax+RECT.right], ebx |
3838 | mov [eax+RECT.right], ebx |
3823 | mov dl, 1 |
3839 | mov dl, 1 |
3824 | ;-------------------------------------- |
3840 | ;-------------------------------------- |
3825 | align 4 |
3841 | align 4 |
3826 | @@: |
3842 | @@: |
3827 | mov ebx, [draw_limits.bottom] |
3843 | mov ebx, [draw_limits.bottom] |
3828 | cmp ebx, [eax+RECT.bottom] |
3844 | cmp ebx, [eax+RECT.bottom] |
3829 | jbe @f |
3845 | jbe @f |
3830 | 3846 | ||
3831 | mov [eax+RECT.bottom], ebx |
3847 | mov [eax+RECT.bottom], ebx |
3832 | mov dl, 1 |
3848 | mov dl, 1 |
3833 | ;-------------------------------------- |
3849 | ;-------------------------------------- |
3834 | align 4 |
3850 | align 4 |
3835 | @@: |
3851 | @@: |
3836 | add [REDRAW_BACKGROUND], dl |
3852 | add [REDRAW_BACKGROUND], dl |
3837 | call wakeup_osloop |
3853 | call wakeup_osloop |
3838 | jmp newdw8 |
3854 | jmp newdw8 |
3839 | ;-------------------------------------- |
3855 | ;-------------------------------------- |
3840 | align 4 |
3856 | align 4 |
3841 | .az: |
3857 | .az: |
3842 | mov eax, edi |
3858 | mov eax, edi |
3843 | add eax, draw_data-window_data |
3859 | add eax, draw_data-window_data |
3844 | 3860 | ||
3845 | mov ebx, [draw_limits.left] ; set limits |
3861 | mov ebx, [draw_limits.left] ; set limits |
3846 | mov [eax + RECT.left], ebx |
3862 | mov [eax + RECT.left], ebx |
3847 | mov ebx, [draw_limits.top] |
3863 | mov ebx, [draw_limits.top] |
3848 | mov [eax + RECT.top], ebx |
3864 | mov [eax + RECT.top], ebx |
3849 | mov ebx, [draw_limits.right] |
3865 | mov ebx, [draw_limits.right] |
3850 | mov [eax + RECT.right], ebx |
3866 | mov [eax + RECT.right], ebx |
3851 | mov ebx, [draw_limits.bottom] |
3867 | mov ebx, [draw_limits.bottom] |
3852 | mov [eax + RECT.bottom], ebx |
3868 | mov [eax + RECT.bottom], ebx |
3853 | 3869 | ||
3854 | sub eax, draw_data-window_data |
3870 | sub eax, draw_data-window_data |
3855 | 3871 | ||
3856 | cmp dword [esp], 1 |
3872 | cmp dword [esp], 1 |
3857 | jne nobgrd |
3873 | jne nobgrd |
3858 | inc [REDRAW_BACKGROUND] |
3874 | inc [REDRAW_BACKGROUND] |
3859 | call wakeup_osloop |
3875 | call wakeup_osloop |
3860 | ;-------------------------------------- |
3876 | ;-------------------------------------- |
3861 | align 4 |
3877 | align 4 |
3862 | newdw8: |
3878 | newdw8: |
3863 | nobgrd: |
3879 | nobgrd: |
3864 | ;-------------------------------------- |
3880 | ;-------------------------------------- |
3865 | push eax edi ebp |
3881 | push eax edi ebp |
3866 | mov edi, [esp+12] |
3882 | mov edi, [esp+12] |
3867 | cmp edi, 1 |
3883 | cmp edi, 1 |
3868 | je .found |
3884 | je .found |
3869 | 3885 | ||
3870 | mov eax, [draw_limits.left] |
3886 | mov eax, [draw_limits.left] |
3871 | mov ebx, [draw_limits.top] |
3887 | mov ebx, [draw_limits.top] |
3872 | mov ecx, [draw_limits.right] |
3888 | mov ecx, [draw_limits.right] |
3873 | sub ecx, eax |
3889 | sub ecx, eax |
3874 | test ecx, ecx |
3890 | test ecx, ecx |
3875 | jz .not_found |
3891 | jz .not_found |
3876 | 3892 | ||
3877 | mov edx, [draw_limits.bottom] |
3893 | mov edx, [draw_limits.bottom] |
3878 | sub edx, ebx |
3894 | sub edx, ebx |
3879 | test edx, edx |
3895 | test edx, edx |
3880 | jz .not_found |
3896 | jz .not_found |
3881 | 3897 | ||
3882 | ; eax - x, ebx - y |
3898 | ; eax - x, ebx - y |
3883 | ; ecx - size x, edx - size y |
3899 | ; ecx - size x, edx - size y |
3884 | add ebx, edx |
3900 | add ebx, edx |
3885 | ;-------------------------------------- |
3901 | ;-------------------------------------- |
3886 | align 4 |
3902 | align 4 |
3887 | .start_y: |
3903 | .start_y: |
3888 | push ecx |
3904 | push ecx |
3889 | ;-------------------------------------- |
3905 | ;-------------------------------------- |
3890 | align 4 |
3906 | align 4 |
3891 | .start_x: |
3907 | .start_x: |
3892 | add eax, ecx |
3908 | add eax, ecx |
3893 | mov ebp, [d_width_calc_area + ebx*4] |
3909 | mov ebp, [d_width_calc_area + ebx*4] |
3894 | add ebp, [_display.win_map] |
3910 | add ebp, [_display.win_map] |
3895 | movzx ebp, byte[eax+ebp] ; get value for current point |
3911 | movzx ebp, byte[eax+ebp] ; get value for current point |
3896 | cmp ebp, edi |
3912 | cmp ebp, edi |
3897 | jne @f |
3913 | jne @f |
3898 | 3914 | ||
3899 | pop ecx |
3915 | pop ecx |
3900 | jmp .found |
3916 | jmp .found |
3901 | ;-------------------------------------- |
3917 | ;-------------------------------------- |
3902 | align 4 |
3918 | align 4 |
3903 | @@: |
3919 | @@: |
3904 | sub eax, ecx |
3920 | sub eax, ecx |
3905 | 3921 | ||
3906 | dec ecx |
3922 | dec ecx |
3907 | jnz .start_x |
3923 | jnz .start_x |
3908 | 3924 | ||
3909 | pop ecx |
3925 | pop ecx |
3910 | dec ebx |
3926 | dec ebx |
3911 | dec edx |
3927 | dec edx |
3912 | jnz .start_y |
3928 | jnz .start_y |
3913 | ;-------------------------------------- |
3929 | ;-------------------------------------- |
3914 | align 4 |
3930 | align 4 |
3915 | .not_found: |
3931 | .not_found: |
3916 | pop ebp edi eax |
3932 | pop ebp edi eax |
3917 | jmp ricino |
3933 | jmp ricino |
3918 | ;-------------------------------------- |
3934 | ;-------------------------------------- |
3919 | align 4 |
3935 | align 4 |
3920 | .found: |
3936 | .found: |
3921 | pop ebp edi eax |
3937 | pop ebp edi eax |
3922 | 3938 | ||
3923 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3939 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3924 | ;-------------------------------------- |
3940 | ;-------------------------------------- |
3925 | align 4 |
3941 | align 4 |
3926 | ricino: |
3942 | ricino: |
3927 | not_this_task: |
3943 | not_this_task: |
3928 | pop ecx |
3944 | pop ecx |
3929 | 3945 | ||
3930 | cmp ecx, [TASK_COUNT] |
3946 | cmp ecx, [TASK_COUNT] |
3931 | jle newdw2 |
3947 | jle newdw2 |
3932 | 3948 | ||
3933 | pop eax |
3949 | pop eax |
3934 | popad |
3950 | popad |
3935 | ret |
3951 | ret |
3936 | ;----------------------------------------------------------------------------- |
3952 | ;----------------------------------------------------------------------------- |
3937 | align 4 |
3953 | align 4 |
3938 | calculatebackground: ; background |
3954 | calculatebackground: ; background |
3939 | mov edi, [_display.win_map] ; set os to use all pixels |
3955 | mov edi, [_display.win_map] ; set os to use all pixels |
3940 | mov eax, 0x01010101 |
3956 | mov eax, 0x01010101 |
3941 | mov ecx, [_display.win_map_size] |
3957 | mov ecx, [_display.win_map_size] |
3942 | shr ecx, 2 |
3958 | shr ecx, 2 |
3943 | rep stosd |
3959 | rep stosd |
3944 | mov byte[window_data+32+WDATA.z_modif], ZPOS_DESKTOP |
3960 | mov byte[window_data+32+WDATA.z_modif], ZPOS_DESKTOP |
3945 | mov [REDRAW_BACKGROUND], 0 |
3961 | mov [REDRAW_BACKGROUND], 0 |
3946 | ret |
3962 | ret |
3947 | ;----------------------------------------------------------------------------- |
3963 | ;----------------------------------------------------------------------------- |
3948 | uglobal |
3964 | uglobal |
3949 | imax dd 0x0 |
3965 | imax dd 0x0 |
3950 | endg |
3966 | endg |
3951 | ;----------------------------------------------------------------------------- |
3967 | ;----------------------------------------------------------------------------- |
3952 | align 4 |
3968 | align 4 |
3953 | delay_ms: ; delay in 1/1000 sec |
3969 | delay_ms: ; delay in 1/1000 sec |
3954 | push eax |
3970 | push eax |
3955 | push ecx |
3971 | push ecx |
3956 | 3972 | ||
3957 | mov ecx, esi |
3973 | mov ecx, esi |
3958 | ; |
3974 | ; |
3959 | imul ecx, 33941 |
3975 | imul ecx, 33941 |
3960 | shr ecx, 9 |
3976 | shr ecx, 9 |
3961 | ; |
3977 | ; |
3962 | 3978 | ||
3963 | in al, 0x61 |
3979 | in al, 0x61 |
3964 | and al, 0x10 |
3980 | and al, 0x10 |
3965 | mov ah, al |
3981 | mov ah, al |
3966 | cld |
3982 | cld |
3967 | ;-------------------------------------- |
3983 | ;-------------------------------------- |
3968 | align 4 |
3984 | align 4 |
3969 | cnt1: |
3985 | cnt1: |
3970 | in al, 0x61 |
3986 | in al, 0x61 |
3971 | and al, 0x10 |
3987 | and al, 0x10 |
3972 | cmp al, ah |
3988 | cmp al, ah |
3973 | jz cnt1 |
3989 | jz cnt1 |
3974 | 3990 | ||
3975 | mov ah, al |
3991 | mov ah, al |
3976 | loop cnt1 |
3992 | loop cnt1 |
3977 | 3993 | ||
3978 | pop ecx |
3994 | pop ecx |
3979 | pop eax |
3995 | pop eax |
3980 | ret |
3996 | ret |
3981 | ;----------------------------------------------------------------------------- |
3997 | ;----------------------------------------------------------------------------- |
3982 | align 4 |
3998 | align 4 |
3983 | set_app_param: |
3999 | set_app_param: |
3984 | mov edi, [TASK_BASE] |
4000 | mov edi, [TASK_BASE] |
3985 | mov eax, ebx |
4001 | mov eax, ebx |
3986 | btr eax, 3 ; move MOUSE_FILTRATION |
4002 | btr eax, 3 ; move MOUSE_FILTRATION |
3987 | mov ebx, [current_slot] ; bit into event_filter |
4003 | mov ebx, [current_slot] ; bit into event_filter |
3988 | setc byte [ebx+APPDATA.event_filter] |
4004 | setc byte [ebx+APPDATA.event_filter] |
3989 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
4005 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3990 | mov [esp+32], eax ; return old mask value |
4006 | mov [esp+32], eax ; return old mask value |
3991 | ret |
4007 | ret |
3992 | ;----------------------------------------------------------------------------- |
4008 | ;----------------------------------------------------------------------------- |
3993 | 4009 | ||
3994 | ; this is for syscall |
4010 | ; this is for syscall |
3995 | proc delay_hs_unprotected |
4011 | proc delay_hs_unprotected |
3996 | call unprotect_from_terminate |
4012 | call unprotect_from_terminate |
3997 | call delay_hs |
4013 | call delay_hs |
3998 | call protect_from_terminate |
4014 | call protect_from_terminate |
3999 | ret |
4015 | ret |
4000 | endp |
4016 | endp |
4001 | 4017 | ||
4002 | if 1 |
4018 | if 1 |
4003 | align 4 |
4019 | align 4 |
4004 | delay_hs: ; delay in 1/100 secs |
4020 | delay_hs: ; delay in 1/100 secs |
4005 | ; ebx = delay time |
4021 | ; ebx = delay time |
4006 | 4022 | ||
4007 | pushad |
4023 | pushad |
4008 | push ebx |
4024 | push ebx |
4009 | xor esi, esi |
4025 | xor esi, esi |
4010 | mov ecx, MANUAL_DESTROY |
4026 | mov ecx, MANUAL_DESTROY |
4011 | call create_event |
4027 | call create_event |
4012 | test eax, eax |
4028 | test eax, eax |
4013 | jz .done |
4029 | jz .done |
4014 | 4030 | ||
4015 | mov ebx, edx |
4031 | mov ebx, edx |
4016 | mov ecx, [esp] |
4032 | mov ecx, [esp] |
4017 | push edx |
4033 | push edx |
4018 | push eax |
4034 | push eax |
4019 | call wait_event_timeout |
4035 | call wait_event_timeout |
4020 | pop eax |
4036 | pop eax |
4021 | pop ebx |
4037 | pop ebx |
4022 | call destroy_event |
4038 | call destroy_event |
4023 | .done: |
4039 | .done: |
4024 | add esp, 4 |
4040 | add esp, 4 |
4025 | popad |
4041 | popad |
4026 | ret |
4042 | ret |
4027 | 4043 | ||
4028 | else |
4044 | else |
4029 | 4045 | ||
4030 | align 4 |
4046 | align 4 |
4031 | delay_hs: ; delay in 1/100 secs |
4047 | delay_hs: ; delay in 1/100 secs |
4032 | ; ebx = delay time |
4048 | ; ebx = delay time |
4033 | push ecx |
4049 | push ecx |
4034 | push edx |
4050 | push edx |
4035 | 4051 | ||
4036 | mov edx, [timer_ticks] |
4052 | mov edx, [timer_ticks] |
4037 | ;-------------------------------------- |
4053 | ;-------------------------------------- |
4038 | align 4 |
4054 | align 4 |
4039 | newtic: |
4055 | newtic: |
4040 | mov ecx, [timer_ticks] |
4056 | mov ecx, [timer_ticks] |
4041 | sub ecx, edx |
4057 | sub ecx, edx |
4042 | cmp ecx, ebx |
4058 | cmp ecx, ebx |
4043 | jae zerodelay |
4059 | jae zerodelay |
4044 | 4060 | ||
4045 | call change_task |
4061 | call change_task |
4046 | 4062 | ||
4047 | jmp newtic |
4063 | jmp newtic |
4048 | ;-------------------------------------- |
4064 | ;-------------------------------------- |
4049 | align 4 |
4065 | align 4 |
4050 | zerodelay: |
4066 | zerodelay: |
4051 | pop edx |
4067 | pop edx |
4052 | pop ecx |
4068 | pop ecx |
4053 | ret |
4069 | ret |
4054 | end if |
4070 | end if |
4055 | 4071 | ||
4056 | ;----------------------------------------------------------------------------- |
4072 | ;----------------------------------------------------------------------------- |
4057 | align 16 ;very often call this subrutine |
4073 | align 16 ;very often call this subrutine |
4058 | memmove: ; memory move in bytes |
4074 | memmove: ; memory move in bytes |
4059 | ; eax = from |
4075 | ; eax = from |
4060 | ; ebx = to |
4076 | ; ebx = to |
4061 | ; ecx = no of bytes |
4077 | ; ecx = no of bytes |
4062 | test ecx, ecx |
4078 | test ecx, ecx |
4063 | jle .ret |
4079 | jle .ret |
4064 | 4080 | ||
4065 | push esi edi ecx |
4081 | push esi edi ecx |
4066 | 4082 | ||
4067 | mov edi, ebx |
4083 | mov edi, ebx |
4068 | mov esi, eax |
4084 | mov esi, eax |
4069 | 4085 | ||
4070 | test ecx, not 11b |
4086 | test ecx, not 11b |
4071 | jz @f |
4087 | jz @f |
4072 | 4088 | ||
4073 | push ecx |
4089 | push ecx |
4074 | shr ecx, 2 |
4090 | shr ecx, 2 |
4075 | rep movsd |
4091 | rep movsd |
4076 | pop ecx |
4092 | pop ecx |
4077 | and ecx, 11b |
4093 | and ecx, 11b |
4078 | jz .finish |
4094 | jz .finish |
4079 | ;-------------------------------------- |
4095 | ;-------------------------------------- |
4080 | align 4 |
4096 | align 4 |
4081 | @@: |
4097 | @@: |
4082 | rep movsb |
4098 | rep movsb |
4083 | ;-------------------------------------- |
4099 | ;-------------------------------------- |
4084 | align 4 |
4100 | align 4 |
4085 | .finish: |
4101 | .finish: |
4086 | pop ecx edi esi |
4102 | pop ecx edi esi |
4087 | ;-------------------------------------- |
4103 | ;-------------------------------------- |
4088 | align 4 |
4104 | align 4 |
4089 | .ret: |
4105 | .ret: |
4090 | ret |
4106 | ret |
4091 | ;----------------------------------------------------------------------------- |
4107 | ;----------------------------------------------------------------------------- |
4092 | ; |
4108 | ; |
4093 | ;align 4 |
4109 | ;align 4 |
4094 | ; |
4110 | ; |
4095 | ;read_floppy_file: |
4111 | ;read_floppy_file: |
4096 | ; |
4112 | ; |
4097 | ;; as input |
4113 | ;; as input |
4098 | ;; |
4114 | ;; |
4099 | ;; eax pointer to file |
4115 | ;; eax pointer to file |
4100 | ;; ebx file lenght |
4116 | ;; ebx file lenght |
4101 | ;; ecx start 512 byte block number |
4117 | ;; ecx start 512 byte block number |
4102 | ;; edx number of blocks to read |
4118 | ;; edx number of blocks to read |
4103 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4119 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4104 | ;; |
4120 | ;; |
4105 | ;; |
4121 | ;; |
4106 | ;; on return |
4122 | ;; on return |
4107 | ;; |
4123 | ;; |
4108 | ;; eax = 0 command succesful |
4124 | ;; eax = 0 command succesful |
4109 | ;; 1 no fd base and/or partition defined |
4125 | ;; 1 no fd base and/or partition defined |
4110 | ;; 2 yet unsupported FS |
4126 | ;; 2 yet unsupported FS |
4111 | ;; 3 unknown FS |
4127 | ;; 3 unknown FS |
4112 | ;; 4 partition not defined at hd |
4128 | ;; 4 partition not defined at hd |
4113 | ;; 5 file not found |
4129 | ;; 5 file not found |
4114 | ;; ebx = size of file |
4130 | ;; ebx = size of file |
4115 | ; |
4131 | ; |
4116 | ; mov edi,[TASK_BASE] |
4132 | ; mov edi,[TASK_BASE] |
4117 | ; add edi,0x10 |
4133 | ; add edi,0x10 |
4118 | ; add esi,[edi] |
4134 | ; add esi,[edi] |
4119 | ; add eax,[edi] |
4135 | ; add eax,[edi] |
4120 | ; |
4136 | ; |
4121 | ; pushad |
4137 | ; pushad |
4122 | ; mov edi,esi |
4138 | ; mov edi,esi |
4123 | ; add edi,1024 |
4139 | ; add edi,1024 |
4124 | ; mov esi,0x100000+19*512 |
4140 | ; mov esi,0x100000+19*512 |
4125 | ; sub ecx,1 |
4141 | ; sub ecx,1 |
4126 | ; shl ecx,9 |
4142 | ; shl ecx,9 |
4127 | ; add esi,ecx |
4143 | ; add esi,ecx |
4128 | ; shl edx,9 |
4144 | ; shl edx,9 |
4129 | ; mov ecx,edx |
4145 | ; mov ecx,edx |
4130 | ; cld |
4146 | ; cld |
4131 | ; rep movsb |
4147 | ; rep movsb |
4132 | ; popad |
4148 | ; popad |
4133 | ; |
4149 | ; |
4134 | ; mov [esp+36],eax |
4150 | ; mov [esp+36],eax |
4135 | ; mov [esp+24],ebx |
4151 | ; mov [esp+24],ebx |
4136 | ; ret |
4152 | ; ret |
4137 | 4153 | ||
4138 | 4154 | ||
4139 | 4155 | ||
4140 | align 4 |
4156 | align 4 |
4141 | set_io_access_rights: |
4157 | set_io_access_rights: |
4142 | push edi eax |
4158 | push edi eax |
4143 | mov edi, tss._io_map_0 |
4159 | mov edi, tss._io_map_0 |
4144 | ; mov ecx,eax |
4160 | ; mov ecx,eax |
4145 | ; and ecx,7 ; offset in byte |
4161 | ; and ecx,7 ; offset in byte |
4146 | ; shr eax,3 ; number of byte |
4162 | ; shr eax,3 ; number of byte |
4147 | ; add edi,eax |
4163 | ; add edi,eax |
4148 | ; mov ebx,1 |
4164 | ; mov ebx,1 |
4149 | ; shl ebx,cl |
4165 | ; shl ebx,cl |
4150 | test ebp, ebp |
4166 | test ebp, ebp |
4151 | ; cmp ebp,0 ; enable access - ebp = 0 |
4167 | ; cmp ebp,0 ; enable access - ebp = 0 |
4152 | jnz .siar1 |
4168 | jnz .siar1 |
4153 | ; not ebx |
4169 | ; not ebx |
4154 | ; and [edi],byte bl |
4170 | ; and [edi],byte bl |
4155 | btr [edi], eax |
4171 | btr [edi], eax |
4156 | pop eax edi |
4172 | pop eax edi |
4157 | ret |
4173 | ret |
4158 | .siar1: |
4174 | .siar1: |
4159 | bts [edi], eax |
4175 | bts [edi], eax |
4160 | ; or [edi],byte bl ; disable access - ebp = 1 |
4176 | ; or [edi],byte bl ; disable access - ebp = 1 |
4161 | pop eax edi |
4177 | pop eax edi |
4162 | ret |
4178 | ret |
4163 | ;reserve/free group of ports |
4179 | ;reserve/free group of ports |
4164 | ; * eax = 46 - number function |
4180 | ; * eax = 46 - number function |
4165 | ; * ebx = 0 - reserve, 1 - free |
4181 | ; * ebx = 0 - reserve, 1 - free |
4166 | ; * ecx = number start arrea of ports |
4182 | ; * ecx = number start arrea of ports |
4167 | ; * edx = number end arrea of ports (include last number of port) |
4183 | ; * edx = number end arrea of ports (include last number of port) |
4168 | ;Return value: |
4184 | ;Return value: |
4169 | ; * eax = 0 - succesful |
4185 | ; * eax = 0 - succesful |
4170 | ; * eax = 1 - error |
4186 | ; * eax = 1 - error |
4171 | ; * The system has reserve this ports: |
4187 | ; * The system has reserve this ports: |
4172 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4188 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4173 | ;destroys eax,ebx, ebp |
4189 | ;destroys eax,ebx, ebp |
4174 | r_f_port_area: |
4190 | r_f_port_area: |
4175 | 4191 | ||
4176 | test ebx, ebx |
4192 | test ebx, ebx |
4177 | jnz free_port_area |
4193 | jnz free_port_area |
4178 | ; je r_port_area |
4194 | ; je r_port_area |
4179 | ; jmp free_port_area |
4195 | ; jmp free_port_area |
4180 | 4196 | ||
4181 | ; r_port_area: |
4197 | ; r_port_area: |
4182 | 4198 | ||
4183 | ; pushad |
4199 | ; pushad |
4184 | 4200 | ||
4185 | cmp ecx, edx ; beginning > end ? |
4201 | cmp ecx, edx ; beginning > end ? |
4186 | ja rpal1 |
4202 | ja rpal1 |
4187 | cmp edx, 65536 |
4203 | cmp edx, 65536 |
4188 | jae rpal1 |
4204 | jae rpal1 |
4189 | mov eax, [RESERVED_PORTS] |
4205 | mov eax, [RESERVED_PORTS] |
4190 | test eax, eax ; no reserved areas ? |
4206 | test eax, eax ; no reserved areas ? |
4191 | je rpal2 |
4207 | je rpal2 |
4192 | cmp eax, 255 ; max reserved |
4208 | cmp eax, 255 ; max reserved |
4193 | jae rpal1 |
4209 | jae rpal1 |
4194 | rpal3: |
4210 | rpal3: |
4195 | mov ebx, eax |
4211 | mov ebx, eax |
4196 | shl ebx, 4 |
4212 | shl ebx, 4 |
4197 | add ebx, RESERVED_PORTS |
4213 | add ebx, RESERVED_PORTS |
4198 | cmp ecx, [ebx+8] |
4214 | cmp ecx, [ebx+8] |
4199 | ja rpal4 |
4215 | ja rpal4 |
4200 | cmp edx, [ebx+4] |
4216 | cmp edx, [ebx+4] |
4201 | jae rpal1 |
4217 | jae rpal1 |
4202 | ; jb rpal4 |
4218 | ; jb rpal4 |
4203 | ; jmp rpal1 |
4219 | ; jmp rpal1 |
4204 | rpal4: |
4220 | rpal4: |
4205 | dec eax |
4221 | dec eax |
4206 | jnz rpal3 |
4222 | jnz rpal3 |
4207 | jmp rpal2 |
4223 | jmp rpal2 |
4208 | rpal1: |
4224 | rpal1: |
4209 | ; popad |
4225 | ; popad |
4210 | ; mov eax,1 |
4226 | ; mov eax,1 |
4211 | xor eax, eax |
4227 | xor eax, eax |
4212 | inc eax |
4228 | inc eax |
4213 | ret |
4229 | ret |
4214 | rpal2: |
4230 | rpal2: |
4215 | ; popad |
4231 | ; popad |
4216 | ; enable port access at port IO map |
4232 | ; enable port access at port IO map |
4217 | cli |
4233 | cli |
4218 | pushad ; start enable io map |
4234 | pushad ; start enable io map |
4219 | 4235 | ||
4220 | cmp edx, 65536;16384 |
4236 | cmp edx, 65536;16384 |
4221 | jae no_unmask_io; jge |
4237 | jae no_unmask_io; jge |
4222 | mov eax, ecx |
4238 | mov eax, ecx |
4223 | ; push ebp |
4239 | ; push ebp |
4224 | xor ebp, ebp ; enable - eax = port |
4240 | xor ebp, ebp ; enable - eax = port |
4225 | new_port_access: |
4241 | new_port_access: |
4226 | ; pushad |
4242 | ; pushad |
4227 | call set_io_access_rights |
4243 | call set_io_access_rights |
4228 | ; popad |
4244 | ; popad |
4229 | inc eax |
4245 | inc eax |
4230 | cmp eax, edx |
4246 | cmp eax, edx |
4231 | jbe new_port_access |
4247 | jbe new_port_access |
4232 | ; pop ebp |
4248 | ; pop ebp |
4233 | no_unmask_io: |
4249 | no_unmask_io: |
4234 | popad ; end enable io map |
4250 | popad ; end enable io map |
4235 | sti |
4251 | sti |
4236 | 4252 | ||
4237 | mov eax, [RESERVED_PORTS] |
4253 | mov eax, [RESERVED_PORTS] |
4238 | add eax, 1 |
4254 | add eax, 1 |
4239 | mov [RESERVED_PORTS], eax |
4255 | mov [RESERVED_PORTS], eax |
4240 | shl eax, 4 |
4256 | shl eax, 4 |
4241 | add eax, RESERVED_PORTS |
4257 | add eax, RESERVED_PORTS |
4242 | mov ebx, [TASK_BASE] |
4258 | mov ebx, [TASK_BASE] |
4243 | mov ebx, [ebx+TASKDATA.pid] |
4259 | mov ebx, [ebx+TASKDATA.pid] |
4244 | mov [eax], ebx |
4260 | mov [eax], ebx |
4245 | mov [eax+4], ecx |
4261 | mov [eax+4], ecx |
4246 | mov [eax+8], edx |
4262 | mov [eax+8], edx |
4247 | 4263 | ||
4248 | xor eax, eax |
4264 | xor eax, eax |
4249 | ret |
4265 | ret |
4250 | 4266 | ||
4251 | free_port_area: |
4267 | free_port_area: |
4252 | 4268 | ||
4253 | ; pushad |
4269 | ; pushad |
4254 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4270 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4255 | test eax, eax |
4271 | test eax, eax |
4256 | jz frpal2 |
4272 | jz frpal2 |
4257 | mov ebx, [TASK_BASE] |
4273 | mov ebx, [TASK_BASE] |
4258 | mov ebx, [ebx+TASKDATA.pid] |
4274 | mov ebx, [ebx+TASKDATA.pid] |
4259 | frpal3: |
4275 | frpal3: |
4260 | mov edi, eax |
4276 | mov edi, eax |
4261 | shl edi, 4 |
4277 | shl edi, 4 |
4262 | add edi, RESERVED_PORTS |
4278 | add edi, RESERVED_PORTS |
4263 | cmp ebx, [edi] |
4279 | cmp ebx, [edi] |
4264 | jne frpal4 |
4280 | jne frpal4 |
4265 | cmp ecx, [edi+4] |
4281 | cmp ecx, [edi+4] |
4266 | jne frpal4 |
4282 | jne frpal4 |
4267 | cmp edx, [edi+8] |
4283 | cmp edx, [edi+8] |
4268 | jne frpal4 |
4284 | jne frpal4 |
4269 | jmp frpal1 |
4285 | jmp frpal1 |
4270 | frpal4: |
4286 | frpal4: |
4271 | dec eax |
4287 | dec eax |
4272 | jnz frpal3 |
4288 | jnz frpal3 |
4273 | frpal2: |
4289 | frpal2: |
4274 | ; popad |
4290 | ; popad |
4275 | inc eax |
4291 | inc eax |
4276 | ret |
4292 | ret |
4277 | frpal1: |
4293 | frpal1: |
4278 | push ecx |
4294 | push ecx |
4279 | mov ecx, 256 |
4295 | mov ecx, 256 |
4280 | sub ecx, eax |
4296 | sub ecx, eax |
4281 | shl ecx, 4 |
4297 | shl ecx, 4 |
4282 | mov esi, edi |
4298 | mov esi, edi |
4283 | add esi, 16 |
4299 | add esi, 16 |
4284 | cld |
4300 | cld |
4285 | rep movsb |
4301 | rep movsb |
4286 | 4302 | ||
4287 | dec dword [RESERVED_PORTS] |
4303 | dec dword [RESERVED_PORTS] |
4288 | ;popad |
4304 | ;popad |
4289 | ;disable port access at port IO map |
4305 | ;disable port access at port IO map |
4290 | 4306 | ||
4291 | ; pushad ; start disable io map |
4307 | ; pushad ; start disable io map |
4292 | pop eax ;start port |
4308 | pop eax ;start port |
4293 | cmp edx, 65536;16384 |
4309 | cmp edx, 65536;16384 |
4294 | jge no_mask_io |
4310 | jge no_mask_io |
4295 | 4311 | ||
4296 | ; mov eax,ecx |
4312 | ; mov eax,ecx |
4297 | xor ebp, ebp |
4313 | xor ebp, ebp |
4298 | inc ebp |
4314 | inc ebp |
4299 | new_port_access_disable: |
4315 | new_port_access_disable: |
4300 | ; pushad |
4316 | ; pushad |
4301 | ; mov ebp,1 ; disable - eax = port |
4317 | ; mov ebp,1 ; disable - eax = port |
4302 | call set_io_access_rights |
4318 | call set_io_access_rights |
4303 | ; popad |
4319 | ; popad |
4304 | inc eax |
4320 | inc eax |
4305 | cmp eax, edx |
4321 | cmp eax, edx |
4306 | jbe new_port_access_disable |
4322 | jbe new_port_access_disable |
4307 | no_mask_io: |
4323 | no_mask_io: |
4308 | ; popad ; end disable io map |
4324 | ; popad ; end disable io map |
4309 | xor eax, eax |
4325 | xor eax, eax |
4310 | ret |
4326 | ret |
4311 | ;----------------------------------------------------------------------------- |
4327 | ;----------------------------------------------------------------------------- |
4312 | align 4 |
4328 | align 4 |
4313 | drawbackground: |
4329 | drawbackground: |
4314 | dbrv20: |
4330 | dbrv20: |
4315 | cmp [BgrDrawMode], dword 1 |
4331 | cmp [BgrDrawMode], dword 1 |
4316 | jne bgrstr |
4332 | jne bgrstr |
4317 | call vesa20_drawbackground_tiled |
4333 | call vesa20_drawbackground_tiled |
4318 | ; call [draw_pointer] |
4334 | ; call [draw_pointer] |
4319 | call __sys_draw_pointer |
4335 | call __sys_draw_pointer |
4320 | ret |
4336 | ret |
4321 | ;-------------------------------------- |
4337 | ;-------------------------------------- |
4322 | align 4 |
4338 | align 4 |
4323 | bgrstr: |
4339 | bgrstr: |
4324 | call vesa20_drawbackground_stretch |
4340 | call vesa20_drawbackground_stretch |
4325 | ; call [draw_pointer] |
4341 | ; call [draw_pointer] |
4326 | call __sys_draw_pointer |
4342 | call __sys_draw_pointer |
4327 | ret |
4343 | ret |
4328 | ;----------------------------------------------------------------------------- |
4344 | ;----------------------------------------------------------------------------- |
4329 | align 4 |
4345 | align 4 |
4330 | syscall_putimage: ; PutImage |
4346 | syscall_putimage: ; PutImage |
4331 | sys_putimage: |
4347 | sys_putimage: |
4332 | test ecx, 0x80008000 |
4348 | test ecx, 0x80008000 |
4333 | jnz .exit |
4349 | jnz .exit |
4334 | test ecx, 0x0000FFFF |
4350 | test ecx, 0x0000FFFF |
4335 | jz .exit |
4351 | jz .exit |
4336 | test ecx, 0xFFFF0000 |
4352 | test ecx, 0xFFFF0000 |
4337 | jnz @f |
4353 | jnz @f |
4338 | ;-------------------------------------- |
4354 | ;-------------------------------------- |
4339 | align 4 |
4355 | align 4 |
4340 | .exit: |
4356 | .exit: |
4341 | ret |
4357 | ret |
4342 | ;-------------------------------------- |
4358 | ;-------------------------------------- |
4343 | align 4 |
4359 | align 4 |
4344 | @@: |
4360 | @@: |
4345 | mov edi, [current_slot] |
4361 | mov edi, [current_slot] |
4346 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4362 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4347 | rol edx, 16 |
4363 | rol edx, 16 |
4348 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4364 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4349 | rol edx, 16 |
4365 | rol edx, 16 |
4350 | ;-------------------------------------- |
4366 | ;-------------------------------------- |
4351 | align 4 |
4367 | align 4 |
4352 | .forced: |
4368 | .forced: |
4353 | push ebp esi 0 |
4369 | push ebp esi 0 |
4354 | mov ebp, putimage_get24bpp |
4370 | mov ebp, putimage_get24bpp |
4355 | mov esi, putimage_init24bpp |
4371 | mov esi, putimage_init24bpp |
4356 | ;-------------------------------------- |
4372 | ;-------------------------------------- |
4357 | align 4 |
4373 | align 4 |
4358 | sys_putimage_bpp: |
4374 | sys_putimage_bpp: |
4359 | call vesa20_putimage |
4375 | call vesa20_putimage |
4360 | pop ebp esi ebp |
4376 | pop ebp esi ebp |
4361 | ret |
4377 | ret |
4362 | ; jmp [draw_pointer] |
4378 | ; jmp [draw_pointer] |
4363 | ;----------------------------------------------------------------------------- |
4379 | ;----------------------------------------------------------------------------- |
4364 | align 4 |
4380 | align 4 |
4365 | sys_putimage_palette: |
4381 | sys_putimage_palette: |
4366 | ; ebx = pointer to image |
4382 | ; ebx = pointer to image |
4367 | ; ecx = [xsize]*65536 + [ysize] |
4383 | ; ecx = [xsize]*65536 + [ysize] |
4368 | ; edx = [xstart]*65536 + [ystart] |
4384 | ; edx = [xstart]*65536 + [ystart] |
4369 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4385 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4370 | ; edi = pointer to palette |
4386 | ; edi = pointer to palette |
4371 | ; ebp = row delta |
4387 | ; ebp = row delta |
4372 | mov eax, [CURRENT_TASK] |
4388 | mov eax, [CURRENT_TASK] |
4373 | shl eax, 8 |
4389 | shl eax, 8 |
4374 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4390 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4375 | rol edx, 16 |
4391 | rol edx, 16 |
4376 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4392 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4377 | rol edx, 16 |
4393 | rol edx, 16 |
4378 | ;-------------------------------------- |
4394 | ;-------------------------------------- |
4379 | align 4 |
4395 | align 4 |
4380 | .forced: |
4396 | .forced: |
4381 | cmp esi, 1 |
4397 | cmp esi, 1 |
4382 | jnz @f |
4398 | jnz @f |
4383 | push edi |
4399 | push edi |
4384 | mov eax, [edi+4] |
4400 | mov eax, [edi+4] |
4385 | sub eax, [edi] |
4401 | sub eax, [edi] |
4386 | push eax |
4402 | push eax |
4387 | push dword [edi] |
4403 | push dword [edi] |
4388 | push 0ffffff80h |
4404 | push 0ffffff80h |
4389 | mov edi, esp |
4405 | mov edi, esp |
4390 | call put_mono_image |
4406 | call put_mono_image |
4391 | add esp, 12 |
4407 | add esp, 12 |
4392 | pop edi |
4408 | pop edi |
4393 | ret |
4409 | ret |
4394 | ;-------------------------------------- |
4410 | ;-------------------------------------- |
4395 | align 4 |
4411 | align 4 |
4396 | @@: |
4412 | @@: |
4397 | cmp esi, 2 |
4413 | cmp esi, 2 |
4398 | jnz @f |
4414 | jnz @f |
4399 | push edi |
4415 | push edi |
4400 | push 0ffffff80h |
4416 | push 0ffffff80h |
4401 | mov edi, esp |
4417 | mov edi, esp |
4402 | call put_2bit_image |
4418 | call put_2bit_image |
4403 | pop eax |
4419 | pop eax |
4404 | pop edi |
4420 | pop edi |
4405 | ret |
4421 | ret |
4406 | ;-------------------------------------- |
4422 | ;-------------------------------------- |
4407 | align 4 |
4423 | align 4 |
4408 | @@: |
4424 | @@: |
4409 | cmp esi, 4 |
4425 | cmp esi, 4 |
4410 | jnz @f |
4426 | jnz @f |
4411 | push edi |
4427 | push edi |
4412 | push 0ffffff80h |
4428 | push 0ffffff80h |
4413 | mov edi, esp |
4429 | mov edi, esp |
4414 | call put_4bit_image |
4430 | call put_4bit_image |
4415 | pop eax |
4431 | pop eax |
4416 | pop edi |
4432 | pop edi |
4417 | ret |
4433 | ret |
4418 | ;-------------------------------------- |
4434 | ;-------------------------------------- |
4419 | align 4 |
4435 | align 4 |
4420 | @@: |
4436 | @@: |
4421 | push ebp esi ebp |
4437 | push ebp esi ebp |
4422 | cmp esi, 8 |
4438 | cmp esi, 8 |
4423 | jnz @f |
4439 | jnz @f |
4424 | mov ebp, putimage_get8bpp |
4440 | mov ebp, putimage_get8bpp |
4425 | mov esi, putimage_init8bpp |
4441 | mov esi, putimage_init8bpp |
4426 | jmp sys_putimage_bpp |
4442 | jmp sys_putimage_bpp |
4427 | ;-------------------------------------- |
4443 | ;-------------------------------------- |
4428 | align 4 |
4444 | align 4 |
4429 | @@: |
4445 | @@: |
4430 | cmp esi, 9 |
4446 | cmp esi, 9 |
4431 | jnz @f |
4447 | jnz @f |
4432 | mov ebp, putimage_get9bpp |
4448 | mov ebp, putimage_get9bpp |
4433 | mov esi, putimage_init9bpp |
4449 | mov esi, putimage_init9bpp |
4434 | jmp sys_putimage_bpp |
4450 | jmp sys_putimage_bpp |
4435 | ;-------------------------------------- |
4451 | ;-------------------------------------- |
4436 | align 4 |
4452 | align 4 |
4437 | @@: |
4453 | @@: |
4438 | cmp esi, 15 |
4454 | cmp esi, 15 |
4439 | jnz @f |
4455 | jnz @f |
4440 | mov ebp, putimage_get15bpp |
4456 | mov ebp, putimage_get15bpp |
4441 | mov esi, putimage_init15bpp |
4457 | mov esi, putimage_init15bpp |
4442 | jmp sys_putimage_bpp |
4458 | jmp sys_putimage_bpp |
4443 | ;-------------------------------------- |
4459 | ;-------------------------------------- |
4444 | align 4 |
4460 | align 4 |
4445 | @@: |
4461 | @@: |
4446 | cmp esi, 16 |
4462 | cmp esi, 16 |
4447 | jnz @f |
4463 | jnz @f |
4448 | mov ebp, putimage_get16bpp |
4464 | mov ebp, putimage_get16bpp |
4449 | mov esi, putimage_init16bpp |
4465 | mov esi, putimage_init16bpp |
4450 | jmp sys_putimage_bpp |
4466 | jmp sys_putimage_bpp |
4451 | ;-------------------------------------- |
4467 | ;-------------------------------------- |
4452 | align 4 |
4468 | align 4 |
4453 | @@: |
4469 | @@: |
4454 | cmp esi, 24 |
4470 | cmp esi, 24 |
4455 | jnz @f |
4471 | jnz @f |
4456 | mov ebp, putimage_get24bpp |
4472 | mov ebp, putimage_get24bpp |
4457 | mov esi, putimage_init24bpp |
4473 | mov esi, putimage_init24bpp |
4458 | jmp sys_putimage_bpp |
4474 | jmp sys_putimage_bpp |
4459 | ;-------------------------------------- |
4475 | ;-------------------------------------- |
4460 | align 4 |
4476 | align 4 |
4461 | @@: |
4477 | @@: |
4462 | cmp esi, 32 |
4478 | cmp esi, 32 |
4463 | jnz @f |
4479 | jnz @f |
4464 | mov ebp, putimage_get32bpp |
4480 | mov ebp, putimage_get32bpp |
4465 | mov esi, putimage_init32bpp |
4481 | mov esi, putimage_init32bpp |
4466 | jmp sys_putimage_bpp |
4482 | jmp sys_putimage_bpp |
4467 | ;-------------------------------------- |
4483 | ;-------------------------------------- |
4468 | align 4 |
4484 | align 4 |
4469 | @@: |
4485 | @@: |
4470 | pop ebp esi ebp |
4486 | pop ebp esi ebp |
4471 | ret |
4487 | ret |
4472 | ;----------------------------------------------------------------------------- |
4488 | ;----------------------------------------------------------------------------- |
4473 | align 4 |
4489 | align 4 |
4474 | put_mono_image: |
4490 | put_mono_image: |
4475 | push ebp esi ebp |
4491 | push ebp esi ebp |
4476 | mov ebp, putimage_get1bpp |
4492 | mov ebp, putimage_get1bpp |
4477 | mov esi, putimage_init1bpp |
4493 | mov esi, putimage_init1bpp |
4478 | jmp sys_putimage_bpp |
4494 | jmp sys_putimage_bpp |
4479 | ;----------------------------------------------------------------------------- |
4495 | ;----------------------------------------------------------------------------- |
4480 | align 4 |
4496 | align 4 |
4481 | put_2bit_image: |
4497 | put_2bit_image: |
4482 | push ebp esi ebp |
4498 | push ebp esi ebp |
4483 | mov ebp, putimage_get2bpp |
4499 | mov ebp, putimage_get2bpp |
4484 | mov esi, putimage_init2bpp |
4500 | mov esi, putimage_init2bpp |
4485 | jmp sys_putimage_bpp |
4501 | jmp sys_putimage_bpp |
4486 | ;----------------------------------------------------------------------------- |
4502 | ;----------------------------------------------------------------------------- |
4487 | align 4 |
4503 | align 4 |
4488 | put_4bit_image: |
4504 | put_4bit_image: |
4489 | push ebp esi ebp |
4505 | push ebp esi ebp |
4490 | mov ebp, putimage_get4bpp |
4506 | mov ebp, putimage_get4bpp |
4491 | mov esi, putimage_init4bpp |
4507 | mov esi, putimage_init4bpp |
4492 | jmp sys_putimage_bpp |
4508 | jmp sys_putimage_bpp |
4493 | ;----------------------------------------------------------------------------- |
4509 | ;----------------------------------------------------------------------------- |
4494 | align 4 |
4510 | align 4 |
4495 | putimage_init24bpp: |
4511 | putimage_init24bpp: |
4496 | lea eax, [eax*3] |
4512 | lea eax, [eax*3] |
4497 | putimage_init8bpp: |
4513 | putimage_init8bpp: |
4498 | putimage_init9bpp: |
4514 | putimage_init9bpp: |
4499 | ret |
4515 | ret |
4500 | ;----------------------------------------------------------------------------- |
4516 | ;----------------------------------------------------------------------------- |
4501 | align 16 |
4517 | align 16 |
4502 | putimage_get24bpp: |
4518 | putimage_get24bpp: |
4503 | movzx eax, byte [esi+2] |
4519 | movzx eax, byte [esi+2] |
4504 | shl eax, 16 |
4520 | shl eax, 16 |
4505 | mov ax, [esi] |
4521 | mov ax, [esi] |
4506 | add esi, 3 |
4522 | add esi, 3 |
4507 | ret 4 |
4523 | ret 4 |
4508 | ;----------------------------------------------------------------------------- |
4524 | ;----------------------------------------------------------------------------- |
4509 | align 16 |
4525 | align 16 |
4510 | putimage_get8bpp: |
4526 | putimage_get8bpp: |
4511 | movzx eax, byte [esi] |
4527 | movzx eax, byte [esi] |
4512 | push edx |
4528 | push edx |
4513 | mov edx, [esp+8] |
4529 | mov edx, [esp+8] |
4514 | mov eax, [edx+eax*4] |
4530 | mov eax, [edx+eax*4] |
4515 | pop edx |
4531 | pop edx |
4516 | inc esi |
4532 | inc esi |
4517 | ret 4 |
4533 | ret 4 |
4518 | ;----------------------------------------------------------------------------- |
4534 | ;----------------------------------------------------------------------------- |
4519 | align 16 |
4535 | align 16 |
4520 | putimage_get9bpp: |
4536 | putimage_get9bpp: |
4521 | lodsb |
4537 | lodsb |
4522 | mov ah, al |
4538 | mov ah, al |
4523 | shl eax, 8 |
4539 | shl eax, 8 |
4524 | mov al, ah |
4540 | mov al, ah |
4525 | ret 4 |
4541 | ret 4 |
4526 | ;----------------------------------------------------------------------------- |
4542 | ;----------------------------------------------------------------------------- |
4527 | align 4 |
4543 | align 4 |
4528 | putimage_init1bpp: |
4544 | putimage_init1bpp: |
4529 | add eax, ecx |
4545 | add eax, ecx |
4530 | push ecx |
4546 | push ecx |
4531 | add eax, 7 |
4547 | add eax, 7 |
4532 | add ecx, 7 |
4548 | add ecx, 7 |
4533 | shr eax, 3 |
4549 | shr eax, 3 |
4534 | shr ecx, 3 |
4550 | shr ecx, 3 |
4535 | sub eax, ecx |
4551 | sub eax, ecx |
4536 | pop ecx |
4552 | pop ecx |
4537 | ret |
4553 | ret |
4538 | ;----------------------------------------------------------------------------- |
4554 | ;----------------------------------------------------------------------------- |
4539 | align 16 |
4555 | align 16 |
4540 | putimage_get1bpp: |
4556 | putimage_get1bpp: |
4541 | push edx |
4557 | push edx |
4542 | mov edx, [esp+8] |
4558 | mov edx, [esp+8] |
4543 | mov al, [edx] |
4559 | mov al, [edx] |
4544 | add al, al |
4560 | add al, al |
4545 | jnz @f |
4561 | jnz @f |
4546 | lodsb |
4562 | lodsb |
4547 | adc al, al |
4563 | adc al, al |
4548 | @@: |
4564 | @@: |
4549 | mov [edx], al |
4565 | mov [edx], al |
4550 | sbb eax, eax |
4566 | sbb eax, eax |
4551 | and eax, [edx+8] |
4567 | and eax, [edx+8] |
4552 | add eax, [edx+4] |
4568 | add eax, [edx+4] |
4553 | pop edx |
4569 | pop edx |
4554 | ret 4 |
4570 | ret 4 |
4555 | ;----------------------------------------------------------------------------- |
4571 | ;----------------------------------------------------------------------------- |
4556 | align 4 |
4572 | align 4 |
4557 | putimage_init2bpp: |
4573 | putimage_init2bpp: |
4558 | add eax, ecx |
4574 | add eax, ecx |
4559 | push ecx |
4575 | push ecx |
4560 | add ecx, 3 |
4576 | add ecx, 3 |
4561 | add eax, 3 |
4577 | add eax, 3 |
4562 | shr ecx, 2 |
4578 | shr ecx, 2 |
4563 | shr eax, 2 |
4579 | shr eax, 2 |
4564 | sub eax, ecx |
4580 | sub eax, ecx |
4565 | pop ecx |
4581 | pop ecx |
4566 | ret |
4582 | ret |
4567 | ;----------------------------------------------------------------------------- |
4583 | ;----------------------------------------------------------------------------- |
4568 | align 16 |
4584 | align 16 |
4569 | putimage_get2bpp: |
4585 | putimage_get2bpp: |
4570 | push edx |
4586 | push edx |
4571 | mov edx, [esp+8] |
4587 | mov edx, [esp+8] |
4572 | mov al, [edx] |
4588 | mov al, [edx] |
4573 | mov ah, al |
4589 | mov ah, al |
4574 | shr al, 6 |
4590 | shr al, 6 |
4575 | shl ah, 2 |
4591 | shl ah, 2 |
4576 | jnz .nonewbyte |
4592 | jnz .nonewbyte |
4577 | lodsb |
4593 | lodsb |
4578 | mov ah, al |
4594 | mov ah, al |
4579 | shr al, 6 |
4595 | shr al, 6 |
4580 | shl ah, 2 |
4596 | shl ah, 2 |
4581 | add ah, 1 |
4597 | add ah, 1 |
4582 | .nonewbyte: |
4598 | .nonewbyte: |
4583 | mov [edx], ah |
4599 | mov [edx], ah |
4584 | mov edx, [edx+4] |
4600 | mov edx, [edx+4] |
4585 | movzx eax, al |
4601 | movzx eax, al |
4586 | mov eax, [edx+eax*4] |
4602 | mov eax, [edx+eax*4] |
4587 | pop edx |
4603 | pop edx |
4588 | ret 4 |
4604 | ret 4 |
4589 | ;----------------------------------------------------------------------------- |
4605 | ;----------------------------------------------------------------------------- |
4590 | align 4 |
4606 | align 4 |
4591 | putimage_init4bpp: |
4607 | putimage_init4bpp: |
4592 | add eax, ecx |
4608 | add eax, ecx |
4593 | push ecx |
4609 | push ecx |
4594 | add ecx, 1 |
4610 | add ecx, 1 |
4595 | add eax, 1 |
4611 | add eax, 1 |
4596 | shr ecx, 1 |
4612 | shr ecx, 1 |
4597 | shr eax, 1 |
4613 | shr eax, 1 |
4598 | sub eax, ecx |
4614 | sub eax, ecx |
4599 | pop ecx |
4615 | pop ecx |
4600 | ret |
4616 | ret |
4601 | ;----------------------------------------------------------------------------- |
4617 | ;----------------------------------------------------------------------------- |
4602 | align 16 |
4618 | align 16 |
4603 | putimage_get4bpp: |
4619 | putimage_get4bpp: |
4604 | push edx |
4620 | push edx |
4605 | mov edx, [esp+8] |
4621 | mov edx, [esp+8] |
4606 | add byte [edx], 80h |
4622 | add byte [edx], 80h |
4607 | jc @f |
4623 | jc @f |
4608 | movzx eax, byte [edx+1] |
4624 | movzx eax, byte [edx+1] |
4609 | mov edx, [edx+4] |
4625 | mov edx, [edx+4] |
4610 | and eax, 0x0F |
4626 | and eax, 0x0F |
4611 | mov eax, [edx+eax*4] |
4627 | mov eax, [edx+eax*4] |
4612 | pop edx |
4628 | pop edx |
4613 | ret 4 |
4629 | ret 4 |
4614 | @@: |
4630 | @@: |
4615 | movzx eax, byte [esi] |
4631 | movzx eax, byte [esi] |
4616 | add esi, 1 |
4632 | add esi, 1 |
4617 | mov [edx+1], al |
4633 | mov [edx+1], al |
4618 | shr eax, 4 |
4634 | shr eax, 4 |
4619 | mov edx, [edx+4] |
4635 | mov edx, [edx+4] |
4620 | mov eax, [edx+eax*4] |
4636 | mov eax, [edx+eax*4] |
4621 | pop edx |
4637 | pop edx |
4622 | ret 4 |
4638 | ret 4 |
4623 | ;----------------------------------------------------------------------------- |
4639 | ;----------------------------------------------------------------------------- |
4624 | align 4 |
4640 | align 4 |
4625 | putimage_init32bpp: |
4641 | putimage_init32bpp: |
4626 | shl eax, 2 |
4642 | shl eax, 2 |
4627 | ret |
4643 | ret |
4628 | ;----------------------------------------------------------------------------- |
4644 | ;----------------------------------------------------------------------------- |
4629 | align 16 |
4645 | align 16 |
4630 | putimage_get32bpp: |
4646 | putimage_get32bpp: |
4631 | lodsd |
4647 | lodsd |
4632 | ret 4 |
4648 | ret 4 |
4633 | ;----------------------------------------------------------------------------- |
4649 | ;----------------------------------------------------------------------------- |
4634 | align 4 |
4650 | align 4 |
4635 | putimage_init15bpp: |
4651 | putimage_init15bpp: |
4636 | putimage_init16bpp: |
4652 | putimage_init16bpp: |
4637 | add eax, eax |
4653 | add eax, eax |
4638 | ret |
4654 | ret |
4639 | ;----------------------------------------------------------------------------- |
4655 | ;----------------------------------------------------------------------------- |
4640 | align 16 |
4656 | align 16 |
4641 | putimage_get15bpp: |
4657 | putimage_get15bpp: |
4642 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4658 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4643 | push ecx edx |
4659 | push ecx edx |
4644 | movzx eax, word [esi] |
4660 | movzx eax, word [esi] |
4645 | add esi, 2 |
4661 | add esi, 2 |
4646 | mov ecx, eax |
4662 | mov ecx, eax |
4647 | mov edx, eax |
4663 | mov edx, eax |
4648 | and eax, 0x1F |
4664 | and eax, 0x1F |
4649 | and ecx, 0x1F shl 5 |
4665 | and ecx, 0x1F shl 5 |
4650 | and edx, 0x1F shl 10 |
4666 | and edx, 0x1F shl 10 |
4651 | shl eax, 3 |
4667 | shl eax, 3 |
4652 | shl ecx, 6 |
4668 | shl ecx, 6 |
4653 | shl edx, 9 |
4669 | shl edx, 9 |
4654 | or eax, ecx |
4670 | or eax, ecx |
4655 | or eax, edx |
4671 | or eax, edx |
4656 | pop edx ecx |
4672 | pop edx ecx |
4657 | ret 4 |
4673 | ret 4 |
4658 | ;----------------------------------------------------------------------------- |
4674 | ;----------------------------------------------------------------------------- |
4659 | align 16 |
4675 | align 16 |
4660 | putimage_get16bpp: |
4676 | putimage_get16bpp: |
4661 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4677 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4662 | push ecx edx |
4678 | push ecx edx |
4663 | movzx eax, word [esi] |
4679 | movzx eax, word [esi] |
4664 | add esi, 2 |
4680 | add esi, 2 |
4665 | mov ecx, eax |
4681 | mov ecx, eax |
4666 | mov edx, eax |
4682 | mov edx, eax |
4667 | and eax, 0x1F |
4683 | and eax, 0x1F |
4668 | and ecx, 0x3F shl 5 |
4684 | and ecx, 0x3F shl 5 |
4669 | and edx, 0x1F shl 11 |
4685 | and edx, 0x1F shl 11 |
4670 | shl eax, 3 |
4686 | shl eax, 3 |
4671 | shl ecx, 5 |
4687 | shl ecx, 5 |
4672 | shl edx, 8 |
4688 | shl edx, 8 |
4673 | or eax, ecx |
4689 | or eax, ecx |
4674 | or eax, edx |
4690 | or eax, edx |
4675 | pop edx ecx |
4691 | pop edx ecx |
4676 | ret 4 |
4692 | ret 4 |
4677 | ;----------------------------------------------------------------------------- |
4693 | ;----------------------------------------------------------------------------- |
4678 | ;align 4 |
4694 | ;align 4 |
4679 | ; eax x beginning |
4695 | ; eax x beginning |
4680 | ; ebx y beginning |
4696 | ; ebx y beginning |
4681 | ; ecx x end |
4697 | ; ecx x end |
4682 | ; edx y end |
4698 | ; edx y end |
4683 | ; edi color |
4699 | ; edi color |
4684 | ;__sys_drawbar: |
4700 | ;__sys_drawbar: |
4685 | ; mov esi, [current_slot] |
4701 | ; mov esi, [current_slot] |
4686 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4702 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4687 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4703 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4688 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4704 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4689 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4705 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4690 | ;-------------------------------------- |
4706 | ;-------------------------------------- |
4691 | ;align 4 |
4707 | ;align 4 |
4692 | ;.forced: |
4708 | ;.forced: |
4693 | ; call vesa20_drawbar |
4709 | ; call vesa20_drawbar |
4694 | ; call [draw_pointer] |
4710 | ; call [draw_pointer] |
4695 | ; ret |
4711 | ; ret |
4696 | ;----------------------------------------------------------------------------- |
4712 | ;----------------------------------------------------------------------------- |
4697 | align 4 |
4713 | align 4 |
4698 | kb_write_wait_ack: |
4714 | kb_write_wait_ack: |
4699 | 4715 | ||
4700 | push ecx edx |
4716 | push ecx edx |
4701 | 4717 | ||
4702 | mov dl, al |
4718 | mov dl, al |
4703 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4719 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4704 | .wait_output_ready: |
4720 | .wait_output_ready: |
4705 | in al, 0x64 |
4721 | in al, 0x64 |
4706 | test al, 2 |
4722 | test al, 2 |
4707 | jz @f |
4723 | jz @f |
4708 | loop .wait_output_ready |
4724 | loop .wait_output_ready |
4709 | mov ah, 1 |
4725 | mov ah, 1 |
4710 | jmp .nothing |
4726 | jmp .nothing |
4711 | @@: |
4727 | @@: |
4712 | mov al, dl |
4728 | mov al, dl |
4713 | out 0x60, al |
4729 | out 0x60, al |
4714 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4730 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4715 | .wait_ack: |
4731 | .wait_ack: |
4716 | in al, 0x64 |
4732 | in al, 0x64 |
4717 | test al, 1 |
4733 | test al, 1 |
4718 | jnz @f |
4734 | jnz @f |
4719 | loop .wait_ack |
4735 | loop .wait_ack |
4720 | mov ah, 1 |
4736 | mov ah, 1 |
4721 | jmp .nothing |
4737 | jmp .nothing |
4722 | @@: |
4738 | @@: |
4723 | in al, 0x60 |
4739 | in al, 0x60 |
4724 | xor ah, ah |
4740 | xor ah, ah |
4725 | 4741 | ||
4726 | .nothing: |
4742 | .nothing: |
4727 | pop edx ecx |
4743 | pop edx ecx |
4728 | 4744 | ||
4729 | ret |
4745 | ret |
4730 | ;----------------------------------------------------------------------------- |
4746 | ;----------------------------------------------------------------------------- |
4731 | 4747 | ||
4732 | setmouse: ; set mousepicture -pointer |
4748 | setmouse: ; set mousepicture -pointer |
4733 | ; ps2 mouse enable |
4749 | ; ps2 mouse enable |
4734 | 4750 | ||
4735 | ; mov [MOUSE_PICTURE], dword mousepointer |
4751 | ; mov [MOUSE_PICTURE], dword mousepointer |
4736 | 4752 | ||
4737 | cli |
4753 | cli |
4738 | 4754 | ||
4739 | ret |
4755 | ret |
4740 | 4756 | ||
4741 | if used _rdtsc |
4757 | if used _rdtsc |
4742 | _rdtsc: |
4758 | _rdtsc: |
4743 | bt [cpu_caps], CAPS_TSC |
4759 | bt [cpu_caps], CAPS_TSC |
4744 | jnc ret_rdtsc |
4760 | jnc ret_rdtsc |
4745 | rdtsc |
4761 | rdtsc |
4746 | ret |
4762 | ret |
4747 | ret_rdtsc: |
4763 | ret_rdtsc: |
4748 | mov edx, 0xffffffff |
4764 | mov edx, 0xffffffff |
4749 | mov eax, 0xffffffff |
4765 | mov eax, 0xffffffff |
4750 | ret |
4766 | ret |
4751 | end if |
4767 | end if |
4752 | 4768 | ||
4753 | sys_msg_board_str: |
4769 | sys_msg_board_str: |
4754 | 4770 | ||
4755 | pushad |
4771 | pushad |
4756 | @@: |
4772 | @@: |
4757 | cmp [esi], byte 0 |
4773 | cmp [esi], byte 0 |
4758 | je @f |
4774 | je @f |
4759 | mov ebx, 1 |
4775 | mov ebx, 1 |
4760 | movzx ecx, byte [esi] |
4776 | movzx ecx, byte [esi] |
4761 | call sys_msg_board |
4777 | call sys_msg_board |
4762 | inc esi |
4778 | inc esi |
4763 | jmp @b |
4779 | jmp @b |
4764 | @@: |
4780 | @@: |
4765 | popad |
4781 | popad |
4766 | ret |
4782 | ret |
4767 | 4783 | ||
4768 | sys_msg_board_byte: |
4784 | sys_msg_board_byte: |
4769 | ; in: al = byte to display |
4785 | ; in: al = byte to display |
4770 | ; out: nothing |
4786 | ; out: nothing |
4771 | ; destroys: nothing |
4787 | ; destroys: nothing |
4772 | pushad |
4788 | pushad |
4773 | mov ecx, 2 |
4789 | mov ecx, 2 |
4774 | shl eax, 24 |
4790 | shl eax, 24 |
4775 | jmp @f |
4791 | jmp @f |
4776 | 4792 | ||
4777 | sys_msg_board_word: |
4793 | sys_msg_board_word: |
4778 | ; in: ax = word to display |
4794 | ; in: ax = word to display |
4779 | ; out: nothing |
4795 | ; out: nothing |
4780 | ; destroys: nothing |
4796 | ; destroys: nothing |
4781 | pushad |
4797 | pushad |
4782 | mov ecx, 4 |
4798 | mov ecx, 4 |
4783 | shl eax, 16 |
4799 | shl eax, 16 |
4784 | jmp @f |
4800 | jmp @f |
4785 | 4801 | ||
4786 | sys_msg_board_dword: |
4802 | sys_msg_board_dword: |
4787 | ; in: eax = dword to display |
4803 | ; in: eax = dword to display |
4788 | ; out: nothing |
4804 | ; out: nothing |
4789 | ; destroys: nothing |
4805 | ; destroys: nothing |
4790 | pushad |
4806 | pushad |
4791 | mov ecx, 8 |
4807 | mov ecx, 8 |
4792 | @@: |
4808 | @@: |
4793 | push ecx |
4809 | push ecx |
4794 | rol eax, 4 |
4810 | rol eax, 4 |
4795 | push eax |
4811 | push eax |
4796 | and al, 0xF |
4812 | and al, 0xF |
4797 | cmp al, 10 |
4813 | cmp al, 10 |
4798 | sbb al, 69h |
4814 | sbb al, 69h |
4799 | das |
4815 | das |
4800 | mov cl, al |
4816 | mov cl, al |
4801 | xor ebx, ebx |
4817 | xor ebx, ebx |
4802 | inc ebx |
4818 | inc ebx |
4803 | call sys_msg_board |
4819 | call sys_msg_board |
4804 | pop eax |
4820 | pop eax |
4805 | pop ecx |
4821 | pop ecx |
4806 | loop @b |
4822 | loop @b |
4807 | popad |
4823 | popad |
4808 | ret |
4824 | ret |
4809 | 4825 | ||
4810 | msg_board_data_size = 65536 ; Must be power of two |
4826 | msg_board_data_size = 65536 ; Must be power of two |
4811 | 4827 | ||
4812 | uglobal |
4828 | uglobal |
4813 | msg_board_data rb msg_board_data_size |
4829 | msg_board_data rb msg_board_data_size |
4814 | msg_board_count dd ? |
4830 | msg_board_count dd ? |
4815 | endg |
4831 | endg |
4816 | 4832 | ||
4817 | iglobal |
4833 | iglobal |
4818 | msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen |
4834 | msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen |
4819 | endg |
4835 | endg |
4820 | 4836 | ||
4821 | sys_msg_board: |
4837 | sys_msg_board: |
4822 | ; ebx=1 -> write, cl = byte to write |
4838 | ; ebx=1 -> write, cl = byte to write |
4823 | ; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al |
4839 | ; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al |
4824 | push eax ebx |
4840 | push eax ebx |
4825 | mov eax, ebx |
4841 | mov eax, ebx |
4826 | mov ebx, ecx |
4842 | mov ebx, ecx |
4827 | mov ecx, [msg_board_count] |
4843 | mov ecx, [msg_board_count] |
4828 | cmp eax, 1 |
4844 | cmp eax, 1 |
4829 | jne .read |
4845 | jne .read |
4830 | 4846 | ||
4831 | if defined debug_com_base |
4847 | if defined debug_com_base |
4832 | push dx ax |
4848 | push dx ax |
4833 | @@: ; wait for empty transmit register |
4849 | @@: ; wait for empty transmit register |
4834 | mov dx, debug_com_base+5 |
4850 | mov dx, debug_com_base+5 |
4835 | in al, dx |
4851 | in al, dx |
4836 | test al, 1 shl 5 |
4852 | test al, 1 shl 5 |
4837 | jz @r |
4853 | jz @r |
4838 | mov dx, debug_com_base ; Output the byte |
4854 | mov dx, debug_com_base ; Output the byte |
4839 | mov al, bl |
4855 | mov al, bl |
4840 | out dx, al |
4856 | out dx, al |
4841 | pop ax dx |
4857 | pop ax dx |
4842 | end if |
4858 | end if |
4843 | 4859 | ||
4844 | mov [msg_board_data+ecx], bl |
4860 | mov [msg_board_data+ecx], bl |
4845 | cmp byte [debug_direct_print], 1 |
4861 | cmp byte [debug_direct_print], 1 |
4846 | jnz .end |
4862 | jnz .end |
4847 | pusha |
4863 | pusha |
4848 | lea edx, [msg_board_data+ecx] |
4864 | lea edx, [msg_board_data+ecx] |
4849 | mov ecx, 0x40FFFFFF |
4865 | mov ecx, 0x40FFFFFF |
4850 | mov ebx, [msg_board_pos] |
4866 | mov ebx, [msg_board_pos] |
4851 | mov edi, 1 |
4867 | mov edi, 1 |
4852 | mov esi, 1 |
4868 | mov esi, 1 |
4853 | call dtext |
4869 | call dtext |
4854 | popa |
4870 | popa |
4855 | add word [msg_board_pos+2], 6 |
4871 | add word [msg_board_pos+2], 6 |
4856 | cmp word [msg_board_pos+2], 105*6 |
4872 | cmp word [msg_board_pos+2], 105*6 |
4857 | jnc @f |
4873 | jnc @f |
4858 | cmp bl, 10 |
4874 | cmp bl, 10 |
4859 | jnz .end |
4875 | jnz .end |
4860 | @@: |
4876 | @@: |
4861 | mov word [msg_board_pos+2], 42*6 |
4877 | mov word [msg_board_pos+2], 42*6 |
4862 | add word [msg_board_pos], 10 |
4878 | add word [msg_board_pos], 10 |
4863 | mov eax, [_display.height] |
4879 | mov eax, [_display.height] |
4864 | sub eax, 10 |
4880 | sub eax, 10 |
4865 | cmp ax, word [msg_board_pos] |
4881 | cmp ax, word [msg_board_pos] |
4866 | jnc @f |
4882 | jnc @f |
4867 | mov word [msg_board_pos], 10 |
4883 | mov word [msg_board_pos], 10 |
4868 | @@: |
4884 | @@: |
4869 | pusha |
4885 | pusha |
4870 | mov eax, [msg_board_pos] |
4886 | mov eax, [msg_board_pos] |
4871 | movzx ebx, ax |
4887 | movzx ebx, ax |
4872 | shr eax, 16 |
4888 | shr eax, 16 |
4873 | mov edx, 105*6 |
4889 | mov edx, 105*6 |
4874 | xor ecx, ecx |
4890 | xor ecx, ecx |
4875 | mov edi, 1 |
4891 | mov edi, 1 |
4876 | mov esi, 9 |
4892 | mov esi, 9 |
4877 | @@: |
4893 | @@: |
4878 | call hline |
4894 | call hline |
4879 | inc ebx |
4895 | inc ebx |
4880 | dec esi |
4896 | dec esi |
4881 | jnz @b |
4897 | jnz @b |
4882 | popa |
4898 | popa |
4883 | .end: |
4899 | .end: |
4884 | inc ecx |
4900 | inc ecx |
4885 | and ecx, msg_board_data_size - 1 |
4901 | and ecx, msg_board_data_size - 1 |
4886 | mov [msg_board_count], ecx |
4902 | mov [msg_board_count], ecx |
4887 | .ret: |
4903 | .ret: |
4888 | pop ebx eax |
4904 | pop ebx eax |
4889 | ret |
4905 | ret |
4890 | 4906 | ||
4891 | @@: |
4907 | @@: |
4892 | mov [esp+32], ecx |
4908 | mov [esp+32], ecx |
4893 | mov [esp+20], ecx |
4909 | mov [esp+20], ecx |
4894 | jmp .ret |
4910 | jmp .ret |
4895 | 4911 | ||
4896 | .read: |
4912 | .read: |
4897 | cmp eax, 2 |
4913 | cmp eax, 2 |
4898 | jne .ret |
4914 | jne .ret |
4899 | test ecx, ecx |
4915 | test ecx, ecx |
4900 | jz @b |
4916 | jz @b |
4901 | add esp, 8 ; returning data in ebx and eax, so no need to restore them |
4917 | add esp, 8 ; returning data in ebx and eax, so no need to restore them |
4902 | mov eax, msg_board_data+1 |
4918 | mov eax, msg_board_data+1 |
4903 | mov ebx, msg_board_data |
4919 | mov ebx, msg_board_data |
4904 | movzx edx, byte [ebx] |
4920 | movzx edx, byte [ebx] |
4905 | call memmove |
4921 | call memmove |
4906 | dec [msg_board_count] |
4922 | dec [msg_board_count] |
4907 | mov [esp + 32], edx ;eax |
4923 | mov [esp + 32], edx ;eax |
4908 | mov [esp + 20], dword 1 |
4924 | mov [esp + 20], dword 1 |
4909 | ret |
4925 | ret |
4910 | 4926 | ||
4911 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4927 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4912 | ;; 66 sys function. ;; |
4928 | ;; 66 sys function. ;; |
4913 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4929 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4914 | ;; out eax ;; |
4930 | ;; out eax ;; |
4915 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4931 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4916 | iglobal |
4932 | iglobal |
4917 | align 4 |
4933 | align 4 |
4918 | f66call: |
4934 | f66call: |
4919 | dd sys_process_def.1 ; 1 = set keyboard mode |
4935 | dd sys_process_def.1 ; 1 = set keyboard mode |
4920 | dd sys_process_def.2 ; 2 = get keyboard mode |
4936 | dd sys_process_def.2 ; 2 = get keyboard mode |
4921 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4937 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4922 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4938 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4923 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4939 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4924 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4940 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4925 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4941 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4926 | endg |
4942 | endg |
4927 | ;----------------------------------------------------------------------------- |
4943 | ;----------------------------------------------------------------------------- |
4928 | align 4 |
4944 | align 4 |
4929 | sys_process_def: |
4945 | sys_process_def: |
4930 | dec ebx |
4946 | dec ebx |
4931 | cmp ebx, 7 |
4947 | cmp ebx, 7 |
4932 | jae .not_support ;if >=8 then or eax,-1 |
4948 | jae .not_support ;if >=8 then or eax,-1 |
4933 | 4949 | ||
4934 | mov edi, [CURRENT_TASK] |
4950 | mov edi, [CURRENT_TASK] |
4935 | jmp dword [f66call+ebx*4] |
4951 | jmp dword [f66call+ebx*4] |
4936 | 4952 | ||
4937 | .not_support: |
4953 | .not_support: |
4938 | or eax, -1 |
4954 | or eax, -1 |
4939 | ret |
4955 | ret |
4940 | ;----------------------------------------------------------------------------- |
4956 | ;----------------------------------------------------------------------------- |
4941 | align 4 |
4957 | align 4 |
4942 | .1: |
4958 | .1: |
4943 | shl edi, 8 |
4959 | shl edi, 8 |
4944 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4960 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4945 | 4961 | ||
4946 | ret |
4962 | ret |
4947 | ;----------------------------------------------------------------------------- |
4963 | ;----------------------------------------------------------------------------- |
4948 | align 4 |
4964 | align 4 |
4949 | .2: ; 2 = get keyboard mode |
4965 | .2: ; 2 = get keyboard mode |
4950 | shl edi, 8 |
4966 | shl edi, 8 |
4951 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4967 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4952 | mov [esp+32], eax |
4968 | mov [esp+32], eax |
4953 | ret |
4969 | ret |
4954 | ;----------------------------------------------------------------------------- |
4970 | ;----------------------------------------------------------------------------- |
4955 | align 4 |
4971 | align 4 |
4956 | .3: ;3 = get keyboard ctrl, alt, shift |
4972 | .3: ;3 = get keyboard ctrl, alt, shift |
4957 | mov eax, [kb_state] |
4973 | mov eax, [kb_state] |
4958 | mov [esp+32], eax |
4974 | mov [esp+32], eax |
4959 | ret |
4975 | ret |
4960 | ;----------------------------------------------------------------------------- |
4976 | ;----------------------------------------------------------------------------- |
4961 | align 4 |
4977 | align 4 |
4962 | .4: |
4978 | .4: |
4963 | mov eax, hotkey_list |
4979 | mov eax, hotkey_list |
4964 | @@: |
4980 | @@: |
4965 | cmp dword [eax+8], 0 |
4981 | cmp dword [eax+8], 0 |
4966 | jz .found_free |
4982 | jz .found_free |
4967 | add eax, 16 |
4983 | add eax, 16 |
4968 | cmp eax, hotkey_list+16*256 |
4984 | cmp eax, hotkey_list+16*256 |
4969 | jb @b |
4985 | jb @b |
4970 | mov dword [esp+32], 1 |
4986 | mov dword [esp+32], 1 |
4971 | ret |
4987 | ret |
4972 | .found_free: |
4988 | .found_free: |
4973 | mov [eax+8], edi |
4989 | mov [eax+8], edi |
4974 | mov [eax+4], edx |
4990 | mov [eax+4], edx |
4975 | movzx ecx, cl |
4991 | movzx ecx, cl |
4976 | lea ecx, [hotkey_scancodes+ecx*4] |
4992 | lea ecx, [hotkey_scancodes+ecx*4] |
4977 | mov edx, [ecx] |
4993 | mov edx, [ecx] |
4978 | mov [eax], edx |
4994 | mov [eax], edx |
4979 | mov [ecx], eax |
4995 | mov [ecx], eax |
4980 | mov [eax+12], ecx |
4996 | mov [eax+12], ecx |
4981 | test edx, edx |
4997 | test edx, edx |
4982 | jz @f |
4998 | jz @f |
4983 | mov [edx+12], eax |
4999 | mov [edx+12], eax |
4984 | @@: |
5000 | @@: |
4985 | and dword [esp+32], 0 |
5001 | and dword [esp+32], 0 |
4986 | ret |
5002 | ret |
4987 | ;----------------------------------------------------------------------------- |
5003 | ;----------------------------------------------------------------------------- |
4988 | align 4 |
5004 | align 4 |
4989 | .5: |
5005 | .5: |
4990 | movzx ebx, cl |
5006 | movzx ebx, cl |
4991 | lea ebx, [hotkey_scancodes+ebx*4] |
5007 | lea ebx, [hotkey_scancodes+ebx*4] |
4992 | mov eax, [ebx] |
5008 | mov eax, [ebx] |
4993 | .scan: |
5009 | .scan: |
4994 | test eax, eax |
5010 | test eax, eax |
4995 | jz .notfound |
5011 | jz .notfound |
4996 | cmp [eax+8], edi |
5012 | cmp [eax+8], edi |
4997 | jnz .next |
5013 | jnz .next |
4998 | cmp [eax+4], edx |
5014 | cmp [eax+4], edx |
4999 | jz .found |
5015 | jz .found |
5000 | .next: |
5016 | .next: |
5001 | mov eax, [eax] |
5017 | mov eax, [eax] |
5002 | jmp .scan |
5018 | jmp .scan |
5003 | .notfound: |
5019 | .notfound: |
5004 | mov dword [esp+32], 1 |
5020 | mov dword [esp+32], 1 |
5005 | ret |
5021 | ret |
5006 | .found: |
5022 | .found: |
5007 | mov ecx, [eax] |
5023 | mov ecx, [eax] |
5008 | jecxz @f |
5024 | jecxz @f |
5009 | mov edx, [eax+12] |
5025 | mov edx, [eax+12] |
5010 | mov [ecx+12], edx |
5026 | mov [ecx+12], edx |
5011 | @@: |
5027 | @@: |
5012 | mov ecx, [eax+12] |
5028 | mov ecx, [eax+12] |
5013 | mov edx, [eax] |
5029 | mov edx, [eax] |
5014 | mov [ecx], edx |
5030 | mov [ecx], edx |
5015 | xor edx, edx |
5031 | xor edx, edx |
5016 | mov [eax+4], edx |
5032 | mov [eax+4], edx |
5017 | mov [eax+8], edx |
5033 | mov [eax+8], edx |
5018 | mov [eax+12], edx |
5034 | mov [eax+12], edx |
5019 | mov [eax], edx |
5035 | mov [eax], edx |
5020 | mov [esp+32], edx |
5036 | mov [esp+32], edx |
5021 | ret |
5037 | ret |
5022 | ;----------------------------------------------------------------------------- |
5038 | ;----------------------------------------------------------------------------- |
5023 | align 4 |
5039 | align 4 |
5024 | .6: |
5040 | .6: |
5025 | pushfd |
5041 | pushfd |
5026 | cli |
5042 | cli |
5027 | mov eax, [PID_lock_input] |
5043 | mov eax, [PID_lock_input] |
5028 | test eax, eax |
5044 | test eax, eax |
5029 | jnz @f |
5045 | jnz @f |
5030 | ; get current PID |
5046 | ; get current PID |
5031 | mov eax, [CURRENT_TASK] |
5047 | mov eax, [CURRENT_TASK] |
5032 | shl eax, 5 |
5048 | shl eax, 5 |
5033 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5049 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5034 | ; set current PID for lock input |
5050 | ; set current PID for lock input |
5035 | mov [PID_lock_input], eax |
5051 | mov [PID_lock_input], eax |
5036 | @@: |
5052 | @@: |
5037 | popfd |
5053 | popfd |
5038 | ret |
5054 | ret |
5039 | ;----------------------------------------------------------------------------- |
5055 | ;----------------------------------------------------------------------------- |
5040 | align 4 |
5056 | align 4 |
5041 | .7: |
5057 | .7: |
5042 | mov eax, [PID_lock_input] |
5058 | mov eax, [PID_lock_input] |
5043 | test eax, eax |
5059 | test eax, eax |
5044 | jz @f |
5060 | jz @f |
5045 | ; get current PID |
5061 | ; get current PID |
5046 | mov ebx, [CURRENT_TASK] |
5062 | mov ebx, [CURRENT_TASK] |
5047 | shl ebx, 5 |
5063 | shl ebx, 5 |
5048 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5064 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5049 | ; compare current lock input with current PID |
5065 | ; compare current lock input with current PID |
5050 | cmp ebx, eax |
5066 | cmp ebx, eax |
5051 | jne @f |
5067 | jne @f |
5052 | 5068 | ||
5053 | xor eax, eax |
5069 | xor eax, eax |
5054 | mov [PID_lock_input], eax |
5070 | mov [PID_lock_input], eax |
5055 | @@: |
5071 | @@: |
5056 | ret |
5072 | ret |
5057 | ;----------------------------------------------------------------------------- |
5073 | ;----------------------------------------------------------------------------- |
5058 | uglobal |
5074 | uglobal |
5059 | PID_lock_input dd 0x0 |
5075 | PID_lock_input dd 0x0 |
5060 | endg |
5076 | endg |
5061 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5077 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5062 | ;; 61 sys function. ;; |
5078 | ;; 61 sys function. ;; |
5063 | ;; in eax=61,ebx in [1..3] ;; |
5079 | ;; in eax=61,ebx in [1..3] ;; |
5064 | ;; out eax ;; |
5080 | ;; out eax ;; |
5065 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5081 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5066 | iglobal |
5082 | iglobal |
5067 | align 4 |
5083 | align 4 |
5068 | f61call: |
5084 | f61call: |
5069 | dd sys_gs.1 ; resolution |
5085 | dd sys_gs.1 ; resolution |
5070 | dd sys_gs.2 ; bits per pixel |
5086 | dd sys_gs.2 ; bits per pixel |
5071 | dd sys_gs.3 ; bytes per scanline |
5087 | dd sys_gs.3 ; bytes per scanline |
5072 | endg |
5088 | endg |
5073 | 5089 | ||
5074 | 5090 | ||
5075 | align 4 |
5091 | align 4 |
5076 | 5092 | ||
5077 | sys_gs: ; direct screen access |
5093 | sys_gs: ; direct screen access |
5078 | dec ebx |
5094 | dec ebx |
5079 | cmp ebx, 2 |
5095 | cmp ebx, 2 |
5080 | ja .not_support |
5096 | ja .not_support |
5081 | jmp dword [f61call+ebx*4] |
5097 | jmp dword [f61call+ebx*4] |
5082 | .not_support: |
5098 | .not_support: |
5083 | or [esp+32], dword -1 |
5099 | or [esp+32], dword -1 |
5084 | ret |
5100 | ret |
5085 | 5101 | ||
5086 | 5102 | ||
5087 | .1: ; resolution |
5103 | .1: ; resolution |
5088 | mov eax, [_display.width] |
5104 | mov eax, [_display.width] |
5089 | shl eax, 16 |
5105 | shl eax, 16 |
5090 | mov ax, word [_display.height] |
5106 | mov ax, word [_display.height] |
5091 | mov [esp+32], eax |
5107 | mov [esp+32], eax |
5092 | ret |
5108 | ret |
5093 | .2: ; bits per pixel |
5109 | .2: ; bits per pixel |
5094 | mov eax, [_display.bits_per_pixel] |
5110 | mov eax, [_display.bits_per_pixel] |
5095 | mov [esp+32], eax |
5111 | mov [esp+32], eax |
5096 | ret |
5112 | ret |
5097 | .3: ; bytes per scanline |
5113 | .3: ; bytes per scanline |
5098 | mov eax, [_display.lfb_pitch] |
5114 | mov eax, [_display.lfb_pitch] |
5099 | mov [esp+32], eax |
5115 | mov [esp+32], eax |
5100 | ret |
5116 | ret |
5101 | 5117 | ||
5102 | align 4 ; system functions |
5118 | align 4 ; system functions |
5103 | 5119 | ||
5104 | syscall_setpixel: ; SetPixel |
5120 | syscall_setpixel: ; SetPixel |
5105 | 5121 | ||
5106 | mov eax, ebx |
5122 | mov eax, ebx |
5107 | mov ebx, ecx |
5123 | mov ebx, ecx |
5108 | mov ecx, edx |
5124 | mov ecx, edx |
5109 | mov edx, [TASK_BASE] |
5125 | mov edx, [TASK_BASE] |
5110 | add eax, [edx-twdw+WDATA.box.left] |
5126 | add eax, [edx-twdw+WDATA.box.left] |
5111 | add ebx, [edx-twdw+WDATA.box.top] |
5127 | add ebx, [edx-twdw+WDATA.box.top] |
5112 | mov edi, [current_slot] |
5128 | mov edi, [current_slot] |
5113 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5129 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5114 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5130 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5115 | xor edi, edi ; no force |
5131 | xor edi, edi ; no force |
5116 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5132 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5117 | ; jmp [putpixel] |
5133 | ; jmp [putpixel] |
5118 | jmp __sys_putpixel |
5134 | jmp __sys_putpixel |
5119 | 5135 | ||
5120 | align 4 |
5136 | align 4 |
5121 | 5137 | ||
5122 | syscall_writetext: ; WriteText |
5138 | syscall_writetext: ; WriteText |
5123 | 5139 | ||
5124 | mov eax, [TASK_BASE] |
5140 | mov eax, [TASK_BASE] |
5125 | mov ebp, [eax-twdw+WDATA.box.left] |
5141 | mov ebp, [eax-twdw+WDATA.box.left] |
5126 | push esi |
5142 | push esi |
5127 | mov esi, [current_slot] |
5143 | mov esi, [current_slot] |
5128 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5144 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5129 | shl ebp, 16 |
5145 | shl ebp, 16 |
5130 | add ebp, [eax-twdw+WDATA.box.top] |
5146 | add ebp, [eax-twdw+WDATA.box.top] |
5131 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5147 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5132 | pop esi |
5148 | pop esi |
5133 | test ecx, 0x08000000 ; redirect the output to the user area |
5149 | test ecx, 0x08000000 ; redirect the output to the user area |
5134 | jnz @f |
5150 | jnz @f |
5135 | add ebx, ebp |
5151 | add ebx, ebp |
5136 | align 4 |
5152 | align 4 |
5137 | @@: |
5153 | @@: |
5138 | mov eax, edi |
5154 | mov eax, edi |
5139 | test ecx, 0x08000000 ; redirect the output to the user area |
5155 | test ecx, 0x08000000 ; redirect the output to the user area |
5140 | jnz dtext |
5156 | jnz dtext |
5141 | xor edi, edi |
5157 | xor edi, edi |
5142 | jmp dtext |
5158 | jmp dtext |
5143 | 5159 | ||
5144 | align 4 |
5160 | align 4 |
5145 | 5161 | ||
5146 | syscall_drawrect: ; DrawRect |
5162 | syscall_drawrect: ; DrawRect |
5147 | 5163 | ||
5148 | mov edi, edx ; color + gradient |
5164 | mov edi, edx ; color + gradient |
5149 | and edi, 0x80FFFFFF |
5165 | and edi, 0x80FFFFFF |
5150 | test bx, bx ; x.size |
5166 | test bx, bx ; x.size |
5151 | je .drectr |
5167 | je .drectr |
5152 | test cx, cx ; y.size |
5168 | test cx, cx ; y.size |
5153 | je .drectr |
5169 | je .drectr |
5154 | 5170 | ||
5155 | mov eax, ebx ; bad idea |
5171 | mov eax, ebx ; bad idea |
5156 | mov ebx, ecx |
5172 | mov ebx, ecx |
5157 | 5173 | ||
5158 | movzx ecx, ax ; ecx - x.size |
5174 | movzx ecx, ax ; ecx - x.size |
5159 | shr eax, 16 ; eax - x.coord |
5175 | shr eax, 16 ; eax - x.coord |
5160 | movzx edx, bx ; edx - y.size |
5176 | movzx edx, bx ; edx - y.size |
5161 | shr ebx, 16 ; ebx - y.coord |
5177 | shr ebx, 16 ; ebx - y.coord |
5162 | mov esi, [current_slot] |
5178 | mov esi, [current_slot] |
5163 | 5179 | ||
5164 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5180 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5165 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5181 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5166 | add ecx, eax |
5182 | add ecx, eax |
5167 | add edx, ebx |
5183 | add edx, ebx |
5168 | ; jmp [drawbar] |
5184 | ; jmp [drawbar] |
5169 | jmp vesa20_drawbar |
5185 | jmp vesa20_drawbar |
5170 | .drectr: |
5186 | .drectr: |
5171 | ret |
5187 | ret |
5172 | 5188 | ||
5173 | align 4 |
5189 | align 4 |
5174 | syscall_getscreensize: ; GetScreenSize |
5190 | syscall_getscreensize: ; GetScreenSize |
5175 | mov ax, word [_display.width] |
5191 | mov ax, word [_display.width] |
5176 | dec ax |
5192 | dec ax |
5177 | shl eax, 16 |
5193 | shl eax, 16 |
5178 | mov ax, word [_display.height] |
5194 | mov ax, word [_display.height] |
5179 | dec ax |
5195 | dec ax |
5180 | mov [esp + 32], eax |
5196 | mov [esp + 32], eax |
5181 | ret |
5197 | ret |
5182 | ;----------------------------------------------------------------------------- |
5198 | ;----------------------------------------------------------------------------- |
5183 | align 4 |
5199 | align 4 |
5184 | syscall_cdaudio: |
5200 | syscall_cdaudio: |
5185 | ; ECX - position of CD/DVD-drive |
5201 | ; ECX - position of CD/DVD-drive |
5186 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5202 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5187 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5203 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5188 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5204 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5189 | cmp ecx, 11 |
5205 | cmp ecx, 11 |
5190 | ja .exit |
5206 | ja .exit |
5191 | 5207 | ||
5192 | mov eax, ecx |
5208 | mov eax, ecx |
5193 | shr eax, 2 |
5209 | shr eax, 2 |
5194 | lea eax, [eax*5] |
5210 | lea eax, [eax*5] |
5195 | mov al, [eax+DRIVE_DATA+1] |
5211 | mov al, [eax+DRIVE_DATA+1] |
5196 | 5212 | ||
5197 | push ecx ebx |
5213 | push ecx ebx |
5198 | mov ebx, ecx |
5214 | mov ebx, ecx |
5199 | and ebx, 11b |
5215 | and ebx, 11b |
5200 | shl ebx, 1 |
5216 | shl ebx, 1 |
5201 | mov cl, 6 |
5217 | mov cl, 6 |
5202 | sub cl, bl |
5218 | sub cl, bl |
5203 | shr al, cl |
5219 | shr al, cl |
5204 | test al, 2 ; it's not an ATAPI device |
5220 | test al, 2 ; it's not an ATAPI device |
5205 | pop ebx ecx |
5221 | pop ebx ecx |
5206 | 5222 | ||
5207 | jz .exit |
5223 | jz .exit |
5208 | 5224 | ||
5209 | cmp ebx, 4 |
5225 | cmp ebx, 4 |
5210 | je .eject |
5226 | je .eject |
5211 | 5227 | ||
5212 | cmp ebx, 5 |
5228 | cmp ebx, 5 |
5213 | je .load |
5229 | je .load |
5214 | ;-------------------------------------- |
5230 | ;-------------------------------------- |
5215 | .exit: |
5231 | .exit: |
5216 | ret |
5232 | ret |
5217 | ;-------------------------------------- |
5233 | ;-------------------------------------- |
5218 | .load: |
5234 | .load: |
5219 | call .reserve |
5235 | call .reserve |
5220 | call LoadMedium |
5236 | call LoadMedium |
5221 | jmp .free |
5237 | jmp .free |
5222 | ;-------------------------------------- |
5238 | ;-------------------------------------- |
5223 | .eject: |
5239 | .eject: |
5224 | call .reserve |
5240 | call .reserve |
5225 | call clear_CD_cache |
5241 | call clear_CD_cache |
5226 | call allow_medium_removal |
5242 | call allow_medium_removal |
5227 | call EjectMedium |
5243 | call EjectMedium |
5228 | jmp .free |
5244 | jmp .free |
5229 | ;-------------------------------------- |
5245 | ;-------------------------------------- |
5230 | .reserve: |
5246 | .reserve: |
5231 | call reserve_cd |
5247 | call reserve_cd |
5232 | 5248 | ||
5233 | mov ebx, ecx |
5249 | mov ebx, ecx |
5234 | inc ebx |
5250 | inc ebx |
5235 | mov [cdpos], ebx |
5251 | mov [cdpos], ebx |
5236 | 5252 | ||
5237 | mov eax, ecx |
5253 | mov eax, ecx |
5238 | shr eax, 1 |
5254 | shr eax, 1 |
5239 | and eax, 1 |
5255 | and eax, 1 |
5240 | inc eax |
5256 | inc eax |
5241 | mov [ChannelNumber], al |
5257 | mov [ChannelNumber], al |
5242 | mov eax, ecx |
5258 | mov eax, ecx |
5243 | and eax, 1 |
5259 | and eax, 1 |
5244 | mov [DiskNumber], al |
5260 | mov [DiskNumber], al |
5245 | call reserve_cd_channel |
5261 | call reserve_cd_channel |
5246 | ret |
5262 | ret |
5247 | ;-------------------------------------- |
5263 | ;-------------------------------------- |
5248 | .free: |
5264 | .free: |
5249 | call free_cd_channel |
5265 | call free_cd_channel |
5250 | and [cd_status], 0 |
5266 | and [cd_status], 0 |
5251 | ret |
5267 | ret |
5252 | ;----------------------------------------------------------------------------- |
5268 | ;----------------------------------------------------------------------------- |
5253 | align 4 |
5269 | align 4 |
5254 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5270 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5255 | cmp ebx, [_display.width] |
5271 | cmp ebx, [_display.width] |
5256 | jb @f |
5272 | jb @f |
5257 | cmp ecx, [_display.height] |
5273 | cmp ecx, [_display.height] |
5258 | jb @f |
5274 | jb @f |
5259 | xor eax, eax |
5275 | xor eax, eax |
5260 | jmp .store |
5276 | jmp .store |
5261 | ;-------------------------------------- |
5277 | ;-------------------------------------- |
5262 | align 4 |
5278 | align 4 |
5263 | @@: |
5279 | @@: |
5264 | mov eax, [d_width_calc_area + ecx*4] |
5280 | mov eax, [d_width_calc_area + ecx*4] |
5265 | add eax, [_display.win_map] |
5281 | add eax, [_display.win_map] |
5266 | movzx eax, byte[eax+ebx] ; get value for current point |
5282 | movzx eax, byte[eax+ebx] ; get value for current point |
5267 | ;-------------------------------------- |
5283 | ;-------------------------------------- |
5268 | align 4 |
5284 | align 4 |
5269 | .store: |
5285 | .store: |
5270 | mov [esp + 32], eax |
5286 | mov [esp + 32], eax |
5271 | ret |
5287 | ret |
5272 | ;----------------------------------------------------------------------------- |
5288 | ;----------------------------------------------------------------------------- |
5273 | align 4 |
5289 | align 4 |
5274 | syscall_getpixel: ; GetPixel |
5290 | syscall_getpixel: ; GetPixel |
5275 | mov ecx, [_display.width] |
5291 | mov ecx, [_display.width] |
5276 | xor edx, edx |
5292 | xor edx, edx |
5277 | mov eax, ebx |
5293 | mov eax, ebx |
5278 | div ecx |
5294 | div ecx |
5279 | mov ebx, edx |
5295 | mov ebx, edx |
5280 | xchg eax, ebx |
5296 | xchg eax, ebx |
5281 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5297 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5282 | call dword [GETPIXEL]; eax - x, ebx - y |
5298 | call dword [GETPIXEL]; eax - x, ebx - y |
5283 | mov [esp + 32], ecx |
5299 | mov [esp + 32], ecx |
5284 | ret |
5300 | ret |
5285 | ;----------------------------------------------------------------------------- |
5301 | ;----------------------------------------------------------------------------- |
5286 | align 4 |
5302 | align 4 |
5287 | syscall_getarea: |
5303 | syscall_getarea: |
5288 | ;eax = 36 |
5304 | ;eax = 36 |
5289 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5305 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5290 | ;ecx = [size x]*65536 + [size y] |
5306 | ;ecx = [size x]*65536 + [size y] |
5291 | ;edx = [start x]*65536 + [start y] |
5307 | ;edx = [start x]*65536 + [start y] |
5292 | pushad |
5308 | pushad |
5293 | mov edi, ebx |
5309 | mov edi, ebx |
5294 | mov eax, edx |
5310 | mov eax, edx |
5295 | shr eax, 16 |
5311 | shr eax, 16 |
5296 | mov ebx, edx |
5312 | mov ebx, edx |
5297 | and ebx, 0xffff |
5313 | and ebx, 0xffff |
5298 | dec eax |
5314 | dec eax |
5299 | dec ebx |
5315 | dec ebx |
5300 | ; eax - x, ebx - y |
5316 | ; eax - x, ebx - y |
5301 | mov edx, ecx |
5317 | mov edx, ecx |
5302 | 5318 | ||
5303 | shr ecx, 16 |
5319 | shr ecx, 16 |
5304 | and edx, 0xffff |
5320 | and edx, 0xffff |
5305 | mov esi, ecx |
5321 | mov esi, ecx |
5306 | ; ecx - size x, edx - size y |
5322 | ; ecx - size x, edx - size y |
5307 | 5323 | ||
5308 | mov ebp, edx |
5324 | mov ebp, edx |
5309 | dec ebp |
5325 | dec ebp |
5310 | lea ebp, [ebp*3] |
5326 | lea ebp, [ebp*3] |
5311 | 5327 | ||
5312 | imul ebp, esi |
5328 | imul ebp, esi |
5313 | 5329 | ||
5314 | mov esi, ecx |
5330 | mov esi, ecx |
5315 | dec esi |
5331 | dec esi |
5316 | lea esi, [esi*3] |
5332 | lea esi, [esi*3] |
5317 | 5333 | ||
5318 | add ebp, esi |
5334 | add ebp, esi |
5319 | add ebp, edi |
5335 | add ebp, edi |
5320 | 5336 | ||
5321 | add ebx, edx |
5337 | add ebx, edx |
5322 | ;-------------------------------------- |
5338 | ;-------------------------------------- |
5323 | align 4 |
5339 | align 4 |
5324 | .start_y: |
5340 | .start_y: |
5325 | push ecx edx |
5341 | push ecx edx |
5326 | ;-------------------------------------- |
5342 | ;-------------------------------------- |
5327 | align 4 |
5343 | align 4 |
5328 | .start_x: |
5344 | .start_x: |
5329 | push eax ebx ecx |
5345 | push eax ebx ecx |
5330 | add eax, ecx |
5346 | add eax, ecx |
5331 | 5347 | ||
5332 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5348 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5333 | call dword [GETPIXEL]; eax - x, ebx - y |
5349 | call dword [GETPIXEL]; eax - x, ebx - y |
5334 | 5350 | ||
5335 | mov [ebp], cx |
5351 | mov [ebp], cx |
5336 | shr ecx, 16 |
5352 | shr ecx, 16 |
5337 | mov [ebp+2], cl |
5353 | mov [ebp+2], cl |
5338 | 5354 | ||
5339 | pop ecx ebx eax |
5355 | pop ecx ebx eax |
5340 | sub ebp, 3 |
5356 | sub ebp, 3 |
5341 | dec ecx |
5357 | dec ecx |
5342 | jnz .start_x |
5358 | jnz .start_x |
5343 | pop edx ecx |
5359 | pop edx ecx |
5344 | dec ebx |
5360 | dec ebx |
5345 | dec edx |
5361 | dec edx |
5346 | jnz .start_y |
5362 | jnz .start_y |
5347 | popad |
5363 | popad |
5348 | ret |
5364 | ret |
5349 | ;----------------------------------------------------------------------------- |
5365 | ;----------------------------------------------------------------------------- |
5350 | align 4 |
5366 | align 4 |
5351 | syscall_putarea_backgr: |
5367 | syscall_putarea_backgr: |
5352 | ;eax = 25 |
5368 | ;eax = 25 |
5353 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5369 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5354 | ;ecx = [size x]*65536 + [size y] |
5370 | ;ecx = [size x]*65536 + [size y] |
5355 | ;edx = [start x]*65536 + [start y] |
5371 | ;edx = [start x]*65536 + [start y] |
5356 | pushad |
5372 | pushad |
5357 | mov edi, ebx |
5373 | mov edi, ebx |
5358 | mov eax, edx |
5374 | mov eax, edx |
5359 | shr eax, 16 |
5375 | shr eax, 16 |
5360 | mov ebx, edx |
5376 | mov ebx, edx |
5361 | and ebx, 0xffff |
5377 | and ebx, 0xffff |
5362 | dec eax |
5378 | dec eax |
5363 | dec ebx |
5379 | dec ebx |
5364 | ; eax - x, ebx - y |
5380 | ; eax - x, ebx - y |
5365 | mov edx, ecx |
5381 | mov edx, ecx |
5366 | shr ecx, 16 |
5382 | shr ecx, 16 |
5367 | and edx, 0xffff |
5383 | and edx, 0xffff |
5368 | mov esi, ecx |
5384 | mov esi, ecx |
5369 | ; ecx - size x, edx - size y |
5385 | ; ecx - size x, edx - size y |
5370 | mov ebp, edx |
5386 | mov ebp, edx |
5371 | dec ebp |
5387 | dec ebp |
5372 | shl ebp, 2 |
5388 | shl ebp, 2 |
5373 | 5389 | ||
5374 | imul ebp, esi |
5390 | imul ebp, esi |
5375 | 5391 | ||
5376 | mov esi, ecx |
5392 | mov esi, ecx |
5377 | dec esi |
5393 | dec esi |
5378 | shl esi, 2 |
5394 | shl esi, 2 |
5379 | 5395 | ||
5380 | add ebp, esi |
5396 | add ebp, esi |
5381 | add ebp, edi |
5397 | add ebp, edi |
5382 | 5398 | ||
5383 | add ebx, edx |
5399 | add ebx, edx |
5384 | ;-------------------------------------- |
5400 | ;-------------------------------------- |
5385 | align 4 |
5401 | align 4 |
5386 | .start_y: |
5402 | .start_y: |
5387 | push ecx edx |
5403 | push ecx edx |
5388 | ;-------------------------------------- |
5404 | ;-------------------------------------- |
5389 | align 4 |
5405 | align 4 |
5390 | .start_x: |
5406 | .start_x: |
5391 | push eax ecx |
5407 | push eax ecx |
5392 | add eax, ecx |
5408 | add eax, ecx |
5393 | 5409 | ||
5394 | mov ecx, [ebp] |
5410 | mov ecx, [ebp] |
5395 | rol ecx, 8 |
5411 | rol ecx, 8 |
5396 | test cl, cl ; transparensy = 0 |
5412 | test cl, cl ; transparensy = 0 |
5397 | jz .no_put |
5413 | jz .no_put |
5398 | 5414 | ||
5399 | xor cl, cl |
5415 | xor cl, cl |
5400 | ror ecx, 8 |
5416 | ror ecx, 8 |
5401 | 5417 | ||
5402 | pushad |
5418 | pushad |
5403 | mov edx, [d_width_calc_area + ebx*4] |
5419 | mov edx, [d_width_calc_area + ebx*4] |
5404 | add edx, [_display.win_map] |
5420 | add edx, [_display.win_map] |
5405 | movzx edx, byte [eax+edx] |
5421 | movzx edx, byte [eax+edx] |
5406 | cmp dl, byte 1 |
5422 | cmp dl, byte 1 |
5407 | jne @f |
5423 | jne @f |
5408 | 5424 | ||
5409 | call dword [PUTPIXEL]; eax - x, ebx - y |
5425 | call dword [PUTPIXEL]; eax - x, ebx - y |
5410 | ;-------------------------------------- |
5426 | ;-------------------------------------- |
5411 | align 4 |
5427 | align 4 |
5412 | @@: |
5428 | @@: |
5413 | popad |
5429 | popad |
5414 | ;-------------------------------------- |
5430 | ;-------------------------------------- |
5415 | align 4 |
5431 | align 4 |
5416 | .no_put: |
5432 | .no_put: |
5417 | pop ecx eax |
5433 | pop ecx eax |
5418 | 5434 | ||
5419 | sub ebp, 4 |
5435 | sub ebp, 4 |
5420 | dec ecx |
5436 | dec ecx |
5421 | jnz .start_x |
5437 | jnz .start_x |
5422 | 5438 | ||
5423 | pop edx ecx |
5439 | pop edx ecx |
5424 | dec ebx |
5440 | dec ebx |
5425 | dec edx |
5441 | dec edx |
5426 | jnz .start_y |
5442 | jnz .start_y |
5427 | 5443 | ||
5428 | popad |
5444 | popad |
5429 | ret |
5445 | ret |
5430 | ;----------------------------------------------------------------------------- |
5446 | ;----------------------------------------------------------------------------- |
5431 | align 4 |
5447 | align 4 |
5432 | syscall_drawline: ; DrawLine |
5448 | syscall_drawline: ; DrawLine |
5433 | 5449 | ||
5434 | mov edi, [TASK_BASE] |
5450 | mov edi, [TASK_BASE] |
5435 | movzx eax, word[edi-twdw+WDATA.box.left] |
5451 | movzx eax, word[edi-twdw+WDATA.box.left] |
5436 | mov ebp, eax |
5452 | mov ebp, eax |
5437 | mov esi, [current_slot] |
5453 | mov esi, [current_slot] |
5438 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5454 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5439 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5455 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5440 | add ebp, ebx |
5456 | add ebp, ebx |
5441 | shl eax, 16 |
5457 | shl eax, 16 |
5442 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5458 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5443 | add eax, ebp |
5459 | add eax, ebp |
5444 | mov ebp, ebx |
5460 | mov ebp, ebx |
5445 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5461 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5446 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5462 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5447 | add ebp, ecx |
5463 | add ebp, ecx |
5448 | shl ebx, 16 |
5464 | shl ebx, 16 |
5449 | xor edi, edi |
5465 | xor edi, edi |
5450 | add ebx, ebp |
5466 | add ebx, ebp |
5451 | mov ecx, edx |
5467 | mov ecx, edx |
5452 | ; jmp [draw_line] |
5468 | ; jmp [draw_line] |
5453 | jmp __sys_draw_line |
5469 | jmp __sys_draw_line |
5454 | 5470 | ||
5455 | 5471 | ||
5456 | align 4 |
5472 | align 4 |
5457 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5473 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5458 | 5474 | ||
5459 | call r_f_port_area |
5475 | call r_f_port_area |
5460 | mov [esp+32], eax |
5476 | mov [esp+32], eax |
5461 | ret |
5477 | ret |
5462 | 5478 | ||
5463 | align 4 |
5479 | align 4 |
5464 | syscall_threads: ; CreateThreads |
5480 | syscall_threads: ; CreateThreads |
5465 | ; |
5481 | ; |
5466 | ; ecx=thread entry point |
5482 | ; ecx=thread entry point |
5467 | ; edx=thread stack pointer |
5483 | ; edx=thread stack pointer |
5468 | ; |
5484 | ; |
5469 | ; on return : eax = pid |
5485 | ; on return : eax = pid |
5470 | 5486 | ||
5471 | xor ebx, ebx |
5487 | xor ebx, ebx |
5472 | call new_sys_threads |
5488 | call new_sys_threads |
5473 | 5489 | ||
5474 | mov [esp+32], eax |
5490 | mov [esp+32], eax |
5475 | ret |
5491 | ret |
5476 | 5492 | ||
5477 | align 4 |
5493 | align 4 |
5478 | 5494 | ||
5479 | paleholder: |
5495 | paleholder: |
5480 | ret |
5496 | ret |
5481 | ;------------------------------------------------------------------------------ |
5497 | ;------------------------------------------------------------------------------ |
5482 | align 4 |
5498 | align 4 |
5483 | calculate_fast_getting_offset_for_WinMapAddress: |
5499 | calculate_fast_getting_offset_for_WinMapAddress: |
5484 | ; calculate data area for fast getting offset to _WinMapAddress |
5500 | ; calculate data area for fast getting offset to _WinMapAddress |
5485 | xor eax, eax |
5501 | xor eax, eax |
5486 | mov ecx, [_display.height] |
5502 | mov ecx, [_display.height] |
5487 | mov edi, d_width_calc_area |
5503 | mov edi, d_width_calc_area |
5488 | cld |
5504 | cld |
5489 | @@: |
5505 | @@: |
5490 | stosd |
5506 | stosd |
5491 | add eax, [_display.width] |
5507 | add eax, [_display.width] |
5492 | dec ecx |
5508 | dec ecx |
5493 | jnz @r |
5509 | jnz @r |
5494 | ret |
5510 | ret |
5495 | ;------------------------------------------------------------------------------ |
5511 | ;------------------------------------------------------------------------------ |
5496 | align 4 |
5512 | align 4 |
5497 | calculate_fast_getting_offset_for_LFB: |
5513 | calculate_fast_getting_offset_for_LFB: |
5498 | ; calculate data area for fast getting offset to LFB |
5514 | ; calculate data area for fast getting offset to LFB |
5499 | xor eax, eax |
5515 | xor eax, eax |
5500 | mov ecx, [_display.height] |
5516 | mov ecx, [_display.height] |
5501 | mov edi, BPSLine_calc_area |
5517 | mov edi, BPSLine_calc_area |
5502 | cld |
5518 | cld |
5503 | @@: |
5519 | @@: |
5504 | stosd |
5520 | stosd |
5505 | add eax, [_display.lfb_pitch] |
5521 | add eax, [_display.lfb_pitch] |
5506 | dec ecx |
5522 | dec ecx |
5507 | jnz @r |
5523 | jnz @r |
5508 | ret |
5524 | ret |
5509 | ;------------------------------------------------------------------------------ |
5525 | ;------------------------------------------------------------------------------ |
5510 | align 4 |
5526 | align 4 |
5511 | set_screen: |
5527 | set_screen: |
5512 | ; in: |
5528 | ; in: |
5513 | ; eax - new Screen_Max_X |
5529 | ; eax - new Screen_Max_X |
5514 | ; ecx - new BytesPerScanLine |
5530 | ; ecx - new BytesPerScanLine |
5515 | ; edx - new Screen_Max_Y |
5531 | ; edx - new Screen_Max_Y |
5516 | 5532 | ||
5517 | pushfd |
5533 | pushfd |
5518 | cli |
5534 | cli |
5519 | 5535 | ||
5520 | mov [_display.lfb_pitch], ecx |
5536 | mov [_display.lfb_pitch], ecx |
5521 | 5537 | ||
5522 | mov [screen_workarea.right], eax |
5538 | mov [screen_workarea.right], eax |
5523 | mov [screen_workarea.bottom], edx |
5539 | mov [screen_workarea.bottom], edx |
5524 | 5540 | ||
5525 | push ebx |
5541 | push ebx |
5526 | push esi |
5542 | push esi |
5527 | push edi |
5543 | push edi |
5528 | 5544 | ||
5529 | pushad |
5545 | pushad |
5530 | 5546 | ||
5531 | cmp [do_not_touch_winmap], 1 |
5547 | cmp [do_not_touch_winmap], 1 |
5532 | je @f |
5548 | je @f |
5533 | 5549 | ||
5534 | stdcall kernel_free, [_display.win_map] |
5550 | stdcall kernel_free, [_display.win_map] |
5535 | 5551 | ||
5536 | mov eax, [_display.width] |
5552 | mov eax, [_display.width] |
5537 | mul [_display.height] |
5553 | mul [_display.height] |
5538 | mov [_display.win_map_size], eax |
5554 | mov [_display.win_map_size], eax |
5539 | 5555 | ||
5540 | stdcall kernel_alloc, eax |
5556 | stdcall kernel_alloc, eax |
5541 | mov [_display.win_map], eax |
5557 | mov [_display.win_map], eax |
5542 | test eax, eax |
5558 | test eax, eax |
5543 | jz .epic_fail |
5559 | jz .epic_fail |
5544 | ; store for f.18.24 |
5560 | ; store for f.18.24 |
5545 | mov eax, [_display.width] |
5561 | mov eax, [_display.width] |
5546 | mov [display_width_standard], eax |
5562 | mov [display_width_standard], eax |
5547 | 5563 | ||
5548 | mov eax, [_display.height] |
5564 | mov eax, [_display.height] |
5549 | mov [display_height_standard], eax |
5565 | mov [display_height_standard], eax |
5550 | @@: |
5566 | @@: |
5551 | call calculate_fast_getting_offset_for_WinMapAddress |
5567 | call calculate_fast_getting_offset_for_WinMapAddress |
5552 | ; for Qemu or non standart video cards |
5568 | ; for Qemu or non standart video cards |
5553 | ; Unfortunately [BytesPerScanLine] does not always |
5569 | ; Unfortunately [BytesPerScanLine] does not always |
5554 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5570 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5555 | call calculate_fast_getting_offset_for_LFB |
5571 | call calculate_fast_getting_offset_for_LFB |
5556 | popad |
5572 | popad |
5557 | 5573 | ||
5558 | call repos_windows |
5574 | call repos_windows |
5559 | xor eax, eax |
5575 | xor eax, eax |
5560 | xor ebx, ebx |
5576 | xor ebx, ebx |
5561 | mov ecx, [_display.width] |
5577 | mov ecx, [_display.width] |
5562 | mov edx, [_display.height] |
5578 | mov edx, [_display.height] |
5563 | dec ecx |
5579 | dec ecx |
5564 | dec edx |
5580 | dec edx |
5565 | call calculatescreen |
5581 | call calculatescreen |
5566 | pop edi |
5582 | pop edi |
5567 | pop esi |
5583 | pop esi |
5568 | pop ebx |
5584 | pop ebx |
5569 | 5585 | ||
5570 | popfd |
5586 | popfd |
5571 | ret |
5587 | ret |
5572 | 5588 | ||
5573 | .epic_fail: |
5589 | .epic_fail: |
5574 | hlt ; Houston, we've had a problem |
5590 | hlt ; Houston, we've had a problem |
5575 | 5591 | ||
5576 | ; --------------- APM --------------------- |
5592 | ; --------------- APM --------------------- |
5577 | uglobal |
5593 | uglobal |
5578 | apm_entry dp 0 |
5594 | apm_entry dp 0 |
5579 | apm_vf dd 0 |
5595 | apm_vf dd 0 |
5580 | endg |
5596 | endg |
5581 | 5597 | ||
5582 | align 4 |
5598 | align 4 |
5583 | sys_apm: |
5599 | sys_apm: |
5584 | xor eax, eax |
5600 | xor eax, eax |
5585 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5601 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5586 | jne @f |
5602 | jne @f |
5587 | inc eax |
5603 | inc eax |
5588 | or dword [esp + 44], eax ; error |
5604 | or dword [esp + 44], eax ; error |
5589 | add eax, 7 |
5605 | add eax, 7 |
5590 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5606 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5591 | ret |
5607 | ret |
5592 | 5608 | ||
5593 | @@: |
5609 | @@: |
5594 | ; xchg eax, ecx |
5610 | ; xchg eax, ecx |
5595 | ; xchg ebx, ecx |
5611 | ; xchg ebx, ecx |
5596 | 5612 | ||
5597 | cmp dx, 3 |
5613 | cmp dx, 3 |
5598 | ja @f |
5614 | ja @f |
5599 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5615 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5600 | mov eax, [apm_vf] |
5616 | mov eax, [apm_vf] |
5601 | mov [esp + 32], eax |
5617 | mov [esp + 32], eax |
5602 | shr eax, 16 |
5618 | shr eax, 16 |
5603 | mov [esp + 28], eax |
5619 | mov [esp + 28], eax |
5604 | ret |
5620 | ret |
5605 | 5621 | ||
5606 | @@: |
5622 | @@: |
5607 | 5623 | ||
5608 | mov esi, [master_tab+(OS_BASE shr 20)] |
5624 | mov esi, [master_tab+(OS_BASE shr 20)] |
5609 | xchg [master_tab], esi |
5625 | xchg [master_tab], esi |
5610 | push esi |
5626 | push esi |
5611 | mov edi, cr3 |
5627 | mov edi, cr3 |
5612 | mov cr3, edi ;flush TLB |
5628 | mov cr3, edi ;flush TLB |
5613 | 5629 | ||
5614 | call pword [apm_entry] ;call APM BIOS |
5630 | call pword [apm_entry] ;call APM BIOS |
5615 | 5631 | ||
5616 | xchg eax, [esp] |
5632 | xchg eax, [esp] |
5617 | mov [master_tab], eax |
5633 | mov [master_tab], eax |
5618 | mov eax, cr3 |
5634 | mov eax, cr3 |
5619 | mov cr3, eax |
5635 | mov cr3, eax |
5620 | pop eax |
5636 | pop eax |
5621 | 5637 | ||
5622 | mov [esp + 4 ], edi |
5638 | mov [esp + 4 ], edi |
5623 | mov [esp + 8], esi |
5639 | mov [esp + 8], esi |
5624 | mov [esp + 20], ebx |
5640 | mov [esp + 20], ebx |
5625 | mov [esp + 24], edx |
5641 | mov [esp + 24], edx |
5626 | mov [esp + 28], ecx |
5642 | mov [esp + 28], ecx |
5627 | mov [esp + 32], eax |
5643 | mov [esp + 32], eax |
5628 | setc al |
5644 | setc al |
5629 | and [esp + 44], byte 0xfe |
5645 | and [esp + 44], byte 0xfe |
5630 | or [esp + 44], al |
5646 | or [esp + 44], al |
5631 | ret |
5647 | ret |
5632 | ; ----------------------------------------- |
5648 | ; ----------------------------------------- |
5633 | 5649 | ||
5634 | align 4 |
5650 | align 4 |
5635 | 5651 | ||
5636 | undefined_syscall: ; Undefined system call |
5652 | undefined_syscall: ; Undefined system call |
5637 | mov [esp + 32], dword -1 |
5653 | mov [esp + 32], dword -1 |
5638 | ret |
5654 | ret |
5639 | 5655 | ||
5640 | 5656 | ||
5641 | if ~ lang eq sp |
5657 | if ~ lang eq sp |
5642 | diff16 "end of .text segment",0,$ |
5658 | diff16 "end of .text segment",0,$ |
5643 | end if |
5659 | end if |
5644 | 5660 | ||
5645 | include "data32.inc" |
5661 | include "data32.inc" |
5646 | 5662 | ||
5647 | __REV__ = __REV |
5663 | __REV__ = __REV |
5648 | 5664 | ||
5649 | if ~ lang eq sp |
5665 | if ~ lang eq sp |
5650 | diff16 "end of kernel code",0,$ |
5666 | diff16 "end of kernel code",0,$ |
5651 | end if=> |
5667 | end if=> |