Rev 709 | Rev 726 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
431 | serge | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
||
5 | ;; Distributed under terms of the GNU General Public License ;; |
||
6 | ;; ;; |
||
7 | ;; BOOTCODE.INC ;; |
||
8 | ;; ;; |
||
9 | ;; KolibriOS 16-bit loader, ;; |
||
10 | ;; based on bootcode for MenuetOS ;; |
||
11 | ;; ;; |
||
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1 | ha | 13 | |
593 | mikedld | 14 | $Revision: 713 $ |
1 | ha | 15 | |
16 | |||
17 | ;========================================================================== |
||
18 | ; |
||
19 | ; 16 BIT FUNCTIONS |
||
20 | ; |
||
21 | ;========================================================================== |
||
22 | |||
183 | diamond | 23 | |
29 | halyavin | 24 | putchar: |
25 | ; in: al=character |
||
514 | diamond | 26 | mov ah, 0Eh |
27 | mov bh, 0 |
||
28 | int 10h |
||
29 | ret |
||
1 | ha | 30 | |
29 | halyavin | 31 | print: |
32 | ; in: si->string |
||
514 | diamond | 33 | mov al, 186 |
34 | call putchar |
||
35 | mov al, ' ' |
||
36 | call putchar |
||
1 | ha | 37 | |
29 | halyavin | 38 | printplain: |
39 | ; in: si->string |
||
514 | diamond | 40 | pusha |
41 | lodsb |
||
29 | halyavin | 42 | @@: |
514 | diamond | 43 | call putchar |
44 | lodsb |
||
45 | cmp al, 0 |
||
46 | jnz @b |
||
47 | popa |
||
48 | ret |
||
1 | ha | 49 | |
29 | halyavin | 50 | getkey: |
51 | ; get number in range [bl,bh] (bl,bh in ['0'..'9']) |
||
52 | ; in: bx=range |
||
53 | ; out: ax=digit (1..9, 10 for 0) |
||
514 | diamond | 54 | mov ah, 0 |
55 | int 16h |
||
56 | cmp al, bl |
||
57 | jb getkey |
||
58 | cmp al, bh |
||
59 | ja getkey |
||
60 | push ax |
||
61 | call putchar |
||
62 | pop ax |
||
63 | and ax, 0Fh |
||
64 | jnz @f |
||
65 | mov al, 10 |
||
29 | halyavin | 66 | @@: |
514 | diamond | 67 | ret |
1 | ha | 68 | |
29 | halyavin | 69 | setcursor: |
70 | ; in: dl=column, dh=row |
||
514 | diamond | 71 | mov ah, 2 |
72 | mov bh, 0 |
||
73 | int 10h |
||
74 | ret |
||
29 | halyavin | 75 | |
76 | macro _setcursor row,column |
||
77 | { |
||
514 | diamond | 78 | mov dx, row*256 + column |
79 | call setcursor |
||
29 | halyavin | 80 | } |
81 | |||
134 | diamond | 82 | boot_read_floppy: |
83 | push si |
||
84 | xor si, si |
||
85 | mov ah, 2 ; read |
||
86 | @@: |
||
87 | push ax |
||
88 | int 0x13 |
||
89 | pop ax |
||
90 | jnc @f |
||
91 | inc si |
||
92 | cmp si, 10 |
||
93 | jb @b |
||
465 | serge | 94 | mov si, badsect |
134 | diamond | 95 | sayerr_plain: |
96 | call printplain |
||
97 | jmp $ |
||
98 | @@: |
||
99 | pop si |
||
100 | ret |
||
101 | |||
1 | ha | 102 | ;========================================================================= |
103 | ; |
||
104 | ; 16 BIT CODE |
||
105 | ; |
||
106 | ;========================================================================= |
||
107 | |||
713 | Lrz | 108 | include 'bootvesa.inc' ;Include source for boot vesa |
1 | ha | 109 | |
110 | start_of_code: |
||
514 | diamond | 111 | cld |
29 | halyavin | 112 | ; \begin{diamond}[02.12.2005] |
514 | diamond | 113 | ; if bootloader sets ax = 'KL', then ds:si points to loader block |
114 | cmp ax, 'KL' |
||
115 | jnz @f |
||
116 | mov word [cs:cfgmanager.loader_block], si |
||
117 | mov word [cs:cfgmanager.loader_block+2], ds |
||
29 | halyavin | 118 | @@: |
119 | ; \end{diamond}[02.12.2005] |
||
1 | ha | 120 | |
514 | diamond | 121 | ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk |
122 | ; (see comment to bx_from_load) |
||
123 | cmp cx, 'HA' |
||
124 | jnz no_hd_load |
||
125 | cmp dx,'RD' |
||
126 | jnz no_hd_load |
||
127 | mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] |
||
488 | spraid | 128 | no_hd_load: |
129 | |||
29 | halyavin | 130 | ; set up stack |
514 | diamond | 131 | mov ax, 3000h |
132 | mov ss, ax |
||
133 | mov sp, 0EC00h |
||
29 | halyavin | 134 | ; set up segment registers |
514 | diamond | 135 | push cs |
136 | pop ds |
||
137 | push cs |
||
138 | pop es |
||
1 | ha | 139 | |
29 | halyavin | 140 | ; set videomode |
514 | diamond | 141 | mov ax, 3 |
142 | int 0x10 |
||
1 | ha | 143 | |
134 | diamond | 144 | if lang eq ru |
1 | ha | 145 | ; Load & set russian VGA font (RU.INC) |
514 | diamond | 146 | mov bp, RU_FNT1 ; RU_FNT1 - First part |
147 | mov bx, 1000h ; 768 bytes |
||
148 | mov cx, 30h ; 48 symbols |
||
149 | mov dx, 80h ; 128 - position of first symbol |
||
150 | mov ax, 1100h |
||
151 | int 10h |
||
1 | ha | 152 | |
514 | diamond | 153 | mov bp, RU_FNT2 ; RU_FNT2 -Second part |
154 | mov bx, 1000h ; 512 bytes |
||
155 | mov cx, 20h ; 32 symbols |
||
156 | mov dx, 0E0h ; 224 - position of first symbol |
||
157 | mov ax, 1100h |
||
158 | int 10h |
||
1 | ha | 159 | ; End set VGA russian font |
274 | kaitz | 160 | else if lang eq et |
514 | diamond | 161 | mov bp, ET_FNT ; ET_FNT1 |
162 | mov bx, 1000h ; |
||
163 | mov cx, 255 ; 256 symbols |
||
164 | xor dx, dx ; 0 - position of first symbol |
||
165 | mov ax, 1100h |
||
166 | int 10h |
||
134 | diamond | 167 | end if |
1 | ha | 168 | |
29 | halyavin | 169 | ; draw frames |
514 | diamond | 170 | push 0xb800 |
171 | pop es |
||
172 | xor di, di |
||
173 | mov ah, 1*16+15 |
||
465 | serge | 174 | |
29 | halyavin | 175 | ; draw top |
514 | diamond | 176 | mov si, d80x25_top |
177 | mov cx, d80x25_top_num * 80 |
||
29 | halyavin | 178 | @@: |
514 | diamond | 179 | lodsb |
180 | stosw |
||
181 | loop @b |
||
29 | halyavin | 182 | ; draw spaces |
514 | diamond | 183 | mov si, space_msg |
184 | mov dx, 25 - d80x25_top_num - d80x25_bottom_num |
||
29 | halyavin | 185 | dfl1: |
514 | diamond | 186 | push si |
187 | mov cx, 80 |
||
29 | halyavin | 188 | @@: |
514 | diamond | 189 | lodsb |
190 | stosw |
||
191 | loop @b |
||
192 | pop si |
||
193 | dec dx |
||
194 | jnz dfl1 |
||
29 | halyavin | 195 | ; draw bottom |
514 | diamond | 196 | mov si, d80x25_bottom |
197 | mov cx, d80x25_bottom_num * 80 |
||
29 | halyavin | 198 | @@: |
514 | diamond | 199 | lodsb |
200 | stosw |
||
201 | loop @b |
||
1 | ha | 202 | |
514 | diamond | 203 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
1 | ha | 204 | |
514 | diamond | 205 | _setcursor d80x25_top_num,0 |
1 | ha | 206 | |
207 | |||
208 | ; TEST FOR 386+ |
||
209 | |||
514 | diamond | 210 | mov bx, 0x4000 |
1 | ha | 211 | pushf |
212 | pop ax |
||
514 | diamond | 213 | mov dx, ax |
214 | xor ax, bx |
||
1 | ha | 215 | push ax |
216 | popf |
||
217 | pushf |
||
218 | pop ax |
||
514 | diamond | 219 | and ax, bx |
220 | and dx, bx |
||
221 | cmp ax, dx |
||
1 | ha | 222 | jnz cpugood |
514 | diamond | 223 | mov si, not386 |
40 | halyavin | 224 | sayerr: |
1 | ha | 225 | call print |
226 | jmp $ |
||
227 | cpugood: |
||
228 | |||
514 | diamond | 229 | push 0 |
465 | serge | 230 | popf |
231 | sti |
||
232 | |||
29 | halyavin | 233 | ; set up esp |
514 | diamond | 234 | movzx esp, sp |
1 | ha | 235 | |
160 | diamond | 236 | push 0 |
237 | pop es |
||
238 | and word [es:0x9031], 0 |
||
164 | serge | 239 | ; \begin{Mario79} |
240 | ; find HDD IDE DMA PCI device |
||
160 | diamond | 241 | ; check for PCI BIOS |
242 | mov ax, 0xB101 |
||
243 | int 0x1A |
||
244 | jc .nopci |
||
245 | cmp edx, 'PCI ' |
||
246 | jnz .nopci |
||
247 | ; find PCI class code |
||
248 | ; class 1 = mass storage |
||
249 | ; subclass 1 = IDE controller |
||
250 | ; a) class 1, subclass 1, programming interface 0x80 |
||
251 | mov ax, 0xB103 |
||
252 | mov ecx, 1*10000h + 1*100h + 0x80 |
||
514 | diamond | 253 | xor si, si ; device index = 0 |
160 | diamond | 254 | int 0x1A |
255 | jnc .found |
||
187 | diamond | 256 | ; b) class 1, subclass 1, programming interface 0x8A |
160 | diamond | 257 | mov ax, 0xB103 |
187 | diamond | 258 | mov ecx, 1*10000h + 1*100h + 0x8A |
514 | diamond | 259 | xor si, si ; device index = 0 |
160 | diamond | 260 | int 0x1A |
261 | jnc .found |
||
187 | diamond | 262 | ; c) class 1, subclass 1, programming interface 0x85 |
160 | diamond | 263 | mov ax, 0xB103 |
187 | diamond | 264 | mov ecx, 1*10000h + 1*100h + 0x85 |
514 | diamond | 265 | xor si, si |
160 | diamond | 266 | int 0x1A |
267 | jc .nopci |
||
268 | .found: |
||
269 | ; get memory base |
||
270 | mov ax, 0xB10A |
||
271 | mov di, 0x20 ; memory base is config register at 0x20 |
||
272 | int 0x1A |
||
273 | jc .nopci |
||
274 | and cx, 0xFFF0 ; clear address decode type |
||
275 | mov [es:0x9031], cx |
||
276 | .nopci: |
||
164 | serge | 277 | ; \end{Mario79} |
160 | diamond | 278 | |
514 | diamond | 279 | mov al, 0xf6 ; Ñáðîñ êëàâèàòóðû, ðàçðåøèòü ñêàíèðîâàíèå |
280 | out 0x60, al |
||
281 | xor cx, cx |
||
1 | ha | 282 | wait_loop: ; variant 2 |
283 | ; reading state of port of 8042 controller |
||
514 | diamond | 284 | in al, 64h |
285 | and al, 00000010b ; ready flag |
||
164 | serge | 286 | ; wait until 8042 controller is ready |
1 | ha | 287 | loopnz wait_loop |
288 | |||
713 | Lrz | 289 | ;;;/diamond today 5.02.2008 |
290 | ; set keyboard typematic rate & delay |
||
291 | mov al, 0xf3 |
||
292 | out 0x60, al |
||
293 | xor cx, cx |
||
294 | @@: |
||
295 | in al, 64h |
||
296 | test al, 2 |
||
297 | loopnz @b |
||
298 | mov al, 0 |
||
299 | out 0x60, al |
||
300 | xor cx, cx |
||
301 | @@: |
||
302 | in al, 64h |
||
303 | test al, 2 |
||
304 | loopnz @b |
||
305 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
76 | mario79 | 306 | ; --------------- APM --------------------- |
514 | diamond | 307 | and word [es:0x9044], 0 ; ver = 0.0 (APM not found) |
308 | mov ax, 0x5300 |
||
309 | xor bx, bx |
||
310 | int 0x15 |
||
311 | jc apm_end ; APM not found |
||
312 | test cx, 2 |
||
313 | jz apm_end ; APM 32-bit protected-mode interface not supported |
||
314 | mov [es:0x9044], ax ; Save APM Version |
||
315 | mov [es:0x9046], cx ; Save APM flags |
||
164 | serge | 316 | |
514 | diamond | 317 | ; Write APM ver ---- |
318 | and ax, 0xf0f |
||
319 | add ax, '00' |
||
320 | mov si, msg_apm |
||
321 | mov [si + 5], ah |
||
322 | mov [si + 7], al |
||
323 | _setcursor 0, 3 |
||
324 | call printplain |
||
325 | ; ------------------ |
||
164 | serge | 326 | |
514 | diamond | 327 | mov ax, 0x5304 ; Disconnect interface |
328 | xor bx, bx |
||
329 | int 0x15 |
||
330 | mov ax, 0x5303 ; Connect 32 bit mode interface |
||
331 | xor bx, bx |
||
332 | int 0x15 |
||
465 | serge | 333 | |
514 | diamond | 334 | mov [es:0x9040], ebx |
335 | mov [es:0x9050], ax |
||
336 | mov [es:0x9052], cx |
||
337 | mov [es:0x9054], dx |
||
465 | serge | 338 | |
76 | mario79 | 339 | apm_end: |
437 | diamond | 340 | _setcursor d80x25_top_num, 0 |
76 | mario79 | 341 | |
713 | Lrz | 342 | ;CHECK current of code |
343 | cmp [cfgmanager.loader_block], -1 |
||
344 | jz noloaderblock |
||
345 | les bx, [cfgmanager.loader_block] |
||
346 | cmp byte [es:bx], 1 |
||
347 | mov si, loader_block_error |
||
348 | jnz sayerr |
||
349 | |||
350 | noloaderblock: |
||
1 | ha | 351 | ; DISPLAY VESA INFORMATION |
713 | Lrz | 352 | call print_vesa_info |
353 | call calc_vmodes_table |
||
354 | call check_first_parm ;check and enable cursor_pos |
||
1 | ha | 355 | |
356 | |||
29 | halyavin | 357 | ; \begin{diamond}[30.11.2005] |
358 | cfgmanager: |
||
359 | ; settings: |
||
360 | ; a) preboot_graph = graphical mode |
||
361 | ; preboot_gprobe = probe this mode? |
||
713 | Lrz | 362 | ; b) preboot_dma = use DMA access? |
29 | halyavin | 363 | ; c) preboot_vrrm = use VRR? |
364 | ; d) preboot_device = from what boot? |
||
713 | Lrz | 365 | |
29 | halyavin | 366 | ; determine default settings |
514 | diamond | 367 | mov [.bSettingsChanged], 0 |
713 | Lrz | 368 | |
369 | ;.preboot_gr_end: |
||
370 | ; following 6 lines set variables to 1 if its current value is 0 |
||
371 | cmp byte[preboot_dma], 1 |
||
372 | adc byte[preboot_dma], 0 |
||
373 | cmp byte[preboot_vrrm], 1 |
||
374 | adc byte[preboot_vrrm], 0 |
||
375 | cmp byte[preboot_device], 1 |
||
376 | adc byte[preboot_device], 0 |
||
29 | halyavin | 377 | ; notify user |
713 | Lrz | 378 | _setcursor 5,2 |
379 | |||
514 | diamond | 380 | mov si, linef |
713 | Lrz | 381 | call printplain |
514 | diamond | 382 | mov si, start_msg |
383 | call print |
||
384 | mov si, time_msg |
||
385 | call print |
||
29 | halyavin | 386 | ; get start time |
514 | diamond | 387 | call .gettime |
388 | mov [.starttime], eax |
||
389 | mov word [.timer], .newtimer |
||
390 | mov word [.timer+2], cs |
||
29 | halyavin | 391 | .printcfg: |
514 | diamond | 392 | _setcursor 9,0 |
393 | mov si, current_cfg_msg |
||
394 | call print |
||
395 | mov si, curvideo_msg |
||
396 | call print |
||
713 | Lrz | 397 | |
398 | call draw_current_vmode |
||
399 | |||
709 | diamond | 400 | mov si, usebd_msg |
401 | cmp [preboot_biosdisk], 1 |
||
402 | call .say_on_off |
||
514 | diamond | 403 | mov si, vrrm_msg |
404 | cmp [preboot_vrrm], 1 |
||
405 | call .say_on_off |
||
406 | mov si, preboot_device_msg |
||
407 | call print |
||
408 | mov al, [preboot_device] |
||
545 | spraid | 409 | and eax, 7 |
514 | diamond | 410 | mov si, [preboot_device_msgs+eax*2] |
411 | call printplain |
||
29 | halyavin | 412 | .wait: |
514 | diamond | 413 | _setcursor 25,0 ; out of screen |
34 | halyavin | 414 | ; set timer interrupt handler |
514 | diamond | 415 | cli |
416 | push 0 |
||
417 | pop es |
||
713 | Lrz | 418 | push dword [es:8*4] |
419 | pop dword [.oldtimer] |
||
420 | push dword [.timer] |
||
421 | pop dword [es:8*4] |
||
422 | ; mov eax, [es:8*4] |
||
423 | ; mov [.oldtimer], eax |
||
424 | ; mov eax, [.timer] |
||
425 | ; mov [es:8*4], eax |
||
514 | diamond | 426 | sti |
29 | halyavin | 427 | ; wait for keypressed |
713 | Lrz | 428 | xor ax,ax |
514 | diamond | 429 | int 16h |
430 | push ax |
||
29 | halyavin | 431 | ; restore timer interrupt |
713 | Lrz | 432 | ; push 0 |
433 | ; pop es |
||
514 | diamond | 434 | mov eax, [.oldtimer] |
435 | mov [es:8*4], eax |
||
436 | mov [.timer], eax |
||
437 | _setcursor 7,0 |
||
438 | mov si, space_msg |
||
439 | call printplain |
||
440 | pop ax |
||
29 | halyavin | 441 | ; switch on key |
514 | diamond | 442 | cmp al, 13 |
443 | jz .continue |
||
444 | or al, 20h |
||
445 | cmp al, 'a' |
||
446 | jz .change_a |
||
447 | cmp al, 'b' |
||
448 | jz .change_b |
||
449 | cmp al, 'c' |
||
450 | jz .change_c |
||
451 | cmp al, 'd' |
||
452 | jnz .wait |
||
453 | _setcursor 15,0 |
||
454 | mov si, bdev |
||
455 | call print |
||
545 | spraid | 456 | mov bx, '14' |
514 | diamond | 457 | call getkey |
458 | mov [preboot_device], al |
||
459 | _setcursor 13,0 |
||
29 | halyavin | 460 | .d: |
514 | diamond | 461 | mov [.bSettingsChanged], 1 |
713 | Lrz | 462 | call clear_vmodes_table ;clear vmodes_table |
514 | diamond | 463 | jmp .printcfg |
29 | halyavin | 464 | .change_a: |
713 | Lrz | 465 | .loops: |
466 | call draw_vmodes_table |
||
467 | |||
468 | xor ax,ax |
||
469 | int 0x16 |
||
470 | ; call clear_table_cursor ;clear current position of cursor |
||
471 | |||
472 | mov si,word [cursor_pos] |
||
473 | |||
474 | cmp ah,0x48;x,0x48E0 ; up |
||
475 | jne .down |
||
476 | cmp si,modes_table |
||
477 | jbe .loops |
||
478 | sub word [cursor_pos],size_of_step |
||
479 | jmp .loops |
||
480 | |||
481 | .down: cmp ah,0x50;x,0x50E0 ; down |
||
482 | jne .enter |
||
483 | cmp word[es:si+10],-1 |
||
484 | je .loops |
||
485 | add word [cursor_pos],size_of_step |
||
486 | jmp .loops |
||
487 | |||
488 | .enter: cmp al,0x0D;x,0x1C0D ; enter |
||
489 | jne .loops |
||
490 | push word [cursor_pos] |
||
491 | pop word [preboot_graph] ;save choose |
||
514 | diamond | 492 | jmp .d |
713 | Lrz | 493 | |
29 | halyavin | 494 | .change_b: |
514 | diamond | 495 | _setcursor 15,0 |
709 | diamond | 496 | ; mov si, ask_dma |
497 | ; call print |
||
498 | ; mov bx, '13' |
||
499 | ; call getkey |
||
500 | ; mov [preboot_dma], al |
||
501 | mov si, ask_bd |
||
514 | diamond | 502 | call print |
709 | diamond | 503 | mov bx, '12' |
514 | diamond | 504 | call getkey |
709 | diamond | 505 | mov [preboot_biosdisk], al |
514 | diamond | 506 | _setcursor 11,0 |
507 | jmp .d |
||
29 | halyavin | 508 | .change_c: |
514 | diamond | 509 | _setcursor 15,0 |
510 | mov si, vrrmprint |
||
511 | call print |
||
512 | mov bx, '12' |
||
513 | call getkey |
||
514 | mov [preboot_vrrm], al |
||
515 | _setcursor 12,0 |
||
516 | jmp .d |
||
713 | Lrz | 517 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
40 | halyavin | 518 | .say_on_off: |
514 | diamond | 519 | pushf |
520 | call print |
||
521 | mov si, on_msg |
||
522 | popf |
||
523 | jz @f |
||
524 | mov si, off_msg |
||
525 | @@: jmp printplain |
||
40 | halyavin | 526 | ; novesa and vervesa strings are not used at the moment of executing this code |
527 | virtual at novesa |
||
29 | halyavin | 528 | .oldtimer dd ? |
529 | .starttime dd ? |
||
530 | .bSettingsChanged db ? |
||
34 | halyavin | 531 | .timer dd ? |
40 | halyavin | 532 | end virtual |
143 | diamond | 533 | .loader_block dd -1 |
29 | halyavin | 534 | .gettime: |
514 | diamond | 535 | mov ah, 0 |
536 | int 1Ah |
||
537 | xchg ax, cx |
||
538 | shl eax, 10h |
||
539 | xchg ax, dx |
||
540 | ret |
||
29 | halyavin | 541 | .newtimer: |
514 | diamond | 542 | push ds |
543 | push cs |
||
544 | pop ds |
||
545 | pushf |
||
546 | call [.oldtimer] |
||
547 | pushad |
||
548 | call .gettime |
||
549 | sub eax, [.starttime] |
||
550 | sub ax, 18*5 |
||
551 | jae .timergo |
||
552 | neg ax |
||
553 | add ax, 18-1 |
||
554 | mov bx, 18 |
||
555 | xor dx, dx |
||
556 | div bx |
||
29 | halyavin | 557 | if lang eq ru |
558 | ; ¯®¤®¦¤¨â¥ 5 ᥪã¤, 4/3/2 ᥪã¤ë, 1 ᥪã¤ã |
||
514 | diamond | 559 | cmp al, 5 |
560 | mov cl, ' ' |
||
561 | jae @f |
||
562 | cmp al, 1 |
||
563 | mov cl, 'ã' |
||
564 | jz @f |
||
565 | mov cl, 'ë' |
||
566 | @@: mov [time_str+9], cl |
||
274 | kaitz | 567 | else if lang eq et |
514 | diamond | 568 | cmp al, 1 |
569 | ja @f |
||
570 | mov [time_str+9], ' ' |
||
571 | mov [time_str+10],' ' |
||
381 | serge | 572 | @@: |
29 | halyavin | 573 | else |
574 | ; wait 5/4/3/2 seconds, 1 second |
||
514 | diamond | 575 | cmp al, 1 |
576 | mov cl, 's' |
||
577 | ja @f |
||
578 | mov cl, ' ' |
||
579 | @@: mov [time_str+9], cl |
||
29 | halyavin | 580 | end if |
514 | diamond | 581 | add al, '0' |
582 | mov [time_str+1], al |
||
583 | mov si, time_msg |
||
584 | _setcursor 7,0 |
||
585 | call print |
||
586 | _setcursor 25,0 |
||
587 | popad |
||
588 | pop ds |
||
589 | iret |
||
29 | halyavin | 590 | .timergo: |
514 | diamond | 591 | push 0 |
592 | pop es |
||
593 | mov eax, [.oldtimer] |
||
594 | mov [es:8*4], eax |
||
595 | mov sp, 0EC00h |
||
29 | halyavin | 596 | .continue: |
514 | diamond | 597 | sti |
598 | _setcursor 6,0 |
||
599 | mov si, space_msg |
||
600 | call printplain |
||
601 | call printplain |
||
602 | _setcursor 6,0 |
||
603 | mov si, loading_msg |
||
604 | call print |
||
605 | _setcursor 15,0 |
||
606 | cmp [.bSettingsChanged], 0 |
||
607 | jz .load |
||
608 | cmp [.loader_block], -1 |
||
609 | jz .load |
||
610 | les bx, [.loader_block] |
||
611 | mov eax, [es:bx+3] |
||
612 | push ds |
||
613 | pop es |
||
614 | test eax, eax |
||
615 | jz .load |
||
616 | push eax |
||
617 | mov si, save_quest |
||
618 | call print |
||
29 | halyavin | 619 | .waityn: |
514 | diamond | 620 | mov ah, 0 |
621 | int 16h |
||
622 | or al, 20h |
||
623 | cmp al, 'n' |
||
624 | jz .loadc |
||
625 | cmp al, 'y' |
||
626 | jnz .waityn |
||
627 | call putchar |
||
628 | mov byte [space_msg+80], 186 |
||
629 | pop eax |
||
630 | push cs |
||
631 | push .cont |
||
632 | push eax |
||
633 | retf |
||
29 | halyavin | 634 | .loadc: |
514 | diamond | 635 | pop eax |
29 | halyavin | 636 | .cont: |
514 | diamond | 637 | push cs |
638 | pop ds |
||
639 | mov si, space_msg |
||
640 | mov byte [si+80], 0 |
||
641 | _setcursor 15,0 |
||
642 | call printplain |
||
643 | _setcursor 15,0 |
||
29 | halyavin | 644 | .load: |
645 | ; \end{diamond}[02.12.2005] |
||
1 | ha | 646 | |
647 | ; ASK GRAPHICS MODE |
||
648 | |||
713 | Lrz | 649 | call set_vmode |
1 | ha | 650 | |
651 | ; GRAPHICS ACCELERATION |
||
346 | diamond | 652 | ; force yes |
653 | mov [es:0x901C], byte 1 |
||
1 | ha | 654 | |
514 | diamond | 655 | ; DMA ACCESS TO HD |
1 | ha | 656 | |
514 | diamond | 657 | mov al, [preboot_dma] |
658 | mov [es:0x901F], al |
||
346 | diamond | 659 | |
1 | ha | 660 | ; VRR_M USE |
661 | |||
465 | serge | 662 | mov al,[preboot_vrrm] |
514 | diamond | 663 | mov [es:0x9030], al |
664 | mov [es:0x901E], byte 1 |
||
1 | ha | 665 | |
666 | ; BOOT DEVICE |
||
667 | |||
514 | diamond | 668 | mov al, [preboot_device] |
40 | halyavin | 669 | dec al |
514 | diamond | 670 | mov [boot_dev], al |
1 | ha | 671 | |
672 | ; READ DISKETTE TO MEMORY |
||
673 | |||
465 | serge | 674 | ; cmp [boot_dev],0 |
1 | ha | 675 | jne no_sys_on_floppy |
465 | serge | 676 | mov si,diskload |
1 | ha | 677 | call print |
514 | diamond | 678 | xor ax, ax ; reset drive |
679 | xor dx, dx |
||
1 | ha | 680 | int 0x13 |
709 | diamond | 681 | ; do we boot from CD-ROM? |
682 | mov ah, 41h |
||
683 | mov bx, 55AAh |
||
684 | xor dx, dx |
||
685 | int 0x13 |
||
686 | jc .nocd |
||
687 | cmp bx, 0AA55h |
||
688 | jnz .nocd |
||
689 | mov ah, 48h |
||
690 | push ds |
||
691 | push es |
||
692 | pop ds |
||
693 | mov si, 0xa000 |
||
694 | mov word [si], 30 |
||
695 | int 0x13 |
||
696 | pop ds |
||
697 | jc .nocd |
||
698 | push ds |
||
699 | lds si, [es:si+26] |
||
700 | test byte [ds:si+10], 40h |
||
701 | pop ds |
||
702 | jz .nocd |
||
703 | ; yes - read all floppy by 18 sectors |
||
704 | mov cx, 0x0001 ; startcyl,startsector |
||
705 | .a1: |
||
706 | push cx dx |
||
707 | mov al, 18 |
||
708 | mov bx, 0xa000 |
||
709 | call boot_read_floppy |
||
710 | mov si, movedesc |
||
711 | push es |
||
712 | push ds |
||
713 | pop es |
||
714 | mov cx, 256*18 |
||
715 | mov ah, 0x87 |
||
716 | int 0x15 |
||
717 | pop es |
||
718 | pop dx cx |
||
719 | test ah, ah |
||
720 | jnz sayerr_floppy |
||
721 | add dword [si+8*3+2], 512*18 |
||
722 | inc dh |
||
723 | cmp dh, 2 |
||
724 | jnz .a1 |
||
725 | mov dh, 0 |
||
726 | inc ch |
||
727 | cmp ch, 80 |
||
728 | jae ok_sys_on_floppy |
||
729 | pusha |
||
730 | mov al, ch |
||
731 | shr ch, 2 |
||
732 | add al, ch |
||
733 | aam |
||
734 | xchg al, ah |
||
735 | add ax, '00' |
||
736 | mov si, pros |
||
737 | mov [si], ax |
||
738 | call printplain |
||
739 | popa |
||
740 | jmp .a1 |
||
741 | .nocd: |
||
742 | ; no - read only used sectors from floppy |
||
134 | diamond | 743 | ; now load floppy image to memory |
744 | ; at first load boot sector and first FAT table |
||
745 | mov cx, 0x0001 ; startcyl,startsector |
||
746 | xor dx, dx ; starthead,drive |
||
747 | mov al, 1+9 ; no of sectors to read |
||
748 | mov bx, 0xB000 ; es:bx -> data area |
||
749 | call boot_read_floppy |
||
750 | ; and copy them to extended memory |
||
465 | serge | 751 | mov si, movedesc |
134 | diamond | 752 | mov [si+8*2+3], bh |
753 | push es |
||
754 | push ds |
||
755 | pop es |
||
756 | mov cx, 256*10 |
||
757 | mov ah, 0x87 |
||
758 | int 0x15 |
||
76 | mario79 | 759 | test ah, ah |
134 | diamond | 760 | jz @f |
761 | sayerr_floppy: |
||
762 | mov dx, 0x3f2 |
||
763 | mov al, 0 |
||
764 | out dx, al |
||
465 | serge | 765 | mov si, memmovefailed |
134 | diamond | 766 | jmp sayerr_plain |
767 | @@: |
||
768 | add dword [si+8*3+2], 512*10 |
||
769 | ; copy FAT to second copy |
||
770 | mov byte [si+8*2+3], 0xB2 |
||
771 | mov cx, 256*9 |
||
772 | mov ah, 0x87 |
||
773 | int 0x15 |
||
774 | pop es |
||
775 | test ah, ah |
||
776 | jnz sayerr_floppy |
||
777 | add dword [si+8*3+2], 512*9 |
||
778 | ; calculate total number of sectors to read |
||
779 | mov ax, 1+9+14 ; boot+FAT+root |
||
780 | mov di, 0xB203 |
||
781 | .calc_loop: |
||
782 | test word [es:di], 0xFFF |
||
783 | jz @f |
||
784 | inc ax |
||
785 | @@: |
||
786 | test word [es:di+1], 0xFFF0 |
||
787 | jz @f |
||
788 | inc ax |
||
789 | @@: |
||
790 | add di, 3 |
||
791 | cmp di, 0xB200+1440*3 |
||
792 | jb .calc_loop |
||
793 | push ax |
||
794 | mov bp, 1+9 ; already read sectors |
||
795 | ; now read rest |
||
796 | mov byte [si+8*2+3], 0xA0 |
||
797 | mov di, 2-14 ; absolute sector-31 |
||
798 | mov cx, 0x0002 ; cylinder=0, sector=2 |
||
799 | mov dx, 0x0100 ; head=1, disk=0 |
||
800 | .read_loop: |
||
801 | ; determine whether sector must be read |
||
802 | cmp di, 2 |
||
803 | jl .read |
||
804 | mov bx, di |
||
805 | shr bx, 1 |
||
806 | jnc .even |
||
807 | test word [es:bx+di+0xB200], 0xFFF0 |
||
808 | jmp @f |
||
809 | .even: |
||
810 | test word [es:bx+di+0xB200], 0xFFF |
||
811 | @@: |
||
812 | jz .skip |
||
813 | .read: |
||
814 | mov bx, 0xA000 |
||
815 | mov al, 1 ; 1 sector |
||
816 | call boot_read_floppy |
||
817 | inc bp |
||
76 | mario79 | 818 | push es |
819 | push ds |
||
1 | ha | 820 | pop es |
134 | diamond | 821 | pusha |
822 | mov cx, 256 |
||
823 | mov ah, 0x87 |
||
1 | ha | 824 | int 0x15 |
134 | diamond | 825 | test ah, ah |
1 | ha | 826 | popa |
134 | diamond | 827 | pop es |
828 | jnz sayerr_floppy |
||
829 | .skip: |
||
830 | add dword [si+8*3+2], 512 |
||
831 | inc cx |
||
832 | cmp cl, 19 |
||
833 | jnz @f |
||
834 | mov cl, 1 |
||
1 | ha | 835 | inc dh |
134 | diamond | 836 | cmp dh, 2 |
837 | jnz @f |
||
838 | mov dh, 0 |
||
1 | ha | 839 | inc ch |
29 | halyavin | 840 | @@: |
134 | diamond | 841 | pop ax |
842 | push ax |
||
843 | pusha |
||
844 | ; draw percentage |
||
845 | ; total sectors: ax |
||
846 | ; read sectors: bp |
||
847 | xchg ax, bp |
||
848 | mov cx, 100 |
||
849 | mul cx |
||
850 | div bp |
||
851 | aam |
||
852 | xchg al, ah |
||
853 | add ax, '00' |
||
465 | serge | 854 | mov si, pros |
134 | diamond | 855 | cmp [si], ax |
856 | jz @f |
||
857 | mov [si], ax |
||
1 | ha | 858 | call printplain |
134 | diamond | 859 | @@: |
1 | ha | 860 | popa |
134 | diamond | 861 | inc di |
862 | cmp di, 2880-31 |
||
863 | jnz .read_loop |
||
864 | |||
865 | ; mov cx, 0x0001 ; startcyl,startsector |
||
866 | ; xor dx, dx ; starthead,drive |
||
867 | ; push word 80*2 ; read no of sect |
||
868 | ; reads: |
||
869 | ; pusha |
||
870 | ; xor si,si |
||
871 | ; newread: |
||
872 | ; mov bx,0xa000 ; es:bx -> data area |
||
873 | ; mov ax,0x0200+18 ; read, no of sectors to read |
||
874 | ; int 0x13 |
||
875 | ; test ah, ah |
||
876 | ; jz goodread |
||
877 | ; inc si |
||
878 | ; cmp si,10 |
||
879 | ; jnz newread |
||
880 | ; mov si,badsect-0x10000 |
||
881 | ;sayerr_plain: |
||
882 | ; call printplain |
||
883 | ; jmp $ |
||
884 | ; goodread: |
||
885 | ; ; move -> 1mb |
||
886 | ; mov si,movedesc-0x10000 |
||
887 | ; push es |
||
888 | ; push ds |
||
889 | ; pop es |
||
890 | ; mov cx,256*18 |
||
891 | ; mov ah,0x87 |
||
892 | ; int 0x15 |
||
893 | ; pop es |
||
894 | ; |
||
895 | ; test ah,ah ; was the move successfull ? |
||
896 | ; je goodmove |
||
897 | ; mov dx,0x3f2 ; floppy motor off |
||
898 | ; mov al,0 |
||
899 | ; out dx,al |
||
900 | ; mov si,memmovefailed-0x10000 |
||
901 | ; jmp sayerr_plain |
||
902 | ; goodmove: |
||
903 | ; |
||
904 | ; add dword [movedesc-0x10000+0x18+2], 512*18 |
||
905 | ; popa |
||
906 | ; inc dh |
||
907 | ; cmp dh,2 |
||
908 | ; jnz bb2 |
||
909 | ; mov dh,0 |
||
910 | ; inc ch |
||
911 | ; pusha ; print prosentage |
||
912 | ; mov si,pros-0x10000 |
||
913 | ; shr ch, 2 |
||
914 | ; mov al, '5' |
||
915 | ; test ch, 1 |
||
916 | ; jnz @f |
||
917 | ; mov al, '0' |
||
918 | ;@@: |
||
919 | ; mov [si+1], al |
||
920 | ; shr ch, 1 |
||
921 | ; add ch, '0' |
||
922 | ; mov [si], ch |
||
923 | ; call printplain |
||
924 | ; popa |
||
925 | ; bb2: |
||
926 | ; pop ax |
||
927 | ; dec ax |
||
928 | ; push ax |
||
929 | ; jnz reads |
||
930 | ; readdone: |
||
931 | ; pop ax |
||
465 | serge | 932 | |
709 | diamond | 933 | ok_sys_on_floppy: |
514 | diamond | 934 | mov si, backspace2 |
1 | ha | 935 | call printplain |
514 | diamond | 936 | mov si, okt |
1 | ha | 937 | call printplain |
514 | diamond | 938 | no_sys_on_floppy: |
939 | xor ax, ax ; reset drive |
||
940 | xor dx, dx |
||
1 | ha | 941 | int 0x13 |
514 | diamond | 942 | mov dx, 0x3f2 ; floppy motor off |
943 | mov al, 0 |
||
944 | out dx, al |
||
1 | ha | 945 | |
946 | |||
947 | ; SET GRAPHICS |
||
948 | |||
514 | diamond | 949 | xor ax, ax |
950 | mov es, ax |
||
164 | serge | 951 | |
514 | diamond | 952 | mov ax, [es:0x9008] ; vga & 320x200 |
953 | mov bx, ax |
||
954 | cmp ax, 0x13 |
||
1 | ha | 955 | je setgr |
514 | diamond | 956 | cmp ax, 0x12 |
1 | ha | 957 | je setgr |
514 | diamond | 958 | mov ax, 0x4f02 ; Vesa |
412 | serge | 959 | setgr: |
1 | ha | 960 | int 0x10 |
514 | diamond | 961 | test ah, ah |
962 | mov si, fatalsel |
||
713 | Lrz | 963 | jnz v_mode_error |
1 | ha | 964 | ; set mode 0x12 graphics registers: |
514 | diamond | 965 | cmp bx, 0x12 |
1 | ha | 966 | jne gmok2 |
967 | |||
514 | diamond | 968 | mov al, 0x05 |
969 | mov dx, 0x03ce |
||
40 | halyavin | 970 | push dx |
514 | diamond | 971 | out dx, al ; select GDC mode register |
972 | mov al, 0x02 |
||
973 | inc dx |
||
974 | out dx, al ; set write mode 2 |
||
1 | ha | 975 | |
514 | diamond | 976 | mov al, 0x02 |
977 | mov dx, 0x03c4 |
||
978 | out dx, al ; select VGA sequencer map mask register |
||
979 | mov al, 0x0f |
||
980 | inc dx |
||
981 | out dx, al ; set mask for all planes 0-3 |
||
1 | ha | 982 | |
514 | diamond | 983 | mov al, 0x08 |
984 | pop dx |
||
985 | out dx, al ; select GDC bit mask register |
||
1 | ha | 986 | ; for writes to 0x03cf |
412 | serge | 987 | gmok2: |
76 | mario79 | 988 | push ds |
514 | diamond | 989 | pop es |