Subversion Repositories Kolibri OS

Rev

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

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