From de1a08c0612c36ca7528b9208a5a28d47d6b830a Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sun, 8 Sep 2024 18:02:38 +0200 Subject: [PATCH] [headers 11] stackcheck.h, jpeg functions (#2171) * [headers 11] stackcheck.h, jpeg functions * bss --- include/functions.h | 19 ++------------- include/jpeg.h | 7 ++++++ include/stack.h | 2 ++ include/stackcheck.h | 27 +++++++++++++++++++++ include/z64.h | 17 +------------ src/code/fault_gc.c | 4 +-- src/code/jpegdecoder.c | 4 +++ src/overlays/actors/ovl_En_Xc/z_en_xc.c | 2 +- src/overlays/actors/ovl_Fishing/z_fishing.c | 2 +- 9 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 include/stackcheck.h diff --git a/include/functions.h b/include/functions.h index e134758eab..ada903e586 100644 --- a/include/functions.h +++ b/include/functions.h @@ -25,10 +25,6 @@ NORETURN void func_80002384(const char* exp, const char* file, int line); #endif OSPiHandle* osDriveRomInit(void); void Mio0_Decompress(u8* src, u8* dst); -void StackCheck_Init(StackEntry* entry, void* stackBottom, void* stackTop, u32 initValue, s32 minSpace, - const char* name); -void StackCheck_Cleanup(StackEntry* entry); -u32 StackCheck_Check(StackEntry* entry); #if OOT_DEBUG void LogUtils_LogHexDump(void* ptr, s32 size0); void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, int line); @@ -687,7 +683,7 @@ void func_8006D0EC(PlayState* play, Player* player); void func_8006D684(PlayState* play, Player* player); void func_8006DC68(PlayState* play, Player* player); void func_8006DD9C(Actor* actor, Vec3f* arg1, s16 arg2); -s32 Jpeg_Decode(void* data, void* zbuffer, void* work, u32 workSize); + void KaleidoSetup_Update(PlayState* play); void KaleidoSetup_Init(PlayState* play); void KaleidoSetup_Destroy(PlayState* play); @@ -1419,18 +1415,7 @@ void Sleep_Nsec(u32 nsec); void Sleep_Usec(u32 usec); void Sleep_Msec(u32 ms); void Sleep_Sec(u32 sec); -void JpegUtils_ProcessQuantizationTable(u8* dqt, JpegQuantizationTable* qt, u8 count); -s32 JpegUtils_ParseHuffmanCodesLengths(u8* ptr, u8* codesLengths); -s32 JpegUtils_GetHuffmanCodes(u8* codesLengths, u16* codes); -s32 JpegUtils_SetHuffmanTable(u8* data, JpegHuffmanTable* ht, u16* codes); -u32 JpegUtils_ProcessHuffmanTableImpl(u8* data, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 isAc); -u32 JpegUtils_ProcessHuffmanTable(u8* dht, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 count); -void JpegUtils_SetHuffmanTableOld(u8* data, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes, s16 count, u8 isAc); -u32 JpegUtils_ProcessHuffmanTableImplOld(u8* dht, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes); -s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollowing, JpegDecoderState* state); -s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, u16* mcu, s16* unk); -s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount); -u16 JpegDecoder_ReadBits(u8 len); + s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes); void guScale(Mtx* m, f32 x, f32 y, f32 z); OSTask* _VirtualToPhysicalTask(OSTask* intp); diff --git a/include/jpeg.h b/include/jpeg.h index 85b048baf3..4dab27632a 100644 --- a/include/jpeg.h +++ b/include/jpeg.h @@ -77,4 +77,11 @@ typedef struct JpegDecoderState { /* 0x10 */ s16 unk_10; } JpegDecoderState; // size = 0x14 +s32 Jpeg_Decode(void* data, void* zbuffer, void* work, u32 workSize); + +void JpegUtils_ProcessQuantizationTable(u8* dqt, JpegQuantizationTable* qt, u8 count); +u32 JpegUtils_ProcessHuffmanTable(u8* dht, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 count); + +s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollowing, JpegDecoderState* state); + #endif diff --git a/include/stack.h b/include/stack.h index 231f0d061b..3667862cb6 100644 --- a/include/stack.h +++ b/include/stack.h @@ -1,6 +1,8 @@ #ifndef STACK_H #define STACK_H +#include "alignment.h" + #define STACK(stack, size) \ u64 stack[ALIGN8(size) / sizeof(u64)] diff --git a/include/stackcheck.h b/include/stackcheck.h new file mode 100644 index 0000000000..33b4a674c9 --- /dev/null +++ b/include/stackcheck.h @@ -0,0 +1,27 @@ +#ifndef STACKCHECK_H +#define STACKCHECK_H + +#include "ultra64.h" + +typedef enum StackStatus { + /* 0 */ STACK_STATUS_OK, + /* 1 */ STACK_STATUS_WARNING, + /* 2 */ STACK_STATUS_OVERFLOW +} StackStatus; + +typedef struct StackEntry { + /* 0x00 */ struct StackEntry* next; + /* 0x04 */ struct StackEntry* prev; + /* 0x08 */ u32* head; + /* 0x0C */ u32* tail; + /* 0x10 */ u32 initValue; + /* 0x14 */ s32 minSpace; + /* 0x18 */ const char* name; +} StackEntry; + +void StackCheck_Init(StackEntry* entry, void* stackBottom, void* stackTop, u32 initValue, s32 minSpace, + const char* name); +void StackCheck_Cleanup(StackEntry* entry); +u32 StackCheck_Check(StackEntry* entry); + +#endif diff --git a/include/z64.h b/include/z64.h index 03354915d0..9fbb9b6a94 100644 --- a/include/z64.h +++ b/include/z64.h @@ -69,6 +69,7 @@ #include "sys_matrix.h" #include "main.h" #include "segmented_address.h" +#include "stackcheck.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -397,22 +398,6 @@ typedef struct DebugDispObject { /* 0x28 */ struct DebugDispObject* next; } DebugDispObject; // size = 0x2C -typedef struct StackEntry { - /* 0x00 */ struct StackEntry* next; - /* 0x04 */ struct StackEntry* prev; - /* 0x08 */ u32* head; - /* 0x0C */ u32* tail; - /* 0x10 */ u32 initValue; - /* 0x14 */ s32 minSpace; - /* 0x18 */ const char* name; -} StackEntry; - -typedef enum StackStatus { - /* 0 */ STACK_STATUS_OK, - /* 1 */ STACK_STATUS_WARNING, - /* 2 */ STACK_STATUS_OVERFLOW -} StackStatus; - typedef struct ISVDbg { /* 0x00 */ u32 magic; // IS64 /* 0x04 */ u32 get; diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c index 67dbb34569..32d99f368b 100644 --- a/src/code/fault_gc.c +++ b/src/code/fault_gc.c @@ -42,8 +42,8 @@ */ #if PLATFORM_GC -#pragma increment_block_number "gc-eu:208 gc-eu-mq:208 gc-eu-mq-dbg:208 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224" \ - "gc-us-mq:224" +#pragma increment_block_number "gc-eu:208 gc-eu-mq:208 gc-eu-mq-dbg:208 gc-jp:208 gc-jp-ce:208 gc-jp-mq:208 gc-us:208" \ + "gc-us-mq:208" #include "global.h" #include "alloca.h" diff --git a/src/code/jpegdecoder.c b/src/code/jpegdecoder.c index c0c772abd6..a29752511c 100644 --- a/src/code/jpegdecoder.c +++ b/src/code/jpegdecoder.c @@ -1,5 +1,9 @@ #include "global.h" +s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, u16* mcu, s16* unk); +s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount); +u16 JpegDecoder_ReadBits(u8 len); + u8* sJpegBitStreamPtr; u32 sJpegBitStreamByteIdx; u8 sJpegBitStreamBitIdx; diff --git a/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/src/overlays/actors/ovl_En_Xc/z_en_xc.c index bd424121e2..b8f9cf9d5f 100644 --- a/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -1395,7 +1395,7 @@ void func_80B3F3D8(void) { Sfx_PlaySfxCentered2(NA_SE_PL_SKIP); } -#pragma increment_block_number "gc-eu:128 gc-eu-mq:64 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:64 gc-jp:128 gc-jp-ce:128 gc-jp-mq:64 gc-us:128 gc-us-mq:64" void EnXc_PlayDiveSFX(Vec3f* src, PlayState* play) { static Vec3f D_80B42DA0; diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index e446b7f8b8..b60c3ee476 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -15,7 +15,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:142 gc-eu-mq:142 gc-jp:144 gc-jp-ce:144 gc-jp-mq:144 gc-us:144 gc-us-mq:144" +#pragma increment_block_number "gc-eu:141 gc-eu-mq:141 gc-jp:143 gc-jp-ce:143 gc-jp-mq:143 gc-us:143 gc-us-mq:143" #define FLAGS ACTOR_FLAG_4