2021-09-15 19:24:19 -04:00
|
|
|
#ifndef Z64_H
|
|
|
|
#define Z64_H
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-10-03 17:22:44 +02:00
|
|
|
#include "ultra64.h"
|
|
|
|
#include "ultra64/gs2dex.h"
|
2023-09-09 15:24:52 +01:00
|
|
|
#include "attributes.h"
|
2023-11-30 21:22:30 +00:00
|
|
|
#include "audiomgr.h"
|
2024-09-06 01:24:19 -07:00
|
|
|
#include "controller.h"
|
2024-09-12 02:24:31 -07:00
|
|
|
#include "versions.h"
|
2020-10-03 17:22:44 +02:00
|
|
|
#include "z64player.h"
|
|
|
|
#include "z64audio.h"
|
2022-05-10 02:59:23 +10:00
|
|
|
#include "z64ocarina.h"
|
2022-05-20 07:27:54 +01:00
|
|
|
#include "z64curve.h"
|
2020-10-03 17:22:44 +02:00
|
|
|
#include "z64effect.h"
|
|
|
|
#include "z64animation.h"
|
2022-11-30 18:46:12 +01:00
|
|
|
#include "z64animation_legacy.h"
|
2024-09-25 19:45:06 +02:00
|
|
|
#include "letterbox.h"
|
2020-10-03 17:22:44 +02:00
|
|
|
#include "z64math.h"
|
2021-03-29 13:24:08 -04:00
|
|
|
#include "z64map_mark.h"
|
2024-10-01 19:14:54 +02:00
|
|
|
#include "one_point_cutscene.h"
|
2024-06-25 15:13:31 -04:00
|
|
|
#include "z64play.h"
|
2022-01-12 20:00:28 -03:00
|
|
|
#include "z64skin.h"
|
2024-09-25 00:18:01 +02:00
|
|
|
#include "z64skin_matrix.h"
|
2023-09-16 22:16:58 +01:00
|
|
|
#include "z64vis.h"
|
2024-10-01 08:46:56 +02:00
|
|
|
#include "zelda_arena.h"
|
2022-02-11 20:23:57 -03:00
|
|
|
#include "alignment.h"
|
2024-02-01 10:25:23 +11:00
|
|
|
#include "audiothread_cmd.h"
|
2020-10-03 17:22:44 +02:00
|
|
|
#include "sfx.h"
|
|
|
|
#include "color.h"
|
2025-01-24 13:25:05 -05:00
|
|
|
#include "libu64/gfxprint.h"
|
2024-06-19 00:00:23 -04:00
|
|
|
#include "z_lib.h"
|
2020-10-03 17:22:44 +02:00
|
|
|
#include "regs.h"
|
2022-02-02 21:43:34 +00:00
|
|
|
#include "irqmgr.h"
|
|
|
|
#include "padmgr.h"
|
2022-06-03 20:43:30 +01:00
|
|
|
#include "sched.h"
|
2022-09-27 17:40:26 +01:00
|
|
|
#include "rumble.h"
|
2024-09-27 20:51:00 +02:00
|
|
|
#include "map.h"
|
2022-11-16 07:32:07 +00:00
|
|
|
#include "mempak.h"
|
2022-11-13 23:29:50 +00:00
|
|
|
#include "tha.h"
|
|
|
|
#include "thga.h"
|
2025-01-23 14:39:23 -05:00
|
|
|
#include "speed_meter.h"
|
2023-08-15 18:21:19 +02:00
|
|
|
#include "gfx.h"
|
2024-09-25 00:18:01 +02:00
|
|
|
#include "gfx_setupdl.h"
|
2024-09-27 20:51:00 +02:00
|
|
|
#include "gfxalloc.h"
|
2023-08-15 18:21:19 +02:00
|
|
|
#include "prerender.h"
|
2024-06-19 00:00:23 -04:00
|
|
|
#include "rand.h"
|
|
|
|
#include "sys_math.h"
|
|
|
|
#include "sys_math3d.h"
|
2024-09-11 11:02:42 +02:00
|
|
|
#include "libc64/math64.h"
|
2024-09-07 06:26:47 +02:00
|
|
|
#include "sys_matrix.h"
|
2024-09-07 22:55:06 +02:00
|
|
|
#include "main.h"
|
|
|
|
#include "segmented_address.h"
|
2024-09-08 18:02:38 +02:00
|
|
|
#include "stackcheck.h"
|
2024-09-11 10:17:47 +02:00
|
|
|
#include "kaleido_manager.h"
|
2024-09-11 11:02:42 +02:00
|
|
|
#include "libc64/aprintf.h"
|
|
|
|
#include "libc64/malloc.h"
|
|
|
|
#include "libc64/sleep.h"
|
|
|
|
#include "libc64/sprintf.h"
|
2025-01-24 13:25:05 -05:00
|
|
|
#include "libu64/debug.h"
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2024-08-12 00:07:48 -07:00
|
|
|
typedef struct GameStateOverlay {
|
2021-12-01 00:40:42 +01:00
|
|
|
/* 0x00 */ void* loadedRamAddr;
|
2024-02-29 05:15:04 -08:00
|
|
|
/* 0x04 */ RomFile file; // if applicable
|
2021-12-01 00:40:42 +01:00
|
|
|
/* 0x0C */ void* vramStart; // if applicable
|
|
|
|
/* 0x10 */ void* vramEnd; // if applicable
|
2022-06-05 18:48:44 +02:00
|
|
|
/* 0x14 */ void* unk_14;
|
2021-12-01 00:40:42 +01:00
|
|
|
/* 0x18 */ void* init; // initializes and executes the given context
|
|
|
|
/* 0x1C */ void* destroy; // deconstructs the context, and sets the next context to load
|
2022-06-05 18:48:44 +02:00
|
|
|
/* 0x20 */ void* unk_20;
|
|
|
|
/* 0x24 */ void* unk_24;
|
2021-12-01 00:40:42 +01:00
|
|
|
/* 0x28 */ UNK_TYPE4 unk_28;
|
|
|
|
/* 0x2C */ u32 instanceSize;
|
2020-03-17 00:31:30 -04:00
|
|
|
} GameStateOverlay; // size = 0x30
|
|
|
|
|
2024-08-12 00:07:48 -07:00
|
|
|
typedef struct ISVDbg {
|
2020-03-22 22:50:11 +01:00
|
|
|
/* 0x00 */ u32 magic; // IS64
|
2020-03-17 00:31:30 -04:00
|
|
|
/* 0x04 */ u32 get;
|
|
|
|
/* 0x08 */ u8 unk_08[0x14-0x08];
|
|
|
|
/* 0x14 */ u32 put;
|
|
|
|
/* 0x18 */ u8 unk_18[0x20-0x18];
|
|
|
|
/* 0x20 */ u8 data[0x10000-0x20];
|
|
|
|
} ISVDbg;
|
|
|
|
|
2024-08-12 00:07:48 -07:00
|
|
|
typedef struct LocaleCartInfo {
|
2020-04-14 01:03:10 +02:00
|
|
|
/* 0x00 */ char name[0x18];
|
|
|
|
/* 0x18 */ u32 mediaFormat;
|
|
|
|
/* 0x1C */ union {
|
2020-03-22 22:50:11 +01:00
|
|
|
struct {
|
2020-03-17 00:31:30 -04:00
|
|
|
u16 cartId;
|
|
|
|
u8 countryCode;
|
|
|
|
u8 version;
|
|
|
|
};
|
|
|
|
u32 regionInfo;
|
|
|
|
};
|
2020-04-14 01:03:10 +02:00
|
|
|
} LocaleCartInfo; // size = 0x20
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2024-08-12 00:07:48 -07:00
|
|
|
typedef struct Yaz0Header {
|
2020-04-14 01:03:10 +02:00
|
|
|
/* 0x00 */ char magic[4]; // Yaz0
|
|
|
|
/* 0x04 */ u32 decSize;
|
2020-06-05 19:18:39 +02:00
|
|
|
/* 0x08 */ u32 compInfoOffset; // only used in mio0
|
|
|
|
/* 0x0C */ u32 uncompDataOffset; // only used in mio0
|
2024-01-29 15:14:30 -08:00
|
|
|
} Yaz0Header; // size = 0x10
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2023-02-27 08:14:02 +00:00
|
|
|
/* Relocation entry field getters */
|
|
|
|
#define RELOC_SECTION(reloc) ((reloc) >> 30)
|
|
|
|
#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF)
|
2022-05-31 11:28:17 -07:00
|
|
|
#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000)
|
|
|
|
#define RELOC_TYPE_SHIFT 24
|
|
|
|
|
2023-02-27 08:14:02 +00:00
|
|
|
/* MIPS Relocation Types, matches the MIPS ELF spec */
|
|
|
|
#define R_MIPS_32 2
|
|
|
|
#define R_MIPS_26 4
|
2022-05-31 11:28:17 -07:00
|
|
|
#define R_MIPS_HI16 5
|
|
|
|
#define R_MIPS_LO16 6
|
|
|
|
|
2023-02-27 08:14:02 +00:00
|
|
|
/* Reloc section id, must fit in 2 bits otherwise the relocation format must be modified */
|
2024-08-12 00:07:48 -07:00
|
|
|
typedef enum RelocSectionId {
|
2023-02-27 08:14:02 +00:00
|
|
|
/* 0 */ RELOC_SECTION_NULL,
|
|
|
|
/* 1 */ RELOC_SECTION_TEXT,
|
|
|
|
/* 2 */ RELOC_SECTION_DATA,
|
|
|
|
/* 3 */ RELOC_SECTION_RODATA,
|
|
|
|
/* 4 */ RELOC_SECTION_MAX
|
|
|
|
} RelocSectionId;
|
|
|
|
|
2020-03-17 00:31:30 -04:00
|
|
|
typedef struct OverlayRelocationSection {
|
|
|
|
/* 0x00 */ u32 textSize;
|
|
|
|
/* 0x04 */ u32 dataSize;
|
|
|
|
/* 0x08 */ u32 rodataSize;
|
|
|
|
/* 0x0C */ u32 bssSize;
|
|
|
|
/* 0x10 */ u32 nRelocations;
|
2023-02-27 08:14:02 +00:00
|
|
|
/* 0x14 */ u32 relocations[1]; // size is nRelocations
|
2020-03-18 21:22:00 +01:00
|
|
|
} OverlayRelocationSection; // size >= 0x18
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2024-02-28 00:01:47 +00:00
|
|
|
// This struct is used at osAppNMIBuffer which is not at an 8-byte aligned address. This causes an unaligned access
|
|
|
|
// crash if the OSTime variables use 64-bit load/store instructions, which is the case in any MIPS ABI other than O32
|
|
|
|
// where 64-bit load/store instructions are emulated with 2x 32-bit load/store instructions. The alignment attribute
|
|
|
|
// conveys that this structure will not always be 8-bytes aligned, allowing a modern compiler to generate non-crashing
|
|
|
|
// code for accessing these. This is not an issue in the original compiler as it only output O32 ABI code.
|
2024-08-12 00:07:48 -07:00
|
|
|
ALIGNED(4) typedef struct PreNmiBuff {
|
2020-03-20 12:43:51 +01:00
|
|
|
/* 0x00 */ u32 resetting;
|
|
|
|
/* 0x04 */ u32 resetCount;
|
|
|
|
/* 0x08 */ OSTime duration;
|
|
|
|
/* 0x10 */ OSTime resetTime;
|
2022-05-01 00:03:22 +01:00
|
|
|
} PreNmiBuff; // size = 0x18 (actually osAppNMIBuffer is 0x40 bytes large but the rest is unused)
|
2020-03-20 12:43:51 +01:00
|
|
|
|
2024-08-12 00:07:48 -07:00
|
|
|
typedef enum ViModeEditState {
|
2024-11-11 14:50:56 -08:00
|
|
|
#if OOT_VERSION < PAL_1_0
|
2024-10-09 06:48:53 -07:00
|
|
|
/* -2 */ VI_MODE_EDIT_STATE_NEGATIVE_2 = -2,
|
|
|
|
/* -1 */ VI_MODE_EDIT_STATE_NEGATIVE_1,
|
2024-11-11 14:50:56 -08:00
|
|
|
/* 0 */ VI_MODE_EDIT_STATE_INACTIVE,
|
|
|
|
/* 1 */ VI_MODE_EDIT_STATE_2, // active, more adjustments
|
|
|
|
/* 2 */ VI_MODE_EDIT_STATE_3 // active, more adjustments, print comparison with NTSC LAN1 mode
|
|
|
|
#else
|
2024-10-09 06:48:53 -07:00
|
|
|
/* 0 */ VI_MODE_EDIT_STATE_INACTIVE,
|
|
|
|
/* 1 */ VI_MODE_EDIT_STATE_ACTIVE,
|
|
|
|
/* 2 */ VI_MODE_EDIT_STATE_2, // active, more adjustments
|
|
|
|
/* 3 */ VI_MODE_EDIT_STATE_3 // active, more adjustments, print comparison with NTSC LAN1 mode
|
2024-11-11 14:50:56 -08:00
|
|
|
#endif
|
2022-11-13 23:07:27 +00:00
|
|
|
} ViModeEditState;
|
|
|
|
|
2024-08-12 00:07:48 -07:00
|
|
|
typedef struct ViMode {
|
2023-07-06 08:36:19 +10:00
|
|
|
/* 0x00 */ OSViMode customViMode;
|
|
|
|
/* 0x50 */ s32 viHeight;
|
|
|
|
/* 0x54 */ s32 viWidth;
|
|
|
|
/* 0x58 */ s32 rightAdjust;
|
|
|
|
/* 0x5C */ s32 leftAdjust;
|
|
|
|
/* 0x60 */ s32 lowerAdjust;
|
|
|
|
/* 0x64 */ s32 upperAdjust;
|
|
|
|
/* 0x68 */ s32 editState;
|
|
|
|
/* 0x6C */ s32 tvType;
|
|
|
|
/* 0x70 */ u32 loRes;
|
|
|
|
/* 0x74 */ u32 antialiasOff;
|
|
|
|
/* 0x78 */ u32 modeN; // Controls interlacing, the meaning of this mode is different based on choice of resolution
|
|
|
|
/* 0x7C */ u32 fb16Bit;
|
|
|
|
/* 0x80 */ u32 viFeatures;
|
|
|
|
/* 0x84 */ u32 unk_84;
|
|
|
|
} ViMode; // size = 0x88
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2020-03-17 00:31:30 -04:00
|
|
|
#endif
|