汇编源代码之图形显示方式屏幕的保存和恢复
2009-01-28 09:37:10 来源:WEB开发网xor si,si
mov cx,1000h
mov di,offset ram_buffer
push cs
push ds
cld
rep movsb
xor di,di ;
mov cx,80*25
mov ax,57b1h ;填充背景,不然有乱字符
cld
rep stosw
scr_ret
pop es
pop ds
ret
ss_mode3:
call save_vram ;显示模式 3 保存显示 RAM
jmp short scr_ret
ss_mode7:
push 0b000h ;显示模式 7 保存显示 RAM
pop ds
call save_vram1
mov ax,3
int 10h
call restore_vram
jmp short scr_ret
SAVE_SCR ENDP
SAVE_VRAM PROC
push 0b800h ;把显示内存保存到自己的缓冲区
pop ds
save_vram1:
push cs
pop ds
xor si,si
mov di,offset ram_buffer
mov cx,2000h
cld
rep movsb
ret
SAVE_VRAM ENDP
RESTORE_VRAM PROC
push 0b800h ;恢复显示缓冲区内容
pop es
restore_vram1:
xor di,di
push cs
pop ds
mov si,offset ram_buffer
mov cx,2000h
cld
rep movsb
ret
RESTORE_VRAM ENDP
VGA_PAGE PROC
cmp vga_type,1
jnz other_vga1
cmp ah,1
jz vp_vesa2
cmp ah,2
jz vp_vesa1
mov ax,4f05h ;保存 VESA 显示卡状态
mov bx,0100h
int 10h
mov vga_win1,dx
mov ax,4f05h
mov bx,0101h
int 10h
mov vga_win2,dx
vp_vesa1:
mov ax,4f05h
xor bx,bx
xor dx,dx
int 10h
mov ax,4f05h
mov bx,0001h
xor dx,dx
int 10h
ret
vp_vesa2:
mov ax,4f05h
xor bx,bx
mov dx,vga_win1
int 10h
mov ax,4f05h
mov bx,0001h
mov dx,vga_win2
int 10h
ret
other_vga1:
cmp vga_type,3
jnz other_vga2
mov dx,3cdh
cmp ah,1
jz vp_tseng2
cmp ah,2
jz vp_tseng1
in al,dx
mov vga_win3,al
vp_tseng1:
xor al,al
out dx,al
ret
vp_tseng2:
mov al,vga_win3
out dx,al
vp_ret:
ret
更多精彩
赞助商链接