Subversion Repositories Kolibri OS

Rev

Rev 521 | Rev 527 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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