Subversion Repositories Kolibri OS

Rev

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

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