Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 3795 $
  9.  
  10. struc VBE_VGAInfo {
  11.   .VESASignature          dd ?    ; char
  12.   .VESAVersion            dw ?    ; short
  13.   .OemStringPtr           dd ?    ; char *
  14.   .Capabilities           dd ?    ; ulong
  15.   .VideoModePtr           dd ?    ; ulong
  16.   .TotalMemory            dw ?    ; short
  17.   ; VBE 2.0+
  18.   .OemSoftwareRev         db ?    ; short
  19.   .OemVendorNamePtr       dw ?    ; char *
  20.   .OemProductNamePtr      dw ?    ; char *
  21.   .OemProductRevPtr       dw ?    ; char *
  22.   .reserved               rb 222  ; char
  23.   .OemData                rb 256  ; char
  24. }
  25.  
  26. struc VBE_ModeInfo {
  27.   .ModeAttributes         dw ?    ; short
  28.   .WinAAttributes         db ?    ; char
  29.   .WinBAttributes         db ?    ; char
  30.   .WinGranularity         dw ?    ; short
  31.   .WinSize                dw ?    ; short
  32.   .WinASegment            dw ?    ; ushort
  33.   .WinBSegment            dw ?    ; ushort
  34.   .WinFuncPtr             dd ?    ; void *
  35.   .BytesPerScanLine       dw ?    ; short
  36.   .XRes                   dw ?    ; short
  37.   .YRes                   dw ?    ; short
  38.   .XCharSize              db ?    ; char
  39.   .YCharSize              db ?    ; char
  40.   .NumberOfPlanes         db ?    ; char
  41.   .BitsPerPixel           db ?    ; char
  42.   .NumberOfBanks          db ?    ; char
  43.   .MemoryModel            db ?    ; char
  44.   .BankSize               db ?    ; char
  45.   .NumberOfImagePages     db ?    ; char
  46.   .res1                   db ?    ; char
  47.   .RedMaskSize            db ?    ; char
  48.   .RedFieldPosition       db ?    ; char
  49.   .GreenMaskSize          db ?    ; char
  50.   .GreenFieldPosition     db ?    ; char
  51.   .BlueMaskSize           db ?    ; char
  52.   .BlueFieldPosition      db ?    ; char
  53.   .RsvedMaskSize          db ?    ; char
  54.   .RsvedFieldPosition     db ?    ; char
  55.   .DirectColorModeInfo    db ?    ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE
  56.   ; VBE 2.0+
  57.   .PhysBasePtr            dd ?    ; ulong
  58.   .OffScreenMemOffset     dd ?    ; ulong
  59.   .OffScreenMemSize       dw ?    ; short
  60.   ; VBE 3.0+
  61.   .LinbytesPerScanLine    dw ?    ; short
  62.   .BankNumberOfImagePages db ?    ; char
  63.   .LinNumberOfImagePages  db ?    ; char
  64.   .LinRedMaskSize         db ?    ; char
  65.   .LinRedFieldPosition    db ?    ; char
  66.   .LingreenMaskSize       db ?    ; char
  67.   .LinGreenFieldPosition  db ?    ; char
  68.   .LinBlueMaskSize        db ?    ; char
  69.   .LinBlueFieldPosition   db ?    ; char
  70.   .LinRsvdMaskSize        db ?    ; char
  71.   .LinRsvdFieldPosition   db ?    ; char
  72.   .MaxPixelClock          dd ?    ; ulong
  73.   .res2                   rb 190  ; char
  74. }
  75.  
  76. virtual at $A000
  77.   vi VBE_VGAInfo
  78.   mi VBE_ModeInfo
  79. modes_table:
  80. end virtual
  81. cursor_pos  dw 0         ;временное хранение курсора.
  82. home_cursor dw 0    ;current shows rows a table
  83. end_cursor  dw 0     ;end of position current shows rows a table
  84. scroll_start dw 0    ;start position of scroll bar
  85. scroll_end  dw 0     ;end position of scroll bar
  86. long_v_table equ 9   ;long of visible video table
  87. size_of_step equ 10
  88. scroll_area_size equ (long_v_table-2)
  89. int2str:
  90.         dec     bl
  91.         jz      @f
  92.         xor     edx, edx
  93.         div     ecx
  94.         push    edx
  95.         call    int2str
  96.         pop     eax
  97.     @@:
  98.         or      al, 0x30
  99.         mov     [ds:di], al
  100.         inc     di
  101.         ret
  102.  
  103. int2strnz:
  104.         cmp     eax, ecx
  105.         jb      @f
  106.         xor     edx, edx
  107.         div     ecx
  108.         push    edx
  109.         call    int2strnz
  110.         pop     eax
  111.     @@:
  112.         or      al, 0x30
  113.         mov     [es:di], al
  114.         inc     di
  115.         ret
  116.  
  117. ;-------------------------------------------------------
  118. ;Write message about incorrect v_mode and write message about jmp on swith v_mode
  119. v_mode_error:
  120.         _setcursor 19,2
  121.         mov     si, fatalsel
  122.         call    printplain
  123.         _setcursor 20,2
  124.         mov     si, pres_key
  125.         call    printplain
  126.         xor     eax, eax
  127.         int     16h
  128.         jmp     cfgmanager.d
  129. ;-------------------------------------------------------
  130. ;
  131.  
  132.  
  133.  
  134. ;-------------------------------------------------------
  135. print_vesa_info:
  136.         _setcursor 5,2
  137.  
  138.         mov     [es:vi.VESASignature], 'VBE2'
  139.         mov     ax, 0x4F00
  140.         mov     di, vi     ;0xa000
  141.         int     0x10
  142.         or      ah, ah
  143.         jz      @f
  144.         mov     [es:vi.VESASignature], 'VESA'
  145.         mov     ax, $4F00
  146.         mov     di, vi
  147.         int     0x10
  148.         or      ah, ah
  149.         jnz     .exit
  150.   @@:
  151.         cmp     [es:vi.VESASignature], 'VESA'
  152.         jne     .exit
  153.         cmp     [es:vi.VESAVersion], 0x0100
  154.         jb      .exit
  155.         jmp     .vesaok2
  156.  
  157.   .exit:
  158.         mov     si, novesa
  159.         call    printplain
  160.         ret
  161.  
  162.   .vesaok2:
  163.         mov     ax, [es:vi.VESAVersion]
  164.         add     ax, '00'
  165.  
  166.         mov     [s_vesa.ver], ah
  167.         mov     [s_vesa.ver+2], al
  168.         mov     si, s_vesa
  169.         call    printplain
  170.  
  171.         _setcursor 4,2
  172.         mov     si, word[es:vi.OemStringPtr]
  173.         mov     di, si
  174.  
  175.         push    ds
  176.         mov     ds, word[es:vi.OemStringPtr+2]
  177.         call    printplain
  178.         pop     ds
  179.  
  180.         ret
  181. ;-----------------------------------------------------------------------------
  182.  
  183. calc_vmodes_table:
  184.         pushad
  185.  
  186. ;        push    0
  187. ;        pop     es
  188.  
  189.         lfs     si, [es:vi.VideoModePtr]
  190.  
  191.         mov     bx, modes_table
  192. ;save no vesa mode of work 320x200, EGA/CGA 256 梥⮢ and 640x480, VGA 16 梥⮢
  193.         mov     word [es:bx], 640
  194.         mov     word [es:bx+2], 480
  195.         mov     word [es:bx+6], 0x13
  196.        
  197.         mov     word [es:bx+10], 640
  198.         mov     word [es:bx+12], 480
  199.         mov     word [es:bx+16], 0x12
  200.         add     bx, 20
  201.   .next_mode:
  202.         mov     cx, word [fs:si]; mode number
  203.         cmp     cx, -1
  204.         je      .modes_ok.2
  205.  
  206.         mov     ax, 0x4F01
  207.         mov     di, mi
  208.         int     0x10
  209.  
  210.         or      ah, ah
  211.         jnz     .modes_ok.2;vesa_info.exit
  212.  
  213.         test    [es:mi.ModeAttributes], 00000001b  ;videomode support ?
  214.         jz      @f
  215.         test    [es:mi.ModeAttributes], 00010000b  ;picture ?
  216.         jz      @f
  217.         test    [es:mi.ModeAttributes], 10000000b  ;LFB ?
  218.         jz      @f
  219.  
  220.         cmp     [es:mi.BitsPerPixel], 24   ;It show only videomodes to have support 24 and 32 bpp
  221.         jb      @f
  222.  
  223. ;        cmp     [es:mi.BitsPerPixel],16
  224. ;        jne     .l0
  225. ;        cmp     [es:mi.GreenMaskSize],5
  226. ;        jne     .l0
  227. ;        mov     [es:mi.BitsPerPixel],15
  228.  
  229.  
  230. .l0:
  231.         cmp     [es:mi.XRes], 640
  232.         jb      @f
  233.         cmp     [es:mi.YRes], 480
  234.         jb      @f
  235. ;        cmp     [es:mi.BitsPerPixel],8
  236. ;        jb      @f
  237.  
  238.         mov     ax, [es:mi.XRes]
  239.         mov     [es:bx+0], ax              ; +0[2] : resolution X
  240.         mov     ax, [es:mi.YRes]
  241.         mov     [es:bx+2], ax              ; +2[2] : resolution Y
  242.         mov     ax, [es:mi.ModeAttributes]
  243.         mov     [es:bx+4], ax              ; +4[2] : attributes
  244.  
  245.         cmp     [s_vesa.ver], '2'
  246. ;        jb      .lp1
  247.         jb      @f    ; We do not use Vesa 1.2 mode is now
  248.  
  249.         or      cx, 0x4000 ; use LFB
  250. .lp1:
  251.         mov     [es:bx+6], cx              ; +6 : mode number
  252.         movzx   ax, byte [es:mi.BitsPerPixel]
  253.         mov     word [es:bx+8], ax              ; +8 : bits per pixel
  254.         add     bx, size_of_step                ; size of record
  255.  
  256.     @@:
  257.         add     si, 2
  258.         jmp     .next_mode
  259.  
  260.   .modes_ok.2:
  261.  
  262.         mov     word[es:bx], -1 ;end video table
  263.         mov     word[end_cursor], bx    ;save end cursor position
  264. ;;;;;;;;;;;;;;;;;;
  265. ;Sort array
  266. ;        mov     si,modes_table
  267. ;.new_mode:
  268. ;        mov     ax,word [es:si]
  269. ;        cmp     ax,-1
  270. ;        je      .exxit
  271. ;        add     ax,word [es:si+2]
  272. ;        add     ax,word [es:si+8]
  273. ;        mov     bp,si
  274. ;.again:
  275. ;        add     bp,12
  276. ;        mov     bx,word [es:bp]
  277. ;        cmp     bx,-1
  278. ;        je      .exit
  279. ;        add     bx,word [es:bp+2]
  280. ;        add     bx,word [es:bp+8]
  281. ;
  282. ;        cmp     ax,bx
  283. ;        ja      .loops
  284. ;        jmp     .again
  285. ;.loops:
  286. ;        push    dword [es:si]
  287. ;        push    dword [es:si+4]
  288. ;        push    dword [es:si+8]
  289. ;        push    dword [es:bp]
  290. ;        push    dword [es:bp+4]
  291. ;        push    dword [es:bp+8]
  292. ;
  293. ;        pop     dword [es:si+8]
  294. ;        pop     dword [es:si+4]
  295. ;        pop     dword [es:si]
  296. ;        pop     dword [es:bp+8]
  297. ;        pop     dword [es:bp+4]
  298. ;        pop     dword [es:bp]
  299. ;        jmp     .new_mode
  300. ;
  301. ;.exit:  add     si,12
  302. ;        jmp     .new_mode
  303. ;.exxit:
  304.         popad
  305.         ret
  306.  
  307. ;-----------------------------------------------------------------------------
  308.  
  309. draw_current_vmode:
  310.         push    0
  311.         pop     es
  312.  
  313.         mov     si, word [cursor_pos]
  314.  
  315.         cmp     word [es:si+6], 0x12
  316.         je      .no_vesa_0x12
  317.  
  318.         cmp     word [es:si+6], 0x13
  319.         je      .no_vesa_0x13
  320.  
  321. if defined extended_primary_loader
  322.         mov     di, config_file_variables
  323. else
  324.         mov     di, loader_block_error
  325. end if
  326.         movzx   eax, word[es:si+0]
  327.         mov     ecx, 10
  328.         call    int2strnz
  329.         mov     byte[es:di], 'x'
  330.         inc     di
  331.         movzx   eax, word[es:si+2]
  332.         call    int2strnz
  333.         mov     byte[es:di], 'x'
  334.         inc     di
  335.         movzx   eax, word[es:si+8]
  336.         call    int2strnz
  337.         mov     dword[es:di], 0x00000d0a
  338. if defined extended_primary_loader
  339.         mov     si, config_file_variables
  340. else
  341.         mov     si, loader_block_error
  342. end if
  343.         push    ds
  344.         push    es
  345.         pop     ds
  346.         call    printplain
  347.         pop     ds
  348.         ret
  349. .no_vesa_0x13:
  350.         mov     si, mode0
  351.         jmp     .print
  352. .no_vesa_0x12:
  353.         mov     si, mode9
  354. .print:
  355.         call    printplain
  356.         ret
  357. ;-----------------------------------------------------------------------------
  358. check_first_parm:
  359. if defined extended_primary_loader
  360.         mov     cx, [number_vm]
  361.         jcxz    .novbemode
  362.         mov     si, modes_table
  363. .findvbemode:
  364.         cmp     [es:si+6], cx
  365.         jnz     @f
  366.         cmp     word [es:si+8], 32
  367.         je      .ok_found_mode
  368.         cmp     word [es:si+8], 24
  369.         je      .ok_found_mode
  370. @@:
  371.         add     si, size_of_step
  372.         cmp     word [es:si], -1
  373.         jnz     .findvbemode
  374. .novbemode:
  375.         mov     ax, [x_save]
  376.         test    ax, ax
  377.         jz      .zerro
  378.         mov     bx, [y_save]
  379.         mov     si, modes_table
  380.         call    .loops
  381.         test    ax, ax
  382.         jz      .ok_found_mode
  383. else
  384.         mov     si, word [preboot_graph]
  385.         test    si, si
  386.         jnz     .no_zero         ;if no zero
  387. end if
  388. .zerro:
  389. ;        mov     ax,modes_table
  390. ;        mov     word [cursor_pos],ax
  391. ;        mov     word [home_cursor],ax
  392. ;        mov     word [preboot_graph],ax
  393. ;SET default video of mode first probe will fined a move of work 1024x768@32
  394.  
  395.         mov     ax, 1024
  396.         mov     bx, 768
  397.         mov     si, modes_table
  398.         call    .loops
  399.         test    ax, ax
  400.         jz      .ok_found_mode
  401.         mov     ax, 800
  402.         mov     bx, 600
  403.         mov     si, modes_table
  404.         call    .loops
  405.         test    ax, ax
  406.         jz      .ok_found_mode
  407.         mov     ax, 640
  408.         mov     bx, 480
  409.         mov     si, modes_table
  410.         call    .loops
  411.         test    ax, ax
  412.         jz      .ok_found_mode
  413.  
  414.         mov     si, modes_table
  415. if ~ defined extended_primary_loader
  416.         jmp     .ok_found_mode
  417.  
  418.  
  419.  
  420. .no_zero:
  421.         mov     bp, word [number_vm]
  422.         cmp     bp, word [es:si+6]
  423.         jz      .ok_found_mode
  424.         mov     ax, word [x_save]
  425.         mov     bx, word [y_save]
  426.         mov     si, modes_table
  427.         call    .loops
  428.         test    ax, ax
  429.         jz      .ok_found_mode
  430.  
  431.         mov     si, modes_table
  432. ;        cmp     ax,modes_table
  433. ;        jb      .zerro           ;check on correct if bellow
  434. ;        cmp     ax,word [end_cursor]
  435. ;        ja      .zerro           ;check on correct if anymore
  436. end if
  437.  
  438. .ok_found_mode:
  439.         mov     word [home_cursor], si
  440. ;        mov     word [cursor_pos],si
  441.         mov     word [preboot_graph], si
  442.         mov     ax, si
  443.  
  444.         mov     ecx, long_v_table
  445.  
  446. .loop:
  447.         add     ax, size_of_step
  448.         cmp     ax, word [end_cursor]
  449.         jae     .next_step
  450.         loop    .loop
  451. .next_step:
  452.         sub     ax, size_of_step*long_v_table
  453.         cmp     ax, modes_table
  454.         jae     @f
  455.         mov     ax, modes_table
  456. @@:
  457.  
  458.         mov     word [home_cursor], ax
  459.         mov     si, [preboot_graph]
  460.         mov     word [cursor_pos], si
  461.  
  462.         push    word [es:si]
  463.         pop     word [x_save]
  464.         push    word [es:si+2]
  465.         pop     word [y_save]
  466.         push    word [es:si+6]
  467.         pop     word [number_vm]
  468.  
  469.         ret
  470. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  471. .loops:
  472.         cmp     ax, word [es:si]
  473.         jne     .next
  474.         cmp     bx, word [es:si+2]
  475.         jne     .next
  476.         cmp     word [es:si+8], 32
  477.         je      .ok
  478.         cmp     word [es:si+8], 24
  479.         je      .ok
  480. .next:
  481.         add     si, size_of_step
  482.         cmp     word [es:si], -1
  483.         je      .exit
  484.         jmp     .loops
  485. .ok:
  486.         xor     ax, ax
  487.         ret
  488. .exit:
  489.         or      ax, -1
  490.         ret
  491.  
  492.  
  493. ;-----------------------------------------------------------------------------
  494.  
  495. ;default_vmode:
  496.  
  497. ;-----------------------------------------------------------------------------
  498. draw_vmodes_table:
  499.         _setcursor 9, 2
  500.         mov     si, gr_mode
  501.         call    printplain
  502.  
  503.         mov     si, _st
  504.         call    printplain
  505.  
  506.         push    word [cursor_pos]
  507.         pop     ax
  508.         push    word [home_cursor]
  509.         pop     si
  510.         mov     cx, si
  511.  
  512.         cmp     ax, si
  513.         je      .ok
  514.         jb      .low
  515.  
  516.  
  517.         add     cx, size_of_step*long_v_table
  518.  
  519.         cmp     ax, cx
  520.         jb      .ok
  521.  
  522.         sub     cx, size_of_step*long_v_table
  523.         add     cx, size_of_step
  524.         cmp     cx, word[end_cursor]
  525.         jae     .ok
  526.         add     si, size_of_step
  527.         push    si
  528.         pop     word [home_cursor]
  529.         jmp     .ok
  530.  
  531.  
  532. .low:
  533.         sub     cx, size_of_step
  534.         cmp     cx, modes_table
  535.         jb      .ok
  536.         push    cx
  537.         push    cx
  538.         pop     word [home_cursor]
  539.         pop     si
  540.  
  541.  
  542. .ok:
  543. ; calculate scroll position
  544.         push    si
  545.         mov     ax, [end_cursor]
  546.         sub     ax, modes_table
  547.         mov     bx, size_of_step
  548.         cwd
  549.         div     bx
  550.         mov     si, ax          ; si = size of list
  551.         mov     ax, [home_cursor]
  552.         sub     ax, modes_table
  553.         cwd
  554.         div     bx
  555.         mov     di, ax
  556.         mov     ax, scroll_area_size*long_v_table
  557.         cwd
  558.         div     si
  559.         test    ax, ax
  560.         jnz     @f
  561.         inc     ax
  562. @@:
  563.         cmp     al, scroll_area_size
  564.         jb      @f
  565.         mov     al, scroll_area_size
  566. @@:
  567.         mov     cx, ax
  568. ; cx = scroll height
  569. ; calculate scroll pos
  570.         xor     bx, bx          ; initialize scroll pos
  571.         sub     al, scroll_area_size+1
  572.         neg     al
  573.         sub     si, long_v_table-1
  574.         jbe     @f
  575.         mul     di
  576.         div     si
  577.         mov     bx, ax
  578. @@:
  579.         inc     bx
  580.         imul    ax, bx, size_of_step
  581.         add     ax, [home_cursor]
  582.         mov     [scroll_start], ax
  583.         imul    cx, size_of_step
  584.         add     ax, cx
  585.         mov     [scroll_end], ax
  586.         pop     si
  587.         mov     bp, long_v_table              ;show rows
  588. .@@_next_bit:
  589. ;clear cursor
  590.         mov     ax, '  '
  591.         mov     word[ds:_r1+21], ax
  592.         mov     word[ds:_r1+50], ax
  593.  
  594.         mov     word[ds:_r2+21], ax
  595.         mov     word[ds:_r2+45], ax
  596.  
  597.         mov     word[ds:_rs+21], ax
  598.         mov     word[ds:_rs+46], ax
  599. ; draw string
  600.         cmp     word [es:si+6], 0x12
  601.         je      .show_0x12
  602.         cmp     word [es:si+6], 0x13
  603.         je      .show_0x13
  604.  
  605.         movzx   eax, word[es:si]
  606.         cmp     ax, -1
  607.         je      .@@_end
  608.         mov     di, _rs+23
  609.         mov     ecx, 10
  610.         mov     bl, 4
  611.         call    int2str
  612.         movzx   eax, word[es:si+2]
  613.         inc     di
  614.         mov     bl, 4
  615.         call    int2str
  616.  
  617.         movzx   eax, word[es:si+8]
  618.         inc     di
  619.         mov     bl, 2
  620.         call    int2str
  621.  
  622.         cmp     si, word [cursor_pos]
  623.         jne     .next
  624. ;draw   cursor
  625.         mov     word[ds:_rs+21], '>>'
  626.         mov     word[ds:_rs+46], '<<'
  627.  
  628.  
  629.  
  630. .next:
  631.         push    si
  632.         mov     si, _rs
  633. .@@_sh:
  634. ; add to the string pseudographics for scrollbar
  635.         pop     bx
  636.         push    bx
  637.         mov     byte [si+53], ' '
  638.         cmp     bx, [scroll_start]
  639.         jb      @f
  640.         cmp     bx, [scroll_end]
  641.         jae     @f
  642.         mov     byte [si+53], 0xDB ; filled bar
  643. @@:
  644.         push    bx
  645.         add     bx, size_of_step
  646.         cmp     bx, [end_cursor]
  647.         jnz     @f
  648.         mov     byte [si+53], 31 ; 'down arrow' symbol
  649. @@:
  650.         sub     bx, [home_cursor]
  651.         cmp     bx, size_of_step*long_v_table
  652.         jnz     @f
  653.         mov     byte [si+53], 31 ; 'down arrow' symbol
  654. @@:
  655.         pop     bx
  656.         cmp     bx, [home_cursor]
  657.         jnz     @f
  658.         mov     byte [si+53], 30 ; 'up arrow' symbol
  659. @@:
  660.         call    printplain
  661.         pop     si
  662.         add     si, size_of_step
  663.  
  664.         dec     bp
  665.         jnz     .@@_next_bit
  666.  
  667. .@@_end:
  668.         mov     si, _bt
  669.         call    printplain
  670.         ret
  671. .show_0x13:
  672.         push    si
  673.  
  674.         cmp     si, word [cursor_pos]
  675.         jne     @f
  676.         mov     word[ds:_r1+21], '>>'
  677.         mov     word[ds:_r1+50], '<<'
  678. @@:
  679.         mov     si, _r1
  680.         jmp     .@@_sh
  681. .show_0x12:
  682.         push    si
  683.         cmp     si, word [cursor_pos]
  684.         jne     @f
  685.  
  686.         mov     word[ds:_r2+21], '>>'
  687.         mov     word[ds:_r2+45], '<<'
  688. @@:
  689.         mov     si, _r2
  690.         jmp     .@@_sh
  691.  
  692. ;-----------------------------------------------------------------------------
  693. ;Clear arrea of current video page (0xb800)
  694. clear_vmodes_table:
  695.         pusha
  696.        ; draw frames
  697.         push    es
  698.         push    0xb800
  699.         pop     es
  700.         mov     di, 1444
  701.         xor     ax, ax
  702.         mov     ah, 1*16+15
  703.         mov     cx, 77
  704.         mov     bp, 12
  705. .loop_start:
  706.         rep stosw
  707.         mov     cx, 77
  708.         add     di, 6
  709.         dec     bp
  710.         jns     .loop_start
  711.         pop     es
  712.         popa
  713.         ret
  714.  
  715. ;-----------------------------------------------------------------------------
  716.  
  717. set_vmode:
  718.         push    0 ;0;x1000
  719.         pop     es
  720.  
  721.         mov     si, word [preboot_graph]           ;[preboot_graph]
  722.         mov     cx, word [es:si+6]           ; number of mode
  723.        
  724.  
  725.         mov     ax, word [es:si+0]           ; resolution X
  726.         mov     bx, word [es:si+2]           ; resolution Y
  727.  
  728.  
  729.         mov     word [es:BOOT_X_RES], ax             ; resolution X
  730.         mov     word [es:BOOT_Y_RES], bx             ; resolution Y
  731.         mov     word [es:BOOT_VESA_MODE], cx             ; number of mode
  732.  
  733.         cmp     cx, 0x12
  734.         je      .mode0x12_0x13
  735.         cmp     cx, 0x13
  736.         je      .mode0x12_0x13
  737.  
  738.  
  739. ;        cmp     byte [s_vesa.ver], '2'
  740. ;        jb      .vesa12
  741.  
  742. ;  VESA 2 and Vesa 3
  743.  
  744.         mov     ax, 0x4f01
  745.         and     cx, 0xfff
  746.         mov     di, mi;0xa000
  747.         int     0x10
  748.         ; LFB
  749.         mov     eax, [es:mi.PhysBasePtr];di+0x28]
  750.         mov     [es:BOOT_LFB], eax
  751.         ; ---- vbe voodoo
  752.         BytesPerLine equ 0x10
  753.         mov     ax, [es:di+BytesPerLine]
  754.         mov     [es:BOOT_PITCH], ax
  755.         ; BPP
  756.         cmp     [es:mi.BitsPerPixel], 16
  757.         jne     .l0
  758.         cmp     [es:mi.GreenMaskSize], 5
  759.         jne     .l0
  760.         mov     [es:mi.BitsPerPixel], 15
  761. .l0:
  762.         mov     al, byte [es:di+0x19]
  763.         mov     [es:BOOT_BPP], al
  764.         jmp     .exit
  765.  
  766. .mode0x12_0x13:
  767.         mov     byte [es:BOOT_BPP], 32
  768.         or      dword [es:BOOT_LFB], 0xFFFFFFFF; 0x800000
  769.  
  770.  
  771. ;  VESA 1.2 PM BANK SWITCH ADDRESS
  772.  
  773. ;.vesa12:
  774. ;        mov     ax, 0x4f0A
  775. ;        xor     bx, bx
  776. ;        int     0x10
  777. ;        xor     eax, eax
  778. ;        xor     ebx, ebx
  779. ;        mov     ax, es
  780. ;        shl     eax, 4
  781. ;        mov     bx, di
  782. ;        add     eax, ebx
  783. ;        movzx   ebx, word[es:di]
  784. ;        add     eax, ebx
  785. ;        push    0x0000
  786. ;        pop     es
  787. ;        mov     [es:0x9014], eax
  788.   .exit:
  789.         ret
  790.  
  791. ;=============================================================================
  792. ;=============================================================================
  793. ;=============================================================================
  794.  
  795.