1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
#include <game.h>
struct HijackedStream {
//const char *original;
//const char *originalFast;
u32 stringOffset;
u32 stringOffsetFast;
u8 originalID;
};
struct Hijacker {
HijackedStream stream[2];
u8 currentStream;
u8 currentCustomTheme;
};
const char* SongNameList [] = {
"AIRSHIP",
"BOSS",
"MENU",
"UNDERWATER",
"ATHLETIC",
"CASTLE",
"MAIN",
"MOUNTAIN",
"TOWER",
"UNDERGROUND",
"DESERT",
"FIRE",
"FOREST",
"FREEZEFLAME",
"JAPAN",
"PUMPKIN",
"SEWER",
"SPACE",
"BOWSER",
"BONUS",
"AMBUSH",
"",
"",
"",
"",
"AUTUMN",
"CRYSTALCAVES",
"GHOST_HOUSE",
"GRAVEYARD",
"JUNGLE",
"TROPICAL",
"SKY_CITY",
"SNOW",
"STAR_HAVEN",
"SINGALONG",
"FACTORY",
"TANK",
"TRAIN",
"YOSHIHOUSE",
"FACTORYB",
"",
"",
"",
"MINIGAME",
"BONUS_AREA",
"CHALLENGE",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"MAP_YOSHIISLAND",
"MAP_GOLDWOOD",
"MAP_SEWER",
"FULLMAP_FRONT",
"FULLMAP_REAR",
"MAP_MINIMEGA",
"MAP_FF_VOLCANO",
"MAP_CRYSTAL_CAVE",
"MAP_SPACE",
"MAP_SKYCITY",
"MAP_KOOPA_PLANET",
"MAP_KOOPA_CORE",
NULL
};
// Offsets are from the start of the INFO block, not the start of the brsar.
// INFO begins at 0x212C0, so that has to be subtracted from absolute offsets
// within the brsar.
#define _I(offs) ((offs)-0x212C0)
Hijacker Hijackers[2] = {
{
{
{/*"athletic_lr.n.32.brstm", "athletic_fast_lr.n.32.brstm",*/ _I(0x4A8F8), _I(0x4A938), 4},
{/*"BGM_SIRO.32.brstm", "BGM_SIRO_fast.32.brstm",*/ _I(0x4B2E8), _I(0x4B320), 10}
},
0, 0
},
{
{
{/*"STRM_BGM_CHIJOU.brstm", "STRM_BGM_CHIJOU_FAST.brstm",*/ _I(0x4A83C), _I(0x4A8B4), 1},
{/*"STRM_BGM_CHIKA.brstm", "STRM_BGM_CHIKA_FAST.brstm",*/ _I(0x4A878), _I(0x4A780), 2},
},
0, 0
}
};
extern void *SoundRelatedClass;
inline char *BrsarInfoOffset(u32 offset) {
return (char*)(*(u32*)(((u32)SoundRelatedClass) + 0x5CC)) + offset;
}
void FixFilesize(u32 streamNameOffset);
extern "C" u8 after_course_getMusicForZone(u8 realThemeID) {
if (realThemeID < 100)
return realThemeID;
// drums get to use type 1
int hjIndex = (realThemeID >= 200) ? 1 : 0;
Hijacker *hj = &Hijackers[hjIndex];
// do we already have this theme in this slot?
// if so, don't switch streams
// if we do, NSMBW will think it's a different song, and restart it ...
// but if it's just an area transition where both areas are using the same
// song, we don't want that
if (hj->currentCustomTheme == realThemeID)
return hj->stream[hj->currentStream].originalID;
// which one do we use this time...?
int toUse = (hj->currentStream + 1) & 1;
hj->currentStream = toUse;
hj->currentCustomTheme = realThemeID;
// write the stream's info
HijackedStream *stream = &hj->stream[hj->currentStream];
OSReport("%d", realThemeID);
OSReport("%s", SongNameList[realThemeID-100]);
sprintf(BrsarInfoOffset(stream->stringOffset), "new/%s.er", SongNameList[realThemeID-100]);
sprintf(BrsarInfoOffset(stream->stringOffsetFast), "new/%s_F.er", SongNameList[realThemeID-100]);
// update filesizes
FixFilesize(stream->stringOffset);
FixFilesize(stream->stringOffsetFast);
// done!
return stream->originalID;
}
//oh for fuck's sake
#include "fileload.h"
//#include <rvl/dvd.h>
void FixFilesize(u32 streamNameOffset) {
char *streamName = BrsarInfoOffset(streamNameOffset);
char nameWithSound[80];
snprintf(nameWithSound, 79, "/Sound/%s", streamName);
s32 entryNum;
DVDHandle info;
if ((entryNum = DVDConvertPathToEntrynum(nameWithSound)) >= 0) {
if (DVDFastOpen(entryNum, &info)) {
u32 *lengthPtr = (u32*)(streamName - 0x1C);
*lengthPtr = info.length;
}
}
}
|