Subversion Repositories Kolibri OS

Rev

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

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