home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / MAILMIND.ZOO / NETMSGBW.ASM < prev    next >
Assembly Source File  |  1992-03-11  |  6KB  |  233 lines

  1.  TITLE NETMSG.ASM --  TSR to receive messages
  2. ;Thomas A. Marciniak, M.D. = ytm@nihccpc1.bitnet
  3. ;Division of Cancer Prevention & Control, NCI
  4.  
  5. ;Revision history:
  6. ;1.02  ytm  03/25/91  quick fix for bw monitor
  7. ;1.01  ytm  02/19/91  correct uninitialized use of bp
  8. ;1.00  ytm  02/05/91  first release
  9.  
  10. ;Program notes:
  11. ;This program uses the Tesseract TSR library.
  12. ;Modify for:
  13. ;  Monochrome monitor;
  14. ;  Second video page;
  15. ;  Graphics skip.
  16.  
  17.  PAGE 60,80
  18.  LOCALS
  19. .MODEL tiny
  20.  
  21.  INCLUDE NETBIOS.INC
  22.  
  23. ;equates
  24. MSG_ATTR    EQU 0efh
  25. VIDEO_SEG   EQU 0b000h
  26. UR_CORNER   EQU 09eh
  27. MAXLINE     EQU 81
  28. STATE_IDLE  EQU 0
  29. STATE_INIT  EQU 1
  30. STATE_RCV   EQU 2
  31.  
  32. ;external refererences
  33. EXTRN TESSBEEP:NEAR
  34. EXTRN TSDOINIT:NEAR
  35. EXTRN TSCHECKRESIDENT:NEAR
  36. EXTRN TSSETSTACK:NEAR
  37.  
  38. .CODE
  39.  
  40. ;globals
  41. State      DW STATE_INIT                ;state flag
  42. NetmsgNum  DW 0                         ;ID number
  43. NetmsgName DB 'NETMSG  '                ;Identification string
  44. Packet     DB MAXLINE DUP (0)           ;message buffer
  45. Ncb        NCB_STRUC <>
  46.  
  47. ;posting routine for NETBIOS receive datagram
  48. Post    PROC    FAR
  49.         ASSUME cs:_TEXT
  50.     mov    cs:[State], STATE_RCV
  51.     iret    
  52. Post    ENDP
  53.  
  54. ;TesSeRact Entry Points
  55. PUBLIC  TSRUSERPROC, TSRTIMERPROC, TSRBACKCHECK, TSRMAIN, TSRBACKPROC
  56. PUBLIC  TSRCLEANUP
  57.  
  58. ;NULL procedures
  59. TSRUSERPROC:
  60. TSRMAIN:
  61. TSRCLEANUP:
  62. TSRTIMERPROC:
  63.         ret
  64.  
  65. TSRBACKCHECK PROC NEAR
  66.         ASSUME cs:_TEXT, ds:_TEXT
  67.         mov     ax, [State]
  68.         ret
  69. TSRBACKCHECK ENDP
  70.  
  71. TSRBACKPROC PROC NEAR
  72.         ASSUME cs:_TEXT, ds:_TEXT
  73.         push    es
  74.         push    di
  75.         push    si
  76.     cmp    WORD PTR [State], STATE_INIT
  77.         jne     @@ChkCmdCplt
  78.     jmp     @@NetRcv
  79. @@ChkCmdCplt:
  80.     cmp    BYTE PTR [Ncb.NCB_CMD_CPLT], 0 ;0 = receive OK
  81.         je      @@DoMsg
  82.     jmp    @@NetRcv
  83. @@DoMsg:
  84.     call    TESSBEEP
  85.     xor    si, si                  ;displacement for character store
  86.     mov    ax, VIDEO_SEG
  87.     mov    es, ax                  ;video seg pointer
  88.         mov     dh, MSG_ATTR            ;message attribute character
  89.     cmp    WORD PTR [Ncb.NCB_LENGTH], 3 ;< 3 URC; > 2 ULC of screen
  90.     jae    SHORT @@LongMsg
  91.     cmp    WORD PTR [Ncb.NCB_LENGTH], 1 ;1 = no displacement character
  92.     jbe    SHORT @@PutOne
  93.     mov    al, BYTE PTR [Packet + 1] ;get displacement character
  94.         mov     ah, 0
  95.     add    ax, 0 - '0'
  96.     shl    ax, 1
  97.     mov    si, ax
  98.     cmp    si, MAXLINE
  99.     jle    SHORT @@PutOne
  100.     xor    si, si
  101. @@PutOne:
  102.     mov    bx, UR_CORNER
  103.     sub    bx, si
  104.     mov    dl, BYTE PTR [Packet]
  105.     mov    WORD PTR es:[bx], dx
  106.     jmp    @@NetRcv
  107. @@LongMsg:
  108.     mov    di, OFFSET [Ncb.NCB_CALLNAME]
  109.     jmp    SHORT @@ChkNameC
  110. @@PutNameC:
  111.     mov    dl, BYTE PTR [di]
  112.     mov    WORD PTR es:[si], dx
  113.     inc    di
  114.     mov    ax, si
  115.     inc    ax
  116.     inc    ax
  117.     mov    si, ax
  118. @@ChkNameC:
  119.     cmp    BYTE PTR [di], 0
  120.     je    SHORT @@PutColon
  121.     cmp    BYTE PTR [di], ' '
  122.     jne    SHORT @@PutNameC
  123. @@PutColon:
  124.     mov    dl, ':'
  125.     mov    WORD PTR es:[si], dx
  126.     mov    ax, si
  127.     inc    ax
  128.     inc    ax
  129.     mov    si, ax
  130.     mov    dl, ' '
  131.     mov    WORD PTR es:[si], dx
  132.     mov    ax, si
  133.     inc    ax
  134.     inc    ax
  135.     mov    si, ax
  136.     mov    ax, WORD PTR [Ncb.NCB_LENGTH]
  137.     shl    ax, 1
  138.     add    ax, si
  139.     mov    cx, ax                  ;cx = stop pos
  140.     mov    ax, si
  141.     mov    di, OFFSET Packet
  142.     jmp    SHORT @@ChkStop
  143. @@PutMsgC:
  144.     mov    dl, BYTE PTR [di]
  145.     mov    WORD PTR es:[si], dx
  146.     inc    di
  147.     mov    ax, si
  148.     inc    ax
  149.     inc    ax
  150. @@ChkStop:
  151.     cmp    ax, cx
  152.     mov    si, ax
  153.     jl    SHORT @@PutMsgC
  154.     mov    dl, ' '
  155.     mov    WORD PTR es:[si], dx
  156. @@NetRcv:
  157.     mov    WORD PTR [State], STATE_IDLE
  158.         mov     ax, ds                  ;zero Ncb
  159.         mov     es, ax
  160.     mov    di, OFFSET Ncb
  161.         mov     cx, 32                  ;Ncb length in words
  162.     xor    ax, ax
  163.         cld
  164.         rep stosw
  165.     mov    BYTE PTR [Ncb.NCB_COMMAND], RECEIVE_DATAGRAM ;setup Ncb
  166.     mov    BYTE PTR [Ncb.NCB_NUM], 0ffh ;0ffh = from any user
  167.     mov    WORD PTR [Ncb.NCB_LENGTH], MAXLINE
  168.     mov    WORD PTR [Ncb.NCB_BUF_OFF], OFFSET Packet
  169.     mov    WORD PTR [Ncb.NCB_BUF_SEG], ds
  170.     mov    WORD PTR [Ncb.NCB_POST_OFF], OFFSET Post
  171.     mov    WORD PTR [Ncb.NCB_POST_SEG], cs
  172.     mov    BYTE PTR [Ncb.NCB_CMD_CPLT], 0ffh ;0ffh = not completed
  173.     mov    ax, ds
  174.     mov    es, ax
  175.     mov    bx, OFFSET Ncb
  176.     mov    ax, 100h
  177.     int    05ch                    ;NETBIOS call
  178.         pop     si
  179.         pop     di
  180.         pop     es
  181.         ret
  182. TSRBACKPROC ENDP
  183.  
  184. ;TSR stack
  185. PUBLIC TsrStack
  186. PUBLIC TopStack
  187. TsrStack        DB 256 dup(0)           ;stack to use
  188. TopStack        EQU this byte
  189.  
  190. PUBLIC TESSINITSTART                    ;required entry point
  191. TESSINITSTART:
  192.         ASSUME cs:_TEXT, ds:_TEXT
  193.         mov     dx, OFFSET Signon
  194.         mov     ah, 09
  195.         int     21h                     ;display the signon message
  196.         mov     si, OFFSET NetmsgName
  197.         mov     di, OFFSET NetmsgNum
  198.         call    TSCHECKRESIDENT
  199.         or      ax, ax
  200.         jz      @@Install
  201.         mov     dx, OFFSET AlreadyInstalled ;we must already be installed
  202.         mov     ah, 09
  203.         int     21h                     ;display message
  204. @@Terminate:
  205.         mov     ax, 4c01h
  206.         int     21h                     ;and exit with error code
  207. @@Install:
  208.         mov     di, OFFSET TopStack
  209.         dec     di
  210.         dec     di
  211.         mov     si, di
  212.         call    TSSETSTACK
  213.         mov     dx, OFFSET Installed
  214.         mov     ah, 09
  215.         int     21h
  216.         mov     dx, OFFSET TESSINITSTART
  217.         mov     bx, 1020h               ;no pop graphics, background procs
  218.         xor     ax, ax                  ;no hotkey!
  219.         dec     ax                      ;no hotkey is -1
  220.         call    TSDOINIT
  221.         jmp     @@Terminate               ;we should never do this!
  222.  
  223. ;messages
  224. Signon  DB      13,10,'NETMSG.COM v1.01',13,10,'$'
  225. Installed       LABEL   BYTE
  226.         DB      'NETMSG installed',13,10,'$'
  227. AlreadyInstalled       LABEL   BYTE
  228.         DB      'NETMSG already installed',7,13,10,'$'
  229.  
  230. _TEXT ENDS
  231.  
  232.         END
  233.