Merge pull request #902 from LagoLunatic/misc

Misc fixes
This commit is contained in:
LagoLunatic
2025-11-24 20:25:34 -05:00
committed by GitHub
19 changed files with 107 additions and 72 deletions
+1 -1
View File
@@ -386,7 +386,7 @@ config.libs = [
Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "m_Do/m_Do_machine.cpp"),
Object(Matching, "m_Do/m_Do_mtx.cpp"),
Object(NonMatching, "m_Do/m_Do_ext.cpp"),
Object(NonMatching, "m_Do/m_Do_lib.cpp"),
Object(Matching, "m_Do/m_Do_lib.cpp"),
Object(Matching, "m_Do/m_Do_hostIO.cpp"),
Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "m_Do/m_Do_Reset.cpp"),
Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "m_Do/m_Do_dvd_thread.cpp"),
-8
View File
@@ -4029,14 +4029,6 @@ inline dCcS* dComIfG_Ccsp() {
return &g_dComIfG_gameInfo.play.mCcS;
}
// This should be dComIfG_Ccsp()->SetMass everywhere, but for some reason that combination of two
// inlines consistently breaks the match on retail. But for the demo, using the proper inlines is required to match.
#if VERSION == VERSION_DEMO
#define dComIfG_Ccsp_SetMass dComIfG_Ccsp()->SetMass
#else
#define dComIfG_Ccsp_SetMass dComIfG_Ccsp()->mMass_Mng.Set
#endif
inline void dComIfG_setTimerMode(int ms) { g_dComIfG_gameInfo.play.setTimerMode(ms); }
inline int dComIfG_getTimerMode() { return g_dComIfG_gameInfo.play.getTimerMode(); }
+6 -7
View File
@@ -20,15 +20,14 @@ typedef enum _GXCullMode {
/* 0x3 */ GX_CULL_ALL,
} GXCullMode;
typedef enum _GXBoolVal {
/* 0x0 */ GX_FALSE,
/* 0x1 */ GX_TRUE,
/* 0x0 */ GX_DISABLE = 0,
/* 0x1 */ GX_ENABLE,
} GXBoolVal;
typedef u8 GXBool;
#define GX_FALSE ((GXBool)0)
#define GX_TRUE ((GXBool)1)
#define GX_ENABLE ((GXBool)1)
#define GX_DISABLE ((GXBool)0)
typedef enum _GXTexMapID {
/* 0x000 */ GX_TEXMAP0,
/* 0x001 */ GX_TEXMAP1,
+1 -1
View File
@@ -42,7 +42,7 @@ struct mDoLib_clipper {
};
void mDoLib_project(Vec* src, Vec* dst);
u8 mDoLib_setResTimgObj(ResTIMG* res, GXTexObj* o_texObj, u32 tlut_name, GXTlutObj* o_tlutObj);
u32 mDoLib_setResTimgObj(ResTIMG* res, GXTexObj* o_texObj, u32 tlut_name, GXTlutObj* o_tlutObj);
void mDoLib_pos2camera(Vec* src, Vec* dst);
u32 mDoLib_cnvind32(u32 r3);
u16 mDoLib_cnvind16(u16 r3);
+2 -2
View File
@@ -298,7 +298,7 @@ void daArrow_c::arrowShooting() {
mAtCps.CalcAtVec();
dComIfG_Ccsp()->Set(&mAtCps);
dComIfG_Ccsp_SetMass(&mAtCps, 1);
dComIfG_Ccsp()->SetMass(&mAtCps, 1);
clrAtHitNormal();
setAtHitPosBuff(&end);
@@ -872,7 +872,7 @@ BOOL daArrow_c::procMove() {
mAtCps.CalcAtVec();
dComIfG_Ccsp()->Set(&mAtCps);
dComIfG_Ccsp_SetMass(&mAtCps, 1);
dComIfG_Ccsp()->SetMass(&mAtCps, 1);
}
return TRUE;
+3 -3
View File
@@ -2131,7 +2131,7 @@ static fopAc_ac_c* yari_hit_check(bk_class* i_this) {
i_this->m1040.MoveCAt(i_this->m11A8);
dComIfG_Ccsp()->Set(&i_this->m1040);
if (i_this->m02D5 != 0) {
dComIfG_Ccsp_SetMass(&i_this->m1040, 3);
dComIfG_Ccsp()->SetMass(&i_this->m1040, 3);
}
if (i_this->m1040.ChkAtHit()) {
i_this->m0B78 = 5;
@@ -3329,7 +3329,7 @@ static void Bk_move(bk_class* i_this) {
i_this->m1040.OffAtVsPlayerBit();
i_this->m1040.SetAtSpl(dCcG_At_Spl_UNK1);
dComIfG_Ccsp()->Set(&i_this->m1040);
dComIfG_Ccsp_SetMass(&i_this->m1040, 3);
dComIfG_Ccsp()->SetMass(&i_this->m1040, 3);
if (i_this->m1040.ChkAtHit() && actor->speed.y < -50.0f) {
actor->speed.y = 0.0f;
@@ -4415,7 +4415,7 @@ static BOOL daBk_Execute(bk_class* i_this) {
MtxPosition(&sp58, &sp4C);
i_this->m0B88.SetC(sp4C);
dComIfG_Ccsp()->Set(&i_this->m0B88);
dComIfG_Ccsp_SetMass(&i_this->m0B88, 3);
dComIfG_Ccsp()->SetMass(&i_this->m0B88, 3);
cXyz sp40 = i_this->m116C;
cXyz sp34 = i_this->current.pos;
+2 -2
View File
@@ -784,9 +784,9 @@ BOOL daBoko_c::execute() {
mSph.SetC(m2D0);
dComIfG_Ccsp()->Set(&mSph);
if (getNowMode() == Mode_PLAYER_CARRY_e) {
dComIfG_Ccsp_SetMass(&mSph, 1);
dComIfG_Ccsp()->SetMass(&mSph, 1);
} else {
dComIfG_Ccsp_SetMass(&mSph, 4);
dComIfG_Ccsp()->SetMass(&mSph, 4);
}
}
+1 -1
View File
@@ -476,7 +476,7 @@ namespace daBomb2 {
mSph.SetR(radius);
mSph.SetC(pos);
dComIfG_Ccsp()->Set(&mSph);
dComIfG_Ccsp_SetMass(&mSph, 3);
dComIfG_Ccsp()->SetMass(&mSph, 3);
}
}
+4 -4
View File
@@ -707,7 +707,7 @@ void daBomb_c::makeWaterEffect() {
mSph.SetC(current.pos);
if(mMassCounter != g_Counter.mCounter0) {
dComIfG_Ccsp()->Set(&mSph);
dComIfG_Ccsp_SetMass(&mSph, 3);
dComIfG_Ccsp()->SetMass(&mSph, 3);
mMassCounter = g_Counter.mCounter0;
field_0x782 = 1;
}
@@ -867,7 +867,7 @@ BOOL daBomb_c::procExplode_init() {
mSph.SetC(current.pos);
if(mMassCounter != g_Counter.mCounter0) {
dComIfG_Ccsp()->Set(&mSph);
dComIfG_Ccsp_SetMass(&mSph, 3);
dComIfG_Ccsp()->SetMass(&mSph, 3);
field_0x782 = 1;
mMassCounter = g_Counter.mCounter0;
}
@@ -933,7 +933,7 @@ bool daBomb_c::procExplode() {
mSph.SetC(current.pos);
if(mMassCounter != g_Counter.mCounter0) {
dComIfG_Ccsp()->Set(&mSph);
dComIfG_Ccsp_SetMass(&mSph, 3);
dComIfG_Ccsp()->SetMass(&mSph, 3);
mMassCounter = g_Counter.mCounter0;
field_0x782 = 1;
}
@@ -1126,7 +1126,7 @@ BOOL daBomb_c::execute() {
mSph.SetR(scale.x * 30.0f);
if(mMassCounter != g_Counter.mCounter0) {
dComIfG_Ccsp()->Set(&mSph);
dComIfG_Ccsp_SetMass(&mSph, 3);
dComIfG_Ccsp()->SetMass(&mSph, 3);
mMassCounter = g_Counter.mCounter0;
}
}
+2 -2
View File
@@ -195,7 +195,7 @@ BOOL daHookshot_c::procWait() {
mSightCps.SetR(5.0f);
mSightCps.CalcAtVec();
dComIfG_Ccsp()->Set(&mSightCps);
dComIfG_Ccsp_SetMass(&mSightCps, 1);
dComIfG_Ccsp()->SetMass(&mSightCps, 1);
m2A3 = false;
mCurrProcFunc = &daHookshot_c::procShot;
@@ -311,7 +311,7 @@ BOOL daHookshot_c::procShot() {
mSightCps.SetR(5.0f);
mSightCps.CalcAtVec();
dComIfG_Ccsp()->Set(&mSightCps);
dComIfG_Ccsp_SetMass(&mSightCps, 1);
dComIfG_Ccsp()->SetMass(&mSightCps, 1);
current.pos = sp8C;
}
+6 -6
View File
@@ -9844,7 +9844,7 @@ void daPy_lk_c::setCollision() {
mCyl.OnTgSetBit();
}
dComIfG_Ccsp()->Set(&mCyl);
dComIfG_Ccsp_SetMass(&mCyl, 1);
dComIfG_Ccsp()->SetMass(&mCyl, 1);
mWindCyl.SetC(spD0);
mWindCyl.SetH(mCyl.GetH());
mWindCyl.SetR(mCyl.GetR());
@@ -10098,12 +10098,12 @@ void daPy_lk_c::setCollision() {
}
}
dComIfG_Ccsp()->Set(&mAtCyl);
dComIfG_Ccsp_SetMass(&mAtCyl, 1);
dComIfG_Ccsp()->SetMass(&mAtCyl, 1);
int i;
dCcD_Cps* pdVar21 = &mAtCps[0];
for (i = 0; i < 3; i++, pdVar21++) {
dComIfG_Ccsp()->Set(pdVar21);
dComIfG_Ccsp_SetMass(pdVar21, 1);
dComIfG_Ccsp()->SetMass(pdVar21, 1);
}
} else {
if (mSwBlur.field_0x014 < 10) {
@@ -10224,7 +10224,7 @@ void daPy_lk_c::setCollision() {
mFanWindCps.SetAtVec(spC4);
mFanWindCps.SetR(in_f31);
dComIfG_Ccsp()->Set(&mFanWindCps);
dComIfG_Ccsp_SetMass(&mFanWindCps, 1);
dComIfG_Ccsp()->SetMass(&mFanWindCps, 1);
} else {
mFanWindCps.ResetAtHit();
}
@@ -10240,7 +10240,7 @@ void daPy_lk_c::setCollision() {
mFanWindSph.SetC(current.pos);
}
dComIfG_Ccsp()->Set(&mFanWindSph);
dComIfG_Ccsp_SetMass(&mFanWindSph, 1);
dComIfG_Ccsp()->SetMass(&mFanWindSph, 1);
m353A--;
} else {
mFanWindSph.ResetAtHit();
@@ -10259,7 +10259,7 @@ void daPy_lk_c::setCollision() {
mFanLightCps.SetAtVec(local_118);
mFanLightCps.OnAtSetBit();
dComIfG_Ccsp()->Set(&mFanLightCps);
dComIfG_Ccsp_SetMass(&mFanLightCps, 1);
dComIfG_Ccsp()->SetMass(&mFanLightCps, 1);
} else {
mFanLightCps.ResetAtHit();
mFanLightCps.OffAtSetBit();
+1 -1
View File
@@ -937,7 +937,7 @@ bool Act_c::_execute() {
mCyl.MoveCAtTg(current.pos);
dComIfG_Ccsp()->Set(&mCyl);
if (m674 == 2 || m674 == 3 || m67B != 0) {
dComIfG_Ccsp_SetMass(&mCyl, 3);
dComIfG_Ccsp()->SetMass(&mCyl, 3);
}
attention_info.position.x = current.pos.x;
attention_info.position.y = current.pos.y + data().m08;
+1 -1
View File
@@ -726,7 +726,7 @@ BOOL Act_c::Execute(Mtx** outMtx) {
mCyl.MoveCAtTg(current.pos);
dComIfG_Ccsp()->Set(&mCyl);
if (m648 == 2) {
dComIfG_Ccsp_SetMass(&mCyl, 3);
dComIfG_Ccsp()->SetMass(&mCyl, 3);
}
}
+1 -1
View File
@@ -3554,7 +3554,7 @@ bool Act_c::_execute() {
}
if (m678 == 5 || m678 == 6 || m678 == 3 || m683 != 0) {
dComIfG_Ccsp_SetMass(&mCyl, 3);
dComIfG_Ccsp()->SetMass(&mCyl, 3);
}
attention_info.position.x = current.pos.x;
+2 -4
View File
@@ -1905,8 +1905,7 @@ bool dCamera_c::lineBGCheckBoth(cXyz* i_start, cXyz* i_end, dBgS_LinChk* i_linCh
u32 dCamera_c::lineCollisionCheckBush(cXyz* i_start, cXyz* i_end) {
u32 ret = 0;
// Fakematch
u32 result = g_dComIfG_gameInfo.play.mCcS.GetMassResultCam();
u32 result = dComIfG_Ccsp()->GetMassResultCam();
if (result & 2) {
ret |= 1;
}
@@ -1919,8 +1918,7 @@ u32 dCamera_c::lineCollisionCheckBush(cXyz* i_start, cXyz* i_end) {
cM3dGCps cps;
cps.Set(*i_start, *i_end, 30.0f);
// Fakematch
g_dComIfG_gameInfo.play.mCcS.SetMassCam(cps);
dComIfG_Ccsp()->SetMassCam(cps);
return ret;
}
+1 -3
View File
@@ -346,9 +346,7 @@ static BOOL dScnPly_Draw(dScnPly_ply_c* i_this) {
if (dComIfGp_getGrass() != NULL || dComIfGp_getTree() != NULL ||
dComIfGp_getWood() != NULL || dComIfGp_getFlower() != NULL || dKyr_poison_live_check())
{
// using the inline breaks the match
// dComIfG_Ccsp()->PrepareMass();
g_dComIfG_gameInfo.play.mCcS.PrepareMass();
dComIfG_Ccsp()->PrepareMass();
}
dComIfGp_executeGrass();
+5 -7
View File
@@ -12,17 +12,15 @@
#include "dolphin/gx/GX.h"
/* 80017530-800176BC .text mDoLib_setResTimgObj__FP7ResTIMGP9_GXTexObjUlP10_GXTlutObj */
u8 mDoLib_setResTimgObj(ResTIMG* i_img, GXTexObj* r4, u32 i_tlut_name, GXTlutObj * o_tlutObj) {
/* Nonmatching - regalloc */
GXTexObj* o_texObj = (GXTexObj*)r4; // fixes regalloc for r31, but the other 3 are incorrect in a different way
u32 mDoLib_setResTimgObj(ResTIMG* i_img, GXTexObj* o_texObj, u32 i_tlut_name, GXTlutObj * o_tlutObj) {
if (i_img->indexTexture) {
JUT_ASSERT(0x2b, o_tlutObj != NULL);
GXInitTlutObj(o_tlutObj, ((char*)i_img) + i_img->paletteOffset, (GXTlutFmt)i_img->colorFormat, i_img->numColors);
JUT_ASSERT(43, o_tlutObj != NULL);
GXInitTlutObj(o_tlutObj, ((char*)i_img) + i_img->paletteOffset, (GXTlutFmt)i_img->colorFormat, (u16)i_img->numColors);
GXInitTexObjCI(o_texObj, ((char*)i_img) + i_img->imageOffset, i_img->width, i_img->height, (GXCITexFmt)i_img->format,
(GXTexWrapMode)i_img->wrapS, (GXTexWrapMode)i_img->wrapT, (GXBool)(i_img->mipmapCount > 1), i_tlut_name);
(GXTexWrapMode)i_img->wrapS, (GXTexWrapMode)i_img->wrapT, i_img->mipmapCount > 1 ? GX_TRUE : GX_FALSE, i_tlut_name);
} else {
GXInitTexObj(o_texObj, ((char*)i_img) + i_img->imageOffset, i_img->width, i_img->height, (GXTexFmt)i_img->format,
(GXTexWrapMode)i_img->wrapS, (GXTexWrapMode)i_img->wrapT, (GXBool)(i_img->mipmapCount > 1));
(GXTexWrapMode)i_img->wrapS, (GXTexWrapMode)i_img->wrapT, i_img->mipmapCount > 1 ? GX_TRUE : GX_FALSE);
}
GXInitTexObjLOD(o_texObj, (GXTexFilter)i_img->minFilter, (GXTexFilter)i_img->magFilter,
+61
View File
@@ -0,0 +1,61 @@
import os
import struct
from typing import BinaryIO
def skip_bytes(binary_file:BinaryIO, byte_count:int) -> None:
binary_file.seek(byte_count, os.SEEK_CUR)
def read_s8(binary_file: BinaryIO)-> int:
chunk = binary_file.read(1)
if len(chunk) < 1:
raise EOFError()
return struct.unpack(">b", chunk)[0]
def read_s16(binary_file: BinaryIO) -> int:
chunk = binary_file.read(2)
if len(chunk) < 2:
raise EOFError()
return struct.unpack(">h", chunk)[0]
def read_s32(binary_file: BinaryIO) -> int:
chunk = binary_file.read(4)
if len(chunk) < 4:
raise EOFError()
return struct.unpack(">i", chunk)[0]
def read_u8(binary_file: BinaryIO) -> int:
chunk = binary_file.read(1)
if len(chunk) < 1:
raise EOFError()
return struct.unpack(">B", chunk)[0]
def read_u16(binary_file: BinaryIO) -> int:
chunk = binary_file.read(2)
if len(chunk) < 2:
raise EOFError()
return struct.unpack(">H", chunk)[0]
def read_u32(binary_file: BinaryIO) -> int:
chunk = binary_file.read(4)
if len(chunk) < 4:
raise EOFError()
return struct.unpack(">I", chunk)[0]
def read_f32(binary_file: BinaryIO) -> int:
chunk = binary_file.read(4)
if len(chunk) < 4:
raise EOFError()
return struct.unpack(">f", chunk)[0]
def read_bytes_until_null(binary_file: BinaryIO) -> bytes:
begin = binary_file.tell()
while True:
b = binary_file.read(1)
if len(b) == 0:
raise EOFError()
if b[0] == 0:
break
str_length = binary_file.tell() - begin - 1
binary_file.seek(begin)
return binary_file.read(str_length)
+7 -18
View File
@@ -4,6 +4,7 @@ from argparse import ArgumentParser
import struct
import os
from enum import Enum
from binary_funcs import read_u16, read_u8
class GXBPRegs(Enum):
@@ -311,27 +312,14 @@ class GXCPRegs(Enum):
GX_CP_REG_ARRAYSTRIDE = 0xB0
def read_u8(binary_file):
chunk = binary_file.read(1)
if len(chunk) < 1:
return None
return struct.unpack(">B", chunk)[0]
def read_u16(binary_file):
chunk = binary_file.read(2)
if len(chunk) < 1:
return None
return struct.unpack(">H", chunk)[0]
def convert_binary_to_matDL_c_source(src_path, dest_path, symbol_name, scope):
# Load data
macro_name = os.path.splitext(os.path.basename(src_path))[0]
with open(src_path, "rb") as binary_file, open(dest_path, "w") as c_file:
c_file.write("#ifndef LOAD_BP_REG\n")
c_file.write("#define U32_AS_U8(v) ((u8)((v) >> 24)), ((u8)((v) >> 16)), ((u8)((v) >> 8)), ((u8)((v) >> 0))\n")
c_file.write("#define U24_AS_U8(v) ((u8)((v) >> 16)), ((u8)((v) >> 8)), ((u8)((v) >> 0))\n")
c_file.write("#define U16_AS_U8(v) ((u8)((v) >> 8)), ((u8)((v) >> 0))\n")
c_file.write("#define U32_AS_U8(v) (((v) >> 24) & 0xFF), (((v) >> 16) & 0xFF), (((v) >> 8) & 0xFF), (((v) >> 0) & 0xFF)\n")
c_file.write("#define U24_AS_U8(v) (((v) >> 16) & 0xFF), (((v) >> 8) & 0xFF), (((v) >> 0) & 0xFF)\n")
c_file.write("#define U16_AS_U8(v) (((v) >> 8) & 0xFF), (((v) >> 0) & 0xFF)\n")
c_file.write("#define IMAGE_ADDR(addr) (u32)(addr) >> 5\n")
c_file.write("#define LOAD_BP_REG(reg, value) GX_CMD_LOAD_BP_REG, reg, U24_AS_U8(value)\n")
c_file.write("#define LOAD_XF_REG(reg, num_args, ...) GX_CMD_LOAD_XF_REG, U16_AS_U8(num_args-1), U16_AS_U8(reg), __VA_ARGS__\n")
@@ -351,8 +339,9 @@ def convert_binary_to_matDL_c_source(src_path, dest_path, symbol_name, scope):
write_macro_line(f"{var_def_prefix}u8 {symbol_name}[] ALIGN_DECL(32) = {{")
while True:
command_type = read_u8(binary_file)
if command_type is None:
try:
command_type = read_u8(binary_file)
except EOFError:
break
line_elements = []