中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » 显示256色bmp图片的汇编程序(带附件)
作者:
标题: 显示256色bmp图片的汇编程序(带附件) 上一主题 | 下一主题
pick
新手上路





积分 16
发帖 4
注册 2006-6-19
状态 离线
『楼 主』:  显示256色bmp图片的汇编程序(带附件) 使用 LLM 解释/回答一下

;**************************************************************************************
;
; This Code Show a 256 Color bitmap file in 13h mode. Support negative
; coordinate and auto cut out. The 'Bitmap' function have there para:
; the pointer to bitmap file name, X coordinate and Y coordinate. The
; function can be called like this:
;
; push Y coordinate
; push X coordinate
; push offset ImageSrc
; call Bitmap
;
; Written By Nirvana
; email:westdatas@163.com
; oicq :19820914
;**************************************************************************************

Stack Segment
Stk db 65535 dup(?)
Stack Ends
Data Segment
ImageBuffer db 65078 dup(?)
ImageSrc db 'test.bmp',0
Eflag db ?
OpenErrorMsg db 'open file error',24h
Not256Color db 'Not a 256 color bitmap',24h
handle dw ?
Data Ends
Code Segment
Assume cs:Code,ds:Data,ss:Stack
Start:
mov ax,Data
mov ds,ax
mov di,-100
mov si,50
mov dx,offset ImageSrc
push si
push di
push dx
call Bitmap
mov ax,0
int 16h
mov ax,4c01h
int 21h

BitMap Proc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; =================== ;
; * Local Variable list * ;
; =================== ;
; ;
; (1) BmpWidth (:Word) ;
; (2) BmpOnScreenWidth (:Word) ;
; (3) BytePerRow (:Word) ;
; (4) LeftCutWidth (:Word) ;
; (5) BmpHeight (:Word) ;
; (6) BmpOnScreenHeight (:Word) ;
; (7) BytePerPixel (:Word) ;
; (8) PaletteOffset (:Word) ;
; (9) ImgDataOffset (:Word) ;
; (10) RowOffset (:Word) ;
; ;
; ;
;===========================================================================

push bp
mov bp,sp
sub sp,20
push ax
push bx
push cx
push dx
push si
push di
push es
mov dx,
mov ax,3d00h
int 21h ;Open the bitmap file
jnc OpenOk
mov Eflag,0
Error: ;Show error message
cmp Eflag,0
jz OpenError
cmp Eflag,1
jz Not256
OpenError:
mov dx,offset OpenErrorMsg
jmp showtext
Not256:
mov dx,offset Not256Color
jmp ShowText
ShowText:
mov ah,09h
int 21h
jmp exit
OpenOk:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Read first 4 byte of the file in order to get the file size ;;;;;;;;;;;;
; ; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
;;
mov bx,ax ;;
mov handle,bx ;;
mov dx,offset ImageBuffer ;;
mov cx,4 ;;
mov ax,3f00h ;;
int 21h ;Read the first 4 byte to memory ;;
mov ax,3e00h ;;
mov bx,handle ;;
int 21h ;Close the bitmap file ;;
;;
;====================================================================================;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Read The entire bitmap file to memory ;;;;;;;;;;;;
; ; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
;;
mov si,2 ;;
mov cx, ;Save the bitmap file entire size to CX Register ;;
mov dx, ; ;;
mov ax,3d00h ;;
int 21h ;Open the bitmap file again ;;
mov bx,ax ;;
mov handle,bx ;;
mov dx,offset ImageBuffer ;;
mov ax,3f00h ;;
int 21h ;Read the entire bitmap file to memory ;;
mov ax,3e00h ;;
mov bx,handle ;;
int 21h ;Close the bitmap file ;;
;;
;====================================================================================;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Save Information to local variable ;;;;;;;;;;;;
; ; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
;;
mov si,012h ;;
mov ax, ;;
mov ,ax ;Save BmpWidth ;;
mov ,ax ;Save BmpOnScreenWidth ;;
mov ,ax ;Save BytePerRow ;;
mov cl,4 ;;
div cl ;;
cmp ah,0 ;;
jz NoDwAA ;No Dword align adjust ;;
mov cl,4 ;;
sub cl,ah ;;
add ,cl ;;
NoDwAA: ;;
mov cx,0 ;;
mov ,cx ;Save LeftCutWidth,Default = 0 ;;
mov si,016h ;;
mov ax, ;;
mov ,ax ;Save BmpHeight ;;
mov ,ax ;Save BmpOnScreenHeight ;;
mov si,01ch ;;
mov ax, ;;
mov ,ax ;Save BitPerPixel ;;
mov si,0eh ;;
mov ax, ;Save bmpfileheader length ;;
add ax,14 ;;
mov ,ax ;Save PaletteOffset ;;
mov si,0ah ;;
mov ax, ;;
mov ,ax ;Save ImgDataOffset ;;
;mov ,0 ;Save RowOffset ;;
;;
;====================================================================================;;

;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
;
; Seve the value to Local variable
;
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

jmp CoorDinateX
exitzz:
jmp exit
CoordinateX:
mov ax, ;X coordinate
push ax
and ah,80
pop ax
jz PositiveX ;If X coordinate>=0,jump
mov ax,
push ax
not ax
inc ax
mov ,ax ;Save LeftCutWidth
pop ax
add ax, ;X coordinate add BmpWidth
jnc exitzz ;Exit if X coordinate add BmpWidth < 0
jz exitzz ;Exit if X coordinate add BmpWidth = 0
push ax
mov cx,320
sub cx,ax
mov ,cx ;Save RowOffset
add ax,
mov ,ax ;Save BmpOnScreenWidth + LeftCut
pop ax
mov cx,320
cmp cx,ax
jnc NoWOverf ;No Width Overflow
mov ax,
add ax,320
mov ,ax ;Save BmpOnScreenWidth = 320 + LeftCutWidth
mov ax,0
mov ,ax
NoWOverf:
mov ax,0
mov ,ax
jmp CoordinateY
PositiveX:
cmp ax,320
jnc exitzz
mov cx,320
sub cx,
mov ,cx
add ax,
mov cx,320
cmp cx,ax
jnc CoordinateY
mov ax,320
sub ax,
mov ,ax ;Save OnScreenWidth
mov cx,320
sub cx,ax
mov ,cx ;SaveRowOffset
CoordinateY:
mov ax, ;Y coordinate
push ax
and ah,80
pop ax
jz PositiveY
add ax,
jnc exitzz1
jz exitzz1
mov ,ax ;Save BmpHeight
mov ,ax ;Save OnScreenHeight
mov cx,0
mov ,cx
mov cx,200
cmp cx,ax
jnc SetInt10 ;No Height Overflow
mov cx,200
mov ,cx
NoHOverf:
jmp SetInt10
exitzz1:
jmp exit
PositiveY:
cmp ax,200
jnc exitzz1
add ax,
mov cx,200
cmp cx,ax
jnc SetInt10
mov ax,200
sub ax,
mov ,ax

;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

;**************************************************************************************
;
; Set the Palette register and copy image data to video buffer which
; address start at A000:0000.
;
;**************************************************************************************

SetInt10:
mov ax,013h
int 10h ;Set Video Mode to 13h
mov dx,03c6h
mov ax,0ffh
out dx,ax
mov si,
mov di,0
mov cx,256
SetPalette:
mov dx,03c8h
mov ax,di
out dx,al
mov dx,03c9h
mov al,byte ptr
push bx
mov bl,63
mul bl
mov bl,0ffh
div bl
pop bx
out dx,al
mov al,byte ptr
push bx
mov bl,63
mul bl
mov bl,0ffh
div bl
pop bx
out dx,al
mov al,byte ptr
push bx
mov bl,63
mul bl
mov bl,0ffh
div bl
pop bx
out dx,al
add si,4
inc di
loop SetPalette
Showbmp:
mov ax,0a000h ;Video memory start address
mov es,ax
mov ax,
mov cx,320
mul cx
add ax,
mov di,ax
vertical:
cmp word ptr,0
jz exit
dec word ptr
dec word ptr
mov ax,
mul word ptr
mov bx,ax
add bx,
mov si,0
add si,
horizon:
cmp si,word ptr
jz horizonend
mov al,
mov es:,al
inc si
inc di
jmp horizon
horizonend:
add di,
jmp Vertical

;**************************************************************************************

exit:
pop es
pop di
pop si
pop dx
pop cx
pop bx
pop ax
add sp,20
pop bp
ret 6
Bitmap endp
Code Ends
End Start

Last edited by pick on 2006-6-19 at 16:16 ]


附件 1: bitmap.rar (2006-6-19 16:14, 31.04 KiB, 下载附件所需积分 1 点 ,下载次数: 129)
2006-6-19 16:14
查看资料  发送邮件  发短消息  网志   编辑帖子  回复  引用回复
070
高级用户

苏醒的沉睡者


积分 659
发帖 217
注册 2003-2-15
来自 福建
状态 离线
『第 2 楼』:   使用 LLM 解释/回答一下

没办法退出




好久没碰Dos,手都生了,赶紧回来练练.嘿嘿
2006-6-19 18:27
查看资料  发送邮件  发短消息  网志  OICQ (181315400)  编辑帖子  回复  引用回复
6622186
高级用户





积分 894
发帖 411
注册 2007-2-17
状态 离线
『第 3 楼』:   使用 LLM 解释/回答一下

这是源码?




@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul


2007-5-17 21:53
查看资料  发短消息  网志   编辑帖子  回复  引用回复
6622186
高级用户





积分 894
发帖 411
注册 2007-2-17
状态 离线
『第 4 楼』:   使用 LLM 解释/回答一下

不懂汇编语言




@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul


2007-5-17 22:02
查看资料  发短消息  网志   编辑帖子  回复  引用回复
henrya2
中级用户





积分 486
发帖 171
注册 2006-2-12
状态 离线
『第 5 楼』:   使用 LLM 解释/回答一下

在那里找到的,还是你自己写的?




Those who do not study the past are condemned to repeat it
2007-5-22 17:36
查看资料  发送邮件  发短消息  网志   编辑帖子  回复  引用回复
netwinxp
高级用户





积分 741
发帖 366
注册 2007-7-25
状态 离线
『第 6 楼』:   使用 LLM 解释/回答一下

只支持320x200及以下的图片,没有多大价值


2007-7-25 23:07
查看资料  发短消息  网志   编辑帖子  回复  引用回复
mendianbo
初级用户





积分 21
发帖 6
注册 2005-9-8
状态 离线
『第 7 楼』:   使用 LLM 解释/回答一下

DJGPP + ALEGRO可实现dos下显示位图。


2007-7-27 18:56
查看资料  发送邮件  发短消息  网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: