Subversion Repositories Kolibri OS

Rev

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

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