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