📄 gwscr.asm
字号:
; AH - 0 if no parameter specified, else 1
; AL - parameter specified by user iff AH <> 0
; psw.z - set if no parameter was specified
;Uses:
; None.
;Exceptions:
; None.
;****
cProc GetCsrParm,<NEAR>,<DX>
cBegin
MOV DH,1 ;default is parm specified
cCall B$GetParm ;call low level routine to get parm
JNZ GCP10 ;brif got parm in [AL]
DEC DH ;no parm was specified (sets psw.z)
GCP10:
MOV AH,DH ;[AH]=flag, [AL]=parm iff AH<>0
cEnd
SUBTTL CLS statement
PAGE
;***
; B$SCLS - clear text/graphics/both screens. Re-written as revision [15].
;
; Purpose:
; This statement may have an optional byte parameter. The value
; of this parameter indicates what area of the screen is to be cleared.
;
; CLS (no param)
; if text mode:
; clear text window (VIEW PRINT)
; refresh function keys (if on, else blank the line)
; home the cursor in text window
; if graphics and viewport (VIEW):
; clear defined graphics viewport
; initialize graphics viewport variables
; if graphics, but no viewport (no VIEW):
; clear all text and graphics
; initialize graphics viewport variables
; refresh function keys (if on, else blank the line)
; home the cursor in text window
; CLS 0
; clear all text and graphics
; initialize graphics viewport variables
; refresh function keys (if on, else blank the line)
; home the cursor in text window
; CLS 1
; if text mode:
; no-operation (return immediately)
; if graphics and viewport (VIEW):
; clear defined graphics viewport
; initialize graphics viewport variables
; if graphics, but no viewport (no VIEW):
; clear all text and graphics
; initialize graphics viewport variables
; refresh function keys (if on, else blank the line)
; home the cursor in text window
; CLS 2
; clear text window (VIEW PRINT)
; home the cursor in text window
;
; Entry:
; ScnNum - screen to clear
; Exit:
; None.
; Uses:
; Per convention.
; Exceptions:
; B$ERR_FC
;****
cProc B$SCLS,<PUBLIC,FAR>
parmW ScnNum ;screen number to clear
cBegin
MOV BX,ScnNum ;keep screen number in BX
INC BX ;test if parameter was given
JNZ ClsParamGiven ;if given, then jump
MOV AX,0602H ;assume CLS 2 with key and text refresh
CALL B$GRMODE ;test if graphics mode
JZ ClsStart ;if not, use assumed value
MOV AX,0101H ;assume CLS 1 with only graphic vp init
CMP B$VIEWSW,0 ;test if viewport active
JNZ ClsStart ;if so, use assumed value
MOV AX,0700H ;else CLS 0 with full initialization
JMP SHORT ClsStart ;process the initialization
ClsParamGiven:
DEC BX ;restore parameter
CMP BX,2 ;test upper limit of parameter
JA ClsError ;if over, then report error
MOV AL,BL ;get lower byte of parameter
MOV AH,7 ;assume full initialization
CMP AL,1 ;test the parameter value
JB ClsStart ;if CLS 0, then full initialization
MOV AH,4 ;assume just redisplay keys after clear
JA ClsStart ;if CLS 2, then text initialization
CALL B$GRMODE ;else CLS 1, test for graphics mode
JZ ClsReturn ;if no graphics mode, then just return
MOV AH,1 ;just erase the viewport
CMP B$VIEWSW,0 ;test if viewport active
JNZ ClsStart ;if so, then just redisplay keys
MOV AH,7 ;else erase screen and redisplay keys
; AL contains the mode for the call to B$CLRSCN.
; AH contains a bit mask to execute the proper combination
; of routines after B$CLRSCN.
; 1 - clear the graphics viewport
; 2 - refresh the function key display
; 4 - home the cursor to the current text window
ClsStart:
CALL B$CLRSCN ; clear the screen with value in AL
JB ClsError ;if error, then jump to report it
TEST AH,1 ;test if graphics viewport is initialized
JZ ClsNoViewInit ;if not, then jump
PUSH AX ;save bit mode and bit mask over call
CALL [b$VWCLR_PTR] ;initialize viewport variables
POP AX ;and restore it
ClsNoViewInit:
TEST AH,2 ; test if keys are to be redisplayed
JZ ClsNoKeys ; brif not
CALL B$KEYDSP ; redisplay key line or blank last line
ClsNoKeys:
TEST AH,4 ; test if text cursor to be homed
JZ ClsReturn ; brif not
CALL B$WHOME ; DX has home position
CALL B$SCNLOC ; display user cursor. TRASHES AX, so
; don't get any ideas about moving this
; up before the call to B$KEYDSP.
ClsReturn:
cEnd
ClsError:
JMP B$ERR_FC ;Bad Parm, complain.
SUBTTL CSRLIN and POS functions
PAGE
;***
;B$CSRL - return current line (row) of the cursor
;
;Purpose:
; Runtime enty point.
; Return current 1-relative line (row) of the cursor on the screen.
;Entry:
; None.
;Exit:
; AX = screen row
;Uses:
; Per convention
;Exceptions:
; None.
;****
cProc B$CSRL,<PUBLIC,FAR>
cBegin
MOV DX,b$CURSOR ; place screen row in DL, column in DH
CMP DH,b$CRTWIDTH ; past last physical column?
JBE VALUE_OK ; brif not -- row is ok
CALL B$CRLF ; adjust DL, DH trashed by CBW anyway
VALUE_OK:
XCHG AX,DX ; return line in AL
CBW ; clear high byte
cEnd
;***
; B$FPOS - POS(n) function
;
; Purpose:
; Runtime Entry Point.
; Return the 1-relative horizontal screen position of the cursor.
; Input:
; NONE
; Output:
; AX= position (1-relative)
; Modifies:
; F
; Exceptions:
; NONE
;****
cProc B$FPOS,<PUBLIC,FAR>
parmW Dummy
cBegin
MOV AL,b$CSRX ; get 1-relative column position
CMP AL,b$CRTWIDTH ; past last physical column?
JBE POS_OK ; brif not -- value OK
MOV AL,1 ; assume first column
POS_OK:
CBW ; clear high byte
cEnd
SUBTTL KEY statement
PAGE
;***
;B$KFUN - KEY ON, KEY OFF, KEY LIST
;
;Purpose:
; Runtime Entry Point.
; Executes KEY ON, KEY OFF, or KEY LIST depending on input
;Entry:
; fAction = 0 - KEY OFF
; 1 - KEY ON
; 2 - KEY LIST
;Exit:
; None.
;Uses:
; Per convention.
;Exceptions:
; None.
;****
cProc B$KFUN,<PUBLIC,FAR>
parmW fAction
cBegin
MOV AX,100H ;AH=scroll delta, AL=scroll flag (off)
MOV CX,fAction ;get action flag
JCXZ KEYOFF ;key off
LOOP KEYLST ;brif Key list
; KEY ON...
MOV AX,-1 ;AH=scroll delta, AL=scroll flag (ON)
KEYOFF:
CMP AL,b$KEY_SW ;state change?
MOV b$KEY_SW,AL
JZ KEYXX ;Brif same, do nothing
CALL B$KEYDSP ;On, Display on 25th line.
JMP SHORT KEYXX ;exit
KEYLST:
DbAssertRel CX,E,1,CN_TEXT,<Illegal flag as input for B$KFUN>
CALL KEYLIST
KEYXX:
cEnd
PAGE
;***
;KEYLIST - List function key definitions
;
;Purpose:
; Prints all currently defined function keys.
;Entry:
; None.
;Exit:
; None.
;Uses:
; Per convention.
;Exceptions:
; None.
;****
cProc KEYLIST,<NEAR>,<SI,DI>
cBegin
MOV DI,OFFSET DGROUP:b$STRTAB ;function key str descriptors
MOV CX,NUM_FKEYS ; Keys to the Screen, default 12 for Ronco
XOR DL,DL ;DL = FN key counter
TEST b$RcoFlg,0FFH ; is Ronco keyboard presented ?
JNZ KEY_LIST_0 ; Brif yes
DEC CX
DEC CX ; AT keyboard has 10 function keys
KEY_LIST_0:
INC DL
MOV AL,"F"
CALL B$$WCHT
CALL KEY_DSP_NUM ;Display the Key number.
MOV AL," "
CALL B$$WCHT
PUSH CX
MOV CX,[DI] ;get char count of string
JCXZ KEY_LIST_3
MOV SI,[DI+2] ;get ptr to string
KEY_LIST_1:
LODSB
OR AL,AL
JZ KEY_LIST_3
CMP AL,ASCCR
JNZ KEY_LIST_2
MOV AL," "
KEY_LIST_2:
CALL B$$WCHT
LOOP KEY_LIST_1
KEY_LIST_3:
MOV AL,ASCCR
CALL B$$WCHT
POP CX
ADD DI,4 ;point to next FN key SD
LOOP KEY_LIST_0
cEnd
PAGE
;***
;KEY_DSP_NUM - convert function key number to 2 chars and display them
;
;Purpose:
; Converts function key number in DL to ascii chars and
; displays 2 chars (leading space if num < 10
;Entry:
; DL - function key number
;Exit:
; None.
;Uses:
; Per convention.
;Preserves:
; BX,CX,DX
;Exceptions:
; None.
;****
cProc KEY_DSP_NUM,<NEAR>
cBegin
MOV AL,DL ;get fn key number
AAM
OR AX,"00"
CMP AH,"0"
JNZ KEY_DSP_NUM2
XCHG AH,AL
MOV AL," "
KEY_DSP_NUM2:
PUSH AX
MOV AL,AH
CALL B$$WCHT ;Output MSD
POP AX
JMP B$$WCHT ;Output LSD
cEnd nogen ;returns through B$$WCHT
SUBTTL Screen function
PAGE
;***
;B$FSCN - SCREEN Function
;
;Purpose:
; Syntax: x = SCREEN(row,col [,z])
;
; Returns the Ordinal of the char on the screen
; at row,col.
;
; If z is given, and non-zero, then:
; Returns the Color Attribute of the character
; on the screen at row,col.
;Entry:
; Row
; Column
; fAttr - If non-zero then return Attribute.
; If zero then return character Ordinal.
;Exit:
; [AX] - Contains character ordinal or attribute value.
;Uses:
; Per Convention
;Exceptions:
; B$ERR_FC
;****
cProc B$FSCN,<PUBLIC,FAR>
parmW Row
parmW Column
parmW fAttr
cBegin
MOV DX,Row
MOV AX,Column
OR AH,DH
JNZ SCF_ERROR ;Out of range if either GT 255
; It is assumed that both b$CRTWIDTH & B$LINCNT will be less than 255
DEC DX ; For comparison purposes make AX & DX
DEC AX ; 0-relative
CMP AL,b$CRTWIDTH ; Is Y greater than the number of rows?
JAE SCF_ERROR ;Error if so.
CMP DL,B$LINCNT ;Check for parameter range
JAE SCF_ERROR ;1..B$LINCNT-1 if keys on, 1..B$LINCNT if off
INC DX ; Bring AX & DX back
INC AX ; to 1-relative values
MOV DH,AL ;DH=col, DL=row
cCALL B$SCREEN ; [AX] = Char read at position
; [BX] = Attribute at position
XCHG AX,BX ; Get Attribute in AX
CMP fAttr,0 ; Was attribute wanted?
JNE FSCN_RET ; Brif so - AX contains attribute
XCHG AX,BX ; AX = Character
; else return character in AX
FSCN_RET: ; Common exit point
cEnd
SCF_ERROR:
JMP B$ERR_FC ;Generic Complaint
sEnd CN_TEXT
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -