Subversion Repositories Kolibri OS

Rev

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

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