📄 llcgrp.asm
字号:
TITLE LLCGRP - Core GW-BASIC Graphics Interface
;***
; LLCGRP - Core GW-BASIC Graphics Interface
;
; Copyright <C> 1986, Microsoft Corporation
;
;Purpose:
; This module contains support for graphics functions required
; by programs that may not use graphics drawing statements.
; Some non-graphic statements (such as CLS) require some graphic
; support. Routines directly supporting only graphics drawing
; statements are placed in LLAGRP to improve runtime granularity
; and reduce the size of programs not directly using graphics.
;
; Routines in this module are mode-independent in one or more of the
; following ways:
; 1) no device-dependent interaction,
; 2) table driven through mode-dependent data vectors, or
; 3) calls mode-dependent routines through function vectors.
;
; Mode-dependent graphics functions and initializers for vectors
; are segregated in separate modules for better granularity.
;
;******************************************************************************
INCLUDE switch.inc ;switch file
INCLUDE rmacros.inc
USESEG _BSS
USESEG _DATA
USESEG GR_TEXT
INCLUDE seg.inc
INCLUDE idmac.inc
INCLUDE grmac.inc
INCLUDE ibmunv.inc
sBegin _BSS
;
;#***************************************************************************
; External variables
;#***************************************************************************
;
externW b$HugeDelta ;OS dependent selector increment
;
;#***************************************************************************
; Global variables
;#***************************************************************************
;
labelW <PUBLIC,b$PenC> ;cursor "pen" is mask + attribute
globalB b$MaskC,,1 ; cursor mask byte
globalB b$AttrC,,1 ; each pixel in byte set to color attribute
labelD <PUBLIC,b$AddrC> ;address of cursor in video memory
globalW b$OffC,,1 ; cursor address offset
globalW b$SegC,,1 ; cursor address segment
globalB b$PaintBorder,,1 ;color attribute of PAINT border
globalB b$Tiling,,1 ;tiling flag
globalW b$SaveCa,,1 ;cursor values for first
globalB b$SaveCm,,1 ; non-border pixel during PAINT
globalB b$PlaneMask,,1 ;bit mask for Map Mask Reg for PUT
globalW b$Incr1,,1 ;major axis update value for Line
globalW b$Incr2,,1 ;minor axis update value for Line
globalW b$IncrY,,1 ;change for Y movement for Line
globalW B$VTOFST,,1 ;second row down from top of viewport
globalW B$VBOFST,,1 ;bottom edge of viewport
globalW B$VLOFST,,1 ;left edge of viewport and row 0
globalW B$VROFST,,1 ;right edge of viewport and row 0
globalB B$VLMASK,,1 ;corresponding mask for left edge
globalB B$VRMASK,,1 ;corresponding mask for right edge
globalW B$LEOFST,,1 ;left edge offset of viewport at current row
globalW B$REOFST,,1 ;right edge offset of viewport at current row
globalB b$BorderColor,,1 ;border color (overscan)
sEnd _BSS
sBegin _DATA
;
;#***************************************************************************
; Mode-dependent data and function vectors
;
; This data is filled by B$InitModeData from matching tables in the mode-
; dependent modules. All are created using the same macro set to insure
; consistency in their structure and to provide a central point (the macros)
; for modifying that structure. The "mEnd" macro actually builds the table.
; Specifying TRUE for its "def" (third) parameter causes it to also create
; 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.
;
; Refer to GRMAC.INC for more details on the actual structure and the
; variables provided. To aid in the textual search for these names,
; omit the "b$" in the search. This will locate all of the macro-generated
; sources for the data item in all the modules. (e.g.: searching for
; "ScreenMode" instead of "b$ScreenMode" will find all of the "mScreenMode"
; macro invocations.)
;
;This data table is pre-initialized to resemble a 40-column (worst case)
; text mode to account for its possible usage even before any screen mode
; initialization takes place. Function vectors are initialized to
; B$ErrorReturn, which just sets the carry (as an error indication) and
; returns.
;#***************************************************************************
;
mModeData b$ModeData
mScreenMode 0
mBiosMode 0
mBurst 0
mScrWidth 40
mScrHeight 25
mHorzRes 320
mVertRes 200
mVideoBase 0B800H
mMaxAttr 15
mMaxColor 0
mPageSize 2 ;page size in K
mCurrPSize <(2*1024) shr 4> ;page size in paragraphs
mMaxPage 0
mNullColor 7
mForeColor 7
mBackColor 0
mEgaWrMd 0
mInitPalette 0
mInitVgaPal 0
mAlphaDim B$ErrorReturn
mSetMode B$ErrorReturn
mSetPages B$ErrorReturn
mPalReset B$ErrorReturn
mPalPut B$ErrorReturn
mPalTrans B$ErrorReturn
mPalSet B$ErrorReturn
mSetColor B$ErrorReturn
mForeMapped 7
mBitsPerPixel 1
mPlanes 1
mMapXYC B$ErrorReturn
mLeftC B$ErrorReturn
mChkUpC B$ErrorReturn
mUpC B$ErrorReturn
mChkDownC B$ErrorReturn
mDownC B$ErrorReturn
mSetAttr B$ErrorReturn
mReadC B$ErrorReturn
mSetC B$ErrorReturn
mSetPixC B$ErrorReturn
mSetPixFirstC B$ErrorReturn
mSetPixLastC B$ErrorReturn
mLineX B$ErrorReturn
mLineY B$ErrorReturn
mLineV B$ErrorReturn
mPutAction B$ErrorReturn
mNReadL B$ErrorReturn
mNWriteL B$ErrorReturn
mNSetC B$ErrorReturn
mPaintBound B$ErrorReturn
mSetTile B$ErrorReturn
mScanL B$ErrorReturn
mScanR B$ErrorReturn
mEnd GraphDataLen,TextDataLen,TRUE
;
; End of table-initialized mode-dependent data
;
;#***************************************************************************
; Mode-dependent functions set-up and used by other mode-dependent functions
; (see detailed descriptions below)
;#***************************************************************************
;
globalW b$PutVector,B$ErrorReturn,1
;
;#***************************************************************************
; Mode-dependent variables are described in detail here
;#***************************************************************************
;
;***
;b$ScreenMode - Current Basic Screen Mode
;OEM-interface routine (variable)
;
;Purpose:
; This variable contains the BASIC mode number of the current
; screen mode. This is the number as given in the SCREEN
; statement, not the BIOS mode number.
;
;Allocated:
; b$ScreenMode is a BYTE value allocated in _DATA by the OEM.
;
;Values:
; This variable is initially set to 0 for a worst case scenario
; when an error message has to be printed before the screen is
; initialized. After initialization, it may take on the value
; of any legal screen mode (0-2, 7-13 if all possible modes are
; supported).
;
;Initially Set:
; b$ScreenMode is statically initialized to 0.
;
;Modified By:
; This variable is only modified by the OEM-Dependent routines.
; It should be updated when the screen is initialized, and when
; a SCREEN statement is given.
;
;Used By:
; This routine is used by the OEM-Dependent code to keep track
; of which screen mode is current. It is used by the OEM-Independent
; Code to determine if a graphics mode is in effect.
; (b$ScreenMode = 0 <=> non graphics mode)
;******************************************************************************
;
;#***************************************************************************
; Mode-dependent functions called indirectly are described in detail here
;#***************************************************************************
;
;***
; b$AlphaDim
;
;Purpose:
; Validate the proposed text dimensions and establish mode-dependent
; variables accordingly. This routine may indicate that the
; dimensions are invalid or unsupportable, or may request a change
; in screen mode where the dimensions are supported.
; NOTE: No actual change in screen mode occurs until SetMode is called!
;
;Entry:
; [BH] = number of lines
; [BL] = number of columns
;
;Exit:
; PSW.C = set if error
; [AL] = -1 if dimensions set in current mode or error,
; otherwise AL is SCREEN mode to invoke for desired dimensions
;
;Uses:
;Exceptions:
;******************************************************************************
;
;***
; b$SetMode
;
;Purpose:
; Set the screen mode according to the characteristics established
; by previous calls to B$Screenx and b$AlphaDim
;
;Entry:
;Exit:
;Uses:
;Exceptions:
;******************************************************************************
;***
; b$SetPages
;
;Purpose:
; Set the current active and visual pages and calculate page size
; and video segment offsets.
;
;Entry:
; [AL] = active page
; [AH] = visual page
;
;Exit:
;Uses:
;Exceptions:
;******************************************************************************
;***
; b$PalReset - Reset PALETTE to default state.
;OEM-interface routine
;
;Purpose:
; Reset the PALETTE to the initial, default colors. This routine
; is only called for the PALETTE command and when the screen modes
; change (note: screen initialization is a mode change).
;
; NOTE: b$PalReset is a variable through which the routine is
; indirectly called.
;
;Entry:
; None
;
;Exit:
; PSW.C is set to indicate an error.
;
;Uses:
; Per convention
;
;Exceptions:
; None.
;******************************************************************************
;***
; b$PalPut - Change palette entry
;OEM-interface routine
;
;Purpose:
; Change palette entry with translation/verification.
; A color value of negative one indicates that the associated
; palette entry is not to be modified.
;
; Before setting the palette, the color and attribute values
; are verified as legal and translated, if necessary, to the
; internal/hardware values. Attribute values are seen by the
; BASIC user as being contiguous, when in fact they may not
; be. Color values are similarly manipulated.
;
; NOTE: b$PalPut is a variable through which the routine is
; indirectly called.
;
;Entry:
; [DX:AX] = color
; [BL] = attribute
;
;Exit:
; PSW.C reset indicates successful operation
; set indicates PALETTE function call error
;
;Uses:
; Per convention
;
;Exceptions:
; None.
;******************************************************************************
;***
; b$PalTrans
;
;Purpose:
; User supplied color and attribute values are verified as legal
; and translated, if necessary, to internal/hardware values.
; Attribute values are seen by the BASIC user as being contiguous
; from 0 to b$MaxAttr, when in fact they may not be. This
; routine vector provides the opportunity for modes to map from the
; user supplied attribute to that which is actually used as a pixel
; value in video memory or as a palette index.
; Color values are similarly disguised and may also be manipulated
; in support of different monitors.
;
; NOTE: b$PalTrans is a variable through which the routine is
; indirectly called.
;
;Entry:
; [DX:AX] = internal color
; [BL] = internal attribute
;
;Exit:
; PSW.C reset if entry OK
; [DX:AX] = actual color
; [BL] = actual attribute
;
;Uses:
;Exceptions:
;******************************************************************************
;***
; b$PalSet - Set entire palette from an array
;OEM-interface routine
;
;Purpose:
; Set the entire palette from an array specified by the user. Each
; element of the array is a color value for the attribute which is
; the current index of the array. A color value of
; of -1 indicates the entry should be left alone. All entries are
; verified before any are set and are also translated, as needed.
; Verification and Translation are discussed in b$PalTrans (a non
; OEM interface routine) and b$PalPut.
;
; Special consideration must be made for the number of bytes per
; element in the array. Also, if there are not enough elements in
; the array to fill the palette, the return with PSW.C set for
; an Illegal Function Call.
;
; NOTE: b$PalSet is a variable through which the routine is
; indirectly called.
;
;Entry:
; [AX] = size of the array in elements
; [ES:SI] = address of the array
; [CX] = size of each array element in bytes (2 or 4)
;
;Exit:
; PSW.C set indicates function call error
;
;Uses:
; Per convention
;
;Exceptions:
; None.
;******************************************************************************
;***
; b$MapXYC - Map coordinates to graphics cursor
;OEM-interface routine
;
;Purpose:
; Move the graphics cursor to the pixel specified by the given
; coordinates. Both coordinates will always be within the screen
; boundaries and will already have been clipped to ensure that
; they are within the viewport.
;
; NOTE: b$MapXYC is a variable through which the routine is
; indirectly called.
;
;Entry:
; [CX] = X coordinate
; [DX] = Y coordinate
;
;Exit:
; Graphics Cursor location updated.
;
;Uses:
; Per convention
;
;Exceptions:
; None.
;******************************************************************************
;Our Exit Condition:
; b$OffC, b$MaskC updated
;***
; b$LeftC - Move graphics cursor left a pixel
;OEM-interface routine
;
;Purpose:
; Move graphics cursor left 1 pixel. No test is made for
; screen boundaries.
;
; NOTE: b$LeftC is a variable through which the routine is
; indirectly called.
;
;Entry:
; none
;
;Exit:
; Graphics Cursor location updated.
;
;Uses:
; Per convention
;
;Exceptions:
; None
;******************************************************************************
;Our Exit Condition:
; b$OffC, b$MaskC updated
;***
; b$ChkUpC - Move graphics cursor up a pixel, checking for upper boundary
;OEM-interface routine
;
;Purpose:
; This routine will move the graphics cursor up one pixel if it
; would stay within the viewport boundaries. If this move would
; make it leave the viewport, then PSW.C is set upon the return
; and no move is made. The viewport boundaries are specified by
; a previous call to B$MapVWC. Note that there does not have
; to be a separate check for screen boundaries, as the viewport
; defaults to the screen boundary.
;
; NOTE: b$ChkUpc is a variable through which the routine is
; indirectly called.
;
;Entry:
; None.
;
;Exit:
; PSW.C = set if original graphics cursor was on screen top edge.
; PSW.C = reset if cursor could move. Graphics Cursor location updated.
;
;Uses:
; Per convention
;
;Exceptions:
; None
;******************************************************************************
;Our Exit Condition:
; b$OffC, b$MaskC updated if cursor not on boundary.
;***
; b$UpC - Move graphics cursor up 1 pixel.
;OEM-interface routine
;
;Purpose:
; Move graphics cursor up 1 pixel. No test is made for
; screen or viewport boundaries.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -