mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-04 15:04:31 +00:00
Experiment: remove global.h dependency from sys_math, sys_math3d, z_lib (#1956)
* split sys_math, sys_math3d, z_lib from global.h * suggestions * forgot this * more math stuff * nit fix * re-add ichain.h * resolve tharo's comments
This commit is contained in:
parent
06bbdf88f1
commit
8d83727429
33 changed files with 289 additions and 220 deletions
|
@ -1,4 +1,4 @@
|
|||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
/**
|
||||
* memcpy: copies `len` bytes from memory starting at `src` to memory starting at `dest`. Expects the memory
|
||||
|
|
|
@ -48,9 +48,9 @@
|
|||
// just above (the exact upper bound depends on the block numbers assigned to
|
||||
// extern variables declared in headers).
|
||||
#if OOT_DEBUG
|
||||
#pragma increment_block_number 20
|
||||
#pragma increment_block_number 0
|
||||
#else
|
||||
#pragma increment_block_number 25
|
||||
#pragma increment_block_number 20
|
||||
#endif
|
||||
|
||||
void FaultDrawer_Init(void);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
/**
|
||||
* Computes one `x` modulo `y` for floats.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "z64math.h"
|
||||
#include "macros.h"
|
||||
|
||||
s32 gUseAtanContFrac;
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
*
|
||||
* @note Original name: qrand.c
|
||||
*/
|
||||
#include "ultra64.h"
|
||||
#include "rand.h"
|
||||
|
||||
#define RAND_MULTIPLIER 1664525
|
||||
#define RAND_INCREMENT 1013904223
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "global.h"
|
||||
#include "sys_math.h"
|
||||
|
||||
f32 sFactorialTbl[] = { 1.0f, 1.0f, 2.0f, 6.0f, 24.0f, 120.0f, 720.0f,
|
||||
5040.0f, 40320.0f, 362880.0f, 3628800.0f, 39916800.0f, 479001600.0f };
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "z_lib.h"
|
||||
#include "z64math.h"
|
||||
#include "terminal.h"
|
||||
#include "macros.h"
|
||||
#include "sys_math3d.h"
|
||||
|
||||
// For retail BSS ordering, the block number of cbf in Math3D_CylVsCylOverlapCenterDist
|
||||
// must be 0.
|
||||
#pragma increment_block_number 187
|
||||
#pragma increment_block_number 114
|
||||
|
||||
s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB,
|
||||
Vec3f* lineAClosestToB, Vec3f* lineBClosestToA);
|
||||
|
@ -2147,11 +2151,3 @@ s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
void Math3D_DrawSphere(PlayState* play, Sphere16* sph) {
|
||||
}
|
||||
|
||||
void Math3D_DrawCylinder(PlayState* play, Cylinder16* cyl) {
|
||||
}
|
||||
#endif
|
||||
|
|
7
src/code/sys_math3d_draw.c
Normal file
7
src/code/sys_math3d_draw.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "z64.h"
|
||||
|
||||
void Math3D_DrawSphere(PlayState* play, Sphere16* sph) {
|
||||
}
|
||||
|
||||
void Math3D_DrawCylinder(PlayState* play, Cylinder16* cyl) {
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "z64math.h"
|
||||
#include "macros.h"
|
||||
|
||||
static u16 sAtan2Tbl[] = {
|
||||
0x0000, 0x000A, 0x0014, 0x001F, 0x0029, 0x0033, 0x003D, 0x0047, 0x0051, 0x005C, 0x0066, 0x0070, 0x007A, 0x0084,
|
||||
|
|
|
@ -2360,9 +2360,6 @@ void CollisionCheck_ATTrisVsACTris(PlayState* play, CollisionCheckContext* colCh
|
|||
|
||||
#if OOT_DEBUG
|
||||
static s8 sBssDummy7;
|
||||
static s8 sBssDummy8;
|
||||
static s8 sBssDummy9;
|
||||
static s8 sBssDummy10;
|
||||
#endif
|
||||
|
||||
void CollisionCheck_ATTrisVsACQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol,
|
||||
|
@ -3329,12 +3326,10 @@ void Collider_SetTrisDim(PlayState* play, ColliderTris* tris, s32 elemIndex, Col
|
|||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
// Due to an unknown reason, bss ordering changed between the 2 static Vec3f variables in the function below.
|
||||
// In order to reproduce this behavior, we need a specific number of bss variables in the file before that point.
|
||||
// For this, we introduce a certain amount of dummy variables throughout the file, which we fit inside padding added
|
||||
// by the compiler between structs like TriNorm and/or Vec3f, so they don't take space in bss.
|
||||
static s8 sBssDummy11;
|
||||
static s8 sBssDummy12;
|
||||
// The two static Vec3f variables in the function below cross a block index rollover, causing a bss order swap.
|
||||
//! In order to replicate this behavior, we declare a certain amount of sBssDummy variables throughout the file, which
|
||||
//! we fit inside padding added by the compiler between structs like TriNorm and/or Vec3f, so they don't take space in
|
||||
//! bss.
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -215,7 +215,7 @@ s16 sSunDepthTestY;
|
|||
// These variables could be moved farther down in the file to reduce the amount
|
||||
// of block number padding here, but currently this causes BSS ordering issues
|
||||
// for debug.
|
||||
#pragma increment_block_number 230
|
||||
#pragma increment_block_number 227
|
||||
|
||||
LightNode* sNGameOverLightNode;
|
||||
LightInfo sNGameOverLightInfo;
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "z_lib.h"
|
||||
#include "ichain.h"
|
||||
#include "regs.h"
|
||||
#include "macros.h"
|
||||
#include "sys_math.h"
|
||||
#include "rand.h"
|
||||
#include "sfx.h"
|
||||
|
||||
/**
|
||||
* memset: sets `len` bytes to `val` starting at address `dest`.
|
||||
|
@ -334,7 +341,7 @@ void (*sInitChainHandlers[])(u8* ptr, InitChainEntry* ichain) = {
|
|||
IChain_Apply_Vec3f, IChain_Apply_Vec3fdiv1000, IChain_Apply_Vec3s,
|
||||
};
|
||||
|
||||
void Actor_ProcessInitChain(Actor* actor, InitChainEntry* ichain) {
|
||||
void Actor_ProcessInitChain(struct Actor* actor, InitChainEntry* ichain) {
|
||||
do {
|
||||
sInitChainHandlers[ichain->type]((u8*)actor, ichain);
|
||||
} while ((ichain++)->cont);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include "global.h"
|
||||
#include "z64math.h"
|
||||
#include "fp_math.h"
|
||||
#include "z_lib.h"
|
||||
|
||||
/**
|
||||
* Calculates the distances between `a` and `b`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue