Decompile wipe.c
This commit is contained in:
parent
72c850b0fb
commit
f383e26929
12 changed files with 390 additions and 31 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "game/object.h"
|
||||
#include "game/printfunc.h"
|
||||
#include "game/pad.h"
|
||||
#include "game/wipe.h"
|
||||
|
||||
#include "math.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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
327
src/game/wipe.c
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue