feat: bibliotheque gerant les fichier BMP

This commit is contained in:
Nicolas Hordé 2004-11-30 19:28:32 +00:00
parent 306c0ed771
commit 8025aca688
1 changed files with 108 additions and 0 deletions

108
lib/bmp.asm Normal file
View File

@ -0,0 +1,108 @@
.model tiny
.486
smart
locals
.code
org 0h
include ..\include\mem.h
include ..\include\bmp.h
start:
header exe <,1,0,,,,offset exports,>
exports:
db "showbmp",0
dw showbmp
db "loadbmppalet",0
dw loadbmppalet
dw 0
;==========SHOWBMP=========
;Affiche le BMP pointée par DS:%0 en %1, %2
;<- DS:%0 BMP, %1 coordonnées X, %2 coordonnées Y
;->
;==========================
showbmp PROC FAR
ARG pointer:word, x:word, y:word=taille
push bp
mov bp,sp
push ax bx cx si di
mov si,[pointer]
cmp word ptr [si+BMP_file.BMP_FileType],"MB"
jne @@errorshowing
mov di,si
add di,436h
mov ah,8
xor bx,bx
mov cx,[si+offset BMP_File.BMP_height]
@@bouclette:
mov al,[di]
push bx cx
add bx,[x]
add cx,[y]
int 47h
pop cx bx
inc bx
inc di
cmp bx,[si+offset BMP_File.BMP_width]
jb @@bouclette
xor bx,bx
dec cx
cmp cx,0
jne @@bouclette
clc
pop di si cx bx ax
pop bp
retf taille
@@errorshowing:
stc
pop di si cx bx ax
pop bp
retf taille
xc dw 0
yc dw 0
showbmp ENDP
;==========LOADBMPPALET=========
;Charge la palette du BMP pointée par DS:%0
;-> DS:%0 BMP
;<-
;===============================
loadbmppalet PROC FAR
ARG pointer:word=taille
push bp
mov bp,sp
push ax bx cx dx si
mov si,[pointer]
mov bx,0400h+36h-4
mov cx,100h
mov dx, 3c8h
paletteload:
mov al, cl
dec al
out dx, al
inc dx
mov al,[bx+si+2]
shr al,2
out dx, al
mov al,[bx+si+1]
shr al,2
out dx, al
mov al,[bx+si]
shr al,2
out dx, al
sub bx,4
dec dx
dec cl
jnz paletteload
pop si dx cx bx ax
pop bp
retf taille
loadbmppalet ENDP
end start