Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
One thing to be aware of is one byte does not represent 2 pixels; it represents 8. Every time you write to the video memory in 16 color mode each individual bit corresponds to one pixel, and it is written to one or more color planes. (By default you'll be writing to all 4 planes).
This function will set which plane you read from and which plane(s) you write to:
setcolorplane:
;ah = plane to read from (0-3)
;al = planes to write to (0-15)
push dx
push ax
mov dx, 3c4h
mov al, 2
out dx, al
mov dx, 3c5h
pop ax
push ax
out dx, al ;set plane to write to
mov dx, 3ceh
mov al, 4; read map select register
out dx, al
mov dx, 3cfh
;pop ax
;push ax
mov al, ah ;get plane to read
out dx, al
pop ax
pop dx
ret
Plus, again, bitmaps are upside-down. Read it in line-by-line and flip it. Or, as I've done, seek to the end minus one line, read a line, seek back 2 lines, read a line etc.