Skip to content

Commit fb64cf9

Browse files
committed
c
1 parent b5670e5 commit fb64cf9

770 files changed

Lines changed: 89548 additions & 11109 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/symbols_resort.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
memcpy=0x80004000
2+
wmemcpy=0x80010870
23
memset=0x80004350
34
vprintf=0x8000ceec
45
vsprintf=0x8000cff0
@@ -13,8 +14,11 @@ sscanf=0x8000e604
1314
wcslen=0x80012c18
1415
strncat=0x8000e864
1516
strncmp=0x8000e9cc
17+
swprintf=0x80012a94
1618
wcsncpy=0x80012c50
1719
wcschr=0x80012d14
20+
wcstombs=0x8000a938
21+
mbstowcs=0x8000a878
1822

1923
_f_dol_init=0x80004000
2024
_e_dol_init=0x800066df
@@ -121,6 +125,8 @@ __shl2i=0x80007cd0
121125
__shr2i=0x80007cf4
122126
__cvt_dbl_sll=0x80007d18
123127
__cvt_dbl_ull=0x80007dc8
128+
__wStringWrite=0x80012a28
129+
__wpformatter=0x8001209c
124130

125131
__DBIntrHandler=0x8001c204
126132
DBInitComm=0x8001c228
@@ -544,6 +550,7 @@ OSDefaultExceptionHandler=0x80044d50
544550
__OSPSInit=0x80044db0
545551
__OSGetDIConfig=0x80044e10
546552
OSGetAppGamename=0x80044e30
553+
OSCreateAlarm=0x80044f40
547554
__OSInitAlarm=0x80044ee0
548555
InsertAlarm=0x80044f50
549556
OSSetAlarm=0x800451a0
@@ -3564,6 +3571,12 @@ Free__Q44nw4r3lyt6detail11TexCoordAryFv=0x801a2980
35643571
Reserve__Q44nw4r3lyt6detail11TexCoordAryFUc=0x801a29d0
35653572
SetSize__Q44nw4r3lyt6detail11TexCoordAryFUc=0x801a2a70
35663573
DrawQuad__Q34nw4r3lyt6detailFRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeUcPA4_CQ34nw4r4math4VEC2PCQ34nw4r2ut5Color=0x801a2e60
3574+
UpdateVertexColor__Q34nw4r2ut10CharWriterFv=0x80110640
3575+
__dt__Q34nw4r2ut17TextWriterBase<w>Fv=0x80113480
3576+
__ct__Q34nw4r2ut17TextWriterBase<w>Fv=0x80113420
3577+
Print__Q34nw4r2ut17TextWriterBase<w>FPCwi=0x80114510
3578+
3579+
sInstance__Q23EGG17CoreControllerMgr=0x806f4a08
35673580

35683581
create__Q23EGG7ExpHeapFUlPQ23EGG4HeapUs=0x801c0e58
35693582
alloc__Q23EGG4HeapFUliPQ23EGG4Heap=0x801c1654
@@ -3573,11 +3586,14 @@ getCoreStatus__Q23EGG14CoreControllerCFi=0x801c4380
35733586
getNthController__Q23EGG17CoreControllerMgrFi=0x801c4ab8
35743587
__dt__Q23EGG5SceneFv=0x801c8318
35753588
sCurrentHeap__Q23EGG4Heap=0x806f49b0
3589+
sTVMode__Q23EGG6Screen=0x806f4938
3590+
sTVInfo__Q23EGG6Screen=0x806b4ad8
35763591

35773592
spInstance__11RPSysSystem=0x806f4c68
35783593
spInstance__13RPSysSceneMgr=0x806f4c98
35793594
spInstance__13RPSndAudioMgr=0x806f5088
35803595
spInstance__17RPSysSceneCreator=0x806f4c88
3596+
spInstance__16RPSysFontManager=0x806f4cc8
35813597

35823598
sUnkStruct__10RPSysScene=0x806f4c90
35833599
__ct__10RPSysSceneFv=0x8022fb88
@@ -3614,3 +3630,5 @@ sDrawPass__13RPGrpRenderer=0x806f0bf8
36143630
spInstance__15RPSysTextWriter=0x806f4d08
36153631
Begin__15RPSysTextWriterFv=0x8023bdfc
36163632
mainLoop__11RPSysSystemFv=0x80237b2c
3633+
3634+
sActiveScreen__13RPGrpRenderer=0x807cef2c

include/MSL/algorithm

Lines changed: 177 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace std {
66

77
template <typename T> inline const T& max(const T& a, const T& b) {
8-
return a < b ? b : a;
8+
return (a < b) ? b : a;
99
}
1010

1111
template <typename T> inline const T& min(const T& a, const T& b) {
12-
return b < a ? b : a;
12+
return (b < a) ? b : a;
1313
}
1414

1515
template <typename TPtr, typename T>
@@ -22,32 +22,196 @@ inline TPtr find(TPtr first, TPtr last, const T& value) {
2222
}
2323

2424
template <typename TPtr> inline long distance(TPtr first, TPtr last) {
25-
random_access_iterator_tag tag;
26-
return __distance(first, last, tag);
25+
return __distance(first, last, random_access_iterator_tag());
2726
}
2827

2928
template <typename TPtr>
30-
inline long __distance(TPtr first, TPtr last, random_access_iterator_tag tag) {
31-
long dist = reinterpret_cast<long>(last) - reinterpret_cast<long>(first);
32-
return dist / static_cast<long>(sizeof(TPtr));
29+
inline long __distance(TPtr first, TPtr last, random_access_iterator_tag) {
30+
return static_cast<long>(last - first);
3331
}
3432

35-
#if __option(rvalue_refs)
36-
template <typename T> inline T&& move(T&& x) {
37-
return static_cast<T&&>(x);
38-
}
39-
#else
4033
template <typename T> inline T& move(T& x) {
4134
return x;
4235
}
43-
#endif
4436

4537
template <typename T> inline void swap(T& a, T& b) {
4638
T tmp = move(a);
4739
a = move(b);
4840
b = move(tmp);
4941
}
5042

43+
template <typename TIt, typename TCompare>
44+
inline TIt min_element(TIt first, TIt last, TCompare compare) {
45+
TIt it = first;
46+
47+
if (first != last) {
48+
for (++first; first != last; ++first) {
49+
if (compare(*first, *it)) {
50+
it = first;
51+
}
52+
}
53+
}
54+
55+
return it;
56+
}
57+
58+
template <typename TCompare, typename TIt>
59+
inline void __selection_sort(TIt first, TIt last, TCompare compare) {
60+
if (first == last) {
61+
return;
62+
}
63+
64+
TIt j = last;
65+
for (--j; first != j; ++first) {
66+
TIt i = min_element<TIt, TCompare&>(first, last, compare);
67+
68+
if (i != first) {
69+
swap(*i, *first);
70+
}
71+
}
72+
}
73+
74+
template <typename TCompare, typename TIt>
75+
void __sort132(TIt a1, TIt a2, TIt a3, TCompare compare) DECOMP_DONT_INLINE {
76+
bool b1 = !compare(*a3, *a1);
77+
bool b2 = !compare(*a2, *a3);
78+
79+
if (!b1 || !b2) {
80+
if (!b1 && !b2) {
81+
swap(*a1, *a2);
82+
return;
83+
}
84+
85+
if (compare(*a2, *a1)) {
86+
swap(*a1, *a2);
87+
}
88+
89+
if (b1) {
90+
swap(*a2, *a3);
91+
return;
92+
}
93+
94+
swap(*a1, *a3);
95+
}
96+
}
97+
98+
template <typename TIt, typename TCompare>
99+
void sort(TIt first, TIt last, TCompare compare) {
100+
static const int SHUFFLE_MIN = -4;
101+
static const int SHUFFLE_MAX = 5;
102+
static const int SELECTION_SORT_MIN = 20;
103+
104+
while (true) {
105+
long len = static_cast<long>(last - first);
106+
if (len <= 1) {
107+
return;
108+
}
109+
110+
if (len <= SELECTION_SORT_MIN) {
111+
__selection_sort<TCompare&, TIt>(first, last, compare);
112+
return;
113+
}
114+
115+
static int shuffle = -4;
116+
TIt m = first +
117+
(len / static_cast<long>(sizeof(TIt)) + shuffle % SHUFFLE_MAX);
118+
119+
if (++shuffle >= SHUFFLE_MAX) {
120+
shuffle = SHUFFLE_MIN;
121+
}
122+
123+
TIt i1 = first + (len * static_cast<long>(sizeof(TIt) - 1) /
124+
static_cast<long>(sizeof(TIt)) +
125+
shuffle % SHUFFLE_MAX);
126+
127+
if (++shuffle >= SHUFFLE_MAX) {
128+
shuffle = SHUFFLE_MIN;
129+
}
130+
131+
TIt j = last - 1;
132+
__sort132<TCompare&, TIt>(m, i1, j, compare);
133+
134+
m = first;
135+
i1 = j;
136+
while (compare(*m, *j)) {
137+
m++;
138+
}
139+
140+
do {
141+
i1--;
142+
143+
if (m == i1) {
144+
break;
145+
}
146+
} while (!compare(*i1, *j));
147+
148+
if (m < i1) {
149+
swap(*m, *i1);
150+
m++;
151+
152+
while (true) {
153+
while (compare(*m, *j)) {
154+
m++;
155+
}
156+
157+
while (!compare(*--i1, *j)) {
158+
;
159+
}
160+
161+
if (m < i1) {
162+
swap(*m, *i1);
163+
m++;
164+
} else {
165+
break;
166+
}
167+
}
168+
}
169+
170+
if (m == first) {
171+
swap(*m, *j);
172+
m++;
173+
174+
i1 = last;
175+
if (!compare(*first, *--i1)) {
176+
while (m != last && !compare(*first, *m)) {
177+
m++;
178+
}
179+
180+
if (m < i1) {
181+
swap(*m, *i1);
182+
}
183+
}
184+
185+
if (m < i1) {
186+
while (true) {
187+
while (!compare(*first, *m)) {
188+
m++;
189+
}
190+
191+
while (compare(*first, *--i1)) {
192+
;
193+
}
194+
195+
if (m < i1) {
196+
swap(*m, *i1);
197+
m++;
198+
} else {
199+
break;
200+
}
201+
}
202+
}
203+
204+
first = m;
205+
} else if (m - first < last - m) {
206+
sort<TIt, TCompare&>(first, m, compare);
207+
first = m;
208+
} else {
209+
sort<TIt, TCompare&>(m, last, compare);
210+
last = m;
211+
}
212+
}
213+
}
214+
51215
} // namespace std
52216

53217
#endif

include/MSL/cctype

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#ifdef __cplusplus
55

66
namespace std {
7+
using ::isalpha;
8+
using ::isdigit;
9+
using ::islower;
10+
using ::isupper;
711
using ::tolower;
812
using ::toupper;
913
} // namespace std

include/MSL/cmath

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
#include <math.h>
44
#ifdef __cplusplus
55

6+
// Remove C macro
7+
#undef fabs
8+
69
namespace std {
710
using ::acos;
811
using ::acosf;
912
using ::asin;
1013
using ::atan;
1114
using ::atan2;
15+
using ::atan2f;
1216
using ::ceil;
1317
using ::ceilf;
1418
using ::copysign;
@@ -21,6 +25,7 @@ using ::fmod;
2125
using ::fmodf;
2226
using ::frexp;
2327
using ::ldexp;
28+
using ::ldexpf;
2429
using ::modf;
2530
using ::modff;
2631
using ::nan;
@@ -32,6 +37,20 @@ using ::sqrt;
3237
using ::sqrtf;
3338
using ::tan;
3439
using ::tanf;
40+
41+
inline float sqrt(float x) {
42+
return ::sqrtf(x);
43+
}
44+
45+
// TODO: Very fake!
46+
inline double fabs_wrapper(double x) {
47+
return __fabs(x);
48+
}
49+
50+
inline float fabs(float x) {
51+
return fabs_wrapper(x);
52+
}
53+
3554
} // namespace std
3655

3756
#endif

include/MSL/cstddef

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
#ifdef __cplusplus
55

66
namespace std {
7+
using ::intptr_t;
78
using ::ptrdiff_t;
89
using ::size_t;
10+
using ::uintptr_t;
911
} // namespace std
1012

1113
#endif

include/MSL/cstdlib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ using ::mbstowcs;
1010
using ::mbtowc;
1111
using ::rand;
1212
using ::wcstombs;
13+
using ::strtoul;
1314
} // namespace std
1415

1516
#endif

include/MSL/ctype.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ inline int toupper(int x) {
3131
: (int)(&_current_locale)->cmap->to_upper_table[x];
3232
}
3333

34+
int isdigit(int);
35+
int isalpha(int);
36+
int isupper(int);
37+
int islower(int);
38+
3439
#ifdef __cplusplus
3540
}
3641
#endif

0 commit comments

Comments
 (0)