使用汇编语言通过双色点阵实现一个动画,这里是表情的变化。
基本思路就是分别编写不同的帧,然后依次显示。 颜色的变化是 290h:黄色 288h: 红色。
data segment
buff1 db 00h,00h,00h,18h,18h,00h,00h,00h
db 00h,00h,18h,24h,24h,18h,00h,00h
db 00h,3ch,42h,5ah,5ah,42h,3ch,00h
db 7eh,81h,81h,81h,81h,81h,81h,7eh
db 7eh,81h,0a5h,81h,81h,0a5h,81h,7eh;
db 7eh,81h,0a5h,89h,89h,0a5h,81h,7eh;
db 7eh,81h,0a9h,89h,89h,0a9h,81h,7eh;
db 7eh,81h,0a9h,81h,81h,0a9h,81h,7eh;笑脸
db 7eh,91h,0a5h,85h,85h,0a5h,91h,7eh
db 7eh,91h,0a7h,85h,85h,0a7h,91h,7eh
buff2 db 7eh,91h,0a7h,85h,85h,0a7h,91h,7eh
data ends
;-----------------------------------------------
code segment
assume cs:code,ds:data
;-----------------------------------------------
start: mov ax,data
mov ds,ax
;-----------------------------------------------
LLL: mov cx,10 ;buff1帧数
mov bx,00h
L: push cx
mov cx,20h
D: mov ah,01h
push cx
mov cx,8
mov si,0
next: mov al,[buff1+si+bx]
mov dx,280h
out dx,al
mov al,ah
mov dx,288h
out dx,al
mov al,0
out dx,al
;---------------------------
;-----------------------------
shl ah,01h
inc si
call delay
loop next
pop cx
call delay ;显示后延迟
loop D
mov al,0
mov dx,288h
out dx,al
add bx,8
pop cx
call delay
loop L
;jmp LLL
LLL1: mov cx,1 ;
mov bx,00h
L1: push cx
mov cx,20h
D1: mov ah,01h
push cx
mov cx,8
mov si,0
next1:
;---------------------------
mov al,[buff2+si+bx] ;buff2黄色
mov dx,280h
out dx,al
mov al,ah
mov dx,290h
out dx,al
mov al,0
out dx,al
;-----------------------------
shl ah,01h
inc si
call delay
loop next1
pop cx
call delay
loop D1
mov al,0
mov dx,288h
out dx,al
add bx,8
pop cx
call delay
loop L1
jmp LLL
;--------------------------------------------------------
delay proc near ;延迟子程序
push cx
mov cx,0ffh
ccc: loop ccc
pop cx
ret
delay endp
code ends
end start
原文:http://blog.csdn.net/nk_test/article/details/50358654