Subversion Repositories Kolibri OS

Rev

Rev 1066 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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