使用匯編語言通過雙色點陣實現一個動畫,這裡是表情的變化。
基本思路就是分別編寫不同的幀,然後依次顯示。 顏色的變化是 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