Subversion Repositories Kolibri OS

Rev

Rev 838 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13.  
  14. $Revision: 848 $
  15.  
  16.  
  17. ;==========================================================================
  18. ;
  19. ;                           16 BIT FUNCTIONS
  20. ;
  21. ;==========================================================================
  22.  
  23. use16
  24.  
  25. putchar:
  26. ; in: al=character
  27.         mov     ah, 0Eh
  28.         mov     bh, 0
  29.         int     10h
  30.         ret
  31.  
  32. print:
  33. ; in: si->string
  34.         mov     al, 186
  35.         call    putchar
  36.         mov     al, ' '
  37.         call    putchar
  38.  
  39. printplain:
  40. ; in: si->string
  41.         pusha
  42.         lodsb
  43. @@:
  44.         call    putchar
  45.         lodsb
  46.         cmp     al, 0
  47.         jnz     @b
  48.         popa
  49.         ret
  50.  
  51. getkey:
  52. ; get number in range [bl,bh] (bl,bh in ['0'..'9'])
  53. ; in: bx=range
  54. ; out: ax=digit (1..9, 10 for 0)
  55.         mov     ah, 0
  56.         int     16h
  57.         cmp     al, bl
  58.         jb      getkey
  59.         cmp     al, bh
  60.         ja      getkey
  61.         push    ax
  62.         call    putchar
  63.         pop     ax
  64.         and     ax, 0Fh
  65.         jnz     @f
  66.         mov     al, 10
  67. @@:
  68.         ret
  69.  
  70. setcursor:
  71. ; in: dl=column, dh=row
  72.         mov     ah, 2
  73.         mov     bh, 0
  74.         int     10h
  75.         ret
  76.  
  77. macro _setcursor row,column
  78. {
  79.         mov     dx, row*256 + column
  80.         call    setcursor
  81. }
  82.  
  83. boot_read_floppy:
  84.         push    si
  85.         xor     si, si
  86.         mov     ah, 2   ; read
  87. @@:
  88.         push    ax
  89.         int     0x13
  90.         pop     ax
  91.         jnc     @f
  92.         inc     si
  93.         cmp     si, 10
  94.         jb      @b
  95.         mov     si, badsect
  96. sayerr_plain:
  97.         call    printplain
  98.         jmp     $
  99. @@:
  100.         pop     si
  101.         ret
  102.  
  103. ; convert abs. sector number (AX) to BIOS T:H:S
  104. ; sector number = (abs.sector%BPB_SecPerTrk)+1
  105. ; pre.track number = (abs.sector/BPB_SecPerTrk)
  106. ; head number = pre.track number%BPB_NumHeads
  107. ; track number = pre.track number/BPB_NumHeads
  108. ; Return: cl - sector number
  109. ;         ch - track number
  110. ;         dl - drive number (0 = a:)
  111. ;         dh - head number
  112. conv_abs_to_THS:
  113.         push    bx
  114.         mov     bx,word [BPB_SecPerTrk]
  115.         xor     dx,dx
  116.         div     bx
  117.         inc     dx
  118.         mov     cl, dl                          ; cl = sector number
  119.         mov     bx,word [BPB_NumHeads]
  120.         xor     dx,dx
  121.         div     bx
  122.         ; !!!!!!! ax = track number, dx = head number
  123.         mov     ch,al                           ; ch=track number
  124.         xchg    dh,dl                           ; dh=head number
  125.         mov     dl,0                            ; dl=0 (drive 0 (a:))
  126.         pop     bx
  127.         retn
  128.  
  129. sayerr:
  130.         call    print
  131.         jmp     $
  132.  
  133. ; needed variables
  134. BPB_SecPerTrk   dw      0                       ; sectors per track
  135. BPB_NumHeads    dw      0                       ; number of heads
  136. BPB_FATSz16     dw      0                       ; size of FAT
  137. BPB_RootEntCnt  dw      0                       ; count of root dir. entries
  138. BPB_BytsPerSec  dw      0                       ; bytes per sector
  139. BPB_RsvdSecCnt  dw      0                       ; number of reserved sectors
  140. BPB_TotSec16    dw      0                       ; count of the sectors on the volume
  141. BPB_SecPerClus  db      0                       ; number of sectors per cluster
  142. BPB_NumFATs     db      0                       ; number of FAT tables
  143. abs_sector_adj  dw      0                       ; adjustment to make abs. sector number
  144. end_of_FAT      dw      0                       ; end of FAT table
  145. FirstDataSector dw      0                       ; begin of data
  146.  
  147. ;=========================================================================
  148. ;
  149. ;                           16 BIT CODE
  150. ;
  151. ;=========================================================================
  152.  
  153. include 'bootvesa.inc'                 ;Include source for boot vesa
  154.  
  155. start_of_code:
  156.  
  157.         cld
  158.  
  159.         xor ecx, ecx
  160.         xor edx, edx
  161.         xor esi, esi
  162.         xor edi, edi
  163.         xor ebp, ebp
  164.  
  165.         mov eax, 0x3000
  166.         mov ss, ax
  167.         mov esp, 0EC00h
  168.  
  169.         mov ebx, 0x1000
  170.         mov ds, bx
  171.         mov es, bx
  172.  
  173. ; set videomode
  174.         mov     ax, 3
  175.         int     0x10
  176.  
  177. if lang eq ru
  178.  ; Load & set russian VGA font (RU.INC)
  179.         mov     bp, RU_FNT1             ; RU_FNT1 - First part
  180.         mov     bx, 1000h               ; 768 bytes
  181.         mov     cx, 30h                 ; 48 symbols
  182.         mov     dx, 80h                 ; 128 - position of first symbol
  183.         mov     ax, 1100h
  184.         int     10h
  185.  
  186.         mov     bp, RU_FNT2             ; RU_FNT2 -Second part
  187.         mov     bx, 1000h               ; 512 bytes
  188.         mov     cx, 20h                 ; 32 symbols
  189.         mov     dx, 0E0h                ; 224 - position of first symbol
  190.         mov     ax, 1100h
  191.         int     10h
  192.  ; End set VGA russian font
  193. else if lang eq et
  194.         mov     bp, ET_FNT              ; ET_FNT1
  195.         mov     bx, 1000h               ;
  196.         mov     cx, 255                 ; 256 symbols
  197.         xor     dx, dx                  ; 0 - position of first symbol
  198.         mov     ax, 1100h
  199.         int     10h
  200. end if
  201.  
  202. ; draw frames
  203.         push    0xb800
  204.         pop     es
  205.         xor     di, di
  206.         mov     ah, 1*16+15
  207.  
  208. ; draw top
  209.         mov     si, d80x25_top
  210.         mov     cx, d80x25_top_num * 80
  211. @@:
  212.         lodsb
  213.         stosw
  214.         loop    @b
  215.  
  216. ; draw spaces
  217.         mov     si, space_msg
  218.         mov     dx, 25 - d80x25_top_num - d80x25_bottom_num
  219. dfl1:
  220.         push    si
  221.         mov     cx, 80
  222. @@:
  223.         lodsb
  224.         stosw
  225.         loop    @b
  226.         pop     si
  227.         dec     dx
  228.         jnz     dfl1
  229. ; draw bottom
  230.         mov     si, d80x25_bottom
  231.         mov     cx, d80x25_bottom_num * 80
  232. @@:
  233.         lodsb
  234.         stosw
  235.         loop    @b
  236.  
  237.         mov     byte [space_msg+80], 0    ; now space_msg is null terminated
  238.  
  239.         _setcursor d80x25_top_num,0
  240.  
  241.         push    0
  242.         popf
  243.         sti
  244.  
  245.         push    0
  246.         pop     es
  247.         and     word [es:0x9031], 0
  248. ; \begin{Mario79}
  249. ; find HDD IDE DMA PCI device
  250. ; check for PCI BIOS
  251.         mov     ax, 0xB101
  252.         int     0x1A
  253.         jc      .nopci
  254.         cmp     edx, 'PCI '
  255.         jnz     .nopci
  256. ; find PCI class code
  257. ; class 1 = mass storage
  258. ; subclass 1 = IDE controller
  259. ; a) class 1, subclass 1, programming interface 0x80
  260.         mov     ax, 0xB103
  261.         mov     ecx, 1*10000h + 1*100h + 0x80
  262.         xor     si, si  ; device index = 0
  263.         int     0x1A
  264.         jnc     .found
  265. ; b) class 1, subclass 1, programming interface 0x8A
  266.         mov     ax, 0xB103
  267.         mov     ecx, 1*10000h + 1*100h + 0x8A
  268.         xor     si, si  ; device index = 0
  269.         int     0x1A
  270.         jnc     .found
  271. ; c) class 1, subclass 1, programming interface 0x85
  272.         mov     ax, 0xB103
  273.         mov     ecx, 1*10000h + 1*100h + 0x85
  274.         xor     si, si
  275.         int     0x1A
  276.         jc      .nopci
  277. .found:
  278. ; get memory base
  279.         mov     ax, 0xB10A
  280.         mov     di, 0x20        ; memory base is config register at 0x20
  281.         int     0x1A
  282.         jc      .nopci
  283.         and     cx, 0xFFF0      ; clear address decode type
  284.         mov     [es:0x9031], cx
  285. .nopci:
  286. ; \end{Mario79}
  287.  
  288.         mov     al, 0xf6        ; Ñáðîñ êëàâèàòóðû, ðàçðåøèòü ñêàíèðîâàíèå
  289.         out     0x60, al
  290.         xor     cx, cx
  291. wait_loop:       ; variant 2
  292. ; reading state of port of 8042 controller
  293.         in      al, 64h
  294.         and     al, 00000010b  ; ready flag
  295. ; wait until 8042 controller is ready
  296.         loopnz  wait_loop
  297.  
  298. ;;;/diamond today   5.02.2008
  299. ; set keyboard typematic rate & delay
  300.         mov     al, 0xf3
  301.         out     0x60, al
  302.         xor     cx, cx
  303. @@:
  304.         in      al, 64h
  305.         test    al, 2
  306.         loopnz  @b
  307.         mov     al, 0
  308.         out     0x60, al
  309.         xor     cx, cx
  310. @@:
  311.         in      al, 64h
  312.         test    al, 2
  313.         loopnz  @b
  314. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  315. ; --------------- APM ---------------------
  316.         and     word [es:0x9044], 0     ; ver = 0.0 (APM not found)
  317.         mov     ax, 0x5300
  318.         xor     bx, bx
  319.         int     0x15
  320.         jc      apm_end                 ; APM not found
  321.         test    cx, 2
  322.         jz      apm_end                 ; APM 32-bit protected-mode interface not supported
  323.         mov     [es:0x9044], ax         ; Save APM Version
  324.         mov     [es:0x9046], cx         ; Save APM flags
  325.  
  326.         ; Write APM ver ----
  327.         and     ax, 0xf0f
  328.         add     ax, '00'
  329.         mov     si, msg_apm
  330.         mov     [si + 5], ah
  331.         mov     [si + 7], al
  332.         _setcursor 0, 3
  333.         call    printplain
  334.         ; ------------------
  335.  
  336.         mov     ax, 0x5304              ; Disconnect interface
  337.         xor     bx, bx
  338.         int     0x15
  339.         mov     ax, 0x5303              ; Connect 32 bit mode interface
  340.         xor     bx, bx
  341.         int     0x15
  342.  
  343.         mov     [es:0x9040], ebx
  344.         mov     [es:0x9050], ax
  345.         mov     [es:0x9052], cx
  346.         mov     [es:0x9054], dx
  347.  
  348. apm_end:
  349.         _setcursor d80x25_top_num, 0
  350.  
  351.         push    0
  352.         pop     es
  353.  
  354. noloaderblock:
  355. ; DISPLAY VESA INFORMATION
  356.          call    print_vesa_info
  357.          call    calc_vmodes_table
  358.          call    check_first_parm  ;check and enable cursor_pos
  359.  
  360. ; \begin{diamond}[30.11.2005]
  361. cfgmanager:
  362. ; settings:
  363. ; a) preboot_graph = graphical mode
  364. ;    preboot_gprobe = probe this mode?
  365. ; b) preboot_dma  = use DMA access?
  366. ; c) preboot_vrrm = use VRR?
  367. ; d) preboot_device = from what boot?
  368.  
  369. ; determine default settings
  370.         mov     [.bSettingsChanged], 0
  371.  
  372. ;.preboot_gr_end:
  373.         mov     di, preboot_device
  374. ; if image in memory is present and [preboot_device] is uninitialized,
  375. ; set it to use this preloaded image
  376.         cmp     byte [di], 0
  377.         jnz     .preboot_device_inited
  378.         cmp     [.loader_block], -1
  379.         jz      @f
  380.         les     bx, [.loader_block]
  381.         test    byte [es:bx+1], 1
  382.         jz      @f
  383.         mov     byte [di], 3
  384.         jmp     .preboot_device_inited
  385. @@:
  386. ; otherwise, set [preboot_device] to 1 (default value - boot from floppy)
  387.         mov     byte [di], 1
  388. .preboot_device_inited:
  389. ; following 6 lines set variables to 1 if its current value is 0
  390.         cmp     byte [di+preboot_dma-preboot_device], 1
  391.         adc     byte [di+preboot_dma-preboot_device], 0
  392.         cmp     byte [di+preboot_biosdisk-preboot_device], 1
  393.         adc     byte [di+preboot_biosdisk-preboot_device], 0
  394.         cmp     byte [di+preboot_vrrm-preboot_device], 1
  395.         adc     byte [di+preboot_vrrm-preboot_device], 0
  396. ; notify user
  397.         _setcursor 5,2
  398.  
  399.         mov     si, linef
  400.         call    printplain
  401.         mov     si, start_msg
  402.         call    print
  403.         mov     si, time_msg
  404.         call    print
  405. ; get start time
  406.         call    .gettime
  407.         mov     [.starttime], eax
  408.         mov     word [.timer], .newtimer
  409.         mov     word [.timer+2], cs
  410. .printcfg:
  411.         _setcursor 9,0
  412.         mov     si, current_cfg_msg
  413.         call    print
  414.         mov     si, curvideo_msg
  415.         call    print
  416.  
  417.             call    draw_current_vmode
  418.  
  419.         mov     si, usebd_msg
  420.         cmp     [preboot_biosdisk], 1
  421.         call    .say_on_off
  422.         mov     si, vrrm_msg
  423.         cmp     [preboot_vrrm], 1
  424.         call    .say_on_off
  425.         mov     si, preboot_device_msg
  426.         call    print
  427.         mov     al, [preboot_device]
  428.         and     eax, 7
  429.         mov     si, [preboot_device_msgs+eax*2]
  430.         call    printplain
  431. .show_remarks:
  432. ; show remarks in gray color
  433.         mov     di, ((21-num_remarks)*80 + 2)*2
  434.         push    0xB800
  435.         pop     es
  436.         mov     cx, num_remarks
  437.         mov     si, remarks
  438. .write_remarks:
  439.         lodsw
  440.         push    si
  441.         xchg    ax, si
  442.         mov     ah, 1*16+7      ; background: blue (1), foreground: gray (7)
  443.         push    di
  444. .write_remark:
  445.         lodsb
  446.         test    al, al
  447.         jz      @f
  448.         stosw
  449.         jmp     .write_remark
  450. @@:
  451.         pop     di
  452.         pop     si
  453.         add     di, 80*2
  454.         loop    .write_remarks
  455. .wait:
  456.         _setcursor 25,0         ; out of screen
  457. ; set timer interrupt handler
  458.         cli
  459.         push    0
  460.         pop     es
  461.         push    dword [es:8*4]
  462.         pop     dword [.oldtimer]
  463.         push    dword [.timer]
  464.         pop     dword [es:8*4]
  465. ;        mov     eax, [es:8*4]
  466. ;        mov     [.oldtimer], eax
  467. ;        mov     eax, [.timer]
  468. ;        mov     [es:8*4], eax
  469.         sti
  470. ; wait for keypressed
  471.         xor     ax,ax
  472.         int     16h
  473.         push    ax
  474. ; restore timer interrupt
  475. ;        push    0
  476. ;        pop     es
  477.         mov     eax, [.oldtimer]
  478.         mov     [es:8*4], eax
  479.         mov     [.timer], eax
  480.         _setcursor 7,0
  481.         mov     si, space_msg
  482.         call    printplain
  483. ; clear remarks and restore normal attributes
  484.         push    es
  485.         mov     di, ((21-num_remarks)*80 + 2)*2
  486.         push    0xB800
  487.         pop     es
  488.         mov     cx, num_remarks
  489.         mov     ax, ' ' + (1*16 + 15)*100h
  490. @@:
  491.         push    cx
  492.         mov     cx, 76
  493.         rep     stosw
  494.         pop     cx
  495.         add     di, 4*2
  496.         loop    @b
  497.         pop     es
  498.         pop     ax
  499. ; switch on key
  500.         cmp     al, 13
  501.         jz      .continue
  502.         or      al, 20h
  503.         cmp     al, 'a'
  504.         jz      .change_a
  505.         cmp     al, 'b'
  506.         jz      .change_b
  507.         cmp     al, 'c'
  508.         jz      .change_c
  509.         cmp     al, 'd'
  510.         jnz     .show_remarks
  511.         _setcursor 15,0
  512.         mov     si, bdev
  513.         call    print
  514.         mov     bx, '14'
  515.         call    getkey
  516.         mov     [preboot_device], al
  517.         _setcursor 13,0
  518. .d:
  519.         mov     [.bSettingsChanged], 1
  520.         call    clear_vmodes_table             ;clear vmodes_table
  521.         jmp    .printcfg
  522. .change_a:
  523. .loops:
  524.         call    draw_vmodes_table
  525.         _setcursor 25,0         ; out of screen
  526.         xor     ax,ax
  527.         int     0x16
  528. ;        call    clear_table_cursor             ;clear current position of cursor
  529.  
  530.         mov     si,word [cursor_pos]
  531.  
  532.         cmp     ah,0x48;x,0x48E0               ; up
  533.         jne     .down
  534.         cmp     si,modes_table
  535.         jbe     .loops
  536.         sub     word [cursor_pos],size_of_step
  537.         jmp     .loops
  538.  
  539. .down:  cmp     ah,0x50;x,0x50E0               ; down
  540.         jne     .pgup
  541.         cmp     word[es:si+10],-1
  542.         je      .loops
  543.         add     word [cursor_pos],size_of_step
  544.         jmp     .loops
  545.  
  546. .pgup:  cmp     ah,0x49                 ; page up
  547.         jne     .pgdn
  548.         sub     si, size_of_step*long_v_table
  549.         cmp     si, modes_table
  550.         jae     @f
  551.         mov     si, modes_table
  552. @@:
  553.         mov     word [cursor_pos], si
  554.         mov     si, word [home_cursor]
  555.         sub     si, size_of_step*long_v_table
  556.         cmp     si, modes_table
  557.         jae     @f
  558.         mov     si, modes_table
  559. @@:
  560.         mov     word [home_cursor], si
  561.         jmp     .loops
  562.  
  563. .pgdn:  cmp     ah,0x51                 ; page down
  564.         jne     .enter
  565.         mov     ax, [end_cursor]
  566.         add     si, size_of_step*long_v_table
  567.         cmp     si, ax
  568.         jb      @f
  569.         mov     si, ax
  570.         sub     si, size_of_step
  571. @@:
  572.         mov     word [cursor_pos], si
  573.         mov     si, word [home_cursor]
  574.         sub     ax, size_of_step*long_v_table
  575.         add     si, size_of_step*long_v_table
  576.         cmp     si, ax
  577.         jb      @f
  578.         mov     si, ax
  579. @@:
  580.         mov     word [home_cursor], si
  581.         jmp     .loops
  582.  
  583. .enter: cmp     al,0x0D;x,0x1C0D               ; enter
  584.         jne     .loops
  585.         push    word [cursor_pos]
  586.         pop     bp
  587.         push    word [es:bp]
  588.         pop     word [x_save]
  589.         push    word [es:bp+2]
  590.         pop     word [y_save]
  591.         push    word [es:bp+6]
  592.         pop     word [number_vm]
  593.         mov     word [preboot_graph],bp           ;save choose
  594.  
  595.         jmp    .d
  596.  
  597. .change_b:
  598.         _setcursor 15,0
  599. ;        mov     si, ask_dma
  600. ;        call    print
  601. ;        mov     bx, '13'
  602. ;        call    getkey
  603. ;        mov     [preboot_dma], al
  604.         mov     si, ask_bd
  605.         call    print
  606.         mov     bx, '12'
  607.         call    getkey
  608.         mov     [preboot_biosdisk], al
  609.         _setcursor 11,0
  610.         jmp     .d
  611. .change_c:
  612.         _setcursor 15,0
  613.         mov     si, vrrmprint
  614.         call    print
  615.         mov     bx, '12'
  616.         call    getkey
  617.         mov     [preboot_vrrm], al
  618.         _setcursor 12,0
  619.         jmp     .d
  620. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  621. .say_on_off:
  622.         pushf
  623.         call    print
  624.         mov     si, on_msg
  625.         popf
  626.         jz      @f
  627.         mov     si, off_msg
  628. @@:     jmp     printplain
  629. ; novesa and vervesa strings are not used at the moment of executing this code
  630. virtual at novesa
  631. .oldtimer dd ?
  632. .starttime dd ?
  633. .bSettingsChanged db ?
  634. .timer dd ?
  635. end virtual
  636. .loader_block dd -1
  637. .gettime:
  638.         mov     ah, 0
  639.         int     1Ah
  640.         xchg    ax, cx
  641.         shl     eax, 10h
  642.         xchg    ax, dx
  643.         ret
  644. .newtimer:
  645.         push    ds
  646.         push    cs
  647.         pop     ds
  648.         pushf
  649.         call    [.oldtimer]
  650.         pushad
  651.         call    .gettime
  652.         sub     eax, [.starttime]
  653.         sub     ax, 18*5
  654.         jae     .timergo
  655.         neg     ax
  656.         add     ax, 18-1
  657.         mov     bx, 18
  658.         xor     dx, dx
  659.         div     bx
  660. if lang eq ru
  661. ; ¯®¤®¦¤¨â¥ 5 ᥪ㭤, 4/3/2 ᥪ㭤ë, 1 ᥪ㭤ã
  662.         cmp     al, 5
  663.         mov     cl, ' '
  664.         jae     @f
  665.         cmp     al, 1
  666.         mov     cl, 'ã'
  667.         jz      @f
  668.         mov     cl, 'ë'
  669. @@:     mov     [time_str+9], cl
  670. else if lang eq et
  671.         cmp     al, 1
  672.         ja      @f
  673.         mov     [time_str+9], ' '
  674.         mov     [time_str+10],' '
  675. @@:
  676. else
  677. ; wait 5/4/3/2 seconds, 1 second
  678.         cmp     al, 1
  679.         mov     cl, 's'
  680.         ja      @f
  681.         mov     cl, ' '
  682. @@:     mov     [time_str+9], cl
  683. end if
  684.         add     al, '0'
  685.         mov     [time_str+1], al
  686.         mov     si, time_msg
  687.         _setcursor 7,0
  688.         call    print
  689.         _setcursor 25,0
  690.         popad
  691.         pop     ds
  692.         iret
  693. .timergo:
  694.         push    0
  695.         pop     es
  696.         mov     eax, [.oldtimer]
  697.         mov     [es:8*4], eax
  698.         mov     sp, 0EC00h
  699. .continue:
  700.         sti
  701.         _setcursor 6,0
  702.         mov     si, space_msg
  703.         call    printplain
  704.         call    printplain
  705.         _setcursor 6,0
  706.         mov     si, loading_msg
  707.         call    print
  708.         _setcursor 15,0
  709.         cmp     [.bSettingsChanged], 0
  710.         jz      .load
  711.         cmp     [.loader_block], -1
  712.         jz      .load
  713.         les     bx, [.loader_block]
  714.         mov     eax, [es:bx+3]
  715.         push    ds
  716.         pop     es
  717.         test    eax, eax
  718.         jz      .load
  719.         push    eax
  720.         mov     si, save_quest
  721.         call    print
  722. .waityn:
  723.         mov     ah, 0
  724.         int     16h
  725.         or      al, 20h
  726.         cmp     al, 'n'
  727.         jz      .loadc
  728.         cmp     al, 'y'
  729.         jnz     .waityn
  730.         call    putchar
  731.         mov     byte [space_msg+80], 186
  732.         pop     eax
  733.         push    cs
  734.         push    .cont
  735.         push    eax
  736.         retf
  737. .loadc:
  738.         pop     eax
  739. .cont:
  740.         push    cs
  741.         pop     ds
  742.         mov     si, space_msg
  743.         mov     byte [si+80], 0
  744.         _setcursor 15,0
  745.         call    printplain
  746.         _setcursor 15,0
  747. .load:
  748. ; \end{diamond}[02.12.2005]
  749.  
  750. ; ASK GRAPHICS MODE
  751.  
  752.         call    set_vmode
  753.  
  754. ; GRAPHICS ACCELERATION
  755. ; force yes
  756.         mov     [es:0x901C], byte 1
  757.  
  758. ; DMA ACCESS TO HD
  759.  
  760.         mov     al, [preboot_dma]
  761.         mov     [es:0x901F], al
  762.  
  763. ; SET GRAPHICS
  764.  
  765.         xor     ax, ax
  766.         mov     es, ax
  767.  
  768.         mov     ax, [es:0x9008]         ; vga & 320x200
  769.         mov     bx, ax
  770.         cmp     ax, 0x13
  771.         je      setgr
  772.         cmp     ax, 0x12
  773.         je      setgr
  774.         mov     ax, 0x4f02              ; Vesa
  775. setgr:
  776.         int     0x10
  777.         test    ah, ah
  778.         mov     si, fatalsel
  779.         jnz     v_mode_error
  780. ; set mode 0x12 graphics registers:
  781.         cmp     bx, 0x12
  782.         jne     gmok2
  783.  
  784.         mov     al, 0x05
  785.         mov     dx, 0x03ce
  786.         push    dx
  787.         out     dx, al      ; select GDC mode register
  788.         mov     al, 0x02
  789.         inc     dx
  790.         out     dx, al      ; set write mode 2
  791.  
  792.         mov     al, 0x02
  793.         mov     dx, 0x03c4
  794.         out     dx, al      ; select VGA sequencer map mask register
  795.         mov     al, 0x0f
  796.         inc     dx
  797.         out     dx, al      ; set mask for all planes 0-3
  798.  
  799.         mov     al, 0x08
  800.         pop     dx
  801.         out     dx, al      ; select GDC bit mask register
  802.                            ; for writes to 0x03cf
  803. gmok2:
  804.         push    ds
  805.         pop     es
  806.  
  807.