Vesa BIOS Example. Page 6: Plotting Pixels in SVGA

VESA BIOS Example

Page 6: Plotting Pixels in SVGA


Right, this can be tricky. There's lots of horrid Bank Switching and stuff, and moving these windows around. I'll assume for the moment that we're plotting 256 colour pixels.

If you just want to plot a single pixel, the process requires several steps:
1. Calculate the Memory location of the pixel
2. Calculate the Required Window position
3. Switch to the Bank
4. Calculate the memory offset of the pixel from the start of the bank.
5. write the pixel to the screen.

This is much easier in a flat memory mode.

There are a few Global variables that this procedure will need when calculating things. If you don't like global variables, then you can figure out the cute little message passing stuff yourself.

   BytesPerScanline	; the number of bytes used per scanline. see page 5
   WinGranularity	; the accuracy to which a memory window can be positioned see page 0
   CurrentWindowPos	; the current position of the Write Window (in granularity units). 
			  If it's already in the right position, we won't bother to move it.
OK, i'll explain how to perform each step in turn to plot a pixel at (x, y):

Step 1: Calculate the Memory location of the pixel

If you are writing this in assembler, then you will need to use the extended registers (eax, ebx etc) to calculate the memory position, because it may well be higher than 65535. If you are writing it in a high level language, then the variable type will probably be called LONG or DOUBLE or something.

	MemoryPosition = (BytesPerScanLine * y) + x
That's simple enough.

Step 2: Calculate the Required Window position

	WindowPosition = MemoryPosition / WinGranularity

Step 3: Move the Window into that position

	SetWindowPosition(WindowPosition)
	CurrentWindowPos = WindowPosition

Step 4: Calculate address of pixel within window

	PixelOffset = MemoryPosition - (WinGranularity * WindowPosition)

Step 5: Write The pixel

	Write a byte at [PixelOffset]