title VT100
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; -----------------------------------
;; VT100 EMULATOR PROM
;; (C) Copyright 1995 Gregory Ercolano
;; -----------------------------------
;;
;; VERSION DATE AUTHOR COMMENTS
;; 1.00 04/21/95 erco@3dsite.com Initial burst of energy
;; 1.01 11/16/96 erco@3dsite.com Second burst of energy
;;
;; Description:
;; vt100 terminal emulator. Intended to be burned on a prom, or
;; tested in ram. Here's how to compile the code:
;;
;; masm this;
;; link this;
;; promprep this.exe prom.out # convert to binary
;;
;; ..'prom.out' will be a 65536 byte binary ready to burn onto the prom.
;; 'promprep' simply pads out the executable, then creates checksum info
;; needed for the IBM PC POST to recognize it as a bootable PROM.
;;
;; TESTING
;; -------
;; When doing non-prom testing, ensure PROM equate is commented out.
;; To return to dos during testing, use <CTRL-BREAK>.
;;
;; PROM BURNING
;; ------------
;; To compile a binary for use in eproms, uncomment the 'PROM' equate.
;; Note that <CTRL-BREAK> emulates a BREAK sequence on the tty line.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;PROM equ 1 ; MUST BE DEFINED WHEN COMPILING FOR PROMS
; INCLUDE GLOBAL MACROS AND EQUATES
include vtprom.h
; TEXT SEGMENT BEGINS HERE
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT, DS:_TEXT
prom_0000:
ifdef PROM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;
;;;;;;; PROM CODE START
;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dw 0,0,0 ; reserved for PROM SIGNATURE
mov [spsave],0fffeh ; setup stack for downward growth
mov [sssave],PROM_STACKSEG
mov byte ptr [printbanner],0 ; clear print banner flag
; ENTRY FOR 'ESC c' (TTY INIT SEQUENCE)
master_init:
mov ax,PROM_DATASEG ; hard code data segment address
mov ds,ax
mov sp,[spsave]
mov ss,[sssave]
else
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;
;;;;;;; 'TEST MODE' CODE START
;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
push cs
pop ds
mov [spsave],sp ; SAVE STACK POINTER/SEGMENT
mov [sssave],ss ; given to us by DOS
mov byte ptr [printbanner],0 ; clear print banner flag
; ENTRY FOR 'ESC c' TTY INIT SEQUENCES
master_init:
mov ax,cs ; CS is our DS
mov ds,ax
mov sp,[spsave] ; restore stack
mov ss,[sssave]
endif
jmp init
init proc near
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; INITIALIZE THE DRIVER MODULES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cld ; assume cld flag throughout
call initcomring ; SERIAL COMM: communications ring
call initkeyboard ; KEYBOARD INIT: keyboard drivers
call initserial ; SERIAL INIT
call initvideo ; VIDEO INIT: initialize screen manager
mov es,[vidseg] ; es is seg addr of screen from now on
call vidstatusline ; slam in the video status line
; or [vidflags], HEX_DEBUG ; DEBUGGING ONLY
; CLEAR SCREEN
mov ax,0720h ; clear screen
call vidclear
mov [curx],0 ; home cursor
mov [cury],0
call curupdate
; PRINT TTY BANNER (JUST ONCE)
test byte ptr [printbanner],1 ; only print the banner once
jt i_noban
mov si,offset ttymsg
call printstring ; print TTY banner
i_noban:
or byte ptr [printbanner],1
; READ CHARACTERS FROM KEYBOARD, SEND TO SERIAL PORT
ttyloop:
mov ah,1 ; ARE CHARACTERS WAITING?
int 16h
jz nokeyboard
mov ah,0 ; YES, READ THEM FROM BUFFER
int 16h ; (AL=ascii, AH=scan code)
stl_notbackscroll:
call handlekey ; process keypress if necessary
; READ CHARACTERS FROM SERIAL PORT, DISPLAY TO SCREEN
nokeyboard:
call serialin
jnc ttyloop
; BEFORE PROCESSING SERIAL DATA
; MAKE SURE WE'RE NOT IN BACKSCROLL MODE
;
cmp [vidbackscroll],0
jz tloop_notbscroll2
mov [vidbackscroll],0
call vidresscrn
tloop_notbscroll2:
call printchar
jmp ttyloop
init endp
;; DRIVER MODULES INSERTED HERE
include video.asm ;; INCLUDE VIDEO DRIVERS
include serial.asm ;; INCLUDE SERIAL DRIVERS
include keyboard.asm ;; INCLUDE KEYBOARD DRIVERS
;; PROM READONLY DATA
ttymsg db 0dh,0ah
db 1bh,'[2J' ; clear screen
db 1bh,'[0;0H' ; home cursor
db 0dh,0ah,0ah
db ' Ü Ü ',0dh,0ah
db ' ßÛß ßÛß Û Û ',0dh,0ah
db ' Û Û Û Û ',0dh,0ah
db ' ÛÜ ÛÜ ÛÜÜÛ ',0dh,0ah
db ' Û ',0dh,0ah
db ' ßßßßßßßß ÛÜÜÛ ',0dh,0ah
db ' ßßßßßßßß ',0dh,0ah
db ' ßßßßßßßßßßßßßß ',0dh,0ah,0ah
db 0
copyrightmsg db '(C) COPYRIGHT GREG ERCOLANO 1995',0
breakmsg1 db '<BREAK>',0
crlfmsg db 0dh,0ah,0
esczresponsemsg db 1bh,'/Z',0 ; vt100 response to ESC Z
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; DATA AREA.
;; During testing, this is static memory that exists at +5000H.
;;
;; For PROM runs, this data will reside in an uninitialized RAM
;; somewhere in low memory (probably 1000:0000). This will be
;; hardcoded into the data segment register during execution.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ifdef PROM_BURN
_TEXT ends
_DATA segment at PROM_DATASEG
else
org 05000h
endif
printbanner db ? ; print banner flag
;;;;;; MOUSE VARIABLES
mousex dw ? ; MOUSE CURSOR
mousey dw ?
;;;;;; VIDEO VARIABLES
curx db ? ; VIDEO CURSOR
cury db ?
curxsave db ? ; saved cursor position (ESC8, etc)
curysave db ?
top db ? ; top line for scrolling (00)
bottom db ? ; bot line for scrolling (23)
left db ? ; left edge for scrolling (00)
right db ? ; right edge for scrolling (79)
phystop db ? ; physical top line (00)
physbottom db ? ; physical bot line (23)
physleft db ? ; physical left edge (00)
physright db ? ; physical right edge (79)
vidseg dw ? ; segment address of video card
vidcolor db ? ; color of characters sent to screen
vidflags dw ? ; (see VIDEO EQUATES)
videsc dw ? ; index into esc buf (=0 if no esc seq)
vidbackscroll dw ? ; #lines we are scrolled back
vidblank db 0 ; =0 if normal, =1 if blanked display
; (0=active display)
escbuf db 40 dup ( ? ) ; buffer for ESC sequences
escbufend db ? ; end of esc buffer
scrbufin dw ? ; SCROLL BUFFER VECTORS
scrbufinseg dw ?
scrbufstart dw ? ; start of scrollbuffer
scrbufstartseg dw ?
scrbufend dw ? ; end of scrollbuffer
scrbufendseg dw ?
scrbufdispseg dw ? ; (used by vidupdatebackscroll)
scrbufdisp dw ?
tabstops db TABSTOP_SIZE dup ( ? ) ; tabstop buffer (0=no, 1=tabstop)
hexdebug_x db ? ; hex debug mode byte count for line
dectable dw 1d,10d,100d,1000d ; decimal table
textcolortable db 00h,04h,02h,06h,01h,05h,03h,07h ; ANSI -> IBM colors
pagecolortable db 00h,40h,20h,60h,10h,50h,30h,70h ; ANSI -> IBM colors
ifndef PROM
scrbuf db SCRBUF_SIZE dup ( ? ) ; SCREEN SCROLL BUFFER
; for testing only. With prom,
; we use larger unused segment
scrsavebuf dw 80d*25d dup ( ? ) ; #words in a full screen
; KEYBOARD HARDWARE JUMP
tokeybdbios:
keybdint1 db ? ; this is the JMP FAR
keybdint2 dw ? ; offset
keybdint3 dw ? ; segment
endif
;;;;;; SERIAL VARIABLES
com1in dw ? ; COM1 RING VECTORS
com1out dw ?
com1end dw ?
com1port dw ? ; port base address for com1
com2in dw ? ; COM2 RING VECTORS
com2out dw ?
com2end dw ?
com2port dw ? ; port base address for com2
com1buf db COMBUF_SIZE dup ( ? ) ; COM1 RING BUFFER
com2buf db COMBUF_SIZE dup ( ? ) ; COM2 RING BUFFER
spsave dw ? ; SP register save
sssave dw ? ; SS register save
ifdef PROM_BURN
_DATA ends
else
_TEXT ends
endif
end