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

Walks of the track model, the blocks of display data allocated afresh each frame, and the sort the game uses, which follows the qsort() of the Microsoft C runtime. More...

#include <PR/gbi.h>
#include <PR/ultratypes.h>
#include "common/track.h"
Include dependency graph for util.h:

Go to the source code of this file.

Classes

struct  DisplayListBlock
 A block of eight display list commands. More...

Macros

#define FRAME_DISPLAY_LIST_BLOCKS   256
#define FRAME_HILITE_BLOCKS   20
#define FRAME_LIGHT_BLOCKS   20

Typedefs

typedef s32(* CompareFunc) (const void *a, const void *b)
 A routine that orders two elements as strcmp() orders strings.
typedef void(* SwapFunc) (void *a, void *b, u32 size)
 A routine that exchanges two elements of a size.

Functions

void MarkTrackSections (TrackSection *section)
 Mark every section of a tree of the route as visited, skipping sections already visited and alternate branches.
void UnmarkTrackSections (TrackSection *section)
 Clear the visited mark of every section of a tree of the route.
void PrepareTrackSections (void)
 Adjust the route of the loaded track for the current track.
DisplayListBlock * AllocDisplayListBlock (void)
 Allocate a block of display list commands for the current frame.
Hilite * AllocHiliteBlock (void)
 Allocate a block of highlight coordinates for the current frame.
LookAt * AllocLightBlock (void)
 Allocate a block of reflection directions for the current frame.
void ResetFrameBlocks (void)
 Start the allocations of a new frame.
void QuickSort (void *base, u32 count, u32 size, CompareFunc compare)
 Sort count elements of a size with a comparison.
void ShortSort (u8 *lo, u8 *hi, u32 size, CompareFunc compare, SwapFunc swap)
 Sort the elements from lo to hi by selection, for the short ranges of QuickSort().
void ExchangeByteBuffers (u8 *a, u8 *b, u32 size)
 Exchange two buffers byte by byte.
void ExchangeHalfwordBuffers (s16 *a, s16 *b, u32 size)
 Exchange two buffers halfword by halfword.
void ExchangeWordBuffers (u32 *a, u32 *b, u32 size)
 Exchange two buffers word by word.

Variables

DisplayListBlock g_aDisplayListBlocks [2][FRAME_DISPLAY_LIST_BLOCKS+1]
 The display list blocks of the two frames.
Hilite g_aHiliteBlocks [2][FRAME_HILITE_BLOCKS+1]
 The highlight blocks of the two frames and one spare block per frame.
LookAt g_aLightBlocks [2][FRAME_LIGHT_BLOCKS+1]
 The light blocks of the two frames and one spare block per frame.
s32 g_dwDisplayListBlockCount
 The blocks the current frame has allocated.
s32 g_dwHiliteBlockCount
 The highlight blocks allocated in the current frame.
s32 g_dwLightBlockCount
 The light blocks allocated in the current frame.
s32 g_dwFrameBufferIndex
 The frame buffer the current frame draws into.

Detailed Description

Walks of the track model, the blocks of display data allocated afresh each frame, and the sort the game uses, which follows the qsort() of the Microsoft C runtime.

Macro Definition Documentation

◆ FRAME_DISPLAY_LIST_BLOCKS

#define FRAME_DISPLAY_LIST_BLOCKS   256

The display list blocks of a frame.

◆ FRAME_HILITE_BLOCKS

#define FRAME_HILITE_BLOCKS   20

The specular highlight blocks of a frame.

◆ FRAME_LIGHT_BLOCKS

#define FRAME_LIGHT_BLOCKS   20

The light blocks of a frame.

Typedef Documentation

◆ CompareFunc

typedef s32(* CompareFunc) (const void *a, const void *b)

A routine that orders two elements as strcmp() orders strings.

◆ SwapFunc

typedef void(* SwapFunc) (void *a, void *b, u32 size)

A routine that exchanges two elements of a size.

Function Documentation

◆ MarkTrackSections()

void MarkTrackSections ( TrackSection * section)

Mark every section of a tree of the route as visited, skipping sections already visited and alternate branches.

On the strip mine and its mirrored version, a section whose grid starts at row 2 starts at row 0.

Parameters
sectionThe first section of the tree.
Ghidra address:
USA: 0x80255ba0
Ghidra address:
Asia: 0x802556F0
Ghidra address:
EUR: 0x80257170
Ghidra address:
JPN: 0x80256b00
Ghidra address:
BRD3D: 0x10061660
Ghidra address:
BRGlide: 0x1005a6e0

◆ UnmarkTrackSections()

void UnmarkTrackSections ( TrackSection * section)

Clear the visited mark of every section of a tree of the route.

Parameters
sectionThe first section of the tree.
Ghidra address:
USA: 0x80255c50
Ghidra address:
Asia: 0x802557A0
Ghidra address:
EUR: 0x80257220
Ghidra address:
JPN: 0x80256bb0
Ghidra address:
BRD3D: 0x100616c0
Ghidra address:
BRGlide: 0x1005a740

◆ PrepareTrackSections()

void PrepareTrackSections ( void )

Adjust the route of the loaded track for the current track.

Ghidra address:
USA: 0x80255ca0
Ghidra address:
Asia: 0x802557F0
Ghidra address:
EUR: 0x80257270
Ghidra address:
JPN: 0x80256c00
Ghidra address:
BRD3D: 0x10061700
Ghidra address:
BRGlide: 0x1005a780

◆ AllocDisplayListBlock()

DisplayListBlock * AllocDisplayListBlock ( void )

Allocate a block of display list commands for the current frame.

Returns
The block, or the spare block after the last once every block is taken.
Ghidra address:
USA: 0x80255cd0
Ghidra address:
Asia: 0x80255820
Ghidra address:
EUR: 0x802572a0
Ghidra address:
JPN: 0x80256c30
Ghidra address:
BRD3D: 0x10069490
Ghidra address:
BRGlide: 0x10062500

◆ AllocHiliteBlock()

Hilite * AllocHiliteBlock ( void )

Allocate a block of highlight coordinates for the current frame.

Returns
The block, or the spare block after the last once every block is taken.
Ghidra address:
USA: 0x80255d4c
Ghidra address:
Asia: 0x8025589C
Ghidra address:
EUR: 0x8025731c
Ghidra address:
JPN: 0x80256cac
Ghidra address:
BRD3D: 0x100694e0
Ghidra address:
BRGlide: 0x10062550

◆ AllocLightBlock()

LookAt * AllocLightBlock ( void )

Allocate a block of reflection directions for the current frame.

Returns
The block, or the spare block after the last once every block is taken.
Ghidra address:
USA: 0x80255dd8
Ghidra address:
Asia: 0x80255928
Ghidra address:
EUR: 0x802573a8
Ghidra address:
JPN: 0x80256d38
Ghidra address:
BRD3D: 0x10069530
Ghidra address:
BRGlide: 0x100625a0

◆ ResetFrameBlocks()

void ResetFrameBlocks ( void )

Start the allocations of a new frame.

Ghidra address:
USA: 0x80255e64
Ghidra address:
Asia: 0x802559B4
Ghidra address:
EUR: 0x80257434
Ghidra address:
JPN: 0x80256dc4
Ghidra address:
BRD3D: 0x10069580
Ghidra address:
BRGlide: 0x100625f0

◆ QuickSort()

void QuickSort ( void * base,
u32 count,
u32 size,
CompareFunc compare )

Sort count elements of a size with a comparison.

Equal elements end in the order the qsort() of the C runtime of the PC release gives them, and the SDL game sorts with this routine where the PC release calls that qsort().

Parameters
baseThe first element.
countThe number of elements.
sizeThe size of each element, in bytes.
compareThe comparison that orders two elements.
Ghidra address:
USA: 0x80255e80
Ghidra address:
Asia: 0x802559D0
Ghidra address:
EUR: 0x80257450
Ghidra address:
JPN: 0x80256de0

◆ ShortSort()

void ShortSort ( u8 * lo,
u8 * hi,
u32 size,
CompareFunc compare,
SwapFunc swap )

Sort the elements from lo to hi by selection, for the short ranges of QuickSort().

Parameters
loThe first element.
hiThe last element, included in the sort.
sizeThe size of each element, in bytes.
compareThe comparison that orders two elements.
swapThe routine that exchanges two elements.
Ghidra address:
USA: 0x802560dc
Ghidra address:
Asia: 0x80255C2C
Ghidra address:
EUR: 0x802576ac
Ghidra address:
JPN: 0x8025703c

◆ ExchangeByteBuffers()

void ExchangeByteBuffers ( u8 * a,
u8 * b,
u32 size )

Exchange two buffers byte by byte.

Parameters
aThe first buffer.
bThe second buffer.
sizeThe size of each buffer, in bytes.
Ghidra address:
USA: 0x802561a8
Ghidra address:
Asia: 0x80255CF8
Ghidra address:
EUR: 0x80257778
Ghidra address:
JPN: 0x80257108

◆ ExchangeHalfwordBuffers()

void ExchangeHalfwordBuffers ( s16 * a,
s16 * b,
u32 size )

Exchange two buffers halfword by halfword.

Parameters
aThe first buffer.
bThe second buffer.
sizeThe size of each buffer, in bytes.
Ghidra address:
USA: 0x802561e4
Ghidra address:
Asia: 0x80255D34
Ghidra address:
EUR: 0x802577b4
Ghidra address:
JPN: 0x80257144

◆ ExchangeWordBuffers()

void ExchangeWordBuffers ( u32 * a,
u32 * b,
u32 size )

Exchange two buffers word by word.

Parameters
aThe first buffer.
bThe second buffer.
sizeThe size of each buffer, in bytes.
Ghidra address:
USA: 0x80256228
Ghidra address:
Asia: 0x80255D78
Ghidra address:
EUR: 0x802577f8
Ghidra address:
JPN: 0x80257188

Variable Documentation

◆ g_aDisplayListBlocks

DisplayListBlock g_aDisplayListBlocks[2][FRAME_DISPLAY_LIST_BLOCKS+1]
extern

The display list blocks of the two frames.

The entry after the last of each frame takes every allocation beyond it.

Ghidra address:
USA: 0x8036ae50
Ghidra address:
Asia: 0x8036A900
Ghidra address:
EUR: 0x8036d350
Ghidra address:
JPN: 0x8036bfc0
Ghidra address:
BRD3D: 0x10af9bc0
Ghidra address:
BRGlide: 0x10b1cf20

◆ g_aHiliteBlocks

Hilite g_aHiliteBlocks[2][FRAME_HILITE_BLOCKS+1]
extern

The highlight blocks of the two frames and one spare block per frame.

Ghidra address:
USA: 0x80372ed0
Ghidra address:
Asia: 0x80372980
Ghidra address:
EUR: 0x803753d0
Ghidra address:
JPN: 0x80374040
Ghidra address:
BRD3D: 0x10b02190
Ghidra address:
BRGlide: 0x10b254f0

◆ g_aLightBlocks

LookAt g_aLightBlocks[2][FRAME_LIGHT_BLOCKS+1]
extern

The light blocks of the two frames and one spare block per frame.

Ghidra address:
USA: 0x80373170
Ghidra address:
Asia: 0x80372C20
Ghidra address:
EUR: 0x80375670
Ghidra address:
JPN: 0x803742e0
Ghidra address:
BRD3D: 0x10b01c50
Ghidra address:
BRGlide: 0x10b24fb0

◆ g_dwDisplayListBlockCount

s32 g_dwDisplayListBlockCount
extern

The blocks the current frame has allocated.

Ghidra address:
USA: 0x8028dfb0
Ghidra address:
Asia: 0x8028DB00
Ghidra address:
EUR: 0x80290770
Ghidra address:
JPN: 0x80290210
Ghidra address:
BRD3D: 0x10b01c40
Ghidra address:
BRGlide: 0x10b24fa0

◆ g_dwHiliteBlockCount

s32 g_dwHiliteBlockCount
extern

The highlight blocks allocated in the current frame.

Ghidra address:
USA: 0x8028dfb4
Ghidra address:
Asia: 0x8028DB04
Ghidra address:
EUR: 0x80290774
Ghidra address:
JPN: 0x80290214
Ghidra address:
BRD3D: 0x10b01c48
Ghidra address:
BRGlide: 0x10b24fa8

◆ g_dwLightBlockCount

s32 g_dwLightBlockCount
extern

The light blocks allocated in the current frame.

Ghidra address:
USA: 0x8028dfb8
Ghidra address:
Asia: 0x8028DB08
Ghidra address:
EUR: 0x80290778
Ghidra address:
JPN: 0x80290218
Ghidra address:
BRD3D: 0x10b01c44
Ghidra address:
BRGlide: 0x10b24fa4

◆ g_dwFrameBufferIndex

s32 g_dwFrameBufferIndex
extern

The frame buffer the current frame draws into.

Ghidra address:
USA: 0x8028a85c
Ghidra address:
Asia: 0x8028A3AC
Ghidra address:
EUR: 0x8028ca5c
Ghidra address:
JPN: 0x8028c52c
Ghidra address:
BRD3D: 0x106c65ec
Ghidra address:
BRGlide: 0x106ed67c