1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-05-09 18:43:45 +00:00

merge main

This commit is contained in:
fig02 2025-04-25 21:19:00 -04:00
commit 2291fc58f0
35 changed files with 136 additions and 90 deletions

13
include/avoid_ub.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef AVOID_UB_H
#define AVOID_UB_H
/**
* This macro is used when the return type of a function is incorrect
*/
#ifndef AVOID_UB
#define BAD_RETURN(type) type
#else
#define BAD_RETURN(type) void
#endif
#endif

View file

@ -33,4 +33,6 @@ typedef union Color_RGBA16 {
u16 rgba;
} Color_RGBA16;
#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0))
#endif

View file

@ -1,9 +1,10 @@
#ifndef FAULT_H
#define FAULT_H
#include "ultra64.h"
#include "attributes.h"
#include "libu64/debug.h"
#include "libu64/pad.h"
#include "attributes.h"
#include "ultra64.h"
#if !PLATFORM_N64
// These are the same as the 3-bit ansi color codes
@ -50,6 +51,12 @@ void Fault_Init(void);
NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2);
NORETURN void Fault_AddHungupAndCrash(const char* file, int line);
#if PLATFORM_N64 || DEBUG_FEATURES
#define HUNGUP_AND_CRASH(file, line) Fault_AddHungupAndCrash(file, line)
#else
#define HUNGUP_AND_CRASH(file, line) LogUtils_HungupThread(file, line)
#endif
// Client Registration
void Fault_AddClient(FaultClient* client, void* callback, void* arg0, void* arg1);

View file

@ -7,6 +7,9 @@
#include "thga.h"
#include "versions.h"
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
// Texture memory size, 4 KiB
#define TMEM_SIZE 0x1000
@ -124,4 +127,39 @@ void Graph_ThreadEntry(void*);
extern u64 gMojiFontTLUTs[4][4]; // original name: "moji_tlut"
extern u64 gMojiFontTex[]; // original name: "font_ff"
/**
* `x` vertex x
* `y` vertex y
* `z` vertex z
* `s` texture s coordinate
* `t` texture t coordinate
* `crnx` red component of color vertex, or x component of normal vertex
* `cgny` green component of color vertex, or y component of normal vertex
* `cbnz` blue component of color vertex, or z component of normal vertex
* `a` alpha
*/
#define VTX(x,y,z,s,t,crnx,cgny,cbnz,a) { { { x, y, z }, 0, { s, t }, { crnx, cgny, cbnz, a } } }
#define VTX_T(x,y,z,s,t,cr,cg,cb,a) { { x, y, z }, 0, { s, t }, { cr, cg, cb, a } }
#define gDPSetTileCustom(pkt, fmt, siz, uls, ult, lrs, lrt, pal, \
cms, cmt, masks, maskt, shifts, shiftt) \
_DW({ \
gDPPipeSync(pkt); \
gDPTileSync(pkt); \
gDPSetTile(pkt, fmt, siz, \
(((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), 0, \
G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, \
shifts); \
gDPTileSync(pkt); \
gDPSetTile(pkt, fmt, siz, \
(((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), 0, \
G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, shifts); \
gDPSetTileSize(pkt, G_TX_RENDERTILE, \
(uls) << G_TEXTURE_IMAGE_FRAC, \
(ult) << G_TEXTURE_IMAGE_FRAC, \
(lrs) << G_TEXTURE_IMAGE_FRAC, \
(lrt) << G_TEXTURE_IMAGE_FRAC); \
})
#endif

12
include/language_array.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef LANGUAGE_ARRAY_H
#define LANGUAGE_ARRAY_H
#include "versions.h"
#if OOT_NTSC
#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { jpn, eng }
#else
#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { eng, ger, fra }
#endif
#endif

View file

@ -1,83 +1,6 @@
#ifndef MACROS_H
#define MACROS_H
#include "versions.h"
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#ifndef AVOID_UB
#define BAD_RETURN(type) type
#else
#define BAD_RETURN(type) void
#endif
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define DECR(x) ((x) == 0 ? 0 : --(x))
#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x))
#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x))
#define SWAP(type, a, b) \
{ \
type _temp = (a); \
(a) = (b); \
(b) = _temp; \
} \
(void)0
#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0))
#define CHECK_FLAG_ALL(flags, mask) (((flags) & (mask)) == (mask))
#if PLATFORM_N64 || DEBUG_FEATURES
#define HUNGUP_AND_CRASH(file, line) Fault_AddHungupAndCrash(file, line)
#else
#define HUNGUP_AND_CRASH(file, line) LogUtils_HungupThread(file, line)
#endif
#define MATRIX_FINALIZE_AND_LOAD(pkt, gfxCtx, file, line) \
gSPMatrix(pkt, MATRIX_FINALIZE(gfxCtx, file, line), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW)
#if OOT_NTSC
#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { jpn, eng }
#else
#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { eng, ger, fra }
#endif
/**
* `x` vertex x
* `y` vertex y
* `z` vertex z
* `s` texture s coordinate
* `t` texture t coordinate
* `crnx` red component of color vertex, or x component of normal vertex
* `cgny` green component of color vertex, or y component of normal vertex
* `cbnz` blue component of color vertex, or z component of normal vertex
* `a` alpha
*/
#define VTX(x,y,z,s,t,crnx,cgny,cbnz,a) { { { x, y, z }, 0, { s, t }, { crnx, cgny, cbnz, a } } }
#define VTX_T(x,y,z,s,t,cr,cg,cb,a) { { x, y, z }, 0, { s, t }, { cr, cg, cb, a } }
#define gDPSetTileCustom(pkt, fmt, siz, uls, ult, lrs, lrt, pal, \
cms, cmt, masks, maskt, shifts, shiftt) \
_DW({ \
gDPPipeSync(pkt); \
gDPTileSync(pkt); \
gDPSetTile(pkt, fmt, siz, \
(((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), 0, \
G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, \
shifts); \
gDPTileSync(pkt); \
gDPSetTile(pkt, fmt, siz, \
(((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), 0, \
G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, shifts); \
gDPSetTileSize(pkt, G_TX_RENDERTILE, \
(uls) << G_TEXTURE_IMAGE_FRAC, \
(ult) << G_TEXTURE_IMAGE_FRAC, \
(lrs) << G_TEXTURE_IMAGE_FRAC, \
(lrt) << G_TEXTURE_IMAGE_FRAC); \
})
#endif

View file

@ -64,6 +64,9 @@ Mtx* Matrix_Finalize(struct GraphicsContext* gfxCtx);
#endif
#define MATRIX_FINALIZE_AND_LOAD(pkt, gfxCtx, file, line) \
gSPMatrix(pkt, MATRIX_FINALIZE(gfxCtx, file, line), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW)
/* Vector operations */
void Matrix_MultVec3f(Vec3f* src, Vec3f* dest);

View file

@ -5,6 +5,7 @@
// After assets are modified to include the headers they need directly, delete this file.
#include "array_count.h"
#include "gfx.h"
#include "sequence.h"
#include "sys_matrix.h"
#include "ultra64.h"

View file

@ -1,6 +1,7 @@
#ifndef Z64_ANIMATION_H
#define Z64_ANIMATION_H
#include "avoid_ub.h"
#include "ultra64.h"
#include "z64dma.h"
#include "z64math.h"

View file

@ -1,11 +1,8 @@
#ifndef Z64MATH_H
#define Z64MATH_H
#include "ultra64.h"
#include "math.h"
#define SQ(x) ((x)*(x))
#define VEC_SET(V,X,Y,Z) (V).x=(X);(V).y=(Y);(V).z=(Z)
#include "ultra64.h"
typedef union FloatInt {
f32 f;
@ -95,6 +92,27 @@ typedef VecSphGeo VecSph;
// Pitch is 0 along the xz-plane (horizon)
typedef VecSphGeo VecGeo;
/**
* Macros
*/
// General number macros
#define SQ(x) ((x)*(x))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define DECR(x) ((x) == 0 ? 0 : --(x))
#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x))
#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x))
#define SWAP(type, a, b) \
{ \
type _temp = (a); \
(a) = (b); \
(b) = _temp; \
} \
(void)0
// LERP macros
#define LERP(x, y, scale) (((y) - (x)) * (scale) + (x))
#define LERP32(x, y, scale) ((s32)(((y) - (x)) * (scale)) + (x))
#define LERP16(x, y, scale) ((s16)(((y) - (x)) * (scale)) + (x))
@ -110,6 +128,7 @@ typedef VecSphGeo VecGeo;
(dst)->z = (v0)->z + (((v1)->z - (v0)->z) * t); \
}
// Floating point macros
#define IS_ZERO(f) (fabsf(f) < 0.008f)
// Casting a float to an integer, when the float value is larger than what the integer type can hold,
@ -145,6 +164,7 @@ typedef VecSphGeo VecGeo;
#define CAM_BINANG_TO_DEG(binang) ((f32)(binang) * (360.0001525f / 65535.0f))
// Vector macros
#define VEC_SET(V,X,Y,Z) (V).x=(X);(V).y=(Y);(V).z=(Z)
#define SQXZ(vec) ((vec).x * (vec).x + (vec).z * (vec).z)
#define DOTXZ(vec1, vec2) ((vec1).x * (vec2).x + (vec1).z * (vec2).z)
#define SQXYZ(vec) ((vec).x * (vec).x + (vec).y * (vec).y + (vec).z * (vec).z)

View file

@ -1,6 +1,7 @@
#ifndef Z64SCENE_H
#define Z64SCENE_H
#include "avoid_ub.h"
#include "macros.h"
#include "ultra64.h"
#include "z64bgcheck.h"

View file

@ -1,6 +1,7 @@
#ifndef Z64VIEW_H
#define Z64VIEW_H
#include "avoid_ub.h"
#include "macros.h"
#include "ultra64.h"
#include "z64math.h"

View file

@ -41,14 +41,15 @@
* DPad-Down disables sending fault pages over osSyncPrintf.
*/
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-eu-mq-dbg:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192" \
"gc-us-mq:192 ique-cn:192"
#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-eu-mq-dbg:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160" \
"gc-us-mq:160 ique-cn:160"
#include "libc64/sleep.h"
#include "libc64/sprintf.h"
#include "alloca.h"
#include "array_count.h"
#include "controller.h"
#include "gfx.h"
#include "padmgr.h"
#include "fault.h"
#include "stack.h"

View file

@ -7,6 +7,8 @@
#include "array_count.h"
#include "fault.h"
#include "gfx.h"
#include "terminal.h"
#include "global.h"

View file

@ -4,6 +4,7 @@
#include "array_count.h"
#include "controller.h"
#include "fault.h"
#include "gfx.h"
#include "padmgr.h"
#include "segmented_address.h"
#include "stack.h"
@ -14,7 +15,7 @@
#include "global.h"
#pragma increment_block_number "ntsc-1.0:176 ntsc-1.1:176 ntsc-1.2:176 pal-1.0:176 pal-1.1:176"
#pragma increment_block_number "ntsc-1.0:144 ntsc-1.1:144 ntsc-1.2:144 pal-1.0:144 pal-1.1:144"
typedef struct FaultMgr {
OSThread thread;

View file

@ -46,7 +46,7 @@ extern struct IrqMgr gIrqMgr;
#include "global.h"
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
"ique-cn:0 ntsc-1.0:35 ntsc-1.1:35 ntsc-1.2:35 pal-1.0:33 pal-1.1:33"
"ique-cn:0 ntsc-1.0:34 ntsc-1.1:34 ntsc-1.2:34 pal-1.0:32 pal-1.1:32"
extern u8 _buffersSegmentEnd[];

View file

@ -2,6 +2,7 @@
#include "libu64/debug.h"
#include "attributes.h"
#include "gfx.h"
#include "line_numbers.h"
#include "printf.h"
#include "translation.h"

View file

@ -4,6 +4,7 @@
#include "attributes.h"
#include "controller.h"
#include "db_camera.h"
#include "gfx.h"
#include "letterbox.h"
#include "one_point_cutscene.h"
#include "quake.h"
@ -3660,7 +3661,7 @@ s32 Camera_KeepOn3(Camera* camera) {
}
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
"ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
"ique-cn:128 ntsc-1.0:86 ntsc-1.1:86 ntsc-1.2:86 pal-1.0:86 pal-1.1:86"
s32 Camera_KeepOn4(Camera* camera) {
static Vec3f D_8015BD50;

View file

@ -1,5 +1,6 @@
#include "transition_circle.h"
#include "color.h"
#include "gfx.h"
#include "sfx.h"

View file

@ -1,6 +1,8 @@
#include "jpeg.h"
#include "array_count.h"
#include "attributes.h"
#include "jpeg.h"
#include "gfx.h"
#include "printf.h"
#include "sys_ucode.h"
#include "terminal.h"

View file

@ -1,3 +1,4 @@
#include "avoid_ub.h"
#include "buffers.h"
#include "gfx.h"
#include "gfx_setupdl.h"

View file

@ -5,6 +5,7 @@
#include "gfx.h"
#include "gfx_setupdl.h"
#include "gfxalloc.h"
#include "language_array.h"
#include "memory_utils.h"
#include "message_data_static.h"
#if PLATFORM_N64

View file

@ -4,6 +4,7 @@
#include "flag_set.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "language_array.h"
#include "main.h"
#include "map.h"
#include "printf.h"

View file

@ -3,6 +3,7 @@
#include "libu64/debug.h"
#include "array_count.h"
#include "buffers.h"
#include "color.h"
#include "controller.h"
#include "fault.h"
#include "file_select_state.h"

View file

@ -1,4 +1,5 @@
#include "array_count.h"
#include "avoid_ub.h"
#include "printf.h"
#include "regs.h"
#include "romfile.h"

View file

@ -1,4 +1,5 @@
#include "libu64/debug.h"
#include "avoid_ub.h"
#include "gfx.h"
#include "printf.h"
#include "regs.h"

View file

@ -2,6 +2,7 @@
#include "libc64/malloc.h"
#include "libu64/debug.h"
#include "avoid_ub.h"
#include "gfx.h"
#include "letterbox.h"
#include "main.h"

View file

@ -3,6 +3,7 @@
#include "libu64/debug.h"
#include "ultra64/viint.h"
#include "controller.h"
#include "gfx.h"
#include "main.h"
#include "printf.h"
#include "regs.h"

View file

@ -6,6 +6,7 @@
#include "libc64/sleep.h"
#include "array_count.h"
#include "fault.h"
#include "gfx.h"
#include "irqmgr.h"
#include "line_numbers.h"
#include "stack.h"
@ -15,7 +16,7 @@
#include "z64audio.h"
#include "z64thread.h"
#pragma increment_block_number "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64"
#pragma increment_block_number "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0"
typedef struct struct_801D9C30 {
/* 0x000 */ s32 unk_000; // disk start

View file

@ -7,6 +7,7 @@
#include "z_en_mag.h"
#include "array_count.h"
#include "avoid_ub.h"
#include "controller.h"
#include "gfx.h"
#include "gfx_setupdl.h"

View file

@ -19,6 +19,7 @@
#include "libc64/qrand.h"
#include "libu64/debug.h"
#include "array_count.h"
#include "avoid_ub.h"
#include "controller.h"
#include "gfx.h"
#include "gfx_setupdl.h"

View file

@ -5,6 +5,7 @@
#include "controller.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "language_array.h"
#include "letterbox.h"
#include "macros.h"
#include "main.h"

View file

@ -5,6 +5,7 @@
#include "controller.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "language_array.h"
#include "printf.h"
#include "regs.h"
#include "rumble.h"

View file

@ -2,6 +2,7 @@
#include "gfx.h"
#include "gfx_setupdl.h"
#include "language_array.h"
#include "map.h"
#include "printf.h"
#include "regs.h"

View file

@ -6,6 +6,7 @@
#include "gfx.h"
#include "gfx_setupdl.h"
#include "gfxalloc.h"
#include "language_array.h"
#include "map.h"
#if PLATFORM_N64
#include "n64dd.h"