Subversion Repositories Kolibri OS

Rev

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

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