Subversion Repositories Kolibri OS

Rev

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

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