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

View File

@@ -0,0 +1,14 @@
IMPORTS
DirectDrawCreate=DDRAW.DirectDrawCreate
DirectSoundCreate=DSOUND.DirectSoundCreate
DirectPlayEnumerate=DPLAY.DirectPlayEnumerate
DirectPlayCreate=DPLAY.DirectPlayCreate

View File

@@ -0,0 +1,401 @@
/*
** Command & Conquer Red Alert(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***********************************************************************************************
* *
* Project Name : Westwood Keyboard Library *
* *
* File Name : KEYBOARD.CPP *
* *
* Programmer : Philip W. Gorrow *
* *
* Start Date : 10/16/95 *
* *
* Last Update : October 17, 1995 [PWG] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] *
* WWKeyboardClass::Get -- Logic to get a metakey from the buffer *
* WWKeyboardClass::Check -- Checks to see if a key is in the buffer *
* WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer *
* WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer *
* WWKeyboardClass::Get_Mouse_X -- Returns the mouses current x position in pixels *
* WWKeyboardClass::Get_Mouse_Y -- returns the mouses current y position in pixels *
* WWKeyboardClass::Get_Mouse_XY -- Returns the mouses x,y position via reference vars *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "keyboard.h"
/***********************************************************************************************
* WWKeyboardClass::WWKeyBoardClass -- Construction for Westwood Keyboard Class *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
WWKeyboardClass::WWKeyboardClass(void)
{
//
// Initialize the keyboard remap table for our system (note it would be bad if someone
// switched keyboard modes after this happened.
//
memset(VKRemap, 0, 2048);
memset(AsciiRemap, 0, 256);
for (short lp = 1; lp < 255; lp ++) {
int vk_key = VkKeyScan(lp);
if (vk_key > 0 && vk_key < 2048) {
AsciiRemap[vk_key] = lp;
VKRemap[vk_key] = vk_key & 0xFF;
}
}
//
// Build a remap table of the different keys which are affected by the caps lock and
// the num lock.
//
memset(ToggleKeys, 0, 256);
for (lp = 0; lp < 255; lp++ ) {
if (isalpha(lp) && isupper(lp)) {
ToggleKeys[lp] = 1;
}
if (lp >= VK_NUMPAD0 && lp <= VK_DIVIDE) {
ToggleKeys[lp] = 2;
}
}
//
// Our buffer should start devoid of keys.
//
memset(Buffer, 0, 256);
Head = 0;
Tail = 0;
//
// There should be no starting queued mouse events for us to have to worry
// about.
//
MouseQX = 0;
MouseQY = 0;
}
/***********************************************************************************************
* WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer *
* *
* INPUT: none *
* *
* OUTPUT: int - the key value that was pulled from buffer (includes bits) * *
* *
* WARNINGS: If the key was a mouse event MouseQX and MouseQY will be updated *
* *
* HISTORY: *
* 10/17/1995 PWG : Created. *
*=============================================================================================*/
int WWKeyboardClass::Buff_Get(void)
{
while (!Check()) {} // wait for key in buffer
int temp = Buffer[Head]; // get key out of the buffer
int newhead = Head; // save off head for manipulation
if (Is_Mouse_Key(temp)) { // if key is a mouse then
MouseQX = Buffer[Head+1]; // get the x and y pos
MouseQY = Buffer[Head+2]; // from the buffer
newhead += 3; // adjust head forward
} else {
newhead += 1; // adjust head forward
}
newhead &= 255;
Head = newhead;
return(temp);
}
BOOL WWKeyboardClass::Is_Mouse_Key(int key)
{
key &= 0xFF;
return (key == VK_LBUTTON || key == VK_MBUTTON || key == VK_RBUTTON);
}
/***********************************************************************************************
* WWKeyboardClass::Check -- Checks to see if a key is in the buffer *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
BOOL WWKeyboardClass::Check(void)
{
unsigned short temp; // store temp holding spot for key
if (Head == Tail) return(FALSE); // if no keys in buff then get out
temp = Buffer[Head]; // get key out of the buffer
return(temp); // send it back to main program
}
/***********************************************************************************************
* WWKeyboardClass::Get -- Logic to get a metakey from the buffer *
* *
* INPUT: none *
* *
* OUTPUT: int - the meta key taken from the buffer. *
* *
* WARNINGS: This routine will not return until a keypress is received *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
int WWKeyboardClass::Get(void)
{
int temp,bits; // store temp holding spot for key
while (!Check()) {} // wait for key in buffer
temp = Buff_Get(); // get key from the buffer
bits = temp & 0xFF00; // save of keyboard bits
if (!(bits & WWKEY_VK_BIT)) { // if its not a virtual key
temp = AsciiRemap[temp&0x1FF] | bits; // convert to ascii equivalent
}
return(temp); // return the key that we pulled out
}
/***********************************************************************************************
* WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] *
* *
* INPUT: int - the key to insert into the buffer *
* *
* OUTPUT: bool - true if key is sucessfuly inserted. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
BOOL WWKeyboardClass::Put(int key)
{
int temp = (Tail + 1) & 255;
if (temp != Head)
{
Buffer[Tail] = key;
//
// Critical Line
//
Tail = temp;
return(TRUE);
}
return(FALSE);
}
/***********************************************************************************************
* WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
WWKeyboardClass::Put_Key_Message(UINT vk_key, BOOL release, BOOL dbl)
{
int bits = 0;
//
// Get the status of all of the different keyboard modifiers. Note, only pay attention
// to numlock and caps lock if we are dealing with a key that is affected by them.
//
int shift = (GetKeyState(VK_SHIFT) & 0xFF00) != 0;
int ctrl = (GetKeyState(VK_CONTROL) & 0xFF00) != 0;
int alt = (GetKeyState(VK_MENU) & 0xFF00) != 0;
int caps = ((GetKeyState(VK_CAPITAL) & 0x00FF) != 0) && (ToggleKeys[vk_key] == 1);
int nums = ((GetKeyState(VK_NUMLOCK) & 0x00FF) != 0) && (ToggleKeys[vk_key] == 2);
//
// Set the proper bits for whatever the key we got is.
//
if (shift || caps || nums) {
bits |= WWKEY_SHIFT_BIT;
}
if (ctrl) {
bits |= WWKEY_CTRL_BIT;
}
if (alt) {
bits |= WWKEY_ALT_BIT;
}
if (!AsciiRemap[vk_key|bits]) {
bits |= WWKEY_VK_BIT;
}
if (release) {
bits |= WWKEY_RLS_BIT;
}
if (dbl) {
bits |= WWKEY_DBL_BIT;
}
//
// Finally use the put command to enter the key into the keyboard
// system.
//
return(Put(vk_key|bits));
}
VOID WWKeyboardClass::Split(int &key, int &shift, int &ctrl, int &alt, int &rls, int &dbl)
{
shift = (key & WWKEY_SHIFT_BIT) != 0;
ctrl = (key & WWKEY_CTRL_BIT) != 0;
alt = (key & WWKEY_ALT_BIT) != 0;
rls = (key & WWKEY_RLS_BIT) != 0;
dbl = (key & WWKEY_DBL_BIT) != 0;
key = (key & 0xFF);
}
#pragma argsused
void WWKeyboardClass::Message_Handler(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
switch (message) {
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
Put_Key_Message(wParam);
break;
case WM_SYSKEYUP:
case WM_KEYUP:
Put_Key_Message(wParam, TRUE);
break;
case WM_LBUTTONDOWN:
Put_Key_Message(VK_LBUTTON);
Put(LOWORD(lParam));
Put(HIWORD(lParam));
break;
case WM_LBUTTONUP:
Put_Key_Message(VK_LBUTTON, TRUE);
Put(LOWORD(lParam));
Put(HIWORD(lParam));
break;
case WM_LBUTTONDBLCLK:
Put_Key_Message(VK_LBUTTON, TRUE, TRUE);
Put(LOWORD(lParam));
Put(HIWORD(lParam));
break;
case WM_MBUTTONDOWN:
Put_Key_Message(VK_MBUTTON);
Put(LOWORD(lParam));
Put(HIWORD(lParam));
break;
case WM_MBUTTONUP:
Put_Key_Message(VK_MBUTTON, TRUE);
Put(LOWORD(lParam));
Put(HIWORD(lParam));
break;
case WM_MBUTTONDBLCLK:
Put_Key_Message(VK_MBUTTON, TRUE, TRUE);
Put(LOWORD(lParam));
Put(HIWORD(lParam));
break;
case WM_RBUTTONDOWN:
Put_Key_Message(VK_RBUTTON);
Put(LOWORD(lParam));
Put(HIWORD(lParam));
break;
case WM_RBUTTONUP:
Put_Key_Message(VK_RBUTTON, TRUE);
Put(LOWORD(lParam));
Put(HIWORD(lParam));
break;
case WM_RBUTTONDBLCLK:
Put_Key_Message(VK_RBUTTON, TRUE, TRUE);
Put(LOWORD(lParam));
Put(HIWORD(lParam));
break;
}
}
/***********************************************************************************************
* WWKeyboardClass::Get_Mouse_X -- Returns the mouses current x position in pixels *
* *
* INPUT: none *
* *
* OUTPUT: int - returns the mouses current x position in pixels *
* *
* HISTORY: *
* 10/17/1995 PWG : Created. *
*=============================================================================================*/
int WWKeyboardClass::Get_Mouse_X(void)
{
POINT pt;
GetCursorPos(&pt);
return(pt.x);
}
void WWKeyboardClass::Clear(void)
{
Head = Tail;
}
/***********************************************************************************************
* WWKeyboardClass::Get_Mouse_Y -- returns the mouses current y position in pixels *
* *
* INPUT: none *
* *
* OUTPUT: int - returns the mouses current y position in pixels *
* *
* HISTORY: *
* 10/17/1995 PWG : Created. *
*=============================================================================================*/
int WWKeyboardClass::Get_Mouse_Y(void)
{
POINT pt;
GetCursorPos(&pt);
return(pt.y);
}
/***********************************************************************************************
* WWKeyboardClass::Get_Mouse_XY -- Returns the mouses x,y position via reference vars *
* *
* INPUT: int &x - variable to return the mouses x position in pixels *
* int &y - variable to return the mouses y position in pixels *
* *
* OUTPUT: none - output is via reference variables *
* *
* HISTORY: *
* 10/17/1995 PWG : Created. *
*=============================================================================================*/
void WWKeyboardClass::Get_Mouse_XY(int &x, int &y)
{
POINT pt;
GetCursorPos(&pt);
x = pt.x;
y = pt.y;
}

View File

@@ -0,0 +1,577 @@
/*
** 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/>.
*/
/***********************************************************************************************
* *
* Project Name : Westwood Keyboard Library *
* *
* File Name : KEYBOARD.H *
* *
* Programmer : Philip W. Gorrow *
* *
* Start Date : 10/16/95 *
* *
* Last Update : October 16, 1995 [PWG] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <WWSTD.H>
typedef enum {
WWKEY_SHIFT_BIT = 0x100,
WWKEY_CTRL_BIT = 0x200,
WWKEY_ALT_BIT = 0x400,
WWKEY_VK_BIT = 0x800,
WWKEY_RLS_BIT = 0x1000,
WWKEY_DBL_BIT = 0x2000,
WWKEY_BTN_BIT = 0x4000,
} WWKey_Type;
#define VK_NONE 0x00
#define VK_LBUTTON 0x01
#define VK_RBUTTON 0x02
#define VK_CANCEL 0x03
#define VK_MBUTTON 0x04
#define VK_NONE_05 0x05
#define VK_NONE_06 0x06
#define VK_NONE_07 0x07
#define VK_BACK 0x08
#define VK_TAB 0x09
#define VK_NONE_0A 0x0A
#define VK_NONE_0B 0x0B
#define VK_CLEAR 0x0C
#define VK_RETURN 0x0D
#define VK_NONE_0E 0x0E
#define VK_NONE_0F 0x0F
#define VK_SHIFT 0x10
#define VK_CONTROL 0x11
#define VK_MENU 0x12
#define VK_PAUSE 0x13
#define VK_CAPITAL 0x14
#define VK_NONE_15 0x15
#define VK_NONE_16 0x16
#define VK_NONE_17 0x17
#define VK_NONE_18 0x18
#define VK_NONE_19 0x19
#define VK_NONE_1A 0x1A
#define VK_ESCAPE 0x1B
#define VK_NONE_1C 0x1C
#define VK_NONE_1D 0x1D
#define VK_NONE_1E 0x1E
#define VK_NONE_1F 0x1F
#define VK_SPACE 0x20
#define VK_PRIOR 0x21
#define VK_NEXT 0x22
#define VK_END 0x23
#define VK_HOME 0x24
#define VK_LEFT 0x25
#define VK_UP 0x26
#define VK_RIGHT 0x27
#define VK_DOWN 0x28
#define VK_SELECT 0x29
#define VK_PRINT 0x2A
#define VK_EXECUTE 0x2B
#define VK_SNAPSHOT 0x2C
#define VK_INSERT 0x2D
#define VK_DELETE 0x2E
#define VK_HELP 0x2F
#define VK_0 0x30
#define VK_1 0x31
#define VK_2 0x32
#define VK_3 0x33
#define VK_4 0x34
#define VK_5 0x35
#define VK_6 0x36
#define VK_7 0x37
#define VK_8 0x38
#define VK_9 0x39
#define VK_NONE_3B 0x3B
#define VK_NONE_3C 0x3C
#define VK_NONE_3D 0x3D
#define VK_NONE_3E 0x3E
#define VK_NONE_3F 0x3F
#define VK_NONE_40 0x40
#define VK_A 0x41
#define VK_B 0x42
#define VK_C 0x43
#define VK_D 0x44
#define VK_E 0x45
#define VK_F 0x46
#define VK_G 0x47
#define VK_H 0x48
#define VK_I 0x49
#define VK_J 0x4A
#define VK_K 0x4B
#define VK_L 0x4C
#define VK_M 0x4D
#define VK_N 0x4E
#define VK_O 0x4F
#define VK_P 0x50
#define VK_Q 0x51
#define VK_R 0x52
#define VK_S 0x53
#define VK_T 0x54
#define VK_U 0x55
#define VK_V 0x56
#define VK_W 0x57
#define VK_X 0x58
#define VK_Y 0x59
#define VK_Z 0x5A
#define VK_NONE_5B 0x5B
#define VK_NONE_5C 0x5C
#define VK_NONE_5D 0x5D
#define VK_NONE_5E 0x5E
#define VK_NONE_5F 0x5F
#define VK_NUMPAD0 0x60
#define VK_NUMPAD1 0x61
#define VK_NUMPAD2 0x62
#define VK_NUMPAD3 0x63
#define VK_NUMPAD4 0x64
#define VK_NUMPAD5 0x65
#define VK_NUMPAD6 0x66
#define VK_NUMPAD7 0x67
#define VK_NUMPAD8 0x68
#define VK_NUMPAD9 0x69
#define VK_MULTIPLY 0x6A
#define VK_ADD 0x6B
#define VK_SEPARATOR 0x6C
#define VK_SUBTRACT 0x6D
#define VK_DECIMAL 0x6E
#define VK_DIVIDE 0x6F
#define VK_F1 0x70
#define VK_F2 0x71
#define VK_F3 0x72
#define VK_F4 0x73
#define VK_F5 0x74
#define VK_F6 0x75
#define VK_F7 0x76
#define VK_F8 0x77
#define VK_F9 0x78
#define VK_F10 0x79
#define VK_F11 0x7A
#define VK_F12 0x7B
#define VK_F13 0x7C
#define VK_F14 0x7D
#define VK_F15 0x7E
#define VK_F16 0x7F
#define VK_F17 0x80
#define VK_F18 0x81
#define VK_F19 0x82
#define VK_F20 0x83
#define VK_F21 0x84
#define VK_F22 0x85
#define VK_F23 0x86
#define VK_F24 0x87
#define VK_NONE_88 0x88
#define VK_NONE_89 0x89
#define VK_NONE_8A 0x8A
#define VK_NONE_8B 0x8B
#define VK_NONE_8C 0x8C
#define VK_NONE_8D 0x8D
#define VK_NONE_8E 0x8E
#define VK_NONE_8F 0x8F
#define VK_NUMLOCK 0x90
#define VK_SCROLL 0x91
#define VK_NONE_92 0x92
#define VK_NONE_93 0x93
#define VK_NONE_94 0x94
#define VK_NONE_95 0x95
#define VK_NONE_96 0x96
#define VK_NONE_97 0x97
#define VK_NONE_98 0x98
#define VK_NONE_99 0x99
#define VK_NONE_9A 0x9A
#define VK_NONE_9B 0x9B
#define VK_NONE_9C 0x9C
#define VK_NONE_9D 0x9D
#define VK_NONE_9E 0x9E
#define VK_NONE_9F 0x9F
#define VK_NONE_A0 0xA0
#define VK_NONE_A1 0xA1
#define VK_NONE_A2 0xA2
#define VK_NONE_A3 0xA3
#define VK_NONE_A4 0xA4
#define VK_NONE_A5 0xA5
#define VK_NONE_A6 0xA6
#define VK_NONE_A7 0xA7
#define VK_NONE_A8 0xA8
#define VK_NONE_A9 0xA9
#define VK_NONE_AA 0xAA
#define VK_NONE_AB 0xAB
#define VK_NONE_AC 0xAC
#define VK_NONE_AD 0xAD
#define VK_NONE_AE 0xAE
#define VK_NONE_AF 0xAF
#define VK_NONE_B0 0xB0
#define VK_NONE_B1 0xB1
#define VK_NONE_B2 0xB2
#define VK_NONE_B3 0xB3
#define VK_NONE_B4 0xB4
#define VK_NONE_B5 0xB5
#define VK_NONE_B6 0xB6
#define VK_NONE_B7 0xB7
#define VK_NONE_B8 0xB8
#define VK_NONE_B9 0xB9
#define VK_NONE_BA 0xBA
#define VK_NONE_BB 0xBB
#define VK_NONE_BC 0xBC
#define VK_NONE_BD 0xBD
#define VK_NONE_BE 0xBE
#define VK_NONE_BF 0xBF
#define VK_NONE_C0 0xC0
#define VK_NONE_C1 0xC1
#define VK_NONE_C2 0xC2
#define VK_NONE_C3 0xC3
#define VK_NONE_C4 0xC4
#define VK_NONE_C5 0xC5
#define VK_NONE_C6 0xC6
#define VK_NONE_C7 0xC7
#define VK_NONE_C8 0xC8
#define VK_NONE_C9 0xC9
#define VK_NONE_CA 0xCA
#define VK_NONE_CB 0xCB
#define VK_NONE_CC 0xCC
#define VK_NONE_CD 0xCD
#define VK_NONE_CE 0xCE
#define VK_NONE_CF 0xCF
#define VK_NONE_D0 0xD0
#define VK_NONE_D1 0xD1
#define VK_NONE_D2 0xD2
#define VK_NONE_D3 0xD3
#define VK_NONE_D4 0xD4
#define VK_NONE_D5 0xD5
#define VK_NONE_D6 0xD6
#define VK_NONE_D7 0xD7
#define VK_NONE_D8 0xD8
#define VK_NONE_D9 0xD9
#define VK_NONE_DA 0xDA
#define VK_NONE_DB 0xDB
#define VK_NONE_DC 0xDC
#define VK_NONE_DD 0xDD
#define VK_NONE_DE 0xDE
#define VK_NONE_DF 0xDF
#define VK_NONE_E0 0xE0
#define VK_NONE_E1 0xE1
#define VK_NONE_E2 0xE2
#define VK_NONE_E3 0xE3
#define VK_NONE_E4 0xE4
#define VK_NONE_E5 0xE5
#define VK_NONE_E6 0xE6
#define VK_NONE_E7 0xE7
#define VK_NONE_E8 0xE8
#define VK_NONE_E9 0xE9
#define VK_NONE_EA 0xEA
#define VK_NONE_EB 0xEB
#define VK_NONE_EC 0xEC
#define VK_NONE_ED 0xED
#define VK_NONE_EE 0xEE
#define VK_NONE_EF 0xEF
#define VK_NONE_F0 0xF0
#define VK_NONE_F1 0xF1
#define VK_NONE_F2 0xF2
#define VK_NONE_F3 0xF3
#define VK_NONE_F4 0xF4
#define VK_NONE_F5 0xF5
#define VK_NONE_F6 0xF6
#define VK_NONE_F7 0xF7
#define VK_NONE_F8 0xF8
#define VK_NONE_F9 0xF9
#define VK_NONE_FA 0xFA
#define VK_NONE_FB 0xFB
#define VK_NONE_FC 0xFC
#define VK_NONE_FD 0xFD
#define VK_NONE_FE 0xFE
#define VK_NONE_FF 0xFF
#define VK_UPLEFT VK_HOME
#define VK_UPRIGHT VK_PRIOR
#define VK_DOWNLEFT VK_END
#define VK_DOWNRIGHT VK_NEXT
#define VK_ALT VK_MENU
typedef enum {
KA_CTRL_AT = 0,
KA_CTRL_A,
KA_MORE = KA_CTRL_A,
KA_CTRL_B,
KA_SETBKGDCOL = KA_CTRL_B,
KA_CTRL_C,
KA_CTRL_D,
KA_CTRL_E,
KA_CTRL_F,
KA_SETFORECOL = KA_CTRL_F,
KA_CTRL_G,
KA_CTRL_H,
KA_BACKSPACE = KA_CTRL_H,
KA_CTRL_I,
KA_TAB = KA_CTRL_I,
KA_CTRL_J,
KA_CTRL_K,
KA_CTRL_L,
KA_FORMFEED = KA_CTRL_L,
KA_CTRL_M,
KA_RETURN = KA_CTRL_M,
KA_CTRL_N,
KA_CTRL_O,
KA_CTRL_P,
KA_CTRL_Q,
KA_CTRL_R,
KA_CTRL_S,
KA_SPCTAB = KA_CTRL_S,
KA_CTRL_T,
KA_CTRL_U,
KA_CTRL_V,
KA_CTRL_W,
KA_CTRL_X,
KA_SETX = KA_CTRL_X,
KA_CTRL_Y,
KA_SETY = KA_CTRL_Y,
KA_CTRL_Z,
KA_CTRL_LBRACKET,
KA_ESC = KA_CTRL_LBRACKET,
KA_EXTEND = KA_ESC,
KA_CTRL_BACKSLASH,
KA_CTRL_RBRACKET,
KA_LITERAL = KA_CTRL_RBRACKET,
KA_CTRL_CARROT,
KA_CTRL_UNDERLINE,
KA_SPACE, /* */
KA_EXCLAMATION, /* ! */
KA_DQUOTE, /* " */
KA_POUND, /* # */
KA_DOLLAR, /* $ */
KA_PERCENT, /* % */
KA_AMPER, /* & */
KA_SQUOTE, /* ' */
KA_LPAREN, /* ( */
KA_RPAREN, /* ) */
KA_ASTERISK, /* * */
KA_PLUS, /* + */
KA_COMMA, /* , */
KA_MINUS, /* - */
KA_PERIOD, /* . */
KA_SLASH, /* / */
KA_0, KA_1, KA_2, KA_3, KA_4, KA_5, KA_6, KA_7, KA_8, KA_9,
KA_COLON, /* : */
KA_SEMICOLON, /* ; */
KA_LESS_THAN, /* < */
KA_EQUAL, /* = */
KA_GREATER_THAN, /* > */
KA_QUESTION, /* ? */
KA_AT, /* @ */
KA_A, /* A */
KA_B, /* B */
KA_C, /* C */
KA_D, /* D */
KA_E, /* E */
KA_F, /* F */
KA_G, /* G */
KA_H, /* H */
KA_I, /* I */
KA_J, /* J */
KA_K, /* K */
KA_L, /* L */
KA_M, /* M */
KA_N, /* N */
KA_O, /* O */
KA_P, /* P */
KA_Q, /* Q */
KA_R, /* R */
KA_S, /* S */
KA_T, /* T */
KA_U, /* U */
KA_V, /* V */
KA_W, /* W */
KA_X, /* X */
KA_Y, /* Y */
KA_Z, /* Z */
KA_LBRACKET, /* [ */
KA_BACKSLASH, /* \ */
KA_RBRACKET, /* ] */
KA_CARROT, /* ^ */
KA_UNDERLINE, /* _ */
KA_GRAVE, /* ` */
KA_a, /* a */
KA_b, /* b */
KA_c, /* c */
KA_d, /* d */
KA_e, /* e */
KA_f, /* f */
KA_g, /* g */
KA_h, /* h */
KA_i, /* i */
KA_j, /* j */
KA_k, /* k */
KA_l, /* l */
KA_m, /* m */
KA_n, /* n */
KA_o, /* o */
KA_p, /* p */
KA_q, /* q */
KA_r, /* r */
KA_s, /* s */
KA_t, /* t */
KA_u, /* u */
KA_v, /* v */
KA_w, /* w */
KA_x, /* x */
KA_y, /* y */
KA_z, /* z */
KA_LBRACE, /* { */
KA_BAR, /* | */
KA_RBRACE, /* ] */
KA_TILDA, /* ~ */
KA_DEL, /* not used */
KA_ALT_F10 = 143,
KA_ALT_F9, KA_ALT_F8, KA_ALT_F7, KA_ALT_F6, KA_ALT_F5,
KA_ALT_F4, KA_ALT_F3, KA_ALT_F2, KA_ALT_F1,
KA_CTRL_F10, KA_CTRL_F9, KA_CTRL_F8, KA_CTRL_F7, KA_CTRL_F6,
KA_CTRL_F5, KA_CTRL_F4, KA_CTRL_F3, KA_CTRL_F2, KA_CTRL_F1,
KA_SHIFT_F10, KA_SHIFT_F9, KA_SHIFT_F8, KA_SHIFT_F7, KA_SHIFT_F6,
KA_SHIFT_F5, KA_SHIFT_F4, KA_SHIFT_F3, KA_SHIFT_F2, KA_SHIFT_F1,
KA_DELETE, /* <DELETE> */
KA_INSERT, /* <INSERT> */
KA_PGDN, /* <PAGE DOWN> */
KA_DOWNRIGHT = KA_PGDN,
KA_DOWN, /* <DOWN ARROW> */
KA_END, /* <END> */
KA_DOWNLEFT = KA_END,
KA_RESERVED1,
KA_RIGHT, /* <RIGHT ARROW> */
KA_KEYPAD5, /* NUMERIC KEY PAD <5> */
KA_LEFT, /* <LEFT ARROW> */
KA_RESERVED2,
KA_PGUP, /* <PAGE UP> */
KA_UPRIGHT = KA_PGUP,
KA_UP, /* <UP ARROW> */
KA_HOME, /* <HOME> */
KA_UPLEFT = KA_HOME,
KA_RESERVED3,
KA_RESERVED4,
KA_F10, KA_F9, KA_F8, KA_F7, KA_F6, KA_F5, KA_F4, KA_F3, KA_F2, KA_F1,
KA_LMOUSE,
KA_RMOUSE,
KA_JBUTTON1,
KA_JBUTTON2,
KA_J_UP,
KA_J_RIGHT,
KA_J_DOWN,
KA_J_LEFT,
KA_SHIFT_BIT = 0x0100,
KA_CTRL_BIT = 0x0200,
KA_ALT_BIT = 0x0400,
KA_RLSE_BIT = 0x0800,
KA_LCOMM_BIT = 0x1000, /* Amiga Left Comm key */
KA_RCOMM_BIT = 0x2000 /* Amiga Right Comm key */
} KA_Type;
class WWKeyboardClass
{
public:
/*===================================================================*/
/* Define the base constructor and destructors for the class */
/*===================================================================*/
WWKeyboardClass();
// ~WWKeyboardClass();
/*===================================================================*/
/* Define the functions which work with the Keyboard Class */
/*===================================================================*/
BOOL Check(void); // checks keybuff for meta key
int Get(void); // gets a meta key from the keybuffer
BOOL Put(int key); // dumps a key into the keybuffer
BOOL Put_Key_Message( UINT vk_key, BOOL release = FALSE, // handles keyboard related message
BOOL dbl = FALSE); // and mouse clicks and dbl clicks
int Check_Num(void); // checks keybuff for a keynum key
int Get_Num(void); // gets keynum key from key buff
int Check_ACII(void); // checks keybuff for an ascii key
int Get_ASCII(void); // gets an ascii key from keybuff
int Check_Bits(void); // checks keybuff for key w/ bits
int Get_Bits(void); // get key from keybuff w/ bits
int To_ASCII(int num); // converts keynum to ascii value
int Option_On(int option); // turns specified option on
int Option_Off(int option); // turns specified option off
void Clear(void); // clears all keys from keybuffer
int Down(int key); // tests to see if a key is down
void AI(void); // messaging logic for key manager
/*===================================================================*/
/* Define the main hook for the message processing loop. */
/*===================================================================*/
void Message_Handler(HWND hwnd, UINT message, UINT wParam, LONG lParam);
/*===================================================================*/
/* Define public routines which can be used on keys in general. */
/*===================================================================*/
VOID Split(int &key, int &shift, int &ctrl, int &alt, int &rls, int &dbl);
BOOL Is_Mouse_Key(int key);
/*===================================================================*/
/* Routines to sneak through and get the mouses position. */
/*===================================================================*/
int Get_Mouse_X(void);
int Get_Mouse_Y(void);
void Get_Mouse_XY(int &x, int &y);
/*===================================================================*/
/* Define the public access variables which are used with the */
/* Keyboard Class. */
/*===================================================================*/
int MouseQX;
int MouseQY;
private:
/*===================================================================*/
/* Define the private access functions which are used by keyboard */
/*===================================================================*/
int Buff_Get(void);
/*===================================================================*/
/* Define the private access variables which are used with the */
/* Keyboard Class. */
/*===================================================================*/
unsigned char AsciiRemap[2048]; // remap for shft/ctrl/alt key combos
unsigned char VKRemap[256]; // gives vk for any ascii char
unsigned short Buffer[256]; // buffer which holds actual keypresses
unsigned char ToggleKeys[256]; // determines toggles which affect key
long Head; // the head position in keyboard buffer
long Tail; // the tail position in keyboard buffer
};

View File

@@ -0,0 +1,174 @@
#
# 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 .EXE makefile *
#* *
#* File Name : MAKEFILE *
#* *
#* Programmer : Julio R. Jerez *
#* *
#* Start Date : Jan 20, 1995 *
#* *
#* Last Update : *
#* *
#*-------------------------------------------------------------------------*
#* *
#* 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 executable program you're building *
#* PROJ_LIBS = Westwood libraries to link your EXE to *
#* OBJECTS = list of objects in your current working directory *
#* *
#* Optional changes to makefile: *
#* PROJ_DIR = full pathname of your working directory *
#* .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 = library name
# PROJ_DIR = directory containing source & objects
#---------------------------------------------------------------------------
PROJ_NAME = TEST
PROJ_DIR = $(%WIN32LIB)\keyboard\TEST
LIB_DIR = $(%WIN32LIB)\lib
!include $(%WIN32LIB)\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = &
$(PROJ_NAME).obj &
testasm.obj
CPS_FILES = &
test1.cps &
test2.cps
PROJ_LIBS = &
keyboard.lib &
win32lib.lib
#---------------------------------------------------------------------------
# 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)
#---------------------------------------------------------------------------
# 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
#---------------------------------------------------------------------------
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB386\NT
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
#---------------------------------------------------------------------------
all: $(PROJ_NAME).exe
#---------------------------------------------------------------------------
# Build the EXE
#---------------------------------------------------------------------------
$(PROJ_NAME).exe: $(OBJECTS) $(PROJ_NAME).lnk $(PROJ_LIBS) $(CPS_FILES)
$(LINK_CMD) $(LINK_CFG) name $^@ @$(PROJ_NAME).lnk
$(PROJ_LIBS):
echo updating base library $^@
cd ..
wmake
cd $(PROJ_DIR)
$(PROJ_NAME).lnk : $(OBJECTS)
%create $^@
for %index in ($(OBJECTS)) do %append $^@ file %index
for %index in ($(PROJ_LIBS)) do %append $^@ library $(LIB_DIR)\%index
%append $^@ library $(LIB_DIR)\ddraw.lib
#**************************** End of makefile ******************************

View File

@@ -0,0 +1,187 @@
#
# 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 .EXE makefile *
#* *
#* File Name : MAKEFILE *
#* *
#* Programmer : Julio R. Jerez *
#* *
#* Start Date : Jan 20, 1995 *
#* *
#* Last Update : *
#* *
#*-------------------------------------------------------------------------*
#* *
#* 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 executable program you're building *
#* PROJ_LIBS = Westwood libraries to link your EXE to *
#* OBJECTS = list of objects in your current working directory *
#* *
#* Optional changes to makefile: *
#* PROJ_DIR = full pathname of your working directory *
#* .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 = library name
# PROJ_DIR = directory containing source & objects
#---------------------------------------------------------------------------
PROJ_NAME = test
PROJ_DIR = $(WIN32LIB)\drawbuff\$(PROJ_NAME)
LIB_DIR = $(WIN32LIB)\lib
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = \
$(PROJ_NAME).obj
CPS_FILES = \
test1.cps \
test2.cps
!if 0
PROJ_LIBS = \
drawbuff.lib \
win32lib.lib
!else
PROJ_LIBS = \
drawbuff.lib \
mem.lib \
misc.lib \
iff.lib \
rawfile.lib \
tile.lib \
font.lib
!endif
#---------------------------------------------------------------------------
# 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)
#---------------------------------------------------------------------------
# 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
#---------------------------------------------------------------------------
LIBPATH = $(WIN32LIB)\LIB;$(COMPILER)\LIB
INCLUDEPATH = $(WIN32LIB)\INCLUDE;$(COMPILER)\INCLUDE
!include $(WIN32LIB)\\project.cfg
#---------------------------------------------------------------------------
# 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) $<
.lbm.cps:
$(WIN32LIB)\\TOOLS\WWCOMP $*.lbm $*.cps
#---------------------------------------------------------------------------
# Default target
#---------------------------------------------------------------------------
all: $(PROJ_NAME).exe $(CPS_FILES)
#---------------------------------------------------------------------------
# Build the EXE
#---------------------------------------------------------------------------
$(PROJ_NAME).exe: $(OBJECTS) $(PROJ_LIBS)
$(LINK_CMD) @&&|
$(LINK_CFG) +
$(COMPILER)\\LIB\\c0w32.obj+
$(OBJECTS)
$<,$*
$(PROJ_LIBS) +
import32.lib +
cw32i.lib
$*.def
|
$(PROJ_LIBS):
echo updating base library $^@
cd ..
make
cd $(PROJ_DIR)
#**************************** End of makefile ******************************

View File

@@ -0,0 +1,180 @@
#
# Command & Conquer Red Alert(tm)
# Copyright 2025 Electronic Arts Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************
#** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
#***************************************************************************
#* *
#* Project Name : Westwood Library .EXE makefile *
#* *
#* File Name : MAKEFILE *
#* *
#* Programmer : Julio R. Jerez *
#* *
#* Start Date : Jan 20, 1995 *
#* *
#* Last Update : *
#* *
#*-------------------------------------------------------------------------*
#* *
#* 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 executable program you're building *
#* PROJ_LIBS = Westwood libraries to link your EXE to *
#* OBJECTS = list of objects in your current working directory *
#* *
#* Optional changes to makefile: *
#* PROJ_DIR = full pathname of your working directory *
#* .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 = library name
# PROJ_DIR = directory containing source & objects
#---------------------------------------------------------------------------
PROJ_NAME = TEST
PROJ_DIR = $(%WIN32LIB)\drawbuff\TEST
LIB_DIR = $(%WIN32LIB)\lib
!include $(%WIN32LIB)\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = &
$(PROJ_NAME).obj
CPS_FILES = &
test1.cps &
test2.cps
PROJ_LIBS = &
drawbuff.lib &
mem.lib &
misc.lib &
iff.lib &
rawfile.lib &
tile.lib &
font.lib
#PROJ_LIBS = &
# drawbuff.lib &
# win32lib.lib
#---------------------------------------------------------------------------
# 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)
#---------------------------------------------------------------------------
# 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
#---------------------------------------------------------------------------
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB386\NT
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
#---------------------------------------------------------------------------
all: $(PROJ_NAME).exe
#---------------------------------------------------------------------------
# Build the EXE
#---------------------------------------------------------------------------
$(PROJ_NAME).exe: $(OBJECTS) $(PROJ_NAME).lnk $(PROJ_LIBS) $(CPS_FILES)
$(LINK_CMD) $(LINK_CFG) name $^@ @$(PROJ_NAME).lnk
$(PROJ_LIBS):
echo updating base library $^@
cd ..
wmake
cd $(PROJ_DIR)
$(PROJ_NAME).lnk : $(OBJECTS)
%create $^@
for %index in ($(OBJECTS)) do %append $^@ file %index
for %index in ($(PROJ_LIBS)) do %append $^@ library $(LIB_DIR)\%index
%append $^@ library $(LIB_DIR)\ddraw.lib
#**************************** End of makefile ******************************

View File

@@ -0,0 +1,342 @@
/*
** 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 : GraphicBufferClass Test Program *
* *
* File Name : DRAWTEST.CPP *
* *
* Programmer : Steve Tall *
* *
* Start Date : September 25, 1995 *
* *
* Last Update : September 27, 1995 [ST] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* WinMain -- Program entry point *
* WndProc -- Callback procedure for main window *
* *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define WIN32
#define WIN32_LEAN_AND_MEAN
#include <wwlib32.h>
#include <direct.h>
#include "..\mouse.h"
#define NAME "KEYBOARD/MOUSE test"
#define TITLE "KEYBOARD/MOUSE library test"
//
// Misc globals for testing
//
BOOL AllDone = FALSE; // Flag that we should exit
#define MODE_WIDTH 640 // Width in pixels of required video mode
#define MODE_HEIGHT 400 // Height in pixels of required video mode
int ScreenWidth=MODE_WIDTH;
GraphicBufferClass *ScreenBuffer=NULL; // Global pointer to screen GraphicBufferClass
GraphicBufferClass *HidBuffer = NULL;
GraphicBufferClass SysMemPage(320,200); // page in real memory
WWMouseClass *Mouse=NULL; // Global pointer to mouse information
WinTimerClass *WindowsTimer=NULL;
PALETTEENTRY pe[256]; // DD Palette entries
unsigned char Palette[256*3]; // Place to load palette to
extern LPDIRECTDRAWPALETTE PalettePtr; // Pointer to direct draw palette object
//
// Prototypes
//
long FAR PASCAL _export WndProc (HWND, UINT, UINT, LONG) ;
//
// Externs
//
extern LPDIRECTDRAW DirectDrawObject;
extern HWND MainWindow;
VOID *ShapeFile;
int CurrentShape;
/***********************************************************************************************
* WinMain -- Program entry point *
* *
* *
* *
* INPUT: Standard Windows startup parameters *
* *
* OUTPUT: msg.wParam *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 9/27/95 1:28PM ST : Created *
*=============================================================================================*/
#pragma off(unreferenced)
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow)
{
static char szAppName[] = "HelloWin" ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
char path_to_exe[132];
char drive[_MAX_DRIVE];
char path[_MAX_PATH];
unsigned drivecount;
unsigned olddrive;
char oldpath[PATH_MAX];
/*
** Get a path to the executable and make sure that we are pointing
** at the location our datafiles are located at.
*/
GetModuleFileName (hInstance, &path_to_exe[0], 132);
getcwd(oldpath, sizeof(oldpath));
_dos_getdrive(&olddrive);
_splitpath(path_to_exe, drive, path, NULL, NULL);
if (!drive[0]) {
drive[0] = (char)(('A' + olddrive)-1);
}
if (!path[0]) {
strcpy(path, ".");
}
_dos_setdrive(toupper((drive[0])-'A')+1, &drivecount);
if (path[strlen(path)-1] == '\\') {
path[strlen(path)-1] = '\0';
}
chdir(path);
//
// Register the window class
//
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (hInstance, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = NULL;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = NAME;
RegisterClass (&wndclass) ;
}
//
// Create our main window
//
hwnd = CreateWindowEx (
WS_EX_TOPMOST,
NAME,
TITLE,
WS_POPUP | WS_MAXIMIZE,
0,
0,
MODE_WIDTH,
MODE_HEIGHT,
NULL,
NULL,
hInstance,
NULL );
ShowWindow (hwnd, nCmdShow) ;
UpdateWindow (hwnd) ;
SetFocus (hwnd);
MainWindow=hwnd; //Save the handle to our main window
// (Dangerous if Windoze can change the handle)
// Set the video mode
Set_Video_Mode( MainWindow , MODE_WIDTH , MODE_HEIGHT , 8 );
Set_Shape_Buffer(new unsigned char[5000], 5000);
//
// Create the GraphicBufferClass that will be the screen buffer
//
ScreenBuffer = new GraphicBufferClass ( MODE_WIDTH , MODE_HEIGHT , (GBC_Enum)(GBC_VIDEOMEM | GBC_VISIBLE));
HidBuffer = new GraphicBufferClass ( MODE_WIDTH , MODE_HEIGHT , (GBC_Enum)(GBC_VIDEOMEM));
ShowCursor (FALSE);
Mouse = new WWMouseClass(ScreenBuffer,32,32);
//
// Load up the picture and display it on the scene page
//
Load_Picture("TITLE.CPS", SysMemPage, SysMemPage, Palette, BM_DEFAULT);
FontPtr = Load_Font("font.fnt");
ShapeFile = Load_Alloc_Data("MOUSE.SHP", MEM_NORMAL);
CurrentShape = 0;
Mouse->Set_Cursor(0,0,Extract_Shape(ShapeFile,CurrentShape));
Set_Palette(Palette);
SysMemPage.Scale(*HidBuffer);
Mouse->Show_Mouse();
WindowsTimer = new WinTimerClass(60,FALSE);
//
// Get rid of the windows cursor
//
AllDone = FALSE;
//
// Windows message loop
//
int count = 0;
char temp[100];
CountDownTimerClass timer(BT_SYSTEM, 0);
timer.Set(60);
timer.Start();
while ( ! AllDone ){
if (timer.Time() == 0) {
sprintf(temp,"%d frames per second",count);
Mouse->Erase_Mouse(HidBuffer, TRUE);
HidBuffer->Print(temp,0,0,255,1);
count = 0;
timer.Set(60);
timer.Start();
} else {
count++;
Mouse->Erase_Mouse(HidBuffer, TRUE);
}
Mouse->Draw_Mouse(HidBuffer);
HidBuffer->Blit(*ScreenBuffer);
Mouse->Erase_Mouse(HidBuffer, FALSE);
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ){
if( !GetMessage( &msg, NULL, 0, 0 ) ){
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
delete Mouse;
return msg.wParam;
}
#pragma on(unreferenced)
/***********************************************************************************************
* WndProc -- windows message callback *
* *
* Pilfered from a windows example program - HELLOWIN.C *
* *
* *
* INPUT: Standard Windoze callback parameters *
* *
* OUTPUT: long *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 9/27/95 1:39PM ST : Pilfered *
*=============================================================================================*/
long FAR PASCAL _export WndProc (HWND hwnd, UINT message, UINT wParam,
LONG lParam)
{
static int condhide = 0;
switch (message){
// case WM_MOUSEMOVE:
// if (Mouse)
// Mouse->Process_Mouse();
// break;
case WM_LBUTTONDOWN:
if (Mouse) {
Mouse->Set_Cursor(0,0,Extract_Shape(ShapeFile,++CurrentShape));
if (CurrentShape>160) CurrentShape = 0;
}
break;
case WM_RBUTTONDOWN:
if (condhide) {
Mouse->Show_Mouse();
Mouse->Conditional_Show_Mouse();
Mouse->Conditional_Show_Mouse();
condhide = FALSE;
} else {
Mouse->Hide_Mouse();
Mouse->Conditional_Hide_Mouse(0,0,320,200);
Mouse->Conditional_Hide_Mouse(0,0,320,200);
condhide = TRUE;
}
break;
case WM_ACTIVATEAPP:
if ((BOOL)wParam) {
if (ScreenBuffer) {
ScreenBuffer->Get_DD_Surface()->Restore();
}
}
break;
case WM_DESTROY:
//
// Tidy up
//
delete ScreenBuffer;
delete Mouse;
if ( DirectDrawObject ){
Reset_Video_Mode();
}
AllDone = TRUE;
PostQuitMessage (0) ;
return(0);
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}

View File

@@ -0,0 +1,14 @@
IMPORTS
DirectDrawCreate=DDRAW.DirectDrawCreate
DirectSoundCreate=DSOUND.DirectSoundCreate
DirectPlayEnumerate=DPLAY.DirectPlayEnumerate
DirectPlayCreate=DPLAY.DirectPlayCreate

View File

@@ -0,0 +1,80 @@
;
; 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/>.
;
IDEAL
P386
MODEL USE32 FLAT
jumps
codeseg
masm
;
; Change a DAC colour register directly
;
; register number in al
;
; bh=red bl=green cl=blue
;
set_dac_col proc near
pushad
cli
push eax
mov dx,03dah
in al,dx
jmp @@1
@@1: mov dx,03c8h
pop eax
out dx,al
jmp @@2
@@2: inc dl
mov al,bh
out dx,al
jmp @@3
@@3: mov al,bl
out dx,al
jmp @@4
@@4: mov al,cl
out dx,al
jmp @@5
@@5: sti
popad
ret
set_dac_col endp
ideal
global Set_Palette_Register_:near
proc Set_Palette_Register_ near
pushad
and cl,63
mov bh,dl
and bh,63
and bl,63
call set_dac_col
popad
ret
endp Set_Palette_Register_
end