Merge branch 'master' into voice

This commit is contained in:
engineer124
2021-11-07 20:59:08 +11:00
936 changed files with 44090 additions and 10365 deletions
+1 -1
View File
@@ -92,7 +92,7 @@
#define SEGMENT_ADDR(num, off) (((num) << 24) + (off))
#ifndef NULL
#define NULL 0
#define NULL ((void*)0)
#endif
#endif /* !_MBI_H_ */
-4
View File
@@ -1,4 +0,0 @@
#ifndef _ASSERT_H_
#define _ASSERT_H_
#endif
+6
View File
@@ -0,0 +1,6 @@
#ifndef BGM_H
#define BGM_H
#define NA_BGM_STOP 0x100000FF
#endif
+8 -2
View File
@@ -3,7 +3,7 @@
/**
* Command Base macros intended for use in designing of more specific command macros
* Each macro packs bytes (B), halfowrds (H) and words (W, for consistency) into a single word
* Each macro packs bytes (B), halfwords (H) and words (W, for consistency) into a single word
*/
#define CMD_BBBB(a, b, c, d) (_SHIFTL(a, 24, 8) | _SHIFTL(b, 16, 8) | _SHIFTL(c, 8, 8) | _SHIFTL(d, 0, 8))
@@ -16,6 +16,12 @@
#define CMD_W(a) (a)
#define CMD_PTR(a) (u32)(a)
#ifdef __GNUC__
#define CMD_F(a) {.f = (a)}
#else
#define CMD_F(a) {(a)}
#endif
#define CMD_PTR(a) (uintptr_t)(a)
#endif
+2
View File
@@ -1,6 +1,8 @@
#ifndef _ULTRA64_CONVERT_H_
#define _ULTRA64_CONVERT_H_
#include "libc/stdint.h"
#define OS_CLOCK_RATE 62500000LL
#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4)
+34
View File
@@ -0,0 +1,34 @@
#ifndef FIXED_POINT_H
#define FIXED_POINT_H
#include "ultra64.h"
extern f32 qNaN0x3FFFFF;
extern f32 qNaN0x10000;
extern f32 sNaN0x3FFFFF;
f32 floorf(f32 x);
f64 floor(f64 x);
s32 lfloorf(f32 x);
s32 lfloor(f64 x);
f32 ceilf(f32 x);
f64 ceil(f64 x);
s32 lceilf(f32 x);
s32 lceil(f64 x);
f32 truncf(f32 x);
f64 trunc(f64 x);
s32 ltruncf(f32 x);
s32 ltrunc(f64 x);
f32 nearbyintf(f32 x);
f64 nearbyint(f64 x);
s32 lnearbyintf(f32 x);
s32 lnearbyint(f64 x);
f32 roundf(f32 x);
f64 round(f64 x);
s32 lroundf(f32 x);
s32 lround(f64 x);
#endif
+414 -411
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1,6 +1,8 @@
#ifndef _ICHAIN_H_
#define _ICHAIN_H_
#include "libc/stddef.h"
typedef struct {
u32 cont: 1;
u32 type: 4;
@@ -8,8 +10,6 @@ typedef struct {
s32 value: 16;
} InitChainEntry;
#define OFFSETOF(structure, member) ((size_t)&(((structure*)0)->member))
typedef enum {
/* 0x0 */ ICHAINTYPE_U8, // sets byte
/* 0x1 */ ICHAINTYPE_S8,
@@ -38,7 +38,7 @@ typedef enum {
* * cont ----- ICHAIN_CONTINUE (or ICHAIN_STOP) to continue (or stop) parsing
*/
#define ICHAIN(type, member, value, cont) \
{ cont, type, OFFSETOF(Actor, member), value }
{ cont, type, offsetof(Actor, member), value }
#define ICHAIN_U8(member, val, cont) ICHAIN(ICHAINTYPE_U8, member, val, cont)
#define ICHAIN_S8(member, val, cont) ICHAIN(ICHAINTYPE_S8, member, val, cont)
+8 -1
View File
@@ -139,10 +139,17 @@ typedef struct {
/* 0x01 */ u8 txsize;
/* 0x02 */ u8 rxsize;
/* 0x03 */ u8 cmd;
/* 0x04 */ u16 address;
/* 0x04 */ u8 hi;
/* 0x05 */ u8 lo;
/* 0x06 */ u8 data[32];
/* 0x26 */ u8 datacrc;
} __OSContRamReadFormat;
extern OSPifRam __osContPifRam;
// extern UNK_TYPE1 D_8009CF0C;
extern u8 __osContLastCmd;
extern u8 __osMaxControllers;
// extern OSMesgQueue D_8009CF38;
// extern OSMesg D_8009CF50;
#endif
+7
View File
@@ -0,0 +1,7 @@
#ifndef ALLOCA_H
#define ALLOCA_H
void* alloca(u32);
#define alloca __builtin_alloca
#endif
+4
View File
@@ -0,0 +1,4 @@
#ifndef ASSERT_H
#define ASSERT_H
#endif
+10 -4
View File
@@ -1,5 +1,5 @@
#ifndef _MATH_H_
#define _MATH_H_
#ifndef MATH_H
#define MATH_H
#include "PR/ultratypes.h"
@@ -12,12 +12,11 @@
#define DEGTORAD(x) ((x) * (M_PI / 180.0f))
typedef union {
f64 d;
struct {
u32 hi;
u32 lo;
} word;
f64 d;
} du;
typedef union {
@@ -27,4 +26,11 @@ typedef union {
extern f32 __libm_qnan_f;
float fabsf(float f);
#pragma intrinsic(fabsf)
float sqrtf(float f);
#pragma intrinsic(sqrtf)
double sqrt(double d);
#pragma intrinsic(sqrt)
#endif
+5 -4
View File
@@ -1,5 +1,5 @@
#ifndef _STDARG_H_
#define _STDARG_H_
#ifndef STDARG_H
#define STDARG_H
#include "ultra64.h"
@@ -41,5 +41,6 @@ typedef char *va_list;
: __va_stack_arg(list, mode))))[-1]
#define va_end(__list)
#endif
#endif
#endif /* __GNUC__ */
#endif /* STDARG_H */
+3 -3
View File
@@ -1,5 +1,5 @@
#ifndef _STDBOOL
#define _STDBOOL
#ifndef STDBOOL
#define STDBOOL
#define __bool_true_false_are_defined 1
@@ -11,4 +11,4 @@
#endif /* __cplusplus */
#endif /* _STDBOOL */
#endif /* STDBOOL */
+20
View File
@@ -0,0 +1,20 @@
#ifndef STDDEF_H
#define STDDEF_H
#include "PR/ultratypes.h"
typedef u32 size_t;
typedef s32 ptrdiff_t;
#ifndef NULL
#define NULL (void*)0
#endif
#ifdef __GNUC__
#define offsetof(structure, member) __builtin_offsetof (structure, member)
#else
#define offsetof(structure, member) ((size_t)&(((structure*)0)->member))
#endif
#endif /* STDDEF_H */
+4 -4
View File
@@ -1,7 +1,7 @@
#ifndef _STDINT_H_
#define _STDINT_H_
#ifndef STDINT_H
#define STDINT_H
#include "ultra64.h"
#include "PR/ultratypes.h"
typedef s32 intptr_t;
typedef u32 uintptr_t;
@@ -26,4 +26,4 @@ typedef u32 uintptr_t;
#define UINTPTR_MAX 0xffffffff
#endif /* _STDINT_H_ */
#endif /* STDINT_H */
+5 -7
View File
@@ -1,27 +1,25 @@
#ifndef _STDLIB_H_
#define _STDLIB_H_
#ifndef STDLIB_H
#define STDLIB_H
#include "libc/stddef.h"
typedef struct {
/* 0x0 */ int quot;
/* 0x4 */ int rem;
} div_t;
typedef struct {
/* 0x0 */ long quot;
/* 0x4 */ long rem;
} ldiv_t;
typedef struct {
/* 0x0 */ long long quot;
/* 0x8 */ long long rem;
} lldiv_t;
typedef unsigned int size_t;
typedef int ssize_t;
typedef long wchar_t;
#endif
#endif /* STDLIB_H */
+35 -13
View File
@@ -1,23 +1,20 @@
#ifndef _MACROS_H_
#define _MACROS_H_
#include "libc/stdint.h"
#include "convert.h"
#include "stdint.h"
#include "z64.h"
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))
#define HW_REG(reg, type) *(volatile type*)((reg) | 0xa0000000)
// TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address
// rather than add/sub 0x80000000
#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) + 0x80000000)
#define PHYSICAL_TO_VIRTUAL2(addr) ((uintptr_t)(addr)-0x80000000)
#define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr)-0x80000000)
// TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address rather than add/sub 0x80000000
#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) + RDRAM_CACHED)
#define PHYSICAL_TO_VIRTUAL2(addr) ((uintptr_t)(addr) - RDRAM_CACHED)
#define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - RDRAM_CACHED)
#define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr))
// Currently most often called ctxt in MM, TODO: Refactor names when its used
#define ACTIVE_CAM globalCtx->cameraPtrs[globalCtx->activeCamera]
#define GET_ACTIVE_CAM(globalCtx) ((globalCtx)->cameraPtrs[(globalCtx)->activeCamera])
#define MAIN_CAM 0
#define SUBCAM_FREE 0
@@ -25,9 +22,20 @@
(curState)->nextGameStateInit = (GameStateFunc)newInit; \
(curState)->nextGameStateSize = sizeof(newStruct)
#define PLAYER ((Player*)globalCtx->actorCtx.actorList[ACTORCAT_PLAYER].first)
#define SET_FULLSCREEN_VIEWPORT(view) \
{ \
Viewport viewport; \
viewport.bottomY = SCREEN_HEIGHT; \
viewport.rightX = SCREEN_WIDTH; \
viewport.topY = 0; \
viewport.leftX = 0; \
View_SetViewport(view, &viewport); \
} \
(void)0
#define FIRST_ENEMY ((Actor*)globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first)
#define GET_PLAYER(globalCtx) ((Player*)(globalCtx)->actorCtx.actorList[ACTORCAT_PLAYER].first)
#define GET_FIRST_ENEMY(globalCtx) ((Actor*)(globalCtx)->actorCtx.actorList[ACTORCAT_ENEMY].first)
// linkAge still exists in MM, but is always set to 0 (always adult)
// There are remnants of these macros from OOT, but they are essentially useless
@@ -37,6 +45,7 @@
#define CURRENT_DAY (((void)0, gSaveContext.day) % 5)
#define CLOCK_TIME(hr, min) ((s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60)))
#define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1))
#define SLOT(item) gItemSlots[item]
#define AMMO(item) gSaveContext.inventory.ammo[SLOT(item)]
@@ -49,12 +58,15 @@
#define CUR_UPG_VALUE_VOID(upg) \
((((void)0, gSaveContext.inventory.upgrades) & gUpgradeMasks[upg]) >> gUpgradeShifts[upg])
#define CUR_FORM ((gSaveContext.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.playerForm)
#define ALL_EQUIP_VALUE(equip) ((gSaveContext.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip])
#define CUR_EQUIP_VALUE(equip) ((gSaveContext.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip])
#define CUR_UPG_VALUE(upg) ((gSaveContext.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg])
#define TAKE_EQUIPPED_ITEM(equip) (gSaveContext.equips.equipment = ((((void)0, gSaveContext.equips.equipment) & (gEquipNegMasks[equip])) | (u16)(0 << gEquipShifts[equip])))
#define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[gSaveContext.playerForm == PLAYER_FORM_HUMAN ? 0 : gSaveContext.playerForm][button])
#define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[CUR_FORM][button])
#define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item])
#define REMOVE_QUEST_ITEM(item) (gSaveContext.inventory.questItems = (((void)0, gSaveContext.inventory.questItems) & (-1 - gBitFlags[item])))
#define CAPACITY(upg, value) gUpgradeCapacities[upg][value]
#define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg) - 4)
@@ -73,6 +85,7 @@ extern GraphicsContext* __gfxCtx;
#define POLY_OPA_DISP __gfxCtx->polyOpa.p
#define POLY_XLU_DISP __gfxCtx->polyXlu.p
#define OVERLAY_DISP __gfxCtx->overlay.p
#define DEBUG_DISP __gfxCtx->debug.p
// __gfxCtx shouldn't be used directly.
// Use the DISP macros defined above when writing to display buffers.
@@ -106,6 +119,7 @@ extern GraphicsContext* __gfxCtx;
#define ALIGN8(val) (((val) + 7) & ~7)
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
#define ALIGN64(val) (((val) + 0x3F) & ~0x3F)
#define SQ(x) ((x) * (x))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
@@ -116,6 +130,8 @@ extern GraphicsContext* __gfxCtx;
#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x))
#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x))
#define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5))
#define SWAP(type, a, b) \
{ \
type _temp = (a); \
@@ -123,4 +139,10 @@ extern GraphicsContext* __gfxCtx;
(b) = _temp; \
}
#ifdef __GNUC__
#define ALIGNED8 __attribute__ ((aligned (8)))
#else
#define ALIGNED8
#endif
#endif // _MACROS_H_
+4 -6
View File
@@ -1,6 +1,7 @@
#ifndef _OS_H_
#define _OS_H_
#include "libc/stdlib.h"
#include "ultra64/thread.h"
#include "ultra64/message.h"
@@ -65,7 +66,7 @@ typedef struct {
/* 0x00 */ OSIoMesgHdr hdr;
/* 0x08 */ void* dramAddr;
/* 0x0C */ u32 devAddr;
/* 0x10 */ u32 size;
/* 0x10 */ size_t size;
/* 0x14 */ OSPiHandle* piHandle;
} OSIoMesg; // size = 0x88
@@ -76,14 +77,12 @@ typedef struct {
/* 0x08 */ OSMesgQueue* cmdQueue;
/* 0x0C */ OSMesgQueue* evtQueue;
/* 0x10 */ OSMesgQueue* acsQueue;
/* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, u32);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, u32);
/* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t);
} OSDevMgr; // size = 0x1C
typedef u64 OSTime;
typedef struct OSTimer_s {
/* 0x00 */ struct OSTimer_s* next;
/* 0x04 */ struct OSTimer_s* prev;
@@ -93,7 +92,6 @@ typedef struct OSTimer_s {
/* 0x1C */ OSMesg msg;
} OSTimer; // size = 0x20
typedef struct {
/* 0x0 */ u16 type;
/* 0x2 */ u8 status;
+10
View File
@@ -6,4 +6,14 @@ typedef struct {
/* 0x04 */ OSMesg msg;
} __osHwInt; // size = 0x08
typedef struct {
/* 0x00 */ u32 initialized;
/* 0x04 */ OSThread* mgrThread;
/* 0x08 */ OSMesgQueue* cmdQueue;
/* 0x0C */ OSMesgQueue* eventQueue;
/* 0x10 */ OSMesgQueue* accessQueue;
/* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t);
} OSMgrArgs; // size = 0x1C
#endif

Some files were not shown because too many files have changed in this diff Show More