Page 2 of 4

Posted: Wed Mar 05, 2008 9:49 am
by lukem95
nice idea :)

on a side note (hint hint) i still can't edit the wiki because of my username. if a mod would kindly change it and pm me? :D

Posted: Fri Mar 07, 2008 9:42 am
by Philip
Combuster wrote:There's still the v8086 option.

But if you really do *not* want to rely on the bios, you'll have to write your own drivers. For each card.
yeah, just thinking of writing driver for each card already makes me shivering
btw, how are you developing your os anyway? still writing drivers? :D

Posted: Fri Mar 07, 2008 12:50 pm
by lukem95
Well writing drivers is really the only way to get the best out of cards, even if it is only drivers for specific features.

I'm going to implement a basic (either VGA or drop back to real mode and set up VESA using BIOS) gui, and then from there have a network download for the card driver (if available). well... if i ever get to that point.

Posted: Fri Mar 07, 2008 9:38 pm
by Philip
i think dropping back to real mode to use vesa isn't a option,
anybody here can start a high resolution graphic mode without using vesa in protected mode?

Posted: Fri Mar 07, 2008 10:56 pm
by Dex
You can
1. change vesa mode in realmode on bootup and stay in that mode :) .
2. implement a v86 :(.
3. write driver for all graphic cards :( .
4. go to and from realmode for vesa mode changing :) .
5. Theres also a pmode vesa3 interface, that no one has got working and means you need to go to 16bit pm (which is half way to realmode) :( .

Here a simple vesa demo that show's mode switch by going to and from realmode to pmode.
Just in case you change you mind, when you find the others not to your liking.

http://www.dex4u.com/demos/VesaDemo.zip

Posted: Sat Mar 08, 2008 2:22 am
by Philip
Dex wrote:You can
1. change vesa mode in realmode on bootup and stay in that mode :) .
2. implement a v86 :(.
3. write driver for all graphic cards :( .
4. go to and from realmode for vesa mode changing :) .
5. Theres also a pmode vesa3 interface, that no one has got working and means you need to go to 16bit pm (which is half way to realmode) :( .

Here a simple vesa demo that show's mode switch by going to and from realmode to pmode.
Just in case you change you mind, when you find the others not to your liking.

http://www.dex4u.com/demos/VesaDemo.zip
i find option no 1 is interesting,
set the video mode using vesa in real mode,
then go to protected mode
but in protected mode, how to access more than 64k at 0:A0000?

Posted: Sat Mar 08, 2008 9:15 am
by lukem95
xor edi,edi ; We make shore edi 0.
oh dear Dex. Shore?

:D

Posted: Sat Mar 08, 2008 11:51 am
by Dex
Philip wrote:
Dex wrote:You can
1. change vesa mode in realmode on bootup and stay in that mode :) .
2. implement a v86 :(.
3. write driver for all graphic cards :( .
4. go to and from realmode for vesa mode changing :) .
5. Theres also a pmode vesa3 interface, that no one has got working and means you need to go to 16bit pm (which is half way to realmode) :( .

Here a simple vesa demo that show's mode switch by going to and from realmode to pmode.
Just in case you change you mind, when you find the others not to your liking.

http://www.dex4u.com/demos/VesaDemo.zip
i find option no 1 is interesting,
set the video mode using vesa in real mode,
then go to protected mode
but in protected mode, how to access more than 64k at 0:A0000?
If your vesa is vesa2 or above it most likley has LFB linear frame buffer which is a pointer that you can use from pmode, without any 64k limit.
First you test for vesa

Code: Select all

	;------------------------------------------------------------
	; Purpose: Checks to see if VESA is available and if the desired mode is
	; available.
	; Inputs:  None
	; Outputs: VESAInfo and VESA_Info structures filled (if successful)
	;------------------------------------------------------------
	mov   dword [VESAInfo_Signature],'VBE2'
	mov   ax,4f00h			       ; Is Vesa installed ?
	mov   di,VESA_Info		       ; This is the address of how info block.
	int   10h


	cmp   ax,004Fh			       ; Is vesa installed ?,
	jne   near NoVesa2		       ; If not print a mesage & quit.
Then if available, we fill the vesa info out and test for the mode we want and if vesa 2 is available.

Code: Select all

	mov   ax,4f01h			       ; Get Vesa Mode information.
	mov   di,Mode_Info		       ; This is the address of how info block.
	mov   cx,0x4112 		       ; 4112h = 640*480 24/32bpp
	and   cx,0xfff
	int   10h

	cmp   dword [VESAInfo_Signature], 'VESA'
	jne   near NoVesa2

	cmp   byte [VESAInfo_Version+1], 2
	jb    NoVesa2			       ; VESA version below 2.0
If they are, we can set the mode

Code: Select all

	mov   ax,4f02h			       ; set vesa screen mode
	mov   bx,0x4112 		       ; 4112h = 32/24bit
	int   10h 
Now we can go to pmode, set A20 and if you do not use paging you can use the info from the VESAInfo strut to use vesa, as easy as say mode 13h in the old dos days.
The VESAInfo strut is layout like this:

Code: Select all

;=========================================================;
; Vesa Information Block                         11/12/03 ;
;---------------------------------------------------------;
; DOS EXTREME OS V0.01                                    ;
; (Now called DexOS)                                      ;
;                                                         ;
;=========================================================;

;-------------------------------- FASM VESA INFORMATION BLOCK -----------------------------------

VESA_Info:
VESAInfo_Signature		rb	4      ; VBE Signature
VESAInfo_Version		rw	1      ; VBE Version
VESAInfo_OEMStringPtr		rd	1      ; VbeFarPtr to OEM String
VESAInfo_Capabilities		rb	4      ; Capabilities of graphics controller
VESAInfo_VideoModePtr		rd	1      ; VbeFarPtr to VideoModeList
VESAInfo_TotalMemory		rw	1      ; Number of 64kb memory blocks
VESAInfo_OEMSoftwareRev 	rw	1      ; VBE implementation Software revision
VESAInfo_OEMVendorNamePtr	rd	1      ; VbeFarPtr to Vendor Name String
VESAInfo_OEMProductNamePtr	rd	1      ; VbeFarPtr to Product Name String
VESAInfo_OEMProductRevPtr	rd	1      ; VbeFarPtr to Product Revision String
VESAInfo_Reserved		rb	222    ; Reserved for VBE implementation scratch area
VESAInfo_OEMData		rb	256    ; Data Area for OEM Strings

;============================== VESA MODE INFORMATION ===========================================

Mode_Info:
ModeInfo_ModeAttributes 	rw	1      ; mode attributes
ModeInfo_WinAAttributes 	rb	1      ; window A attributes
ModeInfo_WinBAttributes 	rb	1      ; window B attributes
ModeInfo_WinGranularity 	rw	1      ; window granularity
ModeInfo_WinSize		rw	1      ; window size
ModeInfo_WinASegment		rw	1      ; window A start segment
ModeInfo_WinBSegment		rw	1      ; window B start segment
ModeInfo_WinFuncPtr		rd	1      ; real mode pointer to window function
ModeInfo_BytesPerScanLine	rw	1      ; bytes per scan line
ModeInfo_XResolution		rw	1      ; horizontal resolution in pixels or characters
ModeInfo_YResolution		rw	1      ; vertical resolution in pixels or characters
ModeInfo_XCharSize		rb	1      ; character cell width in pixels
ModeInfo_YCharSize		rb	1      ; character cell height in pixels
ModeInfo_NumberOfPlanes 	rb	1      ; number of memory planes
ModeInfo_BitsPerPixel		rb	1      ; bits per pixel
ModeInfo_NumberOfBanks		rb	1      ; number of banks
ModeInfo_MemoryModel		rb	1      ; memory model type
ModeInfo_BankSize		rb	1      ; bank size in KB
ModeInfo_NumberOfImagePages	rb	1      ; number of images
ModeInfo_Reserved_page		rb	1      ; reserved for page function
ModeInfo_RedMaskSize		rb	1      ; size of direct color red mask in bits
ModeInfo_RedMaskPos		rb	1      ; bit position of lsb of red mask
ModeInfo_GreenMaskSize		rb	1      ; size of direct color green mask in bits
ModeInfo_GreenMaskPos		rb	1      ; bit position of lsb of green mask
ModeInfo_BlueMaskSize		rb	1      ; size of direct color blue mask in bits
ModeInfo_BlueMaskPos		rb	1      ; bit position of lsb of blue mask
ModeInfo_ReservedMaskSize	rb	1      ; size of direct color reserved mask in bits
ModeInfo_ReservedMaskPos	rb	1      ; bit position of lsb of reserved mask
ModeInfo_DirectColorModeInfo	rb	1      ; direct color mode attributes
; VBE 2.0 extensions
ModeInfo_PhysBasePtr		rd	1      ; *physical address for flat memory frame buffer*
ModeInfo_OffScreenMemOffset	rd	1      ; Reserved - always set to 0
ModeInfo_OffScreenMemSize	rw	1      ; Reserved - always set to 0
; VBE 3.0 extensions
ModeInfo_LinBytesPerScanLine	rw	1      ; bytes per scan line for linear modes
ModeInfo_BnkNumberOfPages	rb	1      ; number of images for banked modes
ModeInfo_LinNumberOfPages	rb	1      ; number of images for linear modes
ModeInfo_LinRedMaskSize 	rb	1      ; size of direct color red mask (linear modes)
ModeInfo_LinRedFieldPos 	rb	1      ; bit position of lsb of red mask (linear modes)
ModeInfo_LinGreenMaskSize	rb	1      ; size of direct color green mask (linear modes)
ModeInfo_LinGreenFieldPos	rb	1      ; bit position of lsb of green mask (linear modes)
ModeInfo_LinBlueMaskSize	rb	1      ; size of direct color blue mask (linear modes)
ModeInfo_LinBlueFieldPos	rb	1      ; bit position of lsb of blue mask (linear modes)
ModeInfo_LinRsvdMaskSize	rb	1      ; size of direct color reserved mask (linear modes)
ModeInfo_LinRsvdFieldPos	rb	1      ; bit position of lsb of reserved mask (linear modes)
ModeInfo_MaxPixelClock		rd	1      ; maximum pixel clock (in Hz) for graphics mode
; Reserved
ModeInfo_Reserved		rb	190    ; remainder of ModeInfoBlock
Now to fill the screen in pmode you would do this:

Code: Select all

render_screen:

	mov   ax,linear_sel		       ; This is so we have a linear descriptor.
	mov   es,ax
	mov   edi,[ModeInfo_PhysBasePtr]       ; **See in the VESA INFORMATION BLOCK for this var
	mov   ecx,640*480		       ; Size of screen, you should really get the size from "ModeInfo_XResolution" and "ModeInfo_YResolution"  
	mov   eax,0xffffffff		       ; This is for the color of one pixel(note: this could be 24bit or 32bit)
	rep   stosd
	ret
Of cause if you are using paging you will need to map the LFB etc, but i will leave that to you to workout.
lukem_95 wrote:
xor edi,edi ; We make shore edi 0.
oh dear Dex. Shore?

:D
OK, so i am a bad speller, maybe that's why i like ASM.

Posted: Sat Mar 08, 2008 1:19 pm
by lukem95
:)

nice code explanation too btw

Posted: Sun Mar 09, 2008 12:02 am
by Philip
thanks dex for the code, very useful
that means in protected mode, vesa can be used?
dex, do you have documents about using vesa in protected mode?
would you please send to me [email protected]
thank you so so much :)

Posted: Sun Mar 09, 2008 7:51 am
by lukem95
using VESA in pmode is the same as using it in rmode really, if you set it up to use LFB (linear frame buffer) then you can just use memcpy's to plot pixels to the screen.

you only really need the bios for switching modes, and bank switches

Posted: Sun Mar 09, 2008 8:11 am
by jal
Philip wrote:thanks dex for the code, very useful
that means in protected mode, vesa can be used?
dex, do you have documents about using vesa in protected mode?
would you please send to me [email protected]
thank you so so much :)
1) There's plenty of documentation available, just look in the Wiki and Google.
2) It is very stupid having your e-mail address on a forum, expect being heavily spammed!


JAL

Posted: Sun Mar 09, 2008 12:58 pm
by Dex
Yes, as pointed out, once you set mode and fill the vesa info block in realmode, you can use the LFB and info from the vesa info block to write to the screen.
Its a simple case of what 32 or 24 bits you write to the LFB will come out on screen up to the size of screen.
Note: in 32bit mode, some cards use 24bpp and other's use 32bpp, you need to check in the vesa info block and used differant code.
As 24bpp are RRGGBBRRGGBB..
and 32bpp are 00RRGGBB00RRGGBB..

Anyway the best doc i found is this:
http://passxos.googlecode.com/files/vbe3.pdf

Posted: Mon Mar 10, 2008 1:36 am
by eddyb
i found some ports informations about XGA(big resolutions and 65536 colors)...
maybe this help u...

PS this is XGA.TXT from vgadocs. can i attach it?

Posted: Mon Mar 10, 2008 2:07 am
by Philip
yeah eddy, that would be very useful -- the information about ports to control the screen, please attach :)