Initial commit of Command & Conquer Red Alert source code.
This commit is contained in:
277
WWFLAT32/DIPTHONG/DIPTHONG.CPP
Normal file
277
WWFLAT32/DIPTHONG/DIPTHONG.CPP
Normal file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
** 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/>.
|
||||
*/
|
||||
|
||||
/* $Header: g:/library/source/rcs/./dipthong.c 1.15 1994/05/20 15:35:17 joe_bostic Exp $ */
|
||||
/***************************************************************************
|
||||
** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
|
||||
***************************************************************************
|
||||
* *
|
||||
* Project Name : Westwood Library *
|
||||
* *
|
||||
* File Name : DIPTHONG.C *
|
||||
* *
|
||||
* Programmer : Joe L. Bostic *
|
||||
* *
|
||||
* Start Date : February 23, 1992 *
|
||||
* *
|
||||
* Last Update : February 13, 1995 [BWG] *
|
||||
* *
|
||||
* DIGRAM or DIATOMIC encoding is the correct term for this method. *
|
||||
* This is a fixed dictionary digram encoding optimized for English text. *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Extract_String -- Extracts a string pointer from a string data block. *
|
||||
* UnDip_Text -- Undipthongs a text string into specified buffer. *
|
||||
* Dip_Text -- Compresses text by using dipthonging. *
|
||||
* Fixup_Text -- Converts dipthonged foreign text into normal text. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
//#include "function.h"
|
||||
//#include "ems.h"
|
||||
#include <keyboard.h>
|
||||
#include "dipthong.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Fixup_Text -- Converts dipthonged foreign text into normal text. *
|
||||
* *
|
||||
* Takes text that has been processed (or undipped) to hold foriegn *
|
||||
* language character pairs (needed for Window_Print) and converts it *
|
||||
* so that Text_Print will print it properly. Typically this would be *
|
||||
* used after text has been undipped but before it will be Text_Printed.*
|
||||
* Text that is to be Window_Printed doesn't and mustn't have its text *
|
||||
* processed by this routine. *
|
||||
* *
|
||||
* INPUT: source -- Pointer to the source string to process. *
|
||||
* *
|
||||
* dest -- Destination buffer to hold the processed string. *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: This routine will only reduce the size of the string if it *
|
||||
* modifies it at all. Because of this it is quite legal to *
|
||||
* pass the same pointers to this routine so that it will *
|
||||
* modify the string "in place". *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 08/13/1993 JLB : Created. *
|
||||
* 10/06/1994 JLB : Handles source string in EMS. *
|
||||
*=========================================================================*/
|
||||
void Fixup_Text(char const *source, char *dest)
|
||||
{
|
||||
if (source && dest) {
|
||||
char const *src;
|
||||
|
||||
src = source;
|
||||
while (*src) {
|
||||
if (*src == KA_EXTEND) {
|
||||
src++;
|
||||
*dest++ = (*src++) + 127;
|
||||
} else {
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
*dest = '\0';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Dip_Text -- Compresses text by using dipthonging. *
|
||||
* *
|
||||
* This routine is used to compress text by using dipthonging. Text *
|
||||
* that is compressed in this fashion usually is reduced in size by *
|
||||
* approximately 40%. *
|
||||
* *
|
||||
* INPUT: source -- Pointer to the source string to compress. *
|
||||
* *
|
||||
* dest -- Pointer to the buffer that will hold the dipthong *
|
||||
* text output. *
|
||||
* *
|
||||
* OUTPUT: Returns the number of bytes output into the output buffer. *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 08/13/1993 JLB : Created. *
|
||||
*=========================================================================*/
|
||||
int Dip_Text(char const *source, char *dest)
|
||||
{
|
||||
unsigned char first, // First character in pair.
|
||||
next; // Second character in pair.
|
||||
int len; // Length of output string.
|
||||
int common, // Common character index.
|
||||
dipthong; // Dipthong character index.
|
||||
|
||||
len = 0; // No output characters YET.
|
||||
|
||||
first = *source++;
|
||||
next = *source;
|
||||
while (first) {
|
||||
|
||||
if (first > 127) {
|
||||
|
||||
/*
|
||||
** Characters greater than 127 cannot be dipthonged. They must
|
||||
** be preceeded with an extended character code.
|
||||
*/
|
||||
*dest++ = KA_EXTEND;
|
||||
len++;
|
||||
first -= 127;
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
** Normal characters can be dipthonged. First see if there is a
|
||||
** match in the Common table.
|
||||
*/
|
||||
for (common = 0; common < 16; common++) {
|
||||
if (Common[common] == first) {
|
||||
|
||||
/*
|
||||
** Common character found. See if there is a matching
|
||||
** Dipthong character.
|
||||
*/
|
||||
for (dipthong = 0; dipthong < 8; dipthong++) {
|
||||
if (Dipthong[common][dipthong] == next) {
|
||||
first = (unsigned char)(common << 3) | (unsigned char)dipthong | 0x80;
|
||||
source++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Output the translated character to the destination buffer.
|
||||
*/
|
||||
*dest++ = first;
|
||||
len++;
|
||||
|
||||
first = *source++;
|
||||
next = *source;
|
||||
}
|
||||
|
||||
*dest = '\0';
|
||||
|
||||
return(len);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* UnDip_Text -- Undipthongs a text string into specified buffer. *
|
||||
* *
|
||||
* This routine is used to undipthong a text string and place the *
|
||||
* undipped text into the buffer specified. Since dipthonged text is *
|
||||
* compressed, in order for the text to be used it must be undipped *
|
||||
* first. *
|
||||
* *
|
||||
* INPUT: source -- Pointer to the dipped string. *
|
||||
* *
|
||||
* dest -- Pointer to the destination buffer. *
|
||||
* *
|
||||
* OUTPUT: Returns the number of bytes placed into the destination *
|
||||
* buffer. *
|
||||
* *
|
||||
* WARNINGS: Be sure the destination buffer is big enough to hold the *
|
||||
* undipped text. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 08/13/1993 JLB : Created. *
|
||||
* 10/06/1994 JLB : Handles source string in EMS. *
|
||||
*=========================================================================*/
|
||||
int UnDip_Text(char const *source, char *dest)
|
||||
{
|
||||
int c; // Source input character.
|
||||
int common; // Common character index.
|
||||
int len; // Length of output string.
|
||||
char const *src;
|
||||
|
||||
len = 0; // Presume no translation.
|
||||
|
||||
/*
|
||||
** Sweep through the source text and dipthong it.
|
||||
*/
|
||||
src = source;
|
||||
c = *src++;
|
||||
while (c) {
|
||||
|
||||
/*
|
||||
** Convert a dipthong character into it's component
|
||||
** ASCII characters.
|
||||
*/
|
||||
if (c & 0x80) {
|
||||
c &= 0x7F;
|
||||
|
||||
common = (c & 0x78) >> 3;
|
||||
|
||||
*dest++ = Common[common];
|
||||
len++;
|
||||
|
||||
c = Dipthong[common][c & 0x07];
|
||||
}
|
||||
|
||||
*dest++ = (unsigned char)c;
|
||||
len++;
|
||||
|
||||
c = *src++;
|
||||
}
|
||||
|
||||
/*
|
||||
** End the output text with a '\0'.
|
||||
*/
|
||||
*dest++ = '\0';
|
||||
|
||||
return(len);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Extract_String -- Extracts a string pointer from a string data block. *
|
||||
* *
|
||||
* This routine is used to find a pointer to the specified string *
|
||||
* inside a string block. String data blocks are created with the *
|
||||
* TEXTMAKE utility. The data block my reside in XMS or EMS memory, *
|
||||
* but of course the returned string pointer will also point to *
|
||||
* such memory. In this case, the string must be placed in real *
|
||||
* memory before it can be used. *
|
||||
* *
|
||||
* INPUT: data -- Pointer to the string data block. *
|
||||
* *
|
||||
* string -- The string number to extract (if < 0 then NULL *
|
||||
* is returned). *
|
||||
* *
|
||||
* OUTPUT: Returns with pointer to the string number specified. *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 08/13/1993 JLB : Created. *
|
||||
* 08/13/1993 JLB : Handles EMS or XMS data pointer. *
|
||||
*=========================================================================*/
|
||||
char *Extract_String(void const *data, int string)
|
||||
{
|
||||
unsigned short int const *ptr;
|
||||
unsigned int offset;
|
||||
|
||||
if (!data || string < 0) return(NULL);
|
||||
|
||||
ptr = (unsigned short int const *)data;
|
||||
return (((char*)data) + ptr[string]);
|
||||
}
|
24
WWFLAT32/DIPTHONG/DIPTHONG.H
Normal file
24
WWFLAT32/DIPTHONG/DIPTHONG.H
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
** 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/>.
|
||||
*/
|
||||
|
||||
int Dip_Text(char const *source, char *dest);
|
||||
int UnDip_Text(char const *source, char *dest);
|
||||
char *Extract_String(void const *data, int string);
|
||||
void Fixup_Text(char const *source, char *dest);
|
||||
extern char Common[];
|
||||
extern char Dipthong[16][8];
|
193
WWFLAT32/DIPTHONG/MAKEFILE
Normal file
193
WWFLAT32/DIPTHONG/MAKEFILE
Normal file
@@ -0,0 +1,193 @@
|
||||
#
|
||||
# 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 24, 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 = dipthong
|
||||
PROJ_DIR = $(%WWFLAT)\$(PROJ_NAME)
|
||||
LIB_DIR = $(%WWFLAT)\lib
|
||||
|
||||
!include $(%WWFLAT)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
dipthong.obj &
|
||||
_diptabl.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
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Create the test directory and make it.
|
||||
#---------------------------------------------------------------------------
|
||||
test:
|
||||
mkdir test
|
||||
cd test
|
||||
copy $(%WWVCS)\$(PROJ_NAME)\test\vcs.cfg
|
||||
update
|
||||
mkdir run
|
||||
cd run
|
||||
copy $(%WWVCS)\$(PROJ_NAME)\test\run\vcs.cfg
|
||||
update
|
||||
cd..
|
||||
mkdir art
|
||||
cd art
|
||||
copy $(%WWVCS)\$(PROJ_NAME)\test\art\vcs.cfg
|
||||
update
|
||||
cd..
|
||||
wmake
|
||||
cd ..
|
||||
|
||||
|
||||
#**************************** End of makefile ******************************
|
||||
|
||||
|
58
WWFLAT32/DIPTHONG/_DIPTABL.CPP
Normal file
58
WWFLAT32/DIPTHONG/_DIPTABL.CPP
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
** 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/>.
|
||||
*/
|
||||
|
||||
/* $Header: g:/library/source/rcs/./_diptabl.c 1.11 1994/05/20 15:36:04 joe_bostic Exp $ */
|
||||
/***************************************************************************
|
||||
** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
|
||||
***************************************************************************
|
||||
* *
|
||||
* Project Name : Westwood Library *
|
||||
* *
|
||||
* File Name : _DIPTABL.C *
|
||||
* *
|
||||
* Programmer : Joe L. Bostic *
|
||||
* *
|
||||
* Start Date : July 3, 1991 *
|
||||
* *
|
||||
* Last Update : July 3, 1991 [JLB] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
char Common[16]={' ','e','t','a','i','n','o','s','r','l','h','c','d','u','p','m'};
|
||||
|
||||
char Dipthong[16][8]={
|
||||
{'t','a','s','i','o',' ','w','b'},
|
||||
{' ','r','n','s','d','a','l','m'},
|
||||
{'h',' ','i','e','o','r','a','s'},
|
||||
{'n','r','t','l','c',' ','s','y'},
|
||||
{'n','s','t','c','l','o','e','r'},
|
||||
{' ','d','t','g','e','s','i','o'},
|
||||
{'n','r',' ','u','f','m','s','w'},
|
||||
{' ','t','e','p','.','i','c','a'},
|
||||
{'e',' ','o','i','a','d','u','r'},
|
||||
{' ','l','a','e','i','y','o','d'},
|
||||
{'e','i','a',' ','o','t','r','u'},
|
||||
{'e','t','o','a','k','h','l','r'},
|
||||
{' ','e','i','u',',','.','o','a'},
|
||||
{'n','s','r','c','t','l','a','i'},
|
||||
{'l','e','o','i','r','a','t','p'},
|
||||
{'e','a','o','i','p',' ','b','m'},
|
||||
};
|
||||
|
Reference in New Issue
Block a user