diff --git a/include/d/d_kankyo_wether.h b/include/d/d_kankyo_wether.h index 529a76145..d39e0a2ef 100644 --- a/include/d/d_kankyo_wether.h +++ b/include/d/d_kankyo_wether.h @@ -3,6 +3,8 @@ #include "JSystem/J3DGraphBase/J3DPacket.h" #include "SSystem/SComponent/c_xyz.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo.h" class JUTTexture; class JPABaseEmitter; @@ -120,6 +122,7 @@ public: /* 0x36D4 */ f32 field_0x36d4; /* 0x36D8 */ s16 mEffCount; /* 0x36DA */ s16 mTamariStart; + /* 0x36DC */ void *field_0x36dc; }; struct STAR_EFF { @@ -140,7 +143,7 @@ public: virtual void draw(); virtual ~dKankyo_star_Packet(); - /* 0x10 */ u8* field_0x10; + /* 0x10 */ u8* mpTexture; /* 0x14 */ STAR_EFF mStarEff[1]; /* 0x48 */ s16 mCount; }; @@ -149,7 +152,8 @@ struct POISON_EFF { POISON_EFF(); ~POISON_EFF(); - /* 0x0 */ u8 field_0x0[0x30]; + /* 0x00 */ u8 mStatus; + /* 0x01 */ u8 field_0x1[0x2F]; }; class dKankyo_poison_Packet : public J3DPacket { @@ -159,11 +163,11 @@ public: virtual void draw(); virtual ~dKankyo_poison_Packet(); - /* 0x0010 */ POISON_EFF mPoisonEff[1000]; + /* 0x0010 */ POISON_EFF mEff[1000]; /* 0xBB90 */ u8 field_0xbb90[0xBB9C - 0xBB90]; /* 0xBB9C */ cXyz field_0xbb9c; - /* 0xBBA8 */ u8 field_0xbba8[0xBBAC - 0xBBA8]; - /* 0xBBAC */ u8* field_0xbbac; + /* 0xBBA8 */ u32 mCount; + /* 0xBBAC */ u8* mpTexture; }; struct CLOUD_EFF { diff --git a/include/dolphin/gx/GX.h b/include/dolphin/gx/GX.h index cc692a1a3..6deccd578 100644 --- a/include/dolphin/gx/GX.h +++ b/include/dolphin/gx/GX.h @@ -127,18 +127,18 @@ inline void GXTexCoord2s16(const s16 u, const s16 v) { } inline void GFWriteBPCmd(u32 param_1) { - GXFIFO.u8 = 0x61; - GXFIFO.u32 = param_1; + GXFIFO.u8 = 0x61; + GXFIFO.u32 = param_1; } inline void GFFill(u16 param_1, u32 param_2) { - GXFIFO.u8 = 0x10; - GXFIFO.u16 = 0; - GXFIFO.u16 = param_1; - GXFIFO.u32 = param_2; + GXFIFO.u8 = 0x10; + GXFIFO.u16 = 0; + GXFIFO.u16 = param_1; + GXFIFO.u32 = param_2; } -inline void i_GXEnd() {} +inline void GXEnd() {} #ifdef __cplusplus }; diff --git a/src/JSystem/J2DGraph/J2DGrafContext.cpp b/src/JSystem/J2DGraph/J2DGrafContext.cpp index 129b1f50c..eb16557b9 100644 --- a/src/JSystem/J2DGraph/J2DGrafContext.cpp +++ b/src/JSystem/J2DGraph/J2DGrafContext.cpp @@ -150,7 +150,7 @@ void J2DGrafContext::fillBox(const JGeometry::TBox2& box) { GXColor1u32(mColorBL); GXPosition3f32(box.i.x, box.f.y, 0); GXColor1u32(mColorBR); - i_GXEnd(); + GXEnd(); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0); } @@ -171,7 +171,7 @@ void J2DGrafContext::drawFrame(const JGeometry::TBox2& box) { GXColor1u32(mColorBR); GXPosition3f32(box.i.x, box.i.y, 0); GXColor1u32(mColorTL); - i_GXEnd(); + GXEnd(); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0); } @@ -187,7 +187,7 @@ void J2DGrafContext::line(JGeometry::TVec2 start, JGeometry::TVec2 end GXColor1u32(mColorTL); GXPosition3f32(end.x, end.y, 0); GXColor1u32(mColorBR); - i_GXEnd(); + GXEnd(); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0); } diff --git a/src/d/actor/d_a_agbsw0.cpp b/src/d/actor/d_a_agbsw0.cpp index 38a683c6f..02e1fcafa 100644 --- a/src/d/actor/d_a_agbsw0.cpp +++ b/src/d/actor/d_a_agbsw0.cpp @@ -328,8 +328,8 @@ public: field_0x299 = 0; mTimer = 0; - l_cyl_src.mCyl.mRadius = mScale.x; - l_cyl_src.mCyl.mHeight = mScale.y; + l_cyl_src.mCylAttr.mCyl.mRadius = mScale.x; + l_cyl_src.mCylAttr.mCyl.mHeight = mScale.y; mStts.Init(0, 0xFF, this); mCyl.Set(l_cyl_src); mCyl.SetC(current.pos); @@ -1069,8 +1069,13 @@ BOOL daAgbsw0_c::ExeSubMW() { return true; } +class daBomb_c { +public: + enum State_e { EIGHT = 8, }; + bool chk_state(State_e) const; +}; + BOOL daAgbsw0_c::ExeSubT() { - /* Nonmatching */ u8 sw = getSw0(); if(sw != 0xFF && fopAcM_isSwitch(this, sw)) { @@ -1095,10 +1100,7 @@ BOOL daAgbsw0_c::ExeSubT() { else { if(g_mDoGaC_gbaCom.mDoGaC_GbaLink()) { if(g_mDoGaC_gbaCom.mDoGaC_SendStatusCheck(0xF)) { - //daBomb_c* bomb = mCyl.GetTgHitAc(); - //if(bomb->chk_state(8)) - // ^ replace field_0x298 with this later - if(mCyl.ChkTgHit() && mCyl.GetTgHitAc() && fopAcM_GetName(mCyl.GetTgHitAc()) == 0x128 && field_0x298) { //0x298 filler condition so objdiff is less confused + if(mCyl.ChkTgHit() && mCyl.GetTgHitAc() && fopAcM_GetName(mCyl.GetTgHitAc()) == PROC_BOMB && ((daBomb_c*)mCyl.GetTgHitAc())->chk_state(daBomb_c::EIGHT)) { mSE = BigLittleChange(0x12); g_mDoGaC_gbaCom.mDoGaC_SendDataSet((u32*)&mSE, 4, 0xF, 0); fopAcM_onSwitch(this, sw); @@ -1146,8 +1148,7 @@ BOOL daAgbsw0_c::ExeSubS() { return true; } else { - if(g_mDoGaC_gbaCom.mDoGaC_SendStatusCheck(5)) - { + if(g_mDoGaC_gbaCom.mDoGaC_SendStatusCheck(5)) { MailSend(BigLittleChange(getMsgNo()) >> 0x10, 0x9, sw1, sw, 0); field_0x299 = 1; } @@ -1165,8 +1166,7 @@ BOOL daAgbsw0_c::ExeSubS() { return true; } else { - if(g_mDoGaC_gbaCom.mDoGaC_SendStatusCheck(5)) - { + if(g_mDoGaC_gbaCom.mDoGaC_SendStatusCheck(5)) { u32 param = fopAcM_GetParam(this); MailSend(BigLittleChange(param & 0xFFFF) >> 0x10, 0x9, sw1, sw, 0); field_0x299 = 1; @@ -1328,7 +1328,7 @@ BOOL daAgbsw0_c::ExeSubB() { fpoAcM_relativePos(this, &agb->current.pos, &rel); rel.y = rel.y - mScale.y / 2.0f + 5.0f; f32 x_diff = mScale.x - fabsf(rel.x); - f32 y_diff = mScale.y - fabsf(rel.y) + 50.0f; //some register oddity here + f32 y_diff = (mScale.y / 2.0f) - fabsf(rel.y) + 50.0f; //some register oddity here f32 z_diff = mScale.z - fabsf(rel.z); if(y_diff < x_diff && y_diff < z_diff) { if(agb->current.pos.y < current.pos.y + mScale.y / 2.0f) { diff --git a/src/d/d_kankyo_rain.cpp b/src/d/d_kankyo_rain.cpp index b0668b507..7ebc4ac71 100644 --- a/src/d/d_kankyo_rain.cpp +++ b/src/d/d_kankyo_rain.cpp @@ -10,6 +10,9 @@ #include "d/d_kankyo_wether.h" #include "f_op/f_op_camera_mng.h" #include "m_Do/m_Do_lib.h" +#include "JSystem/JKernel/JKRHeap.h" + +static u32 now_room; /* 8008AA30-8008AB3C .text vectle_calc__FP10DOUBLE_POSP4cXyz */ void vectle_calc(DOUBLE_POS* i_pos, cXyz* o_out) { @@ -165,7 +168,10 @@ void dKyr_lenzflare_move() { /* 8008C888-8008C8B8 .text dKyr_moon_arrival_check__Fv */ BOOL dKyr_moon_arrival_check() { - /* Nonmatching */ + BOOL ret = false; + if (g_env_light.mCurTime > 277.5f || g_env_light.mCurTime < 112.5f) + ret = true; + return ret; } /* 8008C8B8-8008CF68 .text dKyr_sun_move__Fv */ @@ -175,7 +181,24 @@ void dKyr_sun_move() { /* 8008CF68-8008D0B4 .text dKyr_rain_init__Fv */ void dKyr_rain_init() { - /* Nonmatching */ + camera_class * pCamera = dComIfGp_getCamera(0); + g_env_light.mpRainPacket->mpTxSnow01 = (u8*)dComIfG_getObjectRes("Always", 0x81); + g_env_light.mpRainPacket->mpTxRingAHalf = (u8*)dComIfG_getObjectRes("Always", 0x85); + g_env_light.mpRainPacket->mCamEyePos = pCamera->mLookat.mEye; + g_env_light.mpRainPacket->mCamCenterPos = pCamera->mLookat.mCenter; + g_env_light.mpRainPacket->mCenterDeltaMul = 0.0f; + g_env_light.mpRainPacket->field_0x3700 = 0.0f; + g_env_light.mpRainPacket->mSibukiAlpha = 0.0f; + g_env_light.mpRainPacket->mOverheadFade = 0.0f; + g_env_light.mpRainPacket->mFwd1Fade = 0.0f; + g_env_light.mpRainPacket->mFwdFade2 = 0.0f; + g_env_light.mpRainPacket->mStatus = 0; + g_env_light.mpRainPacket->mCenterDelta.x = 0.0f; + g_env_light.mpRainPacket->mCenterDelta.y = 0.0f; + g_env_light.mpRainPacket->mCenterDelta.z = 0.0f; + for (u32 i = 0; i < ARRAY_SIZE(g_env_light.mpRainPacket->mRainEff); i++) + g_env_light.mpRainPacket->mRainEff[i].mStatus = 0; + g_env_light.mpRainPacket->mRainCount = 0; } /* 8008D0B4-8008D0DC .text rain_bg_chk__FP19dKankyo_rain_Packeti */ @@ -205,7 +228,19 @@ void dKyr_housi_move() { /* 8008F0BC-8008F23C .text dKyr_snow_init__Fv */ void dKyr_snow_init() { - /* Nonmatching */ + camera_class * pCamera = dComIfGp_getCamera(0); + g_env_light.mpSnowPacket = new(0x20) dKankyo_snow_Packet(); + if (g_env_light.mpSnowPacket != NULL) { + if (strcmp(dComIfGp_getStartStageName(), "Adanmae") != 0) { + g_env_light.mpSnowPacket->mpTexture = (u8*)dComIfG_getObjectRes("Always", 0x81); + } else { + g_env_light.mpSnowPacket->mpTexture = (u8*)dComIfG_getStageRes("Stage", "ak_kazanbai00.bti"); + } + } + for (u32 i = 0; i < ARRAY_SIZE(g_env_light.mpSnowPacket->mEff); i++) + g_env_light.mpSnowPacket->mEff[i].mStatus = 0; + g_env_light.mpSnowPacket->mEffCount = 0; + g_env_light.mpSnowPacket->mOldEyePos = pCamera->mLookat.mEye; } /* 8008F23C-8008F9FC .text dKyr_snow_move__Fv */ @@ -225,12 +260,24 @@ void dKyr_kazanbai_tamari_move() { /* 80090C68-80090D50 .text dKyr_star_init__Fv */ void dKyr_star_init() { - /* Nonmatching */ + g_env_light.mpStarPacket = new(0x20) dKankyo_star_Packet(); + if (g_env_light.mpStarPacket != NULL) { + g_env_light.mpStarPacket->field_0x10 = (u8*)dComIfG_getObjectRes("Always", 0x81); + g_env_light.mpStarPacket->mStarEff[0].mSin = 1.0f; + g_env_light.mpStarPacket->mCount = 0; + } } /* 80090D50-80090DE0 .text dKyr_star_move__Fv */ void dKyr_star_move() { - /* Nonmatching */ + dKankyo_star_Packet * pPkt = g_env_light.mpStarPacket; + pPkt->mCount = g_env_light.mStarCount; + if (pPkt->mCount != 0) { + f32 wave = fabsf(cM_fsin(pPkt->mStarEff[0].mAnimCounter)); + pPkt->mStarEff[0].mAnimCounter += 0.01f; + pPkt->mStarEff[0].mSin = wave; + cLib_addCalc(&pPkt->mStarEff[0].mSin, wave, 0.5f, 0.1f, 0.01f); + } } /* 80090DE0-80091964 .text wave_move__Fv */ @@ -260,7 +307,18 @@ void dKyr_poison_light_colision() { /* 80092448-8009258C .text poison_init__Fv */ void poison_init() { - /* Nonmatching */ + g_env_light.mpPoisonPacket = new(0x20) dKankyo_poison_Packet(); + g_env_light.mpPoisonPacket->field_0xbb9c.x = 0.0f; + g_env_light.mpPoisonPacket->field_0xbb9c.y = 0.0f; + g_env_light.mpPoisonPacket->field_0xbb9c.z = 0.0f; + g_env_light.mpPoisonPacket->mCount = 0; + if (g_env_light.mpPoisonPacket != NULL) { + g_env_light.mpPoisonPacket->mpTex = (u8*)dComIfG_getObjectRes("Always", 0x6e); + for (u32 i = 0; i < ARRAY_SIZE(g_env_light.mpPoisonPacket->mEff); i++) + g_env_light.mpPoisonPacket->mEff[i].mStatus = 0; + poison_move(); + now_room = dComIfGp_roomControl_getStayNo(); + } } /* 8009258C-800937BC .text poison_move__Fv */ @@ -312,6 +370,7 @@ void dKyr_drawRain(Mtx, u8**) { /* 8009682C-80096D18 .text dKyr_drawSibuki__FPA4_fPPUc */ void dKyr_drawSibuki(Mtx drawMtx, u8** pImg) { + /* Nonmatching */ dKankyo_rain_Packet * pPkt = g_env_light.mpRainPacket; camera_class *pCamera = dComIfGp_getCamera(0); @@ -403,7 +462,7 @@ void dKyr_drawSibuki(Mtx drawMtx, u8** pImg) { GXTexCoord2s16(0x1FF, 0x1FF); GXPosition3f32(p3.x, p3.y, p3.z); GXTexCoord2s16(0, 0x1FF); - i_GXEnd(); + GXEnd(); } GXSetClipMode(GX_CLIP_ENABLE); diff --git a/src/d/d_kankyo_wether.cpp b/src/d/d_kankyo_wether.cpp index a46fd2c51..9a6c86d22 100644 --- a/src/d/d_kankyo_wether.cpp +++ b/src/d/d_kankyo_wether.cpp @@ -96,7 +96,7 @@ STAR_EFF::STAR_EFF() {} /* 800872D8-80087308 .text draw__19dKankyo_star_PacketFv */ void dKankyo_star_Packet::draw() { - dKyr_drawStar(j3dSys.getViewMtx(), &field_0x10); + dKyr_drawStar(j3dSys.getViewMtx(), &mpTexture); } /* 80087308-80087344 .text __dt__10POISON_EFFFv */ @@ -107,7 +107,7 @@ POISON_EFF::POISON_EFF() {} /* 80087348-8008737C .text draw__21dKankyo_poison_PacketFv */ void dKankyo_poison_Packet::draw() { - drawPoison(j3dSys.getViewMtx(), &field_0xbbac); + drawPoison(j3dSys.getViewMtx(), &mpTexture); } /* 8008737C-800873B8 .text __dt__9CLOUD_EFFFv */