DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
mathutil.hpp File Reference

Go to the source code of this file.

Classes

struct  MWGlobalDestructor
 
struct  MWCatchRecord
 
struct  MWExceptionSpecification
 
struct  OverlayHeader
 
struct  MWTypeInfo
 
struct  MWBaseClass
 
struct  MWSingleBaseClass
 

Typedefs

typedef void(* MWRuntimeObjectFunction) (void *object, int mode)
 

Enumerations

enum  InterpolateMode { INTERPOLATE_STEP = 0 , INTERPOLATE_FRACTION = 1 }
 

Functions

void __construct_array (void *array, MWRuntimeObjectFunction constructor, MWRuntimeObjectFunction destructor, unsigned int element_size, unsigned int count)
 
void * __construct_new_array (void *allocation, MWRuntimeObjectFunction constructor, MWRuntimeObjectFunction destructor, unsigned int element_size, unsigned int count)
 
void __dl (void *storage) throw ()
 
char __throw_catch_compare (const char *thrown_type, const char *caught_type, long *pointer_adjustment)
 
void unexpected__3stdFv ()
 
void terminate__3stdFv ()
 
void duhandler__3stdFv ()
 
void dthandler__3stdFv ()
 
void * __register_global_object (void *object, MWRuntimeObjectFunction destructor, MWGlobalDestructor *record)
 
void __initialize_cpp_rts (void *first, void *last, void *overlay_start, void *overlay_end)
 
char * __DecodeUnsignedNumber (char *encoded, unsigned int *value)
 
char * __DecodeSignedNumber (char *encoded, int *value)
 
void __end__catch (MWCatchRecord *record)
 
void __unexpected (void *exception_record)
 
void mwInit (int argc, const char **argv, const char **envp)
 
 STATIC_ASSERT (sizeof(OverlayHeader)==0x40)
 
void mwOverlayInit (void *overlay, int size)
 
void MWNotifyOverlayLoaded (void *address)
 
int mwBload (char *path, void *buffer)
 
int mwLoadOverlay (char *path, void *address)
 
void VectorMax (float *max, float *a, float *b)
 
void VectorMax (float *max, float *a, float *b, float *c)
 
void VectorMax (float *max, float *a, float *b, float *c, float *d)
 
void VectorMin (float *min, float *a, float *b)
 
void VectorMin (float *min, float *a, float *b, float *c, float *d)
 
void VectorMaxMin (float *max, float *min, float *a, float *b)
 
void VectorMaxMin (float *max, float *min, float *a, float *b, float *c)
 
void VectorMaxMin (float *max, float *min, float *a, float *b, float *c, float *d)
 
void PlaneNormal (float *normal, float *v0, float *v1, float *v2)
 
float DistPlanePoint (float *normal, float *on_plane, float *point)
 
float ReflectionPlane (float *normal, float *on_plane, float *point, float *reflection)
 
int IntersectionPoint_line_poly3 (float *from, float *to, float *v0, float *v1, float *v2, float *normal, float *hit)
 
int Check_Point_Poly3_XYZ (float *point, float *v0, float *v1, float *v2, float *normal)
 
float DistVector (float *vector)
 
float DistVector (float *a, float *b)
 
void MulMatrix (float(*product)[4], float(*left_matrix)[4], float(*right_matrix)[4])
 
void RotMatrixY (float(*matrix)[4], float angle_y)
 
void LookAtMatrixZ (float(*matrix)[4], float *direction)
 
void ApplyMatrixN (float(*out)[4], float(*matrix)[4], float(*in)[4], int count)
 
void VectorInterpolate (float *out, float *from, float *to, float step, int mode)
 
float AngleInterpolate (float from, float to, float step, int mode)
 
int AngleCmp (float a, float b, float tolerance)
 
float AngleLimit (float angle)
 
float rnd ()
 
float nrnd ()
 
void CreateSinTable ()
 
float Sinf (float angle)
 
float Cosf (float angle)
 
void * __dt__Q23std9exceptionFv (void **self, short flag) throw ()
 
const char * what__Q23std9exceptionCFv (const void *exception)
 
void * __dt__Q23std13bad_exceptionFv (void **self, short flag) throw ()
 
const char * what__Q23std13bad_exceptionCFv (const void *exception)
 

Variables

void(* thandler__3std )()
 
void(* uhandler__3std )()
 
MWGlobalDestructor * __global_destructor_chain
 
void(* __static_init [])()
 
void(* __static_init_end [])()
 
const unsigned char __RTTI__Q23std9exception []
 
const char BadExceptionTypeName []
 
const char ExceptionTypeName []
 
const MWTypeInfo ExceptionTypeInfo
 
const MWSingleBaseClass BadExceptionBaseClasses
 
const MWTypeInfo __RTTI__Q23std13bad_exception
 
const char ExceptionWhat []
 
const char BadExceptionWhat []
 

Detailed Description

Declares the game's vector, geometry, interpolation, and trigonometry helpers.

Definition in file mathutil.hpp.

Typedef Documentation

◆ MWRuntimeObjectFunction

typedef void(* MWRuntimeObjectFunction) (void *object, int mode)

Runs a constructor over every element of an array.

Mangled name:
__construct_array
Address:
0x1222D0
Size:
0x12C Function used by the runtime to construct or destroy one object.

Definition at line 29 of file mathutil.hpp.

Enumeration Type Documentation

◆ InterpolateMode

How VectorInterpolate and AngleInterpolate move toward their target.

Enumerator
INTERPOLATE_STEP 

A fixed step, snapping when closer.

INTERPOLATE_FRACTION 

The gap divided by the step.

Definition at line 14 of file mathutil.hpp.

Function Documentation

◆ __construct_array()

void __construct_array ( void *  array,
MWRuntimeObjectFunction  constructor,
MWRuntimeObjectFunction  destructor,
unsigned int  element_size,
unsigned int  count 
)

Runs a constructor over every element of an array.

Mangled name:
__construct_array
Address:
0x1222D0
Size:
0x12C

Definition at line 94 of file mathutil.cpp.

◆ __construct_new_array()

void * __construct_new_array ( void *  allocation,
MWRuntimeObjectFunction  constructor,
MWRuntimeObjectFunction  destructor,
unsigned int  element_size,
unsigned int  count 
)

Runs a constructor over every element of a newly allocated array.

Mangled name:
__construct_new_array
Address:
0x122400
Size:
0x14C

Definition at line 119 of file mathutil.cpp.

◆ __dl()

void __dl ( void *  storage)
throw (
)

Frees storage that operator new handed out.

Mangled name:
__dl__FPv
Address:
0x122550
Size:
0x40

Definition at line 155 of file mathutil.cpp.

◆ __throw_catch_compare()

char __throw_catch_compare ( const char *  thrown_type,
const char *  caught_type,
long *  pointer_adjustment 
)

Reports whether a thrown type matches a catch clause's type.

Mangled name:
__throw_catch_compare
Address:
0x122610
Size:
0x26C

Definition at line 213 of file mathutil.cpp.

◆ unexpected__3stdFv()

void unexpected__3stdFv ( )

Calls the handler for an exception a function did not declare.

Mangled name:
unexpected__3stdFv
Address:
0x122880
Size:
0x24

Definition at line 337 of file mathutil.cpp.

◆ terminate__3stdFv()

void terminate__3stdFv ( )

Calls the handler that ends the program after an unrecoverable exception.

Mangled name:
terminate__3stdFv
Address:
0x1228B0
Size:
0x24

Definition at line 351 of file mathutil.cpp.

◆ duhandler__3stdFv()

void duhandler__3stdFv ( )

The default unexpected-exception handler, which terminates.

Mangled name:
duhandler__3stdFv
Address:
0x1228E0
Size:
0x24

Definition at line 365 of file mathutil.cpp.

◆ dthandler__3stdFv()

void dthandler__3stdFv ( )

The default terminate handler, which stops the program.

Mangled name:
dthandler__3stdFv
Address:
0x122910
Size:
0x1C

Definition at line 379 of file mathutil.cpp.

◆ __register_global_object()

void * __register_global_object ( void *  object,
MWRuntimeObjectFunction  destructor,
MWGlobalDestructor *  record 
)

Records one global object so that its destructor runs at exit.

Mangled name:
__register_global_object
Address:
0x122930
Size:
0x24

Definition at line 393 of file mathutil.cpp.

◆ __initialize_cpp_rts()

void __initialize_cpp_rts ( void *  first,
void *  last,
void *  overlay_start,
void *  overlay_end 
)

Calls each static initializer in the table from the first pointer up to the second.

Mangled name:
__initialize_cpp_rts
Address:
0x122960
Size:
0x54

Starts the C++ runtime: its handlers and its global-object list.

Mangled name:
__initialize_cpp_rts
Address:
0x122960
Size:
0x54

Definition at line 413 of file mathutil.cpp.

◆ __DecodeUnsignedNumber()

char * __DecodeUnsignedNumber ( char *  encoded,
unsigned int *  value 
)

Reads an unsigned number out of a mangled type name.

Mangled name:
__DecodeUnsignedNumber__FPcPUi
Address:
0x1229C0
Size:
0xA0

Definition at line 436 of file mathutil.cpp.

◆ __DecodeSignedNumber()

char * __DecodeSignedNumber ( char *  encoded,
int *  value 
)

Reads a signed number out of a mangled type name.

Mangled name:
__DecodeSignedNumber__FPcPi
Address:
0x122A60
Size:
0xA0

Definition at line 472 of file mathutil.cpp.

◆ __end__catch()

void __end__catch ( MWCatchRecord *  record)

Ends a catch clause and releases the exception it caught.

Mangled name:
__end__catch
Address:
0x122B00
Size:
0x38

Definition at line 508 of file mathutil.cpp.

◆ __unexpected()

void __unexpected ( void *  exception_record)

Raises an exception a function did not declare, through the unexpected handler.

Mangled name:
__unexpected
Address:
0x122B40
Size:
0x1C0

Definition at line 544 of file mathutil.cpp.

◆ mwInit()

void mwInit ( int  argc,
const char **  argv,
const char **  envp 
)

Starts the MetroWerks runtime.

Mangled name:
mwInit
Address:
0x122DA0
Size:
0x40

Definition at line 634 of file mathutil.cpp.

◆ mwOverlayInit()

void mwOverlayInit ( void *  overlay,
int  size 
)

Starts the overlay loader and records where overlays are read to.

Mangled name:
mwOverlayInit
Address:
0x122DE0
Size:
0x8C

Definition at line 645 of file mathutil.cpp.

◆ MWNotifyOverlayLoaded()

void MWNotifyOverlayLoaded ( void *  address)

Tells the runtime that an overlay has finished loading.

Mangled name:
MWNotifyOverlayLoaded
Address:
0x122E70
Size:
0x8

Definition at line 667 of file mathutil.cpp.

◆ mwBload()

int mwBload ( char *  path,
void *  buffer 
)

Reads one overlay image off the disc.

Mangled name:
mwBload
Address:
0x122E80
Size:
0xB4

Definition at line 676 of file mathutil.cpp.

◆ mwLoadOverlay()

int mwLoadOverlay ( char *  path,
void *  address 
)

Reads an overlay into memory and gives back whether it succeeded.

Mangled name:
mwLoadOverlay
Address:
0x122F40
Size:
0x70

Definition at line 705 of file mathutil.cpp.

◆ VectorMax() [1/3]

void VectorMax ( float *  max,
float *  a,
float *  b 
)
Mangled name:
VectorMax__FPfPfPf
Address:
0x122FB0
Size:
0x18
Return type:
Not recovered.

Definition at line 723 of file mathutil.cpp.

◆ VectorMax() [2/3]

void VectorMax ( float *  max,
float *  a,
float *  b,
float *  c 
)
Mangled name:
VectorMax__FPfPfPfPf
Address:
0x122FD0
Size:
0x20
Return type:
Not recovered.

Definition at line 736 of file mathutil.cpp.

◆ VectorMax() [3/3]

void VectorMax ( float *  max,
float *  a,
float *  b,
float *  c,
float *  d 
)
Mangled name:
VectorMax__FPfPfPfPfPf
Address:
0x122FF0
Size:
0x28
Return type:
Not recovered.

One extreme of four points, which is what folds a set of bounds back into a single one.

Definition at line 752 of file mathutil.cpp.

◆ VectorMin() [1/2]

void VectorMin ( float *  min,
float *  a,
float *  b 
)
Mangled name:
VectorMin__FPfPfPf
Address:
0x123020
Size:
0x18
Return type:
Not recovered.

Definition at line 771 of file mathutil.cpp.

◆ VectorMin() [2/2]

void VectorMin ( float *  min,
float *  a,
float *  b,
float *  c,
float *  d 
)
Mangled name:
VectorMin__FPfPfPfPfPf
Address:
0x123040
Size:
0x28
Return type:
Not recovered.

Definition at line 784 of file mathutil.cpp.

◆ VectorMaxMin() [1/3]

void VectorMaxMin ( float *  max,
float *  min,
float *  a,
float *  b 
)
Mangled name:
VectorMaxMin__FPfPfPfPf
Address:
0x123070
Size:
0x20
Return type:
Not recovered.

Definition at line 803 of file mathutil.cpp.

◆ VectorMaxMin() [2/3]

void VectorMaxMin ( float *  max,
float *  min,
float *  a,
float *  b,
float *  c 
)
Mangled name:
VectorMaxMin__FPfPfPfPfPf
Address:
0x123090
Size:
0x2C
Return type:
Not recovered.

The two extremes of three or four points at once, which is what builds a bound out of corners. Both write the greater extreme through the first argument, so the outputs are in the order a CBoxVu0 holds them.

Definition at line 819 of file mathutil.cpp.

◆ VectorMaxMin() [3/3]

void VectorMaxMin ( float *  max,
float *  min,
float *  a,
float *  b,
float *  c,
float *  d 
)
Mangled name:
VectorMaxMin__FPfPfPfPfPfPf
Address:
0x1230C0
Size:
0x38
Return type:
Not recovered.

Definition at line 839 of file mathutil.cpp.

◆ PlaneNormal()

void PlaneNormal ( float *  normal,
float *  v0,
float *  v1,
float *  v2 
)
Mangled name:
PlaneNormal__FPfPfPfPf
Address:
0x123100
Size:
0x28
Return type:
Not recovered.

Definition at line 863 of file mathutil.cpp.

◆ DistPlanePoint()

float DistPlanePoint ( float *  normal,
float *  on_plane,
float *  point 
)
Mangled name:
DistPlanePoint__FPfPfPf
Address:
0x123130
Size:
0x4C

Definition at line 881 of file mathutil.cpp.

◆ ReflectionPlane()

float ReflectionPlane ( float *  normal,
float *  on_plane,
float *  point,
float *  reflection 
)
Mangled name:
ReflectionPlane__FPfPfPfPf
Address:
0x123180
Size:
0xA8

Definition at line 888 of file mathutil.cpp.

◆ IntersectionPoint_line_poly3()

int IntersectionPoint_line_poly3 ( float *  from,
float *  to,
float *  v0,
float *  v1,
float *  v2,
float *  normal,
float *  hit 
)
Mangled name:
IntersectionPoint_line_poly3__FPfPfPfPfPfPfPf
Address:
0x123230
Size:
0x144

Where a line meets a triangle, given the triangle's plane normal rather than deriving it. Answers zero when the line misses, and writes the point through the last argument otherwise. Defined beside the rest of the vector helpers, in vector.h's unit.

Definition at line 899 of file mathutil.cpp.

◆ Check_Point_Poly3_XYZ()

int Check_Point_Poly3_XYZ ( float *  point,
float *  v0,
float *  v1,
float *  v2,
float *  normal 
)
Mangled name:
Check_Point_Poly3_XYZ__FPfPfPfPfPf
Address:
0x123380
Size:
0x1DC

Definition at line 923 of file mathutil.cpp.

◆ DistVector() [1/2]

float DistVector ( float *  vector)
Mangled name:
DistVector__FPf
Address:
0x123560
Size:
0x30

The length of a vector, and the distance between two points. Declared here rather than in vector.h for the same reason as the extremes above: frame.cpp reaches for them and cannot see that header at all.

Definition at line 965 of file mathutil.cpp.

◆ DistVector() [2/2]

float DistVector ( float *  a,
float *  b 
)

Returns the distance between two positions.

Mangled name:
DistVector__FPfPf
Address:
0x123590
Size:
0x38

Definition at line 986 of file mathutil.cpp.

◆ MulMatrix()

void MulMatrix ( float(*)  product[4],
float(*)  left_matrix[4],
float(*)  right_matrix[4] 
)
Mangled name:
MulMatrix__FPA4_fPA4_fPA4_f
Address:
0x1235D0
Size:
0x78
Return type:
Not recovered.

◆ RotMatrixY()

void RotMatrixY ( float(*)  matrix[4],
float  angle_y 
)
Mangled name:
RotMatrixY__FPA4_ff
Address:
0x123650
Size:
0x74
Return type:
Not recovered.

◆ LookAtMatrixZ()

void LookAtMatrixZ ( float(*)  matrix[4],
float *  direction 
)
Mangled name:
LookAtMatrixZ__FPA4_fPf
Address:
0x1236D0
Size:
0x10C
Return type:
Not recovered.

◆ ApplyMatrixN()

void ApplyMatrixN ( float(*)  out[4],
float(*)  matrix[4],
float(*)  in[4],
int  count 
)
Mangled name:
ApplyMatrixN__FPA4_fPA4_fPA4_fi
Address:
0x1237E0
Size:
0x60
Return type:
Not recovered.

◆ VectorInterpolate()

void VectorInterpolate ( float *  out,
float *  from,
float *  to,
float  step,
int  mode 
)
Mangled name:
VectorInterpolate__FPfPfPffi
Address:
0x123840
Size:
0x18C
Return type:
Not recovered.

Definition at line 1143 of file mathutil.cpp.

◆ AngleInterpolate()

float AngleInterpolate ( float  from,
float  to,
float  step,
int  mode 
)
Mangled name:
AngleInterpolate__Ffffi
Address:
0x1239D0
Size:
0x160

Definition at line 1189 of file mathutil.cpp.

◆ AngleCmp()

int AngleCmp ( float  a,
float  b,
float  tolerance 
)
Mangled name:
AngleCmp__Ffff
Address:
0x123B30
Size:
0xA8
Return type:
Not recovered.

Definition at line 1247 of file mathutil.cpp.

◆ AngleLimit()

float AngleLimit ( float  angle)

Wraps one angle into the half turn either side of zero.

Mangled name:
AngleLimit__Ff
Address:
0x123BE0
Size:
0xD0

Definition at line 1275 of file mathutil.cpp.

◆ rnd()

float rnd ( )
Mangled name:
rnd__Fv
Address:
0x123CB0
Size:
0x3C

Definition at line 1300 of file mathutil.cpp.

◆ nrnd()

float nrnd ( )
Mangled name:
nrnd__Fv
Address:
0x123CF0
Size:
0xC0

Definition at line 1304 of file mathutil.cpp.

◆ CreateSinTable()

void CreateSinTable ( )
Mangled name:
CreateSinTable__Fv
Address:
0x123DB0
Size:
0x90
Return type:
Not recovered.

Definition at line 1308 of file mathutil.cpp.

◆ Sinf()

float Sinf ( float  angle)
Mangled name:
Sinf__Ff
Address:
0x123E40
Size:
0xB8

Definition at line 1319 of file mathutil.cpp.

◆ Cosf()

float Cosf ( float  angle)
Mangled name:
Cosf__Ff
Address:
0x123F00
Size:
0x28

Definition at line 1327 of file mathutil.cpp.

◆ __dt__Q23std9exceptionFv()

void * __dt__Q23std9exceptionFv ( void **  self,
short  flag 
)
throw (
)

Destructor of std::exception.

Mangled name:
__dt__Q23std9exceptionFv
Address:
0x122590
Size:
0x6c

Destroys a std::exception.

Mangled name:
__dt__Q23std9exceptionFv
Address:
0x122590
Size:
0x6C

Definition at line 171 of file mathutil.cpp.

◆ what__Q23std9exceptionCFv()

const char * what__Q23std9exceptionCFv ( const void *  exception)

std::exception::what.

Mangled name:
what__Q23std9exceptionCFv
Address:
0x122600
Size:
0xc

Gives a std::exception's description.

Mangled name:
what__Q23std9exceptionCFv
Address:
0x122600
Size:
0xC

Definition at line 194 of file mathutil.cpp.

◆ __dt__Q23std13bad_exceptionFv()

void * __dt__Q23std13bad_exceptionFv ( void **  self,
short  flag 
)
throw (
)

Destructor of std::bad_exception.

Mangled name:
__dt__Q23std13bad_exceptionFv
Address:
0x122D00
Size:
0x84

Destroys a std::bad_exception.

Mangled name:
__dt__Q23std13bad_exceptionFv
Address:
0x122D00
Size:
0x84

Definition at line 593 of file mathutil.cpp.

◆ what__Q23std13bad_exceptionCFv()

const char * what__Q23std13bad_exceptionCFv ( const void *  exception)

std::bad_exception::what.

Mangled name:
what__Q23std13bad_exceptionCFv
Address:
0x122D90
Size:
0xc

Gives a std::bad_exception's description.

Mangled name:
what__Q23std13bad_exceptionCFv
Address:
0x122D90
Size:
0xC

Definition at line 620 of file mathutil.cpp.

Variable Documentation

◆ thandler__3std

void(* thandler__3std) () ( )

Handler that std::terminate calls to end the program.

Definition at line 108 of file mathutil.hpp.

◆ uhandler__3std

void(* uhandler__3std) () ( )

Handler that std::unexpected calls for an exception a function did not declare.

Definition at line 113 of file mathutil.hpp.

◆ __global_destructor_chain

MWGlobalDestructor* __global_destructor_chain

Most recently registered global object, heading the list destroyed at exit.

Definition at line 118 of file mathutil.hpp.

◆ __static_init

void(* __static_init[])() ( )
extern
  • 4 more not-yet-named function(s) in this range (IDA/disassembler could not name them) First entry of the table of static initialisers the runtime calls at startup; the linker script places it.

◆ __static_init_end

void(* __static_init_end[])() ( )
extern

End of the table of static initialisers the runtime calls at startup; the linker script places it.

◆ __RTTI__Q23std9exception

const unsigned char __RTTI__Q23std9exception[]
extern

Run-time type information record of std::exception.

◆ BadExceptionTypeName

const char BadExceptionTypeName[]
extern

Qualified name of std::bad_exception.

Definition at line 574 of file mathutil.cpp.

◆ ExceptionTypeName

const char ExceptionTypeName[]
extern

Qualified name of std::exception.

Definition at line 575 of file mathutil.cpp.

◆ ExceptionTypeInfo

const MWTypeInfo ExceptionTypeInfo
extern

The runtime's own run-time type information record of std::exception.

Definition at line 576 of file mathutil.cpp.

◆ BadExceptionBaseClasses

const MWSingleBaseClass BadExceptionBaseClasses
extern

The base classes of std::bad_exception: std::exception alone.

Definition at line 577 of file mathutil.cpp.

◆ __RTTI__Q23std13bad_exception

const MWTypeInfo __RTTI__Q23std13bad_exception
extern

Run-time type information record of std::bad_exception.

Definition at line 581 of file mathutil.cpp.

◆ ExceptionWhat

const char ExceptionWhat[]
extern

What std::exception::what returns.

Definition at line 80 of file mathutil.cpp.

◆ BadExceptionWhat

const char BadExceptionWhat[]
extern

What std::bad_exception::what returns.

Definition at line 582 of file mathutil.cpp.