Skip to content

Commit

Permalink
take: Decompile efftornado.c
Browse files Browse the repository at this point in the history
  • Loading branch information
entriphy committed Jul 18, 2024
1 parent 3b667b1 commit 38d8c04
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
151 changes: 151 additions & 0 deletions src/take/efftornado.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#include <eetypes.h>
#include <libdev.h>
#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;
}
}
11 changes: 11 additions & 0 deletions src/take/efftornado.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/take/t_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
FUNCTBL MainFuncTbl[] = {
// { tkMenuFuncTbl, -1 },
// { tkViewerFuncTbl, -1 },
// { D_00395E10, -1 },
// { tkTornadoFuncTbl, -1 },
// { tkTitleFuncTbl, -1 }
};

Expand Down

0 comments on commit 38d8c04

Please sign in to comment.