coastline 0.0.4
Loading...
Searching...
No Matches
relocation.h File Reference

The byte swapping and the relocation of the pointers of the data the game loads from files. More...

#include "common/gbicommand.h"
#include "common/render.h"
#include "common/track.h"
#include "common/vecmath.h"
Include dependency graph for relocation.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RELOCATED_POINTER_COUNT   0x800
 The most entries of g_apRelocatedPointers.

Functions

void ByteSwapAndRelocateDisplayList (GbiCommand *pCommands)
 Byte-swap a display list through its end command and relocate texture and vertex pointers.
void ByteSwapTextureVariantTable (TextureAnimation *pAnimation)
 The source table used when copying track texture images during relocation.
void ByteSwapAndRelocateTextureDescriptor (ModelTexture *pTexture)
 Relocate a texture's image and palette pointers and byte-swap its dimensions and flags.
void ByteSwapTextureDescriptorArray (ModelTexture *pTextures, int nCount)
 Apply texture descriptor relocation to nCount consecutive textures.
void AddPointerToRelocatedList (void *pPointer)
 Add a pointer to g_apRelocatedPointers while it has room.
int IsPointerInRelocatedList (void *pPointer)
 Report whether a pointer was relocated already.
void RelocatePointerValue (unsigned *pdwPointer)
 Move a pointer from g_dwOldBaseAddress to g_dwNewBaseAddress.
void ByteSwapArray16 (unsigned short *pData, int nCount)
 Swap the two bytes of each of a run of halfwords.
void ByteSwapFourShorts (TrackSurface *pData)
 Swap the two bytes of each of the four halfwords of a triangle of the track.
void ByteSwapShortQuadArray (TrackSurface *pData, int nCount)
 Swap the bytes of each halfword of a run of groups of four halfwords.
void ByteSwap3DWords (Vec3f *pData)
 Reverse the four bytes of each component of a vector.
void ByteSwap3DWordsArray (Vec3f *pData, int nCount)
 Reverse the bytes of each component of a run of vectors.
void ResetVertexConversionCache (void)
 Empty the cache of converted vertices and the count of relocated pointers.
void SetPointerRelocationBase (unsigned dwOldBase, unsigned dwNewBase)
 Empty the cache of converted vertices and record the address the pointers to relocate are based at and the address they move to.
void SetCopyTextureDataOnRelocate (int bCopy)
 Set whether the data of a texture is copied when its pointers are relocated.

Variables

int g_dwRelocatedPointerCount
 The number of pointers relocated.
void * g_apRelocatedPointers [RELOCATED_POINTER_COUNT]
 The pointers relocated, g_dwRelocatedPointerCount of them.

Detailed Description

The byte swapping and the relocation of the pointers of the data the game loads from files.

Macro Definition Documentation

◆ RELOCATED_POINTER_COUNT

#define RELOCATED_POINTER_COUNT   0x800

The most entries of g_apRelocatedPointers.

Function Documentation

◆ ByteSwapAndRelocateDisplayList()

void ByteSwapAndRelocateDisplayList ( GbiCommand * pCommands)

Byte-swap a display list through its end command and relocate texture and vertex pointers.

Parameters
pCommandsThe loaded display list, or NULL.
Ghidra address:
BRD3D: 0x1002bf80
Ghidra address:
BRGlide: 0x10019040

◆ ByteSwapTextureVariantTable()

void ByteSwapTextureVariantTable ( TextureAnimation * pAnimation)

The source table used when copying track texture images during relocation.

Ghidra address:
BRD3D: 0x10690bec
Ghidra address:
BRGlide: 0x106b7c7c Byte-swap animation frame offsets and times in a loaded texture variant table.
Parameters
pAnimationThe table, or NULL.
Ghidra address:
BRD3D: 0x1002bc90
Ghidra address:
BRGlide: 0x10018d50

◆ ByteSwapAndRelocateTextureDescriptor()

void ByteSwapAndRelocateTextureDescriptor ( ModelTexture * pTexture)

Relocate a texture's image and palette pointers and byte-swap its dimensions and flags.

Parameters
pTextureThe loaded texture descriptor.
Ghidra address:
BRD3D: 0x1002baa0
Ghidra address:
BRGlide: 0x10018b60

◆ ByteSwapTextureDescriptorArray()

void ByteSwapTextureDescriptorArray ( ModelTexture * pTextures,
int nCount )

Apply texture descriptor relocation to nCount consecutive textures.

Parameters
pTexturesThe first loaded texture descriptor.
nCountThe number of descriptors.
Ghidra address:
BRD3D: 0x1002ba80
Ghidra address:
BRGlide: 0x10018b40

◆ AddPointerToRelocatedList()

void AddPointerToRelocatedList ( void * pPointer)

Add a pointer to g_apRelocatedPointers while it has room.

Parameters
pPointerThe pointer.
Ghidra address:
BRD3D: 0x1002c1f0
Ghidra address:
BRGlide: 0x100192b0

◆ IsPointerInRelocatedList()

int IsPointerInRelocatedList ( void * pPointer)

Report whether a pointer was relocated already.

Parameters
pPointerThe pointer.
Returns
Whether g_apRelocatedPointers includes it, and true for a null pointer.
Ghidra address:
BRD3D: 0x1002bf40
Ghidra address:
BRGlide: 0x10019000

◆ RelocatePointerValue()

void RelocatePointerValue ( unsigned * pdwPointer)

Move a pointer from g_dwOldBaseAddress to g_dwNewBaseAddress.

A pointer below the old base becomes null, and a null pointer is left null.

Parameters
pdwPointerThe pointer, as a word.
Ghidra address:
BRD3D: 0x1002b970
Ghidra address:
BRGlide: 0x100189e0

◆ ByteSwapArray16()

void ByteSwapArray16 ( unsigned short * pData,
int nCount )

Swap the two bytes of each of a run of halfwords.

Parameters
pDataThe halfwords.
nCountThe number of halfwords.
Ghidra address:
BRD3D: 0x1002b9e0
Ghidra address:
BRGlide: 0x10018a50

◆ ByteSwapFourShorts()

void ByteSwapFourShorts ( TrackSurface * pData)

Swap the two bytes of each of the four halfwords of a triangle of the track.

Parameters
pDataThe triangle.
Ghidra address:
BRD3D: 0x1002ba20
Ghidra address:
BRGlide: 0x10018a90

◆ ByteSwapShortQuadArray()

void ByteSwapShortQuadArray ( TrackSurface * pData,
int nCount )

Swap the bytes of each halfword of a run of groups of four halfwords.

Parameters
pDataThe groups.
nCountThe number of groups.
Ghidra address:
BRD3D: 0x1002ba00
Ghidra address:
BRGlide: 0x10018a70

◆ ByteSwap3DWords()

void ByteSwap3DWords ( Vec3f * pData)

Reverse the four bytes of each component of a vector.

Parameters
pDataThe vector.
Ghidra address:
BRD3D: 0x100383c0
Ghidra address:
BRGlide: 0x10018af0

◆ ByteSwap3DWordsArray()

void ByteSwap3DWordsArray ( Vec3f * pData,
int nCount )

Reverse the bytes of each component of a run of vectors.

Parameters
pDataThe vectors.
nCountThe number of vectors.
Ghidra address:
BRD3D: 0x1002ba60
Ghidra address:
BRGlide: 0x10018ad0

◆ ResetVertexConversionCache()

void ResetVertexConversionCache ( void )

Empty the cache of converted vertices and the count of relocated pointers.

Ghidra address:
BRD3D: 0x1002b9c0
Ghidra address:
BRGlide: 0x10018a30

◆ SetPointerRelocationBase()

void SetPointerRelocationBase ( unsigned dwOldBase,
unsigned dwNewBase )

Empty the cache of converted vertices and record the address the pointers to relocate are based at and the address they move to.

Parameters
dwOldBaseThe address the pointers are based at.
dwNewBaseThe address the pointers move to.
Ghidra address:
BRD3D: 0x1002b9a0
Ghidra address:
BRGlide: 0x10018a10

◆ SetCopyTextureDataOnRelocate()

void SetCopyTextureDataOnRelocate ( int bCopy)

Set whether the data of a texture is copied when its pointers are relocated.

Parameters
bCopyWhether to copy.
Ghidra address:
BRD3D: 0x1002b9d0
Ghidra address:
BRGlide: 0x10018a40

Variable Documentation

◆ g_dwRelocatedPointerCount

int g_dwRelocatedPointerCount
extern

The number of pointers relocated.

Ghidra address:
BRD3D: 0x1067b548
Ghidra address:
BRGlide: 0x105b76f0

◆ g_apRelocatedPointers

void* g_apRelocatedPointers[RELOCATED_POINTER_COUNT]
extern

The pointers relocated, g_dwRelocatedPointerCount of them.

Ghidra address:
BRD3D: 0x1067b550
Ghidra address:
BRGlide: 0x105b76f8