Final Specifications
Code from MP4 and other example code that was not written during the time spent on the final project is marked in red.
Client Constants/Variables
Server Constants/Variables
Client Procedures
Server Procedures
:Client
Constants
DOWNARROW EQU 80
RIGHTARROW EQU 77
LEFTARROW EQU 75
UPARROW EQU 72
CANVAS_X EQU 106
CANVAS_Y EQU 30
TOOL_X EQU 0
TOOL_Y EQU 30
TOOL_W EQU 106
TOOL_H EQU 283
NUM_MENU_ITEMS EQU 11
BKSP EQU 8
ESC EQU 1
ENTERKEY EQU 13
SPACE EQU 57
LSHIFT EQU 42
RSHIFT EQU 54
;--Packet masks (get them out of the ASCII char range)
CONTROL_MASK EQU 0FCh
; control packet
MESSAGE_MASK EQU 0FEh
; message packet
DRAW_MASK EQU 0FDh
; draw packet
;-------Second byte of the packet (subtype)
;--Draw
DRAW_PIXEL_M EQU 0F0h
; draw circle
DRAW_LINE_M EQU 0F1h
; draw line
DRAW_RECT_M EQU 0F2h
; draw rect
DRAW_CIRCLE_M EQU 0F3h
; draw circle
DRAW_TEXT_M EQU 0F4h
; draw text
DRAW_FILL_M EQU 0F5h
;--Control
CHANGE_NAME EQU 0FBh
; user is trying to change name
SIGNON EQU 0F6h
; sent on connect
SIGNOFF EQU 0F7h
; send on disconnect
USERLIST EQU 0F8h
;new user list coming in
TB EQU 0FFh
;text break, used to terminate text data
;----SOUND
DMASIZE EQU 1024*64
;DMA SIZE MAX: 64 KB
RECFILESIZE EQU 396
;incoming message
REC2FILESIZE EQU 1332
;alternate incoming message
SIGNONFILESIZE EQU 4730
;change in the user list
DRAWFILESIZE EQU 4366
; incoming draw
Variables
DMASel resw 1
;DMA selector
DMAAddr resd 1
;DMA linear address
DMAChan resb 1
;DMA channel
FileOffset resd 1
; Pointer to beginning of wav data
FileBufferSize resd 1
; Size of data in the buffer
_GraphicsMode resw 1
; Graphics mode #
_kbINT resb 1
; Keyboard interrupt #
_kbIRQ resb 1
; Keyboard IRQ
_kbPort resw 1
; Keyboard port
_MouseSeg resw 1
; real mode segment for MouseCallback
_MouseOff resw 1
; real mode offset for MouseCallback
_MouseX resw 1
; X coordinate position of mouse on screen
_MouseY resw 1
; Y coordinate position of mouse on screen
_ScreenOff resd 1
; Screen image offset
_CanvasOff resd 1
; Canvas image offset
_OverlayOff resd 1
; Overlay image offset
_SmallFontOff resd 1
; Font image offset
_Font2Off resd 1
_MenuOff resd 1
; Menu image offset
_UsersOff resd 1
; Users list offset
_ToolsOff resd 1
; Tools offset
_DividerOff resd 1
; divider bar
_TextDispOff resd 1
; Chat window
_TextEnterOff resd 1
; Text bar
_Net_ErrOff resd 1
; Network error dialog
_hosterrOff resd 1
; hostname failed message
_connerrOff resd 1
; connect failed message
_recverrOff resd 1
; receive error message
_senderrOff resd 1
; send error message
_connOff resd 1
; connected icon
_notconnOff resd 1
; disconnected icon
_guideOff resd 1
; user guide
_TextMessage resb 96
;text message buffer
_MPFlags resb 1 ; program flags
; Bit 0 - Exit program
; Bit 1 - Left mouse button (LMB) status: set if down, cleared if up
; Bit 2 - Change in LMB status: set if button status
; moves from pressed->released or vice-versa
; Bit 3 - Right shift key status: set if down, cleared if up
; Bit 4 - Left shift key status: set if down, cleared if up
; Bit 5 - Key other than shift was pressed
; Bit 6 - Not Used Anymore
; Bit 7 - Not Used
_MenuItem resb 1 ; selected menu item
; -1 - none
; 1 - pencil
; 2 - flood
; 3 - rect empty
; 4 - rect fill
; 5 - circle empty
; 6 - circle fill
; 7 - line
; 8 - text
; 9 - color
; 10 - text box
; Line algorithm variables
_x resw 1
_y resw 1
_dx resw 1
_dy resw 1
_lineerror resw 1
_xhorizinc resw 1
_xdiaginc resw 1
_yvertinc resw 1
_ydiaginc resw 1
_errordiaginc resw 1
_errornodiaginc resw 1
; Circle algorithm variables
_radius resw 1
_circleerror resw 1
_xdist resw 1
_ydist resw 1
; flood fill variables
_PointQueue resd 1
_QueueHead resd 1
_QueueTail resd 1
_key resb 1
_Numpixels resw 1
_SelectedUser resd 1
;pointer to beginning of selected user name in _UserList
_UserLength resb 1
;length of users current user name
_UserList resb 320
;current list of connected users
_errorMsg resd 1
;pointer to network error message
_socket resd 1
;pointer to outgoing socket
_address resb SOCKADDR_size
; SOCKADDR structures
recvbuf_len equ 96
_recvbuf resb recvbuf_len
;buffer for incoming data
_buf resb 96
;scratch buffer for outgoing data
_listensock resd 1
;pointer to listening socket
_connsocket resd 1
;socket connected from server
_listenaddr resb SOCKADDR_size ;address structure for listening socket
_gotaccept db 0
;set by socket handler on waiting connection
;SOUND files
SoundRec db "rec.wav",0
SoundRec2 db "rec2.wav",0
SoundSignOn db "signon.wav",0
SoundDraw db "draw.wav",0
DMAFlag dd 0
; Required image files
_SmallFontFN db 'small.png',0
;8x16 font used by DrawSmallText
_Font2FN db 'font3.png',0
;12x24 font used by DrawText
_MenuFN db 'menu.png',0
;menu/title bar
_UsersFN db 'users.png',0
;user list
_ToolsFN db 'tools.png',0
;drawing toolbox
_DrawFN db 'draw.png',0
;canvas area
_DividerFN db 'divider.png',0
;divider between canvas and messages
_T_DispFN db 't_disp.png',0
;message area
_T_EnterFN db 't_enter.png',0
;text entry box
_Net_ErrFN db 'net_err.png',0
;network error dialog
_hosterrFN db 'hosterr.png',0
;hostname failed message
_connerrFN db 'connerr.png',0
;connect failed message
_senderrFN db 'senderr.png',0
;receive error message
_recverrFN db 'recverr.png',0
;send error message
_connFN db 'conn.png',0
;connected icon
_notconnFN db 'notconn.png',0
;disconnected icon
_guideFN db 'guide.png', 0
;user guide
_ssFN db 'ss_test.bmp',0
;screen shot test file name
; Defined color values
_CurrentColor dd 0ffff0000h
; current color (initially red)
_ColorBlue dd 0ff0033ffh
_ColorWhite dd 0ffffffffh
_ColorBlack dd 0ff000000h
_ColorHalfBlack dd 0cc000000h
_ColorRed dd 0ffe00f0fh
_buffer db ' ','$'
_ColorString1 db 'Enter numerical values for','$'
_ColorString2 db 'each channel (ARGB), and','$'
_ColorString3 db 'separate each number by a','$'
_ColorString4 db 'space (ex. 127 255 255 0).','$'
_QwertyNames
db 0 ; filler
db 0,'1','2','3','4','5','6','7','8','9','0','-','=',BKSP
db 0, 'q','w','e','r','t','y','u','i','o','p','[',']',ENTERKEY
db 0,'a','s','d','f','g','h','j','k','l',';',"'","`"
db 0,'\','z','x','c','v','b','n','m',",",'.','/',0,'*'
db 0, ' ', 0, 0,0,0,0,0,0,0,0,0,0 ; F1-F10
db 0,0 ; numlock, scroll lock
db 0, 0, 0, '-'
db 0, 0, 0, '+'
db 0, 0, 0, 0
db 0, 0; sysrq
_QwertyNames_end resb 0
_QwertyShift
db 0 ; filler
db 0,'!','@','#','$','%','^','&','*','(',')','_','+',BKSP
db 0, 'Q','W','E','R','T','Y','U','I','O','P','{','}',ENTERKEY
db 0,'A','S','D','F','G','H','J','K','L',':','"','~'
db 0,'|','Z','X','C','V','B','N','M',"<",'>','?',0,'*'
db 0, ' ', 0, 0,0,0,0,0,0,0,0,0,0 ; F1-F10
db 0,0 ; numlock, scroll lock
db 0, 0, 0, '-'
db 0, 0, 0, '+'
db 0, 0, 0, 0
db 0, 0; sysrq
_QwertyShift_end resb 0
_TextInputString times 80 db 0,'$'
;max message length plus room for user name at end
_ColorInputString times 15 db 0,'$'
_RoundingFactor dd 000800080h, 00000080h
_UserName times 9 db 0
;8 char max
_FileName times 13 db 0
;8 char max entry, +4 extension
;NETWORK VARIABLES
_connected db 0
;set whenever connected to a server
_listenconnected db 0
;set when server has connected back
;Various text prompts
_UserString1 db 'Enter a user name to', '$'
_UserString2 db 'display to others','$'
_FileString1 db 'Enter a file name:','$'
_FileString2 db '(.bmp extension is assumed)','$'
_ServerString1 db 'Enter hostname or IP of', '$'
_ServerString2 db 'server to connect to', '$'
_InitString db 'CONNECT FROM CLIENT',10,13
_Server times 24 db 0
;IP address buffer, 23 char max server name/ip
_port dw 12345
; outgoing port
:Server
Constants
;-------Packet masks (out of the ASCII char range)
CONTROL_MASK EQU 0FCh ; control packet
MESSAGE_MASK EQU 0FEh ; message packet
DRAW_MASK EQU 0FDh
; draw packet
;-------Second envelope of the packet
;--Draw
DRAW_PIXEL_M EQU 0F0h ; draw circle
DRAW_LINE_M EQU 0F1h ; draw line
DRAW_RECT_M EQU 0F2h ; draw rect
DRAW_CIRCLE_M EQU 0F3h ; draw circle
DRAW_TEXT_M EQU 0F4h ; draw text
DRAW_FILL_M EQU 0F5h
;--Control
CHANGE_NAME EQU 0FBh ; user is trying to change name
SIGNON EQU 0F6h
; when user signs in
SIGNOFF EQU 0F7h
; when user closes the client
USERLIST EQU 0F8h
; for a username list
TB EQU 0FFh
;text break, used to terminate/separate text data
Variables
_port dw 12345
; port number to listen on
_numusers db 0
; number of users connected (0-30)
lim_users equ 30
_usernames resb lim_users*9+4 ;array of user names/pointers to sockets (9 bytes for user name, 4 for pointer to socket)
_usersockets resd lim_users
;array of pointers to socket user is connected on
_socket resd 1 ; listening socket
_connsockets resd lim_users
;array of connection sockets back to users
_gotaccept resb 1
_address resb SOCKADDR_size ; SOCKADDR structure
_clientaddress resb SOCKADDR_size
_currentuser resd 1
;holds a pointer to the current socket (as we traverse the arrays)
buf_len equ 16*1024
_buf resb buf_len
;incoming/scratch buffer
Procedures/Subroutines
:Client
.init
--Will Snodgrass--
;pseudocode :
call _LibInit
Allocate image buffers
Load image files into buffers
Initialize graphics
Install keyboard and mouse ISR's
Initialize socket library
Create outgoing socket
Create & bind listening socket
Install socket handler
Start listening on listen socket
Copy image buffers to main screen buffer
Display user guide until ESC press
call _GetUserName
call _GetServer
.mainLoop
--Will Snodgrass--
Check flags to determine if the
server is ready to connect to client
Call AcceptConnection to accept
incoming connection if necessary
Fill current color box with the current color
Check the connection status and display either connected or
disconnected icon
Call Recv_and_Update to check for incoming data
Check for mouse press, call .MouseEvent if true
Check if in draw text or change color mode, jump to their
handler if so
Check for data on the socket from server, pass it to
PacketDecode if it exists
.endloop
.MouseEvent
--Will Snodgrass--
Called from main loop when mouse
button is pressed. Handles all mouse clicks while in
drawing mode. Checks for and handles Server, User Name
and Close button clicks.
Also handles selection of drawing tools, and entry into text
messaging mode. If a tool
was clicked, sets [_MenuItem] to the corresponding integer
value and jumps to the associated
handler loop for that tool if applicable. Otherwise returns
to beginning of main loop. Draws red
rectangle around selected object if applicable.
Inputs:
_MouseX, _MouseY - coordinates of
mouse when pressed
Outputs:
[_MenuItem] - number that corresponds
to mode of operation
[_MPFlags] - updated to reflect
handling of mouse event
Highlight rectangle cleared and drawn
in new location
Calls: _DrawRect, _CopyBuffer, _CopyToScreen, _PointInBox,
_GetUserName,
_GetServer,
_ScreenShot
.HandleTextBox
--Will Snodgrass--
Loop to control entering of text
message:
Displays text entry into box as it is typed and sends entered
text to server when ENTER is pressed.
Checks for new incoming data on each iteration to prevent
blocking. Checks for clicks within the
user list to handle user selection. Returns to drawing
mode (main loop) when ESC is pressed.
Inputs:
[_key] -- ASCII value of current
keypress
[_connected] -- flag set when
connected to server
[_MPFlags] -- identifies mouse
events and ESC presses
[_MouseX], [_MouseY] -- coordinates
of a mouse click
*_UserName - ptr to current user name
string, to add to text entered before transmittal
Outputs:
_TextMessage - message that was
entered + $ + user name + $
Calls: _Packet_Encode, _DrawSmallText, _ClearBuffer, _CopyBuffer,
_ComposeBuffers, _CopyToScreen,
_PointInBox,
_UpdateUsers
void AcceptConnection
--Will Snodgrass--
Accepts a waiting connection on the listening socket and
saves a reference to the socket.
Sets flags to reflect status.
Inputs:
[_listensocket] - incoming socket
with ready connection
Outputs:
[_connsocket] - reference to accepted
connection
[_gotaccept] - cleared to indicate
waiting connection was handled
[_listenconnected] - set to indicate
we have an active incoming connection
Calls:
_Socket_accept
void _SocketHandler
--Will Snodgrass--
Ran when a new connection is
incoming on the listening socket. Sets a flag that will be seen
by the main loop.
Inputs:
[_listensocket] - socket we're
listening on
Outputs:
[_gotaccept] - flag set if we have a
new connection ready
Calls:
none
void _GetUserName (word flag)
--Will Snodgrass--
Prompts user for username to be displayed to other users.
Transmits username to server if being
called to change current user name.
Inputs:
flag -- 0 if initial call, 1 if
calling to change user name
Text entered to prompt
Outputs:
[_UserName] - text stored here,
terminated by $
Calls: _ClearBuffer, _CopyBuffer, _DrawRect, _ComposeBuffers,
_DrawText, _CopyToScreen, _PacketEncode
void _GetServer (word flag)
--Will Snodgrass--
Prompts user for server URL or IP to
connect to. Disconnects from current server if required,
and connects to entered server. Transmits signon packet
with username when connected.
Inputs:
flag -- for future features
[_connected] - status flag to
determine if we need to disconnect first
[_socket] - connection socket
*_address - pointer to address
structure for connection socket
Text entered to prompt
Outputs:
[_Server] - text stored here,
terminated by 0
[_listenconnected] - cleared if
disconnect is executed
Calls: _ClearBuffer, _CopyBuffer, _DrawRect,
_ComposeBuffers, _DrawText, _CopyToScreen, _PacketEncode,
_Socket_close, _Socket_create, _Socket_getbyhostname, _Socket_connect
void NetworkError (dword [_errorMsg])
--Will Snodgrass--
Displays network error message who's
image buffer is pointed to by _errorMsg. Waits for
ESC press before clearing dialog box.
Inputs:
*[_errorMsg] - pointer to error
message image buffer
*[_Net_ErrOff] - pointer to dialog
box image buffer
Outputs:
[_connected] - flag is set to 0
Prompt displayed
Calls: DrawText, DrawRect ClearBuffer, CopyBuffer,
ComposeBuffers, CopyToScreen
void _MessageUpdate(dword *buf)
--Will Snodgrass--
Updates the messaging window with new
text message that was received. The data pointed to by
buf will have a $ terminated message followed by a $
terminated user name followed by a TB byte
Inputs:
*buf - pointer to packet
data
Outputs:
Messaging text rotated upwards, new
message inserted at bottom of message window
Calls: _DrawSmallText, _ClearBuffer, _CopyBuffer, _ComposeBuffers,
_CopyToScreen
void _UpdateUsers(dword *buf, word
userselect) --Will
Snodgrass--
Updates the list of online users when
a userlist packet is received from server and highlights
the user at index userselect if it is valid for the current
number of users. Also saves a pointer
to the selected username
Inputs:
*buf - pointer to
packet data
userselect - index of user to
highlight and save
Outputs:
_UserList - new user list written to
this buffer
[_SelectedUser] - pointer to the
selected user in _UserList
Calls: _DrawSmallText, _ClearBuffer, _CopyBuffer, _ComposeBuffers,
_CopyToScreen
void _PacketEncode (word type, word
subtype, dword *buf, dword buffersize)
--Will Snodgrass--
Prepares packet data to be
sent. Packet types are prepended to packet data, then transmitted
Inputs:
type - Main type of packet
subtype - Sub type of packet
*buf - Address to where the buffer is
now
buffersize - Size of packet in bytes
Outputs:
Formatted packet created in memory
Calls:
_Socket_send
void _Recv_and_Update
--Will Snodgrass--
Checks incoming socket for
waiting data. Processes data based on its header information.
Handles drawing of image data to canvas. Plays
notification sound based on data type.
Inputs:
[_connsocket] - incoming socket
to receive data from
*_recvbuf - pointer to scratch buffer
for incoming data
Outputs:
none
Calls:
_ClearBuffer, _CopyBuffer,
_ComposeBuffers, _CopyToScreen,
_DrawLine, _DrawRect,_DrawCircle,_DrawText,_FloodFill,
_ReadInFile, _MessageUpdate, _UpdateUsers
void _ScreenShot
--Will Snodgrass--
Prompts for user entered file
name then saves screen image data to a bitmap file in the
program directory.
Inputs:
none
Outputs:
bitmap file written
Calls:
_ClearBuffer, _CopyBuffer, _DrawRect,
_ComposeBuffers, _DrawText, _CopyToScreen, _SaveBMP,
void _DrawSmallText(dword *StringOff, dword *DestOff, word DestWidth, word
DestHeight, word X, word Y, dword Color)
--Will Snodgrass--
Draws a text string pointed to by StringOff with color Color at point (X,Y)
in the buffer pointed to by DestOff using small font file
Inputs:
StringOff - offset of string to draw
DestOff - offset of an image buffer in memory
DestWidth - width of the buffer
DestHeight - height of the buffer
X - x coordinate of start point
Y - y coordinate of start point
Color - color of the string to draw
[_FontOff] - offset of font image data
Outputs: String drawn to buffer
Calls: _PointInBox
void
_SoundISR
--Josh Kim--
Triggered when a sound completes
Inputs: none
Outputs: [DMAFlag] set when run
Calls: none
void
_InitSound
--Josh Kim--
Purpose: Initialize everything that has to do with sound, including the DMA buffer
Inputs: None
Outputs: None
Calls: DMA_Allocate_Mem
DMA_Lock_Mem
LockArea
SB16_Init
SB16_GetChannel
SB16_SetFormat
SB16_SetMixers
Comments: Sets _DMAChannel, _DMASelector, and _DMAAddress
void ReadinFile (dword FileName, dword
Size)
--Josh Kim--
Reads the file, and sets up a Buffer and BufferSize.
Plays the loaded file.
Inputs: .Filename: Name of the file
.Size: Size of the file
Outputs: None
Calls: AllocMem
OpenFile
ReadFile
CloseFile
DMA_Start
SB16_Start
Comments: The main for the sound stuff
void StopSound
--Josh Kim--
Purpose: Kill everything that has to do with sound and DMA
Inputs: [DMAChan], dma channel we were using
Outputs: None
Calls: DMA_Stop
SB16_Stop
SB16_SetMixers
SB16_Exit
Comments: Ends the sound insanity
***All draw handlers modified
to call PacketEncode with appropriate data when release event occurs***
.HandlePen
Loop,
handles drawing w/ pen tool
.HandleRect
Loop,
handles rectangle tool
.HandleCircle
Loop,
handles circle tool
.HandleLine
Loop,
handles line tool
.HandleFill
Loop,
handles fill tool
.HandleText
Loop, handles text tool
.HandleColor
Loop,
handles color changes
dword _PointInBox(word
PointX, word PointY, word BoxULCornerX, word BoxULCornerY, word BoxLRCornerX,
word BoxLRCornerY)
- Determines if the point (X,Y)
is located in the box formed by the points (BoxULCornerX,BoxULCornerY) and
(BoxLRCornerX,BoxLRCornerY)
- Inputs:
- X - x coordinate of point
in question
- Y - y coordinate of point
in question
- BoxULCornerX - x
coordinate of upper-left hand corner of box
- BoxULCornerY - y
coordinate of upper-left hand corner of box
- BoxLRCornerX - x
coordinate of lower-right hand corner of box
- BoxLRCornerY - y
coordinate of lower-right hand corner of box
- Outputs:
- Calls: None
- Returns: 1 if BoxULCornerX
<= X <= BoxLRCornerX and BoxULCornerY <= Y <= BoxLRCornerY, 0
otherwise
dword _GetPixel(dword *DestOff,
word DestWidth, word DestHeight, word X, word Y)
- Gets the color of the pixel
located at the point (X,Y) in the buffer pointed to by DestOff
- Inputs:
- DestOff - offset of an
image buffer in memory
- DestWidth - width of the
buffer
- DestHeight - height of the
buffer
- X - x coordinate of point
- Y - y coordinate of point
- Outputs: None
- Calls: _PointInBox
- Returns: color of the pixel
located at (X,Y) in the buffer, otherwise 0 if the point (X,Y) is not within
the boundary of the buffer
void _DrawPixel(dword *DestOff,
word DestWidth, word DestHeight, word X, word Y, dword Color)
- Draws a pixel with color Color
at point (X,Y) in the buffer pointed to by DestOff
- Inputs:
- DestOff - offset of an
image buffer in memory
- DestWidth - width of the
buffer
- DestHeight - height of the
buffer
- X - x coordinate of point
- Y - y coordinate of point
- Color - color of pixel to
draw
- Outputs: Pixel drawn to buffer
- Calls: _PointInBox
- Returns: None
void _DrawLine(dword *DestOff,
word DestWidth, word DestHeight, word X1, word Y1, word X2, word Y2, dword
Color)
- Draws a line with color Color
from point (X1,Y1) to (X2,Y2) in the buffer pointed to by DestOff
- Inputs:
- DestOff - offset of an
image buffer in memory
- DestWidth - width of the
buffer
- DestHeight - height of the
buffer
- X1 - x coordinate of start
point
- Y1 - y coordinate of start
point
- X2 - x coordinate of end
point
- Y2 - y coordinate of end
point
- Color - color of line to
draw
- Outputs: Line drawn to buffer
- Calls: _DrawPixel
- Returns: None
void _DrawRect(dword *DestOff,
word DestWidth, word DestHeight, word DestX1, word DestY1, word DestX2, word
DestY2, dword Color, dword FillRectFlag)
- Draws a rectangle with color
Color from point (X1,Y1) to (X2,Y2) in the buffer pointed to by DestOff
- Inputs:
- DestOff - offset of an
image buffer in memory
- DestWidth - width of the
buffer
- DestHeight - height of the
buffer
- X1 - x coordinate of start
point
- Y1 - y coordinate of start
point
- X2 - x coordinate of end
point
- Y2 - y coordinate of end
point
- Color - color of rectangle
to draw
- FillRectFlag - flag to
determine whether or not to fill the rectangle
- Outputs: Rectangle drawn to
buffer, filled if necessary
- Calls: _DrawLine, _FloodFill
- Returns: None
void _DrawCircle(dword *DestOff,
word DestWidth, word DestHeight, word X, word Y, word Radius, dword Color, dword
FillCircleFlag)
- Draws a circle with center
(X,Y), color Color, and radius Radius in the buffer pointed to by DestOff
- Inputs:
- DestOff - offset of an
image buffer in memory
- DestWidth - width of the
buffer
- DestHeight - height of the
buffer
- X - x coordinate of center
- Y - y coordinate of center
- Color - color of line to
draw
- FillCircleFlag - flag to
determine whether or not to fill the circle
- Outputs: Circle drawn to
buffer, filled if necessary
- Calls: _DrawPixel, _FloodFill
- Returns: None
void _DrawText(dword *StringOff,
dword *DestOff, word DestWidth, word DestHeight, word X, word Y, dword Color)
- Draws a text string pointed to
by StringOff with color Color at point (X,Y) in the buffer pointed to by
DestOff
- Inputs:
- StringOff - offset of
string to draw
- DestOff - offset of
an image buffer in memory
- DestWidth - width of the
buffer
- DestHeight - height of the
buffer
- X - x coordinate of start
point
- Y - y coordinate of start
point
- Color - color of the
string to draw
- [_FontOff] - offset of
font image data
- Outputs: String drawn to
buffer
- Calls: _PointInBox
void _ClearBuffer(dword
*DestOff, word DestWidth, word DestHeight, dword Color)
- Clears a buffer pointed to by
DestOff by filling it with color Color
- Inputs:
- DestOff - offset of
an image buffer in memory
- DestWidth - width of the
buffer
- DestHeight - height of the
buffer
- Color - color to make
buffer
- Outputs: Color copied to
buffer
- Calls: None
void _CopyBuffer(dword *SrcOff,
word SrcWidth, word SrcHeight, dword *DestOff, word DestWidth, word DestHeight, word
X, word Y)
- Copies a source buffer pointed
to by SrcOff to a location (X,Y) in a destination buffer pointed to by
DestOff
- Inputs:
- SrcOff - offset of source
buffer
- SrcWidth - width of source
buffer
- SrcHeight - height of
source buffer
- DestOff - offset of
destination buffer
- DestWidth - width of
destination buffer
- DestHeight - height of
destination buffer
- X - x coordinate of start
point in destination buffer
- Y - y coordinate of start
point in destination buffer
- Outputs: Source buffer copied
onto destination buffer
- Calls: None
void _ComposeBuffers(dword
*SrcOff, word SrcWidth, word SrcHeight, dword *DestOff, word DestWidth, word
DestHeight, word X, word Y)
- Alpha composes a source buffer
pointed to by SrcOff onto a destination buffer pointed to by DestOff at
location (X,Y)
- Inputs:
- SrcOff - offset of source
buffer
- SrcWidth - width of source
buffer
- SrcHeight - height of
source buffer
- DestOff - offset of
destination buffer
- DestWidth - width of
destination buffer
- DestHeight - height of
destination buffer
- X - x coordinate of start
point in destination buffer
- Y - y coordinate of start
point in destination buffer
- Outputs: Source buffer alpha
composed onto destination buffer
- Calls: None
void _FloodFill(dword
*DestOff, word DestWidth, word DestHeight, word X, word Y, dword Color, dword
ComposeFlag)
- Performs a flood fill
operation on a region in the buffer pointed to by DestOff
- Inputs:
- DestOff - offset of
an image buffer in memory
- DestWidth - width of the
buffer
- DestHeight - height of the
buffer
- X - x coordinate of point
in the region
- Y - y coordinate of point
in the region
- Color - new color for
region
- ComposeFlag - flag to
determine whether or not to alpha compose the current color of the
region with Color
- Outputs: Region filled with
color Color in buffer
- Calls: _PointInBox, _GetPixel,
_DrawPixel
dword _InstallKeyboard(void)
- Installs the keyboard ISR
- Inputs: None
- Outputs: None
- Calls: _LockArea
- Returns: 1 on error, 0
otherwise
void _RemoveKeyboard(void)
- Uninstalls the keyboard ISR
- Inputs: None
- Outputs: None
void _KeyboardISR(void)
- Handles keyboard input from
the user
- Inputs: Keypress waiting at
port [_kbPort], [_kbIRQ]
- Outputs: [_key], [_MPFlags]
- Calls: None
dword _InstallMouse(void)
- Installs the mouse callback
- Inputs: None
- Outputs: [_MouseSeg],
[_MouseOff]
- Returns: 1 on error, 0
otherwise
- Calls: _LockArea, _Get_RMCB,
DPMI_Int
void _RemoveMouse(void)
- Removes the mouse callback
- Inputs: [_MouseSeg],
[_MouseOff]
- Outputs: None
- Calls: _Free_RMCB, DPMI_Int
void _MouseCallback(dword
*DPMIRegsPtr)
- Handles mouse input from the
user
- Inputs:
- DPMIRegsPtr - pointer to
DPMI register structure
- [_MouseX], [_MouseY],
[_MPFlags]
- Outputs: [_MouseX], [_MouseY],
[_MPFlags]
- Calls: None
:Server
.init
--Alessandro Bellina, Will Snodgrass--
;pseudocode:
call _LibInit
Create _socket, the listen socket
Create _usersockets, an array of 30 outgoing sockets
Initialize _usernames array with header bytes and fill with
TB bytes
Initialize _connsockets, the array of connected incoming
sockets to 0's
Bind listening socket, install handler, and start
listening
.mainLoop
--Alessandro Bellina--
Check for keypress,
exit on true
Check for new incoming connection, jump to .gotconn on true
Attempt receive on incoming array of sockets.
On successful receive from any
socket:
Dump
packet data to screen
If
control packet:
call _Packet_Decode
Transmit user list to all clients
If other
type of packet:
Loop through outgoing sockets and broadcast received data to each
.endloop
void _Packet_Decode (dword *buf, word index)
--Alessandro Bellina--
Called when a control packet
is received (Change in users)
Updates the usernames array to reflect the changes, and
clears
socket data for a user if they sent a SIGNOFF packet
Inputs:
*buf - pointer to packet data
index - the index in the arrays of
the user even came from
Outputs:
_usernames - new name written at
index, or name cleared (EEh written)
Calls:
none
void _SocketHandler
This callback procedure will be executed when a new connection
is received. Will set a flag to signify the main loop that it should
accept a new socket.
Inputs:
Socket to socket responsible for the event thrown
Event the event that was received
Outputs:
[_gotaccept] set to 1, since a new connection should be
ready
|