home *** CD-ROM | disk | FTP | other *** search
- .model small
- dosseg
- .stack 2048
-
- ;-----------------------
- .data
-
- titstr db 'TTY (c)1989 MagicSoft, Inc. All Rights Reserved',13,10,0,26
- titstr1 db 13,10,10
- db 'Press F1 for Help, Alt-X to Exit to DOS.',13,10
- db 13,10
- db 'Ready.',13,10,0
- nomx5 db 'ERROR: MX5 Not Installed.',7,13,10,0
- port_str db 13,10,'What Com Port (1-4) [CR=COM1]? ',0
-
- online_str db 13,10,'═══ On-Line ═══',13,10,0
- offline_str db 13,10,'═══ OffLine ═══',13,10,0
-
- yesmnp_str db 13,10,'═══ CONNECT/MNP'
- disp_lvl db 'x ═══',13,10,0
- nomnp_str db 13,10,'═══ NO CARRIER/MNP ═══',13,10,0
-
-
- instruct_str db 'Press SPACE to Toggle, CR to Accept',13,10,0
-
- baud_str db 'Baud Rate',0
- baud db 5
- bauds dw b192,b384,b3,b6,b12,b24,b48,b96
- b192 db '19200',0
- b384 db '38400',0
- b3 db '300 ',0
- b6 db '600 ',0
- b12 db '1200 ',0
- b24 db '2400 ',0
- b48 db '4800 ',0
- b96 db '9600 ',0
-
- parity_str db 'Wordlength/Parity',0
- parity db 0
- paritys dw p1,p2,p3
- p1 db '8/None ',0
- p2 db '7/Odd ',0
- p3 db '7/Even ',0
-
- level_str db 'MNP Level',0
- real_levels db 0,2,4,5
- level db 3
- levels dw l0,l2,l4,l5
- l0 db 'No MNP',0
- l2 db '2 ',0
- l4 db '4 ',0
- l5 db '5 ',0
-
- sound_str db 'MNP Sound Level',0
- sound db 0
- sounds dw off_str,on_str
- off_str db 'Off',0
- on_str db 'On ',0
-
- stuff_str db 13,10
- db '══════ MNP Status Information ══════',13,10,10
- db ' ┌─────── Last Occurrence ────────┐',13,10,0
- stuff_str1 db ' │ MNP Level : ',0
- stuff_str2 db ' │ Series ID : ',0
-
- tx_str db ' ┌─────────── Transmit ───────────┐',13,10,0
- alti_str1 db ' │ Total Packets : ',0
- alti_str2 db ' │ Duplicate Packets : ',0
- alti_str3 db ' │ Max Speed : ',0
- tx_str1 db ' └────────────────────────────────┘',13,10,0
-
- rx_str db ' ┌─────────── Receive ────────────┐',13,10,0
-
- help_str db 13,10
- db ' ┌─────── TTY Alt Key Help ────────┐',13,10
- db ' │ │',13,10
- db ' │ F1 Help │',13,10
- db ' │ Alt-X Exit to DOS │',13,10
- db ' │ Alt-H Hangup │',13,10
- db ' │ Alt-I MNP Status Information │',13,10
- db ' │ Alt-B Set Baud Rate │',13,10
- db ' │ Alt-P Set Wordlength/Parity │',13,10
- db ' │ Alt-L Set MNP Connect Level │',13,10
- db ' │ Alt-S Set MNP Sound Level │',13,10
- db ' │ │',13,10
- db ' └─────────────────────────────────┘',13,10
- db 0
-
- putdbuf db 11 dup(0)
- charbuf db 0
- mnpflag db 0
- carrier db 0
- port dw 0
- ;-----------------------
- .code
- start:
- mov ax,@data ;standard EXE segment adjust
- mov ds,ax ;for SMALL model
- mov es,ax
- mov ss,ax
- mov sp,offset STACK
-
- lea si,titstr ;print title string
- call print
-
- mov ah,0e0h ;see if MX5 is installed
- mov al,6
- mov bx,0
- int 14h
- cmp bx,'MX'
- je yesdrvr
-
- lea si,nomx5 ;no, error message
- call print
-
- mov al,1 ;and exit to DOS
- mov ah,4ch
- int 21h
-
- yesdrvr:
- lea si,port_str ;ask "What port?"
- call print
-
- askport:
- call getkey
-
- cmp al,'1'
- jb bong
- cmp al,'4'
- jbe nobong
- bong:
- cmp al,13
- je com1
-
- mov al,7
- call putc
- jmp askport
-
- com1:
- mov al,'1'
- nobong:
- push ax
- call putc
- pop ax
-
- sub al,'1'
- mov byte ptr port,al
-
- mov ah,04h ;Init driver
- mov dx,port
- int 14h
-
- ;----- Read Current MX5 Settings
-
- mov bh,0 ;get sound level
- mov ah,0e0h
- mov al,4
- mov dx,port
- int 14h
- mov sound,bl
-
- ;----- Set MX5 Defaults
-
- mov bh,1 ;set MNP level to 5
- mov bl,5
- mov ah,0e0h
- mov al,1
- mov dx,port
- int 14h
-
- call set_rate ;2400,n,8,1
- ;-----
-
- lea si,titstr1 ;"Alt-X to Exit..."
- call print
-
- ;--------------------------------------------
- ; Main Terminal Loop
- ;--------------------------------------------
- mloop:
- call checkkey ;is there a char in kbd buffer?
- jnz yeskey
- jmp nochar ;no, jump
-
- yeskey:
- cmp al,0 ;yes, is it a extended key?
- je yesext ;yes, jump
- jmp noext
-
- yesext:
- call getkey ;get the char from kbd buffer
-
- ;-----------
- cmp ah,45 ;Alt-X? (exit)
- jne noaltx
-
- mov ah,6 ;lower DTR
- mov al,0
- mov dx,port
- int 14h
-
- mov ah,5 ;deinit driver
- mov dx,port
- int 14h
-
- mov ah,4ch ;exit to DOS
- mov al,0
- int 21h
-
- noaltx:
- ;-----------
- cmp ah,35 ;Alt-H
- jne noalth
-
- mov ah,6 ;lower DTR
- mov al,0
- mov dx,port
- int 14h
-
- mov ah,0e0h ;wait 500ms
- mov al,7
- mov cx,9
- int 14h
-
- mov ah,6 ;lower DTR
- mov al,1
- mov dx,port
- int 14h
-
- jmp nochar
-
- noalth:
- ;-----------
- cmp ah,48 ;Alt-B
- jne noaltb
-
- lea si,baud_str ;point to "Baud Rate"
- mov cl,8 ;8 choices
- lea di,bauds ;point to list of choices ([di][-1] => BYTE variable)
- call toggles ;go...
- call set_rate ;set baudrate, etc...
- jmp nochar
-
- noaltb:
- ;-----------
- cmp ah,25 ;Alt-P
- jne noaltp
-
- lea si,parity_str
- mov cl,3
- lea di,paritys
- call toggles
- call set_rate
- jmp nochar
-
- noaltp:
- ;-----------
- cmp ah,31 ;Alt-S
- jne noalts
-
- lea si,sound_str
- mov cl,2
- lea di,sounds
- call toggles
-
- mov bl,sound
- mov bh,1
- mov ah,0e0h
- mov al,4
- mov dx,port
- int 14h
-
- jmp nochar
-
- noalts:
- ;-----------
- cmp ah,38 ;Alt-L
- jne noaltl
-
- lea si,level_str
- mov cl,4
- lea di,levels
- call toggles
-
- mov bl,level
- xor bh,bh
- mov bl,real_levels[bx]
- mov bh,1
- mov ah,0e0h
- mov al,1
- mov dx,port
- int 14h
-
- jmp nochar
-
- noaltl:
- ;-----------
- cmp ah,23 ;Alt-I (Info)
- je yesalti
- jmp noalti
-
- yesalti:
- push es
- mov ah,0e0h ;get MNP information
- mov al,0
- mov dx,port
- int 14h
-
- xor dx,dx
- lea si,stuff_str
- call print
- xor ah,ah
- mov al,es:[bx][1]
- lea si,stuff_str1
- call print_long1
- lea si,stuff_str2
- xor ah,ah
- mov al,es:[bx][2]
- call print_long1
- lea si,tx_str1
- call print
-
- lea si,tx_str
- call print
- mov di,3
- lea si,alti_str1
- call print_long
- lea si,alti_str2
- call print_long
- lea si,alti_str3
- call print_long
- lea si,tx_str1
- call print
-
- lea si,rx_str
- call print
- lea si,alti_str1
- call print_long
- lea si,alti_str2
- call print_long
- lea si,alti_str3
- call print_long
- lea si,tx_str1
- call print
-
- mov al,10
- call putc
-
- pop es
- jmp nochar
-
- print_long:
- mov ax,es:[bx][di]
- mov dx,es:[bx][di][2]
- print_long1:
- push bx
- push di
- push si
-
- push ax
- call print
- pop ax
-
- lea si,putdbuf
- call xlmputd
- lea si,putdbuf
- call print
-
- mov al,' '
- call putc
- mov al,179
- call putc
- mov al,13
- call putc
- mov al,10
- call putc
-
- pop si
- pop di
- pop bx
- add di,4
- ret
-
- noalti:
- ;-----------
- cmp ah,59 ;F1? (Help)
- jne nof1
- lea si,help_str
- call print
- jmp nochar
-
- nof1:
- ;-----------
- jmp nochar
-
- ;--------------------------------------------
- noext:
- push ax
- mov ah,3 ;is there room in com output buffer?
- mov dx,port
- int 14h
- test ah,20h
- pop ax
- jz nochar ;no, try again later
-
- ;*** USE WRITE BLOCK METHOD ***
- lea di,charbuf ;point to 1 char buffer
- mov [di],al ;place char in buffer
- mov cx,1 ;1 character
- mov ah,19h
- mov dx,port
- int 14h
-
- ;*** USE WRITE CHARACTER METHOD ***
- ; mov ah,1 ;send the character
- ; mov dx,port
- ; int 14h
-
- call getkey ;eat the char from kbd buffer
-
- nochar:
- mov ah,3 ;any received characters?
- mov dx,port
- int 14h
- test ah,1
- jnz char_ready ;yes, jump
-
- call stat ;check carrier, etc...
- jmp mloop
-
- char_ready:
- mov ah,2 ;get the RX char
- mov dx,port
- int 14h
-
- call putc ;print it to the screen
- jmp mloop
-
- ;--------------------------------------------
- ; Subroutines
- ;--------------------------------------------
- ;
- ; PUTC
- ; Outputs a character in AL to the screen.
- ;
- putc proc
-
- mov ah,14
- int 10h
- ret
-
- ; push dx
- ; mov ah,2
- ; mov dl,al
- ; int 21h
- ; pop dx
- ; ret
-
- putc endp
- ;
- ;--------------
- ;
- ; PRINT
- ; Outputs an ASCIIZ string at DS:SI to the screen (uses PUTC).
- ;
- print proc
-
- push si
- printlp:
- lodsb
- cmp al,0
- je pdone
- call putc
- jmp printlp
- pdone:
- pop si
- ret
-
- print endp
- ;
- ;--------------
- ;
- ; STAT
- ; Monitors for Delta CD and Delta MNP and prints
- ; "On-Line", "OffLine", "CONNECT/MNPx" and "MNP Disconnect"
- ; when applicable.
- ;
- stat proc
-
- mov ah,3 ;get carrier status
- mov dx,port
- int 14h
- and al,80h
-
- cmp carrier,al
- je nodeltacd
- mov carrier,al
-
- lea si,online_str
- cmp al,0
- jne stat_print
- lea si,offline_str
- stat_print:
- call print
- nodeltacd:
- ;---
- push es
- mov ah,0e0h ;get carrier status
- mov al,0
- mov dx,port
- int 14h
- mov al,es:[bx]
- mov ah,es:[bx][1]
- pop es
-
- cmp mnpflag,al
- je nodeltamnp
- mov mnpflag,al
-
- lea si,nomnp_str
- cmp al,0
- je stat_print1
- lea si,yesmnp_str
- add ah,'0'
- mov disp_lvl,ah
- stat_print1:
- call print
- nodeltamnp:
-
- ret
-
- stat endp
- ;
- ;--------------
- ;
- checkkey proc
-
- mov ah,1 ;check for a key
- int 16h
- ret
-
- checkkey endp
- ;
- ;--------------
- ;
- getkey proc
-
- mov ah,0 ;get the key
- int 16h
- ret
-
- getkey endp
- ;
- ;--------------
- ;
- set_rate proc
-
- xor ah,ah ;put baud rate in bits 7-5
- mov al,baud
- mov cl,5
- shl al,cl
- or ah,al
-
- mov al,parity ;put parity in bits 4-3
- cmp al,0
- jz nosp
- or al,1
- nosp:
- mov cl,3
- shl al,cl
- or ah,al
-
- mov al,2 ;put wordlength in bits 1-0
- cmp parity,0
- jne nonone
- or al,1
- nonone:
- or ah,al
-
- mov al,ah ;go...
- mov ah,0
- mov dx,port
- int 14h
- ret
-
- set_rate endp
- ;
- ; -----------------------------
- ;
- toggles proc
-
- call crlf
- push si
- lea si,instruct_str
- call print
- pop si
- jmp toggle_print
-
- toggle_loop:
- call getkey ;wait for a key
- cmp al,' '
- je toggle_space
- cmp al,13
- je toggle_cr
- jmp toggle_loop
-
- toggle_space:
- inc byte ptr [di][-1]
- cmp byte ptr [di][-1],cl
- jb toggle_print
- mov byte ptr [di][-1],0
- toggle_print:
- mov al,13
- call putc
- call print
- mov al,' '
- call putc
- mov al,'='
- call putc
- mov al,' '
- call putc
- push si
- mov al,byte ptr [di][-1]
- xor ah,ah
- shl ax,1
- mov si,ax
- add si,di
- mov si,[si]
- call print ;'xxxx'
- pop si
- jmp toggle_loop
-
- toggle_cr:
- call crlf
- mov al,10
- call putc
- ret
-
- toggles endp
- ;
- ; -----------------------------
- ;
- crlf proc
-
- mov al,13
- call putc
- mov al,10
- call putc
- ret
-
- crlf endp
- ;
- ; -----------------------------
- ;
- ; Call with DX:AX = Unsigned 32 bit value
- ; DS:SI = 10 byte buffer
- ; (make sure it is ASCIIZ if you are going to print
- ; it alone.)
- ;
- ; Destroys AX, BX, CX, DX, and SI.
- ;
- public xlmputd
- xlmputd proc near
-
- mov cx,10
- splp:
- mov byte ptr [si],' '
- inc si
- loop splp
-
- mov cx,10 ;radix
- ;divide the 32 bit value by the radix
- ;to extract the next digit for the
- bin1: ;forming string.
- call divide ;no, divide by radix
- add bl,'0' ;convert the rem to an ascii digit
- bin2:
- dec si ;backup through string,
- mov [si],bl ;store this character into string.
- mov bx,ax ;is the value zero yet?
- or bx,dx
- jnz bin1 ;no, do it again
- ret
-
- xlmputd endp
- ;
- ; =================
- ;
- ; 32 bit by 16 bit unsigned divide
- ;
- ; Call with DX:AX = 32 bit dividend
- ; CX = divisor
- ;
- ; Returns DX:AX = quotient
- ; BX = remainder
- ; CX = divisor (unchanged)
- ;
- public divide
- divide proc near ;divide dx:ax by cx
-
- jcxz divl ;exit if divide by zero
- push ax ;0:dividend_upper/divisor
- mov ax,dx
- xor dx,dx
- div cx
- mov bx,ax ;bx - quotientl
- pop ax ;remainterl:dividend_lower/divisor
- div cx
- xchg bx,dx ;dx:ax = quotientl:quotient2
- divl:
- ret ;bx = remainder2
-
- divide endp
- ;
- ;--------------
- ;
- end start
-