Richard Boegli's CnC_Generals_Zero_Hour Fork
WIP
This is documentation of Richard Boegil's Zero Hour Fork
Loading...
Searching...
No Matches
load.cpp
Go to the documentation of this file.
1
/*
2
** Command & Conquer Generals Zero Hour(tm)
3
** Copyright 2025 Electronic Arts Inc.
4
**
5
** This program is free software: you can redistribute it and/or modify
6
** it under the terms of the GNU General Public License as published by
7
** the Free Software Foundation, either version 3 of the License, or
8
** (at your option) any later version.
9
**
10
** This program is distributed in the hope that it will be useful,
11
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
** GNU General Public License for more details.
14
**
15
** You should have received a copy of the GNU General Public License
16
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
/***********************************************************************************************
20
*** 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 ***
21
***********************************************************************************************
22
* *
23
* Project Name : Command & Conquer *
24
* *
25
* $Archive:: /Commando/Library/LOAD.CPP $*
26
* *
27
* $Author:: Greg_h $*
28
* *
29
* $Modtime:: 7/22/97 11:37a $*
30
* *
31
* $Revision:: 1 $*
32
* *
33
*---------------------------------------------------------------------------------------------*
34
* Functions: *
35
* Load_Uncompress -- Load and uncompress the given file. *
36
* Uncompress_Data -- Uncompress standard CPS buffer. *
37
* Load_Data -- Loads a data file from disk. *
38
* Load_Alloc_Data -- Loads and allocates buffer for a file. *
39
* Write_Data -- Writes a block of data as a file to disk. *
40
* Uncompress_Data -- Uncompresses data from one buffer to another. *
41
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
42
43
#include "
always.h
"
44
#include "
iff.h
"
45
#include "
lcw.h
"
46
#include <
string.h
>
47
48
49
/***************************************************************************
50
* Uncompress_Data -- Uncompresses data from one buffer to another. *
51
* *
52
* This routine takes data from a compressed file (sans the first two *
53
* size bytes) and uncompresses it to a destination buffer. The source *
54
* data MUST have the CompHeaderType at its start. *
55
* *
56
* INPUT: src -- Source compressed data pointer. *
57
* *
58
* dst -- Destination (paragraph aligned) pointer. *
59
* *
60
* OUTPUT: Returns with the size of the uncompressed data. *
61
* *
62
* WARNINGS: If LCW compression is used, the destination buffer must *
63
* be paragraph aligned. *
64
* *
65
* HISTORY: *
66
* 09/17/1993 JLB : Created. *
67
*=========================================================================*/
68
unsigned
long
__cdecl
Uncompress_Data
(
void
const
*src,
void
*dst)
69
{
70
unsigned
int
skip;
// Number of leading data to skip.
71
CompressionType
method;
// Compression method used.
72
unsigned
long
uncomp_size;
73
74
if
(!src || !dst)
return
(
NULL
);
75
76
/*
77
** Interpret the data block header structure to determine
78
** compression method, size, and skip data amount.
79
*/
80
uncomp_size = ((
CompHeaderType
*)src)->Size;
81
#if(AMIGA)
82
uncomp_size = Reverse_Long(uncomp_size);
83
#endif
84
skip = ((
CompHeaderType
*)src)->Skip;
85
#if(AMIGA)
86
skip = Reverse_Word(skip);
87
#endif
88
method = (
CompressionType
) ((
CompHeaderType
*)src)->Method;
89
src = ((
char
*)src) + (long)
sizeof
(
CompHeaderType
) + (long)skip;
90
// src = Add_Long_To_Pointer((void *)src, (long)sizeof(CompHeaderType) + (long)skip);
91
92
switch
(method) {
93
94
default
:
95
case
NOCOMPRESS
:
96
memmove(dst, (
void
*) src, uncomp_size);
97
// Mem_Copy((void *) src, dst, uncomp_size);
98
break
;
99
100
case
HORIZONTAL
:
101
break
;
102
103
case
LCW
:
104
LCW_Uncomp
((
void
*) src, (
void
*) dst, (
unsigned
long
) uncomp_size);
105
break
;
106
107
}
108
109
return
(uncomp_size);
110
}
111
112
NULL
#define NULL
Definition
BaseType.h:92
CompressionType
CompressionType
Definition
Compression.h:31
LCW.H
IFF.H
__cdecl
#define __cdecl
Definition
IFF.H:44
LCW
@ LCW
Definition
IFF.H:80
NOCOMPRESS
@ NOCOMPRESS
Definition
IFF.H:76
HORIZONTAL
@ HORIZONTAL
Definition
IFF.H:79
always.h
LCW_Uncomp
int LCW_Uncomp(void const *source, void *dest, unsigned long)
Definition
lcw.cpp:75
Uncompress_Data
unsigned long __cdecl Uncompress_Data(void const *src, void *dst)
Definition
load.cpp:68
string.h
CompHeaderType
Definition
IFF.H:89
Code
Libraries
Source
WWVegas
WWLib
load.cpp
Generated by
1.13.2