cos2000v1/lib/bmp.asm

100 lines
1.7 KiB
NASM
Raw Normal View History

2019-07-13 20:49:22 +02:00
use16
align 1
include "..\include\mem.h"
include "..\include\divers.h"
include "..\include\bmp.h"
org 0h
header exe 1,exports,imports,0,0
exporting
declare showbmp
declare loadbmppalet
ende
importing
use VIDEO,showpixel
endi
;==========SHOWBMP=========
;Affiche le BMP point<6E>e par DS:%0 en %1, %2
;<- DS:%0 BMP, %1 coordonn<6E>es X, %2 coordonn<6E>es Y
;->
;==========================
2019-07-09 18:30:00 +02:00
proc showbmp uses ax bx cx dx si di, pointer:word, x:word, y:word
mov si,[pointer]
virtual at si
.bmp_file bmp_file
end virtual
cmp word [.bmp_file.bmp_filetype],"MB"
jne .errorshowing
mov edi,[.bmp_file.bmp_bitmapoffset]
2007-03-28 23:23:55 +02:00
add di,400h
add di,si
xor ebx,ebx
2019-07-09 18:30:00 +02:00
mov ecx,[.bmp_file.bmp_height]
mov edx,[.bmp_file.bmp_width]
2007-03-28 23:23:55 +02:00
;and dx,11111100b
2019-07-09 18:30:00 +02:00
cmp edx,[.bmp_file.bmp_width]
;jae .noadjust
2007-03-28 23:23:55 +02:00
;add dx,4
2019-07-09 18:30:00 +02:00
.noadjust:
sub edx,[.bmp_file.bmp_width]
.bouclette:
push bx cx
2019-07-09 18:30:00 +02:00
add bx,[x]
add cx,[y]
invoke showpixel,bx,cx,word [di]
pop cx bx
inc bx
inc di
2019-07-09 18:30:00 +02:00
cmp ebx,[.bmp_file.bmp_width]
jb .bouclette
xor bx,bx
2007-03-28 23:23:55 +02:00
;add di,dx
dec cx
cmp cx,0
2019-07-09 18:30:00 +02:00
jne .bouclette
clc
ret
2019-07-09 18:30:00 +02:00
.errorshowing:
stc
ret
2019-07-09 18:30:00 +02:00
endp
;==========LOADBMPPALET=========
;Charge la palette du BMP point<6E>e par DS:%0
;-> DS:%0 BMP
;<-
;===============================
2019-07-09 18:30:00 +02:00
proc loadbmppalet uses ax bx cx dx si, pointer:word
mov si,[pointer]
mov bx,0400h+36h-4
mov cx,100h
mov dx, 3c8h
2019-07-09 18:30:00 +02:00
.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
2019-07-09 18:30:00 +02:00
jnz .paletteload
ret
2019-07-09 18:30:00 +02:00
endp