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