I did a search on my archives, and I've found this code (see attachment). It sets VGA modes without using the BIOS.
Just for the records, the only standard resolution with 256 colors on VGA is 320x200. There's a trick to use 320x240, but that's all. The reason is because there's no more video RAM to handle larger resolutions. 640x480 and 800x600 are 16 colors only to fit into 64k. (320 * 200 * 8 bit = 64k, and the standard 80x25 text mode is 9*80x16*25 = 720x400 pixels)
To support higher resolutions with 256 colors, you'll need SVGA. There you can only access 64k at once too, but you have a so called "bank" function which selects a window on a larger video RAM (meaning you can access different segments at 0xA0000 depending which bank is used). Unfortunately the banking function is manufacturer specific and not standardized as the other VGA registers.
For higher resolutions and packed pixels (hicolor or truecolor), you'll need VESA which is not VGA. VESA is only standardized at BIOS int interface level, so either you write a native video card driver or you need to use the BIOS. This mode uses so called linear framebuffer, which is not mapped at 0xA0000, therefore it's not limited to 64k. The buffer is contiguous, and can be arbitrary large.
Cheers,
bzt
VGA programming problems
Re: VGA programming problems
- Attachments
-
- vgamodes.c
- (62.36 KiB) Downloaded 118 times
-
- Member
- Posts: 5572
- Joined: Mon Mar 25, 2013 7:01 pm
Re: VGA programming problems
Changing the mode involves changing the palette controller. Disassemble any VGA option ROM and see for yourself.bzt wrote:No, of course you don't need to change the palette controller. What you need to change is the mode.
Correct. When did I say the 64-color palette was a limitation of the hardware? The palette controller is simply programmed to output only 64 unique colors. In 16-color modes, the attribute controller can only select 16 of the palette controller's 256 entries.bzt wrote:For VGA you can have either a mode with 16 colors, or with 256 colors, no other options exists
Video modes set using the VGA ROM are designed to be register-compatible with EGA, if the mode existed on EGA. EGA allows you to select 16 out of a total of 64 colors via the attribute controller. In order for that to work on VGA, the VGA ROM must program the palette controller to produce the 64 EGA colors. Disassemble any VGA option ROM and see for yourself.bzt wrote:(there's no such thing as 64 color mode, and BIOS was never programmed to produce 64 EGA colors.
Minus zero degrees has a few VGA ROMs if you're not sure where to look.
Re: VGA programming problems
Nope, the code I've attached to my previous post changes modes but it does not touch any DAC registers. It even has a comment on the top, "To do: do something with 16- and 256-color palettes?"Octocontrabass wrote:Changing the mode involves changing the palette controller.
No, they weren't. The modes were designed to use the same buffer layout, but not registers. (And FYI while EGA had two buffers for two monitors, VGA had only one buffer for a single monitor). The EGA palette registers had 2 bits per color channels, while VGA had 6 bits, so it cannot be register-compatible. Converting EGA channel values to VGA channel values requires SHL 4. See IBM EGA specification, page 12 section Registers.Octocontrabass wrote:Video modes set using the VGA ROM are designed to be register-compatible with EGA
Where did you get that "must produce the 64 EGA colors" thing? Would you mind sharing a link with us? By default, the first 16 (and only 16, not 64) VGA palette entries are configured to match the default 16 EGA colors. End of story.Octocontrabass wrote:In order for that to work on VGA, the VGA ROM must program the palette controller to produce the 64 EGA colors.
Believe it or not, I actually did disassemble many video ROMs back in the day. Mostly SVGA ROMs, to reverse engineer their banking routine and additional register set. I wrote an SVGA assembly library for DOS with native drivers, years before VESA got widespread. Later I rewrote that library with VESA, and I've posted a screenshot of that rewrite on this forum (huh, that post was 8 years ago, and the rewrite was in 1998).Octocontrabass wrote:Disassemble any VGA option ROM and see for yourself.
But please, this conversation is going nowhere, and it definitely does not help the OP. No matter how many times you write "64 EGA colors", that won't make it true.
Cheers,
bzt
-
- Member
- Posts: 5572
- Joined: Mon Mar 25, 2013 7:01 pm
Re: VGA programming problems
Where did you hear this? Last I checked, EGA can only drive one monitor at a time. It is possible to install a CGA or MDA to attach a second monitor, but VGA supports that too. (I've even seen one PCI chipset that routes MDA I/O independently from the other VGA-related I/O to allow installing a PCI VGA alongside an ISA MDA, although I don't know how well it works.)bzt wrote:(And FYI while EGA had two buffers for two monitors, VGA had only one buffer for a single monitor).
Those are the attribute controller palette registers, which are the same for both EGA and VGA. VGA also has a second set of palette registers in the DAC, which converts the indices programmed into the attribute controller's palette into colors. The VGA attribute controller's palette is compatible with EGA only when the DAC palette is programmed to produce EGA colors.bzt wrote:The EGA palette registers had 2 bits per color channels, while VGA had 6 bits, so it cannot be register-compatible. Converting EGA channel values to VGA channel values requires SHL 4. See IBM EGA specification, page 12 section Registers.
Here's a link. Look at the "Color Paging with the Color Select Register" section.bzt wrote:Where did you get that "must produce the 64 EGA colors" thing? Would you mind sharing a link with us? By default, the first 16 (and only 16, not 64) VGA palette entries are configured to match the default 16 EGA colors. End of story.
Re: VGA programming problems
To settle this, from Wikipedia:
Wikipedia wrote:EGA produces a display of up to 16 colors (using a fixed palette, or one selected from a gamut of 64 colors, depending on mode) at several resolutions up to 640×350 pixels, as well as two monochrome modes at higher resolutions. EGA cards include a ROM to extend the system BIOS for additional graphics functions, and a custom CRT controller (CRTC).]