Skip to content

Commit 23cba4d

Browse files
authored
getDemoIDData matched, fix up various inlines and template classes (#2489)
* Fix debug build * getDemoIDData matched, fix up various inlines and template classes * Remove nonmatching comments
1 parent 5a13ca4 commit 23cba4d

File tree

19 files changed

+177
-102
lines changed

19 files changed

+177
-102
lines changed

config/GZ2E01/symbols.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21909,7 +21909,8 @@ struct_80450FB0 = .sbss:0x80450FB0; // type:object size:0x1 scope:global align:8
2190921909
lbl_80450FB1 = .sbss:0x80450FB1; // type:object size:0x1 data:byte
2191021910
lbl_80450FB2 = .sbss:0x80450FB2; // type:object size:0x1 data:byte
2191121911
struct_80450FB8 = .sbss:0x80450FB8; // type:object size:0x4 scope:global align:4 data:byte
21912-
struct_80450FBC = .sbss:0x80450FBC; // type:object size:0x4 scope:global align:4 data:byte
21912+
init$33110 = .sbss:0x80450FBC; // type:object size:0x1 scope:local align:1 data:byte
21913+
init$33113 = .sbss:0x80450FBD; // type:object size:0x1 scope:local align:1 data:byte
2191321914
it$36766 = .sbss:0x80450FC0; // type:object size:0x4 scope:local align:4 data:4byte
2191421915
struct_80450FC4 = .sbss:0x80450FC4; // type:object size:0x4 scope:local align:4 data:byte
2191521916
m_eye_move_flg = .sbss:0x80450FC8; // type:object size:0x1 scope:local align:1 data:byte

config/ShieldD/symbols.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64483,8 +64483,8 @@ lbl_8074C890 = .sbss:0x8074C890; // type:object size:0x1 data:byte hash:0xB74E39
6448364483
lbl_8074C891 = .sbss:0x8074C891; // type:object size:0x1 data:byte hash:0xC3C1301D dhash:0xBD2F6E4C
6448464484
lbl_8074C892 = .sbss:0x8074C892; // type:object size:0x1 data:byte hash:0xC3C1345F dhash:0xBD2F6E4C
6448564485
lbl_8074C893 = .sbss:0x8074C893; // type:object size:0x1 data:byte hash:0xC3C1491D dhash:0xBD2F6E4C
64486-
lbl_8074C894 = .sbss:0x8074C894; // type:object size:0x1 data:byte hash:0x2C9C4113 dhash:0xC335850F
64487-
lbl_8074C895 = .sbss:0x8074C895; // type:object size:0x1 data:byte hash:0xABFECE16 dhash:0xC335850F
64486+
@GUARD@daAlink_c_getDemoIDData__FP13dDemo_actor_cPiPiPiPUsPiPi@dummy = .sbss:0x8074C894; // type:object size:0x1 data:byte hash:0x2C9C4113 dhash:0xC335850F
64487+
@GUARD@daAlink_c_getDemoIDData__FP13dDemo_actor_cPiPiPiPUsPiPi@it@0 = .sbss:0x8074C895; // type:object size:0x1 data:byte hash:0xABFECE16 dhash:0xC335850F
6448864488
@LOCAL@daAlink_c_getDemoIDData__FP13dDemo_actor_cPiPiPiPUsPiPi@it@0 = .sbss:0x8074C898; // type:object size:0x4 scope:local hash:0x7C41017E dhash:0x7A3314A7
6448964489
lbl_8074C89C = .sbss:0x8074C89C; // type:object size:0x1 data:byte hash:0x91B5CF4E dhash:0x3C2D8E6B
6449064490
lbl_8074C89D = .sbss:0x8074C89D; // type:object size:0x1 data:byte hash:0x1F6B40C0 dhash:0x3C2D8E6B

include/JSystem/JGadget/binary.h

Lines changed: 75 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define BINARY_H
33

44
#include "dolphin/types.h"
5+
#include "JSystem/JGadget/search.h"
56

67
namespace JGadget {
78
namespace binary {
@@ -26,11 +27,11 @@ struct TParseData {
2627
/* 0x0 */ const void* raw;
2728
};
2829

29-
template <int T>
30+
template <int S>
3031
struct TParseData_aligned : public TParseData {
3132
TParseData_aligned(const void* pContent) : TParseData(pContent) {}
3233
void setRaw(const void* p) {
33-
/* if ((u32)p % T != 0) {
34+
/* if ((u32)p % S != 0) {
3435
JUTWarn w;
3536
w << "misaligned : " << (u32)p;
3637
} */
@@ -63,41 +64,56 @@ struct TParse_header_block {
6364
template <typename T>
6465
struct TParseValue_raw_ {
6566
typedef T ParseType;
66-
static T parse(const void* data) { return *(T*)data; }
67+
static T parse(const void* data) { return (T)*(T*)data; }
68+
};
69+
70+
template <typename T>
71+
struct TParseValue_raw : public TParseValue_raw_<T> {
72+
typedef TParseValue_raw_<T> InnerParseValueClass;
6773
};
6874

6975
template <typename T>
7076
struct TParseValue_endian_big_ : public TParseValue_raw_<T> {
71-
static T parse(const void* data) { return TParseValue_raw_::parse(data); }
77+
static T parse(const void* data) { return TParseValue_raw_<T>::parse(data); }
7278
};
7379

74-
template <typename T, template <class> class Parser>
75-
struct TParseValue : public Parser<T> {
76-
static T parse(const void* data) { return Parser<T>::parse(data); }
80+
template <class Parser>
81+
struct TParseValue : public Parser {
82+
static typename Parser::ParseType parse(const void* data) { return Parser::parse(data); }
7783

78-
static T parse(const void* data, s32 advanceNum) {
79-
return Parser<T>::parse(advance(data, advanceNum));
84+
static typename Parser::ParseType parse(const void* data, s32 advanceNum) {
85+
return Parser::parse(advance(data, advanceNum));
8086
}
8187

8288
static const void* advance(const void* data, s32 advanceNum) {
83-
return (char*)data + (advanceNum * sizeof(T));
89+
return (char*)data + (advanceNum * sizeof(Parser::ParseType));
8490
}
8591
};
8692

8793
template<class Parser, int size>
88-
struct TValueIterator {
94+
struct TValueIterator
95+
: public JGadget::TIterator<
96+
std::random_access_iterator_tag,
97+
typename Parser::ParseType,
98+
ptrdiff_t,
99+
typename Parser::ParseType*,
100+
typename Parser::ParseType&
101+
>
102+
{
103+
typedef typename Parser::ParseType ValueType;
104+
89105
TValueIterator(const void* begin) {
90-
mBegin = begin;
106+
mBegin = reinterpret_cast<const char*>(begin);
91107
}
92108

93109
const void* get() const { return mBegin; }
94110

95111
typename Parser::ParseType operator*() const {
96-
return Parser::parse(get());
112+
return TParseValue<typename Parser::InnerParseValueClass>::parse(get());
97113
}
98114

99115
TValueIterator& operator++() {
100-
const_cast<u32*>(mBegin)++;
116+
mBegin += size;
101117
return *this;
102118
}
103119

@@ -107,31 +123,67 @@ struct TValueIterator {
107123
return old;
108124
}
109125

110-
TValueIterator& operator+=(s32 v) {
111-
const_cast<u32*>(mBegin) += v;
126+
TValueIterator& operator+=(s32 n) {
127+
mBegin += size * n;
128+
return *this;
129+
}
130+
131+
TValueIterator& operator--() {
132+
mBegin -= size;
112133
return *this;
113134
}
114135

115-
const void* mBegin;
136+
char const* mBegin;
116137
};
117138

118139
template<typename T>
119-
struct TValueIterator_raw : public TValueIterator<TParseValue_raw_<u8>, 1> {
120-
TValueIterator_raw(const void* begin) : TValueIterator<TParseValue_raw_<u8>, 1>(begin) {}
140+
struct TValueIterator_raw : public TValueIterator<TParseValue_raw<T>, sizeof(T)> {
141+
TValueIterator_raw(const void* begin) : TValueIterator<TParseValue_raw<T>, sizeof(T)>(begin) {}
142+
143+
friend bool operator==(TValueIterator<TParseValue_raw<T>, sizeof(T)> a, TValueIterator<TParseValue_raw<T>, sizeof(T)> b) {
144+
return a.mBegin == b.mBegin;
145+
}
146+
147+
friend bool operator!=(TValueIterator<TParseValue_raw<T>, sizeof(T)> a, TValueIterator<TParseValue_raw<T>, sizeof(T)> b) {
148+
return !operator==(a, b);
149+
}
150+
151+
friend TValueIterator<TParseValue_raw<T>, sizeof(T)> operator+(TValueIterator<TParseValue_raw<T>, sizeof(T)> a, s32 b) {
152+
TValueIterator<TParseValue_raw<T>, sizeof(T)> it = a;
153+
it += b;
154+
return it;
155+
}
156+
};
157+
158+
template <typename T>
159+
struct TParseValue_misaligned_ : public TParseValue_raw_<T> {
160+
typedef T ParseType;
161+
static T parse(const void* data) { return TParseValue_raw_<T>::parse(data); }
121162
};
122163

123164
template <typename T>
124-
struct TParseValue_misaligned : TParseValue_raw_<T> {
125-
static T parse(const void* data) { return TParseValue_raw_::parse(data); }
165+
struct TParseValue_misaligned : public TParseValue_raw_<T> {
166+
typedef TParseValue_misaligned_<T> InnerParseValueClass;
126167
};
127168

128169
template<typename T>
129170
struct TValueIterator_misaligned : public TValueIterator<TParseValue_misaligned<T>, sizeof(T)> {
130171
TValueIterator_misaligned(const void* begin) : TValueIterator<TParseValue_misaligned<T>, sizeof(T)>(begin) {}
131-
};
132172

173+
friend bool operator==(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, TValueIterator<TParseValue_misaligned<T>, sizeof(T)> b) {
174+
return a.mBegin == b.mBegin;
175+
}
176+
177+
friend bool operator!=(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, TValueIterator<TParseValue_misaligned<T>, sizeof(T)> b) {
178+
return !operator==(a, b);
179+
}
133180

134-
inline bool operator==(TValueIterator<TParseValue_misaligned<u32>, 4> a, TValueIterator<TParseValue_misaligned<u32>, 4> b) { return a.mBegin == b.mBegin; }
181+
friend TValueIterator<TParseValue_misaligned<T>, sizeof(T)> operator+(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, s32 b) {
182+
TValueIterator<TParseValue_misaligned<T>, sizeof(T)> it(a);
183+
it += b;
184+
return it;
185+
}
186+
};
135187

136188
} // namespace binary
137189
} // namespace JGadget

include/JSystem/JStudio/JStudio/object-id.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct TObject_ID : public TIDData {
2828

2929
struct TPRObject_ID_equal : public TIDData {
3030
TPRObject_ID_equal(const void* id, u32 id_size) : TIDData(id, id_size) {}
31-
TPRObject_ID_equal(const TPRObject_ID_equal& other) : TIDData(other.mID, other.mID_size) {}
31+
~TPRObject_ID_equal() {}
3232
bool operator()(TObject_ID const& id) const { return TIDData::isEqual(id.getIDData(), *this); }
3333
};
3434

include/JSystem/JStudio/JStudio/stb-data-parse.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ class TParse_TParagraph : public TParseData_aligned<4> {
6565
/* 80289A08 */ void getData(TData*) const;
6666
};
6767

68-
struct TParse_TParagraph_data : public TParseData_aligned<4> {
68+
struct TParse_TParagraph_data : public TParseData {
6969
struct TData {
7070
/* 0x00 */ u8 status;
71-
/* 0x04 */ u32 dataSize;
72-
/* 0x08 */ u32 _8;
73-
/* 0x0C */ const void* fileCount;
74-
/* 0x10 */ const void* _10;
71+
/* 0x04 */ u32 entrySize;
72+
/* 0x08 */ u32 entryCount;
73+
/* 0x0C */ const void* content;
74+
/* 0x10 */ const void* next;
7575
};
7676

77-
TParse_TParagraph_data(const void* content) : TParseData_aligned<4>(content) {}
77+
TParse_TParagraph_data(const void* content) : TParseData(content) {}
7878
/* 80289A80 */ void getData(TData* pData) const;
7979
};
8080

@@ -90,7 +90,6 @@ class TParse_TBlock_object : public TParse_TBlock {
9090

9191
u16 get_flag() const { return get()->flag; }
9292
u16 get_IDSize() const { return get()->id_size; }
93-
u32 get_type() const { return get()->type; }
9493
const void* get_ID() const { return get()->id; }
9594
};
9695

include/JSystem/JStudio/JStudio/stb.h

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "dolphin/os.h"
88

99
namespace JStudio {
10-
struct TObject;
10+
class TObject;
1111
namespace stb {
1212

1313
class TControl;
@@ -156,11 +156,10 @@ class TControl {
156156
/* 0x54 */ s32 _54;
157157
};
158158

159-
template <int T>
159+
template <int S>
160160
struct TParseData : public data::TParse_TParagraph_data::TData {
161161
TParseData(const void* pContent) {
162-
data::TParse_TParagraph_data data(pContent);
163-
set(data);
162+
set(data::TParse_TParagraph_data(pContent));
164163
}
165164

166165
TParseData() {
@@ -171,45 +170,57 @@ struct TParseData : public data::TParse_TParagraph_data::TData {
171170
data.getData(this);
172171
}
173172

173+
void set(const void* pContent) {
174+
set(data::TParse_TParagraph_data(pContent));
175+
}
176+
174177
bool isEnd() const {
175178
return status == 0;
176179
}
177180

178181
bool empty() const {
179-
return fileCount == NULL;
182+
return content == NULL;
180183
}
181184

182185
bool isValid() const {
183-
return !empty() && status == 50;
186+
return !empty() && status == S;
184187
}
185188

186-
const void* getContent() const { return fileCount; }
189+
const void* getContent() const { return content; }
187190

188-
u32 size() const { return dataSize; }
191+
u32 size() const { return entryCount; }
189192
};
190193

191-
template <int T, class Iterator=JGadget::binary::TValueIterator_raw<u8> >
192-
struct TParseData_fixed : public TParseData<T> {
193-
TParseData_fixed(const void* pContent) : TParseData<T>(pContent) {}
194-
TParseData_fixed() : TParseData<T>() {}
194+
template <int S, class Iterator=JGadget::binary::TValueIterator_raw<u8> >
195+
struct TParseData_fixed : public TParseData<S> {
196+
TParseData_fixed(const void* pContent) : TParseData<S>(pContent) {}
197+
TParseData_fixed() : TParseData<S>() {}
195198

196199
const void* getNext() const {
197-
return _10;
200+
return this->next;
198201
}
199202

200203
bool isValid() const {
201-
return TParseData::isValid() && getNext() != NULL;
204+
return TParseData<S>::isValid() && getNext() != NULL;
202205
}
203206

204207
Iterator begin() const {
205-
return Iterator(fileCount);
208+
return Iterator(this->content);
206209
}
207210

208211
Iterator end() const {
209-
Iterator i(fileCount);
210-
i += size();
212+
Iterator i(this->content);
213+
i += this->size();
211214
return i;
212215
}
216+
217+
typename Iterator::ValueType front() const {
218+
return *begin();
219+
}
220+
221+
typename Iterator::ValueType back() const {
222+
return *--end();
223+
}
213224
};
214225

215226
struct TParseData_string : public TParseData<0x60> {

include/JSystem/JUtility/JUTFader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class JUTFader {
2525
/* 802E56DC */ virtual void draw();
2626

2727
s32 getStatus() const { return mStatus; }
28-
void setColor(JUtility::TColor& color) { mColor.set(color); }
28+
void setColor(JUtility::TColor color) { mColor.set(color); }
2929

3030
/* 0x04 */ s32 mStatus;
3131
/* 0x08 */ u16 field_0x8;

include/JSystem/JUtility/TColor.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ struct TColor : public GXColor {
2828
}
2929

3030
void set(u32 u32Color) { *(u32*)&r = u32Color; }
31-
void set(GXColor gxColor) { *(GXColor*)&r = gxColor; }
31+
void set(GXColor gxColor) {
32+
GXColor* temp = this;
33+
*temp = gxColor;
34+
}
3235
};
3336
} // namespace JUtility
3437

include/d/actor/d_a_obj_gra2.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ class daObj_GrA_c : public daBaseNpc_moveBgActor_c {
8686
typedef int (daObj_GrA_c::*MotionFunc)(int);
8787
typedef int (daObj_GrA_c::*Process)(void*);
8888

89+
enum {
90+
NUMLOOKMODES_e = 4,
91+
};
92+
8993
class daObj_GrA_prtclMngr_c {
9094
public:
9195
/* 80C04E14 */ ~daObj_GrA_prtclMngr_c() {}

include/d/d_s_logo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class dScnLogo_c : public scene_class {
9595
/* 0x212 */ u16 field_0x212;
9696
/* 0x214 */ u16 field_0x214;
9797
/* 0x218 */ u32 field_0x218;
98-
/* 0x21C */ void* buffer;
98+
/* 0x21C */ void* dummyGameAlloc;
9999
/* 0x220 */ mDoDvdThd_mountXArchive_c* mpField0Command;
100100
/* 0x224 */ mDoDvdThd_mountXArchive_c* mpAlAnmCommand;
101101
/* 0x228 */ u8 field_0x228[4];

0 commit comments

Comments
 (0)