Subversion Repositories Kolibri OS

Rev

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

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