Subversion Repositories Kolibri OS

Rev

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

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