home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
archives
/
ccdos.zip
/
cczibm.dat
< prev
next >
Wrap
Text File
|
1991-09-08
|
24KB
|
458 lines
public anstty, ansini, ansrei, ansdsl, anstat, anskbi ; Entry points
public ans52t, vclick, vsinit
public mar_top, mar_bot, anspflg, scroll ; data for msyibm
include ccsdef.h
; * Disclaimer *
;
; DEC and VT are trademarks of Digital Equipment Corporation.
;
; There is a naming convention
; for the ANSI and VT100 functions and flags; generally, the stuff in the
; symbol after "ans" or "at" is the function or mode mnemonic used in the
; VT100 manual.
;
; Every effort has been made to make the VT100 emulation as much like the
; real thing as possible. The reference used was the VT100 User's Guide, 2nd
; ed. Jan. 1979, DEC part no. EK-VT100-UG. Some aspects of the behavior
; of the terminal (e.g., the interaction of the "origin mode", limited
; scrolling region, and indexing), were gleaned from programming experiments
; on an actual VT100 terminal. Implemented features include: (1) Limited
; scolling region, (2) Settable tab stops, (3) Special "graphics" character
; set and UK ASII set, (4) All graphic renditions (underline, blink, and
; high intensity), (5) Simulated "LEDs" on the mode line, (6) Screen mode
; (normal or reverse video), (7) All terminal reports (status, active position,
; terminal parameters, and device attributes), (8) The ANSI new-line mode and
; several of the DEC private modes, including keypad application, cursor key,
; screen, auto-wrap, and origin, (9) cursor position/graphic rendition/
; character set save/restore, and last (and probably least): (10) VT52 com-
; patibility mode. Also, various details of behavior required by the ANSI
; standard (e.g. most control characters do not affect the interpretation of
; the current escape sequence, relative cursor positioning (up, down, left
; right, and of course tab) stop at the screen margins, etc.) have been
; scrupulously observed.
;
; This was the first thing I ever wrote in 8088 assembler (some of it was
; stolen from CCYIBM), and one of the constraints was that the emulator
; should work with a vanilla PC with a monochrome monitor. Given these and
; other constraints, no attempt was made to implement the following VT100
; features: (1) Smooth scolling, (2) 132 column lines, (3) Auto repeat,
; (5) Interlace/no interlace, (6) Double-width/double-height lines. The
; escape sequences to set and reset these are recognized, but ignored.
;
; - James A. Harvey, IUPUI Computing Services, DEC Systems Group
;
; * End of Disclamer *
; ---------------------------------------------------------------------------
;
; Description of the global entry points and calls on external routines
; needed by this emulator. [jrd]
;
; vsinit - start up routine called as Kermit initializes. Takes no arguments.
; Sets up address pointers to tabs, reads default terminal parameters
; reads current screen coloring. Examines and updates structure
; "vtemu." which is how mssset communicates changed information
; about many Set Term parameters; "flags." is a Kermit structure
; carrying the other Set Term parameters.
; anstty - starting point for displaying a character, delivered in AL.
; Returns when the display operation is completed and that may
; take many many instructions. All normal "characters received by
; the terminal" are provided by calling anstty with the char in AL.
; ansini - entry point to initialize the emulator. It requires information
; from msy in four registers: the Kermit terminal routine flags
; "yflags" (used mainly to sense debug mode and the mode line toggle)
; "low_rgt" (bh = row, bl = column of the lower right display corner)
; "lbaudtab" (index into baud rate table, for status reporting)
; "lpartab" (index into parity table, for status reporting)
; Ansini causes a full reset of the emulator, including screen
; clearing and a beep. Ansini is also called by msy in response to
; sensing the Alt = key combination to fully reset the emulator.
; ansrei - entry point to reinitialize the emulator. Nearly the same as
; ansini except operating flags, tabs, etc are retained from the
; previous emulator session. Items which can be changed by Set Term
; are examined and updated. The msy flags "yflags" are needed.
; This is the warm-restart entry point used when connect mode
; is reentered gracefully. The screen is cleared only if the coloring
; has changed. The starting cursor location is whereever msy puts it.
; ansdsl - display "led" (status line) information. Invoked by msy when
; the mode line is constructed so the emulator can write the
; terminal type and the VT100 led status lights when Connect mode
; is started. Requires "yflags" from msy to sense whether the mode
; line is to be shown.
; anstat - reports our working flags and screen coloring to msy. Nearly
; obselete but not quite. Reads msy "yflags" and reports "mlbattr"
; the video attributes used on the mode line, "scbattr" the video
; attributes of an empty character cell (background), "curattr"
; the video attributes of displayable characters, and "ansflgs"
; the emulator's working flags (needed for keyboard translations
; done in msy).
; anskbi - a routine called by msy to notify the emulator that a character
; is available from the keyboard. No character is read, just flag
; ttkbi is set. This is actually used only to beep when the cursor
; goes beyond column 72 and the margin bell flag is on.
; ans52t - called by msy to change terminal types "on the fly" without
; fully updating all operating parameters and without losing setup
; information. Msy senses the Alt minus key and calls ans52t with
; no arguments. Ans52t cycles among VT102, VT52 and Heath-19 modes.
; vclick - called by msy to cause a click sound. Simulates keyboard clicks,
; sort of anyway. No arguments.
; other modules in msy are called by this file to handle screen scrolling
; mode line on/off, output to the serial port (reports), screen
; particulars (location, cursor shape, blanking). The list is
; the set of code extrn procedures below; all are in file msy.
;
; data exchange is directly with msy to assist in scrolling (varaibles
; "mar_top", "mar_bot") and in sensing the non-connect
; mode screen coloring ("scbattr"). Screen coloring controlled by
; the emulator is not permitted to influence the non-connect mode
; screens whereas the emulator attempts to use the regular Kermit
; screen colors as defaults. The kind of terminal to emulate is
; held in byte "flags.vtflg" which is set by Set Term and by this
; module for global information within Kermit.
;
; The emulator assumes the screen is laid out in the manner of a conventional
; IBM monochrome or color graphics adapter running in 80 column TEXT
; modes. That layout is one word per displayable location starting at
; the upper left corner (0,0) and running contiguously to the lower
; right corner (24,79). Each word holds the displayable character in
; the low order byte and the display attributes in the high order
; byte. Attributes are, from high to low bits: blinking on, back-
; ground red, green, and blue on, high intensity, foreground red,
; green, and blue on. Normal white chars on a black field is 07H.
; The starting segment of screen memory is given by msy module
; "scrseg" to be TopView/MS Windows compatible. Msy module "scrsync"
; is used to inform these windowing environments of memory updates.
; Variable "crt_mode" is set by msy to indicate which IBM display
; mode is active; only the monochrome and CGA modes are recognized.
; Direct reading and writing of display memory is done, compatibly
; with TopView/Windows, to attain speed over Bios and DOS calls
; when editing of previously entered text is needed. However, IBM
; Bios interrupt 10H is used where possible for normal cursor
; movement/sensing and writing of new characters. See the IBM PC
; hardware Technical Reference Manuals for further details.
;
; Many things have been added, or modified since James Harvey donated this
; code to Columbia University for use in Kermit. [jrd]
; ---------------------------------------------------------------------------
screen equ 10h ; Bios screen call
swidth equ 132 ; assumed max screen width [dlk]
slen equ 60 ; assumed max screen length [jrd]
att_low_mask equ 06H ; Various attribute-related equates
;;;att_reverse equ 70H ; these two are now storable items
;;;att_normal equ 07H ; to allow external settings. [jrd]
att_underline equ 01H
att_intensity equ 08H
att_blink equ 80H
; VT100 status flags ansflg
;anslnm equ 01H ; ANSI line feed/new line mode
;decckm equ 02H ; VT100 cursor keys mode
;deckpam equ 04H ; VT100 keypad application mode
;decscnm equ 08H ; VT100 screen mode (n.y.i.)
;decom equ 10H ; VT100 origin mode
;decawm equ 20H ; VT100 autowrap mode
;decanm equ 40H ; ANSI(VT100)/VT52 mode
;dececho equ 80H ; ANSI local echo on (1)
;;;;;;;;;;;;;;;; items for reference from mssdef.h ;;;;;;;;;;;;;
; VT100 SETUP mode flags
;vswdir equ 80H ; Writing direction (0=left to right)
;vsscreen equ 40H ; Screen mode (0 = normal video)
;vscursor equ 20H ; Cursor (0 = block)
;vsmarginbell equ 10H ; Margin bell (0 = off)
;vskeyclick equ 08H ; Keyclick (0 = off)
;vsshift3 equ 04H ; Shift-3 (0 = American pound sign)
;vswrap equ 02H ; Line wrap around (0 = no wrap)
;vsnewline equ 01H ; ANSI new line (0 = off)
;vsdefaults equ 0+vscursor
;[IU1] Definitions for terminal emulation
;TTGENRC EQU 0 ; Type 0 - TTY (no special emulation)
;TTHEATH EQU 1 ; Type 1 - HEATH 19
;TTVT52 EQU 2 ; Type 2 - VT52
;TTVT100 EQU 3 ; Type 3 - ANSI (VT100 subset)
;TTTEK EQU 4 ; Type 4: Tektronix 4010
;TTTYPES equ 5 ; Number of terminal types defined
;emulst struc ; structure of vtemu.xxx for VT100 emulator
;vtflgst db 0 ; VT100 setup flags (from SET)
;vtflgop db 0 ; VT100 runtime flags, like setup flags (here & STAT)
;vttbs dw 0 ; pointer to default tab stops, for SET
;vttbst dw 0 ; pointer to active tab stops, for STATUS
;vtchset db 1 ; value of default character set (1=US-ascii)
;att_ptr dw 0 ; pointer to normal & reverse video attributes
;emulst ends
;;;;;;;;;;;;;;;; end references ;;;;;;;;;;;;;;;;;;;;
datas segment public 'datas'
extrn vtemu:byte, crt_mode:byte, scbattr:byte, flags:byte
extrn crt_lins:byte, crt_cols:byte, rxtable:byte, denyflg:word
extrn tekflg:byte
extrn isccdos:byte ; Jun 25,1990
; Early versions of MASM have a bug that causes it to consider the
; expression (offset foo) as non-relocatable if used in an arithmetic
; operation (for example, "sub di,offset foo"), and if foo is defined
; within the first 256 bytes of the data segment.
; ANSI special character table - 32 entries indexed by control char value
ansspc dw 5 dup (atign) ; ignore NUL,SOH,STX,ETX,EOT
dw atign ; ENQ - answerback message
dw atign ; ACK - ignore
dw atbel ; BEL - ring terminal bell
dw atbs ; BS - ANSI backspace
dw atht ; HT - ANSI tab
dw atlf ; LF - ANSI line feed
dw atlf ; VT - Interpreted as ANSI LF
dw atff ; FF - do as LF (but ESC FF does Tek)
dw atcr ; CR - ANSI carriage-return
dw atso ; SO - Select char set G1
dw atsi ; SI - Select char set G0
dw 8 DUP (atign) ; ignore DLE,DC1,DC2,DC3,DE4,NAK,SYN,ETB
dw atcan ; CAN - cancel ANSI sequence
dw atign ; EM - ignore
dw atcan ; SUB - treat as CAN
dw atesc ; ESC - ANSI CSI
dw 4 DUP (atign) ; ignore FS,GS,RS,US
; Heath-19 mode escape follower table
h19esc db 'YABCD', 'KIHJF', 'G=><Z', 'ELM'
db 'NO@p', 'qvwjk', 'xynz', 'blor'
lh19esc equ $-h19esc
; Dispatch table for Heath-19 escape sequence table h19esc.
; Two byte sequences of the form ESC char, where char is not in the
; table above, are completely ignored.
h19ejt dw v52pos,atcuu,h19cud,h19cuf,atbs ; 'YABCD'
dw atel,atri,atcup,ated,v52egm ; 'KIHJF'
dw v52xgm,atkpam,atkpnm,h19ans,decid ; 'G=><Z'
dw h19clrs,inslin,dellin ; 'ELM'
dw atdelc,noins,entins,h19herv ; 'NO@p'
dw h19hxrv,h19wrap,h19nowrp,atsc,atrc ; 'qvwjk'
dw h19smod,h19cmod,hrcup,atreset ; 'xynz'
dw h19erb,h19erl,h19ero,h19mbr ; 'blor'
; Heath-19 special graphics characters. Use as offsets from caret (94D)
hgrtab db 249,17,179,196,197 ; caret,underscore,accent grave,a,b
db 191,217,192,218,241 ; c,d,e,f,g
db 26,219,246,25,220 ; h,i,j,k,l
db 220,223,223,223,222 ; m,n,o,p,q
db 16,203,185,202,204 ; r,s,t,u,v
db 'X','/','\','-','-' ; w,x,y,z,{
db 221,222,20 ; |,},~
; VT52 compatibility mode escape follower table
v52esc db 'Y','A','B','C','D'
db 'K','I','H','J','F'
db 'G','=','>','<','Z'
db '7','8','c','^','_'
db 'W','X',']','V'
lv52esc equ $-v52esc ; length of table
; Dispatch for v52esc table
v52ejt dw v52pos,atcuu,atcud,atcuf,atcub
dw atel,atri,atcup,ated,v52egm
dw v52xgm,atkpam,atkpnm,v52ans,decid
dw atsc,atrc,v52ris,v52apb,v52ape
dw v52pcb,v52pce,v52ps,v52pl
; ANSI escape special character table
ansesc db '[','D','E','M','H'
db '7','8','=','>','c'
db '(',')','#','Z','<'
db 'P','*','+',7bh ; 7bh is left curly brace
lansesc equ $-ansesc ; length of table
; Dispatch for ansesc table
ansejt dw atcsi,atind,atnel,atri,athts
dw atsc,atrc,atkpam,atkpnm,atris
dw atsg0,atsg1,atsdhl,at52id,atnorm
dw atpriv,atpriv,atpriv,atnorm
; Final char table for ANSI escape sequences (ESC [ Pn ; ... Pm ch)
anstab db 'H','A','B','C','D'
db 'K','J','m','g','r'
db 'c','q','x','n','f'
db 'l','h','y','P','L'
db 'M','i','s','u','z'
db '@'
lanstab equ $-anstab ; Define table length
; Dispatch for anstab table
ansjmp dw atcup,atcuu,atcud,atcuf,atcub
dw atel,ated,atsgr,attbc,atstbm
dw atda,atll,atreqt,atdsr,atcup
dw atrm,atsm,atctst,atdelc,inslin
dw dellin,ansprt,htsc,htrc,htrest
dw ansich
; "Special graphics" set translation table for characters 137 (octal)
; through 176 when the special graphics set is selected. Some characters
; (142, 143, 144, 145, 150, 151, 157, 160, 162, 163, and 174) do not
; have exact equivalents in the available set on the IBM, so a (some-
; times reasonably close) substitution is made. Table is indexed by
; ASCII char value minus 137 octal for chars 137-176 octal.
sgrtab db 032,004,177,026,023
db 027,025,248,241,021
db 018,217,191,218,192
db 197,196,196,196,196
db 196,195,180,193,194
db 179,243,242,227,157
db 156,250
; Device attributes response string. (Note: If "with AVO" causes problems,
; change the last parameter from "2" to "0". The default is to indicate
; the AVO option is present because the emulator can set all of the graphic
; rendition attributes (bold, blink, etc.) independently). A VT100 reports
; as ESC [ ? 1 ; 2 c but a VT102 uses ESC [ ? 6 ; 2 c.
;;;dastr db escape,'[?6;2c',0 ; VT102
dastr db escape,'[?6c',0 ; shortened to help some mainframes
db 5 dup (0) ; patch space
; Identify response used while in VT52 compatibility mode
v52str db escape,'/Z',0
db 5 dup (0) ; patch space
; Identify response when a Heath-19 terminal
h19str db escape,'/K',0
db 5 dup (0) ; patch space
; ANSI Escape sequence to turn off Media Copy (Print Controller Off)
mcoffs db 24 dup (0) ; received chars in sequence
mccnt dw 0 ; counter of matched char in mcoff
; Parity code translation table
partab db 5 ; Even
db 3 ; Mark
db 1 ; None
db 4 ; Odd
db 2 ; Space
lpartab equ $-partab
; Baud rate code translation table
baudtab db 0 ; 45.5 - no VT100 code (call it 50)
db 0 ; 50
db 8 ; 75
db 16 ; 110
db 24 ; 134.5
db 32 ; 150
db 48 ; 300
db 56 ; 600
db 64 ; 1200
db 72 ; 1800
db 80 ; 2000
db 88 ; 2400
db 104 ; 4800
db 112 ; 9600
db 120 ; 19200
db 128 ; 38400 extended beyond DEC
lbaudtab equ $-baudtab
belcol db ? ; column at which to ring margin bell
yflags db ? ; Flags from CCYxxx term routine
oldbatr db ? ; old scbattr
oldterm db ? ; terminal type from previous entry
escdec db 0 ; DEC private sequence (ESC [ ?) seen
decmode equ 80H ; "?" seen in lead-in
baudidx db ? ; Index into baud rate table
parcode db ? ; Parity code (0-4)
datbits db ? ; Number of databits (7 or 8)
savflgs db ? ; Saved flags for atsc/atrc
modeset db ? ; Temp for atsm/atrm
h19mod db ? ; flag for atsm/atrm
h19l25 db ? ; Heath-19 25th line enabled flag
insmod db ? ; Insert mode on (1) or off (0)
kbicsr dw ? ; Cursor when keyboard input typed
kbiflg db ? ; Set/reset for keyboard input
ttstate dw offset atnrm ; terminal automata state
; Start of stuff to save for ESC 7 fxn
ukset equ 0 ; Set 1 = UK ASCII set
ascset equ 1 ; Set 2 = US ASCII set
sgrset equ 2 ; Set 3 = "Special graphics set"
alcset equ 3 ; Set 4 = "Alt. Character Set" [bk]
svattr_index equ 0 ; To set saved cursor attribute only
curattr db 07h ; Cursor attribute
cursor dw 0 ; Cursor position
video_state db 0 ; video state (0=normal,1=reversed)
chr_set dw offset chr_sg0 ; Ptr. to currently selected char set
chr_sg0 db ascset ; Current SG0 set
chr_sg1 db ascset ; Current SG1 set
lsavecu equ $-curattr ; Length of stuff to save
savecu db lsavecu dup (?) ; Saved cursor, attr., charset, etc
h19ctyp db 1 ; H-19 cursor type (1=ul, 2=bk, 4=off)
att_normal db 07H ; retain order: normal then reverse
att_reverse db 70H
mlbattr db ? ; Mode line background attribute
ansflgs db 0 ; ANSI/VT100 mode flags
; (flags are defined in mssdefs.h)
vtflags db 0 ; VT100 SETUP flags
; (SETUP flags are defined in mssdefs.h)
tmpflags db 0 ; (Temporary for asnrei/stblmds)
; (tab stops are stored here)
tabs db swidth dup (?) ; active tab stops
deftabs db swidth dup (?) ; default tab stops
vttabs dw 0 ; Pointer to default VT100 tab stops
; byte per line, type of line: 0=normal, 1=double wide, 2=double high
linetype db slen dup (0)
linelen db 79 ; active screen line length (79, 131)
low_rgt dw 0 ; text screen dimensions
; byte low_rgt = max columns (79)
; byte low_rgt+1 = max rows (23)
oldscrn dw 0 ; old screen. hi=rows-1, low=cols-1
ttkbi db 0 ; Flag for keyboard input seen
; Scrolling region - do not separate or change order of mar_top & mar_bot
mar_top db ? ; Scrolling region top margin
mar_bot db ? ; Scrolling region bottom margin
scroll db 1 ; lines to scroll
led_col equ 65 ; column position for "LEDs" display
led_off equ '.' ; "Off" LED
ansleds db 'VT102 ....' ; "LEDs".Terminal ident (10 bytes)
v52leds db ' VT52 ' ; This is used in VT52 mode
h19leds db ' Heath-19 ' ; For Heath-19 mode
nansarg db 0 ; Index for ANSI argument list
ansargs db 16 dup (0) ; Room for 16 ANSI arguments
lansarg equ $-ansargs ; Max number of ANSI arguments
; printer support data
anspflg db 0 ; printer flag bits and definitions
vtautop equ 1 ; autoprint enabled (1)
vtcntp equ 2 ; controller print enabled (1)
vtextp equ 4 ; printer extent set (1)
vtffp equ 8 ; form feed wanted at end of print (1)
datas ends