Planes in mode 0x13? (320x200x256 VGA)
Posted: Tue Feb 21, 2012 3:26 pm
I'm moving my bootloader/kernel over to VGA output, however I'm encountering some errors. Whenever I try to plot a pixel, I end up getting four pixels evenly spaced and in the wrong location. I believe this has something to do with plane switching, but from my understanding mode 0x13 uses a consecutive memory for consecutive pixels. I'm sure it's something simple I'm missing, but figured I'd try and get fresh eyes looking at it.
I set the video mode using this:
and plot a pixel using this:
This is what I get as output for plotting a pixel at (24, 34) which is odd because there should be 200 addressable (Y) pixels, yet there are only 50 available on screen.
EDIT: Forgot to mention I'm using Boch's for emulation
I set the video mode using this:
Code: Select all
mov ax, 0x0013
int 0x10
Code: Select all
;--------------------------------------------------------------
; plotPixel
; Prints a pixel to the screen at a given location
; inputs:
; RAX: Y location
; RBX: X location
;--------------------------------------------------------------
plotPixel:
; [x + y * width] = color
push rdi
mov rdi, VIDEO_COLUMNS
mul rdi ; AX = Y * VIDEO_COLUMNS
add ax, bx ; AX = (Y * VIDEO_COLUMNS) + X
mov rdi, rax
add edi, DWORD [videoMemory]
mov al, BYTE [currentTextColor]
stosb
pop rdi
ret
EDIT: Forgot to mention I'm using Boch's for emulation