Skip to content

Commit 96ef0c7

Browse files
committed
2 parents 984f951 + ee83ec5 commit 96ef0c7

File tree

8 files changed

+175
-27
lines changed

8 files changed

+175
-27
lines changed

base/symbols_resort.txt

Lines changed: 4 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
@@ -3089,6 +3090,7 @@ Bind__Q34nw4r3g3d6ResMatFQ34nw4r3g3d7ResFile=0x80170020
30893090
Release__Q34nw4r3g3d6ResMatFv=0x801700f0
30903091
Init__Q34nw4r3g3d6ResMatFv=0x80170190
30913092
IsOpaque__Q34nw4r3g3d6ResMatCFv=0x801701c0
3093+
GetResTev__Q34nw4r3g3d6ResMatFv=0x80170210
30923094
Bind__Q34nw4r3g3d14ResTexPlttInfoFQ34nw4r3g3d7ResFileQ34nw4r3g3d9ResTexObjQ34nw4r3g3d10ResTlutObj=0x80170270
30933095
SetArray__Q34nw4r3g3d9ResVtxNrmFv=0x80170610
30943096
SetArray__Q34nw4r3g3d9ResVtxClrF7_GXAttr=0x801706f0
@@ -3186,6 +3188,8 @@ Bind__Q34nw4r3g3d12AnmObjShpResFQ34nw4r3g3d6ResMdl=0x8017e220
31863188
GetResult__Q34nw4r3g3d12AnmObjShpResFPQ34nw4r3g3d12ShpAnmResultUl=0x8017e3e0
31873189
GetLightSetting__Q34nw4r3g3d6AnmScnFPQ34nw4r3g3d12LightSetting=0x8017e820
31883190
Destroy__Q34nw4r3g3d6G3dObjFv=0x8017eba0
3191+
PlayPolicy_Onetime__Q24nw4r3g3dFfff=0x8017ec80
3192+
PlayPolicy_Loop__Q24nw4r3g3dFfff=0x8017ec90
31893193
SetAnmFlag__Q34nw4r3g3d6AnmObjFQ44nw4r3g3d6AnmObj7AnmFlagb=0x8017ed00
31903194
TestAnmFlag__Q34nw4r3g3d6AnmObjCFQ44nw4r3g3d6AnmObj7AnmFlag=0x8017ed30
31913195
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);

include/nw4r/g3d/res/g3d_restev.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class ResTev : public ResCommon<ResTevData> {
8888
u8 GetNumTevStages() const {
8989
return ref().nStages;
9090
}
91+
void SetNumTevStages(u8 num) {
92+
ref().nStages = num;
93+
}
9194

9295
void EndEdit() {
9396
DCStore(false);

lib/libkiwi/support/kiwiNw4r.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <nw4r/g3d.h>
2+
3+
#include <libkiwi.h>
4+
5+
namespace nw4r {
6+
namespace g3d {
7+
8+
void ResTev::GXSetTevColorIn(GXTevStageID stage, GXTevColorArg a,
9+
GXTevColorArg b, GXTevColorArg c,
10+
GXTevColorArg d) {
11+
u8* pCmd = ref()
12+
.dl.dl.var[stage / TEV_STAGES_PER_DL]
13+
.dl.tevColorCalc[stage % TEV_STAGES_PER_DL];
14+
15+
// clang-format off
16+
detail::ResWriteBPCmd(pCmd,
17+
(d << GX_BP_TEVCOLORCOMBINER_D_SHIFT) |
18+
(c << GX_BP_TEVCOLORCOMBINER_C_SHIFT) |
19+
(b << GX_BP_TEVCOLORCOMBINER_B_SHIFT) |
20+
(a << GX_BP_TEVCOLORCOMBINER_A_SHIFT) |
21+
((GX_BP_REG_TEVCOLORCOMBINER0 + stage * 2)
22+
<< GX_BP_OPCODE_SHIFT),
23+
24+
~(GX_BP_TEVCOLORCOMBINER_DEST_MASK |
25+
GX_BP_TEVCOLORCOMBINER_SCALE_OR_COMPARE_MODE_MASK |
26+
GX_BP_TEVCOLORCOMBINER_CLAMP_MASK |
27+
GX_BP_TEVCOLORCOMBINER_OP_OR_COMPARISON_MASK |
28+
GX_BP_TEVCOLORCOMBINER_BIAS_MASK));
29+
// clang-format on
30+
}
31+
32+
} // namespace g3d
33+
} // namespace nw4r

src/hooks/Cmn/cosmetics_Cmn.cpp

Lines changed: 89 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,91 @@ 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+
/**
273+
* Ball color is stored in TEV color 0
274+
*/
275+
nw4r::g3d::ResMatTevColor tevColor = bwg_ball_mat.GetResMatTevColor();
276+
ASSERT(tevColor.IsValid());
277+
tevColor.GXSetTevColor(GX_TEVREG0, color);
278+
279+
/**
280+
* Patch the shader to use TEVREG0
281+
*/
282+
nw4r::g3d::ResTev tev = bwg_ball_mat.GetResTev();
283+
284+
// TODO: Need to decompile GXSetTevColorOp to set the result of the shader
285+
#if 0
286+
// Texture color * 1/4 to keep pattern but lower color impact
287+
tev.GXSetTevColorIn(GX_TEVSTAGE3, GX_CC_ZERO, GX_CC_HALF, GX_CC_TEXC,
288+
GX_CC_ZERO);
289+
290+
// Multiply by ball color in TEV register
291+
tev.GXSetTevColorIn(GX_TEVSTAGE4, GX_CC_ZERO, GX_CC_TEXC, GX_CC_C0,
292+
GX_CC_ZERO);
293+
294+
// Activate shader stages
295+
tev.SetNumTevStages(tev.GetNumTevStages() + 2);
296+
#else
297+
tev.GXSetTevColorIn(GX_TEVSTAGE2, GX_CC_ZERO, GX_CC_CPREV, GX_CC_HALF,
298+
GX_CC_ZERO);
299+
#endif
300+
}
301+
302+
void InterceptBwlBallColor(RPGrpModelG3D* pModel, RPGrpModelG3D* pModelMirror) {
303+
ASSERT_PTR(pModel);
304+
ASSERT_PTR(pModelMirror);
305+
306+
nw4r::g3d::ResMdl mdl =
307+
pModel->GetModelEx()->getScnMdlSimple()->GetResMdl();
308+
309+
ASSERT(mdl.IsValid());
310+
311+
nw4r::g3d::ResMdl mdlMirror =
312+
pModelMirror->GetModelEx()->getScnMdlSimple()->GetResMdl();
313+
314+
ASSERT(mdlMirror.IsValid());
315+
316+
kiwi::Color color =
317+
kiwi::Color::FromHsv(kiwi::Random().NextF32(1.0f), 0.5f, 1.0f);
318+
319+
PatchBwlBallColor(mdl, color);
320+
PatchBwlBallColor(mdlMirror, color);
321+
}
322+
323+
/**
324+
* @brief InterceptBwlBallColor trampoline
325+
*/
326+
TRAMPOLINE_DEF(0x804d1174, 0x804d1178){
327+
// clang-format off
328+
TRAMPOLINE_BEGIN
329+
330+
mr r3, r5
331+
mr r4, r6
332+
bl InterceptBwlBallColor
333+
334+
TRAMPOLINE_END
335+
rlwinm r0, r4, 0x3, 0x0, 0x1C // original instruction
336+
blr
337+
// clang-format on
338+
}
339+
257340
/******************************************************************************
258341
*
259342
* Random Island Time

0 commit comments

Comments
 (0)