[ Home ]

mac.c File Reference

This module is used to extract data from the Macintosh version of Wolfenstein 3-D. More...

#include <stdio.h>
#include <string.h>
#include "mac.h"
#include "../../common/platform.h"
#include "../../common/common_utils.h"
#include "../../loaders/tga.h"
#include "../../memory/memory.h"
#include "../../string/wtstring.h"
#include "../../filesys/file.h"

Include dependency graph for mac.c:


Data Structures

struct  spriteRun

Functions

PRIVATE W8 * getResourceBlock (W32 offset, W32 length, W32 *glen)
 Get block of resource data.
PRIVATE void Decode_LZSS (W8 *dst, const W8 *src, W32 length)
 Decodes a block of data that was encoded with LZSS.
PRIVATE void ConvertPaletteToRGB (W8 *dst, W8 *src, W32 length, W8 *palette)
 Convert 256 palette data to RGB.
PRIVATE void setPalette (W32 offset)
 Set global palette.
PRIVATE void DecodeBJMapImage (W32 offset, W32 length)
 Decodes BJ map image and writes data to tga file.
PRIVATE void DecodeBJIntermImages (W32 offset, W32 length)
 Decodes BJ intermission images and writes data to tga file.
PRIVATE void DecodeScreen (W32 offset, W32 length, const char *filename)
 Decode screen from Macintosh resource fork.
PRIVATE void decodeScreens (void)
 Decodes art data from Macintosh resource fork.
PRIVATE W8 * obverseWall (const W8 *src, W16 width, W16 height)
 Realign wall image.
PRIVATE void DecodeWall (W32 offset, W32 length, W32 *retval, const char *filename)
 Decode then save wall data as TARGA image file.
PRIVATE void decodeWalls (void)
 Extract wall image data from resource fork.
PRIVATE void DecodeSprite (W32 offset, W32 length, W32 *retval, const char *filename)
 Decode then save sprite data as TARGA image file.
PRIVATE void decodeSprites (void)
 Extract sprites from resource fork.
PRIVATE W8 * DecodeItem (W8 *data, W8 *pal)
 Convert item data into RGB raw data.
PRIVATE void decodeItems (void)
 Extract pic images from resource file.
PRIVATE void decodeMidi (void)
 Extract midi files from resource fork.
PRIVATE wtBoolean parseMacBinaryHead (void)
 Parse mac binary header.
PUBLIC void Macintosh_Decoder (void)
 Interface to Macintosh data extractor.
PUBLIC void wolf3do_decoder (void)
 Interface to Wolfenstein 3DO data extractor.

Variables

PRIVATE W32 DATAFORKLENGTH = 105754L
PRIVATE W32 RESFORKLENGTH = 2424697L
PRIVATE W32 MACPAL = 898370L
PRIVATE W32 IDPAL = 899142L
PRIVATE W32 GAMEPAL = 946811L
PRIVATE W32 INTERPAL = 997211L
PRIVATE W32 YUMMYPAL = 1011345L
PRIVATE W32 TITLEPAL = 2235007L
PRIVATE W32 PALETTE_SIZE = 768
PRIVATE const char * MAC_FEXT = "*.MAC"
PRIVATE const char * MACBINFILENAME = "Wolfenstein 3D"
PRIVATE const char * FILETYPECREATOR = "APPLWOLF"
PRIVATE W8 * macPalette
PRIVATE FILE * fResHandle

Detailed Description

This module is used to extract data from the Macintosh version of Wolfenstein 3-D.

Author:
Michael Liebscher
Date:
2004-2005
Note:
Portion of this code was derived from code that was originally written by Id Software, Inc., Bill Heineman and Chris DeSalvo.

Function Documentation

PRIVATE void ConvertPaletteToRGB ( W8 *  dst,
W8 *  src,
W32  length,
W8 *  palette 
)

Convert 256 palette data to RGB.

Parameters:
[in,out] dst Destination buffer to convert to.
[in] src 256 palette data.
[in] length Length of source data.
[in] palette Pointer to 256*3 array.
Returns:
Nothing.

Here is the caller graph for this function:

PRIVATE void Decode_LZSS ( W8 *  dst,
const W8 *  src,
W32  length 
)

Decodes a block of data that was encoded with LZSS.

Parameters:
[in,out] dst Buffer to hold uncompressed data.
[in] src Compressed data block.
[in] Length Length of source data block in bytes.
Returns:
Nothing.

Here is the caller graph for this function:

PRIVATE void DecodeBJIntermImages ( W32  offset,
W32  length 
)

Decodes BJ intermission images and writes data to tga file.

Parameters:
[in] offset Offset in bytes the resource block.
[in] length Length of encoded data in bytes.
Returns:
Nothing.

Here is the call graph for this function:

Here is the caller graph for this function:

PRIVATE void DecodeBJMapImage ( W32  offset,
W32  length 
)

Decodes BJ map image and writes data to tga file.

Parameters:
[in] offset Offset in bytes the resource block.
[in] length Length of encoded data in bytes.
Returns:
Nothing.

Here is the call graph for this function:

Here is the caller graph for this function:

PRIVATE W8* DecodeItem ( W8 *  data,
W8 *  pal 
)

Convert item data into RGB raw data.

Parameters:
[in] data data chunk to decode.
[in] pal palette.
Returns:
On success pointer to RGB data, otherwise NULL.
Note:
src and dest can point to the same memory block.

Here is the caller graph for this function:

PRIVATE void DecodeScreen ( W32  offset,
W32  length,
const char *  filename 
)

Decode screen from Macintosh resource fork.

Parameters:
[in] offset Offset in bytes the resource block.
[in] length Length of encoded data in bytes.
[in] filename Name of file to save as.
Returns:
Nothing.

Here is the call graph for this function:

Here is the caller graph for this function:

PRIVATE void DecodeSprite ( W32  offset,
W32  length,
W32 *  retval,
const char *  filename 
)

Decode then save sprite data as TARGA image file.

Parameters:
[in] offset Offset from the start of the resource file in bytes.
[in] length Length of data block in bytes.
[out] retval Length of next data block in bytes.
[in] filename Name of file to save as.
Returns:
Nothing.

Here is the call graph for this function:

Here is the caller graph for this function:

PRIVATE void DecodeWall ( W32  offset,
W32  length,
W32 *  retval,
const char *  filename 
)

Decode then save wall data as TARGA image file.

Parameters:
[in] offset Offset from the start of the resource file in bytes.
[in] length Length of data in bytes.
[out] retval Length of next block in bytes.
[in] filename Name of file to save as.
Returns:
Nothing.

Here is the call graph for this function:

Here is the caller graph for this function:

PRIVATE W8* getResourceBlock ( W32  offset,
W32  length,
W32 *  glen 
)

Get block of resource data.

Parameters:
[in] offset Number of bytes from start of file.
[in] length Length of resource block.
[in] glen Next four bytes after block.
Returns:
NULL on error, otherwise pointer to block of memory.
Note:
Caller is responsible for freeing memory block.

Here is the caller graph for this function:

PRIVATE W8* obverseWall ( const W8 *  src,
W16  width,
W16  height 
)

Realign wall image.

Parameters:
[in] src Source data.
[in] width Width of wall image in pixels.
[in] height Height of wall image in pixels.
Returns:
NULL on error, otherwise pointer to memory block with realigned wall image data.
Note:
Caller is responsible for freeing returned memory block.

Here is the caller graph for this function:

PRIVATE wtBoolean parseMacBinaryHead ( void   ) 

Parse mac binary header.

Returns:
Returns true if this is Wolfenstein Mac binary file, otherwise false.

Here is the caller graph for this function:

PRIVATE void setPalette ( W32  offset  ) 

Set global palette.

Parameters:
[in] offset Offset of palette in resource file.
Returns:
Nothing.

Here is the call graph for this function:

Here is the caller graph for this function: