Subversion Repositories Kolibri OS

Rev

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

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