Initial commit of Command & Conquer Red Alert source code.
This commit is contained in:
205
WWFLAT32/TIMER/MAKEFILE
Normal file
205
WWFLAT32/TIMER/MAKEFILE
Normal file
@@ -0,0 +1,205 @@
|
||||
#
|
||||
# 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 27, 1995 *
|
||||
#* *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WWFLAT = your root WWFLAT path *
|
||||
#* WWVCS = root directory for wwlib version control archive *
|
||||
#* WATCOM = 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 %WWFLAT
|
||||
!error WWFLAT Environment var not configured.
|
||||
!endif
|
||||
|
||||
|
||||
!ifndef %WWVCS
|
||||
!error WWVCS 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 = $(%WWFLAT)\$(PROJ_NAME)
|
||||
LIB_DIR = $(%WWFLAT)\lib
|
||||
|
||||
!include $(%WWFLAT)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
timer.obj &
|
||||
timerdwn.obj &
|
||||
timerini.obj &
|
||||
timera.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: $(%WWFLAT)\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 = $(%WWFLAT)\LIB;$(%WATCOM)\LIB
|
||||
INCLUDEPATH = $(%WWFLAT)\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: $(%WWFLAT)\project.cfg .AUTODEPEND
|
||||
$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj: $(%WWFLAT)\project.cfg .AUTODEPEND
|
||||
$(CPP_CMD) $(CC_CFG) $<
|
||||
|
||||
.asm.obj: $(%WWFLAT)\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 WWFLAT\SRCDEBUG, for debugging
|
||||
#---------------------------------------------------------------------------
|
||||
$(LIB_DIR)\$(PROJ_NAME).lib: $(OBJECTS) objects.lbc
|
||||
copy *.h $(%WWFLAT)\include
|
||||
copy *.inc $(%WWFLAT)\include
|
||||
copy *.cpp $(%WWFLAT)\srcdebug
|
||||
copy *.asm $(%WWFLAT)\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 ******************************
|
||||
|
178
WWFLAT32/TIMER/TIMER.CPP
Normal file
178
WWFLAT32/TIMER/TIMER.CPP
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
** 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;
|
||||
|
||||
switch (timer) {
|
||||
case BT_USER:
|
||||
Get_Ticks = Get_User_Tick_Count;
|
||||
break;
|
||||
|
||||
default:
|
||||
case BT_SYSTEM:
|
||||
Get_Ticks = Get_System_Tick_Count;
|
||||
break;
|
||||
}
|
||||
if (on && TimerSystemOn) Start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* 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());
|
||||
}
|
||||
|
||||
|
153
WWFLAT32/TIMER/TIMER.H
Normal file
153
WWFLAT32/TIMER/TIMER.H
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
** 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
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: TIMERA.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////// Externs /////////////////////////////////////////////
|
||||
extern BOOL TimerSystemOn;
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
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.
|
||||
};
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////// externs //////////////////////////////////////////
|
||||
|
||||
extern TimerClass TickCount;
|
||||
extern CountDownTimerClass CountDown;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////// Prototypes //////////////////////////////////////////
|
||||
|
||||
extern "C" {
|
||||
long Get_System_Tick_Count(void);
|
||||
long Get_User_Tick_Count(void);
|
||||
void far Timer_Interrupt_Func(void);
|
||||
// long Get_Num_Interrupts(unsigned int realmode);
|
||||
void Disable_Timer_Interrupt(void);
|
||||
void Enable_Timer_Interrupt(void);
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: TIMER.CPP */
|
||||
/*=========================================================================*/
|
||||
BOOL Init_Timer_System(unsigned int freq, int partial = FALSE);
|
||||
BOOL Remove_Timer_System(VOID);
|
||||
|
||||
|
||||
#endif // TIMER_H
|
||||
|
||||
|
1018
WWFLAT32/TIMER/TIMERA.ASM
Normal file
1018
WWFLAT32/TIMER/TIMERA.ASM
Normal file
File diff suppressed because it is too large
Load Diff
1014
WWFLAT32/TIMER/TIMERA.BAK
Normal file
1014
WWFLAT32/TIMER/TIMERA.BAK
Normal file
File diff suppressed because it is too large
Load Diff
127
WWFLAT32/TIMER/TIMERDWN.CPP
Normal file
127
WWFLAT32/TIMER/TIMERDWN.CPP
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
** 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 <descmgmt.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());
|
||||
}
|
||||
|
||||
|
||||
|
241
WWFLAT32/TIMER/TIMEREAL.ASM
Normal file
241
WWFLAT32/TIMER/TIMEREAL.ASM
Normal file
@@ -0,0 +1,241 @@
|
||||
;
|
||||
; 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 interrupt for RM *
|
||||
;* *
|
||||
;* File Name : TIMEREAL.ASM *
|
||||
;* *
|
||||
;* Programmer : Scott K. Bowen *
|
||||
;* *
|
||||
;* Start Date : July 8, 1994 *
|
||||
;* *
|
||||
;* Last Update : July 8, 1994 [SKB] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
MODEL TINY
|
||||
P386N
|
||||
|
||||
LOCALS ??
|
||||
|
||||
;//////////////////////////////////////////////////////////////////////////////////////
|
||||
;///////////////////////////////////// Equates ////////////////////////////////////////
|
||||
|
||||
INTCHIP0 EQU 20h ; 8259 interrupt chip controller 0
|
||||
CLEARISR EQU 20h ; Value to write to 8259 to reenable interrupts.
|
||||
|
||||
CODESEG
|
||||
;//////////////////////////////////////////////////////////////////////////////////////
|
||||
;///////////////////////////////////// Data ////////////////////////////////////////
|
||||
; This information may not change unless the protected mode version is
|
||||
; also changed.
|
||||
; For speed, PM uses a DD while RM used DW
|
||||
TrueRate DW 0 ; True rate of clock. (only use word)
|
||||
TrueRateNA DW 0 ; used for speed in prot mode.
|
||||
|
||||
; For speed, SysRate and SysError are DD in PM and are DW in real mode.
|
||||
SysTicks DD 0 ; Tick count of timer.
|
||||
SysRate DD 0 ; Desired rate of timer.
|
||||
SysError DD 0 ; Amount of error in clock rate for desired frequency.
|
||||
SysCurRate DW 0 ; Keeps track of when to increment timer.
|
||||
SysCurError DW 0 ; Keeps track of amount of error in timer.
|
||||
|
||||
UserTicks DD 0 ; Tick count of timer.
|
||||
UserRate DD 0 ; Desired rate of timer.
|
||||
UserError DD 0 ; Amount of error in clock rate for desired frequency.
|
||||
UserCurRate DW 0 ; Keeps track of when to increment timer.
|
||||
UserCurError DW 0 ; Keeps track of amount of error in timer.
|
||||
|
||||
DosAdder DW 0 ; amount to add to DosFraction each interrupt.
|
||||
DosFraction DW 0 ; Call dos when overflowed.
|
||||
|
||||
OldRMI DD 0 ; The origianl RM interrupt seg:off.
|
||||
OldPMIOffset DD 0 ; The origianl PM interrupt offset
|
||||
OldPMISelector DD 0 ; The original PM interrupt segment.
|
||||
|
||||
CodeOffset DW RM_Timer_Interrupt_Handler ; Offset of the code in the RM stuff.
|
||||
CallRMIntOffset DW Call_Interrupt_Chain ; Offset of function to call DOS timer interrupt.
|
||||
CallRMIntAddr DD 0 ; PM address of CallRealIntOffset for speed.
|
||||
|
||||
PMIssuedInt DD 0 ; PM signals RM to just call Int chain.
|
||||
|
||||
; These are just used for information on testing. When all is done, they can
|
||||
; be removed, but why? The don't add too much proccessing time and can
|
||||
; be useful.
|
||||
NumPMInts DD 0 ; Number of PM interrupts
|
||||
NumRMInts DD 0 ; Number of RM interrupts.
|
||||
|
||||
;//////////////////////////////////////////////////////////////////////////////////////
|
||||
;///////////////////////////////////// Code ////////////////////////////////////////
|
||||
|
||||
|
||||
; This is here for easy comparison with the PM version.
|
||||
MACRO INCREMENT_TIMERS
|
||||
inc [NumRMInts] ; For testing.
|
||||
|
||||
|
||||
; At this point, increment the system and user timers.
|
||||
mov ax,[TrueRate] ; Get the rate of the PC clock.
|
||||
|
||||
sub [SysCurRate],ax ; Sub from our rate counter.
|
||||
ja ??end_sys ; If !below zero, do not inc.
|
||||
|
||||
mov bx,[WORD PTR SysRate] ; Get rate of timer.
|
||||
mov dx,[WORD PTR SysError] ; Get amount of error.
|
||||
add [SysCurRate],bx ; Add rate to the current.
|
||||
|
||||
sub [SysCurError],dx ; Subtract err from error count.
|
||||
jb ??error_adj_sys ; If !below 0, increment counter.
|
||||
|
||||
inc [SysTicks] ; increment the timer.
|
||||
jmp short ??end_sys ; don't modify SysCurError.
|
||||
??error_adj_sys:
|
||||
add [SysCurError],bx ; reajust the error by timer rate.
|
||||
??end_sys:
|
||||
|
||||
sub [UserCurRate],ax ; Sub from our rate counter.
|
||||
ja ??end_user ; If !below zero, do not inc.
|
||||
|
||||
mov bx,[WORD PTR UserRate] ; Get rate of timer.
|
||||
mov dx,[WORD PTR UserError] ; Get amount of error.
|
||||
add [UserCurRate],bx ; Add rate to the current.
|
||||
|
||||
sub [UserCurError],dx ; Subtract err from error count.
|
||||
jb ??error_adj_user ; If !below 0, increment counter.
|
||||
|
||||
inc [UserTicks] ; increment the timer.
|
||||
jmp short ??end_user ; don't modify UserCurError.
|
||||
??error_adj_user:
|
||||
add [UserCurError],bx ; reajust the error by timer rate.
|
||||
??end_user:
|
||||
|
||||
ENDM
|
||||
|
||||
|
||||
|
||||
|
||||
;**************************************************************************
|
||||
;* RM_INTERRUPT_HANDLER -- Called when processor interrupted in real mode. *
|
||||
;* *
|
||||
;* *
|
||||
;* INPUT: *
|
||||
;* *
|
||||
;* OUTPUT: *
|
||||
;* *
|
||||
;* WARNINGS: *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 07/08/1994 SKB : Created. *
|
||||
;*=========================================================================*
|
||||
label RM_Timer_Interrupt_Handler
|
||||
start_RM_Timer_Interrupt_Handler:
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push dx
|
||||
push ds
|
||||
|
||||
mov ax,cs ; Set data segment to code segment
|
||||
mov ds,ax ; since data is in code seg.
|
||||
|
||||
cmp [WORD PTR PMIssuedInt],0; Check to see if PM made Int call.
|
||||
mov [WORD PTR PMIssuedInt],0; Make it false.
|
||||
jne ??call_int_chain ; if so, just call Int Chain.
|
||||
|
||||
|
||||
INCREMENT_TIMERS
|
||||
|
||||
|
||||
; Now check to see if we should call the old timer handler.
|
||||
mov ax,[DosAdder] ; Get amount to add each tick.
|
||||
add [DosFraction],ax ; add it to the fraction.
|
||||
jnc ??no_int_chain ; Skip call if no overflow.
|
||||
|
||||
??call_int_chain:
|
||||
pushf ; Push flags for interrupt call.
|
||||
call [OldRMI] ; chain the call.
|
||||
|
||||
??no_int_chain:
|
||||
sti
|
||||
mov al,CLEARISR ; value to clear In Service Register
|
||||
mov dx,INTCHIP0
|
||||
out dx,al ; 8259 interrupt chip controller 0
|
||||
exit1:
|
||||
|
||||
pop ds
|
||||
pop dx
|
||||
pop bx
|
||||
pop ax
|
||||
iret
|
||||
|
||||
|
||||
|
||||
;**************************************************************************
|
||||
;* CALL_INTERRUPT_CHAIN -- Function PM calls to call the RM interrupt chain*
|
||||
;* *
|
||||
;* *
|
||||
;* INPUT: *
|
||||
;* *
|
||||
;* OUTPUT: *
|
||||
;* *
|
||||
;* WARNINGS: *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 07/08/1994 SKB : Created. *
|
||||
;*=========================================================================*
|
||||
Call_Interrupt_Chain:
|
||||
|
||||
pushf
|
||||
call [OldRMI] ;
|
||||
retf
|
||||
|
||||
STACK ; Don't really need this
|
||||
|
||||
END
|
||||
|
||||
|
||||
|
||||
|
||||
IF 0
|
||||
; mono print stuff.
|
||||
pushf
|
||||
push ax
|
||||
push di
|
||||
push es
|
||||
|
||||
mov ax,0B000h ; ES:DI = Mono RAM address.
|
||||
mov es,ax
|
||||
|
||||
mov al,'A'
|
||||
mov ah,2
|
||||
and di,63
|
||||
|
||||
stosw
|
||||
|
||||
pop es
|
||||
pop di
|
||||
pop ax
|
||||
popf
|
||||
ENDIF
|
14
WWFLAT32/TIMER/TIMEREAL.IBN
Normal file
14
WWFLAT32/TIMER/TIMEREAL.IBN
Normal file
@@ -0,0 +1,14 @@
|
||||
DB 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
|
||||
DB 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
|
||||
DB 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
|
||||
DB 000h,000h,000h,000h,000h,000h,000h,048h,000h,0C5h,000h,000h,000h,000h,000h
|
||||
DB 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,050h,053h,052h
|
||||
DB 01Eh,08Ch,0C8h,08Eh,0D8h,083h,03Eh,03Ch,000h,000h,0C7h,006h,03Ch,000h,000h
|
||||
DB 000h,075h,057h,066h,0FFh,006h,044h,000h,0A1h,000h,000h,029h,006h,010h,000h
|
||||
DB 077h,01Dh,08Bh,01Eh,008h,000h,08Bh,016h,00Ch,000h,001h,01Eh,010h,000h,029h
|
||||
DB 016h,012h,000h,072h,007h,066h,0FFh,006h,004h,000h,0EBh,004h,001h,01Eh,012h
|
||||
DB 000h,029h,006h,020h,000h,077h,01Dh,08Bh,01Eh,018h,000h,08Bh,016h,01Ch,000h
|
||||
DB 001h,01Eh,020h,000h,029h,016h,022h,000h,072h,007h,066h,0FFh,006h,014h,000h
|
||||
DB 0EBh,004h,001h,01Eh,022h,000h,0A1h,024h,000h,001h,006h,026h,000h,073h,005h
|
||||
DB 09Ch,0FFh,01Eh,028h,000h,0FBh,0B0h,020h,0BAh,020h,000h,0EEh,01Fh,05Ah,05Bh
|
||||
DB 058h,0CFh,09Ch,0FFh,01Eh,028h,000h,0CBh
|
161
WWFLAT32/TIMER/TIMERINI.CPP
Normal file
161
WWFLAT32/TIMER/TIMERINI.CPP
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
** 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 <descmgmt.h>
|
||||
#include "timer.H"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////// Defines /////////////////////////////////////
|
||||
|
||||
#define COPY_FROM_MEM TRUE
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////// timera.asm functions//////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern VOID *Get_RM_Timer_Address(VOID);
|
||||
extern ULONG Get_RM_Timer_Size(VOID);
|
||||
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);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////// Code ////////////////////////////////////////
|
||||
|
||||
/***************************************************************************
|
||||
* INIT_TIMER_SYSTEM -- Initialize the WW timer system. *
|
||||
* *
|
||||
* *
|
||||
* INPUT: UINT : user timer frequency. *
|
||||
* *
|
||||
* OUTPUT: BOOL success? *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 07/06/1994 SKB : Created. *
|
||||
*=========================================================================*/
|
||||
BOOL Init_Timer_System(UINT freq, BOOL partial)
|
||||
{
|
||||
VOID *binary;
|
||||
UINT binsize;
|
||||
BOOL success;
|
||||
|
||||
#if COPY_FROM_MEM
|
||||
|
||||
// The binary is stuffed in an ASM module.
|
||||
// Get it's address and size.
|
||||
binary = Get_RM_Timer_Address();
|
||||
binsize = Get_RM_Timer_Size();
|
||||
|
||||
#else
|
||||
WORD fd;
|
||||
VOID *mem;
|
||||
|
||||
//
|
||||
// Open binary image of real mode timer code.
|
||||
// get its size and allocate a temp block for it.
|
||||
// Copy the file into the block and close the file
|
||||
//
|
||||
fd = Open("timer.ibn", READ);
|
||||
binsize = File_Size(fd);
|
||||
binary = Alloc(binsize, MEM_NORMAL);
|
||||
Read_File(fd, binary, binsize);
|
||||
Close_File(fd);
|
||||
|
||||
#endif // COPY_FROM_MEM
|
||||
|
||||
// If no size, size too big or no address, then it's a bug.
|
||||
if (!binsize || (binsize > 0xFFFFL) || !binary) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
TimerSystemOn = success = Install_Timer_Interrupt(binary, binsize, freq, partial);
|
||||
|
||||
#if !COPY_FROM_MEM
|
||||
// Free up the temp pointer.
|
||||
Free(mem);
|
||||
#endif // !COPY_FROM_MEM
|
||||
|
||||
if (success) {
|
||||
if (!partial)
|
||||
TickCount.Start();
|
||||
return (TRUE);
|
||||
} else {
|
||||
Remove_Timer_Interrupt();
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* REMOVE_TIMER_SYSTEM -- Removes the timer system. *
|
||||
* *
|
||||
* *
|
||||
* INPUT: NONE. *
|
||||
* *
|
||||
* OUTPUT: BOOL was it removed successfuly *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 07/06/1994 SKB : Created. *
|
||||
*=========================================================================*/
|
||||
BOOL Remove_Timer_System(VOID)
|
||||
{
|
||||
TimerSystemOn = FALSE;
|
||||
return(Remove_Timer_Interrupt());
|
||||
}
|
||||
|
Reference in New Issue
Block a user