mirror of
https://github.com/pmret/papermario.git
synced 2024-09-09 11:02:38 +02:00
3unks the Threequel (#955)
* Fix modern gcc issue with function call arg evaluation order, shiftability issue with heap, other fixes * cursed function byebye * configure cleanup * npc_do_other_npc_collision & func_80244550_A2E790 * wip * PR comments
This commit is contained in:
parent
8f974438a3
commit
ba42928a18
@ -1947,7 +1947,7 @@ typedef struct Effect65FXData {
|
||||
/* 0x0C8 */ f32 unk_C8[30];
|
||||
/* 0x140 */ f32 unk_140[30];
|
||||
/* 0x1B8 */ s32 unk_1B8[30];
|
||||
/* 0x230 */ s32 unk_230[30];
|
||||
/* 0x230 */ s32 unk_230[30]; // a bool
|
||||
/* 0x2A8 */ s32 unk_2A8;
|
||||
/* 0x2AC */ f32 unk_2AC[30];
|
||||
} Effect65FXData; // size = 0x324
|
||||
|
@ -103,7 +103,7 @@ extern s16 D_800A095E;
|
||||
extern u8 D_800A095F;
|
||||
extern s32 D_800A0960;
|
||||
extern s32 D_800A0964;
|
||||
extern s8 D_800A0B94;
|
||||
extern s8 gNpcPlayerCollisionsEnabled;
|
||||
extern s16 D_800A0BB8;
|
||||
|
||||
extern SpriteShadingProfile* gAuxSpriteShadingProfile;
|
||||
|
@ -8,12 +8,6 @@ extern SpriteShadingProfile wSpriteShadingProfileAux;
|
||||
extern SpriteShadingProfile bSpriteShadingProfileAux;
|
||||
extern s8 D_80159880[0x20];
|
||||
|
||||
extern int ENVIRONMENT;
|
||||
extern int COMBINED;
|
||||
extern int COMBINED_ALPHA;
|
||||
extern int SHADE;
|
||||
extern int TEXEL0_ALPHA;
|
||||
|
||||
void appendGfx_shading_palette(Matrix4f mtx, s32 uls, s32 ult, s32 lrs, s32 lrt, s32 alpha,
|
||||
f32 shadowX, f32 shadowY, f32 shadowZ,
|
||||
s32 shadowR, s32 shadowG, s32 shadowB,
|
||||
|
@ -93,13 +93,23 @@ void blast_render(EffectInstance* effect) {
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void blast_appendGfx(void* effect) {
|
||||
Matrix4f sp18, sp58, sp98;
|
||||
BlastFXData* data = ((EffectInstance*)effect)->data.blast;
|
||||
Gfx* dlist = D_090017B0_37F180;
|
||||
s32 unk_20 = data->unk_20;
|
||||
f32 unk_20f = unk_20;
|
||||
s32 envAlpha = (unk_20f - unk_20) * 256.0f;
|
||||
void blast_appendGfx(void *effect) {
|
||||
Matrix4f sp18;
|
||||
Matrix4f sp58;
|
||||
Matrix4f sp98;
|
||||
BlastFXData* data;
|
||||
Gfx* dlist;
|
||||
f32 unk_20f;
|
||||
s32 unk_20;
|
||||
s32 envAlpha;
|
||||
f32 two_fifty_six;
|
||||
|
||||
data = ((EffectInstance*) effect)->data.blast;
|
||||
dlist = D_090017B0_37F180;
|
||||
two_fifty_six = 256.0f;
|
||||
unk_20 = data->unk_20;
|
||||
unk_20f = unk_20;
|
||||
envAlpha = (unk_20f - unk_20) * two_fifty_six;
|
||||
|
||||
gDPPipeSync(gMasterGfxPos++);
|
||||
gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
|
||||
@ -117,6 +127,7 @@ void blast_appendGfx(void* effect) {
|
||||
|
||||
gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++],
|
||||
G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
|
||||
|
||||
if (data->unk_20 > 4.0f) {
|
||||
gDPSetPrimColor(gMasterGfxPos++, 0, 0, 255, 255, 255, 127);
|
||||
} else {
|
||||
|
@ -32,14 +32,14 @@ UnkBulbGlow D_E0078918[] = {
|
||||
|
||||
s32 D_E00789A8 = 0;
|
||||
|
||||
u8 D_E00789AC[] = {
|
||||
255, 255, 255,
|
||||
255, 255, 128,
|
||||
255, 128, 255,
|
||||
128, 255, 255,
|
||||
255, 128, 128,
|
||||
128, 255, 128,
|
||||
128, 128, 255,
|
||||
Color_RGB8 D_E00789AC[] = {
|
||||
{255, 255, 255},
|
||||
{255, 255, 128},
|
||||
{255, 128, 255},
|
||||
{128, 255, 255},
|
||||
{255, 128, 128},
|
||||
{128, 255, 128},
|
||||
{128, 128, 255},
|
||||
};
|
||||
|
||||
void bulb_glow_init(EffectInstance* effect);
|
||||
@ -151,116 +151,142 @@ void bulb_glow_render(EffectInstance* effect) {
|
||||
void func_E0078274(void) {
|
||||
}
|
||||
|
||||
#define TMEM_ADDR(x) (x / sizeof(u64))
|
||||
|
||||
// wip
|
||||
#ifdef WIP
|
||||
void bulb_glow_appendGfx(void* effect) {
|
||||
f32 sp18;
|
||||
f32 sp1C;
|
||||
s32 sp20;
|
||||
s32 sp28;
|
||||
s32 sp30;
|
||||
BulbGlowFXData* data = ((EffectInstance*) effect)->data.bulbGlow;
|
||||
s32 unk_10;
|
||||
s32 unk_00;
|
||||
BulbGlowFXData* data = ((EffectInstance*) effect)->data.bulbGlow; //s0
|
||||
f32 centerX;
|
||||
f32 centerY;
|
||||
s32 xMin;
|
||||
s32 numRects;
|
||||
s32 yMin;
|
||||
s32 temp_s2;
|
||||
s32 rectHeight;
|
||||
s32 glowExtent;
|
||||
s32 colorScale;
|
||||
s32 brightness;
|
||||
s32 xMax;
|
||||
s32 yMax;
|
||||
s32 xStart;
|
||||
s32 isPointVisible;
|
||||
s32 yStart;
|
||||
UnkBulbGlow* temp_s1;
|
||||
s32 temp_s3;
|
||||
s32 temp_s6;
|
||||
Color_RGB8* temp_v0;
|
||||
|
||||
s32 i;
|
||||
s32 j;
|
||||
s32 r, g, b;
|
||||
|
||||
f32 temp_f0;
|
||||
f32 temp_f4;
|
||||
s32 temp_a0_2;
|
||||
s32 temp_f6;
|
||||
s32 temp_lo;
|
||||
s32 temp_s0_2;
|
||||
s32 temp_s2_2;
|
||||
s32 temp_t0;
|
||||
s32 temp_t5;
|
||||
s32 var_t2;
|
||||
s32 var_t4;
|
||||
s32 var_t5;
|
||||
s32 var_t7;
|
||||
s32 var_v1;
|
||||
s32 var_v1_2;
|
||||
u32 temp_t6;
|
||||
u8* temp_v0;
|
||||
|
||||
|
||||
unk_10 = data->unk_10;
|
||||
unk_00 = data->unk_00;
|
||||
if (unk_10 > 127) {
|
||||
unk_10 = 127;
|
||||
brightness = data->unk_10;
|
||||
temp_s2 = data->unk_00;
|
||||
if (brightness > 0x7F) {
|
||||
brightness = 0x7F;
|
||||
}
|
||||
|
||||
gDPPipeSync(gMasterGfxPos++);
|
||||
gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
|
||||
|
||||
temp_s1 = &D_E0078918[unk_00];
|
||||
temp_s6 = temp_s1->unk_10;
|
||||
temp_s3 = temp_s1->unk_14;
|
||||
temp_s1 = &D_E0078918[temp_s2];
|
||||
glowExtent = temp_s1->unk_10;
|
||||
rectHeight = temp_s1->unk_14;
|
||||
|
||||
var_v1 = shim_is_point_visible(data->pos.x, data->pos.y, data->pos.z, data->unk_1C, &sp18, &sp1C);
|
||||
if (unk_00 == 5) {
|
||||
var_v1 = 1;
|
||||
isPointVisible = shim_is_point_visible(data->pos.x, data->pos.y, data->pos.z, data->unk_1C, ¢erX, ¢erY);
|
||||
|
||||
// There are 6 UnkStruct entries in the array at E0078918, so this refers to the last one
|
||||
if (temp_s2 == 5) {
|
||||
isPointVisible = TRUE;
|
||||
}
|
||||
if ((var_v1 != 0) && !(sp18 < 0.0f) && !(sp1C < 0.0f) && !(sp18 >= 320.0f) && !(sp1C >= 240.0f)) {
|
||||
u8 r, g, b;
|
||||
|
||||
gSPDisplayList(gMasterGfxPos++, D_E0078900[unk_00]);
|
||||
if (!isPointVisible || centerX < 0.0f || centerY < 0.0f || centerX >= SCREEN_WIDTH || centerY >= SCREEN_HEIGHT) {
|
||||
return;
|
||||
}
|
||||
|
||||
temp_v0 = &D_E00789AC[data->unk_20 * 3];
|
||||
temp_t0 = unk_10 * 2;
|
||||
gSPDisplayList(gMasterGfxPos++, D_E0078900[temp_s2]);
|
||||
temp_v0 = &D_E00789AC[data->unk_20];
|
||||
colorScale = (brightness * 2);
|
||||
r = temp_v0->r * colorScale / 255;
|
||||
g = temp_v0->g * colorScale / 255;
|
||||
b = temp_v0->b * colorScale / 255;
|
||||
|
||||
r = temp_v0[0] * temp_t0 / 255;
|
||||
g = temp_v0[1] * temp_t0 / 255;
|
||||
b = temp_v0[2] * temp_t0 / 255;
|
||||
gDPSetPrimColor(gMasterGfxPos++, 0, 0, r, g, b, 0x7F);
|
||||
|
||||
gDPSetPrimColor(gMasterGfxPos++, 0, 0, r, g, b, 127);
|
||||
// temp_s1 = E0078948
|
||||
// unk_00 = 64
|
||||
// unk_04 = 64
|
||||
// unk_08 = 1.0f
|
||||
// unk_0C = 1.0f
|
||||
// unk_10 = 64 (glow_extent)
|
||||
// unk_14 = 8 (rect_height)
|
||||
|
||||
sp20 = sp18 - temp_s6;
|
||||
var_t7 = sp20 + temp_s6 * 2;
|
||||
temp_f6 = sp1C - temp_s6;
|
||||
var_t4 = temp_f6 + temp_s6 * 2;
|
||||
// x_center = 247
|
||||
// y_center = 107
|
||||
// glow_extent = 64
|
||||
// x_min = 183
|
||||
// x_max = 311
|
||||
// y_min = 43
|
||||
// y_max = 171
|
||||
|
||||
var_t5 = 0;
|
||||
if (sp20 < 0) {
|
||||
var_t5 = -sp20;
|
||||
}
|
||||
var_v1_2 = 0;
|
||||
if (temp_f6 < 0) {
|
||||
var_v1_2 = -temp_f6;
|
||||
}
|
||||
if (var_t7 > 320) {
|
||||
var_t7 = 319;
|
||||
}
|
||||
if (var_t4 > 240) {
|
||||
var_t4 = 239;
|
||||
}
|
||||
temp_lo = (s32) (var_t4 - temp_f6) / temp_s3;
|
||||
xMin = centerX - glowExtent;
|
||||
xMax = xMin + glowExtent * 2;
|
||||
yMin = centerY - glowExtent;
|
||||
yMax = yMin + glowExtent * 2;
|
||||
|
||||
for (i = var_v1_2 / temp_s3; i < temp_lo; i++) {
|
||||
if ((i + 1) * temp_s3 + temp_f6 >= 240) {
|
||||
break;
|
||||
}
|
||||
xStart = 0;
|
||||
if (xMin < 0) {
|
||||
xStart = -xMin;
|
||||
}
|
||||
yStart = 0;
|
||||
if (yMin < 0) {
|
||||
yStart = -yMin;
|
||||
}
|
||||
if (xMax > SCREEN_WIDTH) {
|
||||
xMax = SCREEN_WIDTH - 1;
|
||||
}
|
||||
if (yMax > SCREEN_HEIGHT) {
|
||||
yMax = SCREEN_HEIGHT - 1;
|
||||
}
|
||||
|
||||
gDPSetTileSize(gMasterGfxPos++, G_TX_RENDERTILE,
|
||||
(s32) (sp20 * temp_s1->unk_08) * 4,
|
||||
(s32) (temp_s1->unk_04 * 0x14 - i * temp_s1->unk_14 * temp_s1->unk_0C) * 4,
|
||||
(s32) (sp20 * temp_s1->unk_08 + temp_s1->unk_00) * 4,
|
||||
(s32) (temp_s1->unk_04 * 0x15 - i * temp_s1->unk_14 * temp_s1->unk_0C) * 4);
|
||||
numRects = (yMax - yMin) / rectHeight;
|
||||
|
||||
for (j = 0; j < 1; j++) {
|
||||
gDPLoadMultiTile(gMasterGfxPos++, VIRTUAL_TO_PHYSICAL(nuGfxCfb_ptr + (i * temp_s3 + temp_f6) * 0x280),
|
||||
0x0100, 1, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, 0, sp20 + var_t5, 0, var_t7 - 1, temp_s3 - 1,
|
||||
0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 9, 8, G_TX_NOLOD, G_TX_NOLOD);
|
||||
gSPTextureRectangle(gMasterGfxPos++, (sp20 + var_t5) * 4, (i * temp_s3 + temp_f6) * 4, var_t7 * 4, ((i + 1) * temp_s3 + temp_f6) * 4, G_TX_RENDERTILE, sp20 + var_t5, 0, 0x0400, 0x0400);
|
||||
gDPPipeSync(gMasterGfxPos++);
|
||||
}
|
||||
for (i = yStart / rectHeight; i < numRects && (i + 1) * rectHeight + yMin < SCREEN_HEIGHT; i++) {
|
||||
gDPSetTileSize(gMasterGfxPos++, G_TX_RENDERTILE,
|
||||
// uls = 183 << 2
|
||||
(s32) (xMin * temp_s1->unk_08) << 2,
|
||||
// This code is correct due to being masked to 12 bits
|
||||
// However, the wrapping may not be intended from the developer's perspective so it may be a bug
|
||||
// ult = (256 << 2, 248 << 2, 240 << 2, ...)
|
||||
(s32) (temp_s1->unk_04 * 20 - i * temp_s1->unk_14 * temp_s1->unk_0C) << 2,
|
||||
// lrs = 247 << 2
|
||||
(s32) (xMin * temp_s1->unk_08 + temp_s1->unk_00) << 2,
|
||||
// This code is correct as well, same as above
|
||||
// lrt = (320 << 2, 312 << 2, 304 << 2, ...)
|
||||
(s32) (temp_s1->unk_04 * 21 - i * temp_s1->unk_14 * temp_s1->unk_0C) << 2);
|
||||
|
||||
for (j = 0; j < 1; j++) {
|
||||
gDPLoadMultiTile(gMasterGfxPos++,
|
||||
// Offset the image to the rows being loaded
|
||||
VIRTUAL_TO_PHYSICAL(nuGfxCfb_ptr + (i * rectHeight + yMin) * (SCREEN_WIDTH * sizeof(u16))),
|
||||
TMEM_ADDR(TMEM_SIZE/2), G_TX_RENDERTILE + 1, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, 0,
|
||||
// uls = 183, ult = 0
|
||||
(xMin + xStart), 0,
|
||||
// lrs = 311 - 1, lrt = 8 - 1
|
||||
xMax - 1, rectHeight - 1,
|
||||
0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 9, 8, G_TX_NOLOD, G_TX_NOLOD);
|
||||
gSPTextureRectangle(gMasterGfxPos++,
|
||||
// xl = 183 << 2, yl = (43 << 2, 51 << 2, 59 << 2, ...)
|
||||
(xMin + xStart) << 2, (i * rectHeight + yMin) << 2,
|
||||
// xr = 311 << 2, yh = (51 << 2, 59 << 2, 67 << 2, ...)
|
||||
xMax << 2, ((i + 1) * rectHeight + yMin) << 2,
|
||||
G_TX_RENDERTILE,
|
||||
// s = 183 << 5, t = 0
|
||||
((xMin + xStart) & 0x1FF) << 5, 0,
|
||||
1 << 10, 1 << 10);
|
||||
gDPPipeSync(gMasterGfxPos++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
INCLUDE_ASM(s32, "effects/bulb_glow", bulb_glow_appendGfx);
|
||||
#endif
|
||||
|
@ -92,14 +92,14 @@ EffectInstance* fx_65_main(
|
||||
data->pos.z = arg3;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(data->unk_230); i++) {
|
||||
data->unk_230[i] = 0;
|
||||
data->unk_230[i] = FALSE;
|
||||
}
|
||||
|
||||
data->unk_2A8 = 0;
|
||||
data->unk_50[0] = arg1;
|
||||
data->unk_C8[0] = arg2;
|
||||
data->unk_140[0] = arg3;
|
||||
data->unk_230[0] = 1;
|
||||
data->unk_230[0] = TRUE;
|
||||
data->unk_1B8[0] = 0;
|
||||
data->unk_2AC[0] = 0;
|
||||
data->unk_44 = shim_rand_int(30) + 10;
|
||||
@ -165,7 +165,7 @@ void fx_65_update(EffectInstance* effect) {
|
||||
tempY = data->unk_C8[idx];
|
||||
tempZ = data->unk_140[idx];
|
||||
|
||||
if ((posX != tempX) || (posY != tempY) || (posZ != tempZ)) {
|
||||
if (posX != tempX || posY != tempY || posZ != tempZ) {
|
||||
unk_2AC = data->unk_2AC[idx];
|
||||
|
||||
data->unk_2A8++;
|
||||
@ -175,7 +175,7 @@ void fx_65_update(EffectInstance* effect) {
|
||||
|
||||
idx = data->unk_2A8;
|
||||
|
||||
data->unk_230[idx] = 1;
|
||||
data->unk_230[idx] = TRUE;
|
||||
data->unk_50[idx] = posX;
|
||||
data->unk_C8[idx] = posY;
|
||||
data->unk_140[idx] = posZ;
|
||||
@ -206,42 +206,43 @@ void fx_65_render(EffectInstance* effect) {
|
||||
// floats and more
|
||||
#ifdef NON_MATCHING
|
||||
void fx_65_appendGfx(void* effect) {
|
||||
Effect65FXData* data = ((EffectInstance*)effect)->data.unk_65;
|
||||
Effect65FXData* data = ((EffectInstance*)effect)->data.unk_65; //s6
|
||||
Matrix4f sp10;
|
||||
f32 padding[2];
|
||||
s32 sp50;
|
||||
s32 sp54;
|
||||
f32 sp58;
|
||||
Gfx* vtxBuffer;
|
||||
Vtx_t* sp5C;
|
||||
Vtx_t* vtx;
|
||||
s32 sp60;
|
||||
s32 sp64;
|
||||
s32 sp68;
|
||||
s32 idx;
|
||||
s32 idx2;
|
||||
f32 posX, posY, posZ;
|
||||
f32 deltaX, deltaY;
|
||||
Vtx_t* vtx;
|
||||
s32 i;
|
||||
|
||||
f32 temp_f0;
|
||||
f32 temp_f20;
|
||||
f32 sp58;
|
||||
f32 temp_f22;
|
||||
f32 temp_f24;
|
||||
f32 temp_f26;
|
||||
f32 temp_f28;
|
||||
f32 temp_f2;
|
||||
f32 var_f12;
|
||||
f32 var_f20;
|
||||
f32 var_f30;
|
||||
s32 temp_fp;
|
||||
s32 temp_s1;
|
||||
s32 temp_s5;
|
||||
s32 primAlpha;
|
||||
s32 temp_s5_2;
|
||||
s32 temp_v0;
|
||||
s32 temp_v1_2;
|
||||
s32 var_fp;
|
||||
s32 vtxG;
|
||||
s32 var_s1;
|
||||
s32 vtxB;
|
||||
s32 vtxR;
|
||||
s32 vtxA;
|
||||
s32 temp_s1;
|
||||
s32 a;
|
||||
s32 r, g, b;
|
||||
|
||||
s32 idx; //s3
|
||||
s32 next; //v1
|
||||
s32 prev;
|
||||
s32 i;
|
||||
|
||||
float new_var;
|
||||
|
||||
primAlpha = data->unk_24;
|
||||
sp50 = data->unk_14;
|
||||
temp_s5 = data->unk_24;
|
||||
sp54 = data->unk_00;
|
||||
sp58 = data->unk_34;
|
||||
|
||||
@ -257,124 +258,134 @@ void fx_65_appendGfx(void* effect) {
|
||||
if (sp54 >= 2) {
|
||||
gDPSetCombineLERP(gMasterGfxPos++, SHADE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, SHADE, 0, 0, 0, 0, COMBINED, COMBINED, 0, PRIMITIVE, 0);
|
||||
}
|
||||
var_fp = 0;
|
||||
|
||||
gDPSetPrimColor(gMasterGfxPos++, 0, 0, data->unk_18, data->unk_1C, data->unk_20, primAlpha);
|
||||
gDPSetEnvColor(gMasterGfxPos++, data->unk_28, data->unk_2C, data->unk_30, 0);
|
||||
gSPBranchList(gMasterGfxPos, gMasterGfxPos + 0x79);
|
||||
|
||||
sp5C = (Vtx_t*) (gMasterGfxPos + 1);
|
||||
sp60 = -1;
|
||||
sp64 = (sp50 & 0x3F) << 5;
|
||||
gDPSetPrimColor(gMasterGfxPos++, 0, 0, data->unk_18, data->unk_1C, data->unk_20, temp_s5);
|
||||
gDPSetEnvColor(gMasterGfxPos++, data->unk_28, data->unk_2C, data->unk_30, 0);
|
||||
gSPBranchList(gMasterGfxPos, &gMasterGfxPos[121]);
|
||||
gMasterGfxPos += 0x79;
|
||||
|
||||
vtxBuffer = (Vtx_t*) (gMasterGfxPos + 1);
|
||||
gMasterGfxPos = &gMasterGfxPos[121];
|
||||
|
||||
for (i = 1; i < 30; i++) {
|
||||
if (data->unk_230[(data->unk_2A8 + i) % 30] != 0) {
|
||||
var_fp += 1;
|
||||
// use i in iteration?
|
||||
var_fp = 0;
|
||||
for (i = 0; i < 30; i++) {
|
||||
s32 a1 = i + 1;
|
||||
s32 idx = (data->unk_2A8 + a1) % 30;
|
||||
if (data->unk_230[idx]) {
|
||||
var_fp++;
|
||||
}
|
||||
}
|
||||
|
||||
temp_fp = var_fp - 1;
|
||||
i = 0;
|
||||
if (temp_fp > 0) {
|
||||
var_fp--;
|
||||
if (var_fp > 0) {
|
||||
sp68 = 0;
|
||||
|
||||
for (; i < 30; i++) {
|
||||
Vtx_t* vtx = &vtxBuffer[i * 2];
|
||||
|
||||
idx2 = (data->unk_2A8 + (i + 1)) % 30;
|
||||
vtxA = shim_sin_deg((f32) (sp68 / temp_fp)) * 255.0f;
|
||||
if (vtxA > 200) {
|
||||
vtxA = 200;
|
||||
for (i = 0; i < 30; i++) {
|
||||
s32 a1 = i + 1;
|
||||
vtx = &sp5C[i * 2];
|
||||
prev = sp68 / var_fp;
|
||||
idx = (data->unk_2A8 + a1) % 30;
|
||||
a = shim_sin_deg(prev) * 255.0f;
|
||||
if (a > 200) {
|
||||
a = 200;
|
||||
}
|
||||
if (data->unk_230[idx2] != 0) {
|
||||
|
||||
if (data->unk_230[idx]) {
|
||||
if (sp60 == -1) {
|
||||
idx = idx2 + 1;
|
||||
if (idx >= 30) {
|
||||
idx = 0;
|
||||
}
|
||||
sp60 = i;
|
||||
var_f30 = -shim_atan2(data->unk_C8[idx], -data->unk_50[idx], data->unk_C8[idx2], -data->unk_50[idx2]);
|
||||
do {
|
||||
next = idx + 1;
|
||||
if (next >= 30) {
|
||||
next = 0;
|
||||
}
|
||||
sp60 = i;
|
||||
var_f30 = -shim_atan2(data->unk_C8[next], -data->unk_50[next], data->unk_C8[idx], -data->unk_50[idx]);
|
||||
} while (0); // TODO required to match
|
||||
} else {
|
||||
idx = idx2 + 1;
|
||||
if (i != 0x1D) {
|
||||
var_s1 = idx2 - 1;
|
||||
if (idx >= 30) {
|
||||
idx = 0;
|
||||
if (i != 29) {
|
||||
next = idx + 1;
|
||||
prev = idx - 1;
|
||||
if (next >= 30) {
|
||||
next = 0;
|
||||
}
|
||||
if (var_s1 < 0) {
|
||||
var_s1 = 29;
|
||||
if (prev < 0) {
|
||||
prev = 29;
|
||||
}
|
||||
var_f20 = -shim_atan2(data->unk_C8[idx], -data->unk_50[idx], data->unk_C8[idx2], -data->unk_50[idx2]);
|
||||
var_f12 = -shim_atan2(data->unk_C8[idx2], -data->unk_50[idx2], data->unk_C8[var_s1], -data->unk_50[var_s1]);
|
||||
var_f20 = -shim_atan2(data->unk_C8[next], -data->unk_50[next], data->unk_C8[idx], -data->unk_50[idx]);
|
||||
var_f12 = -shim_atan2(data->unk_C8[idx], -data->unk_50[idx], data->unk_C8[prev], -data->unk_50[prev]);
|
||||
temp_f2 = var_f12 - var_f20;
|
||||
if (temp_f2 > 180.0f) {
|
||||
var_f20 += 360.0f;
|
||||
} else if (temp_f2 < -180.0f) {
|
||||
var_f12 += 360.0f;
|
||||
}
|
||||
var_f30 = (f64) (var_f20 + var_f12) * 0.5;
|
||||
var_f30 = (var_f20 + var_f12);
|
||||
var_f30 *= 0.5;
|
||||
}
|
||||
}
|
||||
temp_v1_2 = data->unk_1B8[idx2];
|
||||
posX = data->unk_50[idx2];
|
||||
posY = data->unk_C8[idx2];
|
||||
posZ = data->unk_140[idx2];
|
||||
temp_s1 = sp50 - temp_v1_2;
|
||||
//temp_f22 = ((shim_sin_deg(((sp50 - (temp_v1_2 * 80)) * 4)) * 3.0f) + 16.0f + temp_s1) * sp58;
|
||||
temp_f22 = ((shim_sin_deg((sp50 - (temp_v1_2 * 80)) * 4) * 3.0f) + 16.0f) + temp_s1;
|
||||
temp_f22 = temp_f22 * sp58;
|
||||
temp_s5_2 = (data->unk_2AC[idx2] * 24.0f) + sp64;
|
||||
temp_f24 = data->unk_50[idx];
|
||||
temp_f26 = data->unk_C8[idx];
|
||||
temp_f28 = data->unk_140[idx];
|
||||
new_var = 24.0f;
|
||||
//temp_v1 = data->unk_1B8[idx];
|
||||
temp_s1 = sp50 - data->unk_1B8[idx];
|
||||
temp_f22 = (shim_sin_deg((sp50 - data->unk_1B8[idx] * 80) * 4) * 3.0f + 16.0f + temp_s1) * sp58;
|
||||
temp_s5_2 = sp64;
|
||||
temp_s5_2 = (data->unk_2AC[idx] * new_var) + temp_s5_2;
|
||||
|
||||
do {
|
||||
vtxR = 0xFF;
|
||||
vtxG = 0xFF;
|
||||
vtxB = 0xFF - (temp_s1 * 100);
|
||||
if (vtxB < 0) {
|
||||
vtxG = ((f32) vtxB * 0.8) + 255.0;
|
||||
vtxB = 0;
|
||||
if (vtxG < 0) {
|
||||
vtxR = ((f32) vtxG * 0.4) + 255.0;
|
||||
vtxG = 0;
|
||||
if (vtxR < 0) {
|
||||
vtxR = 0;
|
||||
}
|
||||
do {} while (0);
|
||||
|
||||
r = 255;
|
||||
g = 255;
|
||||
b = 255 - temp_s1 * 100;
|
||||
if (b < 0) {
|
||||
g = (f32) b * 0.8 + 255.0;
|
||||
b = 0;
|
||||
if (g < 0) {
|
||||
r = (f32) g * 0.4 + 255.0;
|
||||
g = 0;
|
||||
sp54 = r < 0;
|
||||
if (sp54) {
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
|
||||
deltaX = temp_f22 * shim_sin_deg(var_f30);
|
||||
deltaY = temp_f22 * shim_cos_deg(var_f30);
|
||||
sp68 += 180;
|
||||
temp_f20 = temp_f22 * shim_sin_deg(var_f30);
|
||||
temp_f0 = temp_f22 * shim_cos_deg(var_f30);
|
||||
|
||||
vtx->ob[0] = posX + deltaX;
|
||||
vtx->ob[1] = posY + deltaY;
|
||||
vtx->ob[2] = posZ + 0.0f;
|
||||
vtx->ob[0] = temp_f24 + temp_f20;
|
||||
vtx->ob[1] = temp_f26 + temp_f0;
|
||||
vtx->ob[2] = temp_f28 + 0.0f;
|
||||
vtx->tc[0] = temp_s5_2;
|
||||
vtx->tc[1] = 0x400;
|
||||
vtx->cn[0] = vtxR;
|
||||
vtx->cn[1] = vtxG;
|
||||
vtx->cn[2] = vtxB;
|
||||
vtx->cn[3] = vtxA;
|
||||
vtx->cn[0] = r;
|
||||
vtx->cn[1] = g;
|
||||
vtx->cn[2] = b;
|
||||
vtx->cn[3] = a;
|
||||
vtx++;
|
||||
|
||||
vtx->ob[0] = posX - deltaX;
|
||||
vtx->ob[1] = posY - deltaY;
|
||||
vtx->ob[2] = posZ + 0.0f;
|
||||
vtx->ob[0] = temp_f24 - temp_f20;
|
||||
vtx->ob[1] = temp_f26 - temp_f0;
|
||||
vtx->ob[2] = temp_f28 + 0.0f;
|
||||
vtx->tc[0] = temp_s5_2;
|
||||
vtx->tc[1] = 0;
|
||||
vtx->cn[0] = vtxR;
|
||||
vtx->cn[1] = vtxG;
|
||||
vtx->cn[2] = vtxB;
|
||||
vtx->cn[3] = vtxA;
|
||||
vtx->cn[0] = r;
|
||||
vtx->cn[1] = g;
|
||||
vtx->cn[2] = b;
|
||||
vtx->cn[3] = a;
|
||||
vtx++;
|
||||
|
||||
sp68 += 180;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = sp60; i < 29; i++) {
|
||||
gSPVertex(gMasterGfxPos++, &vtxBuffer[i * 4], 4, 0);
|
||||
gSPVertex(gMasterGfxPos++, &sp5C[i * 2], 4, 0);
|
||||
gSP2Triangles(gMasterGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
|
||||
}
|
||||
}
|
||||
|
||||
gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW);
|
||||
}
|
||||
#else
|
||||
|
@ -214,12 +214,12 @@ void lightning_bolt_appendGfx(void* effect) {
|
||||
|
||||
gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gDPSetPrimColor(gMasterGfxPos++, 0, 0, data->outerColor.r, data->outerColor.g, data->outerColor.b, temp_s3);
|
||||
gDPSetEnvColor(gMasterGfxPos++, data->innerColor.r, data->innerColor.g, data->innerColor.b, 0x80);
|
||||
gDPSetEnvColor(gMasterGfxPos++, data->innerColor.r, data->innerColor.g, data->innerColor.b, 128);
|
||||
gSPDisplayList(gMasterGfxPos++, D_09001000_3BBEA0);
|
||||
|
||||
temp_a0 = temp_s7 - 1;
|
||||
if (temp_s6 != 2) {
|
||||
if (temp_a0 < 0xB) {
|
||||
if (temp_a0 <= 10) {
|
||||
var_s2 = &D_E00BCE40[temp_s6][temp_a0];
|
||||
} else {
|
||||
var_s2 = &D_E00BCE40[temp_s6][10];
|
||||
@ -235,7 +235,7 @@ void lightning_bolt_appendGfx(void* effect) {
|
||||
for (i = 0; i < 12; i++) {
|
||||
temp_f24 = (data->endPos.x - data->startPos.x) * (1 / 11.0f);
|
||||
temp_f22 = (data->endPos.y - data->startPos.y) * (1 / 11.0f);
|
||||
temp_f28 = (data->unk_110 + (i - temp_s7) * 0xA) % 120 - 0x3C;
|
||||
temp_f28 = (data->unk_110 + (i - temp_s7) * 10) % 120 - 60;
|
||||
temp_f26 = var_s2->unk_00[i];
|
||||
|
||||
temp_f20 = shim_sin_deg(temp_f28) * temp_f26 * 0.04;
|
||||
@ -262,17 +262,20 @@ void lightning_bolt_appendGfx(void* effect) {
|
||||
var_f22 = -shim_atan2(data->unk_80[1], -data->unk_50[1], data->unk_80[0], -data->unk_50[0]);
|
||||
} else {
|
||||
temp_fs2 = 8.0f;
|
||||
if (i == 0xB) {
|
||||
if (i == 11) {
|
||||
var_f22 = -90.0f;
|
||||
} else {
|
||||
var_f20 = -shim_atan2(data->unk_80[i + 1], -data->unk_50[i + 1], data->unk_80[i], -data->unk_50[i]);
|
||||
var_f2 = -shim_atan2(data->unk_80[i], -data->unk_50[i], data->unk_80[i - 1], -data->unk_50[i - 1]);
|
||||
if (var_f2 - var_f20 > 180.0f) {
|
||||
var_f22 = var_f2 - var_f20;
|
||||
if (var_f22 > 180.0f) {
|
||||
var_f20 += 360.0f;
|
||||
} else if (var_f2 - var_f20 < -180.0f) {
|
||||
} else if (var_f22 < -180.0f) {
|
||||
var_f2 += 360.0f;
|
||||
}
|
||||
var_f22 = (var_f20 + var_f2) * 0.5;
|
||||
//var_f22 = (var_f20 + var_f2) * 0.5;
|
||||
var_f22 = (var_f20 + var_f2);
|
||||
var_f22 /= 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,23 @@
|
||||
#include "common.h"
|
||||
#include "effects_internal.h"
|
||||
#include "nu/nusys.h"
|
||||
|
||||
s32 D_E00A29D0[] = { 0x09000200, 0x090002A8, 0x09000358 };
|
||||
|
||||
s32 D_E00A29DC[] = { 0x00000010, 0x00000010, 0x3F800000, 0x3F800000, 0x00000008, 0x00000008, 0x00000010, 0x00000010, 0x3F800000, 0x3F800000, 0x00000008, 0x00000008, 0x00000010, 0x00000010, 0x3F800000, 0x3F800000, 0x00000008, 0x00000008 };
|
||||
typedef struct UnkStruct {
|
||||
/* 0x00 */ s32 unk_00;
|
||||
/* 0x04 */ s32 unk_04;
|
||||
/* 0x08 */ f32 unk_08;
|
||||
/* 0x0C */ f32 unk_0C;
|
||||
/* 0x10 */ s32 unk_10;
|
||||
/* 0x14 */ s32 unk_14;
|
||||
} UnkStruct; // size = 0x18
|
||||
|
||||
UnkStruct D_E00A29DC[] = {
|
||||
{ 16, 16, 1.0f, 1.0f, 8, 8 },
|
||||
{ 16, 16, 1.0f, 1.0f, 8, 8 },
|
||||
{ 16, 16, 1.0f, 1.0f, 8, 8 },
|
||||
};
|
||||
|
||||
s32 D_E00A2A24[] = { 100, 60, 30, 10, 0, 0, 0 };
|
||||
|
||||
@ -105,4 +119,158 @@ void motion_blur_flame_render(EffectInstance* effect) {
|
||||
void func_E00A2234(void) {
|
||||
}
|
||||
|
||||
INCLUDE_ASM(s32, "effects/motion_blur_flame", motion_blur_flame_appendGfx);
|
||||
void motion_blur_flame_appendGfx(void* effect) {
|
||||
MotionBlurFlameFXData* data = ((EffectInstance*)effect)->data.motionBlurFlame;
|
||||
s32 temp_a2 = data->unk_00;
|
||||
f32 sp48;
|
||||
f32 sp4C;
|
||||
s32 sp50 = data->unk_4C;
|
||||
UnkStruct* temp_s1 = &D_E00A29DC[temp_a2];
|
||||
s32 sp54; // declaration must come after sp50
|
||||
s32 envR, envG, envB;
|
||||
s32 sp18[4];
|
||||
f32 sp28[4];
|
||||
f32 sp38[4];
|
||||
s32 i;
|
||||
|
||||
s32 t3;
|
||||
s32 v0;
|
||||
s32 temp_a0;
|
||||
s32 s3;
|
||||
s32 temp_v0_2;
|
||||
s32 temp_v0_3;
|
||||
s32 temp_v1;
|
||||
s32 var_a0;
|
||||
s32 var_a1;
|
||||
s32 var_a2;
|
||||
s32 uly;
|
||||
s32 var_t2_2;
|
||||
s32 var_t4;
|
||||
s32 t6;
|
||||
s32 var_v1;
|
||||
|
||||
gDPPipeSync(gMasterGfxPos++);
|
||||
gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
|
||||
gSPDisplayList(gMasterGfxPos++, D_E00A29D0[temp_a2]);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
f32 temp_f12 = data->unk_1C[i];
|
||||
f32 temp_f14 = data->unk_2C[i];
|
||||
f32 temp_f0 = data->unk_3C[i];
|
||||
s32 temp_s5 = temp_s1->unk_10;
|
||||
s32 height = temp_s1->unk_14;
|
||||
|
||||
if (i == 0) {
|
||||
var_a2 = shim_is_point_visible(temp_f12, temp_f14, temp_f0, -1, &sp48, &sp4C);
|
||||
} else {
|
||||
var_a2 = temp_f0;
|
||||
sp48 = temp_f12;
|
||||
sp4C = temp_f14;
|
||||
}
|
||||
|
||||
sp18[i] = var_a2;
|
||||
sp28[i] = sp48;
|
||||
sp38[i] = sp4C;
|
||||
|
||||
if ((var_a2 != 0) && !(sp48 < 0.0f) && !(sp4C < 0.0f) && !(sp48 >= 320.0f) && !(sp4C >= 240.0f)) {
|
||||
temp_a0 = (sp50 * D_E00A2A24[i]) / 100;
|
||||
temp_v1 = (data->unk_5C * temp_a0) >> 9;
|
||||
temp_v0_2 = (data->unk_60 * temp_a0) >> 9;
|
||||
temp_v0_3 = (data->unk_64 * temp_a0) >> 9;
|
||||
|
||||
gDPSetPrimColor(gMasterGfxPos++, 0, 0,
|
||||
(temp_v1 * temp_a0) >> 8,
|
||||
(temp_v0_2 * temp_a0) >> 8,
|
||||
(temp_v0_3 * temp_a0) >> 8,
|
||||
255
|
||||
);
|
||||
|
||||
envR = temp_v1 + 32;
|
||||
envG = temp_v0_2 + 32;
|
||||
envB = temp_v0_3 + 32;
|
||||
if (envR > 127) {
|
||||
envR = 127;
|
||||
}
|
||||
if (envG > 127) {
|
||||
envG = 127;
|
||||
}
|
||||
if (envB > 127) {
|
||||
envB = 127;
|
||||
}
|
||||
|
||||
gDPSetEnvColor(gMasterGfxPos++, envR, envG, envB, 0);
|
||||
|
||||
s3 = sp48 - temp_s5;
|
||||
t6 = s3 + temp_s5 * 2;
|
||||
v0 = sp4C - temp_s5;
|
||||
var_a0 = v0 + 2 * temp_s5;
|
||||
t3 = uly = sp4C - temp_s5;
|
||||
|
||||
if (s3 < 0) {
|
||||
var_a1 = -s3;
|
||||
} else {
|
||||
var_a1 = 0;
|
||||
}
|
||||
|
||||
if (t3 < 0) {
|
||||
var_v1 = -uly;
|
||||
} else {
|
||||
var_v1 = 0;
|
||||
}
|
||||
|
||||
if (t6 > SCREEN_WIDTH) {
|
||||
t6 = SCREEN_WIDTH - 1;
|
||||
}
|
||||
if (var_a0 > SCREEN_HEIGHT) {
|
||||
var_a0 = SCREEN_HEIGHT - 1;
|
||||
}
|
||||
|
||||
var_t2_2 = var_v1 / height;
|
||||
sp54 = (var_a0 - t3) / height;
|
||||
|
||||
while (var_t2_2 < sp54) {
|
||||
uly = t3 + var_t2_2 * height;
|
||||
if (uly + height >= SCREEN_HEIGHT) {
|
||||
break;
|
||||
}
|
||||
|
||||
gDPSetTileSize(gMasterGfxPos++, G_TX_RENDERTILE,
|
||||
(s32) (s3 * temp_s1->unk_08) * 4,
|
||||
(s32) (temp_s1->unk_04 * 20 - var_t2_2 * temp_s1->unk_14 * temp_s1->unk_0C) * 4,
|
||||
(s32) (s3 * temp_s1->unk_08 + temp_s1->unk_00) * 4,
|
||||
(s32) (temp_s1->unk_04 * 21 - var_t2_2 * temp_s1->unk_14 * temp_s1->unk_0C) * 4);
|
||||
|
||||
for (var_t4 = 0; var_t4 < 2; var_t4++) {
|
||||
gDPLoadMultiTile(gMasterGfxPos++, VIRTUAL_TO_PHYSICAL(nuGfxCfb_ptr + uly * SCREEN_WIDTH),
|
||||
0x0100, 1, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
s3 + var_a1,
|
||||
0,
|
||||
t6 - 1,
|
||||
height - 1,
|
||||
0,
|
||||
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 9, 8, G_TX_NOLOD, G_TX_NOLOD
|
||||
);
|
||||
gSPTextureRectangle(gMasterGfxPos++,
|
||||
(s3 + var_a1) * 4,
|
||||
uly * 4,
|
||||
t6 * 4,
|
||||
(uly + height) * 4,
|
||||
G_TX_RENDERTILE,
|
||||
((u32) (s3 + var_a1) % 0x200) * 32,
|
||||
0,
|
||||
0x0400,
|
||||
0x0400
|
||||
);
|
||||
gDPPipeSync(gMasterGfxPos++);
|
||||
}
|
||||
var_t2_2++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(data->unk_3C) - 1; i++) {
|
||||
data->unk_3C[i + 1] = sp18[i];
|
||||
data->unk_1C[i + 1] = sp28[i];
|
||||
data->unk_2C[i + 1] = sp38[i];
|
||||
}
|
||||
}
|
||||
|
136
src/npc.c
136
src/npc.c
@ -65,7 +65,7 @@ void clear_npcs(void) {
|
||||
}
|
||||
|
||||
gNpcCount = 0;
|
||||
D_800A0B94 = 1;
|
||||
gNpcPlayerCollisionsEnabled = TRUE;
|
||||
}
|
||||
|
||||
void init_npc_list(void) {
|
||||
@ -76,7 +76,7 @@ void init_npc_list(void) {
|
||||
}
|
||||
|
||||
gNpcCount = 0;
|
||||
D_800A0B94 = 1;
|
||||
gNpcPlayerCollisionsEnabled = TRUE;
|
||||
}
|
||||
|
||||
void npc_iter_no_op(void) {
|
||||
@ -381,15 +381,9 @@ void npc_do_world_collision(Npc* npc) {
|
||||
}
|
||||
}
|
||||
|
||||
// float regalloc :(
|
||||
#ifdef NON_MATCHING
|
||||
void npc_do_other_npc_collision(Npc* npc) {
|
||||
Npc* otherNpc;
|
||||
f32 temp_f20_2;
|
||||
f32 temp_f22_3;
|
||||
f32 temp_f24_2;
|
||||
f32 temp_f22_4;
|
||||
f32 temp_f2;
|
||||
f32 angle;
|
||||
f32 thisX, thisY, thisZ;
|
||||
f32 thisBuf;
|
||||
f32 otherX, otherZ;
|
||||
@ -406,7 +400,7 @@ void npc_do_other_npc_collision(Npc* npc) {
|
||||
thisY = npc->pos.y;
|
||||
thisZ = npc->pos.z;
|
||||
|
||||
for (i = 0; i < 0x40; i++) {
|
||||
for (i = 0; i < MAX_NPCS; i++) {
|
||||
otherNpc = get_npc_by_index(i);
|
||||
if (otherNpc != NULL && npc != otherNpc) {
|
||||
if (otherNpc->flags != 0 && !(otherNpc->flags & (NPC_FLAG_SUSPENDED | NPC_FLAG_IGNORE_PLAYER_COLLISION))) {
|
||||
@ -414,8 +408,8 @@ void npc_do_other_npc_collision(Npc* npc) {
|
||||
!(thisY + npc->collisionHeight < otherNpc->pos.y))
|
||||
{
|
||||
otherX = otherNpc->pos.x;
|
||||
otherZ = otherNpc->pos.z;
|
||||
xDiff = otherX - thisX;
|
||||
otherZ = otherNpc->pos.z;
|
||||
zDiff = otherZ - thisZ;
|
||||
otherBuf = otherNpc->collisionRadius * 0.5f;
|
||||
dist = sqrtf(SQ(xDiff) + SQ(zDiff));
|
||||
@ -424,17 +418,19 @@ void npc_do_other_npc_collision(Npc* npc) {
|
||||
collision = FALSE;
|
||||
if (npc->flags & NPC_FLAG_PARTNER) {
|
||||
collision = gPartnerActionStatus.partnerActionState == PARTNER_ACTION_NONE;
|
||||
} else if (!(otherNpc->flags & NPC_FLAG_PARTNER) || gPartnerActionStatus.partnerActionState == PARTNER_ACTION_NONE) {
|
||||
} else if (!(otherNpc->flags & NPC_FLAG_PARTNER) ||
|
||||
gPartnerActionStatus.partnerActionState == PARTNER_ACTION_NONE)
|
||||
{
|
||||
collision = TRUE;
|
||||
}
|
||||
|
||||
if (collision) {
|
||||
temp_f20_2 = DEG_TO_RAD(atan2(otherX, otherZ, thisX, thisZ));
|
||||
temp_f24_2 = thisBuf + otherBuf - dist;
|
||||
temp_f22_3 = temp_f24_2 * sin_rad(temp_f20_2);
|
||||
temp_f22_4 = -temp_f24_2 * cos_rad(temp_f20_2);
|
||||
thisX += temp_f22_3 * 0.1f;
|
||||
thisZ += temp_f22_4 * 0.1f;
|
||||
angle = DEG_TO_RAD(atan2(otherX, otherZ, thisX, thisZ));
|
||||
dist = (thisBuf + otherBuf) - dist;
|
||||
xDiff = dist * sin_rad(angle);
|
||||
zDiff = -dist * cos_rad(angle);
|
||||
thisX += xDiff * 0.1f;
|
||||
thisZ += zDiff * 0.1f;
|
||||
}
|
||||
npc->flags |= NPC_FLAG_COLLIDING_WITH_NPC;
|
||||
}
|
||||
@ -446,11 +442,103 @@ void npc_do_other_npc_collision(Npc* npc) {
|
||||
npc->pos.z = thisZ;
|
||||
}
|
||||
}
|
||||
#else
|
||||
INCLUDE_ASM(void, "npc", npc_do_other_npc_collision, Npc* npc);
|
||||
#endif
|
||||
|
||||
// float regalloc
|
||||
#ifdef NON_MATCHING
|
||||
s32 npc_do_player_collision(Npc* npc) {
|
||||
PlayerStatus* playerStatus = &gPlayerStatus;
|
||||
f32 xDiff, zDiff;
|
||||
f32 npcColliderX, npcColliderZ;
|
||||
f32 playerX, playerZ;
|
||||
f32 tempX, tempZ;
|
||||
|
||||
f32 temp_f0;
|
||||
f32 temp_f22_2;
|
||||
f32 temp_f24;
|
||||
f32 temp_f24_2;
|
||||
f32 temp_f28;
|
||||
|
||||
if (npc->flags & NPC_FLAG_IGNORE_PLAYER_COLLISION) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (npc->flags & PS_FLAG_CAMERA_DOESNT_FOLLOW) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gNpcPlayerCollisionsEnabled) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (playerStatus->position.y + playerStatus->colliderHeight < npc->pos.y) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (npc->pos.y + npc->collisionHeight < playerStatus->position.y) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
playerX = playerStatus->position.x;
|
||||
playerZ = playerStatus->position.z;
|
||||
tempX = npc->pos.x;
|
||||
tempZ = npc->pos.z;
|
||||
|
||||
xDiff = playerX - tempX;
|
||||
zDiff = playerZ - tempZ;
|
||||
|
||||
temp_f22_2 = (npc->collisionRadius / 2) + (f32)(playerStatus->colliderDiameter / 2);
|
||||
if (temp_f22_2 < sqrtf(SQ(xDiff) + SQ(zDiff))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
playerStatus->animFlags |= 0x8000;
|
||||
//playerX = playerStatus->position.x;
|
||||
npcColliderX = npc->colliderPos.x;
|
||||
npcColliderZ = npc->colliderPos.z;
|
||||
tempX = playerX - npcColliderX;
|
||||
tempZ = playerZ - npcColliderZ;
|
||||
|
||||
//temp_f24 = sqrtf(SQ(tempX) + SQ(tempZ));
|
||||
xDiff = tempZ;
|
||||
temp_f24 = sqrtf((tempX * tempX) + (xDiff * xDiff));
|
||||
|
||||
temp_f0 = atan2(playerX, playerZ, npcColliderX, npcColliderZ);
|
||||
temp_f28 = playerStatus->targetYaw;
|
||||
temp_f24_2 = temp_f22_2 - temp_f24;
|
||||
temp_f24 = temp_f24_2 * sin_rad(DEG_TO_RAD(temp_f0));
|
||||
playerZ = -temp_f24_2 * cos_rad(DEG_TO_RAD(temp_f0));
|
||||
if (playerStatus->animFlags & PA_FLAG_RIDING_PARTNER) {
|
||||
if (fabsf(get_clamped_angle_diff(temp_f0, temp_f28)) < 45.0f) {
|
||||
playerStatus->position.x -= temp_f24;
|
||||
playerStatus->position.z -= playerZ;
|
||||
wPartnerNpc->pos.x -= temp_f24;
|
||||
wPartnerNpc->pos.z -= playerZ;
|
||||
} else {
|
||||
playerStatus->position.x -= temp_f24 * 0.5f;
|
||||
playerStatus->position.z -= playerZ * 0.5f;
|
||||
wPartnerNpc->pos.x -= temp_f24 * 0.5f;
|
||||
wPartnerNpc->pos.z -= playerZ * 0.5f;
|
||||
}
|
||||
} else {
|
||||
if (playerStatus->flags & (PS_FLAG_JUMPING | PS_FLAG_FALLING)) {
|
||||
playerStatus->position.x -= temp_f24 * 0.4f;
|
||||
playerStatus->position.z -= playerZ * 0.4f;
|
||||
} else if (fabsf(get_clamped_angle_diff(temp_f0, temp_f28)) < 45.0f) {
|
||||
playerStatus->position.x -= temp_f24;
|
||||
playerStatus->position.z -= playerZ;
|
||||
} else {
|
||||
playerStatus->position.x -= temp_f24 * 0.5f;
|
||||
playerStatus->position.z -= playerZ * 0.5f;
|
||||
}
|
||||
}
|
||||
npc->pos.x = npc->colliderPos.x;
|
||||
npc->pos.y = npc->colliderPos.y;
|
||||
npc->pos.z = npc->colliderPos.z;
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
INCLUDE_ASM(s32, "npc", npc_do_player_collision, Npc* npc);
|
||||
#endif
|
||||
|
||||
void npc_do_gravity(Npc* npc) {
|
||||
if (npc->flags & NPC_FLAG_GRAVITY) {
|
||||
@ -857,7 +945,7 @@ void render_npcs(void) {
|
||||
|
||||
for (i = 0; i < MAX_NPCS; i++) {
|
||||
Npc* npc = (*gCurrentNpcListPtr)[i];
|
||||
if ((npc != NULL)
|
||||
if ((npc != NULL)
|
||||
&& (npc->flags != 0)
|
||||
&& !(npc->flags & (NPC_FLAG_SUSPENDED | NPC_FLAG_HAS_NO_SPRITE | NPC_FLAG_INACTIVE | NPC_FLAG_INVISIBLE))
|
||||
) {
|
||||
@ -1105,11 +1193,11 @@ void appendGfx_npc_blur(void* data) {
|
||||
}
|
||||
|
||||
void npc_enable_collisions(void) {
|
||||
D_800A0B94 = 1;
|
||||
gNpcPlayerCollisionsEnabled = TRUE;
|
||||
}
|
||||
|
||||
void npc_disable_collisions(void) {
|
||||
D_800A0B94 = 0;
|
||||
gNpcPlayerCollisionsEnabled = FALSE;
|
||||
}
|
||||
|
||||
void func_8003B1A8(void) {
|
||||
|
@ -1770,11 +1770,14 @@ API_CALLABLE(N(ForceStarRodAlwaysFaceCamera)) {
|
||||
return ApiStatus_BLOCK;
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
API_CALLABLE(func_80244550_A2E790) {
|
||||
Npc* kammy = resolve_npc(script, NPC_Kammy);
|
||||
EffectInstance* effect = evt_get_variable(script, ArrayVar(0));
|
||||
EffectInstance* effect = (EffectInstance*) evt_get_variable(script, ArrayVar(0));
|
||||
Npc* npc2;
|
||||
f32 x, y, z;
|
||||
f32* x2;
|
||||
f32* y2;
|
||||
f32* z2;
|
||||
s32 i;
|
||||
|
||||
if (isInitialCall) {
|
||||
@ -1783,40 +1786,42 @@ API_CALLABLE(func_80244550_A2E790) {
|
||||
N(D_8024F304) = kammy->pos.z;
|
||||
|
||||
for (i = NPC_Eldstar; i < ARRAY_COUNT(N(StarSpiritsPosX)); i++) {
|
||||
Npc* npc2 = resolve_npc(script, i);
|
||||
npc2 = resolve_npc(script, i);
|
||||
|
||||
N(StarSpiritsPosX)[i] = npc2->pos.x;
|
||||
N(StarSpiritsPosY)[i] = npc2->pos.y;
|
||||
N(StarSpiritsPosZ)[i] = npc2->pos.z;
|
||||
}
|
||||
N(D_8024F308) = effect->data.somethingRotating->unk_04;
|
||||
N(D_8024F30C) = effect->data.somethingRotating->unk_08;
|
||||
N(D_8024F310) = effect->data.somethingRotating->unk_0C;
|
||||
N(D_8024F308) = effect->data.somethingRotating->pos.x;
|
||||
N(D_8024F30C) = effect->data.somethingRotating->pos.y;
|
||||
N(D_8024F310) = effect->data.somethingRotating->pos.z;
|
||||
}
|
||||
|
||||
x = kammy->pos.x - N(D_8024F2FC);
|
||||
y = kammy->pos.y - N(D_8024F300);
|
||||
z = kammy->pos.z - N(D_8024F304);
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(N(StarSpiritsPosX)); i++) {
|
||||
Npc* npc2 = resolve_npc(script, i);
|
||||
i = 0;
|
||||
z2 = N(StarSpiritsPosZ);
|
||||
y2 = N(StarSpiritsPosY);
|
||||
x2 = N(StarSpiritsPosX);
|
||||
for (; i < ARRAY_COUNT(N(StarSpiritsPosX)); ) {
|
||||
npc2 = resolve_npc(script, i);
|
||||
i++;
|
||||
npc2->pos.x = *x2++ + x;
|
||||
npc2->pos.y = *y2++ + y;
|
||||
npc2->pos.z = *z2++ + z;
|
||||
|
||||
npc2->pos.x = N(StarSpiritsPosX)[i] + x;
|
||||
npc2->pos.y = N(StarSpiritsPosY)[i] + y;
|
||||
npc2->pos.z = N(StarSpiritsPosZ)[i] + z;
|
||||
npc2->colliderPos.x = npc2->pos.x;
|
||||
npc2->colliderPos.y = npc2->pos.y;
|
||||
npc2->colliderPos.z = npc2->pos.z;
|
||||
}
|
||||
effect->data.somethingRotating->unk_04 = N(D_8024F308) + x;
|
||||
effect->data.somethingRotating->unk_08 = N(D_8024F30C) + y;
|
||||
effect->data.somethingRotating->unk_0C = N(D_8024F310) + z;
|
||||
|
||||
effect->data.somethingRotating->pos.x = N(D_8024F308) + x;
|
||||
effect->data.somethingRotating->pos.y = N(D_8024F30C) + y;
|
||||
effect->data.somethingRotating->pos.z = N(D_8024F310) + z;
|
||||
return ApiStatus_BLOCK;
|
||||
}
|
||||
#else
|
||||
API_CALLABLE(func_80244550_A2E790);
|
||||
INCLUDE_ASM(s32, "world/area_hos/hos_05/A2AAC0", func_80244550_A2E790);
|
||||
#endif
|
||||
|
||||
extern EvtScript N(EVS_Scene_IntroStory);
|
||||
|
||||
|
@ -174,7 +174,7 @@ API_CALLABLE(func_80282E30) {
|
||||
zThing /= BLOCK_GRID_SIZE;
|
||||
|
||||
varX = xThing;
|
||||
varZ = zThing;
|
||||
varZ = entityZ = zThing;
|
||||
|
||||
xThing *= BLOCK_GRID_SIZE;
|
||||
yThing *= BLOCK_GRID_SIZE;
|
||||
@ -188,15 +188,14 @@ API_CALLABLE(func_80282E30) {
|
||||
script->varTable[4] = yThing = entity->position.y;
|
||||
script->varTable[5] = entityZ = entity->position.z;
|
||||
|
||||
xThing = (xThing - grid->centerPos.x);
|
||||
xThing = xThing - grid->centerPos.x;
|
||||
entityZ = entityZ - grid->centerPos.z;
|
||||
xThing /= BLOCK_GRID_SIZE;
|
||||
var_a1 = xThing - varX;
|
||||
entityZ = (entityZ - grid->centerPos.z);
|
||||
entityZ /= BLOCK_GRID_SIZE;
|
||||
var_a0_2 = entityZ - varZ;
|
||||
if (var_a1 != 0 && var_a0_2 != 0) {
|
||||
var_a0_2 = 0;
|
||||
var_a1 = 0;
|
||||
var_a0_2 = var_a1 = 0;
|
||||
}
|
||||
script->varTable[6] = var_a1;
|
||||
script->varTable[7] = 0;
|
||||
@ -250,14 +249,14 @@ API_CALLABLE(CanPlayerPushBlock) {
|
||||
if ((gCollisionStatus.pushingAgainstWall == blockCollider)
|
||||
&& (playerStatus->actionState == ACTION_STATE_PUSHING_BLOCK
|
||||
|| playerStatus->actionState == ACTION_STATE_WALK
|
||||
|| playerStatus->actionState == ACTION_STATE_RUN)
|
||||
|| playerStatus->actionState == ACTION_STATE_RUN)
|
||||
&& !(playerStatus->animFlags & PA_FLAG_USING_WATT))
|
||||
{
|
||||
script->varTable[13] = TRUE;
|
||||
} else {
|
||||
script->varTable[13] = FALSE;
|
||||
}
|
||||
|
||||
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,9 @@ def write_ninja_rules(ninja: ninja_syntax.Writer, cpp: str, extra_cppflags: str,
|
||||
"-DVERSION=$version -DF3DEX_GBI_2 -D_MIPS_SZLONG=32 -nostdinc"
|
||||
|
||||
cflags = f"-c -G0 -O2 -gdwarf-2 -x c -B {BUILD_TOOLS}/cc/gcc/ {extra_cflags}"
|
||||
|
||||
cflags_modern = f"-c -G0 -O2 -gdwarf-2 -fno-builtin-bcopy -fno-tree-loop-distribute-patterns -funsigned-char -mgp32 -mfp32 -mabi=32 -mfix4300 -march=vr4300 -mno-gpopt -fno-toplevel-reorder -mno-abicalls -fno-pic -fno-exceptions -fno-stack-protector -fno-zero-initialized-in-bss -Wno-builtin-declaration-mismatch -x c {extra_cflags}"
|
||||
|
||||
cflags_272 = f"-c -G0 -mgp32 -mfp32 -mips3 {extra_cflags}"
|
||||
cflags_272 = cflags_272.replace("-ggdb3","-g1")
|
||||
|
||||
|
@ -436,7 +436,7 @@ dlabel gBattleNpcList
|
||||
dlabel gCurrentNpcListPtr
|
||||
.space 4
|
||||
|
||||
dlabel D_800A0B94
|
||||
dlabel gNpcPlayerCollisionsEnabled
|
||||
.space 4
|
||||
|
||||
dlabel D_800A0B98
|
||||
|
@ -1,192 +0,0 @@
|
||||
.set noat /* allow manual use of $at */
|
||||
.set noreorder /* don't insert nops after branches */
|
||||
|
||||
/* Generated by spimdisasm 1.11.1 */
|
||||
|
||||
glabel npc_do_other_npc_collision
|
||||
/* 13ABC 800386BC 27BDFFA0 */ addiu $sp, $sp, -0x60
|
||||
/* 13AC0 800386C0 AFB1001C */ sw $s1, 0x1C($sp)
|
||||
/* 13AC4 800386C4 0080882D */ daddu $s1, $a0, $zero
|
||||
/* 13AC8 800386C8 AFBF0028 */ sw $ra, 0x28($sp)
|
||||
/* 13ACC 800386CC AFB30024 */ sw $s3, 0x24($sp)
|
||||
/* 13AD0 800386D0 AFB20020 */ sw $s2, 0x20($sp)
|
||||
/* 13AD4 800386D4 AFB00018 */ sw $s0, 0x18($sp)
|
||||
/* 13AD8 800386D8 F7BE0058 */ sdc1 $f30, 0x58($sp)
|
||||
/* 13ADC 800386DC F7BC0050 */ sdc1 $f28, 0x50($sp)
|
||||
/* 13AE0 800386E0 F7BA0048 */ sdc1 $f26, 0x48($sp)
|
||||
/* 13AE4 800386E4 F7B80040 */ sdc1 $f24, 0x40($sp)
|
||||
/* 13AE8 800386E8 F7B60038 */ sdc1 $f22, 0x38($sp)
|
||||
/* 13AEC 800386EC F7B40030 */ sdc1 $f20, 0x30($sp)
|
||||
/* 13AF0 800386F0 8E230000 */ lw $v1, 0x0($s1)
|
||||
/* 13AF4 800386F4 30620100 */ andi $v0, $v1, 0x100
|
||||
/* 13AF8 800386F8 14400096 */ bnez $v0, .LIQUE_80038954
|
||||
/* 13AFC 800386FC 3C02FDFF */ lui $v0, (0xFDFFFFFF >> 16)
|
||||
/* 13B00 80038700 3442FFFF */ ori $v0, $v0, (0xFDFFFFFF & 0xFFFF)
|
||||
/* 13B04 80038704 0000902D */ daddu $s2, $zero, $zero
|
||||
/* 13B08 80038708 3C130400 */ lui $s3, (0x4000000 >> 16)
|
||||
/* 13B0C 8003870C C63E0038 */ lwc1 $f30, 0x38($s1)
|
||||
/* 13B10 80038710 C626003C */ lwc1 $f6, 0x3C($s1)
|
||||
/* 13B14 80038714 3C013F00 */ lui $at, (0x3F000000 >> 16)
|
||||
/* 13B18 80038718 44811000 */ mtc1 $at, $f2
|
||||
/* 13B1C 8003871C 00621024 */ and $v0, $v1, $v0
|
||||
/* 13B20 80038720 E7A60010 */ swc1 $f6, 0x10($sp)
|
||||
/* 13B24 80038724 AE220000 */ sw $v0, 0x0($s1)
|
||||
/* 13B28 80038728 862200A6 */ lh $v0, 0xA6($s1)
|
||||
/* 13B2C 8003872C C63C0040 */ lwc1 $f28, 0x40($s1)
|
||||
/* 13B30 80038730 44820000 */ mtc1 $v0, $f0
|
||||