summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorengineer124 <47598039+engineer124@users.noreply.github.com>2023-09-16 08:34:16 +1000
committerGitHub <noreply@github.com>2023-09-15 19:34:16 -0300
commitdf800c74aecfb6b89ee976df8a2f11451f295e37 (patch)
treecf51aeffe924ebcfb11ec0d0511358fd7b06027a /include
parent4b30f1a6549c99eff5344a815b12f54e69d689e9 (diff)
PreRender.c OK (#1320)
* begin prerender * match func_801716C4 * copy more docs from OoT * begin func_801720FC * improve func_801720FC * match func_801720FC * background 2D * merge master * func_801717F8 attempt * z64prerender.h * import bss * non-equivalent * document func_801716C4 * cleanup comments * import tharo docs * minor improvement on PreRender_DivotFilter * Match PreRender_DivotFilter * Remove fakes * format * Fix comment about RM_VISCVG in PreRender_FetchFbufCoverage * PreRender cleanup * PR Review * review * listalloc.h * bss * capitalization --------- Co-authored-by: angie <angheloalf95@gmail.com> Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/functions.h32
-rw-r--r--include/listalloc.h16
-rw-r--r--include/z64.h48
-rw-r--r--include/z64prerender.h73
4 files changed, 90 insertions, 79 deletions
diff --git a/include/functions.h b/include/functions.h
index 4c6c74cef..31ebb9c20 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -1160,34 +1160,6 @@ void Play_AssignPlayerCsIdsFromScene(GameState* thisx, s32 spawnCsId);
void Play_FillScreen(GameState* thisx, s16 fillScreenOn, u8 red, u8 green, u8 blue, u8 alpha);
void Play_Init(GameState* thisx);
-void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg);
-void PreRender_Init(PreRender* this);
-void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf);
-void PreRender_Destroy(PreRender* this);
-void func_8016FDB8(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 arg4);
-void func_8016FF70(PreRender* this, Gfx** gfxp, void* buf, void* bufSave);
-void func_8016FF90(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, s32 envR, s32 envG, s32 envB, s32 envA);
-void func_80170200(PreRender* this, Gfx** gfxp, void* buf, void* bufSave);
-void func_8017023C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave);
-void func_8017057C(PreRender* this, Gfx** gfxp);
-void func_801705B4(PreRender* this, Gfx** gfxp);
-void func_801705EC(PreRender* this, Gfx** gfxp);
-void func_80170730(PreRender* this, Gfx** gfxp);
-void func_80170774(PreRender* this, Gfx** gfxp);
-void func_80170798(PreRender* this, Gfx** gfxp);
-void func_80170AE0(PreRender* this, Gfx** gfxp, s32 alpha);
-void func_80170B28(PreRender* this, Gfx** gfxp);
-void PreRender_AntiAliasAlgorithm(PreRender* this, s32 x, s32 y);
-void PreRender_ApplyAntiAliasingFilter(PreRender* this);
-u32 func_801716C4(u8* arg0, u8* arg1, u8* arg2);
-void func_801717F8(PreRender* this);
-void PreRender_ApplyFilters(PreRender* this);
-void PreRender_ApplyFiltersSlowlyInit(PreRender* this);
-void PreRender_ApplyFiltersSlowlyDestroy(PreRender* this);
-void func_801720C4(PreRender* this);
-void func_801720FC(PreRenderParams* params, Gfx** gfxp);
-void Prerender_DrawBackground2D(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags);
-
void GameAlloc_Log(GameAlloc* this);
void* GameAlloc_Malloc(GameAlloc* this, size_t size);
void GameAlloc_Free(GameAlloc* this, void* data);
@@ -1208,10 +1180,6 @@ void Graph_ThreadEntry(void* arg);
Gfx* Graph_GfxPlusOne(Gfx* gfx);
Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst);
void* Graph_DlistAlloc(Gfx** gfx, size_t size);
-ListAlloc* ListAlloc_Init(ListAlloc* this);
-// void ListAlloc_Alloc(void);
-// void ListAlloc_Free(void);
-void ListAlloc_FreeAll(ListAlloc* this);
void Sched_SwapFramebuffer(CfbInfo* cfbInfo);
void Sched_RetraceUpdateFramebuffer(SchedContext* sched, CfbInfo* cfbInfo);
diff --git a/include/listalloc.h b/include/listalloc.h
new file mode 100644
index 000000000..e4ca07f07
--- /dev/null
+++ b/include/listalloc.h
@@ -0,0 +1,16 @@
+#ifndef LISTALLOC_H
+#define LISTALLOC_H
+
+#include "ultra64.h"
+
+typedef struct ListAlloc {
+ /* 0x0 */ struct ListAlloc* prev;
+ /* 0x4 */ struct ListAlloc* next;
+} ListAlloc; // size = 0x8
+
+ListAlloc* ListAlloc_Init(ListAlloc* this);
+void* ListAlloc_Alloc(ListAlloc* this, size_t size);
+void ListAlloc_Free(ListAlloc* this, void* data);
+void ListAlloc_FreeAll(ListAlloc* this);
+
+#endif
diff --git a/include/z64.h b/include/z64.h
index ca9748509..63aec32ef 100644
--- a/include/z64.h
+++ b/include/z64.h
@@ -52,6 +52,7 @@
#include "z64object.h"
#include "z64ocarina.h"
#include "z64player.h"
+#include "z64prerender.h"
#include "z64save.h"
#include "z64scene.h"
#include "z64schedule.h"
@@ -222,53 +223,6 @@ typedef struct {
/* 0xFA */ u8 unk_FA[4];
} EnvironmentContext; // size = 0x100
-typedef struct ListAlloc {
- /* 0x0 */ struct ListAlloc* prev;
- /* 0x4 */ struct ListAlloc* next;
-} ListAlloc; // size = 0x8
-
-typedef struct {
- /* 0x00 */ u16 width;
- /* 0x02 */ u16 height;
- /* 0x04 */ u16 widthSave;
- /* 0x06 */ u16 heightSave;
- /* 0x08 */ char unk_8[8];
- /* 0x10 */ u16* fbuf;
- /* 0x14 */ u16* fbufSave;
- /* 0x18 */ u8* cvgSave;
- /* 0x1C */ u16* zbuf;
- /* 0x20 */ u16* zbufSave;
- /* 0x24 */ u16 ulxSave;
- /* 0x26 */ u16 ulySave;
- /* 0x28 */ u16 lrxSave;
- /* 0x2A */ u16 lrySave;
- /* 0x2C */ u16 ulx;
- /* 0x2E */ u16 uly;
- /* 0x30 */ u16 lrx;
- /* 0x32 */ u16 lry;
- /* 0x34 */ char unk_34[16];
- /* 0x44 */ ListAlloc alloc;
- /* 0x4C */ u8 unk_4C;
- /* 0x4D */ u8 unk_4D;
- /* 0x4E */ char unk_4E[2];
-} PreRender; // size = 0x50
-
-typedef struct {
- /* 0x00 */ void* timg;
- /* 0x04 */ void* tlut;
- /* 0x08 */ u16 width;
- /* 0x0A */ u16 height;
- /* 0x0C */ u8 fmt;
- /* 0x0D */ u8 siz;
- /* 0x0E */ u16 tt;
- /* 0x10 */ u16 unk_10;
- /* 0x14 */ f32 x;
- /* 0x18 */ f32 y;
- /* 0x1C */ f32 xScale;
- /* 0x20 */ f32 yScale;
- /* 0x24 */ u32 flags;
-} PreRenderParams; // size = 0x28
-
struct PlayState;
typedef struct {
diff --git a/include/z64prerender.h b/include/z64prerender.h
new file mode 100644
index 000000000..813f6827a
--- /dev/null
+++ b/include/z64prerender.h
@@ -0,0 +1,73 @@
+#ifndef Z64_PRERENDER_H
+#define Z64_PRERENDER_H
+
+#include "ultra64.h"
+#include "listalloc.h"
+#include "unk.h"
+
+#define BG2D_FLAGS_1 (1 << 0)
+#define BG2D_FLAGS_2 (1 << 1)
+#define BG2D_FLAGS_AC_THRESHOLD (1 << 2)
+#define BG2D_FLAGS_LOAD_S2DEX2 (1 << 3)
+#define BG2D_FLAGS_COPY (1 << 4)
+
+typedef enum PrerenderFilterState {
+ /* 0 */ PRERENDER_FILTER_STATE_NONE,
+ /* 1 */ PRERENDER_FILTER_STATE_PROCESS,
+ /* 2 */ PRERENDER_FILTER_STATE_DONE
+} PrerenderFilterState;
+
+typedef struct PreRender {
+ /* 0x00 */ u16 width;
+ /* 0x02 */ u16 height;
+ /* 0x04 */ u16 widthSave;
+ /* 0x06 */ u16 heightSave;
+ /* 0x08 */ UNK_TYPE1 unk_08[0x8];
+ /* 0x10 */ u16* fbuf;
+ /* 0x14 */ u16* fbufSave;
+ /* 0x18 */ u8* cvgSave;
+ /* 0x1C */ u16* zbuf;
+ /* 0x20 */ u16* zbufSave;
+ /* 0x24 */ u16 ulxSave;
+ /* 0x26 */ u16 ulySave;
+ /* 0x28 */ u16 lrxSave;
+ /* 0x2A */ u16 lrySave;
+ /* 0x2C */ u16 ulx;
+ /* 0x2E */ u16 uly;
+ /* 0x30 */ u16 lrx;
+ /* 0x32 */ u16 lry;
+ /* 0x34 */ UNK_TYPE1 unk_34[0x10];
+ /* 0x44 */ ListAlloc alloc;
+ /* 0x4C */ u8 unk_4C;
+ /* 0x4D */ u8 filterState; // See `PrerenderFilterState`
+} PreRender; // size = 0x50
+
+
+void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg);
+void PreRender_Init(PreRender* this);
+void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf);
+void PreRender_Destroy(PreRender* this);
+void PreRender_CopyImage(PreRender* this, Gfx** gfxp, void* img, void* imgDst, u32 useThresholdAlphaCompare);
+void PreRender_RestoreBuffer(PreRender* this, Gfx** gfxp, void* buf, void* bufSave);
+void func_8016FF90(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, s32 envR, s32 envG, s32 envB, s32 envA);
+void func_80170200(PreRender* this, Gfx** gfxp, void* buf, void* bufSave);
+void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxp, void* img, void* cvgDst);
+void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxp);
+void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp);
+void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp);
+void PreRender_DrawCoverage(PreRender* this, Gfx** gfxp);
+void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxp);
+void func_80170798(PreRender* this, Gfx** gfxp);
+void func_80170AE0(PreRender* this, Gfx** gfxp, s32 alpha);
+void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxp);
+void PreRender_AntiAliasFilterPixel(PreRender* this, s32 x, s32 y);
+void PreRender_AntiAliasFilter(PreRender* this);
+u32 PreRender_Get5bMedian9(u8* px1, u8* px2, u8* px3);
+void PreRender_DivotFilter(PreRender* this);
+void PreRender_ApplyFilters(PreRender* this);
+void PreRender_ApplyFiltersSlowlyInit(PreRender* this);
+void PreRender_ApplyFiltersSlowlyDestroy(PreRender* this);
+void func_801720C4(PreRender* this);
+void Prerender_DrawBackground2D(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 tlutCount, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags);
+
+#endif