Skip to content

Commit bb0faa2

Browse files
committed
Bowling ball tev color
1 parent 407c543 commit bb0faa2

6 files changed

Lines changed: 118 additions & 27 deletions

File tree

base/symbols_resort.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,6 +3007,7 @@ GetResVtxNrm__Q34nw4r3g3d6ResMdlCFQ34nw4r3g3d7ResName=0x8016bed0
30073007
GetResVtxNrmNumEntries__Q34nw4r3g3d6ResMdlCFv=0x8016bfe0
30083008
GetResVtxClr__Q34nw4r3g3d6ResMdlCFQ34nw4r3g3d7ResName=0x8016c020
30093009
GetResVtxClrNumEntries__Q34nw4r3g3d6ResMdlCFv=0x8016c130
3010+
GetResMat__Q34nw4r3g3d6ResMdlCFPCc=0x8016c230
30103011
GetResMat__Q34nw4r3g3d6ResMdlCFQ34nw4r3g3d7ResName=0x8016c280
30113012
GetResMatNumEntries__Q34nw4r3g3d6ResMdlCFv=0x8016c390
30123013
GetResShpNumEntries__Q34nw4r3g3d6ResMdlCFv=0x8016c4e0
@@ -3186,6 +3187,8 @@ Bind__Q34nw4r3g3d12AnmObjShpResFQ34nw4r3g3d6ResMdl=0x8017e220
31863187
GetResult__Q34nw4r3g3d12AnmObjShpResFPQ34nw4r3g3d12ShpAnmResultUl=0x8017e3e0
31873188
GetLightSetting__Q34nw4r3g3d6AnmScnFPQ34nw4r3g3d12LightSetting=0x8017e820
31883189
Destroy__Q34nw4r3g3d6G3dObjFv=0x8017eba0
3190+
PlayPolicy_Onetime__Q24nw4r3g3dFfff=0x8017ec80
3191+
PlayPolicy_Loop__Q24nw4r3g3dFfff=0x8017ec90
31893192
SetAnmFlag__Q34nw4r3g3d6AnmObjFQ44nw4r3g3d6AnmObj7AnmFlagb=0x8017ed00
31903193
TestAnmFlag__Q34nw4r3g3d6AnmObjCFQ44nw4r3g3d6AnmObj7AnmFlag=0x8017ed30
31913194
GDSetCullMode__Q34nw4r3g3d4fifoF11_GXCullMode=0x8017edd0

include/Pack/RPGraphics/RPGrpModel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef RP_GRAPHICS_MODEL_H
22
#define RP_GRAPHICS_MODEL_H
33
#include "RPTypes.h"
4+
45
#include <egg/gfx/eggModelEx.h>
56

67
class RPGrpModel {
@@ -11,6 +12,9 @@ class RPGrpModel {
1112

1213
private:
1314
char _00[0x40];
15+
#if defined(PACK_RESORT)
16+
char _40[0x4];
17+
#endif
1418
EGG::ModelEx* mModelEx; // at 0x40
1519
};
1620

include/egg/gfx/eggModelEx.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ class ModelEx {
3434
enum EDrawShape { cDrawShape_None = (1 << 0) };
3535

3636
private:
37+
#if defined(PACK_RESORT)
38+
nw4r::g3d::ScnObj* mScnObj; // at 0x0
39+
EType mType; // at 0x4
40+
u16 mFlag; // at 0x8
41+
ModelBoundingInfo* mpBV; // at 0xC
42+
#else
3743
EType mType; // at 0x0
3844
u16 mFlag; // at 0x4
3945
nw4r::g3d::ScnObj* mScnObj; // at 0x8
4046
ModelBoundingInfo* mpBV; // at 0xC
47+
#endif
4148

4249
static u32 sDrawFlag;
4350
static const char* sByteCodeCalcStr;

include/nw4r/g3d/res/g3d_resmat.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -519,16 +519,19 @@ struct ResMatDLData {
519519
};
520520

521521
struct ResMatData {
522-
u32 size; // at 0x0
523-
s32 toResMdlData; // at 0x4
524-
s32 name; // at 0x8
525-
u32 id; // at 0xC
526-
u32 flag; // at 0x10
527-
ResGenModeData genMode; // at 0x14
528-
ResMatMiscData misc; // at 0x1C
529-
s32 toResTevData; // at 0x28
530-
u32 numResTexPlttInfo; // at 0x2C
531-
s32 toResTexPlttInfo; // at 0x30
522+
u32 size; // at 0x0
523+
s32 toResMdlData; // at 0x4
524+
s32 name; // at 0x8
525+
u32 id; // at 0xC
526+
u32 flag; // at 0x10
527+
ResGenModeData genMode; // at 0x14
528+
ResMatMiscData misc; // at 0x1C
529+
s32 toResTevData; // at 0x28
530+
u32 numResTexPlttInfo; // at 0x2C
531+
s32 toResTexPlttInfo; // at 0x30
532+
#if defined(PACK_RESORT)
533+
s32 toResMatFurData;
534+
#endif
532535
s32 toResUserData; // at 0x34
533536
s32 toResMatDLData; // at 0x38
534537
ResTexObjData texObjData; // at 0x3C

include/nw4r/g3d/res/g3d_resmdl.h

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,28 +101,39 @@ class ResMdlInfo : public ResCommon<ResMdlInfoData>,
101101
*
102102
******************************************************************************/
103103
struct ResMdlData {
104-
ResBlockHeaderData header; // at 0x0
105-
u32 revision; // at 0x8
106-
s32 toResFileData; // at 0xC
107-
s32 toResByteCodeDic; // at 0x10
108-
s32 toResNodeDic; // at 0x14
109-
s32 toResVtxPosDic; // at 0x18
110-
s32 toResVtxNrmDic; // at 0x1C
111-
s32 toResVtxClrDic; // at 0x20
112-
s32 toResVtxTexCoordDic; // at 0x24
104+
ResBlockHeaderData header; // at 0x0
105+
u32 revision; // at 0x8
106+
s32 toResFileData; // at 0xC
107+
s32 toResByteCodeDic; // at 0x10
108+
s32 toResNodeDic; // at 0x14
109+
s32 toResVtxPosDic; // at 0x18
110+
s32 toResVtxNrmDic; // at 0x1C
111+
s32 toResVtxClrDic; // at 0x20
112+
s32 toResVtxTexCoordDic; // at 0x24
113+
#if defined(PACK_RESORT)
114+
s32 toResVtxFurVecDic;
115+
s32 toResVtxFurPosDic;
116+
#endif
113117
s32 toResMatDic; // at 0x28
114118
s32 toResTevDic; // at 0x2C
115119
s32 toResShpDic; // at 0x30
116120
s32 toResTexNameToTexPlttInfoDic; // at 0x34
117121
s32 toResPlttNameToTexPlttInfoDic; // at 0x38
118-
s32 name; // at 0x3C
119-
ResMdlInfoData info; // at 0x40
122+
#if defined(PACK_RESORT)
123+
s32 toResUserData;
124+
#endif
125+
s32 name; // at 0x3C
126+
ResMdlInfoData info; // at 0x40
120127
};
121128

122129
class ResMdl : public ResCommon<ResMdlData> {
123130
public:
124131
static const u32 SIGNATURE = 'MDL0';
132+
#if defined(PACK_RESORT)
133+
static const int REVISION = 11;
134+
#else
125135
static const int REVISION = 9;
136+
#endif
126137

127138
public:
128139
NW4R_G3D_RESOURCE_FUNC_DEF(ResMdl);

src/hooks/Cmn/cosmetics_Cmn.cpp

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
#include "hooks/Swf/items_Swf.h"
66
#include "hooks/trampoline.h"
77

8+
#include <Pack/RPGraphics.h>
89
#include <Pack/RPKernel.h>
910
#include <Pack/RPSystem.h>
1011
#include <Sports2/Sp2Cmn.h>
12+
#include <nw4r/g3d.h>
1113

1214
#include <libkiwi.h>
1315

@@ -45,7 +47,7 @@ u32 InterceptBgm(u32 id) {
4547
/**
4648
* @brief InterceptBgm trampoline
4749
*/
48-
TRAMPOLINE_DEF(0x802B722C, 0x802B7230) {
50+
TRAMPOLINE_DEF(0x802B722C, 0x802B7230){
4951
// clang-format off
5052
TRAMPOLINE_BEGIN
5153

@@ -64,8 +66,6 @@ TRAMPOLINE_DEF(0x802B722C, 0x802B7230) {
6466
*
6567
******************************************************************************/
6668

67-
namespace {
68-
6969
/**
7070
* @brief Generates a random Mii favorite color
7171
*/
@@ -117,8 +117,6 @@ kiwi::Color GetRandomFavoriteColor() {
117117
// r.NextF32(0.40f, 1.0f));
118118
}
119119

120-
} // namespace
121-
122120
/**
123121
* @brief Generates a random RFL favorite color
124122
*
@@ -241,7 +239,7 @@ TRAMPOLINE_DEF(0x801f546c, 0x801f5514){
241239
/**
242240
* @brief InterceptFavoriteColorHat trampoline
243241
*/
244-
TRAMPOLINE_DEF(0x801032c4, 0x801032c8){
242+
TRAMPOLINE_DEF(0x801032c4, 0x801032c8) {
245243
// clang-format off
246244
TRAMPOLINE_BEGIN
247245

@@ -254,6 +252,71 @@ TRAMPOLINE_DEF(0x801032c4, 0x801032c8){
254252
// clang-format on
255253
}
256254

255+
/******************************************************************************
256+
*
257+
* Random Bowling Ball Color
258+
*
259+
******************************************************************************/
260+
/**
261+
* @brief Overrides the bowling ball model color based on the randomizer
262+
* settings
263+
*
264+
* @param mdl Ball model
265+
*/
266+
void PatchBwlBallColor(nw4r::g3d::ResMdl mdl, kiwi::Color color) {
267+
ASSERT(mdl.IsValid());
268+
269+
nw4r::g3d::ResMat bwg_ball_mat = mdl.GetResMat("bwg_ball_mat");
270+
ASSERT(bwg_ball_mat.IsValid());
271+
272+
// Ball color is stored in TEV color 0
273+
nw4r::g3d::ResMatTevColor tevColor = bwg_ball_mat.GetResMatTevColor();
274+
ASSERT(tevColor.IsValid());
275+
276+
tevColor.GXSetTevColor(GX_TEVREG0, color);
277+
278+
// TODO: Patch the shader to use the TEV color
279+
;
280+
}
281+
282+
void InterceptBwlBallColor(RPGrpModelG3D* pModel, RPGrpModelG3D* pModelMirror) {
283+
ASSERT_PTR(pModel);
284+
ASSERT_PTR(pModelMirror);
285+
286+
nw4r::g3d::ResMdl mdl =
287+
pModel->GetModelEx()->getScnMdlSimple()->GetResMdl();
288+
289+
ASSERT(mdl.IsValid());
290+
291+
nw4r::g3d::ResMdl mdlMirror =
292+
pModelMirror->GetModelEx()->getScnMdlSimple()->GetResMdl();
293+
294+
ASSERT(mdlMirror.IsValid());
295+
296+
kiwi::Color color =
297+
kiwi::Color::FromHsv(kiwi::Random().NextF32(1.0f), 0.5f, 1.0f);
298+
299+
PatchBwlBallColor(mdl, color);
300+
PatchBwlBallColor(mdlMirror, color);
301+
}
302+
303+
/**
304+
* @brief InterceptBwlBallColor trampoline
305+
*/
306+
TRAMPOLINE_DEF(0x804d1174, 0x804d1178){
307+
// clang-format off
308+
TRAMPOLINE_BEGIN
309+
310+
mr r3, r5
311+
mr r4, r6
312+
bl InterceptBwlBallColor
313+
314+
TRAMPOLINE_END
315+
rlwinm r0, r4, 0x3, 0x0, 0x1C // original instruction
316+
blr
317+
// clang-format on
318+
}
319+
257320
/******************************************************************************
258321
*
259322
* Random Island Time

0 commit comments

Comments
 (0)