Subversion Repositories Kolibri OS

Rev

Rev 1962 | Rev 2407 | 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. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 2288 $
  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.  
  248.         or      cx, 0x4000 ; use LFB
  249. .lp1:
  250.         mov     [es:bx+6], cx              ; +6 : mode number
  251.         movzx   ax, byte [es:mi.BitsPerPixel]
  252.         mov     word [es:bx+8], ax              ; +8 : bits per pixel
  253.         add     bx, size_of_step                ; size of record
  254.  
  255.     @@:
  256.         add     si, 2
  257.         jmp     .next_mode
  258.  
  259.   .modes_ok.2:
  260.  
  261.         mov     word[es:bx], -1 ;end video table
  262.         mov     word[end_cursor], bx    ;save end cursor position
  263. ;;;;;;;;;;;;;;;;;;
  264. ;Sort array
  265. ;        mov     si,modes_table
  266. ;.new_mode:
  267. ;        mov     ax,word [es:si]
  268. ;        cmp     ax,-1
  269. ;        je      .exxit
  270. ;        add     ax,word [es:si+2]
  271. ;        add     ax,word [es:si+8]
  272. ;        mov     bp,si
  273. ;.again:
  274. ;        add     bp,12
  275. ;        mov     bx,word [es:bp]
  276. ;        cmp     bx,-1
  277. ;        je      .exit
  278. ;        add     bx,word [es:bp+2]
  279. ;        add     bx,word [es:bp+8]
  280. ;        
  281. ;        cmp     ax,bx
  282. ;        ja      .loops
  283. ;        jmp     .again
  284. ;.loops:
  285. ;        push    dword [es:si]
  286. ;        push    dword [es:si+4]
  287. ;        push    dword [es:si+8]
  288. ;        push    dword [es:bp]
  289. ;        push    dword [es:bp+4]
  290. ;        push    dword [es:bp+8]
  291. ;
  292. ;        pop     dword [es:si+8]
  293. ;        pop     dword [es:si+4]
  294. ;        pop     dword [es:si]
  295. ;        pop     dword [es:bp+8]
  296. ;        pop     dword [es:bp+4]
  297. ;        pop     dword [es:bp]
  298. ;        jmp     .new_mode
  299. ;
  300. ;.exit:  add     si,12
  301. ;        jmp     .new_mode
  302. ;.exxit:
  303.         popad
  304.         ret
  305.  
  306. ;-----------------------------------------------------------------------------
  307.  
  308. draw_current_vmode:
  309.         push    0
  310.         pop     es
  311.  
  312.         mov     si, word [cursor_pos]
  313.  
  314.         cmp     word [es:si+6], 0x12
  315.         je      .no_vesa_0x12
  316.  
  317.         cmp     word [es:si+6], 0x13
  318.         je      .no_vesa_0x13
  319.  
  320. if defined extended_primary_loader
  321.         mov     di, config_file_variables
  322. else
  323.         mov     di, loader_block_error
  324. end if
  325.         movzx   eax, word[es:si+0]
  326.         mov     ecx, 10
  327.         call    int2strnz
  328.         mov     byte[es:di], 'x'
  329.         inc     di
  330.         movzx   eax, word[es:si+2]
  331.         call    int2strnz
  332.         mov     byte[es:di], 'x'
  333.         inc     di
  334.         movzx   eax, word[es:si+8]
  335.         call    int2strnz
  336.         mov     dword[es:di], 0x00000d0a
  337. if defined extended_primary_loader
  338.         mov     si, config_file_variables
  339. else
  340.         mov     si, loader_block_error
  341. end if
  342.         push    ds
  343.         push    es
  344.         pop     ds
  345.         call    printplain
  346.         pop     ds
  347.         ret
  348. .no_vesa_0x13:
  349.         mov     si, mode0
  350.         jmp     .print
  351. .no_vesa_0x12:
  352.         mov     si, mode9
  353. .print:
  354.         call    printplain
  355.         ret
  356. ;-----------------------------------------------------------------------------
  357. check_first_parm:
  358. if defined extended_primary_loader
  359.         mov     cx, [number_vm]
  360.         jcxz    .novbemode
  361.         mov     si, modes_table
  362. .findvbemode:
  363.         cmp     [es:si+6], cx
  364.         jnz     @f
  365.         cmp     word [es:si+8], 32
  366.         je      .ok_found_mode
  367.         cmp     word [es:si+8], 24
  368.         je      .ok_found_mode
  369. @@:
  370.         add     si, size_of_step
  371.         cmp     word [es:si], -1
  372.         jnz     .findvbemode
  373. .novbemode:
  374.         mov     ax, [x_save]
  375.         test    ax, ax
  376.         jz      .zerro
  377.         mov     bx, [y_save]
  378.         mov     si, modes_table
  379.         call    .loops
  380.         test    ax, ax
  381.         jz      .ok_found_mode
  382. else
  383.         mov     si, word [preboot_graph]
  384.         test    si, si
  385.         jnz     .no_zero         ;if no zero
  386. end if
  387. .zerro:
  388. ;        mov     ax,modes_table
  389. ;        mov     word [cursor_pos],ax
  390. ;        mov     word [home_cursor],ax
  391. ;        mov     word [preboot_graph],ax
  392. ;SET default video of mode first probe will fined a move of work 1024x768@32
  393.  
  394.         mov     ax, 1024
  395.         mov     bx, 768
  396.         mov     si, modes_table
  397.         call    .loops
  398.         test    ax, ax
  399.         jz      .ok_found_mode
  400.         mov     ax, 800
  401.         mov     bx, 600
  402.         mov     si, modes_table
  403.         call    .loops
  404.         test    ax, ax
  405.         jz      .ok_found_mode
  406.         mov     ax, 640
  407.         mov     bx, 480
  408.         mov     si, modes_table
  409.         call    .loops
  410.         test    ax, ax
  411.         jz      .ok_found_mode
  412.  
  413.         mov     si, modes_table
  414. if ~ defined extended_primary_loader
  415.         jmp     .ok_found_mode
  416.  
  417.  
  418.  
  419. .no_zero:
  420.         mov     bp, word [number_vm]
  421.         cmp     bp, word [es:si+6]
  422.         jz      .ok_found_mode
  423.         mov     ax, word [x_save]
  424.         mov     bx, word [y_save]
  425.         mov     si, modes_table
  426.         call    .loops
  427.         test    ax, ax
  428.         jz      .ok_found_mode
  429.  
  430.         mov     si, modes_table
  431. ;        cmp     ax,modes_table
  432. ;        jb      .zerro           ;check on correct if bellow
  433. ;        cmp     ax,word [end_cursor]
  434. ;        ja      .zerro           ;check on correct if anymore
  435. end if
  436.  
  437. .ok_found_mode:
  438.         mov     word [home_cursor], si
  439. ;        mov     word [cursor_pos],si
  440.         mov     word [preboot_graph], si
  441.         mov     ax, si
  442.  
  443.         mov     ecx, long_v_table
  444.  
  445. .loop:
  446.         add     ax, size_of_step
  447.         cmp     ax, word [end_cursor]
  448.         jae     .next_step
  449.         loop    .loop
  450. .next_step:
  451.         sub     ax, size_of_step*long_v_table
  452.         cmp     ax, modes_table
  453.         jae     @f
  454.         mov     ax, modes_table
  455. @@:
  456.  
  457.         mov     word [home_cursor], ax
  458.         mov     si, [preboot_graph]
  459.         mov     word [cursor_pos], si
  460.  
  461.         push    word [es:si]
  462.         pop     word [x_save]
  463.         push    word [es:si+2]
  464.         pop     word [y_save]
  465.         push    word [es:si+6]
  466.         pop     word [number_vm]
  467.  
  468.         ret
  469. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  470. .loops:
  471.         cmp     ax, word [es:si]
  472.         jne     .next
  473.         cmp     bx, word [es:si+2]
  474.         jne     .next
  475.         cmp     word [es:si+8], 32
  476.         je      .ok
  477.         cmp     word [es:si+8], 24
  478.         je      .ok
  479. .next:
  480.         add     si, size_of_step
  481.         cmp     word [es:si], -1
  482.         je      .exit
  483.         jmp     .loops
  484. .ok:
  485.         xor     ax, ax
  486.         ret
  487. .exit:
  488.         or      ax, -1
  489.         ret
  490.  
  491.  
  492. ;-----------------------------------------------------------------------------
  493.  
  494. ;default_vmode:
  495.        
  496. ;-----------------------------------------------------------------------------
  497. draw_vmodes_table:
  498.         _setcursor 9, 2
  499.         mov     si, gr_mode
  500.         call    printplain
  501.  
  502.         mov     si, _st
  503.         call    printplain
  504.  
  505.         push    word [cursor_pos]
  506.         pop     ax
  507.         push    word [home_cursor]
  508.         pop     si
  509.         mov     cx, si
  510.  
  511.         cmp     ax, si
  512.         je      .ok
  513.         jb      .low
  514.  
  515.  
  516.         add     cx, size_of_step*long_v_table
  517.        
  518.         cmp     ax, cx
  519.         jb      .ok
  520.        
  521.         sub     cx, size_of_step*long_v_table
  522.         add     cx, size_of_step
  523.         cmp     cx, word[end_cursor]
  524.         jae     .ok
  525.         add     si, size_of_step
  526.         push    si
  527.         pop     word [home_cursor]
  528.         jmp     .ok
  529.  
  530.  
  531. .low:
  532.         sub     cx, size_of_step
  533.         cmp     cx, modes_table
  534.         jb      .ok
  535.         push    cx
  536.         push    cx
  537.         pop     word [home_cursor]
  538.         pop     si
  539.  
  540.  
  541. .ok:
  542. ; calculate scroll position
  543.         push    si
  544.         mov     ax, [end_cursor]
  545.         sub     ax, modes_table
  546.         mov     bx, size_of_step
  547.         cwd
  548.         div     bx
  549.         mov     si, ax          ; si = size of list
  550.         mov     ax, [home_cursor]
  551.         sub     ax, modes_table
  552.         cwd
  553.         div     bx
  554.         mov     di, ax
  555.         mov     ax, scroll_area_size*long_v_table
  556.         cwd
  557.         div     si
  558.         test    ax, ax
  559.         jnz     @f
  560.         inc     ax
  561. @@:
  562.         cmp     al, scroll_area_size
  563.         jb      @f
  564.         mov     al, scroll_area_size
  565. @@:
  566.         mov     cx, ax
  567. ; cx = scroll height
  568. ; calculate scroll pos
  569.         xor     bx, bx          ; initialize scroll pos
  570.         sub     al, scroll_area_size+1
  571.         neg     al
  572.         sub     si, long_v_table-1
  573.         jbe     @f
  574.         mul     di
  575.         div     si
  576.         mov     bx, ax
  577. @@:
  578.         inc     bx
  579.         imul    ax, bx, size_of_step
  580.         add     ax, [home_cursor]
  581.         mov     [scroll_start], ax
  582.         imul    cx, size_of_step
  583.         add     ax, cx
  584.         mov     [scroll_end], ax
  585.         pop     si
  586.         mov     bp, long_v_table              ;show rows
  587. .@@_next_bit:
  588. ;clear cursor
  589.         mov     ax, '  '
  590.         mov     word[ds:_r1+21], ax
  591.         mov     word[ds:_r1+50], ax
  592.  
  593.         mov     word[ds:_r2+21], ax
  594.         mov     word[ds:_r2+45], ax
  595.  
  596.         mov     word[ds:_rs+21], ax
  597.         mov     word[ds:_rs+46], ax
  598. ; draw string
  599.         cmp     word [es:si+6], 0x12
  600.         je      .show_0x12
  601.         cmp     word [es:si+6], 0x13
  602.         je      .show_0x13
  603.  
  604.         movzx   eax, word[es:si]
  605.         cmp     ax, -1
  606.         je      .@@_end
  607.         mov     di, _rs+23
  608.         mov     ecx, 10
  609.         mov     bl, 4
  610.         call    int2str
  611.         movzx   eax, word[es:si+2]
  612.         inc     di
  613.         mov     bl, 4
  614.         call    int2str
  615.  
  616.         movzx   eax, word[es:si+8]
  617.         inc     di
  618.         mov     bl, 2
  619.         call    int2str
  620.  
  621.         cmp     si, word [cursor_pos]
  622.         jne     .next
  623. ;draw   cursor
  624.         mov     word[ds:_rs+21], '>>'
  625.         mov     word[ds:_rs+46], '<<'
  626.        
  627.  
  628.  
  629. .next:
  630.         push    si
  631.         mov     si, _rs
  632. .@@_sh:
  633. ; add to the string pseudographics for scrollbar
  634.         pop     bx
  635.         push    bx
  636.         mov     byte [si+53], ' '
  637.         cmp     bx, [scroll_start]
  638.         jb      @f
  639.         cmp     bx, [scroll_end]
  640.         jae     @f
  641.         mov     byte [si+53], 0xDB ; filled bar
  642. @@:
  643.         push    bx
  644.         add     bx, size_of_step
  645.         cmp     bx, [end_cursor]
  646.         jnz     @f
  647.         mov     byte [si+53], 31 ; 'down arrow' symbol
  648. @@:
  649.         sub     bx, [home_cursor]
  650.         cmp     bx, size_of_step*long_v_table
  651.         jnz     @f
  652.         mov     byte [si+53], 31 ; 'down arrow' symbol
  653. @@:
  654.         pop     bx
  655.         cmp     bx, [home_cursor]
  656.         jnz     @f
  657.         mov     byte [si+53], 30 ; 'up arrow' symbol
  658. @@:
  659.         call    printplain
  660.         pop     si
  661.         add     si, size_of_step
  662.  
  663.         dec     bp
  664.         jnz     .@@_next_bit
  665.  
  666. .@@_end:
  667.         mov     si, _bt
  668.         call    printplain
  669.         ret
  670. .show_0x13:
  671.         push    si
  672.  
  673.         cmp     si, word [cursor_pos]
  674.         jne     @f
  675.         mov     word[ds:_r1+21], '>>'
  676.         mov     word[ds:_r1+50], '<<'
  677. @@:
  678.         mov     si, _r1
  679.         jmp     .@@_sh
  680. .show_0x12:
  681.         push    si
  682.         cmp     si, word [cursor_pos]
  683.         jne     @f
  684.  
  685.         mov     word[ds:_r2+21], '>>'
  686.         mov     word[ds:_r2+45], '<<'
  687. @@:
  688.         mov     si, _r2
  689.         jmp     .@@_sh
  690.  
  691. ;-----------------------------------------------------------------------------
  692. ;Clear arrea of current video page (0xb800)
  693. clear_vmodes_table:
  694.         pusha
  695.        ; draw frames
  696.         push    es
  697.         push    0xb800
  698.         pop     es
  699.         mov     di, 1444
  700.         xor     ax, ax
  701.         mov     ah, 1*16+15
  702.         mov     cx, 70
  703.         mov     bp, 12
  704. .loop_start:
  705.         rep stosw
  706.         mov     cx, 70
  707.         add     di, 20
  708.         dec     bp
  709.         jns     .loop_start
  710.         pop     es
  711.         popa
  712.         ret
  713.  
  714. ;-----------------------------------------------------------------------------
  715.  
  716. set_vmode:
  717.         push    0 ;0;x1000
  718.         pop     es
  719.  
  720.         mov     si, word [preboot_graph]           ;[preboot_graph]
  721.         mov     cx, word [es:si+6]           ; number of mode
  722.        
  723.  
  724.         mov     ax, word [es:si+0]           ; resolution X
  725.         mov     bx, word [es:si+2]           ; resolution Y
  726.  
  727.  
  728.         mov     word [es:0x900A], ax             ; resolution X
  729.         mov     word [es:0x900C], bx             ; resolution Y
  730.         mov     word [es:0x9008], cx             ; number of mode
  731.  
  732.         cmp     cx, 0x12
  733.         je      .mode0x12_0x13
  734.         cmp     cx, 0x13
  735.         je      .mode0x12_0x13
  736.  
  737.  
  738.         cmp     byte [s_vesa.ver], '2'
  739.         jb      .vesa12
  740.  
  741. ;  VESA 2 and Vesa 3
  742.  
  743.         mov     ax, 0x4f01
  744.         and     cx, 0xfff
  745.         mov     di, mi;0xa000
  746.         int     0x10
  747.         ; LFB
  748.         mov     eax, [es:mi.PhysBasePtr];di+0x28]
  749.         mov     [es:0x9018], eax
  750.         ; ---- vbe voodoo
  751.         BytesPerLine equ 0x10
  752.         mov     ax, [es:di+BytesPerLine]
  753.         mov     [es:0x9001], ax
  754.         ; BPP
  755.         cmp     [es:mi.BitsPerPixel], 16
  756.         jne     .l0
  757.         cmp     [es:mi.GreenMaskSize], 5
  758.         jne     .l0
  759.         mov     [es:mi.BitsPerPixel], 15
  760. .l0:
  761.         mov     al, byte [es:di+0x19]
  762.         mov     [es:0x9000], al
  763.         jmp     .exit
  764.  
  765. .mode0x12_0x13:
  766.         mov     byte [es:0x9000], 32
  767.         or      dword [es:0x9018], 0xFFFFFFFF; 0x800000
  768.  
  769.  
  770. ;  VESA 1.2 PM BANK SWITCH ADDRESS
  771.  
  772. .vesa12:
  773.  
  774.  
  775.         mov     ax, 0x4f0A
  776.         xor     bx, bx
  777.         int     0x10
  778.         xor     eax, eax
  779.         xor     ebx, ebx
  780.         mov     ax, es
  781.         shl     eax, 4
  782.         mov     bx, di
  783.         add     eax, ebx
  784.         movzx   ebx, word[es:di]
  785.         add     eax, ebx
  786.         push    0x0000
  787.         pop     es
  788.         mov     [es:0x9014], eax
  789.   .exit:
  790.         ret
  791.  
  792.  
  793. ;        mov     dword[es:0x9018],0x000A0000
  794. ;        ret
  795.  
  796. ;=============================================================================
  797. ;=============================================================================
  798. ;=============================================================================
  799.  
  800.