Skip to content

Commit

Permalink
Merge branch 'master' into cleanup_colchk_1
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragorn421 committed Nov 17, 2022
2 parents 353194c + 7ecafcf commit fa8bf58
Show file tree
Hide file tree
Showing 101 changed files with 2,404 additions and 1,949 deletions.
32 changes: 5 additions & 27 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,10 @@ void Main_ThreadEntry(void* arg);
void Idle_ThreadEntry(void* arg);
void ViConfig_UpdateVi(u32 black);
void ViConfig_UpdateBlack(void);
s32 DmaMgr_CompareName(const char* name1, const char* name2);
s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, u32 size);
s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction);
void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc);
const char* DmaMgr_GetFileNameImpl(uintptr_t vrom);
const char* DmaMgr_GetFileName(uintptr_t vrom);
void DmaMgr_ProcessMsg(DmaRequest* req);
void DmaMgr_ThreadEntry(void* arg);
s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg);
s32 DmaMgr_SendRequest0(void* ram, uintptr_t vrom, u32 size);
void DmaMgr_Init(void);
s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg,
const char* file, s32 line);
s32 DmaMgr_SendRequest1(void* ram, uintptr_t vrom, u32 size, const char* file, s32 line);
void* Yaz0_FirstDMA(void);
void* Yaz0_NextDMA(u8* curSrcPos);
void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst);
void Yaz0_Decompress(uintptr_t romStart, u8* dst, u32 size);
void Yaz0_Decompress(uintptr_t romStart, u8* dst, size_t size);
void Locale_Init(void);
void Locale_ResetRegion(void);
u32 func_80001F48(void);
Expand Down Expand Up @@ -995,9 +981,9 @@ void Inventory_ChangeAmmo(s16 item, s16 ammoChange);
void Magic_Fill(PlayState* play);
void Magic_Reset(PlayState* play);
s32 Magic_RequestChange(PlayState* play, s16 amount, s16 type);
void func_80088AA0(s16 arg0);
void func_80088AF0(PlayState* play);
void func_80088B34(s16 arg0);
void Interface_SetSubTimer(s16 seconds);
void Interface_SetSubTimerToFinalSecond(PlayState* play);
void Interface_SetTimer(s16 seconds);
void Interface_Draw(PlayState* play);
void Interface_Update(PlayState* play);
Path* Path_GetByIndex(PlayState* play, s16 index, s16 max);
Expand Down Expand Up @@ -1039,7 +1025,7 @@ s32 Player_GetBottleHeld(Player* this);
s32 Player_ActionToExplosive(Player* this, s32 itemAction);
s32 Player_GetExplosiveHeld(Player* this);
s32 func_8008F2BC(Player* this, s32 itemAction);
s32 func_8008F2F8(PlayState* play);
s32 Player_GetEnvironmentalHazard(PlayState* play);
void Player_DrawImpl(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic,
s32 boots, s32 face, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw,
void* data);
Expand Down Expand Up @@ -1394,14 +1380,6 @@ void DbCamera_Reset(Camera* cam, DbCamera* dbCam);
// ? DbCamera_UpdateDemoControl(?);
void func_800BB0A0(f32 u, Vec3f* pos, f32* roll, f32* viewAngle, f32* point0, f32* point1, f32* point2, f32* point3);
s32 func_800BB2B4(Vec3f* pos, f32* roll, f32* fov, CutsceneCameraPoint* point, s16* keyFrame, f32* curFrame);
s32 Mempak_Init(s32 controllerNb);
s32 Mempak_GetFreeBytes(s32 controllerNb);
s32 Mempak_FindFile(s32 controllerNb, char start, char end);
s32 Mempak_Write(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size);
s32 Mempak_Read(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size);
s32 Mempak_Alloc(s32 controllerNb, char* idx, s32 size);
s32 Mempak_DeleteFile(s32 controllerNb, char idx);
s32 Mempak_GetFileSize(s32 controllerNb, char idx);
void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl);
void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl);
void KaleidoManager_Init(PlayState* play);
Expand Down
10 changes: 5 additions & 5 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#define SLOT(item) gItemSlots[item]
#define INV_CONTENT(item) gSaveContext.inventory.items[SLOT(item)]
#define AMMO(item) gSaveContext.inventory.ammo[SLOT(item)]
#define BEANS_BOUGHT AMMO(ITEM_BEAN + 1)
#define BEANS_BOUGHT AMMO(ITEM_MAGIC_BEAN + 1)

#define ALL_EQUIP_VALUE(equip) ((s32)(gSaveContext.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip])
#define CUR_EQUIP_VALUE(equip) ((s32)(gSaveContext.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip])
Expand Down Expand Up @@ -92,10 +92,10 @@
#define SET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] |= (1 << ((flag) & 0xF)))
#define CLEAR_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF)))

#define B_BTN_ITEM ((gSaveContext.buttonStatus[0] == ITEM_NONE) \
? ITEM_NONE \
: (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KNIFE) \
? ITEM_SWORD_BGS \
#define B_BTN_ITEM ((gSaveContext.buttonStatus[0] == ITEM_NONE) \
? ITEM_NONE \
: (gSaveContext.equips.buttonItems[0] == ITEM_GIANTS_KNIFE) \
? ITEM_SWORD_BIGGORON \
: gSaveContext.equips.buttonItems[0])

#define C_BTN_ITEM(button) ((gSaveContext.buttonStatus[(button) + 1] != BTN_DISABLED) \
Expand Down
21 changes: 21 additions & 0 deletions include/mempak.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef MEMPAK_H
#define MEMPAK_H

#include "ultra64.h"

s32 Mempak_Init(s32 controllerNum);
s32 Mempak_GetFreeBytes(s32 controllerNum);
s32 Mempak_FindFiles(s32 controllerNum, char start, char end);
s32 Mempak_Write(s32 controllerNum, char letter, void* buffer, s32 offset, s32 size);
s32 Mempak_Read(s32 controllerNum, char letter, void* buffer, s32 offset, s32 size);
s32 Mempak_CreateFile(s32 controllerNum, char* letter, s32 size);
s32 Mempak_DeleteFile(s32 controllerNum, char letter);
s32 Mempak_GetFileSize(s32 controllerNum, char letter);

// Converts a file letter to its numerical index
#define MEMPAK_LETTER_TO_INDEX(c) ((c) - 'A')

// Converts a numerical index to a file letter
#define MEMPAK_INDEX_TO_LETTER(i) ((i) + 'A')

#endif
3 changes: 0 additions & 3 deletions include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ extern u32 osMemSize;
extern u8 osAppNMIBuffer[0x40];

extern s8 D_80009430;
extern u32 gDmaMgrVerbose;
extern u32 gDmaMgrDmaBuffSize;
extern vu8 gViConfigBlack;
extern u8 gViConfigAdditionalScanLines;
extern u32 gViConfigFeatures;
Expand Down Expand Up @@ -53,7 +51,6 @@ extern OSTime __osCurrentTime;
extern u32 __osBaseCounter;
extern u32 __osViIntrCount;
extern u32 __osTimerCounter;
extern DmaEntry gDmaDataTable[0x60C];
extern EffectSsOverlay gEffectSsOverlayTable[EFFECT_SS_TYPE_MAX];
extern Gfx D_80116280[];
extern ActorOverlay gActorOverlayTable[ACTOR_ID_MAX]; // original name: "actor_dlftbls" 801162A0
Expand Down
30 changes: 29 additions & 1 deletion include/z64.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "fault.h"
#include "sched.h"
#include "rumble.h"
#include "mempak.h"
#include "tha.h"
#include "thga.h"

Expand Down Expand Up @@ -419,11 +420,14 @@ typedef enum {
// TODO get these properties from the textures themselves
#define FONT_CHAR_TEX_WIDTH 16
#define FONT_CHAR_TEX_HEIGHT 16
#define FONT_CHAR_TEX_SIZE ((16 * 16) / 2) // 16x16 I4 texture
#define FONT_CHAR_TEX_SIZE ((FONT_CHAR_TEX_WIDTH * FONT_CHAR_TEX_HEIGHT) / 2) // 16x16 I4 texture

// TODO get these properties from the textures themselves
#define MESSAGE_STATIC_TEX_SIZE 0x1000

// TODO get these properties from the textures themselves
#define MESSAGE_TEXTURE_STATIC_TEX_SIZE 0x900

typedef enum {
/* 0x00 */ MSGMODE_NONE,
/* 0x01 */ MSGMODE_TEXT_START,
Expand Down Expand Up @@ -615,6 +619,11 @@ typedef enum {
/* 0x1D */ DO_ACTION_MAX
} DoAction;

// TODO extract this information from the texture definitions themselves
#define DO_ACTION_TEX_WIDTH 48
#define DO_ACTION_TEX_HEIGHT 16
#define DO_ACTION_TEX_SIZE ((DO_ACTION_TEX_WIDTH * DO_ACTION_TEX_HEIGHT) / 2) // (sizeof(gCheckDoActionENGTex))

typedef struct {
/* 0x0000 */ View view;
/* 0x0128 */ Vtx* actionVtx;
Expand Down Expand Up @@ -1428,6 +1437,25 @@ typedef struct {
/* 0x6C */ s16* skullFloorIconY; // dungeon big skull icon Y pos
} MapData; // size = 0x70

// TODO get these properties from the textures themselves
#define MAP_I_TEX_WIDTH 96
#define MAP_I_TEX_HEIGHT 85
#define MAP_I_TEX_SIZE ((MAP_I_TEX_WIDTH * MAP_I_TEX_HEIGHT) / 2) // 96x85 I4 texture

#define MAP_48x85_TEX_WIDTH 48
#define MAP_48x85_TEX_HEIGHT 85
#define MAP_48x85_TEX_SIZE ((MAP_48x85_TEX_WIDTH * MAP_48x85_TEX_HEIGHT) / 2) // 48x85 CI4 texture

// Note that z_kaleido_scope_PAL.c assumes that the dimensions and texture format here also matches the dimensions and
// texture format for ITEM_NAME_TEX_*
#define MAP_NAME_TEX1_WIDTH 128
#define MAP_NAME_TEX1_HEIGHT 16
#define MAP_NAME_TEX1_SIZE ((MAP_NAME_TEX1_WIDTH * MAP_NAME_TEX1_HEIGHT) / 2) // 128x16 IA4 texture

#define MAP_NAME_TEX2_WIDTH 80
#define MAP_NAME_TEX2_HEIGHT 32
#define MAP_NAME_TEX2_SIZE (MAP_NAME_TEX2_WIDTH * MAP_NAME_TEX2_HEIGHT) // 80x32 IA8 texture

#define PAUSE_MAP_MARK_NONE -1
#define PAUSE_MAP_MARK_CHEST 0
#define PAUSE_MAP_MARK_BOSS 1
Expand Down
2 changes: 1 addition & 1 deletion include/z64animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct Actor;
struct SkelAnime;

#define LINK_ANIMATION_OFFSET(addr, offset) \
(((u32)_link_animetionSegmentRomStart) + ((u32)addr) - ((u32)_link_animetionSegmentStart) + ((u32)offset))
(((uintptr_t)_link_animetionSegmentRomStart) + ((uintptr_t)(addr)) - ((uintptr_t)_link_animetionSegmentStart) + (offset))
#define LIMB_DONE 0xFF
#define ANIMATION_ENTRY_MAX 50
#define ANIM_FLAG_UPDATEY (1 << 1)
Expand Down
27 changes: 26 additions & 1 deletion include/z64dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
#define Z64_DMA_H

#include "ultra64.h"
#include "alignment.h"

typedef struct {
/* 0x00 */ uintptr_t vromAddr; // VROM address (source)
/* 0x04 */ void* dramAddr; // DRAM address (destination)
/* 0x08 */ u32 size; // File Transfer size
/* 0x08 */ size_t size; // File Transfer size
/* 0x0C */ const char* filename; // Filename for debugging
/* 0x10 */ s32 line; // Line for debugging
/* 0x14 */ s32 unk_14;
Expand All @@ -21,4 +22,28 @@ typedef struct {
/* 0x0C */ uintptr_t romEnd;
} DmaEntry;

extern DmaEntry gDmaDataTable[];

extern u32 gDmaMgrVerbose;
extern size_t gDmaMgrDmaBuffSize;

#define DMAMGR_DEFAULT_BUFSIZE ALIGN16(0x2000)

// Standard DMA Requests

s32 DmaMgr_RequestSync(void* ram, uintptr_t vrom, size_t size);
s32 DmaMgr_RequestSyncDebug(void* ram, uintptr_t vrom, size_t size, const char* file, s32 line);
s32 DmaMgr_RequestAsync(DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk5, OSMesgQueue* queue,
OSMesg msg, const char* file, s32 line);

// Special-purpose DMA Requests

s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size);
void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size);
s32 DmaMgr_AudioDmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction);

// Initialization

void DmaMgr_Init(void);

#endif
Loading

0 comments on commit fa8bf58

Please sign in to comment.