📄 gwscr.asm
字号:
TITLE GWSCR - GENERAL support for LOCATE, SCREEN stmt & fct,COLOR, CLS
;***
; GWSCR - GENERAL support for LOCATE, SCREEN stmt & fct,COLOR, CLS
;
; Copyright <C> 1986, Microsoft Corporation
;
;Purpose:
;
; BASIC Syntax mapping to included runtime entry points:
;
;
; - CLS Statement:
;
; CLS [0,1,2]
; |
; B$SCLS
;
;
; - COLOR Statement:
;
; Text:
; COLOR [foreground] [,[background] [,border]]
;
; Graphics:
; COLOR [background] [,[palette]]
;
; COLOR 1,2,3
; |
; B$COLR
;
;
; - CSRLIN Function:
;
; v = CSRLIN
; |
; B$CSRL
;
;
; - KEY Statement - calls B$KFUN or B$KMAP depending on syntax:
;
; KEY (ON | OFF | LIST | (n,x$))
;
; The first 3 possibilities cause $KY0 to be called, $KY1 for the 4rth:
;
; KEY (ON | OFF | LIST) KEY n,x$
; --------------------- --------
; | |
; B$KFUN B$KMAP
;
;
; - LOCATE Statement:
;
; LOCATE [row][,[col][,[cursor][,[start][,stop]]]]
;
; LOCATE 1,1
; |
; B$LOCT
;
;
; - POS Function:
;
; POS(I)
; |
; B$FPOS
;
;
; - SCREEN Function:
;
; v = SCREEN(row, col [,z])
; |
; B$FSCN
;
;******************************************************************************
INCLUDE switch.inc
INCLUDE rmacros.inc ;Runtime Macro Defintions
USESEG _DATA
USESEG _BSS
USESEG CN_TEXT
USESEG RT_TEXT
INCLUDE seg.inc
INCLUDE ascii.inc ;must follow switch.inc
INCLUDE idmac.inc
sBegin _DATA
externW b$CURSOR ; (1,1)-relative screen cursor
externB b$CSRY ; 1-relative y-coordinate cursor
externB b$CSRX ; 1-relative x-coordinate cursor
externB b$LINCNT
externB b$WDOBOT
externB b$WDOTOP
externB b$CRTWIDTH
externW b$VWCLR_PTR
sEnd _DATA
sBegin _BSS
externB b$RcoFlg ;NZ if Ronco keyboard present
externB b$KEY_SW ;defined in GWDATA.ASM
externW b$STRTAB ;defined in GWDATA.ASM
externB B$VIEWSW ; defined in GWDATA.ASM
sEnd _BSS
assumes CS,CN_TEXT
sBegin CN_TEXT
externNP B$SETCLR
externNP B$GetParm
externNP B$KEYDSP
externNP B$WHOME
externNP B$SCNLOC
externNP B$ERR_FC
externNP B$CSRATR
externNP B$CLRSCN
externNP B$GRMODE
externNP B$$WCHT
externNP B$SCREEN ; new name for $SCRATR & $SCRINP
externNP B$SCINIT ; init screen if not already done
externNP B$CRLF ; perform CR/LF processing
SUBTTL COLOR statement
PAGE
;***
;B$COLR - execute COLOR Statement
;void pascal B$COLR([I2 flag,<I2 parm>]...,cwParams)
;
;Purpose:
; Pass parameters on to low level COLOR statement routine (SetColor).
; There is one flag per parameter. If flag is zero, then the parameter
; was defaulted. If flag is non-zero, the next word in parameter
; block contains user specifed value. No dummy values are specified.
;Entry:
; parameter block is on stack. First word is count of params, excluding
; the count parameter.
;Exit:
; None.
;Uses:
; Per convention
;Exceptions:
; Could result in a jump to B$ERR_FC if parameter is too large
; or if some error occurs in SetColor
;****
cProc B$COLR,<PUBLIC,FAR>
cBegin <nogen>
cCall B$ScSetup ;set up frame, parms
CALL B$SETCLR ;call low level COLOR statement support
JB FUNC_ERROR ;brif error occurred
cEnd <nogen> ;fall into routine to clean up and return
SUBTTL COLOR/SCREEN/LOCATE statement support
PAGE
;***
;CleanUpParms - clean a variable number of parameters off of the stack and ret
;
;Purpose:
; This routine cleans a variable length parameter block off of the
; stack and does a far ret back to the caller.
;Entry:
; Stack contains -
;
; | first parm |
; +---------------+
; | |
; \ /
; | |
; +---------------+
; | last parm |
; +---------------+
; | cw parms |
; +---------------+
; | return seg |
; +---------------+
; | return off |
; +---------------+
; | old BP |
; +---------------+
; SP -> | saved SI |
; +---------------+
;Exit:
; Stack cleaned
;Uses:
; Per convention
;Exceptions:
; None.
;NOTE:
; This routine should be jumped into...
;****
cProc B$ScCleanUpParms,<FAR,PUBLIC>
cBegin
POP SI
POP ES
POP BP ;recover BP
POP AX ;get return offset
POP DX ;get return segment
POP CX ;get count of parms
SHL CX,1 ;convert word count to byte count
ADD SP,CX ;clean up parms
PUSH DX ;replace segment
PUSH AX ;replace offset
cEnd
PAGE
;***
;B$ScSetup - Preamble for LOCATE, COLOR, and SCREEN statements
;
;Purpose:
; Does initial setup of parameters for LOCATE, COLOR,
; and SCREEN statements.
;Entry:
; BX - CS relative address to exit to.
; parameter block is on stack. First word is count of params, excluding
; the count parameter.
; Stack contains -
;
; | first parm |
; +---------------+
; | |
; \ /
; | |
; +---------------+
; | last parm |
; +---------------+
; | cw parms |
; +---------------+
; | return seg |
; +---------------+
; | return off |
; +---------------+
; | near ret |
; +---------------+
;Exit:
; initial SI is pushed on stack
; CX - count of words in parameter block
; SI - ptr to start of parameter block (grows down in memory).
;Uses:
; Per convention
;Exceptions:
; None.
;****
cProc B$ScSetup,<NEAR,PUBLIC>
parmW parmBlock ;beginning of parameter block
parmW cwParms ;word count of parameter block
parmW retAddr ;return address of compiled/interp code
cBegin <nogen>
POP BX ;get near return addr
PUSH BP ;set up ...
MOV BP,SP ;... stack frame
PUSH ES ;save ES
PUSH SI ;preserve SI
MOV CX,cwParms ;get param count
MOV AX,CX ;convert cwParms to cbParms
SHL AX,1
LEA SI,cwParms ;get pointer to end of block
ADD SI,AX ;point to start of block
JMP BX ;return to caller
cEnd <nogen>
FUNC_ERROR:
JMP B$ERR_FC ;Bad Parm, complain.
SUBTTL LOCATE statement
PAGE
;***
;B$LOCT - execute the LOCATE Statement
;
;Purpose:
; LOCATE - Moves the Cursor to the Specified position
; on the Active Screen. Optionally:
; 1). Turns the Cursor on/off.
; 2). Allows setting of the Cursor Start/Stop
; Raster Lines.
;
; Syntax: LOCATE [row] [, [col] [,[cursor] [, [start] [, [stop] ]]
;
; WHERE: row is Screen line number 1 to B$LINCNT-1 if KEY ON.
; row is Screen line number 1 to B$LINCNT if KEY OFF.
; col is Screen column number. 1 to 40 or 1 to 80
; depending on WIDTH.
;
; If Row and/or Column are missing, the current
; value(s) are used.
;
; cursor is a boolean value indicating whether
; the cursor is visible or not.
; 0 for off, non-zero for on.
;
; start is the Cursor Start Raster Line (0-31).
; stop is the Cursor End Raster Line (0-31).
; If omitted, stop assumes start value.
;
; The Cursor Raster Start/Stop parms are optional.
; Cursor Blink is not selectable and always set
; at 1/16 Rate...
;
;Entry:
; parameter block is on stack. First word is count of params, excluding
; the count parameter.
;Exit:
; None.
;Uses:
; None.
;Exceptions:
; Control may be transfered to B$ERR_FC
;****
cProc B$LOCT,<PUBLIC,FAR>
cBegin <nogen>
cCall B$ScSetup ;set up frame, parms
cCall GetCsrParm ;not psw.z if got parm in [AL],flg in [AH]
JNZ LOCT20 ;brif got parm
MOV AL,b$CSRY ;get current y coord
LOCT20:
PUSH AX ;save flag/row
cCall GetCsrParm ;get column if specified
JNZ LOCT30 ;brif got column
MOV AL,b$CSRX ;get current column
LOCT30:
PUSH AX ;save flag/column
cCall GetCsrParm ;get cursor parm if specified
XCHG AX,DX ;[DX]=cursor flag/type
cCall GetCsrParm ;get start raster if specified
XCHG AX,BX ;[BX]=cursor flag/start raster
cCall GetCsrParm ;get stop raster if specified
XCHG AX,CX ;[CX]=cursor flag/stop raster
XCHG AX,DX ;[AX]=cursor type for ll call
cCall B$CSRATR ;let low level do it's thing with cursor
JB FUNC_ERROR ;brif ll error
POP CX ;[CX]=flag/column
POP DX ;[DX]=flag/row
OR DH,DH ;was row specified?
JZ ChkCol ;brif not - go check column
; here if the row parameter was specified
OR DL,DL ;check if new row zero
JZ FUNC_ERROR ;if so, then error
MOV AL,DL
CMP AL,b$WDOBOT ;don't allow locate to outside text window
JBE StoreRow ; if row < wdobot check against top
CMP b$KEY_SW,0 ; function keys on ?
JNE FUNC_ERROR ; Brif so
CMP AL,B$LINCNT ; is row same as B$LINCNT ?
JNE FUNC_ERROR ; Brif not (This is the only time
; a locate outside textt window
; is allowed
StoreRow:
CMP AL,b$WDOTOP ; don't allow locate above text window
JB FUNC_ERROR ; brif above text window
ChkCol:
DEC CH ;was new column specified?
JNZ SetPos ;brif not - go set cursor position
; Here if new column was specified...
JCXZ FUNC_ERROR ;Must be 1 to Width (40 or 80).
CMP CL,b$CRTWIDTH ; Test against physical screen width
JA FUNC_ERROR ;Error if Col is GT than Width.
SetPos:
CALL B$SCINIT ; Init screen if not already done. Makes
; sure that if this is the first screen
; operation, that the next locate operation
; can go to any line it wants to.
MOV DH,CL ;DH=col,DL=row
CALL B$SCNLOC ; Store DX into b$CURSOR, and display
; user cursor at new position
JMP B$ScCleanUpParms;clean up stack and exit...
cEnd <nogen>
PAGE
;***
;GetCsrParm - Get a locate statement parameter if specified by user
;
;Purpose:
; Gets a parameter for locate statement if one was specified
; by the user.
;Entry:
; SI - points to next parameter flag in parameter block
; CX - count of words left in parameter block
;Exit:
; SI,CX - advanced over parmeter flag and parameter
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -