| ECE291 | Computer Engineering II | Lockwood, Spring 1999 |
Todd Manchester
Kevin McMahon
Jason LaPenta
NetPHONE is a multi-user conferencing tool. Users will have the ability to talk to single or multiple people in remote locations. The NetPHONE interface will allow you to change the volume, see groups available to talk with, and pull up a help menu to display all the commands.
Sound: The program will read 8-bit mono sound captured by the sound card. The sound data will be accessed using DMA transfers to move it to buffers in main memory. The sound output will be taken from a buffer filled by data transfered over the network and moved using DMA transfers to the sound card for output. Users will be able to change the volume and mute the output.
Network: The program will establish a network connection with other netphones running on the network. The program will track available groups to talk with. It will be able to establish connections (separate from the control connection) to send the audio data to a group of people.
GUI: The interface will include a list of active groups to join. It will have controls to adjust setting such as volume, mute, talk, etc. It will provide the ability to have graphical debugging in a debug window.
As the program is load, it automatically establishes a network connection. The sound system is initialized for both input and output. The GUI is loaded and displayed. User enters their handle (name), and then have the option of joining a group or creating their own. Once a group is joined, the conversation will be heard, and users can talk by pressing the space bar or using the mouse to push the talk button.
The network code will handle all taffic over the network, and maintain the groups variable of available groups on the network. All programs on the network will be queried at minimun intervals, and if in a group will respond with the group they are a part of. Thus the list of available groups will be maintained. If a group is not heard from aftert a length of time, it is declared inactive. All control traffic will be sent to a universal group separate from the groups which sound data is sent to. When sound packets are recieved, the network handler will call sound functions to read the data to be played. Similarly, when sound is recorded to be send out, a sound function will be called to read the data into the packet buffer.
The sound code will reset and setup the sound card. It will take care of setting up all sound card DMA transfers. It will also maintain a 65k buffer for holding streamed sound data. The Buffer will be filled and emptied at a queue would in a round about way. This will allow for a constant flow of data with only one buffer. The sound card will be used in 8-bit standard DMA mode for both input and output.
User Interface Procedures - Kevin McMahon
MouseInstall
Purpose: Have mouse driver recognizes the new mouse handler procedure
Inputs: None
Outputs: None
Notes: Uses mouse function
Implementation:
Three calls to Int 33h routines must be made.
MouseHandler
Purpose: This routine will be called by the mouse driver. It should
process clicks on the screen and put characters into InputBuffer.
KbdUninstall
Purpose: Restore keyboard Interrupt vector to the original value.
Input: oldKbdV variable
Output: None
KbdHandler
Input: None
Output:
kbdBuf updated with user entered text if prompted
to
inputValid
0 if input not finished
(carriage return not seen)
+1 if input finished
loadPCX ( Modification of the drawPCX procedure
outlined in the lab manual )
Purpose: Loads the file whose offset is in DX to the seg set aside
for the pcx files
Inputs:
DX - the offset of the filename of the pcx
file
pcxseg - the segment of the pcx to be drawn ( Either
the Background or Screen Component Segment )
pcxoff - the offset of the pcx to be drawn
Outputs:
Writes a PCX file in palette included with file
to the screen
writeString
Purpose: Draws the letter on the component pcx file that matches the
scan code read in from the keyboard
Inputs:
stringBuf- Buffer holding the ASCII values of the string
DX - the location to write the string
BX - the offset of the string to write
Outputs:
outputs the string to the location specified in
DX
Notes:
Calls SetLetterOff to get the character offset in
the screen component buffer lettersBuf
Also calls writeChar to write the individual characters
SetLetterOff
Purpose: Gets the correct offset of the letter in the letters.pcx file
Inputs:
AL - the keyboard scan code
Outputs:
BX - the offset of the letter in the lettersBuf
drawBox - ( Code modified from the drawPCX
procedure in the lab manual )
Purpose: Draw a filled square in the status and conection boxes on
the screen
Inputs:
SI - the offset of the box to write in the lettersBuf
DI - Screen location (from the top-left corner)
Output:
Writes directly to screen in the connection and
status box
Description: Draws a filled square to screen w/ color specified in
AL.
updateGrpWin
Purpose: Lists the group names in the display window and redraws them
Inputs: NONE
Output:
Writes directly to screen in the groups availible
box, highlighting the group selected
getNumber
Purpose: convert the ascii code of the number to the actual number
Inputs: AL - ascii to convert to number
Output: AX - the number that was converted
actionJoinGrp
Purpose - Handle all the necessary actions surrounding the join
group button being pressed
Prints out msg to prompt the user for group number
to join and then converts the
ascii to a number, checks if the number is a valid
entry (ie not a letter or mixed entry)
and then calls the NetJoinGrp function
Inputs:
Connection - status flag of the connection, either
ACTIVE or INACTIVE
Outputs:
NONE
actionLeaveGrp
Purpose: Goes through the process of leaving the group you are
currently in
Inputs:
connection - status flag to see if a connection
is active or inactive
Outputs:
NONE
NOTES: Call netLeaveGrp which performs the leaving of group from the
network
actionMakeGrp
Purpose: Performs the steps necessary to create a new group.
Copys the string names from the user to the
network variables and then calls
the net functions to create the group.
Input: connection - status of current connection
Output: NONE
performAction
Purpose: called when a button is hit and calls the appropriate action
based on what is in the strAction variable
Input: BX - the strAction command to use in a jmp table
Output: NONE
doStrAction
Purpose: this is called in the kbd handler to get the correct inputs
called after the keyboard has an input from the
user
Inputs BX - offset to string buffer
Outputs: inputValid - status of the input entered
cmdWrite
Purpose: Writes a character to the command line
Input: AX - the ascii value of the character to write
bksp_hit - a flag to tell
if the backspace key has been hit
Output: The character written to the command line
clrWrite
Purpose: clears the command line
Inputs: NONE
Outputs: NONE
Description: writes spaces over teh command line so the characters
disapper
setLetterOff
Purpose: Get the correct offset for the graphic character in the lettersBuf
Input: AX - the ascii code for the character to write
Ouput: BX - the offset
drawScreen
Purpose redraws the control panel screen from the buffer
Inputs: none
Output: new screen
drawHelpScreen
Purpose: Draws the help screen
Input: NONE
Output: Display help screen
lineAdjust
Purpose: calculates what the offset caused by line position on the
screen is
Input - AX the line number
Output - AX the screen offset corresponding to that line num
writeChar
Purpose: Finds the letter entered from the letterBuf and displays it
Input: AL - the character to be written
Output: NONE
gwriteString
Purpose : Write a string of ASCII characters to the screenBuf in the
grp window
Inputs : BX - offset to the String
DX - window offset
strGrpNum - the group number of the string to write
Output : NONE
gwriteChar
Purpose: Finds the letter entered from the letterBuf and displays it
in the group window
Input: AL - the character to write
Output: NONE
Set_Status
Purpose: Draw a box in the status area that indicates whether
the user
is available to chat
Inputs: AL - Color of the status box
Output: Sets the color of the status box at the DI location
Set_CONX
Purpose: Draw a box in the status area that indicates whether
the user
is available
to chat
Inputs: CONNECTION - status of the connection (ACTIVE or
INACTIVE)
Output: Sets the color of the connection box at the DI
location
Network Procedures - Todd Manchester
(parts of code are based on portions of code from Netlib.asm
specifically: ncb struc, int5c calls, parts of sendpacket, initialize
and destroy)
SendCtrlPacket
Purpose: Sends control packet out to control group
Input: txCtlBuf - holds packet to send
AX - number of bytes
to send
Output: none
SendPacket
Purpose: Sends sound packet out
Input:
txbuffer - holds packet to send
AX - number of bytes to send
sendChan - name of group/person to send to
sendChanNum - number to send to
Output:
whoTalk - update to indicate user is talking
read from sound buff, send to network
PostCtrl
Purpose: Call back function for packet received from control group
Input:
rxCtlBuf - holds packet received
ctlrcv - NCB for recieved packet
Output:
users - may be updated to change users available
groups - may be updated to change groups available
querytime - updated if query received
whoTalk - updated to NOBODY if talker times out
may send out QResp packet to respond to query
PostMsg
Purpose: Call back function for packet received from conversation group
Input:
rxbuffer - holds packet received
ctlrcv - NCB for recieved packet
Output:
write to sound buffer
whoTalk - updated to talking user
NetSendSnd
Purpose: Sends sound data out to conversation group; reads data from
buffer
Input:
sendChan - name of group/person to send to (used
in call to SendPacket)
sendChanNum - number to send to (used in call to
SendPacket)
whoTalk - to check who is talking
myId - user's ID
Output:
whoTalk - updates to NOBODY if sending done talking
packet
NetSetup
Purpose: Initializes the network connection; Sets up the control group,
and net names
Input: none
Output:
groups - initializes groups variable
connection - initialize to INACTIVE
ctrl_num - get group number from netbios
my_name - sets to unused network name
NetDestroy
Purpose: Removes net resources; notifies others of depature
Input:
connection - status of connection; will call NetLeaveGrp
if ACTIVE
Output: none
NetJoinGrp
Purpose: Joins conversation group
Input:
connection - to check if already in a group
sendChan - group to join
Output:
sendChanNum - group number from netbios
connection - status of connection
NetLeaveGrp
Purpose: Leaves conversation group
Input:
connection - checks if active
sndChan - group user in that is to be left
Output:
connection - status of connection
NetQuery
Purpose: Forces query of network for available groups and people
Input: none
Output: none
Sound Procedures - Jason Lapenta
Structures, Types & Constants:
NetBIOS Network Control Block structure
NCB struc
ncb_command db ? ; command code
ncb_retcode db ? ; error return code
ncb_lsn db ? ; session number
ncb_num db ? ; name number
ncb_buf_off dw ? ; ptr to send/receive data offset
ncb_buf_seg dw ? ; ptr to send/receive data segment
ncb_buflen dw ? ; length of data
ncb_callname db 16 dup (?) ; remote name
ncb_name db 16 dup (?) ; local name
ncb_rto db 0 ; receive timeout
ncb_sto db 0 ; send timeout
ncb_post_off dw ? ; async command complete post offset
ncb_post_seg dw ? ; async command complete post segment
ncb_lana_num db ? ; adapter number
ncb_cmd_done db ? ; 0FFh until command completed
ncb_res db 14 dup (?) ; reserved
NCB ends
NetBIOS command constants
RESET equ 032h
CANCEL equ 035h
STATUS equ 0B3h
STATUS_WAIT equ 034h
TRACE equ 0F9h
UNLINK equ 070h
ADD_NAME equ 0B0h
ADD_NAME_WAIT equ 030h
ADD_GROUP_NAME equ 0B6h
ADD_GROUP_NAME_WAIT equ 036h
DELETE_NAME equ 0B1h
DELETE_NAME_WAIT equ 031h
CALL_ equ 090h
LISTEN equ 091h
HANG_UP equ 092h
SEND equ 094h
CHAIN_SEND equ 097h
RECEIVE equ 095h
RECEIVE_ANY equ 096h
SESSION_STATUS equ 0B4h
SEND_DATAGRAM equ 0A0h
SEND_BCST equ 0A2h
RECEIVE_DATA equ 0A1h
RECEIVE_BCST_DATA equ 0A3h
Network Message Types & Formats
QUERY EQU 0
QRESP EQU
1
GDBYE EQU 2
RING
EQU 3
CONNECT EQU 4
HANGUP EQU 5
SNDDAT EQU 6
Network Timeout Constants
Determines if timeout has occured
GRPHLDTIME EQU 74 ; ticks groups stay active
after last heard from
MINQTIME EQU 26
; ticks after which query should be sent
WTALKTIME EQU 26 ; tickes until
talker times out if not heard from
General Constants
MAXSNDDAT EQU 508 ; must be even num - size in bytes
MAXNAMELEN EQU 32
MAXGRPNAME EQU MAXNAMELEN
MAXUSERS EQU 64
MAXGROUPS EQU 64
VidGrSEG EQU 0A000h
CR EQU 13 ; ASCII Carriage Return
LF EQU 10 ; ASCII LineFeed
ESCKEY EQU 27
BSKEY EQU 8
SEMI EQU 59
SPACE EQU 32
VidGrSEG EQU 0A000h
CMDLINE EQU 37120
HELP
EQU 1
CMD
EQU 0
JOINGRP EQU 1
LEAVEGRP EQU 2
MAKEGRP EQU 3
TALK
EQU 4
MsgWindow EQU 0
GrpWindow EQU 212+2560
User Status Constants
ACTIVE EQU 0
INACTIVE EQU 1
TALKING EQU 2
Packet Structures
NPMsg STRUC ; Generic Message Structure
MsgType db ? ; packet type identifier
UserID db ? ; User who sent packet
NPMsg ENDS
RingMsg STRUC ; Ring Packet
MsgType db RING
UserID db ?
UserName db MAXNAMELEN dup (?)
RingMsg ENDS
ConnectMsg STRUC ; Connect Packet
MsgType db CONNECT
UserID db ?
ConnectMsg ENDS
HangUpMsg STRUC ; HangUp Message
MsgType db HANGUP
UserID db ?
HangUpMsg ENDS
QueryMsg STRUC ; Query Message
MsgType db QUERY
UserID db ?
QueryMsg ENDS
QRespMsg STRUC ; Query Response Message
MsgType db QRESP
UserID db ?
UserName db MAXNAMELEN dup (?)
GroupID db ?
GroupName db MAXNAMELEN dup (?)
UG db ? ; Contains User(0), or Group(1) info
NetName db 16 dup (?)
QRespMsg ENDS
LeaveMsg STRUC ; Leaving Message
MsgType db GDBYE
UserID db ?
LeaveMsg ENDS
SndDataMsg STRUC ; Sound Data Packet
MsgType db SNDDAT
UserID db ?
DataSize dw ?
Data db MAXSNDDAT dup (?)
SndDataMsg ENDS
User Type - holds info about known users
UserType STRUC
UserName db MAXNAMELEN dup (?)
NetName db 16 dup (?)
Status db ?
UserType ENDS
Group Type - holds info about known groups
GroupType STRUC
GrpName db MAXGRPNAME dup (?)
NetName db 16 dup (?)
Status db ?
GroupType ENDS
VARIABLES
Net.asm Variables
Netbios Control Vars
msgsnd NCB <> ; Send Network Control
Block
msgrcv NCB <> ; Receive Network Control
Block
ctlsnd NCB <> ; Send Network Control
Block
ctlrcv NCB <> ; Receive Network Control
Block
Netbios communication buffers
rxBuffer db 512 dup('?') ; Receive Data Buffer
txBuffer db 512 dup('?') ; Transmit Data Buffer
rxCtlBuf db 512 dup('?') ; Receive Data Buffer
txCtlBuf db 512 dup('?') ; Transmit Data Buffer
16 Byte NCB Group and User names and numbers --
ctrl_grp db 'NetPhoneCtrl0$$$'
; Control Group Name
ctrl_num db ?
; Determined by NetBIOS at runtime
my_name db 'NetPhoneUser00$$' ; User
Name
my_num db ?
; Determined by NetBIOS at runtime
sndChan db 16 dup ('$')
; name to send sound data to
sndChanNum db ?
; sndChan group num determined by NetBios
sndChanName db MAXGRPNAME dup ('$') ; Group Long Name
myGrpNum db ?
; Group number in groups table
Packet counters
rcvcnt dw 0
sndcnt dw 0
rcvbadpost dw 0
Misc Variables
pbuf db 7 dup(?)
crlf db CR,LF,'$'
fullName db MAXNAMELEN dup (?) ; own display
name
myID db ?
; user ID
whoTalk db NOBODY
; ID of current person talking
numUsers db 0
; not currently used
users UserType MAXUSERS dup(< >) ; User
array, not used in current implementation
numGroups db 0
; number of activve groups - no longer used
groups GroupType MAXGROUPS dup(< >) ; Group array
querytime dw ?
; time of last query
whoTalkTime dw ?
; time last sound message received
PlaySoundFlag db 0 ; flag to play sound
UI Variables
connection db INACTIVE ; status of audio connection
Display Messages
welcomeMsg db
'Welcome to NetPHONE','$'
noGroups
db ' No Groups ','$'
joinGrpMsg db
'Group Number to Join','$'
invalidEntryMsg db 'Entry is Invalid','$'
successMsg db
'Action Successful','$'
failedMsg
db 'Action Failed','$'
noAction
db 'Release Talk to do Action','$'
joinMsg
db 'Group Number to Join:','$'
lMsg
db 'Leaving Group','$'
makeMsg
db 'Enter Group Name','$'
blank
db '
','$'
Wave Files
WelcomeWav db 'Welcome.wav',0
PCX file variables
control db 'control.PCX',0
; Null-terminated Filename
letters db 'letters.PCX',0
helpscrn db 'helpscn.PCX',0
Counter variables
counter db 0
count db 0
Offset location variables
writeLoc dw ?
; Base Location (grp or msg window) + writeLoc = current Position
screenLoc dw ?
cmdLoc dw ?
MsgWinOff dw ?
GrpWinOff dw ?
Variables used in the string displays
lineNum dw -1
glineNum dw -1
strGrpNum db -1
hiLight dw 0
screenType db CMD
stringBuf db 25 dup(?),'$'
str_index db 0
Keyboard
oldKbdV dd ?
shift_hit dw 0
bksp_hit dw ?
inputValid db 0
; 0: InputBuffer is not ready
; 1: InputBuffer is ready
;-1: Esc key pressed
kbdVal db 0, 0, '1','2','3','4','5','6','7','8'
db '9','0', 0 , 0,
0, 0, 'q','w','e','r'
db 't','y','u','i','o','p',
0, 0, 0, 0
db 'a','s','d','f','g','h','j','k','l',
0
db 0 , 0, 0,
0, 'z','x','c','v','b','n'
db 'm', 0, '.', 0,
0, 0, 0, 32, 0, 0
db 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,
0, 0
shfVal db 0, 0, 0, 0, 0, 0,
0, 0, 0, 0
db 0, 0,
0, 0, 0, 0, 'Q','W','E','R'
db 'T','Y','U','I','O','P',
0, 0, 0, 0
db 'A','S','D','F','G','H','J','K','L',
0
db 0, 0,
0, 0, 'Z','X','C','V','B','N'
db 'M', 0, 0,
0, 0, 0, 0, 0, 0, 0
db 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,
0, 0
Status flags for the different types of button actions
joinInputValid db 0
leaveInputValid db 0
makeInputValid db 0
tempbuf db 7 dup(?)
PTT
db 0
strAction
dw 0
joinNum
dw ?
leaveNum dw ?
result
dw ?
factor
dw ?
ten
dw 10