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