Merge pull request #55 from gamemasterplc/main

Decompile wipe.c
This commit is contained in:
gamemasterplc 2023-12-26 12:32:32 -06:00 committed by GitHub
commit d264051a59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 390 additions and 31 deletions

View file

@ -225,16 +225,17 @@ game/ShapeExec.c:
.text start:0x80040D60 end:0x80041170
.sdata2 start:0x801D4ED0 end:0x801D4EE0
dolphin/os/__start.c:
.init start:0x80003100 end:0x80003354
game/wipe.c:
.text start:0x80041170 end:0x8004207C
.data start:0x80130120 end:0x80130138
.bss start:0x80192360 end:0x801923C0
.sdata start:0x801D35E0 end:0x801D35E8
.sbss start:0x801D3DA8 end:0x801D3DB0
.sdata2 start:0x801D4EE0 end:0x801D4F08
dolphin/os/__start.c:
.init start:0x80003100 end:0x80003354
game/window.c:
.text start:0x8004207C end:0x800483A0
.data start:0x80130140 end:0x80130688

View file

@ -5047,8 +5047,8 @@ lbl_8012FDBF = .data:0x8012FDBF; // type:object size:0xF data:string
lbl_8012FDCE = .data:0x8012FDCE; // type:object size:0x12
_ovltbl = .data:0x8012FDE0; // type:object size:0x320
lbl_80130100 = .data:0x80130100; // type:object size:0x20
lbl_80130120 = .data:0x80130120; // type:object size:0xC
lbl_8013012C = .data:0x8013012C; // type:object size:0xC
fadeInFunc = .data:0x80130120; // type:object size:0xC scope:local
fadeOutFunc = .data:0x8013012C; // type:object size:0xC scope:local
spcFontTbl = .data:0x80130140; // type:object size:0x170 scope:local
charWETbl = .data:0x801302B0; // type:object size:0x130
charWJTbl = .data:0x801303E0; // type:object size:0x140
@ -5737,14 +5737,8 @@ lbl_801D35C0 = .sdata:0x801D35C0; // type:object size:0x8
lbl_801D35C8 = .sdata:0x801D35C8; // type:object size:0x8
lbl_801D35D0 = .sdata:0x801D35D0; // type:object size:0x8
lbl_801D35D8 = .sdata:0x801D35D8; // type:object size:0x8
lbl_801D35E0 = .sdata:0x801D35E0; // type:object size:0x1 data:byte
lbl_801D35E1 = .sdata:0x801D35E1; // type:object size:0x1 data:byte
lbl_801D35E2 = .sdata:0x801D35E2; // type:object size:0x1 data:byte
lbl_801D35E3 = .sdata:0x801D35E3; // type:object size:0x1 data:byte
lbl_801D35E4 = .sdata:0x801D35E4; // type:object size:0x1 data:byte
lbl_801D35E5 = .sdata:0x801D35E5; // type:object size:0x1 data:byte
lbl_801D35E6 = .sdata:0x801D35E6; // type:object size:0x1 data:byte
lbl_801D35E7 = .sdata:0x801D35E7; // type:object size:0x1 data:byte
colorN$400 = .sdata:0x801D35E0; // type:object size:0x4 data:byte
colorN$444 = .sdata:0x801D35E4; // type:object size:0x4 data:byte
winPrio = .sdata:0x801D35E8; // type:object size:0x8 data:2byte
lbl_801D35F0 = .sdata:0x801D35F0; // type:object size:0x8
lbl_801D35F8 = .sdata:0x801D35F8; // type:object size:0x8
@ -6173,7 +6167,7 @@ SeqDone = .sbss:0x801D3D95; // type:object size:0x1 scope:local data:byte
SeqTimer = .sbss:0x801D3D96; // type:object size:0x2 scope:local data:2byte
gid = .sbss:0x801D3D98; // type:object size:0x8 scope:local data:2byte
lbl_801D3DA0 = .sbss:0x801D3DA0; // type:object size:0x8
lbl_801D3DA8 = .sbss:0x801D3DA8; // type:object size:0x8 data:4byte
wipeFadeInF = .sbss:0x801D3DA8; // type:object size:0x8 data:4byte
fontAnim = .sbss:0x801D3DB0; // type:object size:0x4 data:4byte
LanguageNo = .sbss:0x801D3DB4; // type:object size:0x1 scope:local data:byte
comKeyIdx = .sbss:0x801D3DB6; // type:object size:0x2 scope:local data:2byte

View file

@ -266,7 +266,7 @@ config.libs = [
Object(NonMatching, "game/code_8003FF68.c"),
Object(NonMatching, "game/ClusterExec.c"),
Object(NonMatching, "game/ShapeExec.c"),
Object(NonMatching, "game/wipe.c"),
Object(Matching, "game/wipe.c"),
Object(Matching, "game/window.c"),
Object(Matching, "game/messdata.c"),
Object(NonMatching, "game/card.c"),

View file

@ -12,16 +12,6 @@ typedef struct player_config {
s16 iscom;
} PlayerConfig;
typedef struct wipe_state {
char unk00[0x30];
float unk30;
float duration;
char unk38[0x11];
u8 unk49;
char unk4A[2];
} WipeState;
typedef struct system_state {
/* 0x00 */ struct {
u16 story : 1;

View file

@ -86,6 +86,11 @@ static inline void GXPosition2f32(const f32 x, const f32 y) {
GXWGFifo.f32 = y;
}
static inline void GXPosition2u16(const u16 x, const u16 y) {
GXWGFifo.u16 = x;
GXWGFifo.u16 = y;
}
static inline void GXPosition2s16(const s16 x, const s16 y) {
GXWGFifo.s16 = x;
GXWGFifo.s16 = y;

View file

@ -13,9 +13,6 @@ void Hu3DCameraPerspectiveSet(s32, f32, f32, f32, f32);
void Hu3DCameraViewportSet(s32, f32, f32, f32, f32, f32, f32);
void HuAudFadeOut(s32 arg0);
void WipeCreate(char dir, char type, short duration);
u8 WipeStatGet(void);
void Hu3DModelPosSet(s16 index, float x, float y, float z);
void Hu3DModelRotSet(s16 index, float x, float y, float z);
void Hu3DModelScaleSet(s16 index, float x, float y, float z);

42
include/game/wipe.h Normal file
View file

@ -0,0 +1,42 @@
#ifndef _GAME_WIPE_H
#define _GAME_WIPE_H
#include "dolphin.h"
#define WIPE_TYPE_NORMAL 0
#define WIPE_TYPE_CROSS 1
#define WIPE_TYPE_DUMMY 2
#define WIPE_MODE_IN 1
#define WIPE_MODE_OUT 2
#define WIPE_MODE_BLANK 3
typedef struct wipe_state {
u32 unk00;
u32 unk04;
void *copy_data;
u32 unk0C;
void *unk10[8];
float time;
float duration;
u32 unk38;
u16 w;
u16 h;
u16 x;
u16 y;
GXColor color;
volatile u8 type;
u8 mode;
u8 stat;
u8 keep_copy;
} WipeState;
void WipeInit(GXRenderModeObj *rmode);
void WipeExecAlways(void);
void WipeCreate(s16 mode, s16 type, s16 duration);
void WipeColorSet(u8 r, u8 g, u8 b);
u8 WipeStatGet(void);
extern WipeState wipeData;
extern BOOL wipeFadeInF;
#endif

View file

@ -4,7 +4,6 @@
#include "dolphin.h"
#include "common_structs.h"
extern WipeState wipeData;
extern PlayerConfig GWPlayerCfg[4];

View file

@ -2,6 +2,7 @@
#include "game/object.h"
#include "game/printfunc.h"
#include "game/pad.h"
#include "game/wipe.h"
#include "math.h"

View file

@ -1,6 +1,7 @@
#include "REL/w10Dll.h"
#include "game/pad.h"
#include "game/data.h"
#include "game/wipe.h"
char lbl_1_data_98[] = "@@@@@@@@@@@@@@ Tutorial Exit @@@@@@@@@@@@@@\n\000";

View file

@ -2,6 +2,8 @@
#include "game/memory.h"
#include "game/msm.h"
#include "game/object.h"
#include "game/wipe.h"
typedef struct {
/* 0x00 */ s16 unk00;
@ -109,9 +111,9 @@ void HuAudFadeOut(s32 arg0) {
}
s32 HuAudFXPlay(s32 arg0) {
WipeState *temp_r31 = &wipeData;
WipeState *wipe = &wipeData;
if (omSysExitReq != 0 || (wipeData.unk49 == 2 && temp_r31->unk30 / temp_r31->duration > 0.5)) {
if (omSysExitReq != 0 || (wipeData.mode == WIPE_MODE_OUT && wipe->time / wipe->duration > 0.5)) {
return 0;
}
return HuAudFXPlayVolPan(arg0, 0x7F, 0x40);

327
src/game/wipe.c Normal file
View file

@ -0,0 +1,327 @@
#include "dolphin.h"
#include "game/wipe.h"
#include "game/memory.h"
extern s8 lbl_801D429C;
s16 HuSysVWaitGet(s16 old);
typedef int (*fadeFunc)(void);
WipeState wipeData;
BOOL wipeFadeInF;
static void WipeColorFill(GXColor color);
static void WipeFrameStill(GXColor color);
static int WipeNormalFade(void);
static int WipeCrossFade(void);
static int WipeDummyFade(void);
static fadeFunc fadeInFunc[3] = { WipeNormalFade, WipeCrossFade, WipeDummyFade };
static fadeFunc fadeOutFunc[3] = { WipeNormalFade, WipeCrossFade, WipeDummyFade };
void WipeInit(GXRenderModeObj *rmode)
{
WipeState *wipe;
int i;
wipe = &wipeData;
wipe->unk00 = 0;
wipe->unk04 = 0;
wipe->copy_data = NULL;
wipe->stat = WIPE_TYPE_NORMAL;
wipe->mode = WIPE_MODE_BLANK;
wipe->type = 0;
wipe->keep_copy = 0;
for(i=0; i<8; i++) {
wipe->unk10[i] = NULL;
}
wipe->color.r = wipe->color.g = wipe->color.b = wipe->color.a = 0;
wipe->w = rmode->fbWidth;
wipe->h = rmode->efbHeight;
wipe->x = 0;
wipe->y = 0;
}
void WipeExecAlways(void)
{
int i;
WipeState *wipe;
wipe = &wipeData;
switch(wipe->mode) {
case WIPE_MODE_BLANK:
wipe->type;
wipe->color.a = 255;
if(wipe->copy_data) {
WipeFrameStill(wipe->color);
} else {
WipeColorFill(wipe->color);
}
break;
case WIPE_MODE_IN:
if(wipe->type < WIPE_TYPE_DUMMY) {
wipe->stat = fadeInFunc[wipe->type]();
} else {
wipe->stat = 0;
}
wipe->time += HuSysVWaitGet(0);
if(wipe->stat) {
return;
}
if(wipe->copy_data) {
if(!wipe->keep_copy) {
HuMemDirectFree(wipe->copy_data);
}
wipe->copy_data = NULL;
}
for(i=0; i<8; i++) {
if(wipe->unk10[i] != NULL) {
HuMemDirectFree(wipe->unk10[i]);
wipe->unk10[i] = NULL;
}
}
wipe->unk0C = 0;
wipe->time = 0;
wipe->mode = 0;
break;
case WIPE_MODE_OUT:
if(wipe->type < WIPE_TYPE_DUMMY) {
wipe->stat = fadeOutFunc[wipe->type]();
} else {
wipe->stat = 0;
}
wipe->time += HuSysVWaitGet(0);
if(wipe->stat) {
return;
}
wipe->time = 0;
wipe->mode = WIPE_MODE_BLANK;
break;
case 0:
break;
}
}
void WipeCreate(s16 mode, s16 type, s16 duration)
{
WipeState *wipe;
if(_CheckFlag(0x1000B) && lbl_801D429C) {
return;
}
wipe = &wipeData;
if(wipe->stat) {
return;
}
if(mode == WIPE_MODE_IN || mode == WIPE_MODE_OUT) {
if(mode == WIPE_MODE_IN) {
wipeFadeInF = TRUE;
}
wipe->mode = mode;
wipe->stat = 1;
if(type >= 0) {
wipe->type = type;
}
if(duration > 0) {
wipe->duration = duration;
} else {
if(mode == WIPE_MODE_IN) {
wipe->duration = 30.0f;
} else {
wipe->duration = 30.0f;
}
}
wipe->time = 0;
}
}
void WipeColorSet(u8 r, u8 g, u8 b)
{
wipeData.color.r = r;
wipeData.color.g = g;
wipeData.color.b = b;
}
u8 WipeStatGet(void)
{
return wipeData.stat;
}
static int WipeDummyFade(void)
{
return 0;
}
static int WipeNormalFade(void)
{
u8 alpha;
WipeState *wipe = &wipeData;
if(wipe->duration == 0) {
return 0;
}
alpha = (wipe->time/wipe->duration)*255.0f;
switch(wipe->mode) {
case WIPE_MODE_IN:
wipe->color.a = 255-alpha;
break;
case WIPE_MODE_OUT:
wipe->color.a = alpha;
break;
default:
return 0;
}
WipeColorFill(wipe->color);
if(wipe->time >= wipe->duration) {
return 0;
} else {
return 1;
}
}
static void WipeColorFill(GXColor color)
{
static GXColor colorN = { 0xFF, 0xFF, 0xFF, 0xFF };
Mtx44 proj;
Mtx modelview;
WipeState *wipe;
u16 ulx, lrx, uly, lry;
wipe = &wipeData;
ulx = (int)wipe->x;
lrx = wipe->x+wipe->w;
uly = (int)wipe->y;
lry = wipe->x+wipe->h+1;
MTXOrtho(proj, uly, lry, ulx, lrx, 0, 10);
GXSetProjection(proj, GX_ORTHOGRAPHIC);
MTXIdentity(modelview);
GXLoadPosMtxImm(modelview, GX_PNMTX0);
GXSetCurrentMtx(GX_PNMTX0);
GXSetViewport(0, 0, wipe->w, wipe->h+1, 0, 1);
GXSetScissor(0, 0, wipe->w, wipe->h+1);
GXClearVtxDesc();
GXSetChanMatColor(GX_COLOR0A0, color);
GXSetNumChans(1);
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_REG, 0, GX_DF_NONE, GX_AF_NONE);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GXSetNumTexGens(0);
GXSetNumTevStages(1);
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_U16, 0);
GXSetZMode(GX_FALSE, GX_LEQUAL, GX_FALSE);
GXSetAlphaUpdate(GX_FALSE);
GXSetColorUpdate(GX_TRUE);
GXSetAlphaCompare(GX_GEQUAL, 1, GX_AOP_AND, GX_GEQUAL, 1);
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition2u16(ulx, uly);
GXPosition2u16(lrx, uly);
GXPosition2u16(lrx, lry);
GXPosition2u16(ulx, lry);
GXEnd();
GXSetChanMatColor(GX_COLOR0A0, colorN);
}
static int WipeCrossFade(void)
{
u32 size;
u8 alpha;
WipeState *wipe = &wipeData;
if(wipe->duration == 0) {
return 0;
}
if(wipe->copy_data == NULL) {
size = GXGetTexBufferSize(wipe->w, wipe->h, GX_TF_RGB565, GX_FALSE, 0);
wipe->copy_data = HuMemDirectMallocNum(HEAP_DATA, size, 0x20000000);
GXSetTexCopySrc(wipe->x, wipe->y, wipe->w, wipe->h);
GXSetTexCopyDst(wipe->w, wipe->h, GX_TF_RGB565, GX_FALSE);
GXCopyTex(wipe->copy_data, GX_FALSE);
DCStoreRangeNoSync(wipe->copy_data, size);
}
alpha = (wipe->time/wipe->duration)*255.0f;
switch(wipe->mode) {
case WIPE_MODE_IN:
wipe->color.a = 255-alpha;
break;
case WIPE_MODE_OUT:
wipe->color.a = alpha;
break;
default:
return 0;
}
WipeFrameStill(wipe->color);
if(wipe->time >= wipe->duration) {
return 0;
} else {
return 1;
}
}
static void WipeFrameStill(GXColor color)
{
GXTexObj tex;
static GXColor colorN = { 0xFF, 0xFF, 0xFF, 0xFF };
Mtx44 proj;
Mtx modelview, temp;
WipeState *wipe;
u16 ulx, lrx, uly, lry;
wipe = &wipeData;
ulx = (int)wipe->x;
lrx = wipe->x+wipe->w;
uly = (int)wipe->y;
lry = wipe->x+wipe->h+1;
MTXOrtho(proj, uly, lry, ulx, lrx, 0, 10);
GXSetProjection(proj, GX_ORTHOGRAPHIC);
MTXIdentity(modelview);
GXLoadPosMtxImm(modelview, GX_PNMTX0);
GXSetCurrentMtx(GX_PNMTX0);
GXSetViewport(0, 0, wipe->w, wipe->h+1, 0, 1);
GXSetScissor(0, 0, wipe->w, wipe->h+1);
GXClearVtxDesc();
GXSetNumChans(1);
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_REG, 1, GX_DF_CLAMP, GX_AF_SPOT);
GXSetNumTexGens(1);
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GXSetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GXSetNumTevStages(2);
GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_C0, GX_CC_CPREV, GX_CC_ZERO);
GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_APREV, GX_CA_A0, GX_CA_ZERO);
GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevColor(GX_TEVSTAGE1, color);
GXSetChanAmbColor(GX_COLOR0A0, colorN);
GXSetChanMatColor(GX_COLOR0A0, colorN);
GXInitTexObj(&tex, wipe->copy_data, wipe->w, wipe->h, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXLoadTexObj(&tex, GX_TEXMAP0);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_U16, 0);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
MTXIdentity(temp);
GXLoadPosMtxImm(temp, GX_PNMTX0);
GXSetZMode(GX_FALSE, GX_LEQUAL, GX_FALSE);
GXSetAlphaUpdate(GX_FALSE);
GXSetColorUpdate(GX_TRUE);
GXSetAlphaCompare(GX_GEQUAL, 1, GX_AOP_AND, GX_GEQUAL, 1);
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition2u16(ulx, uly);
GXTexCoord2f32(0, 0);
GXPosition2u16(lrx, uly);
GXTexCoord2f32(1, 0);
GXPosition2u16(lrx, lry);
GXTexCoord2f32(1, 1);
GXPosition2u16(ulx, lry);
GXTexCoord2f32(0, 1);
GXEnd();
GXSetChanMatColor(GX_COLOR0A0, colorN);
}