Subversion Repositories Kolibri OS

Rev

Rev 1941 | Blame | 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: 2014 $
  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     ;temporary cursor storage.
  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. ;-------------------------------------------------------
  117. print_vesa_info:
  118.  
  119.         mov     [es:vi.VESASignature],'VBE2'
  120.         mov     ax,0x4F00
  121.         mov     di,vi      ;0xa000
  122.         int     0x10
  123.         or      ah,ah
  124.         jz      @f
  125.         mov     [es:vi.VESASignature],'VESA'
  126.         mov     ax,$4F00
  127.         mov     di,vi
  128.         int     0x10
  129.         or      ah,ah
  130.         jnz     $
  131.   @@:
  132.         cmp     [es:vi.VESASignature],'VESA'
  133.         jne     $
  134.         cmp     [es:vi.VESAVersion],0x0100
  135.         jb      $
  136.  
  137.   .vesaok2:
  138.  
  139.         ret
  140. ;-----------------------------------------------------------------------------
  141.  
  142. calc_vmodes_table:
  143.         pushad
  144.  
  145. ;        push    0
  146. ;        pop     es
  147.  
  148.         lfs     si, [es:vi.VideoModePtr]
  149.  
  150.         mov     bx,modes_table
  151.  
  152.   .next_mode:
  153.         mov     cx,word [fs:si] ; mode number
  154.         cmp     cx,-1
  155.         je      .modes_ok.2
  156.  
  157.         mov     ax,0x4F01
  158.         mov     di,mi
  159.         int     0x10
  160.  
  161.         or      ah,ah
  162.         jnz     .modes_ok.2             ;vesa_info.exit
  163.  
  164.         test    [es:mi.ModeAttributes],00000001b   ;videomode support ?
  165.         jz      @f
  166.         test    [es:mi.ModeAttributes],00010000b   ;picture ?
  167.         jz      @f
  168.         test    [es:mi.ModeAttributes],10000000b   ;LFB ?
  169.         jz      @f
  170.  
  171.         cmp     [es:mi.BitsPerPixel], 32        ;to show only 32 bpp videomodes
  172.         jb      @f
  173.  
  174. .l0:
  175.         cmp     [es:mi.XRes],800        ; only 800x600 and higher
  176.         jb      @f
  177.  
  178.         mov     ax,[es:mi.XRes]
  179.         mov     [es:bx+0],ax               ; +0[2] : resolution X
  180.         mov     ax,[es:mi.YRes]
  181.         mov     [es:bx+2],ax               ; +2[2] : resolution Y
  182.         mov     ax,[es:mi.ModeAttributes]
  183.         mov     [es:bx+4],ax               ; +4[2] : attributes
  184.  
  185. ;<<        cmp     [s_vesa.ver],'2'
  186. ;<<        jb      .lp1
  187.  
  188.         or      cx,0x4000                       ; use LFB <<< ?
  189. .lp1:   mov     [es:bx+6],cx               ; +6 : mode number
  190.         movzx   ax,byte [es:mi.BitsPerPixel]
  191.         mov     word [es:bx+8],ax               ; +8 : bits per pixel << ?
  192.         add     bx,size_of_step                 ; size of record
  193.  
  194.     @@:
  195.         add     si,2
  196.         jmp     .next_mode
  197.  
  198.   .modes_ok.2:
  199.  
  200.         mov     word[es:bx],-1  ;end video table
  201.         mov     word[end_cursor],bx     ;save end cursor position
  202.         popad
  203.         ret
  204.  
  205. check_first_parm:
  206.         mov     si,word [preboot_graph]
  207.         test    si,si
  208.         jnz      .no_zero        ;if no zero
  209. .zerro:
  210.         mov     word[preboot_graph], ax
  211.  
  212.         mov     ax,1024
  213.         mov     bx,768
  214.         mov     si,modes_table
  215.         call    .loops
  216.         test    ax,ax
  217.         jz     .ok_found_mode
  218.  
  219.         mov     si,modes_table
  220.         jmp     .ok_found_mode
  221.  
  222. .no_zero:
  223.         mov     bp,word [number_vm]
  224.         cmp     bp,word [es:si+6]
  225.         jz      .ok_found_mode
  226.         mov     ax,word [x_save]
  227.         mov     bx,word [y_save]
  228.         mov     si,modes_table
  229.         call    .loops
  230.         test    ax,ax
  231.         jz     .ok_found_mode
  232.  
  233.         mov    si,modes_table
  234.  
  235. .ok_found_mode:
  236.         mov     word [home_cursor],si
  237.         mov     word [preboot_graph],si
  238.         mov     ax,si
  239.  
  240.         mov     ecx,long_v_table
  241.  
  242. .loop:  add     ax,size_of_step
  243.         cmp     ax,word [end_cursor]
  244.         jae     .next_step
  245.         loop    .loop
  246. .next_step:
  247.         sub     ax,size_of_step*long_v_table
  248.         cmp     ax,modes_table
  249.         jae     @f
  250.         mov     ax,modes_table
  251. @@:
  252.  
  253.         mov     word [home_cursor],ax
  254.         mov     si,[preboot_graph]
  255.         mov     word [cursor_pos],si
  256.  
  257.         push    word [es:si]
  258.         pop     word [x_save]
  259.         push    word [es:si+2]
  260.         pop     word [y_save]
  261.         push    word [es:si+6]
  262.         pop     word [number_vm]
  263.  
  264.         ret
  265. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  266. .loops:
  267.         cmp     ax,word [es:si]
  268.         jne     .next
  269.         cmp     bx,word [es:si+2]
  270.         jne     .next
  271.         je      .ok
  272. .next:  add     si,size_of_step
  273.         cmp     word [es:si],-1
  274.         je      .exit
  275.         jmp     .loops
  276. .ok:    xor     ax,ax
  277.         ret
  278. .exit:  or      ax,-1
  279.         ret
  280.  
  281.  
  282. ;-----------------------------------------------------------------------------
  283.  
  284. set_vmode:
  285.         push    0 ;0;x1000
  286.         pop     es
  287.  
  288.         mov     si,word [preboot_graph]            ;[preboot_graph]
  289.         mov     cx,word [es:si+6]            ; number of mode
  290.  
  291.  
  292.         mov     ax,word [es:si+0]            ; resolution X
  293.         mov     bx,word [es:si+2]            ; resolution Y
  294.  
  295.  
  296.         mov     word [es:0x900A],ax              ; resolution X
  297.         mov     word [es:0x900C],bx              ; resolution Y
  298.         mov     word [es:0x9008],cx              ; number of mode
  299.  
  300.  
  301. ;  VESA 2 and Vesa 3 only
  302.  
  303.         mov     ax,0x4f01
  304.         and     cx,0xfff
  305.         mov     di,mi;0xa000
  306.         int     0x10
  307.         ; LFB
  308.         mov     eax,[es:mi.PhysBasePtr]         ;di+0x28]
  309.         mov     [es:0x9018],eax
  310.         ; ---- vbe voodoo
  311.         BytesPerLine equ 0x10
  312.         mov     ax, [es:di+BytesPerLine]
  313.         mov     [es:0x9001], ax
  314.         ; BPP
  315. .l0:
  316.         mov     al, byte [es:di+0x19]
  317.         mov     [es:0x9000], al
  318.         jmp     .exit
  319.  
  320.   .exit:
  321.         ret
  322.  
  323.  
  324. ;=============================================================================
  325.  
  326.