Bochs VBE Extensions: Difference between revisions

[unchecked revision][unchecked revision]
(added some information, removing some todos as I did the tests)
(→‎Memory layout of video modes: Adding information)
Line 54:
=== Memory layout of video modes ===
 
In all modes the first byte represents the top left of the screen. A formula to calculate the video memory offset from a pixel coordinate is: <tt>offset = (Y * X-resolution + X) * <some-factor></tt>. The factor varies using the different bit depths. The 4 and 8 BPP modes are palette modes. Read more about programming the attribute controller and DAC palettes in [[VGA documents]]. The other modes are using the colour value directly.
For 24 BPP, the order of the colour components is blue first, then green, then red.
 
In 4 BPP you have 16 colours. The pixel colour is used an index to the attribute controller, which again points to the DAC, which in turn gives an 18 bit colour (6 bits each for red, green and blue) that is shown. The memory is layout like this: The first byte is the colour bit 0 of pixels 0-7. The second byte is the colour bit 1 of pixels 0-7, and so forth. You can access 8 pixels at a time using longwords (32 bits).
[I'm about to add info on the other modes. --[[User:Walling|Walling]] 05:57, 26 October 2008 (UTC)]
 
[[Image:Linear video memory layout 4bpp.png]]
 
In 8 BPP you have 256 colours. The pixel colour is sent to the DAC, which gives an 18 bit colour that is shown. The memory layout is very simple. Each pixel is exactly one byte.
 
[[Image:Linear video memory layout 8bpp.png]]
 
In 15 BPP each pixel is easiest accessed as words (16 bits). There are 5 bits each colour component and the last bit is ignored.
 
[[Image:Linear video memory layout 15bpp.png]]
 
In 16 BPP each pixel is easiest accessed as words (16 bits). There are 5 bits for the red and blue components and 6 bits for green. This makes sense, because the human eye is more sensitive to green colours.
 
[[Image:Linear video memory layout 16bpp.png]]
 
ForIn 24 BPP, theeach orderpixel ofis the3 bytes. There is one byte for each component. The colour components is blue first, then green, then red.
 
[[Image:Linear video memory layout 24bpp.png]]
 
In 32 BPP each pixel is 4 bytes and easiest accessed as longwords (32 bits). The fourth byte is ignored. The colour components is layout like in 24 BPP. Accessing pixels as longwords the colour should be defined as 0x00RRGGBB.
 
[[Image:Linear video memory layout 32bpp.png]]
 
=== Using banked mode ===
Anonymous user