if the data value > 0xc0, then (data value - 0xc0 ) is the
repeate time of color value,
the color value is the next byte,
else color value is current byte
*/
int dp=0;
int rept=0;
for (i=0,dp=0;dp < count;i++)
{
rept=pHeader->data[i]-0xc0;
if ( rept >0 )
{
// repeate next byte (x-0xc0) times
i++;
for (j=0; j<rept; j++,dp++ )
{
// load color data
decode->data[dp] = pHeader->data[i];
}
}
else //loader color value
{
decode->data[dp] = pHeader->data[i];
dp++;
}
} //end load color
Load Bitmaps (16-bit ASM)
.model small
.stack 100h
_DATA segment word public 'DATA'
filename db 'C:\bmp\UNITS.BMP',0 ; insert the name and location
GLEN db 'Programmed by Glen Quinn, BINARY SOFTWARE' ; of the bitmap here
db '$'
handle dw ? ; handle is used to store the file pointer
X dw ? ; X and Y is used to fill the screen with pixels
Y dw ?
col db 640 dup(?) ; col is used as a buffer to do a screen line
; at a time
buff dw 0
dw 0
dw 0
dw 0
multi dw 6
dw 4
dw 0
dw 0
num dw 0
y dw 409 ; y is used to store where the banks break up
dw 408
dw 307
dw 306
dw 204
dw 203
dw 102
dw 101
RGBQUAD struc ; This is how the bitmap stores its colours
blue db ?
green db ?
red db ?
fill db ?
RGBQUAD ends
params BMPHEAD <> ; assigning the structures to these values
param RGBQUAD <>
_DATA ends
.code
start:
mov ax,@data ; moving all data into required memory position
mov ds,ax
call loadbmp ; calls a procedure called loadbmp
mov ah,00h ; waits for a key to be pressed
int 16h
mov ah,00h ; changes the video mode to the normal setting
mov al,02h
int 10h
mov ah,09h ; Prints out a message on the screen
mov dx,offset GLEN
int 21h
mov ah,4ch ; ends the program
mov al,0
int 21h
putpixel proc near ; this procedure is for putting a single pixel any
; where on the display plane
; The linear address of the display plane is=y*640+x
mov ax,Y ; calculating linear=y*640 in 16-bit
mul multi
mov buff,ax ; first 16-bit calculation
mov ax,100
mul buff
mov buff,ax
mov buff+2,dx
mov ax,Y ; secound 16-bit calculation
mul multi+2
mov buff+4,ax
mov ax,10
mul buff+4
mov buff+4,ax
mov buff+6,dx
mov ax,buff ; now adding the two 16-bit values
add ax,buff+4
mov buff,ax
mov ax,buff+2
adc ax,buff+6
mov buff+2,ax
mov ax,X ; now adding x to the expression
add buff,ax
adc buff+2,0 ; expression is now lin=y*640+x
mov ax,buff
mov dx,buff+2
mov cx,16 ; calculating bank number
F1: sar dx,1
rcr ax,1
loop F1
mov num,ax
mov ax,y ; testing each of the bank boundaries
cmp ax,Y
je pass
mov ax,y+2
cmp ax,Y
je pass
mov ax,y+4
cmp ax,Y
je pass
mov ax,y+6
cmp ax,Y
je pass
mov ax,y+8
cmp ax,Y
je pass
mov ax,y+10
cmp ax,Y
je pass
mov ax,y+12
cmp ax,Y
je pass
mov ax,y+14
cmp ax,Y
jne bypass
pass:
mov ah,4fh ; adjusting the bank
mov al,05h
mov bh,00h
mov bl,00h
mov dx,num
int 10h
bypass:
mov ax,0A000h ;writing a single pixel to the display
mov es,ax
mov ax,buff
mov di,ax
mov al,[si]
stosb ; writing pixel ends
inc si
ret
endp
loadbmp proc near ;this procedure is for loading in the bitmap
mov ah,4fh ; set mode to SVGA (101h i.e 640X480 in 256 colours
mov al,02h
mov bx,101h
int 10h