Amulets & Armor
v1.02
Open Source Game
|
Modem Driver. More...
Data Structures | |
struct | T_commPortStruct |
struct | T_selfCommInfo |
Macros | |
#define | MAX_SIZE_LOOK_AHEAD 200 |
#define | SELF_COMM_BUFFER_SIZE 1024 |
Variables | |
T_commPortStruct * | G_currentPort = COMM_PORT_BAD |
T_word16(* | LowLevelCommGetReadBufferLength )(T_void) |
T_word16(* | LowLevelCommGetWriteBufferLength )(T_void) |
T_word16(* | LowLevelCommReadByte )(T_void) |
T_void(* | LowLevelCommSendByte )(T_byte8 byte) |
Modem Driver.
#define MAX_SIZE_LOOK_AHEAD 200 |
#define SELF_COMM_BUFFER_SIZE 1024 |
This routine checks to see if this is a machine that has both a client and a server on the same machine/process.
T_void CommClearPort | ( | ) |
Clears out the incoming data.
CommCloseAll closes all the ports opened by CommReadConfigFile.
NOTE: You should not close any of the ports that were opened by CommRead... except by calling this routine.
T_void CommClosePort | ( | T_commPort | port) |
CommClosePort finalizes the port's existence by removing it from memory and removing any interrupts tied to that port. It does not worry about hanging up the phone or sending last messages – this is up to the calling routines.
port | – Port to close |
T_word32 CommConvertBaudTo32 | ( | E_commBaudRate | baud) |
CommConvertBaudTo32 converts given enumerated baud type to a 32 bit integer.
baud | – Rate of baud as enumeration |
E_commBaudRate CommGetBaudRate | ( | T_void | ) |
CommGetBaudRate tells what the active port's baud rate is.
CommGetNumberPorts tells the number of ports previously opened by CommReadConfigFile. This routine is usually used with CommSetActivePortN.
NOTE: You should of called CommReadConfigFile before calling this routine.
E_commType CommGetPortType | ( | void | ) |
Tells what type of port is attached (modem, null modem, server, ...)
CommGetReadBufferLength returns the number of characters in the read buffer.
CommGetSendBufferLength returns the number of USED locations (number of characters that can be sent) in the output buffer.
T_commPort CommOpenPort | ( | E_commType | type, |
T_word16 | addressOrComNum, | ||
T_word16 | irq, | ||
E_commBaudRate | baud | ||
) |
CommOpenPort creates a port and initializes it to the given parameters. Pass in the type of connection (null modem, standard modem, or irq based modem), COM number or base address, baud rate, and irq (if an irq is needed).
type | – type of connection being used |
addressOrComNum | – base communication address if irq modem, or COM port number if null or standard modem (1 = COM1) |
irq | – Interrupt # for irq modem. Ignored for other modem types (just pass 0) |
baud | – Communications rate |
CommReadByte reads in one character in from the appropriate low level driver. However, if characters are in the look ahead buffer, they are taken out of there first.
CommReadConfigFile reads in the "PORT.CFG" file and opens all the ports counting the number of actually opened ports.
NOTE: No real errors are detected by this routine and ports that could not be opened are ignored.
CommReadData is used to read n number of bytes from the input stream (taking from the look ahead buffer as needed).
NOTE: Make sure to only call this routine if there is already that many characters in the receive buffer.
p_data | – Pointer to where to store data |
numberBytes | – Number of bytes to read |
CommRewindScan moves the current position of the scanned data back the given number of bytes. This, in effect, allows the system to go to previous characters that were already scanned from the data stream (since they have not been "read" they are still in the scan buffer).
NOTE: Make sure that you don't rewind more than you have scanned MINUS what you have read. If you do, this will bomb.
numChar | – Number of characters to rewind |
CommScanByte looks ahead into the buffer and returns characters as they are found. If no more characters are found, a zero is returned.
NOTE: No more than MAX_SIZE_LOOK_AHEAD characters can be scanned ahead. If there are, this problem bombs since there is no more space to store the look ahead characters.
CommScanData scans a number of bytes ahead into the read stream and stores the bytes into the given pointer.
NOTE: No more than MAX_SIZE_LOOK_AHEAD characters can be scanned ahead. If there are, this problem bombs since there is no more space to store the look ahead characters. Make sure to only call this routine if there is already that many characters in the receive buffer.
p_data | – Pointer to where to store data |
numberBytes | – Number of bytes to scan |
CommSendByte puts a character on the output buffer for sending.
NOTE: If the output buffer is full, the character sent is discarded.
byte | – Data to send |
CommSendData sends n number of bytes out the output port.
p_data | – Pointer to where to get data |
numberBytes | – Number of bytes to send |
T_void CommSetActivePort | ( | T_commPort | port) |
CommSetActivePort declares what port is to be used in all the next Comm port routine calls. This also sets up faster ways to call the comm port routines.
port | – Port to make the active port |
CommSetActivePortN sets the active port to be one of the already opened ports by CommReadConfigFile.
NOTE: Make sure you pass in a numOfPort that is less than the number of ports open (the first is 0, ..., number of ports-1).
T_commPortStruct* G_currentPort = COMM_PORT_BAD |