Rev 1700 | Rev 1941 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1700 | Rev 1703 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | ;; KolibriOS 16-bit loader, ;; |
9 | ;; KolibriOS 16-bit loader, ;; |
10 | ;; based on bootcode for MenuetOS ;; |
10 | ;; based on bootcode for MenuetOS ;; |
11 | ;; ;; |
11 | ;; ;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 13... | Line 13... | ||
13 | 13 | ||
Line 14... | Line 14... | ||
14 | $Revision: 1700 $ |
14 | $Revision: 1703 $ |
15 | 15 | ||
16 | 16 | ||
Line 45... | Line 45... | ||
45 | test al,al |
45 | test al,al |
46 | jnz @b |
46 | jnz @b |
47 | popa |
47 | popa |
48 | ret |
48 | ret |
Line 49... | Line -... | ||
49 | - | ||
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) |
- | |
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 |
- | |
66 | @@: |
- | |
Line 67... | Line 49... | ||
67 | ret |
49 | |
68 | 50 | ||
69 | setcursor: |
51 | setcursor: |
70 | ; in: dl=column, dh=row |
52 | ; in: dl=column, dh=row |
Line 88... | Line 70... | ||
88 | int 0x13 |
70 | int 0x13 |
89 | pop ax |
71 | pop ax |
90 | jnc @f |
72 | jnc @f |
91 | inc si |
73 | inc si |
92 | cmp si, 10 |
74 | cmp si, 10 |
93 | jb @b |
- | |
94 | mov si, badsect |
- | |
95 | sayerr_plain: |
- | |
96 | call printplain |
- | |
97 | jmp $ |
75 | jnb $ |
98 | @@: |
76 | @@: |
99 | pop si |
77 | pop si |
100 | ret |
78 | ret |
Line -... | Line 79... | ||
- | 79 | ||
- | 80 | sayerr_plain: |
|
- | 81 | call printplain |
|
- | 82 | jmp $ |
|
- | 83 | ||
- | 84 | sayerr: |
|
- | 85 | call print |
|
- | 86 | jmp $ |
|
- | 87 | ||
101 | 88 | ||
102 | ; convert abs. sector number (AX) to BIOS T:H:S |
89 | ; convert abs. sector number (AX) to BIOS T:H:S |
103 | ; sector number = (abs.sector%BPB_SecPerTrk)+1 |
90 | ; sector number = (abs.sector%BPB_SecPerTrk)+1 |
104 | ; pre.track number = (abs.sector/BPB_SecPerTrk) |
91 | ; pre.track number = (abs.sector/BPB_SecPerTrk) |
105 | ; head number = pre.track number%BPB_NumHeads |
92 | ; head number = pre.track number%BPB_NumHeads |
Line 207... | Line 194... | ||
207 | dec dx |
194 | dec dx |
208 | jnz dfl1 |
195 | jnz dfl1 |
209 | ; draw bottom |
196 | ; draw bottom |
210 | mov si, d80x25_bottom |
197 | mov si, d80x25_bottom |
211 | mov cx, d80x25_bottom_num * 80 |
198 | mov cx, d80x25_bottom_num * 80 |
212 | ;@@: |
199 | @@: |
213 | ; lodsb |
200 | lodsb |
214 | ; stoswvmode |
201 | stosw |
215 | ; loop @b |
202 | loop @b |
Line 216... | Line 203... | ||
216 | 203 | ||
Line 217... | Line 204... | ||
217 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
204 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
Line 218... | Line -... | ||
218 | - | ||
219 | _setcursor d80x25_top_num,0 |
- | |
220 | - | ||
221 | - | ||
222 | sayerr: |
205 | |
Line 223... | Line 206... | ||
223 | call print |
206 | _setcursor d80x25_top_num,0 |
224 | jmp $ |
207 | |
225 | cpugood: |
208 | cpugood: |
Line 334... | Line 317... | ||
334 | ; b) preboot_dma = use DMA access? |
317 | ; b) preboot_dma = use DMA access? |
335 | ; c) preboot_vrrm = use VRR? |
318 | ; c) preboot_vrrm = use VRR? |
336 | ; d) preboot_device = from what boot? |
319 | ; d) preboot_device = from what boot? |
Line 337... | Line 320... | ||
337 | 320 | ||
338 | ; determine default settings |
321 | ; determine default settings |
Line 339... | Line 322... | ||
339 | mov [.bSettingsChanged], 0 |
322 | ; mov [.bSettingsChanged], 0 |
340 | 323 | ||
341 | ;.preboot_gr_end: |
324 | ;.preboot_gr_end: |
342 | mov di, preboot_device |
325 | mov di, preboot_device |
Line 358... | Line 341... | ||
358 | ; following 4 lines set variables to 1 if its current value is 0 |
341 | ; following 4 lines set variables to 1 if its current value is 0 |
359 | cmp byte [di+preboot_dma-preboot_device], 1 |
342 | cmp byte [di+preboot_dma-preboot_device], 1 |
360 | adc byte [di+preboot_dma-preboot_device], 0 |
343 | adc byte [di+preboot_dma-preboot_device], 0 |
361 | cmp byte [di+preboot_biosdisk-preboot_device], 1 |
344 | cmp byte [di+preboot_biosdisk-preboot_device], 1 |
362 | adc byte [di+preboot_biosdisk-preboot_device], 0 |
345 | adc byte [di+preboot_biosdisk-preboot_device], 0 |
363 | ; default value for VRR is OFF |
- | |
364 | cmp byte [di+preboot_vrrm-preboot_device], 0 |
- | |
365 | jnz @f |
- | |
366 | mov byte [di+preboot_vrrm-preboot_device], 2 |
- | |
367 | @@: |
- | |
368 | ; notify user |
- | |
369 | _setcursor 5,2 |
- | |
370 | - | ||
371 | mov si, linef |
- | |
372 | call printplain |
- | |
373 | mov si, start_msg |
- | |
374 | call print |
- | |
375 | mov si, time_msg |
- | |
376 | call print |
- | |
377 | ; get start time |
- | |
378 | call .gettime |
- | |
379 | mov [.starttime], eax |
- | |
380 | mov word [.timer], .newtimer |
- | |
381 | mov word [.timer+2], cs |
- | |
382 | .printcfg: |
- | |
383 | - | ||
384 | _setcursor 9,0 |
- | |
385 | mov si, current_cfg_msg |
- | |
386 | call print |
- | |
387 | mov si, curvideo_msg |
- | |
388 | call print |
- | |
389 | - | ||
390 | ;<< call draw_current_vmode |
- | |
391 | - | ||
392 | mov si, usebd_msg |
- | |
393 | cmp [preboot_biosdisk], 1 |
- | |
394 | call .say_on_off |
- | |
395 | mov si, vrrm_msg |
- | |
396 | cmp [preboot_vrrm], 1 |
- | |
397 | call .say_on_off |
- | |
398 | mov si, preboot_device_msg |
- | |
399 | call print |
- | |
400 | mov al, [preboot_device] |
- | |
401 | and eax, 7 |
- | |
402 | mov si, [preboot_device_msgs+eax*2] |
- | |
403 | call printplain |
- | |
404 | .show_remarks: |
- | |
405 | ; show remarks in gray color |
- | |
406 | mov di, ((21-num_remarks)*80 + 2)*2 |
- | |
407 | push 0xB800 |
- | |
408 | pop es |
- | |
409 | mov cx, num_remarks |
- | |
410 | mov si, remarks |
- | |
411 | .write_remarks: |
- | |
412 | lodsw |
- | |
413 | push si |
- | |
414 | xchg ax, si |
- | |
415 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
- | |
416 | push di |
- | |
417 | .write_remark: |
- | |
418 | lodsb |
- | |
419 | test al, al |
- | |
420 | jz @f |
- | |
421 | stosw |
- | |
422 | jmp .write_remark |
- | |
423 | @@: |
- | |
424 | pop di |
- | |
425 | pop si |
- | |
426 | add di, 80*2 |
- | |
427 | loop .write_remarks |
- | |
428 | .wait: |
- | |
429 | _setcursor 25,0 ; out of screen |
- | |
430 | ; set timer interrupt handler |
- | |
431 | cli |
- | |
432 | push 0 |
- | |
433 | pop es |
- | |
434 | push dword [es:8*4] |
- | |
435 | pop dword [.oldtimer] |
- | |
436 | push dword [.timer] |
- | |
437 | pop dword [es:8*4] |
- | |
438 | sti |
- | |
439 | ; wait for keypressed |
- | |
440 | xor ax,ax |
- | |
441 | int 16h |
- | |
442 | push ax |
- | |
443 | ; restore timer interrupt |
- | |
444 | mov eax, [.oldtimer] |
- | |
445 | mov [es:8*4], eax |
- | |
446 | mov [.timer], eax |
- | |
Line 447... | Line 346... | ||
447 | 346 | ||
448 | _setcursor 7,0 |
347 | _setcursor 7,0 |
449 | mov si, space_msg |
348 | mov si, space_msg |
450 | call printplain |
349 | call printplain |
451 | ; clear remarks and restore normal attributes |
- | |
452 | push es |
- | |
453 | mov di, ((21-num_remarks)*80 + 2)*2 |
- | |
454 | push 0xB800 |
- | |
455 | pop es |
- | |
456 | mov cx, num_remarks |
- | |
457 | mov ax, ' ' + (1*16 + 15)*100h |
- | |
458 | @@: |
- | |
459 | push cx |
- | |
460 | mov cx, 76 |
- | |
461 | rep stosw |
- | |
462 | pop cx |
- | |
463 | add di, 4*2 |
- | |
464 | loop @b |
- | |
465 | pop es |
- | |
466 | pop ax |
- | |
467 | ; switch on key |
- | |
468 | cmp al, 13 |
350 | ; pop ax ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ?? |
469 | jz .continue |
- | |
470 | or al, 20h |
- | |
471 | cmp al, 'a' |
- | |
472 | jz .change_a |
- | |
473 | cmp al, 'b' |
- | |
474 | jz .change_b |
- | |
475 | cmp al, 'c' |
- | |
476 | jz .change_c |
- | |
477 | cmp al, 'd' |
- | |
478 | jnz .show_remarks |
- | |
479 | _setcursor 15,0 |
- | |
480 | mov si, bdev |
- | |
481 | call print |
- | |
482 | mov bx, '14' |
- | |
483 | call getkey |
- | |
484 | mov [preboot_device], al |
- | |
485 | _setcursor 13,0 |
- | |
486 | .d: |
- | |
487 | mov [.bSettingsChanged], 1 |
- | |
488 | call clear_vmodes_table ;clear vmodes_table |
- | |
489 | jmp .printcfg |
- | |
490 | .change_a: |
- | |
491 | .loops: |
- | |
492 | call draw_vmodes_table |
- | |
493 | _setcursor 25,0 ; out of screen |
- | |
494 | xor ax,ax |
- | |
495 | int 0x16 |
- | |
496 | - | ||
497 | mov si,word [cursor_pos] |
- | |
498 | - | ||
499 | cmp ah,0x48;x,0x48E0 ; up |
- | |
500 | jne .down |
- | |
501 | cmp si,modes_table |
- | |
502 | jbe .loops |
- | |
503 | sub word [cursor_pos],size_of_step |
- | |
504 | jmp .loops |
- | |
505 | - | ||
506 | .down: cmp ah,0x50;x,0x50E0 ; down |
- | |
507 | jne .pgup |
- | |
508 | cmp word[es:si+10],-1 |
- | |
509 | je .loops |
- | |
510 | add word [cursor_pos],size_of_step |
- | |
511 | jmp .loops |
- | |
512 | - | ||
513 | .pgup: cmp ah,0x49 ; page up |
- | |
514 | jne .pgdn |
- | |
515 | sub si, size_of_step*long_v_table |
- | |
516 | cmp si, modes_table |
- | |
517 | jae @f |
- | |
518 | mov si, modes_table |
- | |
519 | @@: |
- | |
520 | mov word [cursor_pos], si |
- | |
521 | mov si, word [home_cursor] |
- | |
522 | sub si, size_of_step*long_v_table |
- | |
523 | cmp si, modes_table |
- | |
524 | jae @f |
- | |
525 | mov si, modes_table |
- | |
526 | @@: |
- | |
527 | mov word [home_cursor], si |
- | |
528 | jmp .loops |
- | |
529 | - | ||
530 | .pgdn: cmp ah,0x51 ; page down |
- | |
531 | jne .enter |
- | |
532 | mov ax, [end_cursor] |
- | |
533 | add si, size_of_step*long_v_table |
- | |
534 | cmp si, ax |
- | |
535 | jb @f |
- | |
536 | mov si, ax |
- | |
537 | sub si, size_of_step |
- | |
538 | @@: |
- | |
539 | mov word [cursor_pos], si |
- | |
540 | mov si, word [home_cursor] |
- | |
541 | sub ax, size_of_step*long_v_table |
- | |
542 | add si, size_of_step*long_v_table |
- | |
543 | cmp si, ax |
- | |
544 | jb @f |
- | |
545 | mov si, ax |
- | |
546 | @@: |
- | |
547 | mov word [home_cursor], si |
- | |
548 | jmp .loops |
- | |
549 | - | ||
550 | .enter: cmp al,0x0D;x,0x1C0D ; enter |
- | |
551 | jne .loops |
- | |
552 | push word [cursor_pos] |
- | |
553 | pop bp |
- | |
554 | push word [es:bp] |
- | |
555 | pop word [x_save] |
- | |
556 | push word [es:bp+2] |
- | |
557 | pop word [y_save] |
- | |
558 | push word [es:bp+6] |
- | |
559 | pop word [number_vm] |
- | |
560 | mov word [preboot_graph],bp ;save choose |
- | |
561 | - | ||
562 | jmp .d |
- | |
563 | - | ||
564 | .change_b: |
- | |
565 | _setcursor 15,0 |
- | |
566 | mov si, ask_bd |
- | |
567 | call print |
- | |
568 | mov bx, '12' |
- | |
569 | call getkey |
- | |
570 | mov [preboot_biosdisk], al |
- | |
571 | _setcursor 11,0 |
- | |
572 | jmp .d |
- | |
573 | .change_c: |
- | |
574 | _setcursor 15,0 |
- | |
575 | mov si, vrrmprint |
- | |
576 | call print |
- | |
577 | mov bx, '12' |
- | |
578 | call getkey |
- | |
579 | mov [preboot_vrrm], al |
- | |
580 | _setcursor 12,0 |
- | |
581 | jmp .d |
- | |
582 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
- | |
583 | .say_on_off: |
- | |
584 | pushf |
- | |
585 | call print |
- | |
586 | mov si, on_msg |
- | |
587 | popf |
- | |
588 | jz @f |
- | |
589 | mov si, off_msg |
- | |
590 | @@: jmp printplain |
- | |
591 | ; novesa and vervesa strings are not used at the moment of executing this code |
- | |
592 | virtual at novesa |
- | |
593 | .oldtimer dd ? |
- | |
594 | .starttime dd ? |
- | |
595 | .bSettingsChanged db ? |
- | |
596 | .timer dd ? |
- | |
597 | end virtual |
351 | jmp .continue |
598 | .loader_block dd -1 |
- | |
599 | .gettime: |
- | |
600 | mov ah, 0 |
- | |
601 | int 1Ah |
- | |
602 | xchg ax, cx |
- | |
603 | shl eax, 10h |
- | |
604 | xchg ax, dx |
- | |
605 | ret |
- | |
606 | .newtimer: |
- | |
607 | push ds |
- | |
608 | push cs |
- | |
609 | pop ds |
- | |
610 | pushf |
- | |
611 | call [.oldtimer] |
- | |
612 | pushad |
- | |
613 | call .gettime |
- | |
614 | sub eax, [.starttime] |
- | |
615 | sub ax, 18*5 |
- | |
616 | jae .timergo |
- | |
617 | neg ax |
- | |
618 | add ax, 18-1 |
- | |
619 | mov bx, 18 |
- | |
620 | xor dx, dx |
- | |
621 | div bx |
- | |
622 | - | ||
623 | ; wait 5/4/3/2 seconds, 1 second |
- | |
624 | cmp al, 1 |
- | |
625 | mov cl, 's' |
- | |
626 | ja @f |
- | |
627 | mov cl, ' ' |
- | |
628 | @@: mov [time_str+9], cl |
- | |
629 | add al, '0' |
- | |
630 | mov [time_str+1], al |
- | |
631 | mov si, time_msg |
- | |
632 | _setcursor 7,0 |
- | |
633 | call print |
- | |
634 | _setcursor 25,0 |
- | |
635 | popad |
- | |
636 | pop ds |
- | |
637 | iret |
- | |
638 | .timergo: |
- | |
639 | push 0 |
- | |
640 | pop es |
- | |
641 | mov eax, [.oldtimer] |
- | |
642 | mov [es:8*4], eax |
- | |
643 | mov sp, 0EC00h |
352 | .loader_block dd -1 |
644 | .continue: |
353 | .continue: |
645 | sti |
354 | sti |
646 | _setcursor 6,0 |
355 | _setcursor 6,0 |
647 | mov si, space_msg |
356 | mov si, space_msg |
648 | call printplain |
357 | call printplain |
649 | call printplain |
358 | call printplain |
650 | _setcursor 6,0 |
359 | _setcursor 6,0 |
651 | mov si, loading_msg |
360 | mov si, loading_msg |
652 | call print |
361 | call print |
653 | _setcursor 15,0 |
- | |
654 | cmp [.bSettingsChanged], 0 |
- | |
655 | jz .load |
- | |
656 | cmp [.loader_block], -1 |
362 | _setcursor 15,0 |
657 | jz .load |
- | |
658 | les bx, [.loader_block] |
- | |
659 | mov eax, [es:bx+3] |
- | |
660 | push ds |
- | |
661 | pop es |
- | |
662 | test eax, eax |
- | |
663 | jz .load |
- | |
664 | push eax |
- | |
665 | mov si, save_quest |
- | |
666 | call print |
- | |
667 | .waityn: |
- | |
668 | mov ah, 0 |
- | |
669 | int 16h |
- | |
670 | or al, 20h |
- | |
671 | cmp al, 'n' |
- | |
672 | jz .loadc |
- | |
673 | cmp al, 'y' |
- | |
674 | jnz .waityn |
- | |
675 | call putchar |
- | |
Line 676... | Line -... | ||
676 | mov byte [space_msg+80], 186 |
- | |
677 | - | ||
678 | pop eax |
- | |
679 | push cs |
- | |
680 | push .cont |
- | |
681 | push eax |
363 | jmp .load |
682 | retf ;call back |
364 | |
683 | .loadc: |
365 | .loadc: |
684 | pop eax |
366 | pop eax |
685 | .cont: |
367 | .cont: |
Line 689... | Line 371... | ||
689 | mov byte [si+80], 0 |
371 | mov byte [si+80], 0 |
690 | _setcursor 15,0 |
372 | _setcursor 15,0 |
691 | call printplain |
373 | call printplain |
692 | _setcursor 15,0 |
374 | _setcursor 15,0 |
693 | .load: |
375 | .load: |
694 | ; \end{diamond}[02.12.2005] |
- | |
Line 695... | Line 376... | ||
695 | 376 | ||
Line 696... | Line 377... | ||
696 | ; ASK GRAPHICS MODE |
377 | ; ASK GRAPHICS MODE |
Line 868... | Line 549... | ||
868 | jz @f |
549 | jz @f |
869 | sayerr_floppy: |
550 | sayerr_floppy: |
870 | mov dx, 0x3f2 |
551 | mov dx, 0x3f2 |
871 | mov al, 0 |
552 | mov al, 0 |
872 | out dx, al |
553 | out dx, al |
873 | mov si, memmovefailed |
554 | ; mov si, memmovefailed |
874 | jmp sayerr_plain |
555 | jmp $ |
875 | @@: |
556 | @@: |
876 | pop ax ; restore from stack count of words in boot+FAT |
557 | pop ax ; restore from stack count of words in boot+FAT |
877 | shl ax, 1 ; make bytes count from count of words |
558 | shl ax, 1 ; make bytes count from count of words |
878 | and eax, 0ffffh |
559 | and eax, 0ffffh |
879 | add dword [si+8*3+2], eax |
560 | add dword [si+8*3+2], eax |
Line 1053... | Line 734... | ||
1053 | 734 | ||
1054 | xor ax, ax |
735 | xor ax, ax |
Line 1055... | Line 736... | ||
1055 | mov es, ax |
736 | mov es, ax |
1056 | - | ||
1057 | mov bx, [es:0x9008] ; vga & 320x200 |
- | |
1058 | ; mov bx, ax |
- | |
1059 | ; cmp ax, 0x13 |
- | |
1060 | ; je setgr |
- | |
1061 | ; cmp ax, 0x12 |
737 | |
1062 | ; je setgr |
738 | mov bx, [es:0x9008] ; vga & 320x200 |
1063 | mov ax, 0x4f02 ; Vesa |
739 | mov ax, 0x4f02 ; Vesa |
1064 | setgr: |
740 | setgr: |
1065 | int 0x10 |
- | |
1066 | test ah, ah |
741 | int 0x10 |
1067 | mov si, fatalsel |
- | |
1068 | jnz v_mode_error |
- | |
1069 | ; set mode 0x12 graphics registers: |
- | |
1070 | ; cmp bx, 0x12 |
- | |
1071 | ; jne gmok2 |
- | |
1072 | ; mov al, 0x05 |
- | |
1073 | ; mov dx, 0x03ce |
- | |
1074 | ; push dx |
- | |
1075 | ; out dx, al ; select GDC mode register |
- | |
1076 | ; mov al, 0x02 |
- | |
1077 | ; inc dx |
- | |
1078 | ; out dx, al ; set write mode 2 |
- | |
1079 | ; mov al, 0x02 |
- | |
1080 | ; mov dx, 0x03c4 |
- | |
1081 | ; out dx, al ; select VGA sequencer map mask register |
- | |
1082 | ; mov al, 0x0f |
- | |
1083 | ; inc dx |
- | |
1084 | ; out dx, al ; set mask for all planes 0-3 |
- | |
1085 | ; mov al, 0x08 |
- | |
1086 | ; pop dx |
- | |
1087 | ; out dx, al ; select GDC bit mask register |
742 | test ah, ah |
1088 | ; for writes to 0x03cf |
743 | jnz $ |
1089 | gmok2: |
744 | gmok2: |