mirror of
https://github.com/electronicarts/CnC_Red_Alert.git
synced 2025-12-15 15:11:39 -05:00
Initial commit of Command & Conquer Red Alert source code.
This commit is contained in:
89
CODE/LZW.H
Normal file
89
CODE/LZW.H
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
** Command & Conquer Red Alert(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* $Header: /CounterStrike/LZW.H 1 3/03/97 10:25a 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 : LZW.H *
|
||||
* *
|
||||
* Programmer : Joe L. Bostic *
|
||||
* *
|
||||
* Start Date : 08/28/96 *
|
||||
* *
|
||||
* Last Update : August 28, 1996 [JLB] *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifndef _LZW_H
|
||||
#define _LZW_H
|
||||
|
||||
#include "buff.h"
|
||||
|
||||
class LZWEngine
|
||||
{
|
||||
public:
|
||||
LZWEngine(void);
|
||||
|
||||
int Compress(Buffer const & input, Buffer const & output);
|
||||
int Uncompress(Buffer const & input, Buffer const & output);
|
||||
|
||||
void Reset(void);
|
||||
|
||||
private:
|
||||
typedef short CodeType;
|
||||
struct CodeClass {
|
||||
CodeType CodeValue;
|
||||
CodeType ParentCode;
|
||||
char CharValue;
|
||||
|
||||
CodeClass(void) {}
|
||||
CodeClass(CodeType code, CodeType parent, char c) : CodeValue(code), ParentCode(parent), CharValue(c) {}
|
||||
|
||||
enum {UNUSED=-1};
|
||||
void Make_Unused(void) {CodeValue = UNUSED;}
|
||||
bool Is_Unused(void) const {return(CodeValue == UNUSED);}
|
||||
bool Is_Matching(CodeType code, char c) const {return(ParentCode == code && CharValue == c);}
|
||||
};
|
||||
|
||||
enum {
|
||||
BITS=12,
|
||||
MAX_CODE=((1 << BITS ) - 1),
|
||||
FIRST_CODE=257,
|
||||
END_OF_STREAM=256,
|
||||
TABLE_SIZE=5021
|
||||
};
|
||||
CodeClass dict[TABLE_SIZE];
|
||||
|
||||
char decode_stack[TABLE_SIZE];
|
||||
|
||||
int Find_Child_Node(CodeType parent_code, char child_character);
|
||||
int Decode_String(char * ptr, CodeType code);
|
||||
static int Make_LZW_Hash(CodeType code, char character);
|
||||
};
|
||||
|
||||
|
||||
int LZW_Compress(Buffer const & inbuff, Buffer const & outbuff);
|
||||
int LZW_Uncompress(Buffer const & inbuff, Buffer const & outbuff);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user