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
|
#include <game.h>
#include <newer.h>
#include "levelinfo.h"
int lastLevelIDs[] = {
-1, /*no world*/
27, 27, 27, 27, 27, 27, 27, 25,
10,
24, 24, 21, 24, 3
};
/*
extern "C" void FuckUpYoshi(void *_this) {
dEn_c *koopa = (dEn_c*)fBase_c::search(EN_NOKONOKO, 0);
static int thing = 0;
thing++;
nw4r::db::Exception_Printf_("Fruit eaten: %d\n", thing);
if (thing == 5) {
nw4r::db::Exception_Printf_("5th fruit eaten\n");
nw4r::db::Exception_Printf_("Let's try fucking up Yoshi!\n");
daPlBase_c *yoshi = (daPlBase_c*)fBase_c::search(YOSHI, 0);
nw4r::db::Exception_Printf_("Fruit: %p ; Koopa: %p ; Yoshi: %p\n", _this, koopa, yoshi);
koopa->_vf220(yoshi);
nw4r::db::Exception_Printf_("Yoshi fucked up. Yay.\n");
thing = 0;
}
}
extern "C" void FuckUpYoshi2() {
dEn_c *koopa = (dEn_c*)fBase_c::search(EN_NOKONOKO, 0);
nw4r::db::Exception_Printf_("Let's try fucking up Yoshi!\n");
daPlBase_c *yoshi = (daPlBase_c*)fBase_c::search(YOSHI, 0);
koopa->_vf220(yoshi);
nw4r::db::Exception_Printf_("Yoshi fucked up. Yay.\n");
}
extern "C" void StartAnimOrig(dPlayerModelBase_c *_this, int id, float updateRate, float unk, float frame);
extern "C" void YoshiStartAnimWrapper(dPlayerModelBase_c *_this, int id, float updateRate, float unk, float frame) {
nw4r::db::Exception_Printf_("[%d] anim %d (%f, %f, %f)\n", GlobalTickCount, id, updateRate, unk, frame);
StartAnimOrig(_this, id, updateRate, unk, frame);
}
extern "C" void YoshiStateOrig(daPlBase_c *_this, dStateBase_c *state, void *param);
extern "C" void YoshiStateWrapper(daPlBase_c *_this, dStateBase_c *state, void *param) {
nw4r::db::Exception_Printf_("[%d] %s,%p\n", GlobalTickCount, state->getName(), param);
YoshiStateOrig(_this, state, param);
}
*/
void WriteAsciiToTextBox(nw4r::lyt::TextBox *tb, const char *source) {
int i = 0;
wchar_t buffer[1024];
while (i < 1023 && source[i]) {
buffer[i] = source[i];
i++;
}
buffer[i] = 0;
tb->SetString(buffer);
}
void getNewerLevelNumberString(int world, int level, wchar_t *dest) {
static const wchar_t *numberKinds[] = {
// 0-19 are handled by code
// To insert a picturefont character:
// \x0B\x01YY\xZZZZ
// YY is the character code, ZZZZ is ignored
L"A", // 20, alternate
L"\x0B\x0148\xBEEF", // 21, tower
L"\x0B\x0148\xBEEF" L"2", // 22, tower 2
L"\x0B\x012E\xBEEF", // 23, castle
L"\x0B\x012F\xBEEF", // 24, fortress
L"\x0B\x013D\xBEEF", // 25, final castle
L"\x0B\x014D\xBEEF", // 26, train
L"\x0B\x0132\xBEEF", // 27, airship
L"Palace", // 28, switch palace
L"\x0B\x0147\xBEEF", // 29, yoshi's house
L"\x0B\x014E\xBEEF" L"1", // 30, key 1
L"\x0B\x014E\xBEEF" L"2", // 31, key 2
L"\x0B\x014E\xBEEF" L"3", // 32, key 3
L"\x0B\x014E\xBEEF" L"4", // 33, key 4
L"\x0B\x014E\xBEEF" L"5", // 34, key 5
L"\x0B\x014E\xBEEF" L"6", // 35, key 6
L"\x0B\x0138\xBEEF", // 36, music house
L"\x0B\x0133\xBEEF", // 37, shop
L"\x0B\x0139\xBEEF", // 38, challenge house
L"\x0B\x0151\xBEEF", // 39, red switch palace
L"\x0B\x0152\xBEEF", // 40, blue switch palace
L"\x0B\x0153\xBEEF", // 41, yellow switch palace
L"\x0B\x0154\xBEEF", // 42, green switch palace
};
dest[0] = (world >= 10) ? (world-10+'A') : (world+'0');
dest[1] = '-';
if (level >= 20) {
wcscpy(&dest[2], numberKinds[level-20]);
} else if (level >= 10) {
dest[2] = '1';
dest[3] = ('0' - 10) + level;
dest[4] = 0;
} else {
dest[2] = '0' + level;
dest[3] = 0;
}
}
int getUnspentStarCoinCount() {
SaveBlock *save = GetSaveFile()->GetBlock(-1);
int coinsSpent = save->spentStarCoins;
return getStarCoinCount() - coinsSpent;
}
int getStarCoinCount() {
SaveBlock *save = GetSaveFile()->GetBlock(-1);
int coinsEarned = 0;
for (int w = 0; w < 10; w++) {
for (int l = 0; l < 42; l++) {
u32 conds = save->GetLevelCondition(w, l);
if (conds & COND_COIN1) { coinsEarned++; }
if (conds & COND_COIN2) { coinsEarned++; }
if (conds & COND_COIN3) { coinsEarned++; }
}
}
return coinsEarned;
}
struct GEIFS {
int starCoins, exits;
};
extern "C" GEIFS *GrabExitInfoForFileSelect(GEIFS *out, SaveBlock *save) {
out->starCoins = 0;
out->exits = 0;
for (int i = 0; i < dLevelInfo_c::s_info.sectionCount(); i++) {
dLevelInfo_c::section_s *section = dLevelInfo_c::s_info.getSectionByIndex(i);
for (int j = 0; j < section->levelCount; j++) {
dLevelInfo_c::entry_s *l = §ion->levels[j];
if (l->flags & 2) {
//OSReport("Checking %d-%d...\n", l->worldSlot+1, l->levelSlot+1);
u32 cond = save->GetLevelCondition(l->worldSlot, l->levelSlot);
if ((l->flags & 0x10) && (cond & COND_NORMAL))
out->exits++;
if ((l->flags & 0x20) && (cond & COND_SECRET))
out->exits++;
if (cond & COND_COIN1)
out->starCoins++;
if (cond & COND_COIN2)
out->starCoins++;
if (cond & COND_COIN3)
out->starCoins++;
}
}
}
OSReport("Done, got %d coins and %d exits\n", out->starCoins, out->exits);
return out;
}
|