diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2023-08-09 19:44:31 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-09 19:44:31 -0400 |
| commit | d107b6c2a922fff477075fb3525e6541b6d7f108 (patch) | |
| tree | cf2eb64789dc4ea7cd22cd2eec6620f7c316a875 /src/code | |
| parent | 17b774effe03aa959158d8a650bcb6b6bb9ac9a2 (diff) | |
`z64vi*.h` and `sys_cfb.h` headers (#1259)
* z64vimode.h
* z64viscvg.h
* z64vis*.h
* VisCvg
* sys_cfb.h
* a bit of naming
* review
* Renames
* bss
* fix
* bss
* bss
* bss
* messed up the merge
* bss is borken
* reordering 2
* remove prevent header from fault.c
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/game.c | 79 | ||||
| -rw-r--r-- | src/code/graph.c | 1 | ||||
| -rw-r--r-- | src/code/sys_cfb.c | 22 | ||||
| -rw-r--r-- | src/code/z_actor.c | 1 | ||||
| -rw-r--r-- | src/code/z_fbdemo_circle.c | 1 | ||||
| -rw-r--r-- | src/code/z_lights.c | 1 | ||||
| -rw-r--r-- | src/code/z_parameter.c | 1 | ||||
| -rw-r--r-- | src/code/z_play.c | 44 | ||||
| -rw-r--r-- | src/code/z_play_hireso.c | 1 | ||||
| -rw-r--r-- | src/code/z_player_call.c | 1 | ||||
| -rw-r--r-- | src/code/z_rcp.c | 1 | ||||
| -rw-r--r-- | src/code/z_scene_proc.c | 1 | ||||
| -rw-r--r-- | src/code/z_skin.c | 1 | ||||
| -rw-r--r-- | src/code/z_vimode.c | 1 | ||||
| -rw-r--r-- | src/code/z_viscvg.c | 7 | ||||
| -rw-r--r-- | src/code/z_vismono.c | 1 | ||||
| -rw-r--r-- | src/code/z_viszbuf.c | 3 |
17 files changed, 105 insertions, 62 deletions
diff --git a/src/code/game.c b/src/code/game.c index a5e02304c..0884de444 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -1,11 +1,22 @@ #include "global.h" #include "audiomgr.h" #include "idle.h" +#include "sys_cfb.h" #include "system_malloc.h" #include "z64debug_text.h" #include "z64rumble.h" +#include "z64vimode.h" +#include "z64viscvg.h" +#include "z64vismono.h" +#include "z64viszbuf.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" +extern UNK_TYPE1 D_801F7FF0; +extern VisCvg sGameVisCvg; +extern VisZbuf sGameVisZbuf; +extern VisMono sGameVisMono; +extern ViMode sGameViMode; + s32 gFramerateDivisor = 1; f32 gFramerateDivisorF = 1.0f; f32 gFramerateDivisorHalf = 1.0f / 2.0f; @@ -28,34 +39,34 @@ void GameState_SetFBFilter(Gfx** gfx, void* zbuffer) { Gfx* dlist = *gfx; if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) { - D_801F8010.type = R_FB_FILTER_TYPE; - D_801F8010.color.r = R_FB_FILTER_PRIM_COLOR(0); - D_801F8010.color.g = R_FB_FILTER_PRIM_COLOR(1); - D_801F8010.color.b = R_FB_FILTER_PRIM_COLOR(2); - D_801F8010.color.a = R_FB_FILTER_A; - VisCvg_Draw(&D_801F8010, &dlist); + sGameVisCvg.type = R_FB_FILTER_TYPE; + sGameVisCvg.color.r = R_FB_FILTER_PRIM_COLOR(0); + sGameVisCvg.color.g = R_FB_FILTER_PRIM_COLOR(1); + sGameVisCvg.color.b = R_FB_FILTER_PRIM_COLOR(2); + sGameVisCvg.color.a = R_FB_FILTER_A; + VisCvg_Draw(&sGameVisCvg, &dlist); } else if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) { - sVisZbuf.useRgba = (R_FB_FILTER_TYPE == 6); - sVisZbuf.primColor.r = R_FB_FILTER_PRIM_COLOR(0); - sVisZbuf.primColor.g = R_FB_FILTER_PRIM_COLOR(1); - sVisZbuf.primColor.b = R_FB_FILTER_PRIM_COLOR(2); - sVisZbuf.primColor.a = R_FB_FILTER_A; - sVisZbuf.envColor.r = R_FB_FILTER_ENV_COLOR(0); - sVisZbuf.envColor.g = R_FB_FILTER_ENV_COLOR(1); - sVisZbuf.envColor.b = R_FB_FILTER_ENV_COLOR(2); - sVisZbuf.envColor.a = R_FB_FILTER_A; - VisZbuf_Draw(&sVisZbuf, &dlist, zbuffer); + sGameVisZbuf.useRgba = (R_FB_FILTER_TYPE == 6); + sGameVisZbuf.primColor.r = R_FB_FILTER_PRIM_COLOR(0); + sGameVisZbuf.primColor.g = R_FB_FILTER_PRIM_COLOR(1); + sGameVisZbuf.primColor.b = R_FB_FILTER_PRIM_COLOR(2); + sGameVisZbuf.primColor.a = R_FB_FILTER_A; + sGameVisZbuf.envColor.r = R_FB_FILTER_ENV_COLOR(0); + sGameVisZbuf.envColor.g = R_FB_FILTER_ENV_COLOR(1); + sGameVisZbuf.envColor.b = R_FB_FILTER_ENV_COLOR(2); + sGameVisZbuf.envColor.a = R_FB_FILTER_A; + VisZbuf_Draw(&sGameVisZbuf, &dlist, zbuffer); } else if (R_FB_FILTER_TYPE == 7) { - sMonoColors.unk_00 = 0; - sMonoColors.primColor.r = R_FB_FILTER_PRIM_COLOR(0); - sMonoColors.primColor.g = R_FB_FILTER_PRIM_COLOR(1); - sMonoColors.primColor.b = R_FB_FILTER_PRIM_COLOR(2); - sMonoColors.primColor.a = R_FB_FILTER_A; - sMonoColors.envColor.r = R_FB_FILTER_ENV_COLOR(0); - sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1); - sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2); - sMonoColors.envColor.a = R_FB_FILTER_A; - VisMono_Draw(&sMonoColors, &dlist); + sGameVisMono.unk_00 = 0; + sGameVisMono.primColor.r = R_FB_FILTER_PRIM_COLOR(0); + sGameVisMono.primColor.g = R_FB_FILTER_PRIM_COLOR(1); + sGameVisMono.primColor.b = R_FB_FILTER_PRIM_COLOR(2); + sGameVisMono.primColor.a = R_FB_FILTER_A; + sGameVisMono.envColor.r = R_FB_FILTER_ENV_COLOR(0); + sGameVisMono.envColor.g = R_FB_FILTER_ENV_COLOR(1); + sGameVisMono.envColor.b = R_FB_FILTER_ENV_COLOR(2); + sGameVisMono.envColor.a = R_FB_FILTER_A; + VisMono_Draw(&sGameVisMono, &dlist); } *gfx = dlist; @@ -209,10 +220,10 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g init(gameState); - VisCvg_Init(&D_801F8010); - VisZbuf_Init(&sVisZbuf); - VisMono_Init(&sMonoColors); - ViMode_Init(&D_801F8048); + VisCvg_Init(&sGameVisCvg); + VisZbuf_Init(&sGameVisZbuf); + VisMono_Init(&sGameVisMono); + ViMode_Init(&sGameViMode); func_801773A0(&D_801F7FF0); Rumble_Init(); @@ -230,10 +241,10 @@ void GameState_Destroy(GameState* gameState) { Rumble_Destroy(); func_801773C4(&D_801F7FF0); - VisCvg_Destroy(&D_801F8010); - VisZbuf_Destroy(&sVisZbuf); - VisMono_Destroy(&sMonoColors); - ViMode_Destroy(&D_801F8048); + VisCvg_Destroy(&sGameVisCvg); + VisZbuf_Destroy(&sGameVisZbuf); + VisMono_Destroy(&sGameVisMono); + ViMode_Destroy(&sGameViMode); THA_Destroy(&gameState->heap); GameAlloc_Cleanup(&gameState->alloc); } diff --git a/src/code/graph.c b/src/code/graph.c index ce929e6c0..24a554dc2 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -14,6 +14,7 @@ OSTime sGraphTaskStartTime; #include "macros.h" #include "buffers.h" #include "idle.h" +#include "sys_cfb.h" #include "system_malloc.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/gamestates/ovl_file_choose/z_file_select.h" diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c index 29d6e39c4..383a35cc9 100644 --- a/src/code/sys_cfb.c +++ b/src/code/sys_cfb.c @@ -1,11 +1,9 @@ -#include "prevent_bss_reordering.h" -#include "global.h" -#include "buffers.h" -#include "system_malloc.h" - -extern u16 gFramebufferHiRes0[HIRES_BUFFER_WIDTH][HIRES_BUFFER_HEIGHT]; -extern u16 gFramebufferHiRes1[HIRES_BUFFER_WIDTH][HIRES_BUFFER_HEIGHT]; +#include "z64.h" +#include "regs.h" +#include "functions.h" +#include "macros.h" +// Variables are put before most headers as a hacky way to bypass bss reordering OSViMode sNotebookViMode; // placeholder name void* gFramebuffers[2]; OSViMode* gActiveViMode; @@ -35,6 +33,16 @@ s16 gCfbUpperAdjust; u8 gSysCfbHiResEnabled; +#include "variables.h" +#include "sys_cfb.h" +#include "libc/stdbool.h" +#include "buffers.h" +#include "system_malloc.h" +#include "z64vimode.h" + +extern u16 gFramebufferHiRes0[HIRES_BUFFER_WIDTH][HIRES_BUFFER_HEIGHT]; +extern u16 gFramebufferHiRes1[HIRES_BUFFER_WIDTH][HIRES_BUFFER_HEIGHT]; + void SysCfb_SetLoResMode(void) { gFramebuffers[1] = sCfbLoRes1; gFramebuffers[0] = sCfbLoRes0; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 1579c1ff9..ef1ca4b48 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -5,6 +5,7 @@ #include "global.h" #include "fault.h" +#include "sys_cfb.h" #include "loadfragment.h" #include "z64horse.h" #include "z64quake.h" diff --git a/src/code/z_fbdemo_circle.c b/src/code/z_fbdemo_circle.c index 185373e06..efd492d5c 100644 --- a/src/code/z_fbdemo_circle.c +++ b/src/code/z_fbdemo_circle.c @@ -1,4 +1,5 @@ #include "global.h" +#include "sys_cfb.h" typedef enum { /* 0 */ TRANS_CIRCLE_DIR_IN, diff --git a/src/code/z_lights.c b/src/code/z_lights.c index e82c3a9b2..ef1af66f5 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -1,4 +1,5 @@ #include "global.h" +#include "sys_cfb.h" #include "objects/gameplay_keep/gameplay_keep.h" LightsBuffer sLightsBuffer; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index cbbe959e7..cd458e331 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,4 +1,5 @@ #include "global.h" +#include "sys_cfb.h" #include "z64snap.h" #include "z64view.h" #include "archives/icon_item_static/icon_item_static_yar.h" diff --git a/src/code/z_play.c b/src/code/z_play.c index 2965e0e2e..1d5617850 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1,13 +1,33 @@ -#include "prevent_bss_reordering.h" -#include "global.h" +#include "z64.h" +#include "regs.h" +#include "functions.h" +#include "z64vismono.h" + +// Variables are put before most headers as a hacky way to bypass bss reordering +s16 sTransitionFillTimer; +Input D_801F6C18; +TransitionTile sTransitionTile; +s32 gTransitionTileState; +VisMono sPlayVisMono; +Color_RGBA8_u32 gVisMonoColor; +Struct_80140E80 D_801F6D38; +Struct_80140E80* D_801F6D4C; +BombersNotebook sBombersNotebook; +u8 sBombersNotebookOpen; +u8 sMotionBlurStatus; + +#include "variables.h" +#include "macros.h" #include "buffers.h" #include "idle.h" +#include "sys_cfb.h" #include "z64bombers_notebook.h" #include "z64debug_display.h" #include "z64quake.h" #include "z64rumble.h" #include "z64shrink_window.h" #include "z64view.h" + #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/gamestates/ovl_opening/z_opening.h" #include "overlays/gamestates/ovl_file_choose/z_file_select.h" @@ -16,18 +36,6 @@ s32 gDbgCamEnabled = false; u8 D_801D0D54 = false; -s16 sTransitionFillTimer; -Input D_801F6C18; -TransitionTile sTransitionTile; -s32 gTransitionTileState; -VisMono sVisMono; -Color_RGBA8_u32 gVisMonoColor; -Struct_80140E80 D_801F6D38; -Struct_80140E80* D_801F6D4C; -BombersNotebook sBombersNotebook; -u8 sBombersNotebookOpen; -u8 sMotionBlurStatus; - typedef enum { /* 0 */ MOTION_BLUR_OFF, /* 1 */ MOTION_BLUR_SETUP, @@ -406,7 +414,7 @@ void Play_Destroy(GameState* thisx) { ShrinkWindow_Destroy(); TransitionFade_Destroy(&this->unk_18E48); - VisMono_Destroy(&sVisMono); + VisMono_Destroy(&sPlayVisMono); func_80140EA0(D_801F6D4C); D_801F6D4C = NULL; @@ -1227,8 +1235,8 @@ void Play_DrawMain(PlayState* this) { TransitionFade_Draw(&this->unk_18E48, &sp218); if (gVisMonoColor.a != 0) { - sVisMono.primColor.rgba = gVisMonoColor.rgba; - VisMono_Draw(&sVisMono, &sp218); + sPlayVisMono.primColor.rgba = gVisMonoColor.rgba; + VisMono_Draw(&sPlayVisMono, &sp218); } gSPEndDisplayList(sp218++); @@ -2299,7 +2307,7 @@ void Play_Init(GameState* thisx) { TransitionFade_SetType(&this->unk_18E48, 3); TransitionFade_SetColor(&this->unk_18E48, RGBA8(160, 160, 160, 255)); TransitionFade_Start(&this->unk_18E48); - VisMono_Init(&sVisMono); + VisMono_Init(&sPlayVisMono); gVisMonoColor.a = 0; D_801F6D4C = &D_801F6D38; diff --git a/src/code/z_play_hireso.c b/src/code/z_play_hireso.c index 18d483889..1b2572ea8 100644 --- a/src/code/z_play_hireso.c +++ b/src/code/z_play_hireso.c @@ -1,4 +1,5 @@ #include "global.h" +#include "sys_cfb.h" #include "z64bombers_notebook.h" #include "interface/schedule_static/schedule_static.h" #include "archives/schedule_dma_static/schedule_dma_static_yar.h" diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 6aee18baf..a109dab17 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #define FLAGS \ diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 4b5787129..1e25aca8b 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1,4 +1,5 @@ #include "global.h" +#include "sys_cfb.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" Gfx gSetupDLs[SETUPDL_MAX][6] = { diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index b4597a5c2..2daa0ee78 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" s32 sMatAnimStep; diff --git a/src/code/z_skin.c b/src/code/z_skin.c index 0b7c5d5a0..5569c886b 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "z64skin.h" diff --git a/src/code/z_vimode.c b/src/code/z_vimode.c index 3909c7a05..778c89c14 100644 --- a/src/code/z_vimode.c +++ b/src/code/z_vimode.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64vimode.h" #include "ultra64/viint.h" typedef struct { diff --git a/src/code/z_viscvg.c b/src/code/z_viscvg.c index 888fa19b3..1821805ee 100644 --- a/src/code/z_viscvg.c +++ b/src/code/z_viscvg.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64viscvg.h" Gfx D_801C5DD0[] = { gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | @@ -39,7 +40,7 @@ Gfx D_801C5E00[] = { gsSPBranchList(D_0E000000.fillRect), }; -void VisCvg_Init(struct_801F8010* this) { +void VisCvg_Init(VisCvg* this) { this->type = 0; this->setScissor = false; this->color.r = 255; @@ -48,10 +49,10 @@ void VisCvg_Init(struct_801F8010* this) { this->color.a = 255; } -void VisCvg_Destroy(struct_801F8010* this) { +void VisCvg_Destroy(VisCvg* this) { } -void VisCvg_Draw(struct_801F8010* this, Gfx** gfxp) { +void VisCvg_Draw(VisCvg* this, Gfx** gfxp) { Gfx* gfx = *gfxp; gDPPipeSync(gfx++); diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c index b28ed2aa6..86937c315 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.c @@ -4,6 +4,7 @@ */ #include "global.h" +#include "z64vismono.h" #include "system_malloc.h" // Height of the fragments the color frame buffer (CFB) is split into. diff --git a/src/code/z_viszbuf.c b/src/code/z_viszbuf.c index cf603f324..17c734cb0 100644 --- a/src/code/z_viszbuf.c +++ b/src/code/z_viszbuf.c @@ -1,4 +1,7 @@ #include "global.h" +#include "z64viszbuf.h" +#include "sys_cfb.h" +#include "libc/stdbool.h" #define VISZBUF_ZBUFFRAG_HEIGHT (TMEM_SIZE / (gCfbWidth * G_IM_SIZ_16b_BYTES)) |
