home *** CD-ROM | disk | FTP | other *** search
- TITLE NETMSG.ASM -- TSR to receive messages
- ;Thomas A. Marciniak, M.D. = ytm@nihccpc1.bitnet
- ;Division of Cancer Prevention & Control, NCI
-
- ;Revision history:
- ;1.02 ytm 03/25/91 quick fix for bw monitor
- ;1.01 ytm 02/19/91 correct uninitialized use of bp
- ;1.00 ytm 02/05/91 first release
-
- ;Program notes:
- ;This program uses the Tesseract TSR library.
- ;Modify for:
- ; Monochrome monitor;
- ; Second video page;
- ; Graphics skip.
-
- PAGE 60,80
- LOCALS
- .MODEL tiny
-
- INCLUDE NETBIOS.INC
-
- ;equates
- MSG_ATTR EQU 0efh
- VIDEO_SEG EQU 0b000h
- UR_CORNER EQU 09eh
- MAXLINE EQU 81
- STATE_IDLE EQU 0
- STATE_INIT EQU 1
- STATE_RCV EQU 2
-
- ;external refererences
- EXTRN TESSBEEP:NEAR
- EXTRN TSDOINIT:NEAR
- EXTRN TSCHECKRESIDENT:NEAR
- EXTRN TSSETSTACK:NEAR
-
- .CODE
-
- ;globals
- State DW STATE_INIT ;state flag
- NetmsgNum DW 0 ;ID number
- NetmsgName DB 'NETMSG ' ;Identification string
- Packet DB MAXLINE DUP (0) ;message buffer
- Ncb NCB_STRUC <>
-
- ;posting routine for NETBIOS receive datagram
- Post PROC FAR
- ASSUME cs:_TEXT
- mov cs:[State], STATE_RCV
- iret
- Post ENDP
-
- ;TesSeRact Entry Points
- PUBLIC TSRUSERPROC, TSRTIMERPROC, TSRBACKCHECK, TSRMAIN, TSRBACKPROC
- PUBLIC TSRCLEANUP
-
- ;NULL procedures
- TSRUSERPROC:
- TSRMAIN:
- TSRCLEANUP:
- TSRTIMERPROC:
- ret
-
- TSRBACKCHECK PROC NEAR
- ASSUME cs:_TEXT, ds:_TEXT
- mov ax, [State]
- ret
- TSRBACKCHECK ENDP
-
- TSRBACKPROC PROC NEAR
- ASSUME cs:_TEXT, ds:_TEXT
- push es
- push di
- push si
- cmp WORD PTR [State], STATE_INIT
- jne @@ChkCmdCplt
- jmp @@NetRcv
- @@ChkCmdCplt:
- cmp BYTE PTR [Ncb.NCB_CMD_CPLT], 0 ;0 = receive OK
- je @@DoMsg
- jmp @@NetRcv
- @@DoMsg:
- call TESSBEEP
- xor si, si ;displacement for character store
- mov ax, VIDEO_SEG
- mov es, ax ;video seg pointer
- mov dh, MSG_ATTR ;message attribute character
- cmp WORD PTR [Ncb.NCB_LENGTH], 3 ;< 3 URC; > 2 ULC of screen
- jae SHORT @@LongMsg
- cmp WORD PTR [Ncb.NCB_LENGTH], 1 ;1 = no displacement character
- jbe SHORT @@PutOne
- mov al, BYTE PTR [Packet + 1] ;get displacement character
- mov ah, 0
- add ax, 0 - '0'
- shl ax, 1
- mov si, ax
- cmp si, MAXLINE
- jle SHORT @@PutOne
- xor si, si
- @@PutOne:
- mov bx, UR_CORNER
- sub bx, si
- mov dl, BYTE PTR [Packet]
- mov WORD PTR es:[bx], dx
- jmp @@NetRcv
- @@LongMsg:
- mov di, OFFSET [Ncb.NCB_CALLNAME]
- jmp SHORT @@ChkNameC
- @@PutNameC:
- mov dl, BYTE PTR [di]
- mov WORD PTR es:[si], dx
- inc di
- mov ax, si
- inc ax
- inc ax
- mov si, ax
- @@ChkNameC:
- cmp BYTE PTR [di], 0
- je SHORT @@PutColon
- cmp BYTE PTR [di], ' '
- jne SHORT @@PutNameC
- @@PutColon:
- mov dl, ':'
- mov WORD PTR es:[si], dx
- mov ax, si
- inc ax
- inc ax
- mov si, ax
- mov dl, ' '
- mov WORD PTR es:[si], dx
- mov ax, si
- inc ax
- inc ax
- mov si, ax
- mov ax, WORD PTR [Ncb.NCB_LENGTH]
- shl ax, 1
- add ax, si
- mov cx, ax ;cx = stop pos
- mov ax, si
- mov di, OFFSET Packet
- jmp SHORT @@ChkStop
- @@PutMsgC:
- mov dl, BYTE PTR [di]
- mov WORD PTR es:[si], dx
- inc di
- mov ax, si
- inc ax
- inc ax
- @@ChkStop:
- cmp ax, cx
- mov si, ax
- jl SHORT @@PutMsgC
- mov dl, ' '
- mov WORD PTR es:[si], dx
- @@NetRcv:
- mov WORD PTR [State], STATE_IDLE
- mov ax, ds ;zero Ncb
- mov es, ax
- mov di, OFFSET Ncb
- mov cx, 32 ;Ncb length in words
- xor ax, ax
- cld
- rep stosw
- mov BYTE PTR [Ncb.NCB_COMMAND], RECEIVE_DATAGRAM ;setup Ncb
- mov BYTE PTR [Ncb.NCB_NUM], 0ffh ;0ffh = from any user
- mov WORD PTR [Ncb.NCB_LENGTH], MAXLINE
- mov WORD PTR [Ncb.NCB_BUF_OFF], OFFSET Packet
- mov WORD PTR [Ncb.NCB_BUF_SEG], ds
- mov WORD PTR [Ncb.NCB_POST_OFF], OFFSET Post
- mov WORD PTR [Ncb.NCB_POST_SEG], cs
- mov BYTE PTR [Ncb.NCB_CMD_CPLT], 0ffh ;0ffh = not completed
- mov ax, ds
- mov es, ax
- mov bx, OFFSET Ncb
- mov ax, 100h
- int 05ch ;NETBIOS call
- pop si
- pop di
- pop es
- ret
- TSRBACKPROC ENDP
-
- ;TSR stack
- PUBLIC TsrStack
- PUBLIC TopStack
- TsrStack DB 256 dup(0) ;stack to use
- TopStack EQU this byte
-
- PUBLIC TESSINITSTART ;required entry point
- TESSINITSTART:
- ASSUME cs:_TEXT, ds:_TEXT
- mov dx, OFFSET Signon
- mov ah, 09
- int 21h ;display the signon message
- mov si, OFFSET NetmsgName
- mov di, OFFSET NetmsgNum
- call TSCHECKRESIDENT
- or ax, ax
- jz @@Install
- mov dx, OFFSET AlreadyInstalled ;we must already be installed
- mov ah, 09
- int 21h ;display message
- @@Terminate:
- mov ax, 4c01h
- int 21h ;and exit with error code
- @@Install:
- mov di, OFFSET TopStack
- dec di
- dec di
- mov si, di
- call TSSETSTACK
- mov dx, OFFSET Installed
- mov ah, 09
- int 21h
- mov dx, OFFSET TESSINITSTART
- mov bx, 1020h ;no pop graphics, background procs
- xor ax, ax ;no hotkey!
- dec ax ;no hotkey is -1
- call TSDOINIT
- jmp @@Terminate ;we should never do this!
-
- ;messages
- Signon DB 13,10,'NETMSG.COM v1.01',13,10,'$'
- Installed LABEL BYTE
- DB 'NETMSG installed',13,10,'$'
- AlreadyInstalled LABEL BYTE
- DB 'NETMSG already installed',7,13,10,'$'
-
- _TEXT ENDS
-
- END