Skip to content
This repository was archived by the owner on Feb 27, 2025. It is now read-only.

Commit 5e733d5

Browse files
committed
Initial commit of Command & Conquer Red Alert source code.
1 parent b685cea commit 5e733d5

File tree

2,082 files changed

+797727
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,082 files changed

+797727
-0
lines changed

CODE/2KEYFBUF.ASM

+4,848
Large diffs are not rendered by default.

CODE/2KEYFRAM.CPP

+583
Large diffs are not rendered by default.

CODE/2SUPPORT.ASM

+564
Large diffs are not rendered by default.

CODE/2TXTPRNT.ASM

+507
Large diffs are not rendered by default.

CODE/AADATA.CPP

+655
Large diffs are not rendered by default.

CODE/ABSTRACT.CPP

+216
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
/*
2+
** Command & Conquer Red Alert(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
/* $Header: /CounterStrike/ABSTRACT.CPP 1 3/03/97 10:24a Joe_bostic $ */
20+
/***********************************************************************************************
21+
*** 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 ***
22+
***********************************************************************************************
23+
* *
24+
* Project Name : Command & Conquer *
25+
* *
26+
* File Name : ABSTRACT.CPP *
27+
* *
28+
* Programmer : Joe L. Bostic *
29+
* *
30+
* Start Date : 01/26/95 *
31+
* *
32+
* Last Update : July 10, 1996 [JLB] *
33+
* *
34+
*---------------------------------------------------------------------------------------------*
35+
* Functions: *
36+
* AbstractClass::Debug_Dump -- Display debug information to mono screen. *
37+
* AbstractClass::Distance -- Determines distance to target. *
38+
* AbstractTypeClass::AbstractTypeClass -- Constructor for abstract type objects. *
39+
* AbstractTypeClass::Coord_Fixup -- Performs custom adjustments to location coordinate. *
40+
* AbstractTypeClass::Full_Name -- Returns the full name (number) of this object type. *
41+
* AbstractTypeClass::Get_Ownable -- Fetch the ownable bits for this object. *
42+
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
43+
44+
#include "function.h"
45+
46+
47+
/***********************************************************************************************
48+
* AbstractClass::Debug_Dump -- Display debug information to mono screen. *
49+
* *
50+
* This debug only routine will display various information about this abstract class *
51+
* object to the monochrome screen specified. *
52+
* *
53+
* INPUT: mono -- Pointer to the monochrome screen to display the debug information to. *
54+
* *
55+
* OUTPUT: none *
56+
* *
57+
* WARNINGS: none *
58+
* *
59+
* HISTORY: *
60+
* 07/10/1996 JLB : Created. *
61+
*=============================================================================================*/
62+
#ifdef CHEAT_KEYS
63+
void AbstractClass::Debug_Dump(MonoClass * mono) const
64+
{
65+
assert(IsActive);
66+
67+
mono->Set_Cursor(11, 5);mono->Printf("%08X", As_Target());
68+
mono->Set_Cursor(20, 1);mono->Printf("%08X", Coord);
69+
mono->Set_Cursor(29, 1);mono->Printf("%3d", Height);
70+
if (Owner() != HOUSE_NONE) {
71+
mono->Set_Cursor(1, 3);
72+
mono->Printf("%-18s", Text_String(HouseTypeClass::As_Reference(Owner()).FullName));
73+
}
74+
}
75+
#endif
76+
77+
78+
/***********************************************************************************************
79+
* AbstractClass::Distance -- Determines distance to target. *
80+
* *
81+
* This will determine the distance (direct line) to the target. The distance is in *
82+
* 'leptons'. This routine is typically used for weapon range checks. *
83+
* *
84+
* INPUT: target -- The target to determine range to. *
85+
* *
86+
* OUTPUT: Returns with the range to the specified target (in leptons). *
87+
* *
88+
* WARNINGS: none *
89+
* *
90+
* HISTORY: *
91+
* 08/17/1994 JLB : Created. *
92+
*=============================================================================================*/
93+
int AbstractClass::Distance(TARGET target) const
94+
{
95+
/*
96+
** Should subtract a fudge-factor distance for building targets.
97+
*/
98+
BuildingClass * obj = As_Building(target);
99+
int dist = Distance(As_Coord(target));
100+
101+
/*
102+
** If the object is a building the adjust it by the average radius
103+
** of the object.
104+
*/
105+
if (obj) {
106+
dist -= ((obj->Class->Width() + obj->Class->Height()) * (0x100 / 4));
107+
if (dist < 0) dist = 0;
108+
}
109+
110+
/*
111+
** Return the distance to the target
112+
*/
113+
return(dist);
114+
}
115+
116+
117+
/***********************************************************************************************
118+
* AbstractTypeClass::AbstractTypeClass -- Constructor for abstract type objects. *
119+
* *
120+
* This is the constructor for AbstractTypeClass objects. It initializes the INI name and *
121+
* the text name for this object type. *
122+
* *
123+
* INPUT: name -- Text number for the full name of the object. *
124+
* *
125+
* ini -- The ini name for this object type. *
126+
* *
127+
* OUTPUT: none *
128+
* *
129+
* WARNINGS: none *
130+
* *
131+
* HISTORY: *
132+
* 05/22/1995 JLB : Created. *
133+
*=============================================================================================*/
134+
AbstractTypeClass::AbstractTypeClass(RTTIType rtti, int id, int name, char const * ini) :
135+
RTTI(rtti),
136+
ID(id),
137+
FullName(name)
138+
{
139+
strncpy((char *)IniName, ini, sizeof(IniName));
140+
((char &)IniName[sizeof(IniName)-1]) = '\0';
141+
}
142+
143+
144+
/***********************************************************************************************
145+
* AbstractTypeClass::Coord_Fixup -- Performs custom adjustments to location coordinate. *
146+
* *
147+
* This routine is called when the placement coordinate should be fixed up according *
148+
* to any special rules specific to this object type. At this level, no transformation *
149+
* occurs. Derived classes will transform the coordinate as necessary. *
150+
* *
151+
* INPUT: coord -- The proposed coordinate that this object type will be placed down at. *
152+
* *
153+
* OUTPUT: Returns with the adjusted coordinate that the object should be placed down at. *
154+
* *
155+
* WARNINGS: none *
156+
* *
157+
* HISTORY: *
158+
* 09/21/1995 JLB : Created. *
159+
*=============================================================================================*/
160+
COORDINATE AbstractTypeClass::Coord_Fixup(COORDINATE coord) const
161+
{
162+
return(coord);
163+
}
164+
165+
166+
/***********************************************************************************************
167+
* AbstractTypeClass::Full_Name -- Returns the full name (number) of this object type. *
168+
* *
169+
* This routine is used to fetch the full name of this object type. The name value *
170+
* returned is actually the index number into the text array. *
171+
* *
172+
* INPUT: none *
173+
* *
174+
* OUTPUT: Returns with the full name index number for this object type. *
175+
* *
176+
* WARNINGS: none *
177+
* *
178+
* HISTORY: *
179+
* 09/21/1995 JLB : Created. *
180+
*=============================================================================================*/
181+
int AbstractTypeClass::Full_Name(void) const
182+
{
183+
#ifdef FIXIT_NAME_OVERRIDE
184+
for (int index = 0; index < ARRAY_SIZE(NameOverride); index++) {
185+
if (NameIDOverride[index] == ((RTTI+1) * 100) + ID) {
186+
return(-(index+1));
187+
}
188+
}
189+
#endif
190+
return(FullName);
191+
}
192+
193+
194+
/***********************************************************************************************
195+
* AbstractTypeClass::Get_Ownable -- Fetch the ownable bits for this object. *
196+
* *
197+
* This returns a bit flag that indicates which houses are allowed to own this object *
198+
* type. At this level, all houses have ownership rights. This routine will be overridden *
199+
* by object types that restrict ownership. *
200+
* *
201+
* INPUT: none *
202+
* *
203+
* OUTPUT: Returns with a bit flag indicating which houses have ownership rights. *
204+
* *
205+
* WARNINGS: none *
206+
* *
207+
* HISTORY: *
208+
* 09/21/1995 JLB : Created. *
209+
*=============================================================================================*/
210+
int AbstractTypeClass::Get_Ownable(void) const
211+
{
212+
return(HOUSEF_ALLIES | HOUSEF_SOVIET | HOUSEF_OTHERS);
213+
}
214+
215+
216+

CODE/ABSTRACT.H

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
** Command & Conquer Red Alert(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
/* $Header: /CounterStrike/ABSTRACT.H 1 3/03/97 10:24a Joe_bostic $ */
20+
/***********************************************************************************************
21+
*** 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 ***
22+
***********************************************************************************************
23+
* *
24+
* Project Name : Command & Conquer *
25+
* *
26+
* File Name : ABSTRACT.H *
27+
* *
28+
* Programmer : Joe L. Bostic *
29+
* *
30+
* Start Date : 01/26/95 *
31+
* *
32+
* Last Update : January 26, 1995 [JLB] *
33+
* *
34+
*---------------------------------------------------------------------------------------------*
35+
* Functions: *
36+
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37+
38+
#ifndef ABSTRACT_H
39+
#define ABSTRACT_H
40+
41+
DirType Direction(CELL cell1, CELL cell2);
42+
DirType Direction(COORDINATE coord1, COORDINATE coord2);
43+
int Distance(COORDINATE coord1, COORDINATE coord2);
44+
COORDINATE As_Coord(TARGET target);
45+
46+
class AbstractTypeClass;
47+
48+
/*
49+
** This class is the base class for all game objects that have an existence on the
50+
** battlefield.
51+
*/
52+
class AbstractClass
53+
{
54+
public:
55+
56+
/*
57+
** This specifies the type of object and the unique ID number
58+
** associated with it. The ID number happens to match the index into
59+
** the object heap appropriate for this object type.
60+
*/
61+
RTTIType RTTI;
62+
int ID;
63+
64+
/*
65+
** The coordinate location of the unit. For vehicles, this is the center
66+
** point. For buildings, it is the upper left corner.
67+
*/
68+
COORDINATE Coord;
69+
70+
/*
71+
** This is the height of the object above ground (expressed in leptons).
72+
*/
73+
int Height;
74+
75+
/*
76+
** The actual object ram-space is located in arrays in the data segment. This flag
77+
** is used to indicate which objects are free to be reused and which are currently
78+
** in use by the game.
79+
*/
80+
unsigned IsActive:1;
81+
82+
/*-----------------------------------------------------------------------------------
83+
** Constructor & destructors.
84+
*/
85+
AbstractClass(RTTIType rtti, int id) : RTTI(rtti), ID(id), Coord(0xFFFFFFFFL), Height(0) {};
86+
AbstractClass(NoInitClass const & x) {x();};
87+
virtual ~AbstractClass(void) {};
88+
89+
/*
90+
** Query functions.
91+
*/
92+
virtual char const * Name(void) const {return("");}
93+
virtual HousesType Owner(void) const {return HOUSE_NONE;};
94+
TARGET As_Target(void) const {return(Build_Target(RTTI, ID));};
95+
RTTIType What_Am_I(void) const {return(RTTI);};
96+
97+
/*
98+
** Scenario and debug support.
99+
*/
100+
#ifdef CHEAT_KEYS
101+
virtual void Debug_Dump(MonoClass * mono) const;
102+
#endif
103+
104+
/*
105+
** Coordinate query support functions.
106+
*/
107+
virtual COORDINATE Center_Coord(void) const {return Coord;};
108+
virtual COORDINATE Target_Coord(void) const {return Coord;};
109+
110+
/*
111+
** Coordinate inquiry functions. These are used for both display and
112+
** combat purposes.
113+
*/
114+
DirType Direction(AbstractClass const * object) const {return ::Direction(Center_Coord(), object->Target_Coord());};
115+
DirType Direction(COORDINATE coord) const {return ::Direction(Center_Coord(), coord);};
116+
DirType Direction(TARGET target) const {return ::Direction(Center_Coord(), As_Coord(target));};
117+
DirType Direction(CELL cell) const {return ::Direction(Coord_Cell(Center_Coord()), cell);};
118+
int Distance(TARGET target) const;
119+
int Distance(COORDINATE coord) const {return ::Distance(Center_Coord(), coord);};
120+
int Distance(AbstractClass const * object) const {return ::Distance(Center_Coord(), object->Target_Coord());};
121+
122+
/*
123+
** Object entry and exit from the game system.
124+
*/
125+
virtual MoveType Can_Enter_Cell(CELL , FacingType = FACING_NONE) const {return MOVE_OK;};
126+
127+
/*
128+
** AI.
129+
*/
130+
virtual void AI(void) {};
131+
132+
};
133+
134+
135+
#endif

0 commit comments

Comments
 (0)