Bitmap (BMP) Files
A type of storage of data for graphic files.
Looking at bitmap.asm (Irvine Chap 12.5)
Header[00,01] first 2 bytes - BMP ID (“BM”)
Header[0Ah] – position 10 – length (header+graphics)
- subtract 54 (length of header)
- divide by 4 to get the # of colors in BMP
- each palette entry is 4 bytes long
o B,G,R,Null
- (2 bytes copied to PalSize)
Header[12h] – position 18 – Horizontal Resolution
(2 bytes copied to BMPWidth)
Header[16h] – position 22 – Vertical Resolution
(2 bytes copied to BMPHeight)
Video mode set to 13h – 320x200x256
address 0A00h is used as video segment (stored as ES)
Int 21h, function 3F –
used to copy the palette into the PAL buffer-ReadPal
Palette sent from buffer to video registers -SendPal
Colors in BMP file are saved as BGR values rather than
RGB values. We need to read them in and write to video
registers as RGB.
Send 1 byte out port 03C8h
Then send data out port 03C9h
Assuming old video cards that only allow 64 colors
1. shift max values for color right by 2
2. divide by 4 (256/4 = 64) allows 64 different
colors (note this is .186 code)
BMP graphics are stored upside down, displaying the lines
from bottom to top. The line at which it starts is based on
the vertical resolution, so the upper left corner of the grahic
will always be at the upper left corner of the screen.
Video memory is a two-dimensional array of memory bytes
which can be addressed and modified individually. File is
read one graphics line at a time, tends to slow the program
down.