From 38d8c04c19708da8a1ab2b0d5c3508ee898b5465 Mon Sep 17 00:00:00 2001 From: entriphy <1747088+entriphy@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:14:59 -0700 Subject: [PATCH] take: Decompile efftornado.c --- include/defines.h | 5 ++ src/take/efftornado.c | 151 ++++++++++++++++++++++++++++++++++++++++++ src/take/efftornado.h | 11 +++ src/take/t_func.c | 2 +- 4 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 src/take/efftornado.c create mode 100644 src/take/efftornado.h diff --git a/include/defines.h b/include/defines.h index d8da536..73962ff 100644 --- a/include/defines.h +++ b/include/defines.h @@ -7,6 +7,7 @@ #define M_PIf 3.141592f #define M_TWOPIf 6.283184f #define M_PI_2f 1.570796f +#define M_PI_3f 1.047198f #define M_PI_4f 0.785398f #define M_PI_8f 0.392699f #define M_PI_32f 0.09817475f @@ -56,6 +57,8 @@ #define PAD_LVL_L2(kpd) (kpd.lvl & 0x1) #define PAD_LVL_R1(kpd) (kpd.lvl & 0x8) #define PAD_LVL_R2(kpd) (kpd.lvl & 0x2) +#define PAD_LVL_START(kpd) (kpd.lvl & 0x800) +#define PAD_LVL_SELECT(kpd) (kpd.lvl & 0x100) #define pPAD_TRG_UP(kpd) (kpd->trg & 0x1000) #define pPAD_TRG_DOWN(kpd) (kpd->trg & 0x4000) @@ -89,5 +92,7 @@ #define pPAD_LVL_L2(kpd) (kpd->lvl & 0x1) #define pPAD_LVL_R1(kpd) (kpd->lvl & 0x8) #define pPAD_LVL_R2(kpd) (kpd->lvl & 0x2) +#define pPAD_LVL_START(kpd) (kpd->lvl & 0x800) +#define pPAD_LVL_SELECT(kpd) (kpd->lvl & 0x100) #endif diff --git a/src/take/efftornado.c b/src/take/efftornado.c new file mode 100644 index 0000000..04c7e8b --- /dev/null +++ b/src/take/efftornado.c @@ -0,0 +1,151 @@ +#include +#include +#include "take/efftornado.h" +#include "nakano/drawof.h" +#include "nakano/nkpad.h" +#include "nakano/wmeter.h" +#include "take/camera.h" +#include "take/object.h" +#include "abe/ab_init.h" +#include "nakano/dma.h" +#include "nakano/map00.h" +#include "nakano/objfunc.h" +#include "okanoyo/okio.h" +#include "okanoyo/okprint.h" + +// i don't know the actual name of this file but it does stuff with tornados +// so efftornado.c it is (to put it after effsub.c) + +s32 (*tkTornadoFuncTbl[])() = { + tkTornadoInit, + tkTornadoMain +}; +static OBJWORK *TornadoObj = NULL; +static PsfxMODEL TornadoModel = {}; + +static void func_002064A0(); +static void func_002064D8(sceVu0FVECTOR Trans); + +s32 tkTornadoInit() { + s32 i; + + SysGbl.objwork = malloc(sizeof(OBJWORK) * 128); + SysGbl.n_objw = 128; + InitAllObjWork(SysGbl.objwork, 128); + sceGsResetPath(); + sceDevGifReset(); + sceDevVif1Reset(); + sceDevVu1Reset(); + sceDevVif0Reset(); + sceDevVu0Reset(); + sceGsResetGraph(0, SCE_GS_INTERLACE, SCE_GS_NTSC, SCE_GS_FRAME); + sceGsSetDefDBuffDc(&GameGbl.db, SCE_GS_PSMCT32, SCR_WIDTH, SCR_HEIGHT, SCE_GS_ZGREATER, SCE_GS_PSMZ16S, SCE_GS_CLEAR); + FlushCache(WRITEBACK_DCACHE); + nkInitDma(); + OkSetIDprofile(); + OkDefaultSysInit(0x280, 0xE0, 12, 6); + OkPrintSysInit(7, 0x280, 0xE0, 12, 6); + DataBuffPtr = getBuff(1, 0x100000, NULL, &i); + pDma.Vif0 = sceDmaGetChan(DMAC_VIF0); + pDma.Vif1 = sceDmaGetChan(DMAC_VIF1); + pDma.Gif = sceDmaGetChan(DMAC_GIF); + pDma.ToSpr = sceDmaGetChan(DMAC_TO_SPR); + pDma.FromSpr = sceDmaGetChan(DMAC_FROM_SPR); + ScreenInit(); + LightInit(); + nkPathReset(); + nkInitAtrMain(); + sceGsSyncPath(0, 0); + nkDebFlush(); + nkPathFlush(); + nkPathReset(); + nkPathReset(); + nkInitAtrMain(); + sceGsSyncPath(0, 0); + nkDebFlush(); + nkPathFlush(); + nkPathReset(); + memoryStageFormat(); + memoryAreaptrSet(); + memoryAreaFormat(); + GameGbl.vision = 0x1400; + abGimInit(); + GetWsMtx(); + TornadoObj = SetTornado(); + TornadoModel.Trans[0] = 0.0f; + TornadoModel.Trans[1] = 25.0f; + TornadoModel.Trans[2] = 200.0f; + TornadoModel.Trans[3] = 1.0f; + SysGbl.smode++; +} + +s32 tkTornadoMain() { + s32 inter; + kPadDATA *kpad0; + kPadDATA *kpad1; + + kpad0 = &GameGbl.kpd[0]; + nkGetPad(); + kpad0->lvl = nkGetPlvl(0); + kpad0->trg = nkGetPtrg(0); + kpad0->rep = nkGetPrep(0); + + kpad1 = &GameGbl.kpd[1]; + kpad1->lvl = nkGetPlvl(1); + kpad1->trg = nkGetPtrg(1); + kpad1->rep = nkGetPrep(1); + + nkSetMeter(); + func_002064A0(); + SortObjWork(SysGbl.objwork, SysGbl.n_objw); + ObjFunc(SysGbl.objwork); + DrawObjFunc(SysGbl.objwork); + sceGsSyncPath(0, 0); + DrEffObjFunc(SysGbl.objwork); + sceGsSyncPath(0, 0); + OkPFontFlush(PAD_TRG_SELECT(GameGbl.kpd[1])); + inter = sceGsSyncV(0) ^ 1; + if (GameGbl.fr & 1) { + sceGsSetHalfOffset(&GameGbl.db.draw11, 0x800, 0x800, inter); + sceGsSetHalfOffset2(&GameGbl.db.draw12, 0x800, 0x800, inter); + } else { + sceGsSetHalfOffset(&GameGbl.db.draw01, 0x800, 0x800, inter); + sceGsSetHalfOffset2(&GameGbl.db.draw02, 0x800, 0x800, inter); + } + sceGsSwapDBuffDc(&GameGbl.db, GameGbl.fr); + GameGbl.inter = inter; + GameGbl.fr++; + if (pPAD_TRG_SELECT(kpad0) && pPAD_LVL_START(kpad0)) { + DebmemFormat(7); + SysGbl.fmode = 0; + SysGbl.smode = 0; + } +} + +static void func_002064A0() { + BgDraw(); + func_002064D8(TornadoModel.Trans); + SetTornadoTrans(TornadoObj, TornadoModel.Trans); +} + +static void func_002064D8(sceVu0FVECTOR Trans) { + // double-precision math... + if (PAD_LVL_DOWN(GameGbl.kpd[0])) { + Trans[1] += 2.5; + } + if (PAD_LVL_UP(GameGbl.kpd[0])) { + Trans[1] -= 2.5; + } + if (PAD_LVL_RIGHT(GameGbl.kpd[0])) { + Trans[0] += 2.5; + } + if (PAD_LVL_LEFT(GameGbl.kpd[0])) { + Trans[0] += 2.5; + } + if (PAD_LVL_R1(GameGbl.kpd[0])) { + Trans[2] += 2.5; + } + if (PAD_LVL_R2(GameGbl.kpd[0])) { + Trans[2] -= 2.5; + } +} diff --git a/src/take/efftornado.h b/src/take/efftornado.h new file mode 100644 index 0000000..254bfa4 --- /dev/null +++ b/src/take/efftornado.h @@ -0,0 +1,11 @@ +#ifndef TK_EFFTORNADO_H +#define TK_EFFTORNADO_H + +#include "take.h" + +extern s32 (*tkTornadoFuncTbl[])(); + +extern s32 tkTornadoInit(); +extern s32 tkTornadoMain(); + +#endif \ No newline at end of file diff --git a/src/take/t_func.c b/src/take/t_func.c index a5c8bdd..fee8e4c 100644 --- a/src/take/t_func.c +++ b/src/take/t_func.c @@ -4,7 +4,7 @@ FUNCTBL MainFuncTbl[] = { // { tkMenuFuncTbl, -1 }, // { tkViewerFuncTbl, -1 }, - // { D_00395E10, -1 }, + // { tkTornadoFuncTbl, -1 }, // { tkTitleFuncTbl, -1 } };