Graphics

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
tera4d
Member
Member
Posts: 37
Joined: Sun Apr 26, 2009 11:22 am

Graphics

Post by tera4d »

Hello ,users

First of all yes i have searched but i could not find any artices suitable for me.

I did some research on vesa and vga and i keep on reading that it is the easiest to switch to a vesa / vga mode from real mode.
My current kernel was a pmode one but i wanted to start over anyway so i developed my own bootloader with help from the brokenthorn series. But how would i make the switch to a vesa mode?
I am still in realmode so it should be the easiest but about everything i read it says to use a virtual v86 monitor or something but that should not be needed because i am still in realmode :D But i do not know on how to make the switch can someone please give me a good article or perhaps even a example? I use nasm to compile my bootloader, and what if i finally enabled vesa and then switch to pmode is there any special method for drawing then? Since i already enabled vesa then. It is all a little vague to me so i would really appreciate it if someone could help me out with this.

Thank you for reading

P.S
I do not have any c-code yet so i am looking for a asm based code or article for nasm. if you look at the brokenthorn.com os series that is the bootloader which i based mine off.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Graphics

Post by Dex »

Here is a simple demo

Code: Select all

;************************************
; By Dex
;
; Assemble with fasm 
; c:\fasm Vesa.asm Vesa.bin
;
; Use rawrite to put on floppy
;
;************************************
org 0x7C00 

use16
;****************************
; Realmode startup code.
;****************************

start:
        xor   ax,ax
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   sp,0x7C00 

;****************************
; Vesa start code.
;****************************
;get vesa info
        mov  bx,4112h        ; set the mode you want here
        mov  ax,4f01h
        mov  di,Mode_Info ;which will fill the Mode_Info out
        mov  cx,bx
        int  10h 
 ; Set mode       
        mov  ax,4f02h ;note bx should still have the mode number 4112h
        int  10h

;*****************************
; Setting up, to enter pmode.
;*****************************

        cli 
        lgdt  [gdtr]
        
        mov   eax, cr0
        or    al,0x1 
        mov   cr0,eax
 
        jmp   0x10: protected

;*****************************
; Pmode. ;-)
;*****************************

use32
protected:
        mov   ax,0x8 
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   esp,0x7C00
;*****************************
; Turn floppy off 
;*****************************

        mov   dx,3F2h
        mov   al,0
        out   dx,al

;*****************************
; Do we have 32 BitsPerPixel.
;*****************************

        cmp   byte[ModeInfo_BitsPerPixel],32 ;note some cards use 24bits and some 32bits we test, has the code here is for 32BPP
        jne   JustLoop

;*****************************
; fade background screen.
;*****************************

fade_screen:
        mov   edx,[ModeInfo_PhysBasePtr] ; To write to the screen is as simple as writing to the address thats stored in this var from the 
        mov   edi,edx                                       ; Vesa "Mode_Info" strut
        xor   eax,eax
        mov   al,0xc5          
        xor   ebx,ebx
        mov   bl,195 
DoLoop:    
        mov   cx,640*2 
        dec   eax    

        rep   stosd
       
        dec   ebx
        jnz   DoLoop

;***********************************
; Draws the iPOD.
;***********************************

        mov   edi,236*4+640*4*125 
        add   edi,edx
Pod:
        xor   ecx,ecx
        mov   ebx,245
button2:
        mov   cl,14
        mov   al,0x2d
letsloop1:
        stosd
        add   eax,15
        loop  letsloop1
        mov   cl,130
        rep   stosd
        mov   cl,14
letsloop2:
        stosd
        sub   eax,15
        loop  letsloop2
        add   edi,640*4-158*4
        dec   ebx
        jnz   button2
       
;***********************************
; Draws the Pod window.  :-(
;***********************************

        mov   edi,263*4+640*4*143
        add   edi,edx 
PodWindow:
        mov   eax,0xffa6ffff
        xor   edx,edx
        mov   dl,65
DrawSomePixals:
        mov   cl,104
        rep   stosd
        add   edi,640*4-104*4 
        dec   edx
        jnz   DrawSomePixals

        xor   eax,eax
        mov   dl,65
DrawaLine:
        sub   edi,641*4
        stosd
        dec   edx
        jnz   DrawaLine

        mov   cl,104
        rep   stosd
JustLoop:
        jmp   $


;*************************************
; GDT. 
;*************************************

gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000
sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CF
sys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CF
gdt_end:

gdtr:	    dw gdt_end - gdt - 1	                                  
	    dd gdt 


;*************************************
; Make program 510 byte's + 0xaa55
;*************************************
            
times 510- ($-start)  db 0  
dw 0xaa55

;*************************************
; Put uninitialized data here. eg: vesa info
;*************************************

Mode_Info:		
ModeInfo_ModeAttributes		rw	1
ModeInfo_WinAAttributes		rb	1
ModeInfo_WinBAttributes		rb	1
ModeInfo_WinGranularity		rw	1
ModeInfo_WinSize		rw	1
ModeInfo_WinASegment		rw	1
ModeInfo_WinBSegment		rw	1
ModeInfo_WinFuncPtr		rd	1
ModeInfo_BytesPerScanLine	rw	1
ModeInfo_XResolution		rw	1
ModeInfo_YResolution		rw	1
ModeInfo_XCharSize		rb	1
ModeInfo_YCharSize		rb	1
ModeInfo_NumberOfPlanes		rb	1
ModeInfo_BitsPerPixel		rb	1
ModeInfo_NumberOfBanks		rb	1
ModeInfo_MemoryModel		rb	1
ModeInfo_BankSize		rb	1
ModeInfo_NumberOfImagePages	rb	1
ModeInfo_Reserved_page		rb	1
ModeInfo_RedMaskSize		rb	1
ModeInfo_RedMaskPos		rb	1
ModeInfo_GreenMaskSize		rb	1
ModeInfo_GreenMaskPos		rb	1
ModeInfo_BlueMaskSize		rb	1
ModeInfo_BlueMaskPos		rb	1
ModeInfo_ReservedMaskSize	rb	1
ModeInfo_ReservedMaskPos	rb	1
ModeInfo_DirectColorModeInfo	rb	1
; VBE 2.0 extensions
ModeInfo_PhysBasePtr		rd	1
ModeInfo_OffScreenMemOffset	rd	1
ModeInfo_OffScreenMemSize	rw	1
This demo just switch to vesa mode 640*480 32bpp, then goes to pmode and draws a gui, layed out like a ipod
Its fasm but it should need little converting, any ? just ask

And please anyone do not say about error checking etc, it kept simple as a demo.
User avatar
Thor
Member
Member
Posts: 51
Joined: Mon Jul 06, 2009 12:55 am
Location: Kamloops, BC, Canada

Re: Graphics

Post by Thor »

A good resource: VBE Standards

It goes over them quite well, should have everything you need to know :)

If it asks you for a username/password, put [email protected] and stds2007
Vancouver Canucks fan for life
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Graphics

Post by i586coder »

Hi,

awesome code Dex =D>

for his case i suggest mode 13h or (320x200x256)
it is the easiest mode you can play with :wink:

in C you can do simple pixel plot like this

Code: Select all


#define width 319 //0-319=320

void setpixel(int x,int y,char color){
 int offset=y*width+x;//remember each pixel is one byte from 0-ffh
 pokeb(0xA000,offset,color);
}

void main(void){

   _asm{mov ax,0x13 //switch to mode 13h
            int 0x10
   }

  setpixel(10,10,14); //draw pixel at coordinate x=10 y=10 with yellow color
  //make your art work here

 getch();

   _asm{mov ax,0x13 //switch back to mode 3h 80x25
            int 0x10
   }


}

also there is 640x480 mode 12h but it need some working around bitplane :idea:

or you can use VBE for more power results as guys said

CheerS :mrgreen: ,
a.T.d
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
tera4d
Member
Member
Posts: 37
Joined: Sun Apr 26, 2009 11:22 am

Re: Graphics

Post by tera4d »

Hello guys thank you for the fast reply's

@Dex
Thank you very much for the code but it doesnt want to compile in nasm :S
Here is a screencapture of nasm's output: Image
How would it be possible to switch to 1280x1024 / 1024x768 / 800x600 etc.. how would i do that?
Not that I am pushing myself but I like to tryout stuff no matter if it works or not :P

@thor
Thank you for the link i will check it out right away =D

@i586coder
Currently i am in asm no c code's yet :P
But how would i do it that if i completed my bootloader and then continue to further c coding.
If i enabled vesa in the bios can i then just write to the video memory or do i need to do another thing?
I just wish to stay in 640x480 mode or higher for displaying my bootlogo and then also for my os so there is no need for changing the video mode again.
Also i am in real mode so i switch to vesa and then switch to pmode would that harm my vesa or? :P
May i also ask why is mode13h the easiest to work with? I mean if you draw on the screen how would it be different with other modes? I mean they are just other resolutions are they?
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Graphics

Post by Troy Martin »

That's cause Dex's code (all of it) is made for FASM, not NASM. There are a few differences between the two, but some can blow the whole thing up when you try to compile FASM code on NASM and vice-versa.

I'll leave you to figure it out on your own. Hint: grab a copy of both NASM's and FASM's manuals :P
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
Andr3w
Member
Member
Posts: 76
Joined: Tue Jun 09, 2009 4:09 am
Location: Somewhere

Re: Graphics

Post by Andr3w »

@tera4d
May i also ask why is mode13h the easiest to work with? I mean if you draw on the screen how would it be different with other modes?
For example, mode 12h has planes - if you want to change another part of video memory, you must change a plane.
Also i am in real mode so i switch to vesa and then switch to pmode would that harm my vesa or? :P
No, if you set VESA mode and then switch into Protected Mode, your VESA mode will be OK.
If i enabled vesa in the bios can i then just write to the video memory or do i need to do another thing?
Just look into Dex's demo code. You should understand what you need to do.
But how would i do it that if i completed my bootloader and then continue to further c coding.
You can do it. Look Bran's Kernel Tutorial and wiki for information!

Best regards,
--Andrew
tera4d
Member
Member
Posts: 37
Joined: Sun Apr 26, 2009 11:22 am

Re: Graphics

Post by tera4d »

@Troy Martin
Meh... they'll need a standard :P But ill try it with the docs provided online

@qandrew
Thank you for your answers.
Yeah i know it is in the wiki such as the page : drawing in protected mode hehe
The heat is making me ask some crazy things hehe sorry.

EDIT
I couldnt get it to work so i tried to modify just an example from BrokenThorn and even then it gave just a blackscreen.
Instead of drawing anything.
This is very strange to me could someone please take a look at the modified source for me?
http://www.xilvium.nl/d8.zip < right click->save file as. (else you will get our banner because of our .htacces against hotlinking)
Thanks.
(I must also say that my ASM skills arent that good i can understand the basic functions but nothing more as i am still learning)
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Graphics

Post by Dex »

By looking at the error mesages you will note that the lines are at the end of the file and the number is the same as is in mode_info

fasm users
rb rw rd
nasm users
resb
resw
resd
You will need to use BSS section for the mode_info part
A
3.2.2 RESB and Friends: Declaring Uninitialized Data

RESB, RESW, RESD, RESQ, REST, RESO and RESY are designed to be used in the BSS section of a module: they declare uninitialized storage space. Each takes a single operand, which is the number of bytes, words, doublewords or whatever to reserve. As stated in section 2.2.7, NASM does not support the MASM/TASM syntax of reserving uninitialized space by writing DW ? or similar things: this is what it does instead. The operand to a RESB-type pseudo-instruction is a critical expression: see section 3.8.

For example:

buffer: resb 64 ; reserve 64 bytes
wordvar: resw 1 ; reserve a word
realarray resq 10 ; array of ten reals
ymmval: resy 1 ; one YMM register
Anyway quick mod to nasm UNTESTED

Code: Select all

;************************************
; By Dex
;
; Assemble with nasm 
; c:\nasm Vesa.asm nesa.bin
;
; Use rawrite to put on floppy
; Untested
;************************************
[BITS 16]
[ORG 0x7c00]
;****************************
; Realmode startup code.
;****************************

start:
        xor   ax,ax
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   sp,0x7C00 

;****************************
; Vesa start code.
;****************************

        mov  bx,4112h           ; Replace this with 0x4115 ( for 800 x 600 ) or 0x4118 ( for 1024 x 768 ) or 0x411B ( for 1280 x 1024 )
        mov  ax,4f01h
        mov  di,Mode_Info	
        mov  cx,bx
        int  10h 
        
        mov  ax,4f02h
        int  10h

;*****************************
; Setting up, to enter pmode.
;*****************************

        cli 
        lgdt  [gdtr]
        
        mov   eax, cr0
        or    al,0x1 
        mov   cr0,eax
 
        jmp   0x10: protected

;*****************************
; Pmode. ;-)
;*****************************

[BITS 32]
protected:
        mov   ax,0x8 
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   esp,0x7C00
;*****************************
; Turn floppy off 
;*****************************

        mov   dx,3F2h
        mov   al,0
        out   dx,al

;*****************************
; Do we have 32 BitsPerPixel.
;*****************************

        cmp   byte[ModeInfo_BitsPerPixel],32
        jne   JustLoop

;*****************************
; fade background screen.
;*****************************

fade_screen:
        mov   edx,[ModeInfo_PhysBasePtr]
        mov   edi,edx
        xor   eax,eax
        mov   al,0xc5          
        xor   ebx,ebx
        mov   bl,195 
DoLoop:    
        mov   cx,640*2 
        dec   eax    

        rep   stosd
       
        dec   ebx
        jnz   DoLoop

;***********************************
; Draws the iPOD.
;***********************************

        mov   edi,236*4+640*4*125 
        add   edi,edx
Pod:
        xor   ecx,ecx
        mov   ebx,245
button2:
        mov   cl,14
        mov   al,0x2d
letsloop1:
        stosd
        add   eax,15
        loop  letsloop1
        mov   cl,130
        rep   stosd
        mov   cl,14
letsloop2:
        stosd
        sub   eax,15
        loop  letsloop2
        add   edi,640*4-158*4
        dec   ebx
        jnz   button2
       
;***********************************
; Draws the Pod window.  :-(
;***********************************

        mov   edi,263*4+640*4*143
        add   edi,edx 
PodWindow:
        mov   eax,0xffa6ffff
        xor   edx,edx
        mov   dl,65
DrawSomePixals:
        mov   cl,104
        rep   stosd
        add   edi,640*4-104*4 
        dec   edx
        jnz   DrawSomePixals

        xor   eax,eax
        mov   dl,65
DrawaLine:
        sub   edi,641*4
        stosd
        dec   edx
        jnz   DrawaLine

        mov   cl,104
        rep   stosd
JustLoop:
        jmp   $


;*************************************
; GDT. 
;*************************************

gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000
sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CF
sys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CF
gdt_end:

gdtr:	    dw gdt_end - gdt - 1	                                  
	    dd gdt 


;*************************************
; Make program 510 byte's + 0xaa55
;*************************************

resb 510 - ($ - $$) ; align at 512 bytes
dw 0xAA55



; -------------------------------------
; BSS data 
; -------------------------------------


;*************************************
; Put uninitialized data here. eg: vesa info
;*************************************

Mode_Info:		
ModeInfo_ModeAttributes		resw	1
ModeInfo_WinAAttributes		resb	1
ModeInfo_WinBAttributes		resb	1
ModeInfo_WinGranularity		resw	1
ModeInfo_WinSize		resw	1
ModeInfo_WinASegment		resw	1
ModeInfo_WinBSegment		resw	1
ModeInfo_WinFuncPtr		resd	1
ModeInfo_BytesPerScanLine	resw	1
ModeInfo_XResolution		resw	1
ModeInfo_YResolution		resw	1
ModeInfo_XCharSize		resb	1
ModeInfo_YCharSize		resb	1
ModeInfo_NumberOfPlanes		resb	1
ModeInfo_BitsPerPixel		resb	1
ModeInfo_NumberOfBanks		resb	1
ModeInfo_MemoryModel		resb	1
ModeInfo_BankSize		resb	1
ModeInfo_NumberOfImagePages	resb	1
ModeInfo_Reserved_page		resb	1
ModeInfo_RedMaskSize		resb	1
ModeInfo_RedMaskPos		resb	1
ModeInfo_GreenMaskSize		resb	1
ModeInfo_GreenMaskPos		resb	1
ModeInfo_BlueMaskSize		resb	1
ModeInfo_BlueMaskPos		resb	1
ModeInfo_ReservedMaskSize	resb	1
ModeInfo_ReservedMaskPos	resb	1
ModeInfo_DirectColorModeInfo	resb	1
; VBE 2.0 extensions
ModeInfo_PhysBasePtr		resd	1
ModeInfo_OffScreenMemOffset	resd	1
ModeInfo_OffScreenMemSize	resw	1


Modes are
;0x4112 = 640 , 480 , 32bpp
;0x4115 = 800 , 600 , 32bpp
;0x4118 = 1024 , 768 , ,32bpp
;0x411B = 1280 ,1024 , 32bpp
NOTE: If you change mode number, the GUI wll not be drawn right and you will need to enable A20 or you will have the bottom half of screen mising.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Graphics

Post by Dex »

i586coder wrote:awesome code Dex =D>
Thanks i586coder, you should see the full one (still fits into 512b) because it includes a CdPlayer .
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: Graphics

Post by quanganht »

This topic should be sticky'd
"Programmers are tools for converting caffeine into code."
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Graphics

Post by neon »

quanganht wrote:This topic should be sticky'd
Im not sure about that. All of the information for Vesa is already available via the VBE specs and the Wiki. I just do not see a need for it.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
tera4d
Member
Member
Posts: 37
Joined: Sun Apr 26, 2009 11:22 am

Re: Graphics

Post by tera4d »

Thank you all very much for your great help!

I finally did the switch to vesa 1024x768 thanks to Dex !
Thank you dex for your great explanation and conversion to nasm.

But as always i again have a problem =(
*Sigh* shoot me for asking so much :P
I looked through the wiki for and i did the article on drawing in protected mode.
The putpixel function worked and so does the fillrect function.
But i cant seem to fill the whole screen.
I can only draw on the top 30 pixels or something but i can draw over the WHOLE WIDTH.
Does that has anything to do with my video mode or?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Graphics

Post by Brendan »

Hi,
tera4d wrote:I finally did the switch to vesa 1024x768 thanks to Dex !
tera4d wrote:I can only draw on the top 30 pixels or something but i can draw over the WHOLE WIDTH.
Does that has anything to do with my video mode or?
I'm guessing that you're using "15 bits per pixel" or "16 bits per pixel", and that you're writing pixels to the area at 0x000A0000. The only reason I have for this guess is that "1024 pixels per line * 32 lines * 2 bytes per pixel" works out to 64 KiB, which is exactly how large the area at 0x000A0000 is.

If this guess is right, then to access more pixels you need to use bank switching (where different parts of display memory are mapped into the area at 0x000A0000 where you can access them); or setup a linear frame buffer (where you can access all of the display memory without bank switching at a different address, like from 0xE0000000 to 0xE8000000, but the address depends on a lot of things).

For bank switching there's VBE functions to change banks, which can be a problem when your OS is in protected mode and can't switch banks. To get around that there's 2 protected mode interfaces, one for VBE 2 and a different one for VBE 3. For setting up a linear frame buffer you need to check that the video card supports it for the mode you're using (there's a flag in the mode information data that "VBE FUNCTION 01H - RETURN VBE MODE INFORMATION" returns) and you need to set the corresponding flag (bit 14 in BX) when you set the video mode.

There's probably other things I should mention.

First, old versions of VBE had fixed mode numbers (for e.g. where you can assume that video mode number 0x104 is "1024 * 768 * 16 bits per pixel"). For VBE2 and later, this became optional and you can't rely on it anymore (e.g. video mode number 0x104 might be anything, and "1024 * 768 * 16 bits per pixel" could be a different video mode number).

Some video cards don't support "16 bits per pixel" formats - instead they might support "15 bits per pixel". Most cards support 15 bpp or 16 bpp but not both. The same is true for 24 bpp and 32 bpp. Also, for most video cards pixels are RGB but a few older video cards use BGR instead. To complicate things more, for some video cards, in 15 bpp modes the highest bit is actually used for something (e.g. to select a colour from the palette that's normally only used in 8 bpp modes). If you don't check, then you could end up getting all the colours wrong.

Also, what are you going to do if the video card doesn't support any 1024 * 768 video modes?

For reasonably reliable code, you must:
  • Support a wide variety of resolutions and pixel formats (e.g. 8 bpp, 15 bpp, 16 bpp, 24 bpp and 32 bpp)
  • Use "VBE FUNCTION 00H - RETURN VBE CONTROLLER INFORMATION" to get a list of all video mode numbers
  • Check the details for each video mode (returned by "VBE FUNCTION 01H - RETURN VBE MODE INFORMATION") to see if your code will support it or not (and find out what resolution and pixel format/colour depth, and if LFB is supported, etc).
  • Decide which video mode you want to use (based on the details for each video mode, and what your code can support)
  • Never set any video mode with a resolution that's higher than 640 * 480 without the user's permission
Also, just because a video card supports a certain video mode doesn't mean that the monitor also supports that video mode. If you use a high resolution video mode like 1024 * 768 then it might work, but the monitor might not support it and you might get a black screen, a black screen with some sort of message on it (e.g. "Horizontal sync out of range"), or a strange flickering screen; and in some cases (usually old "VGA only" monitors) you can blow the monitor up. To make this worse it does depend on timing signals, and it's possible (for e.g.) to have a video card that generate signals for 1024 * 768 @ 75 Hz and a monitor that only supports 1024 * 768 @ 60 Hz; where both the video card and the monitor support the resolution but it still doesn't work. In all of these cases, VBE will tell you that it set the video mode correctly (no error messages or anything) and you won't know if it's actually working or not (for all you know, the monitor may have exploded and set the user's desk on fire, but VBE will say it worked fine).

It is possible (for most video cards and most monitors) to find out which video modes the monitor does support. This is called EDID (Extended Display Information Data), where you ask the video card to get the EDID and the video card returns one or more blocks of data that you need to parse to find out what the monitor does/doesn't support. It's complicated, but it's the only way to make sure that the monitor supports the video mode you intend to use. Unfortunately VBE normally doesn't give you enough information to be entirely sure that a video mode will work (VBE won't tell you timing information), but you can use EDID to estimate how likely it is that a video mode will work, and on some video cards it's also possible to use "CRTC Info" when setting the video mode to force the video card into using timings that you know the monitor definitely does support.

For extremely reliable code, you could:
  • Support a wide variety of resolutions and pixel formats (e.g. 8 bpp, 15 bpp, 16 bpp, 24 bpp and 32 bpp)
  • Use "VBE FUNCTION 15H SUBFUNCTION 01H - GET EDID" to get the EDID for the monitor
  • Parse the EDID and set variables, etc that indicate the monitors capabilities (and, if EDID wasn't supported just set these variables, etc to "standard VGA" values)
  • Use "VBE FUNCTION 00H - RETURN VBE CONTROLLER INFORMATION" to get a list of all video mode numbers
  • Check the details for each video mode (returned by "VBE FUNCTION 01H - RETURN VBE MODE INFORMATION") to see if your code will support it or not *and* estimate the chance that the monitor will support it or not
  • Decide which video mode you want to use (based on the details for each video mode, and what your code and the monitor supports)
  • Never set any video mode with a resolution that's higher than 640 * 480 without the user's permission *unless* the EDID information has allowed you to be very confident that the monitor does support the video mode
Almost all good programmers use the first method (without EDID), because it's a lot easier. I implemented the second method in my boot code (partly because I don't want to ask the user anything if it's possible to avoid it).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Graphics

Post by Dex »

Dex wrote: NOTE: If you change mode number, the GUI wll not be drawn right and you will need to enable A20 or you will have the bottom half of screen mising.
You did enable the A20 ?, as i did warn you of the problem, that res is 3MB for that screen size, So you must enable it ;) .
Locked