Subversion Repositories Kolibri OS

Rev

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

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