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

📄 grmac.inc

📁 Microsoft MS-DOS6.0 完整源代码
💻 INC
📖 第 1 页 / 共 2 页
字号:
;***
; GRMAC - ModeData macros
;***
	.XLIST
;***
;
;	Copyright <C> 1986, Microsoft Corporation
;
;Purpose:
;	This macro set is used to create the "ModeData" tables.
;
;	The "master" ModeData table is called "b$ModeData" and resides in
;	DGROUP in LLCGRP.  Each mode-dependent module constructs a separate
;	table for each different mode in the Code Segment using these
;	macros. A mode-dependent ModeData table is then copied to the
;	master table when establishing a new screen mode.
;
;	All the tables are created using this macro set to insure
;	consistency in their structure and to provide a central point (the
;	macros) for modifying that structure.
;
;	The mModeData macro should be followed by individual data item
;	macros (in any order) and terminated using the mEnd macro.
;	The general format and list of data items is as follows:
;
;	mModeData	<table name>
;	mScreenMode	<screen mode>
;	mBiosMode	<BIOS mode>
;	mBurst		<burst>
;	mScrWidth	<text screen width>
;	mScrHeight	<text screen height>
;	mHorzRes	<horizontal pixel resolution>
;	mVertRes	<vertical pixel resolution>
;	mVideoBase	<base address of video segment>
;	mMaxAttr	<maximum attribute value>
;	mMaxColor	<maximum color value (for palette assignment)>
;	mPageSize	<page size (a "rough" size in K)>
;	mCurrPSize	<page size in paragraphs for 1 plane>
;	mMaxPage	<maximum page number>
;	mNullColor	<null character color attribute>
;	mForeColor	<foreground color attribute>
;	mBackColor	<background color attribute>
;	mEgaWrMd	<value for EGA write mode register (odd/even control)>
;	mInitPalette	<pointer to initial palette>
;	mInitVgaPal	<pointer to initial VGA palette>
;	mAlphaDim	<function vector to change screen text dimensions>
;	mSetMode	<function vector to set screen mode>
;	mSetPages	<function vector to change active/visual pages>
;	mPalReset	<function vector to reset palette>
;	mPalPut 	<function vector to set single palette entry>
;	mPalTrans	<function vector to translate attribute/color pair>
;	mPalSet 	<function vector to set entire palette>
;	mSetColor	<function vector to process COLOR statment>
;
;	--- following data items required for GRAPHICS modes only ---
;
;	mForeMapped	<forecolor mapped to hardware value>
;	mBitsPerPixel	<bits per pixel (per plane)>
;	mPlanes 	<number of graphics planes>
;	mMapXYC 	<function vector to map X,Y to mask & offset>
;	mLeftC		<function vector to move graphics cursor left>
;	mChkUpC 	<function vector to move graphics cursor up w/check>
;	mUpC		<function vector to move graphics cursor up>
;	mChkDownC	<function vector to move graphics cursor down w/check>
;	mDownC		<function vector to move graphics cursor down>
;	mSetAttr	<function vector to set current color attribute>
;	mReadC		<function vector to read pixel value>
;	mSetC		<function vector to set pixel value>
;	mSetPixC	<function vector to set pixel multiple times>
;	mSetPixFirstC	<function vector to prologue SetPixC>
;	mSetPixLastC	<function vector to epilogue SetPixC>
;	mLineX		<function vector to draw X-major lines>
;	mLineY		<function vector to draw Y-major lines>
;	mLineV		<function vector to draw vertical lines>
;	mPutAction	<function vector to establish PUT action verb>
;	mNReadL 	<function vector to read a line of pixels>
;	mNWriteL	<function vector to write a line of pixels>
;	mNSetC		<function vector to set a line of pixels>
;	mPaintBound	<function vector to set PAINT boundaries for a line>
;	mSetTile	<function vector to set PAINT tile>
;	mScanL		<function vector to scan left during PAINT>
;	mScanR		<function vector to scan right during PAINT>
;
;	--- mEnd required for ALL modes ---
;
;	mEnd		<graphics length>,<text length>,<define PUBLICS>
;
;******************************************************************************

;*** 
; mModeData (macro)
;
;Purpose:
;	When invoked, mModeData creates a macro called ?mModeData.  This
;	macro generates the label name for the table.  All ?m macros
;	and data values are for internal use by the macro set only.
;	?mModeData purges itself after use (by mEnd).
;
;Arguments:
;	<table name>
;
;******************************************************************************

mModeData macro n
	?mModeData  macro
	    if	?mDEF
		labelW	<PUBLIC,n>
	    else
		labelW	n
	    endif
		purge	?mModeData	;avoid residue from one table to next
		endm
	endm

;*** 
; mEnd (macro)
;
;Purpose:
;
;	This macro actually builds the table.  The data items supplied by the
;	individual macros are placed appropriately in the table. Additional
;	items calculated from the supplied values are also computed and built
;	into the table. The "define" macro (below) is used to check and build
;	each numeric table item. Macros created by invocation of the vector
;	data item macros are used to build the pointers and function vectors.
;
;	Specifying a symbol for the <graphics length> parameter generates a
;	graphics mode table and sets the value of the symbol to the length of
;	the graphics table.
;
;	Specifying a symbol for the <text length> parameter generates a text
;	mode table and sets the value of the symbol to the length of the text
;	table.
;
;	Specifying a symbol for both generates a graphics table, but sets
;	each symbol as above.
;
;	Specifying TRUE for the <define PUBLICS> (third) parameter generates
;	PUBLIC names (prefixed with "b$") for each data item. This also
;	creates the GraphVectStart LABEL and GraphVectCnt ABSOLUTE used by
;	B$InitModeData to reset the graphics function vectors for text
;	modes.	This should be used only to define the "master" table.
;
;TABLE MAINTENANCE:
;	To add new entries in the table, add an entry to the MACRO CREATION
;	section.  Then insert a line in "mEnd" using "define" for numeric
;	items, or invoking the "?mXX" macro for vector items.
;
;Arguments:
;	<graphics length>
;	<text length>
;	<define PUBLICS>
;******************************************************************************

mEnd	macro	glen,tlen,def
    ifb     <def>
	?mDEF		=	0		;no PUBLICS
    else
	?mDEF		=	def		;define PUBLICS
    endif
	?mBurst 	= (?mBurst NE 0) AND 1	;strip Burst to one bit
    ifb     <tlen>
	?mLEN		=	12		;packet len for graphics modes
	?mType		=	10B		;DOS5 graphics flag on
    else
	?mLEN		=	8		;packet len for text modes
	?mType		=	0		;DOS5 graphics flag off
    endif
    if	(?mBiosMode NE 7) AND (?mBiosMode NE 0FH) ;if not a mono mode, set
	?mType		=	?mType + 1	;DOS5 color adapter flag
    endif
    ifnb    <glen>
;
;compute those graphics values which are derivable from the others
;
	?mPixelsPerByte = 8 / ?mBitsPerPixel
	?mBytesPerRow	= ?mHorzRes / ?mPixelsPerByte
	?mMaskLeft	= LOW (0FFH SHL (8-?mBitsPerPixel))
	?mMaskRight	= 0FFH SHR (8-?mBitsPerPixel)
	;
	;DivShift is the shift count used to divide by PixelsPerByte
	;
    if	?mPixelsPerByte EQ 8
	?mDivShift	= 3
    else
    if	?mPixelsPerByte EQ 4
	?mDivShift	= 2
    else
    if	?mPixelsPerByte EQ 1
	?mDivShift	= 0
    else
	.ERR
	%OUT BitsPerPixel: invalid value
    endif
    endif
    endif
	;
	;ModMask is the mask used to MOD by PixelsPerByte
	;
	?mModMask	= ?mPixelsPerByte - 1
	;
	;Aspect is 256*4*(VertRes/HorzRes)/3
	;AspectInv is the inverse of Aspect
	;   The "*256" produces a "fixed-point" decimal value.
	;   The rest of the funniness is to round the value and to
	;   avoid overflow of 16-bit computations during assembly.
	;
	; These are the correct values:
	;
	;  mode(s)	b$Aspect	b$AspectInv
	;  -------	--------	-----------
	;  1,4,7,13	   213		    307
	;    2,8	   107	            614
	;     3		   165		    397
	;    9,10	   187		    351
	;   11,12	   256		    256
	;
	; Note:  Since these formula are not exact, be sure that the correct
	; values are obtained for any new screen modes that are added.
	;
	AspTmp = (?mVertRes MOD ?mHorzRes * 64+?mHorzRes/8)/(?mHorzRes/4) ;;[4]
	?mAspect	= ((?mVertRes/?mHorzRes*256+AspTmp)*8+3)/6	;;[4]
	AspTmpInv = (?mHorzRes MOD ?mVertRes * 128)/(?mVertRes/2)	;;[4]
	?mAspectInv	= ?mHorzRes/?mVertRes*192+(AspTmpInv*3+2)/4	;;[4]
    endif

	?mStart = $

	?mModeData

	define	B,ScreenMode		;current BASIC screen mode
    if	    ?mDEF
	labelW	<PUBLIC,b$ModeBurst>	;BiosMode and Burst in one word
    endif
	define	B,BiosMode		;current BIOS screen mode
	define	B,Burst 		;color burst

;****************************************************************************
;START OF DOS5 VIOSETMODE request packet (keep in this format!!!!)
;****************************************************************************

	define	B,ScrWidth		;otherwise we only need to
	define	B,ScrHeight		;  use bytes
	define	W,HorzRes		;horizontal resolution
	define	W,VertRes		;vertical resolution

;****************************************************************************
;END OF DOS5 VIOSETMODE request packet
;****************************************************************************

	;text mode-dependent data
	define	W,VideoBase		;video segment base
	define	B,MaxAttr		;maximum attribute
	define	B,MaxColor		;maximum color
	define	B,PageSize		;page size in K
	define	W,CurrPSize		;page size in paragraphs (1 plane)
	define	B,MaxPage		;maximum page number
;b$NullColor:
;In text modes, low nibble = b$ForeColor and high nibble = b$BackColor
;In graphics modes, either b$ForeColor or b$BackColor, depending on the mode
	define	B,NullColor		;null character attribute
    if	    ?mDEF
	labelW	<PUBLIC,b$FBColors>	;fore and back colors in one word
    endif
	define	B,ForeColor		;foreground color
	define	B,BackColor		;background color
	define	B,EgaWrMd		;EGA write mode 2 register value,
					;   bit 4=odd/even
	?mInitPalette			;initial (reset) palette
	;text mode-dependent function hooks
	?mAlphaDim

⌨️ 快捷键说明

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