⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 video.inc

📁 DOS下的调试工具
💻 INC
📖 第 1 页 / 共 2 页
字号:
;=============================================================================
; Insight, real-mode debugger for MS DOS / PC DOS / FreeDOS.
; Copyright (c) Victor M. Gamayunov, Sergey Pimenov, 1993, 96, 97, 2002.
; Modifications by Oleg O. Chukaev (2006, 2007).
; Some procedures based on code by M.Martynov, A.Ilyushin, S.Gorokhov.
;-----------------------------------------------------------------------------
; video.inc
; Procedures for saving/restoring screen and font.
;-----------------------------------------------------------------------------
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
; 
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
; 02111-1307, USA.
;=============================================================================


;=============================================================================
; Changelog
;-----------------------------------------------------------------------------
; 2007-02-27 (Oleg O. Chukaev)
;	{save,restore}_screen: SCR_ROWS -> MAX_SCR_ROWS.
;
;=============================================================================


;=============================================================================
; Format of table used by save_mode/set_mode
;-----------------------------------------------------------------------------
;  V G A   r e g i s t e r s
;Sequencer registers		05h bytes	+00h
;CRT controller registers	1ah bytes	+05h
;Attribute controller registers	15h bytes	+1fh
;Graphics controller registers	0ah bytes	+34h
;DAC registers			30h bytes	+3eh
;Feature register		01h byte	+6eh
;Miscellaneous			01h byte	+6fh
;PEL mask			01h byte	+70h
;-----------------------------------------------------------------------------
;  B I O S   v a r i a b l e s
;Cursor position for page 0	02h bytes	+71h
;Screen width in columns	02h bytes	+73h
;Lines per char			02h bytes	+75h
;Last line number		01h byte	+77h
;Video mode number		01h byte	+78h
;-----------------------------------------------------------------------------
; Total bytes: 79h (121 dec)
;-----------------------------------------------------------------------------


;=============================================================================
; xchg_planes
;-----------------------------------------------------------------------------
; Exchanges font, chars, and attributes
;
xchg_planes:
		cld
		push	ds
		push	es
		push	ds
		pop	es		;ES:DI -> data
		mov	di,font
		mov	ax,0a000h
		mov	ds,ax
		xor	si,si		;DS:SI -> screen
		mov	bx,0402h	;2nd plane (font)
		call	set_regs
		mov	bx,256		;Number of characters
@@10:
		mov	cx,16		;Bytes per character
@@20:
		call	xchg_esdi_dssi
		cmpsb			;OPTIMIZE: instead of INC SI; INC DI
		loop	@@20
		add	si,16
		dec	bx
		jnz	@@10

		mov	di,old_screen
		mov	bx,0100h
		call	set_regs
		call	video_xchg

		mov	di,old_screen+1
		mov	bx,0201h
		call	set_regs
		call	video_xchg

		pop	es
		pop	ds
		ret
;=============================================================================
; xchg_esdi_dssi
;-----------------------------------------------------------------------------
xchg_esdi_dssi:
		mov	al,[si]
		xchg	al,[es:di]
		mov	[si],al
		ret
;=============================================================================
; video_xchg
;-----------------------------------------------------------------------------
; Exchanges or saves chars or attributes
;
video_xchg:
		mov	cx,SCR_COLS*SCR_ROWS
		xor	si,si
@@30:
		call	xchg_esdi_dssi
		cmpsw			;OPTIMIZE: instead of
		loop	@@30		;2*[INC SI; INC DI]
		ret
;=============================================================================
; set_regs
;-----------------------------------------------------------------------------
; Performs VGA registers setting to read/write font/chars
;
set_regs:
		mov	dx,03c4h
		mov	al,02h		;Map enable
		mov	ah,bh
		out	dx,ax
		call	dummy
		mov	ax,0704h
		out	dx,ax
		call	dummy
		mov	al,01h
		out	dx,al
		call	dummy
		inc	dx
		in	al,dx
		call	dummy
		or	al,20h
		out	dx,al
		call	dummy
	
		mov	dx,03ceh
		mov	al,04h
		mov	ah,bl		;Plane to read
		out	dx,ax
		call	dummy
		mov	ax,0005h
		out	dx,ax
		call	dummy
		mov	ax,0406h
		out	dx,ax
		call	dummy
		mov	ax,0001h
		out	dx,ax
		call	dummy
		mov	al,03h
		out	dx,ax
		call	dummy
		mov	ax,0ff08h
		out	dx,ax
		ret
;=============================================================================
; save_mode
;-----------------------------------------------------------------------------
; Saves video mode
;
save_mode:
		cld
;-----------------------------------------------------------------------------
; MISCELLANEOUS
;-----------------------------------------------------------------------------
		mov	dx,03cch	;for reading
		in	al,dx
		call	dummy
		mov	[es:di+6fh],al
		or	al,1		;color adapter (3d?h)
		mov	dl,0c2h		;for writing
		out	dx,al
		call	dummy
;-----------------------------------------------------------------------------
; Wait for vertical retrace
;-----------------------------------------------------------------------------
		mov	dl,0dah
@@90:
		in	al,dx
		test	al,00001000b
		jnz	@@90
@@91:
		in	al,dx
		test	al,00001000b
		jz	@@91
;-----------------------------------------------------------------------------
; SEQUENCER
;-----------------------------------------------------------------------------
		mov	dl,0c4h
		mov	cx,4
		mov	ah,01
		call	save_vga_regs
;-----------------------------------------------------------------------------
; CRTC
;-----------------------------------------------------------------------------
		mov	dl,0d4h
		mov	cl,19h
		mov	ah,00
		call	save_vga_regs
;-----------------------------------------------------------------------------
; AC
;-----------------------------------------------------------------------------
		mov	dl,0c0h
		mov	cl,15h
		mov	ah,00
@@30:
		push	dx
		mov	dl,0dah
		in	al,dx		; clear flip/flop
		pop	dx
		mov	al,ah
		out	dx,al
		call	dummy
		inc	dx
		inc	ah
		in	al,dx
		dec	dx
		stosb
		loop	@@30

		mov	dl,0dah
		in	al,dx		; clear flip/flop
		call	dummy
		mov	dl,0c0h
		mov	al,20h
		out	dx,al
		call	dummy
;-----------------------------------------------------------------------------
; GC
;-----------------------------------------------------------------------------
		mov	dl,0ceh
		mov	cl,9
		mov	ah,00
		call	save_vga_regs
;-----------------------------------------------------------------------------
; DAC
;-----------------------------------------------------------------------------
		mov	dl,0c7h
		mov	cl,10h
		mov	ah,00
@@50:
		mov	al,ah
		out	dx,al
		call	dummy
		inc	dx
		inc	dx

		in	al,dx
		stosb
		in	al,dx
		stosb
		in	al,dx
		stosb

		dec	dx
		dec	dx
		inc	ah
		loop	@@50
;-----------------------------------------------------------------------------
; FEATURE
;-----------------------------------------------------------------------------
		mov	dl,0cah
		in	al,dx
		stosb
;-----------------------------------------------------------------------------
; PEL MASK
;-----------------------------------------------------------------------------
		inc	di		;skip MISC reg
		mov	dl,0c6h
		in	al,dx
		stosb
;-----------------------------------------------------------------------------
; BIOS variables
;-----------------------------------------------------------------------------
		push	ds
		xor	ax,ax
		mov	ds,ax
		mov	ax,[450h]
		stosw
		mov	ax,[44ah]
		stosw
		mov	ax,[485h]
		stosw
		mov	al,[484h]
		mov	ah,[449h]
		stosw
		pop	ds
dummy:
		ret
;=============================================================================
; save_vga_regs
;-----------------------------------------------------------------------------
save_vga_regs:
		in	al,dx
		stosb
@@20:
		mov	al,ah
		out	dx,al
		call	dummy
		inc	dx
		inc	ah
		in	al,dx
		dec	dx
		stosb
		loop	@@20
		ret
;=============================================================================
; set_mode
;-----------------------------------------------------------------------------
; Sets video mode
;
set_mode:
		cld
		mov	dx,03cch
		in	al,dx
		call	dummy
		or	al,1		;Miscellaneous ( 3D? )
		mov	dl,0c2h
		out	dx,al
		call	dummy
;-----------------------------------------------------------------------------
; Wait for retrace
;-----------------------------------------------------------------------------
		mov	dl,0dah
@@90l:
		in	al,dx

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -