Subversion Repositories Kolibri OS

Rev

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

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