Skip to content

Commit 1e8e2c8

Browse files
authored
Changes from decomp (#24)
Breaking: - Create include_cpp folder (an old decision I'm probably about to revert) Other: - Remove the now-unused SKIP_PPCDIS - STRIPPED macro for functions that deadstripped outside of decomp - Correct types for decomp in common.h - Expand fadedrv.h - Expand spmario_snd.h - Expand gx.h - Expand mem.h - Expand/correct mtx.h - Create msl exception.h and new.h - Create some nw4r headders
1 parent 364c626 commit 1e8e2c8

32 files changed

+1019
-74
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ It is recommended to use this with [git subrepo](https://github.com/ingydotnet/g
1919

2020
## Decomp
2121

22-
For use in decomp, the `include` and `decomp` folders should be added to the include path, and the preprocessor define `DECOMP` should be used.
22+
For use in decomp, the `include`, `include_cpp` and `decomp` folders should be added to the include path, and the preprocessor define `DECOMP` should be used.
2323

24-
### Testing
24+
## Mods
2525

26-
The `SKIP_PPCDIS` preprocessor define will stop `ppcdis.h` being included.
26+
For use in mods, the `include`, `include_cpp` and `mod` folder should be added to the include path and an lst from `linker` should be used. Mods should include their compiler's standard library headers (do not use `-nostdinc`), though linking it is not required (so `-nostdlib` is fine).
2727

28-
## Mods
28+
## C
2929

30-
For use in mods, the `include` and `mod` folder should be added to the include path and an lst from `linker` should be used. Mods should include their compiler's standard library headers (do not use `-nostdinc`), though linking it is not required (so `-nostdlib` is fine).
30+
For the cases where C is required (such as m2c or maybe some niche modding cases), omitting the `include_cpp` folder should be all that's neccessary.
3131

3232
# Licensing
3333

34-
All code originally written for this project (everything under the `include`, `decomp` and `linker` directories) is available under the MIT license.
34+
All code originally written for this project (everything under the `include`, `include_cpp`, `decomp` and `linker` directories) is available under the MIT license.
3535

3636
Everything under the `mod` folder is available under the GPLv3 license as it's derived from other GPL code.
3737

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def test_mod_ctx(regions: List[str]):
240240
def test_decomp_ctx(regions: List[str]):
241241
assert args.codewarrior, "Error: decomp_ctx test requires --codewarrior"
242242
compile_regions(os.path.join("$builddir", "{region}", "decomp.o"), "$decomp_source", regions,
243-
DECOMP_INCLUDES, ["DECOMP", "SKIP_PPCDIS"], True)
243+
DECOMP_INCLUDES, ["DECOMP"], True)
244244

245245
# Test shuffled include orders
246246
def test_mod_ctx_shuffle(regions: List[str]):

include/common.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#pragma once
22

3-
#if (defined DECOMP) && !(defined SKIP_PPCDIS)
4-
// Decomp should include ppcdis.h in all files
5-
#include <ppcdis.h>
6-
#else
7-
// Unknown function is useful outside of decomp too
3+
// Unknown function declaration
84
#define UNKNOWN_FUNCTION(name) void name(void)
9-
#endif
105

116
// Intellisense doesn't like asm compiler extensions
127
#ifdef __INTELLISENSE__
@@ -50,6 +45,13 @@
5045
#define DECOMP_STATIC(expr) extern expr;
5146
#endif
5247

48+
// Macro for something that is deadstripped outside of decomp
49+
#ifdef DECOMP
50+
#define STRIPPED(expr) expr;
51+
#else
52+
#define STRIPPED(expr)
53+
#endif
54+
5355
// Use extern "C" in C++, use namespacing in mods
5456
#ifdef __cplusplus
5557
#ifndef DECOMP
@@ -139,12 +141,10 @@ typedef int BOOL;
139141
#else
140142
#define offsetof(type, member) ((u32)&((type *)0)->member)
141143
#endif
142-
#define bool char
143144

144145
#define true 1
145146
#define false 0
146147

147-
#define wchar_t s16
148148
typedef wchar_t wchar16_t;
149149

150150
typedef s32 ptrdiff_t;

include/spm/camdrv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
CPP_WRAPPER(spm::camdrv)
1313

14+
USING(wii::gx::GXProjectionType)
1415
USING(wii::mtx::Vec3)
1516
USING(wii::mtx::Mtx34)
1617
USING(wii::mtx::Mtx44)
@@ -63,7 +64,7 @@ typedef struct _CamEntry
6364
/* 0x0F8 */ f32 left;
6465
/* 0x0FC */ f32 right;
6566
/* 0x100 */ u8 unknown_0x100[0x158 - 0x100];
66-
/* 0x158 */ s32 isOrtho;
67+
/* 0x158 */ GXProjectionType projectionType;
6768
/* 0x15C */ Vec3 pos;
6869
/* 0x168 */ Vec3 target;
6970
/* 0x174 */ Vec3 up;

include/spm/evtmgr_cmd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ f32 evtSetFloat(EvtEntry * entry, EvtVar variable, f32 value);
351351
Returns a pointer to the instruction after the specified label
352352
in an entry's script
353353
*/
354-
EvtScriptCode * evtSearchLabel(EvtEntry * entry, s32 id); // inlined
354+
STRIPPED(EvtScriptCode * evtSearchLabel(EvtEntry * entry, s32 id))
355355

356356
/*
357357
Returns a pointer to the instruction after the next else on the

include/spm/fadedrv.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#pragma once
22

33
#include <common.h>
4+
#include <wii/gx.h>
45

56
CPP_WRAPPER(spm::fadedrv)
67

8+
USING(wii::gx::GXColor)
9+
710
void fadeInit();
8-
UNKNOWN_FUNCTION(fadeEntry);
11+
void fadeEntry(u32 transitionType, s32 param_2, GXColor colour);
912
UNKNOWN_FUNCTION(func_80066558);
1013
void fadeMain();
1114
UNKNOWN_FUNCTION(func_80066e4c);

include/spm/hud.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ UNKNOWN_FUNCTION(hudDisp);
2828
void func_8019af88();
2929
void hudTurnOffFlipTimeBox(s32 idx);
3030
UNKNOWN_FUNCTION(func_8019b0dc);
31-
UNKNOWN_FUNCTION(func_8019be84);
31+
void func_8019be84();
3232
UNKNOWN_FUNCTION(func_8019bea8);
3333

3434
CPP_WRAPPER_END()

include/spm/mario_pouch.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ DECOMP_STATIC(MarioPouchWork mario_pouch_work2)
118118
Returns a pointer to the MarioPouchWork / MarioPouchWork2 instance
119119
*/
120120
MarioPouchWork * pouchGetPtr();
121-
MarioPouchWork2 * pouch2GetPtr(); // inlined
121+
STRIPPED(MarioPouchWork2 * pouch2GetPtr())
122122

123123
/*
124124
Initialise data used by pouch functions
125125
Overwritten later once a save is loaded
126126
*/
127127
void pouchInit();
128-
void pouch2Init(); // inlined
128+
STRIPPED(void pouch2Init())
129129
void pouchReInit();
130130

131131
/*
@@ -169,7 +169,7 @@ s32 pouchGetMaxHp();
169169
/*
170170
Get/add to the player's xp
171171
*/
172-
void pouchSetXp(s32 xp); // inlined
172+
STRIPPED(void pouchSetXp(s32 xp))
173173
s32 pouchGetXp();
174174
void pouchAddXp(s32 increase);
175175

@@ -178,7 +178,7 @@ void pouchAddXp(s32 increase);
178178
*/
179179
void pouchSetCoin(s32 coins);
180180
s32 pouchGetCoin();
181-
void pouchAddTotalCoin(s32 increase); // inlined
181+
STRIPPED(void pouchAddTotalCoin(s32 increase))
182182
void pouchAddCoin(s32 increase); // increases totalCoinsCollected
183183

184184
/*

include/spm/seq_title.h

Lines changed: 0 additions & 20 deletions
This file was deleted.

include/spm/spmario_snd.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ UNKNOWN_FUNCTION(spsndPause);
1313
UNKNOWN_FUNCTION(spsndUnpause);
1414
UNKNOWN_FUNCTION(func_8023872c);
1515
UNKNOWN_FUNCTION(spsndSetPosDirListener);
16-
UNKNOWN_FUNCTION(spsndSetSFXReverbMode);
16+
void spsndSetSFXReverbMode(u8 mode);
1717
UNKNOWN_FUNCTION(func_80238804);
1818
UNKNOWN_FUNCTION(func_80238868);
1919
UNKNOWN_FUNCTION(spsndSetFlag);
20-
UNKNOWN_FUNCTION(spsndClearFlag);
20+
void spsndClearFlag(u16 flags);
2121
UNKNOWN_FUNCTION(spsndGetFlag);
2222
UNKNOWN_FUNCTION(func_802388f4);
2323
UNKNOWN_FUNCTION(func_80238b04);
@@ -29,7 +29,7 @@ UNKNOWN_FUNCTION(spsndSFXOn_UnkEffect);
2929
UNKNOWN_FUNCTION(_spsndSFXOn);
3030
UNKNOWN_FUNCTION(spsndSFXOn_3D);
3131
UNKNOWN_FUNCTION(spsndSFXOff);
32-
UNKNOWN_FUNCTION(func_8023b38c);
32+
void func_8023b38c(u32 param_1, u32 param_2);
3333
UNKNOWN_FUNCTION(spsndSetSfxPlayerPos);
3434
UNKNOWN_FUNCTION(spsndSFX_vol);
3535
UNKNOWN_FUNCTION(spsndSFX_pit);
@@ -50,13 +50,13 @@ bool spsndBGMOn(u32 flags, const char * name);
5050
UNKNOWN_FUNCTION(spsndBGMOn_f_d_alt);
5151
bool spsndBGMOff_f_d(s32 player, u32 fadeoutTime);
5252
UNKNOWN_FUNCTION(spsndBGMOff);
53-
UNKNOWN_FUNCTION(spsndBGMOff_f_d_alt);
53+
bool spsndBGMOff_f_d_alt(s32 player, s32 fadeoutTime);
5454
UNKNOWN_FUNCTION(func_8023cab4);
5555
UNKNOWN_FUNCTION(func_8023cc90);
5656
UNKNOWN_FUNCTION(func_8023cc98);
5757
UNKNOWN_FUNCTION(func_8023cc9c);
5858
UNKNOWN_FUNCTION(func_8023ce1c);
59-
UNKNOWN_FUNCTION(func_8023ce20);
59+
void func_8023ce20(s32 player, s32 param_2, s32 param_3);
6060
UNKNOWN_FUNCTION(func_8023cf14);
6161
UNKNOWN_FUNCTION(func_8023cfe8);
6262
UNKNOWN_FUNCTION(func_8023d0dc);
@@ -68,9 +68,9 @@ UNKNOWN_FUNCTION(func_8023d2b8);
6868
UNKNOWN_FUNCTION(spsndENVMain);
6969
UNKNOWN_FUNCTION(spsndENVOn_f_d);
7070
UNKNOWN_FUNCTION(spsndENVOn);
71-
UNKNOWN_FUNCTION(func_8023db5c);
71+
bool func_8023db5c(s32 param_1, s32 param_2);
7272
UNKNOWN_FUNCTION(func_8023dc88);
73-
UNKNOWN_FUNCTION(func_8023dc90);
73+
bool func_8023dc90(s32 param_1, s32 param_2);
7474
UNKNOWN_FUNCTION(func_8023dc94);
7575
UNKNOWN_FUNCTION(func_8023dda4);
7676
UNKNOWN_FUNCTION(func_8023de90);

include/spm/system.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ s32 NORETURN ATTRIBUTE_FORMAT(printf, 4, 5) __assert2(
8989

9090
/*
9191
Rounds a float to an int
92-
Deadstripped, always inlined
9392
*/
94-
s32 roundi(f32 x);
93+
STRIPPED(s32 roundi(f32 x))
9594

9695
/*
9796
Adjusts an angle to be 0 <= x < 360
@@ -144,9 +143,8 @@ void sysRandInit();
144143

145144
/*
146145
Gets the current screen draw token
147-
Deadstripped, always inlined
148146
*/
149-
u16 sysGetToken();
147+
STRIPPED(u16 sysGetToken())
150148

151149
/*
152150
Waits until the next screen draw, or max 100ms

include/wii/gx.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ typedef struct
1616
{
1717
u8 r, g, b, a;
1818
} GXColor;
19+
SIZE_ASSERT(GXColor, 0x4)
20+
21+
typedef struct
22+
{
23+
s16 r, g, b, a;
24+
} GXColorS10;
25+
SIZE_ASSERT(GXColorS10, 0x8)
1926

2027
typedef struct
2128
{
@@ -29,6 +36,13 @@ typedef struct
2936
} GXTexObj;
3037
SIZE_ASSERT(GXTexObj, 0x20)
3138

39+
40+
typedef enum
41+
{
42+
/* 0x0 */ GX_PERSPECTIVE,
43+
/* 0x1 */ GX_ORTHOGRAPHIC
44+
} GXProjectionType;
45+
3246
// Parameters from libogc's gx.h
3347

3448
UNKNOWN_FUNCTION(__GXDefaultTexRegionCallback);
@@ -200,7 +214,7 @@ UNKNOWN_FUNCTION(GXEndDisplayList);
200214
UNKNOWN_FUNCTION(GXCallDisplayList);
201215
UNKNOWN_FUNCTION(GXProject);
202216
UNKNOWN_FUNCTION(__GXSetProjection);
203-
void GXSetProjection(Mtx44 * mtx, u32 type);
217+
void GXSetProjection(Mtx44 mtx, GXProjectionType type);
204218
UNKNOWN_FUNCTION(GXSetProjectionv);
205219
UNKNOWN_FUNCTION(GXGetProjectionv);
206220
void GXLoadPosMtxImm(Mtx34 * mtx, u32 pnidx);

include/wii/mem.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ typedef struct _MEMEXPHeap
3535
} MEMEXPHeap;
3636
SIZE_ASSERT(MEMEXPHeap, 0x50)
3737

38+
typedef struct
39+
{
40+
/* 0x0 */ void * alloc;
41+
/* 0x4 */ void * free;
42+
} MEMAllocatorFunc;
43+
SIZE_ASSERT(MEMAllocatorFunc, 8)
44+
45+
typedef struct
46+
{
47+
/* 0x0 */ MEMAllocatorFunc * func;
48+
/* 0x4 */ void * heap;
49+
/* 0x8 */ u32 heapP0;
50+
/* 0x8 */ u32 heapP1;
51+
} MEMAllocator;
52+
SIZE_ASSERT(MEMAllocator, 0x10)
53+
3854
#define MEM_FLAG_FILL_0 (1 << 0) // initialise allocated memory as 0
3955
#define MEM_FLAG_THREAD_CONTROL (1 << 2) // use mutexes for access when handling heap
4056

@@ -63,9 +79,9 @@ UNKNOWN_FUNCTION(AllocatorAllocForExpHeap_);
6379
UNKNOWN_FUNCTION(AllocatorFreeForExpHeap_);
6480
UNKNOWN_FUNCTION(AllocatorAllocForFrmHeap_);
6581
UNKNOWN_FUNCTION(AllocatorFreeForFrmHeap_);
66-
UNKNOWN_FUNCTION(MEMAllocFromAllocator);
82+
void * MEMAllocFromAllocator(MEMAllocator * allocator, size_t size);
6783
UNKNOWN_FUNCTION(MEMFreeToAllocator);
68-
UNKNOWN_FUNCTION(MEMInitAllocatorForExpHeap);
84+
void MEMInitAllocatorForExpHeap(MEMAllocator * allocator, MEMHeapHandle heap, u32 alignment);
6985
UNKNOWN_FUNCTION(MEMInitAllocatorForFrmHeap);
7086
UNKNOWN_FUNCTION(MEMInitList);
7187
UNKNOWN_FUNCTION(MEMAppendListObject);

include/wii/mtx.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ typedef struct
3333
typedef f32 Mtx34[3][4];
3434
typedef f32 Mtx44[4][4];
3535

36-
void PSMTXIdentity(Mtx34 * dest);
37-
UNKNOWN_FUNCTION(PSMTXCopy);
36+
void PSMTXIdentity(Mtx34 dest);
37+
void PSMTXCopy(const Mtx34 src, Mtx34 dest);
3838
UNKNOWN_FUNCTION(PSMTXConcat);
3939
UNKNOWN_FUNCTION(PSMTXInverse);
4040
UNKNOWN_FUNCTION(PSMTXInvXpose);
4141
UNKNOWN_FUNCTION(PSMTXRotRad);
4242
UNKNOWN_FUNCTION(PSMTXRotTrig);
4343
UNKNOWN_FUNCTION(__PSMTXRotAxisRadInternal);
4444
UNKNOWN_FUNCTION(PSMTXRotAxisRad);
45-
void PSMTXTrans(Mtx34 * dest, f32 x, f32 y, f32 z);
46-
void PSMTXTransApply(Mtx34 * src, Mtx34 * dest, f32 x, f32 y, f32 z);
47-
void PSMTXScale(Mtx34 * dest, f32 x, f32 y, f32 z);
48-
void PSMTXScaleApply(Mtx34 * src, Mtx34 * dest, f32 x, f32 y, f32 z);
45+
void PSMTXTrans(Mtx34 dest, f32 x, f32 y, f32 z);
46+
void PSMTXTransApply(const Mtx34 src, Mtx34 dest, f32 x, f32 y, f32 z);
47+
void PSMTXScale(Mtx34 dest, f32 x, f32 y, f32 z);
48+
void PSMTXScaleApply(const Mtx34 src, Mtx34 dest, f32 x, f32 y, f32 z);
4949
UNKNOWN_FUNCTION(PSMTXQuat);
5050
UNKNOWN_FUNCTION(C_MTXLookAt);
5151
UNKNOWN_FUNCTION(C_MTXLightFrustum);
@@ -56,18 +56,18 @@ UNKNOWN_FUNCTION(PSMTXMultVecArray);
5656
UNKNOWN_FUNCTION(PSMTXMultVecSR);
5757
UNKNOWN_FUNCTION(C_MTXFrustum);
5858
UNKNOWN_FUNCTION(C_MTXPerspective);
59-
void C_MTXOrtho(Mtx44 * dest, f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far);
59+
void C_MTXOrtho(Mtx44 dest, f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far);
6060
UNKNOWN_FUNCTION(PSMTX44Copy);
6161
UNKNOWN_FUNCTION(PSMTX44MultVec);
6262
UNKNOWN_FUNCTION(PSMTX44MultVecArray);
6363
UNKNOWN_FUNCTION(PSVECAdd);
64-
void PSVECSubtract(Vec3 * src1, Vec3 * src2, Vec3 * dest);
65-
void PSVECScale(Vec3 * src, Vec3 * dest, f32 scale);
66-
void PSVECNormalize(Vec3 * src, Vec3 * dest);
67-
f32 PSVecSquareMag(Vec3 * src);
68-
f32 PSVecMag(Vec3 * src);
69-
f32 PSVECDotProduct(Vec3 * src1, Vec3 * src2);
70-
void PSVECCrossProduct(Vec3 * src1, Vec3 * src2, Vec3 * dest);
64+
void PSVECSubtract(const Vec3 * src1, const Vec3 * src2, Vec3 * dest);
65+
void PSVECScale(const Vec3 * src, Vec3 * dest, f32 scale);
66+
void PSVECNormalize(const Vec3 * src, Vec3 * dest);
67+
f32 PSVecSquareMag(const Vec3 * src);
68+
f32 PSVecMag(const Vec3 * src);
69+
f32 PSVECDotProduct(const Vec3 * src1, const Vec3 * src2);
70+
void PSVECCrossProduct(const Vec3 * src1, const Vec3 * src2, Vec3 * dest);
7171
UNKNOWN_FUNCTION(VECHalfAngle);
7272
UNKNOWN_FUNCTION(VECReflect);
7373
UNKNOWN_FUNCTION(PSVECSquareDistance);

0 commit comments

Comments
 (0)