code_80140E80 OK and preliminary documentation, Fbdemo_Wipe4 OK and documented (#1106)

* OK, start documentation

* More documentation

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>

* Decompile func_80167F0C

* FbdemoWipe4 OK and documented

* Mark bug in Wipe4

* More docs

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>

* Mark bug

* Few more notes

* Fix function in Play

* Format

* Review

* Name Play_PostWorldDraw

* functions.h...

* Revert func_80167F0C

* Review

* functions.h

* Review

* Update Wipe4

* Rename system

* Format

* Put skeleton back in the cupboard

* bss

* Fix build

* rename to z_visfbuf

* review

* format

* bss

* some bss cleanup

* review

* bss

* review

---------

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
Co-authored-by: angie <angheloalf95@gmail.com>
This commit is contained in:
EllipticEllipsis
2023-10-26 07:42:24 +01:00
committed by GitHub
parent 7176ed4299
commit 6bdb7c31ea
30 changed files with 568 additions and 124 deletions
@@ -4,7 +4,6 @@
* Description: Fishing Pond Elements (Owner, Fish, Props, Effects...)
*/
#include "prevent_bss_reordering.h"
#include "z_en_fishing.h"
#include "z64rumble.h"
#include "z64shrink_window.h"
@@ -32,9 +32,9 @@ TransitionInit TransitionWipe3_InitVars = {
TransitionWipe3_SetColor, TransitionWipe3_SetEnvColor, TransitionWipe3_IsDone,
};
#define TRANS3_GET_SPEED(type) (type & 1)
#define TRANS3_GET_TEX_INDEX(type) ((type >> 1) & 7)
#define TRANS3_GET_COLOR(type) ((type >> 4) & 3)
#define TRANS3_GET_SPEED(type) ((type)&1)
#define TRANS3_GET_TEX_INDEX(type) (((type) >> 1) & 7)
#define TRANS3_GET_COLOR(type) (((type) >> 4) & 3)
typedef enum {
/* 0 */ TRANS_WIPE3_DIR_IN,
@@ -1,11 +1,25 @@
/*
* File: z_fbdemo_wipe4.c
/**
* @file z_fbdemo_wipe4.c
* Overlay: ovl_fbdemo_wipe4
* Description:
*
* @note The bug in TransitionWipe4_Draw() makes this transition do nothing apart from increase its timer until it is
* finished.
*/
#include "global.h"
#include "z_fbdemo_wipe4.h"
#include "sys_cfb.h"
#define THIS ((TransitionWipe4*)thisx)
#define TRANS4_GET_COLORTYPE(type) (((type) >> 1) & 3)
#define TRANS4_GET_SPEEDTYPE(type) ((type)&1)
typedef enum TransitionWipe4Direction {
/* 0 */ TRANS_WIPE4_DIR_IN,
/* 1 */ TRANS_WIPE4_DIR_OUT
} TransitionWipe4Direction;
void* TransitionWipe4_Init(void* thisx);
void TransitionWipe4_Destroy(void* thisx);
@@ -17,35 +31,115 @@ void TransitionWipe4_SetColor(void* thisx, u32 color);
void TransitionWipe4_SetEnvColor(void* thisx, u32 color);
s32 TransitionWipe4_IsDone(void* thisx);
#if 0
TransitionInit TransitionWipe4_InitVars = {
TransitionWipe4_Init,
TransitionWipe4_Destroy,
TransitionWipe4_Update,
TransitionWipe4_Draw,
TransitionWipe4_Start,
TransitionWipe4_SetType,
TransitionWipe4_SetColor,
TransitionWipe4_SetEnvColor,
TransitionWipe4_IsDone,
TransitionWipe4_Init, TransitionWipe4_Destroy, TransitionWipe4_Update,
TransitionWipe4_Draw, TransitionWipe4_Start, TransitionWipe4_SetType,
TransitionWipe4_SetColor, TransitionWipe4_SetEnvColor, TransitionWipe4_IsDone,
};
#endif
void TransitionWipe4_Start(void* thisx) {
TransitionWipe4* this = (TransitionWipe4*)thisx;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe4/TransitionWipe4_Start.s")
this->isDone = false;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe4/TransitionWipe4_Init.s")
switch (this->speedType) {
default:
this->baseSpeed = 0.2f;
break;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe4/TransitionWipe4_Destroy.s")
case 0:
this->baseSpeed = 0.1f;
break;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe4/TransitionWipe4_Update.s")
case 1:
this->baseSpeed = 0.05f;
break;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe4/TransitionWipe4_Draw.s")
switch (this->colorType) {
default:
this->primColor.rgba = RGBA8(160, 160, 160, 255);
break;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe4/TransitionWipe4_IsDone.s")
case 0:
this->primColor.rgba = RGBA8(0, 0, 0, 255);
break;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe4/TransitionWipe4_SetType.s")
case 1:
this->primColor.rgba = RGBA8(160, 160, 160, 255);
break;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe4/TransitionWipe4_SetColor.s")
void* TransitionWipe4_Init(void* thisx) {
TransitionWipe4* this = (TransitionWipe4*)thisx;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe4/TransitionWipe4_SetEnvColor.s")
bzero(this, sizeof(TransitionWipe4));
return this;
}
void TransitionWipe4_Destroy(void* thisx) {
}
void TransitionWipe4_Update(void* thisx, s32 updateRate) {
TransitionWipe4* this = (TransitionWipe4*)thisx;
this->progress += (this->baseSpeed * 3.0f) / updateRate;
if (this->progress >= 1.0f) {
this->progress = 1.0f;
this->isDone = true;
}
}
// Use of THIS in this function is required to match
void TransitionWipe4_Draw(void* thisx, Gfx** gfxP) {
Gfx* gfx = *gfxP;
VisFbuf* copyFx = &THIS->copyFx;
copyFx->primColor.rgba = THIS->primColor.rgba;
if (THIS->direction != 0) {
copyFx->scale = THIS->progress;
copyFx->lodProportion = 1.0f - THIS->progress;
} else {
copyFx->scale = 1.0f - THIS->progress;
copyFx->lodProportion = THIS->progress;
}
//! @bug (Possibly) Since copyFx->mode is never set after being initialised to 0, the switch in VisFbuf_Draw()
//! does nothing, so this function call does nothing but change to the sprite microcode, then back to 3D microcode.
VisFbuf_Draw(copyFx, &gfx, SysCfb_GetZBuffer());
*gfxP = gfx;
}
s32 TransitionWipe4_IsDone(void* thisx) {
TransitionWipe4* this = (TransitionWipe4*)thisx;
return this->isDone;
}
void TransitionWipe4_SetType(void* thisx, s32 type) {
TransitionWipe4* this = (TransitionWipe4*)thisx;
if (type & TRANS_TYPE_SET_PARAMS) {
this->colorType = TRANS4_GET_COLORTYPE(type);
this->speedType = TRANS4_GET_SPEEDTYPE(type);
} else if (type == TRANS_INSTANCE_TYPE_FILL_OUT) {
this->direction = TRANS_WIPE4_DIR_OUT;
} else {
this->direction = TRANS_WIPE4_DIR_IN;
}
}
void TransitionWipe4_SetColor(void* thisx, u32 color) {
TransitionWipe4* this = (TransitionWipe4*)thisx;
this->primColor.rgba = color;
}
void TransitionWipe4_SetEnvColor(void* thisx, u32 color) {
TransitionWipe4* this = (TransitionWipe4*)thisx;
this->envColor.rgba = color;
}
@@ -3,9 +3,18 @@
#include "ultra64.h"
#include "color.h"
#include "z64visfbuf.h"
typedef struct {
/* 0x00 */ char unk_0[0x28];
typedef struct TransitionWipe4 {
/* 0x00 */ Color_RGBA8_u32 primColor;
/* 0x04 */ Color_RGBA8_u32 envColor;
/* 0x08 */ f32 baseSpeed;
/* 0x0C */ f32 progress;
/* 0x10 */ u8 direction;
/* 0x11 */ u8 colorType;
/* 0x12 */ u8 speedType;
/* 0x13 */ u8 isDone;
/* 0x14 */ VisFbuf copyFx;
} TransitionWipe4; // size = 0x28
#endif
@@ -94,7 +94,7 @@ void TransitionWipe5_Draw(void* thisx, Gfx** gfxP) {
G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE,
G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2);
func_8014116C(&gfx, D_0F000000, workBuffer, width, height, 1);
VisFbuf_SetBgSimple(&gfx, D_0F000000, workBuffer, width, height, VIS_FBUF_BG_CYC_COPY);
} else {
if (alpha == 255) {
gDPSetOtherMode(gfx++,
@@ -110,7 +110,7 @@ void TransitionWipe5_Draw(void* thisx, Gfx** gfxP) {
gDPSetEnvColor(gfx++, 255, 255, 255, alpha);
gDPSetCombineLERP(gfx++, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0,
ENVIRONMENT);
func_8014116C(&gfx, workBuffer, D_0F000000, width, height, 0);
VisFbuf_SetBgSimple(&gfx, workBuffer, D_0F000000, width, height, VIS_FBUF_BG_CYC_1CYC);
}
gDPPipeSync(gfx++);
gSPLoadUcode(gfx++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
@@ -4,7 +4,6 @@
* Description: Pause Menu
*/
#include "prevent_bss_reordering.h"
#include "z_kaleido_scope.h"
#include "z64view.h"
#include "overlays/gamestates/ovl_opening/z_opening.h"