Initial Source Code commit

Initial commit of original Tiberian Dawn and Red Alert source code converted to build as DLLs, and compatible with the release version of Command & Conquer Remastered.
This commit is contained in:
PG-SteveT 2020-05-27 12:16:20 -07:00
parent ea8ecc76fa
commit 03416d24e1
1038 changed files with 629779 additions and 0 deletions

View file

@ -0,0 +1,509 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : ALLOC.CPP *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : February 1, 1992 *
* *
* Last Update : March 9, 1995 [JLB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Alloc -- Allocates system RAM. *
* Ram_Free -- Determines the largest free chunk of RAM. *
* Free -- Free an Alloc'ed block of RAM. *
* Resize_Alloc -- Change the size of an allocated block. *
* Heap_Size -- Size of the heap we have. *
* Total_Ram_Free -- Total amount of free RAM. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
//#include <dos.h>
//#include <bios.h>
#ifndef WWMEM_H
#include "wwmem.h"
#endif
extern "C" unsigned long Largest_Mem_Block ( void ) ;
/*
** Define the equates necessary to call a DPMI interrupt.
*/
#define DPMI_INT 0x0031
#define DPMI_LOCK_MEM 0x0600
#define DPMI_UNLOCK_MEM 0x0601
/*=========================================================================*/
/* The following PRIVATE functions are in this file: */
/*=========================================================================*/
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
unsigned long MinRam=0L; // Record of least memory at worst case.
unsigned long MaxRam=0L; // Record of total allocated at worst case.
static unsigned long TotalRam = 0L;
static unsigned long Memory_Calls = 0L;
void (*Memory_Error)(void) = NULL;
extern void (*Memory_Error_Exit)(char *string)=NULL;
//#define MEM_CHECK
#ifdef MEM_CHECK
extern "C"{
extern void __cdecl Int3(void);
}
#endif //MEM_CHECK
/***************************************************************************
* DPMI_LOCK -- handles locking a block of DPMI memory *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/23/1995 PWG : Created. *
*=========================================================================*/
#include"mono.h"
void DPMI_Lock(VOID const *, long const )
{
}
/***************************************************************************
* DPMI_UNLOCK -- Handles unlocking a locked block of DPMI *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/23/1995 PWG : Created. *
*=========================================================================*/
void DPMI_Unlock(void const *, long const )
{
}
/***************************************************************************
* Alloc -- Allocates system RAM. *
* *
* This is the basic RAM allocation function. It is used for all *
* memory allocations needed by the system or the main program. *
* *
* INPUT: bytes_to_alloc -- LONG value of the number of bytes to alloc. *
* *
* flags -- Memory allocation control flags. *
* MEM_NORMAL: No special flags. *
* MEM_CLEAR: Zero out memory block. *
* MEM_NEW: Called by a new. *
* *
* OUTPUT: Returns with pointer to allocated block. If NULL was returned *
* it indicates a failure to allocate. Note: NULL will never be *
* returned if the standard library allocation error routine is *
* used. *
* *
* WARNINGS: If you replace the standard memory allocation error routine *
* and make it so that Alloc CAN return with a NULL, be sure *
* and check for this in your code. *
* *
* HISTORY: *
* 09/03/1991 JLB : Documented. *
* 08/09/1993 JLB : Updated with EMS memory support. *
* 04/28/1994 JAW : Updated to 32bit Protected mode. *
* 03/09/1995 JLB : Fixed *
* 09/28/1995 ST : Simplified for win95 *
*=========================================================================*/
void *Alloc(unsigned long bytes_to_alloc, MemoryFlagType flags)
{
#ifdef WIN32
void *mem_ptr;
#ifdef MEM_CHECK
bytes_to_alloc += 32;
#endif //MEM_CHECK
mem_ptr = malloc ( bytes_to_alloc );
if ( !mem_ptr && Memory_Error ){
Memory_Error();
}
if ( mem_ptr && ( flags & MEM_CLEAR ) ){
memset ( mem_ptr , 0 , bytes_to_alloc );
}
#ifdef MEM_CHECK
mem_ptr = (void*)((char*)mem_ptr + 16);
unsigned long *magic_ptr =(unsigned long*) ( ((char *)mem_ptr) - 16 );
*magic_ptr++ = (unsigned long)mem_ptr;
*magic_ptr++ = (unsigned long)mem_ptr;
*magic_ptr++ = (unsigned long)mem_ptr;
*magic_ptr = bytes_to_alloc - 32;
magic_ptr = (unsigned long*) ( ((char*)mem_ptr) + bytes_to_alloc - 32 );
*magic_ptr++ = (unsigned long)mem_ptr;
*magic_ptr++ = (unsigned long)mem_ptr;
*magic_ptr++ = (unsigned long)mem_ptr;
*magic_ptr = (unsigned long)mem_ptr;
#endif //MEM_CHECK
Memory_Calls++;
return ( mem_ptr );
#else
union REGS regs ;
struct SREGS sregs ;
unsigned char *retval=NULL; // Pointer to allocated block.
unsigned long original_size; // Original allocation size.
unsigned long bytesfree; // Number of free bytes.
long *longptr=NULL; // Pointer used to store selector
/*
** Save the original allocated space size so that we can clear the
** exact amount of RAM if they specified MEM_CLEAR.
*/
original_size = bytes_to_alloc;
/*
** Reserve one byte for the header of the memory we allocated.
** We will store the flags variable there for later use.
*/
bytes_to_alloc += (flags & MEM_LOCK) ? 5 : 1;
/*
** Initialize the total ram available value.
*/
if (!TotalRam) {
TotalRam = Total_Ram_Free(MEM_NORMAL);
}
// Try to allocate the memory out of the protected mode memory
// chain if we did not require a real mode allocation. If this
// fails we will have to try to allocate it out of real mode memory.
// Real mode memory is a last resort because some types of applications
// require real mode memory.
if (!(flags & MEM_REAL)) {
retval = (unsigned char*)malloc(bytes_to_alloc);
}
// Try to allocate the memory out of the real mode memory using DPMI
// service 0x100. Note that retval will be null if we are requesting
// real mode memory so that we do not have to explicitly check for the
// real mode flag. Remember we need to reserve room for the dos
// selector value at the beginning of our allocated block so rather than
// adding fifteen and rounding, we need to add 19 and round.
if (!retval) {
flags = (MemoryFlagType)(flags | MEM_REAL);
regs.x.eax = 0x100;
regs.x.ebx = (bytes_to_alloc + 19) >> 4;
if (regs.x.ebx & 0xFFFF0000) {
retval = NULL;
} else {
segread ( & sregs ) ;
int386x ( 0x31 , & regs, & regs , & sregs ) ;
if (regs.x.cflag)
retval = NULL;
else {
longptr = (long *)(((regs.x.eax & 0xFFFF) << 4)+ 1);
*longptr++ = regs.x.edx & 0xFFFF;
retval = (unsigned char *)longptr;
}
}
}
// If the alloc failed then we need to signify a memory error.
if (retval == NULL) {
if(Memory_Error != NULL)
Memory_Error();
return NULL;
}
// If the memory needs to be DPMI locked then we should store the
// original size in the header before we store the flags.
if (flags & MEM_LOCK) {
longptr = (long *)retval;
*longptr++ = original_size;
retval = (unsigned char *)longptr;
}
// Now that we know the alloc was sucessful (and for an extra byte
// more than the user wanted) we need to stick in the memory flags.
*retval++ = flags;
// If the memory needed to be DPMI locked then set it up so it
// is locked.
if (flags & MEM_LOCK) {
DPMI_Lock(retval, original_size);
}
/* Clear the space if they wanted it clear */
if (flags & MEM_CLEAR) {
unsigned char *ptr; // Working memory block pointer.
ptr = retval;
memset(ptr, '\0', original_size);
}
bytesfree = Total_Ram_Free(MEM_NORMAL);
if (bytesfree < MinRam) {
MinRam = bytesfree;
}
if (TotalRam-bytesfree > MaxRam) {
MaxRam = TotalRam-bytesfree;
}
Memory_Calls++;
return(retval);
#endif
}
/***************************************************************************
* Free -- Free an Alloc'ed block of RAM. *
* *
* FUNCTION: *
* *
* INPUT: A pointer to a block of RAM from Alloc. *
* *
* OUTPUT: None. *
* *
* WARNINGS: Don't use this for an Alloc_Block'ed RAM block. *
* *
* HISTORY: *
* 05/25/1990 : Created. *
***************************************************************************/
#ifdef WIN32
void Free(void const *pointer)
{
if ( pointer ){
#ifdef MEM_CHECK
unsigned long *magic_ptr = (unsigned long*) ( ((char*)pointer) - 16 );
if (*magic_ptr++ != (unsigned long)pointer ||
*magic_ptr++ != (unsigned long)pointer ||
*magic_ptr++ != (unsigned long)pointer ){
Int3();
}
magic_ptr = (unsigned long*) ( ((char*)pointer) + *magic_ptr );
if (*magic_ptr++ != (unsigned long)pointer ||
*magic_ptr++ != (unsigned long)pointer ||
*magic_ptr++ != (unsigned long)pointer ||
*magic_ptr++ != (unsigned long)pointer ){
Int3();
}
pointer = (void*) (((char*)pointer)-16);
#endif //MEM_CHECK
free ( (void*)pointer );
Memory_Calls--;
}
#else
void Free(void const *pointer)
{
union REGS regs ;
struct SREGS sregs ;
if (pointer) {
/*
** Get a pointer to the flags that we stored off.
*/
char *byteptr = ((char *)pointer) - 1;
/*
** Check to see if this was locked me and if it was unlock it.
*/
if (*byteptr & MEM_LOCK) {
long *longptr = ((long *)byteptr) - 1;
DPMI_Unlock(pointer, *longptr);
pointer = (void *)longptr;
} else
pointer = (void *)byteptr;
// If the pointer is a real mode pointer than it will point to the
// first megabyte of system memory. If it does than we need to
// use DPMI to free it.
if (*byteptr & MEM_REAL) {
regs.x.eax = 0x101;
regs.x.edx = *(((long *)pointer) - 1);
segread ( & sregs ) ;
int386x(0x31, &regs, &regs, &sregs);
} else {
free((void *)pointer);
}
Memory_Calls--;
}
#endif
}
/***************************************************************************
* Resize_Alloc -- Change the size of an allocated block. *
* *
* This routine will take a previously allocated block and change its *
* size without unnecessarily altering its contents. *
* *
* INPUT: pointer -- Pointer to the original memory allocation. *
* *
* new_size -- Size in bytes that it will be converted to. *
* *
* OUTPUT: Returns with a pointer to the new allocation. *
* *
* WARNINGS: ??? *
* *
* HISTORY: *
* 02/01/1992 JLB : Commented. *
*=========================================================================*/
void *Resize_Alloc(void *original_ptr, unsigned long new_size_in_bytes)
{
unsigned long *temp;
temp = (unsigned long*)original_ptr;
/* ReAlloc the space */
temp = (unsigned long *)realloc(temp, new_size_in_bytes);
if (temp == NULL) {
if(Memory_Error != NULL)
Memory_Error();
return NULL;
}
return(temp);
}
/***************************************************************************
* Ram_Free -- Determines the largest free chunk of RAM. *
* *
* Use this routine to determine the largest free chunk of available *
* RAM for allocation. It also performs a check of the memory chain. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with the size of the largest free chunk of RAM. *
* *
* WARNINGS: This does not return the TOTAL memory free, only the *
* largest free chunk. *
* *
* HISTORY: *
* 09/03/1991 JLB : Commented. *
*=========================================================================*/
long Ram_Free(MemoryFlagType)
{
// return(_memmax());
#if(0)
MEMORYSTATUS mem_info;
mem_info.dwLength=sizeof(mem_info);
GlobalMemoryStatus(&mem_info);
return ( mem_info.dwAvailPhys );
#endif
return ( 64*1024*1024 );
}
/***************************************************************************
* Heap_Size -- Size of the heap we have. *
* *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/21/1994 SKB : Created. *
*=========================================================================*/
long Heap_Size(MemoryFlagType )
{
if (!TotalRam) {
TotalRam = Total_Ram_Free(MEM_NORMAL);
}
return(TotalRam);
}
/***************************************************************************
* Total_Ram_Free -- Total amount of free RAM. *
* *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/21/1994 SKB : Created. *
* 03/09/1995 JLB : Uses prerecorded heap size maximum. *
*=========================================================================*/
long Total_Ram_Free(MemoryFlagType )
{
#if(0)
MEMORYSTATUS mem_info;
mem_info.dwLength=sizeof(mem_info);
GlobalMemoryStatus(&mem_info);
return ( mem_info.dwAvailPhys );
#endif
return ( 64*1024*1024 );
}

View file

@ -0,0 +1,158 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 32 bit Library *
* *
* File Name : AUDIO.H *
* *
* Programmer : Phil W. Gorrow *
* *
* Start Date : March 10, 1995 *
* *
* Last Update : March 10, 1995 [PWG] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "wwstd.h"
/*=========================================================================*/
/* AUD file header type */
/*=========================================================================*/
#define AUD_FLAG_STEREO 1
#define AUD_FLAG_16BIT 2
// PWG 3-14-95: This structure used to have bit fields defined for Stereo
// and Bits. These were removed because watcom packs them into a 32 bit
// flag entry even though they could have fit in a 8 bit entry.
//#pragma pack(1);
#pragma pack(push,1)
typedef struct {
unsigned short int Rate; // Playback rate (hertz).
long Size; // Size of data (bytes).
long UncompSize; // Size of data (bytes).
unsigned char Flags; // Holds flags for info
// 1: Is the sample stereo?
// 2: Is the sample 16 bits?
unsigned char Compression; // What kind of compression for this sample?
} AUDHeaderType;
#pragma pack(pop)
/*=========================================================================*/
/* There can be a different sound driver for sound effects, digitized */
/* samples, and musical scores. Each one must be of these specified */
/* types. */
/*=========================================================================*/
typedef enum {
SAMPLE_NONE, // No digitized sounds will be played.
SAMPLE_SB, // Sound Blaster digitized driver.
SAMPLE_SBPRO, // Sound Blaster Pro digitized driver.
SAMPLE_PAS, // Pro-Audio Spectrum digitized driver.
SAMPLE_ADLIBG, // Adlib-Gold digitized driver.
SAMPLE_TANDY, // Tandy 'compatible' driver.
SAMPLE_PCSPKR, // PC speaker digitized driver (The Audio Solution driver).
SAMPLE_ADLIB, // Adlib digitized driver (The Audio Solution driver).
SAMPLE_TEMP=0x1000,
SAMPLE_LAST
} Sample_Type;
typedef enum {
SCORE_NONE, // No scores will be played.
SCORE_ALFX, // Westwood's ALFX adlib compatable driver.
SCORE_WWPCSPKR, // Westwood's PC-speaker driver (obsolete).
SCORE_WWTANDY, // Westwood's PC-speaker driver with Tandy mod (obsolete).
SCORE_PCSPKR, // PC speaker XMIDI driver.
SCORE_TANDY, // Tandy XMIDI driver.
SCORE_MT32, // MT-32 / LAPC-1 Roland XMIDI driver.
SCORE_CANVAS, // Sound Canvas SC-55.
SCORE_ADLIB, // Adlib XMIDI driver.
SCORE_ADLIBG, // Adlib Gold XMIDI driver.
SCORE_PASFM, // Pro Audio Spectrum XMIDI driver.
SCORE_SBFM, // Sound Blaster XMIDI driver.
SCORE_SBP1FM, // Sound Blaster Pro (YM3812) XMIDI driver.
SCORE_SBP2FM, // Sound Blaster Pro (OPL3) XMIDI driver (Can't use with SFX_ALFX).
SCORE_TEMP=0x1000,
SCORE_LAST
} Score_Type;
typedef enum {
SFX_NONE, // No sound effects will be played.
SFX_ALFX, // Westwood's ALFX adlib compatable driver.
SFX_WWPCSPKR, // Westwood's PC-speaker driver.
SFX_WWTANDY, // Westwood's PC-speaker driver with Tandy mod.
SFX_PCSPKR, // PC speaker XMIDI driver.
SFX_TANDY, // Tandy XMIDI driver.
SFX_MT32, // MT-32 / LAPC-1 Roland XMIDI driver.
SFX_CANVAS, // Sound Canvas SC-55.
SFX_ADLIB, // Adlib XMIDI driver.
SFX_ADLIBG, // Adlib Gold XMIDI driver.
SFX_PASFM, // Pro Audio Spectrum XMIDI driver.
SFX_SBFM, // Sound Blaster XMIDI driver.
SFX_SBP1FM, // Sound Blaster Pro (YM3812) XMIDI driver.
SFX_SBP2FM, // Sound Blaster Pro (OPL3) XMIDI driver.
SFX_TEMP=0x1000,
SFX_LAST
} SFX_Type;
/*=========================================================================*/
/* The following prototypes are for the file: SOUNDIO.CPP */
/*=========================================================================*/
int File_Stream_Sample(char const *filename, BOOL real_time_start = FALSE);
int File_Stream_Sample_Vol(char const *filename, int volume, BOOL real_time_start = FALSE);
void __cdecl Sound_Callback(void);
void __cdecl far maintenance_callback(void);
void *Load_Sample(char const *filename);
long Load_Sample_Into_Buffer(char const *filename, void *buffer, long size);
long Sample_Read(int fh, void *buffer, long size);
void Free_Sample(void const *sample);
BOOL Audio_Init( HWND window , int bits_per_sample, BOOL stereo , int rate , int reverse_channels);
void Sound_End(void);
void Stop_Sample(int handle);
BOOL Sample_Status(int handle);
BOOL Is_Sample_Playing(void const * sample);
void Stop_Sample_Playing(void const * sample);
int Play_Sample(void const *sample, int priority=0xFF, int volume=0xFF, signed short panloc = 0x0);
int Play_Sample_Handle(void const *sample, int priority, int volume, signed short panloc, int id);
int Set_Sound_Vol(int volume);
int Set_Score_Vol(int volume);
void Fade_Sample(int handle, int ticks);
int Get_Free_Sample_Handle(int priority);
int Get_Digi_Handle(void);
long Sample_Length(void const *sample);
void Restore_Sound_Buffers (void);
BOOL Set_Primary_Buffer_Format(void);
BOOL Start_Primary_Sound_Buffer (BOOL forced);
void Stop_Primary_Sound_Buffer (void);
/*
** Function to call if we detect focus loss
*/
extern void (*Audio_Focus_Loss_Function)(void);
extern int Misc;
extern SFX_Type SoundType;
extern Sample_Type SampleType;
extern CRITICAL_SECTION GlobalAudioCriticalSection;
extern int StreamLowImpact;

View file

@ -0,0 +1,128 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 32 Bit Library *
* *
* File Name : BUFFER.CPP *
* *
* Programmer : Phil W. Gorrow *
* *
* Start Date : May 18, 1994 *
* *
* Last Update : June 1, 1994 [PWG] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* BC::BufferClass -- The default (void) constructor for a buffer class *
* BC::~BufferClass -- The destructor for the buffer class *
* BC::BufferClass -- The standard constructor for a buffer class *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef BUFFER_H
#include "buffer.h"
#endif
/*=========================================================================*/
/* The following PRIVATE functions are in this file: */
/*=========================================================================*/
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
/***************************************************************************
* BC::BufferClass -- The standard constructor for a buffer class *
* *
* INPUT: VOID * buffer to which should be included in buffer class *
* LONG size of the buffer which we included *
* *
* OUTPUT: NONE *
* *
* WARNINGS: If the buffer passed to this function is equal to NULL, *
* the buffer will be allocated using new. *
* *
* HISTORY: *
* 06/01/1994 PWG : Created. *
*=========================================================================*/
BufferClass::BufferClass(VOID *buffer, LONG size)
{
Size = size; // find size of physical buffer
if (buffer) { // if buffer is specified
Buffer = (BYTE *)buffer; // point to it and mark
Allocated = FALSE; // it as user allocated
} else {
Buffer = new BYTE[Size]; // otherwise allocate it and
Allocated = TRUE; // mark it system alloced
}
}
/***************************************************************************
* BC::BufferClass -- constructor for BufferClass with size only *
* *
* INPUT: LONG the size of the buffer that needs to be allocated *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 06/01/1994 PWG : Created. *
*=========================================================================*/
BufferClass::BufferClass(LONG size)
{
Size = size;
Buffer = new BYTE[Size]; // otherwise allocate it and
Allocated = TRUE; // mark it system alloced
}
/***************************************************************************
* BC::BufferClass -- The default (void) constructor for a buffer class *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* NOTES: The primary function of this class is to be called by a *
* derived class which will fill in the values after the *
* fact. *
* *
* HISTORY: *
* 06/01/1994 PWG : Created. *
*=========================================================================*/
BufferClass::BufferClass(VOID)
{
Buffer = NULL;
Size = 0;
Allocated = FALSE;
}
/***************************************************************************
* BC::~BUFFERCLASS -- The destructor for the buffer class *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 06/01/1994 PWG : Created. *
*=========================================================================*/
BufferClass::~BufferClass(VOID)
{
if (Allocated) {
delete[] Buffer;
}
}

View file

@ -0,0 +1,121 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 32 Bit Library *
* *
* File Name : GBUFFER.H *
* *
* Programmer : Phil W. Gorrow *
* *
* Start Date : May 26, 1994 *
* *
* Last Update : July 5, 1994 [PWG] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* BC::Get_Size -- Returns the buffer size of the BufferClass instance *
* BC::Get_Buffer -- Returns pointer to buffer inherent to BufferClass *
* BC::BufferClass -- inline constructor for BufferClass with size only *
* BC::To_Page -- Copys a buffer class to a page with definable x, y, w, h*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef BUFFER_H
#define BUFFER_H
/*=========================================================================*/
/* If we have not already loaded the standard library header, than we can */
/* load it. */
/*=========================================================================*/
#ifndef WWSTD_H
#include "wwstd.h"
#endif
class GraphicViewPortClass;
/*=========================================================================*/
/* BufferClass - A base class which holds buffer information including a */
/* pointer and the size of the buffer. */
/*=========================================================================*/
class BufferClass {
public:
/*===================================================================*/
/* Define the base constructor and destructors for the class */
/*===================================================================*/
BufferClass(void *ptr, long size);
BufferClass(long size);
BufferClass();
~BufferClass();
/*===================================================================*/
/* Define functions which work with the buffer class. */
/*===================================================================*/
long To_Page(GraphicViewPortClass &view);
long To_Page(int w, int h, GraphicViewPortClass &view);
long To_Page(int x, int y, int w, int h, GraphicViewPortClass &view);
/*===================================================================*/
/* define functions to get at the protected data members */
/*===================================================================*/
void *Get_Buffer(void);
long Get_Size(void);
private:
/*===================================================================*/
/* Define the operators we do not want to happen which are the copy */
/* and equal constructors. These are bad because the Allocated flag */
/* could be copied and the associated buffer freed. If this were to */
/* gappen it could cause weird general protection fault. */
/*===================================================================*/
BufferClass(BufferClass const &);
BufferClass &operator=(BufferClass const &);
protected:
void *Buffer;
long Size;
BOOL Allocated;
};
/***************************************************************************
* BC::GET_SIZE -- Returns the buffer size of the BufferClass instance *
* *
* INPUT: none *
* *
* OUTPUT: long the size of the buffer *
* *
* HISTORY: *
* 06/01/1994 PWG : Created. *
*=========================================================================*/
inline long BufferClass::Get_Size(void)
{
return(Size);
}
/***************************************************************************
* BC::GET_BUFFER -- Returns pointer to buffer inherent to BufferClass *
* *
* INPUT: none *
* *
* OUTPUT: void * to the inherent buffer. *
* *
* HISTORY: *
* 06/01/1994 PWG : Created. *
*=========================================================================*/
inline void *BufferClass::Get_Buffer(void)
{
return(Buffer);
}
#endif

View file

@ -0,0 +1,80 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 32 bit Library *
* *
* File Name : BUFFGLBL.CPP *
* *
* Programmer : Phil W. Gorrow *
* *
* Start Date : January 10, 1995 *
* *
* Last Update : January 10, 1995 [PWG] *
* *
* This module holds the global fixup tables for the MCGA buffer class. *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "gbuffer.h"
/*=========================================================================*/
/* The following PRIVATE functions are in this file: */
/*=========================================================================*/
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
/*=========================================================================*/
/* Globals required by GraphicBufferClass for function pointers. These */
/* pointers will be set to the proper function when set mode is called. */
/*=========================================================================*/
BOOL (*GVPC_Blit_to_VVPC_Func)(void *, void *, int, int, int, int, int, int, BOOL);
BOOL (*GVPC_Scale_To_VVPC)( void *, void *, int, int, int, int, int, int, int, int, BOOL, char *);
#ifdef not_any_more_it_doesnt
/*=========================================================================*/
/* Globals required by VideoBufferClass for function pointers. These */
/* pointers will be set to the proper function when set mode is called. */
/*=========================================================================*/
void (*VVPC_Clear_Func)(void *, unsigned char);
long (*VVPC_To_Buffer_Func)(void *,int x, int y, int w, int h, void *buff, long size);
void (*VVPC_Put_Pixel_Func)(void *,int x, int y, unsigned char color);
int (*VVPC_Get_Pixel_Func)(void *, int x, int y);
long (*VVPC_Buffer_To_Page)(int x, int y, int w, int h, void *Buffer, void *view);
BOOL (*VVPC_Blit_to_GVPC_Func)(void *, void *, int, int, int, int, int, int, BOOL);
BOOL (*VVPC_Blit_to_VVPC_Func)(void *, void *, int, int, int, int, int, int, BOOL);
BOOL (*VVPC_Scale_To_GVPC)( void *, void *, int, int, int, int, int, int, int, int, BOOL, char *);
BOOL (*VVPC_Scale_To_VVPC)( void *, void *, int, int, int, int, int, int, int, int, BOOL, char *);
LONG (*VVPC_Print_Func)( void *, const char *, int, int, int, int);
void (*VVPC_Draw_Stamp)(void *, void *, int, int, int, void *);
long (*VVPC_Size_Of_Region)(void *, int, int);
#endif //not_any_more_it_doesnt
/*=========================================================================*/
/* We need to keep a pointer to the logic page hanging around somewhere */
/*=========================================================================*/
GraphicViewPortClass *LogicPage;
BOOL IconCacheAllowed = TRUE;
/*
** Pointer to a function we will call if we detect loss of focus
*/
void (*Gbuffer_Focus_Loss_Function)(void) = NULL;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,36 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WWLIB32 Example *
* *
* File Name : DEFINES.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : August 3, 1994 *
* *
* Last Update : August 3, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define USER_TIMER_FREQ 60

View file

@ -0,0 +1,90 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WWLIB32 library *
* *
* File Name : DESCMGMT.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : August 3, 1994 *
* *
* Last Update : August 3, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef DESCMGMT_H
#define DESCMGMT_H
#ifndef WWSTD_H
#include "wwstd.h"
#endif
//=====================================================================
// C type include files
#ifdef __cplusplus
extern "C" {
#endif
#include <dos.h>
#include <bios.h>
#ifdef __cplusplus
}
#endif
// ====================================================================
// types
// These where taken from dos.h
//==========================================
// external functions
// ===================================================
extern ULONG Map_Segment_To_Address(ULONG address, ULONG length);
extern "C" {
// Assemble functions
extern UWORD FixSelector(UWORD sel);
extern UWORD GetDs(void);
extern UWORD GetCs(void);
extern VOID GetDefaultSelectors(VOID);
extern UWORD Get_Standard_Selector(void);
// Assembly data variables
extern UWORD CodeSelector;
extern UWORD DataSelector;
extern UWORD ScreenSelector;
extern UWORD GraphicsSelector;
extern UWORD PspSelector;
extern UWORD EnvSelector;
extern UWORD DosMemSelector;
extern UWORD Fp1167Selector;
extern UWORD FpWeitekSelector;
extern UWORD FpCyrixSelector;
}
#endif // DESCMGMT_H


File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,325 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $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;
char temp;
src = source;
while (*src) {
if (*src == KA_EXTEND) {
src++;
temp = *src++;
temp += 127;
*dest++ = temp;
} 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 common, // Common character index.
dipthong; // Dipthong character index.
unsigned long length=0; // Length of output string
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++ = (char)KA_EXTEND;
first -= 127;
length++;
} 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);
first |= (unsigned char)dipthong;
first |= (unsigned char)0x80;
source++;
}
}
}
}
}
/*
** Output the translated character to the destination buffer.
*/
*dest++ = first;
length++;
first = *source++;
next = *source;
}
*dest = '\0';
return(length);
}
/***************************************************************************
* 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. *
*=========================================================================*/
#define TXT_GUEST 4567+3
#define TXT_LOGIN 4567+4
#define TXT_LOGIN_TO_INTERNET 4567+5
#define TXT_YOUR_HANDLE 4567+6
#define TXT_YOUR_PASSWORD 4567+7
#define TXT_INTERNET_HOST 4567+8
#define TXT_INTERNET_JOIN 4567+9
#define TXT_INTERNET_GAME_TYPE 4567+10
#define TXT_JOIN_INTERNET_GAME 4567+11
#define TXT_ENTER_IP_ADDRESS 4567+12
#define TXT_WINSOCK_CONNECTING 4567+13
#define TXT_WINSOCK_NOT_CONNECTING 4567+14
#define TXT_WINSOCK_UNABLE_TO_CONNECT_TO_SERVER 4567+15
#define TXT_WINSOCK_CONTACTING_SERVER 4567+16
#define TXT_WINSOCK_SERVER_ADDRESS_LOOKUP_FAILED 4567+17
#define TXT_WINSOCK_UNABLE_TO_ACCEPT_CLIENT 4567+18
#define TXT_WINSOCK_UNABLE_TO_CONNECT 4567+19
#define TXT_WINSOCK_CONNECTION_LOST 4567+20
#define TXT_WINSOCK_RESOLVING_HOST_ADDRESS 4567+21
static char InternetTxt[22][40]={
"Internet H2H",
"Host Internet Game",
"Join Internet Game",
"Guest",
"Login",
"Login to Planet Westwood",
"Planet Westwood Handle",
"Planet Westwood Password",
"Host Game",
"Join Game",
"Choose Type of Internet Game",
"Join Internet Game",
"Address of Host",
"Connecting...",
"Connection Error!",
"Unable to connect to host!",
"Connecting to host...",
"Unable to resolve host address!",
"Unable to accept client connection",
"Unable to connect!",
"Connection lost!",
"Resolving address of host..."
};
char *Extract_String(void const *data, int string)
{
unsigned short int const *ptr;
if (!data || string < 0) return(NULL);
if (string >= 4567) return (InternetTxt[string-4567]);
ptr = (unsigned short int const *)data;
return (((char*)data) + ptr[string]);
}

View file

@ -0,0 +1,21 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
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];

View file

@ -0,0 +1,323 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/*==========================================================================;
*
* Copyright (C) 1994-1995 Microsoft Corporation. All Rights Reserved.
*
* File: dplay.h
* Content: DirectPlay include file
*
***************************************************************************/
#ifndef __DPLAY_INCLUDED__
#define __DPLAY_INCLUDED__
#ifdef _WIN32
/* for DECLARE_INTERFACE and HRESULT. */
#include <ole2.h>
#endif
#define _FACDP 0x877
#define MAKE_DPHRESULT( code ) MAKE_HRESULT( 1, _FACDP, code )
#ifdef __cplusplus
extern "C" {
#endif
#pragma pack(push, 1)
/*============================================================================
*
* DirectPlay Structures
*
* Various structures used to invoke DirectPlay.
*
*==========================================================================*/
#ifdef __cplusplus
/* 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined */
struct IDirectPlay;
typedef struct IDirectPlay FAR *LPDIRECTPLAY;
#else
typedef struct IDirectPlay FAR *LPDIRECTPLAY;
#endif
typedef DWORD DPID, FAR *LPDPID;
typedef struct _DPCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwMaxBufferSize;
DWORD dwMaxQueueSize; // Function of DPlay, not SP.
DWORD dwMaxPlayers;
DWORD dwHundredBaud; // 24 is 2400, 96 is 9600, etc.
DWORD dwLatency;
} DPCAPS;
typedef DPCAPS FAR *LPDPCAPS;
#define DPLONGNAMELEN 52
#define DPSHORTNAMELEN 20
#define DPSESSIONNAMELEN 32
#define DPPASSWORDLEN 16
#define DPUSERRESERVED 16
typedef struct
{
DWORD dwSize;
GUID guidSession; // Id for Game. Null is all games.
DWORD dwSession; // session identifier
DWORD dwMaxPlayers; // Maximum players allowed in game.
DWORD dwCurrentPlayers; // Current players in Game.
DWORD dwFlags; // DPOPEN_* flags
char szSessionName[DPSESSIONNAMELEN];// Human readable name for Game
char szUserField[DPUSERRESERVED];
DWORD dwReserved1; // Reserved for future MS use.
char szPassword[DPPASSWORDLEN]; // Password to be allowed into game.
DWORD dwReserved2; // Reserved for future MS use.
DWORD dwUser1;
DWORD dwUser2;
DWORD dwUser3;
DWORD dwUser4;
} DPSESSIONDESC;
typedef DPSESSIONDESC FAR *LPDPSESSIONDESC;
/*
* Create API
*/
typedef BOOL (FAR PASCAL * LPDPENUMDPCALLBACK)(
LPGUID lpSPGuid,
LPSTR lpFriendlyName,
DWORD dwMajorVersion,
DWORD dwMinorVersion,
LPVOID lpContext);
typedef BOOL (FAR PASCAL * LPDPENUMSESSIONSCALLBACK)(
LPDPSESSIONDESC lpDPSGameDesc,
LPVOID lpContext,
LPDWORD lpdwTimeOut,
DWORD dwFlags);
extern HRESULT WINAPI DirectPlayCreate( LPGUID lpGUID, LPDIRECTPLAY FAR *lplpDP, IUnknown FAR *pUnk);
extern HRESULT WINAPI DirectPlayEnumerate( LPDPENUMDPCALLBACK, LPVOID );
/* Player enumeration callback prototype */
typedef BOOL (FAR PASCAL *LPDPENUMPLAYERSCALLBACK)(
DPID dpId,
LPSTR lpFriendlyName,
LPSTR lpFormalName,
DWORD dwFlags,
LPVOID lpContext );
/*
* IDirectPlay
*/
#undef INTERFACE
#define INTERFACE IDirectPlay
#ifdef _WIN32
DECLARE_INTERFACE_( IDirectPlay, IUnknown )
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDirectPlay methods ***/
STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE;
STDMETHOD(Close) (THIS) PURE;
STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPSTR,LPSTR,LPHANDLE) PURE;
STDMETHOD(CreateGroup) (THIS_ LPDPID,LPSTR,LPSTR) PURE;
STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE;
STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE;
STDMETHOD(DestroyGroup) (THIS_ DPID) PURE;
STDMETHOD(EnableNewPlayers) (THIS_ BOOL) PURE;
STDMETHOD(EnumGroupPlayers) (THIS_ DPID, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE;
STDMETHOD(EnumGroups) (THIS_ DWORD, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE;
STDMETHOD(EnumPlayers) (THIS_ DWORD, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE;
STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC,DWORD,LPDPENUMSESSIONSCALLBACK,LPVOID,DWORD) PURE;
STDMETHOD(GetCaps) (THIS_ LPDPCAPS) PURE;
STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE;
STDMETHOD(GetPlayerCaps) (THIS_ DPID, LPDPCAPS) PURE;
STDMETHOD(GetPlayerName) (THIS_ DPID,LPSTR,LPDWORD,LPSTR,LPDWORD) PURE;
STDMETHOD(Initialize) (THIS_ LPGUID) PURE;
STDMETHOD(Open) (THIS_ LPDPSESSIONDESC) PURE;
STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE;
STDMETHOD(SaveSession) (THIS_ LPSTR) PURE;
STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE;
STDMETHOD(SetPlayerName) (THIS_ DPID,LPSTR,LPSTR) PURE;
};
#endif
/****************************************************************************
*
* DIRECTPLAY ERRORS
*
* Errors are represented by negative values and cannot be combined.
*
****************************************************************************/
#define DP_OK 0
#define DPERR_ALREADYINITIALIZED MAKE_DPHRESULT( 5 )
#define DPERR_ACCESSDENIED MAKE_DPHRESULT( 10 )
#define DPERR_ACTIVEPLAYERS MAKE_DPHRESULT( 20 )
#define DPERR_BUFFERTOOSMALL MAKE_DPHRESULT( 30 )
#define DPERR_CANTADDPLAYER MAKE_DPHRESULT( 40 )
#define DPERR_CANTCREATEGROUP MAKE_DPHRESULT( 50 )
#define DPERR_CANTCREATEPLAYER MAKE_DPHRESULT( 60 )
#define DPERR_CANTCREATESESSION MAKE_DPHRESULT( 70 )
#define DPERR_CAPSNOTAVAILABLEYET MAKE_DPHRESULT( 80 )
#define DPERR_EXCEPTION MAKE_DPHRESULT( 90 )
#define DPERR_GENERIC E_FAIL
#define DPERR_INVALIDFLAGS MAKE_DPHRESULT( 120 )
#define DPERR_INVALIDOBJECT MAKE_DPHRESULT( 130 )
#define DPERR_INVALIDPARAM E_INVALIDARG
#define DPERR_INVALIDPARAMS DPERR_INVALIDPARAM
#define DPERR_INVALIDPLAYER MAKE_DPHRESULT( 150 )
#define DPERR_NOCAPS MAKE_DPHRESULT( 160 )
#define DPERR_NOCONNECTION MAKE_DPHRESULT( 170 )
#define DPERR_NOMEMORY E_OUTOFMEMORY
#define DPERR_OUTOFMEMORY DPERR_NOMEMORY
#define DPERR_NOMESSAGES MAKE_DPHRESULT( 190 )
#define DPERR_NONAMESERVERFOUND MAKE_DPHRESULT( 200 )
#define DPERR_NOPLAYERS MAKE_DPHRESULT( 210 )
#define DPERR_NOSESSIONS MAKE_DPHRESULT( 220 )
#define DPERR_SENDTOOBIG MAKE_DPHRESULT( 230 )
#define DPERR_TIMEOUT MAKE_DPHRESULT( 240 )
#define DPERR_UNAVAILABLE MAKE_DPHRESULT( 250 )
#define DPERR_UNSUPPORTED E_NOTIMPL
#define DPERR_BUSY MAKE_DPHRESULT( 270 )
#define DPERR_USERCANCEL MAKE_DPHRESULT( 280 )
#define DPOPEN_OPENSESSION 0x00000001
#define DPOPEN_CREATESESSION 0x00000002
#define DPSEND_GUARANTEE 0x00000001
#define DPSEND_HIGHPRIORITY 0x00000002
#define DPSEND_TRYONCE 0x00000004
#define DPRECEIVE_ALL 0x00000001
#define DPRECEIVE_TOPLAYER 0x00000002
#define DPRECEIVE_FROMPLAYER 0x00000004
#define DPRECEIVE_PEEK 0x00000008
#define DPCAPS_NAMESERVICE 0x00000001 // A name server is supported.
#define DPCAPS_NAMESERVER 0x00000002 // You are the name server.
#define DPCAPS_GUARANTEED 0x00000004 // SP's don't have to implement guarantees.
#define DPENUMSESSIONS_AVAILABLE 0x00000001 // All games that match password (if given)
// and have openings.
#define DPENUMSESSIONS_ALL 0x00000002
#define DPENUMSESSIONS_PREVIOUS 0x00000004
#define DPENUMPLAYERS_ALL 0x00000000
#define DPENUMPLAYERS_PREVIOUS 0x00000004
#define DPENUMPLAYERS_LOCAL 0x00000008
#define DPENUMPLAYERS_REMOTE 0x00000010
#define DPENUMPLAYERS_GROUP 0x00000020
#define DPENUMPLAYERS_SESSION 0x00000080
//
// This flag is set on the enumsessions callback when the time out has occured.
// This means that there is no session data for this callback.
// If lpdwTimeOut is set to a non-zero value and the EnumSessionsCallback returns
// TRUE then EnumSessions will continue until the next timeout occurs.
// Timeouts are in milliseconds.
#define DPESC_TIMEDOUT 0x00000001
//
// System message structures and types.
//
// System messages have a leading 4 byte type code to identify the message.
// an app knows it is a system message because it is addressed 'To' player 0.
//
#define DPSYS_ADDPLAYER 0x0003 // DPMSG_ADDPLAYER
#define DPSYS_DELETEPLAYER 0x0005 // DPMSG_DELETEPLAYER
#define DPSYS_ADDPLAYERTOGROUP 0x0007 // DPMSG_GROUPADD
#define DPSYS_INVITE 0x000e // DPMSG_INVITE, Net only.
#define DPSYS_DELETEGROUP 0x0020 // DPMSG_DELETEPLAYER
#define DPSYS_DELETEPLAYERFROMGRP 0x0021 // DPMSG_GROUPDELETE
#define DPSYS_SESSIONLOST 0x0031
#define DPSYS_CONNECT 0x484b // DPMSG_GENERIC
typedef struct
{
DWORD dwType;
DWORD dwPlayerType;
DPID dpId;
char szLongName[DPLONGNAMELEN];
char szShortName[DPSHORTNAMELEN];
DWORD dwCurrentPlayers;
} DPMSG_ADDPLAYER;
typedef DPMSG_ADDPLAYER DPMSG_ADDGROUP;
typedef struct
{
DWORD dwType;
DPID dpIdGroup;
DPID dpIdPlayer;
} DPMSG_GROUPADD;
typedef DPMSG_GROUPADD DPMSG_GROUPDELETE;
typedef struct
{
DWORD dwType;
DPID dpId;
} DPMSG_DELETEPLAYER;
typedef struct
{
DWORD dwType;
DPSESSIONDESC dpsDesc;
} DPMSG_INVITE;
typedef struct
{
DWORD dwType;
} DPMSG_GENERIC;
#pragma pack(pop)
DEFINE_GUID( IID_IDirectPlay, 0x5454e9a0, 0xdb65, 0x11ce, 0x92, 0x1c, 0x00, 0xaa, 0x00, 0x6c, 0x49, 0x72);
#ifdef __cplusplus
};
#endif
#endif

View file

@ -0,0 +1,64 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
#ifndef DRAWBUFF_H
#define DRAWBUFF_H
#ifndef WWSTD_H
#include "wwstd.h"
#endif
class GraphicViewPortClass;
class GraphicBufferClass;
/*=========================================================================*/
/* Define functions which have not under-gone name mangling */
/*=========================================================================*/
extern "C" {
/*======================================================================*/
/* Externs for all of the common functions between the video buffer */
/* class and the graphic buffer class. */
/*======================================================================*/
long __cdecl Buffer_Size_Of_Region(void *thisptr, int w, int h);
void __cdecl Buffer_Put_Pixel(void * thisptr, int x, int y, unsigned char color);
int __cdecl Buffer_Get_Pixel(void * thisptr, int x, int y);
void __cdecl Buffer_Clear(void *thisptr, unsigned char color);
long __cdecl Buffer_To_Buffer(void *thisptr, int x, int y, int w, int h, void *buff, long size);
long __cdecl Buffer_To_Page(int x, int y, int w, int h, void *Buffer, void *view);
BOOL __cdecl Linear_Blit_To_Linear( void *thisptr, void * dest, int x_pixel, int y_pixel, int dx_pixel,
int dy_pixel, int pixel_width, int pixel_height, BOOL trans);
BOOL __cdecl Linear_Scale_To_Linear( void *, void *, int, int, int, int, int, int, int, int, BOOL, char *);
LONG __cdecl Buffer_Print(void *thisptr, const char *str, int x, int y, int fcolor, int bcolor);
/*======================================================================*/
/* Externs for all of the graphic buffer class only functions */
/*======================================================================*/
VOID __cdecl Buffer_Draw_Line(void *thisptr, int sx, int sy, int dx, int dy, unsigned char color);
VOID __cdecl Buffer_Fill_Rect(void *thisptr, int sx, int sy, int dx, int dy, unsigned char color);
VOID __cdecl Buffer_Remap(void * thisptr, int sx, int sy, int width, int height, void *remap);
VOID __cdecl Buffer_Fill_Quad(void * thisptr, VOID *span_buff, int x0, int y0, int x1, int y1,
int x2, int y2, int x3, int y3, int color);
void __cdecl Buffer_Draw_Stamp(void const *thisptr, void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap);
void __cdecl Buffer_Draw_Stamp_Clip(void const *thisptr, void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap, int ,int,int,int);
void * __cdecl Get_Font_Palette_Ptr ( void );
}
extern GraphicViewPortClass *LogicPage;
extern BOOL AllowHardwareBlitFills;
#endif

View file

@ -0,0 +1,90 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 32 bit Library *
;* *
;* File Name : DRAWBUFF.INC *
;* *
;* Programmer : Phil W. Gorrow *
;* *
;* Start Date : January 16, 1995 *
;* *
;* Last Update : January 16, 1995 [PWG] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
; Externs from REGIONSZ.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Size_Of_Region :NEAR
; Externs from GETPIX.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Get_Pixel :NEAR
; Externs from PUTPIX.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Put_Pixel :NEAR
; Externs from CLEAR.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Clear :NEAR
; Externs from BITBLIT.ASM module of the DRAWBUFF library
GLOBAL C Linear_Blit_To_Linear :NEAR
; Externs from TOBUFF.ASM module of the DRAWBUFF library
GLOBAL C Buffer_To_Buffer :NEAR
; Externs from TOPAGE.ASM module of the DRAWBUFF library
GLOBAL C Buffer_To_Page :NEAR
; Externs from SCALE.ASM module of the DRAWBUFF library
GLOBAL C Linear_Scale_To_Linear :NEAR
; Externs from TXTPRNT.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Print :NEAR
;*-------------------------------------------------------------------------*
;* Define Buffer only assembly GLOBALS *
;*-------------------------------------------------------------------------*
; Externs from DRAWLINE.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Draw_Line:NEAR
; Externs from FILLQUAD.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Fill_Quad :NEAR
; Externs from FILLRECT.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Fill_Rect :NEAR
; Externs from REMAP.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Remap :NEAR
; Externs from STAMP.ASM module of the DRAWBUFF library
GLOBAL C Buffer_Draw_Stamp :NEAR
GLOBAL C get_clip : NEAR
struc RECTANGLE
x0 dd ?
y0 dd ?
x1 dd ?
y1 dd ?
ends RECTANGLE

View file

@ -0,0 +1,69 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 32 Bit Library *
* *
* File Name : DRAWRECT.C *
* *
* Programmer : Christopher Yates *
* *
* Last Update : August 20, 1993 [JLB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Draw_Rect -- Draws a rectangle to the LogicPage. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef GBUFFER_H
#include "gbuffer.h"
#include "misc.h"
#endif
/***************************************************************************
* Draw_Rect -- Draws a rectangle to the LogicPage. *
* *
* This routine will draw a rectangle to the LogicPage. The rectangle *
* doesn't have to be aligned on the vertical or horizontal axis. In *
* fact, it doesn't even have to be a rectangle. The "square" can be *
* skewed. *
* *
* INPUT: x1_pixel, y1_pixel -- One corner. *
* *
* x2_pixel, y2_pixel -- The other corner. *
* *
* color -- The color to draw the lines. *
* *
* OUTPUT: none *
* *
* WARNINGS: None, but the rectangle will be clipped to the current *
* draw line clipping rectangle. *
* *
* HISTORY: *
* 08/20/1993 JLB : Created. *
*=========================================================================*/
VOID GraphicViewPortClass::Draw_Rect(int x1_pixel, int y1_pixel, int x2_pixel, int y2_pixel, unsigned char color)
{
Lock();
Draw_Line(x1_pixel, y1_pixel, x2_pixel, y1_pixel, color);
Draw_Line(x1_pixel, y2_pixel, x2_pixel, y2_pixel, color);
Draw_Line(x1_pixel, y1_pixel, x1_pixel, y2_pixel, color);
Draw_Line(x2_pixel, y1_pixel, x2_pixel, y2_pixel, color);
Unlock();
}

View file

@ -0,0 +1,71 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/*==========================================================================
*
* Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
*
* File: dsetup.h
* Content: DirectXSetup, error codes and flags
***************************************************************************/
#ifndef __DSETUP_H__
#define __DSETUP_H__
#ifdef _WIN32
#define COM_NO_WINDOWS_H
#include <objbase.h>
#else
#define GUID void
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define DSETUPERR_BADWINDOWSVERSION -1
#define DSETUPERR_SOURCEFILENOTFOUND -2
#define DSETUPERR_BADSOURCESIZE -3
#define DSETUPERR_BADSOURCETIME -4
#define DSETUPERR_NOCOPY -5
#define DSETUPERR_OUTOFDISKSPACE -6
#define DSETUPERR_CANTFINDINF -7
#define DSETUPERR_CANTFINDDIR -8
#define DSETUPERR_INTERNAL -9
#define MAX_INFLINE (16*1024)
#define MAX_DESCRIPTION 256
#define DSETUP_DDRAW 0x00000001 /* install DirectDraw */
#define DSETUP_DSOUND 0x00000002 /* install DirectSound */
#define DSETUP_DPLAY 0x00000004 /* install DirectPlay */
#define DSETUP_DDRAWDRV 0x00000008 /* install DirectDraw Drivers */
#define DSETUP_DSOUNDDRV 0x00000010 /* install DirectSound Drivers */
#define DSETUP_DPLAYSP 0x00000020 /* install DirectPlay Providers */
#define DSETUP_DIRECTX DSETUP_DDRAW | DSETUP_DSOUND | DSETUP_DPLAY | DSETUP_DDRAWDRV | DSETUP_DSOUNDDRV | DSETUP_DPLAYSP
#define DSETUP_REINSTALL 0x00000080 /* install DirectX even if existing components have the same version */
int WINAPI DirectXSetup( HWND hwnd, LPSTR root_path, DWORD flags );
int WINAPI DirectXDeviceDriverSetup( HWND hwnd, LPSTR driver_class, LPSTR inf_path, LPSTR driver_path, DWORD flags );
typedef int (WINAPI * LPDIRECTXSETUP)( HWND, LPSTR, DWORD );
typedef int (WINAPI * LPDIRECTXDEVICEDRIVERSETUP)( HWND, LPSTR, LPSTR, LPSTR, DWORD );
#ifdef __cplusplus
};
#endif
#endif

View file

@ -0,0 +1,380 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/*==========================================================================;
*
* Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
*
* File: dsound.h
* Content: DirectSound include file
*
***************************************************************************/
#ifndef __DSOUND_INCLUDED__
#define __DSOUND_INCLUDED__
#ifdef _WIN32
#define COM_NO_WINDOWS_H
#include <objbase.h>
#endif
#define _FACDS 0x878
#define MAKE_DSHRESULT( code ) MAKE_HRESULT( 1, _FACDS, code )
#ifdef __cplusplus
extern "C" {
#endif
// Direct Sound Component GUID {47D4D946-62E8-11cf-93BC-444553540000}
DEFINE_GUID(CLSID_DirectSound,
0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
// DirectSound 279afa83-4981-11ce-a521-0020af0be560
DEFINE_GUID(IID_IDirectSound,0x279AFA83,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
// DirectSoundBuffer 279afa85-4981-11ce-a521-0020af0be560
DEFINE_GUID(IID_IDirectSoundBuffer,0x279AFA85,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
//==========================================================================;
//
// Structures...
//
//==========================================================================;
#ifdef __cplusplus
/* 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined */
struct IDirectSound;
struct IDirectSoundBuffer;
#endif
typedef struct IDirectSound *LPDIRECTSOUND;
typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER;
typedef struct IDirectSoundBuffer **LPLPDIRECTSOUNDBUFFER;
typedef struct _DSCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwMinSecondarySampleRate;
DWORD dwMaxSecondarySampleRate;
DWORD dwPrimaryBuffers;
DWORD dwMaxHwMixingAllBuffers;
DWORD dwMaxHwMixingStaticBuffers;
DWORD dwMaxHwMixingStreamingBuffers;
DWORD dwFreeHwMixingAllBuffers;
DWORD dwFreeHwMixingStaticBuffers;
DWORD dwFreeHwMixingStreamingBuffers;
DWORD dwMaxHw3DAllBuffers;
DWORD dwMaxHw3DStaticBuffers;
DWORD dwMaxHw3DStreamingBuffers;
DWORD dwFreeHw3DAllBuffers;
DWORD dwFreeHw3DStaticBuffers;
DWORD dwFreeHw3DStreamingBuffers;
DWORD dwTotalHwMemBytes;
DWORD dwFreeHwMemBytes;
DWORD dwMaxContigFreeHwMemBytes;
DWORD dwUnlockTransferRateHwBuffers;
DWORD dwPlayCpuOverheadSwBuffers;
DWORD dwReserved1;
DWORD dwReserved2;
} DSCAPS, *LPDSCAPS;
typedef struct _DSBCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwUnlockTransferRate;
DWORD dwPlayCpuOverhead;
} DSBCAPS, *LPDSBCAPS;
typedef struct _DSBUFFERDESC
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwReserved;
LPWAVEFORMATEX lpwfxFormat;
} DSBUFFERDESC, *LPDSBUFFERDESC;
typedef LPVOID* LPLPVOID;
typedef BOOL (FAR PASCAL * LPDSENUMCALLBACKW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID);
typedef BOOL (FAR PASCAL * LPDSENUMCALLBACKA)(GUID FAR *, LPSTR, LPSTR, LPVOID);
extern HRESULT WINAPI DirectSoundCreate(GUID FAR * lpGUID, LPDIRECTSOUND * ppDS, IUnknown FAR *pUnkOuter );
extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW lpCallback, LPVOID lpContext );
extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA lpCallback, LPVOID lpContext );
#ifdef UNICODE
#define LPDSENUMCALLBACK LPDSENUMCALLBACKW
#define DirectSoundEnumerate DirectSoundEnumerateW
#else
#define LPDSENUMCALLBACK LPDSENUMCALLBACKA
#define DirectSoundEnumerate DirectSoundEnumerateA
#endif
//
// IDirectSound
//
#undef INTERFACE
#define INTERFACE IDirectSound
#ifdef _WIN32
DECLARE_INTERFACE_( IDirectSound, IUnknown )
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDirectSound methods ***/
STDMETHOD( CreateSoundBuffer)(THIS_ LPDSBUFFERDESC, LPLPDIRECTSOUNDBUFFER, IUnknown FAR *) PURE;
STDMETHOD( GetCaps)(THIS_ LPDSCAPS ) PURE;
STDMETHOD( DuplicateSoundBuffer)(THIS_ LPDIRECTSOUNDBUFFER, LPLPDIRECTSOUNDBUFFER ) PURE;
STDMETHOD( SetCooperativeLevel)(THIS_ HWND, DWORD ) PURE;
STDMETHOD( Compact)(THIS ) PURE;
STDMETHOD( GetSpeakerConfig)(THIS_ LPDWORD ) PURE;
STDMETHOD( SetSpeakerConfig)(THIS_ DWORD ) PURE;
STDMETHOD( Initialize)(THIS_ GUID FAR * ) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSound_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSound_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c)
#define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b)
#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
#define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p)
#define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a)
#define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b)
#define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
#endif
#endif
//
// IDirectSoundBuffer
//
#undef INTERFACE
#define INTERFACE IDirectSoundBuffer
#ifdef _WIN32
DECLARE_INTERFACE_( IDirectSoundBuffer, IUnknown )
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDirectSoundBuffer methods ***/
STDMETHOD( GetCaps)(THIS_ LPDSBCAPS ) PURE;
STDMETHOD(GetCurrentPosition)(THIS_ LPDWORD,LPDWORD ) PURE;
STDMETHOD( GetFormat)(THIS_ LPWAVEFORMATEX, DWORD, LPDWORD ) PURE;
STDMETHOD( GetVolume)(THIS_ LPLONG ) PURE;
STDMETHOD( GetPan)(THIS_ LPLONG ) PURE;
STDMETHOD( GetFrequency)(THIS_ LPDWORD ) PURE;
STDMETHOD( GetStatus)(THIS_ LPDWORD ) PURE;
STDMETHOD( Initialize)(THIS_ LPDIRECTSOUND, LPDSBUFFERDESC ) PURE;
STDMETHOD( Lock)(THIS_ DWORD,DWORD,LPVOID,LPDWORD,LPVOID,LPDWORD,DWORD ) PURE;
STDMETHOD( Play)(THIS_ DWORD,DWORD,DWORD ) PURE;
STDMETHOD(SetCurrentPosition)(THIS_ DWORD ) PURE;
STDMETHOD( SetFormat)(THIS_ LPWAVEFORMATEX ) PURE;
STDMETHOD( SetVolume)(THIS_ LONG ) PURE;
STDMETHOD( SetPan)(THIS_ LONG ) PURE;
STDMETHOD( SetFrequency)(THIS_ DWORD ) PURE;
STDMETHOD( Stop)(THIS ) PURE;
STDMETHOD( Unlock)(THIS_ LPVOID,DWORD,LPVOID,DWORD ) PURE;
STDMETHOD( Restore)(THIS ) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSoundBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSoundBuffer_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b)
#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c)
#define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a)
#define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a)
#define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a)
#define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a)
#define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g)
#define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c)
#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a)
#define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a)
#define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a)
#define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a)
#define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a)
#define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p)
#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d)
#define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p)
#endif
#endif
/*
* Return Codes
*/
#define DS_OK 0
/*
* The call failed because resources (such as a priority level)
* were already being used by another caller.
*/
#define DSERR_ALLOCATED MAKE_DSHRESULT( 10 )
/*
* The control (vol,pan,etc.) requested by the caller is not available.
*/
#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT( 30 )
/*
* An invalid parameter was passed to the returning function
*/
#define DSERR_INVALIDPARAM E_INVALIDARG
/*
* This call is not valid for the current state of this object
*/
#define DSERR_INVALIDCALL MAKE_DSHRESULT( 50 )
/*
* An undetermined error occured inside the DSound subsystem
*/
#define DSERR_GENERIC E_FAIL
/*
* The caller does not have the priority level required for the function to
* succeed.
*/
#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT( 70 )
/*
* The DSound subsystem couldn't allocate sufficient memory to complete the
* caller's request.
*/
#define DSERR_OUTOFMEMORY E_OUTOFMEMORY
/*
* The specified WAVE format is not supported
*/
#define DSERR_BADFORMAT MAKE_DSHRESULT( 100 )
/*
* The function called is not supported at this time
*/
#define DSERR_UNSUPPORTED E_NOTIMPL
/*
* No sound driver is available for use
*/
#define DSERR_NODRIVER MAKE_DSHRESULT( 120 )
/*
* This object is already initialized
*/
#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT( 130 )
/*
* This object does not support aggregation
*/
#define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION
/*
* The buffer memory has been lost, and must be Restored.
*/
#define DSERR_BUFFERLOST MAKE_DSHRESULT( 150 )
/*
* Another app has a higher priority level, preventing this call from
* succeeding.
*/
#define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT( 160 )
/*
* The Initialize() member on the Direct Sound Object has not been
* called or called successfully before calls to other members.
*/
#define DSERR_UNINITIALIZED MAKE_DSHRESULT( 170 )
//==========================================================================;
//
// Flags...
//
//==========================================================================;
#define DSCAPS_PRIMARYMONO 0x00000001
#define DSCAPS_PRIMARYSTEREO 0x00000002
#define DSCAPS_PRIMARY8BIT 0x00000004
#define DSCAPS_PRIMARY16BIT 0x00000008
#define DSCAPS_CONTINUOUSRATE 0x00000010
#define DSCAPS_EMULDRIVER 0x00000020
#define DSCAPS_CERTIFIED 0x00000040
#define DSCAPS_SECONDARYMONO 0x00000100
#define DSCAPS_SECONDARYSTEREO 0x00000200
#define DSCAPS_SECONDARY8BIT 0x00000400
#define DSCAPS_SECONDARY16BIT 0x00000800
#define DSBPLAY_LOOPING 0x00000001
#define DSBSTATUS_PLAYING 0x00000001
#define DSBSTATUS_BUFFERLOST 0x00000002
#define DSBSTATUS_LOOPING 0x00000004
#define DSBLOCK_FROMWRITECURSOR 0x00000001
#define DSSCL_NORMAL 1
#define DSSCL_PRIORITY 2
#define DSSCL_EXCLUSIVE 3
#define DSSCL_WRITEPRIMARY 4
#define DSBCAPS_PRIMARYBUFFER 0x00000001
#define DSBCAPS_STATIC 0x00000002
#define DSBCAPS_LOCHARDWARE 0x00000004
#define DSBCAPS_LOCSOFTWARE 0x00000008
#define DSBCAPS_CTRLFREQUENCY 0x00000020
#define DSBCAPS_CTRLPAN 0x00000040
#define DSBCAPS_CTRLVOLUME 0x00000080
#define DSBCAPS_CTRLDEFAULT 0x000000E0 // Pan + volume + frequency.
#define DSBCAPS_CTRLALL 0x000000E0 // All control capabilities
#define DSBCAPS_STICKYFOCUS 0x00004000
#define DSSPEAKER_HEADPHONE 1
#define DSSPEAKER_MONO 2
#define DSSPEAKER_QUAD 3
#define DSSPEAKER_STEREO 4
#define DSSPEAKER_SURROUND 5
#ifdef __cplusplus
};
#endif
#endif /* __DSOUND_INCLUDED__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,37 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WWLIB32 Example *
* *
* File Name : EXTERNS.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : August 3, 1994 *
* *
* Last Update : August 3, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
extern char NoTimer;
extern char NoKeyBoard;

View file

@ -0,0 +1,162 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 : Support Library *
;* *
;* File Name : FACINGFF.ASM *
;* *
;* Programmer : Joe L. Bostic *
;* *
;* Start Date : May 8, 1991 *
;* *
;* Last Update : February 6, 1995 [BWG] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Desired_Facing256 -- Determines facing to reach a position. *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;IDEAL
;P386
;MODEL USE32 FLAT
GLOBAL C Desired_Facing256 :NEAR
; INCLUDE "wwlib.i"
INCLUDE "..\include\gbuffer.inc"
CODESEG
;***************************************************************************
;* Desired_Facing256 -- Desired facing algorithm 0..255 resolution. *
;* *
;* This is a desired facing algorithm that has a resolution of 0 *
;* through 255. *
;* *
;* INPUT: srcx,srcy -- Source coordinate. *
;* *
;* dstx,dsty -- Destination coordinate. *
;* *
;* OUTPUT: Returns with the desired facing to face the destination *
;* coordinate from the position of the source coordinate. North *
;* is 0, East is 64, etc. *
;* *
;* WARNINGS: This routine is slower than the other forms of desired *
;* facing calculation. Use this routine when accuracy is *
;* required. *
;* *
;* HISTORY: *
;* 12/24/1991 JLB : Adapted. *
;*=========================================================================*/
; LONG cdecl Desired_Facing256(LONG srcx, LONG srcy, LONG dstx, LONG dsty)
PROC Desired_Facing256 C near
USES ebx, ecx, edx
ARG srcx:DWORD
ARG srcy:DWORD
ARG dstx:DWORD
ARG dsty:DWORD
xor ebx,ebx ; Facing number.
; Determine absolute X delta and left/right direction.
mov ecx,[dstx]
sub ecx,[srcx]
jge short ??xnotneg
neg ecx
mov ebx,11000000b ; Set bit 7 and 6 for leftward.
??xnotneg:
; Determine absolute Y delta and top/bottom direction.
mov eax,[srcy]
sub eax,[dsty]
jge short ??ynotneg
xor ebx,01000000b ; Complement bit 6 for downward.
neg eax
??ynotneg:
; Set DX=64 for quadrants 0 and 2.
mov edx,ebx
and edx,01000000b
xor edx,01000000b
; Determine if the direction is closer to the Y axis and make sure that
; CX holds the larger of the two deltas. This is in preparation for the
; divide.
cmp eax,ecx
jb short ??gotaxis
xchg eax,ecx
xor edx,01000000b ; Closer to Y axis so make DX=64 for quad 0 and 2.
??gotaxis:
; If closer to the X axis then add 64 for quadrants 0 and 2. If
; closer to the Y axis then add 64 for quadrants 1 and 3. Determined
; add value is in DX and save on stack.
push edx
; Make sure that the division won't overflow. Reduce precision until
; the larger number is less than 256 if it appears that an overflow
; will occur. If the high byte of the divisor is not zero, then this
; guarantees no overflow, so just abort shift operation.
test eax,0FFFFFF00h
jnz short ??nooverflow
??again:
test ecx,0FFFFFF00h
jz short ??nooverflow
shr ecx,1
shr eax,1
jmp short ??again
??nooverflow:
; Make sure that the division won't underflow (divide by zero). If
; this would occur, then set the quotient to $FF and skip divide.
or ecx,ecx
jnz short ??nounderflow
mov eax,0FFFFFFFFh
jmp short ??divcomplete
; Derive a pseudo angle number for the octant. The angle is based
; on $00 = angle matches long axis, $00 = angle matches $FF degrees.
??nounderflow:
xor edx,edx
shld edx,eax,8 ; shift high byte of eax into dl
shl eax,8
div ecx
??divcomplete:
; Integrate the 5 most significant bits into the angle index. If DX
; is not zero, then it is 64. This means that the dividend must be negated
; before it is added into the final angle value.
shr eax,3
pop edx
or edx,edx
je short ??noneg
dec edx
neg eax
??noneg:
add eax,edx
add eax,ebx
and eax,0FFH
ret
ENDP Desired_Facing256
END

View file

@ -0,0 +1,458 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/*;***************************************************************************
;** 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 : Support Library *
;* *
;* File Name : FACINGFF.ASM *
;* *
;* Programmer : Joe L. Bostic *
;* *
;* Start Date : May 8, 1991 *
;* *
;* Last Update : February 6, 1995 [BWG] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Desired_Facing256 -- Determines facing to reach a position. *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*/
#ifndef FACINGFF_H
#define FACINGFF_H
//IDEAL
//P386
//MODEL USE32 FLAT
//GLOBAL C Desired_Facing256 :NEAR
//; INCLUDE "wwlib.i"
//INCLUDE "..\include\gbuffer.inc"
// CODESEG
/*
;***************************************************************************
;* Desired_Facing256 -- Desired facing algorithm 0..255 resolution. *
;* *
;* This is a desired facing algorithm that has a resolution of 0 *
;* through 255. *
;* *
;* INPUT: srcx,srcy -- Source coordinate. *
;* *
;* dstx,dsty -- Destination coordinate. *
;* *
;* OUTPUT: Returns with the desired facing to face the destination *
;* coordinate from the position of the source coordinate. North *
;* is 0, East is 64, etc. *
;* *
;* WARNINGS: This routine is slower than the other forms of desired *
;* facing calculation. Use this routine when accuracy is *
;* required. *
;* *
;* HISTORY: *
;* 12/24/1991 JLB : Adapted. *
;*=========================================================================*/
int __cdecl Desired_Facing256(LONG srcx, LONG srcy, LONG dstx, LONG dsty);
#if (0)
PROC Desired_Facing256 C near
USES ebx, ecx, edx
ARG srcx:DWORD
ARG srcy:DWORD
ARG dstx:DWORD
ARG dsty:DWORD
xor ebx,ebx ; Facing number.
; Determine absolute X delta and left/right direction.
mov ecx,[dstx]
sub ecx,[srcx]
jge short ??xnotneg
neg ecx
mov ebx,11000000b ; Set bit 7 and 6 for leftward.
??xnotneg:
; Determine absolute Y delta and top/bottom direction.
mov eax,[srcy]
sub eax,[dsty]
jge short ??ynotneg
xor ebx,01000000b ; Complement bit 6 for downward.
neg eax
??ynotneg:
; Set DX=64 for quadrants 0 and 2.
mov edx,ebx
and edx,01000000b
xor edx,01000000b
; Determine if the direction is closer to the Y axis and make sure that
; CX holds the larger of the two deltas. This is in preparation for the
; divide.
cmp eax,ecx
jb short ??gotaxis
xchg eax,ecx
xor edx,01000000b ; Closer to Y axis so make DX=64 for quad 0 and 2.
??gotaxis:
; If closer to the X axis then add 64 for quadrants 0 and 2. If
; closer to the Y axis then add 64 for quadrants 1 and 3. Determined
; add value is in DX and save on stack.
push edx
; Make sure that the division won't overflow. Reduce precision until
; the larger number is less than 256 if it appears that an overflow
; will occur. If the high byte of the divisor is not zero, then this
; guarantees no overflow, so just abort shift operation.
test eax,0FFFFFF00h
jnz short ??nooverflow
??again:
test ecx,0FFFFFF00h
jz short ??nooverflow
shr ecx,1
shr eax,1
jmp short ??again
??nooverflow:
; Make sure that the division won't underflow (divide by zero). If
; this would occur, then set the quotient to $FF and skip divide.
or ecx,ecx
jnz short ??nounderflow
mov eax,0FFFFFFFFh
jmp short ??divcomplete
; Derive a pseudo angle number for the octant. The angle is based
; on $00 = angle matches long axis, $00 = angle matches $FF degrees.
??nounderflow:
xor edx,edx
shld edx,eax,8 ; shift high byte of eax into dl
shl eax,8
div ecx
??divcomplete:
; Integrate the 5 most significant bits into the angle index. If DX
; is not zero, then it is 64. This means that the dividend must be negated
; before it is added into the final angle value.
shr eax,3
pop edx
or edx,edx
je short ??noneg
dec edx
neg eax
??noneg:
add eax,edx
add eax,ebx
and eax,0FFH
ret
ENDP Desired_Facing256
END
#endif
/*
;***************************************************************************
;** 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 : Support Library *
;* *
;* File Name : FACING8.ASM *
;* *
;* Programmer : Joe L. Bostic *
;* *
;* Start Date : May 8, 1991 *
;* *
;* Last Update : February 6, 1995 [BWG] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Desired_Facing8 -- Determines facing to reach a position. *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
GLOBAL C Desired_Facing8 :NEAR
; INCLUDE "wwlib.i"
DATASEG
; 8 direction desired facing lookup table. Build the index according
; to the following bits:
;
; bit 3 = Is y2 < y1?
; bit 2 = Is x2 < x1?
; bit 1 = Is the ABS(x2-x1) < ABS(y2-y1)?
; bit 0 = Is the facing closer to a major axis?
//NewFacing8 DB 1,2,1,0,7,6,7,0,3,2,3,4,5,6,5,4
// CODESEG
*/
/*
;***************************************************************************
;* DESIRED_FACING8 -- Determines facing to reach a position. *
;* *
;* This routine will return with the most desirable facing to reach *
;* one position from another. It is accurate to a resolution of 0 to *
;* 7. *
;* *
;* INPUT: x1,y1 -- Position of origin point. *
;* *
;* x2,y2 -- Position of target. *
;* *
;* OUTPUT: Returns desired facing as a number from 0..255 with an *
;* accuracy of 32 degree increments. *
;* *
;* WARNINGS: If the two coordinates are the same, then -1 will be *
;* returned. It is up to you to handle this case. *
;* *
;* HISTORY: *
;* 07/15/1991 JLB : Documented. *
;* 08/08/1991 JLB : Same position check. *
;* 08/14/1991 JLB : New algorithm *
;* 02/06/1995 BWG : Convert to 32-bit *
;*=========================================================================*
*/
int __cdecl Desired_Facing8(long x1, long y1, long x2, long y2);
#if (0)
PROC Desired_Facing8 C near
USES ebx, ecx, edx
ARG x1:DWORD
ARG y1:DWORD
ARG x2:DWORD
ARG y2:DWORD
xor ebx,ebx ; Index byte (built).
; Determine Y axis difference.
mov edx,[y1]
mov ecx,[y2]
sub edx,ecx ; DX = Y axis (signed).
jns short ??absy
inc ebx ; Set the signed bit.
neg edx ; ABS(y)
??absy:
; Determine X axis difference.
shl ebx,1
mov eax,[x1]
mov ecx,[x2]
sub ecx,eax ; CX = X axis (signed).
jns short ??absx
inc ebx ; Set the signed bit.
neg ecx ; ABS(x)
??absx:
; Determine the greater axis.
cmp ecx,edx
jb short ??dxisbig
xchg ecx,edx
??dxisbig:
rcl ebx,1 ; Y > X flag bit.
; Determine the closeness or farness of lesser axis.
mov eax,edx
inc eax ; Round up.
shr eax,1
cmp ecx,eax
rcl ebx,1 ; Close to major axis bit.
xor eax,eax
mov al,[NewFacing8+ebx]
; Normalize to 0..FF range.
shl eax,5
ret
ENDP Desired_Facing8
END
#endif
/*
; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/TIBERIANDAWN/WIN32LIB/FACINGFF.h#33 $
;***************************************************************************
;** 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 : Support Library *
;* *
;* File Name : FACING16.ASM *
;* *
;* Programmer : Joe L. Bostic *
;* *
;* Start Date : May 8, 1991 *
;* *
;* Last Update : February 6, 1995 [BWG] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Desired_Facing16 -- Converts coordinates into a facing number. *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
GLOBAL C Desired_Facing16 :NEAR
; INCLUDE "wwlib.i"
DATASEG
; 16 direction desired facing lookup table. Build the index according
; to the following bits:
;
; bit 4 = Is y2 < y1?
; bit 3 = Is x2 < x1?
; bit 2 = Is the ABS(x2-x1) < ABS(y2-y1)?
; bit 1 = Is the lesser absolute difference very close to zero?
; bit 0 = Is the lesser absolute difference very close to the greater dist?
NewFacing16 DB 3, 2, 4,-1, 1, 2,0,-1
DB 13,14,12,-1,15,14,0,-1
DB 5, 6, 4,-1, 7, 6,8,-1
DB 11,10,12,-1, 9,10,8,-1
CODESEG
;***************************************************************************
;* DESIRED_FACING16 -- Converts coordinates into a facing number. *
;* *
;* This converts coordinates into a desired facing number that ranges *
;* from 0 to 15 (0 equals North and going clockwise). *
;* *
;* INPUT: x1,y1 -- Position of origin point. *
;* *
;* x2,y2 -- Position of target. *
;* *
;* OUTPUT: Returns desired facing as a number from 0 to 255 but *
;* accurate to 22.5 degree increments. *
;* *
;* WARNINGS: If the two coordinates are the same, then -1 will be *
;* returned. It is up to you to handle this case. *
;* *
;* HISTORY: *
;* 08/14/1991 JLB : Created. *
;*=========================================================================*
*/
long __cdecl Desired_Facing16(long x1, long y1, long x2, long y2);
#if (0)
PROC Desired_Facing16 C near
USES ebx, ecx, edx
ARG x1:DWORD
ARG y1:DWORD
ARG x2:DWORD
ARG y2:DWORD
xor ebx,ebx ; Index byte (built).
; Determine Y axis difference.
mov edx,[y1]
mov ecx,[y2]
sub edx,ecx ; DX = Y axis (signed).
jns short ??absy
inc ebx ; Set the signed bit.
neg edx ; ABS(y)
??absy:
; Determine X axis difference.
shl ebx,1
mov eax,[x1]
mov ecx,[x2]
sub ecx,eax ; CX = X axis (signed).
jns short ??absx
inc ebx ; Set the signed bit.
neg ecx ; ABS(x)
??absx:
; Determine the greater axis.
cmp ecx,edx
jb short ??dxisbig
xchg ecx,edx
??dxisbig:
rcl ebx,1 ; Y > X flag bit.
; Determine the closeness or farness of lesser axis.
mov eax,edx
inc eax ; Round up.
shr eax,1
inc eax ; Round up.
shr eax,1 ; 1/4 of greater axis.
cmp ecx,eax
rcl ebx,1 ; Very close to major axis bit.
sub edx,eax
cmp edx,ecx
rcl ebx,1 ; Very far from major axis bit.
xor eax,eax
mov al,[NewFacing16+ebx]
; Normalize to 0..FF range.
shl eax,4
ret
ENDP Desired_Facing16
END
#endif
#endif FACINGFF_H

View file

@ -0,0 +1,39 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/*==========================================================================
*
* Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
*
* File: fastfile.h
* Content: Definitions for fastfile access.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*
***************************************************************************/
typedef LPVOID HFASTFILE;
extern BOOL FastFileInit( LPSTR fname, int max_handles );
extern void FastFileFini( void );
extern HFASTFILE FastFileOpen( LPSTR name );
extern BOOL FastFileClose( HFASTFILE pfe );
extern BOOL FastFileRead( HFASTFILE pfh, LPVOID ptr, int size );
extern BOOL FastFileSeek( HFASTFILE pfe, int off, int how );
extern long FastFileTell( HFASTFILE pfe );
extern LPVOID FastFileLock( HFASTFILE pfe, int off, int len );
extern BOOL FastFileUnlock( HFASTFILE pfe, int off, int len );

View file

@ -0,0 +1,257 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Library - Filio header stuff. *
* *
* File Name : FILE.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : September 13, 1993 *
* *
* Last Update : April 11, 1994 *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef FILE_H
#define FILE_H
#ifndef FILETEMP_H
// This should be removed once the library is all intacked.
#include "filetemp.h"
#endif
/*=========================================================================*/
/* File IO system defines and enumerations */
/*=========================================================================*/
#define XMAXPATH 80
/*
** These are the Open_File, Read_File, and Seek_File constants.
*/
#ifndef READ
#define READ 1 // Read access.
#endif
#ifndef WRITE
#define WRITE 2 // Write access.
#endif
#ifndef SEEK_SET
#define SEEK_SET 0 // Seek from start of file.
#define SEEK_CUR 1 // Seek relative from current location.
#define SEEK_END 2 // Seek from end of file.
#endif
typedef enum {
FILEB_PROCESSED=8,// Was the packed file header of this file processed?
FILEB_PRELOAD, // Scan for and make file resident at WWDOS_Init time?
FILEB_RESIDENT, // Make resident at Open_File time?
FILEB_FLUSH, // Un-resident at Close_File time?
FILEB_PACKED, // Is this file packed?
FILEB_KEEP, // Don't ever flush this resident file?
FILEB_PRIORITY, // Flush this file last?
FILEB_LAST
} FileFlags_Type;
#define FILEF_NONE 0
#define FILEF_PROCESSED (1<<FILEB_PROCESSED)
#define FILEF_PRELOAD (1<<FILEB_PRELOAD)
#define FILEF_RESIDENT (1<<FILEB_RESIDENT)
#define FILEF_FLUSH (1<<FILEB_FLUSH)
#define FILEF_PACKED (1<<FILEB_PACKED)
#define FILEF_KEEP (1<<FILEB_KEEP)
#define FILEF_PRIORITY (1<<FILEB_PRIORITY)
/*
** These errors are returned by WWDOS_Init(). All errors encountered are
** or'd together so there may be more then one error returned. Not all
** errors are fatal, such as the cache errors.
*/
typedef enum {
FI_SUCCESS = 0x00,
FI_CACHE_TOO_BIG = 0x01,
FI_CACHE_ALREADY_INIT = 0x02,
FI_FILEDATA_FILE_NOT_FOUND = 0x04,
FI_FILEDATA_TOO_BIG = 0x08,
FI_SEARCH_PATH_NOT_FOUND = 0x10,
FI_STARTUP_PATH_NOT_FOUND = 0x20,
FI_NO_CACHE_FOR_PRELOAD = 0x40,
FI_FILETABLE_NOT_INIT = 0x80,
} FileInitErrorType;
/*
** These are the errors that are detected by the File I/O system and
** passed to the io error routine.
*/
//lint -strong(AJX,FileErrorType)
typedef enum {
CANT_CREATE_FILE,
BAD_OPEN_MODE,
COULD_NOT_OPEN,
TOO_MANY_FILES,
CLOSING_NON_HANDLE,
READING_NON_HANDLE,
WRITING_NON_HANDLE,
SEEKING_NON_HANDLE,
SEEKING_BAD_OFFSET,
WRITING_RESIDENT,
UNKNOWN_INDEX,
DID_NOT_CLOSE,
FATAL_ERROR,
FILE_NOT_LISTED,
FILE_LENGTH_MISMATCH,
INTERNAL_ERROR,
MAKE_RESIDENT_ZERO_SIZE,
RESIDENT_SORT_FAILURE,
NUMBER_OF_ERRORS /* MAKE SURE THIS IS THE LAST ENTRY */
} FileErrorType;
// This is here tempararaly until library is put together.
//extern WORD __cdecl ( __cdecl IO_Error)(FileErrorType error, BYTE const *filename);
extern short (*Open_Error)(FileErrorType, BYTE const *);
/*=========================================================================*/
/* File IO system structures */
/*=========================================================================*/
//lint -strong(AJX,FileDataType)
typedef struct {
char *Name; // File name (include sub-directory but not volume).
long Size; // File size (0=indeterminate).
void *Ptr; // Resident file pointer.
long Start; // Starting offset in DOS handle file.
unsigned char Disk; // Disk number location.
unsigned char OpenCount; // Count of open locks on resident file.
unsigned short Flag; // File control flags.
} FileDataType;
/*=========================================================================*/
/* FIle IO system globals. */
/*=========================================================================*/
// These are cpp errors in funtions declarations JULIO JEREZ
// extern FileDataType __cdecl FileData[];
// extern BYTE __cdecl ExecPath[XMAXPATH + 1];
// extern BYTE __cdecl DataPath[XMAXPATH + 1];
// extern BYTE __cdecl StartPath[XMAXPATH + 1];
// extern BOOL __cdecl UseCD;
// The correct syntax is NO TYPE MODIFIER APPLY TO DATA DECLARATIONS
extern FileDataType FileData[];
extern char ExecPath[XMAXPATH + 1];
extern char DataPath[XMAXPATH + 1];
extern char StartPath[XMAXPATH + 1];
extern BOOL UseCD;
/*=========================================================================*/
/* The following prototypes are for the file: FILEINIT.CPP */
/*=========================================================================*/
void __cdecl WWDOS_Shutdown(void);
FileInitErrorType __cdecl WWDOS_Init(unsigned long cachesize, char *filedata, char *cdpath);
/*=========================================================================*/
/* The following prototypes are for the file: FILE.CPP */
/*=========================================================================*/
int __cdecl Open_File(char const *file_name, int mode);
void __cdecl Close_File(int handle);
long __cdecl Read_File(int handle, void *buf, unsigned long bytes);
int __cdecl Load_File ( const char *file_name , void *load_addr);
long __cdecl Write_File(int handle, void const *buf, unsigned long bytes);
unsigned long __cdecl Seek_File(int handle, long offset, int starting);
int __cdecl File_Exists(char const *file_name);
unsigned long __cdecl File_Size(int handle);
BOOL __cdecl Is_Handle_Valid(int handle, FileErrorType error, char const *name);
int __cdecl Open_File_With_Recovery( char const *file_name, unsigned int mode );
/*=========================================================================*/
/* The following prototypes are for the file: FILECACH.CPP */
/*=========================================================================*/
void Unfragment_File_Cache(void);
BOOL __cdecl Make_File_Resident(char const *filename);
int __cdecl Flush_Unused_File_Cache(int flush_keeps);
BOOL __cdecl Free_Resident_File(char const *file);
/*=========================================================================*/
/* The following prototypes are for the file: FILECHNG.CPP */
/*=========================================================================*/
int __cdecl Create_File(char const *file_name);
int __cdecl Delete_File(char const *file_name);
BOOL __cdecl Change_File_Size(int handle, unsigned long new_size);
/*=========================================================================*/
/* The following prototypes are for the file: FILEINFO.CPP */
/*=========================================================================*/
int __cdecl Get_DOS_Handle(int fh);
int __cdecl Free_Handles(void);
int __cdecl Find_Disk_Number(char const *file_name);
int __cdecl Set_File_Flags(char const *filename, int flags);
int __cdecl Clear_File_Flags(char const *filename, int flags);
int __cdecl Get_File_Flags(char const *filename);
BOOL __cdecl Multi_Drive_Search(BOOL on);
/*=========================================================================*/
/* The following prototypes are for the file: FINDFILE.CPP */
/*=========================================================================*/
int __cdecl Find_File(char const *file_name);
int __cdecl Find_File_Index(char const *filename);
/*=========================================================================*/
/* The following prototypes are for the file: FFIRST.ASM */
/*=========================================================================*/
#include <dos.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int __cdecl Find_First(unsigned char *fname, unsigned int mode, struct find_t *ffblk);
extern int __cdecl Find_Next(struct find_t *ffblk);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,74 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
;** 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 : iff *
;* *
;* File Name : FILEPCX.H *
;* *
;* Programmer : Julio R. Jerez *
;* *
;* Start Date : May 2, 1995 *
;* *
;* Last Update : May 2, 1995 [JRJ] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* GraphicBufferClass* Read_PCX_File (char* name, BYTE* palette,void *buff, long size);
;* GraphicBufferClass* Read_PCX_File (char* name, BYTE* palette, BufferClass& Buff);
;* int Write_PCX_File (char* name, GraphicViewPortClass& pic, BYTE* palette );*
;*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
#include <gbuffer.h>
#include <string.h>
#include <buffer.h>
#include <file.h>
#ifndef PCX_H
#define PCX_H
typedef struct {
char red ;
char green ;
char blue ;
} RGB ;
typedef struct {
char id ;
char version ;
char encoding ;
char pixelsize ;
short x ;
short y ;
short width ;
short height ;
short xres ;
short yres ;
RGB ega_palette [ 16 ] ;
char nothing ;
char color_planes ;
short byte_per_line ;
short palette_type ;
char filler [ 58 ] ;
} PCX_HEADER ;
GraphicBufferClass* Read_PCX_File (char* name, char* palette= NULL,void *buff=NULL, long size=0);
GraphicBufferClass* Read_PCX_File (char* name, BufferClass& Buff,char* palette= NULL) ;
int Write_PCX_File (char* name, GraphicViewPortClass& pic, unsigned char* palette );
#endif

View file

@ -0,0 +1,58 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Temp header for file routines. *
* *
* File Name : FILETEMP.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : April 20, 1994 *
* *
* Last Update : April 20, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef FILETEMP_H
#define FILETEMP_H
/////////////////////////////////////////////////////////////////////
// THIS DOES NOT BELONG HERE. IT WAS PUT HERE JUST TO GET THE THING
// TO COMPILE. ONCE THE BUFFER AND PAGE SYSTEMS ARE PUT IN, THESE
// WILL NEED TO BE TAKEN OUT AND MODS MADE TO ANY FUNCTION USING BuffType.
// SKB 4/20/94.
/*=========================================================================*/
/* Defines and such that must go into wwstd.h */
/*=========================================================================*/
// Look at FileErrorType below for the IO_Error function.
//extern WORD __cdecl ( __cdecl IO_Error)(FileErrorType error, BYTE const *filename);
VOID __cdecl Prog_End(VOID);
extern WORD Hard_Error_Occured;
//////////////////////// END OF DON'T BELONG //////////////////////////////////
#endif //FILETEMP_H

View file

@ -0,0 +1,138 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : LIBRARY *
* *
* File Name : FONT.C *
* *
* Programmer : David Dettmer *
* *
* Last Update : July 20, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Char_Pixel_Width -- Return pixel width of a character. *
* String_Pixel_Width -- Return pixel width of a string of characters. *
* Get_Next_Text_Print_XY -- Calculates X and Y given ret value from Text_P*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "font.h"
#include <malloc.h>
#include <dos.h>
#include <fcntl.h>
#include <io.h>
#include <sys\stat.h>
#include <string.h>
#include <wwstd.h>
/***************************************************************************
* CHAR_PIXEL_WIDTH -- Return pixel width of a character. *
* *
* Retreives the pixel width of a character from the font width block. *
* *
* INPUT: Character. *
* *
* OUTPUT: Pixel width of a string of characters. *
* *
* WARNINGS: Set_Font must have been called first. *
* *
* HISTORY: *
* 01/31/1992 DRD : Created. *
* 06/30/1994 SKB : Converted to 32 bit library. *
*=========================================================================*/
int __cdecl Char_Pixel_Width(char chr)
{
int width;
width = (unsigned char)*(FontWidthBlockPtr + (unsigned char)chr) + FontXSpacing;
return(width);
}
/***************************************************************************
* STRING_PIXEL_WIDTH -- Return pixel width of a string of characters. *
* *
* Calculates the pixel width of a string of characters. This uses *
* the font width block for the widths. *
* *
* INPUT: Pointer to string of characters. *
* *
* OUTPUT: Pixel width of a string of characters. *
* *
* WARNINGS: Set_Font must have been called first. *
* *
* HISTORY: *
* 01/30/1992 DRD : Created. *
* 01/31/1992 DRD : Use Char_Pixel_Width. *
* 06/30/1994 SKB : Converted to 32 bit library. *
*=========================================================================*/
unsigned int __cdecl String_Pixel_Width(char const *string)
{
WORD width; // Working accumulator of string width.
WORD largest = 0; // Largest recorded width of the string.
if (!string) return(0);
width = 0;
while (*string) {
if (*string == '\r') {
string++;
largest = MAX(largest, width);
width = 0;
} else {
width += Char_Pixel_Width(*string++); // add each char's width
}
}
largest = MAX(largest, width);
return(largest);
}
/***************************************************************************
* GET_NEXT_TEXT_PRINT_XY -- Calculates X and Y given ret value from Text_P*
* *
* *
* INPUT: VVPC& vp - viewport that was printed to. *
* unsigned long offset - offset that Text_Print returned. *
* INT *x - x return value. *
* INT *y - y return value. *
* *
* OUTPUT: x and y are set. *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/20/1994 SKB : Created. *
*=========================================================================*/
VOID __cdecl Get_Next_Text_Print_XY(GraphicViewPortClass& gp, unsigned long offset, INT *x, INT *y)
{
INT buffwidth;
if (offset) {
buffwidth = gp.Get_Width() + gp.Get_XAdd();
offset -= gp.Get_Offset();
*x = offset % buffwidth;
*y = offset / buffwidth;
} else {
*x = *y = 0;
}
}

View file

@ -0,0 +1,115 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Font and text print 32 bit library *
* *
* File Name : FONT.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : June 27, 1994 *
* *
* Last Update : June 29, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* VVPC::Text_Print -- Text print into a virtual viewport. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef FONT_H
#define FONT_H
#ifndef GBUFFER_H
#include <gbuffer.h>
#endif
//////////////////////////////////////// Defines //////////////////////////////////////////
// defines for font header, offsets to block offsets
#define FONTINFOBLOCK 4
#define FONTOFFSETBLOCK 6
#define FONTWIDTHBLOCK 8
#define FONTDATABLOCK 10
#define FONTHEIGHTBLOCK 12
// defines for font info block
#define FONTINFOMAXHEIGHT 4
#define FONTINFOMAXWIDTH 5
//////////////////////////////////////// Prototypes //////////////////////////////////////////
/*=========================================================================*/
/* The following prototypes are for the file: SET_FONT.CPP */
/*=========================================================================*/
void * __cdecl Set_Font(void const *fontptr);
/*=========================================================================*/
/* The following prototypes are for the file: FONT.CPP */
/*=========================================================================*/
int __cdecl Char_Pixel_Width(char chr);
unsigned int __cdecl String_Pixel_Width(char const *string);
void __cdecl Get_Next_Text_Print_XY(GraphicViewPortClass& vp, unsigned long offset, INT *x, INT *y);
/*=========================================================================*/
/* The following prototypes are for the file: LOADFONT.CPP */
/*=========================================================================*/
void * __cdecl Load_Font(char const *name);
/*=========================================================================*/
/* The following prototypes are for the file: TEXTPRNT.ASM */
/*=========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
void __cdecl Set_Font_Palette_Range(void const *palette, INT start_idx, INT end_idx);
#ifdef __cplusplus
}
#endif
/*=========================================================================*/
//////////////////////////////////////// External varables ///////////////////////////////////////
extern "C" int FontXSpacing;
extern "C" int FontYSpacing;
extern char FontWidth ;
extern char FontHeight;
extern char *FontWidthBlockPtr;
extern "C" void const *FontPtr;
#endif // FONT_H

View file

@ -0,0 +1,44 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/*=========================================================================*/
/* The following prototypes are for the file: SOUNDIO.CPP */
/*=========================================================================*/
short Decompress_Frame(void * source, void * dest, short size);
int __cdecl Stream_Sample_Vol(void *buffer, long size, BOOL (*callback);
int __cdecl Stream_Sample(void *buffer, long size, BOOL (*callback);
int __cdecl File_Stream_Sample(char const *filename);
int __cdecl File_Stream_Sample_Vol(char const *filename, int volume);
void __cdecl _saveregs _loadds Sound_Callback(void);
void __cdecl far _saveregs _loadds maintenance_callback(void);
void __cdecl Load_Sample(char const *filename);
long __cdecl Load_Sample_Into_Buffer(char const *filename, void *buffer, long size);
long __cdecl Sample_Read(int fh, void *buffer, long size);
void __cdecl Free_Sample(void const *sample);
BOOL __cdecl Sound_Init(int sfx, int score, int sample);
void far VQA_TimerCallback(void);
BOOL Audio_Init(int sample, int address, int inter, int dma);
void __cdecl Sound_End(void);
void __cdecl Stop_Sample(int handle);
BOOL __cdecl Sample_Status(int handle);
BOOL __cdecl Is_Sample_Playing(void const * sample);
void __cdecl Stop_Sample_Playing(void const * sample);
int __cdecl Play_Sample(void const *sample);
int __cdecl Play_Sample_Vol(void const *sample, int priority, int volume);
int __cdecl Set_Sound_Vol(int volume);
int __cdecl Set_Score_Vol(int volume);
void __cdecl Fade_Sample(int handle, int ticks);

View file

@ -0,0 +1,707 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 32 bit Library *
* *
* File Name : GBUFFER.CPP *
* *
* Programmer : Phil W. Gorrow *
* *
* Start Date : May 3, 1994 *
* *
* Last Update : October 9, 1995 [] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* VVPC::VirtualViewPort -- Default constructor for a virtual viewport *
* VVPC:~VirtualViewPortClass -- Destructor for a virtual viewport *
* VVPC::Clear -- Clears a graphic page to correct color *
* VBC::VideoBufferClass -- Lowlevel constructor for video buffer class *
* GVPC::Change -- Changes position and size of a Graphic View Port *
* VVPC::Change -- Changes position and size of a Video View Port *
* Set_Logic_Page -- Sets LogicPage to new buffer *
* GBC::DD_Init -- Inits a direct draw surface for a GBC *
* GBC::Init -- Core function responsible for initing a GBC *
* GBC::Lock -- Locks a Direct Draw Surface *
* GBC::Unlock -- Unlocks a direct draw surface *
* GBC::GraphicBufferClass -- Default constructor (requires explicit init)*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef GBUFFER_H
#include "gbuffer.h"
#include "misc.h"
#endif
//#pragma inline
int TotalLocks;
BOOL AllowHardwareBlitFills = TRUE;
//int CacheAllowed;
/*=========================================================================*/
/* The following PRIVATE functions are in this file: */
/*=========================================================================*/
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
/***************************************************************************
* GVPC::GRAPHICVIEWPORTCLASS -- Constructor for basic view port class *
* m *
* INPUT: GraphicBufferClass * gbuffer - buffer to attach to *
* int x - x offset into buffer *
* int y - y offset into buffer *
* int w - view port width in pixels *
* int h - view port height in pixels *
* *
* OUTPUT: Constructors may not have a return value *
* *
* HISTORY: *
* 05/09/1994 PWG : Created. *
*=========================================================================*/
GraphicViewPortClass::GraphicViewPortClass(GraphicBufferClass *gbuffer, int x, int y, int w, int h) :
LockCount(0),
GraphicBuff(NULL)
{
Attach(gbuffer, x, y, w, h);
}
/***************************************************************************
* GVPC::GRAPHICVIEWPORTCLASS -- Default constructor for view port class *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 05/09/1994 PWG : Created. *
*=========================================================================*/
GraphicViewPortClass::GraphicViewPortClass(void)
{
}
/***************************************************************************
* GVPC::~GRAPHICVIEWPORTCLASS -- Destructor for GraphicViewPortClass *
* *
* INPUT: none *
* *
* OUTPUT: A destructor may not return a value. *
* *
* HISTORY: *
* 05/10/1994 PWG : Created. *
*=========================================================================*/
GraphicViewPortClass::~GraphicViewPortClass(void)
{
Offset = 0;
Width = 0; // Record width of Buffer
Height = 0; // Record height of Buffer
XAdd = 0; // Record XAdd of Buffer
XPos = 0; // Record XPos of Buffer
YPos = 0; // Record YPos of Buffer
Pitch = 0; // Record width of Buffer
IsDirectDraw = FALSE;
LockCount = 0;
GraphicBuff = NULL;
}
/***************************************************************************
* GVPC::ATTACH -- Attaches a viewport to a buffer class *
* *
* INPUT: GraphicBufferClass *g_buff - pointer to gbuff to attach to *
* int x - x position to attach to *
* int y - y position to attach to *
* int w - width of the view port *
* int h - height of the view port *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 05/10/1994 PWG : Created. *
*=========================================================================*/
void GraphicViewPortClass::Attach(GraphicBufferClass *gbuffer, int x, int y, int w, int h)
{
/*======================================================================*/
/* Can not attach a Graphic View Port if it is actually the physical */
/* representation of a Graphic Buffer. */
/*======================================================================*/
if (this == Get_Graphic_Buffer()) {
return;
}
/*======================================================================*/
/* Verify that the x and y coordinates are valid and placed within the */
/* physical buffer. */
/*======================================================================*/
if (x < 0) // you cannot place view port off
x = 0; // the left edge of physical buf
if (x >= gbuffer->Get_Width()) // you cannot place left edge off
x = gbuffer->Get_Width() - 1; // the right edge of physical buf
if (y < 0) // you cannot place view port off
y = 0; // the top edge of physical buf
if (y >= gbuffer->Get_Height()) // you cannot place view port off
y = gbuffer->Get_Height() - 1; // bottom edge of physical buf
/*======================================================================*/
/* Adjust the width and height of necessary */
/*======================================================================*/
if (x + w > gbuffer->Get_Width()) // if the x plus width is larger
w = gbuffer->Get_Width() - x; // than physical, fix width
if (y + h > gbuffer->Get_Height()) // if the y plus height is larger
h = gbuffer->Get_Height() - y; // than physical, fix height
/*======================================================================*/
/* Get a pointer to the top left edge of the buffer. */
/*======================================================================*/
Offset = gbuffer->Get_Offset() + ((gbuffer->Get_Width()+gbuffer->Get_Pitch()) * y) + x;
/*======================================================================*/
/* Copy over all of the variables that we need to store. */
/*======================================================================*/
XPos = x;
YPos = y;
XAdd = gbuffer->Get_Width() - w;
Width = w;
Height = h;
Pitch = gbuffer->Get_Pitch();
GraphicBuff = gbuffer;
IsDirectDraw= gbuffer->IsDirectDraw;
}
/***************************************************************************
* GVPC::CHANGE -- Changes position and size of a Graphic View Port *
* *
* INPUT: int the new x pixel position of the graphic view port *
* int the new y pixel position of the graphic view port *
* int the new width of the viewport in pixels *
* int the new height of the viewport in pixels *
* *
* OUTPUT: BOOL whether the Graphic View Port could be sucessfully *
* resized. *
* *
* WARNINGS: You may not resize a Graphic View Port which is derived *
* from a Graphic View Port Buffer, *
* *
* HISTORY: *
* 09/14/1994 SKB : Created. *
*=========================================================================*/
BOOL GraphicViewPortClass::Change(int x, int y, int w, int h)
{
/*======================================================================*/
/* Can not change a Graphic View Port if it is actually the physical */
/* representation of a Graphic Buffer. */
/*======================================================================*/
if (this == Get_Graphic_Buffer()) {
return(FALSE);
}
/*======================================================================*/
/* Since there is no allocated information, just re-attach it to the */
/* existing graphic buffer as if we were creating the */
/* GraphicViewPort. */
/*======================================================================*/
Attach(Get_Graphic_Buffer(), x, y, w, h);
return(TRUE);
}
/***************************************************************************
* GBC::DD_INIT -- Inits a direct draw surface for a GBC *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 10/09/1995 : Created. *
*=========================================================================*/
void GraphicBufferClass::DD_Init(GBC_Enum flags)
{
//
// Create the direct draw surface description
//
memset (&VideoSurfaceDescription , 0 , sizeof ( VideoSurfaceDescription ));
VideoSurfaceDescription.dwSize = sizeof( VideoSurfaceDescription );
VideoSurfaceDescription.dwFlags = DDSD_CAPS;
VideoSurfaceDescription.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (!(flags & GBC_VISIBLE)) {
VideoSurfaceDescription.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
VideoSurfaceDescription.dwFlags |= DDSD_HEIGHT | DDSD_WIDTH;
VideoSurfaceDescription.dwHeight = Height;
VideoSurfaceDescription.dwWidth = Width;
}
//
// Need to set the DDSCAPS_MODEX flag if we want a 320 wide mode
//
if ( Width == 320 ) {
VideoSurfaceDescription.ddsCaps.dwCaps |= DDSCAPS_MODEX;
}
//
// Call CreateSurface
//
DirectDrawObject->CreateSurface( &VideoSurfaceDescription , &VideoSurfacePtr , NULL);
AllSurfaces.Add_DD_Surface (VideoSurfacePtr);
if ( GBC_VISIBLE & flags ){
PaletteSurface=VideoSurfacePtr;
}
Allocated = FALSE; // even if system alloced, dont flag it cuz
// we dont want it freed.
IsDirectDraw = TRUE; // flag it as a video surface
Offset = NOT_LOCKED; // flag it as unavailable for reading or writing
LockCount = 0; // surface is not locked
}
void GraphicBufferClass::Attach_DD_Surface (GraphicBufferClass * attach_buffer)
{
VideoSurfacePtr->AddAttachedSurface (attach_buffer->Get_DD_Surface());
}
/***************************************************************************
* GBC::INIT -- Core function responsible for initing a GBC *
* *
* INPUT: int - the width in pixels of the GraphicBufferClass *
* int - the heigh in pixels of the GraphicBufferClass *
* void * - pointer to user supplied buffer (system will *
* allocate space if buffer is NULL) *
* long - size of the user provided buffer *
* GBC_Enum - flags if this is defined as a direct draw *
* surface *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 10/09/1995 : Created. *
*=========================================================================*/
void GraphicBufferClass::Init(int w, int h, void *buffer, long size, GBC_Enum flags)
{
Size = size; // find size of physical buffer
Width = w; // Record width of Buffer
Height = h; // Record height of Buffer
//
// If the surface we are creating is a direct draw object then
// we need to do a direct draw init. Otherwise we will do
// a normal alloc.
//
if (flags & (GBC_VIDEOMEM | GBC_VISIBLE)) {
DD_Init(flags);
} else {
if (buffer) { // if buffer is specified
Buffer = (BYTE *)buffer; // point to it and mark
Allocated = FALSE; // it as user allocated
} else {
if (!Size) Size = w*h;
Buffer = new BYTE[Size]; // otherwise allocate it and
Allocated = TRUE; // mark it system alloced
}
Offset = (long)Buffer; // Get offset to the buffer
IsDirectDraw = FALSE;
}
Pitch = 0; // Record width of Buffer
XAdd = 0; // Record XAdd of Buffer
XPos = 0; // Record XPos of Buffer
YPos = 0; // Record YPos of Buffer
GraphicBuff = this; // Get a pointer to our self
}
/***********************************************************************************************
* GBC::Un_Init -- releases the video surface belonging to this gbuffer *
* *
* *
* *
* INPUT: Nothing *
* *
* OUTPUT: Nothing *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 6/6/96 12:44PM ST : Created *
*=============================================================================================*/
void GraphicBufferClass::Un_Init (void)
{
if ( IsDirectDraw ){
if ( VideoSurfacePtr ){
while ( LockCount ){
if (VideoSurfacePtr->Unlock ( NULL ) == DDERR_SURFACELOST){
if (Gbuffer_Focus_Loss_Function){
Gbuffer_Focus_Loss_Function();
}
AllSurfaces.Restore_Surfaces();
}
}
AllSurfaces.Remove_DD_Surface (VideoSurfacePtr);
VideoSurfacePtr->Release();
VideoSurfacePtr = NULL;
}
}
}
/***************************************************************************
* GBC::GRAPHICBUFFERCLASS -- Default constructor (requires explicit init) *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 10/09/1995 : Created. *
*=========================================================================*/
GraphicBufferClass::GraphicBufferClass(void)
{
GraphicBuff = this; // Get a pointer to our self
VideoSurfacePtr = NULL;
memset(&VideoSurfaceDescription, 0, sizeof(DDSURFACEDESC));
}
/***************************************************************************
* GBC::GRAPHICBUFFERCLASS -- Constructor for fixed size buffers *
* *
* INPUT: long size - size of the buffer to create *
* int w - width of buffer in pixels (default = 320) *
* int h - height of buffer in pixels (default = 200) *
* void *buffer - a pointer to the buffer if any (optional) *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 05/13/1994 PWG : Created. *
*=========================================================================*/
GraphicBufferClass::GraphicBufferClass(int w, int h, void *buffer, long size)
{
Init(w, h, buffer, size, GBC_NONE);
}
/*=========================================================================*
* GBC::GRAPHICBUFFERCLASS -- inline constructor for GraphicBufferClass *
* *
* INPUT: int w - width of buffer in pixels (default = 320) *
* int h - height of buffer in pixels (default = 200) *
* void *buffer - a pointer to the buffer if any (optional) *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 05/03/1994 PWG : Created. *
*=========================================================================*/
GraphicBufferClass::GraphicBufferClass(int w, int h, void *buffer)
{
Init(w, h, buffer, w * h, GBC_NONE);
}
/*====================================================================================*
* GBC::GRAPHICBUFFERCLASS -- contructor for GraphicsBufferClass with special flags *
* *
* INPUT: int w - width of buffer in pixels (default = 320) *
* int h - height of buffer in pixels (default = 200) *
* void *buffer - unused *
* unsigned flags - flags for creation of special buffer types *
* GBC_VISIBLE - buffer is a visible screen surface *
* GBC_VIDEOMEM - buffer resides in video memory *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 09-21-95 04:19pm ST : Created *
*====================================================================================*/
GraphicBufferClass::GraphicBufferClass(int w, int h, GBC_Enum flags)
{
Init(w, h, NULL, w * h, flags);
}
/*=========================================================================*
* GBC::~GRAPHICBUFFERCLASS -- Destructor for the graphic buffer class *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 05/03/1994 PWG : Created. *
*=========================================================================*/
GraphicBufferClass::~GraphicBufferClass()
{
//
// Release the direct draw surface if it exists
//
Un_Init();
}
/***************************************************************************
* SET_LOGIC_PAGE -- Sets LogicPage to new buffer *
* *
* INPUT: GraphicBufferClass * the buffer we are going to set *
* *
* OUTPUT: GraphicBufferClass * the previous buffer type *
* *
* WARNINGS: *
* *
* HISTORY: *
* 02/23/1995 PWG : Created. *
*=========================================================================*/
GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass *ptr)
{
GraphicViewPortClass *old = LogicPage;
LogicPage = ptr;
return(old);
}
/***************************************************************************
* SET_LOGIC_PAGE -- Sets LogicPage to new buffer *
* *
* INPUT: GraphicBufferClass & the buffer we are going to set *
* *
* OUTPUT: GraphicBufferClass * the previous buffer type *
* *
* WARNINGS: *
* *
* HISTORY: *
* 02/23/1995 PWG : Created. *
*=========================================================================*/
GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass &ptr)
{
GraphicViewPortClass *old = LogicPage;
LogicPage = &ptr;
return(old);
}
/***************************************************************************
* GBC::LOCK -- Locks a Direct Draw Surface *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 10/09/1995 : Created. *
* 10/09/1995 : Code stolen from Steve Tall *
*=========================================================================*/
extern void Colour_Debug (int call_number);
extern bool GameInFocus;
extern void Block_Mouse(GraphicBufferClass *buffer);
extern void Unblock_Mouse(GraphicBufferClass *buffer);
BOOL GraphicBufferClass::Lock(void)
{
HRESULT result;
int restore_attempts=0;
//
// If its not a direct draw surface then the lock is always sucessful.
//
if (!IsDirectDraw) return(TRUE);
/*
** If the video surface pointer is null then return
*/
if (!VideoSurfacePtr) return (FALSE);
/*
** If we dont have focus then return failure
*/
if (!GameInFocus) return (FALSE);
Block_Mouse(this);
//
// If surface is already locked then inc the lock count and return true
//
if (LockCount){
LockCount++;
Unblock_Mouse(this);
return(TRUE);
}
//
// If it isn't locked at all then we will have to request that Direct
// Draw actually lock the surface.
//
if (VideoSurfacePtr){
while (!LockCount && restore_attempts<2) {
result = VideoSurfacePtr->Lock ( NULL
, &(VideoSurfaceDescription)
, DDLOCK_WAIT
, NULL);
switch (result){
case DD_OK :
Offset = (unsigned long)VideoSurfaceDescription.lpSurface;
Pitch = VideoSurfaceDescription.lPitch;
Pitch -= Width;
LockCount++; // increment count so we can track if
TotalLocks++; // Total number of times we have locked (for debugging)
//Colour_Debug (1);
Unblock_Mouse(this);
return (TRUE); // we locked it multiple times.
case DDERR_SURFACELOST :
if (Gbuffer_Focus_Loss_Function){
Gbuffer_Focus_Loss_Function();
}
AllSurfaces.Restore_Surfaces();
restore_attempts++;
break;
default :
Unblock_Mouse(this);
return (FALSE);
}
}
}
//Colour_Debug(1);
Unblock_Mouse(this);
return (FALSE); //Return false because we couldnt lock or restore the surface
}
/***************************************************************************
* GBC::UNLOCK -- Unlocks a direct draw surface *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 10/09/1995 : Created. *
* 10/09/1995 : Code stolen from Steve Tall *
*=========================================================================*/
BOOL GraphicBufferClass::Unlock(void)
{
//
// If there is no lock count or this is not a direct draw surface
// then just return true as there is no harm done.
//
if (!(LockCount && IsDirectDraw)) {
return(TRUE);
}
//
// If lock count is directly equal to one then we actually need to
// unlock so just give it a shot.
//
if (LockCount == 1 && VideoSurfacePtr) {
Block_Mouse(this);
if ( VideoSurfacePtr->Unlock ( NULL ) != DD_OK ){
Unblock_Mouse(this);
return(FALSE);
} else {
Offset=NOT_LOCKED;
LockCount--;
Unblock_Mouse(this);
return(TRUE);
}
}
//Colour_Debug (0);
LockCount--;
return(TRUE);
}
/***********************************************************************************************
* GVPC::DD_Linear_Blit_To_Linear -- blit using the hardware blitter *
* *
* *
* *
* INPUT: destination vvpc *
* x coord to blit from *
* y coord to blit from *
* x coord to blit to *
* y coord to blit to *
* width to blit *
* height to blit *
* *
* OUTPUT: DD_OK if successful *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 09-22-95 11:05am ST : Created *
*=============================================================================================*/
HRESULT GraphicViewPortClass::DD_Linear_Blit_To_Linear (
GraphicViewPortClass &dest
, int source_x
, int source_y
, int dest_x
, int dest_y
, int width
, int height
, BOOL mask )
{
RECT source_rectangle;
RECT dest_rectangle;
int key_source=0;
if ( mask ){
key_source=DDBLT_KEYSRC;
}
source_rectangle.left = source_x;
source_rectangle.top = source_y;
source_rectangle.right = source_x+width;
source_rectangle.bottom = source_y+height;
dest_rectangle.left = dest_x;
dest_rectangle.top = dest_y;
dest_rectangle.right = dest_x+width;
dest_rectangle.bottom = dest_y+height;
return ( dest.GraphicBuff->Get_DD_Surface()->Blt ( &dest_rectangle,
GraphicBuff->Get_DD_Surface(),
&source_rectangle,
key_source | DDBLT_WAIT | DDBLT_ASYNC,
NULL ) );
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,48 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 32 Bit Library *
;* *
;* File Name : GBUFFER.INC *
;* *
;* Programmer : Phil W. Gorrow *
;* *
;* Start Date : May 26, 1994 *
;* *
;* Last Update : May 26, 1994 [PWG] *
;* *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;******************************************************************************
; Much testing was done to determine that only when there are 14 or more bytes
; being copied does it speed the time it takes to do copies in this algorithm.
; For this reason and because 1 and 2 byte copies crash, is the special case
; used. SKB 4/21/94. Tested on 486 66mhz. Copied by PWG 6/7/04.
OPTIMAL_BYTE_COPY equ 14
GraphicViewPort struct
GVPOffset DD ? ; offset to virtual viewport
GVPWidth DD ? ; width of virtual viewport
GVPHeight DD ? ; height of virtual viewport
GVPXAdd DD ? ; x mod to get to next line
GVPXPos DD ? ; x pos relative to Graphic Buff
GVPYPos DD ? ; y pos relative to Graphic Buff
GVPPitch dd ? ; modulo of graphic view port
GVPBuffPtr DD ? ; ptr to associated Graphic Buff
GraphicViewPort ends

View file

@ -0,0 +1,358 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : GETSHAPE.CPP *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : April 5, 1992 *
* *
* Last Update : May 25, 1994 [BR] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Get_Shape_Size -- Fetch the size of the shape in memory. *
* Get_Shape_Uncomp_Size -- gets shape's uncompressed size in bytes *
* Get_Shape_Data -- retrieves a shape's special prefix data *
* Extract_Shape_Count -- returns # of shapes in the given shape block *
* Extract_Shape -- Gets pointer to shape in given shape block *
* Get_Shape_Width -- gets shape width in pixels *
* Get_Shape_Height -- gets shape height in pixels *
* Set_Shape_Height -- modifies shape's height *
* Restore_Shape_Height -- restores a shape to its original height *
* Get_Shape_Original_Height -- gets shape's unmodified height *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
********************************* Includes **********************************
*/
#include "wwstd.h"
#include "shape.h"
/***************************************************************************
* Get_Shape_Size -- Fetch the size of the shape in memory. *
* *
* The shape size returned includes both the shape header & its data. *
* *
* INPUT: *
* shape pointer to shape *
* *
* OUTPUT: *
* shape's size in memory *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int cdecl Get_Shape_Size(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
/*
------------------------- Return if NULL pointer -------------------------
*/
if (!shape)
return(0);
/*
-------------------------- Returns shape's size --------------------------
*/
return (shp->ShapeSize);
} /* end of Get_Shape_Size */
/***************************************************************************
* Get_Shape_Uncomp_Size -- gets shape's uncompressed size in bytes *
* *
* INPUT: *
* shape pointer to shape *
* *
* OUTPUT: *
* shape's size in bytes when uncompressed *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int Get_Shape_Uncomp_Size(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
return (shp->DataLength);
} /* end of Get_Shape_Uncomp_Size */
/***************************************************************************
* Get_Shape_Data -- retrieves a shape's special prefix data *
* *
* MAKESHPS.EXE can store special data values along with a shape. These *
* values are inserted in the shape table >before< the shape's header. *
* So, this routine uses the 'data' parameter as a negative index from *
* the given shape pointer. *
* *
* INPUT: *
* shape pointer to shape *
* data index of WORD data value to get *
* *
* OUTPUT: *
* data value *
* *
* WARNINGS: *
* The shape pointer must be a pointer into a shape table created by *
* MAKESHPS.EXE; it >cannot< be a pointer to shape returned by Make_Shape! *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
WORD cdecl Get_Shape_Data(VOID const *shape, WORD data)
{
WORD *word_ptr = (WORD *)shape;
WORD retval;
retval = *(word_ptr - (data+1));
return (retval);
} /* end of Get_Shape_Data */
/***************************************************************************
* Extract_Shape_Count -- returns # of shapes in the given shape block *
* *
* The # of shapes in a shape block is the first WORD in the block, so *
* this is the value returned. *
* *
* INPUT: *
* buffer pointer to shape block, created with MAKESHPS.EXE *
* *
* OUTPUT: *
* # shapes in the block *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int cdecl Extract_Shape_Count(VOID const *buffer)
{
ShapeBlock_Type *block = (ShapeBlock_Type *)buffer;
return (block->NumShapes);
} /* end of Extract_Shape_Count */
/***************************************************************************
* Extract_Shape -- Gets pointer to shape in given shape block *
* *
* INPUT: *
* buffer pointer to shape block, created with MAKESHPS.EXE *
* shape index of shape to get *
* *
* OUTPUT: *
* pointer to shape in the shape block *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
VOID * cdecl Extract_Shape(VOID const *buffer, int shape)
{
ShapeBlock_Type *block = (ShapeBlock_Type*) buffer;
//int numshapes; // Number of shapes
long offset; // Offset of shape data, from start of block
char *bytebuf = (char*) buffer;
/*
----------------------- Return if invalid argument -----------------------
*/
if (!buffer || shape < 0 || shape >= block->NumShapes)
return(NULL);
offset = block->Offsets[shape];
return(bytebuf + 2 + offset);
} /* end of Extract_Shape */
/***************************************************************************
* Get_Shape_Width -- gets shape width in pixels *
* *
* INPUT: *
* shape pointer to a shape *
* *
* OUTPUT: *
* shape width in pixels *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int Get_Shape_Width(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
return (shp->Width);
} /* end of Get_Shape_Width */
/***************************************************************************
* Get_Shape_Height -- gets shape height in pixels *
* *
* INPUT: *
* shape pointer to a shape *
* *
* OUTPUT: *
* shape height in pixels *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int Get_Shape_Height(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
return (shp->Height);
} /* end of Get_Shape_Height */
/***************************************************************************
* Set_Shape_Height -- modifies shape's height *
* *
* The new height must be shorter than the original height. This effect *
* chops off the lower portion of the shape, like it's sinking into the *
* ground. *
* *
* INPUT: *
* shape pointer to a shape *
* newheight new shape height *
* *
* OUTPUT: *
* old shape height *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int cdecl Set_Shape_Height(VOID const *shape, WORD newheight)
{
Shape_Type *shp = (Shape_Type *)shape;
WORD oldheight;
oldheight = shp->Height;
shp->Height = newheight;
return(oldheight);
} /* end of Set_Shape_Height */
/***************************************************************************
* Restore_Shape_Height -- restores a shape to its original height *
* *
* INPUT: *
* shape pointer to a shape *
* *
* OUTPUT: *
* old shape height *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int cdecl Restore_Shape_Height(VOID *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
WORD oldheight;
oldheight = shp->Height;
shp->Height = shp->OriginalHeight;
return(oldheight);
} /* end of Restore_Shape_Height */
/***************************************************************************
* Get_Shape_Original_Height -- gets shape's unmodified height *
* *
* INPUT: *
* shape pointer to a shape *
* *
* OUTPUT: *
* shape's unmodified height *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int Get_Shape_Original_Height(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
return (shp->OriginalHeight);
} /* end of Get_Shape_Original_Height */
/************************* end of getshape.cpp *****************************/

View file

@ -0,0 +1,150 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***********************************************************************************************
*** 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 : Drawbuff - Westwood win95 library *
* *
* File Name : Iconcach.H *
* *
* Programmer : Steve Tall *
* *
* Start Date : November 8th, 1995 *
* *
* Last Update : November 16th, 1995 [ST] *
* *
*---------------------------------------------------------------------------------------------*
* Overview: This file cantains definition of the IconCacheClass and associated non member *
* function prototypes. *
* *
* Functions: *
* IconCacheClass::Get_Is_Cached -- member to allow access to private IsCached flag *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef ICONCACH_H
#define ICONCACH_H
#include <tile.h>
#define ICON_WIDTH 24 // Icons must be this width to be cached
#define ICON_HEIGHT 24 // Icons must be this height to be cached
#define MAX_CACHED_ICONS 500 // Maximum number of icons that can be cached
#define MAX_ICON_SETS 100 // Maximum number of icon sets that can be registered
#define MAX_LOOKUP_ENTRIES 3000 // Size of icon index table
/*
** IconCacheClass for tracking individual icons cached into video memory
**
** Use Register_Icon_Set to identify a set of icons as cachable. Once registered, the icons
** will be cached automatically when drawn.
** Use Invalidate_Cached_Icons at the end of icon drawing to release the video memory used by the
** caching system.
** Restore_Cached_Icons may be used to reload the icons into video memory after a focus loss.
**
*/
class IconCacheClass {
public:
IconCacheClass (void); // class constructor
~IconCacheClass (void); // class destructor
void Restore(void); // restore the surface
BOOL Cache_It (void * icon_ptr); // Cache the icon to video memory
void Uncache_It (void); // Restore the video memory and flag the icon as uncached
void Draw_It (LPDIRECTDRAWSURFACE dest_surface , int x_pixel, int y_pixel, int window_left , int window_top , int window_width , int window_height);
inline BOOL Get_Is_Cached(void); // Return the IsCached member
int TimesDrawn; // counter of times cached icon has been drawn
int TimesFailed; // counter of times cached icon has failed to draw
private:
LPDIRECTDRAWSURFACE CacheSurface; // Ptr to direct draw surface where icon resides
BOOL IsCached; // Flag to say whether an icon is cached
BOOL SurfaceLost; // Flag to indicate that our icons surface has been lost
int DrawFrequency; // Number of times icon has been drawn
void *IconSource; // Ptr to original icon data in system memory
};
/*
** Structure to keep track of registered icon sets
**
*/
typedef struct tIconSetType{
IControl_Type *IconSetPtr; // Ptr to icon set data
int IconListOffset; // Offset into icon index table for this icon set
}IconSetType;
extern IconCacheClass CachedIcons[MAX_CACHED_ICONS];
extern void Invalidate_Cached_Icons (void);
extern void Restore_Cached_Icons (void);
extern void Register_Icon_Set (void *icon_data , BOOL pre_cache);
//
// Prototypes for assembly language procedures in STMPCACH.ASM
//
extern "C" void Clear_Icon_Pointers (void);
extern "C" void Cache_Copy_Icon (void const *icon_ptr ,void * , int);
extern "C" int Is_Icon_Cached (void const *icon_data , int icon);
extern "C" int Get_Icon_Index (void *icon_ptr);
extern "C" int Get_Free_Index (void);
extern "C" BOOL Cache_New_Icon (int icon_index, void *icon_ptr);
extern "C" int Get_Free_Cache_Slot(void);
extern int CachedIconsDrawn;
extern int UnCachedIconsDrawn;
/***********************************************************************************************
* ICC::Get_Is_Cached -- member to allow access to the private IsCached flag *
* *
* *
* *
* INPUT: Nothing *
* *
* OUTPUT: IsCached *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 11/13/95 9:42AM ST : Created *
*=============================================================================================*/
inline BOOL IconCacheClass::Get_Is_Cached (void)
{
return (IsCached);
}
#endif //ICONCACH_H

View file

@ -0,0 +1,340 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Library *
* *
* File Name : ICONSET.C *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : June 9, 1991 *
* *
* Last Update : September 15, 1993 [JLB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Load_Icon_Set -- Loads an icons set and initializes it. *
* Free_Icon_Set -- Frees allocations made by Load_Icon_Set(). *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//#include "function.h"
//#define _WIN32
//#define WIN32_LEAN_AND_MEAN
#include <dos.h>
#include <stdlib.h>
#include <stdio.h>
//#include <mem.h>
#include <wwstd.h>
#include <file.h>
#include "tile.h"
#include <iff.h>
// Misc? ST - 1/3/2019 10:40AM
//extern int Misc;
int Misc;
void * Load_Icon_Set(char const *filename, void *iconsetptr, long buffsize);
void Free_Icon_Set(void const *iconset);
long Get_Icon_Set_Size(void const *iconset);
int Get_Icon_Set_Width(void const *iconset);
int Get_Icon_Set_Height(void const *iconset);
void * Get_Icon_Set_Icondata(void const *iconset);
void * Get_Icon_Set_Trans(void const *iconset);
void * Get_Icon_Set_Remapdata(void const *iconset);
void * Get_Icon_Set_Palettedata(void const *iconset);
int Get_Icon_Set_Count(void const *iconset);
void * Get_Icon_Set_Map(void const *iconset);
//#define ICON_PALETTE_BYTES 16
//#define ICON_MAX 256
/***************************************************************************
** The terrain is rendered by using icons. These are the buffers that hold
** the icon data, remap tables, and remap index arrays.
*/
//PRIVATE char *IconPalette = NULL; // MCGA only.
//PRIVATE char *IconRemap = NULL; // MCGA only.
#define FORM_RPAL MAKE_ID('R','P','A','L')
#define FORM_RTBL MAKE_ID('R','T','B','L')
#define FORM_SSET MAKE_ID('S','S','E','T')
#define FORM_SINF MAKE_ID('S','I','N','F')
#define FORM_ICON MAKE_ID('I','C','O','N')
#define FORM_TRNS MAKE_ID('T','R','N','S')
#define FORM_MAP MAKE_ID('M','A','P',' ')
/***************************************************************************
* LOAD_ICON_SET -- Loads an icons set and initializes it. *
* *
* This routine will load an IFF icon set from disk. It handles all *
* of the necessary allocations. *
* *
* INPUT: filename -- Name of the icon file. *
* *
* buffer -- Pointer to paragraph aligned buffer to hold data. *
* *
* size -- Size of the buffer (in bytes). *
* *
* OUTPUT: none *
* *
* WARNINGS: In EEGA mode the iconset buffer will be free because the *
* icons will have been transferred to card ram. *
* *
* HISTORY: *
* 06/21/1991 JLB : Created. *
* 07/01/1991 JLB : Determines icon size from file. *
* 07/15/1991 JLB : Load and uncompress onto the same buffer. *
* 09/15/1993 JLB : Added EMS support. *
*=========================================================================*/
void * Load_Icon_Set(char const *filename, void *iconsetptr, long buffsize)
{
int fh; // File handle of iconset.
int bytespericon; // The number of bytes per icon.
unsigned long icons=0; // Number of icons loaded.
unsigned long size; // Size of the icon chunk (raw).
unsigned long transsize;
void *transptr=NULL;
unsigned long mapsize; // Icon map chunk size.
void *mapptr=NULL; // Icon map pointer.
void *returnptr=NULL; // Iconset pointer returned by routine.
BOOL allocated=FALSE; // Was the iconset block allocated?
IControl_Type *idata=NULL; // Icon data loaded.
long id; // ID of file openned.
struct {
char Width; // Width of icon in bytes.
char Height; // Height of icon in bytes.
char Format; // Graphic mode.
//lint -esym(754,Format)
char Bitplanes; // Number of bitplanes per icon.
} sinf;
/*
** Open the icon set for loading. If it is not a legal icon set
** data file, then abort.
*/
fh = Open_Iff_File(filename);
if (fh != WW_ERROR) {
Read_File(fh, &id, sizeof(long));
if (id == FORM_ICON) {
/*
** Determine the size of the icons and set up the graphic
** system accordingly. Also get the sizes of the various
** data blocks that have to be loaded.
*/
Read_Iff_Chunk(fh, FORM_SINF, &sinf, sizeof(sinf));
bytespericon = ((((int)sinf.Width)<<3)*(((int)sinf.Height)<<3)*(int)sinf.Bitplanes)>>3;
size = Get_Iff_Chunk_Size(fh,FORM_SSET);
transsize = Get_Iff_Chunk_Size(fh, FORM_TRNS);
mapsize = Get_Iff_Chunk_Size(fh, FORM_MAP);
/*
** Allocate the icon buffer if one isn't provided. First try EMS and
** then try conventional RAM.
*/
allocated = FALSE;
if (!iconsetptr) {
buffsize = size + transsize + mapsize + sizeof(IControl_Type);
Misc = buffsize;
iconsetptr = Alloc(buffsize, MEM_NORMAL);
allocated = (iconsetptr != NULL);
}
if (iconsetptr && (size+transsize+mapsize+sizeof(IControl_Type)) <= (unsigned long)buffsize) {
idata = (IControl_Type *)iconsetptr;
memset(idata, 0, sizeof(IControl_Type));
/*
** Initialize the iconset header structure.
*/
idata->Width = (short)(((short)sinf.Width)<<3);
idata->Height = (short)(((short)sinf.Height)<<3);
idata->Allocated = (short)allocated;
idata->Icons = (unsigned char *)iconsetptr + sizeof(IControl_Type);
idata->Map = (unsigned char *) (idata->Icons + size);
idata->TransFlag = sizeof(IControl_Type) + size + mapsize;
idata->Size = buffsize;
{
long val;
val = Read_Iff_Chunk(fh, FORM_SSET, Add_Long_To_Pointer(iconsetptr, sizeof(IControl_Type)), size);
icons = (int)(val/(long)bytespericon);
idata = (IControl_Type *)iconsetptr;
}
if (mapsize) {
icons = mapsize;
}
idata->Count = (short)icons;
/*
** Limit buffer to only the size needed. This is done AFTER loading of the
** raw icon data because it might have been compressed and thus need any
** extra space to perform an overlapped decompression.
*/
if ((unsigned long)buffsize > size + transsize + mapsize + sizeof(IControl_Type)) {
buffsize = size + transsize + mapsize + sizeof(IControl_Type);
}
transptr = Add_Long_To_Pointer(iconsetptr, idata->TransFlag);
Read_Iff_Chunk(fh, FORM_TRNS, transptr, transsize);
idata = (IControl_Type *)iconsetptr;
mapptr = (void*)idata->Map;
Read_Iff_Chunk(fh, FORM_MAP, mapptr, mapsize);
/*
** Let the graphic overlay know of the icon data. This could involve
** translation and other data manipulations.
*/
//Init_Stamps(iconsetptr);
returnptr = iconsetptr;
}
}
Close_Iff_File(fh);
}
return (returnptr); // Return with icon pointer.
}
/***************************************************************************
* FREE_ICON_SET -- Frees allocations made by Load_Icon_Set(). *
* *
* This routine is used to free up any allocations by Load_Icon_Set(). *
* Use this routine when a new icon set is to be loaded. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/21/1991 JLB : Created. *
*=========================================================================*/
void Free_Icon_Set(void const *iconset)
{
IControl_Type *icontrol;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
if (icontrol->Allocated) {
Free((void *)iconset);
}
}
}
long Get_Icon_Set_Size(void const *iconset)
{
IControl_Type *icontrol;
long size=0;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
size = icontrol->Size;
}
return(size);
}
int Get_Icon_Set_Width(void const *iconset)
{
IControl_Type *icontrol;
int width=0;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
width = icontrol->Width;
}
return(width);
}
int Get_Icon_Set_Height(void const *iconset)
{
IControl_Type *icontrol;
int height=0;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
height = icontrol->Height;
}
return(height);
}
void * Get_Icon_Set_Icondata(void const *iconset)
{
IControl_Type *icontrol;
icontrol = (IControl_Type *)iconset;
if (icontrol)
return(Add_Long_To_Pointer(iconset, (LONG)icontrol->Icons));
return(NULL);
}
void * Get_Icon_Set_Trans(void const *iconset)
{
IControl_Type *icontrol;
void *ptr=NULL;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
ptr = Add_Long_To_Pointer((void *)iconset, icontrol->TransFlag);
}
return(ptr);
}
int Get_Icon_Set_Count(void const *iconset)
{
IControl_Type *icontrol;
int count;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
count = icontrol->Count;
}
return(count);
}
void * Get_Icon_Set_Map(void const *iconset)
{
IControl_Type *icontrol;
icontrol = (IControl_Type *)iconset;
if (icontrol)
return(Add_Long_To_Pointer(iconset, (LONG)icontrol->Map));
return(NULL);
}

View file

@ -0,0 +1,325 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : IFF.C *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : May 16, 1991 *
* *
* Last Update : April 19, 1994 [SKB] *
* *
* *
* IFF reader code designed for loading pictures (ILBM or PBM). *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Close_Iff_File -- Closes an IFF file handle. *
* Get_Iff_Chunk_Size -- Get the size of the given IFF chunk. *
* Open_Iff_File -- Opens an IFF file for reading. *
* Read_Iff_Chunk -- Reads a chunk from an IFF file. *
* Write_Iff_Chunk -- Writes an IFF chuck out. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "iff.h"
#include "file.h"
#define ID_FORM MAKE_ID('F','O','R','M')
#ifdef MIN
#undef MIN
#endif
/***************************************************************************
* OPEN_IFF_FILE -- Opens an IFF file for reading. *
* *
* This function will open an IFF file for reading. It will perform *
* a the simple validity test of checking the first four bytes to make *
* sure they are "FORM". The value returned is the filehandle of the *
* opened file. *
* *
* INPUT: filename - ASCII name of the IFF file to be opened. *
* *
* OUTPUT: Returns the filehandle. If there is an error or the file *
* is not an IFF FORM then -1 will be returned. *
* *
* WARNINGS: You are responsible for error handling if this function *
* returns -1 (not an IFF file). *
* *
* HISTORY: *
* 05/16/1991 JLB : Created. *
* 04/19/1994 SKB : Update to 32 bit library. *
*=========================================================================*/
int __cdecl Open_Iff_File(char const *filename)
{
int fh; // File handle.
long type; // IFF file type.
/* We want to be able to open the file for READ | WRITE, but we do not
want the Open_File to create it. So check to see if it exists before
the Open_File */
// fh = Open_File(filename, READ); // Open the source file for READ
// Close_File(fh);
//fh = Open_File(filename, READ | WRITE); // Open the source file again
fh = Open_File(filename, READ); // Open the source file again
// Validate that it is a FORM type.
Read_File(fh, &type, 4L);
if (type == ID_FORM) {
// The file is valid (so far). Position the read so that the actual
// IFF file type code can be read.
Seek_File(fh, 4L, SEEK_CUR); // Skip the filesize bytes.
} else {
// This is NOT an IFF file. Close the source file and return with
// the error code.
Close_File(fh);
fh = WW_ERROR;
}
return fh;
}
/***************************************************************************
* CLOSE_IFF_FILE -- Closes an IFF file handle. *
* *
* The routine will close the file that was opened with the *
* Open_Iff_File() function. *
* *
* INPUT: fh - File handle that was returned from Open_Iff_File(). *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/16/1991 JLB : Created. *
* 04/19/1994 SKB : Update to 32 bit library. *
*=========================================================================*/
void __cdecl Close_Iff_File(int fh)
{
if (fh != WW_ERROR) Close_File(fh);
}
/***************************************************************************
* GET_IFF_CHUNK_SIZE -- Get the size of the given IFF chunk. *
* *
* INPUT: int file handle to open IFF file, long id to get size of *
* *
* OUTPUT: long size of the chunk or 0L if it was not found *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/03/1991 CY : Created. *
* 04/19/1994 SKB : Update to 32 bit library. *
*=========================================================================*/
unsigned long __cdecl Get_Iff_Chunk_Size(int fh, long id)
{
long form; // Chunk iff form name.
long chunksize; // Size of the chunk.
char first_iteration; // Check once the current chunk name
first_iteration = TRUE;
for (;;) {
if (Read_File(fh, &form, 4L) != 4L && !first_iteration) break;
if (Read_File(fh, (char *) &chunksize, 4L) != 4L && !first_iteration) break;
#if(IBM)
chunksize = Reverse_Long(chunksize);
#endif
if (id == form) {
Seek_File(fh, -8L, SEEK_CUR); // Seek back to the start of
return(chunksize); // the chunk & return size
} else {
if (first_iteration) {
Seek_File(fh, 12L, SEEK_SET); // Start at beginning of file.
first_iteration = FALSE; // Don't do this again
} else {
/* Otherwise, go to the next chunk in the file */
chunksize = (chunksize + 1) & 0xFFFFFFFEL;
Seek_File(fh, chunksize, SEEK_CUR);
}
}
}
return(0L);
}
/***************************************************************************
* READ_IFF_CHUNK -- Reads a chunk from an IFF file. *
* *
* Once an IFF file is opened, various chunks must be read from it. *
* This routine will search through the IFF file and load in the *
* specified chunk. It will scan through the entire file when *
* searching for the chunk. It will load the FIRST chunk of the given *
* type. *
* *
* INPUT: fh - File handle of IFF file. *
* *
* id - Chunk ID code. *
* *
* buffer - Pointer to buffer to load the chunk. *
* *
* maxsize - Maximum data bytes to read. *
* *
* OUTPUT: Returns with the number of bytes read from the chunk. *
* If 0 is returned, this indicates that the chunk wasn't *
* found. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/16/1991 JLB : Created. *
* 04/19/1994 SKB : Update to 32 bit library. *
*=========================================================================*/
unsigned long __cdecl Read_Iff_Chunk(int fh, long id, void *buffer, unsigned long maxsize)
{
long form; // Chunk iff form name.
unsigned long chunksize; // Size of the chunk.
char first_iteration; // Check once the current chunk name
first_iteration = TRUE;
for (;;) {
if (Read_File(fh, &form, 4L) != 4L && !first_iteration) break;
if (Read_File(fh, (char *) &chunksize, 4L) != 4L && !first_iteration) break;
#if(IBM)
chunksize = Reverse_Long(chunksize);
#endif
if (id == form) {
maxsize = MIN(maxsize, chunksize);
Read_File(fh, buffer, maxsize); // Read the buffer.
chunksize = (chunksize + 1) & 0xFFFFFFFEL;
if (maxsize < chunksize) {
Seek_File(fh, chunksize - maxsize, SEEK_CUR);
}
return(maxsize);
} else {
if (first_iteration) {
Seek_File(fh, 12L, SEEK_SET); // Start at beginning of file.
first_iteration = FALSE; // Don't do this again
} else {
/* Otherwise, go to the next chunk in the file */
chunksize = (chunksize + 1) & 0xFFFFFFFEL;
Seek_File(fh, chunksize, SEEK_CUR);
}
}
}
return(0L);
}
/***************************************************************************
* WRITE_IFF_CHUNK -- Writes an IFF chuck out. *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 04/19/1994 SKB : Created. *
*=========================================================================*/
void __cdecl Write_Iff_Chunk(int file, long id, void *buffer, long length)
{
long pos; // Current position in the IFF file.
long oldpos; // Record of start of chunk offset.
long endpos; // end of file offset before we write our data
long value;
BOOL odd; // Is length odd?
char pad = 0; // Optional padding byte for even sized chunks.
/*
** Get the current end of file (before we write more data to the file)
*/
pos = Seek_File (file, 0L, SEEK_CUR);
endpos = Seek_File (file, 0L, SEEK_END);
Seek_File (file, pos, SEEK_SET);
if (length) {
value = id;
odd = (short)length & 0x01;
Write_File(file, &value, 4L);
oldpos = Seek_File(file, 0L, SEEK_CUR);
Write_File(file, &value, 4L);
Write_File(file, buffer, length);
pos = Seek_File(file, 0L, SEEK_CUR);
if (odd) {
Write_File(file, &pad, 1L);
}
/*
** Update the chunk size long.
*/
Seek_File(file, oldpos, SEEK_SET);
value = IFFize_LONG((pos - oldpos)-4);
Write_File(file, &value, 4L);
/*
** Update the file size LONG. if we are not just overwriting existing data
*/
// (MCC)
if ( endpos < pos ) {
Seek_File(file, 4L, SEEK_SET);
value = IFFize_LONG((pos+odd) - 8);
Write_File(file, &value, 4L);
}
/*
** Return to end of file.
*/
Seek_File(file, 0L, SEEK_END);
}
}

164
TIBERIANDAWN/WIN32LIB/IFF.H Normal file
View file

@ -0,0 +1,164 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Part of the FILEIO Library *
* *
* File Name : IFF.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : April 20, 1994 *
* *
* Last Update : April 20, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef IFF_H
#define IFF_H
#ifndef GBUFFER_H
#include <gbuffer.h>
#endif
#ifndef MISC_H
#include <misc.h> // This is needed fro Reverse_WORD and _LONG
#endif
#ifndef MEMFLAGS_H
#include <memflag.h> // This is needed for MemoryFlagType.
#endif
#define LZW_SUPPORTED FALSE
/*=========================================================================*/
/* Iff and Load Picture system defines and enumerations */
/*=========================================================================*/
#define MAKE_ID(a,b,c,d) ((long) ((long) d << 24) | ((long) c << 16) | ((long) b << 8) | (long)(a))
#define IFFize_WORD(a) Reverse_Word(a)
#define IFFize_LONG(a) Reverse_Long(a)
//lint -strong(AJX,PicturePlaneType)
typedef enum {
BM_AMIGA, // Bit plane format (8K per bitplane).
BM_MCGA, // Byte per pixel format (64K).
BM_DEFAULT=BM_MCGA // Default picture format.
} PicturePlaneType;
/*
** This is the compression type code. This value is used in the compressed
** file header to indicate the method of compression used. Note that the
** LZW method may not be supported.
*/
//lint -strong(AJX,CompressionType)
typedef enum {
NOCOMPRESS, // No compression (raw data).
LZW12, // LZW 12 bit codes.
LZW14, // LZW 14 bit codes.
HORIZONTAL, // Run length encoding (RLE).
LCW // Westwood proprietary compression.
} CompressionType;
/*
** Compressed blocks of data must start with this header structure.
** Note that disk based compressed files have an additional two
** leading bytes that indicate the size of the entire file.
*/
//lint -strong(AJX,CompHeaderType)
typedef struct {
char Method; // Compression method (CompressionType).
char pad; // Reserved pad byte (always 0).
long Size; // Size of the uncompressed data.
short Skip; // Number of bytes to skip before data.
} CompHeaderType;
/*=========================================================================*/
/* The following prototypes are for the file: IFF.CPP */
/*=========================================================================*/
int __cdecl Open_Iff_File(char const *filename);
void __cdecl Close_Iff_File(int fh);
unsigned long __cdecl Get_Iff_Chunk_Size(int fh, long id);
unsigned long __cdecl Read_Iff_Chunk(int fh, long id, void *buffer, unsigned long maxsize);
void __cdecl Write_Iff_Chunk(int file, long id, void *buffer, long length);
/*=========================================================================*/
/* The following prototypes are for the file: LOADPICT.CPP */
/*=========================================================================*/
int __cdecl Load_Picture(char const *filename, BufferClass& scratchbuf, BufferClass& destbuf, unsigned char *palette=NULL, PicturePlaneType format=BM_DEFAULT);
/*=========================================================================*/
/* The following prototypes are for the file: LOAD.CPP */
/*=========================================================================*/
unsigned long __cdecl Load_Data(char const *name, void *ptr, unsigned long size);
unsigned long __cdecl Write_Data(char const *name, void *ptr, unsigned long size);
void * __cdecl Load_Alloc_Data(char const *name, MemoryFlagType flags);
unsigned long __cdecl Load_Uncompress(char const *file, BufferClass& uncomp_buff, BufferClass& dest_buff, void *reserved_data=NULL);
unsigned long __cdecl Uncompress_Data(void const *src, void *dst);
void __cdecl Set_Uncomp_Buffer(int buffer_segment, int size_of_buffer);
/*=========================================================================*/
/* The following prototypes are for the file: WRITELBM.CPP */
/*=========================================================================*/
PUBLIC BOOL Write_LBM_File(int lbmhandle, BufferClass& buff, int bitplanes, unsigned char *palette);
/*========================= Assembly Functions ============================*/
#ifdef __cplusplus
extern "C" {
#endif
/*=========================================================================*/
/* The following prototypes are for the file: PACK2PLN.ASM */
/*=========================================================================*/
extern void __cdecl Pack_2_Plane(void *buffer, void * pageptr, int planebit);
/*=========================================================================*/
/* The following prototypes are for the file: LCWCOMP.ASM */
/*=========================================================================*/
extern unsigned long __cdecl LCW_Compress(void *source, void *dest, unsigned long length);
/*=========================================================================*/
/* The following prototypes are for the file: LCWUNCMP.ASM */
/*=========================================================================*/
extern unsigned long __cdecl LCW_Uncompress(void *source, void *dest, unsigned long length);
#ifdef __cplusplus
}
#endif
/*=========================================================================*/
#endif //IFF_H

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,176 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : LIBRARY *
* *
* File Name : IRANDOM.C *
* *
* Programmer : Barry W. Green *
* *
* Last Update : 10 Feb, 1995 [BWG] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <stdlib.h>
#include <time.h>
#include "misc.h"
extern "C" unsigned long RandNumb = 0x12349876;
/* IRANDOM ----------------------------------------------------------
IRandom returns a random value between min and max inclusive.
INPUTS: int min and int max
RETURNS: int random number
*/
int IRandom(int minval, int maxval)
{
int num,mask;
// Keep minval and maxval straight.
if (minval > maxval) {
minval ^= maxval;
maxval ^= minval;
minval ^= maxval;
}
mask = Get_Random_Mask(maxval - minval);
while( (num = (rand() & mask) + minval) > maxval ) ;
return(num);
}
unsigned char Random(void)
{
__asm {
lea esi, [RandNumb] //; get offset in segment of RandNumb
xor eax,eax
mov al,[esi]
shr al,1 //; shift right 1 bit (bit0 in carry)
shr al,1
rcl [BYTE PTR esi+2],1 //; rcl byte 3 of RandNumb
rcl [BYTE PTR esi+1],1 //; rcl byte 2 of RandNumb
cmc //; complement carry
sbb al,[esi] //; sbb byte 1 of RandNumb
shr al,1 //; sets carry
rcr [BYTE PTR esi],1 //; rcr byte 1 of RandNumb
mov al,[esi] //; reload byte 1 of RandNumb
xor al,[esi+1] //; xor with byte 2 of RandNumb
}
}
int Get_Random_Mask(int maxval)
{
__asm {
bsr ecx,[maxval] // ; put bit position of highest bit in ecx
mov eax, 1 // ; set one bit on in eax
jz invalid // ; if BSR shows maxval==0, return eax=1
inc ecx // ; get one bit higher than count showed
shl eax,cl // ; move our EAX bit into position
dec eax // ; dec it to create the mask.
invalid:
}
}
#if (0)
RandNumb DD 12349876H
;
; UBYTE Random(VOID);
; int Get_Random_Mask(int maxval);
;
; ----------------------------------------------------------------
;-----------------------------------------------------------------
; RANDOM
;
; UBYTE Random(VOID);
;
;*
PROC Random C near
USES esi
lea esi, [RandNumb] ; get offset in segment of RandNumb
xor eax,eax
mov al,[esi]
shr al,1 ; shift right 1 bit (bit0 in carry)
shr al,1
rcl [BYTE PTR esi+2],1 ; rcl byte 3 of RandNumb
rcl [BYTE PTR esi+1],1 ; rcl byte 2 of RandNumb
cmc ; complement carry
sbb al,[esi] ; sbb byte 1 of RandNumb
shr al,1 ; sets carry
rcr [BYTE PTR esi],1 ; rcr byte 1 of RandNumb
mov al,[esi] ; reload byte 1 of RandNumb
xor al,[esi+1] ; xor with byte 2 of RandNumb
ret
ENDP Random
;-----------------------------------------------------------------
; GET_RANDOM_MASK - returns an AND value that is large enough that it
; encloses the 'maxval' parameter.
;
; int Get_Random_Mask(int maxval);
;
;*
PROC Get_Random_Mask C near
USES ecx
ARG maxval:DWORD
; This function takes as a parameter a maximum value, for example, 61. It
; then tries to create an AND mask that is big enough to enclose that number.
; For our example case, that AND mask would be 0x3F. It does this by scanning
; for the highest bit in the number, then making an all-1's mask from that
; bit position down to bit 0.
bsr ecx,[maxval] ; put bit position of highest bit in ecx
mov eax,1 ; set one bit on in eax
jz ??invalid ; if BSR shows maxval==0, return eax=1
inc ecx ; get one bit higher than count showed
shl eax,cl ; move our EAX bit into position
dec eax ; dec it to create the mask.
??invalid:
ret
ENDP Get_Random_Mask
;----------------------------------------------------------------------------
END
#endif

View file

@ -0,0 +1,533 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***********************************************************************************************
* *
* Project Name : Westwood Keyboard Library *
* *
* File Name : KEYBOARD.CPP *
* *
* Programmer : Philip W. Gorrow *
* *
* Start Date : 10/16/95 *
* *
* Last Update : October 26, 1995 [] *
* *
*---------------------------------------------------------------------------------------------*
* 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 *
* Check_Key -- compatability routine for old 32 bit library *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "keyboard.h"
#include "timer.h"
#include "mono.h"
void Message_Loop(void);
WWKeyboardClass *_Kbd;
/***********************************************************************************************
* WWKeyboardClass::WWKeyBoardClass -- Construction for Westwood Keyboard Class *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
WWKeyboardClass::WWKeyboardClass(void)
{
_Kbd = this;
//
// Initialize the keyboard remap table for our system (note it would be bad if someone
// switched keyboard modes after this happened.
//
memset(VKRemap, 0, 256);
memset(AsciiRemap, 0, 2048);
short lp;
for (lp = 31; lp < 255; lp ++) {
if (isprint(lp)) {
int vk_key = VkKeyScan((unsigned char)lp);
if (vk_key > 0 && vk_key < 2048) {
AsciiRemap[vk_key] = (unsigned char)lp;
VKRemap[lp] = (unsigned char)(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;
MState = 0;
Conditional = 0;
CurrentCursor = NULL;
}
/***********************************************************************************************
* 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) & 255]; // get the x and y pos
MouseQY = Buffer[(Head + 2) & 255]; // 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)
{
Message_Loop();
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] = (short)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. *
*=============================================================================================*/
BOOL 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. Note
// that we do not want to set the shift, ctrl and alt bits for Mouse keypresses as this
// would be incompatible with the dos version.
//
if (vk_key != VK_LBUTTON && vk_key != VK_MBUTTON && vk_key != VK_RBUTTON) {
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::Clear(void)
{
Head = Tail;
}
int WWKeyboardClass::To_ASCII(int key)
{
if ( key && WWKEY_RLS_BIT)
return(KN_NONE);
return(key);
}
int WWKeyboardClass::Down(int key)
{
return(GetAsyncKeyState(key&0xFF));
}
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);
}
extern "C" {
void __cdecl Stop_Execution (void);
}
//#pragma off(unreferenced)
void WWKeyboardClass::Message_Handler(HWND , UINT message, UINT wParam, LONG lParam)
{
return;
#if (0) // ST - 12/20/2018 11:27AM
switch (message) {
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
if ( wParam==VK_SCROLL ){
Stop_Execution();
} else {
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;
case WM_MOUSEMOVE:
if (CurrentCursor)
SetCursor(CurrentCursor);
break;
}
#endif
}
//#pragma on(unreferenced)
void Message_Loop(void)
{
MSG msg;
while (PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE )) {
if( !GetMessage( &msg, NULL, 0, 0 ) ){
return;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
/***************************************************************************
* CHECK_KEY -- compatability routine for old 32 bit library *
* *
* This routine checks to see if there is a key in the keyboard buffer *
* and returns it to the sender if there is. It does not remove the key *
* from the buffer. *
* *
* INPUT: none *
* *
* OUTPUT: The key that was pressed. *
* *
* WARNINGS: You must declare a WWKeyboardClass object before calling *
* this routine. *
* *
* HISTORY: *
* 10/26/1995 : Created. *
*=========================================================================*/
int Check_Key(void)
{
if (!_Kbd) return(KA_NONE);
return(_Kbd->Check() & ~WWKEY_SHIFT_BIT);
}
void Clear_KeyBuffer(void)
{
if (!_Kbd) return;
_Kbd->Clear();
}
int Check_Key_Num(void)
{
if (!_Kbd) return(KN_NONE);
int key = _Kbd->Check();
int flags = key & 0xFF00;
key = key & 0x00FF;
if (isupper(key)) {
key = tolower(key);
if ( !(flags & WWKEY_VK_BIT) ) {
flags |= WWKEY_SHIFT_BIT;
}
}
return(key | flags);
}
int Get_Key_Num(void)
{
if (!_Kbd) return(KN_NONE);
int key = _Kbd->Get();
int flags = key & 0xFF00;
key = key & 0x00FF;
if (isupper(key)) {
key = tolower(key);
if ( !(flags & WWKEY_VK_BIT) ) {
flags |= WWKEY_SHIFT_BIT;
}
}
return(key | flags);
}
int KN_To_KA(int key)
{
if ( key & WWKEY_RLS_BIT) {
return(KA_NONE);
}
if (!(key & WWKEY_VK_BIT)) {
int flags = key & 0xFF00;
key = key & 0x00FF;
if (flags & WWKEY_SHIFT_BIT) {
key = toupper(key);
flags &= ~WWKEY_SHIFT_BIT;
}
}else{
/*
** If its a numeric keypad key then fix it up
*/
if ((key & 0xff) >=VK_NUMPAD0 && (key & 0xff) <=VK_NUMPAD9){
key = (key & 0xff) - VK_NUMPAD0 + KA_0;
}
}
return(key);
}
int KN_To_VK(int key)
{
if (!_Kbd) return(KN_NONE);
if ( key & WWKEY_RLS_BIT) {
return(VK_NONE);
}
int flags = key & 0xFF00;
if (!(flags & WWKEY_VK_BIT)) {
key = _Kbd->VKRemap[key & 0x00FF] | flags;
}
key &= ~WWKEY_VK_BIT;
return(key);
}
int Key_Down(int key)
{
if (!_Kbd) return(FALSE);
return(_Kbd->Down(key));
}
int Get_Key(void)
{
int retval;
if (!_Kbd) return(KN_NONE);
retval = _Kbd->Get() & ~WWKEY_SHIFT_BIT;
if (retval & WWKEY_RLS_BIT) {
retval = KN_NONE;
}
return(retval);
}

View file

@ -0,0 +1,675 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***********************************************************************************************
* *
* 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: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef KEYBOARD_H
#define KEYBOARD_H
#include <WWSTD.H>
typedef enum {
WWKEY_SHIFT_BIT = 0x100,
WWKEY_CTRL_BIT = 0x200,
WWKEY_ALT_BIT = 0x400,
WWKEY_RLS_BIT = 0x800,
WWKEY_VK_BIT = 0x1000,
WWKEY_DBL_BIT = 0x2000,
WWKEY_BTN_BIT = 0x8000,
} WWKey_Type;
class WWKeyboardClass
{
public:
/*===================================================================*/
/* Define the base constructor and destructors for the class */
/*===================================================================*/
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_VK(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);
/*===================================================================*/
/* Define the public access variables which are used with the */
/* Keyboard Class. */
/*===================================================================*/
int MouseQX;
int MouseQY;
unsigned char VKRemap[256]; // gives vk for any ascii char
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 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
int MState;
int Conditional;
HANDLE CurrentCursor;
};
#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
enum {
//
// Define all the KA types as variations of the VK types. This is
// so the KA functions will work properly under windows 95.
//
KA_NONE = 0,
KA_MORE = 1,
KA_SETBKGDCOL = 2,
KA_SETFORECOL = 6,
KA_FORMFEED = 12,
KA_SPCTAB = 20,
KA_SETX = 25,
KA_SETY = 26,
KA_SPACE = 32, /* */
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_ESC = VK_ESCAPE | WWKEY_VK_BIT,
KA_EXTEND = VK_ESCAPE | WWKEY_VK_BIT,
KA_RETURN = VK_RETURN | WWKEY_VK_BIT,
KA_BACKSPACE = VK_BACK | WWKEY_VK_BIT,
KA_TAB = VK_TAB | WWKEY_VK_BIT,
KA_DELETE = VK_DELETE | WWKEY_VK_BIT, /* <DELETE> */
KA_INSERT = VK_INSERT | WWKEY_VK_BIT, /* <INSERT> */
KA_PGDN = VK_NEXT | WWKEY_VK_BIT, /* <PAGE DOWN> */
KA_DOWNRIGHT = VK_NEXT | WWKEY_VK_BIT,
KA_DOWN = VK_DOWN | WWKEY_VK_BIT, /* <DOWN ARROW> */
KA_END = VK_END | WWKEY_VK_BIT, /* <END> */
KA_DOWNLEFT = VK_END | WWKEY_VK_BIT,
KA_RIGHT = VK_RIGHT | WWKEY_VK_BIT, /* <RIGHT ARROW> */
KA_KEYPAD5 = VK_SELECT | WWKEY_VK_BIT, /* NUMERIC KEY PAD <5> */
KA_LEFT = VK_LEFT | WWKEY_VK_BIT, /* <LEFT ARROW> */
KA_PGUP = VK_PRIOR | WWKEY_VK_BIT, /* <PAGE UP> */
KA_UPRIGHT = VK_PRIOR | WWKEY_VK_BIT,
KA_UP = VK_UP | WWKEY_VK_BIT, /* <UP ARROW> */
KA_HOME = VK_HOME | WWKEY_VK_BIT, /* <HOME> */
KA_UPLEFT = VK_HOME | WWKEY_VK_BIT,
KA_F12 = VK_F12 | WWKEY_VK_BIT,
KA_F11 = VK_F11 | WWKEY_VK_BIT,
KA_F10 = VK_F10 | WWKEY_VK_BIT,
KA_F9 = VK_F9 | WWKEY_VK_BIT,
KA_F8 = VK_F8 | WWKEY_VK_BIT,
KA_F7 = VK_F7 | WWKEY_VK_BIT,
KA_F6 = VK_F6 | WWKEY_VK_BIT,
KA_F5 = VK_F5 | WWKEY_VK_BIT,
KA_F4 = VK_F4 | WWKEY_VK_BIT,
KA_F3 = VK_F3 | WWKEY_VK_BIT,
KA_F2 = VK_F2 | WWKEY_VK_BIT,
KA_F1 = VK_F1 | WWKEY_VK_BIT,
KA_LMOUSE = VK_LBUTTON | WWKEY_VK_BIT,
KA_RMOUSE = VK_RBUTTON | WWKEY_VK_BIT,
KA_SHIFT_BIT = WWKEY_SHIFT_BIT,
KA_CTRL_BIT = WWKEY_CTRL_BIT,
KA_ALT_BIT = WWKEY_ALT_BIT,
KA_RLSE_BIT = WWKEY_RLS_BIT,
//
// Define all the KN types as variations of the KA types. This is
// so the KN functions will work properly under windows 95.
//
KN_NONE = 0,
KN_GRAVE = KA_GRAVE,
KN_1 = KA_1,
KN_2 = KA_2,
KN_3 = KA_3,
KN_4 = KA_4,
KN_5 = KA_5,
KN_6 = KA_6,
KN_7 = KA_7,
KN_8 = KA_8,
KN_9 = KA_9,
KN_0 = KA_0,
KN_MINUS = KA_MINUS, /* - */
KN_EQUAL = KA_EQUAL, /* = */
KN_BACKSPACE = KA_BACKSPACE,
KN_TAB = KA_TAB, /* <TAB> */
KN_Q = KA_q,
KN_W = KA_w,
KN_E = KA_e,
KN_R = KA_r,
KN_T = KA_t,
KN_Y = KA_y,
KN_U = KA_u,
KN_I = KA_i,
KN_O = KA_o,
KN_P = KA_p,
KN_LBRACKET = KA_LBRACKET, /* [ */
KN_RBRACKET = KA_RBRACKET, /* ] */
KN_BACKSLASH = KA_BACKSLASH, /* \ */
KN_A = KA_a,
KN_S = KA_s,
KN_D = KA_d,
KN_F = KA_f,
KN_G = KA_g,
KN_H = KA_h,
KN_J = KA_j,
KN_K = KA_k,
KN_L = KA_l,
KN_SEMICOLON = KA_SEMICOLON, /* ; */
KN_SQUOTE = KA_SQUOTE, /* ' */
KN_BACKSLASH2 = KA_BACKSLASH,
KN_RETURN = KA_RETURN,
KN_Z = KA_z,
KN_X = KA_x,
KN_C = KA_c,
KN_V = KA_v,
KN_B = KA_b,
KN_N = KA_n,
KN_M = KA_m,
KN_COMMA = KA_COMMA, /* , */
KN_PERIOD = KA_PERIOD, /* . */
KN_SLASH = KA_SLASH, /* / */
KN_SPACE = KA_SPACE,
KN_LMOUSE = KA_LMOUSE,
KN_RMOUSE = KA_RMOUSE,
KN_HOME = KA_HOME, /* num key pad 7 */
KN_UPLEFT = KA_UPLEFT,
KN_LEFT = KA_LEFT, /* num key pad 4 */
KN_END = KA_END, /* num key pad 1 */
KN_DOWNLEFT = KA_DOWNLEFT,
KN_KEYPAD_SLASH = KA_SLASH, /* num key pad / */
KN_UP = KA_UP, /* num key pad 8 */
KN_CENTER = KA_KEYPAD5, /* num key pad 5 */
KN_DOWN = KA_DOWN, /* num key pad 2 */
KN_INSERT = KA_INSERT, /* num key pad 0 */
KN_KEYPAD_ASTERISK= KA_ASTERISK, /* num key pad * */
KN_PGUP = KA_PGUP, /* num key pad 9 */
KN_UPRIGHT = KA_UPRIGHT,
KN_RIGHT = KA_RIGHT, /* num key pad 6 */
KN_PGDN = KA_PGDN, /* num key pad 3 */
KN_DOWNRIGHT = KA_DOWNRIGHT,
KN_DELETE = KA_DELETE, /* num key pad . */
KN_KEYPAD_MINUS = KA_MINUS, /* num key pad - */
KN_KEYPAD_PLUS = KA_PLUS, /* num key pad + */
KN_KEYPAD_RETURN = KA_RETURN, /* num key pad <ENTER> */
KN_ESC = KA_ESC,
KN_F1 = KA_F1,
KN_F2 = KA_F2,
KN_F3 = KA_F3,
KN_F4 = KA_F4,
KN_F5 = KA_F5,
KN_F6 = KA_F6,
KN_F7 = KA_F7,
KN_F8 = KA_F8,
KN_F9 = KA_F9,
KN_F10 = KA_F10,
KN_F11 = KA_F11,
KN_F12 = KA_F12,
KN_PRNTSCRN = VK_PRINT | WWKEY_VK_BIT,
KN_CAPSLOCK = VK_CAPITAL | WWKEY_VK_BIT,
KN_SCROLLLOCK = VK_SCROLL | WWKEY_VK_BIT, /* <SCROLL LOCK> */
KN_PAUSE = VK_PAUSE | WWKEY_VK_BIT, /* <PAUSE> */
KN_LSHIFT = VK_SHIFT | WWKEY_VK_BIT,
KN_RSHIFT = VK_SHIFT | WWKEY_VK_BIT,
KN_LCTRL = VK_CONTROL | WWKEY_VK_BIT,
KN_RCTRL = VK_CONTROL | WWKEY_VK_BIT,
KN_LALT = VK_MENU | WWKEY_VK_BIT,
KN_RALT = VK_MENU | WWKEY_VK_BIT,
KN_E_INSERT = VK_INSERT | WWKEY_VK_BIT,
KN_E_DELETE = VK_DELETE | WWKEY_VK_BIT,
KN_E_LEFT = VK_LEFT | WWKEY_VK_BIT, /* extended <LEFT ARROW> */
KN_E_HOME = VK_HOME | WWKEY_VK_BIT, /* extended <HOME> */
KN_E_END = VK_END | WWKEY_VK_BIT, /* extended <END> */
KN_E_UP = VK_UP | WWKEY_VK_BIT, /* extended <UP ARROW> */
KN_E_DOWN = VK_DOWN | WWKEY_VK_BIT, /* extended <DOWN ARROW> */
KN_E_PGUP = VK_PRIOR | WWKEY_VK_BIT, /* extended <PAGE UP> */
KN_E_PGDN = VK_NEXT | WWKEY_VK_BIT, /* extended <PAGE DOWN> */
KN_E_RIGHT = VK_RIGHT | WWKEY_VK_BIT, /* extended <RIGHT ARROW> */
KN_NUMLOCK = VK_NUMLOCK | WWKEY_VK_BIT, /* <NUM LOCK> */
KN_SHIFT_BIT = WWKEY_SHIFT_BIT,
KN_CTRL_BIT = WWKEY_CTRL_BIT | WWKEY_VK_BIT,
KN_ALT_BIT = WWKEY_ALT_BIT | WWKEY_VK_BIT,
KN_RLSE_BIT = WWKEY_RLS_BIT,
KN_BUTTON = WWKEY_BTN_BIT,
};
extern WWKeyboardClass *_Kbd;
/*
** The following routines provide some compatability with the old westwood
** library.
*/
int Check_Key(void);
int Check_Key_Num(void);
int Get_Key_Num(void);
int Get_Key(void);
int KN_To_KA(int key);
void Clear_KeyBuffer(void);
int Key_Down(int key);
int KN_To_VK(int key);
#endif

View file

@ -0,0 +1,126 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 32 bit Library *
;* *
;* File Name : KEYBOARD.INC *
;* *
;* Programmer : Phil W. Gorrow *
;* *
;* Start Date : July 12, 1994 *
;* *
;* Last Update : July 12, 1994 [PWG] *
;* *
;*-------------------------------------------------------------------------*
;* Contains all the defines used by the keyboard interrupt for assembly *
;* includes. *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
TRUE EQU 1 ; numerical true
FALSE EQU 0 ; numerical false
DEBUG EQU 1
MAX_X_PIXEL EQU 319
MAX_Y_PIXEL EQU 199
KN_RESERVED1 EQU 14
KN_RESERVED2 EQU 45
KN_RESERVED3 EQU 56
; these two are reserved for AMIGA open and close.
KN_LCOMM EQU 59
KN_RCOMM EQU 63
KN_LMOUSE EQU 65
KN_RMOUSE EQU 66
KN_JBUTTON1 EQU 67
KN_JBUTTON2 EQU 68
KN_J_UP EQU 69
KN_J_RIGHT EQU 70
KN_J_DOWN EQU 71
KN_J_LEFT EQU 72
KN_LEFT EQU 92
KN_UPLEFT EQU 91
KN_UP EQU 96
KN_UPRIGHT EQU 101
KN_RIGHT EQU 102
KN_DOWNRIGHT EQU 103
KN_DOWN EQU 98
KN_DOWNLEFT EQU 93
KN_CENTER EQU 97
KN_INSERT EQU 99
KN_DELETE EQU 104
KN_RETURN EQU 43
KN_SPACE EQU 61
KN_KEYPAD_RETURN EQU 108
; these two are reserved for AMIGA K left and right paren
KN_KLPAREN EQU 87
KN_KRPAREN EQU 88
KN_NUMLOCK EQU 90
KN_SCROLLOCK EQU 125 ; key ignored by the logging system
KN_MOUSE_MOVE EQU 45 ; Indicate a mouse move (for playback of logged data)
; ----------------------------------------------------------------
; flags used in Keyflags to customize keystroke interrupt.
REPEATON EQU 0001H ; 1:all makes into buffer, 0:only 1st make
TRACKEXT EQU 0002H ; 1:Home != keypad Home, 0:Home=keypad Home
FILTERONLY EQU 0004H ; 1:Normal BIOS operation with filter
CTRLSON EQU 0008H ; 1:pass scroll lock sequence into BIOS
CTRLALTTURBO EQU 0010H ; 1:Allow turbo up and down in application
CTRLCON EQU 0020H ; 1:pass stop code to BIOS
SCROLLLOCKON EQU 0040H ; 1:pass scroll lock key into BIOS
PAUSEON EQU 0080H ; 1:pass the pause key and seq to BIOS
BREAKON EQU 0100H ; 1:pass the ctrl break seq to BIOS
NONUMLOCK EQU 0200H ; 1:do NOT remap keypad to numbers
TASKSWITCHABLE EQU 0400H ; 1:allows task switching keys thru ALT-TAB,
; ALT-ESC,CTRL-ESC
PASSBREAKS EQU 0800H ; 1:Pass all break codes to keyboard buffer.
KEYMOUSE EQU 1000H ; 1:Numeric keypad moves mouse
SIMLBUTTON EQU 2000H ; 1:have space and enter keys simulate Left
DEBUGINT EQU 4000H ; mouse button when KEYMOUSE is set
SHIFTPRESS EQU 001H ; bit 0 for shift key pressed
CTRLPRESS EQU 002H ; bit 1 for ctrl key pressed
ALTPRESS EQU 004H ; bit 2 for alt key pressed
KEYRELEASE EQU 008H ; bit 3 for key released
NOTKEYRELEASE EQU 0F7H ; not of key released
CAPSLOCK EQU 00001H ; bit 0 for caps locked
NUMLOCK EQU 00002H ; bit 1 for num locked
CLEARISR EQU 020H ; value to clear In Service Register
DOS EQU 021H
INTCHIP0 EQU 020H ; 8259 interrupt chip controller 0
KEYCTRL EQU 061H ; control bits for KB sense data
KEYDATA EQU 060H ; keyboard scan code port

View file

@ -0,0 +1,159 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 32 bit Library *
;* *
;* File Name : KEYSTRUC.INC *
;* *
;* Programmer : Phil W. Gorrow *
;* *
;* Start Date : July 13, 1994 *
;* *
;* Last Update : July 13, 1994 [PWG] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
STRUC KeyboardType
SoundOn DW ? ; toggled by alt S
MusicOn DW ? ; toggled by alt M
KeyFlags DD ? ; all but repeat for now
Break DW ?
KeyMouseMove DB 6 DUP(?)
ScreenEdge DW 18 DUP (?)
Bits DB 8 DUP (?)
CondPassKey DW 17 DUP (?)
CondPassCond DW 17 DUP (?)
EscRoutine DD ?
ExtCodes DB 16 DUP (?)
ExtNums DB 16 DUP (?)
ExtRemap DB 16 DUP (?)
ExtRemapEnd DB ?
ExtKeyboard DB ?
KeyBuffer DW 128 DUP(?) ; set to empty
KeyBufferHead DD ? ; set to first entry
KeyBufferTail DD ? ; set to head for empty buffer
KeyLock DW ? ; num and caps lock bits
KeyNums DB 89 DUP (?)
KeysCapsLock DB 16 DUP (?)
KeysNumLock DB 16 DUP (?)
KeysUpDown DB 16 DUP (?)
KeyStream DB 16 DUP (?)
PassCount DW ?
KeyStreamIndex DW ?
LastKeyE0 DB ?
LastKeyE1 DB ?
PassAlways DB 10 DUP (?)
PassAlwaysEnd DB ? ; invalid code to END PassAlways
CtrlFlags DB ?
Buffer DW ?
Time DW ?
XYAdjust DB 26 DUP (?)
EdgeConv DW 16 DUP (?)
MouseUpdate DW ?
MouseX DD ?
LocalMouseX DW ?
MouseY DD ?
LocalMouseY DW ?
IsExtKey DB ?
ExtIndex DW ?
KeyOldRMI DD ? ; The origianl RM interrupt seg:off.
KeyOldPMIOffset DD ? ; The origianl PM interrupt offset
KeyOldPMISelector DD ? ; The original PM interrupt segment.
KeyCodeOffset DW ? ; Offset of the code in the RM stuff.
CallKeyRMIntOffset DW ? ; Offset of function to call DOS timer interrupt.
CallKeyRMIntAddr DD ? ; PM address of CallRealIntOffset for speed.
PMIssuedKeyInt DD ? ; did Protected mode pass this through?
BrkOldRMI DD ? ; The origianl RM interrupt seg:off.
BrkOldPMIOffset DD ? ; The origianl PM interrupt offset
BrkOldPMISelector DD ? ; The original PM interrupt segment.
BrkCodeOffset DW ? ; Offset of the code in the RM stuff.
CallBrkRMIntOffset DW ? ; Offset of function to call DOS timer interrupt.
CallBrkRMIntAddr DD ? ; PM address of CallRealIntOffset for speed.
PMIssuedBrkInt DD ? ; did Protected mode pass this through?
KeyIntDisabled DD ?
DbgOldPMIOffset DD ? ; The origianl PM interrupt offset
DbgOldPMISelector DD ? ; The original PM interrupt segment.
;---------------------------------------------------------------------------
; Begin definition of Mouse Specific Variables for real mode
;---------------------------------------------------------------------------
Button DB ? ; current value of the mouse button
MDisabled DB ? ; Is the mouse driver disabled
MInput DB ? ; Defaults to mouse input allowed.
Adjust DW ? ; flag to adjust coordinates if necessary
MouseStepX DW ? ; step values if the mouse moves at
MouseStepY DW ? ; more than one pixel at a time
MouseOffsetX DW ? ; Fractional step values used if a mouse
MouseOffsetY DW ? ; moves at less than one pixel at a time
MState DD ? ; Tracks if mouse is hidden (TRUE) or not (FALSE)
MouseXOld DW ? ; Holds last MouseX and MouseY to determine if
MouseYOld DW ? ; mouse needs to be redrawn
MCState DW ? ; Tracks if mouse conditional hidden (TRUE) or not
MouseCXLeft DD ? ; Conditional hide mouse left x position
MouseCYUpper DD ? ; Conditional hide mouse top y position
MouseCXRight DD ? ; Conditional hide mouse right x position
MouseCYLower DD ? ; Conditional hide mouse lower y position
MouseCursor DD ? ; Pointer to the mouse cursor to draw
MouseCursorSize DW ? ; Size of mouse cursor draw area
MouseBuffer DD ? ; Pointer to buffer mouse is saved in
MouseXHot DD ? ; Offset to mouse's x hot spot
MouseYHot DD ? ; Offset to mouse's y hot spot
MouseBuffX DD ? ; X position background was saved at
MouseBuffY DD ? ; Y position background was saved at
MouseBuffW DD ? ; Width of the region saved for mouse
MouseBuffH DD ? ; Height of the region saved for mouse
MouseWidth DD ? ; Mouse cursor theoretical width
MouseHeight DD ? ; Mouse cursor theoretical height
MouseCodeOffset DW ? ; Offset to the real mode code offset
MouseRight DD ? ; Right hand side of the screen
MouseBottom DD ? ; Bottom of the screen
ShadowPtr dw ?
DrawMousePtr dw ?
VGAMouseDraw dw ?
VGAMouseShadow dw ?
VESAMouseDraw dw ?
VESAMouseShadow dw ?
VesaPtr dd ?
VesaBankTable DD 8 dup (?)
Adjust_XPos dd ?
Adjust_YPos dd ?
ENDS
; InitFlags that are set to have a fully functional interrupt.
IF_ALLOC_RM equ 1 ; Allocation of RM was successful.
IF_SET_VECTORS equ 2 ; Vectors have been set.
IF_LOCKED_PM_CODE equ 4 ; Locked PM code for DPMI.
IF_LOCKED_PM_DATA equ 8 ; Locked PM code for DPMI.
IF_RATE_CHANGE equ 10 ; Timer rate was changed.
IF_FUNCTIONAL equ 20 ; Timer is in and functional.
IF_LOCKED_RM_CODE equ 40

View file

@ -0,0 +1,375 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: g:/library/wwlib32/file/rcs/load.cpp 1.4 1994/04/22 12:42:21 scott_bowen 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 : LIBRARY *
* *
* File Name : LOAD.C *
* *
* Programmer : Christopher Yates *
* *
* Last Update : September 17, 1993 [JLB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Load_Uncompress -- Load and uncompress the given file. *
* Uncompress_Data -- Uncompress standard CPS buffer. *
* Load_Data -- Loads a data file from disk. *
* Load_Alloc_Data -- Loads and allocates buffer for a file. *
* Write_Data -- Writes a block of data as a file to disk. *
* Uncompress_Data -- Uncompresses data from one buffer to another. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "iff.h"
#include "file.h"
#include <misc.h>
#include <wwstd.h>
#include <dos.h>
#include <wwmem.h>
/*=========================================================================*/
/* The following PRIVATE functions are in this file: */
/*=========================================================================*/
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
/***************************************************************************
* LOAD_DATA -- Loads a data file from disk. *
* *
* This routine will load a data file from disk. It does no translation*
* on the data. *
* *
* INPUT: name -- Pointer to ASCII filename of the data file. *
* *
* ptr -- Buffer to load the data file into. *
* *
* size -- Maximum size of the buffer (in bytes). *
* *
* OUTPUT: Returns with the number of bytes read. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/24/1991 JLB : Created. *
*=========================================================================*/
unsigned long __cdecl Load_Data(char const *name, void *ptr, unsigned long size)
{
int fd;
fd = Open_File(name, READ);
size = Read_File(fd, ptr, size);
Close_File(fd);
return(size);
}
/***************************************************************************
* WRITE_DATA -- Writes a block of data as a file to disk. *
* *
* This routine will write a block of data as a file to the disk. It *
* is the compliment of Load_Data. *
* *
* INPUT: name -- Name of the file to create. *
* *
* ptr -- Pointer to the block of data to write. *
* *
* size -- Size of the data block to be written. *
* *
* OUTPUT: Returns with the number of bytes actually written. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/05/1992 JLB : Created. *
*=========================================================================*/
unsigned long __cdecl Write_Data(char const *name, void *ptr, unsigned long size)
{
int fd;
fd = Open_File(name, WRITE);
size = Write_File(fd, ptr, size);
Close_File(fd);
return(size);
}
/***************************************************************************
* LOAD_ALLOC_DATA -- Loads and allocates buffer for a file. *
* *
* The routine will allocate a buffer and load the specified file into *
* it. The kind of memory used for the buffer is determined by the *
* memory allocation flags passed in. *
* *
* INPUT: name -- Name of the file to load. *
* *
* flags -- Memory allocation flags to use when allocating. *
* *
* OUTPUT: Returns with a pointer to the buffer that contains the file's *
* data. *
* *
* WARNINGS: A memory error could occur if regular memory flags are *
* specified. If XMS memory is specified, then this routine *
* could likely return NULL. *
* *
* HISTORY: *
* 05/28/1992 JLB : Created. *
*=========================================================================*/
void * __cdecl Load_Alloc_Data(char const *name, MemoryFlagType flags)
{
int fd; // Working file handle.
unsigned long size; // Size of the file to load.
void *buffer; // Buffer to hold the file.
fd = Open_File(name, READ);
size = File_Size(fd);
buffer = Alloc(size, flags);
if (buffer) {
Read_File(fd, buffer, size);
}
Close_File(fd);
return(buffer);
}
/***************************************************************************
* LOAD_UNCOMPRESS -- Load and uncompress the given file. *
* *
* INPUT: char * - file name to uncompress *
* GraphicBufferClass& - to load the source data into *
* GraphicBufferClass& - for the picture *
* void * - ptr for header uncompressed data *
* *
* OUTPUT: unsigned long size of uncompressed data *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/28/1991 CY : Created. *
* 06/26/1991 JLB : Handles load & uncompress to same buffer. *
*=========================================================================*/
unsigned long __cdecl Load_Uncompress(char const *file, BufferClass& uncomp_buff, BufferClass& dest_buff, void *reserved_data)
{
int fd; // Source file handle.
unsigned int isize=0; // Size of the file.
unsigned int skipsize; // Size of the skip data bytes.
void *uncomp_ptr; // Source buffer pointer.
char *newuncomp_ptr; // Adjusted source pointer.
uncomp_ptr = uncomp_buff.Get_Buffer(); // get a pointer to buffer
/*======================================================================*/
/* Read the file into the uncompression buffer. */
/*======================================================================*/
fd = Open_File(file, READ); // Open up the file to read from
Read_File(fd, (char *) &isize, 2L); // Read the file size
Read_File(fd, uncomp_ptr, 8L); // Read the header bytes in.
isize -= 8; // Remaining data in file.
/*======================================================================*/
/* Check for and read in the skip data block. */
/*======================================================================*/
skipsize = *(((short *)uncomp_ptr) + 3);
if (reserved_data && skipsize) {
Read_File(fd, reserved_data, (unsigned long) skipsize);
} else {
Seek_File(fd, skipsize, SEEK_CUR);
}
*( ((short *)uncomp_ptr+3) ) = 0; // K/O any skip value.
isize -= skipsize;
/*======================================================================*/
/* If the source and dest buffer are the same, we adjust the pointer so */
/* that the compressed data is loaded into the end of the buffer. In */
/* this way the uncompress code can write to the same buffer. */
/*======================================================================*/
newuncomp_ptr = (char *)Add_Long_To_Pointer(uncomp_buff.Get_Buffer(), uncomp_buff.Get_Size() - (isize+8L));
/*======================================================================*/
/* Duplicate the header bytes. */
/*======================================================================*/
Mem_Copy(uncomp_ptr,newuncomp_ptr,8);
/*======================================================================*/
/* Read in the main compressed part of the file. */
/*======================================================================*/
Read_File(fd, newuncomp_ptr + 8, (unsigned long)isize);
Close_File(fd);
/*======================================================================*/
/* Uncompress the file into the destination buffer (which may very well */
/* be the source buffer). */
/*======================================================================*/
return(Uncompress_Data(newuncomp_ptr, dest_buff.Get_Buffer()));
}
#if(0)
/***************************************************************************
* LOAD_UNCOMPRESS -- Load and uncompress the given file. *
* *
* INPUT: char *file name to uncompress, BuffType uncomp_buff to load *
* the source data into, BuffType dest_buff for the picture, *
* void *reserved_data pointer for header uncompressed data *
* *
* OUTPUT: unsigned long size of uncompressed data *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/28/1991 CY : Created. *
* 06/26/1991 JLB : Handles load & uncompress to same buffer. *
*=========================================================================*/
unsigned long __cdecl Load_Uncompress(char const *file, BuffType uncomp_buff, BuffType dest_buff, void *reserved_data)
{
int fd; // Source file handle.
unsigned int isize; // Size of the file.
unsigned int skipsize; // Size of the skip data bytes.
void *uncomp_ptr; // Source buffer pointer.
char *newuncomp_ptr; // Adjusted source pointer.
uncomp_ptr = Get_Buff(uncomp_buff); /* Get pointer to uncomp buffer */
/* Read the file into the uncomp_buff */
fd = Open_File(file, READ);
Read_File(fd, (char *) &isize, 2L); /* Read the file size */
#if(AMIGA)
isize = Reverse_Word(isize);
#endif
Read_File(fd, uncomp_ptr, 8L); // Read the header bytes in.
isize -= 8; // Remaining data in file.
/*
** Check for and read in the skip data block.
*/
skipsize = *(((short*)uncomp_ptr) + 3);
#if(AMIGA)
skipsize = Reverse_Word(skipsize);
#endif
if (reserved_data && skipsize) {
Read_File(fd, reserved_data, (unsigned long) skipsize);
} else {
Seek_File(fd, skipsize, SEEK_CUR);
}
*( ((short *)uncomp_ptr+3) ) = 0; // K/O any skip value.
isize -= skipsize;
/*
** If the source and dest buffer are the same, we
** adjust the pointer so that the compressed data is
** loaded into the end of the buffer. In this way the
** uncompress code can write to the same buffer.
*/
#if(IBM)
newuncomp_ptr = (char *)Add_Long_To_Pointer(Get_Buff(uncomp_buff), PageArraySize[uncomp_buff] - (isize+8L));
#else
newuncomp_ptr = Get_Buff(uncomp_buff);
newuncomp_ptr += PageArraySize[uncomp_buff] - ((isize+10) & 0xFFFE);
#endif
/*
** Duplicate the header bytes.
*/
Mem_Copy(uncomp_ptr,newuncomp_ptr,8);
/*
** Read in the main compressed part of the file.
*/
Read_File(fd, newuncomp_ptr + 8, (unsigned long)isize);
Close_File(fd);
return(Uncompress_Data(newuncomp_ptr, Get_Buff(dest_buff)));
}
#endif
/***************************************************************************
* Uncompress_Data -- Uncompresses data from one buffer to another. *
* *
* This routine takes data from a compressed file (sans the first two *
* size bytes) and uncompresses it to a destination buffer. The source *
* data MUST have the CompHeaderType at its start. *
* *
* INPUT: src -- Source compressed data pointer. *
* *
* dst -- Destination (paragraph aligned) pointer. *
* *
* OUTPUT: Returns with the size of the uncompressed data. *
* *
* WARNINGS: If LCW compression is used, the destination buffer must *
* be paragraph aligned. *
* *
* HISTORY: *
* 09/17/1993 JLB : Created. *
*=========================================================================*/
unsigned long __cdecl Uncompress_Data(void const *src, void *dst)
{
unsigned int skip; // Number of leading data to skip.
CompressionType method; // Compression method used.
unsigned long uncomp_size=NULL;
if (!src || !dst) return(NULL);
/*
** Interpret the data block header structure to determine
** compression method, size, and skip data amount.
*/
uncomp_size = ((CompHeaderType*)src)->Size;
#if(AMIGA)
uncomp_size = Reverse_Long(uncomp_size);
#endif
skip = ((CompHeaderType*)src)->Skip;
#if(AMIGA)
skip = Reverse_Word(skip);
#endif
method = (CompressionType) ((CompHeaderType*)src)->Method;
src = Add_Long_To_Pointer((void *)src, (long)sizeof(CompHeaderType) + (long)skip);
switch (method) {
default:
case NOCOMPRESS:
Mem_Copy((void *) src, dst, uncomp_size);
break;
case HORIZONTAL:
#if LIB_EXTERNS_RESOLVED
RLE_Uncompress((void *) src, dst, uncomp_size);
#endif
break;
case LCW:
LCW_Uncompress((void *) src, (void *) dst, (unsigned long) uncomp_size);
break;
}
return(uncomp_size);
}

View file

@ -0,0 +1,137 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : LOADFONT.C *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : September 6, 1991 *
* *
* Last Update : June 27, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Load_Font -- Loads a font from disk. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "font.h"
#include <file.h>
#include <wwmem.h>
#include <wwstd.h>
#if(IBM)
#include <fcntl.h>
#include <io.h>
#include <errno.h>
int FontXSpacing = 0;
int FontYSpacing = 0;
void const *FontPtr = NULL;
char FontWidth = 8;
char FontHeight = 8;
// only font.c and set_font.c use the following
char *FontWidthBlockPtr = NULL;
/***************************************************************************
* LOAD_FONT -- Loads a font from disk. *
* *
* This loads a font from disk. This function must be called as a *
* precursor to calling Set_Font(). You need only call this function *
* once per desired font at the beginning of your code, but AFTER *
* Prog_Init() is called. *
* *
* INPUT: name - Pointer to font name to use (eg. "topaz.font") *
* *
* fontsize - Size in points of the font loaded. *
* *
* OUTPUT: Pointer to font data or NULL if unable to load. *
* *
* WARNINGS: Some system memory is grabbed by this routine. *
* *
* HISTORY: *
* 4/10/91 BS : 2.0 compatibily *
* 6/09/91 JLB : IBM and Amiga compatability. *
* 11/27/1991 JLB : Uses file I/O routines for disk access. *
* 01/29/1992 DRD : Modified to use new font format. *
* 02/01/1992 DRD : Added font file verification. *
* 06/29/1994 SKB : modified for 32 bit library *
*=========================================================================*/
void * __cdecl Load_Font(char const *name)
{
char valid;
int fh; // DOS file handle for font file.
unsigned short size; // Size of the data in the file (-2);
char *ptr = NULL; // Pointer to newly loaded font.
fh=Open_File(name,READ);
if ( fh>=0 ){
if ( Read_File(fh, (char *) &size, 2) != 2) return(NULL);
ptr = (char *) Alloc(size , MEM_NORMAL );
*(short *)ptr = size;
Read_File(fh, ptr + 2, size - 2);
Close_File(fh);
} else {
return ((void*)errno);
}
#ifdef cuts
if (Find_File(name)) {
fh = Open_File(name, READ);
if (Read_File(fh, (char *) &size, 2) != 2) return(NULL);
ptr = (char *) Alloc(size, MEM_NORMAL);
*(short *)ptr = size;
Read_File(fh, ptr + 2, size - 2);
Close_File(fh);
} else {
return (NULL);
}
#endif
//
// verify that the file loaded is a valid font file.
//
valid = FALSE;
if (*(ptr + 2) == 0) { // no compression
if (*(ptr + 3) == 5) { // currently only 5 data blocks are used.
valid = TRUE;
}
}
if ( !valid ) {
return (NULL);
}
return(ptr);
}
#endif

View file

@ -0,0 +1,82 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Load_Palette *
* *
* File Name : LOADPAL.CPP *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : April 25, 1994 *
* *
* Last Update : April 27, 1994 [BR] *
* *
*-------------------------------------------------------------------------*
* Note: This module contains dependencies upon the file I/O system, *
* specifically Load_Data(). *
*-------------------------------------------------------------------------*
* Functions: *
* Load_Palette -- Loads a palette file into the given palette buffer. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
********************************* Includes **********************************
*/
//#include <wwstd.h>
#include "wwstd.h"
#include "iff.h"
#include "palette.h"
/*
********************************* Constants *********************************
*/
/*
********************************** Globals **********************************
*/
/*
******************************** Prototypes *********************************
*/
/***************************************************************************
* Load_Palette -- Loads a palette file into the given palette buffer. *
* *
* INPUT: *
* BYTE * file_name - name of the file to load. *
* BYTE * palette_pointer - pointer to palette buffer. *
* *
* OUTPUT: *
* none *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/20/1991 BS : Created. *
* 04/27/1994 BR : Converted to 32-bit *
*=========================================================================*/
void __cdecl Load_Palette(char *palette_file_name, void *palette_pointer)
{
#if(IBM)
Load_Data(palette_file_name, palette_pointer, 768);
#else
Load_Data(palette_file_name, palette_pointer, (ULONG)(2<<BIT_PLANES));
#endif
}
/**************************** End of loadpal.cpp ***************************/

View file

@ -0,0 +1,119 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 32 bit Library *
;* *
;* File Name : MCGAPRIM.INC *
;* *
;* Programmer : Phil W. Gorrow *
;* *
;* Start Date : January 16, 1995 *
;* *
;* Last Update : January 16, 1995 [PWG] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
; Externs from REGIONSZ.ASM module of the MCGAPRIM library
GLOBAL MCGA_Size_Of_Region :NEAR
; Externs from GETPIX.ASM module of the MCGAPRIM library
GLOBAL MCGA_Get_Pixel :NEAR
; Externs from VGETPIX.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_Get_Pixel :NEAR
; Externs from PUTPIX.ASM module of the MCGAPRIM library
GLOBAL MCGA_Put_Pixel :NEAR
; Externs from VPUTTPIX.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_Put_Pixel :NEAR
; Externs from CLEAR.ASM module of the MCGAPRIM library
GLOBAL MCGA_Clear :NEAR
; Externs from VCLEAR.ASM module of the MCGA/SVGAPRIM library
GLOBAL Vesa_Clear :NEAR
; Externs from BITBLIT.ASM module of the MCGAPRIM library
GLOBAL Linear_Blit_To_Linear :NEAR
; Externs from VBITBLIT.ASM module of the MCGA/SVGAPRIM library
GLOBAL Linear_Blit_To_Vesa :NEAR
GLOBAL Vesa_Blit_To_Linear :NEAR
GLOBAL Vesa_Blit_To_Vesa :NEAR
; Externs from TOBUFF.ASM module of the MCGAPRIM library
GLOBAL MCGA_To_Buffer :NEAR
; Externs from VTOBUFF.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_To_Buffer :NEAR
; Externs from TOPAGE.ASM module of the MCGAPRIM library
GLOBAL MCGA_Buffer_To_Page :NEAR
; Externs from VTOPAGE.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_Buffer_To_Page :NEAR
; Externs from SCALE.ASM module of the MCGAPRIM library
GLOBAL Linear_Scale_To_Linear :NEAR
; Externs from VSCALE.ASM module of the SVGA/MCGAPRIM library
GLOBAL Linear_Scale_To_Vesa :NEAR
GLOBAL Vesa_Scale_To_Linear :NEAR
GLOBAL Vesa_Scale_To_Vesa :NEAR
; Externs from TXTPRNT.ASM module of the MCGAPRIM library
GLOBAL MCGA_Print :NEAR
; Externs from VTXTPRNT.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_Print :NEAR
;*-------------------------------------------------------------------------*
;* Define MCGA only assembly GLOBALS *
;*-------------------------------------------------------------------------*
; Externs from DRAWLINE.ASM module of the MCGAPRIM library
GLOBAL MCGA_Draw_Line :NEAR
; Externs from FILLQUAD.ASM module of the MCGAPRIM library
GLOBAL MCGA_Fill_Quad :NEAR
; Externs from FILLRECT.ASM module of the MCGAPRIM library
GLOBAL MCGA_Fill_Rect :NEAR
; Externs from REMAP.ASM module of the MCGAPRIM library
GLOBAL MCGA_Remap :NEAR
; Externs from STAMP.ASM module of the MCGAPRIM library
GLOBAL MCGA_Draw_Stamp :NEAR
GLOBAL get_clip : NEAR
struc RECTANGLE
x0 dd ?
y0 dd ?
x1 dd ?
y1 dd ?
ends RECTANGLE



File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,107 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Memory System *
* *
* File Name : MEMFLAG.H *
* *
* Programmer : Jeff Wilson *
* *
* Start Date : April 4, 1994 *
* *
* Last Update : September 8, 1994 [IML] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef MEMFLAG_H
#define MEMFLAG_H
// Memory Flags
/*
** Memory allocation flags. These are the flags that are passed into Alloc
** in order to control the type of memory allocated.
*/
typedef enum {
MEM_NORMAL = 0x0000, // Default memory (normal).
MEM_NEW = 0x0001, // Called by the operator new and was overloaded.
MEM_CLEAR = 0x0002, // Clear memory before returning.
MEM_REAL = 0x0004, // Clear memory before returning.
MEM_TEMP = 0x0008, // Clear memory before returning.
MEM_LOCK = 0x0010, // Lock the memory that we allocated
} MemoryFlagType;
/*
** Prototypes for VMPAGEIN.ASM
*/
extern "C"{
void __cdecl Force_VM_Page_In (void *buffer, int length);
}
/*=========================================================================*/
/* The following prototypes are for the file: ALLOC.CPP */
/*=========================================================================*/
void * operator new(size_t size, MemoryFlagType flag);
void * operator new[] (size_t size, MemoryFlagType flag);
void *Alloc(unsigned long bytes_to_alloc, MemoryFlagType flags);
void Free(void const *pointer);
void DPMI_Lock(VOID const *ptr, long const size);
void DPMI_Unlock(void const *ptr, long const size);
void *Resize_Alloc(void *original_ptr, unsigned long new_size_in_bytes);
long Ram_Free(MemoryFlagType flag);
long Heap_Size(MemoryFlagType flag);
long Total_Ram_Free(MemoryFlagType flag);
//PG_TO_FIX
//#pragma option -Jgd
inline void * operator new(size_t size, MemoryFlagType flag)
{
return(Alloc(size, flag));
}
inline void * operator new[] (size_t size, MemoryFlagType flag)
{
return(Alloc(size, flag));
}
//#pragma option -Jgd
/*=========================================================================*/
/* The following prototypes are for the file: MEM_COPY.ASM */
/*=========================================================================*/
extern "C" {
void __cdecl Mem_Copy(void const *source, void *dest, unsigned long bytes_to_copy);
}
inline void *Add_Long_To_Pointer(void const *ptr, long size)
{
return ((void *) ( (char const *) ptr + size));
}
extern void (*Memory_Error)(void);
extern void (*Memory_Error_Exit)(char *string);
extern unsigned long MinRam; // Record of least memory at worst case.
extern unsigned long MaxRam; // Record of total allocated at worst case.
#endif

View file

@ -0,0 +1,268 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : 32 bit library *
* *
* File Name : MISC.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : August 3, 1994 *
* *
* Last Update : August 3, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef MISC_H
#define MISC_H
#define WIN32_LEAN_AND_MEAN // eliminates unecessary definitions in windows.h
#ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
#define _WIN32
#endif // _WIN32
#include <windows.h>
#include <windowsx.h>
#include <ddraw.h>
extern LPDIRECTDRAWSURFACE PaletteSurface;
/*========================= C++ Routines ==================================*/
/*=========================================================================*/
/* The following prototypes are for the file: DDRAW.CPP */
/*=========================================================================*/
void Process_DD_Result(HRESULT result, int display_ok_msg);
BOOL Set_Video_Mode(HWND hwnd, int w, int h, int bits_per_pixel);
void Reset_Video_Mode(void);
unsigned Get_Free_Video_Memory(void);
void Wait_Blit(void);
unsigned Get_Video_Hardware_Capabilities(void);
extern "C" void Wait_Vert_Blank(void);
extern "C" void Set_DD_Palette (void *palette);
/*
** Pointer to function to call if we detect a focus loss
*/
extern void (*Misc_Focus_Loss_Function)(void);
/*
** Pointer to function to call if we detect a surface restore
*/
extern void (*Misc_Focus_Restore_Function)(void);
/*
* Flags returned by Get_Video_Hardware_Capabilities
*/
/* Hardware blits supported? */
#define VIDEO_BLITTER 1
/* Hardware blits asyncronous? */
#define VIDEO_BLITTER_ASYNC 2
/* Can palette changes be synced to vertical refresh? */
#define VIDEO_SYNC_PALETTE 4
/* Is the video cards memory bank switched? */
#define VIDEO_BANK_SWITCHED 8
/* Can the blitter do filled rectangles? */
#define VIDEO_COLOR_FILL 16
/* Is there no hardware assistance avaailable at all? */
#define VIDEO_NO_HARDWARE_ASSIST 32
/*
* Definition of surface monitor class
*
* This class keeps track of all the graphic buffers we generate in video memory so they
* can be restored after a focus switch.
*/
#define MAX_SURFACES 20
class SurfaceMonitorClass {
public:
SurfaceMonitorClass();
void Add_DD_Surface (LPDIRECTDRAWSURFACE);
void Remove_DD_Surface (LPDIRECTDRAWSURFACE);
BOOL Got_Surface_Already (LPDIRECTDRAWSURFACE);
void Restore_Surfaces (void);
void Set_Surface_Focus ( BOOL in_focus );
void Release(void);
BOOL SurfacesRestored;
private:
LPDIRECTDRAWSURFACE Surface[MAX_SURFACES];
BOOL InFocus;
};
extern SurfaceMonitorClass AllSurfaces; //List of all direct draw surfaces
/*=========================================================================*/
/* The following variables are declared in: DDRAW.CPP */
/*=========================================================================*/
extern LPDIRECTDRAW DirectDrawObject;
extern LPDIRECTDRAW2 DirectDraw2Interface;
extern HWND MainWindow;
extern BOOL SystemToVideoBlits;
extern BOOL VideoToSystemBlits;
extern BOOL SystemToSystemBlits;
extern BOOL OverlappedVideoBlits; // Can video driver blit overlapped regions?
/*=========================================================================*/
/* The following prototypes are for the file: EXIT.CPP */
/* Prog_End Must be supplied by the user program in startup.cpp */
/*=========================================================================*/
VOID __cdecl Prog_End(const char *why = NULL, bool fatal = false); // Added why and fatal parameters. ST - 6/27/2019 10:10PM
VOID __cdecl Exit(INT errorval, const BYTE *message, ...);
/*=========================================================================*/
/* The following prototypes are for the file: DELAY.CPP */
/*=========================================================================*/
void Delay(int duration);
void Vsync(void);
/*=========================================================================*/
/* The following prototypes are for the file: FINDARGV.CPP */
/*=========================================================================*/
BYTE __cdecl Find_Argv(BYTE const *str);
/*=========================================================================*/
/* The following prototypes are for the file: LIB.CPP */
/*=========================================================================*/
char *Find_Argv(char const *str);
void Mono_Mem_Dump(void const *databuf, int bytes, int y);
void Convert_RGB_To_HSV(unsigned int r, unsigned int g, unsigned int b, unsigned int *h, unsigned int *s, unsigned int *v);
void Convert_HSV_To_RGB(unsigned int h, unsigned int s, unsigned int v, unsigned int *r, unsigned int *g, unsigned int *b);
/*=========================================================================*/
/* The following prototypes are for the file: VERSION.CPP */
/*=========================================================================*/
BYTE __cdecl Version(VOID);
/*=========================================================================*/
/* The following prototypes are for the file: IRANDOM.CPP */
/*=========================================================================*/
int IRandom(int minval, int maxval);
/*========================= Assembly Routines ==============================*/
#ifdef __cplusplus
extern "C" {
#endif
/*=========================================================================*/
/* The following prototypes are for the file: RANDOM.ASM */
/*=========================================================================*/
unsigned char __cdecl Random(void);
int __cdecl Get_Random_Mask(int maxval);
/*=========================================================================*/
/* The following prototype is for the file: SHAKESCR.ASM */
/*=========================================================================*/
void __cdecl Shake_Screen(int shakes);
/*=========================================================================*/
/* The following prototypes are for the file: REVERSE.ASM */
/*=========================================================================*/
long __cdecl Reverse_Long(long number);
short __cdecl Reverse_Short(short number);
long __cdecl Swap_Long(long number);
#if (0)
/*=========================================================================*/
/* The following prototype is for the file: FACING8.ASM */
/*=========================================================================*/
int __cdecl Desired_Facing8(int x1, int y1, int x2, int y2);
/*=========================================================================*/
/* The following prototype is for the file: FACING16.ASM */
/*=========================================================================*/
int __cdecl Desired_Facing16(int x1, int y1, int x2, int y2);
/*=========================================================================*/
/* The following prototype is for the file: FACINGFF.ASM */
/*=========================================================================*/
int __cdecl Desired_Facing256(int x1, int y1, int x2, int y2);
/*=========================================================================*/
/* The following prototype is for the file: FADING.ASM */
/*=========================================================================*/
#endif
void * __cdecl Build_Fading_Table(void const *palette, void const *dest, long int color, long int frac);
/*=========================================================================*/
/* The following prototype is for the file: CRC.ASM */
/*=========================================================================*/
long __cdecl Calculate_CRC(void *buffer, long length);
/*=========================================================================*/
/* The following prototypes are for the file: DETPROC.ASM */
/*=========================================================================*/
extern WORD __cdecl Processor(void);
extern WORD __cdecl Operating_System(void);
extern unsigned long random ( unsigned long mod ) ;
//extern void randomize ( void ) ;
extern int __cdecl Clip_Rect ( int * x , int * y , int * dw , int * dh ,
int width , int height ) ;
extern int __cdecl Confine_Rect ( int * x , int * y , int dw , int dh ,
int width , int height ) ;
/*=========================================================================*/
/* The following prototypes are for the file: OPSYS.ASM */
/*=========================================================================*/
extern WORD OperationgSystem;
#ifdef __cplusplus
}
#endif
/*=========================================================================*/
#endif // MISC_H

View file

@ -0,0 +1,69 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
#ifndef WIN32
#define WIN32
#ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
#define _WIN32
#endif // _WIN32
#endif //WIN32
#include <windows.h>
class ModemRegistryEntryClass {
public:
ModemRegistryEntryClass (int modem_number);
~ModemRegistryEntryClass (void);
char *Get_Modem_Name (void) { return (ModemName); }
char *Get_Modem_Device_Name (void) { return (ModemDeviceName); }
char *Get_Modem_Error_Correction_Enable (void) { return (ErrorCorrectionEnable); }
char *Get_Modem_Error_Correction_Disable (void) { return (ErrorCorrectionDisable); }
char *Get_Modem_Compression_Enable (void) { return (CompressionEnable); }
char *Get_Modem_Compression_Disable (void) { return (CompressionDisable); }
char *Get_Modem_Hardware_Flow_Control (void) { return (HardwareFlowControl); }
char *Get_Modem_No_Flow_Control (void) { return (HardwareFlowControl); }
private:
char *ModemName;
char *ModemDeviceName;
char *ErrorCorrectionEnable;
char *ErrorCorrectionDisable;
char *CompressionEnable;
char *CompressionDisable;
char *HardwareFlowControl;
char *NoFlowControl;
};

View file

@ -0,0 +1,181 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: F:\projects\c&c\vcs\code\monoc.h_v 2.16 06 Sep 1995 16:29:02 JOE_BOSTIC $ */
/***********************************************************************************************
*** 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 : Command & Conquer *
* *
* File Name : MONO.H *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : July 2, 1994 *
* *
* Last Update : July 2, 1994 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef MONOC_H
#define MONOC_H
class MonoClass {
/*
** This is a private structure that is used to control which characters
** are used when a box is drawn. Line drawing on the monochrome screen is
** really made up of characters. This specifies which characters to use.
*/
typedef struct {
unsigned char UpperLeft;
unsigned char TopEdge;
unsigned char UpperRight;
unsigned char RightEdge;
unsigned char BottomRight;
unsigned char BottomEdge;
unsigned char BottomLeft;
unsigned char LeftEdge;
} BoxDataType;
/*
** Each cell is constructed of the actual character that is displayed and the
** attribute to use. This character pair is located at every position on the
** display (80 x 25). Since this cell pair can be represented by a "short"
** integer, certain speed optimizations are taken in the monochrome drawing
** code.
*/
typedef struct {
char Character; // Character to display.
char Attribute; // Attribute.
} CellType;
/*
** These private constants are used in the various monochrome operations.
*/
enum MonoClassPortEnums {
CONTROL_PORT=0x03B4, // CRTC control register.
DATA_PORT=0x03B5, // CRTC data register.
COLUMNS=80, // Number of columns.
LINES=25, // Number of lines.
SIZE_OF_PAGE=LINES*COLUMNS*sizeof(CellType), // Entire page size.
DEFAULT_ATTRIBUTE=0x02 // Normal white on black color attribute.
};
public:
enum MonoClassPageEnums {
MAX_MONO_PAGES=16, // Maximum RAM pages on mono card.
SEGMENT=0xB000 // Monochrome screen segment.
};
/*
** These are the various box styles that may be used.
*/
typedef enum BoxStyleType {
SINGLE, // Single thickness.
DOUBLE_HORZ, // Double thick on the horizontal axis.
DOUBLE_VERT, // Double thick on the vertical axis.
DOUBLE, // Double thickness.
COUNT
} BoxStyleType;
MonoClass(void);
~MonoClass(void);
static void Enable(void) {Enabled = 1;};
static void Disable(void) {Enabled = 0;};
static int Is_Enabled(void) {return Enabled;};
static MonoClass * Get_Current(void) {return PageUsage[0];};
void Draw_Box(int x, int y, int w, int h, char attrib=DEFAULT_ATTRIBUTE, BoxStyleType thick=SINGLE);
void Set_Default_Attribute(char attrib) {Attrib = attrib;};
void Clear(void);
void Set_Cursor(int x, int y);
void Print(char const *text);
void Print(int text);
void Printf(char const *text, ...);
void Printf(int text, ...);
void Text_Print(char const *text, int x, int y, char attrib=DEFAULT_ATTRIBUTE);
void Text_Print(int text, int x, int y, char attrib=DEFAULT_ATTRIBUTE);
void View(void);
int Get_X(void) const {return X;};
int Get_Y(void) const {return Y;};
/*
** Handles deep copies for the mono class objects. This performs what is essentially
** a screen copy.
*/
MonoClass & operator = (MonoClass const & );
/*
** This merely makes a duplicate of the mono object into a newly created mono
** object.
*/
MonoClass (MonoClass const &);
private:
char X; // Cursor X position.
char Y; // Cursor Y position.
char Attrib; // Normal attribute to use if none specified.
char Page; // The current page to write to.
/*
** Helper functions to help with display operations.
*/
int Offset(int x=0, int y=0) const {return (SIZE_OF_PAGE*Page) + sizeof(CellType)*(x + (y*COLUMNS));};
void Scroll(int lines);
void Store_Cell(CellType &cell, int x, int y) {
*(CellType *)((long)MonoSegment + Offset(x, y)) = cell;
};
/*
** This is the segment/selector of the monochrome screen.
*/
static void * MonoSegment;
/*
** This the the arrays of characters used for drawing boxes.
*/
static BoxDataType const CharData[4];
/*
** This array contains pointers to the monochrome objects that are assigned
** to each of the monochrome pages. As the monochrome pages are made visible,
** they can be shuffled around between the actual locations. The first entry
** in this table is the one that is visible.
*/
static MonoClass * PageUsage[MAX_MONO_PAGES];
/*
** If this is true, then monochrome output is allowed. It defaults to false
** so that monochrome output must be explicitly enabled.
*/
static int Enabled;
};
void Mono_Set_Cursor(int x, int y);
int Mono_Printf(char const *string, ...);
void Mono_Clear_Screen(void);
void Mono_Text_Print(void const *text, int x, int y, int attrib);
void Mono_Draw_Rect(int x, int y, int w, int h, int attrib, int thick);
void Mono_Print(void const *text);
int Mono_X(void);
int Mono_Y(void);
#endif

View file

@ -0,0 +1,173 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : wwlib32 *
* *
* File Name : PALTOPAL.CPP *
* *
* Programmer : Bill Randolph *
* *
* Start Date : May 2, 1994 *
* *
* Last Update : May 2, 1994 [BR] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Morph_Palette -- morphs a palette from source to destination *
* Palette_To_Palette -- morph src palette to a dst palette *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
********************************* Includes **********************************
*/
#include "wwstd.h"
#include "palette.h"
#include "timer.h"
/*
********************************* Constants *********************************
*/
#define SCALE(a,b,c) (((((long)(a)<<8) / (long)(b) ) * (unsigned long)(c)) >>8)
/*
********************************** Globals **********************************
*/
/*
******************************** Prototypes *********************************
*/
PRIVATE int __cdecl Palette_To_Palette(void *src_palette, void *dst_palette, unsigned long current_time, unsigned long delay);
/***************************************************************************
* Morph_Palette -- morphs a palette from source to destination *
* *
* INPUT: *
* void *src_pal - starting palette *
* void *dst_pal - ending palette *
* unsigned int delay - time delay in 60ths of a second *
* void *callback - user-defined callback, NULL if none *
* *
* OUTPUT: *
* none. *
* *
* WARNINGS: *
* *
* HISTORY: *
* 05/02/1994 BR : Created. *
*=========================================================================*/
void cdecl Morph_Palette (void *src_pal, void *dst_pal, unsigned int delay,
void (*callback) (void) )
{
int result;
unsigned long pal_start = TickCount.Time();
extern void (*cb_ptr) ( void ) ; // callback function pointer
// (void *)cb_ptr = callback;
cb_ptr = callback ;
/*===================================================================*/
/* Make sure that we don't go too fast but also make sure we keep */
/* processing the morph palette if we have one. */
/*===================================================================*/
while (1) {
if (src_pal && dst_pal) {
result = Palette_To_Palette (src_pal, dst_pal,
(TickCount.Time() - pal_start), (unsigned long)delay);
if (!result)
break;
if (callback) {
(*cb_ptr)();
}
}
}
return;
} /* end of Morph_Palette */
/***************************************************************************
* Palette_To_Palette -- morph src palette to a dst palette *
* *
* Creates & sets a palette that's in-between 'src_palette' & *
* 'dst_palette'; how close it is to dst_palette is based on how close *
* 'current_time' is to 'delay'. 'current_time' & 'delay' are based on *
* 0 being the start time. *
* *
* INPUT: void *src_palette = palette we want to morph from *
* void *dst_palette = palette we want to morph to *
* long current_time = time we started morph pal *
* long delay = time we want the morph to take*
* *
* OUTPUT: int if the time had elapsed and no chages were *
* necessary this routine returns FALSE *
* otherwise it will always return TRUE (this *
* was necessary to detect the end of the ice *
* effect. *
* *
* HISTORY: *
* 05/24/1993 MC : Created. *
*=========================================================================*/
PRIVATE int cdecl Palette_To_Palette(void *src_palette, void *dst_palette,
unsigned long current_time, unsigned long delay)
{
char colour;
char diff;
int chgval;
int lp;
int change;
static char palette[768];
char *src_pal = (char*)src_palette;
char *dst_pal = (char*)dst_palette;
/*======================================================================*/
/* Loop through each RGB value attempting to change it to the correct */
/* color. */
/*======================================================================*/
for (change = lp = 0; lp < 768; lp++) {
if (current_time < delay ) {
diff = dst_pal[lp] & (char)63;
diff -= src_pal[lp] & (char)63;
if (diff)
change = TRUE;
chgval = SCALE(diff, delay, current_time);
colour = src_pal[lp] & (char)63;
colour +=(char)chgval;
}
else {
colour = dst_pal[lp] & (char)63;
change = FALSE;
}
palette[lp] = colour;
}
/*======================================================================*/
/* Set the palette to the color that we created. */
/*======================================================================*/
Set_Palette(palette);
return(change);
} /* end of Palette_To_Palette */
/*************************** End of morphpal.cpp ***************************/


View file

@ -0,0 +1,123 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***********************************************************************************************
* *
* Project Name : Westwood 32 Bit Library *
* *
* File Name : MOUSE.H *
* *
* Programmer : Philip W. Gorrow *
* *
* Start Date : 12/12/95 *
* *
* Last Update : December 12, 1995 [PWG] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef WW_MOUSE_H
#define WW_MOUSE_H
#include <gbuffer.h>
class WWMouseClass {
public:
WWMouseClass(GraphicViewPortClass *scr, int mouse_max_width, int mouse_max_height);
~WWMouseClass();
void *Set_Cursor(int xhotspot, int yhotspot, void *cursor);
void Process_Mouse(void);
void Hide_Mouse(void);
void Show_Mouse(void);
void Conditional_Hide_Mouse(int x1, int y1, int x2, int y2);
void Conditional_Show_Mouse(void);
int Get_Mouse_State(void);
int Get_Mouse_X(void);
int Get_Mouse_Y(void);
void Get_Mouse_XY(int &x, int &y);
//
// The following two routines can be used to render the mouse onto a graphicbuffer
// other than the hidpage.
//
void Draw_Mouse(GraphicViewPortClass *scr);
void Erase_Mouse(GraphicViewPortClass *scr, int forced = FALSE);
void Block_Mouse(GraphicBufferClass *buffer);
void Unblock_Mouse(GraphicBufferClass *buffer);
void Set_Cursor_Clip(void);
void Clear_Cursor_Clip(void);
private:
enum {
CONDHIDE = 1,
CONDHIDDEN = 2,
};
void Low_Hide_Mouse(void);
void Low_Show_Mouse(int x, int y);
char *MouseCursor; // pointer to the mouse cursor in memory
int MouseXHot; // X hot spot of the current mouse cursor
int MouseYHot; // Y hot spot of the current mouse cursor
int CursorWidth; // width of the mouse cursor in pixels
int CursorHeight; // height of the mouse cursor in pixels
char *MouseBuffer; // pointer to background buffer in memory
int MouseBuffX; // pixel x mouse buffer was preserved at
int MouseBuffY; // pixel y mouse buffer was preserved at
int MaxWidth; // maximum width of mouse background buffer
int MaxHeight; // maximum height of mouse background buffer
int MouseCXLeft; // left x pos if conditional hide mouse in effect
int MouseCYUpper; // upper y pos if conditional hide mouse in effect
int MouseCXRight; // right x pos if conditional hide mouse in effect
int MouseCYLower; // lower y pos if conditional hide mouse in effect
char MCFlags; // conditional hide mouse flags
char MCCount; // nesting count for conditional hide mouse
GraphicViewPortClass *Screen; // pointer to the surface mouse was init'd with
char * PrevCursor; // pointer to previous cursor shape
int MouseUpdate;
int State;
char *EraseBuffer; // Buffer which holds background to restore to hidden page
int EraseBuffX; // X position of the hidden page background
int EraseBuffY; // Y position of the hidden page background
int EraseBuffHotX; // X position of the hidden page background
int EraseBuffHotY; // Y position of the hidden page background
int EraseFlags; // Records whether mutex has been released
CRITICAL_SECTION MouseCriticalSection; // Control for mouse re-enterancy
unsigned TimerHandle;
};
extern "C" {
void __cdecl Mouse_Shadow_Buffer(void *thisptr, GraphicViewPortClass *srcdst, void *buffer, int x, int y, int hotx, int hoty, int store);
void __cdecl Draw_Mouse(void *thisptr, GraphicViewPortClass *srcdst, int x, int y);
void * __cdecl ASM_Set_Mouse_Cursor(void * thisptr, int hotspotx, int hotspoty, VOID *cursor);
};
void Hide_Mouse(void);
void Show_Mouse(void);
void Conditional_Hide_Mouse(int x1, int y1, int x2, int y2);
void Conditional_Show_Mouse(void);
int Get_Mouse_State(void);
void *Set_Mouse_Cursor(int hotx, int hoty, void *cursor);
int Get_Mouse_X(void);
int Get_Mouse_Y(void);
#endif

View file

@ -0,0 +1,64 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***********************************************************************************************
;* *
;* Project Name : Westwood 32 bit Library *
;* *
;* File Name : MOUSE.INC *
;* *
;* Programmer : Philip W. Gorrow *
;* *
;* Start Date : 12/12/95 *
;* *
;* Last Update : December 12, 1995 [PWG] *
;* *
;*---------------------------------------------------------------------------------------------*
;* Functions: *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
STRUC MouseType
MouseCursor DD ? ; pointer to the mouse cursor in memory
MouseXHot DD ? ; X hot spot of the current mouse cursor
MouseYHot DD ? ; Y hot spot of the current mouse cursor
CursorWidth DD ? ; Width of mouse cursor in pixels
CursorHeight DD ? ; Height of the mouse cursor in pixels
MouseBuffer DD ? ; pointer to background buffer in memory
MouseBuffX DD ? ; pixel x mouse buffer was preserved at
MouseBuffY DD ? ; pixel y mouse buffer was preserved at
MaxWidth DD ? ; Maximum possible width of the background buffer
MaxHeight DD ? ; Maximum possible height of the background buffer
MouseCXLeft DD ? ; left hand x position if conditional hide mouse in effect
MouseCYUpper DD ? ; upper y position if conditional hide mouse in effect
MouseCXRight DD ? ; right hand x position if conditional hide mouse in effect
MouseCYLower DD ? ; lower y position if conditional hide mouse in effect
MCFlags DB ? ; conditional hide mouse flags
MCCount DB ? ; nesting count for conditional hide mouse
Screen DD ? ; pointer to the surface mouse was init'd with
PrevCursor DD ? ; pointer to the prev cursor shape
MouseUpdate DD ? ; is the mouse being currently updated
State DD ?
EraseBuffer DD ?
EraseBuffX DD ?
EraseBuffY DD ?
EraseBuffHotX DD ?
EraseBuffHotY DD ?
EraseFlags DD ?
ENDS

View file

@ -0,0 +1,720 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***********************************************************************************************
* *
* Project Name : Westwood 32 bit Library *
* *
* File Name : MOUSE.CPP *
* *
* Programmer : Philip W. Gorrow *
* *
* Start Date : 12/12/95 *
* *
* Last Update : December 12, 1995 [PWG] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* WWMouseClass::WWMouseClass -- Constructor for the Mouse Class *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "mouse.h"
#include <mmsystem.h>
static WWMouseClass *_Mouse=NULL;
void CALLBACK Process_Mouse( UINT event_id, UINT res1 , DWORD user, DWORD res2, DWORD res3 );
extern bool GameInFocus;
/***********************************************************************************************
* MOUSECLASS::MOUSECLASS -- Constructor for the Mouse Class *
* *
* INPUT: GraphicViewPortClass * screen - pointer to screen mouse is created for *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 12/12/1995 PWG : Created. *
*=============================================================================================*/
WWMouseClass::WWMouseClass(GraphicViewPortClass *scr, int mouse_max_width, int mouse_max_height)
{
MouseCursor = new char[mouse_max_width * mouse_max_height];
MouseXHot = 0;
MouseYHot = 0;
CursorWidth = 0;
CursorHeight = 0;
MouseBuffer = new char[mouse_max_width * mouse_max_height];
MouseBuffX = -1;
MouseBuffY = -1;
MaxWidth = mouse_max_width;
MaxHeight = mouse_max_height;
MouseCXLeft = 0;
MouseCYUpper = 0;
MouseCXRight = 0;
MouseCYLower = 0;
MCFlags = 0;
MCCount = 0;
Screen = scr;
PrevCursor = NULL;
MouseUpdate = 0;
State = 1;
timeBeginPeriod ( 1000/ 60);
InitializeCriticalSection (&MouseCriticalSection);
//
// Install the timer callback event handler
//
EraseBuffer = new char[mouse_max_width * mouse_max_height];
EraseBuffX = -1;
EraseBuffY = -1;
EraseBuffHotX = -1;
EraseBuffHotY = -1;
EraseFlags = FALSE;
_Mouse = this;
// Add TIME_KILL_SYNCHRONOUS flag. ST - 2/13/2019 5:07PM
//TimerHandle = timeSetEvent( 1000/60 , 1 , ::Process_Mouse, 0 , TIME_PERIODIC);
//TimerHandle = timeSetEvent( 1000/60 , 1 , ::Process_Mouse, 0 , TIME_PERIODIC | TIME_KILL_SYNCHRONOUS); // Removed. ST - 2/13/2019 5:12PM
/*
** Force the windows mouse pointer to stay withing the graphic view port region
*/
Set_Cursor_Clip();
}
WWMouseClass::~WWMouseClass()
{
MouseUpdate++;
if (MouseCursor) delete[] MouseCursor;
if (MouseBuffer) delete[] MouseBuffer;
if (TimerHandle) {
timeKillEvent(TimerHandle);
TimerHandle = 0; //ST - 2/13/2019 5:12PM
}
timeEndPeriod (1000/60);
DeleteCriticalSection(&MouseCriticalSection);
/*
** Free up the windows mouse pointer movement
*/
Clear_Cursor_Clip();
}
void Block_Mouse(GraphicBufferClass *buffer)
{
if (_Mouse){
_Mouse->Block_Mouse(buffer);
}
}
void Unblock_Mouse(GraphicBufferClass *buffer)
{
if (_Mouse){
_Mouse->Unblock_Mouse(buffer);
}
}
void WWMouseClass::Block_Mouse(GraphicBufferClass *buffer)
{
if (buffer == Screen->Get_Graphic_Buffer()){
EnterCriticalSection(&MouseCriticalSection);
}
}
void WWMouseClass::Unblock_Mouse(GraphicBufferClass *buffer)
{
if (buffer == Screen->Get_Graphic_Buffer()){
LeaveCriticalSection(&MouseCriticalSection);
}
}
void WWMouseClass::Set_Cursor_Clip(void)
{
#if (0) // Not needed. ST - 1/3/2019 2:18PM
if (Screen){
RECT region;
region.left = 0;
region.top = 0;
region.right = Screen->Get_Width();
region.bottom = Screen->Get_Height();
ClipCursor(&region);
}
#endif
}
void WWMouseClass::Clear_Cursor_Clip(void)
{
#if (0)
ClipCursor(NULL);
#endif
}
void WWMouseClass::Process_Mouse(void)
{
//ST - 1/3/2019 10:50AM
return;
#if (0)
POINT pt; // define a structure to hold current cursor pos
//
// If the mouse is currently hidden or it has not been installed, then we
// have no need to redraw the mouse.
//
if (!Screen || !_Mouse || State > 0 || MouseUpdate || EraseFlags || !GameInFocus)
return;
//
// Make sure there are no conflicts with other
// threads that may try and lock the screen buffer
//
//Block_Mouse(Screen->Get_Graphic_Buffer());
//
// If the screen is already locked by another thread then just exit
//
if (Screen->Get_LockCount()!=0){
//Unblock_Mouse(Screen->Get_Graphic_Buffer());
return;
}
//
// Get the mouse's current real cursor position
//
GetCursorPos(&pt); // get the current cursor position
//
// If the mouse has moved then we are responsible to redraw the mouse
//
if (pt.x != MouseBuffX || pt.y != MouseBuffY) {
//
// If we can't lock the surface we need to draw to, we cannot update
// the mouse.
//
if (Screen->Lock()) {
//
// Erase the old mouse by dumping the mouses shadow buff
// to the screen (if its position had ever been recorded).
//
Low_Hide_Mouse();
//
// Verify that the mouse has not gone into a conditional hiden area
// If it has, mark it as being in one.
//
if (MCFlags & CONDHIDE && pt.x >= MouseCXLeft && pt.x <= MouseCXRight && pt.y >= MouseCYUpper && pt.y <= MouseCYLower) {
MCFlags |= CONDHIDDEN;
}
//
// Show the mouse if we are allowed to.
//
if (!(MCFlags & CONDHIDDEN)) {
Low_Show_Mouse(pt.x, pt.y);
}
//
// Finally unlock the destination surface as we have sucessfully
// updated the mouse.
//
Screen->Unlock();
}
}
//
// Allow other threads to lock the screen again
//
//Unblock_Mouse(Screen->Get_Graphic_Buffer());
#endif
}
void *WWMouseClass::Set_Cursor(int xhotspot, int yhotspot, void *cursor)
{
//ST - 1/3/2019 10:50AM
xhotspot;
yhotspot;
cursor;
return cursor;
#if (0)
//
// If the pointer to the cursor we got is invalid, or its the same as the
// currently set cursor then just return.
if (!cursor || cursor == PrevCursor)
return(cursor);
//
// Wait until we have exclusive access to our data
//
MouseUpdate++;
//
// Since we are updating the mouse we need to hide the cursor so we
// do not get some sort of weird transformation.
//
Hide_Mouse();
//
// Now convert the shape to a mouse cursor with the given hotspots and
// set it as our current mouse.
//
void *retval = ASM_Set_Mouse_Cursor(this, xhotspot, yhotspot, cursor);
//
// Show the mouse which will force it to appear with the new shape we
// have assigned.
//
Show_Mouse();
//
// We are done updating the mouse cursor so on to bigger and better things.
//
MouseUpdate--;
//
// Return the previous mouse cursor which as conveniantly passed back by
// Asm_Set_Mouse_Cursor.
//
return(retval);
#endif
}
void WWMouseClass::Low_Hide_Mouse()
{
//ST - 1/3/2019 10:50AM
#if (0)
if (!State) {
if (MouseBuffX != -1 || MouseBuffY != -1) {
if (Screen->Lock()){
Mouse_Shadow_Buffer(this, Screen, MouseBuffer, MouseBuffX, MouseBuffY, MouseXHot, MouseYHot, 0);
Screen->Unlock();
}
}
MouseBuffX = -1;
MouseBuffY = -1;
}
#endif
State++;
}
void WWMouseClass::Hide_Mouse()
{
MouseUpdate++;
Low_Hide_Mouse();
MouseUpdate--;
}
void WWMouseClass::Low_Show_Mouse(int x, int y)
{
//
// If the mouse is already visible then just ignore the problem.
//
if (State == 0) return;
//
// Make the mouse a little bit more visible
//
State--;
//ST - 1/3/2019 10:50AM
#if (0)
//
// If the mouse is completely visible then draw it at its current
// position.
//
if (!State) {
//
// Try to lock the screen til we sucessfully get a lock.
//
if (Screen->Lock()){
//
// Save off the area behind the mouse.
//
Mouse_Shadow_Buffer(this, Screen, MouseBuffer, x, y, MouseXHot, MouseYHot, 1);
//
// Draw the mouse in its new location
//
::Draw_Mouse(this, Screen, x, y);
//
// Save off the positions that we saved the buffer from
//
MouseBuffX = x;
MouseBuffY = y;
//
// Unlock the screen and lets get moving.
//
Screen->Unlock();
}
}
#endif
}
void WWMouseClass::Show_Mouse()
{
POINT pt;
GetCursorPos(&pt);
MouseUpdate++;
Low_Show_Mouse(pt.x, pt.y);
MouseUpdate--;
}
void WWMouseClass::Conditional_Hide_Mouse(int x1, int y1, int x2, int y2)
{
POINT pt;
MouseUpdate++;
//
// First of all, adjust all the coordinates so that they handle
// the fact that the hotspot is not necessarily the upper left
// corner of the mouse.
//
x1 -= (CursorWidth - MouseXHot);
x1 = MAX(0, x1);
y1 -= (CursorHeight - MouseYHot);
y1 = MAX(0, y1);
x2 += MouseXHot;
x2 = MIN(x2, Screen->Get_Width());
y2 += MouseYHot;
y2 = MIN(y2, Screen->Get_Height());
// The mouse could be in one of four conditions.
// 1) The mouse is visible and no conditional hide has been specified.
// (perform normal region checking with possible hide)
// 2) The mouse is hidden and no conditional hide as been specified.
// (record region and do nothing)
// 3) The mouse is visible and a conditional region has been specified
// (expand region and perform check with possible hide).
// 4) The mouse is already hidden by a previous conditional.
// (expand region and do nothing)
//
// First: Set or expand the region according to the specified parameters
if (!MCCount) {
MouseCXLeft = x1;
MouseCYUpper = y1;
MouseCXRight = x2;
MouseCYLower = y2;
} else {
MouseCXLeft = MIN(x1, MouseCXLeft);
MouseCYUpper = MIN(y1, MouseCYUpper);
MouseCXRight = MAX(x2, MouseCXRight);
MouseCYLower = MAX(y2, MouseCYLower);
}
//
// If the mouse isn't already hidden, then check its location against
// the hiding region and hide if necessary.
//
if (!(MCFlags & CONDHIDDEN)) {
GetCursorPos(&pt);
if (MouseBuffX >= MouseCXLeft && MouseBuffX <= MouseCXRight && MouseBuffY >= MouseCYUpper && MouseBuffY <= MouseCYLower) {
Low_Hide_Mouse();
MCFlags |= CONDHIDDEN;
}
}
//
// Record the fact that a conditional hide was called and then exit
//
//
MCFlags |= CONDHIDE;
MCCount++;
MouseUpdate--;
}
void WWMouseClass::Conditional_Show_Mouse(void)
{
MouseUpdate++;
//
// if there are any nested hides then dec the count
//
if (MCCount) {
MCCount--;
//
// If the mouse is now not hidden and it had actually been
// hidden before then display it.
//
if (!MCCount) {
if (MCFlags & CONDHIDDEN) {
Show_Mouse();
}
MCFlags = 0;
}
}
MouseUpdate--;
}
void WWMouseClass::Draw_Mouse(GraphicViewPortClass *scr)
{
scr;
return;
//ST - 1/3/2019 10:50AM
#if (0)
POINT pt;
if (State != 0) return;
MouseUpdate++;
//
// Get the position that the mouse is currently located at
//
GetCursorPos(&pt);
if (MCFlags & CONDHIDE && pt.x >= MouseCXLeft && pt.x <= MouseCXRight && pt.y >= MouseCYUpper && pt.y <= MouseCYLower) {
Hide_Mouse();
MCFlags |= CONDHIDDEN;
} else {
//
// If the mouse is already visible then just ignore the problem.
//
EraseFlags = TRUE;
//
// Try to lock the screen - dont do video stuff if we cant.
//
if (scr->Lock()){
//
// Save off the area behind the mouse into two different buffers, one
// which will be used to restore the mouse and the other which will
// be used to restore the hidden surface when we get a chance.
//
Mouse_Shadow_Buffer(this, scr, EraseBuffer, pt.x, pt.y, MouseXHot, MouseYHot, 1);
memcpy(MouseBuffer, EraseBuffer, MaxWidth * MaxHeight);
//
// Draw the mouse in its new location
//
::Draw_Mouse(this, scr, pt.x, pt.y);
//
// Save off the positions that we saved the buffer from
//
EraseBuffX = pt.x;
MouseBuffX = pt.x;
EraseBuffY = pt.y;
MouseBuffY = pt.y;
EraseBuffHotX = MouseXHot;
EraseBuffHotY = MouseYHot;
//
// Unlock the screen and lets get moving.
//
scr->Unlock();
}
}
MouseUpdate--;
#endif
}
void WWMouseClass::Erase_Mouse(GraphicViewPortClass *scr, int forced)
{
//ST - 1/3/2019 10:50AM
scr;
forced;
return;
#if (0)
//
// If we are forcing the redraw of a mouse we already managed to
// restore then just get outta here.
//
if (forced && EraseBuffX == -1 && EraseBuffY == -1) return;
MouseUpdate++;
//
// If this is not a forced call, only update the mouse is we can legally
// lock the buffer.
//
if (!forced) {
#if(0)
if (scr->Lock()) {
//
// If the surface has not already been restore then restore it and erase the
// restoration coordinates so we don't accidentally do it twice.
//
if (EraseBuffX != -1 || EraseBuffY != -1) {
Mouse_Shadow_Buffer(this, scr, EraseBuffer, EraseBuffX, EraseBuffY, 0);
EraseBuffX = -1;
EraseBuffY = -1;
}
//
// We are done writing to the buffer so unlock it.
//
scr->Unlock();
}
#endif
} else {
//
// If the surface has not already been restore then restore it and erase the
// restoration coordinates so we don't accidentally do it twice.
//
if (EraseBuffX != -1 || EraseBuffY != -1) {
if (scr->Lock()){
Mouse_Shadow_Buffer(this, scr, EraseBuffer, EraseBuffX, EraseBuffY, EraseBuffHotX, EraseBuffHotY, 0);
scr->Unlock();
}
EraseBuffX = -1;
EraseBuffY = -1;
}
}
MouseUpdate--;
EraseFlags = FALSE;
#endif
}
int WWMouseClass::Get_Mouse_State(void)
{
return(State);
}
/***********************************************************************************************
* 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 WWMouseClass::Get_Mouse_X(void)
{
POINT pt;
GetCursorPos(&pt);
return(pt.x);
}
/***********************************************************************************************
* 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 WWMouseClass::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 WWMouseClass::Get_Mouse_XY(int &x, int &y)
{
POINT pt;
GetCursorPos(&pt);
x = pt.x;
y = pt.y;
}
//#pragma off(unreferenced)
void CALLBACK Process_Mouse( UINT event_id, UINT res1 , DWORD user, DWORD res2, DWORD res3 )
{
static BOOL in_mouse_callback = false;
if (_Mouse && !in_mouse_callback) {
in_mouse_callback = TRUE;
_Mouse->Process_Mouse();
in_mouse_callback = FALSE;
}
}
//#pragma on(unreferenced)
void Hide_Mouse(void)
{
if (!_Mouse) return;
_Mouse->Hide_Mouse();
}
void Show_Mouse(void)
{
if (!_Mouse) return;
_Mouse->Show_Mouse();
}
void Conditional_Hide_Mouse(int x1, int y1, int x2, int y2)
{
if (!_Mouse) return;
_Mouse->Conditional_Hide_Mouse(x1, y1, x2, y2);
}
void Conditional_Show_Mouse(void)
{
if (!_Mouse) return;
_Mouse->Conditional_Show_Mouse();
}
int Get_Mouse_State(void)
{
if (!_Mouse) return(0);
return(_Mouse->Get_Mouse_State());
}
void *Set_Mouse_Cursor(int hotx, int hoty, void *cursor)
{
if (!_Mouse) return(0);
return(_Mouse->Set_Cursor(hotx,hoty,cursor));
}
extern int DLLForceMouseX;
extern int DLLForceMouseY;
int Get_Mouse_X(void)
{
if (DLLForceMouseX >= 0) {
return DLLForceMouseX;
}
if (!_Mouse) return(0);
return(_Mouse->Get_Mouse_X());
}
int Get_Mouse_Y(void)
{
if (DLLForceMouseY >= 0) {
return DLLForceMouseY;
}
if (!_Mouse) return(0);
return(_Mouse->Get_Mouse_Y());
}

View file

@ -0,0 +1,125 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Memory system. *
* *
* File Name : NEWDEL.CPP *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : June 21, 1994 *
* *
* Last Update : October 20, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* operator NEW -- Overides the global new function. *
* operator delete -- Overides the global delete function. *
* operator NEW[] -- Overides the array version of new. *
* operator delete[] -- Overides the array version of delete[] *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "wwmem.h"
/*=========================================================================*/
/* The following PRIVATE functions are in this file: */
/*=========================================================================*/
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
/***************************************************************************
* OPERATOR NEW -- Overides the global new function. *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/21/1994 SKB : Created. *
*=========================================================================*/
void * operator new(size_t size)
{
return (Alloc((unsigned long) size, MEM_NEW));
}
/***************************************************************************
* OPERATOR NEW[] -- Overides the array version of new. *
* *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/21/1994 SKB : Created. *
*=========================================================================*/
void * operator new[](size_t size)
{
return (Alloc((unsigned long) size, MEM_NEW));
}
/***************************************************************************
* OPERATOR DELETE -- Overides the global delete function. *
* *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/21/1994 SKB : Created. *
*=========================================================================*/
void operator delete(void *ptr)
{
Free(ptr);
}
/***************************************************************************
* OPERATOR DELETE[] -- Overides the array version of delete[] *
* *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 10/20/1994 SKB : Created. *
*=========================================================================*/
void operator delete[](void *ptr)
{
Free(ptr);
}

View file

@ -0,0 +1,56 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;****************************************************************************
;* bNybbleTablexxxx - ADPCM Lookup table for nybbles
;****************************************************************************
align 4
bNybbleTableLow DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
DB 00h*2,01h*2,02h*2,03h*2,04h*2,05h*2,06h*2,07h*2,08h*2,09h*2,0Ah*2,0Bh*2,0Ch*2,0Dh*2,0Eh*2,0Fh*2
align 4
bNybbleTableHigh DB 00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2,00h*2
DB 01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2,01h*2
DB 02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2,02h*2
DB 03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2,03h*2
DB 04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2,04h*2
DB 05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2,05h*2
DB 06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2,06h*2
DB 07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2,07h*2
DB 08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2,08h*2
DB 09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2,09h*2
DB 0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2,0Ah*2
DB 0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2,0Bh*2
DB 0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2,0Ch*2
DB 0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2,0Dh*2
DB 0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2,0Eh*2
DB 0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2,0Fh*2

View file

@ -0,0 +1,381 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WWLIB *
* *
* File Name : PALETTE.C *
* *
* Programmer : BILL STOKES *
* *
* Start Date : 6/20/91 *
* *
* Last Update : August 2, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Note: This module contains dependencies upon the video system, *
* specifically Get_Video_Mode(). *
*-------------------------------------------------------------------------*
* Functions: *
* Set_Palette -- sets the current palette *
* Set_Palette_Color -- Set a color number in a palette to the data. *
* Fade_Palette_To -- Fades the current palette into another *
* Determine_Bump_Rate -- determines desired bump rate for fading *
* Bump_Palette -- increments the palette one step, for fading *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
********************************* Includes **********************************
*/
//#include <mem.h>
#include "palette.h"
#include "timer.h"
#include "wwstd.h"
/*
********************************* Constants *********************************
*/
/*
********************************** Globals **********************************
*/
extern "C" extern unsigned char CurrentPalette[]; /* in pal.asm */
/*
******************************** Prototypes *********************************
*/
PRIVATE void __cdecl Determine_Bump_Rate(void *palette, int delay, short *ticks, short *rate);
PRIVATE BOOL __cdecl Bump_Palette(void *palette1, unsigned int step);
/*
******************************** Code *********************************
*/
/***************************************************************************
* Set_Palette -- sets the current palette *
* *
* INPUT: *
* void *palette - palette to set *
* *
* OUTPUT: *
* none *
* *
* WARNINGS: *
* *
* HISTORY: *
* 04/25/1994 SKB : Created. *
* 04/27/1994 BR : Converted to 32-bit *
*=========================================================================*/
void __cdecl Set_Palette(void *palette)
{
#if(IBM)
Set_Palette_Range(palette);
#else
Copy_Palette(palette,CurrentPalette);
LoadRGB4(&Main_Screen->ViewPort,palette,32L);
LoadRGB4(AltVPort,palette,32L);
#endif
} /* end of Set_Palette */
/***************************************************************************
* Set_Palette_Color -- Set a color number in a palette to the data. *
* *
* *
* INPUT: *
* void *palette - palette to set color in *
* int color - which color index to set *
* void *data - RGB data for color *
* *
* OUTPUT: *
* none *
* *
* WARNINGS: *
* *
* HISTORY: *
* 04/25/1994 SKB : Created. *
* 04/27/1994 BR : Converted to 32-bit *
*=========================================================================*/
void __cdecl Set_Palette_Color(void *palette, int color, void *data)
{
/*
---------------------- Return if 'palette' is NULL -----------------------
*/
if (!palette) return;
/*
------------------- Change the color & set the palette -------------------
*/
#if(IBM)
memcpy(&((unsigned char *)palette)[color * RGB_BYTES], data, RGB_BYTES);
Set_Palette_Range(palette);
#else
palette[color] = *(unsigned short*)data;
Set_Palette(palette);
#endif
} /* end of Set_Palette */
/***************************************************************************
* Fade_Palette_To -- Fades the current palette into another *
* *
* This will allow the palette to fade from current palette into the *
* palette that was passed in. This can be used to fade in and fade out. *
* *
* INPUT: *
* char *palette1 - this is the palette to fade to. *
* unsigned int delay - fade with this timer count down *
* void *callback - user-defined callback function *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/20/1991 BS : Created. *
*=========================================================================*/
void Fade_Palette_To(void *palette1, unsigned int delay, void (*callback)() )
{
BOOL changed; // Flag that palette has changed this tick.
short jump; // Gun values to jump per palette set.
unsigned long timer; // Tick count timer used for timing.
short ticksper; // The ticks (fixed point) per bit jump.
int tickaccum;
extern void (*cb_ptr)(void); // callback function pointer
// (void *)cb_ptr = callback;
cb_ptr = callback;
/*
---------------------- Return if 'palette1' is NULL ----------------------
*/
if (!palette1)
return;
/*
--------------------------- Get the bump rate ----------------------------
*/
Determine_Bump_Rate(palette1, delay, &ticksper, &jump);
tickaccum = 0; // init accumulated elapsed time
timer = TickCount.Time(); // timer = current time
do {
changed = FALSE;
tickaccum += ticksper; // tickaccum = time of next change * 256
timer += (tickaccum >> 8); // timer = time of next change (rounded)
tickaccum &= 0x0FF; // shave off high byte, keep roundoff bits
changed = Bump_Palette(palette1, jump); // increment palette
/*
.................. Wait for time increment to elapse ..................
*/
if (changed) {
while (TickCount.Time() < (int)timer) {
/*
................. Update callback while waiting .................
*/
if (callback) {
#if LIB_EXTERNS_RESOLVED
Sound_Callback(); // should be removed!
#endif
(*cb_ptr)();
}
}
}
#if LIB_EXTERNS_RESOLVED
Sound_Callback(); // should be removed!
#endif
if (callback) {
(*cb_ptr)();
}
} while (changed);
} /* end of Fade_Palette_To */
/***************************************************************************
* Determine_Bump_Rate -- determines desired bump rate for fading *
* *
* INPUT: *
* unsigned char *palette - palette to fade to *
* int delay - desired time delay in 60ths of a second *
* short *ticks - output: loop ticks per color jump *
* short *rate - output: color gun increment rate *
* *
* OUTPUT: *
* none *
* *
* WARNINGS: *
* *
* HISTORY: *
* 04/27/1994 BR : Converted to 32-bit *
* 08/02/1994 SKB : Made private *
*=========================================================================*/
PRIVATE void __cdecl Determine_Bump_Rate(void *palette, int delay, short *ticks,
short *rate)
{
int gun1; // Palette 1 gun value.
int gun2; // Palette 2 gun value.
int diff; // Maximum color gun difference.
int tp; // Temporary tick accumulator.
int index; // Color gun working index.
long t; // Working tick intermediate value.
int adiff; // Absolute difference between guns.
/*
------------------------ Find max gun difference -------------------------
*/
diff = 0;
for (index = 0; index < PALETTE_BYTES; index++) {
gun1 = ((unsigned char *)palette)[index];
gun2 = CurrentPalette[index];
adiff = ABS(gun1-gun2);
diff = MAX(diff, adiff);
}
/*------------------------------------------------------------------------
ticks = (total time delay ) / (max gun diff)
The value is computed based on (delay * 256), for fixed-point math;
the lower bits represent the leftover from the division; 'ticks' is
returned still shifted, so the low bits can be used to accumulate the
time more accurately; the caller must shift the accumulated value down
8 bits to determine the actual elapsed time!
------------------------------------------------------------------------*/
t = ((long)delay) << 8;
if (diff) {
t /= diff;
t = MIN((long)t, (long)0x7FFF);
}
*ticks = (short)t;
/*------------------------------------------------------------------------
Adjust the color gun rate value if the time to fade is faster than can
reasonably be performed given the palette change, ie if (ticks>>8)==0,
and thus less than 1/60 of a second
------------------------------------------------------------------------*/
tp = *ticks;
*rate = 1;
while (*rate <= diff && *ticks < 256) {
*ticks += tp;
*rate += 1;
}
} /* end of Determine_Bump_Rate */
/***************************************************************************
* Bump_Palette -- increments the palette one step, for fading *
* *
* INPUT: *
* palette1 - palette to fade towards *
* step - max step amount, determined by Determine_Bump_Rate *
* *
* OUTPUT: *
* FALSE = no change, TRUE = changed *
* *
* WARNINGS: *
* *
* HISTORY: *
* 04/27/1994 BR : Created. *
* 08/02/1994 SKB : Made private *
*=========================================================================*/
#if(IBM)
PRIVATE BOOL __cdecl Bump_Palette(void *palette1, unsigned int step)
{
BOOL changed=FALSE; // Flag that palette has changed this tick.
int index; // Index to DAC register gun.
int gun1,gun2; // Palette 1 gun value.
unsigned char palette[PALETTE_BYTES]; // copy of current palette
/*
---------------------- Return if 'palette1' is NULL ----------------------
*/
if (!palette1)
return (FALSE);
/*
------------------------ Copy the current palette ------------------------
*/
memcpy(palette, CurrentPalette, 768);
/*
----------------------- Loop through palette bytes -----------------------
*/
for (index = 0; index < PALETTE_BYTES; index++) {
gun1 = ((unsigned char *)palette1)[index];
gun2 = palette[index];
/*
............. If the colors match, go on to the next one ..............
*/
if (gun1 == gun2) continue;
changed = TRUE;
/*
.................. Increment current palette's color ..................
*/
if (gun2 < gun1) {
gun2 += step;
gun2 = MIN(gun2, gun1); // make sure we didn't overshoot it
}
/*
.................. Decrement current palette's color ..................
*/
else {
gun2 -= step;
gun2 = MAX(gun2, gun1); // make sure we didn't overshoot it
}
palette[index] = (unsigned char)gun2;
}
/*
----------------- Set current palette to the new palette -----------------
*/
if (changed) {
Set_Palette(&palette[0]);
}
return (changed);
} /* end of Bump_Palette */
#else
/* This is already implemented in asm on the Amiga */
#endif
void (*cb_ptr)(void); // callback function pointer
/**************************** End of palette.cpp ***************************/


View file

@ -0,0 +1,82 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
;** 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 : Palette 32bit Library. *
;* *
;* File Name : PALETTE.H *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : April 25, 1994 *
;* *
;* Last Update : April 27, 1994 [BRR] *
;* *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef PALETTE_H
#define PALETTE_H
#include <gbuffer.h>
/*
********************************* Constants *********************************
*/
#define RGB_BYTES 3
#define PALETTE_SIZE 256
#define PALETTE_BYTES 768
/*
******************************** Prototypes *********************************
*/
/*
-------------------------------- Palette.cpp --------------------------------
*/
void __cdecl Set_Palette(void *palette);
void __cdecl Set_Palette_Color(void *palette, int color, void *data);
void Fade_Palette_To(void *palette1, unsigned int delay, void (*callback)() );
/*
-------------------------------- loadpal.cpp --------------------------------
*/
void __cdecl Load_Palette(char *palette_file_name, void *palette_pointer);
/*
------------------------------- morphpal.cpp --------------------------------
*/
void __cdecl Morph_Palette (void *src_palette, void *dst_palette, unsigned int delay,
void *callback);
/*
---------------------------------- pal.asm ----------------------------------
*/
#ifdef __cplusplus
extern "C" {
#endif
extern void __cdecl Set_Palette_Range(void *palette);
extern BOOL __cdecl Bump_Color(void *palette, int changable, int target);
#ifdef __cplusplus
}
#endif
extern "C" extern unsigned char CurrentPalette[]; /* in pal.asm */
#endif // PALETTE_H
/***************************** End of palette.h ****************************/

View file

@ -0,0 +1,306 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WWLIB *
* *
* File Name : PLAYCD.H *
* *
* Programmer : STEVE WETHERILL *
* *
* Start Date : 5/13/94 *
* *
* Last Update : June 4, 1994 [SW] *
* *
*-------------------------------------------------------------------------*/
#ifndef PLAYCD_H
#define PLAYCD_H
#ifdef NOT_FOR_WIN95
/* ==================================================================== */
/* Defines */
/* ==================================================================== */
#define CHLEFT 0
#define CHRIGHT 1
#define CHBOTH 2
#define AUDIO_START_MIN 1
#define AUDIO_START_SEC 44
typedef struct {
unsigned short seg ;
unsigned short sel ;
} SEGSEL ;
extern "C" int DPMI_real_alloc ( UINT , SEGSEL * , USHORT * ) ;
extern "C" int DPMI_real_free ( SEGSEL ) ;
extern "C" void DPMI_real_intr ( int , union REGS * , struct SREGS * );
extern "C" void DPMI_real_call ( void * funct , union REGS * , struct SREGS * );
/* ==================================================================== */
/* Data structures */
/* ==================================================================== */
// Audio Track Info request block
struct TinfoType {
UBYTE Length;
UBYTE SubCd;
UBYTE Command;
UWORD Status;
UBYTE Rsvd[8];
UBYTE MDescr;
UWORD TrnsAdOff;
UWORD TrnsAdSeg;
UWORD CntTrns;
UWORD StSect;
UWORD VolIDOff;
UWORD VolIDSeg;
UBYTE TrInfo;
UBYTE Track;
ULONG Start;
UBYTE TrCtrl;
};
// Audio Track Status Control Block
struct StatType {
UBYTE Length;
UBYTE SubCd;
UBYTE Command;
UWORD Status;
UBYTE Rsvd[8];
UBYTE MDescr;
UWORD TrnsAdOff;
UWORD TrnsAdSeg;
UWORD CntTrns;
UWORD StSect;
UWORD VolIDOff;
UWORD VolIDSeg;
UBYTE StatInfo;
UWORD Stat;
ULONG Start;
ULONG End;
};
// Audio Track Volume control block
struct VolmType {
UBYTE Length;
UBYTE SubCd;
UBYTE Command;
UWORD Status;
UBYTE Rsvd[8];
UBYTE MDescr;
UWORD TrnsAdOff;
UWORD TrnsAdSeg;
UWORD CntTrns;
UWORD StSect;
UWORD VolIDOff;
UWORD VolIDSeg;
UBYTE TrInfo;
UBYTE In0;
UBYTE Vol0;
UBYTE In1;
UBYTE Vol1;
UBYTE In2;
UBYTE Vol2;
UBYTE In3;
UBYTE Vol3;
};
// Audio Track Play request block
struct PlayType {
UBYTE Length;
UBYTE SubCd;
UBYTE Command;
UWORD Status;
UBYTE Rsvd[8];
UBYTE AddrMd;
ULONG Start;
ULONG CntSect;
};
// Audio Track Stop request block
struct StopType {
UBYTE Length;
UBYTE SubCd;
UBYTE Command;
UWORD Status;
UBYTE Rsvd[8];
};
#endif //NOT_FOR_WIN95
/***************************************************************************
* GetCDClass -- object which will return logical CD drive *
* *
* HISTORY: *
* 06/04/1994 SW : Created. *
*=========================================================================*/
#define MAX_CD_DRIVES 26
#define NO_CD_DRIVE -1
class GetCDClass {
protected:
int CDDrives[MAX_CD_DRIVES]; //Array containing CD drive letters
int CDCount; //Number of available CD drives
int CDIndex;
public:
GetCDClass(VOID); // This is the default constructor
~GetCDClass(VOID); // This is the destructor
inline int Get_First_CD_Drive(void);
inline int Get_Next_CD_Drive(void);
inline int Get_Number_Of_Drives(void) {return (CDCount);};
};
/***********************************************************************************************
* GCDC::Get_Next_CD_Drive -- return the logical drive number of the next CD drive *
* *
* *
* *
* INPUT: Nothing *
* *
* OUTPUT: Logical drive number of a cd drive or -1 if none *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 5/21/96 3:50PM ST : Created *
*=============================================================================================*/
inline int GetCDClass::Get_Next_CD_Drive(void)
{
if (CDCount){
if (CDIndex == CDCount) CDIndex = 0;
return (CDDrives[CDIndex++]);
}else{
return (-1);
}
}
/***************************************************************************
* GCDC::Get_First_CD_Drive -- return the number of the first CD drive *
* *
* *
* *
* INPUT: *
* none *
* OUTPUT: *
* logical drive number *
* WARNINGS: *
* *
* HISTORY: *
* 05/26/1994 SW : Created. *
* 12/4/95 ST : fixed for Win95 *
*=========================================================================*/
inline int GetCDClass::Get_First_CD_Drive(void)
{
CDIndex = 0;
return (Get_Next_CD_Drive());
}
/***************************************************************************
* RedBookClass -- adds red book functionality *
* *
* this class inherits from GetCDClass and adds red book play functionality*
* *
* *
* HISTORY: *
* 06/04/1994 SW : Created. *
*=========================================================================*/
#ifdef NOT_FOR_WIN95
class RedBookClass : public GetCDClass {
private:
SEGSEL Tinfo_addrp;
SEGSEL Stat_addrp;
SEGSEL Stop_addrp;
SEGSEL Volm_addrp;
SEGSEL Play_addrp;
StopType Stop;
PlayType Play;
VolmType Volm;
StatType Stat;
TinfoType Tinfo;
public:
RedBookClass(VOID); // This is the default constructor
~RedBookClass(VOID); // This is the destructor
ULONG RedToHS(ULONG i);
ULONG MSFtoRed(UBYTE m, UBYTE s, UBYTE f);
VOID FullCDVolume(UBYTE chan);
VOID PlayTrack(UWORD track);
VOID Play_CD_MSL(UWORD min_sec, UWORD len);
VOID PlayMSF(UBYTE startM, UBYTE startS, UBYTE startF,
UBYTE endM, UBYTE endS, UBYTE endF, UBYTE chan);
UWORD CheckCDMusic(VOID);
VOID StopCDMusic(VOID);
};
#endif //NOT_FOR_WIN95
/***************************** End of Playcd.h ****************************/
#endif // PLAYCD_H


View file

@ -0,0 +1,102 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***********************************************************************************************
*** 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 : Library profiler *
* *
* File Name : PROFILE.H *
* *
* Programmer : Steve Tall *
* *
* Start Date : 11/17/95 *
* *
* Last Update : November 20th 1995 [ST] *
* *
*---------------------------------------------------------------------------------------------*
* Overview: *
* *
* New System *
* ~~~~~~~~~~~ *
* *
* The new profiler system creates a seperate thread and then starts a timer off there. The *
* timer in the second thread uses GetThreadContext to sample the IP address of each user *
* thread. This system has the advantage of being able to sample what is happening in all the *
* threads we own not just the main thread. Another advantage is that it doesnt require a *
* major recompilation. *
* The disadvantage is that we dont really know what is going on when the IP is outside the *
* scope of our threads - We could be in direct draw, direct sound or even something like the *
* VMM and there is no way to tell. *
* *
* *
* *
* Old System *
* ~~~~~~~~~~~ *
* *
* The profiler works by using the function prologue and epilogue hooks available in Watcom *
* to register the current functions address in a global variable and then sampling the *
* contents of the variable using a windows timer which runs at up to 1000 samples per second.*
* *
* Compile the code to be sampled with the -ep and -ee flags to enable the prologue (__PRO) *
* and epilogue (__EPI) calls to be generated. *
* At the beginning of the section to be profiled (just before main loop normally) call the *
* Start_Profiler function to start sampling. At the end of the section, call Stop_Profiler *
* which will stop the timer and write the profile data to disk in the PROFILE.BIN file. *
* *
* Use PROFILE.EXE to view the results of the session. *
* *
* The addition of prologue and epilogue code will slow down the product and the profiler *
* allocates a huge buffer for data so it should not be linked in unless it is going to be *
* used. *
* *
* The advantage of the prologue/epilogue approach is that all samples represent valid *
* addresses within our code so we get valid results we can use even when the IP is in system *
* code. *
* *
* *
*---------------------------------------------------------------------------------------------*
* *
* Functions: *
* *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define MAX_PROFILE_TIME 60*1 //1 minute(s) @ 14.4 Mb per hour
#define PROFILE_RATE 1000 //samples per sec (max 1000)
/*
* Defines for choosing between the old and new profiler system
*
*/
#define OLD_PROFILE_SYSTEM 1
#define NEW_PROFILE_SYSTEM 2
//#define PROFILE_SYSTEM OLD_PROFILE_SYSTEM
#define PROFILE_SYSTEM NEW_PROFILE_SYSTEM
extern "C"{
void __cdecl Profile_Init(void);
void __cdecl Profile_End(void);
void __cdecl Start_Profiler(void);
void __cdecl Stop_Profiler(void);
}

View file

@ -0,0 +1,41 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;USE_PROFILER =1
macro prologue
Ifdef USE_PROFILER
global __PRO:near
call __PRO
endif ;USE_PROFILER
endm
macro epilogue
ifdef USE_PROFILER
global __EPI:near
push ebp
call __EPI
pop ebp
endif ;USE_PROFILER
endm

View file

@ -0,0 +1,254 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: F:\projects\c&c\vcs\code\rawfile.h_v 2.15 06 Sep 1995 16:29:30 JOE_BOSTIC $ */
/***********************************************************************************************
*** 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 *
* *
* File Name : RAWFILE.H *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : August 8, 1994 *
* *
* Last Update : October 18, 1994 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* RawFileClass::File_Name -- Returns with the filename associate with the file object. *
* RawFileClass::RawFileClass -- Default constructor for a file object. *
* RawFileClass::Is_Open -- Checks to see if the file is open or not. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef RAWFILE_H
#define RAWFILE_H
#ifndef WIN32
#define WIN32 1
#ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
#define _WIN32
#endif // _WIN32
#endif
#include <windows.h>
//#include <wwlib32.h>
#include <limits.h>
#include <errno.h>
#include <windows.h>
//#include <algo.h>
#include "wwfile.h"
#ifdef NEVER
/*
** This is a duplicate of the error numbers. The error handler for the RawFileClass handles
** these errors. If the error routine is overridden and additional errors are defined, then
** use numbers starting with 100. Note that these errors here are listed in numerical order.
** These errors are defined in the standard header file "ERRNO.H".
*/
EZERO, // Non-error.
EINVFNC, // Invalid function number.
ENOFILE, // File not found.
ENOENT=ENOFILE, // No such file or directory.
ENOPATH, // Path not found.
EMFILE, // Too many open files.
EACCES, // Permission denied.
EBADF, // Bad file number.
ECONTR, // Memory blocks destroyed.
ENOMEM, // Not enough core memory.
EINVMEM, // Invalid memory block address.
EINVENV, // Invalid environment.
EINVFMT, // Invalid format.
EINVACC, // Invalid access code.
EINVDAT, // Invalid data.
EFAULT, // Unknown error.
EINVDRV, // Invalid drive specified.
ENODEV=EINVDRV, // No such device.
ECURDIR, // Attempt to remove CurDir.
ENOTSAM, // Not same device.
ENMFILE, // No more files.
EINVAL, // Invalid argument.
E2BIG, // Argument list too long.
ENOEXEC, // exec format error.
EXDEV, // Cross-device link.
ENFILE, // Too many open files.
ECHILD, // No child process.
ENOTTY, // not used
ETXTBSY, // not used
EFBIG, // not used
ENOSPC, // No space left on device.
ESPIPE, // Illegal seek.
EROFS, // Read-only file system.
EMLINK, // not used
EPIPE, // Broken pipe.
EDOM, // Math argument.
ERANGE, // Result too large.
EEXIST, // File already exists.
EDEADLOCK, // Locking violation.
EPERM, // Operation not permitted.
ESRCH, // not used
EINTR, // Interrupted function call.
EIO, // Input/output error.
ENXIO, // No such device or address.
EAGAIN, // Resource temporarily unavailable.
ENOTBLK, // not used
EBUSY, // Resource busy.
ENOTDIR, // not used
EISDIR, // not used
EUCLEAN, // not used
#endif
/*
** This is the definition of the raw file class. It is derived from the abstract base FileClass
** and handles the interface to the low level DOS routines. This is the first class in the
** chain of derived file classes that actually performs a useful function. With this class,
** I/O is possible. More sophisticated features, such as packed files, CD-ROM support,
** file caching, and XMS/EMS memory support, are handled by derived classes.
**
** Of particular importance is the need to override the error routine if more sophisticated
** error handling is required. This is more than likely if greater functionality is derived
** from this base class.
*/
class RawFileClass : public FileClass
{
public:
/*
** This is a record of the access rights used to open the file. These rights are
** used if the file object is duplicated.
*/
int Rights;
RawFileClass(char const *filename);
RawFileClass(void);
RawFileClass (RawFileClass const & f);
RawFileClass & operator = (RawFileClass const & f);
virtual ~RawFileClass(void) {if (Allocated && Filename) free((char *)Filename);};
virtual char const * File_Name(void) const;
virtual char const * Set_Name(char const *filename);
virtual int Create(void);
virtual int Delete(void);
virtual int Is_Available(int forced=false);
virtual int Is_Open(void) const;
virtual int Open(char const *filename, int rights=READ);
virtual int Open(int rights=READ);
virtual long Read(void *buffer, long size);
virtual long Seek(long pos, int dir=SEEK_CUR);
virtual long Size(void);
virtual long Write(void const *buffer, long size);
virtual void Close(void);
virtual void Error(int error, int canretry = false, char const * filename=NULL);
virtual void Set_Buffer_Size(int size);
protected:
/*
** This function returns the largest size a low level DOS read or write may
** perform. Larger file transfers are performed in chunks of this size or less.
*/
long Transfer_Block_Size(void) {return (long)((unsigned)UINT_MAX)-16L;};
private:
/*
** This is the low level DOS handle. A -1 indicates an empty condition.
*/
int Handle;
/*
** This points to the filename as a NULL terminated string. It may point to either a
** constant or an allocated string as indicated by the "Allocated" flag.
*/
char const *Filename;
/*
** Filenames that were assigned as part of the construction process
** are not allocated. It is assumed that the filename string is a
** constant in that case and thus making duplication unnecessary.
** This value will be non-zero if the filename has be allocated
** (using strdup()).
*/
unsigned Allocated:1;
};
/***********************************************************************************************
* RawFileClass::File_Name -- Returns with the filename associate with the file object. *
* *
* Use this routine to determine what filename is associated with this file object. If no *
* filename has yet been assigned, then this routing will return NULL. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with a pointer to the file name associated with this file object or NULL *
* if one doesn't exist. *
* *
* WARNINGS: none *
* *
* HISTORY: *
;* 10/18/1994 JLB : Created. *
*=============================================================================================*/
inline char const * RawFileClass::File_Name(void) const
{
return Filename;
}
/***********************************************************************************************
* RawFileClass::RawFileClass -- Default constructor for a file object. *
* *
* This constructs a null file object. A null file object has no file handle or filename *
* associated with it. In order to use a file object created in this fashion it must be *
* assigned a name and then opened. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
;* 10/18/1994 JLB : Created. *
*=============================================================================================*/
inline RawFileClass::RawFileClass(void) : Filename(0)
{
Handle = -1;
Allocated = false;
}
/***********************************************************************************************
* RawFileClass::Is_Open -- Checks to see if the file is open or not. *
* *
* Use this routine to determine if the file is open. It returns true if it is. *
* *
* INPUT: none *
* *
* OUTPUT: bool; Is the file open? *
* *
* *
* WARNINGS: none *
* *
* HISTORY: *
;* 10/18/1994 JLB : Created. *
*=============================================================================================*/
inline int RawFileClass::Is_Open(void) const
{
return (Handle != -1);
}
#endif

View file

@ -0,0 +1,57 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WWLIB 32 *
* *
* File Name : REGIONSZ.CPP *
* *
* Programmer : Phil W. Gorrow *
* *
* Start Date : November 3, 1994 *
* *
* Last Update : November 3, 1994 [PWG] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Size_Of_Region -- Calculates the size of a given region *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*=========================================================================*/
/* The following PRIVATE functions are in this file: */
/*=========================================================================*/
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
/***************************************************************************
* SIZE_OF_REGION -- Calculates the size of a given region *
* *
* INPUT: int width - the width of the region *
* int height - the height of the region *
* *
* OUTPUT: long - the size of the region *
* *
* HISTORY: *
* 11/03/1994 PWG : Created. *
*=========================================================================*/
long Size_Of_Region(int width, int height)
{
return(width * height);
}

View file

@ -0,0 +1,172 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 32 bit Library *
;* *
;* File Name : REMAP.ASM *
;* *
;* Programmer : Phil W. Gorrow *
;* *
;* Start Date : July 1, 1994 *
;* *
;* Last Update : July 1, 1994 [PWG] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
INCLUDE ".\drawbuff.inc"
INCLUDE ".\gbuffer.inc"
CODESEG
PROC Buffer_Remap C NEAR
USES eax,ebx,ecx,edx,esi,edi
;*===================================================================
;* Define the arguements that our function takes.
;*===================================================================
ARG this_object:DWORD
ARG x0_pixel:DWORD
ARG y0_pixel:DWORD
ARG region_width:DWORD
ARG region_height:DWORD
ARG remap :DWORD
;*===================================================================
; Define some locals so that we can handle things quickly
;*===================================================================
local x1_pixel : DWORD
local y1_pixel : DWORD
local win_width : dword
local counter_x : dword
cmp [ remap ] , 0
jz ??real_out
; Clip Source Rectangle against source Window boundaries.
mov esi , [ this_object ] ; get ptr to src
xor ecx , ecx
xor edx , edx
mov edi , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
mov ebx , [ x0_pixel ]
mov eax , [ x0_pixel ]
add ebx , [ region_width ]
shld ecx , eax , 1
mov [ x1_pixel ] , ebx
inc edi
shld edx , ebx , 1
sub eax , edi
sub ebx , edi
shld ecx , eax , 1
shld edx , ebx , 1
mov edi,[ ( GraphicViewPort esi) . GVPHeight ] ; get height into register
mov ebx , [ y0_pixel ]
mov eax , [ y0_pixel ]
add ebx , [ region_height ]
shld ecx , eax , 1
mov [ y1_pixel ] , ebx
inc edi
shld edx , ebx , 1
sub eax , edi
sub ebx , edi
shld ecx , eax , 1
shld edx , ebx , 1
xor cl , 5
xor dl , 5
mov al , cl
test dl , cl
jnz ??real_out
or al , dl
jz ??do_remap
test cl , 1000b
jz ??scr_left_ok
mov [ x0_pixel ] , 0
??scr_left_ok:
test cl , 0010b
jz ??scr_bottom_ok
mov [ y0_pixel ] , 0
??scr_bottom_ok:
test dl , 0100b
jz ??scr_right_ok
mov eax , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
mov [ x1_pixel ] , eax
??scr_right_ok:
test dl , 0001b
jz ??do_remap
mov eax , [ (GraphicViewPort esi) . GVPHeight ] ; get width into register
mov [ y1_pixel ] , eax
??do_remap:
cld
mov edi , [ (GraphicViewPort esi) . GVPOffset ]
mov eax , [ (GraphicViewPort esi) . GVPXAdd ]
mov ebx , [ x1_pixel ]
add eax , [ (GraphicViewPort esi) . GVPWidth ]
add eax , [ (GraphicViewPort esi) . GVPPitch ]
mov esi , eax
mul [ y0_pixel ]
add edi , [ x0_pixel ]
sub ebx , [ x0_pixel ]
jle ??real_out
add edi , eax
sub esi , ebx
mov ecx , [ y1_pixel ]
sub ecx , [ y0_pixel ]
jle ??real_out
mov eax , [ remap ]
mov [ counter_x ] , ebx
xor edx , edx
??outer_loop:
mov ebx , [ counter_x ]
??inner_loop:
mov dl , [ edi ]
mov dl , [ eax + edx ]
mov [ edi ] , dl
inc edi
dec ebx
jnz ??inner_loop
add edi , esi
dec ecx
jnz ??outer_loop
??real_out:
ret
ENDP Buffer_Remap
END

View file

@ -0,0 +1,87 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : SET_FONT.C *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : September 6, 1991 *
* *
* Last Update : June 29, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Set_Font -- Changes the default text printing font. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "font.h"
#include <wwstd.h>
/***************************************************************************
* SET_FONT -- Changes the default text printing font. *
* *
* This routine will change the default text printing font for all *
* text output. It handles updating the system where necessary. *
* *
* INPUT: fontptr -- Pointer to the font to change to. *
* *
* OUTPUT: Returns with a pointer to the previous font. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/06/1991 JLB : Created. *
* 09/17/1991 JLB : Fixed return value bug. *
* 01/31/1992 DRD : Modified to use new font format. *
* 06/29/1994 SKB : modified for 32 bit library *
*=========================================================================*/
void * __cdecl Set_Font(void const *fontptr)
{
void *oldfont;
char const *blockptr;
oldfont = (void *) FontPtr;
if (fontptr) {
FontPtr = (void *) fontptr;
/*
** Inform the system about the new font.
*/
FontWidthBlockPtr = (char*)fontptr + *(unsigned short *)((char*)fontptr + FONTWIDTHBLOCK);
blockptr = (char*)fontptr + *(unsigned short *)((char*)fontptr + FONTINFOBLOCK);
FontHeight = *(blockptr + FONTINFOMAXHEIGHT);
FontWidth = *(blockptr + FONTINFOMAXWIDTH);
//Draw_Char_Setup();
#if FALSE
WindowLines = WinH / FontHeight;
WindowWidth = WinW << 3;
WindowColumns = WindowWidth / FontWidth;
#endif
}
return(oldfont);
}

View file

@ -0,0 +1,187 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WWLIB32 *
* *
* File Name : SHAPE.H *
* *
* Programmer : Bill Randolph *
* *
* Start Date : May 25, 1994 *
* *
* Last Update : September 14, 1994 [IML] *
* *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef SHAPE_H
#define SHAPE_H
#ifndef GBUFFER_H
#include "gbuffer.h"
#endif
/*
*********************************** Types ***********************************
*/
/*
--------------------------- Shape creation flags ----------------------------
*/
typedef enum {
MAKESHAPE_NORMAL = 0x0000, // 256-color compressed shape
MAKESHAPE_COMPACT = 0x0001, // 16-color shape (with built-in color table)
MAKESHAPE_NOCOMP = 0x0002, // Uncompressed shape
MAKESHAPE_VARIABLE = 0x0004 // <16-color shape
} MakeShapeFlags_Type;
inline MakeShapeFlags_Type operator|(MakeShapeFlags_Type a, MakeShapeFlags_Type b)
{return static_cast<MakeShapeFlags_Type>(static_cast<int>(a) | static_cast<int>(b));}
inline MakeShapeFlags_Type operator&(MakeShapeFlags_Type a, MakeShapeFlags_Type b)
{return static_cast<MakeShapeFlags_Type>(static_cast<int>(a) & static_cast<int>(b));}
inline MakeShapeFlags_Type operator~(MakeShapeFlags_Type a)
{return static_cast<MakeShapeFlags_Type>(~static_cast<int>(a));}
/*---------------------------------------------------------------------------
Shape drawing flags:
- The low byte is for coordinate transformations.
- The high byte is for drawing effects.
---------------------------------------------------------------------------*/
typedef enum {
SHAPE_NORMAL = 0x0000, // Standard shape
SHAPE_HORZ_REV = 0x0001, // Flipped horizontally
SHAPE_VERT_REV = 0x0002, // Flipped vertically
SHAPE_SCALING = 0x0004, // Scaled (WORD scale_x, WORD scale_y)
SHAPE_VIEWPORT_REL = 0x0010, // Coords are window-relative
SHAPE_WIN_REL = 0x0010, // Coordinates are window relative instead of absolute.
SHAPE_CENTER = 0x0020, // Coords are based on shape's center pt
SHAPE_BOTTOM = 0x0040, // Y coord is based on shape's bottom pt
SHAPE_FADING = 0x0100, // Fading effect (void * fading_table,
// WORD fading_num)
SHAPE_PREDATOR = 0x0200, // Transparent warping effect
SHAPE_COMPACT = 0x0400, // Never use this bit
SHAPE_PRIORITY = 0x0800, // Use priority system when drawing
SHAPE_GHOST = 0x1000, // Shape is drawn ghosted
SHAPE_SHADOW = 0x2000,
SHAPE_PARTIAL = 0x4000,
SHAPE_COLOR = 0x8000 // Remap the shape's colors
// (void * color_table)
} ShapeFlags_Type;
inline ShapeFlags_Type operator|(ShapeFlags_Type a, ShapeFlags_Type b)
{return static_cast<ShapeFlags_Type>(static_cast<int>(a) | static_cast<int>(b));}
inline ShapeFlags_Type operator&(ShapeFlags_Type a, ShapeFlags_Type b)
{return static_cast<ShapeFlags_Type>(static_cast<int>(a) & static_cast<int>(b));}
inline ShapeFlags_Type operator~(ShapeFlags_Type a)
{return static_cast<ShapeFlags_Type>(~static_cast<int>(a));}
/*
------------------------------- Shape header --------------------------------
*/
typedef struct {
unsigned short ShapeType; // 0 = normal, 1 = 16 colors,
// 2 = uncompressed, 4 = <16 colors
unsigned char Height; // Height of the shape in scan lines
unsigned short Width; // Width of the shape in bytes
unsigned char OriginalHeight; // Original height of shape in scan lines
unsigned short ShapeSize; // Size of the shape, including header
unsigned short DataLength; // Size of the uncompressed shape (just data)
unsigned char Colortable[16]; // Optional color table for compact shape
} Shape_Type;
/*
------------------------------- Shape block ---------------------------------
*/
//#pragma warning (push, 4200)
#pragma warning (disable : 4200)
typedef struct {
unsigned short NumShapes; // number of shapes in the block
long Offsets[]; // array of offsets to shape data
// (offsets within the shape block, with
// 0 being the first offset value, not the
// start of the shape block)
} ShapeBlock_Type;
//#pragma warning (pop)
/*
******************************** Prototypes *********************************
*/
/*
-------------------------------- prioinit.c ---------------------------------
*/
extern "C" {
extern void *MaskPage;
extern void *BackGroundPage;
extern long _ShapeBufferSize;
extern char *_ShapeBuffer;
}
void __cdecl Init_Priority_System (GraphicBufferClass *mask,
GraphicBufferClass *back);
/*
-------------------------------- drawshp.asm --------------------------------
*/
extern "C" {
int Draw_Shape(GraphicViewPortClass *gvp, void const *shape, LONG x, LONG y, LONG flags, ...);
}
/*
---------------------------------- shape.c ----------------------------------
*/
short __cdecl Get_Shape_Data(void const *shape, int data);
int __cdecl Extract_Shape_Count(void const *buffer);
void * __cdecl Extract_Shape(void const *buffer, int shape);
int __cdecl Restore_Shape_Height(void *shape);
int __cdecl Set_Shape_Height(void const *shape, int newheight);
extern "C" {
int __cdecl Get_Shape_Width(void const *shape);
int __cdecl Get_Shape_Height(void const *shape);
int __cdecl Get_Shape_Original_Height(void const *shape);
int __cdecl Get_Shape_Uncomp_Size(void const *shape);
}
/*
------------------------------- setshape.asm --------------------------------
*/
extern "C" {
void __cdecl Set_Shape_Buffer(void const *buffer, int size);
}
/*
------------------------------- shapeinf.asm --------------------------------
*/
int __cdecl Get_Shape_Flags(void const *shape);
int __cdecl Get_Shape_Size(void const *shape);
int __cdecl Get_Shape_Scaled_Width(void const *shape, int scale);
int __cdecl Get_Shape_Scaled_Height(void const *shape, int scale);
#endif // SHAPE_H
/****************************** End of shape.h *****************************/



View file

@ -0,0 +1,212 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 : WWLIB32 *
;* *
;* File Name : SHAPE.INC *
;* *
;* Programmer : Scott Bowen *
;* *
;* Start Date : May 25, 1994 *
;* *
;* Last Update : September 14, 1994 [IML] *
;* *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;****************************** Equates ************************************
;
;............................ Shape Types ..................................
;
TRUE equ 1 ; Boolean 'true' value
FALSE equ 0 ; Boolean 'false' value
MAKESHAPE_NORMAL EQU 0 ; 256-color compressed shape
MAKESHAPE_COMPACT EQU 1 ; 16-color shape (built-in color table)
MAKESHAPE_NOCOMP EQU 2 ; non-wwcomped shape
MAKESHAPE_VARIABLE EQU 4 ; <16-color shape with variable #
; of colors (ColorTable[0] = # of colors)
; old names:
;COLOR_SHAPE EQU 1 ; flag which determines a color shape
;NORM_SHAPE EQU 2 ; flag that indicates non wwcomped shp
;NORM_SHAPE_16 EQU 4 ; flag that tells us if we have a variable sized table
; variable sized table
;
;...........................................................................
; Drawing flags:
; The low byte is for coordinate transformations.
; The high byte is for drawing effects.
;...........................................................................
;
SHAPE_NORMAL EQU 0000h ; no options; just a copy
SHAPE_HORZ_REV EQU 0001h ; reverse horizontally
SHAPE_VERT_REV EQU 0002h ; reverse vertically
SHAPE_SCALING EQU 0004h ; scale
SHAPE_VIEWPORT_REL EQU 0010h ; viewport-relative coordinates
SHAPE_CENTER EQU 0020h ; use centered coordinates
SHAPE_BOTTOM EQU 0040h ; Y coord is based on shape bottom pt
SHAPE_FADING EQU 0100h ; fading effect shape
SHAPE_PREDATOR EQU 0200h ; predator effect shape
SHAPE_COMPACT EQU 0400h ; shape is in 16 colors
SHAPE_PRIORITY EQU 0800h ; priority draw shape
SHAPE_GHOST EQU 1000h ; ghosting effect
SHAPE_SHADOW EQU 2000h ; shadow effect
SHAPE_PARTIAL EQU 4000h ; partial predator effect
SHAPE_COLOR EQU 8000h ; use alternative color table effect
SHAPE_EFFECTS EQU 03F00h ; shape effect flags
;
;.......................... Shadow Effect ..................................
;
SHADOW_COL EQU 00FFh ; magic number for shadows
;......................... Priority System .................................
;
CLEAR_UNUSED_BITS EQU 0007h ; and with 0000-0111 to clear
; non-walkable high bit and
; scaling id bits
NON_WALKABLE_BIT EQU 0080h ; and with 1000-0000 to clear all
; but non-walkable bit
;
;......................... Predator Effect .................................
;
PRED_MASK EQU 0007h ; mask used for predator pixel puts
;---------------------------------------------------------------------------
; This table is a list of the local stack variables in the function
; Draw_Shape. Many other functions in other modules access these variables
; on the stack. Since the BP is not changed when these other functions are
; called by Draw_Shape (possibly indirectly), they can also access these
; stack varibles. When adding or removing from the table, one must be very
; careful to change the offsets.
;---------------------------------------------------------------------------
;.......................... proc addresses .................................
LSkipRout EQU DWORD PTR ebp - 04h ;DWORD pointer to the skip routine
RSkipRout EQU DWORD PTR ebp - 08h ;DWORD pointer to the skip routine
DrawRout EQU DWORD PTR ebp - 0Ch ;DWORD pointer to the draw routine
;........................ optional arguments ...............................
ColorTable EQU DWORD PTR ebp - 10h ;DWORD ptr to the shapes color table
FadingTable EQU DWORD PTR ebp - 14h ;DWORD ptr to the fading table
FadingNum EQU DWORD PTR ebp - 18h ;DWORD number of times to fade
IsTranslucent EQU DWORD PTR ebp - 1Ch ;DWORD ptr to is_translucent table
Translucent EQU DWORD PTR ebp - 20h ;DWORD ptr to actual translucent tbl
PriLevel EQU BYTE PTR ebp - 24h ;BYTE priority level of the object
ScaleX EQU DWORD PTR ebp - 28h ;DWORD the x increment to scale by
ScaleY EQU DWORD PTR ebp - 2Ch ;DWORD the y increment to scale by
ShadowingTable EQU DWORD PTR ebp - 30h ;DWORD ptr to the shadowing table
;........................ Shape header values ..............................
ShapeType EQU DWORD PTR ebp - 34h ;DWORD shape type
ShapeWidth EQU DWORD PTR ebp - 38h ;DWORD shape's unscaled width
ShapeHeight EQU DWORD PTR ebp - 3Ch ;DWORD shape's unscaled height
UncompDataLen EQU DWORD PTR ebp - 40h ;DWORD uncompressed data length
ShapeData EQU DWORD PTR ebp - 44h ;DWORD pointer to shape data
;...................... Scaled shape dimensions ............................
ScaledWidth EQU DWORD PTR ebp - 48h ;DWORD shape's scaled width
ScaledHeight EQU DWORD PTR ebp - 4Ch ;DWORD shape's scaled height
;...................... Pixel clipping variables ...........................
LeftClipPixels EQU DWORD PTR ebp - 50h ;DWORD # left-clipped pixels
RightClipPixels EQU DWORD PTR ebp - 54h ;DWORD # right-clipped pixels
TopClipPixels EQU DWORD PTR ebp - 58h ;DWORD # top-clipped pixels
BotClipPixels EQU DWORD PTR ebp - 5Ch ;DWORD # bottom-clipped pixels
PixelWidth EQU DWORD PTR ebp - 60h ;DWORD drawable area in pixels
PixelHeight EQU DWORD PTR ebp - 64h ;DWORD drawable area in pixels
;......................... Drawing variables ...............................
NumColors EQU DWORD PTR ebp - 68h ;DWORD # colors for 16-color shapes
StartDraw EQU DWORD PTR ebp - 6Ch ;DWORD offset of drawing start pos
NextLine EQU DWORD PTR ebp - 70h ;DWORD offset of next drawing line
LeftClipBytes EQU DWORD PTR ebp - 74h ;DWORD # left-clipped bytes
XTotal EQU DWORD PTR ebp - 78h ;DWORD accumulated x-pixels
XTotalInit EQU DWORD PTR ebp - 7Ch ;DWORD initial roundoff for XTotal
YTotal EQU DWORD PTR ebp - 80h ;DWORD accumulated y-pixels
HeightCount EQU DWORD PTR ebp - 84h ;DWORD ht counter for drawing lines
LineStart EQU DWORD PTR ebp - 88h ;DWORD address of start of line
WidthCount EQU DWORD PTR ebp - 8Ch ;DWORD counts down # bytes skipped
StashReg EQU DWORD PTR ebp - 90h ;DWORD temp variable for draw routines
MaskAdjust EQU DWORD PTR ebp - 94h ;DWORD priority buffer offset
BackAdjust EQU DWORD PTR ebp - 98h ;DWORD background buffer offset
StashECX EQU DWORD PTR ebp - 9Ch ;DWORD temp variable for ECX register
StashEDX EQU DWORD PTR ebp -0A0h ;DWORD temp variable for EDX register
Local_Size EQU 00A4h ; Amt of data on stack: 4+last offset
;****************************** Declarations *******************************
;---------------------------------------------------------------------------
; Global variables used by the shape routines, defined in drawshp.asm
;---------------------------------------------------------------------------
GLOBAL C ShapeBuffer:DWORD
GLOBAL C ShapeBufferSize:DWORD
GLOBAL C _MaskPage:DWORD
GLOBAL C _BackGroundPage:DWORD
GLOBAL C PredCount:DWORD
GLOBAL C PredTable:BYTE
GLOBAL C PredValue:DWORD
GLOBAL C PartialPred:DWORD
GLOBAL C PartialCount:DWORD
GLOBAL C Flags:DWORD
;---------------------------------------------------------------------------
; External tables that are defined in ds_table.asm.
;---------------------------------------------------------------------------
GLOBAL LSkipTable:DWORD
GLOBAL RSkipTable:DWORD
GLOBAL DrawTable:DWORD
;------------------------------------------------------------------------------
; Public functions, declared in the order they appear in the function tables.
;--------------------------------------------------------------------------------
GLOBAL C Not_Supported:NEAR
; LSkipTable:
GLOBAL Left_Skip:NEAR ; ds_ls
GLOBAL Left_Reverse_Skip:NEAR ; ds_lrs
GLOBAL Left_Skip:NEAR ; ds_ls
GLOBAL Left_Reverse_Skip:NEAR ; ds_lrs
GLOBAL Left_Scale_Skip:NEAR ; ds_lss
GLOBAL Left_Scale_Reverse_Skip:NEAR ; ds_lsrs
GLOBAL Left_Scale_Skip:NEAR ; ds_lss
GLOBAL Left_Scale_Reverse_Skip:NEAR ; ds_lsrs
; RSkipTable:
GLOBAL Right_Skip:NEAR ; ds_rs
GLOBAL Right_Reverse_Skip:NEAR ; ds_rrs
GLOBAL Right_Skip:NEAR ; ds_rs
GLOBAL Right_Reverse_Skip:NEAR ; ds_rrs
GLOBAL Right_Scale_Skip:NEAR ; ds_rss
GLOBAL Right_Scale_Reverse_Skip:NEAR ; ds_rsrs
GLOBAL Right_Scale_Skip:NEAR ; ds_rss
GLOBAL Right_Scale_Reverse_Skip:NEAR ; ds_rsrs
; DrawTable:
GLOBAL Draw_Normal:NEAR ; ds_dn
GLOBAL Draw_Reverse:NEAR ; ds_dr
GLOBAL Draw_Normal:NEAR ; ds_dn
GLOBAL Draw_Reverse:NEAR ; ds_dr
GLOBAL Draw_Scale:NEAR ; ds_ds
GLOBAL Draw_Scale_Reverse:NEAR ; ds_dsr
GLOBAL Draw_Scale:NEAR ; ds_ds
GLOBAL Draw_Scale_Reverse:NEAR ; ds_dsr
;************************* End of shape.inc ********************************


View file

@ -0,0 +1,52 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 *
* *
* File Name : SOUND.H *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : September 1, 1993 *
* *
* Last Update : September 1, 1993 [JLB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef SOUND_H
#define SOUND_H
//#define HMI_DRIVER TRUE
//#include "sos.h"
#include "soscomp.h"
#include "dsound.h"
/*
** Maximum number of sound effects that may run at once.
*/
#define MAX_SFX 5
/*
** Size of temp HMI low memory staging buffer.
*/
#define SECONDARY_BUFFER_SIZE (1024*32)
#endif

View file

@ -0,0 +1,289 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 32 bit Library *
* *
* File Name : SOUNDINT.H *
* *
* Programmer : Phil W. Gorrow *
* *
* Start Date : June 23, 1995 *
* *
* Last Update : June 23, 1995 [PWG] *
* *
* This file is the include file for the Westwood Sound Sytem defines and *
* routines that are handled in an interrupt.
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "sound.h"
/*
** Defines for true and false. These are included because we do not allow
** the sound int to include any of the westwood standard headers. If we
** did, there might be too much temptation to call another library function.
** this would be bad, because then that function would not be locked.
*/
#define FALSE 0
#define TRUE 1
/*
** Define the different type of sound compression avaliable to the westwood
** library.
*/
typedef enum {
SCOMP_NONE=0, // No compression -- raw data.
SCOMP_WESTWOOD=1, // Special sliding window delta compression.
SCOMP_SONARC=33, // Sonarc frame compression.
SCOMP_SOS=99 // SOS frame compression.
} SCompressType;
/*
** This is the safety overrun margin for the sonarc compressed
** data frames. This value should be equal the maximum 'order' times
** the maximum number of bytes per sample. It should be evenly divisible
** by 16 to aid paragraph alignment.
*/
#define SONARC_MARGIN 32
/*
** Define the sample control structure which helps us to handle feeding
** data to the sound interrupt.
*/
#pragma pack(1);
typedef struct {
/*
** This flags whether this sample structure is active or not.
*/
unsigned Active;
//unsigned Active:1;
/*
** This flags whether the sample is loading or has been started.
*/
//unsigned Loading:1;
unsigned Loading;
/*
** This semaphore ensures that simultaneous update of this structure won't
** occur. This is necessary since both interrupt and regular code can modify
** this structure.
*/
//unsigned DontTouch:1;
unsigned DontTouch;
/*
** If this sample is really to be considered a score rather than
** a sound effect, then special rules apply. These largely fall into
** the area of volume control.
*/
//unsigned IsScore:1;
unsigned IsScore;
/*
** This is the original sample pointer. It is used to control the sample based on
** pointer rather than handle. The handle method is necessary when more than one
** sample could be playing simultaneously. The pointer method is necessary when
** the dealing with a sample that may have stopped behind the programmer's back and
** this occurance is not otherwise determinable. It is also used in
** conjunction with original size to unlock a sample which has been DPMI
** locked.
*/
void const *Original;
long OriginalSize;
/*
** These are pointers to the double buffers.
*/
LPDIRECTSOUNDBUFFER PlayBuffer;
/*
** Variable to keep track of the playback rate of this buffer
*/
int PlaybackRate;
/*
** Variable to keep track of the sample type ( 8 or 16 bit ) of this buffer
*/
int BitSize;
/*
** Variable to keep track of the stereo ability of this buffer
*/
int Stereo;
/*
** The number of bytes in the buffer that has been filled but is not
** yet playing. This value is normally the size of the buffer,
** except for the case of the last bit of the sample.
*/
LONG DataLength;
/*
** This is the buffer index for the low buffer that
** has been filled with data but not yet being
** played.
*/
// short int Index;
/*
** Pointer into the play buffer for writing the next
** chunk of sample to
**
*/
VOID *DestPtr;
/*
** This flag indicates that there is more source data
** to copy to the play buffer
**
*/
BOOL MoreSource;
/*
** This flag indicates that the entire sample fitted inside the
** direct sound secondary buffer
**
*/
BOOL OneShot;
/*
** Pointer to the sound data that has not yet been copied
** to the playback buffers.
*/
VOID *Source;
/*
** This is the number of bytes remaining in the source data as
** pointed to by the "Source" element.
*/
LONG Remainder;
/*
** Object to use with Enter/LeaveCriticalSection
**
*/
CRITICAL_SECTION AudioCriticalSection;
/*
** Samples maintain a priority which is used to determine
** which sounds live or die when the maximum number of
** sounds are being played.
*/
int Priority;
/*
** This is the handle as returned by sosDIGIStartSample function.
*/
short int Handle;
/*
** This is the current volume of the sample as it is being played.
*/
int Volume;
int Reducer; // Amount to reduce volume per tick.
/*
** This is the compression that the sound data is using.
*/
SCompressType Compression;
short int TrailerLen; // Number of trailer bytes in buffer.
BYTE Trailer[SONARC_MARGIN]; // Maximum number of 'order' samples needed.
DWORD Pitch;
WORD Flags;
/*
** This flag indicates whether this sample needs servicing.
** Servicing entails filling one of the empty low buffers.
*/
short int Service;
/*
** This flag is TRUE when the sample has stopped playing,
** BUT there is more data available. The sample must be
** restarted upon filling the low buffer.
*/
BOOL Restart;
/*
** Streaming control handlers.
*/
BOOL (*Callback)(short int id, short int *odd, VOID **buffer, LONG *size);
VOID *QueueBuffer; // Pointer to continued sample data.
LONG QueueSize; // Size of queue buffer attached.
short int Odd; // Block number tracker (0..StreamBufferCount-1).
int FilePending; // Number of buffers already filled ahead.
long FilePendingSize; // Number of bytes in last filled buffer.
/*
** The file variables are used when streaming directly off of the
** hard drive.
*/
int FileHandle; // Streaming file handle (ERROR = not in use).
VOID *FileBuffer; // Temporary streaming buffer (allowed to be freed).
/*
** The following structure is used if the sample if compressed using
** the sos 16 bit compression Codec.
*/
_SOS_COMPRESS_INFO sosinfo;
} SampleTrackerType;
typedef struct LockedData {
unsigned int DigiHandle; // = -1;
BOOL ServiceSomething; // = FALSE;
long MagicNumber; // = 0xDEAF;
VOID *UncompBuffer; // = NULL;
long StreamBufferSize; // = (2*SECONDARY_BUFFER_SIZE)+128;
short StreamBufferCount; // = 32;
SampleTrackerType SampleTracker[MAX_SFX];
unsigned int SoundVolume;
unsigned int ScoreVolume;
BOOL _int;
} LockedDataType;
extern LockedDataType LockedData;
#pragma pack(4);
void Init_Locked_Data(void);
long Simple_Copy(void ** source, long * ssize, void ** alternate, long * altsize, void **dest, long size);
long Sample_Copy(SampleTrackerType *st, void ** source, long * ssize, void ** alternate, long * altsize, void * dest, long size, SCompressType scomp, void * trailer, short int *trailersize);
VOID far __cdecl maintenance_callback(VOID);
VOID __cdecl far DigiCallback(unsigned int driverhandle, unsigned int callsource, unsigned int sampleid);
void far HMI_TimerCallback(void);
void *Audio_Add_Long_To_Pointer(void const *ptr, long size);
void DPMI_Unlock(VOID const *ptr, long const size);
extern "C" {
void __cdecl Audio_Mem_Set(void const *ptr, unsigned char value, long size);
// void Mem_Copy(void *source, void *dest, unsigned long bytes_to_copy);
long __cdecl Decompress_Frame(void * source, void * dest, long size);
int __cdecl Decompress_Frame_Lock(void);
int __cdecl Decompress_Frame_Unlock(void);
int __cdecl sosCODEC_Lock(void);
int __cdecl sosCODEC_Unlock(void);
void __GETDS(void);
}

View file

@ -0,0 +1,56 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
; This is the control structure at the start of a loaded icon set. It must match
; the structure in ICONSET.C! This structure MUST be a multiple of 16 bytes long.
ifdef NO_WAY_THIS_WILL_BE_DEFINED_HAHAHAHA
STRUC IControl_Type
Width DW ? ; Width in pixels (per icon).
Height DW ? ; Height in pixels (per icon).
Count DW ? ; Number of icons in this set.
Allocated DW ? ; Was this iconset allocated?
Size DD ? ; Size of entire iconset memory block.
Icons DD ? ; Offset from buffer start to icon data.
Palettes DD ? ; Offset from buffer start to palette data.
Remaps DD ? ; Offset from buffer start to remap index data.
TransFlag DD ? ; Offset for transparency flag data.
Map DD ? ; Icon map offset.
ENDS
else
STRUC IControl_Type
Width DW ? ; Width in pixels (per icon).
Height DW ? ; Height in pixels (per icon).
Count DW ? ; Number of icons in this set.
Allocated DW ? ; Was this iconset allocated?
MapWidth DW ?
MapHeight DW ?
Size DD ? ; Size of entire iconset memory block.
Icons DD ? ; Offset from buffer start to icon data.
Palettes DD ? ; Offset from buffer start to palette data.
Remaps DD ? ; Offset from buffer start to remap index data.
TransFlag DD ? ; Offset for transparency flag data.
ColorMap DD ?
Map DD ? ; Icon map offset.
ENDS
endif
ICON256 EQU 1

View file

@ -0,0 +1,34 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WWLIB32 Examples *
* *
* File Name : STRUCTS.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : August 3, 1994 *
* *
* Last Update : August 3, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

View file

@ -0,0 +1,74 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 32 bit Library *
;* *
;* File Name : SVGAPRIM.INC *
;* *
;* Programmer : Phil W. Gorrow *
;* *
;* Start Date : December 8, 1994 *
;* *
;* Last Update : December 8, 1994 [PWG] *
;* *
;*-------------------------------------------------------------------------*
; Externs from VIDEO.CPP module of the VIDEO library
GLOBAL BankTable :DWORD
GLOBAL VesaFunc :DWORD
GLOBAL XRes :DWORD
GLOBAL YRes :DWORD
GLOBAL CurrentMode :DWORD
global cpu_video_page :dword
global cpu_page_limit :dword
; Externs from VESA.ASM module of the SVGAPRIM library
GLOBAL Vesa_Asm_Set_Win :NEAR
GLOBAL Vesa_Asm_Next_Win :NEAR
; Externs from VGETPIX.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_Get_Pixel :NEAR
; Externs from VPUTTPIX.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_Put_Pixel :NEAR
; Externs from VCLEAR.ASM module of the MCGA/SVGAPRIM library
GLOBAL Vesa_Clear :NEAR
; Externs from VBITBLIT.ASM module of the MCGA/SVGAPRIM library
GLOBAL Linear_Blit_To_Vesa :NEAR
GLOBAL Vesa_Blit_To_Linear :NEAR
GLOBAL Vesa_Blit_To_Vesa :NEAR
; Externs from VTOBUFF.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_To_Buffer :NEAR
; Externs from VTOPAGE.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_Buffer_To_Page :NEAR
; Externs from VSCALE.ASM module of the SVGA/MCGAPRIM library
GLOBAL Linear_Scale_To_Vesa :NEAR
GLOBAL Vesa_Scale_To_Linear :NEAR
GLOBAL Vesa_Scale_To_Vesa :NEAR
; Externs from VSCALE.ASM module of the SVGA/MCGAPRIM library
GLOBAL Vesa_Print :NEAR

View file

@ -0,0 +1,100 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Part of the TILE Library *
* *
* File Name : TILE.H *
* *
* Programmer : Barry W. Green *
* *
* Start Date : February 2, 1995 *
* *
* Last Update : February 2, 1995 [BWG] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef TILE_H
#define TILE_H
/*=========================================================================*/
/* The following prototypes are for the file: ICONSET.CPP */
/*=========================================================================*/
void * Load_Icon_Set(char const *filename, void *iconsetptr, long buffsize);
void Free_Icon_Set(void const *iconset);
long Get_Icon_Set_Size(void const *iconset);
int Get_Icon_Set_Width(void const *iconset);
int Get_Icon_Set_Height(void const *iconset);
void * Get_Icon_Set_Icondata(void const *iconset);
void * Get_Icon_Set_Trans(void const *iconset);
void * Get_Icon_Set_Remapdata(void const *iconset);
void * Get_Icon_Set_Palettedata(void const *iconset);
int Get_Icon_Set_Count(void const *iconset);
void * Get_Icon_Set_Map(void const *iconset);
#if (1)
/*
** This is the control structure at the start of a loaded icon set. It must match
** the structure in WWLIB.I! This structure MUST be a multiple of 16 bytes long.
*/
// C&C version of struct
typedef struct {
short Width; // Width of icons (pixels).
short Height; // Height of icons (pixels).
short Count; // Number of (logical) icons in this set.
// BOOL Allocated; // Was this iconset allocated?
short Allocated; // Was this iconset allocated?
long Size; // Size of entire iconset memory block.
unsigned char *Icons; // Offset from buffer start to icon data.
long Palettes; // Offset from buffer start to palette data.
long Remaps; // Offset from buffer start to remap index data.
long TransFlag; // Offset for transparency flag table.
unsigned char *Map; // Icon map offset (if present).
} IControl_Type;
#else
// RA version of struct
typedef struct {
short Width; // Width of icons (pixels).
short Height; // Height of icons (pixels).
short Count; // Number of (logical) icons in this set.
short Allocated; // Was this iconset allocated?
short MapWidth; // Width of map (in icons).
short MapHeight; // Height of map (in icons).
long Size; // Size of entire iconset memory block.
long Icons; // Offset from buffer start to icon data.
// unsigned char * Icons; // Offset from buffer start to icon data.
long Palettes; // Offset from buffer start to palette data.
long Remaps; // Offset from buffer start to remap index data.
long TransFlag; // Offset for transparency flag table.
long ColorMap; // Offset for color control value table.
long Map; // Icon map offset (if present).
// unsigned char * Map; // Icon map offset (if present).
} IControl_Type;
#endif
#endif //TILE_H

View file

@ -0,0 +1,200 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
***************************************************************************
* *
* Project Name : Temp timer for 32bit lib *
* *
* File Name : TIMER.CPP *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : July 6, 1994 *
* *
* Last Update : May 3, 1995 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* TC::Time -- Return the time on the timer. *
* TC::TimerClass -- Construct a timer class object. *
* TC::Stop -- Stop the timer. *
* TC::Start -- Start a timer. *
* TC::Set -- Set the time of a timer. *
* TC::Reset -- Clear the timer. *
* TimerClass::Time -- Get the current time of timer. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include "timer.H"
#include <stdio.h>
#include <stdlib.h>
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Code ////////////////////////////////////////
/***************************************************************************
* TC::TIMERCLASS -- Construct a timer class object. *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
TimerClass::TimerClass(BaseTimerEnum timer, BOOL on)
{
Accumulated = 0;
Started = 0;
TickType=timer;
if (on && TimerSystemOn) Start();
}
/***********************************************************************************************
* TC:Get_Ticks -- return the number of ticks on the system or user timers *
* *
* *
* *
* INPUT: Nothing *
* *
* OUTPUT: tick count *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 4:17PM ST : Created *
*=============================================================================================*/
long TimerClass::Get_Ticks ( void )
{
if ( WindowsTimer ){
switch ( TickType ){
case BT_SYSTEM :
return ( WindowsTimer->Get_System_Tick_Count() );
case BT_USER :
return ( WindowsTimer->Get_User_Tick_Count() );
}
}
return 0;
}
/***************************************************************************
* TIMERCLASS::TIME -- Get the current time of timer. *
* *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 05/03/1995 SKB : Created. *
*=========================================================================*/
long TimerClass::Time(void)
{
if (Started) {
long ticks = Get_Ticks();
Accumulated += ticks - (Started-1);
Started = ticks+1;
}
return(Accumulated);
}
/***************************************************************************
* TC::STOP -- Stop the timer. *
* *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
long TimerClass::Stop(void)
{
long time = Time();
Started = 0;
return(time);
}
/***************************************************************************
* TC::START -- Start a timer. *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
long TimerClass::Start(void)
{
if (!Started) {
Started = Get_Ticks()+1;
}
return(Time());
}
/***************************************************************************
* TC::SET -- Set the time of a timer. *
* *
* *
* *
* INPUT: long value to set timer at. *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
* 05/03/1995 SKB : If start return Start since it returns Time *
*=========================================================================*/
long TimerClass::Set(long value, BOOL start)
{
Started = 0;
Accumulated = value;
if (start) return (Start());
return(Time());
}

View file

@ -0,0 +1,198 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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
#ifndef WIN32
#define WIN32 1
#ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
#define _WIN32
#endif // _WIN32
#endif
#include <windows.h>
#include <windowsx.h>
/*=========================================================================*/
/* The following prototypes are for the file: TIMERA.ASM */
/*=========================================================================*/
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// Externs /////////////////////////////////////////////
extern BOOL TimerSystemOn;
extern HANDLE TimerThreadHandle; //Handle of timer thread
extern int InTimerCallback; //true if we are currently in a callback
/*=========================================================================*/
typedef enum BaseTimerEnum {
BT_SYSTEM, // System timer (60 / second).
BT_USER // User controllable timer (? / second).
} BaseTimerEnum;
class TimerClass {
public:
// Constructor. Timers set before low level init has been done will not
// be able to be 'Started' or 'on' until timer system is in place.
TimerClass(BaseTimerEnum timer=BT_SYSTEM, BOOL start=FALSE);
// No destructor.
~TimerClass(void){}
//
long Set(long value, BOOL start=TRUE); // Set initial timer value.
long Stop(void); // Pause timer.
long Start(void); // Resume timer.
long Reset(BOOL start=TRUE); // Reset timer to zero.
long Time(void); // Fetch current timer value.
protected:
long Started; // Time last started (0 == not paused).
long Accumulated; // Total accumulated ticks.
private:
// long (*Get_Ticks)(void); // System timer fetch.
BaseTimerEnum TickType;
long Get_Ticks (void);
};
inline long TimerClass::Reset(BOOL start)
{
return(Set(0, start));
}
class CountDownTimerClass : private TimerClass {
public:
// Constructor. Timers set before low level init has been done will not
// be able to be 'Started' or 'on' until timer system is in place.
CountDownTimerClass(BaseTimerEnum timer, long set, int on=FALSE);
CountDownTimerClass(BaseTimerEnum timer=BT_SYSTEM, int on=FALSE);
// No destructor.
~CountDownTimerClass(void){}
// Public functions
long Set(long set, BOOL start=TRUE); // Set count down value.
long Reset(BOOL start=TRUE); // Reset timer to zero.
long Stop(void); // Pause timer.
long Start(void); // Resume timer.
long Time(void); // Fetch current count down value.
protected:
long DelayTime; // Ticks remaining before countdown timer expires.
};
inline long CountDownTimerClass::Stop(void)
{
TimerClass::Stop();
return(Time());
}
inline long CountDownTimerClass::Start(void)
{
TimerClass::Start();
return(Time());
}
inline long CountDownTimerClass::Reset(BOOL start)
{
return (TimerClass::Reset(start));
}
class WinTimerClass {
public:
WinTimerClass ( UINT freq=60 , BOOL partial=0 );
~WinTimerClass();
void Update_Tick_Count ( void );
unsigned Get_System_Tick_Count ( void );
unsigned Get_User_Tick_Count ( void );
private:
unsigned TimerHandle; //Handle for windows timer event
unsigned Frequency; //Frequency of our windows timer in ticks per second
unsigned TrueRate; //True rate of clock. (only use word)
unsigned SysTicks; //Tick count of timer.
unsigned UserTicks; //Tick count of timer.
unsigned UserRate; //Desired rate of timer.
};
extern WinTimerClass *WindowsTimer;
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// externs //////////////////////////////////////////
#ifndef FUNCTION_H
extern TimerClass TickCount;
#endif
extern CountDownTimerClass CountDown;
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// Prototypes //////////////////////////////////////////
extern "C" {
long __cdecl Get_System_Tick_Count(void);
long __cdecl Get_User_Tick_Count(void);
void far __cdecl Timer_Interrupt_Func(void);
// long Get_Num_Interrupts(unsigned int realmode);
void __cdecl Disable_Timer_Interrupt(void);
void __cdecl Enable_Timer_Interrupt(void);
}
/*=========================================================================*/
/* The following prototypes are for the file: TIMER.CPP */
/*=========================================================================*/
BOOL __cdecl Init_Timer_System(unsigned int freq, int partial = FALSE);
BOOL __cdecl Remove_Timer_System(VOID);
#endif // TIMER_H

View file

@ -0,0 +1,123 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
***************************************************************************
* *
* Project Name : Temp timer for 32bit lib *
* *
* File Name : TIMER.CPP *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : July 6, 1994 *
* *
* Last Update : July 12, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* CDTC::Time -- Return the time on the timer. *
* CDTC::Stop -- Stop the timer. *
* CDTC::Start -- Start a timer. *
* CDTC::DownTimerClass -- Construct a timer class object. *
* CDTC::Set -- Set the time of a timer. *
* CDTC::Reset -- Clear the timer. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include "timer.H"
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Defines /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Code ////////////////////////////////////////
/***************************************************************************
* TC::CountDownTimerClass -- Construct a timer class object. *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
CountDownTimerClass::CountDownTimerClass(BaseTimerEnum timer, long set, int on)
:TimerClass(timer, on)
{
Set(set, on);
}
CountDownTimerClass::CountDownTimerClass(BaseTimerEnum timer, int on)
:TimerClass(timer, FALSE)
{
DelayTime = 0;
if (on) Start();
}
/***************************************************************************
* CDTC::TIME -- Return the time on the timer. *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
long CountDownTimerClass::Time()
{
long ticks = DelayTime - TimerClass::Time();
if (ticks < 0) {
ticks = 0;
}
return(ticks);
}
/***************************************************************************
* CDTC::SET -- Set the time of a timer. *
* *
* *
* *
* INPUT: ULONG value to set timer at. *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/12/1994 SKB : Created. *
*=========================================================================*/
long CountDownTimerClass::Set(long value, BOOL start)
{
DelayTime = value;
TimerClass::Reset(start);
return(Time());
}

View file

@ -0,0 +1,312 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
***************************************************************************
* *
* Project Name : Temp timer for 32bit lib *
* *
* File Name : TIMERINI.CPP *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : July 6, 1994 *
* *
* Last Update : July 6, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Init_Timer_System -- Initialize the WW timer system. *
* Remove_Timer_System -- Removes the timer system. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include <mmsystem.h>
#include "timer.H"
#include <profile.h>
#include <stdio.h>
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Defines /////////////////////////////////////
#define COPY_FROM_MEM TRUE
/////////////////////////////////////////////////////////////////////////////////
////////////////////////////// timera.asm functions//////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif
extern BOOL Install_Timer_Interrupt(VOID *bin_ptr, UINT rm_size, UINT freq, BOOL partial);
extern BOOL Remove_Timer_Interrupt(VOID);
#ifdef __cplusplus
}
#endif
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Global Data /////////////////////////////////////
BOOL TimerSystemOn = FALSE;
// Global timers that the library or user can count on existing.
TimerClass TickCount(BT_SYSTEM);
CountDownTimerClass CountDown(BT_SYSTEM, 0);
// Prototype for timer callback
void CALLBACK Timer_Callback ( UINT event_id, UINT res1 , DWORD user, DWORD res2, DWORD res3 );
HANDLE TimerThreadHandle = 0; //Handle of timer thread
int InTimerCallback = 0; //Flag to say if we are in a timer callback
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Code ////////////////////////////////////////
#pragma warning (disable : 4996)
/***************************************************************************
* WinTimerClass::WinTimerClass -- Initialize the WW timer system. *
* *
* *
* INPUT: UINT : user timer frequency. *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 10/5/95 3:47PM : ST Created. *
*=========================================================================*/
WinTimerClass::WinTimerClass (UINT freq, BOOL partial)
{
BOOL success;
//
// Inform windows that we want a higher than normal
// timer resolution
//
#ifdef __SW_EP
timeBeginPeriod(1000/PROFILE_RATE);
Frequency = PROFILE_RATE;
#else
timeBeginPeriod ( 1000/freq );
Frequency = freq;
#endif
//
// Install the timer callback event handler
//
//TimerHandle = timeSetEvent ( 1000/freq , 1 , Timer_Callback , 0 , TIME_PERIODIC);
// Add TIME_KILL_SYNCHRONOUS flag. ST - 2/13/2019 5:07PM
TimerHandle = timeSetEvent ( 1000/freq , 1 , Timer_Callback , 0 , TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
TimerSystemOn = success = ( TimerHandle !=0 );
if (success) {
if (!partial) {
WindowsTimer=this;
TickCount.Start();
}
}else{
char error_str [128];
sprintf (error_str, "Error - timer system failed to start. Error code %d\n", GetLastError());
OutputDebugString(error_str);
}
}
/***************************************************************************
* WinTimerClass::~WinTimerClass -- Removes the timer system. *
* *
* *
* INPUT: NONE. *
* *
* OUTPUT: BOOL was it removed successfuly *
* *
* WARNINGS: *
* *
* HISTORY: *
* 10/5/95 3:47PM : ST Created. *
*=========================================================================*/
WinTimerClass::~WinTimerClass( void )
{
if ( TimerHandle ){
timeKillEvent ( TimerHandle );
TimerHandle = 0; //ST - 2/13/2019 5:12PM
}
TimerSystemOn = FALSE;
timeEndPeriod ( 1000/Frequency );
}
/***********************************************************************************************
* Timer_Callback -- Main timer callback. Equivalent to a timer interrupt handler *
* *
* *
* *
* INPUT: uint timer ID *
* uint reserved *
* long 0 (application defined) *
* long reserved *
* long reserved *
* *
* OUTPUT: Nothing *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 3:19PM ST : Created *
*=============================================================================================*/
void CALLBACK Timer_Callback (UINT , UINT , DWORD , DWORD , DWORD)
{
//CONTEXT context;
InTimerCallback++;
// Removed. ST - 2/13/2019 5:11PM
//if (!TimerThreadHandle){
// DuplicateHandle (GetCurrentProcess(), GetCurrentThread() , GetCurrentProcess() ,&TimerThreadHandle , 0 , TRUE , DUPLICATE_SAME_ACCESS);
//}
if (WindowsTimer) {
WindowsTimer->Update_Tick_Count();
}
InTimerCallback--;
}
/***********************************************************************************************
* WinTimerClass::Update_Tick_Count -- update westwood timers *
* *
* *
* *
* INPUT: Nothing *
* *
* OUTPUT: Nothing *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 3:58PM ST : Created *
*=============================================================================================*/
void WinTimerClass::Update_Tick_Count ( void )
{
/*
*
* Increment westwood timers
*
*/
SysTicks++;
UserTicks++;
}
/*
;***************************************************************************
;* GET_NUM_INTERRUPTS -- Returns the number of interrupts that have occured*
;* *
;* INPUT: TRUE - returns num RM ints. *
;* FALSE - return num PM ints. *
;* *
;* OUTPUT: *
;* *
;* WARNINGS: *
;* *
;* HISTORY: *
;* 07/12/1994 SKB : Created. *
;*=========================================================================*
PROC Get_Num_Interrupts C Near
USES esi
ARG realmode:DWORD
mov esi,[RealModePtr]
cmp [realmode],0
je ??prot_mode
mov eax,[(TimerType PTR esi).NumRMInts]
ret
??prot_mode:
mov eax,[(TimerType PTR esi).NumPMInts]
ret
ENDP
*/
/***********************************************************************************************
* WinTimerClass::Get_System_Tick_Count -- returns the system tick count *
* *
* INPUT: Nothing *
* *
* OUTPUT: tick count *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 4:02PM ST : Created *
*=============================================================================================*/
unsigned WinTimerClass::Get_System_Tick_Count ( void )
{
return ( SysTicks );
}
/***********************************************************************************************
* WinTimerClass::Get_User_Tick_Count -- returns the user tick count *
* *
* INPUT: Nothing *
* *
* OUTPUT: tick count *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/5/95 4:02PM ST : Created *
*=============================================================================================*/
unsigned WinTimerClass::Get_User_Tick_Count ( void )
{
return ( UserTicks );
}

View file

@ -0,0 +1,294 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 32 bit Library *
;* *
;* File Name : TOBUFFER.ASM *
;* *
;* Programmer : Phil W. Gorrow *
;* *
;* Start Date : June 8, 1994 *
;* Last Update : Feb 10, 1995 [jrj] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* VVC::TOBUFFER -- Copies a virtual viewport to a linear buffer *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;IDEAL
;P386
;MODEL USE32 FLAT
;LOCALS ??
.model flat
TRANSP equ 0
;INCLUDE "drawbuff.inc"
INCLUDE gbuffer.inc
;CODESEG
.code
;***************************************************************************
;* VIVC::TOBUFFER -- Copies a virtual viewport to a linear buffer *
;* *
;* INPUT: BYTE * dest - buffer to copy to *
;* size - size of the buffer to copy to *
;* x_pixel - x pixel on viewport to copy from *
;* y_pixel - y pixel on viewport to copy from *
;* pixel_width - the width of copy region *
;* pixel_height - the height of copy region *
;* *
;* OUTPUT: none *
;* *
;* WARNINGS: Coordinates and dimensions will be adjusted if they exceed *
;* the boundaries. In the event that no adjustment is *
;* possible this routine will abort. If the size of the *
;* region to copy exceeds the size passed in for the buffer *
;* the routine will automatically abort. *
;* *
;* HISTORY: *
;* 06/15/1994 PWG : Created. *
;*=========================================================================*
Buffer_To_Buffer proc C public USES ebx ecx edx esi edi this_object:DWORD, x_pixel:DWORD, y_pixel:DWORD, pixel_width:DWORD, pixel_height:DWORD, dest:DWORD, buffer_size:DWORD
;PROC Buffer_To_Buffer C near
;USES ebx,ecx,edx,esi,edi
;*===================================================================
;* define the arguements that our function takes.
;*===================================================================
;ARG this_object:DWORD ; this is a class member function
;ARG x_pixel:DWORD ; Page X pixel coordinate.
;ARG y_pixel:DWORD ; Page Y pixel coordinate.
;ARG pixel_width:DWORD ; Width of region in pixels.
;ARG pixel_height:DWORD ; Height of region in pixels.
;ARG dest:DWORD ; the buffer to copy to
;ARG buffer_size:DWORD ; the size of the buffer
;*===================================================================
; Define some locals so that we can handle things quickly
;*===================================================================
LOCAL x1_pixel :dword
LOCAL y1_pixel :dword
LOCAL dest_x1 : dword
LOCAL dest_y1 : dword
LOCAL dest_ajust_width:DWORD
LOCAL scr_ajust_width:DWORD
;LOCAL dest_area : dword
; Clip dest Rectangle against source Window boundaries.
mov [ dest_x1 ] , 0
mov [ dest_y1 ] , 0
mov esi , [ this_object ] ; get ptr to dest
xor ecx , ecx
xor edx , edx
mov edi , [esi].GraphicViewPort.GVPWidth ; get width into register
mov ebx , [ x_pixel ]
mov eax , [ x_pixel ]
add ebx , [ pixel_width ]
shld ecx , eax , 1
mov [ x1_pixel ] , ebx
inc edi
shld edx , ebx , 1
sub eax , edi
sub ebx , edi
shld ecx , eax , 1
shld edx , ebx , 1
mov edi,[esi].GraphicViewPort.GVPHeight ; get height into register
mov ebx , [ y_pixel ]
mov eax , [ y_pixel ]
add ebx , [ pixel_height ]
shld ecx , eax , 1
mov [ y1_pixel ] , ebx
inc edi
shld edx , ebx , 1
sub eax , edi
sub ebx , edi
shld ecx , eax , 1
shld edx , ebx , 1
xor cl , 5
xor dl , 5
mov al , cl
test dl , cl
jnz real_out
or al , dl
jz do_blit
test cl , 1000b
jz scr_left_ok
mov eax , [ x_pixel ]
neg eax
mov [ x_pixel ] , 0
mov [ dest_x1 ] , eax
scr_left_ok:
test cl , 0010b
jz scr_bottom_ok
mov eax , [ y_pixel ]
neg eax
mov [ y_pixel ] , 0
mov [ dest_y1 ] , eax
scr_bottom_ok:
test dl , 0100b
jz scr_right_ok
mov eax , [esi].GraphicViewPort.GVPWidth ; get width into register
mov [ x1_pixel ] , eax
scr_right_ok:
test dl , 0001b
jz do_blit
mov eax , [esi].GraphicViewPort.GVPHeight ; get width into register
mov [ y1_pixel ] , eax
do_blit:
cld
mov eax , [esi].GraphicViewPort.GVPXAdd
add eax , [esi].GraphicViewPort.GVPWidth
add eax , [esi].GraphicViewPort.GVPPitch
mov esi , [esi].GraphicViewPort.GVPOffset
mov ecx , eax
mul [ y_pixel ]
add esi , [ x_pixel ]
add esi , eax
add ecx , [ x_pixel ]
sub ecx , [ x1_pixel ]
mov [ scr_ajust_width ] , ecx
mov edi , [ dest ]
mov eax , [ pixel_width ]
sub eax , [ x1_pixel ]
add eax , [ x_pixel ]
mov [ dest_ajust_width ] , eax
mov eax , [ dest_y1 ]
mul [ pixel_width ]
add eax , [ dest_x1 ]
add edi , eax
mov edx , [ y1_pixel ]
mov eax , [ x1_pixel ]
sub edx , [ y_pixel ]
jle real_out
sub eax , [ x_pixel ]
jle real_out
mov ebx , [ pixel_width ]
imul ebx , edx
cmp ebx , [ buffer_size ]
jg real_out
; ********************************************************************
; Forward bitblit only
IF TRANSP
cmp [ transp ] , 0
jnz forward_Blit_trans
ENDIF
; the inner loop is so efficient that
; the optimal consept no longer apply because
; the optimal byte have to by a number greather than 9 bytes
cmp eax , 10
jl forward_loop_bytes
forward_loop_dword:
mov ecx , edi
mov ebx , eax
neg ecx
and ecx , 3
sub ebx , ecx
rep movsb
mov ecx , ebx
shr ecx , 2
rep movsd
mov ecx , ebx
and ecx , 3
rep movsb
add esi , [ scr_ajust_width ]
add edi , [ dest_ajust_width ]
dec edx
jnz forward_loop_dword
ret
forward_loop_bytes:
mov ecx , eax
rep movsb
add esi , [ scr_ajust_width ]
add edi , [ dest_ajust_width ]
dec edx ; decrement the height
jnz forward_loop_bytes
ret
IF TRANSP
forward_Blit_trans:
mov ecx , eax
and ecx , 01fh
lea ecx , [ ecx + ecx * 4 ]
neg ecx
shr eax , 5
lea ecx , [ transp_reference + ecx * 2 ]
mov [ y1_pixel ] , ecx
forward_loop_trans:
mov ecx , eax
jmp [ y1_pixel ]
forward_trans_line:
REPT 32
local transp_pixel
mov bl , [ esi ]
test bl , bl
jz transp_pixel
mov [ edi ] , bl
transp_pixel:
inc esi
inc edi
ENDM
transp_reference:
dec ecx
jge forward_trans_line
add esi , [ scr_ajust_width ]
add edi , [ dest_ajust_width ]
dec edx
jnz forward_loop_trans
ret
ENDIF
real_out:
ret
;ENDP Buffer_To_Buffer
Buffer_To_Buffer endp
END

View file

@ -0,0 +1,216 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : 32 bit library *
* *
* File Name : VIDEO.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : August 3, 1994 *
* *
* Last Update : August 3, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef VIDEO_H
#define VIDEO_H
#ifndef WWSTD_H
#include "wwstd.h"
#endif
/*=========================================================================*/
/* The machine can be in one of the following graphic modes. The global */
/* GraphicMode is set to one of these values. */
/*=========================================================================*/
#define CGA_MODE 4 // DOS 320x200 4 color mode
#define TGA_MODE 9 // TANDY 320x200 16 color mode
#define EGA_MODE 13 // DOS 320x200 16 color mode
#define MCGA_MODE 0x13 // DOS 320x200 256 color mode
#define VGA_MODE 0x13 // DOS 320x200 256 color mode
#define EEGA_MODE 14 // DOS 640x400 16 color mode
#define ETGA_MODE 9 // TANDY 640x400 16 color mode
#define HGA_MODE 7 // DOS 768x400 2 color mode
#define TXT_MODE 3 // DOS plain old color text mode
#define VESA_640X400_256 0x100 // VESA 640x400 256 color mode
#define VESA_640X480_256 0x101 // VESA 640x480 256 color mode
#define VESA_800X600_256 0x103 // VESA 800x600 256 color mode
#define VESA_1024X768_256 0x105 // VESA 1024x768 256 color mode
#define VESA_1280X400_256 0x107 // VESA 1280x400 256 color mode
#define VESA_TEXT_80X60 0x108 // VESA 80x60 text mode
#define VESA_TEXT_132X25 0x109 // VESA 132x25 text mode
#define VESA_TEXT_132X60 0x10C // VESA 132x60 text mode
#define RESET_MODE -1
#define UNINITIALIZED_MODE -1
#define VESA_MIN VESA_640X400_256
#define VESA_MAX VESA_TEXT_132X60
/*=========================================================================*/
/* Define the maximum number of bank entries */
/*=========================================================================*/
#define MAX_BANK_ENTRIES ((1280L*1024L)/65536L)
/*=========================================================================*
* VesaInfoType - General info about this VESA implementation *
* (Filled in by VESA BIOS Function 0) *
* *
* Signature - Will always be 'VESA' *
* Version - Version # *
* OEMString - OEM ID string *
* Capabilities - Not defined by VESA yet *
* AvailModes - List of available modes; terminated with -1 (0xffff) *
* TotalMemory - ??? *
* Reserved - Pads structure to 256 bytes total *
*=========================================================================*/
#ifdef NOT_FOR_WIN95
typedef struct {
char Signature[4];
short Version;
REALPTR OEMString;
long Capabilities;
REALPTR AvailModes;
short TotalMemory;
char Reserved[236];
} VesaInfoType;
#endif //NOT_FOR_WIN95
/*=========================================================================*
* VesaModeInfoType - Info about this VESA mode *
* (Filled in by VESA BIOS Function 1) *
* *
* Attributes - bit 0: 1 = mode is supported *
* bit 1: 1 = optional info available *
* bit 2: 1 = std BIOS output funcs valid in this mode *
* bit 3: 0 = monochrome, 1 = color *
* bit 4: 0 = text mode, 1 = graphics *
* WinA_Attributes - bit 0 = win exists, bit 1=readable, bit 2= writable *
* WinB_Attributes - bit 0 = win exists, bit 1=readable, bit 2= writable *
* WinGranularity - smallest address boundary window can be placed upon; *
* size is in KB (ie 64, 32, 4) *
* WinSize - size of windows in KB (ie 64, 32) *
* WinA_Segment - location of Window A in CPU space (usually 0xa000) *
* WinB_Segment - location of Window B in CPU space (usually 0xb000) *
* WinFunc - address of window-setting function (This is provided *
* as an alternative to Int 10 for speed.) *
* BytesPerScanline - # bytes per scan line *
* *
* Optional info (available if bit 1 of Attributes is set): *
* *
* XRes - X-resolution *
* YRes - Y-resolution *
* XCharSize - Horizontal size of char cell *
* YCharSize - Vertical size of char cell *
* NumPlanes - # of memory planes (???) *
* BitsPerPixel - # bites per pixel *
* NumBanks - # of banks (ie planes) *
* MemoryModel - 00h = Text mode *
* 01h = CGA mode *
* 02h = Hercules *
* 03h = 4 plane planar mode *
* 04h = packed pixel mode (1 byte/pixel) *
* 05h = non-chain 4, 256-color mode *
* 06-0Fh = *
* 10-FFh = OEM-specific *
* BankSize - Bank size in KB *
*=========================================================================*/
#ifdef NOT_FOR_WIN95
typedef struct {
short Attributes;
char WinA_Attributes;
char WinB_Attributes;
short WinGranularity;
short WinSize;
short WinA_Segment;
short WinB_Segment;
REALPTR WinFunc;
short BytesPerScanline;
short XRes;
short YRes;
char XCharSize;
char YCharSize;
char NumPlanes;
char BitsPerPixel;
char NumBanks;
char MemoryModel;
char BankSize;
char NumInputPages;
char Reserved;
char RedMaskSize;
char RedFieldPosition;
char GreenMaskSize;
char GreenFieldPosition;
char BlueMaskSize;
char BlueFieldPosition;
char RsvdMaskSize;
char RsvdFieldPosition;
char DirectColorModeInfo;
char pad[216];
} VesaModeInfoType;
extern REALPTR VesaFunc;
#endif //NOT_FOR_WIN95
extern "C" {
extern int GraphicMode;
extern long XRes;
extern long YRes;
extern long BankTable [];
extern unsigned long RMVesaVector ;
extern unsigned long RMVesaRegs ;
}
/*=========================================================================*/
/* The following prototypes are for the file: VIDEO.CPP */
/*=========================================================================*/
extern "C" int Set_Video_Mode(int mode);
int Get_Video_Mode(void);
void Update_Video_Mode (void) ;
void Vesa_Info(void);
void Vesa_Set_Window(long grain_num);
int Get_Original_Video_Mode(void);
void Set_Original_Video_Mode(int mode);
/*=========================================================================*/
/* The following prototypes are for the file: INITDLAY.CPP */
/*=========================================================================*/
extern VOID Init_Delay(VOID);
extern BOOL VertBlank;
/*=========================================================================*/
/* The following prototypes are for the file: VERTBLNK.ASM */
/*=========================================================================*/
extern "C" {
extern WORD Get_Vert_Blank(VOID);
extern VOID Wait_Vert_Blank(BOOL blank);
}
/*=========================================================================*/
#endif // VIDEO_H

View file

@ -0,0 +1,454 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***********************************************************************************************
*** 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 : Command & Conquer/ WW Library *
* *
* File Name : WINCOMM.H *
* *
* Programmer : Steve Tall *
* *
* Start Date : 1/10/96 *
* *
* Last Update : January 10th 1996 [ST] *
* *
*---------------------------------------------------------------------------------------------*
* Overview: *
* *
* These classes was created to replace the greenleaf comms functions used in C&C DOS with *
* WIN32 API calls. *
* *
*---------------------------------------------------------------------------------------------*
* *
* Functions: *
* *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef WIN32
#define WIN32
#define _WIN32
#endif //WIN32
#include <windows.h>
typedef enum WinCommDialMethodType {
WC_TOUCH_TONE = 0,
WC_PULSE
} WinCommDialMethodType;
#define COMMSUCCESS 0
#define ASTIMEOUT -10
#define COMMUSERABORT -16
/*
** The size of our serial buffer within the class.
**
** !!!!!! THIS MUST BE A POWER OF 2 !!!!!!
**
*/
#define SIZE_OF_WINDOWS_SERIAL_BUFFER 2048
/*
** WinModemClass.
**
** This class provides access to modems under Win95. The functions are designed to be more or less
** drop in replacements for the Grenleaf comms functions.
*/
class WinModemClass
{
public:
WinModemClass (void); //WinModemClass Contructor
virtual ~WinModemClass (void); //WinModemClass Destructor
/*
** Serial port open should be called to get a handle to the COM port
** This needs to be called first as other class members rely on the handle
**
** Replacement for Greenleaf function: PortOpenGreenleafFast
*/
//virtual HANDLE Serial_Port_Open (int port, int baud, int parity, int wordlen, int stopbits);
virtual HANDLE Serial_Port_Open (char *device_name, int baud, int parity, int wordlen, int stopbits, int flowcontrol);
/*
** This function releases the COM port handle and should be called after
** communications have finished
**
** Replacement for Greenleaf function: PortClose
*/
void Serial_Port_Close (void);
/*
** This member copies any bytes from the internal class serial buffer
** into your user buffer.
**
** Replacement for Greenleaf function: ReadBuffer
*/
int Read_From_Serial_Port (unsigned char *dest_ptr, int buffer_len);
/*
** Write chars to the serial port
**
** Replacement for Greenleaf function: WriteBuffer
*/
void Write_To_Serial_Port (unsigned char *buffer, int length);
/*
** Wait for the outgoing buffer to empty
*/
void Wait_For_Serial_Write (void);
/*
** Set the dial type to DIAL_TOUCH_TONE or DIAL_PULSE
**
** Replacement for Greenleaf function: HMSetDiallingMethod
*/
virtual void Set_Modem_Dial_Type (WinCommDialMethodType method);
/*
** Get the status of the modem control lines
** Possible flags are: CTS_SET DSR_SET RI_SET & CD_SET
**
** Replacement for Greenleaf function: GetModemStatus
*/
virtual unsigned Get_Modem_Status (void);
/*
** Set the DTR line to the given state
**
** Replacement for Greenleaf function: SetDtr
*/
virtual void Set_Serial_DTR (BOOL state);
/*
** Get the result code from the modem after issuing an 'AT' command
**
** Replacement for Greenleaf function: HMInputLine
*/
virtual int Get_Modem_Result (int delay, char *buffer, int buffer_len);
/*
** Issue a dial command to the modem.
** Use Set_Modem_Dial_Type to select pulse or tone dial
**
** Replacement for Greenleaf function: HMDial
*/
virtual void Dial_Modem (char *dial_number);
/*
** Send a command to the modem. This is usually an 'AT' command.
** Function will optionally retry until 'OK' is received.
*/
virtual int Send_Command_To_Modem (char *command, char terminator, char *buffer, int buflen, int delay, int retries);
/*
** Sets a pointer to a function that will be called for each incoming serial char
**
** Replacement for Greenleaf function: HMSetUpEchoRoutine
*/
virtual void Set_Echo_Function (void(*func)(char c));
/*
** Sets a pointer to a function that will be called if ESC is pressed during a dial
**
** Replacement for Greenleaf function: HMSetUpAbortKey
*/
virtual void Set_Abort_Function (int (*func)(void));
/*
** Member to allow access to the serial port handle
*/
HANDLE Get_Port_Handle(void);
/*
** Status vars for debugging purposes
*/
int FramingErrors;
int IOErrors;
int BufferOverruns;
int InBufferOverflows;
int ParityErrors;
int OutBufferOverflows;
int InQueue;
int OutQueue;
/*
** Modem send result codes
*/
enum SendModemEnum {
MODEM_CMD_TIMEOUT = 0,
MODEM_CMD_OK,
MODEM_CMD_0,
MODEM_CMD_ERROR
};
/*
** Enums for modem status flags
*/
enum {
CTS_SET = 0x10,
DSR_SET = 0x20,
RI_SET = 0x40,
CD_SET = 0x80
};
protected:
/*
** Copy incoming data from the windows file buffer into the internal class buffer
*/
BOOL Read_Serial_Chars(void);
/*
** Pointer to the internal class circular buffer for incoming data
*/
unsigned char *SerialBuffer;
/*
** Overlap object for asyncronous reads from the serial port
*/
OVERLAPPED ReadOverlap;
/*
** Overlap object for asyncronous writes to the serial port
*/
OVERLAPPED WriteOverlap;
/*
** Flag that there is no outstanding incoming data in the windows buffer
*/
BOOL WaitingForSerialCharRead;
/*
** Flag that we are waiting for the last write to port operation to complete
*/
BOOL WaitingForSerialCharWrite;
/*
** Head and Tail pointers for our internal serial buffer
*/
int SerialBufferReadPtr;
int SerialBufferWritePtr;
/*
** Windows handle to the COM port device
*/
HANDLE PortHandle;
/*
** Dialing method - DIAL_TOUCH_TONE or DIAL_PULSE
*/
WinCommDialMethodType DialingMethod;
/*
** Pointer to function for echoing incoming data - can be NULL
*/
void (*EchoFunction)(char c);
/*
** Pointer to function for aborting when ESC pressed - can be NULL
*/
int (*AbortFunction)(void);
/*
** Serial buffer for asyncronous reads
*/
char TempSerialBuffer[SIZE_OF_WINDOWS_SERIAL_BUFFER];
};
/*
** WinNullModemClass.
**
** This class provides access to serial ports under Win95. The functions are designed to be more or less
** drop in replacements for the Grenleaf comms functions.
**
** This class just overloads the WinModemClass members that arent required for direct serial communications
** via a 'null modem' cable.
*/
class WinNullModemClass : public WinModemClass
{
public:
virtual inline void Set_Modem_Dial_Type (int){};
virtual inline unsigned Get_Modem_Status (void){return (0);};
virtual inline void Set_Serial_DTR (BOOL){};
virtual inline int Get_Modem_Result (int, char*, int){return(0);};
virtual inline void Dial_Modem (char*){};
virtual inline int Send_Command_To_Modem (char*, char, char*, int, int, int){return (0);};
virtual inline void Set_Echo_Function (void(*)(char)){};
virtual inline void Set_Abort_Function (int(*)(void)){};
};
extern WinModemClass *SerialPort;
//
//
// This bit swiped from the SDK because its not in the Watcom headers yet
//
//
/************************************************************************
* *
* mcx.h -- This module defines the 32-Bit Windows MCX APIs *
* *
* Copyright (c) 1990-1995, Microsoft Corp. All rights reserved. *
* *
************************************************************************/
#ifndef _MCX_H_
#define _MCX_H_
typedef struct _MODEMDEVCAPS {
DWORD dwActualSize;
DWORD dwRequiredSize;
DWORD dwDevSpecificOffset;
DWORD dwDevSpecificSize;
// product and version identification
DWORD dwModemProviderVersion;
DWORD dwModemManufacturerOffset;
DWORD dwModemManufacturerSize;
DWORD dwModemModelOffset;
DWORD dwModemModelSize;
DWORD dwModemVersionOffset;
DWORD dwModemVersionSize;
// local option capabilities
DWORD dwDialOptions; // bitmap of supported values
DWORD dwCallSetupFailTimer; // maximum in seconds
DWORD dwInactivityTimeout; // maximum in seconds
DWORD dwSpeakerVolume; // bitmap of supported values
DWORD dwSpeakerMode; // bitmap of supported values
DWORD dwModemOptions; // bitmap of supported values
DWORD dwMaxDTERate; // maximum value in bit/s
DWORD dwMaxDCERate; // maximum value in bit/s
// Variable portion for proprietary expansion
BYTE abVariablePortion [1];
} MODEMDEVCAPS, *PMODEMDEVCAPS, *LPMODEMDEVCAPS;
typedef struct _MODEMSETTINGS {
DWORD dwActualSize;
DWORD dwRequiredSize;
DWORD dwDevSpecificOffset;
DWORD dwDevSpecificSize;
// static local options (read/write)
DWORD dwCallSetupFailTimer; // seconds
DWORD dwInactivityTimeout; // seconds
DWORD dwSpeakerVolume; // level
DWORD dwSpeakerMode; // mode
DWORD dwPreferredModemOptions; // bitmap
// negotiated options (read only) for current or last call
DWORD dwNegotiatedModemOptions; // bitmap
DWORD dwNegotiatedDCERate; // bit/s
// Variable portion for proprietary expansion
BYTE abVariablePortion [1];
} MODEMSETTINGS, *PMODEMSETTINGS, *LPMODEMSETTINGS;
// Dial Options
#define DIALOPTION_BILLING 0x00000040 // Supports wait for bong "$"
#define DIALOPTION_QUIET 0x00000080 // Supports wait for quiet "@"
#define DIALOPTION_DIALTONE 0x00000100 // Supports wait for dial tone "W"
// SpeakerVolume for MODEMDEVCAPS
#define MDMVOLFLAG_LOW 0x00000001
#define MDMVOLFLAG_MEDIUM 0x00000002
#define MDMVOLFLAG_HIGH 0x00000004
// SpeakerVolume for MODEMSETTINGS
#define MDMVOL_LOW 0x00000000
#define MDMVOL_MEDIUM 0x00000001
#define MDMVOL_HIGH 0x00000002
// SpeakerMode for MODEMDEVCAPS
#define MDMSPKRFLAG_OFF 0x00000001
#define MDMSPKRFLAG_DIAL 0x00000002
#define MDMSPKRFLAG_ON 0x00000004
#define MDMSPKRFLAG_CALLSETUP 0x00000008
// SpeakerMode for MODEMSETTINGS
#define MDMSPKR_OFF 0x00000000
#define MDMSPKR_DIAL 0x00000001
#define MDMSPKR_ON 0x00000002
#define MDMSPKR_CALLSETUP 0x00000003
// Modem Options
#define MDM_COMPRESSION 0x00000001
#define MDM_ERROR_CONTROL 0x00000002
#define MDM_FORCED_EC 0x00000004
#define MDM_CELLULAR 0x00000008
#define MDM_FLOWCONTROL_HARD 0x00000010
#define MDM_FLOWCONTROL_SOFT 0x00000020
#define MDM_CCITT_OVERRIDE 0x00000040
#define MDM_SPEED_ADJUST 0x00000080
#define MDM_TONE_DIAL 0x00000100
#define MDM_BLIND_DIAL 0x00000200
#define MDM_V23_OVERRIDE 0x00000400
#endif /* _MCX_H_ */

View file

@ -0,0 +1,973 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: g:/library/source/rcs/./windows.c 1.12 1994/05/20 15:35:25 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 : LIBRARY *
* *
* File Name : WINDOWS.C *
* *
* Programmer : Everyone *
* *
* Last Update : February 3, 1992 [DRD] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Change_New_Window -- Combined Change_Window and New_Window. *
* Change_Window -- Changes the 'current' window in the system. *
* Fetch_Char -- Gets one undipthonged char from input. *
* Flush_Line -- Outputs the accumulate text line to screen. *
* In_Char -- Stores (un-dipped) character(s) from input to buffer. *
* New_Window -- Clears the current window to the background color. *
* Set_More_Off -- Turns the 'more' prompting off. *
* Set_More_On -- Turns the 'more' prompting on. *
* Set_More_Prompt -- Adjusts the more prompt text for default routine *
* Standard_More_Prompt -- Default more prompt code for Window_Print *
* Window_Int_Print -- Prints an integer to the window. *
* Window_Print -- Displays and wraps text into a window. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <wwstd.h>
#include "ww_win.h"
#include <keyboard.h>
#include <font.h>
#include <dipthong.h>
PRIVATE void Scroll_Window(void);
PRIVATE void Flush_Line(void);
PRIVATE void In_Char(char *str);
PRIVATE char Fetch_Char(void);
PRIVATE int ScrollCounter = 0; // Count of the lines displayed before a pause.
PRIVATE char Line[84]; // Staging line buffer.
PRIVATE int Pos; // Char Position of next free character.
PRIVATE int PPos; // Pixel position of next free character.
PRIVATE int WPos; // Char position in window.
PRIVATE char *MainSource;
PRIVATE char *AltSource;
PRIVATE char Char[2];
PRIVATE char Stack;
PRIVATE char WordWrapFlag = FALSE; // flag for a word wrap.
PRIVATE int MoreSpace = 7;
PRIVATE int MoreFColor = 0;
PRIVATE int MoreBColor = 0;
int WindowColumns=40;
int WindowLines=25;
int WindowWidth=40;
unsigned int WinB=0;
unsigned int WinC=1;
unsigned int WinX=0;
unsigned int WinY=0;
unsigned int WinCx=0;
unsigned int WinCy=0;
unsigned int WinH=25;
unsigned int WinW=40;
unsigned int Window=0;
int MoreOn = TRUE;
char *TXT_MoreText = "--More--";
void (*Window_More_Ptr)(char const *,int,int,int) = Standard_More_Prompt;
extern GraphicViewPortClass *LogicPage;
/***************************************************************************
* STANDARD_MORE_PROMPT -- Default more prompt code for Window_Print *
* *
* This is the standard "<more>" prompting code that is used by *
* Window_Print when a page is full of text and a pause is desired *
* before the next page of text is printed. This function is called *
* through the Window_More_Ptr global. *
* *
* INPUT: prompt -- Pointer to ASCII text that will be window printed *
* at the right margin. *
* *
* space -- The number of spaces to allow for the 'more' text. *
* *
* fcolor -- The foreground color to use for the 'more' text. *
* *
* bcolor -- The background oclor to use for the 'more' text. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/29/1991 JLB : Created. *
*=========================================================================*/
void Standard_More_Prompt(char const *prompt, int space, int fcolor, int bcolor)
{
int x, y, moresize;
moresize = (space - 1) * (FontWidth+FontXSpacing);
x = ((WinX+WinW) << 3) - moresize;
//y = WinY + ((WinH/FontHeight)-1)*FontHeight;
y = WinY + (WinCy-1) * (FontHeight+FontYSpacing);
// Default "more" prompter.
LogicPage->Print(prompt, x, y, fcolor ? fcolor : WindowList[Window][WINDOWBCOL], bcolor ? bcolor : WindowList[Window][WINDOWFCOL]);
//BG if (LogicPage == SEENPAGE) {
//BG Window_Show_Mouse();
//BG }
// PWG - have to figure out how to do this in windows library
// Clear_KeyBuffer();
// Get_Key();
//BG if (LogicPage == SEENPAGE) {
//BG Window_Hide_Mouse(Window);
//BG }
// Erase the more prompt prompt.
// Text_Print(prompt, x, y, WinB, WinB);
LogicPage->Fill_Rect(x, y, x + moresize - 1, y + (FontHeight+FontYSpacing) - 1, (unsigned char)WinB);
}
/***************************************************************************
* SET_MORE_PROMPT -- Adjusts the more prompt text for default routine *
* *
* Use this routine to control the text of the "<MORE>" prompt that *
* the default more prompt routine uses. This can be useful for *
* foreign language translations. *
* *
* INPUT: prompt -- Pointer to ASCII text that will be window printed *
* at the right margin. *
* *
* space -- The number of spaces to allow for the 'more' text. *
* *
* fcolor -- The foreground color to use for the 'more' text. *
* *
* bcolor -- The background color to use for the 'more' text. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/29/1991 JLB : Created. *
*=========================================================================*/
void Set_More_Prompt(char const *prompt, int space, int fcolor, int bcolor)
{
if (prompt) {
TXT_MoreText = (char*)prompt;
MoreSpace = space;
MoreFColor = fcolor;
MoreBColor = bcolor;
}
else {
TXT_MoreText = "<MORE>";
MoreSpace = 7;
MoreFColor = MoreBColor = 0;
}
}
/***************************************************************************
* SET_MORE_ON -- Turns the 'more' prompting on. *
* *
* Use this routine to turn on the 'more' prompting that Window_Print *
* does. If you have a custom more function pointer, then that *
* routine will be called, otherwise the library default 'more' prompt *
* will be utilized. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
void Set_More_On(void)
{
MoreOn = TRUE;
ScrollCounter = 0;
}
/***************************************************************************
* SET_MORE_OFF -- Turns the 'more' prompting off. *
* *
* This routine will turn the 'more' prompting that Window_Print does *
* off. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
void Set_More_Off(void)
{
MoreOn = FALSE;
}
/***************************************************************************
* CHANGE_WINDOW -- Changes the 'current' window in the system. *
* *
* Use this routine to change the 'current' window. The current window *
* is used in Window_Print and some other graphic output routines. *
* *
* INPUT: windnum -- The window number to change to. *
* *
* OUTPUT: Returns with the previously current window. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
int Change_Window(int windnum)
{
int oldwindow;
int *data;
oldwindow = Window;
Window = windnum;
data = &WindowList[windnum][0];
WinX = *data++;
WinY = *data++;
WinW = *data++;
WinH = *data++;
WinC = *data++;
WinB = *data++;
WinCx = *data++;
WinCy = *data++;
ScrollCounter = 0;
WPos = WinCx / (FontWidth+FontXSpacing);
WindowLines = (WinH-FontYSpacing) / (FontHeight+FontYSpacing);
WindowWidth = WinW << 3;
WindowColumns = WindowWidth / (FontWidth+FontXSpacing);
return (oldwindow);
}
/***************************************************************************
* CHANGE_NEW_WINDOW -- Combined Change_Window and New_Window. *
* *
* This is a combo-routine. It merely combines the Change_Window *
* with the New_Window routines. It will save some (small) code if *
* you use this routine instead of the two function calls. *
* *
* INPUT: window -- Window number to change to and clear. *
* *
* OUTPUT: Returns with the previously current window. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
int Change_New_Window(int windnum)
{
int oldwindow;
oldwindow = Change_Window(windnum);
New_Window();
return(oldwindow);
}
/***************************************************************************
* NEW_WINDOW -- Clears the current window to the background color. *
* *
* This routine clears the current window to the background color. It *
* is used in preparation to Window_Print because it ensures a clean *
* 'slate' for the text. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
void New_Window(void)
{
int x,y,w,h;
x = WinX << 3;
y = WinY;
w = (WinX + WinW) << 3;
h = WinY + WinH;
LogicPage->Fill_Rect(x, y, w - 1, h - 1, (unsigned char)WinB);
WinCx = WPos = 0;
WinCy = 0;
ScrollCounter = 0;
}
/***************************************************************************
* WINDOW_INT_PRINT -- Prints an integer to the window. *
* *
* Use this routine to print an integer to the window. This routine *
* as all other Window printing routines will handle word wrap. *
* *
* INPUT: num -- The integer to convert to ASCII and print. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
void Window_Int_Print(int num)
{
Window_Print("%d", num);
}
/***************************************************************************
* WINDOW_PRINT -- Displays and wraps text into a window. *
* *
* This is the general purpos text output routine that will handle *
* word wrap within a window. It is useful for displaying arbitrary *
* text. This routine will handle dipthonged text and as such it *
* can be quite useful in saving memory. *
* *
* INPUT: string -- String to print. This can be of ANY length and *
* can even contain some formatting codes. The *
* codes supported are: *
* *
* KA_SETX Forces the cursor X position to the value *
* specified. *
* *
* KA_SETY Forces the cursor Y position to the value *
* specified. *
* *
* KA_MORE Causes an immediate "<MORE>" prompt *
* regardless of the scroll situation. *
* *
* KA_RETURN Breaks line and continues output at the *
* left edge of following line. *
* *
* *
* KA_FORMFEED Clears the window and continues printing at *
* the upper left corner. *
* *
* KA_SETBKGDCOL Set the background color with the color *
* specified by the following byte. *
* *
* *
* KA_SETFORECOL Set the foreground color with the color *
* specified by the following byte. *
* *
* KA_TAB Move the cursor over to the next tabstop. *
* Tabstops are set every 8 columns. *
* *
* KA_SPCTAB Insert spaces until the cursor is positioned *
* at the next tabstop. *
* *
* %s Replace the "%s" with the text pointed to *
* by the pointer argument passed to the *
* routine (follows same method a printf). *
* *
* %d Replace the "%d" with an integer ASCII *
* number of the int passed to the routine. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
* 07/29/1991 JLB : Added MORE, SETX, and SETY *
*=========================================================================*/
void Window_Print(char const string[], ...)
{
int oldcx, x, y; // Scratch variables.
char c; // Current character.
char buffer[10]; // Working %d buffer.
int old_c, old_b; // Original window colors.
va_list arg; // Argument list var.
va_start(arg, string);
WordWrapFlag = FALSE; // initialize word wrap flag.
Pos = PPos = 0;
Line[0] = '\0';
Char[0] = Char[1] = 0;
MainSource = (char*)&string[0];
AltSource = NULL;
old_c = WinC;
old_b = WinB;
//BG if (LogicPage == SEENPAGE) {
//BG Window_Hide_Mouse(Window);
//BG }
while (TRUE) {
c = Fetch_Char();
if (!c) break; // Exit on NULL character.
/*
** Substitution commands only work if not already expanding a
** string.
*/
if (!AltSource) {
if (c == '%') {
switch(tolower(Char[0])) {
case 's':
AltSource = va_arg(arg, char*);
if (AltSource) {
Stack = Char[1];
Char[0] = Char[1] = '\0';
c = Fetch_Char();
}
break;
case 'd':
AltSource = buffer;
sprintf(buffer, "%d", va_arg(arg, int));
Stack = Char[1];
Char[0] = Char[1] = '\0';
c = Fetch_Char();
break;
default:
break;
}
}
}
switch(c) {
#if(FALSE)
// these are the positions of foreign language characters
/*
** These are characters that shouldn't be window printed because
** they are currently reserved.
*/
case KA_CTRL_C:
case KA_CTRL_D:
case KA_CTRL_E:
case KA_CTRL_G:
case KA_CTRL_J:
case KA_CTRL_K:
case KA_CTRL_N:
case KA_CTRL_O:
case KA_CTRL_P:
case KA_CTRL_Q:
case KA_CTRL_R:
case KA_CTRL_T:
case KA_CTRL_U:
case KA_CTRL_V:
case KA_CTRL_W:
case KA_CTRL_Z:
case KA_CTRL_BACKSLASH:
case KA_CTRL_CARROT:
case KA_CTRL_UNDERLINE:
break;
#endif
/*
** Force cursor column to specified X value.
*/
case KA_SETX:
Flush_Line();
WPos = Fetch_Char();
WPos = MAX(0, WPos);
// WPos is max width char position
WPos = MIN(WindowColumns-1, WPos);
WinCx = WPos * (FontWidth+FontXSpacing);
break;
/*
** Force the cursor to specified Y value.
*/
case KA_SETY:
Flush_Line();
WinCy = Fetch_Char();
//WinCy = MAX(0, WinCy);
WinCy = MIN((long)WindowLines-1, (long)WinCy);
break;
/*
** Force a "<MORE>" prompt.
*/
case KA_MORE:
Flush_Line();
if (Window_More_Ptr) {
//BG if (LogicPage == SEENPAGE) Window_Show_Mouse();
Window_More_Ptr(TXT_MoreText, MoreSpace, MoreFColor, MoreBColor);
//BG if (LogicPage == SEENPAGE) Window_Hide_Mouse(Window);
}
break;
/*
** Clear and home the window cursor. This is the same
** as New_Window().
*/
case KA_FORMFEED:
New_Window();
break;
/*
** Move cursor to start of next line.
*/
case KA_RETURN:
Flush_Line();
ScrollCounter++;
WinCx = 0;
#if(FALSE)
if (WinCy >= WindowLines-1) {
Scroll_Window();
}
else {
WinCy++;
}
#else
WinCy++;
#endif
break;
/*
** Set the background color.
*/
case KA_SETBKGDCOL:
Flush_Line();
WinB = Fetch_Char();
break;
/*
** Set the foreground color.
*/
case KA_SETFORECOL:
Flush_Line();
WinC = Fetch_Char();
break;
/*
** Move cursor to next column.
*/
case KA_TAB:
Flush_Line();
WPos = ((WPos + 8) & 0xFFF8) - 1;
if (WPos >= WindowColumns) {
WPos = 0;
}
WinCx = WPos * (FontWidth+FontXSpacing);
break;
/*
** Tab to specified column but add spaces.
*/
case KA_SPCTAB:
Flush_Line();
oldcx = WinCx;
x = WinX << 3;
y = WinY + (WinCy * (FontHeight+FontYSpacing));
WPos = ((WPos + 8) & 0xFFF8) - 1;
if (WPos >= WindowColumns) {
WinCx = WPos = 0;
// Fill_Rect instead of printing spaces
LogicPage->Fill_Rect(x + oldcx, y,
x + WindowWidth - 1, y + (FontHeight+FontYSpacing) - 1, (unsigned char)WinB);
ScrollCounter++;
WinCy++;
}
else {
WinCx = WPos * (FontWidth+FontXSpacing);
// Fill_Rect instead of printing spaces
LogicPage->Fill_Rect(x + oldcx, y,
x + WinCx - 1, y + (FontHeight+FontYSpacing) - 1, (unsigned char)WinB);
}
break;
/*
** next character is a extended value 1-127, but 128 is added
** for a value 129-255
*/
case KA_EXTEND:
c = 127;
// NOTE: this falls thru to the default case DO NOT MOVE!!!!!
/*
** next character is a literal value 1-127, except 13
*/
// case KA_LITERAL:
// if (c != (char) 127) { // check if fell thru from extend case
// c = 0; // set to zero for literal case
// }
// c += Fetch_Char();
// NOTE: this falls thru to the default case DO NOT MOVE!!!!!
/*
** Normal character output.
*/
default:
PPos += Char_Pixel_Width(c); // get pixel location of next char
Line[Pos++] = c;
Line[Pos] = '\0';
if (WinCx + PPos > (unsigned)WindowWidth) {
Flush_Line();
}
break;
}
}
/*
** If there is text still pending, then display it before exiting.
*/
if (Pos) Flush_Line();
/*
** Record changes in the cursor position.
*/
WindowList[Window][WINDOWCURSORX] = WinCx;
WindowList[Window][WINDOWCURSORY] = WinCy;
/*
** Restore the window colors to their original values.
*/
WindowList[Window][WINDOWFCOL] = WinC = old_c;
WindowList[Window][WINDOWBCOL] = WinB = old_b;
//BG if (LogicPage == SEENPAGE) {
//BG Window_Show_Mouse();
//BG }
va_end(arg);
}
/***************************************************************************
* SCROLL_WINDOW -- Scrolls the text window up one line. *
* *
* This will scroll the text window up one line. It will handle any *
* pausing for "more" if the MoreOn flag is set. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: This routine assumes that the LogicPage is the SEENPAGE. *
* If this is not the case, the program may appear to hang *
* if a "more" prompt is generated. *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
PRIVATE void Scroll_Window(void)
{
int y; // Top pixel row of bottom line of window.
/*
** Possibly prompt for more text.
*/
if (ScrollCounter >= WindowLines-1 && MoreOn) {
ScrollCounter = 0;
if (Window_More_Ptr) {
//BG if (LogicPage == SEENPAGE) Window_Show_Mouse();
Window_More_Ptr(TXT_MoreText, MoreSpace, MoreFColor, MoreBColor);
//BG if (LogicPage == SEENPAGE) Window_Hide_Mouse(Window);
}
}
/*
** Scroll the window up one line.
*/
y = ((WinH / (FontHeight+FontYSpacing)) - 1) * (FontHeight+FontYSpacing);
LogicPage->Blit(*LogicPage,WinX<<3, WinY + (FontHeight+FontYSpacing), WinX<<3, WinY, WinW<<3, WinH - (FontHeight+FontYSpacing) );
LogicPage->Fill_Rect(WinX<<3,
WinY + y,
((WinX+WinW)<<3) - 1,
WinY + WinH - 1,
(unsigned char)WinB);
}
/***************************************************************************
* FLUSH_LINE -- Outputs the accumulate text line to screen. *
* *
* This will display the accumlated text line to the screen. It will *
* handle breaking the text line at an appropriate position. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
PRIVATE void Flush_Line(void)
{
int breakit, breaksize, breakwidth;
int x, y; // Coordinates of text print.
int breakpoint; // Point to break the line (if possible).
char breakchar; // Break replace character.
int index; // Backward moving index var.
/*
** There could be a held <CR> and this is implied by the cursor Y position
** beyond the bottom of the window. If this is the case, then scroll the
** window and proceed with the line flush.
*/
while (WinCy >= (unsigned)WindowLines /*&& Pos > 0*/) {
Scroll_Window();
if (WinCy >= (unsigned)WindowLines) WinCy--;
}
//if (WinCy >= WindowLines) WinCy = WindowLines-1;
x = (WinX<<3) + WinCx;
y = WinY + (WinCy*(FontHeight+FontYSpacing));
breakwidth = WindowWidth;
// if (ScrollCounter >= WindowLines - 1 && MoreOn) {
// breakwidth -= (MoreSpace * (FontWidth+FontXSpacing)); // use maximum font width
// }
/*
** Try to break the line at the last space IF the line has reached the edge
** of the window.
*/
breakpoint = Pos;
breaksize = PPos;
if (WinCx + breaksize > (unsigned)breakwidth) {
/*
** Since the text WILL spill past the edge of the window, determine the
** point where the break should occur. If this line is ready for the <MORE>
** prompt, then breaking must account for the <MORE> text.
*/
if (ScrollCounter >= WindowLines - 1 && MoreOn) {
breakwidth -= (MoreSpace * (FontWidth+FontXSpacing)); // use maximum font width
}
breakwidth -= WinCx;
breakit = 0;
for (index = breakpoint - 1; index > 0; index--) {
breakchar = Line[index];
breaksize -= Char_Pixel_Width(breakchar);
// only once, find largest text that can fit on the line
if (!breakit) {
// was this the char that went past the right edge
if (breaksize <= breakwidth) {
breakit = index; // save this position if there is no spaces
}
}
// after largest text is found then look for a space to break on
if (breakit && breakchar == KA_SPACE) {
breakpoint = index;
WordWrapFlag = FALSE; // word will start at beginning of next line
break;
}
}
/*
** Exception: When the current text buffer cannot be broken at a logical
** place AND the text is starting past the left margin, THEN there is
** an implied break between the previous text output and this one.
** Output the current text on the next line left margin.
*/
if (!index) {
if (WinCx && !WordWrapFlag) {
breakpoint = breaksize = 0; // Continue text on next line.
WordWrapFlag = TRUE; // indicate a word continuation.
}
else {
breakpoint = breakit; // Just print as much as possible.
}
}
}
breakchar = Line[breakpoint];
Line[breakpoint] = '\0';
LogicPage->Print(Line, x, y, WinC, WinB);
WinCx += breaksize; // add size of text string printed.
Line[breakpoint] = breakchar;
if (breakchar == KA_SPACE) { // take out a space between words.
breakpoint++;
}
// take out another space for double spacing after end of sentence.
if (Line[breakpoint] == KA_SPACE) {
breakpoint++;
}
strcpy(Line, &Line[breakpoint]);
Pos = strlen(Line);
PPos = String_Pixel_Width(Line);
/*
** If at this point there is still text in the buffer, then flushing has
** not been completed. Scroll to next line and repeat the text flushing
** process.
*/
if (Pos || WinCx >= (unsigned)WindowWidth) {
WinCx = WPos = 0;
#if(FALSE)
if (WinCy >= WindowLines-1) {
Scroll_Window();
} else {
WinCy++;
}
#else
WinCy++;
#endif
Flush_Line();
ScrollCounter++; // must be done after flush line for correct counting
}
}
/***************************************************************************
* IN_CHAR -- Stores (un-dipped) character(s) from input to buffer. *
* *
* Use this routine to fetch the next character from the input stream. *
* If the character was dipthonged, then it will be broken into its *
* component ASCII characters and stored in the specified location. *
* This is the core character stream reading code. *
* *
* INPUT: str -- char pointer to the position to store the character(s)*
* fetched from the input stream. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
PRIVATE void In_Char(char *str)
{
char c; // Character to return.
char next; // Following character (if any).
c = next = '\0';
/*
** Fetch a raw byte from the input stream.
*/
if (AltSource) {
if (*AltSource == '\0') {
AltSource = NULL;
c = Stack;
} else {
c = *AltSource++;
}
}
if (!c && MainSource) {
if (*MainSource == '\0') {
MainSource = NULL;
} else {
c = *MainSource++;
}
}
/*
** Convert a dipthong character into it's component
** ASCII characters.
*/
if (c & 0x80) {
c &= 0x7F;
next = c & (char)0x07;
c = (char)((c & (char)0x78) >> 3);
next = Dipthong[c][next]; // Dipthong character.
c = Common[c]; // Common character.
}
*str++ = c;
*str = next;
}
/***************************************************************************
* FETCH_CHAR -- Gets one undipthonged char from input. *
* *
* This routine will fetch one character from the input stream. The *
* character has already been un-dipthonged. It is a straight ASCII *
* character. This routine ensures that if the next character in the *
* input stream needs to be examined, it is available in Char[0]. *
* *
* INPUT: none *
* *
* OUTPUT: Returns next character in the input stream (ASCII). If NULL *
* is returned, then this indicates the end of the input stream. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/25/1991 JLB : Created. *
*=========================================================================*/
PRIVATE char Fetch_Char(void)
{
char c; // Character to return.
if (!Char[0]) {
In_Char(&Char[0]);
}
c = Char[0];
Char[0] = Char[1];
Char[1] = '\0';
if (!Char[0]) {
In_Char(&Char[0]);
}
return (c);
}


View file

@ -0,0 +1,94 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: g:/library/source/rcs/./winhide.c 1.10 1994/05/20 15:35:50 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 : Dune *
* *
* File Name : WINHIDE.C *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : May 30, 1991 *
* *
* Last Update : August 16, 1991 [JLB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Window_Hide_Mouse -- Hides the mouse when it enters a window. *
* Window_Show_Mouse -- Shows the mouse after Window_Hide_Mouse hides it.*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include <keyboard.h>
#include "ww_win.h"
#if(IBM)
/***************************************************************************
* WINDOW_HIDE_MOUSE -- Hides the mouse when it enters a window. *
* *
* This is an intelligent form of Conditional_Hide_Mouse(). It will *
* hide the mouse if it enters the specified window (see the *
* WindowList global). *
* *
* INPUT: window - Window number. *
* *
* OUTPUT: none *
* *
* WARNINGS: Just like Conditional_Hide_Mouse(), this function is NOT *
* nestable. *
* *
* HISTORY: *
* 04/26/1991 JLB : Created. *
*=========================================================================*/
void Window_Hide_Mouse(int window)
{
int x,y,w,h;
x = WindowList[window][WINDOWX]<<3;
y = WindowList[window][WINDOWY];
w = WindowList[window][WINDOWWIDTH]<<3;
h = WindowList[window][WINDOWHEIGHT];
// Conditional_Hide_Mouse(x,y,x+w-1,y+h-1);
}
/***************************************************************************
* WINDOW_SHOW_MOUSE -- Shows the mouse after Window_Hide_Mouse hides it. *
* *
* This routines will show the mouse after Window_Hide_Mouse has hidden *
* it. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/22/1991 JLB : Created. *
*=========================================================================*/
void Window_Show_Mouse(void)
{
// Conditional_Show_Mouse();
}
#endif


View file

@ -0,0 +1,177 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : iff *
* *
* File Name : WRITEPCX.CPP *
* *
* Programmer : Julio R. Jerez *
* *
* Start Date : May 2, 1995 *
* *
* Last Update : May 2, 1995 [JRJ] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* int Save_PCX_File (char* name, GraphicViewPortClass& pic, char* palette)*
*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
#include <wwlib32.h>
#include "filepcx.h"
#include <wwmem.h>
static void Write_Pcx_ScanLine ( int file_handle , int scansize , unsigned char * ptr );
/***************************************************************************
* WRITE_PCX_FILE -- Write the data in ViewPort to a pcx file *
* *
* *
* *
* INPUT: name is a NULL terminated string of the fromat [xxxx.pcx] *
* pic is a pointer to a GraphicViewPortClass or to a *
* GraphicBufferClass holding the picture. *
* palette is a pointer the the memry block holding the color * *
* palette of the picture. *
* *
* OUTPUT: FALSE if the function fails zero otherwise *
* *
* WARNINGS: *
* *
* HISTORY: *
* 05/04/1995 JRJ : Created. *
* 08/01/1995 SKB : Copy the palette so it is not modified. *
*=========================================================================*/
int Write_PCX_File (char* name, GraphicViewPortClass& pic, unsigned char* palette )
{
unsigned char palcopy[256 * 3];
unsigned i ;
//unsigned width ;
int file_handle ;
int VP_Scan_Line ;
char * ptr ;
RGB * pal ;
GraphicBufferClass * Graphic_Buffer ;
PCX_HEADER header = { 10 , 5 , 1 , 8 , 0 , 0 , 319 , 199 ,
320 , 200 , { 0 } , 0 , 1 , 320 , 1 , {0} } ;
// Open file name
file_handle = Open_File ( name , WRITE ) ;
if ( file_handle == WW_ERROR ) return FALSE ;
header.width = pic.Get_Width() - 1 ;
header.height = pic.Get_Height() - 1 ;
header.byte_per_line = pic.Get_Width() ;
Write_File ( file_handle, & header , sizeof (PCX_HEADER)) ;
VP_Scan_Line = pic.Get_Width() + pic.Get_XAdd();
Graphic_Buffer = pic.Get_Graphic_Buffer() ;
ptr = ( char * ) Graphic_Buffer->Get_Buffer() ;
ptr += ( (pic.Get_YPos() * VP_Scan_Line) + pic.Get_XPos() );
for ( i = 0 ; i < (unsigned)header.height + 1 ; i ++ )
Write_Pcx_ScanLine ( file_handle , header.byte_per_line, (unsigned char*)ptr + i * VP_Scan_Line ) ;
Mem_Copy(palette, palcopy, 256 * 3);
pal = ( RGB * ) palcopy ;
for ( i = 0 ; i < 256 ; i ++ ) {
pal -> red <<= 2 ;
pal -> green <<= 2 ;
pal -> blue <<= 2 ;
pal ++ ;
}
i = 0x0c ;
Write_File ( file_handle, & i , 1 ) ;
Write_File ( file_handle, palcopy , 256 * sizeof (RGB) ) ;
Close_File (file_handle) ;
return 0 ;
}
/***************************************************************************
* WRITE_PCX_SCANLINE -- function to write a single pcx scanline to a file *
* *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 05/04/1995 JRJ : Created. *
*=========================================================================*/
#define POOL_SIZE 2048
#define WRITE_CHAR(x) { \
* file_ptr ++ = x ; \
if ( file_ptr >= & pool [ POOL_SIZE ] ) { \
Write_File ( file_handle, pool , POOL_SIZE ) ; \
file_ptr = pool ; \
} }
void Write_Pcx_ScanLine ( int file_handle , int scansize , unsigned char * ptr )
{
unsigned i ;
unsigned rle ;
unsigned color ;
unsigned last ;
unsigned char * file_ptr ;
unsigned char pool [ POOL_SIZE ] ;
file_ptr = pool ;
last = * ptr ;
rle = 1 ;
for ( i = 1 ; i < (unsigned)scansize ; i ++ ) {
color = 0xff & * ++ ptr ;
if ( color == last ) {
rle ++ ;
if ( rle == 63 ) {
WRITE_CHAR ( 255 ) ;
WRITE_CHAR ( color ) ;
rle = 0 ;
}
} else {
if ( rle ) {
if ( rle == 1 && ( 192 != ( 192 & last ))) {
WRITE_CHAR ( last ) ;
} else {
WRITE_CHAR ( rle | 192 ) ;
WRITE_CHAR ( last ) ;
}
}
last = color ;
rle = 1 ;
}
}
if ( rle ) {
if ( rle == 1 && ( 192 != ( 192 & last ))) {
WRITE_CHAR ( last ) ;
} else {
WRITE_CHAR ( rle | 192 ) ;
WRITE_CHAR ( last) ;
}
}
Write_File ( file_handle, pool , ( int ) file_ptr - ( int ) pool ) ;
}

File diff suppressed because it is too large Load diff

160
TIBERIANDAWN/WIN32LIB/WSA.H Normal file
View file

@ -0,0 +1,160 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WSA 32bit LIbrary *
* *
* File Name : WSA.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : May 23, 1994 *
* *
* Last Update : May 25, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Open_Animation -- file name and flags, system allocates buffer. *
* Open_Animation -- file name, flags, palette, system allocates buffer. *
* Open_Animation -- file_name, graphic buffer, flags. *
* Open_Animation -- file name, bufferclass, flags, palette. *
* Open_Animation -- filename, ptr, size, flags, no palette. *
* Animate_Frame -- Animate a frame to a page with magic colors. *
* Animate_Frame -- Animate a frame to a viewport with magic colors. *
* Animate_Frame -- Animate a frame to a page. *
* Animate_Frame -- Animate a frame to a viewport. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef WSA_H
#define WSA_H
#ifndef WWSTD_H
#include "wwstd.h"
#endif
#ifndef GBUFFER_H
#include "gbuffer.h"
#endif
//lint -strong(AJX,WSAType)
typedef enum {
WSA_NORMAL, // Normal WSA animation
WSA_GHOST = 0x1000, // Or'd with the above flags to get ghosting
WSA_PRIORITY2 = 0x2000, // Copy using a priority (or in the priority)
WSA_TRANS = 0x4000, // Copy frame, ignoring transparent colors
WSA_PRIORITY = 0x8000 // Copy using a priority (or in the priority)
} WSAType;
//lint -strong(AJX,WSAOpenType)
typedef enum {
WSA_OPEN_FROM_MEM = 0x0000, // Try to load entire anim into memory.
WSA_OPEN_INDIRECT = 0x0000, // First animate to internal buffer, then copy to page/viewport.
WSA_OPEN_FROM_DISK = 0x0001, // Force the animation to be disk based.
WSA_OPEN_DIRECT = 0x0002, // Animate directly to page or viewport.
// These next two have been added for the 32 bit library to give a better idea of what is
// happening. You may want to animate directly to the destination or indirectly to the
// destination by using the animations buffer. Indirecly is best if the dest is a seenpage
// and the animation is not linear or if the destination is modified between frames.
WSA_OPEN_TO_PAGE = WSA_OPEN_DIRECT ,
WSA_OPEN_TO_BUFFER= WSA_OPEN_INDIRECT ,
} WSAOpenType;
/*=========================================================================*/
/* The following prototypes are for the file: WSA.CPP */
/*=========================================================================*/
void * __cdecl Open_Animation(char const *file_name, char *user_buffer, long user_buffer_size, WSAOpenType user_flags, unsigned char *palette=NULL);
void __cdecl Close_Animation( void *handle );
BOOL __cdecl Animate_Frame(void *handle, GraphicViewPortClass& view,
int frame_number, int x_pixel=0, int y_pixel=0,
WSAType flags_and_prio = WSA_NORMAL, void *magic_cols=NULL, void *magic=NULL);
int __cdecl Get_Animation_Frame_Count(void *handle);
BOOL __cdecl Animate_Frame(void *handle, VideoViewPortClass& view,
int frame_number, int x_pixel=0, int y_pixel=0,
WSAType flags_and_prio = WSA_NORMAL, void *magic_cols=NULL, void *magic=NULL);
int __cdecl Get_Animation_Frame_Count(void *handle);
int __cdecl Get_Animation_X(void const *handle);
int __cdecl Get_Animation_Y(void const *handle);
int __cdecl Get_Animation_Width(void const *handle);
int __cdecl Get_Animation_Height(void const *handle);
int __cdecl Get_Animation_Palette(void const *handle);
unsigned long __cdecl Get_Animation_Size(void const *handle);
/***************************************************************************
* OPEN_ANIMATION -- file name, flags, palette, system allocates buffer. *
* *
* *
* INPUT: char *file_name - name of file to open. *
* WSAOpenType user_flags - flags on how to open. *
* unsigned char *palette - pointer to a palette buffer to fill. *
* *
* OUTPUT: void *pointer to animation data. Must be used for all *
* other WSA calls. *
* *
* WARNINGS: *
* *
* HISTORY: *
* 05/24/1994 SKB : Created. *
*=========================================================================*/
inline void * __cdecl Open_Animation(char *file_name, WSAOpenType user_flags, unsigned char *palette=NULL)
{
return (Open_Animation(file_name, NULL, 0L, user_flags, palette));
}
/***************************************************************************
* OPEN_ANIMATION -- file_name, bufferclass, flags. *
* *
* *
* INPUT: char *file_name - name of file to open. *
* GraphicBufferClass - pointer to a buffer. *
* WSAOpenType user_flags - flags on how to open. *
* unsigned char *palette - pointer to a palette buffer to fill. *
* *
* OUTPUT: void *pointer to animation data. Must be used for all *
* other WSA calls. *
* *
* WARNINGS: *
* *
* HISTORY: *
* 05/24/1994 SKB : Created. *
*=========================================================================*/
inline void * __cdecl Open_Animation(char *file_name, BufferClass& buffer, WSAOpenType user_flags, unsigned char *palette=NULL)
{
return (Open_Animation(file_name, (char *)buffer.Get_Buffer(), buffer.Get_Size(), user_flags, palette));
}
/*=========================================================================*/
/* The following prototypes are for the file: LP_ASM.ASM */
/*=========================================================================*/
extern "C" {
unsigned int __cdecl Apply_XOR_Delta(char *source_ptr, char *delta_ptr);
void __cdecl Apply_XOR_Delta_To_Page_Or_Viewport(void *target, void *delta, int width, int nextrow, int copy);
}
#endif // WSA_H

View file

@ -0,0 +1,68 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: F:\projects\c&c\vcs\code\wwfile.h_v 2.14 06 Sep 1995 16:30:00 JOE_BOSTIC $ */
/***********************************************************************************************
*** 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 *
* *
* File Name : WWFILE.H *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : August 8, 1994 *
* *
* Last Update : August 8, 1994 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef WWFILE_H
#define WWFILE_H
#include <stdio.h>
#ifndef READ
#define READ _READ
#endif
#ifndef WRITE
#define WRITE _WRITE
#endif
class FileClass
{
public:
virtual ~FileClass(void) {};
virtual char const * File_Name(void) const = 0;
virtual char const * Set_Name(char const *filename) = 0;
virtual int Create(void) = 0;
virtual int Delete(void) = 0;
virtual int Is_Available(int forced=false) = 0;
virtual int Is_Open(void) const = 0;
virtual int Open(char const *filename, int rights=READ) = 0;
virtual int Open(int rights=READ) = 0;
virtual long Read(void *buffer, long size) = 0;
virtual long Seek(long pos, int dir=SEEK_CUR) = 0;
virtual long Size(void) = 0;
virtual long Write(void const *buffer, long size) = 0;
virtual void Close(void) = 0;
operator char const * () {return File_Name();};
};
#endif

View file

@ -0,0 +1,65 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : WWLIB32 User include file *
* *
* File Name : WWLIB32.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : August 3, 1994 *
* *
* Last Update : August 3, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef WWLIB32_H
#define WWLIB32_H
#include <gbuffer.h>
#include <wwstd.h>
#include <drawbuff.h>
#include <buffer.h>
#include <font.h>
#include <iff.h>
#include <misc.h>
#include <mono.h>
#include <tile.h>
#include <wwmem.h>
#include <keyboard.h>
#include <mouse.h>
#include <file.h>
#include <rawfile.h>
#include <audio.h>
#include <dipthong.h>
#include <palette.h>
#include <playcd.h>
#include <shape.h>
#include <timer.h>
#include <ww_win.h>
#include <wsa.h>
#include <profile.h>
#endif // WWLIB32_H


View file

@ -0,0 +1,67 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Memory System *
* *
* File Name : MEM.H *
* *
* Programmer : Jeff Wilson *
* *
* Start Date : April 4, 1994 *
* *
* Last Update : September 8, 1994 [IML] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef WWMEM_H
#define WWMEM_H
#include "wwstd.h"
#include "new.h"
#include "memflag.h"
// Defines
//==============
/*=========================================================================*/
/* The following prototypes are for the file: MEM.CPP */
/*=========================================================================*/
int Mem_Init(void *buffer, long size);
void *Mem_Alloc(void *poolptr, long lsize, unsigned long id);
int Mem_Free(void *poolptr, void *buffer);
void Mem_Reference(void *node);
void Mem_Lock_Block(void *node);
void Mem_In_Use(void *node);
void *Mem_Find(void *poolptr, unsigned long id);
unsigned long Mem_Get_ID(void *node);
void *Mem_Find_Oldest(void *poolptr);
void *Mem_Free_Oldest(void *poolptr);
long Mem_Pool_Size(void *poolptr);
long Mem_Avail(void *poolptr);
long Mem_Largest_Avail(void *poolptr);
void Mem_Cleanup(void *poolptr);
#endif


View file

@ -0,0 +1,40 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
;***************************************************************************
;** 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 : Memory System *
;* *
;* File Name : WWMEM.INC *
;* *
;* Programmer : Ian M. Leslie *
;* *
;* Start Date : August 11, 1994 *
;* *
;* Last Update : August 17, 1994 [IML] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
MEM_NORMAL EQU 0000h ; Default memory (normal).
MEM_NEW EQU 0001h ; Called by the operator new and was overloaded.
MEM_CLEAR EQU 0002h ;
GLOBAL @Alloc$qul14MemoryFlagType:PROC
GLOBAL @Free$qpv:PROC

View file

@ -0,0 +1,224 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : wwstd.h *
* *
* File Name : WWLIB.H *
* *
* Programmer : Jeff Wilson *
* *
* Start Date : March 1, 1994 *
* *
* Last Update : March 1, 1994 [] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef WWSTD_H
#define WWSTD_H
#include <windows.h>
#include <windowsx.h>
#ifndef IBM
#define IBM TRUE
#endif
#define WW_ERROR -1
#define PRIVATE static
#define PUBLIC /* Routines & data don't have a specifier */
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
#ifdef GET_SIZE
#undef GET_SIZE
#endif
#define GET_SIZE(a) ((sizeof(a) / sizeof(*a)))
//PG_TO_FIX
//#pragma option -Jg
// Returns the absolute value of the number.
#ifdef ABS
#undef ABS
#endif
template<class T> T ABS(T a)
{
return (a < 0) ? -a : a;
}
//int ABS(int);
//long ABS(long);
// Returns the minimum of the two numbers.
#ifdef MIN
#undef MIN
#endif
template<class T> T MIN(T a, T b)
{
return (b < a) ? b : a;
};
//short MIN(short, short);
//int MIN(int, int);
//long MIN(long, long);
// Returns the maximum of the two numbers.
#ifdef MAX
#undef MAX
#endif
template<class T> T MAX(T a, T b)
{
return (b > a) ? b : a;
};
// Returns the low word of a long
#define LOW_WORD(a) ((unsigned short)((long)(a) & 0x0000FFFFL))
// Returns the high word of a long
#define HIGH_WORD(a) ((unsigned long)(a) >> 16)
// Merges to shorts to become a long
#define MAKE_LONG(a,b) (((long)(a) << 16) | (long)((b)&0x0000FFFFL))
/*
** Macro allows our routines to act like
** sprintf etc..
*/
#ifdef AssembleTo
#undef AssembleTo
#endif
#define AssembleTo(dest,fmt)\
{\
va_list argptr;\
if (fmt != (dest))\
{\
va_start (argptr, fmt);\
vsprintf ((dest), fmt, argptr);\
va_end (argptr);\
}\
}
/*
** The type of processor running on this system as
** returned by Processor().
*/
#define PROC_80386 0
#define PROC_80486 1
#define PROC_PENTIUM 2
// Inline Routines
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
//
// These Template functions are generally used
// by classes when they havce over loaded > and <.
//
#ifdef __cplusplus
template<class T> T Min(T a, T b)
{
return (a<b ? a : b);
}
template<class T> inline T Max(T a, T b)
{
return (a>b ? a : b);
}
template<class T> T Abs(T a)
{
return ((a<0) ? -(a) : a);
}
template<class T> VOID minimize(T &a, T b)
{
if( b<a )
a=b;
}
template<class T> VOID maximize(T &a, T b)
{
if( b>a )
a=b;
}
#endif
/*
** Macros that control bit settings in a variable.
*/
#define Bit_Flags_On(a,b) a |= (b)
#define Bit_Flags_Off(a,b) a &= (~(b))
#define Bit_Flags_Value(a,b) (a & (b))
#define Bit_Flags_Flip(a,b) a ^= (b)
// Template replacements for the user defines above
#ifdef __cplusplus
template<class T> VOID BitFlagsOn(T &a, T b)
{
a |= (b);
}
template<class T> VOID BitFlagsOff(T &a, T b)
{
a &= (~(b));
}
template<class T> T BitFlagsValue(T a, T b)
{
return (a & (b));
}
template<class T> VOID BitFlagsFlip(T &a, T b)
{
a ^= (b);
}
#endif
typedef enum {
TBLACK,
PURPLE,
CYAN,
GREEN,
LTGREEN,
YELLOW,
PINK,
BROWN,
RED,
LTCYAN,
LTBLUE,
BLUE,
BLACK,
GREY,
LTGREY,
WHITE,
COLOR_PADDING=0x1000
} ColorType;
#endif //WWSTD_H

View file

@ -0,0 +1,93 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
** 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 : Part of the WINDOWS Library *
* *
* File Name : WINDOWS.H *
* *
* Programmer : Barry W. Green *
* *
* Start Date : February 16, 1995 *
* *
* Last Update : February 16, 1995 [BWG] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef WINDOWS_H
#define WINDOWS_H
/*=========================================================================*/
/* The following prototypes are for the file: WINHIDE.CPP */
/*=========================================================================*/
void Window_Hide_Mouse(int window);
void Window_Show_Mouse(void);
/*=========================================================================*/
/* The following prototypes are for the file: WINDOWS.CPP */
/*=========================================================================*/
void Standard_More_Prompt(char const *prompt, int space, int fcolor, int bcolor);
void Set_More_Prompt(char const *prompt, int space, int fcolor, int bcolor);
void Set_More_On(void);
void Set_More_Off(void);
int Change_Window(int windnum);
int Change_New_Window(int windnum);
void New_Window(void);
void Window_Int_Print(int num);
void Window_Print(char const string[], ...);
/*
** The WindowList[][8] array contains the following elements. Use these
** defines when accessing the WindowList.
*/
typedef enum {
WINDOWX, // X byte position of left edge.
WINDOWY, // Y pixel position of top edge.
WINDOWWIDTH, // Width in bytes of the window.
WINDOWHEIGHT, // Height in pixels of the window.
WINDOWFCOL, // Default foreground color.
WINDOWBCOL, // Default background color.
WINDOWCURSORX, // Current cursor X position (in rows).
WINDOWCURSORY, // Current cursor Y position (in lines).
WINDOWPADDING=0x1000
} WindowIndexType;
extern int WindowList[][8];
extern int WindowColumns;
extern int WindowLines;
extern int WindowWidth;
extern unsigned int WinB;
extern unsigned int WinC;
extern unsigned int WinX;
extern unsigned int WinY;
extern unsigned int WinCx;
extern unsigned int WinCy;
extern unsigned int WinH;
extern unsigned int WinW;
extern unsigned int Window;
extern int MoreOn;
extern char *TXT_MoreText;
extern void (*Window_More_Ptr)(char const *, int, int, int);
#endif //WINDOWS_H


View file

@ -0,0 +1,668 @@
;
; Copyright 2020 Electronic Arts Inc.
;
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
; in the hope that it will be useful, but with permitted additional restrictions
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
; distributed with this program. You should have received a copy of the
; GNU General Public License along with permitted additional restrictions
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
; **************************************************************************
; ** 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 : WSA Support routines *
; * *
; * File Name : XORDELTA.ASM *
; * *
; * Programmer : Scott K. Bowen *
; * *
; * Last Update :May 23, 1994 [SKB] *
; * *
; *------------------------------------------------------------------------*
; * Functions: *
;* Apply_XOR_Delta -- Apply XOR delta data to a buffer. *
;* Apply_XOR_Delta_To_Page_Or_Viewport -- Calls the copy or the XOR funti*
;* Copy_Delta_buffer -- Copies XOR Delta Data to a section of a page. *
;* XOR_Delta_Buffer -- Xor's the data in a XOR Delta format to a page. *
; * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
;IDEAL
;P386
;MODEL USE32 FLAT
.model flat
;LOCALS ??
; These are used to call Apply_XOR_Delta_To_Page_Or_Viewport() to setup flags parameter. If
; These change, make sure and change their values in wsa.cpp.
DO_XOR equ 0
DO_COPY equ 1
TO_VIEWPORT equ 0
TO_PAGE equ 2
;
; Routines defined in this module
;
;
; UWORD Apply_XOR_Delta(UWORD page_seg, BYTE *delta_ptr);
; PUBLIC Apply_XOR_Delta_To_Page_Or_Viewport(UWORD page_seg, BYTE *delta_ptr, WORD width, WORD copy)
;
; PROC C XOR_Delta_Buffer
; PROC C Copy_Delta_Buffer
;
externdef C Apply_XOR_Delta:NEAR
externdef C Apply_XOR_Delta_To_Page_Or_Viewport:NEAR
;CODESEG
.code
;***************************************************************************
;* APPLY_XOR_DELTA -- Apply XOR delta data to a linear buffer. *
;* AN example of this in C is at the botton of the file commented out. *
;* *
;* INPUT: BYTE *target - destination buffer. *
;* BYTE *delta - xor data to be delta uncompress. *
;* *
;* OUTPUT: *
;* *
;* WARNINGS: *
;* *
;* HISTORY: *
;* 05/23/1994 SKB : Created. *
;*=========================================================================*
Apply_XOR_Delta proc C public USES ebx ecx edx esi edi target:DWORD, delta:DWORD
;USES ebx,ecx,edx,edi,esi
;ARG target:DWORD ; pointers.
;ARG delta:DWORD ; pointers.
; Optimized for 486/pentium by rearanging instructions.
mov edi,[target] ; get our pointers into offset registers.
mov esi,[delta]
cld ; make sure we go forward
xor ecx,ecx ; use cx for loop
top_loop:
xor eax,eax ; clear out eax.
mov al,[esi] ; get delta source byte
inc esi
test al,al ; check for a SHORTDUMP ; check al incase of sign value.
je short_run
js check_others
;
; SHORTDUMP
;
mov ecx,eax ; stick count in cx
dump_loop:
mov al,[esi] ;get delta XOR byte
xor [edi],al ; xor that byte on the dest
inc esi
inc edi
dec ecx
jnz dump_loop
jmp top_loop
;
; SHORTRUN
;
short_run:
mov cl,[esi] ; get count
inc esi ; inc delta source
do_run:
mov al,[esi] ; get XOR byte
inc esi
run_loop:
xor [edi],al ; xor that byte.
inc edi ; go to next dest pixel
dec ecx ; one less to go.
jnz run_loop
jmp top_loop
;
; By now, we know it must be a LONGDUMP, SHORTSKIP, LONGRUN, or LONGSKIP
;
check_others:
sub eax,080h ; opcode -= 0x80
jnz do_skip ; if zero then get next word, otherwise use remainder.
mov ax,[esi]
lea esi,[esi+2] ; get word code in ax
test ax,ax ; set flags. (not 32bit register so neg flag works)
jle not_long_skip
;
; SHORTSKIP AND LONGSKIP
;
do_skip:
add edi,eax ; do the skip.
jmp top_loop
not_long_skip:
jz stop ; long count of zero means stop
sub eax,08000h ; opcode -= 0x8000
test eax,04000h ; is it a LONGRUN (code & 0x4000)?
je long_dump
;
; LONGRUN
;
sub eax,04000h ; opcode -= 0x4000
mov ecx,eax ; use cx as loop count
jmp do_run ; jump to run code.
;
; LONGDUMP
;
long_dump:
mov ecx,eax ; use cx as loop count
jmp dump_loop ; go to the dump loop.
stop:
ret
Apply_XOR_Delta endp
;----------------------------------------------------------------------------
;***************************************************************************
;* APPLY_XOR_DELTA_To_Page_Or_Viewport -- Calls the copy or the XOR funtion. *
;* *
;* *
;* This funtion is call to either xor or copy XOR_Delta data onto a *
;* page instead of a buffer. The routine will set up the registers *
;* need for the actual routines that will perform the copy or xor. *
;* *
;* The registers are setup as follows : *
;* es:edi - destination segment:offset onto page. *
;* ds:esi - source buffer segment:offset of delta data. *
;* dx,cx,ax - are all zeroed out before entry. *
;* *
;* INPUT: *
;* *
;* OUTPUT: *
;* *
;* WARNINGS: *
;* *
;* HISTORY: *
;* 03/09/1992 SB : Created. *
;*=========================================================================*
Apply_XOR_Delta_To_Page_Or_Viewport proc C public USES ebx ecx edx esi edi target:DWORD, delta:DWORD, xwidth:DWORD, nextrow:DWORD, copy:DWORD
;USES ebx,ecx,edx,edi,esi
;ARG target:DWORD ; pointer to the destination buffer.
;ARG delta:DWORD ; pointer to the delta buffer.
;ARG width:DWORD ; width of animation.
;ARG nextrow:DWORD ; Page/Buffer width - anim width.
;ARG copy:DWORD ; should it be copied or xor'd?
mov edi,[target] ; Get the target pointer.
mov esi,[delta] ; Get the destination pointer.
xor eax,eax ; clear eax, later put them into ecx and edx.
cld ; make sure we go forward
mov ebx,[nextrow] ; get the amount to add to get to next row from end. push it later...
mov ecx,eax ; use cx for loop
mov edx,eax ; use dx to count the relative column.
push ebx ; push nextrow onto the stack for Copy/XOR_Delta_Buffer.
mov ebx,[xwidth] ; bx will hold the max column for speed compares
; At this point, all the registers have been set up. Now call the correct function
; to either copy or xor the data.
cmp [copy],DO_XOR ; Do we want to copy or XOR
je xorfunct ; Jump to XOR if not copy
call Copy_Delta_Buffer ; Call the function to copy the delta buffer.
jmp didcopy ; jump past XOR
xorfunct:
call XOR_Delta_Buffer ; Call funtion to XOR the deltat buffer.
didcopy:
pop ebx ; remove the push done to pass a value.
ret
Apply_XOR_Delta_To_Page_Or_Viewport ENDP
;----------------------------------------------------------------------------
;***************************************************************************
;* XOR_DELTA_BUFFER -- Xor's the data in a XOR Delta format to a page. *
;* This will only work right if the page has the previous data on it. *
;* This function should only be called by XOR_Delta_Buffer_To_Page_Or_Viewport. *
;* The registers must be setup as follows : *
;* *
;* INPUT: *
;* es:edi - destination segment:offset onto page. *
;* ds:esi - source buffer segment:offset of delta data. *
;* edx,ecx,eax - are all zeroed out before entry. *
;* *
;* OUTPUT: *
;* *
;* WARNINGS: *
;* *
;* HISTORY: *
;* 03/09/1992 SB : Created. *
;*=========================================================================*
XOR_Delta_Buffer proc C nextrow:DWORD
top_loop2:
xor eax,eax ; clear out eax.
mov al,[esi] ; get delta source byte
inc esi
test al,al ; check for a SHORTDUMP ; check al incase of sign value.
je short_run2
js check_others2
;
; SHORTDUMP
;
mov ecx,eax ; stick count in cx
dump_loop2:
mov al,[esi] ; get delta XOR byte
xor [edi],al ; xor that byte on the dest
inc esi
inc edx ; increment our count on current column
inc edi
cmp edx,ebx ; are we at the final column
jne end_col1 ; if not the jmp over the code
sub edi,edx ; get our column back to the beginning.
xor edx,edx ; zero out our column counter
add edi,[nextrow] ; jump to start of next row
end_col1:
dec ecx
jnz dump_loop2
jmp top_loop2
;
; SHORTRUN
;
short_run2:
mov cl,[esi] ; get count
inc esi ; inc delta source
do_run2:
mov al,[esi] ; get XOR byte
inc esi
run_loop2:
xor [edi],al ; xor that byte.
inc edx ; increment our count on current column
inc edi ; go to next dest pixel
cmp edx,ebx ; are we at the final column
jne end_col2 ; if not the jmp over the code
sub edi,ebx ; get our column back to the beginning.
xor edx,edx ; zero out our column counter
add edi,[nextrow] ; jump to start of next row
end_col2:
dec ecx
jnz run_loop2
jmp top_loop2
;
; By now, we know it must be a LONGDUMP, SHORTSKIP, LONGRUN, or LONGSKIP
;
check_others2:
sub eax,080h ; opcode -= 0x80
jnz do_skip2 ; if zero then get next word, otherwise use remainder.
mov ax,[esi] ; get word code in ax
lea esi,[esi+2]
test ax,ax ; set flags. (not 32bit register so neg flag works)
jle not_long_skip2
;
; SHORTSKIP AND LONGSKIP
;
do_skip2:
sub edi,edx ; go back to beginning or row.
add edx,eax ; incriment our count on current row
recheck2:
cmp edx,ebx ; are we past the end of the row
jb end_col3 ; if not the jmp over the code
sub edx,ebx ; Subtract width from the col counter
add edi,[nextrow] ; jump to start of next row
jmp recheck2 ; jump up to see if we are at the right row
end_col3:
add edi,edx ; get to correct position in row.
jmp top_loop2
not_long_skip2:
jz stop2 ; long count of zero means stop
sub eax,08000h ; opcode -= 0x8000
test eax,04000h ; is it a LONGRUN (code & 0x4000)?
je long_dump2
;
; LONGRUN
;
sub eax,04000h ; opcode -= 0x4000
mov ecx,eax ; use cx as loop count
jmp do_run2 ; jump to run code.
;
; LONGDUMP
;
long_dump2:
mov ecx,eax ; use cx as loop count
jmp dump_loop2 ; go to the dump loop.
stop2:
ret
XOR_Delta_Buffer ENDP
;----------------------------------------------------------------------------
;***************************************************************************
;* COPY_DELTA_BUFFER -- Copies XOR Delta Data to a section of a page. *
;* This function should only be called by XOR_Delta_Buffer_To_Page_Or_Viewport. *
;* The registers must be setup as follows : *
;* *
;* INPUT: *
;* es:edi - destination segment:offset onto page. *
;* ds:esi - source buffer segment:offset of delta data. *
;* dx,cx,ax - are all zeroed out before entry. *
;* *
;* OUTPUT: *
;* *
;* WARNINGS: *
;* *
;* HISTORY: *
;* 03/09/1992 SB : Created. *
;*=========================================================================*
Copy_Delta_Buffer proc C nextrow:DWORD
;ARG nextrow:DWORD
top_loop3:
xor eax,eax ; clear out eax.
mov al,[esi] ; get delta source byte
inc esi
test al,al ; check for a SHORTDUMP ; check al incase of sign value.
je short_run3
js check_others3
;
; SHORTDUMP
;
mov ecx,eax ; stick count in cx
dump_loop3:
mov al,[esi] ; get delta XOR byte
mov [edi],al ; store that byte on the dest
inc edx ; increment our count on current column
inc esi
inc edi
cmp edx,ebx ; are we at the final column
jne end_col1_3 ; if not the jmp over the code
sub edi,edx ; get our column back to the beginning.
xor edx,edx ; zero out our column counter
add edi,[nextrow] ; jump to start of next row
end_col1_3:
dec ecx
jnz dump_loop3
jmp top_loop3
;
; SHORTRUN
;
short_run3:
mov cl,[esi] ; get count
inc esi ; inc delta source
do_run3:
mov al,[esi] ; get XOR byte
inc esi
run_loop3:
mov [edi],al ; store the byte (instead of XOR against current color)
inc edx ; increment our count on current column
inc edi ; go to next dest pixel
cmp edx,ebx ; are we at the final column
jne end_col2_3 ; if not the jmp over the code
sub edi,ebx ; get our column back to the beginning.
xor edx,edx ; zero out our column counter
add edi,[nextrow] ; jump to start of next row
end_col2_3:
dec ecx
jnz run_loop3
jmp top_loop3
;
; By now, we know it must be a LONGDUMP, SHORTSKIP, LONGRUN, or LONGSKIP
;
check_others3:
sub eax,080h ; opcode -= 0x80
jnz do_skip3 ; if zero then get next word, otherwise use remainder.
mov ax,[esi] ; get word code in ax
lea esi,[esi+2]
test ax,ax ; set flags. (not 32bit register so neg flag works)
jle not_long_skip3
;
; SHORTSKIP AND LONGSKIP
;
do_skip3:
sub edi,edx ; go back to beginning or row.
add edx,eax ; incriment our count on current row
recheck3:
cmp edx,ebx ; are we past the end of the row
jb end_col3_3 ; if not the jmp over the code
sub edx,ebx ; Subtract width from the col counter
add edi,[nextrow] ; jump to start of next row
jmp recheck3 ; jump up to see if we are at the right row
end_col3_3:
add edi,edx ; get to correct position in row.
jmp top_loop3
not_long_skip3:
jz stop3 ; long count of zero means stop
sub eax,08000h ; opcode -= 0x8000
test eax,04000h ; is it a LONGRUN (code & 0x4000)?
je long_dump3
;
; LONGRUN
;
sub eax,04000h ; opcode -= 0x4000
mov ecx,eax ; use cx as loop count
jmp do_run3 ; jump to run code.
;
; LONGDUMP
;
long_dump3:
mov ecx,eax ; use cx as loop count
jmp dump_loop3 ; go to the dump loop.
stop3:
ret
Copy_Delta_Buffer ENDP
;----------------------------------------------------------------------------
END
;----------------------------------------------------------------------------
;
;PUBLIC UWORD Apply_XOR_Delta(UWORD page_seg, BYTE *delta_ptr)
;{
;
; register UWORD loop;
; BYTE opcode, xor_byte;
; UWORD bytes_to_uncompress = 64000U;
;
;
; /* Make our buffer pointer */
;
; to = MK_FP(page_seg, 0);
; delta = Normalize_Pointer(delta_ptr);
;
;
; while (bytes_to_uncompress) {
;
; opcode = *delta++;
;
;
; /* Check for SHORTDUMP */
;
; if (opcode > 0) {
;
;
; bytes_to_uncompress -= opcode;
;
; for (loop = 0; loop < opcode; loop++) {
; xor_byte = *delta++;
; *to++ ^= xor_byte;
; }
; continue;
; }
;
; /* Check for SHORTRUN */
;
; if (opcode == 0) {
;
; word_count = *delta++;
; xor_byte = *delta++;
;
; bytes_to_uncompress -= word_count;
;
; for (loop = 0; loop < word_count; loop++) {
; *to++ ^= xor_byte;
; }
; continue;
; }
;
; /* By now, we know it must be a LONGDUMP, SHORTSKIP, or LONGSKIP */
;
; opcode -= 0x80;
;
;
; /* Is it a SHORTSKIP? */
;
; if (opcode != 0) {
;
; to += opcode;
; bytes_to_uncompress -= (WORD) opcode;
; continue;
; }
;
;
; word_count = *((UWORD *) delta)++;
;
; /* Is it a LONGSKIP? */
;
; if ((WORD) word_count > 0) {
;
; to += word_count;
; bytes_to_uncompress -= (WORD) word_count;
; continue;
; }
;
;
; word_count -= 0x8000;
;
; /* Is it a LONGRUN? */
;
; if (word_count & 0x4000) {
;
; word_count -= 0x4000;
;
; bytes_to_uncompress -= word_count;
;
; xor_byte = *delta++;
;
; for (loop = 0; loop < word_count; loop++) {
; *to++ ^= xor_byte;
; }
; continue;
; }
;
;
; /* It must be a LONGDUMP */
;
; bytes_to_uncompress -= word_count;
;
; for (loop = 0; loop < word_count; loop++) {
; xor_byte = *delta++;
; *to++ ^= xor_byte;
; }
; }
;
;
; return(64000U);
;}
;


View file

@ -0,0 +1,55 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $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'},
};


View file

@ -0,0 +1,180 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/***************************************************************************
;** 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 : Library - Filio header stuff. *
;* *
;* File Name : FILE.H *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : September 13, 1993 *
;* *
;* Last Update : April 11, 1994 *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef FILE_H
#include "file.h"
#endif
#ifndef _FILE_H
#define _FILE_H
/*=========================================================================*/
/* Fileio defines */
/*=========================================================================*/
#define LIB_CDROM TRUE
#define MODE_OLDFILE (O_RDONLY | O_BINARY)
#define MODE_NEWFILE (O_WRONLY | O_BINARY | O_CREAT | O_TRUNC)
#define MODE_READWRITE (O_RDWR | O_BINARY)
#define FILEOPENERROR -1
#define FILEOPEN(f,m) ibm_open(f, m, (((UWORD) m) == MODE_OLDFILE) ? S_IREAD : (S_IREAD | S_IWRITE))
#define FILECLOSE(fd) ibm_close(fd)
#define FILEREAD(f,b,n) ibm_read(f,b,(WORD)(n))
#define FILEWRITE(f,b,n) ibm_write(f,b,(WORD)(n))
#define FILESEEK(f,b,n) ibm_lseek(f, b, n)
#define FILEDELETE(f) ibm_unlink(f)
#define CHANGEDIR(p) ibm_chdir(p)
#define FILENAMESIZE 13
#define IO_CHUNK_SIZE 0xfff0UL
/*
** Maximum number of file handles
*/
#define TABLE_MAX 20
/*=========================================================================*/
/* The file handle table */
/*=========================================================================*/
typedef struct {
BOOL Empty; // Is this handle empty?
WORD Handle; // DOS file handle (0 = resident).
LONG Pos; // Current file position.
LONG Start; // Offset of file from pointer.
WORD Index; // FileData[] index.
WORD Mode; // Access mode (WW).
BYTE *Name; // File name pointer.
} FileHandleType;
/*=========================================================================*/
/* The following prototypes are for the file: FILEIO.CPP */
/*=========================================================================*/
WORD ibm_getdisk(VOID);
WORD ibm_setdisk(WORD drive);
WORD ibm_close(WORD handle);
WORD ibm_unlink(BYTE const *name);
LONG ibm_lseek(WORD handle, LONG offset, WORD where);
UWORD ibm_read(WORD handle, VOID *ptr, UWORD bytes);
UWORD ibm_write(WORD handle, VOID *ptr, UWORD bytes);
WORD ibm_open(BYTE const *name, UWORD mode, WORD attrib);
WORD ibm_chdir(BYTE const *path);
/*=========================================================================*/
/* The following prototypes are for the file: FILELIB.CPP */
/*=========================================================================*/
WORD cdecl Do_Open_Error(FileErrorType errormsgnum, BYTE const *file_name);
VOID cdecl Do_IO_Error(FileErrorType errormsgnum, BYTE const *filename);
LONG cdecl Read_File_With_Recovery( WORD handle, VOID *buf, UWORD bytes );
WORD cdecl Open_File_With_Recovery( BYTE const *file_name, UWORD mode );
BOOL cdecl Cache_File(WORD index, WORD file_handle);
/*=========================================================================*/
/* The following prototypes are for the file: DEVICES.ASM */
/*=========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
extern VOID Get_Devices(VOID);
extern WORD Is_Device_Real(WORD device);
#ifdef __cplusplus
}
#endif
/*=========================================================================*/
/* The following prototypes are for the file: DEVTABLE.ASM */
/*=========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
extern VOID Init_Device_Table(BYTE *table);
extern WORD Max_Device(VOID);
#ifdef __cplusplus
}
#endif
/*=========================================================================*/
/* The following prototypes are for the file: HARDERR.ASM */
/*=========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
extern VOID Install_Hard_Error_Handler(VOID);
extern VOID Remove_Hard_Error_Handler(VOID);
#ifdef __cplusplus
}
#endif
/*=========================================================================*/
/* Globale variables in the fileio system. */
/*=========================================================================*/
extern BYTE CallingDOSInt;
extern "C" extern BYTE MaxDevice,DefaultDrive;
extern BYTE MultiDriveSearch;
extern FileDataType *FileDataPtr;
extern FileHandleType FileHandleTable[TABLE_MAX];
extern UWORD NumFiles; // Number of files, except PAK, in file table.
extern UWORD NumPAKFiles; // Number of PAK files in filetable.
extern VOID *FileCacheHeap; // Pointer to the cache in memory.
extern WORD DiskNumber;
extern WORD MaxDirNum;
/*=========================================================================*/
#endif // _FILE_H