Initial commit of Command & Conquer Red Alert source code.

This commit is contained in:
LFeenanEA
2025-02-27 16:15:05 +00:00
parent b685cea758
commit 5e733d5dcc
2082 changed files with 797727 additions and 0 deletions

203
WIN32LIB/TIMER/MAKEFILE Normal file
View File

@@ -0,0 +1,203 @@
#
# 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 = timer
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
LIB_DIR = $(%WIN32LIB)\lib
!include $(%WIN32LIB)\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = &
timer.obj &
timerdwn.obj &
timerini.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: $(%WIN32LIB)\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
#---------------------------------------------------------------------------
# The keyboard object files is also dependant on an IBN file which is
# generated from KEYIREAL.ASM
#---------------------------------------------------------------------------
timereal.ibn: timereal.obj
%create $^*.rsp
%append $^*.rsp $^&.obj
%append $^*.rsp $^&.exe
%append $^*.rsp $^&.map
tlink @$^*.rsp
tdstrip timereal.exe
ebn timereal.exe
timereal.obj: timereal.asm
tasm /zn /la /ml /m2 timereal.asm
timera.obj: timereal.ibn timera.asm
#---------------------------------------------------------------------------
# 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 ******************************

173
WIN32LIB/TIMER/MAKEFILE.BOR Normal file
View File

@@ -0,0 +1,173 @@
#
# 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 WWFLAT 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 *
#* *
#***************************************************************************
.AUTODEPEND
#---------------------------------------------------------------------------
# Verify user's environment
#---------------------------------------------------------------------------
!ifndef WIN32LIB
!error WIN32LIB Environment var not configured.
!endif
!ifndef WIN32VCS
!error WIN32VCS Environment var not configured.
!endif
!ifndef COMPILER
!error COMPILER Environment var not configured.
!endif
#===========================================================================
# User-defined section: the user should tailor this section for each project
#===========================================================================
PROJ_NAME = timer
PROJ_DIR = $(WIN32LIB)\$(PROJ_NAME)
LIB_DIR = $(WIN32LIB)\lib
!include $(WIN32LIB)\\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = \
timer.obj \
timerdwn.obj \
timerini.obj
#---------------------------------------------------------------------------
# Path macros: one path for each file type.
# These paths are used to tell make where to find/put each file type.
#---------------------------------------------------------------------------
.path.asm = $(PROJ_DIR)
.path.c = $(PROJ_DIR)
.path.cpp = $(PROJ_DIR)
.path.h = $(PROJ_DIR)
.path.obj = $(PROJ_DIR)
.path.lib = $(WIN32LIB)\lib
.path.exe = $(PROJ_DIR)
#===========================================================================
# Pre-defined section: there should be little need to modify this section.
#===========================================================================
#---------------------------------------------------------------------------
# Tools/commands
#---------------------------------------------------------------------------
C_CMD = bcc32
CPP_CMD = bcc32
LIB_CMD = tlib
LINK_CMD = tlink32
ASM_CMD = tasm32
#---------------------------------------------------------------------------
# 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;$(COMPILER)\LIB
INCLUDEPATH = $(WIN32LIB)\INCLUDE;$(COMPILER)\INCLUDE
#---------------------------------------------------------------------------
# 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:
$(C_CMD) $(CC_CFG) $<
.cpp.obj:
$(CPP_CMD) $(CC_CFG) $<
.asm.obj:
$(ASM_CMD) $(ASM_CFG) $<
#---------------------------------------------------------------------------
# Default target: configuration files & library (in that order)
#---------------------------------------------------------------------------
all: $(LIB_DIR)\$(PROJ_NAME).lib
#---------------------------------------------------------------------------
# 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)
copy *.h $(WIN32LIB)\\include
copy *.inc $(WIN32LIB)\\include
copy *.cpp $(WIN32LIB)\\srcdebug
copy *.asm $(WIN32LIB)\\srcdebug
$(LIB_CMD) $< $(LIB_CFG) @&&|
+-timer.obj &
+-timerdwn.obj &
+-timerini.obj
|
#---------------------------------------------------------------------------
# Create the test directory and make it.
#---------------------------------------------------------------------------
test:
mkdir test
cd test
copy $(WWVCS)\\$(PROJ_NAME)\test\vcs.cfg
update
wmake
cd ..

203
WIN32LIB/TIMER/MAKEFILE.WAT Normal file
View File

@@ -0,0 +1,203 @@
#
# 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 = timer
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
LIB_DIR = $(%WIN32LIB)\lib
!include $(%WIN32LIB)\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = &
timer.obj &
timerdwn.obj &
timerini.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: $(%WIN32LIB)\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 = tasm32
#---------------------------------------------------------------------------
# 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) $<
.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
#---------------------------------------------------------------------------
# The keyboard object files is also dependant on an IBN file which is
# generated from KEYIREAL.ASM
#---------------------------------------------------------------------------
timereal.ibn: timereal.obj
%create $^*.rsp
%append $^*.rsp $^&.obj
%append $^*.rsp $^&.exe
%append $^*.rsp $^&.map
tlink @$^*.rsp
tdstrip timereal.exe
ebn timereal.exe
timereal.obj: timereal.asm
tasm /zn /la /ml /m2 timereal.asm
timera.obj: timereal.ibn timera.asm
#---------------------------------------------------------------------------
# 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 ******************************

203
WIN32LIB/TIMER/TIMER.CPP Normal file
View File

@@ -0,0 +1,203 @@
/*
** 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 : Temp timer for 32bit lib *
* *
* File Name : TIMER.CPP *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : July 6, 1994 *
* *
* Last Update : May 3, 1995 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* TC::Time -- Return the time on the timer. *
* TC::TimerClass -- Construct a timer class object. *
* TC::Stop -- Stop the timer. *
* TC::Start -- Start a timer. *
* TC::Set -- Set the time of a timer. *
* TC::Reset -- Clear the timer. *
* TimerClass::Time -- Get the current time of timer. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include "timer.H"
#include <stdio.h>
#include <stdlib.h>
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Code ////////////////////////////////////////
/***************************************************************************
* TC::TIMERCLASS -- Construct a timer class object. *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
TimerClass::TimerClass(BaseTimerEnum timer, BOOL on)
{
Accumulated = 0;
Started = 0;
TickType=timer;
if (on && TimerSystemOn) Start();
}
/***********************************************************************************************
* TC:Get_Ticks -- return the number of ticks on the system or user timers *
* *
* *
* *
* INPUT: Nothing *
* *
* OUTPUT: tick count *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 4:17PM ST : Created *
*=============================================================================================*/
long TimerClass::Get_Ticks ( void )
{
if ( WindowsTimer ){
switch ( TickType ){
case BT_SYSTEM :
return ( WindowsTimer->Get_System_Tick_Count() );
case BT_USER :
return ( WindowsTimer->Get_User_Tick_Count() );
}
}
return 0;
}
/***************************************************************************
* TIMERCLASS::TIME -- Get the current time of timer. *
* *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 05/03/1995 SKB : Created. *
*=========================================================================*/
long TimerClass::Time(void)
{
if (Started) {
long ticks = Get_Ticks();
Accumulated += ticks - (Started-1);
Started = ticks+1;
}
return(Accumulated);
}
/***************************************************************************
* TC::STOP -- Stop the timer. *
* *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
long TimerClass::Stop(void)
{
long time = Time();
Started = 0;
return(time);
}
/***************************************************************************
* TC::START -- Start a timer. *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
long TimerClass::Start(void)
{
if (!Started) {
Started = Get_Ticks()+1;
}
return(Time());
}
/***************************************************************************
* TC::SET -- Set the time of a timer. *
* *
* *
* *
* INPUT: long value to set timer at. *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
* 05/03/1995 SKB : If start return Start since it returns Time *
*=========================================================================*/
long TimerClass::Set(long value, BOOL start)
{
Started = 0;
Accumulated = value;
if (start) return (Start());
return(Time());
}

199
WIN32LIB/TIMER/TIMER.H Normal file
View File

@@ -0,0 +1,199 @@
/*
** 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 : Timer Class Functions *
* *
* File Name : TIMER.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : July 6, 1994 *
* *
* Last Update : July 12, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef TIMER_H
#define TIMER_H
#define WIN32 1
#ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
#define _WIN32
#endif // _WIN32
#include <windows.h>
#include <windowsx.h>
/*=========================================================================*/
/* The following prototypes are for the file: TIMERA.ASM */
/*=========================================================================*/
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// Externs /////////////////////////////////////////////
extern BOOL TimerSystemOn;
extern HANDLE TimerThreadHandle; //Handle of timer thread
extern int InTimerCallback; //true if we are currently in a callback
/*=========================================================================*/
typedef enum BaseTimerEnum {
BT_SYSTEM, // System timer (60 / second).
BT_USER // User controllable timer (? / second).
} BaseTimerEnum;
class TimerClass {
public:
// Constructor. Timers set before low level init has been done will not
// be able to be 'Started' or 'on' until timer system is in place.
TimerClass(BaseTimerEnum timer=BT_SYSTEM, BOOL start=FALSE);
// No destructor.
~TimerClass(void){}
//
long Set(long value, BOOL start=TRUE); // Set initial timer value.
long Stop(void); // Pause timer.
long Start(void); // Resume timer.
long Reset(BOOL start=TRUE); // Reset timer to zero.
long Time(void); // Fetch current timer value.
protected:
long Started; // Time last started (0 == not paused).
long Accumulated; // Total accumulated ticks.
private:
// long (*Get_Ticks)(void); // System timer fetch.
BaseTimerEnum TickType;
long Get_Ticks (void);
};
inline long TimerClass::Reset(BOOL start)
{
return(Set(0, start));
}
class CountDownTimerClass : private TimerClass {
public:
// Constructor. Timers set before low level init has been done will not
// be able to be 'Started' or 'on' until timer system is in place.
CountDownTimerClass(BaseTimerEnum timer, long set, int on=FALSE);
CountDownTimerClass(BaseTimerEnum timer=BT_SYSTEM, int on=FALSE);
// No destructor.
~CountDownTimerClass(void){}
// Public functions
long Set(long set, BOOL start=TRUE); // Set count down value.
long Reset(BOOL start=TRUE); // Reset timer to zero.
long Stop(void); // Pause timer.
long Start(void); // Resume timer.
long Time(void); // Fetch current count down value.
protected:
long DelayTime; // Ticks remaining before countdown timer expires.
};
inline long CountDownTimerClass::Stop(void)
{
TimerClass::Stop();
return(Time());
}
inline long CountDownTimerClass::Start(void)
{
TimerClass::Start();
return(Time());
}
inline long CountDownTimerClass::Reset(BOOL start)
{
return (TimerClass::Reset(start));
}
class WinTimerClass {
public:
WinTimerClass ( UINT freq=60 , BOOL partial=0 );
~WinTimerClass();
void Update_Tick_Count ( void );
unsigned Get_System_Tick_Count ( void );
unsigned Get_User_Tick_Count ( void );
private:
unsigned TimerHandle; //Handle for windows timer event
unsigned Frequency; //Frequency of our windows timer in ticks per second
unsigned TrueRate; //True rate of clock. (only use word)
unsigned SysTicks; //Tick count of timer.
unsigned UserTicks; //Tick count of timer.
unsigned UserRate; //Desired rate of timer.
};
extern WinTimerClass *WindowsTimer;
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// externs //////////////////////////////////////////
#ifndef FUNCTION_H
extern TimerClass TickCount;
#endif
extern CountDownTimerClass CountDown;
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// Prototypes //////////////////////////////////////////
extern "C" {
long __cdecl Get_System_Tick_Count(void);
long __cdecl Get_User_Tick_Count(void);
void far __cdecl Timer_Interrupt_Func(void);
// long Get_Num_Interrupts(unsigned int realmode);
void __cdecl Disable_Timer_Interrupt(void);
void __cdecl Enable_Timer_Interrupt(void);
}
/*=========================================================================*/
/* The following prototypes are for the file: TIMER.CPP */
/*=========================================================================*/
BOOL __cdecl Init_Timer_System(unsigned int freq, int partial = FALSE);
BOOL __cdecl Remove_Timer_System(VOID);
#endif // TIMER_H

BIN
WIN32LIB/TIMER/TIMER.IDE Normal file

Binary file not shown.

126
WIN32LIB/TIMER/TIMERDWN.CPP Normal file
View File

@@ -0,0 +1,126 @@
/*
** 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 : Temp timer for 32bit lib *
* *
* File Name : TIMER.CPP *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : July 6, 1994 *
* *
* Last Update : July 12, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* CDTC::Time -- Return the time on the timer. *
* CDTC::Stop -- Stop the timer. *
* CDTC::Start -- Start a timer. *
* CDTC::DownTimerClass -- Construct a timer class object. *
* CDTC::Set -- Set the time of a timer. *
* CDTC::Reset -- Clear the timer. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include "timer.H"
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Defines /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Code ////////////////////////////////////////
/***************************************************************************
* TC::CountDownTimerClass -- Construct a timer class object. *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
CountDownTimerClass::CountDownTimerClass(BaseTimerEnum timer, long set, int on)
:TimerClass(timer, on)
{
Set(set, on);
}
CountDownTimerClass::CountDownTimerClass(BaseTimerEnum timer, int on)
:TimerClass(timer, FALSE)
{
DelayTime = 0;
if (on) Start();
}
/***************************************************************************
* CDTC::TIME -- Return the time on the timer. *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
long CountDownTimerClass::Time()
{
long ticks = DelayTime - TimerClass::Time();
if (ticks < 0) {
ticks = 0;
}
return(ticks);
}
/***************************************************************************
* CDTC::SET -- Set the time of a timer. *
* *
* *
* *
* INPUT: ULONG value to set timer at. *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
long CountDownTimerClass::Set(long value, BOOL start)
{
DelayTime = value;
TimerClass::Reset(start);
return(Time());
}

308
WIN32LIB/TIMER/TIMERINI.CPP Normal file
View File

@@ -0,0 +1,308 @@
/*
** 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 : Temp timer for 32bit lib *
* *
* File Name : TIMERINI.CPP *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : July 6, 1994 *
* *
* Last Update : July 6, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Init_Timer_System -- Initialize the WW timer system. *
* Remove_Timer_System -- Removes the timer system. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include <mmsystem.h>
#include "timer.H"
#include <profile.h>
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Defines /////////////////////////////////////
#define COPY_FROM_MEM TRUE
/////////////////////////////////////////////////////////////////////////////////
////////////////////////////// timera.asm functions//////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif
extern BOOL Install_Timer_Interrupt(VOID *bin_ptr, UINT rm_size, UINT freq, BOOL partial);
extern BOOL Remove_Timer_Interrupt(VOID);
#ifdef __cplusplus
}
#endif
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Global Data /////////////////////////////////////
BOOL TimerSystemOn = FALSE;
// Global timers that the library or user can count on existing.
TimerClass TickCount(BT_SYSTEM);
CountDownTimerClass CountDown(BT_SYSTEM, 0);
// Prototype for timer callback
void CALLBACK Timer_Callback ( UINT event_id, UINT res1 , DWORD user, DWORD res2, DWORD res3 );
HANDLE TimerThreadHandle = 0; //Handle of timer thread
int InTimerCallback = 0; //Flag to say if we are in a timer callback
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Code ////////////////////////////////////////
/***************************************************************************
* WinTimerClass::WinTimerClass -- Initialize the WW timer system. *
* *
* *
* INPUT: UINT : user timer frequency. *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 10/5/95 3:47PM : ST Created. *
*=========================================================================*/
WinTimerClass::WinTimerClass (UINT freq, BOOL partial)
{
BOOL success;
//
// Inform windows that we want a higher than normal
// timer resolution
//
#ifdef __SW_EP
timeBeginPeriod(1000/PROFILE_RATE);
Frequency = PROFILE_RATE;
#else
timeBeginPeriod ( 1000/freq );
Frequency = freq;
#endif
//
// Install the timer callback event handler
//
TimerHandle = timeSetEvent ( 1000/freq , 1 , Timer_Callback , 0 , TIME_PERIODIC);
TimerSystemOn = success = ( TimerHandle !=0 );
if (success) {
if (!partial) {
WindowsTimer=this;
TickCount.Start();
}
}else{
char error_str [128];
sprintf (error_str, "Error - timer system failed to start. Error code %d\n", GetLastError());
OutputDebugString(error_str);
}
}
/***************************************************************************
* WinTimerClass::~WinTimerClass -- Removes the timer system. *
* *
* *
* INPUT: NONE. *
* *
* OUTPUT: BOOL was it removed successfuly *
* *
* WARNINGS: *
* *
* HISTORY: *
* 10/5/95 3:47PM : ST Created. *
*=========================================================================*/
WinTimerClass::~WinTimerClass( void )
{
if ( TimerHandle ){
timeKillEvent ( TimerHandle );
}
TimerSystemOn = FALSE;
timeEndPeriod ( 1000/Frequency );
}
/***********************************************************************************************
* Timer_Callback -- Main timer callback. Equivalent to a timer interrupt handler *
* *
* *
* *
* INPUT: uint timer ID *
* uint reserved *
* long 0 (application defined) *
* long reserved *
* long reserved *
* *
* OUTPUT: Nothing *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 3:19PM ST : Created *
*=============================================================================================*/
void CALLBACK Timer_Callback (UINT , UINT , DWORD , DWORD , DWORD)
{
//CONTEXT context;
InTimerCallback++;
if (!TimerThreadHandle){
DuplicateHandle (GetCurrentProcess(), GetCurrentThread() , GetCurrentProcess() ,&TimerThreadHandle , 0 , TRUE , DUPLICATE_SAME_ACCESS);
}
if (WindowsTimer) {
WindowsTimer->Update_Tick_Count();
}
InTimerCallback--;
}
/***********************************************************************************************
* WinTimerClass::Update_Tick_Count -- update westwood timers *
* *
* *
* *
* INPUT: Nothing *
* *
* OUTPUT: Nothing *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 3:58PM ST : Created *
*=============================================================================================*/
void WinTimerClass::Update_Tick_Count ( void )
{
/*
*
* Increment westwood timers
*
*/
SysTicks++;
UserTicks++;
}
/*
;***************************************************************************
;* GET_NUM_INTERRUPTS -- Returns the number of interrupts that have occured*
;* *
;* INPUT: TRUE - returns num RM ints. *
;* FALSE - return num PM ints. *
;* *
;* OUTPUT: *
;* *
;* WARNINGS: *
;* *
;* HISTORY: *
;* 07/12/1994 SKB : Created. *
;*=========================================================================*
PROC Get_Num_Interrupts C Near
USES esi
ARG realmode:DWORD
mov esi,[RealModePtr]
cmp [realmode],0
je ??prot_mode
mov eax,[(TimerType PTR esi).NumRMInts]
ret
??prot_mode:
mov eax,[(TimerType PTR esi).NumPMInts]
ret
ENDP
*/
/***********************************************************************************************
* WinTimerClass::Get_System_Tick_Count -- returns the system tick count *
* *
* INPUT: Nothing *
* *
* OUTPUT: tick count *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 4:02PM ST : Created *
*=============================================================================================*/
unsigned WinTimerClass::Get_System_Tick_Count ( void )
{
return ( SysTicks );
}
/***********************************************************************************************
* WinTimerClass::Get_User_Tick_Count -- returns the user tick count *
* *
* INPUT: Nothing *
* *
* OUTPUT: tick count *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 4:02PM ST : Created *
*=============================================================================================*/
unsigned WinTimerClass::Get_User_Tick_Count ( void )
{
return ( UserTicks );
}