Skip to content

Commit 357a56b

Browse files
authored
Match xDebug (#657)
* Match xDebug * remove test iColor.h object from configure.py * Set xDebug back to NonMatching
1 parent 75928a6 commit 357a56b

File tree

5 files changed

+99
-61
lines changed

5 files changed

+99
-61
lines changed

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def MatchingFor(*versions):
417417
Object(Matching, "SB/Core/x/xColor.cpp"),
418418
Object(Matching, "SB/Core/x/xCounter.cpp"),
419419
Object(NonMatching, "SB/Core/x/xCutscene.cpp"),
420-
Object(NonMatching, "SB/Core/x/xDebug.cpp"),
420+
Object(NonMatching, "SB/Core/x/xDebug.cpp", extra_cflags=["-sym on"]),
421421
Object(Equivalent, "SB/Core/x/xEnt.cpp", extra_cflags=["-sym on"]),
422422
Object(Equivalent, "SB/Core/x/xEntDrive.cpp", extra_cflags=["-sym on"]),
423423
Object(NonMatching, "SB/Core/x/xEntMotion.cpp"),

src/SB/Core/x/xDebug.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#include "xDebug.h"
2-
#include "xFont.h"
3-
4-
#include "iColor.h"
52

63
#include <types.h>
74

@@ -14,7 +11,7 @@ void xprintf(const char* msg, ...)
1411
// Redacted. :}
1512
}
1613

17-
S32 xDebugModeAdd(const char* mode, void(*debugFunc)())
14+
S32 xDebugModeAdd(const char* mode, void (*debugFunc)())
1815
{
1916
// Redacted. :}
2017
return -1;
@@ -40,17 +37,18 @@ void xDebugTimestampScreen()
4037
// Redacted. :}
4138
}
4239

43-
void xtextbox::render(bool cache) const
40+
void __deadstripped_xDebug(F32 f, iColor_tag col)
4441
{
45-
render(temp_layout(cache), 0, -1);
46-
}
42+
basic_rect<F32> r1;
43+
basic_rect<F32> r2;
44+
r1 = r2;
45+
r1.contract(f, f, f, f);
4746

48-
F32 NSCREENY(F32 scale)
49-
{
50-
return (1.0f / 480) * scale;
47+
F32 x = NSCREENX(f);
48+
F32 y = NSCREENY(f);
49+
50+
xfont font;
51+
font = xfont::create(0, f, f, f, col, r1);
52+
xtextbox textbox = xtextbox::create(font, r1, 0, f, f, f, f);
53+
textbox.render(true);
5154
}
52-
53-
F32 NSCREENX(F32 scale)
54-
{
55-
return (1.0f / 640) * scale;
56-
}

src/SB/Core/x/xDebug.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,5 @@ void xDebugAddTweak(const char*, F32*, F32, F32, const tweak_callback*, void*, U
9999
void xDebugRemoveTweak(const char*);
100100
void xDebugUpdate();
101101

102-
F32 NSCREENY(F32 scale);
103-
F32 NSCREENX(F32 scale);
104102

105103
#endif

src/SB/Core/x/xFont.h

Lines changed: 72 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,21 @@ struct xfont
2121
static void restore_render_state();
2222
static xfont create();
2323
static xfont create(U32 id, F32 width, F32 height, F32 space, iColor_tag color,
24-
const basic_rect<F32>& clip);
25-
24+
const basic_rect<F32>& clip)
25+
{
26+
xfont r;
27+
r.id = id;
28+
r.width = width;
29+
r.height = height;
30+
r.space = space;
31+
r.color = color;
32+
r.clip = clip;
33+
34+
return r;
35+
}
2636
basic_rect<F32> bounds(char c) const;
2737
basic_rect<F32> bounds(const char* text) const;
28-
basic_rect<F32> bounds(const char* text, size_t text_size, F32 max_width,
29-
size_t& size) const;
38+
basic_rect<F32> bounds(const char* text, size_t text_size, F32 max_width, size_t& size) const;
3039
void start_render() const;
3140
void stop_render() const;
3241
void irender(const char* text, F32 x, F32 y) const;
@@ -158,43 +167,43 @@ struct xtextbox
158167
static callback text_cb;
159168

160169
xtextbox& operator=(const xtextbox& rhs)
161-
{
162-
this->font.id = rhs.font.id;
170+
{
171+
this->font.id = rhs.font.id;
163172

164-
*(S32*)(&this->font.width) = *(S32*)(&rhs.font.width);
165-
*(S32*)(&this->font.height) = *(S32*)(&rhs.font.height);
166-
*(S32*)(&this->font.space) = *(S32*)(&rhs.font.space);
173+
*(S32*)(&this->font.width) = *(S32*)(&rhs.font.width);
174+
*(S32*)(&this->font.height) = *(S32*)(&rhs.font.height);
175+
*(S32*)(&this->font.space) = *(S32*)(&rhs.font.space);
167176

168-
*(S32*)(&this->font.color) = *(S32*)(&rhs.font.color);
177+
*(S32*)(&this->font.color) = *(S32*)(&rhs.font.color);
169178

170-
*(S32*)(&this->font.clip.x) = *(S32*)(&rhs.font.clip.x);
171-
*(S32*)(&this->font.clip.y) = *(S32*)(&rhs.font.clip.y);
172-
*(S32*)(&this->font.clip.w) = *(S32*)(&rhs.font.clip.w);
173-
*(S32*)(&this->font.clip.h) = *(S32*)(&rhs.font.clip.h);
179+
*(S32*)(&this->font.clip.x) = *(S32*)(&rhs.font.clip.x);
180+
*(S32*)(&this->font.clip.y) = *(S32*)(&rhs.font.clip.y);
181+
*(S32*)(&this->font.clip.w) = *(S32*)(&rhs.font.clip.w);
182+
*(S32*)(&this->font.clip.h) = *(S32*)(&rhs.font.clip.h);
174183

175-
*(S32*)(&this->bounds.x) = *(S32*)(&rhs.bounds.x);
176-
*(S32*)(&this->bounds.y) = *(S32*)(&rhs.bounds.y);
177-
*(S32*)(&this->bounds.w) = *(S32*)(&rhs.bounds.w);
178-
*(S32*)(&this->bounds.h) = *(S32*)(&rhs.bounds.h);
184+
*(S32*)(&this->bounds.x) = *(S32*)(&rhs.bounds.x);
185+
*(S32*)(&this->bounds.y) = *(S32*)(&rhs.bounds.y);
186+
*(S32*)(&this->bounds.w) = *(S32*)(&rhs.bounds.w);
187+
*(S32*)(&this->bounds.h) = *(S32*)(&rhs.bounds.h);
179188

180-
this->flags = rhs.flags;
189+
this->flags = rhs.flags;
181190

182-
this->line_space = rhs.line_space;
183-
this->tab_stop = rhs.tab_stop;
184-
this->left_indent = rhs.left_indent;
185-
this->right_indent = rhs.right_indent;
191+
this->line_space = rhs.line_space;
192+
this->tab_stop = rhs.tab_stop;
193+
this->left_indent = rhs.left_indent;
194+
this->right_indent = rhs.right_indent;
186195

187-
this->cb = rhs.cb;
188-
this->context = rhs.context;
189-
this->texts = rhs.texts;
190-
this->text_sizes = rhs.text_sizes;
191-
this->texts_size = rhs.texts_size;
192-
this->text.text = rhs.text.text;
193-
this->text.size = rhs.text.size;
194-
this->text_hash = rhs.text_hash;
196+
this->cb = rhs.cb;
197+
this->context = rhs.context;
198+
this->texts = rhs.texts;
199+
this->text_sizes = rhs.text_sizes;
200+
this->texts_size = rhs.texts_size;
201+
this->text.text = rhs.text.text;
202+
this->text.size = rhs.text.size;
203+
this->text_hash = rhs.text_hash;
195204

196-
return *this;
197-
}
205+
return *this;
206+
}
198207

199208
static void text_render(const jot& j, const xtextbox& tb, F32 x, F32 y);
200209
static tag_entry_list read_tag(const substr& s);
@@ -207,20 +216,36 @@ struct xtextbox
207216
static tag_type* find_format_tag(const substr& s, S32& index);
208217
static xtextbox create();
209218
static xtextbox create(const xfont& font, const basic_rect<F32>& bounds, U32 flags,
210-
F32 line_space, F32 tab_stop, F32 left_indent,
211-
F32 right_indent);
219+
F32 line_space, F32 tab_stop, F32 left_indent, F32 right_indent)
220+
{
221+
xtextbox r;
222+
r.font = font;
223+
r.bounds = bounds;
224+
r.flags = flags;
225+
r.line_space = line_space;
226+
r.tab_stop = tab_stop;
227+
r.left_indent = left_indent;
228+
r.right_indent = right_indent;
229+
r.texts_size = 0;
230+
r.text_hash = 0;
231+
r.cb = &text_cb;
232+
233+
return r;
234+
}
212235

213236
void set_text(const char* text);
214237
void set_text(const char* text, size_t text_size);
215238
void set_text(const char** texts, size_t size);
216239
void set_text(const char** texts, const size_t* text_sizes, size_t size);
217240
layout& temp_layout(bool cache) const;
218-
void render(bool cache) const;
241+
void render(bool cache) const
242+
{
243+
render(temp_layout(cache), 0, -1);
244+
}
219245
void render(layout& l, S32 begin_jot, S32 end_jot) const;
220246
F32 yextent(bool cache) const;
221247
F32 yextent(F32 max, S32& size, bool cache) const;
222-
F32 yextent(F32 max, S32& size, const layout& l, S32 begin_jot,
223-
S32 end_jot) const;
248+
F32 yextent(F32 max, S32& size, const layout& l, S32 begin_jot, S32 end_jot) const;
224249
};
225250

226251
struct xtextbox::layout
@@ -253,7 +278,14 @@ struct xtextbox::layout
253278

254279
void render_fill_rect(const basic_rect<F32>& bounds, iColor_tag color);
255280

256-
F32 NSCREENX(F32);
257-
F32 NSCREENY(F32);
281+
inline F32 NSCREENX(F32 scale)
282+
{
283+
return (1.0f / 640) * scale;
284+
}
285+
286+
inline F32 NSCREENY(F32 scale)
287+
{
288+
return (1.0f / 480) * scale;
289+
}
258290

259291
#endif

src/SB/Core/x/xMath2.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@ template <class T> struct basic_rect
1515

1616
basic_rect& assign(T x, T y, T w, T h);
1717
basic_rect& contract(T s);
18-
basic_rect& contract(T x, T y, T w, T h);
18+
basic_rect& contract(T x, T y, T w, T h)
19+
{
20+
return expand(-x, -y, -w, -h);
21+
}
1922
basic_rect& expand(T s);
20-
basic_rect& expand(T x, T y, T w, T h);
23+
basic_rect& expand(T x, T y, T w, T h)
24+
{
25+
this->x -= x;
26+
this->w += x + w;
27+
this->y -= y;
28+
this->h += y + h;
29+
return *this;
30+
}
2131
basic_rect& move(T x, T y);
2232
basic_rect& scale(T s);
2333
basic_rect& scale(T x, T y);
@@ -40,7 +50,7 @@ struct xVec2
4050

4151
xVec2& assign(F32 xy)
4252
{
43-
return assign(xy,xy);
53+
return assign(xy, xy);
4454
}
4555
xVec2& assign(F32 x, F32 y);
4656
F32 length() const;

0 commit comments

Comments
 (0)