Initial commit of Command & Conquer Red Alert source code.
This commit is contained in:
180
WIN32LIB/WINCOMM/MAKEFILE
Normal file
180
WIN32LIB/WINCOMM/MAKEFILE
Normal file
@@ -0,0 +1,180 @@
|
||||
#
|
||||
# Command & Conquer Red Alert(tm)
|
||||
# Copyright 2025 Electronic Arts Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#***************************************************************************
|
||||
#** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Project Name : Westwood Library .LIB makefile *
|
||||
#* *
|
||||
#* File Name : MAKEFILE *
|
||||
#* *
|
||||
#* Programmer : Julio R. Jerez *
|
||||
#* *
|
||||
#* Start Date : Jan 26, 1995 *
|
||||
#* *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WIN32LIB = your root WIN32LIB path *
|
||||
#* WIN32VCS = root directory for wwlib version control archive *
|
||||
#* COMPILER = your Watcom installation path *
|
||||
#* *
|
||||
#* Required changes to makefile: *
|
||||
#* PROJ_NAME = name of the library you're building *
|
||||
#* OBJECTS = list of objects in your library *
|
||||
#* *
|
||||
#* Optional changes to makefile: *
|
||||
#* PROJ_DIR = full pathname of your working directory *
|
||||
#* .path.xxx = full pathname where various file types live *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Verify user's environment
|
||||
#---------------------------------------------------------------------------
|
||||
!ifndef %WIN32LIB
|
||||
!error WIN32LIB Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WIN32VCS
|
||||
!error WIN32VCS Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WATCOM
|
||||
!error WATCOM Environment var not configured.
|
||||
!endif
|
||||
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
|
||||
PROJ_NAME = wincomm
|
||||
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
|
||||
LIB_DIR = $(%WIN32LIB)\lib
|
||||
|
||||
!include $(%WIN32LIB)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
wincomm.obj &
|
||||
modemreg.obj &
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Path macros: one path for each file type.
|
||||
# These paths are used to tell make where to find/put each file type.
|
||||
#---------------------------------------------------------------------------
|
||||
.asm: $(PROJ_DIR)
|
||||
.c: $(PROJ_DIR)
|
||||
.cpp: $(PROJ_DIR)
|
||||
.h: $(PROJ_DIR)
|
||||
.obj: $(PROJ_DIR)
|
||||
.lib: $(WWLIB)\lib
|
||||
.exe: $(PROJ_DIR)
|
||||
|
||||
#===========================================================================
|
||||
# Pre-defined section: there should be little need to modify this section.
|
||||
#===========================================================================
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Tools/commands
|
||||
#---------------------------------------------------------------------------
|
||||
C_CMD = wcc386
|
||||
CPP_CMD = wpp386
|
||||
LIB_CMD = wlib
|
||||
LINK_CMD = wlink
|
||||
ASM_CMD = tasm
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Include & library paths
|
||||
# If LIB & INCLUDE are already defined, they are used in addition to the
|
||||
# WWLIB32 lib & include; otherwise, they're constructed from
|
||||
# BCDIR & TNTDIR
|
||||
#---------------------------------------------------------------------------
|
||||
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB
|
||||
INCLUDEPATH = $(%WIN32LIB)\INCLUDE;$(%WATCOM)\H
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
# Compiler:
|
||||
# ($< = full dependent with path)
|
||||
# Assembler:
|
||||
# output obj's are constructed from .obj: & the $& macro
|
||||
# ($< = full dependent with path)
|
||||
# tasm's cfg file is not invoked as a response file.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
.c.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(CPP_CMD) $(CC_CFG) $(PROJ_DIR)\$^*.cpp
|
||||
|
||||
.asm.obj: $(%WIN32LIB)\project.cfg
|
||||
$(ASM_CMD) $(ASM_CFG) $<
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Default target: configuration files & library (in that order)
|
||||
#---------------------------------------------------------------------------
|
||||
all: $(LIB_DIR)\$(PROJ_NAME).lib .SYMBOLIC
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build the library
|
||||
# The original library is deleted by the librarian
|
||||
# Lib objects & -+ commands are constructed by substituting within the
|
||||
# $^@ macro (which expands to all target dependents, separated with
|
||||
# spaces)
|
||||
# Tlib's cfg file is not invoked as a response file.
|
||||
# All headers & source files are copied into WIN32LIB\SRCDEBUG, for debugging
|
||||
#---------------------------------------------------------------------------
|
||||
$(LIB_DIR)\$(PROJ_NAME).lib: $(OBJECTS) objects.lbc
|
||||
copy *.h $(%WIN32LIB)\include
|
||||
copy *.inc $(%WIN32LIB)\include
|
||||
copy *.cpp $(%WIN32LIB)\srcdebug
|
||||
copy *.asm $(%WIN32LIB)\srcdebug
|
||||
$(LIB_CMD) $(LIB_CFG) $^@ @objects.lbc
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Objects now have a link file which is NOT generated everytime. Instead
|
||||
# it just has its own dependacy rule.
|
||||
#---------------------------------------------------------------------------
|
||||
objects.lbc : $(OBJECTS)
|
||||
%create $^@
|
||||
for %index in ($(OBJECTS)) do %append $^@ +%index
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Create the test directory and make it.
|
||||
#---------------------------------------------------------------------------
|
||||
test:
|
||||
mkdir test
|
||||
cd test
|
||||
copy $(%WWVCS)\$(PROJ_NAME)\test\vcs.cfg
|
||||
update
|
||||
wmake
|
||||
cd ..
|
||||
|
||||
#**************************** End of makefile ******************************
|
401
WIN32LIB/WINCOMM/MODEMREG.CPP
Normal file
401
WIN32LIB/WINCOMM/MODEMREG.CPP
Normal file
@@ -0,0 +1,401 @@
|
||||
/*
|
||||
** Command & Conquer Red Alert(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
***********************************************************************************************
|
||||
* *
|
||||
* Project Name : Command & Conquer/ WW Library *
|
||||
* *
|
||||
* File Name : MODEMREG.CPP *
|
||||
* *
|
||||
* Programmer : Steve Tall *
|
||||
* *
|
||||
* Start Date : 10/18/96 *
|
||||
* *
|
||||
* Last Update : October 18th 1996 [ST] *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Overview: *
|
||||
* *
|
||||
* Functions for obtaining modem infommation from the Win95 registry *
|
||||
* *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Functions: *
|
||||
* *
|
||||
* Search_Registry_Key -- Search a registry key and all its subkeys for a given value *
|
||||
* MREC::ModemRegistryEntryClass -- Constructor for ModemRegistryEntryClass *
|
||||
* MREC::~ModemRegistryEntryClass -- Destructor.Free all the memory we allocated for modem info*
|
||||
* *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "modemreg.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
extern HKEY Get_Registry_Sub_Key (HKEY base_key, char *search_key, BOOL close);
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Search_Registry_Key -- Search a registry key and all its subkeys for a given value *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: handle to key to search in *
|
||||
* name of key to search for *
|
||||
* value expected in key *
|
||||
* *
|
||||
* OUTPUT: Handle to key containing value. Null if not found. *
|
||||
* *
|
||||
* WARNINGS: This function reenters itself. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/18/96 4:01AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
HKEY Search_Registry_Key (HKEY key_in, char *value_name, char *search_string)
|
||||
{
|
||||
|
||||
int top_key_index = 0; // Index of topmost key
|
||||
int retval; // Result of registry api calls
|
||||
HKEY next_key; // handle of next key examine
|
||||
HKEY next_search; // handle of next key to search
|
||||
|
||||
|
||||
char *subkey_name = new char [256]; // Area to contain result of key enumeration
|
||||
unsigned long subkey_name_length = 256; // Length of enumeration result area
|
||||
FILETIME filetime; // Time key was last touched. Not used.
|
||||
unsigned long value_type; // Type of data that is contained in a key.
|
||||
unsigned char *key_value = new unsigned char [256]; // Area to return key values into
|
||||
unsigned long key_value_length = 256; // Length of key value area
|
||||
|
||||
/*
|
||||
** Scan through and enumerate all subkeys of this key. Exit the loop when there are
|
||||
** no more sub keys to enumerate.
|
||||
*/
|
||||
do {
|
||||
subkey_name_length = 256; // Has to be set each time through the loop
|
||||
|
||||
/*
|
||||
** Get the next key
|
||||
*/
|
||||
retval = RegEnumKeyEx (key_in, top_key_index++, subkey_name, &subkey_name_length, NULL, NULL, NULL, &filetime);
|
||||
|
||||
if ( retval == ERROR_SUCCESS ){
|
||||
|
||||
/*
|
||||
** Get a handle to this key so we can search it.
|
||||
*/
|
||||
next_key = Get_Registry_Sub_Key (key_in, subkey_name, FALSE);
|
||||
|
||||
if (next_key){
|
||||
|
||||
key_value_length = 256; // Has to be set each time through the loop
|
||||
|
||||
if ( RegQueryValueEx (next_key, value_name, NULL, &value_type, key_value, &key_value_length) == ERROR_SUCCESS){
|
||||
|
||||
/*
|
||||
** If this value is type string then do a compare with the value we are looking for
|
||||
*/
|
||||
if (value_type == REG_SZ && !strcmp ((char*)key_value, search_string)){
|
||||
/*
|
||||
** This is our man. Delete our workspace and return the key handle
|
||||
*/
|
||||
delete [] subkey_name;
|
||||
delete [] key_value;
|
||||
return (next_key);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** We didnt find our search value so search this key for more sub keys by reentering
|
||||
** this function with the handle of the subkey.
|
||||
*/
|
||||
next_search = Search_Registry_Key (next_key, value_name, search_string);
|
||||
RegCloseKey (next_key);
|
||||
|
||||
/*
|
||||
** If the value was found in a subkey then just return with the key handle.
|
||||
*/
|
||||
if (next_search){
|
||||
delete [] subkey_name;
|
||||
delete [] key_value;
|
||||
return (next_search);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} while (retval == ERROR_SUCCESS);
|
||||
|
||||
/*
|
||||
** Clean up and exit.
|
||||
*/
|
||||
delete [] subkey_name;
|
||||
delete [] key_value;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MREC::ModemRegistryEntryClass -- Constructor for ModemRegistryEntryClass *
|
||||
* *
|
||||
* This function does all the work in the class. All the registry searching is done here *
|
||||
* *
|
||||
* INPUT: Modem number *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/18/96 4:12AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
ModemRegistryEntryClass::ModemRegistryEntryClass (int modem_number)
|
||||
{
|
||||
HKEY key;
|
||||
unsigned char return_buf[256];
|
||||
DWORD retbuf_size = sizeof(return_buf);
|
||||
|
||||
int pnp = 0; //Not a plug n pray modem
|
||||
|
||||
/*
|
||||
** Initialise all the info we expect from the registry to NULL.
|
||||
** Any entries we cant find will just stay NULL.
|
||||
*/
|
||||
ModemName = NULL;
|
||||
ModemDeviceName = NULL;
|
||||
ErrorCorrectionEnable = NULL;
|
||||
ErrorCorrectionDisable = NULL;
|
||||
CompressionEnable = NULL;
|
||||
CompressionDisable = NULL;
|
||||
HardwareFlowControl = NULL;
|
||||
NoFlowControl = NULL;
|
||||
|
||||
|
||||
/*
|
||||
** Modem info is stored under
|
||||
** HKEY_LOCAL_MACHINE / System / CurrentControlSet / Services / Class / Modem / nnnn
|
||||
** where nnnn is a four digit modem number.
|
||||
*/
|
||||
|
||||
key = Get_Registry_Sub_Key (HKEY_LOCAL_MACHINE, "System", FALSE);
|
||||
if (!key) return;
|
||||
|
||||
key = Get_Registry_Sub_Key (key, "CurrentControlSet", TRUE);
|
||||
if (!key) return;
|
||||
|
||||
key = Get_Registry_Sub_Key (key, "Services", TRUE);
|
||||
if (!key) return;
|
||||
|
||||
key = Get_Registry_Sub_Key (key, "Class", TRUE);
|
||||
if (!key) return;
|
||||
|
||||
key = Get_Registry_Sub_Key (key, "Modem", TRUE);
|
||||
if (!key) return;
|
||||
|
||||
char which_modem[5];
|
||||
sprintf (which_modem, "%04d", modem_number);
|
||||
|
||||
/*
|
||||
** Get a handle to the modem key if it exists. Then extract the info we need.
|
||||
*/
|
||||
key = Get_Registry_Sub_Key (key, which_modem, TRUE);
|
||||
if (!key) return;
|
||||
|
||||
|
||||
/*
|
||||
** Get the name of the modem. This is what will be displayed in the modem list presented
|
||||
** to the user.
|
||||
*/
|
||||
if (RegQueryValueEx(key, "Model", NULL, NULL, return_buf, &retbuf_size) != ERROR_SUCCESS){
|
||||
RegCloseKey (key);
|
||||
return;
|
||||
}
|
||||
ModemName = new char [retbuf_size];
|
||||
memcpy (ModemName, return_buf, retbuf_size);
|
||||
|
||||
/*
|
||||
** Find out what COM port the modem is attached to. If this info isnt here, then its a
|
||||
** Plug n Pray modem. Set the flag so we know to do the pnp search later.
|
||||
*/
|
||||
retbuf_size = sizeof (return_buf);
|
||||
if (RegQueryValueEx(key, "AttachedTo", NULL, NULL, return_buf, &retbuf_size) != ERROR_SUCCESS){
|
||||
/*
|
||||
** Must be a plug n pray modem. Set the flag. We will look for the port later.
|
||||
*/
|
||||
pnp = 1;
|
||||
ModemDeviceName = new char [strlen (ModemName)+1];
|
||||
strcpy (ModemDeviceName, ModemName);
|
||||
}else{
|
||||
ModemDeviceName = new char [retbuf_size];
|
||||
memcpy (ModemDeviceName, return_buf, retbuf_size);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** The list of modem 'AT' commands is stored in the 'Settings' key.
|
||||
*/
|
||||
key = Get_Registry_Sub_Key (key, "Settings", TRUE);
|
||||
if (!key) return;
|
||||
|
||||
|
||||
/*
|
||||
** Extract the control strings for error control.
|
||||
*/
|
||||
retbuf_size = sizeof (return_buf);
|
||||
if (RegQueryValueEx(key, "ErrorControl_On", NULL, NULL, return_buf, &retbuf_size) == ERROR_SUCCESS){
|
||||
ErrorCorrectionEnable = new char [retbuf_size];
|
||||
memcpy (ErrorCorrectionEnable, return_buf, retbuf_size);
|
||||
}
|
||||
|
||||
retbuf_size = sizeof (return_buf);
|
||||
if (RegQueryValueEx(key, "ErrorControl_Off", NULL, NULL, return_buf, &retbuf_size) == ERROR_SUCCESS){
|
||||
ErrorCorrectionDisable = new char [retbuf_size];
|
||||
memcpy (ErrorCorrectionDisable, return_buf, retbuf_size);
|
||||
}
|
||||
|
||||
/*
|
||||
** Extract the control strings for data compression.
|
||||
*/
|
||||
retbuf_size = sizeof (return_buf);
|
||||
if (RegQueryValueEx(key, "Compression_On", NULL, NULL, return_buf, &retbuf_size) == ERROR_SUCCESS){
|
||||
CompressionEnable = new char [retbuf_size];
|
||||
memcpy (CompressionEnable, return_buf, retbuf_size);
|
||||
}
|
||||
|
||||
retbuf_size = sizeof (return_buf);
|
||||
if (RegQueryValueEx(key, "Compression_Off", NULL, NULL, return_buf, &retbuf_size) == ERROR_SUCCESS){
|
||||
CompressionDisable = new char [retbuf_size];
|
||||
memcpy (CompressionDisable, return_buf, retbuf_size);
|
||||
}
|
||||
|
||||
/*
|
||||
** Extract the control strings for hardware flow control.
|
||||
*/
|
||||
retbuf_size = sizeof (return_buf);
|
||||
if (RegQueryValueEx(key, "FlowControl_Hard", NULL, NULL, return_buf, &retbuf_size) == ERROR_SUCCESS){
|
||||
HardwareFlowControl = new char [retbuf_size];
|
||||
memcpy (HardwareFlowControl, return_buf, retbuf_size);
|
||||
}
|
||||
|
||||
/*
|
||||
** Extract the control strings for no flow control.
|
||||
*/
|
||||
retbuf_size = sizeof (return_buf);
|
||||
if (RegQueryValueEx(key, "FlowControl_Off", NULL, NULL, return_buf, &retbuf_size) == ERROR_SUCCESS){
|
||||
NoFlowControl = new char [retbuf_size];
|
||||
memcpy (NoFlowControl, return_buf, retbuf_size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RegCloseKey (key);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** If this is a plug n pray modem then we need to search for the COM port it is
|
||||
** attached to.
|
||||
*/
|
||||
if (pnp){
|
||||
|
||||
/*
|
||||
** The driver name in the HKEY_LOCAL_MACHINE / Enum section will be Modem\nnnn where nnnn
|
||||
** is a four digit modem number.
|
||||
*/
|
||||
char search_string [256] = {"Modem\\"};
|
||||
strcat (search_string, which_modem);
|
||||
|
||||
/*
|
||||
** Search through all the registry entries under HKEY_LOCAL_MACHINE / Enum
|
||||
*/
|
||||
key = Get_Registry_Sub_Key (HKEY_LOCAL_MACHINE, "Enum", FALSE);
|
||||
if (!key) return;
|
||||
|
||||
HKEY newkey = Search_Registry_Key ( key, "Driver", search_string );
|
||||
|
||||
if (newkey){
|
||||
retbuf_size = sizeof (return_buf);
|
||||
|
||||
/*
|
||||
** Extract the PORTNAME value. This is the name of the port to use to communicate
|
||||
** with the modem.
|
||||
*/
|
||||
retbuf_size = sizeof (return_buf);
|
||||
if (RegQueryValueEx(newkey, "PORTNAME", NULL, NULL, return_buf, &retbuf_size) == ERROR_SUCCESS){
|
||||
|
||||
if (ModemDeviceName) delete [] ModemDeviceName;
|
||||
|
||||
ModemDeviceName = new char [retbuf_size];
|
||||
memcpy (ModemDeviceName, return_buf, retbuf_size);
|
||||
}
|
||||
}
|
||||
RegCloseKey (key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MREC::~ModemRegistryEntryClass -- Destructor.Free all the memory we allocated for modem info*
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/18/96 11:39AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
ModemRegistryEntryClass::~ModemRegistryEntryClass (void)
|
||||
{
|
||||
if (ModemName) delete [] ModemName;
|
||||
if (ModemDeviceName) delete [] ModemDeviceName;
|
||||
|
||||
if (ErrorCorrectionEnable) delete [] ErrorCorrectionEnable;
|
||||
if (ErrorCorrectionDisable) delete [] ErrorCorrectionDisable;
|
||||
|
||||
if (CompressionEnable) delete [] CompressionEnable;
|
||||
if (CompressionDisable) delete [] CompressionDisable;
|
||||
|
||||
if (HardwareFlowControl) delete [] HardwareFlowControl;
|
||||
if (NoFlowControl) delete [] NoFlowControl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
72
WIN32LIB/WINCOMM/MODEMREG.H
Normal file
72
WIN32LIB/WINCOMM/MODEMREG.H
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
** Command & Conquer Red Alert(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
#define WIN32
|
||||
#ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
|
||||
#define _WIN32
|
||||
#endif // _WIN32
|
||||
#endif //WIN32
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class ModemRegistryEntryClass {
|
||||
|
||||
public:
|
||||
|
||||
ModemRegistryEntryClass (int modem_number);
|
||||
~ModemRegistryEntryClass (void);
|
||||
|
||||
|
||||
char *Get_Modem_Name (void) { return (ModemName); }
|
||||
|
||||
char *Get_Modem_Device_Name (void) { return (ModemDeviceName); }
|
||||
|
||||
char *Get_Modem_Error_Correction_Enable (void) { return (ErrorCorrectionEnable); }
|
||||
|
||||
char *Get_Modem_Error_Correction_Disable (void) { return (ErrorCorrectionDisable); }
|
||||
|
||||
char *Get_Modem_Compression_Enable (void) { return (CompressionEnable); }
|
||||
|
||||
char *Get_Modem_Compression_Disable (void) { return (CompressionDisable); }
|
||||
|
||||
char *Get_Modem_Hardware_Flow_Control (void) { return (HardwareFlowControl); }
|
||||
|
||||
char *Get_Modem_No_Flow_Control (void) { return (HardwareFlowControl); }
|
||||
|
||||
private:
|
||||
|
||||
char *ModemName;
|
||||
char *ModemDeviceName;
|
||||
char *ErrorCorrectionEnable;
|
||||
char *ErrorCorrectionDisable;
|
||||
char *CompressionEnable;
|
||||
char *CompressionDisable;
|
||||
char *HardwareFlowControl;
|
||||
char *NoFlowControl;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1487
WIN32LIB/WINCOMM/WINCOMM.CPP
Normal file
1487
WIN32LIB/WINCOMM/WINCOMM.CPP
Normal file
File diff suppressed because it is too large
Load Diff
457
WIN32LIB/WINCOMM/WINCOMM.H
Normal file
457
WIN32LIB/WINCOMM/WINCOMM.H
Normal file
@@ -0,0 +1,457 @@
|
||||
/*
|
||||
** Command & Conquer Red Alert(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
***********************************************************************************************
|
||||
* *
|
||||
* Project Name : Command & Conquer/ WW Library *
|
||||
* *
|
||||
* File Name : WINCOMM.H *
|
||||
* *
|
||||
* Programmer : Steve Tall *
|
||||
* *
|
||||
* Start Date : 1/10/96 *
|
||||
* *
|
||||
* Last Update : January 10th 1996 [ST] *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Overview: *
|
||||
* *
|
||||
* These classes was created to replace the greenleaf comms functions used in C&C DOS with *
|
||||
* WIN32 API calls. *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Functions: *
|
||||
* *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
#define WIN32
|
||||
#define _WIN32
|
||||
#endif //WIN32
|
||||
#include <windows.h>
|
||||
|
||||
typedef enum WinCommDialMethodType {
|
||||
WC_TOUCH_TONE = 0,
|
||||
WC_PULSE
|
||||
} WinCommDialMethodType;
|
||||
|
||||
|
||||
|
||||
#define COMMSUCCESS 0
|
||||
#define ASTIMEOUT -10
|
||||
#define COMMUSERABORT -16
|
||||
|
||||
|
||||
/*
|
||||
** The size of our serial buffer within the class.
|
||||
**
|
||||
** !!!!!! THIS MUST BE A POWER OF 2 !!!!!!
|
||||
**
|
||||
*/
|
||||
#define SIZE_OF_WINDOWS_SERIAL_BUFFER 2048
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** WinModemClass.
|
||||
**
|
||||
** This class provides access to modems under Win95. The functions are designed to be more or less
|
||||
** drop in replacements for the Grenleaf comms functions.
|
||||
*/
|
||||
|
||||
class WinModemClass
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
WinModemClass (void); //WinModemClass Contructor
|
||||
virtual ~WinModemClass (void); //WinModemClass Destructor
|
||||
|
||||
|
||||
/*
|
||||
** Serial port open should be called to get a handle to the COM port
|
||||
** This needs to be called first as other class members rely on the handle
|
||||
**
|
||||
** Replacement for Greenleaf function: PortOpenGreenleafFast
|
||||
*/
|
||||
//virtual HANDLE Serial_Port_Open (int port, int baud, int parity, int wordlen, int stopbits);
|
||||
virtual HANDLE Serial_Port_Open (char *device_name, int baud, int parity, int wordlen, int stopbits, int flowcontrol);
|
||||
|
||||
/*
|
||||
** This function releases the COM port handle and should be called after
|
||||
** communications have finished
|
||||
**
|
||||
** Replacement for Greenleaf function: PortClose
|
||||
*/
|
||||
void Serial_Port_Close (void);
|
||||
|
||||
/*
|
||||
** This member copies any bytes from the internal class serial buffer
|
||||
** into your user buffer.
|
||||
**
|
||||
** Replacement for Greenleaf function: ReadBuffer
|
||||
*/
|
||||
int Read_From_Serial_Port (unsigned char *dest_ptr, int buffer_len);
|
||||
|
||||
/*
|
||||
** Write chars to the serial port
|
||||
**
|
||||
** Replacement for Greenleaf function: WriteBuffer
|
||||
*/
|
||||
void Write_To_Serial_Port (unsigned char *buffer, int length);
|
||||
|
||||
/*
|
||||
** Wait for the outgoing buffer to empty
|
||||
*/
|
||||
void Wait_For_Serial_Write (void);
|
||||
|
||||
/*
|
||||
** Set the dial type to DIAL_TOUCH_TONE or DIAL_PULSE
|
||||
**
|
||||
** Replacement for Greenleaf function: HMSetDiallingMethod
|
||||
*/
|
||||
virtual void Set_Modem_Dial_Type (WinCommDialMethodType method);
|
||||
|
||||
/*
|
||||
** Get the status of the modem control lines
|
||||
** Possible flags are: CTS_SET DSR_SET RI_SET & CD_SET
|
||||
**
|
||||
** Replacement for Greenleaf function: GetModemStatus
|
||||
*/
|
||||
virtual unsigned Get_Modem_Status (void);
|
||||
|
||||
/*
|
||||
** Set the DTR line to the given state
|
||||
**
|
||||
** Replacement for Greenleaf function: SetDtr
|
||||
*/
|
||||
virtual void Set_Serial_DTR (BOOL state);
|
||||
|
||||
/*
|
||||
** Get the result code from the modem after issuing an 'AT' command
|
||||
**
|
||||
** Replacement for Greenleaf function: HMInputLine
|
||||
*/
|
||||
virtual int Get_Modem_Result (int delay, char *buffer, int buffer_len);
|
||||
|
||||
/*
|
||||
** Issue a dial command to the modem.
|
||||
** Use Set_Modem_Dial_Type to select pulse or tone dial
|
||||
**
|
||||
** Replacement for Greenleaf function: HMDial
|
||||
*/
|
||||
virtual void Dial_Modem (char *dial_number);
|
||||
|
||||
/*
|
||||
** Send a command to the modem. This is usually an 'AT' command.
|
||||
** Function will optionally retry until 'OK' is received.
|
||||
*/
|
||||
virtual int Send_Command_To_Modem (char *command, char terminator, char *buffer, int buflen, int delay, int retries);
|
||||
|
||||
/*
|
||||
** Sets a pointer to a function that will be called for each incoming serial char
|
||||
**
|
||||
** Replacement for Greenleaf function: HMSetUpEchoRoutine
|
||||
*/
|
||||
virtual void Set_Echo_Function (void(*func)(char c));
|
||||
|
||||
/*
|
||||
** Sets a pointer to a function that will be called if ESC is pressed during a dial
|
||||
**
|
||||
** Replacement for Greenleaf function: HMSetUpAbortKey
|
||||
*/
|
||||
virtual void Set_Abort_Function (int (*func)(void));
|
||||
|
||||
/*
|
||||
** Member to allow access to the serial port handle
|
||||
*/
|
||||
HANDLE Get_Port_Handle(void);
|
||||
|
||||
/*
|
||||
** Status vars for debugging purposes
|
||||
*/
|
||||
int FramingErrors;
|
||||
int IOErrors;
|
||||
int BufferOverruns;
|
||||
int InBufferOverflows;
|
||||
int ParityErrors;
|
||||
int OutBufferOverflows;
|
||||
int InQueue;
|
||||
int OutQueue;
|
||||
|
||||
/*
|
||||
** Modem send result codes
|
||||
*/
|
||||
enum SendModemEnum {
|
||||
MODEM_CMD_TIMEOUT = 0,
|
||||
MODEM_CMD_OK,
|
||||
MODEM_CMD_0,
|
||||
MODEM_CMD_ERROR
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** Enums for modem status flags
|
||||
*/
|
||||
enum {
|
||||
CTS_SET = 0x10,
|
||||
DSR_SET = 0x20,
|
||||
RI_SET = 0x40,
|
||||
CD_SET = 0x80
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
/*
|
||||
** Copy incoming data from the windows file buffer into the internal class buffer
|
||||
*/
|
||||
BOOL Read_Serial_Chars(void);
|
||||
|
||||
/*
|
||||
** Pointer to the internal class circular buffer for incoming data
|
||||
*/
|
||||
unsigned char *SerialBuffer;
|
||||
|
||||
/*
|
||||
** Overlap object for asyncronous reads from the serial port
|
||||
*/
|
||||
OVERLAPPED ReadOverlap;
|
||||
|
||||
/*
|
||||
** Overlap object for asyncronous writes to the serial port
|
||||
*/
|
||||
OVERLAPPED WriteOverlap;
|
||||
|
||||
/*
|
||||
** Flag that there is no outstanding incoming data in the windows buffer
|
||||
*/
|
||||
BOOL WaitingForSerialCharRead;
|
||||
|
||||
/*
|
||||
** Flag that we are waiting for the last write to port operation to complete
|
||||
*/
|
||||
BOOL WaitingForSerialCharWrite;
|
||||
|
||||
/*
|
||||
** Head and Tail pointers for our internal serial buffer
|
||||
*/
|
||||
int SerialBufferReadPtr;
|
||||
int SerialBufferWritePtr;
|
||||
|
||||
/*
|
||||
** Windows handle to the COM port device
|
||||
*/
|
||||
HANDLE PortHandle;
|
||||
|
||||
/*
|
||||
** Dialing method - DIAL_TOUCH_TONE or DIAL_PULSE
|
||||
*/
|
||||
WinCommDialMethodType DialingMethod;
|
||||
|
||||
/*
|
||||
** Pointer to function for echoing incoming data - can be NULL
|
||||
*/
|
||||
void (*EchoFunction)(char c);
|
||||
|
||||
/*
|
||||
** Pointer to function for aborting when ESC pressed - can be NULL
|
||||
*/
|
||||
int (*AbortFunction)(void);
|
||||
|
||||
/*
|
||||
** Serial buffer for asyncronous reads
|
||||
*/
|
||||
char TempSerialBuffer[SIZE_OF_WINDOWS_SERIAL_BUFFER];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** WinNullModemClass.
|
||||
**
|
||||
** This class provides access to serial ports under Win95. The functions are designed to be more or less
|
||||
** drop in replacements for the Grenleaf comms functions.
|
||||
**
|
||||
** This class just overloads the WinModemClass members that arent required for direct serial communications
|
||||
** via a 'null modem' cable.
|
||||
*/
|
||||
class WinNullModemClass : public WinModemClass
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual inline void Set_Modem_Dial_Type (int){};
|
||||
virtual inline unsigned Get_Modem_Status (void){return (0);};
|
||||
virtual inline void Set_Serial_DTR (BOOL){};
|
||||
virtual inline int Get_Modem_Result (int, char*, int){return(0);};
|
||||
virtual inline void Dial_Modem (char*){};
|
||||
virtual inline int Send_Command_To_Modem (char*, char, char*, int, int, int){return (0);};
|
||||
virtual inline void Set_Echo_Function (void(*)(char)){};
|
||||
virtual inline void Set_Abort_Function (int(*)(void)){};
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern WinModemClass *SerialPort;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// This bit swiped from the SDK because its not in the Watcom headers yet
|
||||
//
|
||||
//
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* mcx.h -- This module defines the 32-Bit Windows MCX APIs *
|
||||
* *
|
||||
* Copyright (c) 1990-1995, Microsoft Corp. All rights reserved. *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _MCX_H_
|
||||
#define _MCX_H_
|
||||
|
||||
typedef struct _MODEMDEVCAPS {
|
||||
DWORD dwActualSize;
|
||||
DWORD dwRequiredSize;
|
||||
DWORD dwDevSpecificOffset;
|
||||
DWORD dwDevSpecificSize;
|
||||
|
||||
// product and version identification
|
||||
DWORD dwModemProviderVersion;
|
||||
DWORD dwModemManufacturerOffset;
|
||||
DWORD dwModemManufacturerSize;
|
||||
DWORD dwModemModelOffset;
|
||||
DWORD dwModemModelSize;
|
||||
DWORD dwModemVersionOffset;
|
||||
DWORD dwModemVersionSize;
|
||||
|
||||
// local option capabilities
|
||||
DWORD dwDialOptions; // bitmap of supported values
|
||||
DWORD dwCallSetupFailTimer; // maximum in seconds
|
||||
DWORD dwInactivityTimeout; // maximum in seconds
|
||||
DWORD dwSpeakerVolume; // bitmap of supported values
|
||||
DWORD dwSpeakerMode; // bitmap of supported values
|
||||
DWORD dwModemOptions; // bitmap of supported values
|
||||
DWORD dwMaxDTERate; // maximum value in bit/s
|
||||
DWORD dwMaxDCERate; // maximum value in bit/s
|
||||
|
||||
// Variable portion for proprietary expansion
|
||||
BYTE abVariablePortion [1];
|
||||
} MODEMDEVCAPS, *PMODEMDEVCAPS, *LPMODEMDEVCAPS;
|
||||
|
||||
typedef struct _MODEMSETTINGS {
|
||||
DWORD dwActualSize;
|
||||
DWORD dwRequiredSize;
|
||||
DWORD dwDevSpecificOffset;
|
||||
DWORD dwDevSpecificSize;
|
||||
|
||||
// static local options (read/write)
|
||||
DWORD dwCallSetupFailTimer; // seconds
|
||||
DWORD dwInactivityTimeout; // seconds
|
||||
DWORD dwSpeakerVolume; // level
|
||||
DWORD dwSpeakerMode; // mode
|
||||
DWORD dwPreferredModemOptions; // bitmap
|
||||
|
||||
// negotiated options (read only) for current or last call
|
||||
DWORD dwNegotiatedModemOptions; // bitmap
|
||||
DWORD dwNegotiatedDCERate; // bit/s
|
||||
|
||||
// Variable portion for proprietary expansion
|
||||
BYTE abVariablePortion [1];
|
||||
} MODEMSETTINGS, *PMODEMSETTINGS, *LPMODEMSETTINGS;
|
||||
|
||||
// Dial Options
|
||||
#define DIALOPTION_BILLING 0x00000040 // Supports wait for bong "$"
|
||||
#define DIALOPTION_QUIET 0x00000080 // Supports wait for quiet "@"
|
||||
#define DIALOPTION_DIALTONE 0x00000100 // Supports wait for dial tone "W"
|
||||
|
||||
// SpeakerVolume for MODEMDEVCAPS
|
||||
#define MDMVOLFLAG_LOW 0x00000001
|
||||
#define MDMVOLFLAG_MEDIUM 0x00000002
|
||||
#define MDMVOLFLAG_HIGH 0x00000004
|
||||
|
||||
// SpeakerVolume for MODEMSETTINGS
|
||||
#define MDMVOL_LOW 0x00000000
|
||||
#define MDMVOL_MEDIUM 0x00000001
|
||||
#define MDMVOL_HIGH 0x00000002
|
||||
|
||||
// SpeakerMode for MODEMDEVCAPS
|
||||
#define MDMSPKRFLAG_OFF 0x00000001
|
||||
#define MDMSPKRFLAG_DIAL 0x00000002
|
||||
#define MDMSPKRFLAG_ON 0x00000004
|
||||
#define MDMSPKRFLAG_CALLSETUP 0x00000008
|
||||
|
||||
// SpeakerMode for MODEMSETTINGS
|
||||
#define MDMSPKR_OFF 0x00000000
|
||||
#define MDMSPKR_DIAL 0x00000001
|
||||
#define MDMSPKR_ON 0x00000002
|
||||
#define MDMSPKR_CALLSETUP 0x00000003
|
||||
|
||||
// Modem Options
|
||||
#define MDM_COMPRESSION 0x00000001
|
||||
#define MDM_ERROR_CONTROL 0x00000002
|
||||
#define MDM_FORCED_EC 0x00000004
|
||||
#define MDM_CELLULAR 0x00000008
|
||||
#define MDM_FLOWCONTROL_HARD 0x00000010
|
||||
#define MDM_FLOWCONTROL_SOFT 0x00000020
|
||||
#define MDM_CCITT_OVERRIDE 0x00000040
|
||||
#define MDM_SPEED_ADJUST 0x00000080
|
||||
#define MDM_TONE_DIAL 0x00000100
|
||||
#define MDM_BLIND_DIAL 0x00000200
|
||||
#define MDM_V23_OVERRIDE 0x00000400
|
||||
|
||||
#endif /* _MCX_H_ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user