Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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