291Kart Networking Structure
On the main menu, the user is prompt to enter a number
from 0 to 9. The purpose of this is to allow 10 unique 16 byte group names
to allow 10 different networked sessions of two players each. After entering
a number, if no one else enters the same number within 1 minute, then connection
to network is released. Two players who wish to race each other need to
communicate with each other and agree on the number to enter.
Network Variables
- RXBuffer - Data Strucuture for receiving data
- TXBuffer - Data Structure for transmitting data
- grp_name- Unique 16 byte group name
- my_name - Unique 16 byte name of player
- grp_num - assigned by NetBIOS at runtime
- _my_num - Determined in NetINIT (0 or 1)
- rcvcnt - counts bytes received
- sndcnt - counts bytes sent
- rcvbadpost - counts number of bad bytes received
- _TrackFlag - 1 if track selestion was received
- _TimeReceived - 1 if other player fiished the race and finish
time of that player was received
- _InfoFlag - 1 if networked player info was received
- _TimeOverFlag - 1 if waited for networked player for more than
specified number of minutes
- _ErrorNet - 1 if there was an error connecting to the group
name specified
Other Player's Variables
- Other_X - networked player's X position in the world
- Other_Y - networked player's Y position in the world
- Other_View - networked player's view angle
- _OtherKartChoice - kart number of the networked player's choice
of kart
- Otherminute - the minute when the networked player finished
the track
- Othersecond - the second when the networked player finished
the track
- Othertenth - the tenth of second when the networked player finished
the race
Variable for using time control to send packets
- LastTimeCount - contents of the
Network Control Block Structure
- ncb_command - command code
- ncb_retcode - error return code
- ncb_lsn - session number
- ncb_num - name number
- ncb_buf_off - ptr to send/receive data offset
- ncb_buf_seg - ptr to send/receive data segment
- ncb_buflen - length of data
- ncb_callname - remote name
- ncb_name - local name
- ncb_rto - receive timeout
- ncb_sto - send timeout
- ncb_post_off - async command complete post offset
- ncb_post_seg - async command complete post segment
- ncb_lana_num - adapter number
- ncb_cmd_done - 0FFh until command completed
- ncb_res - reserved
Network Procedures
_NetINIT
- Owner: Judy Lee
- Purpose: Initialize Network communication over NetBIOS. If networking
is unable to be established because either the group name already exists
or just could not get on the network, then it calls ConnectFailFunc.
- Inputs: GroupNum #0-9 as specified by user
- Outputs: _my_num = player number (0 or 1) depends on who got
on the network first
- Uses: MACRO STRCPY16 by John Lockwood
- Calls: ConnectFailFunc, _ShowScreenBuffer, LoadPCX, LoadSound,SetupDMA,
Waiting, ConnectFailFunc
_NetRelease
- Owner: Judy Lee
- Purpose: Releases NetBIOS group name and resources
- Inputs: NONE
- Outputs: NONE
SendPacket
- Owner: Judy Lee
- Purpose: Send Datagram to Group.
- Inputs:
- TXBuffer : Data Buffer to Transmit,
- AX : Data Length
- Outputs: DataGram to Network
_SendDataCheck
- Owner: Judy Lee
- Purpose: Checks to see of packet should be sent. Calls SendPlayerData
if difference between LastSendTime and CurrentTime is greater than 3
- Inputs: LastSendTime
- Outputs: CurrentTime, updated LastSendTime
- Calls: SendPlayerData
_SendPlayerInfo
- Owner: Judy Lee
- Purpose: Sends the player's choice of KART to the other computer
- Inputs: KartChoice, _my_num
- Outputs: Sends packet to Nework.
- Calls: SendPacket
- Uses: MACRO STRCPY
- Note: TXBUffer[0]:word=_my_num, TXBuffer[2]:word=KartChoice
_SendTrackInfo
- Owner: Judy Lee
- Purpose: Send's player 0's choice of track
- Inputs: TrackChoice : track number chosen by player 0
- Ouputs: Sends packet to network
- Calls: SendPacket
- Uses: MACRO STRCPY
- Note: TXBuffer[0]:word=TrackChoice , ax=2
SendPlayerData
- Owner: Judy Lee
- Purpose: Sends player's x-position, y-position, view angle
- Inputs: _Player_X_Pos, _Player_Y_Pos,_view_angle
- Outputs: Sends packet to network
- Calls: SendPacket
- Uses: MACRO STRCPY
- Note: TXBuffer[0]:word = _my_num, TXBuffer[2]:word = _Player_X_Pos,
TXBuffer[4]:word = _Player_Y_Pos, TXBuffer[6]:word = _view_angle
_SendTimeExit
- Owner: Judy Lee
- Purpose: Calls when a player finishes the race before networked
opponent
- Inputs: _my_num, AX:length 10, _minute,_second,_tenthOfSecond
- Outputs: Sends packet to network
- Calls: SendPacket
- Note: TXBuffer[0]:word=_my_num, TXBuffer[2]:word=_minute, TXBuffer[4]:word=_second,
TXBuffer[6]:word=_tenthOfsecond, TXBuffer[8]:word=0000h
Post (interupt)
- Owner: Judy Lee
- Purpose: Receives data from network and puts received data into
RXBuffer.
- Inputs: RXBuffer
- Outputs: NONE
- Calls: NetPost
NetPost
- Owner: Judy Lee
- Purpose: Process Data Received
- Updates data according to what AX is:
- AX=4 _SendPlayerInfo [_my_num, KartChoice ]
- AX=2 _SendTrackInfo [ TrackChoice ]
- AX=8 _SendPlayerData [ _my_num, _Player_X_Pos, _Player_Y_Pos, _view_angle
]
- AX=10 _SendTimeExit[_my_num,_minute,_second,_tenthOfSecond,0000h]
- Inputs: AX-Length of data received, RXBuffer-received buffer
- Outputs:
- If AX=8: Updates _Other_X_Pos, _Other_Y_Pos, _Other_View_Angle
- If AX=2: Updates TrackChoice
- If AX=4: Updates OtherKartChoice
- If AX=10: Updates Otherminute, Othersecond, Othertenth and sets _TimeReceived=1
- Called by: Post
Wait
- Owner: Judy Lee
- Purpose: This function will wait for another player to enter
network group specified. If another player does not enter the same network
within 1 minute, then it will call ConnTimeOverFunc.
- Inputs: _minute
- Outputs: NONE
- Calls: ConnTimeOverFunc, LoadPCX, _ShowScreenBuffer
Network Error Functions
ConnectFailFunc
- Owner: Judy Lee
- Purpose: Displayes Error message on screen if connection could
not be established
- Inputs: NONE
- Outputs: NONE
- Calls: LoadPCX, _ShowScreenBuffer
ConnTimeOverFunc
- Owner: Judy Lee
- Purpose: Displays Time Over message on screen and sets _TimeOverFlag=1
- Inputs: NONE
- Outputs: _TimeOverFlag
- Calls: LoadPCX, _ShowScreenBuffer
- Note: _TimeOverFlag is used to determine whether to call _NetRelease
in MAIN.C
Time Variables
- LastSendTime - contents of internal counter when last SendPlayerData
was sent
- CurrentTime - contents of internal clock now
- _minutes - minutes since _initTime
- _seconds - seconds since _initTime
- _timeRemainder - counter since _initTime
Time Functions
_InitTime
- Owner: Judy Lee
- Puropse: Initializes the Time Variables; minutes=0, seconds=0,
timeRemainder=0
- Inputs: NONE
- Outputs: _minutes=0, _seconds=0, _remainder=0
- Uses: MACRO GetTime
_UpDateTime
- Owner: Judy Lee
- Purpose: Updates the Time Variables:
- _minute
- _second
- _tenthOfSecond
- Inputs: _minute, _second, _remainder
- Outputs: _minute, _second, _remainder
- Uses: MACRO GetTime