Subversion Repositories Kolibri OS

Rev

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