Rev 3762 | Rev 3774 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3762 | Rev 3771 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2013. 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: 3762 $ |
74 | $Revision: 3771 $ |
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 | ; The following constant, if nonzero, duplicates debug output to the screen. |
82 | ; The following constant, if nonzero, duplicates debug output to the screen. |
83 | debug_direct_print equ 0 |
83 | debug_direct_print equ 0 |
84 | 84 | ||
85 | include "proc32.inc" |
85 | include "proc32.inc" |
86 | include "kglobals.inc" |
86 | include "kglobals.inc" |
87 | include "lang.inc" |
87 | include "lang.inc" |
88 | include "encoding.inc" |
88 | include "encoding.inc" |
89 | 89 | ||
90 | include "const.inc" |
90 | include "const.inc" |
91 | max_processes equ 255 |
91 | max_processes equ 255 |
92 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
92 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
93 | 93 | ||
94 | 94 | ||
95 | os_stack equ (os_data_l-gdts) ; GDTs |
95 | os_stack equ (os_data_l-gdts) ; GDTs |
96 | os_code equ (os_code_l-gdts) |
96 | os_code equ (os_code_l-gdts) |
97 | graph_data equ (3+graph_data_l-gdts) |
97 | graph_data equ (3+graph_data_l-gdts) |
98 | tss0 equ (tss0_l-gdts) |
98 | tss0 equ (tss0_l-gdts) |
99 | app_code equ (3+app_code_l-gdts) |
99 | app_code equ (3+app_code_l-gdts) |
100 | app_data equ (3+app_data_l-gdts) |
100 | app_data equ (3+app_data_l-gdts) |
101 | app_tls equ (3+tls_data_l-gdts) |
101 | app_tls equ (3+tls_data_l-gdts) |
102 | pci_code_sel equ (pci_code_32-gdts) |
102 | pci_code_sel equ (pci_code_32-gdts) |
103 | pci_data_sel equ (pci_data_32-gdts) |
103 | pci_data_sel equ (pci_data_32-gdts) |
104 | 104 | ||
105 | 105 | ||
106 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
106 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
107 | ;; |
107 | ;; |
108 | ;; Included files: |
108 | ;; Included files: |
109 | ;; |
109 | ;; |
110 | ;; Kernel16.inc |
110 | ;; Kernel16.inc |
111 | ;; - Booteng.inc English text for bootup |
111 | ;; - Booteng.inc English text for bootup |
112 | ;; - Bootcode.inc Hardware setup |
112 | ;; - Bootcode.inc Hardware setup |
113 | ;; - Pci16.inc PCI functions |
113 | ;; - Pci16.inc PCI functions |
114 | ;; |
114 | ;; |
115 | ;; Kernel32.inc |
115 | ;; Kernel32.inc |
116 | ;; - Sys32.inc Process management |
116 | ;; - Sys32.inc Process management |
117 | ;; - Shutdown.inc Shutdown and restart |
117 | ;; - Shutdown.inc Shutdown and restart |
118 | ;; - Fat32.inc Read / write hd |
118 | ;; - Fat32.inc Read / write hd |
119 | ;; - Vesa12.inc Vesa 1.2 driver |
119 | ;; - Vesa12.inc Vesa 1.2 driver |
120 | ;; - Vesa20.inc Vesa 2.0 driver |
120 | ;; - Vesa20.inc Vesa 2.0 driver |
121 | ;; - Vga.inc VGA driver |
121 | ;; - Vga.inc VGA driver |
122 | ;; - Stack.inc Network interface |
122 | ;; - Stack.inc Network interface |
123 | ;; - Mouse.inc Mouse pointer |
123 | ;; - Mouse.inc Mouse pointer |
124 | ;; - Scincode.inc Window skinning |
124 | ;; - Scincode.inc Window skinning |
125 | ;; - Pci32.inc PCI functions |
125 | ;; - Pci32.inc PCI functions |
126 | ;; |
126 | ;; |
127 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
127 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
128 | 128 | ||
129 | 129 | ||
130 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
130 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
131 | ;; ;; |
131 | ;; ;; |
132 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
132 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
133 | ;; ;; |
133 | ;; ;; |
134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
135 | 135 | ||
136 | use16 |
136 | use16 |
137 | org 0x0 |
137 | org 0x0 |
138 | jmp start_of_code |
138 | jmp start_of_code |
139 | 139 | ||
140 | if lang eq sp |
140 | if lang eq sp |
141 | include "kernelsp.inc" ; spanish kernel messages |
141 | include "kernelsp.inc" ; spanish kernel messages |
142 | else |
142 | else |
143 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
143 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
144 | end if |
144 | end if |
145 | 145 | ||
146 | include "boot/bootstr.inc" ; language-independent boot messages |
146 | include "boot/bootstr.inc" ; language-independent boot messages |
147 | include "boot/preboot.inc" |
147 | include "boot/preboot.inc" |
148 | 148 | ||
149 | if lang eq ge |
149 | if lang eq ge |
150 | include "boot/bootge.inc" ; german system boot messages |
150 | include "boot/bootge.inc" ; german system boot messages |
151 | else if lang eq sp |
151 | else if lang eq sp |
152 | include "boot/bootsp.inc" ; spanish system boot messages |
152 | include "boot/bootsp.inc" ; spanish system boot messages |
153 | else if lang eq ru |
153 | else if lang eq ru |
154 | include "boot/bootru.inc" ; russian system boot messages |
154 | include "boot/bootru.inc" ; russian system boot messages |
155 | include "boot/ru.inc" ; Russian font |
155 | include "boot/ru.inc" ; Russian font |
156 | else if lang eq et |
156 | else if lang eq et |
157 | include "boot/bootet.inc" ; estonian system boot messages |
157 | include "boot/bootet.inc" ; estonian system boot messages |
158 | include "boot/et.inc" ; Estonian font |
158 | include "boot/et.inc" ; Estonian font |
159 | else |
159 | else |
160 | include "boot/booten.inc" ; english system boot messages |
160 | include "boot/booten.inc" ; english system boot messages |
161 | end if |
161 | end if |
162 | 162 | ||
163 | include "boot/bootcode.inc" ; 16 bit system boot code |
163 | include "boot/bootcode.inc" ; 16 bit system boot code |
164 | include "bus/pci/pci16.inc" |
164 | include "bus/pci/pci16.inc" |
165 | include "detect/biosdisk.inc" |
165 | include "detect/biosdisk.inc" |
166 | 166 | ||
167 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
167 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
168 | ;; ;; |
168 | ;; ;; |
169 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
169 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
170 | ;; ;; |
170 | ;; ;; |
171 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
171 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
172 | 172 | ||
173 | 173 | ||
174 | ; CR0 Flags - Protected mode and Paging |
174 | ; CR0 Flags - Protected mode and Paging |
175 | 175 | ||
176 | mov ecx, CR0_PE |
176 | mov ecx, CR0_PE |
177 | 177 | ||
178 | ; Enabling 32 bit protected mode |
178 | ; Enabling 32 bit protected mode |
179 | 179 | ||
180 | sidt [cs:old_ints_h] |
180 | sidt [cs:old_ints_h] |
181 | 181 | ||
182 | cli ; disable all irqs |
182 | cli ; disable all irqs |
183 | cld |
183 | cld |
184 | mov al, 255 ; mask all irqs |
184 | mov al, 255 ; mask all irqs |
185 | out 0xa1, al |
185 | out 0xa1, al |
186 | out 0x21, al |
186 | out 0x21, al |
187 | l.5: |
187 | l.5: |
188 | in al, 0x64 ; Enable A20 |
188 | in al, 0x64 ; Enable A20 |
189 | test al, 2 |
189 | test al, 2 |
190 | jnz l.5 |
190 | jnz l.5 |
191 | mov al, 0xD1 |
191 | mov al, 0xD1 |
192 | out 0x64, al |
192 | out 0x64, al |
193 | l.6: |
193 | l.6: |
194 | in al, 0x64 |
194 | in al, 0x64 |
195 | test al, 2 |
195 | test al, 2 |
196 | jnz l.6 |
196 | jnz l.6 |
197 | mov al, 0xDF |
197 | mov al, 0xDF |
198 | out 0x60, al |
198 | out 0x60, al |
199 | l.7: |
199 | l.7: |
200 | in al, 0x64 |
200 | in al, 0x64 |
201 | test al, 2 |
201 | test al, 2 |
202 | jnz l.7 |
202 | jnz l.7 |
203 | mov al, 0xFF |
203 | mov al, 0xFF |
204 | out 0x64, al |
204 | out 0x64, al |
205 | 205 | ||
206 | lgdt [cs:tmp_gdt] ; Load GDT |
206 | lgdt [cs:tmp_gdt] ; Load GDT |
207 | mov eax, cr0 ; protected mode |
207 | mov eax, cr0 ; protected mode |
208 | or eax, ecx |
208 | or eax, ecx |
209 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
209 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
210 | mov cr0, eax |
210 | mov cr0, eax |
211 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
211 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
212 | 212 | ||
213 | align 8 |
213 | align 8 |
214 | tmp_gdt: |
214 | tmp_gdt: |
215 | 215 | ||
216 | dw 23 |
216 | dw 23 |
217 | dd tmp_gdt+0x10000 |
217 | dd tmp_gdt+0x10000 |
218 | dw 0 |
218 | dw 0 |
219 | 219 | ||
220 | dw 0xffff |
220 | dw 0xffff |
221 | dw 0x0000 |
221 | dw 0x0000 |
222 | db 0x00 |
222 | db 0x00 |
223 | dw 11011111b *256 +10011010b |
223 | dw 11011111b *256 +10011010b |
224 | db 0x00 |
224 | db 0x00 |
225 | 225 | ||
226 | dw 0xffff |
226 | dw 0xffff |
227 | dw 0x0000 |
227 | dw 0x0000 |
228 | db 0x00 |
228 | db 0x00 |
229 | dw 11011111b *256 +10010010b |
229 | dw 11011111b *256 +10010010b |
230 | db 0x00 |
230 | db 0x00 |
231 | 231 | ||
232 | include "data16.inc" |
232 | include "data16.inc" |
233 | 233 | ||
234 | if ~ lang eq sp |
234 | if ~ lang eq sp |
235 | diff16 "end of bootcode",0,$+0x10000 |
235 | diff16 "end of bootcode",0,$+0x10000 |
236 | end if |
236 | end if |
237 | 237 | ||
238 | use32 |
238 | use32 |
239 | org $+0x10000 |
239 | org $+0x10000 |
240 | 240 | ||
241 | align 4 |
241 | align 4 |
242 | B32: |
242 | B32: |
243 | mov ax, os_stack ; Selector for os |
243 | mov ax, os_stack ; Selector for os |
244 | mov ds, ax |
244 | mov ds, ax |
245 | mov es, ax |
245 | mov es, ax |
246 | mov fs, ax |
246 | mov fs, ax |
247 | mov gs, ax |
247 | mov gs, ax |
248 | mov ss, ax |
248 | mov ss, ax |
249 | mov esp, 0x006CC00 ; Set stack |
249 | mov esp, 0x006CC00 ; Set stack |
250 | 250 | ||
251 | ; CLEAR 0x280000 - HEAP_BASE |
251 | ; CLEAR 0x280000 - HEAP_BASE |
252 | 252 | ||
253 | xor eax, eax |
253 | xor eax, eax |
254 | mov edi, CLEAN_ZONE |
254 | mov edi, CLEAN_ZONE |
255 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
255 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
256 | cld |
256 | cld |
257 | rep stosd |
257 | rep stosd |
258 | 258 | ||
259 | ; CLEAR KERNEL UNDEFINED GLOBALS |
259 | ; CLEAR KERNEL UNDEFINED GLOBALS |
260 | mov edi, endofcode-OS_BASE |
260 | mov edi, endofcode-OS_BASE |
261 | mov ecx, 0x90000 |
261 | mov ecx, 0x90000 |
262 | sub ecx, edi |
262 | sub ecx, edi |
263 | shr ecx, 2 |
263 | shr ecx, 2 |
264 | rep stosd |
264 | rep stosd |
265 | 265 | ||
266 | ; SAVE & CLEAR 0-0xffff |
266 | ; SAVE & CLEAR 0-0xffff |
267 | 267 | ||
268 | mov edi, 0x1000 |
268 | mov edi, 0x1000 |
269 | mov ecx, 0x8000 / 4 |
269 | mov ecx, 0x8000 / 4 |
270 | rep stosd |
270 | rep stosd |
271 | mov edi, 0xa000 |
271 | mov edi, 0xa000 |
272 | mov ecx, 0x6000 / 4 |
272 | mov ecx, 0x6000 / 4 |
273 | rep stosd |
273 | rep stosd |
274 | 274 | ||
275 | call test_cpu |
275 | call test_cpu |
276 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
276 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
277 | 277 | ||
278 | call check_acpi |
278 | call check_acpi |
279 | call init_BIOS32 |
279 | call init_BIOS32 |
280 | ; MEMORY MODEL |
280 | ; MEMORY MODEL |
281 | call mem_test |
281 | call mem_test |
282 | call init_mem |
282 | call init_mem |
283 | call init_page_map |
283 | call init_page_map |
284 | 284 | ||
285 | ; ENABLE PAGING |
285 | ; ENABLE PAGING |
286 | 286 | ||
287 | mov eax, sys_pgdir-OS_BASE |
287 | mov eax, sys_pgdir-OS_BASE |
288 | mov cr3, eax |
288 | mov cr3, eax |
289 | 289 | ||
290 | mov eax, cr0 |
290 | mov eax, cr0 |
291 | or eax, CR0_PG+CR0_WP |
291 | or eax, CR0_PG+CR0_WP |
292 | mov cr0, eax |
292 | mov cr0, eax |
293 | 293 | ||
294 | lgdt [gdts] |
294 | lgdt [gdts] |
295 | jmp pword os_code:high_code |
295 | jmp pword os_code:high_code |
296 | 296 | ||
297 | align 4 |
297 | align 4 |
298 | bios32_entry dd ? |
298 | bios32_entry dd ? |
299 | tmp_page_tabs dd ? |
299 | tmp_page_tabs dd ? |
300 | 300 | ||
301 | use16 |
301 | use16 |
302 | org $-0x10000 |
302 | org $-0x10000 |
303 | include "boot/shutdown.inc" ; shutdown or restart |
303 | include "boot/shutdown.inc" ; shutdown or restart |
304 | org $+0x10000 |
304 | org $+0x10000 |
305 | use32 |
305 | use32 |
306 | 306 | ||
307 | __DEBUG__ fix 1 |
307 | __DEBUG__ fix 1 |
308 | __DEBUG_LEVEL__ fix 1 |
308 | __DEBUG_LEVEL__ fix 1 |
309 | include 'init.inc' |
309 | include 'init.inc' |
310 | 310 | ||
311 | org OS_BASE+$ |
311 | org OS_BASE+$ |
312 | 312 | ||
313 | include 'fdo.inc' |
313 | include 'fdo.inc' |
314 | 314 | ||
315 | align 4 |
315 | align 4 |
316 | high_code: |
316 | high_code: |
317 | mov ax, os_stack |
317 | mov ax, os_stack |
318 | mov bx, app_data |
318 | mov bx, app_data |
319 | mov cx, app_tls |
319 | mov cx, app_tls |
320 | mov ss, ax |
320 | mov ss, ax |
321 | add esp, OS_BASE |
321 | add esp, OS_BASE |
322 | 322 | ||
323 | mov ds, bx |
323 | mov ds, bx |
324 | mov es, bx |
324 | mov es, bx |
325 | mov fs, cx |
325 | mov fs, cx |
326 | mov gs, bx |
326 | mov gs, bx |
327 | 327 | ||
328 | bt [cpu_caps], CAPS_PGE |
328 | bt [cpu_caps], CAPS_PGE |
329 | jnc @F |
329 | jnc @F |
330 | 330 | ||
331 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
331 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
332 | 332 | ||
333 | mov ebx, cr4 |
333 | mov ebx, cr4 |
334 | or ebx, CR4_PGE |
334 | or ebx, CR4_PGE |
335 | mov cr4, ebx |
335 | mov cr4, ebx |
336 | @@: |
336 | @@: |
337 | xor eax, eax |
337 | xor eax, eax |
338 | mov dword [sys_pgdir], eax |
338 | mov dword [sys_pgdir], eax |
339 | mov dword [sys_pgdir+4], eax |
339 | mov dword [sys_pgdir+4], eax |
340 | 340 | ||
341 | mov eax, cr3 |
341 | mov eax, cr3 |
342 | mov cr3, eax ; flush TLB |
342 | mov cr3, eax ; flush TLB |
343 | 343 | ||
344 | mov ecx, pg_data.mutex |
344 | mov ecx, pg_data.mutex |
345 | call mutex_init |
345 | call mutex_init |
346 | 346 | ||
347 | mov ecx, disk_list_mutex |
347 | mov ecx, disk_list_mutex |
348 | call mutex_init |
348 | call mutex_init |
349 | 349 | ||
350 | mov ecx, keyboard_list_mutex |
350 | mov ecx, keyboard_list_mutex |
351 | call mutex_init |
351 | call mutex_init |
352 | 352 | ||
353 | mov ecx, unpack_mutex |
353 | mov ecx, unpack_mutex |
354 | call mutex_init |
354 | call mutex_init |
355 | 355 | ||
356 | mov ecx, application_table_mutex |
356 | mov ecx, application_table_mutex |
357 | call mutex_init |
357 | call mutex_init |
358 | 358 | ||
359 | mov ecx, ide_mutex |
359 | mov ecx, ide_mutex |
360 | call mutex_init |
360 | call mutex_init |
361 | mov ecx, ide_channel1_mutex |
361 | mov ecx, ide_channel1_mutex |
362 | call mutex_init |
362 | call mutex_init |
363 | mov ecx, ide_channel2_mutex |
363 | mov ecx, ide_channel2_mutex |
364 | call mutex_init |
364 | call mutex_init |
365 | 365 | ||
366 | ; SAVE REAL MODE VARIABLES |
366 | ; SAVE REAL MODE VARIABLES |
367 | xor eax, eax |
367 | xor eax, eax |
368 | mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16] |
368 | mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16] |
369 | mov [IDE_Interrupt], ax |
369 | mov [IDE_Interrupt], ax |
370 | mov ax, [BOOT_VARS + BOOT_IDE_PI_16] |
370 | mov ax, [BOOT_VARS + BOOT_IDE_PI_16] |
371 | mov [IDEContrProgrammingInterface], ax |
371 | mov [IDEContrProgrammingInterface], ax |
372 | mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR] |
372 | mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR] |
373 | mov [IDEContrRegsBaseAddr], ax |
373 | mov [IDEContrRegsBaseAddr], ax |
374 | mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16] |
374 | mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16] |
375 | mov [IDE_BAR0_val], ax |
375 | mov [IDE_BAR0_val], ax |
376 | 376 | ||
377 | cmp ax, 0 |
377 | cmp ax, 0 |
378 | je @f |
378 | je @f |
379 | cmp ax, 1 |
379 | cmp ax, 1 |
380 | je @f |
380 | je @f |
381 | and ax, 0xfff0 |
381 | and ax, 0xfff0 |
382 | mov [StandardATABases], ax |
382 | mov [StandardATABases], ax |
383 | mov [hd_address_table], eax |
383 | mov [hd_address_table], eax |
384 | mov [hd_address_table+8], eax |
384 | mov [hd_address_table+8], eax |
385 | @@: |
385 | @@: |
386 | mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16] |
386 | mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16] |
387 | mov [IDE_BAR1_val], ax |
387 | mov [IDE_BAR1_val], ax |
388 | mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16] |
388 | mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16] |
389 | mov [IDE_BAR2_val], ax |
389 | mov [IDE_BAR2_val], ax |
390 | 390 | ||
391 | cmp ax, 0 |
391 | cmp ax, 0 |
392 | je @f |
392 | je @f |
393 | cmp ax, 1 |
393 | cmp ax, 1 |
394 | je @f |
394 | je @f |
395 | and ax, 0xfff0 |
395 | and ax, 0xfff0 |
396 | mov [StandardATABases+2], ax |
396 | mov [StandardATABases+2], ax |
397 | mov [hd_address_table+16], eax |
397 | mov [hd_address_table+16], eax |
398 | mov [hd_address_table+24], eax |
398 | mov [hd_address_table+24], eax |
399 | @@: |
399 | @@: |
400 | mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16] |
400 | mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16] |
401 | mov [IDE_BAR3_val], ax |
401 | mov [IDE_BAR3_val], ax |
402 | 402 | ||
403 | ; --------------- APM --------------------- |
403 | ; --------------- APM --------------------- |
404 | 404 | ||
405 | ; init selectors |
405 | ; init selectors |
406 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
406 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
407 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
407 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
408 | ; protected-mode 32-bit code segment |
408 | ; protected-mode 32-bit code segment |
409 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
409 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
410 | ; protected-mode 16-bit code segment |
410 | ; protected-mode 16-bit code segment |
411 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
411 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
412 | ; protected-mode 16-bit data segment |
412 | ; protected-mode 16-bit data segment |
413 | 413 | ||
414 | shl eax, 4 |
414 | shl eax, 4 |
415 | mov [dword apm_code_32 + 2], ax |
415 | mov [dword apm_code_32 + 2], ax |
416 | shr eax, 16 |
416 | shr eax, 16 |
417 | mov [dword apm_code_32 + 4], al |
417 | mov [dword apm_code_32 + 4], al |
418 | 418 | ||
419 | shl ecx, 4 |
419 | shl ecx, 4 |
420 | mov [dword apm_code_16 + 2], cx |
420 | mov [dword apm_code_16 + 2], cx |
421 | shr ecx, 16 |
421 | shr ecx, 16 |
422 | mov [dword apm_code_16 + 4], cl |
422 | mov [dword apm_code_16 + 4], cl |
423 | 423 | ||
424 | shl edx, 4 |
424 | shl edx, 4 |
425 | mov [dword apm_data_16 + 2], dx |
425 | mov [dword apm_data_16 + 2], dx |
426 | shr edx, 16 |
426 | shr edx, 16 |
427 | mov [dword apm_data_16 + 4], dl |
427 | mov [dword apm_data_16 + 4], dl |
428 | 428 | ||
429 | mov dword[apm_entry], ebx |
429 | mov dword[apm_entry], ebx |
430 | mov word [apm_entry + 4], apm_code_32 - gdts |
430 | mov word [apm_entry + 4], apm_code_32 - gdts |
431 | 431 | ||
432 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
432 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
433 | mov [apm_vf], eax |
433 | mov [apm_vf], eax |
434 | ; ----------------------------------------- |
434 | ; ----------------------------------------- |
435 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
435 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
436 | mov [allow_dma_access], al |
436 | mov [allow_dma_access], al |
437 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
437 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
438 | mov [_display.bpp], eax |
438 | mov [_display.bpp], eax |
439 | mov [_display.vrefresh], 60 |
439 | mov [_display.vrefresh], 60 |
440 | 440 | ||
441 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
441 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
442 | mov [_display.width], eax |
442 | mov [_display.width], eax |
443 | mov [display_width_standard], eax |
443 | mov [display_width_standard], eax |
444 | dec eax |
444 | dec eax |
445 | mov [Screen_Max_X], eax |
445 | mov [Screen_Max_X], eax |
446 | mov [screen_workarea.right], eax |
446 | mov [screen_workarea.right], eax |
447 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
447 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
448 | mov [_display.height], eax |
448 | mov [_display.height], eax |
449 | mov [display_height_standard], eax |
449 | mov [display_height_standard], eax |
450 | dec eax |
450 | dec eax |
451 | mov [Screen_Max_Y], eax |
451 | mov [Screen_Max_Y], eax |
452 | mov [screen_workarea.bottom], eax |
452 | mov [screen_workarea.bottom], eax |
453 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
453 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
454 | mov dword [SCR_MODE], eax |
454 | mov dword [SCR_MODE], eax |
455 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
455 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
456 | ; mov [BANK_SWITCH], eax |
456 | ; mov [BANK_SWITCH], eax |
457 | mov eax, 640 *4 ; Bytes PerScanLine |
457 | mov eax, 640 *4 ; Bytes PerScanLine |
458 | cmp [SCR_MODE], word 0x13 ; 320x200 |
458 | cmp [SCR_MODE], word 0x13 ; 320x200 |
459 | je @f |
459 | je @f |
460 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
460 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
461 | je @f |
461 | je @f |
462 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
462 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
463 | @@: |
463 | @@: |
464 | mov [_display.pitch], eax |
464 | mov [_display.pitch], eax |
465 | mov eax, [_display.width] |
465 | mov eax, [_display.width] |
466 | mul [_display.height] |
466 | mul [_display.height] |
467 | mov [_WinMapSize], eax |
467 | mov [_WinMapSize], eax |
468 | 468 | ||
469 | call calculate_fast_getting_offset_for_WinMapAddress |
469 | call calculate_fast_getting_offset_for_WinMapAddress |
470 | ; for Qemu or non standart video cards |
470 | ; for Qemu or non standart video cards |
471 | ; Unfortunately [BytesPerScanLine] does not always |
471 | ; Unfortunately [BytesPerScanLine] does not always |
472 | ; equal to [_display.width] * [ScreenBPP] / 8 |
472 | ; equal to [_display.width] * [ScreenBPP] / 8 |
473 | call calculate_fast_getting_offset_for_LFB |
473 | call calculate_fast_getting_offset_for_LFB |
474 | 474 | ||
475 | mov esi, BOOT_VARS+0x9080 |
475 | mov esi, BOOT_VARS+0x9080 |
476 | movzx ecx, byte [esi-1] |
476 | movzx ecx, byte [esi-1] |
477 | mov [NumBiosDisks], ecx |
477 | mov [NumBiosDisks], ecx |
478 | mov edi, BiosDisksData |
478 | mov edi, BiosDisksData |
479 | rep movsd |
479 | rep movsd |
480 | 480 | ||
481 | ; GRAPHICS ADDRESSES |
481 | ; GRAPHICS ADDRESSES |
482 | 482 | ||
483 | mov eax, [BOOT_VARS+BOOT_LFB] |
483 | mov eax, [BOOT_VARS+BOOT_LFB] |
484 | mov [LFBAddress], eax |
484 | mov [LFBAddress], eax |
485 | 485 | ||
486 | cmp [SCR_MODE], word 0100000000000000b |
486 | cmp [SCR_MODE], word 0100000000000000b |
487 | jge setvesa20 |
487 | jge setvesa20 |
488 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
488 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
489 | je v20ga32 |
489 | je v20ga32 |
490 | jmp v20ga24 |
490 | jmp v20ga24 |
491 | 491 | ||
492 | setvesa20: |
492 | setvesa20: |
493 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
493 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
494 | mov [GETPIXEL], dword Vesa20_getpixel24 |
494 | mov [GETPIXEL], dword Vesa20_getpixel24 |
495 | cmp byte [_display.bpp], 24 |
495 | cmp byte [_display.bpp], 24 |
496 | jz v20ga24 |
496 | jz v20ga24 |
497 | v20ga32: |
497 | v20ga32: |
498 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
498 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
499 | mov [GETPIXEL], dword Vesa20_getpixel32 |
499 | mov [GETPIXEL], dword Vesa20_getpixel32 |
500 | jmp no_mode_0x12 |
500 | jmp no_mode_0x12 |
501 | v20ga24: |
501 | v20ga24: |
502 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
502 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
503 | jne no_mode_0x12 |
503 | jne no_mode_0x12 |
504 | mov [PUTPIXEL], dword VGA_putpixel |
504 | mov [PUTPIXEL], dword VGA_putpixel |
505 | mov [GETPIXEL], dword Vesa20_getpixel32 |
505 | mov [GETPIXEL], dword Vesa20_getpixel32 |
506 | no_mode_0x12: |
506 | no_mode_0x12: |
507 | 507 | ||
508 | mov [MOUSE_PICTURE], dword mousepointer |
508 | mov [MOUSE_PICTURE], dword mousepointer |
509 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
509 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
510 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
510 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
511 | 511 | ||
512 | ; -------- Fast System Call init ---------- |
512 | ; -------- Fast System Call init ---------- |
513 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
513 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
514 | bt [cpu_caps], CAPS_SEP |
514 | bt [cpu_caps], CAPS_SEP |
515 | jnc .SEnP ; SysEnter not Present |
515 | jnc .SEnP ; SysEnter not Present |
516 | xor edx, edx |
516 | xor edx, edx |
517 | mov ecx, MSR_SYSENTER_CS |
517 | mov ecx, MSR_SYSENTER_CS |
518 | mov eax, os_code |
518 | mov eax, os_code |
519 | wrmsr |
519 | wrmsr |
520 | mov ecx, MSR_SYSENTER_ESP |
520 | mov ecx, MSR_SYSENTER_ESP |
521 | ; mov eax, sysenter_stack ; Check it |
521 | ; mov eax, sysenter_stack ; Check it |
522 | xor eax, eax |
522 | xor eax, eax |
523 | wrmsr |
523 | wrmsr |
524 | mov ecx, MSR_SYSENTER_EIP |
524 | mov ecx, MSR_SYSENTER_EIP |
525 | mov eax, sysenter_entry |
525 | mov eax, sysenter_entry |
526 | wrmsr |
526 | wrmsr |
527 | .SEnP: |
527 | .SEnP: |
528 | ; AMD SYSCALL/SYSRET |
528 | ; AMD SYSCALL/SYSRET |
529 | cmp byte[cpu_vendor], 'A' |
529 | cmp byte[cpu_vendor], 'A' |
530 | jne .noSYSCALL |
530 | jne .noSYSCALL |
531 | mov eax, 0x80000001 |
531 | mov eax, 0x80000001 |
532 | cpuid |
532 | cpuid |
533 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
533 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
534 | jz .noSYSCALL |
534 | jz .noSYSCALL |
535 | mov ecx, MSR_AMD_EFER |
535 | mov ecx, MSR_AMD_EFER |
536 | rdmsr |
536 | rdmsr |
537 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
537 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
538 | wrmsr |
538 | wrmsr |
539 | 539 | ||
540 | ; !!!! It`s dirty hack, fix it !!! |
540 | ; !!!! It`s dirty hack, fix it !!! |
541 | ; Bits of EDX : |
541 | ; Bits of EDX : |
542 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
542 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
543 | ; and the contents of this field, plus 8, are copied into the SS register. |
543 | ; and the contents of this field, plus 8, are copied into the SS register. |
544 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
544 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
545 | ; and the contents of this field, plus 8, are copied into the SS register. |
545 | ; and the contents of this field, plus 8, are copied into the SS register. |
546 | 546 | ||
547 | ; mov edx, (os_code + 16) * 65536 + os_code |
547 | ; mov edx, (os_code + 16) * 65536 + os_code |
548 | mov edx, 0x1B0008 |
548 | mov edx, 0x1B0008 |
549 | 549 | ||
550 | mov eax, syscall_entry |
550 | mov eax, syscall_entry |
551 | mov ecx, MSR_AMD_STAR |
551 | mov ecx, MSR_AMD_STAR |
552 | wrmsr |
552 | wrmsr |
553 | .noSYSCALL: |
553 | .noSYSCALL: |
554 | ; ----------------------------------------- |
554 | ; ----------------------------------------- |
555 | stdcall alloc_page |
555 | stdcall alloc_page |
556 | stdcall map_page, tss-0xF80, eax, PG_SW |
556 | stdcall map_page, tss-0xF80, eax, PG_SW |
557 | stdcall alloc_page |
557 | stdcall alloc_page |
558 | stdcall map_page, tss+0x80, eax, PG_SW |
558 | stdcall map_page, tss+0x80, eax, PG_SW |
559 | stdcall alloc_page |
559 | stdcall alloc_page |
560 | stdcall map_page, tss+0x1080, eax, PG_SW |
560 | stdcall map_page, tss+0x1080, eax, PG_SW |
561 | 561 | ||
562 | ; LOAD IDT |
562 | ; LOAD IDT |
563 | 563 | ||
564 | call build_interrupt_table ;lidt is executed |
564 | call build_interrupt_table ;lidt is executed |
565 | ;lidt [idtreg] |
565 | ;lidt [idtreg] |
566 | 566 | ||
567 | call init_kernel_heap |
567 | call init_kernel_heap |
568 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
568 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
569 | mov [os_stack_seg], eax |
569 | mov [os_stack_seg], eax |
570 | 570 | ||
571 | lea esp, [eax+RING0_STACK_SIZE] |
571 | lea esp, [eax+RING0_STACK_SIZE] |
572 | 572 | ||
573 | mov [tss._ss0], os_stack |
573 | mov [tss._ss0], os_stack |
574 | mov [tss._esp0], esp |
574 | mov [tss._esp0], esp |
575 | mov [tss._esp], esp |
575 | mov [tss._esp], esp |
576 | mov [tss._cs], os_code |
576 | mov [tss._cs], os_code |
577 | mov [tss._ss], os_stack |
577 | mov [tss._ss], os_stack |
578 | mov [tss._ds], app_data |
578 | mov [tss._ds], app_data |
579 | mov [tss._es], app_data |
579 | mov [tss._es], app_data |
580 | mov [tss._fs], app_data |
580 | mov [tss._fs], app_data |
581 | mov [tss._gs], app_data |
581 | mov [tss._gs], app_data |
582 | mov [tss._io], 128 |
582 | mov [tss._io], 128 |
583 | ;Add IO access table - bit array of permitted ports |
583 | ;Add IO access table - bit array of permitted ports |
584 | mov edi, tss._io_map_0 |
584 | mov edi, tss._io_map_0 |
585 | xor eax, eax |
585 | xor eax, eax |
586 | not eax |
586 | not eax |
587 | mov ecx, 8192/4 |
587 | mov ecx, 8192/4 |
588 | rep stosd ; access to 4096*8=65536 ports |
588 | rep stosd ; access to 4096*8=65536 ports |
589 | 589 | ||
590 | mov ax, tss0 |
590 | mov ax, tss0 |
591 | ltr ax |
591 | ltr ax |
592 | 592 | ||
593 | mov [LFBSize], 0xC00000 |
593 | mov [LFBSize], 0xC00000 |
594 | call init_LFB |
594 | call init_LFB |
595 | call init_fpu |
595 | call init_fpu |
596 | call init_malloc |
596 | call init_malloc |
597 | 597 | ||
598 | stdcall alloc_kernel_space, 0x51000 |
598 | stdcall alloc_kernel_space, 0x51000 |
599 | mov [default_io_map], eax |
599 | mov [default_io_map], eax |
600 | 600 | ||
601 | add eax, 0x2000 |
601 | add eax, 0x2000 |
602 | mov [ipc_tmp], eax |
602 | mov [ipc_tmp], eax |
603 | mov ebx, 0x1000 |
603 | mov ebx, 0x1000 |
604 | 604 | ||
605 | add eax, 0x40000 |
605 | add eax, 0x40000 |
606 | mov [proc_mem_map], eax |
606 | mov [proc_mem_map], eax |
607 | 607 | ||
608 | add eax, 0x8000 |
608 | add eax, 0x8000 |
609 | mov [proc_mem_pdir], eax |
609 | mov [proc_mem_pdir], eax |
610 | 610 | ||
611 | add eax, ebx |
611 | add eax, ebx |
612 | mov [proc_mem_tab], eax |
612 | mov [proc_mem_tab], eax |
613 | 613 | ||
614 | add eax, ebx |
614 | add eax, ebx |
615 | mov [tmp_task_pdir], eax |
615 | mov [tmp_task_pdir], eax |
616 | 616 | ||
617 | add eax, ebx |
617 | add eax, ebx |
618 | mov [tmp_task_ptab], eax |
618 | mov [tmp_task_ptab], eax |
619 | 619 | ||
620 | add eax, ebx |
620 | add eax, ebx |
621 | mov [ipc_pdir], eax |
621 | mov [ipc_pdir], eax |
622 | 622 | ||
623 | add eax, ebx |
623 | add eax, ebx |
624 | mov [ipc_ptab], eax |
624 | mov [ipc_ptab], eax |
625 | 625 | ||
626 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
626 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
627 | (unpack.lc+unpack.lp)))*4 |
627 | (unpack.lc+unpack.lp)))*4 |
628 | 628 | ||
629 | mov [unpack.p], eax |
629 | mov [unpack.p], eax |
630 | 630 | ||
631 | call init_events |
631 | call init_events |
632 | mov eax, srv.fd-SRV.fd |
632 | mov eax, srv.fd-SRV.fd |
633 | mov [srv.fd], eax |
633 | mov [srv.fd], eax |
634 | mov [srv.bk], eax |
634 | mov [srv.bk], eax |
635 | 635 | ||
636 | ;Set base of graphic segment to linear address of LFB |
636 | ;Set base of graphic segment to linear address of LFB |
637 | mov eax, [LFBAddress] ; set for gs |
637 | mov eax, [LFBAddress] ; set for gs |
638 | mov [graph_data_l+2], ax |
638 | mov [graph_data_l+2], ax |
639 | shr eax, 16 |
639 | shr eax, 16 |
640 | mov [graph_data_l+4], al |
640 | mov [graph_data_l+4], al |
641 | mov [graph_data_l+7], ah |
641 | mov [graph_data_l+7], ah |
642 | 642 | ||
643 | stdcall kernel_alloc, [_WinMapSize] |
643 | stdcall kernel_alloc, [_WinMapSize] |
644 | mov [_WinMapAddress], eax |
644 | mov [_WinMapAddress], eax |
645 | 645 | ||
646 | xor eax, eax |
646 | xor eax, eax |
647 | inc eax |
647 | inc eax |
648 | 648 | ||
649 | ; set background |
649 | ; set background |
650 | 650 | ||
651 | mov [BgrDrawMode], eax |
651 | mov [BgrDrawMode], eax |
652 | mov [BgrDataWidth], eax |
652 | mov [BgrDataWidth], eax |
653 | mov [BgrDataHeight], eax |
653 | mov [BgrDataHeight], eax |
654 | mov [mem_BACKGROUND], 4 |
654 | mov [mem_BACKGROUND], 4 |
655 | mov [img_background], static_background_data |
655 | mov [img_background], static_background_data |
656 | 656 | ||
657 | ; SET UP OS TASK |
657 | ; SET UP OS TASK |
658 | 658 | ||
659 | mov esi, boot_setostask |
659 | mov esi, boot_setostask |
660 | call boot_log |
660 | call boot_log |
661 | 661 | ||
662 | mov edx, SLOT_BASE+256 |
662 | mov edx, SLOT_BASE+256 |
663 | mov ebx, [os_stack_seg] |
663 | mov ebx, [os_stack_seg] |
664 | add ebx, 0x2000 |
664 | add ebx, 0x2000 |
665 | call setup_os_slot |
665 | call setup_os_slot |
666 | mov dword [edx], 'IDLE' |
666 | mov dword [edx], 'IDLE' |
667 | sub [edx+APPDATA.saved_esp], 4 |
667 | sub [edx+APPDATA.saved_esp], 4 |
668 | mov eax, [edx+APPDATA.saved_esp] |
668 | mov eax, [edx+APPDATA.saved_esp] |
669 | mov dword [eax], idle_thread |
669 | mov dword [eax], idle_thread |
670 | mov ecx, IDLE_PRIORITY |
670 | mov ecx, IDLE_PRIORITY |
671 | call scheduler_add_thread |
671 | call scheduler_add_thread |
672 | 672 | ||
673 | mov edx, SLOT_BASE+256*2 |
673 | mov edx, SLOT_BASE+256*2 |
674 | mov ebx, [os_stack_seg] |
674 | mov ebx, [os_stack_seg] |
675 | call setup_os_slot |
675 | call setup_os_slot |
676 | mov dword [edx], 'OS' |
676 | mov dword [edx], 'OS' |
677 | xor ecx, ecx |
677 | xor ecx, ecx |
678 | call scheduler_add_thread |
678 | call scheduler_add_thread |
679 | 679 | ||
680 | mov dword [CURRENT_TASK], 2 |
680 | mov dword [CURRENT_TASK], 2 |
681 | mov dword [TASK_COUNT], 2 |
681 | mov dword [TASK_COUNT], 2 |
682 | mov dword [current_slot], SLOT_BASE + 256*2 |
682 | mov dword [current_slot], SLOT_BASE + 256*2 |
683 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
683 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
684 | 684 | ||
685 | 685 | ||
686 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
686 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
687 | mov esi, boot_initirq |
687 | mov esi, boot_initirq |
688 | call boot_log |
688 | call boot_log |
689 | call init_irqs |
689 | call init_irqs |
690 | 690 | ||
691 | mov esi, boot_picinit |
691 | mov esi, boot_picinit |
692 | call boot_log |
692 | call boot_log |
693 | call PIC_init |
693 | call PIC_init |
694 | 694 | ||
695 | mov esi, boot_v86machine |
695 | mov esi, boot_v86machine |
696 | call boot_log |
696 | call boot_log |
697 | ; Initialize system V86 machine |
697 | ; Initialize system V86 machine |
698 | call init_sys_v86 |
698 | call init_sys_v86 |
699 | 699 | ||
700 | mov esi, boot_inittimer |
700 | mov esi, boot_inittimer |
701 | call boot_log |
701 | call boot_log |
702 | ; Initialize system timer (IRQ0) |
702 | ; Initialize system timer (IRQ0) |
703 | call PIT_init |
703 | call PIT_init |
704 | 704 | ||
705 | ; CALCULATE FAT CHAIN FOR RAMDISK |
705 | ; CALCULATE FAT CHAIN FOR RAMDISK |
706 | 706 | ||
707 | call calculatefatchain |
707 | call calculatefatchain |
708 | 708 | ||
709 | mov esi, boot_initapic |
709 | mov esi, boot_initapic |
710 | call boot_log |
710 | call boot_log |
711 | ; Try to Initialize APIC |
711 | ; Try to Initialize APIC |
712 | call APIC_init |
712 | call APIC_init |
713 | 713 | ||
714 | mov esi, boot_enableirq |
714 | mov esi, boot_enableirq |
715 | call boot_log |
715 | call boot_log |
716 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
716 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
717 | ; they are used: when partitions are scanned, hd_read relies on timer |
717 | ; they are used: when partitions are scanned, hd_read relies on timer |
718 | call unmask_timer |
718 | call unmask_timer |
719 | stdcall enable_irq, 2 ; @#$%! PIC |
719 | stdcall enable_irq, 2 ; @#$%! PIC |
720 | stdcall enable_irq, 6 ; FDD |
- | |
721 | stdcall enable_irq, 13 ; co-processor |
720 | stdcall enable_irq, 13 ; co-processor |
722 | 721 | ||
723 | mov esi, boot_disabling_ide |
722 | mov esi, boot_disabling_ide |
724 | call boot_log |
723 | call boot_log |
725 | ;-------------------------------------- |
724 | ;-------------------------------------- |
726 | ; Disable IDE interrupts, because the search |
725 | ; Disable IDE interrupts, because the search |
727 | ; for IDE partitions is in the PIO mode. |
726 | ; for IDE partitions is in the PIO mode. |
728 | ;-------------------------------------- |
727 | ;-------------------------------------- |
729 | .disable_IDE_interrupt: |
728 | .disable_IDE_interrupt: |
730 | ; Disable interrupts in IDE controller for PIO |
729 | ; Disable interrupts in IDE controller for PIO |
731 | mov al, 2 |
730 | mov al, 2 |
732 | mov dx, [IDE_BAR1_val] ;0x3F6 |
731 | mov dx, [IDE_BAR1_val] ;0x3F6 |
733 | add dx, 2 |
732 | add dx, 2 |
734 | out dx, al |
733 | out dx, al |
735 | mov dx, [IDE_BAR3_val] ;0x76 |
734 | mov dx, [IDE_BAR3_val] ;0x76 |
736 | add dx, 2 |
735 | add dx, 2 |
737 | out dx, al |
736 | out dx, al |
738 | ;----------------------------------------------------------------------------- |
737 | ;----------------------------------------------------------------------------- |
739 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
738 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
740 | ; mov esi, boot_detectdisks |
739 | ; mov esi, boot_detectdisks |
741 | ; call boot_log |
740 | ; call boot_log |
742 | ;include 'detect/disks.inc' |
741 | ;include 'detect/disks.inc' |
743 | mov esi, boot_detectfloppy |
742 | mov esi, boot_detectfloppy |
744 | call boot_log |
743 | call boot_log |
745 | include 'detect/dev_fd.inc' |
744 | include 'detect/dev_fd.inc' |
746 | mov esi, boot_detecthdcd |
745 | mov esi, boot_detecthdcd |
747 | call boot_log |
746 | call boot_log |
748 | include 'detect/dev_hdcd.inc' |
747 | include 'detect/dev_hdcd.inc' |
749 | mov esi, boot_getcache |
748 | mov esi, boot_getcache |
750 | call boot_log |
749 | call boot_log |
751 | include 'detect/getcache.inc' |
750 | include 'detect/getcache.inc' |
752 | mov esi, boot_detectpart |
751 | mov esi, boot_detectpart |
753 | call boot_log |
752 | call boot_log |
754 | include 'detect/sear_par.inc' |
753 | include 'detect/sear_par.inc' |
755 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
754 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
756 | 755 | ||
757 | mov esi, boot_init_sys |
756 | mov esi, boot_init_sys |
758 | call boot_log |
757 | call boot_log |
759 | call Parser_params |
758 | call Parser_params |
760 | 759 | ||
761 | if ~ defined extended_primary_loader |
760 | if ~ defined extended_primary_loader |
762 | ; ramdisk image should be loaded by extended primary loader if it exists |
761 | ; ramdisk image should be loaded by extended primary loader if it exists |
763 | ; READ RAMDISK IMAGE FROM HD |
762 | ; READ RAMDISK IMAGE FROM HD |
764 | 763 | ||
765 | ;!!!!!!!!!!!!!!!!!!!!!!! |
764 | ;!!!!!!!!!!!!!!!!!!!!!!! |
766 | include 'boot/rdload.inc' |
765 | include 'boot/rdload.inc' |
767 | ;!!!!!!!!!!!!!!!!!!!!!!! |
766 | ;!!!!!!!!!!!!!!!!!!!!!!! |
768 | end if |
767 | end if |
769 | ; mov [dma_hdd],1 |
768 | ; mov [dma_hdd],1 |
770 | 769 | ||
771 | if 0 |
770 | if 0 |
772 | mov ax, [OS_BASE+0x10000+bx_from_load] |
771 | mov ax, [OS_BASE+0x10000+bx_from_load] |
773 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
772 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
774 | je no_lib_load |
773 | je no_lib_load |
775 | 774 | ||
776 | mov esi, boot_loadlibs |
775 | mov esi, boot_loadlibs |
777 | call boot_log |
776 | call boot_log |
778 | ; LOADING LIBRARES |
777 | ; LOADING LIBRARES |
779 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
778 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
780 | call load_file_parse_table ; prepare file parse table |
779 | call load_file_parse_table ; prepare file parse table |
781 | call set_kernel_conf ; configure devices and gui |
780 | call set_kernel_conf ; configure devices and gui |
782 | no_lib_load: |
781 | no_lib_load: |
783 | end if |
782 | end if |
784 | 783 | ||
785 | ; Display APIC status |
784 | ; Display APIC status |
786 | mov esi, boot_APIC_found |
785 | mov esi, boot_APIC_found |
787 | cmp [irq_mode], IRQ_APIC |
786 | cmp [irq_mode], IRQ_APIC |
788 | je @f |
787 | je @f |
789 | mov esi, boot_APIC_nfound |
788 | mov esi, boot_APIC_nfound |
790 | @@: |
789 | @@: |
791 | call boot_log |
790 | call boot_log |
792 | 791 | ||
793 | ; PRINT AMOUNT OF MEMORY |
792 | ; PRINT AMOUNT OF MEMORY |
794 | mov esi, boot_memdetect |
793 | mov esi, boot_memdetect |
795 | call boot_log |
794 | call boot_log |
796 | 795 | ||
797 | movzx ecx, word [boot_y] |
796 | movzx ecx, word [boot_y] |
798 | if lang eq ru |
797 | if lang eq ru |
799 | or ecx, (10+30*6) shl 16 |
798 | or ecx, (10+30*6) shl 16 |
800 | else if lang eq sp |
799 | else if lang eq sp |
801 | or ecx, (10+33*6) shl 16 |
800 | or ecx, (10+33*6) shl 16 |
802 | else |
801 | else |
803 | or ecx, (10+29*6) shl 16 |
802 | or ecx, (10+29*6) shl 16 |
804 | end if |
803 | end if |
805 | sub ecx, 10 |
804 | sub ecx, 10 |
806 | mov edx, 0xFFFFFF |
805 | mov edx, 0xFFFFFF |
807 | mov ebx, [MEM_AMOUNT] |
806 | mov ebx, [MEM_AMOUNT] |
808 | shr ebx, 20 |
807 | shr ebx, 20 |
809 | xor edi, edi |
808 | xor edi, edi |
810 | mov eax, 0x00040000 |
809 | mov eax, 0x00040000 |
811 | inc edi |
810 | inc edi |
812 | call display_number_force |
811 | call display_number_force |
813 | 812 | ||
814 | ; BUILD SCHEDULER |
813 | ; BUILD SCHEDULER |
815 | 814 | ||
816 | ; call build_scheduler; sys32.inc |
815 | ; call build_scheduler; sys32.inc |
817 | 816 | ||
818 | ; mov esi, boot_devices |
817 | ; mov esi, boot_devices |
819 | ; call boot_log |
818 | ; call boot_log |
820 | 819 | ||
821 | mov [pci_access_enabled], 1 |
820 | mov [pci_access_enabled], 1 |
822 | call pci_enum |
821 | call pci_enum |
823 | 822 | ||
824 | stdcall load_driver, szVidintel |
823 | stdcall load_driver, szVidintel |
825 | 824 | ||
826 | call usb_init |
825 | call usb_init |
827 | 826 | ||
828 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
827 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
829 | 828 | ||
830 | mov esi, boot_windefs |
829 | mov esi, boot_windefs |
831 | call boot_log |
830 | call boot_log |
832 | call set_window_defaults |
831 | call set_window_defaults |
833 | 832 | ||
834 | ; SET BACKGROUND DEFAULTS |
833 | ; SET BACKGROUND DEFAULTS |
835 | 834 | ||
836 | mov esi, boot_bgr |
835 | mov esi, boot_bgr |
837 | call boot_log |
836 | call boot_log |
838 | call init_background |
837 | call init_background |
839 | call calculatebackground |
838 | call calculatebackground |
840 | 839 | ||
841 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
840 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
842 | 841 | ||
843 | mov esi, boot_resirqports |
842 | mov esi, boot_resirqports |
844 | call boot_log |
843 | call boot_log |
845 | call reserve_irqs_ports |
844 | call reserve_irqs_ports |
846 | 845 | ||
847 | call init_display |
846 | call init_display |
848 | mov eax, [def_cursor] |
847 | mov eax, [def_cursor] |
849 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
848 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
850 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
849 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
851 | 850 | ||
852 | ; PRINT CPU FREQUENCY |
851 | ; PRINT CPU FREQUENCY |
853 | 852 | ||
854 | mov esi, boot_cpufreq |
853 | mov esi, boot_cpufreq |
855 | call boot_log |
854 | call boot_log |
856 | 855 | ||
857 | cli ;FIXME check IF |
856 | cli ;FIXME check IF |
858 | rdtsc |
857 | rdtsc |
859 | mov ecx, eax |
858 | mov ecx, eax |
860 | mov esi, 250 ; wait 1/4 a second |
859 | mov esi, 250 ; wait 1/4 a second |
861 | call delay_ms |
860 | call delay_ms |
862 | rdtsc |
861 | rdtsc |
863 | 862 | ||
864 | sub eax, ecx |
863 | sub eax, ecx |
865 | xor edx, edx |
864 | xor edx, edx |
866 | shld edx, eax, 2 |
865 | shld edx, eax, 2 |
867 | shl eax, 2 |
866 | shl eax, 2 |
868 | mov dword [cpu_freq], eax |
867 | mov dword [cpu_freq], eax |
869 | mov dword [cpu_freq+4], edx |
868 | mov dword [cpu_freq+4], edx |
870 | mov ebx, 1000000 |
869 | mov ebx, 1000000 |
871 | div ebx |
870 | div ebx |
872 | mov ebx, eax |
871 | mov ebx, eax |
873 | 872 | ||
874 | movzx ecx, word [boot_y] |
873 | movzx ecx, word [boot_y] |
875 | if lang eq ru |
874 | if lang eq ru |
876 | add ecx, (10+19*6) shl 16 - 10 |
875 | add ecx, (10+19*6) shl 16 - 10 |
877 | else if lang eq sp |
876 | else if lang eq sp |
878 | add ecx, (10+25*6) shl 16 - 10 |
877 | add ecx, (10+25*6) shl 16 - 10 |
879 | else |
878 | else |
880 | add ecx, (10+17*6) shl 16 - 10 |
879 | add ecx, (10+17*6) shl 16 - 10 |
881 | end if |
880 | end if |
882 | 881 | ||
883 | mov edx, 0xFFFFFF |
882 | mov edx, 0xFFFFFF |
884 | xor edi, edi |
883 | xor edi, edi |
885 | mov eax, 0x00040000 |
884 | mov eax, 0x00040000 |
886 | inc edi |
885 | inc edi |
887 | call display_number_force |
886 | call display_number_force |
888 | 887 | ||
889 | ; SET VARIABLES |
888 | ; SET VARIABLES |
890 | 889 | ||
891 | call set_variables |
890 | call set_variables |
892 | 891 | ||
893 | ; STACK AND FDC |
892 | ; STACK AND FDC |
894 | 893 | ||
895 | call stack_init |
894 | call stack_init |
896 | call fdc_init |
895 | call fdc_init |
897 | 896 | ||
898 | ; PALETTE FOR 320x200 and 640x480 16 col |
897 | ; PALETTE FOR 320x200 and 640x480 16 col |
899 | 898 | ||
900 | cmp [SCR_MODE], word 0x12 |
899 | cmp [SCR_MODE], word 0x12 |
901 | jne no_pal_vga |
900 | jne no_pal_vga |
902 | mov esi, boot_pal_vga |
901 | mov esi, boot_pal_vga |
903 | call boot_log |
902 | call boot_log |
904 | call paletteVGA |
903 | call paletteVGA |
905 | no_pal_vga: |
904 | no_pal_vga: |
906 | 905 | ||
907 | cmp [SCR_MODE], word 0x13 |
906 | cmp [SCR_MODE], word 0x13 |
908 | jne no_pal_ega |
907 | jne no_pal_ega |
909 | mov esi, boot_pal_ega |
908 | mov esi, boot_pal_ega |
910 | call boot_log |
909 | call boot_log |
911 | call palette320x200 |
910 | call palette320x200 |
912 | no_pal_ega: |
911 | no_pal_ega: |
913 | 912 | ||
914 | ; LOAD DEFAULT SKIN |
913 | ; LOAD DEFAULT SKIN |
915 | 914 | ||
916 | call load_default_skin |
915 | call load_default_skin |
917 | 916 | ||
918 | ;protect io permission map |
917 | ;protect io permission map |
919 | 918 | ||
920 | mov esi, [default_io_map] |
919 | mov esi, [default_io_map] |
921 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
920 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
922 | add esi, 0x1000 |
921 | add esi, 0x1000 |
923 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
922 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
924 | 923 | ||
925 | stdcall map_page, tss._io_map_0, \ |
924 | stdcall map_page, tss._io_map_0, \ |
926 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
925 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
927 | stdcall map_page, tss._io_map_1, \ |
926 | stdcall map_page, tss._io_map_1, \ |
928 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
927 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
929 | 928 | ||
930 | ; LOAD FIRST APPLICATION |
929 | ; LOAD FIRST APPLICATION |
931 | cli |
930 | cli |
932 | 931 | ||
933 | mov ebp, firstapp |
932 | mov ebp, firstapp |
934 | call fs_execute_from_sysdir |
933 | call fs_execute_from_sysdir |
935 | test eax, eax |
934 | test eax, eax |
936 | jns first_app_found |
935 | jns first_app_found |
937 | 936 | ||
938 | mov esi, boot_failed |
937 | mov esi, boot_failed |
939 | call boot_log |
938 | call boot_log |
940 | 939 | ||
941 | mov eax, 0xDEADBEEF ; otherwise halt |
940 | mov eax, 0xDEADBEEF ; otherwise halt |
942 | hlt |
941 | hlt |
943 | 942 | ||
944 | first_app_found: |
943 | first_app_found: |
945 | 944 | ||
946 | cli |
945 | cli |
947 | 946 | ||
948 | ; SET KEYBOARD PARAMETERS |
947 | ; SET KEYBOARD PARAMETERS |
949 | mov al, 0xf6 ; reset keyboard, scan enabled |
948 | mov al, 0xf6 ; reset keyboard, scan enabled |
950 | call kb_write |
949 | call kb_write |
951 | test ah, ah |
950 | test ah, ah |
952 | jnz .no_keyboard |
951 | jnz .no_keyboard |
953 | 952 | ||
954 | ; wait until 8042 is ready |
953 | ; wait until 8042 is ready |
955 | xor ecx, ecx |
954 | xor ecx, ecx |
956 | @@: |
955 | @@: |
957 | in al, 64h |
956 | in al, 64h |
958 | and al, 00000010b |
957 | and al, 00000010b |
959 | loopnz @b |
958 | loopnz @b |
960 | 959 | ||
961 | iglobal |
960 | iglobal |
962 | align 4 |
961 | align 4 |
963 | ps2_keyboard_functions: |
962 | ps2_keyboard_functions: |
964 | dd .end - $ |
963 | dd .end - $ |
965 | dd 0 ; no close |
964 | dd 0 ; no close |
966 | dd ps2_set_lights |
965 | dd ps2_set_lights |
967 | .end: |
966 | .end: |
968 | endg |
967 | endg |
969 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
968 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
970 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
969 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
971 | ; call kb_write |
970 | ; call kb_write |
972 | ; call kb_read |
971 | ; call kb_read |
973 | ; mov al, 111b |
972 | ; mov al, 111b |
974 | ; call kb_write |
973 | ; call kb_write |
975 | ; call kb_read |
974 | ; call kb_read |
976 | 975 | ||
977 | mov al, 0xF3 ; set repeat rate & delay |
976 | mov al, 0xF3 ; set repeat rate & delay |
978 | call kb_write |
977 | call kb_write |
979 | ; call kb_read |
978 | ; call kb_read |
980 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
979 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
981 | call kb_write |
980 | call kb_write |
982 | ; call kb_read |
981 | ; call kb_read |
983 | ;// mike.dld [ |
982 | ;// mike.dld [ |
984 | call set_lights |
983 | call set_lights |
985 | ;// mike.dld ] |
984 | ;// mike.dld ] |
986 | stdcall attach_int_handler, 1, irq1, 0 |
985 | stdcall attach_int_handler, 1, irq1, 0 |
987 | DEBUGF 1, "K : IRQ0 error code %x\n", eax |
986 | DEBUGF 1, "K : IRQ0 error code %x\n", eax |
988 | .no_keyboard: |
987 | .no_keyboard: |
989 | 988 | ||
990 | ; SET MOUSE |
989 | ; SET MOUSE |
991 | 990 | ||
992 | stdcall load_driver, szPS2MDriver |
991 | stdcall load_driver, szPS2MDriver |
993 | ; stdcall load_driver, szCOM_MDriver |
992 | ; stdcall load_driver, szCOM_MDriver |
994 | 993 | ||
995 | mov esi, boot_setmouse |
994 | mov esi, boot_setmouse |
996 | call boot_log |
995 | call boot_log |
997 | call setmouse |
996 | call setmouse |
998 | 997 | ||
999 | ; Setup serial output console (if enabled) |
998 | ; Setup serial output console (if enabled) |
1000 | 999 | ||
1001 | if defined debug_com_base |
1000 | if defined debug_com_base |
1002 | 1001 | ||
1003 | ; enable Divisor latch |
1002 | ; enable Divisor latch |
1004 | 1003 | ||
1005 | mov dx, debug_com_base+3 |
1004 | mov dx, debug_com_base+3 |
1006 | mov al, 1 shl 7 |
1005 | mov al, 1 shl 7 |
1007 | out dx, al |
1006 | out dx, al |
1008 | 1007 | ||
1009 | ; Set speed to 115200 baud (max speed) |
1008 | ; Set speed to 115200 baud (max speed) |
1010 | 1009 | ||
1011 | mov dx, debug_com_base |
1010 | mov dx, debug_com_base |
1012 | mov al, 0x01 |
1011 | mov al, 0x01 |
1013 | out dx, al |
1012 | out dx, al |
1014 | 1013 | ||
1015 | mov dx, debug_com_base+1 |
1014 | mov dx, debug_com_base+1 |
1016 | mov al, 0x00 |
1015 | mov al, 0x00 |
1017 | out dx, al |
1016 | out dx, al |
1018 | 1017 | ||
1019 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
1018 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
1020 | 1019 | ||
1021 | mov dx, debug_com_base+3 |
1020 | mov dx, debug_com_base+3 |
1022 | mov al, 3 |
1021 | mov al, 3 |
1023 | out dx, al |
1022 | out dx, al |
1024 | 1023 | ||
1025 | ; disable interrupts |
1024 | ; disable interrupts |
1026 | 1025 | ||
1027 | mov dx, debug_com_base+1 |
1026 | mov dx, debug_com_base+1 |
1028 | mov al, 0 |
1027 | mov al, 0 |
1029 | out dx, al |
1028 | out dx, al |
1030 | 1029 | ||
1031 | ; clear + enable fifo (64 bits) |
1030 | ; clear + enable fifo (64 bits) |
1032 | 1031 | ||
1033 | mov dx, debug_com_base+2 |
1032 | mov dx, debug_com_base+2 |
1034 | mov al, 0x7 + 1 shl 5 |
1033 | mov al, 0x7 + 1 shl 5 |
1035 | out dx, al |
1034 | out dx, al |
1036 | 1035 | ||
1037 | 1036 | ||
1038 | end if |
1037 | end if |
1039 | mov eax, [version_inf.rev] |
1038 | mov eax, [version_inf.rev] |
1040 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1039 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1041 | 1040 | ||
1042 | mov eax, [cpu_count] |
1041 | mov eax, [cpu_count] |
1043 | test eax, eax |
1042 | test eax, eax |
1044 | jnz @F |
1043 | jnz @F |
1045 | mov al, 1 ; at least one CPU |
1044 | mov al, 1 ; at least one CPU |
1046 | @@: |
1045 | @@: |
1047 | DEBUGF 1, "K : %d CPU detected\n", eax |
1046 | DEBUGF 1, "K : %d CPU detected\n", eax |
1048 | 1047 | ||
1049 | DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4 |
1048 | DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4 |
1050 | DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4 |
1049 | DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4 |
1051 | DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4 |
1050 | DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4 |
1052 | DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4 |
1051 | DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4 |
1053 | DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4 |
1052 | DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4 |
1054 | DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4 |
1053 | DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4 |
1055 | DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4 |
1054 | DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4 |
1056 | ; START MULTITASKING |
1055 | ; START MULTITASKING |
1057 | 1056 | ||
1058 | ; A 'All set - press ESC to start' messages if need |
1057 | ; A 'All set - press ESC to start' messages if need |
1059 | if preboot_blogesc |
1058 | if preboot_blogesc |
1060 | mov esi, boot_tasking |
1059 | mov esi, boot_tasking |
1061 | call boot_log |
1060 | call boot_log |
1062 | .bll1: |
1061 | .bll1: |
1063 | in al, 0x60 ; wait for ESC key press |
1062 | in al, 0x60 ; wait for ESC key press |
1064 | cmp al, 129 |
1063 | cmp al, 129 |
1065 | jne .bll1 |
1064 | jne .bll1 |
1066 | end if |
1065 | end if |
1067 | 1066 | ||
1068 | cmp [IDEContrRegsBaseAddr], 0 |
1067 | cmp [IDEContrRegsBaseAddr], 0 |
1069 | setnz [dma_hdd] |
1068 | setnz [dma_hdd] |
1070 | 1069 | ||
1071 | ;----------------------------------------------------------------------------- |
1070 | ;----------------------------------------------------------------------------- |
1072 | ; set interrupts for IDE Controller |
1071 | ; set interrupts for IDE Controller |
1073 | ;----------------------------------------------------------------------------- |
1072 | ;----------------------------------------------------------------------------- |
1074 | mov esi, boot_set_int_IDE |
1073 | mov esi, boot_set_int_IDE |
1075 | call boot_log |
1074 | call boot_log |
1076 | set_interrupts_for_IDE_controllers: |
1075 | set_interrupts_for_IDE_controllers: |
1077 | mov ax, [IDEContrProgrammingInterface] |
1076 | mov ax, [IDEContrProgrammingInterface] |
1078 | cmp ax, 0x0180 |
1077 | cmp ax, 0x0180 |
1079 | je .pata_ide |
1078 | je .pata_ide |
1080 | 1079 | ||
1081 | cmp ax, 0x018a |
1080 | cmp ax, 0x018a |
1082 | jne .sata_ide |
1081 | jne .sata_ide |
1083 | ;-------------------------------------- |
1082 | ;-------------------------------------- |
1084 | .pata_ide: |
1083 | .pata_ide: |
1085 | cmp [IDEContrRegsBaseAddr], 0 |
1084 | cmp [IDEContrRegsBaseAddr], 0 |
1086 | je .end_set_interrupts |
1085 | je .end_set_interrupts |
1087 | 1086 | ||
1088 | stdcall attach_int_handler, 14, IDE_common_irq_handler, 0 |
1087 | stdcall attach_int_handler, 14, IDE_common_irq_handler, 0 |
1089 | DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax |
1088 | DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax |
1090 | stdcall attach_int_handler, 15, IDE_common_irq_handler, 0 |
1089 | stdcall attach_int_handler, 15, IDE_common_irq_handler, 0 |
1091 | DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax |
1090 | DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax |
1092 | 1091 | ||
1093 | stdcall enable_irq, 14 |
1092 | stdcall enable_irq, 14 |
1094 | stdcall enable_irq, 15 |
1093 | stdcall enable_irq, 15 |
1095 | 1094 | ||
1096 | jmp .enable_IDE_interrupt |
1095 | jmp .enable_IDE_interrupt |
1097 | ;-------------------------------------- |
1096 | ;-------------------------------------- |
1098 | .sata_ide: |
1097 | .sata_ide: |
1099 | cmp ax, 0x0185 |
1098 | cmp ax, 0x0185 |
1100 | je .sata_ide_1 |
1099 | je .sata_ide_1 |
1101 | 1100 | ||
1102 | cmp ax, 0x018f |
1101 | cmp ax, 0x018f |
1103 | jne .end_set_interrupts |
1102 | jne .end_set_interrupts |
1104 | ;-------------------------------------- |
1103 | ;-------------------------------------- |
1105 | .sata_ide_1: |
1104 | .sata_ide_1: |
1106 | cmp [IDEContrRegsBaseAddr], 0 |
1105 | cmp [IDEContrRegsBaseAddr], 0 |
1107 | je .end_set_interrupts |
1106 | je .end_set_interrupts |
1108 | 1107 | ||
1109 | mov ax, [IDE_Interrupt] |
1108 | mov ax, [IDE_Interrupt] |
1110 | movzx eax, al |
1109 | movzx eax, al |
1111 | stdcall attach_int_handler, eax, IDE_common_irq_handler, 0 |
1110 | stdcall attach_int_handler, eax, IDE_common_irq_handler, 0 |
1112 | DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:2, eax |
1111 | DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:2, eax |
1113 | 1112 | ||
1114 | stdcall enable_irq, eax |
1113 | stdcall enable_irq, eax |
1115 | ;-------------------------------------- |
1114 | ;-------------------------------------- |
1116 | .enable_IDE_interrupt: |
1115 | .enable_IDE_interrupt: |
1117 | mov esi, boot_enabling_ide |
1116 | mov esi, boot_enabling_ide |
1118 | call boot_log |
1117 | call boot_log |
1119 | ; Enable interrupts in IDE controller for DMA |
1118 | ; Enable interrupts in IDE controller for DMA |
1120 | mov al, 0 |
1119 | mov al, 0 |
1121 | mov dx, [IDE_BAR1_val] ;0x3F6 |
1120 | mov dx, [IDE_BAR1_val] ;0x3F6 |
1122 | add dx, 2 |
1121 | add dx, 2 |
1123 | out dx, al |
1122 | out dx, al |
1124 | mov dx, [IDE_BAR3_val] ;0x76 |
1123 | mov dx, [IDE_BAR3_val] ;0x76 |
1125 | add dx, 2 |
1124 | add dx, 2 |
1126 | out dx, al |
1125 | out dx, al |
1127 | ;-------------------------------------- |
1126 | ;-------------------------------------- |
1128 | .end_set_interrupts: |
1127 | .end_set_interrupts: |
1129 | ;----------------------------------------------------------------------------- |
1128 | ;----------------------------------------------------------------------------- |
1130 | cmp [dma_hdd], 0 |
1129 | cmp [dma_hdd], 0 |
1131 | je .print_pio |
1130 | je .print_pio |
1132 | .print_dma: |
1131 | .print_dma: |
1133 | DEBUGF 1, "K : IDE DMA mode\n" |
1132 | DEBUGF 1, "K : IDE DMA mode\n" |
1134 | jmp .continue |
1133 | jmp .continue |
1135 | 1134 | ||
1136 | .print_pio: |
1135 | .print_pio: |
1137 | DEBUGF 1, "K : IDE PIO mode\n" |
1136 | DEBUGF 1, "K : IDE PIO mode\n" |
1138 | .continue: |
1137 | .continue: |
1139 | 1138 | ||
1140 | mov [timer_ticks_enable], 1 ; for cd driver |
1139 | mov [timer_ticks_enable], 1 ; for cd driver |
1141 | 1140 | ||
1142 | sti |
1141 | sti |
1143 | ; call change_task |
1142 | ; call change_task |
1144 | 1143 | ||
1145 | jmp osloop |
1144 | jmp osloop |
1146 | 1145 | ||
1147 | 1146 | ||
1148 | ; Fly :) |
1147 | ; Fly :) |
1149 | 1148 | ||
1150 | include 'unpacker.inc' |
1149 | include 'unpacker.inc' |
1151 | 1150 | ||
1152 | align 4 |
1151 | align 4 |
1153 | boot_log: |
1152 | boot_log: |
1154 | pushad |
1153 | pushad |
1155 | 1154 | ||
1156 | mov ebx, 10*65536 |
1155 | mov ebx, 10*65536 |
1157 | mov bx, word [boot_y] |
1156 | mov bx, word [boot_y] |
1158 | add [boot_y], dword 10 |
1157 | add [boot_y], dword 10 |
1159 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1158 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1160 | xor edi, edi |
1159 | xor edi, edi |
1161 | mov edx, esi |
1160 | mov edx, esi |
1162 | inc edi |
1161 | inc edi |
1163 | call dtext |
1162 | call dtext |
1164 | 1163 | ||
1165 | mov [novesachecksum], 1000 |
1164 | mov [novesachecksum], 1000 |
1166 | call checkVga_N13 |
1165 | call checkVga_N13 |
1167 | 1166 | ||
1168 | popad |
1167 | popad |
1169 | 1168 | ||
1170 | ret |
1169 | ret |
1171 | 1170 | ||
1172 | ; in: edx -> APPDATA for OS/IDLE slot |
1171 | ; in: edx -> APPDATA for OS/IDLE slot |
1173 | ; in: ebx = stack base |
1172 | ; in: ebx = stack base |
1174 | proc setup_os_slot |
1173 | proc setup_os_slot |
1175 | xor eax, eax |
1174 | xor eax, eax |
1176 | mov ecx, 256/4 |
1175 | mov ecx, 256/4 |
1177 | mov edi, edx |
1176 | mov edi, edx |
1178 | rep stosd |
1177 | rep stosd |
1179 | 1178 | ||
1180 | mov eax, tss+0x80 |
1179 | mov eax, tss+0x80 |
1181 | call get_pg_addr |
1180 | call get_pg_addr |
1182 | inc eax |
1181 | inc eax |
1183 | mov [edx+APPDATA.io_map], eax |
1182 | mov [edx+APPDATA.io_map], eax |
1184 | mov eax, tss+0x1080 |
1183 | mov eax, tss+0x1080 |
1185 | call get_pg_addr |
1184 | call get_pg_addr |
1186 | inc eax |
1185 | inc eax |
1187 | mov [edx+APPDATA.io_map+4], eax |
1186 | mov [edx+APPDATA.io_map+4], eax |
1188 | 1187 | ||
1189 | mov dword [edx+APPDATA.pl0_stack], ebx |
1188 | mov dword [edx+APPDATA.pl0_stack], ebx |
1190 | lea edi, [ebx+0x2000-512] |
1189 | lea edi, [ebx+0x2000-512] |
1191 | mov dword [edx+APPDATA.fpu_state], edi |
1190 | mov dword [edx+APPDATA.fpu_state], edi |
1192 | mov dword [edx+APPDATA.saved_esp0], edi |
1191 | mov dword [edx+APPDATA.saved_esp0], edi |
1193 | mov dword [edx+APPDATA.saved_esp], edi |
1192 | mov dword [edx+APPDATA.saved_esp], edi |
1194 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1193 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1195 | 1194 | ||
1196 | mov esi, fpu_data |
1195 | mov esi, fpu_data |
1197 | mov ecx, 512/4 |
1196 | mov ecx, 512/4 |
1198 | cld |
1197 | cld |
1199 | rep movsd |
1198 | rep movsd |
1200 | 1199 | ||
1201 | lea eax, [edx+APP_OBJ_OFFSET] |
1200 | lea eax, [edx+APP_OBJ_OFFSET] |
1202 | mov dword [edx+APPDATA.fd_obj], eax |
1201 | mov dword [edx+APPDATA.fd_obj], eax |
1203 | mov dword [edx+APPDATA.bk_obj], eax |
1202 | mov dword [edx+APPDATA.bk_obj], eax |
1204 | 1203 | ||
1205 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1204 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1206 | 1205 | ||
1207 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1206 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1208 | 1207 | ||
1209 | mov eax, edx |
1208 | mov eax, edx |
1210 | shr eax, 3 |
1209 | shr eax, 3 |
1211 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1210 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1212 | mov [eax+TASKDATA.wnd_number], dh |
1211 | mov [eax+TASKDATA.wnd_number], dh |
1213 | mov byte [eax+TASKDATA.pid], dh |
1212 | mov byte [eax+TASKDATA.pid], dh |
1214 | 1213 | ||
1215 | ret |
1214 | ret |
1216 | endp |
1215 | endp |
1217 | 1216 | ||
1218 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1217 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1219 | ; ; |
1218 | ; ; |
1220 | ; MAIN OS LOOP START ; |
1219 | ; MAIN OS LOOP START ; |
1221 | ; ; |
1220 | ; ; |
1222 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1221 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1223 | align 32 |
1222 | align 32 |
1224 | osloop: |
1223 | osloop: |
1225 | mov edx, osloop_has_work? |
1224 | mov edx, osloop_has_work? |
1226 | xor ecx, ecx |
1225 | xor ecx, ecx |
1227 | call Wait_events |
1226 | call Wait_events |
1228 | xor eax, eax |
1227 | xor eax, eax |
1229 | xchg eax, [osloop_nonperiodic_work] |
1228 | xchg eax, [osloop_nonperiodic_work] |
1230 | test eax, eax |
1229 | test eax, eax |
1231 | jz .no_periodic |
1230 | jz .no_periodic |
1232 | ; call [draw_pointer] |
1231 | ; call [draw_pointer] |
1233 | call __sys_draw_pointer |
1232 | call __sys_draw_pointer |
1234 | call window_check_events |
1233 | call window_check_events |
1235 | call mouse_check_events |
1234 | call mouse_check_events |
1236 | call checkmisc |
1235 | call checkmisc |
1237 | call checkVga_N13 |
1236 | call checkVga_N13 |
1238 | .no_periodic: |
1237 | .no_periodic: |
1239 | call stack_handler |
1238 | call stack_handler |
1240 | call check_fdd_motor_status |
1239 | call check_fdd_motor_status |
1241 | call check_ATAPI_device_event |
1240 | call check_ATAPI_device_event |
1242 | call check_lights_state |
1241 | call check_lights_state |
1243 | call check_timers |
1242 | call check_timers |
1244 | jmp osloop |
1243 | jmp osloop |
1245 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1244 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1246 | ; ; |
1245 | ; ; |
1247 | ; MAIN OS LOOP END ; |
1246 | ; MAIN OS LOOP END ; |
1248 | ; ; |
1247 | ; ; |
1249 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1248 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1250 | proc osloop_has_work? |
1249 | proc osloop_has_work? |
1251 | cmp [osloop_nonperiodic_work], 0 |
1250 | cmp [osloop_nonperiodic_work], 0 |
1252 | jnz .yes |
1251 | jnz .yes |
1253 | call stack_handler_has_work? |
1252 | call stack_handler_has_work? |
1254 | jnz .yes |
1253 | jnz .yes |
1255 | call check_fdd_motor_status_has_work? |
1254 | ; call check_fdd_motor_status_has_work? |
1256 | jnz .yes |
1255 | ; jnz .yes |
1257 | call check_ATAPI_device_event_has_work? |
1256 | call check_ATAPI_device_event_has_work? |
1258 | jnz .yes |
1257 | jnz .yes |
1259 | call check_lights_state_has_work? |
1258 | call check_lights_state_has_work? |
1260 | jnz .yes |
1259 | jnz .yes |
1261 | call check_timers_has_work? |
1260 | call check_timers_has_work? |
1262 | jnz .yes |
1261 | jnz .yes |
1263 | .no: |
1262 | .no: |
1264 | xor eax, eax |
1263 | xor eax, eax |
1265 | ret |
1264 | ret |
1266 | .yes: |
1265 | .yes: |
1267 | xor eax, eax |
1266 | xor eax, eax |
1268 | inc eax |
1267 | inc eax |
1269 | ret |
1268 | ret |
1270 | endp |
1269 | endp |
1271 | 1270 | ||
1272 | proc wakeup_osloop |
1271 | proc wakeup_osloop |
1273 | mov [osloop_nonperiodic_work], 1 |
1272 | mov [osloop_nonperiodic_work], 1 |
1274 | ret |
1273 | ret |
1275 | endp |
1274 | endp |
1276 | 1275 | ||
1277 | uglobal |
1276 | uglobal |
1278 | align 4 |
1277 | align 4 |
1279 | osloop_nonperiodic_work dd ? |
1278 | osloop_nonperiodic_work dd ? |
1280 | endg |
1279 | endg |
1281 | 1280 | ||
1282 | align 4 |
1281 | align 4 |
1283 | idle_thread: |
1282 | idle_thread: |
1284 | sti |
1283 | sti |
1285 | idle_loop: |
1284 | idle_loop: |
1286 | hlt |
1285 | hlt |
1287 | jmp idle_loop |
1286 | jmp idle_loop |
1288 | 1287 | ||
1289 | 1288 | ||
1290 | 1289 | ||
1291 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1290 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1292 | ; ; |
1291 | ; ; |
1293 | ; INCLUDED SYSTEM FILES ; |
1292 | ; INCLUDED SYSTEM FILES ; |
1294 | ; ; |
1293 | ; ; |
1295 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1294 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1296 | 1295 | ||
1297 | 1296 | ||
1298 | include "kernel32.inc" |
1297 | include "kernel32.inc" |
1299 | 1298 | ||
1300 | 1299 | ||
1301 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1300 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1302 | ; ; |
1301 | ; ; |
1303 | ; KERNEL FUNCTIONS ; |
1302 | ; KERNEL FUNCTIONS ; |
1304 | ; ; |
1303 | ; ; |
1305 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1304 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1306 | 1305 | ||
1307 | reserve_irqs_ports: |
1306 | reserve_irqs_ports: |
1308 | 1307 | ||
1309 | 1308 | ||
1310 | ; RESERVE PORTS |
1309 | ; RESERVE PORTS |
1311 | mov eax, RESERVED_PORTS |
1310 | mov eax, RESERVED_PORTS |
1312 | mov ecx, 1 |
1311 | mov ecx, 1 |
1313 | 1312 | ||
1314 | mov [eax], dword 4 |
1313 | mov [eax], dword 4 |
1315 | 1314 | ||
1316 | mov [eax+16], ecx |
1315 | mov [eax+16], ecx |
1317 | mov [eax+16+4], dword 0 |
1316 | mov [eax+16+4], dword 0 |
1318 | mov [eax+16+8], dword 0x2D |
1317 | mov [eax+16+8], dword 0x2D |
1319 | 1318 | ||
1320 | mov [eax+32], ecx |
1319 | mov [eax+32], ecx |
1321 | mov [eax+32+4], dword 0x30 |
1320 | mov [eax+32+4], dword 0x30 |
1322 | mov [eax+32+8], dword 0x4D |
1321 | mov [eax+32+8], dword 0x4D |
1323 | 1322 | ||
1324 | mov [eax+48], ecx |
1323 | mov [eax+48], ecx |
1325 | mov [eax+48+4], dword 0x50 |
1324 | mov [eax+48+4], dword 0x50 |
1326 | mov [eax+48+8], dword 0xDF |
1325 | mov [eax+48+8], dword 0xDF |
1327 | 1326 | ||
1328 | mov [eax+64], ecx |
1327 | mov [eax+64], ecx |
1329 | mov [eax+64+4], dword 0xE5 |
1328 | mov [eax+64+4], dword 0xE5 |
1330 | mov [eax+64+8], dword 0xFF |
1329 | mov [eax+64+8], dword 0xFF |
1331 | 1330 | ||
1332 | ret |
1331 | ret |
1333 | 1332 | ||
1334 | 1333 | ||
1335 | iglobal |
1334 | iglobal |
1336 | process_number dd 0x2 |
1335 | process_number dd 0x2 |
1337 | endg |
1336 | endg |
1338 | 1337 | ||
1339 | set_variables: |
1338 | set_variables: |
1340 | 1339 | ||
1341 | mov ecx, 0x16 ; flush port 0x60 |
1340 | mov ecx, 0x16 ; flush port 0x60 |
1342 | .fl60: |
1341 | .fl60: |
1343 | in al, 0x60 |
1342 | in al, 0x60 |
1344 | loop .fl60 |
1343 | loop .fl60 |
1345 | push eax |
1344 | push eax |
1346 | 1345 | ||
1347 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1346 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1348 | shr ax, 1 |
1347 | shr ax, 1 |
1349 | shl eax, 16 |
1348 | shl eax, 16 |
1350 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1349 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1351 | shr ax, 1 |
1350 | shr ax, 1 |
1352 | mov [MOUSE_X], eax |
1351 | mov [MOUSE_X], eax |
1353 | call wakeup_osloop |
1352 | call wakeup_osloop |
1354 | 1353 | ||
1355 | xor eax, eax |
1354 | xor eax, eax |
1356 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1355 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1357 | 1356 | ||
1358 | mov byte [KEY_COUNT], al ; keyboard buffer |
1357 | mov byte [KEY_COUNT], al ; keyboard buffer |
1359 | mov byte [BTN_COUNT], al ; button buffer |
1358 | mov byte [BTN_COUNT], al ; button buffer |
1360 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1359 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1361 | 1360 | ||
1362 | pop eax |
1361 | pop eax |
1363 | ret |
1362 | ret |
1364 | 1363 | ||
1365 | align 4 |
1364 | align 4 |
1366 | ;input eax=43,bl-byte of output, ecx - number of port |
1365 | ;input eax=43,bl-byte of output, ecx - number of port |
1367 | sys_outport: |
1366 | sys_outport: |
1368 | 1367 | ||
1369 | mov edi, ecx ; separate flag for read / write |
1368 | mov edi, ecx ; separate flag for read / write |
1370 | and ecx, 65535 |
1369 | and ecx, 65535 |
1371 | 1370 | ||
1372 | mov eax, [RESERVED_PORTS] |
1371 | mov eax, [RESERVED_PORTS] |
1373 | test eax, eax |
1372 | test eax, eax |
1374 | jnz .sopl8 |
1373 | jnz .sopl8 |
1375 | inc eax |
1374 | inc eax |
1376 | mov [esp+32], eax |
1375 | mov [esp+32], eax |
1377 | ret |
1376 | ret |
1378 | 1377 | ||
1379 | .sopl8: |
1378 | .sopl8: |
1380 | mov edx, [TASK_BASE] |
1379 | mov edx, [TASK_BASE] |
1381 | mov edx, [edx+0x4] |
1380 | mov edx, [edx+0x4] |
1382 | ;and ecx,65535 |
1381 | ;and ecx,65535 |
1383 | ;cld - set on interrupt 0x40 |
1382 | ;cld - set on interrupt 0x40 |
1384 | .sopl1: |
1383 | .sopl1: |
1385 | 1384 | ||
1386 | mov esi, eax |
1385 | mov esi, eax |
1387 | shl esi, 4 |
1386 | shl esi, 4 |
1388 | add esi, RESERVED_PORTS |
1387 | add esi, RESERVED_PORTS |
1389 | cmp edx, [esi+0] |
1388 | cmp edx, [esi+0] |
1390 | jne .sopl2 |
1389 | jne .sopl2 |
1391 | cmp ecx, [esi+4] |
1390 | cmp ecx, [esi+4] |
1392 | jb .sopl2 |
1391 | jb .sopl2 |
1393 | cmp ecx, [esi+8] |
1392 | cmp ecx, [esi+8] |
1394 | jg .sopl2 |
1393 | jg .sopl2 |
1395 | .sopl3: |
1394 | .sopl3: |
1396 | 1395 | ||
1397 | test edi, 0x80000000; read ? |
1396 | test edi, 0x80000000; read ? |
1398 | jnz .sopl4 |
1397 | jnz .sopl4 |
1399 | 1398 | ||
1400 | mov eax, ebx |
1399 | mov eax, ebx |
1401 | mov dx, cx ; write |
1400 | mov dx, cx ; write |
1402 | out dx, al |
1401 | out dx, al |
1403 | and [esp+32], dword 0 |
1402 | and [esp+32], dword 0 |
1404 | ret |
1403 | ret |
1405 | 1404 | ||
1406 | .sopl2: |
1405 | .sopl2: |
1407 | 1406 | ||
1408 | dec eax |
1407 | dec eax |
1409 | jnz .sopl1 |
1408 | jnz .sopl1 |
1410 | inc eax |
1409 | inc eax |
1411 | mov [esp+32], eax |
1410 | mov [esp+32], eax |
1412 | ret |
1411 | ret |
1413 | 1412 | ||
1414 | 1413 | ||
1415 | .sopl4: |
1414 | .sopl4: |
1416 | 1415 | ||
1417 | mov dx, cx ; read |
1416 | mov dx, cx ; read |
1418 | in al, dx |
1417 | in al, dx |
1419 | and eax, 0xff |
1418 | and eax, 0xff |
1420 | and [esp+32], dword 0 |
1419 | and [esp+32], dword 0 |
1421 | mov [esp+20], eax |
1420 | mov [esp+20], eax |
1422 | ret |
1421 | ret |
1423 | 1422 | ||
1424 | display_number: |
1423 | display_number: |
1425 | ;It is not optimization |
1424 | ;It is not optimization |
1426 | mov eax, ebx |
1425 | mov eax, ebx |
1427 | mov ebx, ecx |
1426 | mov ebx, ecx |
1428 | mov ecx, edx |
1427 | mov ecx, edx |
1429 | mov edx, esi |
1428 | mov edx, esi |
1430 | mov esi, edi |
1429 | mov esi, edi |
1431 | ; eax = print type, al=0 -> ebx is number |
1430 | ; eax = print type, al=0 -> ebx is number |
1432 | ; al=1 -> ebx is pointer |
1431 | ; al=1 -> ebx is pointer |
1433 | ; ah=0 -> display decimal |
1432 | ; ah=0 -> display decimal |
1434 | ; ah=1 -> display hexadecimal |
1433 | ; ah=1 -> display hexadecimal |
1435 | ; ah=2 -> display binary |
1434 | ; ah=2 -> display binary |
1436 | ; eax bits 16-21 = number of digits to display (0-32) |
1435 | ; eax bits 16-21 = number of digits to display (0-32) |
1437 | ; eax bits 22-31 = reserved |
1436 | ; eax bits 22-31 = reserved |
1438 | ; |
1437 | ; |
1439 | ; ebx = number or pointer |
1438 | ; ebx = number or pointer |
1440 | ; ecx = x shl 16 + y |
1439 | ; ecx = x shl 16 + y |
1441 | ; edx = color |
1440 | ; edx = color |
1442 | xor edi, edi |
1441 | xor edi, edi |
1443 | display_number_force: |
1442 | display_number_force: |
1444 | push eax |
1443 | push eax |
1445 | and eax, 0x3fffffff |
1444 | and eax, 0x3fffffff |
1446 | cmp eax, 0xffff ; length > 0 ? |
1445 | cmp eax, 0xffff ; length > 0 ? |
1447 | pop eax |
1446 | pop eax |
1448 | jge cont_displ |
1447 | jge cont_displ |
1449 | ret |
1448 | ret |
1450 | cont_displ: |
1449 | cont_displ: |
1451 | push eax |
1450 | push eax |
1452 | and eax, 0x3fffffff |
1451 | and eax, 0x3fffffff |
1453 | cmp eax, 61*0x10000 ; length <= 60 ? |
1452 | cmp eax, 61*0x10000 ; length <= 60 ? |
1454 | pop eax |
1453 | pop eax |
1455 | jb cont_displ2 |
1454 | jb cont_displ2 |
1456 | ret |
1455 | ret |
1457 | cont_displ2: |
1456 | cont_displ2: |
1458 | 1457 | ||
1459 | pushad |
1458 | pushad |
1460 | 1459 | ||
1461 | cmp al, 1 ; ecx is a pointer ? |
1460 | cmp al, 1 ; ecx is a pointer ? |
1462 | jne displnl1 |
1461 | jne displnl1 |
1463 | mov ebp, ebx |
1462 | mov ebp, ebx |
1464 | add ebp, 4 |
1463 | add ebp, 4 |
1465 | mov ebp, [ebp+std_application_base_address] |
1464 | mov ebp, [ebp+std_application_base_address] |
1466 | mov ebx, [ebx+std_application_base_address] |
1465 | mov ebx, [ebx+std_application_base_address] |
1467 | displnl1: |
1466 | displnl1: |
1468 | sub esp, 64 |
1467 | sub esp, 64 |
1469 | 1468 | ||
1470 | test ah, ah ; DECIMAL |
1469 | test ah, ah ; DECIMAL |
1471 | jnz no_display_desnum |
1470 | jnz no_display_desnum |
1472 | shr eax, 16 |
1471 | shr eax, 16 |
1473 | and eax, 0xC03f |
1472 | and eax, 0xC03f |
1474 | ; and eax,0x3f |
1473 | ; and eax,0x3f |
1475 | push eax |
1474 | push eax |
1476 | and eax, 0x3f |
1475 | and eax, 0x3f |
1477 | mov edi, esp |
1476 | mov edi, esp |
1478 | add edi, 4+64-1 |
1477 | add edi, 4+64-1 |
1479 | mov ecx, eax |
1478 | mov ecx, eax |
1480 | mov eax, ebx |
1479 | mov eax, ebx |
1481 | mov ebx, 10 |
1480 | mov ebx, 10 |
1482 | d_desnum: |
1481 | d_desnum: |
1483 | xor edx, edx |
1482 | xor edx, edx |
1484 | call division_64_bits |
1483 | call division_64_bits |
1485 | div ebx |
1484 | div ebx |
1486 | add dl, 48 |
1485 | add dl, 48 |
1487 | mov [edi], dl |
1486 | mov [edi], dl |
1488 | dec edi |
1487 | dec edi |
1489 | loop d_desnum |
1488 | loop d_desnum |
1490 | pop eax |
1489 | pop eax |
1491 | call normalize_number |
1490 | call normalize_number |
1492 | call draw_num_text |
1491 | call draw_num_text |
1493 | add esp, 64 |
1492 | add esp, 64 |
1494 | popad |
1493 | popad |
1495 | ret |
1494 | ret |
1496 | no_display_desnum: |
1495 | no_display_desnum: |
1497 | 1496 | ||
1498 | cmp ah, 0x01 ; HEXADECIMAL |
1497 | cmp ah, 0x01 ; HEXADECIMAL |
1499 | jne no_display_hexnum |
1498 | jne no_display_hexnum |
1500 | shr eax, 16 |
1499 | shr eax, 16 |
1501 | and eax, 0xC03f |
1500 | and eax, 0xC03f |
1502 | ; and eax,0x3f |
1501 | ; and eax,0x3f |
1503 | push eax |
1502 | push eax |
1504 | and eax, 0x3f |
1503 | and eax, 0x3f |
1505 | mov edi, esp |
1504 | mov edi, esp |
1506 | add edi, 4+64-1 |
1505 | add edi, 4+64-1 |
1507 | mov ecx, eax |
1506 | mov ecx, eax |
1508 | mov eax, ebx |
1507 | mov eax, ebx |
1509 | mov ebx, 16 |
1508 | mov ebx, 16 |
1510 | d_hexnum: |
1509 | d_hexnum: |
1511 | xor edx, edx |
1510 | xor edx, edx |
1512 | call division_64_bits |
1511 | call division_64_bits |
1513 | div ebx |
1512 | div ebx |
1514 | hexletters = __fdo_hexdigits |
1513 | hexletters = __fdo_hexdigits |
1515 | add edx, hexletters |
1514 | add edx, hexletters |
1516 | mov dl, [edx] |
1515 | mov dl, [edx] |
1517 | mov [edi], dl |
1516 | mov [edi], dl |
1518 | dec edi |
1517 | dec edi |
1519 | loop d_hexnum |
1518 | loop d_hexnum |
1520 | pop eax |
1519 | pop eax |
1521 | call normalize_number |
1520 | call normalize_number |
1522 | call draw_num_text |
1521 | call draw_num_text |
1523 | add esp, 64 |
1522 | add esp, 64 |
1524 | popad |
1523 | popad |
1525 | ret |
1524 | ret |
1526 | no_display_hexnum: |
1525 | no_display_hexnum: |
1527 | 1526 | ||
1528 | cmp ah, 0x02 ; BINARY |
1527 | cmp ah, 0x02 ; BINARY |
1529 | jne no_display_binnum |
1528 | jne no_display_binnum |
1530 | shr eax, 16 |
1529 | shr eax, 16 |
1531 | and eax, 0xC03f |
1530 | and eax, 0xC03f |
1532 | ; and eax,0x3f |
1531 | ; and eax,0x3f |
1533 | push eax |
1532 | push eax |
1534 | and eax, 0x3f |
1533 | and eax, 0x3f |
1535 | mov edi, esp |
1534 | mov edi, esp |
1536 | add edi, 4+64-1 |
1535 | add edi, 4+64-1 |
1537 | mov ecx, eax |
1536 | mov ecx, eax |
1538 | mov eax, ebx |
1537 | mov eax, ebx |
1539 | mov ebx, 2 |
1538 | mov ebx, 2 |
1540 | d_binnum: |
1539 | d_binnum: |
1541 | xor edx, edx |
1540 | xor edx, edx |
1542 | call division_64_bits |
1541 | call division_64_bits |
1543 | div ebx |
1542 | div ebx |
1544 | add dl, 48 |
1543 | add dl, 48 |
1545 | mov [edi], dl |
1544 | mov [edi], dl |
1546 | dec edi |
1545 | dec edi |
1547 | loop d_binnum |
1546 | loop d_binnum |
1548 | pop eax |
1547 | pop eax |
1549 | call normalize_number |
1548 | call normalize_number |
1550 | call draw_num_text |
1549 | call draw_num_text |
1551 | add esp, 64 |
1550 | add esp, 64 |
1552 | popad |
1551 | popad |
1553 | ret |
1552 | ret |
1554 | no_display_binnum: |
1553 | no_display_binnum: |
1555 | 1554 | ||
1556 | add esp, 64 |
1555 | add esp, 64 |
1557 | popad |
1556 | popad |
1558 | ret |
1557 | ret |
1559 | 1558 | ||
1560 | normalize_number: |
1559 | normalize_number: |
1561 | test ah, 0x80 |
1560 | test ah, 0x80 |
1562 | jz .continue |
1561 | jz .continue |
1563 | mov ecx, 48 |
1562 | mov ecx, 48 |
1564 | and eax, 0x3f |
1563 | and eax, 0x3f |
1565 | @@: |
1564 | @@: |
1566 | inc edi |
1565 | inc edi |
1567 | cmp [edi], cl |
1566 | cmp [edi], cl |
1568 | jne .continue |
1567 | jne .continue |
1569 | dec eax |
1568 | dec eax |
1570 | cmp eax, 1 |
1569 | cmp eax, 1 |
1571 | ja @r |
1570 | ja @r |
1572 | mov al, 1 |
1571 | mov al, 1 |
1573 | .continue: |
1572 | .continue: |
1574 | and eax, 0x3f |
1573 | and eax, 0x3f |
1575 | ret |
1574 | ret |
1576 | 1575 | ||
1577 | division_64_bits: |
1576 | division_64_bits: |
1578 | test [esp+1+4], byte 0x40 |
1577 | test [esp+1+4], byte 0x40 |
1579 | jz .continue |
1578 | jz .continue |
1580 | push eax |
1579 | push eax |
1581 | mov eax, ebp |
1580 | mov eax, ebp |
1582 | div ebx |
1581 | div ebx |
1583 | mov ebp, eax |
1582 | mov ebp, eax |
1584 | pop eax |
1583 | pop eax |
1585 | .continue: |
1584 | .continue: |
1586 | ret |
1585 | ret |
1587 | 1586 | ||
1588 | draw_num_text: |
1587 | draw_num_text: |
1589 | mov esi, eax |
1588 | mov esi, eax |
1590 | mov edx, 64+4 |
1589 | mov edx, 64+4 |
1591 | sub edx, eax |
1590 | sub edx, eax |
1592 | add edx, esp |
1591 | add edx, esp |
1593 | mov ebx, [esp+64+32-8+4] |
1592 | mov ebx, [esp+64+32-8+4] |
1594 | ; add window start x & y |
1593 | ; add window start x & y |
1595 | mov ecx, [TASK_BASE] |
1594 | mov ecx, [TASK_BASE] |
1596 | 1595 | ||
1597 | mov edi, [CURRENT_TASK] |
1596 | mov edi, [CURRENT_TASK] |
1598 | shl edi, 8 |
1597 | shl edi, 8 |
1599 | 1598 | ||
1600 | mov eax, [ecx-twdw+WDATA.box.left] |
1599 | mov eax, [ecx-twdw+WDATA.box.left] |
1601 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1600 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1602 | shl eax, 16 |
1601 | shl eax, 16 |
1603 | add eax, [ecx-twdw+WDATA.box.top] |
1602 | add eax, [ecx-twdw+WDATA.box.top] |
1604 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1603 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1605 | add ebx, eax |
1604 | add ebx, eax |
1606 | mov ecx, [esp+64+32-12+4] |
1605 | mov ecx, [esp+64+32-12+4] |
1607 | and ecx, not 0x80000000 ; force counted string |
1606 | and ecx, not 0x80000000 ; force counted string |
1608 | mov eax, [esp+64+8] ; background color (if given) |
1607 | mov eax, [esp+64+8] ; background color (if given) |
1609 | mov edi, [esp+64+4] |
1608 | mov edi, [esp+64+4] |
1610 | jmp dtext |
1609 | jmp dtext |
1611 | 1610 | ||
1612 | align 4 |
1611 | align 4 |
1613 | 1612 | ||
1614 | sys_setup: |
1613 | sys_setup: |
1615 | 1614 | ||
1616 | ; 1=roland mpu midi base , base io address |
1615 | ; 1=roland mpu midi base , base io address |
1617 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1616 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1618 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1617 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1619 | ; 5=system language, 1eng 2fi 3ger 4rus |
1618 | ; 5=system language, 1eng 2fi 3ger 4rus |
1620 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1619 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1621 | ; 8=fat32 partition in hd |
1620 | ; 8=fat32 partition in hd |
1622 | ; 9 |
1621 | ; 9 |
1623 | ; 10 = sound dma channel |
1622 | ; 10 = sound dma channel |
1624 | ; 11 = enable lba read |
1623 | ; 11 = enable lba read |
1625 | ; 12 = enable pci access |
1624 | ; 12 = enable pci access |
1626 | 1625 | ||
1627 | 1626 | ||
1628 | and [esp+32], dword 0 |
1627 | and [esp+32], dword 0 |
1629 | dec ebx ; MIDI |
1628 | dec ebx ; MIDI |
1630 | jnz nsyse1 |
1629 | jnz nsyse1 |
1631 | cmp ecx, 0x100 |
1630 | cmp ecx, 0x100 |
1632 | 1631 | ||
1633 | jb nsyse1 |
1632 | jb nsyse1 |
1634 | mov esi, 65535 |
1633 | mov esi, 65535 |
1635 | cmp esi, ecx |
1634 | cmp esi, ecx |
1636 | 1635 | ||
1637 | jb nsyse1 |
1636 | jb nsyse1 |
1638 | mov [midi_base], cx ;bx |
1637 | mov [midi_base], cx ;bx |
1639 | mov word [mididp], cx;bx |
1638 | mov word [mididp], cx;bx |
1640 | inc cx ;bx |
1639 | inc cx ;bx |
1641 | mov word [midisp], cx;bx |
1640 | mov word [midisp], cx;bx |
1642 | ret |
1641 | ret |
1643 | 1642 | ||
1644 | iglobal |
1643 | iglobal |
1645 | midi_base dw 0 |
1644 | midi_base dw 0 |
1646 | endg |
1645 | endg |
1647 | 1646 | ||
1648 | nsyse1: |
1647 | nsyse1: |
1649 | dec ebx ; KEYBOARD |
1648 | dec ebx ; KEYBOARD |
1650 | jnz nsyse2 |
1649 | jnz nsyse2 |
1651 | mov edi, [TASK_BASE] |
1650 | mov edi, [TASK_BASE] |
1652 | mov eax, [edi+TASKDATA.mem_start] |
1651 | mov eax, [edi+TASKDATA.mem_start] |
1653 | add eax, edx |
1652 | add eax, edx |
1654 | 1653 | ||
1655 | dec ecx |
1654 | dec ecx |
1656 | jnz kbnobase |
1655 | jnz kbnobase |
1657 | mov ebx, keymap |
1656 | mov ebx, keymap |
1658 | mov ecx, 128 |
1657 | mov ecx, 128 |
1659 | call memmove |
1658 | call memmove |
1660 | ret |
1659 | ret |
1661 | kbnobase: |
1660 | kbnobase: |
1662 | dec ecx |
1661 | dec ecx |
1663 | jnz kbnoshift |
1662 | jnz kbnoshift |
1664 | 1663 | ||
1665 | mov ebx, keymap_shift |
1664 | mov ebx, keymap_shift |
1666 | mov ecx, 128 |
1665 | mov ecx, 128 |
1667 | call memmove |
1666 | call memmove |
1668 | ret |
1667 | ret |
1669 | kbnoshift: |
1668 | kbnoshift: |
1670 | dec ecx |
1669 | dec ecx |
1671 | jnz kbnoalt |
1670 | jnz kbnoalt |
1672 | mov ebx, keymap_alt |
1671 | mov ebx, keymap_alt |
1673 | mov ecx, 128 |
1672 | mov ecx, 128 |
1674 | call memmove |
1673 | call memmove |
1675 | ret |
1674 | ret |
1676 | kbnoalt: |
1675 | kbnoalt: |
1677 | sub ecx, 6 |
1676 | sub ecx, 6 |
1678 | jnz kbnocountry |
1677 | jnz kbnocountry |
1679 | mov word [keyboard], dx |
1678 | mov word [keyboard], dx |
1680 | ret |
1679 | ret |
1681 | kbnocountry: |
1680 | kbnocountry: |
1682 | mov [esp+32], dword 1 |
1681 | mov [esp+32], dword 1 |
1683 | ret |
1682 | ret |
1684 | nsyse2: |
1683 | nsyse2: |
1685 | dec ebx ; CD |
1684 | dec ebx ; CD |
1686 | jnz nsyse4 |
1685 | jnz nsyse4 |
1687 | 1686 | ||
1688 | test ecx, ecx |
1687 | test ecx, ecx |
1689 | jz nosesl |
1688 | jz nosesl |
1690 | 1689 | ||
1691 | cmp ecx, 4 |
1690 | cmp ecx, 4 |
1692 | ja nosesl |
1691 | ja nosesl |
1693 | mov [cd_base], cl |
1692 | mov [cd_base], cl |
1694 | 1693 | ||
1695 | dec ecx |
1694 | dec ecx |
1696 | jnz noprma |
1695 | jnz noprma |
1697 | mov eax, [hd_address_table] |
1696 | mov eax, [hd_address_table] |
1698 | mov [cdbase], eax ;0x1f0 |
1697 | mov [cdbase], eax ;0x1f0 |
1699 | mov [cdid], 0xa0 |
1698 | mov [cdid], 0xa0 |
1700 | noprma: |
1699 | noprma: |
1701 | 1700 | ||
1702 | dec ecx |
1701 | dec ecx |
1703 | jnz noprsl |
1702 | jnz noprsl |
1704 | mov eax, [hd_address_table] |
1703 | mov eax, [hd_address_table] |
1705 | mov [cdbase], eax ;0x1f0 |
1704 | mov [cdbase], eax ;0x1f0 |
1706 | mov [cdid], 0xb0 |
1705 | mov [cdid], 0xb0 |
1707 | noprsl: |
1706 | noprsl: |
1708 | dec ecx |
1707 | dec ecx |
1709 | jnz nosema |
1708 | jnz nosema |
1710 | mov eax, [hd_address_table+16] |
1709 | mov eax, [hd_address_table+16] |
1711 | mov [cdbase], eax ;0x170 |
1710 | mov [cdbase], eax ;0x170 |
1712 | mov [cdid], 0xa0 |
1711 | mov [cdid], 0xa0 |
1713 | nosema: |
1712 | nosema: |
1714 | dec ecx |
1713 | dec ecx |
1715 | jnz nosesl |
1714 | jnz nosesl |
1716 | mov eax, [hd_address_table+16] |
1715 | mov eax, [hd_address_table+16] |
1717 | mov [cdbase], eax ;0x170 |
1716 | mov [cdbase], eax ;0x170 |
1718 | mov [cdid], 0xb0 |
1717 | mov [cdid], 0xb0 |
1719 | nosesl: |
1718 | nosesl: |
1720 | ret |
1719 | ret |
1721 | 1720 | ||
1722 | iglobal |
1721 | iglobal |
1723 | cd_base db 0 |
1722 | cd_base db 0 |
1724 | 1723 | ||
1725 | endg |
1724 | endg |
1726 | nsyse4: |
1725 | nsyse4: |
1727 | 1726 | ||
1728 | sub ebx, 2 ; SYSTEM LANGUAGE |
1727 | sub ebx, 2 ; SYSTEM LANGUAGE |
1729 | jnz nsyse5 |
1728 | jnz nsyse5 |
1730 | mov [syslang], ecx |
1729 | mov [syslang], ecx |
1731 | ret |
1730 | ret |
1732 | nsyse5: |
1731 | nsyse5: |
1733 | 1732 | ||
1734 | sub ebx, 2 ; HD BASE - obsolete |
1733 | sub ebx, 2 ; HD BASE - obsolete |
1735 | jnz nsyse7 |
1734 | jnz nsyse7 |
1736 | 1735 | ||
1737 | nosethd: |
1736 | nosethd: |
1738 | ret |
1737 | ret |
1739 | 1738 | ||
1740 | nsyse7: |
1739 | nsyse7: |
1741 | 1740 | ||
1742 | ; cmp eax,8 ; HD PARTITION - obsolete |
1741 | ; cmp eax,8 ; HD PARTITION - obsolete |
1743 | dec ebx |
1742 | dec ebx |
1744 | jnz nsyse8 |
1743 | jnz nsyse8 |
1745 | ret |
1744 | ret |
1746 | 1745 | ||
1747 | nsyse8: |
1746 | nsyse8: |
1748 | ; cmp eax,11 ; ENABLE LBA READ |
1747 | ; cmp eax,11 ; ENABLE LBA READ |
1749 | and ecx, 1 |
1748 | and ecx, 1 |
1750 | sub ebx, 3 |
1749 | sub ebx, 3 |
1751 | jnz no_set_lba_read |
1750 | jnz no_set_lba_read |
1752 | mov [lba_read_enabled], ecx |
1751 | mov [lba_read_enabled], ecx |
1753 | ret |
1752 | ret |
1754 | 1753 | ||
1755 | no_set_lba_read: |
1754 | no_set_lba_read: |
1756 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1755 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1757 | dec ebx |
1756 | dec ebx |
1758 | jnz sys_setup_err |
1757 | jnz sys_setup_err |
1759 | mov [pci_access_enabled], ecx |
1758 | mov [pci_access_enabled], ecx |
1760 | ret |
1759 | ret |
1761 | 1760 | ||
1762 | sys_setup_err: |
1761 | sys_setup_err: |
1763 | or [esp+32], dword -1 |
1762 | or [esp+32], dword -1 |
1764 | ret |
1763 | ret |
1765 | 1764 | ||
1766 | align 4 |
1765 | align 4 |
1767 | 1766 | ||
1768 | sys_getsetup: |
1767 | sys_getsetup: |
1769 | 1768 | ||
1770 | ; 1=roland mpu midi base , base io address |
1769 | ; 1=roland mpu midi base , base io address |
1771 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1770 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1772 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1771 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1773 | ; 5=system language, 1eng 2fi 3ger 4rus |
1772 | ; 5=system language, 1eng 2fi 3ger 4rus |
1774 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1773 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1775 | ; 8=fat32 partition in hd |
1774 | ; 8=fat32 partition in hd |
1776 | ; 9=get hs timer tic |
1775 | ; 9=get hs timer tic |
1777 | 1776 | ||
1778 | ; cmp eax,1 |
1777 | ; cmp eax,1 |
1779 | dec ebx |
1778 | dec ebx |
1780 | jnz ngsyse1 |
1779 | jnz ngsyse1 |
1781 | movzx eax, [midi_base] |
1780 | movzx eax, [midi_base] |
1782 | mov [esp+32], eax |
1781 | mov [esp+32], eax |
1783 | ret |
1782 | ret |
1784 | ngsyse1: |
1783 | ngsyse1: |
1785 | ; cmp eax,2 |
1784 | ; cmp eax,2 |
1786 | dec ebx |
1785 | dec ebx |
1787 | jnz ngsyse2 |
1786 | jnz ngsyse2 |
1788 | 1787 | ||
1789 | mov edi, [TASK_BASE] |
1788 | mov edi, [TASK_BASE] |
1790 | mov ebx, [edi+TASKDATA.mem_start] |
1789 | mov ebx, [edi+TASKDATA.mem_start] |
1791 | add ebx, edx |
1790 | add ebx, edx |
1792 | 1791 | ||
1793 | ; cmp ebx,1 |
1792 | ; cmp ebx,1 |
1794 | dec ecx |
1793 | dec ecx |
1795 | jnz kbnobaseret |
1794 | jnz kbnobaseret |
1796 | mov eax, keymap |
1795 | mov eax, keymap |
1797 | mov ecx, 128 |
1796 | mov ecx, 128 |
1798 | call memmove |
1797 | call memmove |
1799 | ret |
1798 | ret |
1800 | kbnobaseret: |
1799 | kbnobaseret: |
1801 | ; cmp ebx,2 |
1800 | ; cmp ebx,2 |
1802 | dec ecx |
1801 | dec ecx |
1803 | jnz kbnoshiftret |
1802 | jnz kbnoshiftret |
1804 | 1803 | ||
1805 | mov eax, keymap_shift |
1804 | mov eax, keymap_shift |
1806 | mov ecx, 128 |
1805 | mov ecx, 128 |
1807 | call memmove |
1806 | call memmove |
1808 | ret |
1807 | ret |
1809 | kbnoshiftret: |
1808 | kbnoshiftret: |
1810 | ; cmp ebx,3 |
1809 | ; cmp ebx,3 |
1811 | dec ecx |
1810 | dec ecx |
1812 | jne kbnoaltret |
1811 | jne kbnoaltret |
1813 | 1812 | ||
1814 | mov eax, keymap_alt |
1813 | mov eax, keymap_alt |
1815 | mov ecx, 128 |
1814 | mov ecx, 128 |
1816 | call memmove |
1815 | call memmove |
1817 | ret |
1816 | ret |
1818 | kbnoaltret: |
1817 | kbnoaltret: |
1819 | ; cmp ebx,9 |
1818 | ; cmp ebx,9 |
1820 | sub ecx, 6 |
1819 | sub ecx, 6 |
1821 | jnz ngsyse2 |
1820 | jnz ngsyse2 |
1822 | movzx eax, word [keyboard] |
1821 | movzx eax, word [keyboard] |
1823 | mov [esp+32], eax |
1822 | mov [esp+32], eax |
1824 | ret |
1823 | ret |
1825 | 1824 | ||
1826 | 1825 | ||
1827 | ngsyse2: |
1826 | ngsyse2: |
1828 | ; cmp eax,3 |
1827 | ; cmp eax,3 |
1829 | dec ebx |
1828 | dec ebx |
1830 | jnz ngsyse3 |
1829 | jnz ngsyse3 |
1831 | movzx eax, [cd_base] |
1830 | movzx eax, [cd_base] |
1832 | mov [esp+32], eax |
1831 | mov [esp+32], eax |
1833 | ret |
1832 | ret |
1834 | ngsyse3: |
1833 | ngsyse3: |
1835 | ; cmp eax,5 |
1834 | ; cmp eax,5 |
1836 | sub ebx, 2 |
1835 | sub ebx, 2 |
1837 | jnz ngsyse5 |
1836 | jnz ngsyse5 |
1838 | mov eax, [syslang] |
1837 | mov eax, [syslang] |
1839 | mov [esp+32], eax |
1838 | mov [esp+32], eax |
1840 | ret |
1839 | ret |
1841 | ngsyse5: |
1840 | ngsyse5: |
1842 | ; cmp eax,7 |
1841 | ; cmp eax,7 |
1843 | sub ebx, 2 |
1842 | sub ebx, 2 |
1844 | jnz ngsyse7 |
1843 | jnz ngsyse7 |
1845 | xor eax, eax |
1844 | xor eax, eax |
1846 | mov [esp+32], eax |
1845 | mov [esp+32], eax |
1847 | ret |
1846 | ret |
1848 | ngsyse7: |
1847 | ngsyse7: |
1849 | ; cmp eax,8 |
1848 | ; cmp eax,8 |
1850 | dec ebx |
1849 | dec ebx |
1851 | jnz ngsyse8 |
1850 | jnz ngsyse8 |
1852 | mov eax, [fat32part] |
1851 | mov eax, [fat32part] |
1853 | mov [esp+32], eax |
1852 | mov [esp+32], eax |
1854 | ret |
1853 | ret |
1855 | ngsyse8: |
1854 | ngsyse8: |
1856 | ; cmp eax,9 |
1855 | ; cmp eax,9 |
1857 | dec ebx |
1856 | dec ebx |
1858 | jnz ngsyse9 |
1857 | jnz ngsyse9 |
1859 | mov eax, [timer_ticks];[0xfdf0] |
1858 | mov eax, [timer_ticks];[0xfdf0] |
1860 | mov [esp+32], eax |
1859 | mov [esp+32], eax |
1861 | ret |
1860 | ret |
1862 | ngsyse9: |
1861 | ngsyse9: |
1863 | ; cmp eax,11 |
1862 | ; cmp eax,11 |
1864 | sub ebx, 2 |
1863 | sub ebx, 2 |
1865 | jnz ngsyse11 |
1864 | jnz ngsyse11 |
1866 | mov eax, [lba_read_enabled] |
1865 | mov eax, [lba_read_enabled] |
1867 | mov [esp+32], eax |
1866 | mov [esp+32], eax |
1868 | ret |
1867 | ret |
1869 | ngsyse11: |
1868 | ngsyse11: |
1870 | ; cmp eax,12 |
1869 | ; cmp eax,12 |
1871 | dec ebx |
1870 | dec ebx |
1872 | jnz ngsyse12 |
1871 | jnz ngsyse12 |
1873 | mov eax, [pci_access_enabled] |
1872 | mov eax, [pci_access_enabled] |
1874 | mov [esp+32], eax |
1873 | mov [esp+32], eax |
1875 | ret |
1874 | ret |
1876 | ngsyse12: |
1875 | ngsyse12: |
1877 | mov [esp+32], dword 1 |
1876 | mov [esp+32], dword 1 |
1878 | ret |
1877 | ret |
1879 | 1878 | ||
1880 | 1879 | ||
1881 | get_timer_ticks: |
1880 | get_timer_ticks: |
1882 | mov eax, [timer_ticks] |
1881 | mov eax, [timer_ticks] |
1883 | ret |
1882 | ret |
1884 | 1883 | ||
1885 | iglobal |
1884 | iglobal |
1886 | align 4 |
1885 | align 4 |
1887 | mousefn dd msscreen, mswin, msbutton, msset |
1886 | mousefn dd msscreen, mswin, msbutton, msset |
1888 | dd app_load_cursor |
1887 | dd app_load_cursor |
1889 | dd app_set_cursor |
1888 | dd app_set_cursor |
1890 | dd app_delete_cursor |
1889 | dd app_delete_cursor |
1891 | dd msz |
1890 | dd msz |
1892 | endg |
1891 | endg |
1893 | 1892 | ||
1894 | readmousepos: |
1893 | readmousepos: |
1895 | 1894 | ||
1896 | ; eax=0 screen relative |
1895 | ; eax=0 screen relative |
1897 | ; eax=1 window relative |
1896 | ; eax=1 window relative |
1898 | ; eax=2 buttons pressed |
1897 | ; eax=2 buttons pressed |
1899 | ; eax=3 set mouse pos ; reserved |
1898 | ; eax=3 set mouse pos ; reserved |
1900 | ; eax=4 load cursor |
1899 | ; eax=4 load cursor |
1901 | ; eax=5 set cursor |
1900 | ; eax=5 set cursor |
1902 | ; eax=6 delete cursor ; reserved |
1901 | ; eax=6 delete cursor ; reserved |
1903 | ; eax=7 get mouse_z |
1902 | ; eax=7 get mouse_z |
1904 | 1903 | ||
1905 | cmp ebx, 7 |
1904 | cmp ebx, 7 |
1906 | ja msset |
1905 | ja msset |
1907 | jmp [mousefn+ebx*4] |
1906 | jmp [mousefn+ebx*4] |
1908 | msscreen: |
1907 | msscreen: |
1909 | mov eax, [MOUSE_X] |
1908 | mov eax, [MOUSE_X] |
1910 | shl eax, 16 |
1909 | shl eax, 16 |
1911 | mov ax, [MOUSE_Y] |
1910 | mov ax, [MOUSE_Y] |
1912 | mov [esp+36-4], eax |
1911 | mov [esp+36-4], eax |
1913 | ret |
1912 | ret |
1914 | mswin: |
1913 | mswin: |
1915 | mov eax, [MOUSE_X] |
1914 | mov eax, [MOUSE_X] |
1916 | shl eax, 16 |
1915 | shl eax, 16 |
1917 | mov ax, [MOUSE_Y] |
1916 | mov ax, [MOUSE_Y] |
1918 | mov esi, [TASK_BASE] |
1917 | mov esi, [TASK_BASE] |
1919 | mov bx, word [esi-twdw+WDATA.box.left] |
1918 | mov bx, word [esi-twdw+WDATA.box.left] |
1920 | shl ebx, 16 |
1919 | shl ebx, 16 |
1921 | mov bx, word [esi-twdw+WDATA.box.top] |
1920 | mov bx, word [esi-twdw+WDATA.box.top] |
1922 | sub eax, ebx |
1921 | sub eax, ebx |
1923 | 1922 | ||
1924 | mov edi, [CURRENT_TASK] |
1923 | mov edi, [CURRENT_TASK] |
1925 | shl edi, 8 |
1924 | shl edi, 8 |
1926 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1925 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1927 | rol eax, 16 |
1926 | rol eax, 16 |
1928 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1927 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1929 | rol eax, 16 |
1928 | rol eax, 16 |
1930 | mov [esp+36-4], eax |
1929 | mov [esp+36-4], eax |
1931 | ret |
1930 | ret |
1932 | msbutton: |
1931 | msbutton: |
1933 | movzx eax, byte [BTN_DOWN] |
1932 | movzx eax, byte [BTN_DOWN] |
1934 | mov [esp+36-4], eax |
1933 | mov [esp+36-4], eax |
1935 | ret |
1934 | ret |
1936 | msz: |
1935 | msz: |
1937 | mov edi, [TASK_COUNT] |
1936 | mov edi, [TASK_COUNT] |
1938 | movzx edi, word [WIN_POS + edi*2] |
1937 | movzx edi, word [WIN_POS + edi*2] |
1939 | cmp edi, [CURRENT_TASK] |
1938 | cmp edi, [CURRENT_TASK] |
1940 | jne @f |
1939 | jne @f |
1941 | mov ax, [MOUSE_SCROLL_H] |
1940 | mov ax, [MOUSE_SCROLL_H] |
1942 | shl eax, 16 |
1941 | shl eax, 16 |
1943 | mov ax, [MOUSE_SCROLL_V] |
1942 | mov ax, [MOUSE_SCROLL_V] |
1944 | mov [esp+36-4], eax |
1943 | mov [esp+36-4], eax |
1945 | and [MOUSE_SCROLL_H], word 0 |
1944 | and [MOUSE_SCROLL_H], word 0 |
1946 | and [MOUSE_SCROLL_V], word 0 |
1945 | and [MOUSE_SCROLL_V], word 0 |
1947 | ret |
1946 | ret |
1948 | @@: |
1947 | @@: |
1949 | and [esp+36-4], dword 0 |
1948 | and [esp+36-4], dword 0 |
1950 | ; ret |
1949 | ; ret |
1951 | msset: |
1950 | msset: |
1952 | ret |
1951 | ret |
1953 | 1952 | ||
1954 | app_load_cursor: |
1953 | app_load_cursor: |
1955 | cmp ecx, OS_BASE |
1954 | cmp ecx, OS_BASE |
1956 | jae msset |
1955 | jae msset |
1957 | stdcall load_cursor, ecx, edx |
1956 | stdcall load_cursor, ecx, edx |
1958 | mov [esp+36-4], eax |
1957 | mov [esp+36-4], eax |
1959 | ret |
1958 | ret |
1960 | 1959 | ||
1961 | app_set_cursor: |
1960 | app_set_cursor: |
1962 | stdcall set_cursor, ecx |
1961 | stdcall set_cursor, ecx |
1963 | mov [esp+36-4], eax |
1962 | mov [esp+36-4], eax |
1964 | ret |
1963 | ret |
1965 | 1964 | ||
1966 | app_delete_cursor: |
1965 | app_delete_cursor: |
1967 | stdcall delete_cursor, ecx |
1966 | stdcall delete_cursor, ecx |
1968 | mov [esp+36-4], eax |
1967 | mov [esp+36-4], eax |
1969 | ret |
1968 | ret |
1970 | 1969 | ||
1971 | is_input: |
1970 | is_input: |
1972 | 1971 | ||
1973 | push edx |
1972 | push edx |
1974 | mov dx, word [midisp] |
1973 | mov dx, word [midisp] |
1975 | in al, dx |
1974 | in al, dx |
1976 | and al, 0x80 |
1975 | and al, 0x80 |
1977 | pop edx |
1976 | pop edx |
1978 | ret |
1977 | ret |
1979 | 1978 | ||
1980 | is_output: |
1979 | is_output: |
1981 | 1980 | ||
1982 | push edx |
1981 | push edx |
1983 | mov dx, word [midisp] |
1982 | mov dx, word [midisp] |
1984 | in al, dx |
1983 | in al, dx |
1985 | and al, 0x40 |
1984 | and al, 0x40 |
1986 | pop edx |
1985 | pop edx |
1987 | ret |
1986 | ret |
1988 | 1987 | ||
1989 | 1988 | ||
1990 | get_mpu_in: |
1989 | get_mpu_in: |
1991 | 1990 | ||
1992 | push edx |
1991 | push edx |
1993 | mov dx, word [mididp] |
1992 | mov dx, word [mididp] |
1994 | in al, dx |
1993 | in al, dx |
1995 | pop edx |
1994 | pop edx |
1996 | ret |
1995 | ret |
1997 | 1996 | ||
1998 | 1997 | ||
1999 | put_mpu_out: |
1998 | put_mpu_out: |
2000 | 1999 | ||
2001 | push edx |
2000 | push edx |
2002 | mov dx, word [mididp] |
2001 | mov dx, word [mididp] |
2003 | out dx, al |
2002 | out dx, al |
2004 | pop edx |
2003 | pop edx |
2005 | ret |
2004 | ret |
2006 | 2005 | ||
2007 | 2006 | ||
2008 | 2007 | ||
2009 | align 4 |
2008 | align 4 |
2010 | 2009 | ||
2011 | sys_midi: |
2010 | sys_midi: |
2012 | cmp [mididp], 0 |
2011 | cmp [mididp], 0 |
2013 | jnz sm0 |
2012 | jnz sm0 |
2014 | mov [esp+36], dword 1 |
2013 | mov [esp+36], dword 1 |
2015 | ret |
2014 | ret |
2016 | sm0: |
2015 | sm0: |
2017 | and [esp+36], dword 0 |
2016 | and [esp+36], dword 0 |
2018 | dec ebx |
2017 | dec ebx |
2019 | jnz smn1 |
2018 | jnz smn1 |
2020 | ; call setuart |
2019 | ; call setuart |
2021 | su1: |
2020 | su1: |
2022 | call is_output |
2021 | call is_output |
2023 | test al, al |
2022 | test al, al |
2024 | jnz su1 |
2023 | jnz su1 |
2025 | mov dx, word [midisp] |
2024 | mov dx, word [midisp] |
2026 | mov al, 0xff |
2025 | mov al, 0xff |
2027 | out dx, al |
2026 | out dx, al |
2028 | su2: |
2027 | su2: |
2029 | mov dx, word [midisp] |
2028 | mov dx, word [midisp] |
2030 | mov al, 0xff |
2029 | mov al, 0xff |
2031 | out dx, al |
2030 | out dx, al |
2032 | call is_input |
2031 | call is_input |
2033 | test al, al |
2032 | test al, al |
2034 | jnz su2 |
2033 | jnz su2 |
2035 | call get_mpu_in |
2034 | call get_mpu_in |
2036 | cmp al, 0xfe |
2035 | cmp al, 0xfe |
2037 | jnz su2 |
2036 | jnz su2 |
2038 | su3: |
2037 | su3: |
2039 | call is_output |
2038 | call is_output |
2040 | test al, al |
2039 | test al, al |
2041 | jnz su3 |
2040 | jnz su3 |
2042 | mov dx, word [midisp] |
2041 | mov dx, word [midisp] |
2043 | mov al, 0x3f |
2042 | mov al, 0x3f |
2044 | out dx, al |
2043 | out dx, al |
2045 | ret |
2044 | ret |
2046 | smn1: |
2045 | smn1: |
2047 | dec ebx |
2046 | dec ebx |
2048 | jnz smn2 |
2047 | jnz smn2 |
2049 | sm10: |
2048 | sm10: |
2050 | call get_mpu_in |
2049 | call get_mpu_in |
2051 | call is_output |
2050 | call is_output |
2052 | test al, al |
2051 | test al, al |
2053 | jnz sm10 |
2052 | jnz sm10 |
2054 | mov al, bl |
2053 | mov al, bl |
2055 | call put_mpu_out |
2054 | call put_mpu_out |
2056 | smn2: |
2055 | smn2: |
2057 | ret |
2056 | ret |
2058 | 2057 | ||
2059 | detect_devices: |
2058 | detect_devices: |
2060 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2059 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2061 | ;include 'detect/commouse.inc' |
2060 | ;include 'detect/commouse.inc' |
2062 | ;include 'detect/ps2mouse.inc' |
2061 | ;include 'detect/ps2mouse.inc' |
2063 | ;include 'detect/dev_fd.inc' |
2062 | ;include 'detect/dev_fd.inc' |
2064 | ;include 'detect/dev_hdcd.inc' |
2063 | ;include 'detect/dev_hdcd.inc' |
2065 | ;include 'detect/sear_par.inc' |
2064 | ;include 'detect/sear_par.inc' |
2066 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2065 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2067 | ret |
2066 | ret |
2068 | 2067 | ||
2069 | sys_end: |
2068 | sys_end: |
2070 | ;-------------------------------------- |
2069 | ;-------------------------------------- |
2071 | cmp [_display.select_cursor], 0 |
2070 | cmp [_display.select_cursor], 0 |
2072 | je @f |
2071 | je @f |
2073 | ; restore default cursor before killing |
2072 | ; restore default cursor before killing |
2074 | pusha |
2073 | pusha |
2075 | mov ecx, [current_slot] |
2074 | mov ecx, [current_slot] |
2076 | call restore_default_cursor_before_killing |
2075 | call restore_default_cursor_before_killing |
2077 | popa |
2076 | popa |
2078 | @@: |
2077 | @@: |
2079 | ;-------------------------------------- |
2078 | ;-------------------------------------- |
2080 | ; kill all sockets this process owns |
2079 | ; kill all sockets this process owns |
2081 | pusha |
2080 | pusha |
2082 | mov edx, [TASK_BASE] |
2081 | mov edx, [TASK_BASE] |
2083 | mov edx, [edx+TASKDATA.pid] |
2082 | mov edx, [edx+TASKDATA.pid] |
2084 | call SOCKET_process_end |
2083 | call SOCKET_process_end |
2085 | popa |
2084 | popa |
2086 | ;-------------------------------------- |
2085 | ;-------------------------------------- |
2087 | mov ecx, [current_slot] |
2086 | mov ecx, [current_slot] |
2088 | mov eax, [ecx+APPDATA.tls_base] |
2087 | mov eax, [ecx+APPDATA.tls_base] |
2089 | test eax, eax |
2088 | test eax, eax |
2090 | jz @F |
2089 | jz @F |
2091 | 2090 | ||
2092 | stdcall user_free, eax |
2091 | stdcall user_free, eax |
2093 | @@: |
2092 | @@: |
2094 | 2093 | ||
2095 | mov eax, [TASK_BASE] |
2094 | mov eax, [TASK_BASE] |
2096 | mov [eax+TASKDATA.state], 3; terminate this program |
2095 | mov [eax+TASKDATA.state], 3; terminate this program |
2097 | call wakeup_osloop |
2096 | call wakeup_osloop |
2098 | 2097 | ||
2099 | .waitterm: ; wait here for termination |
2098 | .waitterm: ; wait here for termination |
2100 | call change_task |
2099 | call change_task |
2101 | jmp .waitterm |
2100 | jmp .waitterm |
2102 | ;------------------------------------------------------------------------------ |
2101 | ;------------------------------------------------------------------------------ |
2103 | align 4 |
2102 | align 4 |
2104 | restore_default_cursor_before_killing: |
2103 | restore_default_cursor_before_killing: |
2105 | pushfd |
2104 | pushfd |
2106 | cli |
2105 | cli |
2107 | mov eax, [def_cursor] |
2106 | mov eax, [def_cursor] |
2108 | mov [ecx+APPDATA.cursor], eax |
2107 | mov [ecx+APPDATA.cursor], eax |
2109 | 2108 | ||
2110 | movzx eax, word [MOUSE_Y] |
2109 | movzx eax, word [MOUSE_Y] |
2111 | movzx ebx, word [MOUSE_X] |
2110 | movzx ebx, word [MOUSE_X] |
2112 | ; mov ecx, [Screen_Max_X] |
2111 | ; mov ecx, [Screen_Max_X] |
2113 | ; inc ecx |
2112 | ; inc ecx |
2114 | ; mul ecx |
2113 | ; mul ecx |
2115 | mov eax, [d_width_calc_area + eax*4] |
2114 | mov eax, [d_width_calc_area + eax*4] |
2116 | 2115 | ||
2117 | add eax, [_WinMapAddress] |
2116 | add eax, [_WinMapAddress] |
2118 | movzx edx, byte [ebx+eax] |
2117 | movzx edx, byte [ebx+eax] |
2119 | shl edx, 8 |
2118 | shl edx, 8 |
2120 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2119 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2121 | 2120 | ||
2122 | cmp esi, [current_cursor] |
2121 | cmp esi, [current_cursor] |
2123 | je @f |
2122 | je @f |
2124 | 2123 | ||
2125 | push esi |
2124 | push esi |
2126 | call [_display.select_cursor] |
2125 | call [_display.select_cursor] |
2127 | mov [current_cursor], esi |
2126 | mov [current_cursor], esi |
2128 | @@: |
2127 | @@: |
2129 | mov [redrawmouse_unconditional], 1 |
2128 | mov [redrawmouse_unconditional], 1 |
2130 | call wakeup_osloop |
2129 | call wakeup_osloop |
2131 | popfd |
2130 | popfd |
2132 | ret |
2131 | ret |
2133 | ;------------------------------------------------------------------------------ |
2132 | ;------------------------------------------------------------------------------ |
2134 | iglobal |
2133 | iglobal |
2135 | align 4 |
2134 | align 4 |
2136 | sys_system_table: |
2135 | sys_system_table: |
2137 | dd sysfn_deactivate ; 1 = deactivate window |
2136 | dd sysfn_deactivate ; 1 = deactivate window |
2138 | dd sysfn_terminate ; 2 = terminate thread |
2137 | dd sysfn_terminate ; 2 = terminate thread |
2139 | dd sysfn_activate ; 3 = activate window |
2138 | dd sysfn_activate ; 3 = activate window |
2140 | dd sysfn_getidletime ; 4 = get idle time |
2139 | dd sysfn_getidletime ; 4 = get idle time |
2141 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2140 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2142 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2141 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2143 | dd sysfn_getactive ; 7 = get active window |
2142 | dd sysfn_getactive ; 7 = get active window |
2144 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2143 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2145 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2144 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2146 | dd sysfn_minimize ; 10 = minimize window |
2145 | dd sysfn_minimize ; 10 = minimize window |
2147 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2146 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2148 | dd sysfn_lastkey ; 12 = get last pressed key |
2147 | dd sysfn_lastkey ; 12 = get last pressed key |
2149 | dd sysfn_getversion ; 13 = get kernel version |
2148 | dd sysfn_getversion ; 13 = get kernel version |
2150 | dd sysfn_waitretrace ; 14 = wait retrace |
2149 | dd sysfn_waitretrace ; 14 = wait retrace |
2151 | dd sysfn_centermouse ; 15 = center mouse cursor |
2150 | dd sysfn_centermouse ; 15 = center mouse cursor |
2152 | dd sysfn_getfreemem ; 16 = get free memory size |
2151 | dd sysfn_getfreemem ; 16 = get free memory size |
2153 | dd sysfn_getallmem ; 17 = get total memory size |
2152 | dd sysfn_getallmem ; 17 = get total memory size |
2154 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2153 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2155 | ; instead of slot |
2154 | ; instead of slot |
2156 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2155 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2157 | dd sysfn_meminfo ; 20 = get extended memory info |
2156 | dd sysfn_meminfo ; 20 = get extended memory info |
2158 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2157 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2159 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2158 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2160 | dd sysfn_min_windows ; 23 = minimize all windows |
2159 | dd sysfn_min_windows ; 23 = minimize all windows |
2161 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2160 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2162 | sysfn_num = ($ - sys_system_table)/4 |
2161 | sysfn_num = ($ - sys_system_table)/4 |
2163 | endg |
2162 | endg |
2164 | ;------------------------------------------------------------------------------ |
2163 | ;------------------------------------------------------------------------------ |
2165 | sys_system: |
2164 | sys_system: |
2166 | dec ebx |
2165 | dec ebx |
2167 | cmp ebx, sysfn_num |
2166 | cmp ebx, sysfn_num |
2168 | jae @f |
2167 | jae @f |
2169 | jmp dword [sys_system_table + ebx*4] |
2168 | jmp dword [sys_system_table + ebx*4] |
2170 | @@: |
2169 | @@: |
2171 | ret |
2170 | ret |
2172 | ;------------------------------------------------------------------------------ |
2171 | ;------------------------------------------------------------------------------ |
2173 | sysfn_shutdown: ; 18.9 = system shutdown |
2172 | sysfn_shutdown: ; 18.9 = system shutdown |
2174 | cmp ecx, 1 |
2173 | cmp ecx, 1 |
2175 | jl exit_for_anyone |
2174 | jl exit_for_anyone |
2176 | cmp ecx, 4 |
2175 | cmp ecx, 4 |
2177 | jg exit_for_anyone |
2176 | jg exit_for_anyone |
2178 | mov [BOOT_VARS+0x9030], cl |
2177 | mov [BOOT_VARS+0x9030], cl |
2179 | 2178 | ||
2180 | mov eax, [TASK_COUNT] |
2179 | mov eax, [TASK_COUNT] |
2181 | mov [SYS_SHUTDOWN], al |
2180 | mov [SYS_SHUTDOWN], al |
2182 | mov [shutdown_processes], eax |
2181 | mov [shutdown_processes], eax |
2183 | call wakeup_osloop |
2182 | call wakeup_osloop |
2184 | and dword [esp+32], 0 |
2183 | and dword [esp+32], 0 |
2185 | exit_for_anyone: |
2184 | exit_for_anyone: |
2186 | ret |
2185 | ret |
2187 | uglobal |
2186 | uglobal |
2188 | shutdown_processes: |
2187 | shutdown_processes: |
2189 | dd 0x0 |
2188 | dd 0x0 |
2190 | endg |
2189 | endg |
2191 | ;------------------------------------------------------------------------------ |
2190 | ;------------------------------------------------------------------------------ |
2192 | sysfn_terminate: ; 18.2 = TERMINATE |
2191 | sysfn_terminate: ; 18.2 = TERMINATE |
2193 | push ecx |
2192 | push ecx |
2194 | cmp ecx, 2 |
2193 | cmp ecx, 2 |
2195 | jb noprocessterminate |
2194 | jb noprocessterminate |
2196 | mov edx, [TASK_COUNT] |
2195 | mov edx, [TASK_COUNT] |
2197 | cmp ecx, edx |
2196 | cmp ecx, edx |
2198 | ja noprocessterminate |
2197 | ja noprocessterminate |
2199 | mov eax, [TASK_COUNT] |
2198 | mov eax, [TASK_COUNT] |
2200 | shl ecx, 5 |
2199 | shl ecx, 5 |
2201 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2200 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2202 | add ecx, CURRENT_TASK+TASKDATA.state |
2201 | add ecx, CURRENT_TASK+TASKDATA.state |
2203 | cmp byte [ecx], 9 |
2202 | cmp byte [ecx], 9 |
2204 | jz noprocessterminate |
2203 | jz noprocessterminate |
2205 | push ecx edx |
2204 | push ecx edx |
2206 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2205 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2207 | call request_terminate |
2206 | call request_terminate |
2208 | pop edx ecx |
2207 | pop edx ecx |
2209 | test eax, eax |
2208 | test eax, eax |
2210 | jz noprocessterminate |
2209 | jz noprocessterminate |
2211 | ;-------------------------------------- |
2210 | ;-------------------------------------- |
2212 | ; terminate all network sockets it used |
2211 | ; terminate all network sockets it used |
2213 | pusha |
2212 | pusha |
2214 | mov eax, edx |
2213 | mov eax, edx |
2215 | call SOCKET_process_end |
2214 | call SOCKET_process_end |
2216 | popa |
2215 | popa |
2217 | ;-------------------------------------- |
2216 | ;-------------------------------------- |
2218 | cmp [_display.select_cursor], 0 |
2217 | cmp [_display.select_cursor], 0 |
2219 | je .restore_end |
2218 | je .restore_end |
2220 | ; restore default cursor before killing |
2219 | ; restore default cursor before killing |
2221 | pusha |
2220 | pusha |
2222 | mov ecx, [esp+32] |
2221 | mov ecx, [esp+32] |
2223 | shl ecx, 8 |
2222 | shl ecx, 8 |
2224 | add ecx, SLOT_BASE |
2223 | add ecx, SLOT_BASE |
2225 | mov eax, [def_cursor] |
2224 | mov eax, [def_cursor] |
2226 | cmp [ecx+APPDATA.cursor], eax |
2225 | cmp [ecx+APPDATA.cursor], eax |
2227 | je @f |
2226 | je @f |
2228 | call restore_default_cursor_before_killing |
2227 | call restore_default_cursor_before_killing |
2229 | @@: |
2228 | @@: |
2230 | popa |
2229 | popa |
2231 | .restore_end: |
2230 | .restore_end: |
2232 | ;-------------------------------------- |
2231 | ;-------------------------------------- |
2233 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2232 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2234 | mov [ecx], byte 3; clear possible i40's |
2233 | mov [ecx], byte 3; clear possible i40's |
2235 | call wakeup_osloop |
2234 | call wakeup_osloop |
2236 | ;call MEM_Heap_UnLock |
2235 | ;call MEM_Heap_UnLock |
2237 | 2236 | ||
2238 | cmp edx, [application_table_owner]; clear app table stat |
2237 | cmp edx, [application_table_owner]; clear app table stat |
2239 | jne noatsc |
2238 | jne noatsc |
2240 | call unlock_application_table |
2239 | call unlock_application_table |
2241 | noatsc: |
2240 | noatsc: |
2242 | noprocessterminate: |
2241 | noprocessterminate: |
2243 | add esp, 4 |
2242 | add esp, 4 |
2244 | ret |
2243 | ret |
2245 | ;------------------------------------------------------------------------------ |
2244 | ;------------------------------------------------------------------------------ |
2246 | sysfn_terminate2: |
2245 | sysfn_terminate2: |
2247 | ;lock application_table_status mutex |
2246 | ;lock application_table_status mutex |
2248 | .table_status: |
2247 | .table_status: |
2249 | call lock_application_table |
2248 | call lock_application_table |
2250 | mov eax, ecx |
2249 | mov eax, ecx |
2251 | call pid_to_slot |
2250 | call pid_to_slot |
2252 | test eax, eax |
2251 | test eax, eax |
2253 | jz .not_found |
2252 | jz .not_found |
2254 | mov ecx, eax |
2253 | mov ecx, eax |
2255 | cli |
2254 | cli |
2256 | call sysfn_terminate |
2255 | call sysfn_terminate |
2257 | call unlock_application_table |
2256 | call unlock_application_table |
2258 | sti |
2257 | sti |
2259 | and dword [esp+32], 0 |
2258 | and dword [esp+32], 0 |
2260 | ret |
2259 | ret |
2261 | .not_found: |
2260 | .not_found: |
2262 | call unlock_application_table |
2261 | call unlock_application_table |
2263 | or dword [esp+32], -1 |
2262 | or dword [esp+32], -1 |
2264 | ret |
2263 | ret |
2265 | ;------------------------------------------------------------------------------ |
2264 | ;------------------------------------------------------------------------------ |
2266 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2265 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2267 | cmp ecx, 2 |
2266 | cmp ecx, 2 |
2268 | jb .nowindowdeactivate |
2267 | jb .nowindowdeactivate |
2269 | cmp ecx, [TASK_COUNT] |
2268 | cmp ecx, [TASK_COUNT] |
2270 | ja .nowindowdeactivate |
2269 | ja .nowindowdeactivate |
2271 | 2270 | ||
2272 | movzx esi, word [WIN_STACK + ecx*2] |
2271 | movzx esi, word [WIN_STACK + ecx*2] |
2273 | cmp esi, 1 |
2272 | cmp esi, 1 |
2274 | je .nowindowdeactivate ; already deactive |
2273 | je .nowindowdeactivate ; already deactive |
2275 | 2274 | ||
2276 | mov edi, ecx |
2275 | mov edi, ecx |
2277 | shl edi, 5 |
2276 | shl edi, 5 |
2278 | add edi, window_data |
2277 | add edi, window_data |
2279 | movzx esi, word [WIN_STACK + ecx * 2] |
2278 | movzx esi, word [WIN_STACK + ecx * 2] |
2280 | lea esi, [WIN_POS + esi * 2] |
2279 | lea esi, [WIN_POS + esi * 2] |
2281 | call window._.window_deactivate |
2280 | call window._.window_deactivate |
2282 | 2281 | ||
2283 | call syscall_display_settings._.calculate_whole_screen |
2282 | call syscall_display_settings._.calculate_whole_screen |
2284 | call syscall_display_settings._.redraw_whole_screen |
2283 | call syscall_display_settings._.redraw_whole_screen |
2285 | .nowindowdeactivate: |
2284 | .nowindowdeactivate: |
2286 | ret |
2285 | ret |
2287 | ;------------------------------------------------------------------------------ |
2286 | ;------------------------------------------------------------------------------ |
2288 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2287 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2289 | cmp ecx, 2 |
2288 | cmp ecx, 2 |
2290 | jb .nowindowactivate |
2289 | jb .nowindowactivate |
2291 | cmp ecx, [TASK_COUNT] |
2290 | cmp ecx, [TASK_COUNT] |
2292 | ja .nowindowactivate |
2291 | ja .nowindowactivate |
2293 | ;------------------------------------- |
2292 | ;------------------------------------- |
2294 | @@: |
2293 | @@: |
2295 | ; If the window is captured and moved by the user, |
2294 | ; If the window is captured and moved by the user, |
2296 | ; then you can't change the position in window stack!!! |
2295 | ; then you can't change the position in window stack!!! |
2297 | mov al, [mouse.active_sys_window.action] |
2296 | mov al, [mouse.active_sys_window.action] |
2298 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2297 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2299 | test al, al |
2298 | test al, al |
2300 | jz @f |
2299 | jz @f |
2301 | call change_task |
2300 | call change_task |
2302 | jmp @b |
2301 | jmp @b |
2303 | @@: |
2302 | @@: |
2304 | ;------------------------------------- |
2303 | ;------------------------------------- |
2305 | mov [window_minimize], 2; restore window if minimized |
2304 | mov [window_minimize], 2; restore window if minimized |
2306 | call wakeup_osloop |
2305 | call wakeup_osloop |
2307 | 2306 | ||
2308 | movzx esi, word [WIN_STACK + ecx*2] |
2307 | movzx esi, word [WIN_STACK + ecx*2] |
2309 | cmp esi, [TASK_COUNT] |
2308 | cmp esi, [TASK_COUNT] |
2310 | je .nowindowactivate; already active |
2309 | je .nowindowactivate; already active |
2311 | 2310 | ||
2312 | mov edi, ecx |
2311 | mov edi, ecx |
2313 | shl edi, 5 |
2312 | shl edi, 5 |
2314 | add edi, window_data |
2313 | add edi, window_data |
2315 | movzx esi, word [WIN_STACK + ecx * 2] |
2314 | movzx esi, word [WIN_STACK + ecx * 2] |
2316 | lea esi, [WIN_POS + esi * 2] |
2315 | lea esi, [WIN_POS + esi * 2] |
2317 | call waredraw |
2316 | call waredraw |
2318 | .nowindowactivate: |
2317 | .nowindowactivate: |
2319 | ret |
2318 | ret |
2320 | ;------------------------------------------------------------------------------ |
2319 | ;------------------------------------------------------------------------------ |
2321 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2320 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2322 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2321 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2323 | mov [esp+32], eax |
2322 | mov [esp+32], eax |
2324 | ret |
2323 | ret |
2325 | ;------------------------------------------------------------------------------ |
2324 | ;------------------------------------------------------------------------------ |
2326 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2325 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2327 | mov eax, dword [cpu_freq] |
2326 | mov eax, dword [cpu_freq] |
2328 | mov [esp+32], eax |
2327 | mov [esp+32], eax |
2329 | ret |
2328 | ret |
2330 | ;------------------------------------------------------------------------------ |
2329 | ;------------------------------------------------------------------------------ |
2331 | get_cpu_freq: |
2330 | get_cpu_freq: |
2332 | mov eax, dword [cpu_freq] |
2331 | mov eax, dword [cpu_freq] |
2333 | mov edx, dword [cpu_freq+4] |
2332 | mov edx, dword [cpu_freq+4] |
2334 | ret |
2333 | ret |
2335 | ; SAVE ramdisk to /hd/1/menuet.img |
2334 | ; SAVE ramdisk to /hd/1/menuet.img |
2336 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2335 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2337 | include 'blkdev/rdsave.inc' |
2336 | include 'blkdev/rdsave.inc' |
2338 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2337 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2339 | ;------------------------------------------------------------------------------ |
2338 | ;------------------------------------------------------------------------------ |
2340 | align 4 |
2339 | align 4 |
2341 | sysfn_getactive: ; 18.7 = get active window |
2340 | sysfn_getactive: ; 18.7 = get active window |
2342 | mov eax, [TASK_COUNT] |
2341 | mov eax, [TASK_COUNT] |
2343 | movzx eax, word [WIN_POS + eax*2] |
2342 | movzx eax, word [WIN_POS + eax*2] |
2344 | mov [esp+32], eax |
2343 | mov [esp+32], eax |
2345 | ret |
2344 | ret |
2346 | ;------------------------------------------------------------------------------ |
2345 | ;------------------------------------------------------------------------------ |
2347 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2346 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2348 | ; cmp ecx,1 |
2347 | ; cmp ecx,1 |
2349 | dec ecx |
2348 | dec ecx |
2350 | jnz nogetsoundflag |
2349 | jnz nogetsoundflag |
2351 | movzx eax, byte [sound_flag]; get sound_flag |
2350 | movzx eax, byte [sound_flag]; get sound_flag |
2352 | mov [esp+32], eax |
2351 | mov [esp+32], eax |
2353 | ret |
2352 | ret |
2354 | nogetsoundflag: |
2353 | nogetsoundflag: |
2355 | ; cmp ecx,2 |
2354 | ; cmp ecx,2 |
2356 | dec ecx |
2355 | dec ecx |
2357 | jnz nosoundflag |
2356 | jnz nosoundflag |
2358 | xor byte [sound_flag], 1 |
2357 | xor byte [sound_flag], 1 |
2359 | nosoundflag: |
2358 | nosoundflag: |
2360 | ret |
2359 | ret |
2361 | ;------------------------------------------------------------------------------ |
2360 | ;------------------------------------------------------------------------------ |
2362 | sysfn_minimize: ; 18.10 = minimize window |
2361 | sysfn_minimize: ; 18.10 = minimize window |
2363 | mov [window_minimize], 1 |
2362 | mov [window_minimize], 1 |
2364 | call wakeup_osloop |
2363 | call wakeup_osloop |
2365 | ret |
2364 | ret |
2366 | ;------------------------------------------------------------------------------ |
2365 | ;------------------------------------------------------------------------------ |
2367 | align 4 |
2366 | align 4 |
2368 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2367 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2369 | ; cmp ecx,1 |
2368 | ; cmp ecx,1 |
2370 | dec ecx |
2369 | dec ecx |
2371 | jnz full_table |
2370 | jnz full_table |
2372 | small_table: |
2371 | small_table: |
2373 | call for_all_tables |
2372 | call for_all_tables |
2374 | mov ecx, 10 |
2373 | mov ecx, 10 |
2375 | cld |
2374 | cld |
2376 | rep movsb |
2375 | rep movsb |
2377 | ret |
2376 | ret |
2378 | for_all_tables: |
2377 | for_all_tables: |
2379 | mov edi, edx |
2378 | mov edi, edx |
2380 | mov esi, DRIVE_DATA |
2379 | mov esi, DRIVE_DATA |
2381 | ret |
2380 | ret |
2382 | full_table: |
2381 | full_table: |
2383 | ; cmp ecx,2 |
2382 | ; cmp ecx,2 |
2384 | dec ecx |
2383 | dec ecx |
2385 | jnz exit_for_anyone |
2384 | jnz exit_for_anyone |
2386 | call for_all_tables |
2385 | call for_all_tables |
2387 | mov ecx, DRIVE_DATA_SIZE/4 |
2386 | mov ecx, DRIVE_DATA_SIZE/4 |
2388 | cld |
2387 | cld |
2389 | rep movsd |
2388 | rep movsd |
2390 | ret |
2389 | ret |
2391 | ;------------------------------------------------------------------------------ |
2390 | ;------------------------------------------------------------------------------ |
2392 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2391 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2393 | and dword [esp+32], 0 |
2392 | and dword [esp+32], 0 |
2394 | ret |
2393 | ret |
2395 | ;------------------------------------------------------------------------------ |
2394 | ;------------------------------------------------------------------------------ |
2396 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2395 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2397 | mov edi, ecx |
2396 | mov edi, ecx |
2398 | mov esi, version_inf |
2397 | mov esi, version_inf |
2399 | mov ecx, version_end-version_inf |
2398 | mov ecx, version_end-version_inf |
2400 | rep movsb |
2399 | rep movsb |
2401 | ret |
2400 | ret |
2402 | ;------------------------------------------------------------------------------ |
2401 | ;------------------------------------------------------------------------------ |
2403 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2402 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2404 | ;wait retrace functions |
2403 | ;wait retrace functions |
2405 | sys_wait_retrace: |
2404 | sys_wait_retrace: |
2406 | mov edx, 0x3da |
2405 | mov edx, 0x3da |
2407 | WaitRetrace_loop: |
2406 | WaitRetrace_loop: |
2408 | in al, dx |
2407 | in al, dx |
2409 | test al, 1000b |
2408 | test al, 1000b |
2410 | jz WaitRetrace_loop |
2409 | jz WaitRetrace_loop |
2411 | and [esp+32], dword 0 |
2410 | and [esp+32], dword 0 |
2412 | ret |
2411 | ret |
2413 | ;------------------------------------------------------------------------------ |
2412 | ;------------------------------------------------------------------------------ |
2414 | align 4 |
2413 | align 4 |
2415 | sysfn_centermouse: ; 18.15 = mouse centered |
2414 | sysfn_centermouse: ; 18.15 = mouse centered |
2416 | ; removed here by |
2415 | ; removed here by |
2417 | ; call mouse_centered |
2416 | ; call mouse_centered |
2418 | ;* mouse centered - start code- Mario79 |
2417 | ;* mouse centered - start code- Mario79 |
2419 | ;mouse_centered: |
2418 | ;mouse_centered: |
2420 | ; push eax |
2419 | ; push eax |
2421 | mov eax, [Screen_Max_X] |
2420 | mov eax, [Screen_Max_X] |
2422 | shr eax, 1 |
2421 | shr eax, 1 |
2423 | mov [MOUSE_X], ax |
2422 | mov [MOUSE_X], ax |
2424 | mov eax, [Screen_Max_Y] |
2423 | mov eax, [Screen_Max_Y] |
2425 | shr eax, 1 |
2424 | shr eax, 1 |
2426 | mov [MOUSE_Y], ax |
2425 | mov [MOUSE_Y], ax |
2427 | call wakeup_osloop |
2426 | call wakeup_osloop |
2428 | ; ret |
2427 | ; ret |
2429 | ;* mouse centered - end code- Mario79 |
2428 | ;* mouse centered - end code- Mario79 |
2430 | xor eax, eax |
2429 | xor eax, eax |
2431 | and [esp+32], eax |
2430 | and [esp+32], eax |
2432 | ; pop eax |
2431 | ; pop eax |
2433 | ret |
2432 | ret |
2434 | ;------------------------------------------------------------------------------ |
2433 | ;------------------------------------------------------------------------------ |
2435 | align 4 |
2434 | align 4 |
2436 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2435 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2437 | test ecx, ecx; get mouse speed factor |
2436 | test ecx, ecx; get mouse speed factor |
2438 | jnz .set_mouse_acceleration |
2437 | jnz .set_mouse_acceleration |
2439 | xor eax, eax |
2438 | xor eax, eax |
2440 | mov ax, [mouse_speed_factor] |
2439 | mov ax, [mouse_speed_factor] |
2441 | mov [esp+32], eax |
2440 | mov [esp+32], eax |
2442 | ret |
2441 | ret |
2443 | .set_mouse_acceleration: |
2442 | .set_mouse_acceleration: |
2444 | ; cmp ecx,1 ; set mouse speed factor |
2443 | ; cmp ecx,1 ; set mouse speed factor |
2445 | dec ecx |
2444 | dec ecx |
2446 | jnz .get_mouse_delay |
2445 | jnz .get_mouse_delay |
2447 | mov [mouse_speed_factor], dx |
2446 | mov [mouse_speed_factor], dx |
2448 | ret |
2447 | ret |
2449 | .get_mouse_delay: |
2448 | .get_mouse_delay: |
2450 | ; cmp ecx,2 ; get mouse delay |
2449 | ; cmp ecx,2 ; get mouse delay |
2451 | dec ecx |
2450 | dec ecx |
2452 | jnz .set_mouse_delay |
2451 | jnz .set_mouse_delay |
2453 | mov eax, [mouse_delay] |
2452 | mov eax, [mouse_delay] |
2454 | mov [esp+32], eax |
2453 | mov [esp+32], eax |
2455 | ret |
2454 | ret |
2456 | .set_mouse_delay: |
2455 | .set_mouse_delay: |
2457 | ; cmp ecx,3 ; set mouse delay |
2456 | ; cmp ecx,3 ; set mouse delay |
2458 | dec ecx |
2457 | dec ecx |
2459 | jnz .set_pointer_position |
2458 | jnz .set_pointer_position |
2460 | mov [mouse_delay], edx |
2459 | mov [mouse_delay], edx |
2461 | ret |
2460 | ret |
2462 | .set_pointer_position: |
2461 | .set_pointer_position: |
2463 | ; cmp ecx,4 ; set mouse pointer position |
2462 | ; cmp ecx,4 ; set mouse pointer position |
2464 | dec ecx |
2463 | dec ecx |
2465 | jnz .set_mouse_button |
2464 | jnz .set_mouse_button |
2466 | cmp dx, word[Screen_Max_Y] |
2465 | cmp dx, word[Screen_Max_Y] |
2467 | ja .end |
2466 | ja .end |
2468 | rol edx, 16 |
2467 | rol edx, 16 |
2469 | cmp dx, word[Screen_Max_X] |
2468 | cmp dx, word[Screen_Max_X] |
2470 | ja .end |
2469 | ja .end |
2471 | mov [MOUSE_X], edx |
2470 | mov [MOUSE_X], edx |
2472 | call wakeup_osloop |
2471 | call wakeup_osloop |
2473 | ret |
2472 | ret |
2474 | .set_mouse_button: |
2473 | .set_mouse_button: |
2475 | ; cmp ecx,5 ; set mouse button features |
2474 | ; cmp ecx,5 ; set mouse button features |
2476 | dec ecx |
2475 | dec ecx |
2477 | jnz .end |
2476 | jnz .end |
2478 | mov [BTN_DOWN], dl |
2477 | mov [BTN_DOWN], dl |
2479 | mov [mouse_active], 1 |
2478 | mov [mouse_active], 1 |
2480 | call wakeup_osloop |
2479 | call wakeup_osloop |
2481 | .end: |
2480 | .end: |
2482 | ret |
2481 | ret |
2483 | ;------------------------------------------------------------------------------ |
2482 | ;------------------------------------------------------------------------------ |
2484 | sysfn_getfreemem: |
2483 | sysfn_getfreemem: |
2485 | mov eax, [pg_data.pages_free] |
2484 | mov eax, [pg_data.pages_free] |
2486 | shl eax, 2 |
2485 | shl eax, 2 |
2487 | mov [esp+32], eax |
2486 | mov [esp+32], eax |
2488 | ret |
2487 | ret |
2489 | ;------------------------------------------------------------------------------ |
2488 | ;------------------------------------------------------------------------------ |
2490 | sysfn_getallmem: |
2489 | sysfn_getallmem: |
2491 | mov eax, [MEM_AMOUNT] |
2490 | mov eax, [MEM_AMOUNT] |
2492 | shr eax, 10 |
2491 | shr eax, 10 |
2493 | mov [esp+32], eax |
2492 | mov [esp+32], eax |
2494 | ret |
2493 | ret |
2495 | ;------------------------------------------------------------------------------ |
2494 | ;------------------------------------------------------------------------------ |
2496 | sysfn_pid_to_slot: |
2495 | sysfn_pid_to_slot: |
2497 | mov eax, ecx |
2496 | mov eax, ecx |
2498 | call pid_to_slot |
2497 | call pid_to_slot |
2499 | mov [esp+32], eax |
2498 | mov [esp+32], eax |
2500 | ret |
2499 | ret |
2501 | ;------------------------------------------------------------------------------ |
2500 | ;------------------------------------------------------------------------------ |
2502 | sysfn_min_rest_window: |
2501 | sysfn_min_rest_window: |
2503 | pushad |
2502 | pushad |
2504 | mov eax, edx ; ebx - operating |
2503 | mov eax, edx ; ebx - operating |
2505 | shr ecx, 1 |
2504 | shr ecx, 1 |
2506 | jnc @f |
2505 | jnc @f |
2507 | call pid_to_slot |
2506 | call pid_to_slot |
2508 | @@: |
2507 | @@: |
2509 | or eax, eax ; eax - number of slot |
2508 | or eax, eax ; eax - number of slot |
2510 | jz .error |
2509 | jz .error |
2511 | cmp eax, 255 ; varify maximal slot number |
2510 | cmp eax, 255 ; varify maximal slot number |
2512 | ja .error |
2511 | ja .error |
2513 | movzx eax, word [WIN_STACK + eax*2] |
2512 | movzx eax, word [WIN_STACK + eax*2] |
2514 | shr ecx, 1 |
2513 | shr ecx, 1 |
2515 | jc .restore |
2514 | jc .restore |
2516 | ; .minimize: |
2515 | ; .minimize: |
2517 | call minimize_window |
2516 | call minimize_window |
2518 | jmp .exit |
2517 | jmp .exit |
2519 | .restore: |
2518 | .restore: |
2520 | call restore_minimized_window |
2519 | call restore_minimized_window |
2521 | .exit: |
2520 | .exit: |
2522 | popad |
2521 | popad |
2523 | xor eax, eax |
2522 | xor eax, eax |
2524 | mov [esp+32], eax |
2523 | mov [esp+32], eax |
2525 | ret |
2524 | ret |
2526 | .error: |
2525 | .error: |
2527 | popad |
2526 | popad |
2528 | xor eax, eax |
2527 | xor eax, eax |
2529 | dec eax |
2528 | dec eax |
2530 | mov [esp+32], eax |
2529 | mov [esp+32], eax |
2531 | ret |
2530 | ret |
2532 | ;------------------------------------------------------------------------------ |
2531 | ;------------------------------------------------------------------------------ |
2533 | sysfn_min_windows: |
2532 | sysfn_min_windows: |
2534 | call minimize_all_window |
2533 | call minimize_all_window |
2535 | mov [esp+32], eax |
2534 | mov [esp+32], eax |
2536 | call change_task |
2535 | call change_task |
2537 | ret |
2536 | ret |
2538 | ;------------------------------------------------------------------------------ |
2537 | ;------------------------------------------------------------------------------ |
2539 | sysfn_set_screen_sizes: |
2538 | sysfn_set_screen_sizes: |
2540 | cmp [SCR_MODE], word 0x13 |
2539 | cmp [SCR_MODE], word 0x13 |
2541 | jbe .exit |
2540 | jbe .exit |
2542 | 2541 | ||
2543 | cmp [_display.select_cursor], select_cursor |
2542 | cmp [_display.select_cursor], select_cursor |
2544 | jne .exit |
2543 | jne .exit |
2545 | 2544 | ||
2546 | cmp ecx, [display_width_standard] |
2545 | cmp ecx, [display_width_standard] |
2547 | ja .exit |
2546 | ja .exit |
2548 | 2547 | ||
2549 | cmp edx, [display_height_standard] |
2548 | cmp edx, [display_height_standard] |
2550 | ja .exit |
2549 | ja .exit |
2551 | 2550 | ||
2552 | pushfd |
2551 | pushfd |
2553 | cli |
2552 | cli |
2554 | mov eax, ecx |
2553 | mov eax, ecx |
2555 | mov ecx, [_display.pitch] |
2554 | mov ecx, [_display.pitch] |
2556 | mov [_display.width], eax |
2555 | mov [_display.width], eax |
2557 | dec eax |
2556 | dec eax |
2558 | mov [_display.height], edx |
2557 | mov [_display.height], edx |
2559 | dec edx |
2558 | dec edx |
2560 | ; eax - new Screen_Max_X |
2559 | ; eax - new Screen_Max_X |
2561 | ; edx - new Screen_Max_Y |
2560 | ; edx - new Screen_Max_Y |
2562 | mov [do_not_touch_winmap], 1 |
2561 | mov [do_not_touch_winmap], 1 |
2563 | call set_screen |
2562 | call set_screen |
2564 | mov [do_not_touch_winmap], 0 |
2563 | mov [do_not_touch_winmap], 0 |
2565 | popfd |
2564 | popfd |
2566 | call change_task |
2565 | call change_task |
2567 | .exit: |
2566 | .exit: |
2568 | ret |
2567 | ret |
2569 | ;------------------------------------------------------------------------------ |
2568 | ;------------------------------------------------------------------------------ |
2570 | uglobal |
2569 | uglobal |
2571 | screen_workarea RECT |
2570 | screen_workarea RECT |
2572 | display_width_standard dd 0 |
2571 | display_width_standard dd 0 |
2573 | display_height_standard dd 0 |
2572 | display_height_standard dd 0 |
2574 | do_not_touch_winmap db 0 |
2573 | do_not_touch_winmap db 0 |
2575 | window_minimize db 0 |
2574 | window_minimize db 0 |
2576 | sound_flag db 0 |
2575 | sound_flag db 0 |
2577 | 2576 | ||
2578 | endg |
2577 | endg |
2579 | 2578 | ||
2580 | UID_NONE=0 |
2579 | UID_NONE=0 |
2581 | UID_MENUETOS=1 ;official |
2580 | UID_MENUETOS=1 ;official |
2582 | UID_KOLIBRI=2 ;russian |
2581 | UID_KOLIBRI=2 ;russian |
2583 | 2582 | ||
2584 | iglobal |
2583 | iglobal |
2585 | version_inf: |
2584 | version_inf: |
2586 | db 0,7,7,0 ; version 0.7.7.0 |
2585 | db 0,7,7,0 ; version 0.7.7.0 |
2587 | db 0 |
2586 | db 0 |
2588 | .rev dd __REV__ |
2587 | .rev dd __REV__ |
2589 | version_end: |
2588 | version_end: |
2590 | endg |
2589 | endg |
2591 | ;------------------------------------------------------------------------------ |
2590 | ;------------------------------------------------------------------------------ |
2592 | align 4 |
2591 | align 4 |
2593 | sys_cachetodiskette: |
2592 | sys_cachetodiskette: |
2594 | cmp ebx, 1 |
2593 | cmp ebx, 1 |
2595 | jne .no_floppy_a_save |
2594 | jne .no_floppy_a_save |
2596 | mov [flp_number], 1 |
2595 | mov [flp_number], 1 |
2597 | jmp .save_image_on_floppy |
2596 | jmp .save_image_on_floppy |
2598 | ;-------------------------------------- |
2597 | ;-------------------------------------- |
2599 | align 4 |
2598 | align 4 |
2600 | .no_floppy_a_save: |
2599 | .no_floppy_a_save: |
2601 | cmp ebx, 2 |
2600 | cmp ebx, 2 |
2602 | jne .no_floppy_b_save |
2601 | jne .no_floppy_b_save |
2603 | mov [flp_number], 2 |
2602 | mov [flp_number], 2 |
2604 | ;-------------------------------------- |
2603 | ;-------------------------------------- |
2605 | align 4 |
2604 | align 4 |
2606 | .save_image_on_floppy: |
2605 | .save_image_on_floppy: |
2607 | call save_image |
2606 | call save_image |
2608 | mov [esp + 32], dword 0 |
2607 | mov [esp + 32], dword 0 |
2609 | cmp [FDC_Status], 0 |
2608 | cmp [FDC_Status], 0 |
2610 | je .yes_floppy_save |
2609 | je .yes_floppy_save |
2611 | ;-------------------------------------- |
2610 | ;-------------------------------------- |
2612 | align 4 |
2611 | align 4 |
2613 | .no_floppy_b_save: |
2612 | .no_floppy_b_save: |
2614 | mov [esp + 32], dword 1 |
2613 | mov [esp + 32], dword 1 |
2615 | ;-------------------------------------- |
2614 | ;-------------------------------------- |
2616 | align 4 |
2615 | align 4 |
2617 | .yes_floppy_save: |
2616 | .yes_floppy_save: |
2618 | ret |
2617 | ret |
2619 | ;------------------------------------------------------------------------------ |
2618 | ;------------------------------------------------------------------------------ |
2620 | uglobal |
2619 | uglobal |
2621 | ; bgrchanged dd 0x0 |
2620 | ; bgrchanged dd 0x0 |
2622 | align 4 |
2621 | align 4 |
2623 | bgrlockpid dd 0 |
2622 | bgrlockpid dd 0 |
2624 | bgrlock db 0 |
2623 | bgrlock db 0 |
2625 | endg |
2624 | endg |
2626 | ;------------------------------------------------------------------------------ |
2625 | ;------------------------------------------------------------------------------ |
2627 | align 4 |
2626 | align 4 |
2628 | sys_background: |
2627 | sys_background: |
2629 | cmp ebx, 1 ; BACKGROUND SIZE |
2628 | cmp ebx, 1 ; BACKGROUND SIZE |
2630 | jnz nosb1 |
2629 | jnz nosb1 |
2631 | test ecx, ecx |
2630 | test ecx, ecx |
2632 | jz sbgrr |
2631 | jz sbgrr |
2633 | 2632 | ||
2634 | test edx, edx |
2633 | test edx, edx |
2635 | jz sbgrr |
2634 | jz sbgrr |
2636 | ;-------------------------------------- |
2635 | ;-------------------------------------- |
2637 | align 4 |
2636 | align 4 |
2638 | @@: |
2637 | @@: |
2639 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2638 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2640 | bts dword [bgrlock], 0 |
2639 | bts dword [bgrlock], 0 |
2641 | jnc @f |
2640 | jnc @f |
2642 | call change_task |
2641 | call change_task |
2643 | jmp @b |
2642 | jmp @b |
2644 | ;-------------------------------------- |
2643 | ;-------------------------------------- |
2645 | align 4 |
2644 | align 4 |
2646 | @@: |
2645 | @@: |
2647 | mov [BgrDataWidth], ecx |
2646 | mov [BgrDataWidth], ecx |
2648 | mov [BgrDataHeight], edx |
2647 | mov [BgrDataHeight], edx |
2649 | ; mov [bgrchanged],1 |
2648 | ; mov [bgrchanged],1 |
2650 | 2649 | ||
2651 | pushad |
2650 | pushad |
2652 | ; return memory for old background |
2651 | ; return memory for old background |
2653 | mov eax, [img_background] |
2652 | mov eax, [img_background] |
2654 | cmp eax, static_background_data |
2653 | cmp eax, static_background_data |
2655 | jz @f |
2654 | jz @f |
2656 | stdcall kernel_free, eax |
2655 | stdcall kernel_free, eax |
2657 | ;-------------------------------------- |
2656 | ;-------------------------------------- |
2658 | align 4 |
2657 | align 4 |
2659 | @@: |
2658 | @@: |
2660 | ; calculate RAW size |
2659 | ; calculate RAW size |
2661 | xor eax, eax |
2660 | xor eax, eax |
2662 | inc eax |
2661 | inc eax |
2663 | cmp [BgrDataWidth], eax |
2662 | cmp [BgrDataWidth], eax |
2664 | jae @f |
2663 | jae @f |
2665 | mov [BgrDataWidth], eax |
2664 | mov [BgrDataWidth], eax |
2666 | ;-------------------------------------- |
2665 | ;-------------------------------------- |
2667 | align 4 |
2666 | align 4 |
2668 | @@: |
2667 | @@: |
2669 | cmp [BgrDataHeight], eax |
2668 | cmp [BgrDataHeight], eax |
2670 | jae @f |
2669 | jae @f |
2671 | mov [BgrDataHeight], eax |
2670 | mov [BgrDataHeight], eax |
2672 | ;-------------------------------------- |
2671 | ;-------------------------------------- |
2673 | align 4 |
2672 | align 4 |
2674 | @@: |
2673 | @@: |
2675 | mov eax, [BgrDataWidth] |
2674 | mov eax, [BgrDataWidth] |
2676 | imul eax, [BgrDataHeight] |
2675 | imul eax, [BgrDataHeight] |
2677 | lea eax, [eax*3] |
2676 | lea eax, [eax*3] |
2678 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2677 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2679 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2678 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2680 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2679 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2681 | shr eax, 12 |
2680 | shr eax, 12 |
2682 | inc eax |
2681 | inc eax |
2683 | shl eax, 12 |
2682 | shl eax, 12 |
2684 | mov [mem_BACKGROUND], eax |
2683 | mov [mem_BACKGROUND], eax |
2685 | ; get memory for new background |
2684 | ; get memory for new background |
2686 | stdcall kernel_alloc, eax |
2685 | stdcall kernel_alloc, eax |
2687 | test eax, eax |
2686 | test eax, eax |
2688 | jz .memfailed |
2687 | jz .memfailed |
2689 | mov [img_background], eax |
2688 | mov [img_background], eax |
2690 | jmp .exit |
2689 | jmp .exit |
2691 | ;-------------------------------------- |
2690 | ;-------------------------------------- |
2692 | align 4 |
2691 | align 4 |
2693 | .memfailed: |
2692 | .memfailed: |
2694 | ; revert to static monotone data |
2693 | ; revert to static monotone data |
2695 | mov [img_background], static_background_data |
2694 | mov [img_background], static_background_data |
2696 | xor eax, eax |
2695 | xor eax, eax |
2697 | inc eax |
2696 | inc eax |
2698 | mov [BgrDataWidth], eax |
2697 | mov [BgrDataWidth], eax |
2699 | mov [BgrDataHeight], eax |
2698 | mov [BgrDataHeight], eax |
2700 | mov [mem_BACKGROUND], 4 |
2699 | mov [mem_BACKGROUND], 4 |
2701 | ;-------------------------------------- |
2700 | ;-------------------------------------- |
2702 | align 4 |
2701 | align 4 |
2703 | .exit: |
2702 | .exit: |
2704 | popad |
2703 | popad |
2705 | mov [bgrlock], 0 |
2704 | mov [bgrlock], 0 |
2706 | ;-------------------------------------- |
2705 | ;-------------------------------------- |
2707 | align 4 |
2706 | align 4 |
2708 | sbgrr: |
2707 | sbgrr: |
2709 | ret |
2708 | ret |
2710 | ;------------------------------------------------------------------------------ |
2709 | ;------------------------------------------------------------------------------ |
2711 | align 4 |
2710 | align 4 |
2712 | nosb1: |
2711 | nosb1: |
2713 | cmp ebx, 2 ; SET PIXEL |
2712 | cmp ebx, 2 ; SET PIXEL |
2714 | jnz nosb2 |
2713 | jnz nosb2 |
2715 | 2714 | ||
2716 | mov eax, [img_background] |
2715 | mov eax, [img_background] |
2717 | test ecx, ecx |
2716 | test ecx, ecx |
2718 | jz @f |
2717 | jz @f |
2719 | cmp eax, static_background_data |
2718 | cmp eax, static_background_data |
2720 | jz .ret |
2719 | jz .ret |
2721 | ;-------------------------------------- |
2720 | ;-------------------------------------- |
2722 | align 4 |
2721 | align 4 |
2723 | @@: |
2722 | @@: |
2724 | mov ebx, [mem_BACKGROUND] |
2723 | mov ebx, [mem_BACKGROUND] |
2725 | add ebx, 4095 |
2724 | add ebx, 4095 |
2726 | and ebx, -4096 |
2725 | and ebx, -4096 |
2727 | sub ebx, 4 |
2726 | sub ebx, 4 |
2728 | cmp ecx, ebx |
2727 | cmp ecx, ebx |
2729 | ja .ret |
2728 | ja .ret |
2730 | 2729 | ||
2731 | mov ebx, [eax+ecx] |
2730 | mov ebx, [eax+ecx] |
2732 | and ebx, 0xFF000000;255*256*256*256 |
2731 | and ebx, 0xFF000000;255*256*256*256 |
2733 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2732 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2734 | add edx, ebx |
2733 | add edx, ebx |
2735 | mov [eax+ecx], edx |
2734 | mov [eax+ecx], edx |
2736 | ;-------------------------------------- |
2735 | ;-------------------------------------- |
2737 | align 4 |
2736 | align 4 |
2738 | .ret: |
2737 | .ret: |
2739 | ret |
2738 | ret |
2740 | ;------------------------------------------------------------------------------ |
2739 | ;------------------------------------------------------------------------------ |
2741 | align 4 |
2740 | align 4 |
2742 | nosb2: |
2741 | nosb2: |
2743 | cmp ebx, 3 ; DRAW BACKGROUND |
2742 | cmp ebx, 3 ; DRAW BACKGROUND |
2744 | jnz nosb3 |
2743 | jnz nosb3 |
2745 | ;-------------------------------------- |
2744 | ;-------------------------------------- |
2746 | align 4 |
2745 | align 4 |
2747 | draw_background_temp: |
2746 | draw_background_temp: |
2748 | mov [background_defined], 1 |
2747 | mov [background_defined], 1 |
2749 | call force_redraw_background |
2748 | call force_redraw_background |
2750 | ;-------------------------------------- |
2749 | ;-------------------------------------- |
2751 | align 4 |
2750 | align 4 |
2752 | nosb31: |
2751 | nosb31: |
2753 | ret |
2752 | ret |
2754 | ;------------------------------------------------------------------------------ |
2753 | ;------------------------------------------------------------------------------ |
2755 | align 4 |
2754 | align 4 |
2756 | nosb3: |
2755 | nosb3: |
2757 | cmp ebx, 4 ; TILED / STRETCHED |
2756 | cmp ebx, 4 ; TILED / STRETCHED |
2758 | jnz nosb4 |
2757 | jnz nosb4 |
2759 | cmp ecx, [BgrDrawMode] |
2758 | cmp ecx, [BgrDrawMode] |
2760 | je nosb41 |
2759 | je nosb41 |
2761 | mov [BgrDrawMode], ecx |
2760 | mov [BgrDrawMode], ecx |
2762 | ;-------------------------------------- |
2761 | ;-------------------------------------- |
2763 | align 4 |
2762 | align 4 |
2764 | nosb41: |
2763 | nosb41: |
2765 | ret |
2764 | ret |
2766 | ;------------------------------------------------------------------------------ |
2765 | ;------------------------------------------------------------------------------ |
2767 | align 4 |
2766 | align 4 |
2768 | nosb4: |
2767 | nosb4: |
2769 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2768 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2770 | jnz nosb5 |
2769 | jnz nosb5 |
2771 | cmp [img_background], static_background_data |
2770 | cmp [img_background], static_background_data |
2772 | jnz @f |
2771 | jnz @f |
2773 | test edx, edx |
2772 | test edx, edx |
2774 | jnz .fin |
2773 | jnz .fin |
2775 | cmp esi, 4 |
2774 | cmp esi, 4 |
2776 | ja .fin |
2775 | ja .fin |
2777 | ;-------------------------------------- |
2776 | ;-------------------------------------- |
2778 | align 4 |
2777 | align 4 |
2779 | @@: |
2778 | @@: |
2780 | ; bughere |
2779 | ; bughere |
2781 | mov eax, ecx |
2780 | mov eax, ecx |
2782 | mov ebx, edx |
2781 | mov ebx, edx |
2783 | add ebx, [img_background];IMG_BACKGROUND |
2782 | add ebx, [img_background];IMG_BACKGROUND |
2784 | mov ecx, esi |
2783 | mov ecx, esi |
2785 | call memmove |
2784 | call memmove |
2786 | ;-------------------------------------- |
2785 | ;-------------------------------------- |
2787 | align 4 |
2786 | align 4 |
2788 | .fin: |
2787 | .fin: |
2789 | ret |
2788 | ret |
2790 | ;------------------------------------------------------------------------------ |
2789 | ;------------------------------------------------------------------------------ |
2791 | align 4 |
2790 | align 4 |
2792 | nosb5: |
2791 | nosb5: |
2793 | cmp ebx, 6 |
2792 | cmp ebx, 6 |
2794 | jnz nosb6 |
2793 | jnz nosb6 |
2795 | ;-------------------------------------- |
2794 | ;-------------------------------------- |
2796 | align 4 |
2795 | align 4 |
2797 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2796 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2798 | @@: |
2797 | @@: |
2799 | bts dword [bgrlock], 0 |
2798 | bts dword [bgrlock], 0 |
2800 | jnc @f |
2799 | jnc @f |
2801 | call change_task |
2800 | call change_task |
2802 | jmp @b |
2801 | jmp @b |
2803 | ;-------------------------------------- |
2802 | ;-------------------------------------- |
2804 | align 4 |
2803 | align 4 |
2805 | @@: |
2804 | @@: |
2806 | mov eax, [CURRENT_TASK] |
2805 | mov eax, [CURRENT_TASK] |
2807 | mov [bgrlockpid], eax |
2806 | mov [bgrlockpid], eax |
2808 | cmp [img_background], static_background_data |
2807 | cmp [img_background], static_background_data |
2809 | jz .nomem |
2808 | jz .nomem |
2810 | stdcall user_alloc, [mem_BACKGROUND] |
2809 | stdcall user_alloc, [mem_BACKGROUND] |
2811 | mov [esp+32], eax |
2810 | mov [esp+32], eax |
2812 | test eax, eax |
2811 | test eax, eax |
2813 | jz .nomem |
2812 | jz .nomem |
2814 | mov ebx, eax |
2813 | mov ebx, eax |
2815 | shr ebx, 12 |
2814 | shr ebx, 12 |
2816 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2815 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2817 | mov esi, [img_background] |
2816 | mov esi, [img_background] |
2818 | shr esi, 12 |
2817 | shr esi, 12 |
2819 | mov ecx, [mem_BACKGROUND] |
2818 | mov ecx, [mem_BACKGROUND] |
2820 | add ecx, 0xFFF |
2819 | add ecx, 0xFFF |
2821 | shr ecx, 12 |
2820 | shr ecx, 12 |
2822 | ;-------------------------------------- |
2821 | ;-------------------------------------- |
2823 | align 4 |
2822 | align 4 |
2824 | .z: |
2823 | .z: |
2825 | mov eax, [page_tabs+ebx*4] |
2824 | mov eax, [page_tabs+ebx*4] |
2826 | test al, 1 |
2825 | test al, 1 |
2827 | jz @f |
2826 | jz @f |
2828 | call free_page |
2827 | call free_page |
2829 | ;-------------------------------------- |
2828 | ;-------------------------------------- |
2830 | align 4 |
2829 | align 4 |
2831 | @@: |
2830 | @@: |
2832 | mov eax, [page_tabs+esi*4] |
2831 | mov eax, [page_tabs+esi*4] |
2833 | or al, PG_UW |
2832 | or al, PG_UW |
2834 | mov [page_tabs+ebx*4], eax |
2833 | mov [page_tabs+ebx*4], eax |
2835 | mov eax, ebx |
2834 | mov eax, ebx |
2836 | shl eax, 12 |
2835 | shl eax, 12 |
2837 | invlpg [eax] |
2836 | invlpg [eax] |
2838 | inc ebx |
2837 | inc ebx |
2839 | inc esi |
2838 | inc esi |
2840 | loop .z |
2839 | loop .z |
2841 | ret |
2840 | ret |
2842 | ;-------------------------------------- |
2841 | ;-------------------------------------- |
2843 | align 4 |
2842 | align 4 |
2844 | .nomem: |
2843 | .nomem: |
2845 | and [bgrlockpid], 0 |
2844 | and [bgrlockpid], 0 |
2846 | mov [bgrlock], 0 |
2845 | mov [bgrlock], 0 |
2847 | ;------------------------------------------------------------------------------ |
2846 | ;------------------------------------------------------------------------------ |
2848 | align 4 |
2847 | align 4 |
2849 | nosb6: |
2848 | nosb6: |
2850 | cmp ebx, 7 |
2849 | cmp ebx, 7 |
2851 | jnz nosb7 |
2850 | jnz nosb7 |
2852 | cmp [bgrlock], 0 |
2851 | cmp [bgrlock], 0 |
2853 | jz .err |
2852 | jz .err |
2854 | mov eax, [CURRENT_TASK] |
2853 | mov eax, [CURRENT_TASK] |
2855 | cmp [bgrlockpid], eax |
2854 | cmp [bgrlockpid], eax |
2856 | jnz .err |
2855 | jnz .err |
2857 | mov eax, ecx |
2856 | mov eax, ecx |
2858 | mov ebx, ecx |
2857 | mov ebx, ecx |
2859 | shr eax, 12 |
2858 | shr eax, 12 |
2860 | mov ecx, [page_tabs+(eax-1)*4] |
2859 | mov ecx, [page_tabs+(eax-1)*4] |
2861 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2860 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2862 | jz .err |
2861 | jz .err |
2863 | jnp .err |
2862 | jnp .err |
2864 | push eax |
2863 | push eax |
2865 | shr ecx, 12 |
2864 | shr ecx, 12 |
2866 | dec ecx |
2865 | dec ecx |
2867 | ;-------------------------------------- |
2866 | ;-------------------------------------- |
2868 | align 4 |
2867 | align 4 |
2869 | @@: |
2868 | @@: |
2870 | and dword [page_tabs+eax*4], 0 |
2869 | and dword [page_tabs+eax*4], 0 |
2871 | mov edx, eax |
2870 | mov edx, eax |
2872 | shl edx, 12 |
2871 | shl edx, 12 |
2873 | push eax |
2872 | push eax |
2874 | invlpg [edx] |
2873 | invlpg [edx] |
2875 | pop eax |
2874 | pop eax |
2876 | inc eax |
2875 | inc eax |
2877 | loop @b |
2876 | loop @b |
2878 | pop eax |
2877 | pop eax |
2879 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2878 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2880 | stdcall user_free, ebx |
2879 | stdcall user_free, ebx |
2881 | mov [esp+32], eax |
2880 | mov [esp+32], eax |
2882 | and [bgrlockpid], 0 |
2881 | and [bgrlockpid], 0 |
2883 | mov [bgrlock], 0 |
2882 | mov [bgrlock], 0 |
2884 | ret |
2883 | ret |
2885 | ;-------------------------------------- |
2884 | ;-------------------------------------- |
2886 | align 4 |
2885 | align 4 |
2887 | .err: |
2886 | .err: |
2888 | and dword [esp+32], 0 |
2887 | and dword [esp+32], 0 |
2889 | ret |
2888 | ret |
2890 | ;------------------------------------------------------------------------------ |
2889 | ;------------------------------------------------------------------------------ |
2891 | align 4 |
2890 | align 4 |
2892 | nosb7: |
2891 | nosb7: |
2893 | cmp ebx, 8 |
2892 | cmp ebx, 8 |
2894 | jnz nosb8 |
2893 | jnz nosb8 |
2895 | 2894 | ||
2896 | mov ecx, [current_slot] |
2895 | mov ecx, [current_slot] |
2897 | xor eax, eax |
2896 | xor eax, eax |
2898 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2897 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2899 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2898 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2900 | xor eax, eax |
2899 | xor eax, eax |
2901 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2900 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2902 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2901 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2903 | ret |
2902 | ret |
2904 | ;------------------------------------------------------------------------------ |
2903 | ;------------------------------------------------------------------------------ |
2905 | align 4 |
2904 | align 4 |
2906 | nosb8: |
2905 | nosb8: |
2907 | cmp ebx, 9 |
2906 | cmp ebx, 9 |
2908 | jnz nosb9 |
2907 | jnz nosb9 |
2909 | ; ecx = [left]*65536 + [right] |
2908 | ; ecx = [left]*65536 + [right] |
2910 | ; edx = [top]*65536 + [bottom] |
2909 | ; edx = [top]*65536 + [bottom] |
2911 | mov eax, [Screen_Max_X] |
2910 | mov eax, [Screen_Max_X] |
2912 | mov ebx, [Screen_Max_Y] |
2911 | mov ebx, [Screen_Max_Y] |
2913 | ; check [right] |
2912 | ; check [right] |
2914 | cmp cx, ax |
2913 | cmp cx, ax |
2915 | ja .exit |
2914 | ja .exit |
2916 | ; check [left] |
2915 | ; check [left] |
2917 | ror ecx, 16 |
2916 | ror ecx, 16 |
2918 | cmp cx, ax |
2917 | cmp cx, ax |
2919 | ja .exit |
2918 | ja .exit |
2920 | ; check [bottom] |
2919 | ; check [bottom] |
2921 | cmp dx, bx |
2920 | cmp dx, bx |
2922 | ja .exit |
2921 | ja .exit |
2923 | ; check [top] |
2922 | ; check [top] |
2924 | ror edx, 16 |
2923 | ror edx, 16 |
2925 | cmp dx, bx |
2924 | cmp dx, bx |
2926 | ja .exit |
2925 | ja .exit |
2927 | 2926 | ||
2928 | movzx eax, cx ; [left] |
2927 | movzx eax, cx ; [left] |
2929 | movzx ebx, dx ; [top] |
2928 | movzx ebx, dx ; [top] |
2930 | 2929 | ||
2931 | shr ecx, 16 ; [right] |
2930 | shr ecx, 16 ; [right] |
2932 | shr edx, 16 ; [bottom] |
2931 | shr edx, 16 ; [bottom] |
2933 | 2932 | ||
2934 | mov [background_defined], 1 |
2933 | mov [background_defined], 1 |
2935 | 2934 | ||
2936 | mov [draw_data+32 + RECT.left], eax |
2935 | mov [draw_data+32 + RECT.left], eax |
2937 | mov [draw_data+32 + RECT.top], ebx |
2936 | mov [draw_data+32 + RECT.top], ebx |
2938 | 2937 | ||
2939 | mov [draw_data+32 + RECT.right], ecx |
2938 | mov [draw_data+32 + RECT.right], ecx |
2940 | mov [draw_data+32 + RECT.bottom], edx |
2939 | mov [draw_data+32 + RECT.bottom], edx |
2941 | 2940 | ||
2942 | inc byte[REDRAW_BACKGROUND] |
2941 | inc byte[REDRAW_BACKGROUND] |
2943 | call wakeup_osloop |
2942 | call wakeup_osloop |
2944 | ;-------------------------------------- |
2943 | ;-------------------------------------- |
2945 | align 4 |
2944 | align 4 |
2946 | .exit: |
2945 | .exit: |
2947 | ret |
2946 | ret |
2948 | ;------------------------------------------------------------------------------ |
2947 | ;------------------------------------------------------------------------------ |
2949 | align 4 |
2948 | align 4 |
2950 | nosb9: |
2949 | nosb9: |
2951 | ret |
2950 | ret |
2952 | ;------------------------------------------------------------------------------ |
2951 | ;------------------------------------------------------------------------------ |
2953 | align 4 |
2952 | align 4 |
2954 | uglobal |
2953 | uglobal |
2955 | BG_Rect_X_left_right dd 0x0 |
2954 | BG_Rect_X_left_right dd 0x0 |
2956 | BG_Rect_Y_top_bottom dd 0x0 |
2955 | BG_Rect_Y_top_bottom dd 0x0 |
2957 | endg |
2956 | endg |
2958 | ;------------------------------------------------------------------------------ |
2957 | ;------------------------------------------------------------------------------ |
2959 | align 4 |
2958 | align 4 |
2960 | force_redraw_background: |
2959 | force_redraw_background: |
2961 | and [draw_data+32 + RECT.left], 0 |
2960 | and [draw_data+32 + RECT.left], 0 |
2962 | and [draw_data+32 + RECT.top], 0 |
2961 | and [draw_data+32 + RECT.top], 0 |
2963 | push eax ebx |
2962 | push eax ebx |
2964 | mov eax, [Screen_Max_X] |
2963 | mov eax, [Screen_Max_X] |
2965 | mov ebx, [Screen_Max_Y] |
2964 | mov ebx, [Screen_Max_Y] |
2966 | mov [draw_data+32 + RECT.right], eax |
2965 | mov [draw_data+32 + RECT.right], eax |
2967 | mov [draw_data+32 + RECT.bottom], ebx |
2966 | mov [draw_data+32 + RECT.bottom], ebx |
2968 | pop ebx eax |
2967 | pop ebx eax |
2969 | inc byte[REDRAW_BACKGROUND] |
2968 | inc byte[REDRAW_BACKGROUND] |
2970 | call wakeup_osloop |
2969 | call wakeup_osloop |
2971 | ret |
2970 | ret |
2972 | ;------------------------------------------------------------------------------ |
2971 | ;------------------------------------------------------------------------------ |
2973 | align 4 |
2972 | align 4 |
2974 | sys_getbackground: |
2973 | sys_getbackground: |
2975 | ; cmp eax,1 ; SIZE |
2974 | ; cmp eax,1 ; SIZE |
2976 | dec ebx |
2975 | dec ebx |
2977 | jnz nogb1 |
2976 | jnz nogb1 |
2978 | mov eax, [BgrDataWidth] |
2977 | mov eax, [BgrDataWidth] |
2979 | shl eax, 16 |
2978 | shl eax, 16 |
2980 | mov ax, word [BgrDataHeight] |
2979 | mov ax, word [BgrDataHeight] |
2981 | mov [esp+32], eax |
2980 | mov [esp+32], eax |
2982 | ret |
2981 | ret |
2983 | ;------------------------------------------------------------------------------ |
2982 | ;------------------------------------------------------------------------------ |
2984 | align 4 |
2983 | align 4 |
2985 | nogb1: |
2984 | nogb1: |
2986 | ; cmp eax,2 ; PIXEL |
2985 | ; cmp eax,2 ; PIXEL |
2987 | dec ebx |
2986 | dec ebx |
2988 | jnz nogb2 |
2987 | jnz nogb2 |
2989 | 2988 | ||
2990 | mov eax, [img_background] |
2989 | mov eax, [img_background] |
2991 | test ecx, ecx |
2990 | test ecx, ecx |
2992 | jz @f |
2991 | jz @f |
2993 | cmp eax, static_background_data |
2992 | cmp eax, static_background_data |
2994 | jz .ret |
2993 | jz .ret |
2995 | ;-------------------------------------- |
2994 | ;-------------------------------------- |
2996 | align 4 |
2995 | align 4 |
2997 | @@: |
2996 | @@: |
2998 | mov ebx, [mem_BACKGROUND] |
2997 | mov ebx, [mem_BACKGROUND] |
2999 | add ebx, 4095 |
2998 | add ebx, 4095 |
3000 | and ebx, -4096 |
2999 | and ebx, -4096 |
3001 | sub ebx, 4 |
3000 | sub ebx, 4 |
3002 | cmp ecx, ebx |
3001 | cmp ecx, ebx |
3003 | ja .ret |
3002 | ja .ret |
3004 | 3003 | ||
3005 | mov eax, [ecx+eax] |
3004 | mov eax, [ecx+eax] |
3006 | 3005 | ||
3007 | and eax, 0xFFFFFF |
3006 | and eax, 0xFFFFFF |
3008 | mov [esp+32], eax |
3007 | mov [esp+32], eax |
3009 | ;-------------------------------------- |
3008 | ;-------------------------------------- |
3010 | align 4 |
3009 | align 4 |
3011 | .ret: |
3010 | .ret: |
3012 | ret |
3011 | ret |
3013 | ;------------------------------------------------------------------------------ |
3012 | ;------------------------------------------------------------------------------ |
3014 | align 4 |
3013 | align 4 |
3015 | nogb2: |
3014 | nogb2: |
3016 | 3015 | ||
3017 | ; cmp eax,4 ; TILED / STRETCHED |
3016 | ; cmp eax,4 ; TILED / STRETCHED |
3018 | dec ebx |
3017 | dec ebx |
3019 | dec ebx |
3018 | dec ebx |
3020 | jnz nogb4 |
3019 | jnz nogb4 |
3021 | mov eax, [BgrDrawMode] |
3020 | mov eax, [BgrDrawMode] |
3022 | ;-------------------------------------- |
3021 | ;-------------------------------------- |
3023 | align 4 |
3022 | align 4 |
3024 | nogb4: |
3023 | nogb4: |
3025 | mov [esp+32], eax |
3024 | mov [esp+32], eax |
3026 | ret |
3025 | ret |
3027 | ;------------------------------------------------------------------------------ |
3026 | ;------------------------------------------------------------------------------ |
3028 | align 4 |
3027 | align 4 |
3029 | sys_getkey: |
3028 | sys_getkey: |
3030 | mov [esp + 32], dword 1 |
3029 | mov [esp + 32], dword 1 |
3031 | ; test main buffer |
3030 | ; test main buffer |
3032 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3031 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3033 | movzx ecx, word [WIN_STACK + ebx * 2] |
3032 | movzx ecx, word [WIN_STACK + ebx * 2] |
3034 | mov edx, [TASK_COUNT] |
3033 | mov edx, [TASK_COUNT] |
3035 | cmp ecx, edx |
3034 | cmp ecx, edx |
3036 | jne .finish |
3035 | jne .finish |
3037 | cmp [KEY_COUNT], byte 0 |
3036 | cmp [KEY_COUNT], byte 0 |
3038 | je .finish |
3037 | je .finish |
3039 | movzx eax, byte [KEY_BUFF] |
3038 | movzx eax, byte [KEY_BUFF] |
3040 | shl eax, 8 |
3039 | shl eax, 8 |
3041 | push eax |
3040 | push eax |
3042 | dec byte [KEY_COUNT] |
3041 | dec byte [KEY_COUNT] |
3043 | and byte [KEY_COUNT], 127 |
3042 | and byte [KEY_COUNT], 127 |
3044 | movzx ecx, byte [KEY_COUNT] |
3043 | movzx ecx, byte [KEY_COUNT] |
3045 | add ecx, 2 |
3044 | add ecx, 2 |
3046 | mov eax, KEY_BUFF + 1 |
3045 | mov eax, KEY_BUFF + 1 |
3047 | mov ebx, KEY_BUFF |
3046 | mov ebx, KEY_BUFF |
3048 | call memmove |
3047 | call memmove |
3049 | pop eax |
3048 | pop eax |
3050 | ;-------------------------------------- |
3049 | ;-------------------------------------- |
3051 | align 4 |
3050 | align 4 |
3052 | .ret_eax: |
3051 | .ret_eax: |
3053 | mov [esp + 32], eax |
3052 | mov [esp + 32], eax |
3054 | ret |
3053 | ret |
3055 | ;-------------------------------------- |
3054 | ;-------------------------------------- |
3056 | align 4 |
3055 | align 4 |
3057 | .finish: |
3056 | .finish: |
3058 | ; test hotkeys buffer |
3057 | ; test hotkeys buffer |
3059 | mov ecx, hotkey_buffer |
3058 | mov ecx, hotkey_buffer |
3060 | ;-------------------------------------- |
3059 | ;-------------------------------------- |
3061 | align 4 |
3060 | align 4 |
3062 | @@: |
3061 | @@: |
3063 | cmp [ecx], ebx |
3062 | cmp [ecx], ebx |
3064 | jz .found |
3063 | jz .found |
3065 | add ecx, 8 |
3064 | add ecx, 8 |
3066 | cmp ecx, hotkey_buffer + 120 * 8 |
3065 | cmp ecx, hotkey_buffer + 120 * 8 |
3067 | jb @b |
3066 | jb @b |
3068 | ret |
3067 | ret |
3069 | ;-------------------------------------- |
3068 | ;-------------------------------------- |
3070 | align 4 |
3069 | align 4 |
3071 | .found: |
3070 | .found: |
3072 | mov ax, [ecx + 6] |
3071 | mov ax, [ecx + 6] |
3073 | shl eax, 16 |
3072 | shl eax, 16 |
3074 | mov ah, [ecx + 4] |
3073 | mov ah, [ecx + 4] |
3075 | mov al, 2 |
3074 | mov al, 2 |
3076 | and dword [ecx + 4], 0 |
3075 | and dword [ecx + 4], 0 |
3077 | and dword [ecx], 0 |
3076 | and dword [ecx], 0 |
3078 | jmp .ret_eax |
3077 | jmp .ret_eax |
3079 | ;------------------------------------------------------------------------------ |
3078 | ;------------------------------------------------------------------------------ |
3080 | align 4 |
3079 | align 4 |
3081 | sys_getbutton: |
3080 | sys_getbutton: |
3082 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3081 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3083 | mov [esp + 32], dword 1 |
3082 | mov [esp + 32], dword 1 |
3084 | movzx ecx, word [WIN_STACK + ebx * 2] |
3083 | movzx ecx, word [WIN_STACK + ebx * 2] |
3085 | mov edx, [TASK_COUNT] ; less than 256 processes |
3084 | mov edx, [TASK_COUNT] ; less than 256 processes |
3086 | cmp ecx, edx |
3085 | cmp ecx, edx |
3087 | jne .exit |
3086 | jne .exit |
3088 | movzx eax, byte [BTN_COUNT] |
3087 | movzx eax, byte [BTN_COUNT] |
3089 | test eax, eax |
3088 | test eax, eax |
3090 | jz .exit |
3089 | jz .exit |
3091 | mov eax, [BTN_BUFF] |
3090 | mov eax, [BTN_BUFF] |
3092 | and al, 0xFE ; delete left button bit |
3091 | and al, 0xFE ; delete left button bit |
3093 | mov [BTN_COUNT], byte 0 |
3092 | mov [BTN_COUNT], byte 0 |
3094 | mov [esp + 32], eax |
3093 | mov [esp + 32], eax |
3095 | ;-------------------------------------- |
3094 | ;-------------------------------------- |
3096 | align 4 |
3095 | align 4 |
3097 | .exit: |
3096 | .exit: |
3098 | ret |
3097 | ret |
3099 | ;------------------------------------------------------------------------------ |
3098 | ;------------------------------------------------------------------------------ |
3100 | align 4 |
3099 | align 4 |
3101 | sys_cpuusage: |
3100 | sys_cpuusage: |
3102 | 3101 | ||
3103 | ; RETURN: |
3102 | ; RETURN: |
3104 | ; |
3103 | ; |
3105 | ; +00 dword process cpu usage |
3104 | ; +00 dword process cpu usage |
3106 | ; +04 word position in windowing stack |
3105 | ; +04 word position in windowing stack |
3107 | ; +06 word windowing stack value at current position (cpu nro) |
3106 | ; +06 word windowing stack value at current position (cpu nro) |
3108 | ; +10 12 bytes name |
3107 | ; +10 12 bytes name |
3109 | ; +22 dword start in mem |
3108 | ; +22 dword start in mem |
3110 | ; +26 dword used mem |
3109 | ; +26 dword used mem |
3111 | ; +30 dword PID , process idenfification number |
3110 | ; +30 dword PID , process idenfification number |
3112 | ; |
3111 | ; |
3113 | 3112 | ||
3114 | cmp ecx, -1 ; who am I ? |
3113 | cmp ecx, -1 ; who am I ? |
3115 | jne .no_who_am_i |
3114 | jne .no_who_am_i |
3116 | mov ecx, [CURRENT_TASK] |
3115 | mov ecx, [CURRENT_TASK] |
3117 | .no_who_am_i: |
3116 | .no_who_am_i: |
3118 | cmp ecx, max_processes |
3117 | cmp ecx, max_processes |
3119 | ja .nofillbuf |
3118 | ja .nofillbuf |
3120 | 3119 | ||
3121 | ; +4: word: position of the window of thread in the window stack |
3120 | ; +4: word: position of the window of thread in the window stack |
3122 | mov ax, [WIN_STACK + ecx * 2] |
3121 | mov ax, [WIN_STACK + ecx * 2] |
3123 | mov [ebx+4], ax |
3122 | mov [ebx+4], ax |
3124 | ; +6: word: number of the thread slot, which window has in the window stack |
3123 | ; +6: word: number of the thread slot, which window has in the window stack |
3125 | ; position ecx (has no relation to the specific thread) |
3124 | ; position ecx (has no relation to the specific thread) |
3126 | mov ax, [WIN_POS + ecx * 2] |
3125 | mov ax, [WIN_POS + ecx * 2] |
3127 | mov [ebx+6], ax |
3126 | mov [ebx+6], ax |
3128 | 3127 | ||
3129 | shl ecx, 5 |
3128 | shl ecx, 5 |
3130 | 3129 | ||
3131 | ; +0: dword: memory usage |
3130 | ; +0: dword: memory usage |
3132 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3131 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3133 | mov [ebx], eax |
3132 | mov [ebx], eax |
3134 | ; +10: 11 bytes: name of the process |
3133 | ; +10: 11 bytes: name of the process |
3135 | push ecx |
3134 | push ecx |
3136 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3135 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3137 | add ebx, 10 |
3136 | add ebx, 10 |
3138 | mov ecx, 11 |
3137 | mov ecx, 11 |
3139 | call memmove |
3138 | call memmove |
3140 | pop ecx |
3139 | pop ecx |
3141 | 3140 | ||
3142 | ; +22: address of the process in memory |
3141 | ; +22: address of the process in memory |
3143 | ; +26: size of used memory - 1 |
3142 | ; +26: size of used memory - 1 |
3144 | push edi |
3143 | push edi |
3145 | lea edi, [ebx+12] |
3144 | lea edi, [ebx+12] |
3146 | xor eax, eax |
3145 | xor eax, eax |
3147 | mov edx, 0x100000*16 |
3146 | mov edx, 0x100000*16 |
3148 | cmp ecx, 1 shl 5 |
3147 | cmp ecx, 1 shl 5 |
3149 | je .os_mem |
3148 | je .os_mem |
3150 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3149 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3151 | mov eax, std_application_base_address |
3150 | mov eax, std_application_base_address |
3152 | .os_mem: |
3151 | .os_mem: |
3153 | stosd |
3152 | stosd |
3154 | lea eax, [edx-1] |
3153 | lea eax, [edx-1] |
3155 | stosd |
3154 | stosd |
3156 | 3155 | ||
3157 | ; +30: PID/TID |
3156 | ; +30: PID/TID |
3158 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3157 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3159 | stosd |
3158 | stosd |
3160 | 3159 | ||
3161 | ; window position and size |
3160 | ; window position and size |
3162 | push esi |
3161 | push esi |
3163 | lea esi, [ecx + window_data + WDATA.box] |
3162 | lea esi, [ecx + window_data + WDATA.box] |
3164 | movsd |
3163 | movsd |
3165 | movsd |
3164 | movsd |
3166 | movsd |
3165 | movsd |
3167 | movsd |
3166 | movsd |
3168 | 3167 | ||
3169 | ; Process state (+50) |
3168 | ; Process state (+50) |
3170 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3169 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3171 | stosd |
3170 | stosd |
3172 | 3171 | ||
3173 | ; Window client area box |
3172 | ; Window client area box |
3174 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3173 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3175 | movsd |
3174 | movsd |
3176 | movsd |
3175 | movsd |
3177 | movsd |
3176 | movsd |
3178 | movsd |
3177 | movsd |
3179 | 3178 | ||
3180 | ; Window state |
3179 | ; Window state |
3181 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3180 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3182 | stosb |
3181 | stosb |
3183 | 3182 | ||
3184 | ; Event mask (+71) |
3183 | ; Event mask (+71) |
3185 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3184 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3186 | stosd |
3185 | stosd |
3187 | 3186 | ||
3188 | pop esi |
3187 | pop esi |
3189 | pop edi |
3188 | pop edi |
3190 | 3189 | ||
3191 | .nofillbuf: |
3190 | .nofillbuf: |
3192 | ; return number of processes |
3191 | ; return number of processes |
3193 | 3192 | ||
3194 | mov eax, [TASK_COUNT] |
3193 | mov eax, [TASK_COUNT] |
3195 | mov [esp+32], eax |
3194 | mov [esp+32], eax |
3196 | ret |
3195 | ret |
3197 | 3196 | ||
3198 | align 4 |
3197 | align 4 |
3199 | sys_clock: |
3198 | sys_clock: |
3200 | cli |
3199 | cli |
3201 | ; Mikhail Lisovin xx Jan 2005 |
3200 | ; Mikhail Lisovin xx Jan 2005 |
3202 | @@: |
3201 | @@: |
3203 | mov al, 10 |
3202 | mov al, 10 |
3204 | out 0x70, al |
3203 | out 0x70, al |
3205 | in al, 0x71 |
3204 | in al, 0x71 |
3206 | test al, al |
3205 | test al, al |
3207 | jns @f |
3206 | jns @f |
3208 | mov esi, 1 |
3207 | mov esi, 1 |
3209 | call delay_ms |
3208 | call delay_ms |
3210 | jmp @b |
3209 | jmp @b |
3211 | @@: |
3210 | @@: |
3212 | ; end Lisovin's fix |
3211 | ; end Lisovin's fix |
3213 | 3212 | ||
3214 | xor al, al ; seconds |
3213 | xor al, al ; seconds |
3215 | out 0x70, al |
3214 | out 0x70, al |
3216 | in al, 0x71 |
3215 | in al, 0x71 |
3217 | movzx ecx, al |
3216 | movzx ecx, al |
3218 | mov al, 02 ; minutes |
3217 | mov al, 02 ; minutes |
3219 | shl ecx, 16 |
3218 | shl ecx, 16 |
3220 | out 0x70, al |
3219 | out 0x70, al |
3221 | in al, 0x71 |
3220 | in al, 0x71 |
3222 | movzx edx, al |
3221 | movzx edx, al |
3223 | mov al, 04 ; hours |
3222 | mov al, 04 ; hours |
3224 | shl edx, 8 |
3223 | shl edx, 8 |
3225 | out 0x70, al |
3224 | out 0x70, al |
3226 | in al, 0x71 |
3225 | in al, 0x71 |
3227 | add ecx, edx |
3226 | add ecx, edx |
3228 | movzx edx, al |
3227 | movzx edx, al |
3229 | add ecx, edx |
3228 | add ecx, edx |
3230 | sti |
3229 | sti |
3231 | mov [esp + 32], ecx |
3230 | mov [esp + 32], ecx |
3232 | ret |
3231 | ret |
3233 | 3232 | ||
3234 | 3233 | ||
3235 | align 4 |
3234 | align 4 |
3236 | 3235 | ||
3237 | sys_date: |
3236 | sys_date: |
3238 | 3237 | ||
3239 | cli |
3238 | cli |
3240 | @@: |
3239 | @@: |
3241 | mov al, 10 |
3240 | mov al, 10 |
3242 | out 0x70, al |
3241 | out 0x70, al |
3243 | in al, 0x71 |
3242 | in al, 0x71 |
3244 | test al, al |
3243 | test al, al |
3245 | jns @f |
3244 | jns @f |
3246 | mov esi, 1 |
3245 | mov esi, 1 |
3247 | call delay_ms |
3246 | call delay_ms |
3248 | jmp @b |
3247 | jmp @b |
3249 | @@: |
3248 | @@: |
3250 | 3249 | ||
3251 | mov ch, 0 |
3250 | mov ch, 0 |
3252 | mov al, 7 ; date |
3251 | mov al, 7 ; date |
3253 | out 0x70, al |
3252 | out 0x70, al |
3254 | in al, 0x71 |
3253 | in al, 0x71 |
3255 | mov cl, al |
3254 | mov cl, al |
3256 | mov al, 8 ; month |
3255 | mov al, 8 ; month |
3257 | shl ecx, 16 |
3256 | shl ecx, 16 |
3258 | out 0x70, al |
3257 | out 0x70, al |
3259 | in al, 0x71 |
3258 | in al, 0x71 |
3260 | mov ch, al |
3259 | mov ch, al |
3261 | mov al, 9 ; year |
3260 | mov al, 9 ; year |
3262 | out 0x70, al |
3261 | out 0x70, al |
3263 | in al, 0x71 |
3262 | in al, 0x71 |
3264 | mov cl, al |
3263 | mov cl, al |
3265 | sti |
3264 | sti |
3266 | mov [esp+32], ecx |
3265 | mov [esp+32], ecx |
3267 | ret |
3266 | ret |
3268 | 3267 | ||
3269 | 3268 | ||
3270 | ; redraw status |
3269 | ; redraw status |
3271 | 3270 | ||
3272 | sys_redrawstat: |
3271 | sys_redrawstat: |
3273 | cmp ebx, 1 |
3272 | cmp ebx, 1 |
3274 | jne no_widgets_away |
3273 | jne no_widgets_away |
3275 | ; buttons away |
3274 | ; buttons away |
3276 | mov ecx, [CURRENT_TASK] |
3275 | mov ecx, [CURRENT_TASK] |
3277 | sys_newba2: |
3276 | sys_newba2: |
3278 | mov edi, [BTN_ADDR] |
3277 | mov edi, [BTN_ADDR] |
3279 | cmp [edi], dword 0 ; empty button list ? |
3278 | cmp [edi], dword 0 ; empty button list ? |
3280 | je end_of_buttons_away |
3279 | je end_of_buttons_away |
3281 | movzx ebx, word [edi] |
3280 | movzx ebx, word [edi] |
3282 | inc ebx |
3281 | inc ebx |
3283 | mov eax, edi |
3282 | mov eax, edi |
3284 | sys_newba: |
3283 | sys_newba: |
3285 | dec ebx |
3284 | dec ebx |
3286 | jz end_of_buttons_away |
3285 | jz end_of_buttons_away |
3287 | 3286 | ||
3288 | add eax, 0x10 |
3287 | add eax, 0x10 |
3289 | cmp cx, [eax] |
3288 | cmp cx, [eax] |
3290 | jnz sys_newba |
3289 | jnz sys_newba |
3291 | 3290 | ||
3292 | push eax ebx ecx |
3291 | push eax ebx ecx |
3293 | mov ecx, ebx |
3292 | mov ecx, ebx |
3294 | inc ecx |
3293 | inc ecx |
3295 | shl ecx, 4 |
3294 | shl ecx, 4 |
3296 | mov ebx, eax |
3295 | mov ebx, eax |
3297 | add eax, 0x10 |
3296 | add eax, 0x10 |
3298 | call memmove |
3297 | call memmove |
3299 | dec dword [edi] |
3298 | dec dword [edi] |
3300 | pop ecx ebx eax |
3299 | pop ecx ebx eax |
3301 | 3300 | ||
3302 | jmp sys_newba2 |
3301 | jmp sys_newba2 |
3303 | 3302 | ||
3304 | end_of_buttons_away: |
3303 | end_of_buttons_away: |
3305 | 3304 | ||
3306 | ret |
3305 | ret |
3307 | 3306 | ||
3308 | no_widgets_away: |
3307 | no_widgets_away: |
3309 | 3308 | ||
3310 | cmp ebx, 2 |
3309 | cmp ebx, 2 |
3311 | jnz srl1 |
3310 | jnz srl1 |
3312 | 3311 | ||
3313 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3312 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3314 | add edx, draw_data - CURRENT_TASK |
3313 | add edx, draw_data - CURRENT_TASK |
3315 | mov [edx + RECT.left], 0 |
3314 | mov [edx + RECT.left], 0 |
3316 | mov [edx + RECT.top], 0 |
3315 | mov [edx + RECT.top], 0 |
3317 | mov eax, [Screen_Max_X] |
3316 | mov eax, [Screen_Max_X] |
3318 | mov [edx + RECT.right], eax |
3317 | mov [edx + RECT.right], eax |
3319 | mov eax, [Screen_Max_Y] |
3318 | mov eax, [Screen_Max_Y] |
3320 | mov [edx + RECT.bottom], eax |
3319 | mov [edx + RECT.bottom], eax |
3321 | 3320 | ||
3322 | srl1: |
3321 | srl1: |
3323 | ret |
3322 | ret |
3324 | 3323 | ||
3325 | ;ok - 100% work |
3324 | ;ok - 100% work |
3326 | ;nt - not tested |
3325 | ;nt - not tested |
3327 | ;--------------------------------------------------------------------------------------------- |
3326 | ;--------------------------------------------------------------------------------------------- |
3328 | ;eax |
3327 | ;eax |
3329 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3328 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3330 | ;1 - change task. Ret nothing. Block. ok. |
3329 | ;1 - change task. Ret nothing. Block. ok. |
3331 | ;2 - performance control |
3330 | ;2 - performance control |
3332 | ; ebx |
3331 | ; ebx |
3333 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3332 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3334 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3333 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3335 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3334 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3336 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3335 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3337 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3336 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3338 | ;eax |
3337 | ;eax |
3339 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3338 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3340 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3339 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3341 | ;--------------------------------------------------------------------------------------------- |
3340 | ;--------------------------------------------------------------------------------------------- |
3342 | iglobal |
3341 | iglobal |
3343 | align 4 |
3342 | align 4 |
3344 | sheduler: |
3343 | sheduler: |
3345 | dd sys_sheduler.00 |
3344 | dd sys_sheduler.00 |
3346 | dd change_task |
3345 | dd change_task |
3347 | dd sys_sheduler.02 |
3346 | dd sys_sheduler.02 |
3348 | dd sys_sheduler.03 |
3347 | dd sys_sheduler.03 |
3349 | dd sys_sheduler.04 |
3348 | dd sys_sheduler.04 |
3350 | endg |
3349 | endg |
3351 | sys_sheduler: |
3350 | sys_sheduler: |
3352 | ;rewritten by |
3351 | ;rewritten by |
3353 | jmp dword [sheduler+ebx*4] |
3352 | jmp dword [sheduler+ebx*4] |
3354 | ;.shed_counter: |
3353 | ;.shed_counter: |
3355 | .00: |
3354 | .00: |
3356 | mov eax, [context_counter] |
3355 | mov eax, [context_counter] |
3357 | mov [esp+32], eax |
3356 | mov [esp+32], eax |
3358 | ret |
3357 | ret |
3359 | 3358 | ||
3360 | .02: |
3359 | .02: |
3361 | ;.perf_control: |
3360 | ;.perf_control: |
3362 | inc ebx ;before ebx=2, ebx=3 |
3361 | inc ebx ;before ebx=2, ebx=3 |
3363 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3362 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3364 | jz cache_disable |
3363 | jz cache_disable |
3365 | 3364 | ||
3366 | dec ebx ;ebx=2 |
3365 | dec ebx ;ebx=2 |
3367 | cmp ebx, ecx ; |
3366 | cmp ebx, ecx ; |
3368 | jz cache_enable ;if ecx=2 and ebx=2 |
3367 | jz cache_enable ;if ecx=2 and ebx=2 |
3369 | 3368 | ||
3370 | dec ebx ;ebx=1 |
3369 | dec ebx ;ebx=1 |
3371 | cmp ebx, ecx |
3370 | cmp ebx, ecx |
3372 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3371 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3373 | 3372 | ||
3374 | dec ebx |
3373 | dec ebx |
3375 | test ebx, ecx ;ebx=0 and ecx=0 |
3374 | test ebx, ecx ;ebx=0 and ecx=0 |
3376 | jz modify_pce ;if ecx=0 |
3375 | jz modify_pce ;if ecx=0 |
3377 | 3376 | ||
3378 | ret |
3377 | ret |
3379 | 3378 | ||
3380 | .03: |
3379 | .03: |
3381 | ;.rdmsr_instr: |
3380 | ;.rdmsr_instr: |
3382 | ;now counter in ecx |
3381 | ;now counter in ecx |
3383 | ;(edx:eax) esi:edi => edx:esi |
3382 | ;(edx:eax) esi:edi => edx:esi |
3384 | mov eax, esi |
3383 | mov eax, esi |
3385 | mov ecx, edx |
3384 | mov ecx, edx |
3386 | rdmsr |
3385 | rdmsr |
3387 | mov [esp+32], eax |
3386 | mov [esp+32], eax |
3388 | mov [esp+20], edx ;ret in ebx? |
3387 | mov [esp+20], edx ;ret in ebx? |
3389 | ret |
3388 | ret |
3390 | 3389 | ||
3391 | .04: |
3390 | .04: |
3392 | ;.wrmsr_instr: |
3391 | ;.wrmsr_instr: |
3393 | ;now counter in ecx |
3392 | ;now counter in ecx |
3394 | ;(edx:eax) esi:edi => edx:esi |
3393 | ;(edx:eax) esi:edi => edx:esi |
3395 | ; Fast Call MSR can't be destroy |
3394 | ; Fast Call MSR can't be destroy |
3396 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3395 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3397 | ; включаются/выключаются расширенные возможности |
3396 | ; включаются/выключаются расширенные возможности |
3398 | cmp edx, MSR_SYSENTER_CS |
3397 | cmp edx, MSR_SYSENTER_CS |
3399 | je @f |
3398 | je @f |
3400 | cmp edx, MSR_SYSENTER_ESP |
3399 | cmp edx, MSR_SYSENTER_ESP |
3401 | je @f |
3400 | je @f |
3402 | cmp edx, MSR_SYSENTER_EIP |
3401 | cmp edx, MSR_SYSENTER_EIP |
3403 | je @f |
3402 | je @f |
3404 | cmp edx, MSR_AMD_STAR |
3403 | cmp edx, MSR_AMD_STAR |
3405 | je @f |
3404 | je @f |
3406 | 3405 | ||
3407 | mov eax, esi |
3406 | mov eax, esi |
3408 | mov ecx, edx |
3407 | mov ecx, edx |
3409 | wrmsr |
3408 | wrmsr |
3410 | ; mov [esp + 32], eax |
3409 | ; mov [esp + 32], eax |
3411 | ; mov [esp + 20], edx ;ret in ebx? |
3410 | ; mov [esp + 20], edx ;ret in ebx? |
3412 | @@: |
3411 | @@: |
3413 | ret |
3412 | ret |
3414 | 3413 | ||
3415 | cache_disable: |
3414 | cache_disable: |
3416 | mov eax, cr0 |
3415 | mov eax, cr0 |
3417 | or eax, 01100000000000000000000000000000b |
3416 | or eax, 01100000000000000000000000000000b |
3418 | mov cr0, eax |
3417 | mov cr0, eax |
3419 | wbinvd ;set MESI |
3418 | wbinvd ;set MESI |
3420 | ret |
3419 | ret |
3421 | 3420 | ||
3422 | cache_enable: |
3421 | cache_enable: |
3423 | mov eax, cr0 |
3422 | mov eax, cr0 |
3424 | and eax, 10011111111111111111111111111111b |
3423 | and eax, 10011111111111111111111111111111b |
3425 | mov cr0, eax |
3424 | mov cr0, eax |
3426 | ret |
3425 | ret |
3427 | 3426 | ||
3428 | is_cache_enabled: |
3427 | is_cache_enabled: |
3429 | mov eax, cr0 |
3428 | mov eax, cr0 |
3430 | mov ebx, eax |
3429 | mov ebx, eax |
3431 | and eax, 01100000000000000000000000000000b |
3430 | and eax, 01100000000000000000000000000000b |
3432 | jz cache_disabled |
3431 | jz cache_disabled |
3433 | mov [esp+32], ebx |
3432 | mov [esp+32], ebx |
3434 | cache_disabled: |
3433 | cache_disabled: |
3435 | mov dword [esp+32], eax;0 |
3434 | mov dword [esp+32], eax;0 |
3436 | ret |
3435 | ret |
3437 | 3436 | ||
3438 | modify_pce: |
3437 | modify_pce: |
3439 | mov eax, cr4 |
3438 | mov eax, cr4 |
3440 | ; mov ebx,0 |
3439 | ; mov ebx,0 |
3441 | ; or bx,100000000b ;pce |
3440 | ; or bx,100000000b ;pce |
3442 | ; xor eax,ebx ;invert pce |
3441 | ; xor eax,ebx ;invert pce |
3443 | bts eax, 8;pce=cr4[8] |
3442 | bts eax, 8;pce=cr4[8] |
3444 | mov cr4, eax |
3443 | mov cr4, eax |
3445 | mov [esp+32], eax |
3444 | mov [esp+32], eax |
3446 | ret |
3445 | ret |
3447 | ;--------------------------------------------------------------------------------------------- |
3446 | ;--------------------------------------------------------------------------------------------- |
3448 | 3447 | ||
3449 | 3448 | ||
3450 | ; check if pixel is allowed to be drawn |
3449 | ; check if pixel is allowed to be drawn |
3451 | 3450 | ||
3452 | ;checkpixel: |
3451 | ;checkpixel: |
3453 | ; push eax edx |
3452 | ; push eax edx |
3454 | 3453 | ||
3455 | ;; mov edx, [Screen_Max_X] ; screen x size |
3454 | ;; mov edx, [Screen_Max_X] ; screen x size |
3456 | ;; inc edx |
3455 | ;; inc edx |
3457 | ;; imul edx, ebx |
3456 | ;; imul edx, ebx |
3458 | ; mov edx, [d_width_calc_area + ebx*4] |
3457 | ; mov edx, [d_width_calc_area + ebx*4] |
3459 | ; add eax, [_WinMapAddress] |
3458 | ; add eax, [_WinMapAddress] |
3460 | ; mov dl, [eax+edx]; lea eax, [...] |
3459 | ; mov dl, [eax+edx]; lea eax, [...] |
3461 | 3460 | ||
3462 | ; xor ecx, ecx |
3461 | ; xor ecx, ecx |
3463 | ; mov eax, [CURRENT_TASK] |
3462 | ; mov eax, [CURRENT_TASK] |
3464 | ; cmp al, dl |
3463 | ; cmp al, dl |
3465 | ; setne cl |
3464 | ; setne cl |
3466 | 3465 | ||
3467 | ; pop edx eax |
3466 | ; pop edx eax |
3468 | ; ret |
3467 | ; ret |
3469 | 3468 | ||
3470 | iglobal |
3469 | iglobal |
3471 | cpustring db 'CPU',0 |
3470 | cpustring db 'CPU',0 |
3472 | endg |
3471 | endg |
3473 | 3472 | ||
3474 | uglobal |
3473 | uglobal |
3475 | background_defined db 0 ; diamond, 11.04.2006 |
3474 | background_defined db 0 ; diamond, 11.04.2006 |
3476 | endg |
3475 | endg |
3477 | ;----------------------------------------------------------------------------- |
3476 | ;----------------------------------------------------------------------------- |
3478 | align 4 |
3477 | align 4 |
3479 | checkmisc: |
3478 | checkmisc: |
3480 | cmp [ctrl_alt_del], 1 |
3479 | cmp [ctrl_alt_del], 1 |
3481 | jne nocpustart |
3480 | jne nocpustart |
3482 | 3481 | ||
3483 | mov ebp, cpustring |
3482 | mov ebp, cpustring |
3484 | call fs_execute_from_sysdir |
3483 | call fs_execute_from_sysdir |
3485 | 3484 | ||
3486 | mov [ctrl_alt_del], 0 |
3485 | mov [ctrl_alt_del], 0 |
3487 | ;-------------------------------------- |
3486 | ;-------------------------------------- |
3488 | align 4 |
3487 | align 4 |
3489 | nocpustart: |
3488 | nocpustart: |
3490 | cmp [mouse_active], 1 |
3489 | cmp [mouse_active], 1 |
3491 | jne mouse_not_active |
3490 | jne mouse_not_active |
3492 | mov [mouse_active], 0 |
3491 | mov [mouse_active], 0 |
3493 | 3492 | ||
3494 | xor edi, edi |
3493 | xor edi, edi |
3495 | mov ebx, CURRENT_TASK |
3494 | mov ebx, CURRENT_TASK |
3496 | 3495 | ||
3497 | mov ecx, [TASK_COUNT] |
3496 | mov ecx, [TASK_COUNT] |
3498 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3497 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3499 | shl eax, 8 |
3498 | shl eax, 8 |
3500 | push eax |
3499 | push eax |
3501 | 3500 | ||
3502 | movzx eax, word [MOUSE_X] |
3501 | movzx eax, word [MOUSE_X] |
3503 | movzx edx, word [MOUSE_Y] |
3502 | movzx edx, word [MOUSE_Y] |
3504 | ;-------------------------------------- |
3503 | ;-------------------------------------- |
3505 | align 4 |
3504 | align 4 |
3506 | .set_mouse_event: |
3505 | .set_mouse_event: |
3507 | add edi, 256 |
3506 | add edi, 256 |
3508 | add ebx, 32 |
3507 | add ebx, 32 |
3509 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3508 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3510 | jz .pos_filter |
3509 | jz .pos_filter |
3511 | 3510 | ||
3512 | cmp edi, [esp] ; skip if filtration active |
3511 | cmp edi, [esp] ; skip if filtration active |
3513 | jne .skip |
3512 | jne .skip |
3514 | ;-------------------------------------- |
3513 | ;-------------------------------------- |
3515 | align 4 |
3514 | align 4 |
3516 | .pos_filter: |
3515 | .pos_filter: |
3517 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3516 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3518 | jz .set |
3517 | jz .set |
3519 | 3518 | ||
3520 | mov esi, [ebx-twdw+WDATA.box.left] |
3519 | mov esi, [ebx-twdw+WDATA.box.left] |
3521 | cmp eax, esi |
3520 | cmp eax, esi |
3522 | jb .skip |
3521 | jb .skip |
3523 | add esi, [ebx-twdw+WDATA.box.width] |
3522 | add esi, [ebx-twdw+WDATA.box.width] |
3524 | cmp eax, esi |
3523 | cmp eax, esi |
3525 | ja .skip |
3524 | ja .skip |
3526 | 3525 | ||
3527 | mov esi, [ebx-twdw+WDATA.box.top] |
3526 | mov esi, [ebx-twdw+WDATA.box.top] |
3528 | cmp edx, esi |
3527 | cmp edx, esi |
3529 | jb .skip |
3528 | jb .skip |
3530 | add esi, [ebx-twdw+WDATA.box.height] |
3529 | add esi, [ebx-twdw+WDATA.box.height] |
3531 | cmp edx, esi |
3530 | cmp edx, esi |
3532 | ja .skip |
3531 | ja .skip |
3533 | ;-------------------------------------- |
3532 | ;-------------------------------------- |
3534 | align 4 |
3533 | align 4 |
3535 | .set: |
3534 | .set: |
3536 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3535 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3537 | ;-------------------------------------- |
3536 | ;-------------------------------------- |
3538 | align 4 |
3537 | align 4 |
3539 | .skip: |
3538 | .skip: |
3540 | loop .set_mouse_event |
3539 | loop .set_mouse_event |
3541 | 3540 | ||
3542 | pop eax |
3541 | pop eax |
3543 | ;-------------------------------------- |
3542 | ;-------------------------------------- |
3544 | align 4 |
3543 | align 4 |
3545 | mouse_not_active: |
3544 | mouse_not_active: |
3546 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3545 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3547 | jz nobackgr |
3546 | jz nobackgr |
3548 | 3547 | ||
3549 | cmp [background_defined], 0 |
3548 | cmp [background_defined], 0 |
3550 | jz nobackgr |
3549 | jz nobackgr |
3551 | ;-------------------------------------- |
3550 | ;-------------------------------------- |
3552 | align 4 |
3551 | align 4 |
3553 | backgr: |
3552 | backgr: |
3554 | mov eax, [draw_data+32 + RECT.left] |
3553 | mov eax, [draw_data+32 + RECT.left] |
3555 | shl eax, 16 |
3554 | shl eax, 16 |
3556 | add eax, [draw_data+32 + RECT.right] |
3555 | add eax, [draw_data+32 + RECT.right] |
3557 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3556 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3558 | 3557 | ||
3559 | mov eax, [draw_data+32 + RECT.top] |
3558 | mov eax, [draw_data+32 + RECT.top] |
3560 | shl eax, 16 |
3559 | shl eax, 16 |
3561 | add eax, [draw_data+32 + RECT.bottom] |
3560 | add eax, [draw_data+32 + RECT.bottom] |
3562 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3561 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3563 | 3562 | ||
3564 | call drawbackground |
3563 | call drawbackground |
3565 | ; DEBUGF 1, "K : drawbackground\n" |
3564 | ; DEBUGF 1, "K : drawbackground\n" |
3566 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3565 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3567 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3566 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3568 | ;--------- set event 5 start ---------- |
3567 | ;--------- set event 5 start ---------- |
3569 | push ecx edi |
3568 | push ecx edi |
3570 | xor edi, edi |
3569 | xor edi, edi |
3571 | mov ecx, [TASK_COUNT] |
3570 | mov ecx, [TASK_COUNT] |
3572 | ;-------------------------------------- |
3571 | ;-------------------------------------- |
3573 | align 4 |
3572 | align 4 |
3574 | set_bgr_event: |
3573 | set_bgr_event: |
3575 | add edi, 256 |
3574 | add edi, 256 |
3576 | mov eax, [BG_Rect_X_left_right] |
3575 | mov eax, [BG_Rect_X_left_right] |
3577 | mov edx, [BG_Rect_Y_top_bottom] |
3576 | mov edx, [BG_Rect_Y_top_bottom] |
3578 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3577 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3579 | jz .set |
3578 | jz .set |
3580 | .join: |
3579 | .join: |
3581 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3580 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3582 | jae @f |
3581 | jae @f |
3583 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3582 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3584 | @@: |
3583 | @@: |
3585 | shr eax, 16 |
3584 | shr eax, 16 |
3586 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3585 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3587 | jbe @f |
3586 | jbe @f |
3588 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3587 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3589 | @@: |
3588 | @@: |
3590 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3589 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3591 | jae @f |
3590 | jae @f |
3592 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3591 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3593 | @@: |
3592 | @@: |
3594 | shr edx, 16 |
3593 | shr edx, 16 |
3595 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3594 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3596 | jbe @f |
3595 | jbe @f |
3597 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3596 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3598 | @@: |
3597 | @@: |
3599 | jmp .common |
3598 | jmp .common |
3600 | .set: |
3599 | .set: |
3601 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3600 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3602 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3601 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3603 | .common: |
3602 | .common: |
3604 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3603 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3605 | loop set_bgr_event |
3604 | loop set_bgr_event |
3606 | pop edi ecx |
3605 | pop edi ecx |
3607 | ;--------- set event 5 stop ----------- |
3606 | ;--------- set event 5 stop ----------- |
3608 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3607 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3609 | jnz backgr |
3608 | jnz backgr |
3610 | 3609 | ||
3611 | xor eax, eax |
3610 | xor eax, eax |
3612 | mov [draw_data+32 + RECT.left], eax |
3611 | mov [draw_data+32 + RECT.left], eax |
3613 | mov [draw_data+32 + RECT.top], eax |
3612 | mov [draw_data+32 + RECT.top], eax |
3614 | mov [draw_data+32 + RECT.right], eax |
3613 | mov [draw_data+32 + RECT.right], eax |
3615 | mov [draw_data+32 + RECT.bottom], eax |
3614 | mov [draw_data+32 + RECT.bottom], eax |
3616 | ;-------------------------------------- |
3615 | ;-------------------------------------- |
3617 | align 4 |
3616 | align 4 |
3618 | nobackgr: |
3617 | nobackgr: |
3619 | ; system shutdown request |
3618 | ; system shutdown request |
3620 | cmp [SYS_SHUTDOWN], byte 0 |
3619 | cmp [SYS_SHUTDOWN], byte 0 |
3621 | je noshutdown |
3620 | je noshutdown |
3622 | 3621 | ||
3623 | mov edx, [shutdown_processes] |
3622 | mov edx, [shutdown_processes] |
3624 | 3623 | ||
3625 | cmp [SYS_SHUTDOWN], dl |
3624 | cmp [SYS_SHUTDOWN], dl |
3626 | jne noshutdown |
3625 | jne noshutdown |
3627 | 3626 | ||
3628 | lea ecx, [edx-1] |
3627 | lea ecx, [edx-1] |
3629 | mov edx, OS_BASE+0x3040 |
3628 | mov edx, OS_BASE+0x3040 |
3630 | jecxz no_mark_system_shutdown |
3629 | jecxz no_mark_system_shutdown |
3631 | ;-------------------------------------- |
3630 | ;-------------------------------------- |
3632 | align 4 |
3631 | align 4 |
3633 | markz: |
3632 | markz: |
3634 | push ecx edx |
3633 | push ecx edx |
3635 | cmp [edx+TASKDATA.state], 9 |
3634 | cmp [edx+TASKDATA.state], 9 |
3636 | jz .nokill |
3635 | jz .nokill |
3637 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3636 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3638 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3637 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3639 | jz .nokill |
3638 | jz .nokill |
3640 | call request_terminate |
3639 | call request_terminate |
3641 | jmp .common |
3640 | jmp .common |
3642 | .nokill: |
3641 | .nokill: |
3643 | dec byte [SYS_SHUTDOWN] |
3642 | dec byte [SYS_SHUTDOWN] |
3644 | xor eax, eax |
3643 | xor eax, eax |
3645 | .common: |
3644 | .common: |
3646 | pop edx ecx |
3645 | pop edx ecx |
3647 | test eax, eax |
3646 | test eax, eax |
3648 | jz @f |
3647 | jz @f |
3649 | mov [edx+TASKDATA.state], byte 3 |
3648 | mov [edx+TASKDATA.state], byte 3 |
3650 | @@: |
3649 | @@: |
3651 | add edx, 0x20 |
3650 | add edx, 0x20 |
3652 | loop markz |
3651 | loop markz |
3653 | call wakeup_osloop |
3652 | call wakeup_osloop |
3654 | ;-------------------------------------- |
3653 | ;-------------------------------------- |
3655 | align 4 |
3654 | align 4 |
3656 | @@: |
3655 | @@: |
3657 | no_mark_system_shutdown: |
3656 | no_mark_system_shutdown: |
3658 | dec byte [SYS_SHUTDOWN] |
3657 | dec byte [SYS_SHUTDOWN] |
3659 | je system_shutdown |
3658 | je system_shutdown |
3660 | ;-------------------------------------- |
3659 | ;-------------------------------------- |
3661 | align 4 |
3660 | align 4 |
3662 | noshutdown: |
3661 | noshutdown: |
3663 | mov eax, [TASK_COUNT] ; termination |
3662 | mov eax, [TASK_COUNT] ; termination |
3664 | mov ebx, TASK_DATA+TASKDATA.state |
3663 | mov ebx, TASK_DATA+TASKDATA.state |
3665 | mov esi, 1 |
3664 | mov esi, 1 |
3666 | ;-------------------------------------- |
3665 | ;-------------------------------------- |
3667 | align 4 |
3666 | align 4 |
3668 | newct: |
3667 | newct: |
3669 | mov cl, [ebx] |
3668 | mov cl, [ebx] |
3670 | cmp cl, byte 3 |
3669 | cmp cl, byte 3 |
3671 | jz .terminate |
3670 | jz .terminate |
3672 | 3671 | ||
3673 | cmp cl, byte 4 |
3672 | cmp cl, byte 4 |
3674 | jnz .noterminate |
3673 | jnz .noterminate |
3675 | .terminate: |
3674 | .terminate: |
3676 | pushad |
3675 | pushad |
3677 | mov ecx, eax |
3676 | mov ecx, eax |
3678 | shl ecx, 8 |
3677 | shl ecx, 8 |
3679 | add ecx, SLOT_BASE |
3678 | add ecx, SLOT_BASE |
3680 | call restore_default_cursor_before_killing |
3679 | call restore_default_cursor_before_killing |
3681 | popad |
3680 | popad |
3682 | 3681 | ||
3683 | pushad |
3682 | pushad |
3684 | call terminate |
3683 | call terminate |
3685 | popad |
3684 | popad |
3686 | cmp byte [SYS_SHUTDOWN], 0 |
3685 | cmp byte [SYS_SHUTDOWN], 0 |
3687 | jz .noterminate |
3686 | jz .noterminate |
3688 | dec byte [SYS_SHUTDOWN] |
3687 | dec byte [SYS_SHUTDOWN] |
3689 | je system_shutdown |
3688 | je system_shutdown |
3690 | 3689 | ||
3691 | .noterminate: |
3690 | .noterminate: |
3692 | add ebx, 0x20 |
3691 | add ebx, 0x20 |
3693 | inc esi |
3692 | inc esi |
3694 | dec eax |
3693 | dec eax |
3695 | jnz newct |
3694 | jnz newct |
3696 | ret |
3695 | ret |
3697 | ;----------------------------------------------------------------------------- |
3696 | ;----------------------------------------------------------------------------- |
3698 | align 4 |
3697 | align 4 |
3699 | redrawscreen: |
3698 | redrawscreen: |
3700 | ; eax , if process window_data base is eax, do not set flag/limits |
3699 | ; eax , if process window_data base is eax, do not set flag/limits |
3701 | 3700 | ||
3702 | pushad |
3701 | pushad |
3703 | push eax |
3702 | push eax |
3704 | 3703 | ||
3705 | ;;; mov ebx,2 |
3704 | ;;; mov ebx,2 |
3706 | ;;; call delay_hs |
3705 | ;;; call delay_hs |
3707 | 3706 | ||
3708 | ;mov ecx,0 ; redraw flags for apps |
3707 | ;mov ecx,0 ; redraw flags for apps |
3709 | xor ecx, ecx |
3708 | xor ecx, ecx |
3710 | ;-------------------------------------- |
3709 | ;-------------------------------------- |
3711 | align 4 |
3710 | align 4 |
3712 | newdw2: |
3711 | newdw2: |
3713 | inc ecx |
3712 | inc ecx |
3714 | push ecx |
3713 | push ecx |
3715 | 3714 | ||
3716 | mov eax, ecx |
3715 | mov eax, ecx |
3717 | shl eax, 5 |
3716 | shl eax, 5 |
3718 | add eax, window_data |
3717 | add eax, window_data |
3719 | 3718 | ||
3720 | cmp eax, [esp+4] |
3719 | cmp eax, [esp+4] |
3721 | je not_this_task |
3720 | je not_this_task |
3722 | ; check if window in redraw area |
3721 | ; check if window in redraw area |
3723 | mov edi, eax |
3722 | mov edi, eax |
3724 | 3723 | ||
3725 | cmp ecx, 1 ; limit for background |
3724 | cmp ecx, 1 ; limit for background |
3726 | jz bgli |
3725 | jz bgli |
3727 | 3726 | ||
3728 | mov eax, [edi + WDATA.box.left] |
3727 | mov eax, [edi + WDATA.box.left] |
3729 | mov ebx, [edi + WDATA.box.top] |
3728 | mov ebx, [edi + WDATA.box.top] |
3730 | mov ecx, [edi + WDATA.box.width] |
3729 | mov ecx, [edi + WDATA.box.width] |
3731 | mov edx, [edi + WDATA.box.height] |
3730 | mov edx, [edi + WDATA.box.height] |
3732 | add ecx, eax |
3731 | add ecx, eax |
3733 | add edx, ebx |
3732 | add edx, ebx |
3734 | 3733 | ||
3735 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3734 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3736 | cmp ecx, ebx |
3735 | cmp ecx, ebx |
3737 | jb ricino |
3736 | jb ricino |
3738 | 3737 | ||
3739 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3738 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3740 | cmp ecx, eax |
3739 | cmp ecx, eax |
3741 | jb ricino |
3740 | jb ricino |
3742 | 3741 | ||
3743 | mov eax, [edi + WDATA.box.left] |
3742 | mov eax, [edi + WDATA.box.left] |
3744 | mov ebx, [edi + WDATA.box.top] |
3743 | mov ebx, [edi + WDATA.box.top] |
3745 | mov ecx, [edi + WDATA.box.width] |
3744 | mov ecx, [edi + WDATA.box.width] |
3746 | mov edx, [edi + WDATA.box.height] |
3745 | mov edx, [edi + WDATA.box.height] |
3747 | add ecx, eax |
3746 | add ecx, eax |
3748 | add edx, ebx |
3747 | add edx, ebx |
3749 | 3748 | ||
3750 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3749 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3751 | cmp edx, eax |
3750 | cmp edx, eax |
3752 | jb ricino |
3751 | jb ricino |
3753 | 3752 | ||
3754 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3753 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3755 | cmp ecx, eax |
3754 | cmp ecx, eax |
3756 | jb ricino |
3755 | jb ricino |
3757 | ;-------------------------------------- |
3756 | ;-------------------------------------- |
3758 | align 4 |
3757 | align 4 |
3759 | bgli: |
3758 | bgli: |
3760 | cmp dword[esp], 1 |
3759 | cmp dword[esp], 1 |
3761 | jnz .az |
3760 | jnz .az |
3762 | 3761 | ||
3763 | cmp byte[REDRAW_BACKGROUND], 0 |
3762 | cmp byte[REDRAW_BACKGROUND], 0 |
3764 | jz .az |
3763 | jz .az |
3765 | 3764 | ||
3766 | mov dl, 0 |
3765 | mov dl, 0 |
3767 | lea eax, [edi+draw_data-window_data] |
3766 | lea eax, [edi+draw_data-window_data] |
3768 | mov ebx, [draw_limits.left] |
3767 | mov ebx, [draw_limits.left] |
3769 | cmp ebx, [eax+RECT.left] |
3768 | cmp ebx, [eax+RECT.left] |
3770 | jae @f |
3769 | jae @f |
3771 | 3770 | ||
3772 | mov [eax+RECT.left], ebx |
3771 | mov [eax+RECT.left], ebx |
3773 | mov dl, 1 |
3772 | mov dl, 1 |
3774 | ;-------------------------------------- |
3773 | ;-------------------------------------- |
3775 | align 4 |
3774 | align 4 |
3776 | @@: |
3775 | @@: |
3777 | mov ebx, [draw_limits.top] |
3776 | mov ebx, [draw_limits.top] |
3778 | cmp ebx, [eax+RECT.top] |
3777 | cmp ebx, [eax+RECT.top] |
3779 | jae @f |
3778 | jae @f |
3780 | 3779 | ||
3781 | mov [eax+RECT.top], ebx |
3780 | mov [eax+RECT.top], ebx |
3782 | mov dl, 1 |
3781 | mov dl, 1 |
3783 | ;-------------------------------------- |
3782 | ;-------------------------------------- |
3784 | align 4 |
3783 | align 4 |
3785 | @@: |
3784 | @@: |
3786 | mov ebx, [draw_limits.right] |
3785 | mov ebx, [draw_limits.right] |
3787 | cmp ebx, [eax+RECT.right] |
3786 | cmp ebx, [eax+RECT.right] |
3788 | jbe @f |
3787 | jbe @f |
3789 | 3788 | ||
3790 | mov [eax+RECT.right], ebx |
3789 | mov [eax+RECT.right], ebx |
3791 | mov dl, 1 |
3790 | mov dl, 1 |
3792 | ;-------------------------------------- |
3791 | ;-------------------------------------- |
3793 | align 4 |
3792 | align 4 |
3794 | @@: |
3793 | @@: |
3795 | mov ebx, [draw_limits.bottom] |
3794 | mov ebx, [draw_limits.bottom] |
3796 | cmp ebx, [eax+RECT.bottom] |
3795 | cmp ebx, [eax+RECT.bottom] |
3797 | jbe @f |
3796 | jbe @f |
3798 | 3797 | ||
3799 | mov [eax+RECT.bottom], ebx |
3798 | mov [eax+RECT.bottom], ebx |
3800 | mov dl, 1 |
3799 | mov dl, 1 |
3801 | ;-------------------------------------- |
3800 | ;-------------------------------------- |
3802 | align 4 |
3801 | align 4 |
3803 | @@: |
3802 | @@: |
3804 | add byte[REDRAW_BACKGROUND], dl |
3803 | add byte[REDRAW_BACKGROUND], dl |
3805 | call wakeup_osloop |
3804 | call wakeup_osloop |
3806 | jmp newdw8 |
3805 | jmp newdw8 |
3807 | ;-------------------------------------- |
3806 | ;-------------------------------------- |
3808 | align 4 |
3807 | align 4 |
3809 | .az: |
3808 | .az: |
3810 | mov eax, edi |
3809 | mov eax, edi |
3811 | add eax, draw_data-window_data |
3810 | add eax, draw_data-window_data |
3812 | 3811 | ||
3813 | mov ebx, [draw_limits.left] ; set limits |
3812 | mov ebx, [draw_limits.left] ; set limits |
3814 | mov [eax + RECT.left], ebx |
3813 | mov [eax + RECT.left], ebx |
3815 | mov ebx, [draw_limits.top] |
3814 | mov ebx, [draw_limits.top] |
3816 | mov [eax + RECT.top], ebx |
3815 | mov [eax + RECT.top], ebx |
3817 | mov ebx, [draw_limits.right] |
3816 | mov ebx, [draw_limits.right] |
3818 | mov [eax + RECT.right], ebx |
3817 | mov [eax + RECT.right], ebx |
3819 | mov ebx, [draw_limits.bottom] |
3818 | mov ebx, [draw_limits.bottom] |
3820 | mov [eax + RECT.bottom], ebx |
3819 | mov [eax + RECT.bottom], ebx |
3821 | 3820 | ||
3822 | sub eax, draw_data-window_data |
3821 | sub eax, draw_data-window_data |
3823 | 3822 | ||
3824 | cmp dword [esp], 1 |
3823 | cmp dword [esp], 1 |
3825 | jne nobgrd |
3824 | jne nobgrd |
3826 | inc byte[REDRAW_BACKGROUND] |
3825 | inc byte[REDRAW_BACKGROUND] |
3827 | call wakeup_osloop |
3826 | call wakeup_osloop |
3828 | ;-------------------------------------- |
3827 | ;-------------------------------------- |
3829 | align 4 |
3828 | align 4 |
3830 | newdw8: |
3829 | newdw8: |
3831 | nobgrd: |
3830 | nobgrd: |
3832 | 3831 | ||
3833 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3832 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3834 | ;-------------------------------------- |
3833 | ;-------------------------------------- |
3835 | align 4 |
3834 | align 4 |
3836 | ricino: |
3835 | ricino: |
3837 | not_this_task: |
3836 | not_this_task: |
3838 | pop ecx |
3837 | pop ecx |
3839 | 3838 | ||
3840 | cmp ecx, [TASK_COUNT] |
3839 | cmp ecx, [TASK_COUNT] |
3841 | jle newdw2 |
3840 | jle newdw2 |
3842 | 3841 | ||
3843 | pop eax |
3842 | pop eax |
3844 | popad |
3843 | popad |
3845 | ret |
3844 | ret |
3846 | ;----------------------------------------------------------------------------- |
3845 | ;----------------------------------------------------------------------------- |
3847 | align 4 |
3846 | align 4 |
3848 | calculatebackground: ; background |
3847 | calculatebackground: ; background |
3849 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3848 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3850 | mov eax, 0x01010101 |
3849 | mov eax, 0x01010101 |
3851 | mov ecx, [_WinMapSize] |
3850 | mov ecx, [_WinMapSize] |
3852 | shr ecx, 2 |
3851 | shr ecx, 2 |
3853 | rep stosd |
3852 | rep stosd |
3854 | 3853 | ||
3855 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3854 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3856 | ret |
3855 | ret |
3857 | ;----------------------------------------------------------------------------- |
3856 | ;----------------------------------------------------------------------------- |
3858 | uglobal |
3857 | uglobal |
3859 | imax dd 0x0 |
3858 | imax dd 0x0 |
3860 | endg |
3859 | endg |
3861 | ;----------------------------------------------------------------------------- |
3860 | ;----------------------------------------------------------------------------- |
3862 | align 4 |
3861 | align 4 |
3863 | delay_ms: ; delay in 1/1000 sec |
3862 | delay_ms: ; delay in 1/1000 sec |
3864 | push eax |
3863 | push eax |
3865 | push ecx |
3864 | push ecx |
3866 | 3865 | ||
3867 | mov ecx, esi |
3866 | mov ecx, esi |
3868 | ; |
3867 | ; |
3869 | imul ecx, 33941 |
3868 | imul ecx, 33941 |
3870 | shr ecx, 9 |
3869 | shr ecx, 9 |
3871 | ; |
3870 | ; |
3872 | 3871 | ||
3873 | in al, 0x61 |
3872 | in al, 0x61 |
3874 | and al, 0x10 |
3873 | and al, 0x10 |
3875 | mov ah, al |
3874 | mov ah, al |
3876 | cld |
3875 | cld |
3877 | ;-------------------------------------- |
3876 | ;-------------------------------------- |
3878 | align 4 |
3877 | align 4 |
3879 | cnt1: |
3878 | cnt1: |
3880 | in al, 0x61 |
3879 | in al, 0x61 |
3881 | and al, 0x10 |
3880 | and al, 0x10 |
3882 | cmp al, ah |
3881 | cmp al, ah |
3883 | jz cnt1 |
3882 | jz cnt1 |
3884 | 3883 | ||
3885 | mov ah, al |
3884 | mov ah, al |
3886 | loop cnt1 |
3885 | loop cnt1 |
3887 | 3886 | ||
3888 | pop ecx |
3887 | pop ecx |
3889 | pop eax |
3888 | pop eax |
3890 | ret |
3889 | ret |
3891 | ;----------------------------------------------------------------------------- |
3890 | ;----------------------------------------------------------------------------- |
3892 | align 4 |
3891 | align 4 |
3893 | set_app_param: |
3892 | set_app_param: |
3894 | mov edi, [TASK_BASE] |
3893 | mov edi, [TASK_BASE] |
3895 | mov eax, ebx |
3894 | mov eax, ebx |
3896 | btr eax, 3 ; move MOUSE_FILTRATION |
3895 | btr eax, 3 ; move MOUSE_FILTRATION |
3897 | mov ebx, [current_slot] ; bit into event_filter |
3896 | mov ebx, [current_slot] ; bit into event_filter |
3898 | setc byte [ebx+APPDATA.event_filter] |
3897 | setc byte [ebx+APPDATA.event_filter] |
3899 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3898 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3900 | mov [esp+32], eax ; return old mask value |
3899 | mov [esp+32], eax ; return old mask value |
3901 | ret |
3900 | ret |
3902 | ;----------------------------------------------------------------------------- |
3901 | ;----------------------------------------------------------------------------- |
3903 | 3902 | ||
3904 | ; this is for syscall |
3903 | ; this is for syscall |
3905 | proc delay_hs_unprotected |
3904 | proc delay_hs_unprotected |
3906 | call unprotect_from_terminate |
3905 | call unprotect_from_terminate |
3907 | call delay_hs |
3906 | call delay_hs |
3908 | call protect_from_terminate |
3907 | call protect_from_terminate |
3909 | ret |
3908 | ret |
3910 | endp |
3909 | endp |
3911 | 3910 | ||
3912 | if 1 |
3911 | if 1 |
3913 | align 4 |
3912 | align 4 |
3914 | delay_hs: ; delay in 1/100 secs |
3913 | delay_hs: ; delay in 1/100 secs |
3915 | ; ebx = delay time |
3914 | ; ebx = delay time |
3916 | 3915 | ||
3917 | pushad |
3916 | pushad |
3918 | push ebx |
3917 | push ebx |
3919 | xor esi, esi |
3918 | xor esi, esi |
3920 | mov ecx, MANUAL_DESTROY |
3919 | mov ecx, MANUAL_DESTROY |
3921 | call create_event |
3920 | call create_event |
3922 | test eax, eax |
3921 | test eax, eax |
3923 | jz .done |
3922 | jz .done |
3924 | 3923 | ||
3925 | mov ebx, edx |
3924 | mov ebx, edx |
3926 | mov ecx, [esp] |
3925 | mov ecx, [esp] |
3927 | push edx |
3926 | push edx |
3928 | push eax |
3927 | push eax |
3929 | call wait_event_timeout |
3928 | call wait_event_timeout |
3930 | pop eax |
3929 | pop eax |
3931 | pop ebx |
3930 | pop ebx |
3932 | call destroy_event |
3931 | call destroy_event |
3933 | .done: |
3932 | .done: |
3934 | add esp, 4 |
3933 | add esp, 4 |
3935 | popad |
3934 | popad |
3936 | ret |
3935 | ret |
3937 | 3936 | ||
3938 | else |
3937 | else |
3939 | 3938 | ||
3940 | align 4 |
3939 | align 4 |
3941 | delay_hs: ; delay in 1/100 secs |
3940 | delay_hs: ; delay in 1/100 secs |
3942 | ; ebx = delay time |
3941 | ; ebx = delay time |
3943 | push ecx |
3942 | push ecx |
3944 | push edx |
3943 | push edx |
3945 | 3944 | ||
3946 | mov edx, [timer_ticks] |
3945 | mov edx, [timer_ticks] |
3947 | ;-------------------------------------- |
3946 | ;-------------------------------------- |
3948 | align 4 |
3947 | align 4 |
3949 | newtic: |
3948 | newtic: |
3950 | mov ecx, [timer_ticks] |
3949 | mov ecx, [timer_ticks] |
3951 | sub ecx, edx |
3950 | sub ecx, edx |
3952 | cmp ecx, ebx |
3951 | cmp ecx, ebx |
3953 | jae zerodelay |
3952 | jae zerodelay |
3954 | 3953 | ||
3955 | call change_task |
3954 | call change_task |
3956 | 3955 | ||
3957 | jmp newtic |
3956 | jmp newtic |
3958 | ;-------------------------------------- |
3957 | ;-------------------------------------- |
3959 | align 4 |
3958 | align 4 |
3960 | zerodelay: |
3959 | zerodelay: |
3961 | pop edx |
3960 | pop edx |
3962 | pop ecx |
3961 | pop ecx |
3963 | ret |
3962 | ret |
3964 | end if |
3963 | end if |
3965 | 3964 | ||
3966 | ;----------------------------------------------------------------------------- |
3965 | ;----------------------------------------------------------------------------- |
3967 | align 16 ;very often call this subrutine |
3966 | align 16 ;very often call this subrutine |
3968 | memmove: ; memory move in bytes |
3967 | memmove: ; memory move in bytes |
3969 | ; eax = from |
3968 | ; eax = from |
3970 | ; ebx = to |
3969 | ; ebx = to |
3971 | ; ecx = no of bytes |
3970 | ; ecx = no of bytes |
3972 | test ecx, ecx |
3971 | test ecx, ecx |
3973 | jle .ret |
3972 | jle .ret |
3974 | 3973 | ||
3975 | push esi edi ecx |
3974 | push esi edi ecx |
3976 | 3975 | ||
3977 | mov edi, ebx |
3976 | mov edi, ebx |
3978 | mov esi, eax |
3977 | mov esi, eax |
3979 | 3978 | ||
3980 | test ecx, not 11b |
3979 | test ecx, not 11b |
3981 | jz @f |
3980 | jz @f |
3982 | 3981 | ||
3983 | push ecx |
3982 | push ecx |
3984 | shr ecx, 2 |
3983 | shr ecx, 2 |
3985 | rep movsd |
3984 | rep movsd |
3986 | pop ecx |
3985 | pop ecx |
3987 | and ecx, 11b |
3986 | and ecx, 11b |
3988 | jz .finish |
3987 | jz .finish |
3989 | ;-------------------------------------- |
3988 | ;-------------------------------------- |
3990 | align 4 |
3989 | align 4 |
3991 | @@: |
3990 | @@: |
3992 | rep movsb |
3991 | rep movsb |
3993 | ;-------------------------------------- |
3992 | ;-------------------------------------- |
3994 | align 4 |
3993 | align 4 |
3995 | .finish: |
3994 | .finish: |
3996 | pop ecx edi esi |
3995 | pop ecx edi esi |
3997 | ;-------------------------------------- |
3996 | ;-------------------------------------- |
3998 | align 4 |
3997 | align 4 |
3999 | .ret: |
3998 | .ret: |
4000 | ret |
3999 | ret |
4001 | ;----------------------------------------------------------------------------- |
4000 | ;----------------------------------------------------------------------------- |
4002 | ; |
4001 | ; |
4003 | ;align 4 |
4002 | ;align 4 |
4004 | ; |
4003 | ; |
4005 | ;read_floppy_file: |
4004 | ;read_floppy_file: |
4006 | ; |
4005 | ; |
4007 | ;; as input |
4006 | ;; as input |
4008 | ;; |
4007 | ;; |
4009 | ;; eax pointer to file |
4008 | ;; eax pointer to file |
4010 | ;; ebx file lenght |
4009 | ;; ebx file lenght |
4011 | ;; ecx start 512 byte block number |
4010 | ;; ecx start 512 byte block number |
4012 | ;; edx number of blocks to read |
4011 | ;; edx number of blocks to read |
4013 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4012 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4014 | ;; |
4013 | ;; |
4015 | ;; |
4014 | ;; |
4016 | ;; on return |
4015 | ;; on return |
4017 | ;; |
4016 | ;; |
4018 | ;; eax = 0 command succesful |
4017 | ;; eax = 0 command succesful |
4019 | ;; 1 no fd base and/or partition defined |
4018 | ;; 1 no fd base and/or partition defined |
4020 | ;; 2 yet unsupported FS |
4019 | ;; 2 yet unsupported FS |
4021 | ;; 3 unknown FS |
4020 | ;; 3 unknown FS |
4022 | ;; 4 partition not defined at hd |
4021 | ;; 4 partition not defined at hd |
4023 | ;; 5 file not found |
4022 | ;; 5 file not found |
4024 | ;; ebx = size of file |
4023 | ;; ebx = size of file |
4025 | ; |
4024 | ; |
4026 | ; mov edi,[TASK_BASE] |
4025 | ; mov edi,[TASK_BASE] |
4027 | ; add edi,0x10 |
4026 | ; add edi,0x10 |
4028 | ; add esi,[edi] |
4027 | ; add esi,[edi] |
4029 | ; add eax,[edi] |
4028 | ; add eax,[edi] |
4030 | ; |
4029 | ; |
4031 | ; pushad |
4030 | ; pushad |
4032 | ; mov edi,esi |
4031 | ; mov edi,esi |
4033 | ; add edi,1024 |
4032 | ; add edi,1024 |
4034 | ; mov esi,0x100000+19*512 |
4033 | ; mov esi,0x100000+19*512 |
4035 | ; sub ecx,1 |
4034 | ; sub ecx,1 |
4036 | ; shl ecx,9 |
4035 | ; shl ecx,9 |
4037 | ; add esi,ecx |
4036 | ; add esi,ecx |
4038 | ; shl edx,9 |
4037 | ; shl edx,9 |
4039 | ; mov ecx,edx |
4038 | ; mov ecx,edx |
4040 | ; cld |
4039 | ; cld |
4041 | ; rep movsb |
4040 | ; rep movsb |
4042 | ; popad |
4041 | ; popad |
4043 | ; |
4042 | ; |
4044 | ; mov [esp+36],eax |
4043 | ; mov [esp+36],eax |
4045 | ; mov [esp+24],ebx |
4044 | ; mov [esp+24],ebx |
4046 | ; ret |
4045 | ; ret |
4047 | 4046 | ||
4048 | 4047 | ||
4049 | 4048 | ||
4050 | align 4 |
4049 | align 4 |
4051 | set_io_access_rights: |
4050 | set_io_access_rights: |
4052 | push edi eax |
4051 | push edi eax |
4053 | mov edi, tss._io_map_0 |
4052 | mov edi, tss._io_map_0 |
4054 | ; mov ecx,eax |
4053 | ; mov ecx,eax |
4055 | ; and ecx,7 ; offset in byte |
4054 | ; and ecx,7 ; offset in byte |
4056 | ; shr eax,3 ; number of byte |
4055 | ; shr eax,3 ; number of byte |
4057 | ; add edi,eax |
4056 | ; add edi,eax |
4058 | ; mov ebx,1 |
4057 | ; mov ebx,1 |
4059 | ; shl ebx,cl |
4058 | ; shl ebx,cl |
4060 | test ebp, ebp |
4059 | test ebp, ebp |
4061 | ; cmp ebp,0 ; enable access - ebp = 0 |
4060 | ; cmp ebp,0 ; enable access - ebp = 0 |
4062 | jnz .siar1 |
4061 | jnz .siar1 |
4063 | ; not ebx |
4062 | ; not ebx |
4064 | ; and [edi],byte bl |
4063 | ; and [edi],byte bl |
4065 | btr [edi], eax |
4064 | btr [edi], eax |
4066 | pop eax edi |
4065 | pop eax edi |
4067 | ret |
4066 | ret |
4068 | .siar1: |
4067 | .siar1: |
4069 | bts [edi], eax |
4068 | bts [edi], eax |
4070 | ; or [edi],byte bl ; disable access - ebp = 1 |
4069 | ; or [edi],byte bl ; disable access - ebp = 1 |
4071 | pop eax edi |
4070 | pop eax edi |
4072 | ret |
4071 | ret |
4073 | ;reserve/free group of ports |
4072 | ;reserve/free group of ports |
4074 | ; * eax = 46 - number function |
4073 | ; * eax = 46 - number function |
4075 | ; * ebx = 0 - reserve, 1 - free |
4074 | ; * ebx = 0 - reserve, 1 - free |
4076 | ; * ecx = number start arrea of ports |
4075 | ; * ecx = number start arrea of ports |
4077 | ; * edx = number end arrea of ports (include last number of port) |
4076 | ; * edx = number end arrea of ports (include last number of port) |
4078 | ;Return value: |
4077 | ;Return value: |
4079 | ; * eax = 0 - succesful |
4078 | ; * eax = 0 - succesful |
4080 | ; * eax = 1 - error |
4079 | ; * eax = 1 - error |
4081 | ; * The system has reserve this ports: |
4080 | ; * The system has reserve this ports: |
4082 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4081 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4083 | ;destroys eax,ebx, ebp |
4082 | ;destroys eax,ebx, ebp |
4084 | r_f_port_area: |
4083 | r_f_port_area: |
4085 | 4084 | ||
4086 | test ebx, ebx |
4085 | test ebx, ebx |
4087 | jnz free_port_area |
4086 | jnz free_port_area |
4088 | ; je r_port_area |
4087 | ; je r_port_area |
4089 | ; jmp free_port_area |
4088 | ; jmp free_port_area |
4090 | 4089 | ||
4091 | ; r_port_area: |
4090 | ; r_port_area: |
4092 | 4091 | ||
4093 | ; pushad |
4092 | ; pushad |
4094 | 4093 | ||
4095 | cmp ecx, edx ; beginning > end ? |
4094 | cmp ecx, edx ; beginning > end ? |
4096 | ja rpal1 |
4095 | ja rpal1 |
4097 | cmp edx, 65536 |
4096 | cmp edx, 65536 |
4098 | jae rpal1 |
4097 | jae rpal1 |
4099 | mov eax, [RESERVED_PORTS] |
4098 | mov eax, [RESERVED_PORTS] |
4100 | test eax, eax ; no reserved areas ? |
4099 | test eax, eax ; no reserved areas ? |
4101 | je rpal2 |
4100 | je rpal2 |
4102 | cmp eax, 255 ; max reserved |
4101 | cmp eax, 255 ; max reserved |
4103 | jae rpal1 |
4102 | jae rpal1 |
4104 | rpal3: |
4103 | rpal3: |
4105 | mov ebx, eax |
4104 | mov ebx, eax |
4106 | shl ebx, 4 |
4105 | shl ebx, 4 |
4107 | add ebx, RESERVED_PORTS |
4106 | add ebx, RESERVED_PORTS |
4108 | cmp ecx, [ebx+8] |
4107 | cmp ecx, [ebx+8] |
4109 | ja rpal4 |
4108 | ja rpal4 |
4110 | cmp edx, [ebx+4] |
4109 | cmp edx, [ebx+4] |
4111 | jae rpal1 |
4110 | jae rpal1 |
4112 | ; jb rpal4 |
4111 | ; jb rpal4 |
4113 | ; jmp rpal1 |
4112 | ; jmp rpal1 |
4114 | rpal4: |
4113 | rpal4: |
4115 | dec eax |
4114 | dec eax |
4116 | jnz rpal3 |
4115 | jnz rpal3 |
4117 | jmp rpal2 |
4116 | jmp rpal2 |
4118 | rpal1: |
4117 | rpal1: |
4119 | ; popad |
4118 | ; popad |
4120 | ; mov eax,1 |
4119 | ; mov eax,1 |
4121 | xor eax, eax |
4120 | xor eax, eax |
4122 | inc eax |
4121 | inc eax |
4123 | ret |
4122 | ret |
4124 | rpal2: |
4123 | rpal2: |
4125 | ; popad |
4124 | ; popad |
4126 | ; enable port access at port IO map |
4125 | ; enable port access at port IO map |
4127 | cli |
4126 | cli |
4128 | pushad ; start enable io map |
4127 | pushad ; start enable io map |
4129 | 4128 | ||
4130 | cmp edx, 65536;16384 |
4129 | cmp edx, 65536;16384 |
4131 | jae no_unmask_io; jge |
4130 | jae no_unmask_io; jge |
4132 | mov eax, ecx |
4131 | mov eax, ecx |
4133 | ; push ebp |
4132 | ; push ebp |
4134 | xor ebp, ebp ; enable - eax = port |
4133 | xor ebp, ebp ; enable - eax = port |
4135 | new_port_access: |
4134 | new_port_access: |
4136 | ; pushad |
4135 | ; pushad |
4137 | call set_io_access_rights |
4136 | call set_io_access_rights |
4138 | ; popad |
4137 | ; popad |
4139 | inc eax |
4138 | inc eax |
4140 | cmp eax, edx |
4139 | cmp eax, edx |
4141 | jbe new_port_access |
4140 | jbe new_port_access |
4142 | ; pop ebp |
4141 | ; pop ebp |
4143 | no_unmask_io: |
4142 | no_unmask_io: |
4144 | popad ; end enable io map |
4143 | popad ; end enable io map |
4145 | sti |
4144 | sti |
4146 | 4145 | ||
4147 | mov eax, [RESERVED_PORTS] |
4146 | mov eax, [RESERVED_PORTS] |
4148 | add eax, 1 |
4147 | add eax, 1 |
4149 | mov [RESERVED_PORTS], eax |
4148 | mov [RESERVED_PORTS], eax |
4150 | shl eax, 4 |
4149 | shl eax, 4 |
4151 | add eax, RESERVED_PORTS |
4150 | add eax, RESERVED_PORTS |
4152 | mov ebx, [TASK_BASE] |
4151 | mov ebx, [TASK_BASE] |
4153 | mov ebx, [ebx+TASKDATA.pid] |
4152 | mov ebx, [ebx+TASKDATA.pid] |
4154 | mov [eax], ebx |
4153 | mov [eax], ebx |
4155 | mov [eax+4], ecx |
4154 | mov [eax+4], ecx |
4156 | mov [eax+8], edx |
4155 | mov [eax+8], edx |
4157 | 4156 | ||
4158 | xor eax, eax |
4157 | xor eax, eax |
4159 | ret |
4158 | ret |
4160 | 4159 | ||
4161 | free_port_area: |
4160 | free_port_area: |
4162 | 4161 | ||
4163 | ; pushad |
4162 | ; pushad |
4164 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4163 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4165 | test eax, eax |
4164 | test eax, eax |
4166 | jz frpal2 |
4165 | jz frpal2 |
4167 | mov ebx, [TASK_BASE] |
4166 | mov ebx, [TASK_BASE] |
4168 | mov ebx, [ebx+TASKDATA.pid] |
4167 | mov ebx, [ebx+TASKDATA.pid] |
4169 | frpal3: |
4168 | frpal3: |
4170 | mov edi, eax |
4169 | mov edi, eax |
4171 | shl edi, 4 |
4170 | shl edi, 4 |
4172 | add edi, RESERVED_PORTS |
4171 | add edi, RESERVED_PORTS |
4173 | cmp ebx, [edi] |
4172 | cmp ebx, [edi] |
4174 | jne frpal4 |
4173 | jne frpal4 |
4175 | cmp ecx, [edi+4] |
4174 | cmp ecx, [edi+4] |
4176 | jne frpal4 |
4175 | jne frpal4 |
4177 | cmp edx, [edi+8] |
4176 | cmp edx, [edi+8] |
4178 | jne frpal4 |
4177 | jne frpal4 |
4179 | jmp frpal1 |
4178 | jmp frpal1 |
4180 | frpal4: |
4179 | frpal4: |
4181 | dec eax |
4180 | dec eax |
4182 | jnz frpal3 |
4181 | jnz frpal3 |
4183 | frpal2: |
4182 | frpal2: |
4184 | ; popad |
4183 | ; popad |
4185 | inc eax |
4184 | inc eax |
4186 | ret |
4185 | ret |
4187 | frpal1: |
4186 | frpal1: |
4188 | push ecx |
4187 | push ecx |
4189 | mov ecx, 256 |
4188 | mov ecx, 256 |
4190 | sub ecx, eax |
4189 | sub ecx, eax |
4191 | shl ecx, 4 |
4190 | shl ecx, 4 |
4192 | mov esi, edi |
4191 | mov esi, edi |
4193 | add esi, 16 |
4192 | add esi, 16 |
4194 | cld |
4193 | cld |
4195 | rep movsb |
4194 | rep movsb |
4196 | 4195 | ||
4197 | dec dword [RESERVED_PORTS] |
4196 | dec dword [RESERVED_PORTS] |
4198 | ;popad |
4197 | ;popad |
4199 | ;disable port access at port IO map |
4198 | ;disable port access at port IO map |
4200 | 4199 | ||
4201 | ; pushad ; start disable io map |
4200 | ; pushad ; start disable io map |
4202 | pop eax ;start port |
4201 | pop eax ;start port |
4203 | cmp edx, 65536;16384 |
4202 | cmp edx, 65536;16384 |
4204 | jge no_mask_io |
4203 | jge no_mask_io |
4205 | 4204 | ||
4206 | ; mov eax,ecx |
4205 | ; mov eax,ecx |
4207 | xor ebp, ebp |
4206 | xor ebp, ebp |
4208 | inc ebp |
4207 | inc ebp |
4209 | new_port_access_disable: |
4208 | new_port_access_disable: |
4210 | ; pushad |
4209 | ; pushad |
4211 | ; mov ebp,1 ; disable - eax = port |
4210 | ; mov ebp,1 ; disable - eax = port |
4212 | call set_io_access_rights |
4211 | call set_io_access_rights |
4213 | ; popad |
4212 | ; popad |
4214 | inc eax |
4213 | inc eax |
4215 | cmp eax, edx |
4214 | cmp eax, edx |
4216 | jbe new_port_access_disable |
4215 | jbe new_port_access_disable |
4217 | no_mask_io: |
4216 | no_mask_io: |
4218 | ; popad ; end disable io map |
4217 | ; popad ; end disable io map |
4219 | xor eax, eax |
4218 | xor eax, eax |
4220 | ret |
4219 | ret |
4221 | ;----------------------------------------------------------------------------- |
4220 | ;----------------------------------------------------------------------------- |
4222 | align 4 |
4221 | align 4 |
4223 | drawbackground: |
4222 | drawbackground: |
4224 | dbrv20: |
4223 | dbrv20: |
4225 | cmp [BgrDrawMode], dword 1 |
4224 | cmp [BgrDrawMode], dword 1 |
4226 | jne bgrstr |
4225 | jne bgrstr |
4227 | call vesa20_drawbackground_tiled |
4226 | call vesa20_drawbackground_tiled |
4228 | ; call [draw_pointer] |
4227 | ; call [draw_pointer] |
4229 | call __sys_draw_pointer |
4228 | call __sys_draw_pointer |
4230 | ret |
4229 | ret |
4231 | ;-------------------------------------- |
4230 | ;-------------------------------------- |
4232 | align 4 |
4231 | align 4 |
4233 | bgrstr: |
4232 | bgrstr: |
4234 | call vesa20_drawbackground_stretch |
4233 | call vesa20_drawbackground_stretch |
4235 | ; call [draw_pointer] |
4234 | ; call [draw_pointer] |
4236 | call __sys_draw_pointer |
4235 | call __sys_draw_pointer |
4237 | ret |
4236 | ret |
4238 | ;----------------------------------------------------------------------------- |
4237 | ;----------------------------------------------------------------------------- |
4239 | align 4 |
4238 | align 4 |
4240 | syscall_putimage: ; PutImage |
4239 | syscall_putimage: ; PutImage |
4241 | sys_putimage: |
4240 | sys_putimage: |
4242 | test ecx, 0x80008000 |
4241 | test ecx, 0x80008000 |
4243 | jnz .exit |
4242 | jnz .exit |
4244 | test ecx, 0x0000FFFF |
4243 | test ecx, 0x0000FFFF |
4245 | jz .exit |
4244 | jz .exit |
4246 | test ecx, 0xFFFF0000 |
4245 | test ecx, 0xFFFF0000 |
4247 | jnz @f |
4246 | jnz @f |
4248 | ;-------------------------------------- |
4247 | ;-------------------------------------- |
4249 | align 4 |
4248 | align 4 |
4250 | .exit: |
4249 | .exit: |
4251 | ret |
4250 | ret |
4252 | ;-------------------------------------- |
4251 | ;-------------------------------------- |
4253 | align 4 |
4252 | align 4 |
4254 | @@: |
4253 | @@: |
4255 | mov edi, [current_slot] |
4254 | mov edi, [current_slot] |
4256 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4255 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4257 | rol edx, 16 |
4256 | rol edx, 16 |
4258 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4257 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4259 | rol edx, 16 |
4258 | rol edx, 16 |
4260 | ;-------------------------------------- |
4259 | ;-------------------------------------- |
4261 | align 4 |
4260 | align 4 |
4262 | .forced: |
4261 | .forced: |
4263 | push ebp esi 0 |
4262 | push ebp esi 0 |
4264 | mov ebp, putimage_get24bpp |
4263 | mov ebp, putimage_get24bpp |
4265 | mov esi, putimage_init24bpp |
4264 | mov esi, putimage_init24bpp |
4266 | ;-------------------------------------- |
4265 | ;-------------------------------------- |
4267 | align 4 |
4266 | align 4 |
4268 | sys_putimage_bpp: |
4267 | sys_putimage_bpp: |
4269 | call vesa20_putimage |
4268 | call vesa20_putimage |
4270 | pop ebp esi ebp |
4269 | pop ebp esi ebp |
4271 | ret |
4270 | ret |
4272 | ; jmp [draw_pointer] |
4271 | ; jmp [draw_pointer] |
4273 | ;----------------------------------------------------------------------------- |
4272 | ;----------------------------------------------------------------------------- |
4274 | align 4 |
4273 | align 4 |
4275 | sys_putimage_palette: |
4274 | sys_putimage_palette: |
4276 | ; ebx = pointer to image |
4275 | ; ebx = pointer to image |
4277 | ; ecx = [xsize]*65536 + [ysize] |
4276 | ; ecx = [xsize]*65536 + [ysize] |
4278 | ; edx = [xstart]*65536 + [ystart] |
4277 | ; edx = [xstart]*65536 + [ystart] |
4279 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4278 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4280 | ; edi = pointer to palette |
4279 | ; edi = pointer to palette |
4281 | ; ebp = row delta |
4280 | ; ebp = row delta |
4282 | mov eax, [CURRENT_TASK] |
4281 | mov eax, [CURRENT_TASK] |
4283 | shl eax, 8 |
4282 | shl eax, 8 |
4284 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4283 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4285 | rol edx, 16 |
4284 | rol edx, 16 |
4286 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4285 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4287 | rol edx, 16 |
4286 | rol edx, 16 |
4288 | ;-------------------------------------- |
4287 | ;-------------------------------------- |
4289 | align 4 |
4288 | align 4 |
4290 | .forced: |
4289 | .forced: |
4291 | cmp esi, 1 |
4290 | cmp esi, 1 |
4292 | jnz @f |
4291 | jnz @f |
4293 | push edi |
4292 | push edi |
4294 | mov eax, [edi+4] |
4293 | mov eax, [edi+4] |
4295 | sub eax, [edi] |
4294 | sub eax, [edi] |
4296 | push eax |
4295 | push eax |
4297 | push dword [edi] |
4296 | push dword [edi] |
4298 | push 0ffffff80h |
4297 | push 0ffffff80h |
4299 | mov edi, esp |
4298 | mov edi, esp |
4300 | call put_mono_image |
4299 | call put_mono_image |
4301 | add esp, 12 |
4300 | add esp, 12 |
4302 | pop edi |
4301 | pop edi |
4303 | ret |
4302 | ret |
4304 | ;-------------------------------------- |
4303 | ;-------------------------------------- |
4305 | align 4 |
4304 | align 4 |
4306 | @@: |
4305 | @@: |
4307 | cmp esi, 2 |
4306 | cmp esi, 2 |
4308 | jnz @f |
4307 | jnz @f |
4309 | push edi |
4308 | push edi |
4310 | push 0ffffff80h |
4309 | push 0ffffff80h |
4311 | mov edi, esp |
4310 | mov edi, esp |
4312 | call put_2bit_image |
4311 | call put_2bit_image |
4313 | pop eax |
4312 | pop eax |
4314 | pop edi |
4313 | pop edi |
4315 | ret |
4314 | ret |
4316 | ;-------------------------------------- |
4315 | ;-------------------------------------- |
4317 | align 4 |
4316 | align 4 |
4318 | @@: |
4317 | @@: |
4319 | cmp esi, 4 |
4318 | cmp esi, 4 |
4320 | jnz @f |
4319 | jnz @f |
4321 | push edi |
4320 | push edi |
4322 | push 0ffffff80h |
4321 | push 0ffffff80h |
4323 | mov edi, esp |
4322 | mov edi, esp |
4324 | call put_4bit_image |
4323 | call put_4bit_image |
4325 | pop eax |
4324 | pop eax |
4326 | pop edi |
4325 | pop edi |
4327 | ret |
4326 | ret |
4328 | ;-------------------------------------- |
4327 | ;-------------------------------------- |
4329 | align 4 |
4328 | align 4 |
4330 | @@: |
4329 | @@: |
4331 | push ebp esi ebp |
4330 | push ebp esi ebp |
4332 | cmp esi, 8 |
4331 | cmp esi, 8 |
4333 | jnz @f |
4332 | jnz @f |
4334 | mov ebp, putimage_get8bpp |
4333 | mov ebp, putimage_get8bpp |
4335 | mov esi, putimage_init8bpp |
4334 | mov esi, putimage_init8bpp |
4336 | jmp sys_putimage_bpp |
4335 | jmp sys_putimage_bpp |
4337 | ;-------------------------------------- |
4336 | ;-------------------------------------- |
4338 | align 4 |
4337 | align 4 |
4339 | @@: |
4338 | @@: |
4340 | cmp esi, 9 |
4339 | cmp esi, 9 |
4341 | jnz @f |
4340 | jnz @f |
4342 | mov ebp, putimage_get9bpp |
4341 | mov ebp, putimage_get9bpp |
4343 | mov esi, putimage_init9bpp |
4342 | mov esi, putimage_init9bpp |
4344 | jmp sys_putimage_bpp |
4343 | jmp sys_putimage_bpp |
4345 | ;-------------------------------------- |
4344 | ;-------------------------------------- |
4346 | align 4 |
4345 | align 4 |
4347 | @@: |
4346 | @@: |
4348 | cmp esi, 15 |
4347 | cmp esi, 15 |
4349 | jnz @f |
4348 | jnz @f |
4350 | mov ebp, putimage_get15bpp |
4349 | mov ebp, putimage_get15bpp |
4351 | mov esi, putimage_init15bpp |
4350 | mov esi, putimage_init15bpp |
4352 | jmp sys_putimage_bpp |
4351 | jmp sys_putimage_bpp |
4353 | ;-------------------------------------- |
4352 | ;-------------------------------------- |
4354 | align 4 |
4353 | align 4 |
4355 | @@: |
4354 | @@: |
4356 | cmp esi, 16 |
4355 | cmp esi, 16 |
4357 | jnz @f |
4356 | jnz @f |
4358 | mov ebp, putimage_get16bpp |
4357 | mov ebp, putimage_get16bpp |
4359 | mov esi, putimage_init16bpp |
4358 | mov esi, putimage_init16bpp |
4360 | jmp sys_putimage_bpp |
4359 | jmp sys_putimage_bpp |
4361 | ;-------------------------------------- |
4360 | ;-------------------------------------- |
4362 | align 4 |
4361 | align 4 |
4363 | @@: |
4362 | @@: |
4364 | cmp esi, 24 |
4363 | cmp esi, 24 |
4365 | jnz @f |
4364 | jnz @f |
4366 | mov ebp, putimage_get24bpp |
4365 | mov ebp, putimage_get24bpp |
4367 | mov esi, putimage_init24bpp |
4366 | mov esi, putimage_init24bpp |
4368 | jmp sys_putimage_bpp |
4367 | jmp sys_putimage_bpp |
4369 | ;-------------------------------------- |
4368 | ;-------------------------------------- |
4370 | align 4 |
4369 | align 4 |
4371 | @@: |
4370 | @@: |
4372 | cmp esi, 32 |
4371 | cmp esi, 32 |
4373 | jnz @f |
4372 | jnz @f |
4374 | mov ebp, putimage_get32bpp |
4373 | mov ebp, putimage_get32bpp |
4375 | mov esi, putimage_init32bpp |
4374 | mov esi, putimage_init32bpp |
4376 | jmp sys_putimage_bpp |
4375 | jmp sys_putimage_bpp |
4377 | ;-------------------------------------- |
4376 | ;-------------------------------------- |
4378 | align 4 |
4377 | align 4 |
4379 | @@: |
4378 | @@: |
4380 | pop ebp esi ebp |
4379 | pop ebp esi ebp |
4381 | ret |
4380 | ret |
4382 | ;----------------------------------------------------------------------------- |
4381 | ;----------------------------------------------------------------------------- |
4383 | align 4 |
4382 | align 4 |
4384 | put_mono_image: |
4383 | put_mono_image: |
4385 | push ebp esi ebp |
4384 | push ebp esi ebp |
4386 | mov ebp, putimage_get1bpp |
4385 | mov ebp, putimage_get1bpp |
4387 | mov esi, putimage_init1bpp |
4386 | mov esi, putimage_init1bpp |
4388 | jmp sys_putimage_bpp |
4387 | jmp sys_putimage_bpp |
4389 | ;----------------------------------------------------------------------------- |
4388 | ;----------------------------------------------------------------------------- |
4390 | align 4 |
4389 | align 4 |
4391 | put_2bit_image: |
4390 | put_2bit_image: |
4392 | push ebp esi ebp |
4391 | push ebp esi ebp |
4393 | mov ebp, putimage_get2bpp |
4392 | mov ebp, putimage_get2bpp |
4394 | mov esi, putimage_init2bpp |
4393 | mov esi, putimage_init2bpp |
4395 | jmp sys_putimage_bpp |
4394 | jmp sys_putimage_bpp |
4396 | ;----------------------------------------------------------------------------- |
4395 | ;----------------------------------------------------------------------------- |
4397 | align 4 |
4396 | align 4 |
4398 | put_4bit_image: |
4397 | put_4bit_image: |
4399 | push ebp esi ebp |
4398 | push ebp esi ebp |
4400 | mov ebp, putimage_get4bpp |
4399 | mov ebp, putimage_get4bpp |
4401 | mov esi, putimage_init4bpp |
4400 | mov esi, putimage_init4bpp |
4402 | jmp sys_putimage_bpp |
4401 | jmp sys_putimage_bpp |
4403 | ;----------------------------------------------------------------------------- |
4402 | ;----------------------------------------------------------------------------- |
4404 | align 4 |
4403 | align 4 |
4405 | putimage_init24bpp: |
4404 | putimage_init24bpp: |
4406 | lea eax, [eax*3] |
4405 | lea eax, [eax*3] |
4407 | putimage_init8bpp: |
4406 | putimage_init8bpp: |
4408 | putimage_init9bpp: |
4407 | putimage_init9bpp: |
4409 | ret |
4408 | ret |
4410 | ;----------------------------------------------------------------------------- |
4409 | ;----------------------------------------------------------------------------- |
4411 | align 16 |
4410 | align 16 |
4412 | putimage_get24bpp: |
4411 | putimage_get24bpp: |
4413 | movzx eax, byte [esi+2] |
4412 | movzx eax, byte [esi+2] |
4414 | shl eax, 16 |
4413 | shl eax, 16 |
4415 | mov ax, [esi] |
4414 | mov ax, [esi] |
4416 | add esi, 3 |
4415 | add esi, 3 |
4417 | ret 4 |
4416 | ret 4 |
4418 | ;----------------------------------------------------------------------------- |
4417 | ;----------------------------------------------------------------------------- |
4419 | align 16 |
4418 | align 16 |
4420 | putimage_get8bpp: |
4419 | putimage_get8bpp: |
4421 | movzx eax, byte [esi] |
4420 | movzx eax, byte [esi] |
4422 | push edx |
4421 | push edx |
4423 | mov edx, [esp+8] |
4422 | mov edx, [esp+8] |
4424 | mov eax, [edx+eax*4] |
4423 | mov eax, [edx+eax*4] |
4425 | pop edx |
4424 | pop edx |
4426 | inc esi |
4425 | inc esi |
4427 | ret 4 |
4426 | ret 4 |
4428 | ;----------------------------------------------------------------------------- |
4427 | ;----------------------------------------------------------------------------- |
4429 | align 16 |
4428 | align 16 |
4430 | putimage_get9bpp: |
4429 | putimage_get9bpp: |
4431 | lodsb |
4430 | lodsb |
4432 | mov ah, al |
4431 | mov ah, al |
4433 | shl eax, 8 |
4432 | shl eax, 8 |
4434 | mov al, ah |
4433 | mov al, ah |
4435 | ret 4 |
4434 | ret 4 |
4436 | ;----------------------------------------------------------------------------- |
4435 | ;----------------------------------------------------------------------------- |
4437 | align 4 |
4436 | align 4 |
4438 | putimage_init1bpp: |
4437 | putimage_init1bpp: |
4439 | add eax, ecx |
4438 | add eax, ecx |
4440 | push ecx |
4439 | push ecx |
4441 | add eax, 7 |
4440 | add eax, 7 |
4442 | add ecx, 7 |
4441 | add ecx, 7 |
4443 | shr eax, 3 |
4442 | shr eax, 3 |
4444 | shr ecx, 3 |
4443 | shr ecx, 3 |
4445 | sub eax, ecx |
4444 | sub eax, ecx |
4446 | pop ecx |
4445 | pop ecx |
4447 | ret |
4446 | ret |
4448 | ;----------------------------------------------------------------------------- |
4447 | ;----------------------------------------------------------------------------- |
4449 | align 16 |
4448 | align 16 |
4450 | putimage_get1bpp: |
4449 | putimage_get1bpp: |
4451 | push edx |
4450 | push edx |
4452 | mov edx, [esp+8] |
4451 | mov edx, [esp+8] |
4453 | mov al, [edx] |
4452 | mov al, [edx] |
4454 | add al, al |
4453 | add al, al |
4455 | jnz @f |
4454 | jnz @f |
4456 | lodsb |
4455 | lodsb |
4457 | adc al, al |
4456 | adc al, al |
4458 | @@: |
4457 | @@: |
4459 | mov [edx], al |
4458 | mov [edx], al |
4460 | sbb eax, eax |
4459 | sbb eax, eax |
4461 | and eax, [edx+8] |
4460 | and eax, [edx+8] |
4462 | add eax, [edx+4] |
4461 | add eax, [edx+4] |
4463 | pop edx |
4462 | pop edx |
4464 | ret 4 |
4463 | ret 4 |
4465 | ;----------------------------------------------------------------------------- |
4464 | ;----------------------------------------------------------------------------- |
4466 | align 4 |
4465 | align 4 |
4467 | putimage_init2bpp: |
4466 | putimage_init2bpp: |
4468 | add eax, ecx |
4467 | add eax, ecx |
4469 | push ecx |
4468 | push ecx |
4470 | add ecx, 3 |
4469 | add ecx, 3 |
4471 | add eax, 3 |
4470 | add eax, 3 |
4472 | shr ecx, 2 |
4471 | shr ecx, 2 |
4473 | shr eax, 2 |
4472 | shr eax, 2 |
4474 | sub eax, ecx |
4473 | sub eax, ecx |
4475 | pop ecx |
4474 | pop ecx |
4476 | ret |
4475 | ret |
4477 | ;----------------------------------------------------------------------------- |
4476 | ;----------------------------------------------------------------------------- |
4478 | align 16 |
4477 | align 16 |
4479 | putimage_get2bpp: |
4478 | putimage_get2bpp: |
4480 | push edx |
4479 | push edx |
4481 | mov edx, [esp+8] |
4480 | mov edx, [esp+8] |
4482 | mov al, [edx] |
4481 | mov al, [edx] |
4483 | mov ah, al |
4482 | mov ah, al |
4484 | shr al, 6 |
4483 | shr al, 6 |
4485 | shl ah, 2 |
4484 | shl ah, 2 |
4486 | jnz .nonewbyte |
4485 | jnz .nonewbyte |
4487 | lodsb |
4486 | lodsb |
4488 | mov ah, al |
4487 | mov ah, al |
4489 | shr al, 6 |
4488 | shr al, 6 |
4490 | shl ah, 2 |
4489 | shl ah, 2 |
4491 | add ah, 1 |
4490 | add ah, 1 |
4492 | .nonewbyte: |
4491 | .nonewbyte: |
4493 | mov [edx], ah |
4492 | mov [edx], ah |
4494 | mov edx, [edx+4] |
4493 | mov edx, [edx+4] |
4495 | movzx eax, al |
4494 | movzx eax, al |
4496 | mov eax, [edx+eax*4] |
4495 | mov eax, [edx+eax*4] |
4497 | pop edx |
4496 | pop edx |
4498 | ret 4 |
4497 | ret 4 |
4499 | ;----------------------------------------------------------------------------- |
4498 | ;----------------------------------------------------------------------------- |
4500 | align 4 |
4499 | align 4 |
4501 | putimage_init4bpp: |
4500 | putimage_init4bpp: |
4502 | add eax, ecx |
4501 | add eax, ecx |
4503 | push ecx |
4502 | push ecx |
4504 | add ecx, 1 |
4503 | add ecx, 1 |
4505 | add eax, 1 |
4504 | add eax, 1 |
4506 | shr ecx, 1 |
4505 | shr ecx, 1 |
4507 | shr eax, 1 |
4506 | shr eax, 1 |
4508 | sub eax, ecx |
4507 | sub eax, ecx |
4509 | pop ecx |
4508 | pop ecx |
4510 | ret |
4509 | ret |
4511 | ;----------------------------------------------------------------------------- |
4510 | ;----------------------------------------------------------------------------- |
4512 | align 16 |
4511 | align 16 |
4513 | putimage_get4bpp: |
4512 | putimage_get4bpp: |
4514 | push edx |
4513 | push edx |
4515 | mov edx, [esp+8] |
4514 | mov edx, [esp+8] |
4516 | add byte [edx], 80h |
4515 | add byte [edx], 80h |
4517 | jc @f |
4516 | jc @f |
4518 | movzx eax, byte [edx+1] |
4517 | movzx eax, byte [edx+1] |
4519 | mov edx, [edx+4] |
4518 | mov edx, [edx+4] |
4520 | and eax, 0x0F |
4519 | and eax, 0x0F |
4521 | mov eax, [edx+eax*4] |
4520 | mov eax, [edx+eax*4] |
4522 | pop edx |
4521 | pop edx |
4523 | ret 4 |
4522 | ret 4 |
4524 | @@: |
4523 | @@: |
4525 | movzx eax, byte [esi] |
4524 | movzx eax, byte [esi] |
4526 | add esi, 1 |
4525 | add esi, 1 |
4527 | mov [edx+1], al |
4526 | mov [edx+1], al |
4528 | shr eax, 4 |
4527 | shr eax, 4 |
4529 | mov edx, [edx+4] |
4528 | mov edx, [edx+4] |
4530 | mov eax, [edx+eax*4] |
4529 | mov eax, [edx+eax*4] |
4531 | pop edx |
4530 | pop edx |
4532 | ret 4 |
4531 | ret 4 |
4533 | ;----------------------------------------------------------------------------- |
4532 | ;----------------------------------------------------------------------------- |
4534 | align 4 |
4533 | align 4 |
4535 | putimage_init32bpp: |
4534 | putimage_init32bpp: |
4536 | shl eax, 2 |
4535 | shl eax, 2 |
4537 | ret |
4536 | ret |
4538 | ;----------------------------------------------------------------------------- |
4537 | ;----------------------------------------------------------------------------- |
4539 | align 16 |
4538 | align 16 |
4540 | putimage_get32bpp: |
4539 | putimage_get32bpp: |
4541 | lodsd |
4540 | lodsd |
4542 | ret 4 |
4541 | ret 4 |
4543 | ;----------------------------------------------------------------------------- |
4542 | ;----------------------------------------------------------------------------- |
4544 | align 4 |
4543 | align 4 |
4545 | putimage_init15bpp: |
4544 | putimage_init15bpp: |
4546 | putimage_init16bpp: |
4545 | putimage_init16bpp: |
4547 | add eax, eax |
4546 | add eax, eax |
4548 | ret |
4547 | ret |
4549 | ;----------------------------------------------------------------------------- |
4548 | ;----------------------------------------------------------------------------- |
4550 | align 16 |
4549 | align 16 |
4551 | putimage_get15bpp: |
4550 | putimage_get15bpp: |
4552 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4551 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4553 | push ecx edx |
4552 | push ecx edx |
4554 | movzx eax, word [esi] |
4553 | movzx eax, word [esi] |
4555 | add esi, 2 |
4554 | add esi, 2 |
4556 | mov ecx, eax |
4555 | mov ecx, eax |
4557 | mov edx, eax |
4556 | mov edx, eax |
4558 | and eax, 0x1F |
4557 | and eax, 0x1F |
4559 | and ecx, 0x1F shl 5 |
4558 | and ecx, 0x1F shl 5 |
4560 | and edx, 0x1F shl 10 |
4559 | and edx, 0x1F shl 10 |
4561 | shl eax, 3 |
4560 | shl eax, 3 |
4562 | shl ecx, 6 |
4561 | shl ecx, 6 |
4563 | shl edx, 9 |
4562 | shl edx, 9 |
4564 | or eax, ecx |
4563 | or eax, ecx |
4565 | or eax, edx |
4564 | or eax, edx |
4566 | pop edx ecx |
4565 | pop edx ecx |
4567 | ret 4 |
4566 | ret 4 |
4568 | ;----------------------------------------------------------------------------- |
4567 | ;----------------------------------------------------------------------------- |
4569 | align 16 |
4568 | align 16 |
4570 | putimage_get16bpp: |
4569 | putimage_get16bpp: |
4571 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4570 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4572 | push ecx edx |
4571 | push ecx edx |
4573 | movzx eax, word [esi] |
4572 | movzx eax, word [esi] |
4574 | add esi, 2 |
4573 | add esi, 2 |
4575 | mov ecx, eax |
4574 | mov ecx, eax |
4576 | mov edx, eax |
4575 | mov edx, eax |
4577 | and eax, 0x1F |
4576 | and eax, 0x1F |
4578 | and ecx, 0x3F shl 5 |
4577 | and ecx, 0x3F shl 5 |
4579 | and edx, 0x1F shl 11 |
4578 | and edx, 0x1F shl 11 |
4580 | shl eax, 3 |
4579 | shl eax, 3 |
4581 | shl ecx, 5 |
4580 | shl ecx, 5 |
4582 | shl edx, 8 |
4581 | shl edx, 8 |
4583 | or eax, ecx |
4582 | or eax, ecx |
4584 | or eax, edx |
4583 | or eax, edx |
4585 | pop edx ecx |
4584 | pop edx ecx |
4586 | ret 4 |
4585 | ret 4 |
4587 | ;----------------------------------------------------------------------------- |
4586 | ;----------------------------------------------------------------------------- |
4588 | ;align 4 |
4587 | ;align 4 |
4589 | ; eax x beginning |
4588 | ; eax x beginning |
4590 | ; ebx y beginning |
4589 | ; ebx y beginning |
4591 | ; ecx x end |
4590 | ; ecx x end |
4592 | ; edx y end |
4591 | ; edx y end |
4593 | ; edi color |
4592 | ; edi color |
4594 | ;__sys_drawbar: |
4593 | ;__sys_drawbar: |
4595 | ; mov esi, [current_slot] |
4594 | ; mov esi, [current_slot] |
4596 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4595 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4597 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4596 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4598 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4597 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4599 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4598 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4600 | ;-------------------------------------- |
4599 | ;-------------------------------------- |
4601 | ;align 4 |
4600 | ;align 4 |
4602 | ;.forced: |
4601 | ;.forced: |
4603 | ; call vesa20_drawbar |
4602 | ; call vesa20_drawbar |
4604 | ; call [draw_pointer] |
4603 | ; call [draw_pointer] |
4605 | ; ret |
4604 | ; ret |
4606 | ;----------------------------------------------------------------------------- |
4605 | ;----------------------------------------------------------------------------- |
4607 | align 4 |
4606 | align 4 |
4608 | kb_read: |
4607 | kb_read: |
4609 | 4608 | ||
4610 | push ecx edx |
4609 | push ecx edx |
4611 | 4610 | ||
4612 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4611 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4613 | kr_loop: |
4612 | kr_loop: |
4614 | in al, 0x64 |
4613 | in al, 0x64 |
4615 | test al, 1 |
4614 | test al, 1 |
4616 | jnz kr_ready |
4615 | jnz kr_ready |
4617 | loop kr_loop |
4616 | loop kr_loop |
4618 | mov ah, 1 |
4617 | mov ah, 1 |
4619 | jmp kr_exit |
4618 | jmp kr_exit |
4620 | kr_ready: |
4619 | kr_ready: |
4621 | push ecx |
4620 | push ecx |
4622 | mov ecx, 32 |
4621 | mov ecx, 32 |
4623 | kr_delay: |
4622 | kr_delay: |
4624 | loop kr_delay |
4623 | loop kr_delay |
4625 | pop ecx |
4624 | pop ecx |
4626 | in al, 0x60 |
4625 | in al, 0x60 |
4627 | xor ah, ah |
4626 | xor ah, ah |
4628 | kr_exit: |
4627 | kr_exit: |
4629 | 4628 | ||
4630 | pop edx ecx |
4629 | pop edx ecx |
4631 | 4630 | ||
4632 | ret |
4631 | ret |
4633 | ;----------------------------------------------------------------------------- |
4632 | ;----------------------------------------------------------------------------- |
4634 | align 4 |
4633 | align 4 |
4635 | kb_write: |
4634 | kb_write: |
4636 | 4635 | ||
4637 | push ecx edx |
4636 | push ecx edx |
4638 | 4637 | ||
4639 | mov dl, al |
4638 | mov dl, al |
4640 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4639 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4641 | ; kw_loop1: |
4640 | ; kw_loop1: |
4642 | ; in al,0x64 |
4641 | ; in al,0x64 |
4643 | ; test al,0x20 |
4642 | ; test al,0x20 |
4644 | ; jz kw_ok1 |
4643 | ; jz kw_ok1 |
4645 | ; loop kw_loop1 |
4644 | ; loop kw_loop1 |
4646 | ; mov ah,1 |
4645 | ; mov ah,1 |
4647 | ; jmp kw_exit |
4646 | ; jmp kw_exit |
4648 | ; kw_ok1: |
4647 | ; kw_ok1: |
4649 | in al, 0x60 |
4648 | in al, 0x60 |
4650 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4649 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4651 | kw_loop: |
4650 | kw_loop: |
4652 | in al, 0x64 |
4651 | in al, 0x64 |
4653 | test al, 2 |
4652 | test al, 2 |
4654 | jz kw_ok |
4653 | jz kw_ok |
4655 | loop kw_loop |
4654 | loop kw_loop |
4656 | mov ah, 1 |
4655 | mov ah, 1 |
4657 | jmp kw_exit |
4656 | jmp kw_exit |
4658 | kw_ok: |
4657 | kw_ok: |
4659 | mov al, dl |
4658 | mov al, dl |
4660 | out 0x60, al |
4659 | out 0x60, al |
4661 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4660 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4662 | kw_loop3: |
4661 | kw_loop3: |
4663 | in al, 0x64 |
4662 | in al, 0x64 |
4664 | test al, 2 |
4663 | test al, 2 |
4665 | jz kw_ok3 |
4664 | jz kw_ok3 |
4666 | loop kw_loop3 |
4665 | loop kw_loop3 |
4667 | mov ah, 1 |
4666 | mov ah, 1 |
4668 | jmp kw_exit |
4667 | jmp kw_exit |
4669 | kw_ok3: |
4668 | kw_ok3: |
4670 | mov ah, 8 |
4669 | mov ah, 8 |
4671 | kw_loop4: |
4670 | kw_loop4: |
4672 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4671 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4673 | kw_loop5: |
4672 | kw_loop5: |
4674 | in al, 0x64 |
4673 | in al, 0x64 |
4675 | test al, 1 |
4674 | test al, 1 |
4676 | jnz kw_ok4 |
4675 | jnz kw_ok4 |
4677 | loop kw_loop5 |
4676 | loop kw_loop5 |
4678 | dec ah |
4677 | dec ah |
4679 | jnz kw_loop4 |
4678 | jnz kw_loop4 |
4680 | kw_ok4: |
4679 | kw_ok4: |
4681 | xor ah, ah |
4680 | xor ah, ah |
4682 | kw_exit: |
4681 | kw_exit: |
4683 | 4682 | ||
4684 | pop edx ecx |
4683 | pop edx ecx |
4685 | 4684 | ||
4686 | ret |
4685 | ret |
4687 | ;----------------------------------------------------------------------------- |
4686 | ;----------------------------------------------------------------------------- |
4688 | align 4 |
4687 | align 4 |
4689 | kb_cmd: |
4688 | kb_cmd: |
4690 | 4689 | ||
4691 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4690 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4692 | c_wait: |
4691 | c_wait: |
4693 | in al, 0x64 |
4692 | in al, 0x64 |
4694 | test al, 2 |
4693 | test al, 2 |
4695 | jz c_send |
4694 | jz c_send |
4696 | loop c_wait |
4695 | loop c_wait |
4697 | jmp c_error |
4696 | jmp c_error |
4698 | c_send: |
4697 | c_send: |
4699 | mov al, bl |
4698 | mov al, bl |
4700 | out 0x64, al |
4699 | out 0x64, al |
4701 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4700 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4702 | c_accept: |
4701 | c_accept: |
4703 | in al, 0x64 |
4702 | in al, 0x64 |
4704 | test al, 2 |
4703 | test al, 2 |
4705 | jz c_ok |
4704 | jz c_ok |
4706 | loop c_accept |
4705 | loop c_accept |
4707 | c_error: |
4706 | c_error: |
4708 | mov ah, 1 |
4707 | mov ah, 1 |
4709 | jmp c_exit |
4708 | jmp c_exit |
4710 | c_ok: |
4709 | c_ok: |
4711 | xor ah, ah |
4710 | xor ah, ah |
4712 | c_exit: |
4711 | c_exit: |
4713 | ret |
4712 | ret |
4714 | 4713 | ||
4715 | 4714 | ||
4716 | setmouse: ; set mousepicture -pointer |
4715 | setmouse: ; set mousepicture -pointer |
4717 | ; ps2 mouse enable |
4716 | ; ps2 mouse enable |
4718 | 4717 | ||
4719 | ; mov [MOUSE_PICTURE], dword mousepointer |
4718 | ; mov [MOUSE_PICTURE], dword mousepointer |
4720 | 4719 | ||
4721 | cli |
4720 | cli |
4722 | 4721 | ||
4723 | ret |
4722 | ret |
4724 | 4723 | ||
4725 | if used _rdtsc |
4724 | if used _rdtsc |
4726 | _rdtsc: |
4725 | _rdtsc: |
4727 | bt [cpu_caps], CAPS_TSC |
4726 | bt [cpu_caps], CAPS_TSC |
4728 | jnc ret_rdtsc |
4727 | jnc ret_rdtsc |
4729 | rdtsc |
4728 | rdtsc |
4730 | ret |
4729 | ret |
4731 | ret_rdtsc: |
4730 | ret_rdtsc: |
4732 | mov edx, 0xffffffff |
4731 | mov edx, 0xffffffff |
4733 | mov eax, 0xffffffff |
4732 | mov eax, 0xffffffff |
4734 | ret |
4733 | ret |
4735 | end if |
4734 | end if |
4736 | 4735 | ||
4737 | sys_msg_board_str: |
4736 | sys_msg_board_str: |
4738 | 4737 | ||
4739 | pushad |
4738 | pushad |
4740 | @@: |
4739 | @@: |
4741 | cmp [esi], byte 0 |
4740 | cmp [esi], byte 0 |
4742 | je @f |
4741 | je @f |
4743 | mov ebx, 1 |
4742 | mov ebx, 1 |
4744 | movzx ecx, byte [esi] |
4743 | movzx ecx, byte [esi] |
4745 | call sys_msg_board |
4744 | call sys_msg_board |
4746 | inc esi |
4745 | inc esi |
4747 | jmp @b |
4746 | jmp @b |
4748 | @@: |
4747 | @@: |
4749 | popad |
4748 | popad |
4750 | ret |
4749 | ret |
4751 | 4750 | ||
4752 | sys_msg_board_byte: |
4751 | sys_msg_board_byte: |
4753 | ; in: al = byte to display |
4752 | ; in: al = byte to display |
4754 | ; out: nothing |
4753 | ; out: nothing |
4755 | ; destroys: nothing |
4754 | ; destroys: nothing |
4756 | pushad |
4755 | pushad |
4757 | mov ecx, 2 |
4756 | mov ecx, 2 |
4758 | shl eax, 24 |
4757 | shl eax, 24 |
4759 | jmp @f |
4758 | jmp @f |
4760 | 4759 | ||
4761 | sys_msg_board_word: |
4760 | sys_msg_board_word: |
4762 | ; in: ax = word to display |
4761 | ; in: ax = word to display |
4763 | ; out: nothing |
4762 | ; out: nothing |
4764 | ; destroys: nothing |
4763 | ; destroys: nothing |
4765 | pushad |
4764 | pushad |
4766 | mov ecx, 4 |
4765 | mov ecx, 4 |
4767 | shl eax, 16 |
4766 | shl eax, 16 |
4768 | jmp @f |
4767 | jmp @f |
4769 | 4768 | ||
4770 | sys_msg_board_dword: |
4769 | sys_msg_board_dword: |
4771 | ; in: eax = dword to display |
4770 | ; in: eax = dword to display |
4772 | ; out: nothing |
4771 | ; out: nothing |
4773 | ; destroys: nothing |
4772 | ; destroys: nothing |
4774 | pushad |
4773 | pushad |
4775 | mov ecx, 8 |
4774 | mov ecx, 8 |
4776 | @@: |
4775 | @@: |
4777 | push ecx |
4776 | push ecx |
4778 | rol eax, 4 |
4777 | rol eax, 4 |
4779 | push eax |
4778 | push eax |
4780 | and al, 0xF |
4779 | and al, 0xF |
4781 | cmp al, 10 |
4780 | cmp al, 10 |
4782 | sbb al, 69h |
4781 | sbb al, 69h |
4783 | das |
4782 | das |
4784 | mov cl, al |
4783 | mov cl, al |
4785 | xor ebx, ebx |
4784 | xor ebx, ebx |
4786 | inc ebx |
4785 | inc ebx |
4787 | call sys_msg_board |
4786 | call sys_msg_board |
4788 | pop eax |
4787 | pop eax |
4789 | pop ecx |
4788 | pop ecx |
4790 | loop @b |
4789 | loop @b |
4791 | popad |
4790 | popad |
4792 | ret |
4791 | ret |
4793 | 4792 | ||
4794 | msg_board_data_size = 65536 ; Must be power of two |
4793 | msg_board_data_size = 65536 ; Must be power of two |
4795 | 4794 | ||
4796 | uglobal |
4795 | uglobal |
4797 | msg_board_data rb msg_board_data_size |
4796 | msg_board_data rb msg_board_data_size |
4798 | msg_board_count dd 0x0 |
4797 | msg_board_count dd 0x0 |
4799 | endg |
4798 | endg |
4800 | 4799 | ||
4801 | sys_msg_board: |
4800 | sys_msg_board: |
4802 | 4801 | ||
4803 | ; ebx=1 : write : bl byte to write |
4802 | ; ebx=1 : write : bl byte to write |
4804 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4803 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4805 | 4804 | ||
4806 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4805 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4807 | mov eax, ebx |
4806 | mov eax, ebx |
4808 | mov ebx, ecx |
4807 | mov ebx, ecx |
4809 | 4808 | ||
4810 | mov ecx, [msg_board_count] |
4809 | mov ecx, [msg_board_count] |
4811 | cmp eax, 1 |
4810 | cmp eax, 1 |
4812 | jne .smbl1 |
4811 | jne .smbl1 |
4813 | 4812 | ||
4814 | if defined debug_com_base |
4813 | if defined debug_com_base |
4815 | 4814 | ||
4816 | push dx ax |
4815 | push dx ax |
4817 | 4816 | ||
4818 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4817 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4819 | mov dx, debug_com_base+5 |
4818 | mov dx, debug_com_base+5 |
4820 | in al, dx |
4819 | in al, dx |
4821 | test al, 1 shl 5 |
4820 | test al, 1 shl 5 |
4822 | jz @r |
4821 | jz @r |
4823 | 4822 | ||
4824 | mov dx, debug_com_base ; Output the byte |
4823 | mov dx, debug_com_base ; Output the byte |
4825 | mov al, bl |
4824 | mov al, bl |
4826 | out dx, al |
4825 | out dx, al |
4827 | 4826 | ||
4828 | pop ax dx |
4827 | pop ax dx |
4829 | 4828 | ||
4830 | end if |
4829 | end if |
4831 | 4830 | ||
4832 | mov [msg_board_data+ecx], bl |
4831 | mov [msg_board_data+ecx], bl |
4833 | if debug_direct_print |
4832 | if debug_direct_print |
4834 | pusha |
4833 | pusha |
4835 | iglobal |
4834 | iglobal |
4836 | msg_board_pos dd 234*65536+10 |
4835 | msg_board_pos dd 234*65536+10 |
4837 | endg |
4836 | endg |
4838 | lea edx, [msg_board_data+ecx] |
4837 | lea edx, [msg_board_data+ecx] |
4839 | mov ecx, 0x40FFFFFF |
4838 | mov ecx, 0x40FFFFFF |
4840 | mov ebx, [msg_board_pos] |
4839 | mov ebx, [msg_board_pos] |
4841 | mov edi, 1 |
4840 | mov edi, 1 |
4842 | mov esi, 1 |
4841 | mov esi, 1 |
4843 | call dtext |
4842 | call dtext |
4844 | popa |
4843 | popa |
4845 | add word [msg_board_pos+2], 6 |
4844 | add word [msg_board_pos+2], 6 |
4846 | cmp bl, 10 |
4845 | cmp bl, 10 |
4847 | jnz @f |
4846 | jnz @f |
4848 | mov word [msg_board_pos+2], 234 |
4847 | mov word [msg_board_pos+2], 234 |
4849 | add word [msg_board_pos], 10 |
4848 | add word [msg_board_pos], 10 |
4850 | mov ax, word [Screen_Max_Y] |
4849 | mov ax, word [Screen_Max_Y] |
4851 | cmp word [msg_board_pos], ax |
4850 | cmp word [msg_board_pos], ax |
4852 | jbe @f |
4851 | jbe @f |
4853 | mov word [msg_board_pos], 10 |
4852 | mov word [msg_board_pos], 10 |
4854 | @@: |
4853 | @@: |
4855 | end if |
4854 | end if |
4856 | if 0 |
4855 | if 0 |
4857 | pusha |
4856 | pusha |
4858 | mov al, bl |
4857 | mov al, bl |
4859 | mov edx, 402h |
4858 | mov edx, 402h |
4860 | out dx, al |
4859 | out dx, al |
4861 | popa |
4860 | popa |
4862 | end if |
4861 | end if |
4863 | inc ecx |
4862 | inc ecx |
4864 | and ecx, msg_board_data_size - 1 |
4863 | and ecx, msg_board_data_size - 1 |
4865 | mov [msg_board_count], ecx |
4864 | mov [msg_board_count], ecx |
4866 | 4865 | ||
4867 | pop ebx eax |
4866 | pop ebx eax |
4868 | ret |
4867 | ret |
4869 | .smbl1: |
4868 | .smbl1: |
4870 | cmp eax, 2 |
4869 | cmp eax, 2 |
4871 | jne .smbl2 |
4870 | jne .smbl2 |
4872 | test ecx, ecx |
4871 | test ecx, ecx |
4873 | jz .smbl21 |
4872 | jz .smbl21 |
4874 | 4873 | ||
4875 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4874 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4876 | mov eax, msg_board_data+1 |
4875 | mov eax, msg_board_data+1 |
4877 | mov ebx, msg_board_data |
4876 | mov ebx, msg_board_data |
4878 | movzx edx, byte [ebx] |
4877 | movzx edx, byte [ebx] |
4879 | call memmove |
4878 | call memmove |
4880 | dec [msg_board_count] |
4879 | dec [msg_board_count] |
4881 | mov [esp + 32], edx ;eax |
4880 | mov [esp + 32], edx ;eax |
4882 | mov [esp + 20], dword 1 |
4881 | mov [esp + 20], dword 1 |
4883 | ret |
4882 | ret |
4884 | .smbl21: |
4883 | .smbl21: |
4885 | mov [esp+32], ecx |
4884 | mov [esp+32], ecx |
4886 | mov [esp+20], ecx |
4885 | mov [esp+20], ecx |
4887 | .smbl2: |
4886 | .smbl2: |
4888 | pop ebx eax |
4887 | pop ebx eax |
4889 | ret |
4888 | ret |
4890 | 4889 | ||
4891 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4890 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4892 | ;; 66 sys function. ;; |
4891 | ;; 66 sys function. ;; |
4893 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4892 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4894 | ;; out eax ;; |
4893 | ;; out eax ;; |
4895 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4894 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4896 | iglobal |
4895 | iglobal |
4897 | align 4 |
4896 | align 4 |
4898 | f66call: |
4897 | f66call: |
4899 | dd sys_process_def.1 ; 1 = set keyboard mode |
4898 | dd sys_process_def.1 ; 1 = set keyboard mode |
4900 | dd sys_process_def.2 ; 2 = get keyboard mode |
4899 | dd sys_process_def.2 ; 2 = get keyboard mode |
4901 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4900 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4902 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4901 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4903 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4902 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4904 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4903 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4905 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4904 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4906 | endg |
4905 | endg |
4907 | ;----------------------------------------------------------------------------- |
4906 | ;----------------------------------------------------------------------------- |
4908 | align 4 |
4907 | align 4 |
4909 | sys_process_def: |
4908 | sys_process_def: |
4910 | dec ebx |
4909 | dec ebx |
4911 | cmp ebx, 7 |
4910 | cmp ebx, 7 |
4912 | jae .not_support ;if >=8 then or eax,-1 |
4911 | jae .not_support ;if >=8 then or eax,-1 |
4913 | 4912 | ||
4914 | mov edi, [CURRENT_TASK] |
4913 | mov edi, [CURRENT_TASK] |
4915 | jmp dword [f66call+ebx*4] |
4914 | jmp dword [f66call+ebx*4] |
4916 | 4915 | ||
4917 | .not_support: |
4916 | .not_support: |
4918 | or eax, -1 |
4917 | or eax, -1 |
4919 | ret |
4918 | ret |
4920 | ;----------------------------------------------------------------------------- |
4919 | ;----------------------------------------------------------------------------- |
4921 | align 4 |
4920 | align 4 |
4922 | .1: |
4921 | .1: |
4923 | shl edi, 8 |
4922 | shl edi, 8 |
4924 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4923 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4925 | 4924 | ||
4926 | ret |
4925 | ret |
4927 | ;----------------------------------------------------------------------------- |
4926 | ;----------------------------------------------------------------------------- |
4928 | align 4 |
4927 | align 4 |
4929 | .2: ; 2 = get keyboard mode |
4928 | .2: ; 2 = get keyboard mode |
4930 | shl edi, 8 |
4929 | shl edi, 8 |
4931 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4930 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4932 | mov [esp+32], eax |
4931 | mov [esp+32], eax |
4933 | ret |
4932 | ret |
4934 | ;----------------------------------------------------------------------------- |
4933 | ;----------------------------------------------------------------------------- |
4935 | align 4 |
4934 | align 4 |
4936 | .3: ;3 = get keyboard ctrl, alt, shift |
4935 | .3: ;3 = get keyboard ctrl, alt, shift |
4937 | mov eax, [kb_state] |
4936 | mov eax, [kb_state] |
4938 | mov [esp+32], eax |
4937 | mov [esp+32], eax |
4939 | ret |
4938 | ret |
4940 | ;----------------------------------------------------------------------------- |
4939 | ;----------------------------------------------------------------------------- |
4941 | align 4 |
4940 | align 4 |
4942 | .4: |
4941 | .4: |
4943 | mov eax, hotkey_list |
4942 | mov eax, hotkey_list |
4944 | @@: |
4943 | @@: |
4945 | cmp dword [eax+8], 0 |
4944 | cmp dword [eax+8], 0 |
4946 | jz .found_free |
4945 | jz .found_free |
4947 | add eax, 16 |
4946 | add eax, 16 |
4948 | cmp eax, hotkey_list+16*256 |
4947 | cmp eax, hotkey_list+16*256 |
4949 | jb @b |
4948 | jb @b |
4950 | mov dword [esp+32], 1 |
4949 | mov dword [esp+32], 1 |
4951 | ret |
4950 | ret |
4952 | .found_free: |
4951 | .found_free: |
4953 | mov [eax+8], edi |
4952 | mov [eax+8], edi |
4954 | mov [eax+4], edx |
4953 | mov [eax+4], edx |
4955 | movzx ecx, cl |
4954 | movzx ecx, cl |
4956 | lea ecx, [hotkey_scancodes+ecx*4] |
4955 | lea ecx, [hotkey_scancodes+ecx*4] |
4957 | mov edx, [ecx] |
4956 | mov edx, [ecx] |
4958 | mov [eax], edx |
4957 | mov [eax], edx |
4959 | mov [ecx], eax |
4958 | mov [ecx], eax |
4960 | mov [eax+12], ecx |
4959 | mov [eax+12], ecx |
4961 | test edx, edx |
4960 | test edx, edx |
4962 | jz @f |
4961 | jz @f |
4963 | mov [edx+12], eax |
4962 | mov [edx+12], eax |
4964 | @@: |
4963 | @@: |
4965 | and dword [esp+32], 0 |
4964 | and dword [esp+32], 0 |
4966 | ret |
4965 | ret |
4967 | ;----------------------------------------------------------------------------- |
4966 | ;----------------------------------------------------------------------------- |
4968 | align 4 |
4967 | align 4 |
4969 | .5: |
4968 | .5: |
4970 | movzx ebx, cl |
4969 | movzx ebx, cl |
4971 | lea ebx, [hotkey_scancodes+ebx*4] |
4970 | lea ebx, [hotkey_scancodes+ebx*4] |
4972 | mov eax, [ebx] |
4971 | mov eax, [ebx] |
4973 | .scan: |
4972 | .scan: |
4974 | test eax, eax |
4973 | test eax, eax |
4975 | jz .notfound |
4974 | jz .notfound |
4976 | cmp [eax+8], edi |
4975 | cmp [eax+8], edi |
4977 | jnz .next |
4976 | jnz .next |
4978 | cmp [eax+4], edx |
4977 | cmp [eax+4], edx |
4979 | jz .found |
4978 | jz .found |
4980 | .next: |
4979 | .next: |
4981 | mov eax, [eax] |
4980 | mov eax, [eax] |
4982 | jmp .scan |
4981 | jmp .scan |
4983 | .notfound: |
4982 | .notfound: |
4984 | mov dword [esp+32], 1 |
4983 | mov dword [esp+32], 1 |
4985 | ret |
4984 | ret |
4986 | .found: |
4985 | .found: |
4987 | mov ecx, [eax] |
4986 | mov ecx, [eax] |
4988 | jecxz @f |
4987 | jecxz @f |
4989 | mov edx, [eax+12] |
4988 | mov edx, [eax+12] |
4990 | mov [ecx+12], edx |
4989 | mov [ecx+12], edx |
4991 | @@: |
4990 | @@: |
4992 | mov ecx, [eax+12] |
4991 | mov ecx, [eax+12] |
4993 | mov edx, [eax] |
4992 | mov edx, [eax] |
4994 | mov [ecx], edx |
4993 | mov [ecx], edx |
4995 | xor edx, edx |
4994 | xor edx, edx |
4996 | mov [eax+4], edx |
4995 | mov [eax+4], edx |
4997 | mov [eax+8], edx |
4996 | mov [eax+8], edx |
4998 | mov [eax+12], edx |
4997 | mov [eax+12], edx |
4999 | mov [eax], edx |
4998 | mov [eax], edx |
5000 | mov [esp+32], edx |
4999 | mov [esp+32], edx |
5001 | ret |
5000 | ret |
5002 | ;----------------------------------------------------------------------------- |
5001 | ;----------------------------------------------------------------------------- |
5003 | align 4 |
5002 | align 4 |
5004 | .6: |
5003 | .6: |
5005 | pushfd |
5004 | pushfd |
5006 | cli |
5005 | cli |
5007 | mov eax, [PID_lock_input] |
5006 | mov eax, [PID_lock_input] |
5008 | test eax, eax |
5007 | test eax, eax |
5009 | jnz @f |
5008 | jnz @f |
5010 | ; get current PID |
5009 | ; get current PID |
5011 | mov eax, [CURRENT_TASK] |
5010 | mov eax, [CURRENT_TASK] |
5012 | shl eax, 5 |
5011 | shl eax, 5 |
5013 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5012 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5014 | ; set current PID for lock input |
5013 | ; set current PID for lock input |
5015 | mov [PID_lock_input], eax |
5014 | mov [PID_lock_input], eax |
5016 | @@: |
5015 | @@: |
5017 | popfd |
5016 | popfd |
5018 | ret |
5017 | ret |
5019 | ;----------------------------------------------------------------------------- |
5018 | ;----------------------------------------------------------------------------- |
5020 | align 4 |
5019 | align 4 |
5021 | .7: |
5020 | .7: |
5022 | mov eax, [PID_lock_input] |
5021 | mov eax, [PID_lock_input] |
5023 | test eax, eax |
5022 | test eax, eax |
5024 | jz @f |
5023 | jz @f |
5025 | ; get current PID |
5024 | ; get current PID |
5026 | mov ebx, [CURRENT_TASK] |
5025 | mov ebx, [CURRENT_TASK] |
5027 | shl ebx, 5 |
5026 | shl ebx, 5 |
5028 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5027 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5029 | ; compare current lock input with current PID |
5028 | ; compare current lock input with current PID |
5030 | cmp ebx, eax |
5029 | cmp ebx, eax |
5031 | jne @f |
5030 | jne @f |
5032 | 5031 | ||
5033 | xor eax, eax |
5032 | xor eax, eax |
5034 | mov [PID_lock_input], eax |
5033 | mov [PID_lock_input], eax |
5035 | @@: |
5034 | @@: |
5036 | ret |
5035 | ret |
5037 | ;----------------------------------------------------------------------------- |
5036 | ;----------------------------------------------------------------------------- |
5038 | uglobal |
5037 | uglobal |
5039 | PID_lock_input dd 0x0 |
5038 | PID_lock_input dd 0x0 |
5040 | endg |
5039 | endg |
5041 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5040 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5042 | ;; 61 sys function. ;; |
5041 | ;; 61 sys function. ;; |
5043 | ;; in eax=61,ebx in [1..3] ;; |
5042 | ;; in eax=61,ebx in [1..3] ;; |
5044 | ;; out eax ;; |
5043 | ;; out eax ;; |
5045 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5044 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5046 | iglobal |
5045 | iglobal |
5047 | align 4 |
5046 | align 4 |
5048 | f61call: |
5047 | f61call: |
5049 | dd sys_gs.1 ; resolution |
5048 | dd sys_gs.1 ; resolution |
5050 | dd sys_gs.2 ; bits per pixel |
5049 | dd sys_gs.2 ; bits per pixel |
5051 | dd sys_gs.3 ; bytes per scanline |
5050 | dd sys_gs.3 ; bytes per scanline |
5052 | endg |
5051 | endg |
5053 | 5052 | ||
5054 | 5053 | ||
5055 | align 4 |
5054 | align 4 |
5056 | 5055 | ||
5057 | sys_gs: ; direct screen access |
5056 | sys_gs: ; direct screen access |
5058 | dec ebx |
5057 | dec ebx |
5059 | cmp ebx, 2 |
5058 | cmp ebx, 2 |
5060 | ja .not_support |
5059 | ja .not_support |
5061 | jmp dword [f61call+ebx*4] |
5060 | jmp dword [f61call+ebx*4] |
5062 | .not_support: |
5061 | .not_support: |
5063 | or [esp+32], dword -1 |
5062 | or [esp+32], dword -1 |
5064 | ret |
5063 | ret |
5065 | 5064 | ||
5066 | 5065 | ||
5067 | .1: ; resolution |
5066 | .1: ; resolution |
5068 | mov eax, [Screen_Max_X] |
5067 | mov eax, [Screen_Max_X] |
5069 | shl eax, 16 |
5068 | shl eax, 16 |
5070 | mov ax, word [Screen_Max_Y] |
5069 | mov ax, word [Screen_Max_Y] |
5071 | add eax, 0x00010001 |
5070 | add eax, 0x00010001 |
5072 | mov [esp+32], eax |
5071 | mov [esp+32], eax |
5073 | ret |
5072 | ret |
5074 | .2: ; bits per pixel |
5073 | .2: ; bits per pixel |
5075 | mov eax, [_display.bpp] |
5074 | mov eax, [_display.bpp] |
5076 | mov [esp+32], eax |
5075 | mov [esp+32], eax |
5077 | ret |
5076 | ret |
5078 | .3: ; bytes per scanline |
5077 | .3: ; bytes per scanline |
5079 | mov eax, [_display.pitch] |
5078 | mov eax, [_display.pitch] |
5080 | mov [esp+32], eax |
5079 | mov [esp+32], eax |
5081 | ret |
5080 | ret |
5082 | 5081 | ||
5083 | align 4 ; system functions |
5082 | align 4 ; system functions |
5084 | 5083 | ||
5085 | syscall_setpixel: ; SetPixel |
5084 | syscall_setpixel: ; SetPixel |
5086 | 5085 | ||
5087 | mov eax, ebx |
5086 | mov eax, ebx |
5088 | mov ebx, ecx |
5087 | mov ebx, ecx |
5089 | mov ecx, edx |
5088 | mov ecx, edx |
5090 | mov edx, [TASK_BASE] |
5089 | mov edx, [TASK_BASE] |
5091 | add eax, [edx-twdw+WDATA.box.left] |
5090 | add eax, [edx-twdw+WDATA.box.left] |
5092 | add ebx, [edx-twdw+WDATA.box.top] |
5091 | add ebx, [edx-twdw+WDATA.box.top] |
5093 | mov edi, [current_slot] |
5092 | mov edi, [current_slot] |
5094 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5093 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5095 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5094 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5096 | xor edi, edi ; no force |
5095 | xor edi, edi ; no force |
5097 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5096 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5098 | ; jmp [putpixel] |
5097 | ; jmp [putpixel] |
5099 | jmp __sys_putpixel |
5098 | jmp __sys_putpixel |
5100 | 5099 | ||
5101 | align 4 |
5100 | align 4 |
5102 | 5101 | ||
5103 | syscall_writetext: ; WriteText |
5102 | syscall_writetext: ; WriteText |
5104 | 5103 | ||
5105 | mov eax, [TASK_BASE] |
5104 | mov eax, [TASK_BASE] |
5106 | mov ebp, [eax-twdw+WDATA.box.left] |
5105 | mov ebp, [eax-twdw+WDATA.box.left] |
5107 | push esi |
5106 | push esi |
5108 | mov esi, [current_slot] |
5107 | mov esi, [current_slot] |
5109 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5108 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5110 | shl ebp, 16 |
5109 | shl ebp, 16 |
5111 | add ebp, [eax-twdw+WDATA.box.top] |
5110 | add ebp, [eax-twdw+WDATA.box.top] |
5112 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5111 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5113 | pop esi |
5112 | pop esi |
5114 | test ecx, 0x08000000 ; redirect the output to the user area |
5113 | test ecx, 0x08000000 ; redirect the output to the user area |
5115 | jnz @f |
5114 | jnz @f |
5116 | add ebx, ebp |
5115 | add ebx, ebp |
5117 | align 4 |
5116 | align 4 |
5118 | @@: |
5117 | @@: |
5119 | mov eax, edi |
5118 | mov eax, edi |
5120 | test ecx, 0x08000000 ; redirect the output to the user area |
5119 | test ecx, 0x08000000 ; redirect the output to the user area |
5121 | jnz dtext |
5120 | jnz dtext |
5122 | xor edi, edi |
5121 | xor edi, edi |
5123 | jmp dtext |
5122 | jmp dtext |
5124 | 5123 | ||
5125 | align 4 |
5124 | align 4 |
5126 | 5125 | ||
5127 | syscall_openramdiskfile: ; OpenRamdiskFile |
5126 | syscall_openramdiskfile: ; OpenRamdiskFile |
5128 | 5127 | ||
5129 | mov eax, ebx |
5128 | mov eax, ebx |
5130 | mov ebx, ecx |
5129 | mov ebx, ecx |
5131 | mov ecx, edx |
5130 | mov ecx, edx |
5132 | mov edx, esi |
5131 | mov edx, esi |
5133 | mov esi, 12 |
5132 | mov esi, 12 |
5134 | call fileread |
5133 | call fileread |
5135 | mov [esp+32], eax |
5134 | mov [esp+32], eax |
5136 | ret |
5135 | ret |
5137 | 5136 | ||
5138 | align 4 |
5137 | align 4 |
5139 | 5138 | ||
5140 | syscall_drawrect: ; DrawRect |
5139 | syscall_drawrect: ; DrawRect |
5141 | 5140 | ||
5142 | mov edi, edx ; color + gradient |
5141 | mov edi, edx ; color + gradient |
5143 | and edi, 0x80FFFFFF |
5142 | and edi, 0x80FFFFFF |
5144 | test bx, bx ; x.size |
5143 | test bx, bx ; x.size |
5145 | je .drectr |
5144 | je .drectr |
5146 | test cx, cx ; y.size |
5145 | test cx, cx ; y.size |
5147 | je .drectr |
5146 | je .drectr |
5148 | 5147 | ||
5149 | mov eax, ebx ; bad idea |
5148 | mov eax, ebx ; bad idea |
5150 | mov ebx, ecx |
5149 | mov ebx, ecx |
5151 | 5150 | ||
5152 | movzx ecx, ax ; ecx - x.size |
5151 | movzx ecx, ax ; ecx - x.size |
5153 | shr eax, 16 ; eax - x.coord |
5152 | shr eax, 16 ; eax - x.coord |
5154 | movzx edx, bx ; edx - y.size |
5153 | movzx edx, bx ; edx - y.size |
5155 | shr ebx, 16 ; ebx - y.coord |
5154 | shr ebx, 16 ; ebx - y.coord |
5156 | mov esi, [current_slot] |
5155 | mov esi, [current_slot] |
5157 | 5156 | ||
5158 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5157 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5159 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5158 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5160 | add ecx, eax |
5159 | add ecx, eax |
5161 | add edx, ebx |
5160 | add edx, ebx |
5162 | ; jmp [drawbar] |
5161 | ; jmp [drawbar] |
5163 | jmp vesa20_drawbar |
5162 | jmp vesa20_drawbar |
5164 | .drectr: |
5163 | .drectr: |
5165 | ret |
5164 | ret |
5166 | 5165 | ||
5167 | align 4 |
5166 | align 4 |
5168 | syscall_getscreensize: ; GetScreenSize |
5167 | syscall_getscreensize: ; GetScreenSize |
5169 | mov ax, word [Screen_Max_X] |
5168 | mov ax, word [Screen_Max_X] |
5170 | shl eax, 16 |
5169 | shl eax, 16 |
5171 | mov ax, word [Screen_Max_Y] |
5170 | mov ax, word [Screen_Max_Y] |
5172 | mov [esp + 32], eax |
5171 | mov [esp + 32], eax |
5173 | ret |
5172 | ret |
5174 | 5173 | ||
5175 | align 4 |
5174 | align 4 |
5176 | 5175 | ||
5177 | syscall_cdaudio: ; CD |
5176 | syscall_cdaudio: ; CD |
5178 | 5177 | ||
5179 | cmp ebx, 4 |
5178 | cmp ebx, 4 |
5180 | jb .audio |
5179 | jb .audio |
5181 | jz .eject |
5180 | jz .eject |
5182 | cmp ebx, 5 |
5181 | cmp ebx, 5 |
5183 | jnz .ret |
5182 | jnz .ret |
5184 | .load: |
5183 | .load: |
5185 | call .reserve |
5184 | call .reserve |
5186 | call LoadMedium |
5185 | call LoadMedium |
5187 | ;call .free |
5186 | ;call .free |
5188 | jmp .free |
5187 | jmp .free |
5189 | ; ret |
5188 | ; ret |
5190 | .eject: |
5189 | .eject: |
5191 | call .reserve |
5190 | call .reserve |
5192 | call clear_CD_cache |
5191 | call clear_CD_cache |
5193 | call allow_medium_removal |
5192 | call allow_medium_removal |
5194 | call EjectMedium |
5193 | call EjectMedium |
5195 | ; call .free |
5194 | ; call .free |
5196 | jmp .free |
5195 | jmp .free |
5197 | ; ret |
5196 | ; ret |
5198 | .audio: |
5197 | .audio: |
5199 | call sys_cd_audio |
5198 | call sys_cd_audio |
5200 | mov [esp+36-4], eax |
5199 | mov [esp+36-4], eax |
5201 | .ret: |
5200 | .ret: |
5202 | ret |
5201 | ret |
5203 | 5202 | ||
5204 | .reserve: |
5203 | .reserve: |
5205 | call reserve_cd |
5204 | call reserve_cd |
5206 | mov eax, ecx |
5205 | mov eax, ecx |
5207 | shr eax, 1 |
5206 | shr eax, 1 |
5208 | and eax, 1 |
5207 | and eax, 1 |
5209 | inc eax |
5208 | inc eax |
5210 | mov [ChannelNumber], ax |
5209 | mov [ChannelNumber], ax |
5211 | mov eax, ecx |
5210 | mov eax, ecx |
5212 | and eax, 1 |
5211 | and eax, 1 |
5213 | mov [DiskNumber], al |
5212 | mov [DiskNumber], al |
5214 | call reserve_cd_channel |
5213 | call reserve_cd_channel |
5215 | and ebx, 3 |
5214 | and ebx, 3 |
5216 | inc ebx |
5215 | inc ebx |
5217 | mov [cdpos], ebx |
5216 | mov [cdpos], ebx |
5218 | add ebx, ebx |
5217 | add ebx, ebx |
5219 | mov cl, 8 |
5218 | mov cl, 8 |
5220 | sub cl, bl |
5219 | sub cl, bl |
5221 | mov al, [DRIVE_DATA+1] |
5220 | mov al, [DRIVE_DATA+1] |
5222 | shr al, cl |
5221 | shr al, cl |
5223 | test al, 2 |
5222 | test al, 2 |
5224 | jz .free;.err |
5223 | jz .free;.err |
5225 | ret |
5224 | ret |
5226 | .free: |
5225 | .free: |
5227 | call free_cd_channel |
5226 | call free_cd_channel |
5228 | and [cd_status], 0 |
5227 | and [cd_status], 0 |
5229 | ret |
5228 | ret |
5230 | .err: |
5229 | .err: |
5231 | call .free |
5230 | call .free |
5232 | ; pop eax |
5231 | ; pop eax |
5233 | ret |
5232 | ret |
5234 | ;----------------------------------------------------------------------------- |
5233 | ;----------------------------------------------------------------------------- |
5235 | align 4 |
5234 | align 4 |
5236 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5235 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5237 | cmp ebx, [Screen_Max_X] |
5236 | cmp ebx, [Screen_Max_X] |
5238 | jbe @f |
5237 | jbe @f |
5239 | cmp ecx, [Screen_Max_Y] |
5238 | cmp ecx, [Screen_Max_Y] |
5240 | jbe @f |
5239 | jbe @f |
5241 | xor eax, eax |
5240 | xor eax, eax |
5242 | jmp .store |
5241 | jmp .store |
5243 | ;-------------------------------------- |
5242 | ;-------------------------------------- |
5244 | align 4 |
5243 | align 4 |
5245 | @@: |
5244 | @@: |
5246 | mov eax, [d_width_calc_area + ecx*4] |
5245 | mov eax, [d_width_calc_area + ecx*4] |
5247 | add eax, [_WinMapAddress] |
5246 | add eax, [_WinMapAddress] |
5248 | movzx eax, byte[eax+ebx] ; get value for current point |
5247 | movzx eax, byte[eax+ebx] ; get value for current point |
5249 | ;-------------------------------------- |
5248 | ;-------------------------------------- |
5250 | align 4 |
5249 | align 4 |
5251 | .store: |
5250 | .store: |
5252 | mov [esp + 32], eax |
5251 | mov [esp + 32], eax |
5253 | ret |
5252 | ret |
5254 | ;----------------------------------------------------------------------------- |
5253 | ;----------------------------------------------------------------------------- |
5255 | align 4 |
5254 | align 4 |
5256 | syscall_getpixel: ; GetPixel |
5255 | syscall_getpixel: ; GetPixel |
5257 | mov ecx, [Screen_Max_X] |
5256 | mov ecx, [Screen_Max_X] |
5258 | inc ecx |
5257 | inc ecx |
5259 | xor edx, edx |
5258 | xor edx, edx |
5260 | mov eax, ebx |
5259 | mov eax, ebx |
5261 | div ecx |
5260 | div ecx |
5262 | mov ebx, edx |
5261 | mov ebx, edx |
5263 | xchg eax, ebx |
5262 | xchg eax, ebx |
5264 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5263 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5265 | call dword [GETPIXEL]; eax - x, ebx - y |
5264 | call dword [GETPIXEL]; eax - x, ebx - y |
5266 | mov [esp + 32], ecx |
5265 | mov [esp + 32], ecx |
5267 | ret |
5266 | ret |
5268 | ;----------------------------------------------------------------------------- |
5267 | ;----------------------------------------------------------------------------- |
5269 | align 4 |
5268 | align 4 |
5270 | syscall_getarea: |
5269 | syscall_getarea: |
5271 | ;eax = 36 |
5270 | ;eax = 36 |
5272 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5271 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5273 | ;ecx = [size x]*65536 + [size y] |
5272 | ;ecx = [size x]*65536 + [size y] |
5274 | ;edx = [start x]*65536 + [start y] |
5273 | ;edx = [start x]*65536 + [start y] |
5275 | pushad |
5274 | pushad |
5276 | mov edi, ebx |
5275 | mov edi, ebx |
5277 | mov eax, edx |
5276 | mov eax, edx |
5278 | shr eax, 16 |
5277 | shr eax, 16 |
5279 | mov ebx, edx |
5278 | mov ebx, edx |
5280 | and ebx, 0xffff |
5279 | and ebx, 0xffff |
5281 | dec eax |
5280 | dec eax |
5282 | dec ebx |
5281 | dec ebx |
5283 | ; eax - x, ebx - y |
5282 | ; eax - x, ebx - y |
5284 | mov edx, ecx |
5283 | mov edx, ecx |
5285 | 5284 | ||
5286 | shr ecx, 16 |
5285 | shr ecx, 16 |
5287 | and edx, 0xffff |
5286 | and edx, 0xffff |
5288 | mov esi, ecx |
5287 | mov esi, ecx |
5289 | ; ecx - size x, edx - size y |
5288 | ; ecx - size x, edx - size y |
5290 | 5289 | ||
5291 | mov ebp, edx |
5290 | mov ebp, edx |
5292 | dec ebp |
5291 | dec ebp |
5293 | lea ebp, [ebp*3] |
5292 | lea ebp, [ebp*3] |
5294 | 5293 | ||
5295 | imul ebp, esi |
5294 | imul ebp, esi |
5296 | 5295 | ||
5297 | mov esi, ecx |
5296 | mov esi, ecx |
5298 | dec esi |
5297 | dec esi |
5299 | lea esi, [esi*3] |
5298 | lea esi, [esi*3] |
5300 | 5299 | ||
5301 | add ebp, esi |
5300 | add ebp, esi |
5302 | add ebp, edi |
5301 | add ebp, edi |
5303 | 5302 | ||
5304 | add ebx, edx |
5303 | add ebx, edx |
5305 | ;-------------------------------------- |
5304 | ;-------------------------------------- |
5306 | align 4 |
5305 | align 4 |
5307 | .start_y: |
5306 | .start_y: |
5308 | push ecx edx |
5307 | push ecx edx |
5309 | ;-------------------------------------- |
5308 | ;-------------------------------------- |
5310 | align 4 |
5309 | align 4 |
5311 | .start_x: |
5310 | .start_x: |
5312 | push eax ebx ecx |
5311 | push eax ebx ecx |
5313 | add eax, ecx |
5312 | add eax, ecx |
5314 | 5313 | ||
5315 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5314 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5316 | call dword [GETPIXEL]; eax - x, ebx - y |
5315 | call dword [GETPIXEL]; eax - x, ebx - y |
5317 | 5316 | ||
5318 | mov [ebp], cx |
5317 | mov [ebp], cx |
5319 | shr ecx, 16 |
5318 | shr ecx, 16 |
5320 | mov [ebp+2], cl |
5319 | mov [ebp+2], cl |
5321 | 5320 | ||
5322 | pop ecx ebx eax |
5321 | pop ecx ebx eax |
5323 | sub ebp, 3 |
5322 | sub ebp, 3 |
5324 | dec ecx |
5323 | dec ecx |
5325 | jnz .start_x |
5324 | jnz .start_x |
5326 | pop edx ecx |
5325 | pop edx ecx |
5327 | dec ebx |
5326 | dec ebx |
5328 | dec edx |
5327 | dec edx |
5329 | jnz .start_y |
5328 | jnz .start_y |
5330 | popad |
5329 | popad |
5331 | ret |
5330 | ret |
5332 | ;----------------------------------------------------------------------------- |
5331 | ;----------------------------------------------------------------------------- |
5333 | align 4 |
5332 | align 4 |
5334 | syscall_putarea_backgr: |
5333 | syscall_putarea_backgr: |
5335 | ;eax = 25 |
5334 | ;eax = 25 |
5336 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5335 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5337 | ;ecx = [size x]*65536 + [size y] |
5336 | ;ecx = [size x]*65536 + [size y] |
5338 | ;edx = [start x]*65536 + [start y] |
5337 | ;edx = [start x]*65536 + [start y] |
5339 | pushad |
5338 | pushad |
5340 | mov edi, ebx |
5339 | mov edi, ebx |
5341 | mov eax, edx |
5340 | mov eax, edx |
5342 | shr eax, 16 |
5341 | shr eax, 16 |
5343 | mov ebx, edx |
5342 | mov ebx, edx |
5344 | and ebx, 0xffff |
5343 | and ebx, 0xffff |
5345 | dec eax |
5344 | dec eax |
5346 | dec ebx |
5345 | dec ebx |
5347 | ; eax - x, ebx - y |
5346 | ; eax - x, ebx - y |
5348 | mov edx, ecx |
5347 | mov edx, ecx |
5349 | shr ecx, 16 |
5348 | shr ecx, 16 |
5350 | and edx, 0xffff |
5349 | and edx, 0xffff |
5351 | mov esi, ecx |
5350 | mov esi, ecx |
5352 | ; ecx - size x, edx - size y |
5351 | ; ecx - size x, edx - size y |
5353 | mov ebp, edx |
5352 | mov ebp, edx |
5354 | dec ebp |
5353 | dec ebp |
5355 | shl ebp, 2 |
5354 | shl ebp, 2 |
5356 | 5355 | ||
5357 | imul ebp, esi |
5356 | imul ebp, esi |
5358 | 5357 | ||
5359 | mov esi, ecx |
5358 | mov esi, ecx |
5360 | dec esi |
5359 | dec esi |
5361 | shl esi, 2 |
5360 | shl esi, 2 |
5362 | 5361 | ||
5363 | add ebp, esi |
5362 | add ebp, esi |
5364 | add ebp, edi |
5363 | add ebp, edi |
5365 | 5364 | ||
5366 | add ebx, edx |
5365 | add ebx, edx |
5367 | ;-------------------------------------- |
5366 | ;-------------------------------------- |
5368 | align 4 |
5367 | align 4 |
5369 | .start_y: |
5368 | .start_y: |
5370 | push ecx edx |
5369 | push ecx edx |
5371 | ;-------------------------------------- |
5370 | ;-------------------------------------- |
5372 | align 4 |
5371 | align 4 |
5373 | .start_x: |
5372 | .start_x: |
5374 | push eax ecx |
5373 | push eax ecx |
5375 | add eax, ecx |
5374 | add eax, ecx |
5376 | 5375 | ||
5377 | mov ecx, [ebp] |
5376 | mov ecx, [ebp] |
5378 | rol ecx, 8 |
5377 | rol ecx, 8 |
5379 | test cl, cl ; transparensy = 0 |
5378 | test cl, cl ; transparensy = 0 |
5380 | jz .no_put |
5379 | jz .no_put |
5381 | 5380 | ||
5382 | xor cl, cl |
5381 | xor cl, cl |
5383 | ror ecx, 8 |
5382 | ror ecx, 8 |
5384 | 5383 | ||
5385 | pushad |
5384 | pushad |
5386 | mov edx, [d_width_calc_area + ebx*4] |
5385 | mov edx, [d_width_calc_area + ebx*4] |
5387 | add edx, [_WinMapAddress] |
5386 | add edx, [_WinMapAddress] |
5388 | movzx edx, byte [eax+edx] |
5387 | movzx edx, byte [eax+edx] |
5389 | cmp dl, byte 1 |
5388 | cmp dl, byte 1 |
5390 | jne @f |
5389 | jne @f |
5391 | 5390 | ||
5392 | call dword [PUTPIXEL]; eax - x, ebx - y |
5391 | call dword [PUTPIXEL]; eax - x, ebx - y |
5393 | ;-------------------------------------- |
5392 | ;-------------------------------------- |
5394 | align 4 |
5393 | align 4 |
5395 | @@: |
5394 | @@: |
5396 | popad |
5395 | popad |
5397 | ;-------------------------------------- |
5396 | ;-------------------------------------- |
5398 | align 4 |
5397 | align 4 |
5399 | .no_put: |
5398 | .no_put: |
5400 | pop ecx eax |
5399 | pop ecx eax |
5401 | 5400 | ||
5402 | sub ebp, 4 |
5401 | sub ebp, 4 |
5403 | dec ecx |
5402 | dec ecx |
5404 | jnz .start_x |
5403 | jnz .start_x |
5405 | 5404 | ||
5406 | pop edx ecx |
5405 | pop edx ecx |
5407 | dec ebx |
5406 | dec ebx |
5408 | dec edx |
5407 | dec edx |
5409 | jnz .start_y |
5408 | jnz .start_y |
5410 | 5409 | ||
5411 | popad |
5410 | popad |
5412 | ret |
5411 | ret |
5413 | ;----------------------------------------------------------------------------- |
5412 | ;----------------------------------------------------------------------------- |
5414 | align 4 |
5413 | align 4 |
5415 | syscall_drawline: ; DrawLine |
5414 | syscall_drawline: ; DrawLine |
5416 | 5415 | ||
5417 | mov edi, [TASK_BASE] |
5416 | mov edi, [TASK_BASE] |
5418 | movzx eax, word[edi-twdw+WDATA.box.left] |
5417 | movzx eax, word[edi-twdw+WDATA.box.left] |
5419 | mov ebp, eax |
5418 | mov ebp, eax |
5420 | mov esi, [current_slot] |
5419 | mov esi, [current_slot] |
5421 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5420 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5422 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5421 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5423 | add ebp, ebx |
5422 | add ebp, ebx |
5424 | shl eax, 16 |
5423 | shl eax, 16 |
5425 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5424 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5426 | add eax, ebp |
5425 | add eax, ebp |
5427 | mov ebp, ebx |
5426 | mov ebp, ebx |
5428 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5427 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5429 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5428 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5430 | add ebp, ecx |
5429 | add ebp, ecx |
5431 | shl ebx, 16 |
5430 | shl ebx, 16 |
5432 | xor edi, edi |
5431 | xor edi, edi |
5433 | add ebx, ebp |
5432 | add ebx, ebp |
5434 | mov ecx, edx |
5433 | mov ecx, edx |
5435 | ; jmp [draw_line] |
5434 | ; jmp [draw_line] |
5436 | jmp __sys_draw_line |
5435 | jmp __sys_draw_line |
5437 | 5436 | ||
5438 | 5437 | ||
5439 | align 4 |
5438 | align 4 |
5440 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5439 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5441 | 5440 | ||
5442 | call r_f_port_area |
5441 | call r_f_port_area |
5443 | mov [esp+32], eax |
5442 | mov [esp+32], eax |
5444 | ret |
5443 | ret |
5445 | 5444 | ||
5446 | align 4 |
5445 | align 4 |
5447 | syscall_threads: ; CreateThreads |
5446 | syscall_threads: ; CreateThreads |
5448 | ; eax=1 create thread |
5447 | ; eax=1 create thread |
5449 | ; |
5448 | ; |
5450 | ; ebx=thread start |
5449 | ; ebx=thread start |
5451 | ; ecx=thread stack value |
5450 | ; ecx=thread stack value |
5452 | ; |
5451 | ; |
5453 | ; on return : eax = pid |
5452 | ; on return : eax = pid |
5454 | 5453 | ||
5455 | call new_sys_threads |
5454 | call new_sys_threads |
5456 | 5455 | ||
5457 | mov [esp+32], eax |
5456 | mov [esp+32], eax |
5458 | ret |
5457 | ret |
5459 | 5458 | ||
5460 | align 4 |
5459 | align 4 |
5461 | 5460 | ||
5462 | paleholder: |
5461 | paleholder: |
5463 | ret |
5462 | ret |
5464 | ;------------------------------------------------------------------------------ |
5463 | ;------------------------------------------------------------------------------ |
5465 | align 4 |
5464 | align 4 |
5466 | calculate_fast_getting_offset_for_WinMapAddress: |
5465 | calculate_fast_getting_offset_for_WinMapAddress: |
5467 | ; calculate data area for fast getting offset to _WinMapAddress |
5466 | ; calculate data area for fast getting offset to _WinMapAddress |
5468 | xor eax, eax |
5467 | xor eax, eax |
5469 | mov ecx, [_display.height] |
5468 | mov ecx, [_display.height] |
5470 | mov edi, d_width_calc_area |
5469 | mov edi, d_width_calc_area |
5471 | cld |
5470 | cld |
5472 | @@: |
5471 | @@: |
5473 | stosd |
5472 | stosd |
5474 | add eax, [_display.width] |
5473 | add eax, [_display.width] |
5475 | dec ecx |
5474 | dec ecx |
5476 | jnz @r |
5475 | jnz @r |
5477 | ret |
5476 | ret |
5478 | ;------------------------------------------------------------------------------ |
5477 | ;------------------------------------------------------------------------------ |
5479 | align 4 |
5478 | align 4 |
5480 | calculate_fast_getting_offset_for_LFB: |
5479 | calculate_fast_getting_offset_for_LFB: |
5481 | ; calculate data area for fast getting offset to LFB |
5480 | ; calculate data area for fast getting offset to LFB |
5482 | xor eax, eax |
5481 | xor eax, eax |
5483 | mov ecx, [_display.height] |
5482 | mov ecx, [_display.height] |
5484 | mov edi, BPSLine_calc_area |
5483 | mov edi, BPSLine_calc_area |
5485 | cld |
5484 | cld |
5486 | @@: |
5485 | @@: |
5487 | stosd |
5486 | stosd |
5488 | add eax, [_display.pitch] |
5487 | add eax, [_display.pitch] |
5489 | dec ecx |
5488 | dec ecx |
5490 | jnz @r |
5489 | jnz @r |
5491 | ret |
5490 | ret |
5492 | ;------------------------------------------------------------------------------ |
5491 | ;------------------------------------------------------------------------------ |
5493 | align 4 |
5492 | align 4 |
5494 | set_screen: |
5493 | set_screen: |
5495 | ; in: |
5494 | ; in: |
5496 | ; eax - new Screen_Max_X |
5495 | ; eax - new Screen_Max_X |
5497 | ; ecx - new BytesPerScanLine |
5496 | ; ecx - new BytesPerScanLine |
5498 | ; edx - new Screen_Max_Y |
5497 | ; edx - new Screen_Max_Y |
5499 | cmp eax, [Screen_Max_X] |
5498 | cmp eax, [Screen_Max_X] |
5500 | jne .set |
5499 | jne .set |
5501 | 5500 | ||
5502 | cmp edx, [Screen_Max_Y] |
5501 | cmp edx, [Screen_Max_Y] |
5503 | jne .set |
5502 | jne .set |
5504 | ret |
5503 | ret |
5505 | .set: |
5504 | .set: |
5506 | pushfd |
5505 | pushfd |
5507 | cli |
5506 | cli |
5508 | 5507 | ||
5509 | mov [Screen_Max_X], eax |
5508 | mov [Screen_Max_X], eax |
5510 | mov [Screen_Max_Y], edx |
5509 | mov [Screen_Max_Y], edx |
5511 | mov [_display.pitch], ecx |
5510 | mov [_display.pitch], ecx |
5512 | 5511 | ||
5513 | mov [screen_workarea.right], eax |
5512 | mov [screen_workarea.right], eax |
5514 | mov [screen_workarea.bottom], edx |
5513 | mov [screen_workarea.bottom], edx |
5515 | 5514 | ||
5516 | push ebx |
5515 | push ebx |
5517 | push esi |
5516 | push esi |
5518 | push edi |
5517 | push edi |
5519 | 5518 | ||
5520 | pushad |
5519 | pushad |
5521 | 5520 | ||
5522 | cmp [do_not_touch_winmap], 1 |
5521 | cmp [do_not_touch_winmap], 1 |
5523 | je @f |
5522 | je @f |
5524 | 5523 | ||
5525 | stdcall kernel_free, [_WinMapAddress] |
5524 | stdcall kernel_free, [_WinMapAddress] |
5526 | 5525 | ||
5527 | mov eax, [_display.width] |
5526 | mov eax, [_display.width] |
5528 | mul [_display.height] |
5527 | mul [_display.height] |
5529 | mov [_WinMapSize], eax |
5528 | mov [_WinMapSize], eax |
5530 | 5529 | ||
5531 | stdcall kernel_alloc, eax |
5530 | stdcall kernel_alloc, eax |
5532 | mov [_WinMapAddress], eax |
5531 | mov [_WinMapAddress], eax |
5533 | test eax, eax |
5532 | test eax, eax |
5534 | jz .epic_fail |
5533 | jz .epic_fail |
5535 | ; store for f.18.24 |
5534 | ; store for f.18.24 |
5536 | mov eax, [_display.width] |
5535 | mov eax, [_display.width] |
5537 | mov [display_width_standard], eax |
5536 | mov [display_width_standard], eax |
5538 | 5537 | ||
5539 | mov eax, [_display.height] |
5538 | mov eax, [_display.height] |
5540 | mov [display_height_standard], eax |
5539 | mov [display_height_standard], eax |
5541 | @@: |
5540 | @@: |
5542 | call calculate_fast_getting_offset_for_WinMapAddress |
5541 | call calculate_fast_getting_offset_for_WinMapAddress |
5543 | ; for Qemu or non standart video cards |
5542 | ; for Qemu or non standart video cards |
5544 | ; Unfortunately [BytesPerScanLine] does not always |
5543 | ; Unfortunately [BytesPerScanLine] does not always |
5545 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5544 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5546 | call calculate_fast_getting_offset_for_LFB |
5545 | call calculate_fast_getting_offset_for_LFB |
5547 | popad |
5546 | popad |
5548 | 5547 | ||
5549 | call repos_windows |
5548 | call repos_windows |
5550 | xor eax, eax |
5549 | xor eax, eax |
5551 | xor ebx, ebx |
5550 | xor ebx, ebx |
5552 | mov ecx, [Screen_Max_X] |
5551 | mov ecx, [Screen_Max_X] |
5553 | mov edx, [Screen_Max_Y] |
5552 | mov edx, [Screen_Max_Y] |
5554 | call calculatescreen |
5553 | call calculatescreen |
5555 | pop edi |
5554 | pop edi |
5556 | pop esi |
5555 | pop esi |
5557 | pop ebx |
5556 | pop ebx |
5558 | 5557 | ||
5559 | popfd |
5558 | popfd |
5560 | ret |
5559 | ret |
5561 | 5560 | ||
5562 | .epic_fail: |
5561 | .epic_fail: |
5563 | hlt ; Houston, we've had a problem |
5562 | hlt ; Houston, we've had a problem |
5564 | 5563 | ||
5565 | ; --------------- APM --------------------- |
5564 | ; --------------- APM --------------------- |
5566 | uglobal |
5565 | uglobal |
5567 | apm_entry dp 0 |
5566 | apm_entry dp 0 |
5568 | apm_vf dd 0 |
5567 | apm_vf dd 0 |
5569 | endg |
5568 | endg |
5570 | 5569 | ||
5571 | align 4 |
5570 | align 4 |
5572 | sys_apm: |
5571 | sys_apm: |
5573 | xor eax, eax |
5572 | xor eax, eax |
5574 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5573 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5575 | jne @f |
5574 | jne @f |
5576 | inc eax |
5575 | inc eax |
5577 | or dword [esp + 44], eax ; error |
5576 | or dword [esp + 44], eax ; error |
5578 | add eax, 7 |
5577 | add eax, 7 |
5579 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5578 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5580 | ret |
5579 | ret |
5581 | 5580 | ||
5582 | @@: |
5581 | @@: |
5583 | ; xchg eax, ecx |
5582 | ; xchg eax, ecx |
5584 | ; xchg ebx, ecx |
5583 | ; xchg ebx, ecx |
5585 | 5584 | ||
5586 | cmp dx, 3 |
5585 | cmp dx, 3 |
5587 | ja @f |
5586 | ja @f |
5588 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5587 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5589 | mov eax, [apm_vf] |
5588 | mov eax, [apm_vf] |
5590 | mov [esp + 32], eax |
5589 | mov [esp + 32], eax |
5591 | shr eax, 16 |
5590 | shr eax, 16 |
5592 | mov [esp + 28], eax |
5591 | mov [esp + 28], eax |
5593 | ret |
5592 | ret |
5594 | 5593 | ||
5595 | @@: |
5594 | @@: |
5596 | 5595 | ||
5597 | mov esi, [master_tab+(OS_BASE shr 20)] |
5596 | mov esi, [master_tab+(OS_BASE shr 20)] |
5598 | xchg [master_tab], esi |
5597 | xchg [master_tab], esi |
5599 | push esi |
5598 | push esi |
5600 | mov edi, cr3 |
5599 | mov edi, cr3 |
5601 | mov cr3, edi ;flush TLB |
5600 | mov cr3, edi ;flush TLB |
5602 | 5601 | ||
5603 | call pword [apm_entry] ;call APM BIOS |
5602 | call pword [apm_entry] ;call APM BIOS |
5604 | 5603 | ||
5605 | xchg eax, [esp] |
5604 | xchg eax, [esp] |
5606 | mov [master_tab], eax |
5605 | mov [master_tab], eax |
5607 | mov eax, cr3 |
5606 | mov eax, cr3 |
5608 | mov cr3, eax |
5607 | mov cr3, eax |
5609 | pop eax |
5608 | pop eax |
5610 | 5609 | ||
5611 | mov [esp + 4 ], edi |
5610 | mov [esp + 4 ], edi |
5612 | mov [esp + 8], esi |
5611 | mov [esp + 8], esi |
5613 | mov [esp + 20], ebx |
5612 | mov [esp + 20], ebx |
5614 | mov [esp + 24], edx |
5613 | mov [esp + 24], edx |
5615 | mov [esp + 28], ecx |
5614 | mov [esp + 28], ecx |
5616 | mov [esp + 32], eax |
5615 | mov [esp + 32], eax |
5617 | setc al |
5616 | setc al |
5618 | and [esp + 44], byte 0xfe |
5617 | and [esp + 44], byte 0xfe |
5619 | or [esp + 44], al |
5618 | or [esp + 44], al |
5620 | ret |
5619 | ret |
5621 | ; ----------------------------------------- |
5620 | ; ----------------------------------------- |
5622 | 5621 | ||
5623 | align 4 |
5622 | align 4 |
5624 | 5623 | ||
5625 | undefined_syscall: ; Undefined system call |
5624 | undefined_syscall: ; Undefined system call |
5626 | mov [esp + 32], dword -1 |
5625 | mov [esp + 32], dword -1 |
5627 | ret |
5626 | ret |
5628 | 5627 | ||
5629 | align 4 |
5628 | align 4 |
5630 | system_shutdown: ; shut down the system |
5629 | system_shutdown: ; shut down the system |
5631 | 5630 | ||
5632 | cmp byte [BOOT_VARS+0x9030], 1 |
5631 | cmp byte [BOOT_VARS+0x9030], 1 |
5633 | jne @F |
5632 | jne @F |
5634 | ret |
5633 | ret |
5635 | @@: |
5634 | @@: |
5636 | call stop_all_services |
5635 | call stop_all_services |
5637 | movi eax, 3 |
5636 | movi eax, 3 |
5638 | call sys_cd_audio |
5637 | call sys_cd_audio |
5639 | 5638 | ||
5640 | yes_shutdown_param: |
5639 | yes_shutdown_param: |
5641 | cli |
5640 | cli |
5642 | 5641 | ||
5643 | if ~ defined extended_primary_loader |
5642 | if ~ defined extended_primary_loader |
5644 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5643 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5645 | movi esi, 12 |
5644 | movi esi, 12 |
5646 | xor ebx, ebx |
5645 | xor ebx, ebx |
5647 | or ecx, -1 |
5646 | or ecx, -1 |
5648 | mov edx, OS_BASE+0x70000 |
5647 | mov edx, OS_BASE+0x70000 |
5649 | call fileread |
5648 | call fileread |
5650 | 5649 | ||
5651 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5650 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5652 | mov edi, OS_BASE+0x40000 |
5651 | mov edi, OS_BASE+0x40000 |
5653 | mov ecx, 1000 |
5652 | mov ecx, 1000 |
5654 | rep movsb |
5653 | rep movsb |
5655 | end if |
5654 | end if |
5656 | 5655 | ||
5657 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5656 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5658 | ; mov edi, OS_BASE |
5657 | ; mov edi, OS_BASE |
5659 | ; mov ecx, 0x10000/4 |
5658 | ; mov ecx, 0x10000/4 |
5660 | ; cld |
5659 | ; cld |
5661 | ; rep movsd |
5660 | ; rep movsd |
5662 | 5661 | ||
5663 | call restorefatchain |
5662 | call restorefatchain |
5664 | 5663 | ||
5665 | call IRQ_mask_all |
5664 | call IRQ_mask_all |
5666 | 5665 | ||
5667 | if 0 |
5666 | if 0 |
5668 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5667 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5669 | mov word [OS_BASE+0x467+2], 0x1000 |
5668 | mov word [OS_BASE+0x467+2], 0x1000 |
5670 | 5669 | ||
5671 | mov al, 0x0F |
5670 | mov al, 0x0F |
5672 | out 0x70, al |
5671 | out 0x70, al |
5673 | mov al, 0x05 |
5672 | mov al, 0x05 |
5674 | out 0x71, al |
5673 | out 0x71, al |
5675 | 5674 | ||
5676 | mov al, 0xFE |
5675 | mov al, 0xFE |
5677 | out 0x64, al |
5676 | out 0x64, al |
5678 | 5677 | ||
5679 | hlt |
5678 | hlt |
5680 | jmp $-1 |
5679 | jmp $-1 |
5681 | 5680 | ||
5682 | else |
5681 | else |
5683 | cmp byte [OS_BASE + 0x9030], 2 |
5682 | cmp byte [OS_BASE + 0x9030], 2 |
5684 | jnz no_acpi_power_off |
5683 | jnz no_acpi_power_off |
5685 | 5684 | ||
5686 | ; scan for RSDP |
5685 | ; scan for RSDP |
5687 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5686 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5688 | movzx eax, word [OS_BASE + 0x40E] |
5687 | movzx eax, word [OS_BASE + 0x40E] |
5689 | shl eax, 4 |
5688 | shl eax, 4 |
5690 | jz @f |
5689 | jz @f |
5691 | mov ecx, 1024/16 |
5690 | mov ecx, 1024/16 |
5692 | call scan_rsdp |
5691 | call scan_rsdp |
5693 | jnc .rsdp_found |
5692 | jnc .rsdp_found |
5694 | @@: |
5693 | @@: |
5695 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5694 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5696 | mov eax, 0xE0000 |
5695 | mov eax, 0xE0000 |
5697 | mov ecx, 0x2000 |
5696 | mov ecx, 0x2000 |
5698 | call scan_rsdp |
5697 | call scan_rsdp |
5699 | jc no_acpi_power_off |
5698 | jc no_acpi_power_off |
5700 | .rsdp_found: |
5699 | .rsdp_found: |
5701 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5700 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5702 | mov ebp, [ipc_tmp] |
5701 | mov ebp, [ipc_tmp] |
5703 | stdcall map_page, ebp, esi, PG_MAP |
5702 | stdcall map_page, ebp, esi, PG_MAP |
5704 | lea eax, [esi+1000h] |
5703 | lea eax, [esi+1000h] |
5705 | lea edx, [ebp+1000h] |
5704 | lea edx, [ebp+1000h] |
5706 | stdcall map_page, edx, eax, PG_MAP |
5705 | stdcall map_page, edx, eax, PG_MAP |
5707 | and esi, 0xFFF |
5706 | and esi, 0xFFF |
5708 | add esi, ebp |
5707 | add esi, ebp |
5709 | cmp dword [esi], 'RSDT' |
5708 | cmp dword [esi], 'RSDT' |
5710 | jnz no_acpi_power_off |
5709 | jnz no_acpi_power_off |
5711 | mov ecx, [esi+4] |
5710 | mov ecx, [esi+4] |
5712 | sub ecx, 24h |
5711 | sub ecx, 24h |
5713 | jbe no_acpi_power_off |
5712 | jbe no_acpi_power_off |
5714 | shr ecx, 2 |
5713 | shr ecx, 2 |
5715 | add esi, 24h |
5714 | add esi, 24h |
5716 | .scan_fadt: |
5715 | .scan_fadt: |
5717 | lodsd |
5716 | lodsd |
5718 | mov ebx, eax |
5717 | mov ebx, eax |
5719 | lea eax, [ebp+2000h] |
5718 | lea eax, [ebp+2000h] |
5720 | stdcall map_page, eax, ebx, PG_MAP |
5719 | stdcall map_page, eax, ebx, PG_MAP |
5721 | lea eax, [ebp+3000h] |
5720 | lea eax, [ebp+3000h] |
5722 | add ebx, 0x1000 |
5721 | add ebx, 0x1000 |
5723 | stdcall map_page, eax, ebx, PG_MAP |
5722 | stdcall map_page, eax, ebx, PG_MAP |
5724 | and ebx, 0xFFF |
5723 | and ebx, 0xFFF |
5725 | lea ebx, [ebx+ebp+2000h] |
5724 | lea ebx, [ebx+ebp+2000h] |
5726 | cmp dword [ebx], 'FACP' |
5725 | cmp dword [ebx], 'FACP' |
5727 | jz .fadt_found |
5726 | jz .fadt_found |
5728 | loop .scan_fadt |
5727 | loop .scan_fadt |
5729 | jmp no_acpi_power_off |
5728 | jmp no_acpi_power_off |
5730 | .fadt_found: |
5729 | .fadt_found: |
5731 | ; ebx is linear address of FADT |
5730 | ; ebx is linear address of FADT |
5732 | mov edi, [ebx+40] ; physical address of the DSDT |
5731 | mov edi, [ebx+40] ; physical address of the DSDT |
5733 | lea eax, [ebp+4000h] |
5732 | lea eax, [ebp+4000h] |
5734 | stdcall map_page, eax, edi, PG_MAP |
5733 | stdcall map_page, eax, edi, PG_MAP |
5735 | lea eax, [ebp+5000h] |
5734 | lea eax, [ebp+5000h] |
5736 | lea esi, [edi+0x1000] |
5735 | lea esi, [edi+0x1000] |
5737 | stdcall map_page, eax, esi, PG_MAP |
5736 | stdcall map_page, eax, esi, PG_MAP |
5738 | and esi, 0xFFF |
5737 | and esi, 0xFFF |
5739 | sub edi, esi |
5738 | sub edi, esi |
5740 | cmp dword [esi+ebp+4000h], 'DSDT' |
5739 | cmp dword [esi+ebp+4000h], 'DSDT' |
5741 | jnz no_acpi_power_off |
5740 | jnz no_acpi_power_off |
5742 | mov eax, [esi+ebp+4004h] ; DSDT length |
5741 | mov eax, [esi+ebp+4004h] ; DSDT length |
5743 | sub eax, 36+4 |
5742 | sub eax, 36+4 |
5744 | jbe no_acpi_power_off |
5743 | jbe no_acpi_power_off |
5745 | add esi, 36 |
5744 | add esi, 36 |
5746 | .scan_dsdt: |
5745 | .scan_dsdt: |
5747 | cmp dword [esi+ebp+4000h], '_S5_' |
5746 | cmp dword [esi+ebp+4000h], '_S5_' |
5748 | jnz .scan_dsdt_cont |
5747 | jnz .scan_dsdt_cont |
5749 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5748 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5750 | jnz .scan_dsdt_cont |
5749 | jnz .scan_dsdt_cont |
5751 | mov dl, [esi+ebp+4000h+6] |
5750 | mov dl, [esi+ebp+4000h+6] |
5752 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5751 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5753 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5752 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5754 | ja .scan_dsdt_cont |
5753 | ja .scan_dsdt_cont |
5755 | cmp dl, 1 |
5754 | cmp dl, 1 |
5756 | jb .scan_dsdt_cont |
5755 | jb .scan_dsdt_cont |
5757 | lea esi, [esi+ebp+4000h+7] |
5756 | lea esi, [esi+ebp+4000h+7] |
5758 | xor ecx, ecx |
5757 | xor ecx, ecx |
5759 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5758 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5760 | jz @f |
5759 | jz @f |
5761 | cmp byte [esi], 0xA |
5760 | cmp byte [esi], 0xA |
5762 | jnz no_acpi_power_off |
5761 | jnz no_acpi_power_off |
5763 | inc esi |
5762 | inc esi |
5764 | mov cl, [esi] |
5763 | mov cl, [esi] |
5765 | @@: |
5764 | @@: |
5766 | inc esi |
5765 | inc esi |
5767 | cmp dl, 2 |
5766 | cmp dl, 2 |
5768 | jb @f |
5767 | jb @f |
5769 | cmp byte [esi], 0 |
5768 | cmp byte [esi], 0 |
5770 | jz @f |
5769 | jz @f |
5771 | cmp byte [esi], 0xA |
5770 | cmp byte [esi], 0xA |
5772 | jnz no_acpi_power_off |
5771 | jnz no_acpi_power_off |
5773 | inc esi |
5772 | inc esi |
5774 | mov ch, [esi] |
5773 | mov ch, [esi] |
5775 | @@: |
5774 | @@: |
5776 | jmp do_acpi_power_off |
5775 | jmp do_acpi_power_off |
5777 | .scan_dsdt_cont: |
5776 | .scan_dsdt_cont: |
5778 | inc esi |
5777 | inc esi |
5779 | cmp esi, 0x1000 |
5778 | cmp esi, 0x1000 |
5780 | jb @f |
5779 | jb @f |
5781 | sub esi, 0x1000 |
5780 | sub esi, 0x1000 |
5782 | add edi, 0x1000 |
5781 | add edi, 0x1000 |
5783 | push eax |
5782 | push eax |
5784 | lea eax, [ebp+4000h] |
5783 | lea eax, [ebp+4000h] |
5785 | stdcall map_page, eax, edi, PG_MAP |
5784 | stdcall map_page, eax, edi, PG_MAP |
5786 | push PG_MAP |
5785 | push PG_MAP |
5787 | lea eax, [edi+1000h] |
5786 | lea eax, [edi+1000h] |
5788 | push eax |
5787 | push eax |
5789 | lea eax, [ebp+5000h] |
5788 | lea eax, [ebp+5000h] |
5790 | push eax |
5789 | push eax |
5791 | stdcall map_page |
5790 | stdcall map_page |
5792 | pop eax |
5791 | pop eax |
5793 | @@: |
5792 | @@: |
5794 | dec eax |
5793 | dec eax |
5795 | jnz .scan_dsdt |
5794 | jnz .scan_dsdt |
5796 | jmp no_acpi_power_off |
5795 | jmp no_acpi_power_off |
5797 | do_acpi_power_off: |
5796 | do_acpi_power_off: |
5798 | mov edx, [ebx+48] |
5797 | mov edx, [ebx+48] |
5799 | test edx, edx |
5798 | test edx, edx |
5800 | jz .nosmi |
5799 | jz .nosmi |
5801 | mov al, [ebx+52] |
5800 | mov al, [ebx+52] |
5802 | out dx, al |
5801 | out dx, al |
5803 | mov edx, [ebx+64] |
5802 | mov edx, [ebx+64] |
5804 | @@: |
5803 | @@: |
5805 | in ax, dx |
5804 | in ax, dx |
5806 | test al, 1 |
5805 | test al, 1 |
5807 | jz @b |
5806 | jz @b |
5808 | .nosmi: |
5807 | .nosmi: |
5809 | and cx, 0x0707 |
5808 | and cx, 0x0707 |
5810 | shl cx, 2 |
5809 | shl cx, 2 |
5811 | or cx, 0x2020 |
5810 | or cx, 0x2020 |
5812 | mov edx, [ebx+64] |
5811 | mov edx, [ebx+64] |
5813 | in ax, dx |
5812 | in ax, dx |
5814 | and ax, 203h |
5813 | and ax, 203h |
5815 | or ah, cl |
5814 | or ah, cl |
5816 | out dx, ax |
5815 | out dx, ax |
5817 | mov edx, [ebx+68] |
5816 | mov edx, [ebx+68] |
5818 | test edx, edx |
5817 | test edx, edx |
5819 | jz @f |
5818 | jz @f |
5820 | in ax, dx |
5819 | in ax, dx |
5821 | and ax, 203h |
5820 | and ax, 203h |
5822 | or ah, ch |
5821 | or ah, ch |
5823 | out dx, ax |
5822 | out dx, ax |
5824 | @@: |
5823 | @@: |
5825 | jmp $ |
5824 | jmp $ |
5826 | 5825 | ||
5827 | 5826 | ||
5828 | no_acpi_power_off: |
5827 | no_acpi_power_off: |
5829 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5828 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5830 | mov word [OS_BASE+0x467+2], 0x1000 |
5829 | mov word [OS_BASE+0x467+2], 0x1000 |
5831 | 5830 | ||
5832 | mov al, 0x0F |
5831 | mov al, 0x0F |
5833 | out 0x70, al |
5832 | out 0x70, al |
5834 | mov al, 0x05 |
5833 | mov al, 0x05 |
5835 | out 0x71, al |
5834 | out 0x71, al |
5836 | 5835 | ||
5837 | mov al, 0xFE |
5836 | mov al, 0xFE |
5838 | out 0x64, al |
5837 | out 0x64, al |
5839 | 5838 | ||
5840 | hlt |
5839 | hlt |
5841 | jmp $-1 |
5840 | jmp $-1 |
5842 | 5841 | ||
5843 | scan_rsdp: |
5842 | scan_rsdp: |
5844 | add eax, OS_BASE |
5843 | add eax, OS_BASE |
5845 | .s: |
5844 | .s: |
5846 | cmp dword [eax], 'RSD ' |
5845 | cmp dword [eax], 'RSD ' |
5847 | jnz .n |
5846 | jnz .n |
5848 | cmp dword [eax+4], 'PTR ' |
5847 | cmp dword [eax+4], 'PTR ' |
5849 | jnz .n |
5848 | jnz .n |
5850 | xor edx, edx |
5849 | xor edx, edx |
5851 | xor esi, esi |
5850 | xor esi, esi |
5852 | @@: |
5851 | @@: |
5853 | add dl, [eax+esi] |
5852 | add dl, [eax+esi] |
5854 | inc esi |
5853 | inc esi |
5855 | cmp esi, 20 |
5854 | cmp esi, 20 |
5856 | jnz @b |
5855 | jnz @b |
5857 | test dl, dl |
5856 | test dl, dl |
5858 | jz .ok |
5857 | jz .ok |
5859 | .n: |
5858 | .n: |
5860 | add eax, 10h |
5859 | add eax, 10h |
5861 | loop .s |
5860 | loop .s |
5862 | stc |
5861 | stc |
5863 | .ok: |
5862 | .ok: |
5864 | ret |
5863 | ret |
5865 | end if |
5864 | end if |
5866 | 5865 | ||
5867 | if ~ lang eq sp |
5866 | if ~ lang eq sp |
5868 | diff16 "end of .text segment",0,$ |
5867 | diff16 "end of .text segment",0,$ |
5869 | end if |
5868 | end if |
5870 | 5869 | ||
5871 | include "data32.inc" |
5870 | include "data32.inc" |
5872 | 5871 | ||
5873 | __REV__ = __REV |
5872 | __REV__ = __REV |
5874 | 5873 | ||
5875 | if ~ lang eq sp |
5874 | if ~ lang eq sp |
5876 | diff16 "end of kernel code",0,$ |
5875 | diff16 "end of kernel code",0,$ |
5877 | end if=> |
5876 | end if=> |