Merge pull request #117 from mrshigure/esprite

Matched ShapeExec, esprite, and jmp
This commit is contained in:
Rainchus 2024-01-17 03:12:29 -06:00 committed by GitHub
commit 64bbeb6e79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 350 additions and 40 deletions

View file

@ -6237,7 +6237,7 @@ SeqSpeed = .sbss:0x801D3D92; // type:object size:0x2 scope:local data:2byte
lbl_801D3D94 = .sbss:0x801D3D94; // type:object size:0x1 data:byte
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
gid = .sbss:0x801D3D98; // type:object size:0x2 scope:local data:2byte
lbl_801D3DA0 = .sbss:0x801D3DA0; // type:object size:0x8
wipeFadeInF = .sbss:0x801D3DA8; // type:object size:0x8 data:4byte
fontAnim = .sbss:0x801D3DB0; // type:object size:0x4 data:4byte

View file

@ -317,7 +317,7 @@ config.libs = [
Object(Matching, "game/decode.c"),
Object(Matching, "game/font.c"),
Object(Matching, "game/init.c"),
Object(NonMatching, "game/jmp.c"),
Object(Matching, "game/jmp.c"),
Object(Matching, "game/malloc.c"),
Object(Matching, "game/memory.c"),
Object(Matching, "game/printfunc.c"),
@ -341,10 +341,10 @@ config.libs = [
Object(Matching, "game/EnvelopeExec.c"),
Object(NonMatching, "game/minigame_seq.c"),
Object(Matching, "game/ovllist.c"),
Object(NonMatching, "game/esprite.c"),
Object(Matching, "game/esprite.c"),
Object(NonMatching, "game/code_8003FF68.c"),
Object(Matching, "game/ClusterExec.c"),
Object(NonMatching, "game/ShapeExec.c"),
Object(Matching, "game/ShapeExec.c"),
Object(Matching, "game/wipe.c"),
Object(Matching, "game/window.c"),
Object(Matching, "game/messdata.c"),

8
include/game/ShapeExec.h Executable file
View file

@ -0,0 +1,8 @@
#ifndef _GAME_SHAPE_EXEC_H
#define _GAME_SHAPE_EXEC_H
#include "game/hsfformat.h"
void ShapeProc(HsfData *arg0);
#endif

24
include/game/esprite.h Executable file
View file

@ -0,0 +1,24 @@
#ifndef _GAME_ESPRITE_H
#define _GAME_ESPRITE_H
#include "dolphin.h"
void espInit(void);
s16 espEntry(s32 arg0, s16 arg1, s16 arg2);
void espKill(s16 arg0);
s16 espGrpIDGet(void);
void espDispOn(s16 arg0);
void espDispOff(s16 arg0);
void espAttrSet(s16 arg0, u16 arg1);
void espAttrReset(s16 arg0, u16 arg1);
void espPosSet(s16 arg0, float arg1, float arg2);
void espScaleSet(s16 arg0, float arg1, float arg2);
void espZRotSet(s16 arg0, float arg1);
void espTPLvlSet(s16 arg0, float arg1);
void espColorSet(s16 arg0, u8 arg1, u8 arg2, u8 arg3);
void espSpeedSet(s16 arg0, float arg1);
void espBankSet(s16 arg0, s16 arg1);
void espDrawNoSet(s16 arg0, s16 arg1);
void espPriSet(s16 arg0, s16 arg1);
#endif

View file

@ -118,7 +118,6 @@ typedef struct light_data {
} LightData;
extern void GXWaitDrawDone(); /* extern */
extern void ShapeProc(HsfData*); /* extern */
extern void GXInitSpecularDir(GXLightObj*, f32, f32, f32);
void Hu3DInit(void);

19
include/game/jmp.h Executable file
View file

@ -0,0 +1,19 @@
#ifndef _GAME_JMP_H
#define _GAME_JMP_H
#include "dolphin.h"
typedef struct jump_buf {
u32 lr;
u32 cr;
u32 sp;
u32 r2;
u32 pad;
u32 regs[19];
double flt_regs[19];
} jmp_buf;
int gcsetjmp(jmp_buf *jump);
int gclongjmp(jmp_buf *jump, int status);
#endif

View file

@ -1,6 +1,7 @@
#ifndef _GAME_PROCESS_H
#define _GAME_PROCESS_H
#include "game/jmp.h"
#include "dolphin/types.h"
#define PROCESS_STAT_PAUSE 0x1
@ -8,16 +9,6 @@
#define PROCESS_STAT_PAUSE_EN 0x4
#define PROCESS_STAT_UPAUSE_EN 0x8
typedef struct jump_buf {
u32 lr;
u32 cr;
u32 sp;
u32 r2;
u32 pad;
u32 regs[19];
double flt_regs[19];
} jmp_buf;
typedef struct process {
struct process *next;
struct process *prev;

View file

@ -3,25 +3,6 @@
#include "dolphin.h"
void Hu3D2Dto3D(Vec*, s16, Vec*);
void HuAudFadeOut(s32 arg0);
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);
void espInit(void);
void espScaleSet(s16, f32, f32);
s16 espEntry(s32, s32, s32);
void espDispOff(s16);
void espKill(s16);
void espDispOn(s16);
void espPosSet(s16, f32, f32);
void HuAudFXListnerKill(void);
void HuAudDllSndGrpSet(u16 ovl);
void HuAudVoiceInit(s16 ovl);
void MGSeqKillAll(void);
void MGSeqPracticeStart(void);

View file

@ -1,4 +1,5 @@
#include "common.h"
#include "game/audio.h"
#include "game/object.h"
#include "game/printfunc.h"
#include "game/pad.h"

View file

@ -1,4 +1,5 @@
#include "REL/w10Dll.h"
#include "game/esprite.h"
#include "game/pad.h"
#include "game/data.h"
#include "game/wipe.h"

69
src/game/ShapeExec.c Executable file
View file

@ -0,0 +1,69 @@
#include "game/ShapeExec.h"
#include "game/EnvelopeExec.h"
static void SetShapeMain(HsfObject *arg0) {
HsfBuffer *temp_r28;
HsfBuffer *temp_r30;
float var_f30;
float var_f31;
s32 temp_r27;
s32 var_r29;
s32 var_r26;
s32 i;
if (arg0->data.shapeType == 2) {
var_f30 = 0.0f;
for (i = 0; i < arg0->data.vertexShapeCnt; i++) {
var_f30 += arg0->data.mesh.morphWeight[i];
}
temp_r30 = *arg0->data.vertexShape;
for (i = 0; i < temp_r30->count; i++) {
Vertextop[i].x = ((Vec*) temp_r30->data)[i].x;
Vertextop[i].y = ((Vec*) temp_r30->data)[i].y;
Vertextop[i].z = ((Vec*) temp_r30->data)[i].z;
}
for (i = 0; i < arg0->data.vertexShapeCnt; i++) {
temp_r30 = arg0->data.vertexShape[i];
var_f31 = arg0->data.mesh.morphWeight[i];
if (var_f31 < 0.0f) {
var_f31 = 0.0f;
} else if (var_f30 > 1.0f) {
var_f31 /= var_f30;
}
for (var_r29 = 0; var_r29 < temp_r30->count; var_r29++) {
Vertextop[var_r29].x += var_f31 * (((Vec*) temp_r30->data)[var_r29].x - Vertextop[var_r29].x);
Vertextop[var_r29].y += var_f31 * (((Vec*) temp_r30->data)[var_r29].y - Vertextop[var_r29].y);
Vertextop[var_r29].z += var_f31 * (((Vec*) temp_r30->data)[var_r29].z - Vertextop[var_r29].z);
}
}
} else {
temp_r27 = arg0->data.mesh.baseMorph;
var_r26 = temp_r27 + 1;
if (var_r26 >= arg0->data.vertexShapeCnt) {
var_r26 = temp_r27;
}
var_f31 = arg0->data.mesh.baseMorph - temp_r27;
temp_r30 = arg0->data.vertexShape[temp_r27];
temp_r28 = arg0->data.vertexShape[var_r26];
for (i = 0; i < temp_r30->count; i++) {
Vertextop[i].x = ((Vec*) temp_r30->data)[i].x + var_f31 * (((Vec*) temp_r28->data)[i].x - ((Vec*) temp_r30->data)[i].x);
Vertextop[i].y = ((Vec*) temp_r30->data)[i].y + var_f31 * (((Vec*) temp_r28->data)[i].y - ((Vec*) temp_r30->data)[i].y);
Vertextop[i].z = ((Vec*) temp_r30->data)[i].z + var_f31 * (((Vec*) temp_r28->data)[i].z - ((Vec*) temp_r30->data)[i].z);
}
}
}
void ShapeProc(HsfData *arg0) {
HsfObject *var_r31;
s32 i;
var_r31 = arg0->object;
for (i = 0; i < arg0->objectCnt; i++, var_r31++) {
if (var_r31->type == 2 && var_r31->data.vertexShapeCnt != 0) {
Vertextop = var_r31->data.vertex->data;
SetShapeMain(var_r31);
DCStoreRange(Vertextop, var_r31->data.vertex->count * sizeof(Vec));
var_r31->data.unk120[0]++;
}
}
}

View file

@ -3,8 +3,8 @@
#include "game/board/player.h"
#include "game/wipe.h"
#include "game/gamework_data.h"
#include "game/hsfex.h"
#include "board_unsplit.h"
#include "unsplit.h"
#include "math.h"
static void WarpInit(s32);

145
src/game/esprite.c Executable file
View file

@ -0,0 +1,145 @@
#include "game/esprite.h"
#include "game/data.h"
#include "game/sprite.h"
typedef struct {
/* 0x00 */ u32 unk00;
/* 0x04 */ u16 unk04;
/* 0x06 */ char unk06[2];
/* 0x08 */ AnimData *unk08;
} UnkEspriteStruct01; // Size 0xC
s16 esprite[0x180][2];
UnkEspriteStruct01 espanim[0x180];
static s16 gid;
void espInit(void) {
s32 i;
gid = HuSprGrpCreate(0x180);
for (i = 0; i < 0x180; i++) {
esprite[i][0] = i;
esprite[i][1] = -1;
}
for (i = 0; i < 0x180; i++) {
espanim[i].unk04 = 0;
}
}
s16 espEntry(s32 arg0, s16 arg1, s16 arg2) {
UnkEspriteStruct01 *var_r30;
UnkEspriteStruct01 *var_r31;
s16 (*var_r29)[2];
void *temp_r26;
s16 temp_r25;
s16 var_r28;
s32 var_r27;
var_r29 = esprite;
for (var_r28 = 0; var_r28 < 0x180; var_r29++, var_r28++) {
if (var_r29[0][1] == -1) {
break;
}
}
if (var_r28 == 0x180) {
return -1;
}
var_r31 = espanim;
var_r30 = NULL;
for (var_r27 = 0; var_r27 < 0x180; var_r31++, var_r27++) {
if (var_r31->unk04 != 0) {
if (var_r31->unk00 == arg0) {
var_r30 = NULL;
break;
}
} else if (var_r30 == NULL) {
var_r30 = var_r31;
}
}
if (var_r27 == 0x180) {
if (var_r30 == NULL) {
return -1;
}
temp_r26 = HuDataSelHeapReadNum(arg0, MEMORY_DEFAULT_NUM, HEAP_DATA);
if (temp_r26 == NULL) {
return -1;
}
var_r30->unk00 = arg0;
var_r30->unk08 = HuSprAnimRead(temp_r26);
var_r31 = var_r30;
}
temp_r25 = HuSprCreate(var_r31->unk08, arg1, arg2);
if (temp_r25 == -1) {
if (var_r30 != NULL) {
HuSprAnimKill(var_r31->unk08);
}
return -1;
}
var_r31->unk04++;
var_r29[0][1] = var_r31 - espanim;
HuSprGrpMemberSet(gid, var_r29[0][0], temp_r25);
return var_r28;
}
void espKill(s16 arg0) {
HuSprGrpMemberKill(gid, esprite[arg0][0]);
espanim[esprite[arg0][1]].unk04--;
esprite[arg0][1] = -1;
}
s16 espGrpIDGet(void) {
return gid;
}
void espDispOn(s16 arg0) {
HuSprAttrReset(gid, esprite[arg0][0], 4);
}
void espDispOff(s16 arg0) {
HuSprAttrSet(gid, esprite[arg0][0], 4);
}
void espAttrSet(s16 arg0, u16 arg1) {
HuSprAttrSet(gid, esprite[arg0][0], arg1);
}
void espAttrReset(s16 arg0, u16 arg1) {
HuSprAttrReset(gid, esprite[arg0][0], arg1);
}
void espPosSet(s16 arg0, float arg1, float arg2) {
HuSprPosSet(gid, esprite[arg0][0], arg1, arg2);
}
void espScaleSet(s16 arg0, float arg1, float arg2) {
HuSprScaleSet(gid, esprite[arg0][0], arg1, arg2);
}
void espZRotSet(s16 arg0, float arg1) {
HuSprZRotSet(gid, esprite[arg0][0], arg1);
}
void espTPLvlSet(s16 arg0, float arg1) {
HuSprTPLvlSet(gid, esprite[arg0][0], arg1);
}
void espColorSet(s16 arg0, u8 arg1, u8 arg2, u8 arg3) {
HuSprColorSet(gid, esprite[arg0][0], arg1, arg2, arg3);
}
void espSpeedSet(s16 arg0, float arg1) {
HuSprSpeedSet(gid, esprite[arg0][0], arg1);
}
void espBankSet(s16 arg0, s16 arg1) {
HuSprBankSet(gid, esprite[arg0][0], arg1);
}
void espDrawNoSet(s16 arg0, s16 arg1) {
HuSprDrawNoSet(gid, esprite[arg0][0], arg1);
}
void espPriSet(s16 arg0, s16 arg1) {
HuSprPriSet(gid, esprite[arg0][0], arg1);
}

View file

@ -8,6 +8,7 @@
#include "game/init.h"
#include "game/memory.h"
#include "game/perf.h"
#include "game/ShapeExec.h"
#include "game/sprite.h"
#include "dolphin/gx/GXVert.h"

View file

@ -5,6 +5,7 @@
#include "game/hsfload.h"
#include "game/hsfman.h"
#include "game/init.h"
#include "game/ShapeExec.h"
#include "math.h"
#include "string.h"
@ -12,8 +13,6 @@
static s32 SearchObjectIndex(HsfData *arg0, u32 arg1);
static s32 SearchAttributeIndex(HsfData *arg0, u32 arg1);
void ShapeProc(HsfData*);
MotionData Hu3DMotion[256];
static HsfBitmap *bitMapPtr;

74
src/game/jmp.c Executable file
View file

@ -0,0 +1,74 @@
#include "game/jmp.h"
int gcsetjmp(register jmp_buf *jump) {
// clang-format off
asm {
mflr r5
mfcr r6
stw r5, jump->lr
stw r6, jump->cr
stw r1, jump->sp
stw r2, jump->r2
stmw r13, jump->regs[0]
mffs f0
stfd f14, jump->flt_regs[0]
stfd f15, jump->flt_regs[1]
stfd f16, jump->flt_regs[2]
stfd f17, jump->flt_regs[3]
stfd f18, jump->flt_regs[4]
stfd f19, jump->flt_regs[5]
stfd f20, jump->flt_regs[6]
stfd f21, jump->flt_regs[7]
stfd f22, jump->flt_regs[8]
stfd f23, jump->flt_regs[9]
stfd f24, jump->flt_regs[10]
stfd f25, jump->flt_regs[11]
stfd f26, jump->flt_regs[12]
stfd f27, jump->flt_regs[13]
stfd f28, jump->flt_regs[14]
stfd f29, jump->flt_regs[15]
stfd f30, jump->flt_regs[16]
stfd f31, jump->flt_regs[17]
stfd f0, jump->flt_regs[18]
}
// clang-format on
return 0;
}
// clang-format off
asm int gclongjmp(register jmp_buf *jump, register int status) {
nofralloc
lwz r5, jump->lr
lwz r6, jump->cr
mtlr r5
mtcrf 255, r6
lwz r1, jump->sp
lwz r2, jump->r2
lmw r13, jump->regs[0]
lfd f14, jump->flt_regs[0]
lfd f15, jump->flt_regs[1]
lfd f16, jump->flt_regs[2]
lfd f17, jump->flt_regs[3]
lfd f18, jump->flt_regs[4]
lfd f19, jump->flt_regs[5]
lfd f20, jump->flt_regs[6]
lfd f21, jump->flt_regs[7]
lfd f22, jump->flt_regs[8]
lfd f23, jump->flt_regs[9]
lfd f24, jump->flt_regs[10]
lfd f25, jump->flt_regs[11]
lfd f26, jump->flt_regs[12]
lfd f27, jump->flt_regs[13]
lfd f28, jump->flt_regs[14]
lfd f29, jump->flt_regs[15]
lfd f30, jump->flt_regs[16]
lfd f0, jump->flt_regs[18]
lfd f31, jump->flt_regs[17]
cmpwi status, 0
mr r3, status
mtfsf 255, f0
bnelr
li r3, 1
blr
}
// clang-format on

View file

@ -1,4 +1,5 @@
#include "game/audio.h"
#include "game/esprite.h"
#include "game/hsfdraw.h"
#include "game/hsfman.h"
#include "game/printfunc.h"

View file

@ -4,9 +4,6 @@
#define PROCESS_MEMORY_RETADDR 0xA5A5A5A5
extern int gcsetjmp(jmp_buf *jump);
extern void gclongjmp(jmp_buf *jump, int status);
#define EXEC_NORMAL 0
#define EXEC_SLEEP 1
#define EXEC_CHILDWATCH 2