diff --git a/configure.py b/configure.py index c112a5782..8160fd40b 100644 --- a/configure.py +++ b/configure.py @@ -417,7 +417,7 @@ def MatchingFor(*versions): Object(Matching, "SB/Core/x/xColor.cpp"), Object(Matching, "SB/Core/x/xCounter.cpp"), Object(NonMatching, "SB/Core/x/xCutscene.cpp"), - Object(NonMatching, "SB/Core/x/xDebug.cpp"), + Object(NonMatching, "SB/Core/x/xDebug.cpp", extra_cflags=["-sym on"]), Object(Equivalent, "SB/Core/x/xEnt.cpp", extra_cflags=["-sym on"]), Object(Equivalent, "SB/Core/x/xEntDrive.cpp", extra_cflags=["-sym on"]), Object(NonMatching, "SB/Core/x/xEntMotion.cpp"), diff --git a/src/SB/Core/x/xDebug.cpp b/src/SB/Core/x/xDebug.cpp index 1d0a099b9..416cc1db6 100644 --- a/src/SB/Core/x/xDebug.cpp +++ b/src/SB/Core/x/xDebug.cpp @@ -1,7 +1,4 @@ #include "xDebug.h" -#include "xFont.h" - -#include "iColor.h" #include @@ -14,7 +11,7 @@ void xprintf(const char* msg, ...) // Redacted. :} } -S32 xDebugModeAdd(const char* mode, void(*debugFunc)()) +S32 xDebugModeAdd(const char* mode, void (*debugFunc)()) { // Redacted. :} return -1; @@ -40,17 +37,18 @@ void xDebugTimestampScreen() // Redacted. :} } -void xtextbox::render(bool cache) const +void __deadstripped_xDebug(F32 f, iColor_tag col) { - render(temp_layout(cache), 0, -1); -} + basic_rect r1; + basic_rect r2; + r1 = r2; + r1.contract(f, f, f, f); -F32 NSCREENY(F32 scale) -{ - return (1.0f / 480) * scale; + F32 x = NSCREENX(f); + F32 y = NSCREENY(f); + + xfont font; + font = xfont::create(0, f, f, f, col, r1); + xtextbox textbox = xtextbox::create(font, r1, 0, f, f, f, f); + textbox.render(true); } - -F32 NSCREENX(F32 scale) -{ - return (1.0f / 640) * scale; -} \ No newline at end of file diff --git a/src/SB/Core/x/xDebug.h b/src/SB/Core/x/xDebug.h index c00a0b64a..93e12066a 100644 --- a/src/SB/Core/x/xDebug.h +++ b/src/SB/Core/x/xDebug.h @@ -99,7 +99,5 @@ void xDebugAddTweak(const char*, F32*, F32, F32, const tweak_callback*, void*, U void xDebugRemoveTweak(const char*); void xDebugUpdate(); -F32 NSCREENY(F32 scale); -F32 NSCREENX(F32 scale); #endif diff --git a/src/SB/Core/x/xFont.h b/src/SB/Core/x/xFont.h index 9377e4aba..b43a621df 100644 --- a/src/SB/Core/x/xFont.h +++ b/src/SB/Core/x/xFont.h @@ -21,12 +21,21 @@ struct xfont static void restore_render_state(); static xfont create(); static xfont create(U32 id, F32 width, F32 height, F32 space, iColor_tag color, - const basic_rect& clip); - + const basic_rect& clip) + { + xfont r; + r.id = id; + r.width = width; + r.height = height; + r.space = space; + r.color = color; + r.clip = clip; + + return r; + } basic_rect bounds(char c) const; basic_rect bounds(const char* text) const; - basic_rect bounds(const char* text, size_t text_size, F32 max_width, - size_t& size) const; + basic_rect bounds(const char* text, size_t text_size, F32 max_width, size_t& size) const; void start_render() const; void stop_render() const; void irender(const char* text, F32 x, F32 y) const; @@ -158,43 +167,43 @@ struct xtextbox static callback text_cb; xtextbox& operator=(const xtextbox& rhs) - { - this->font.id = rhs.font.id; + { + this->font.id = rhs.font.id; - *(S32*)(&this->font.width) = *(S32*)(&rhs.font.width); - *(S32*)(&this->font.height) = *(S32*)(&rhs.font.height); - *(S32*)(&this->font.space) = *(S32*)(&rhs.font.space); + *(S32*)(&this->font.width) = *(S32*)(&rhs.font.width); + *(S32*)(&this->font.height) = *(S32*)(&rhs.font.height); + *(S32*)(&this->font.space) = *(S32*)(&rhs.font.space); - *(S32*)(&this->font.color) = *(S32*)(&rhs.font.color); + *(S32*)(&this->font.color) = *(S32*)(&rhs.font.color); - *(S32*)(&this->font.clip.x) = *(S32*)(&rhs.font.clip.x); - *(S32*)(&this->font.clip.y) = *(S32*)(&rhs.font.clip.y); - *(S32*)(&this->font.clip.w) = *(S32*)(&rhs.font.clip.w); - *(S32*)(&this->font.clip.h) = *(S32*)(&rhs.font.clip.h); + *(S32*)(&this->font.clip.x) = *(S32*)(&rhs.font.clip.x); + *(S32*)(&this->font.clip.y) = *(S32*)(&rhs.font.clip.y); + *(S32*)(&this->font.clip.w) = *(S32*)(&rhs.font.clip.w); + *(S32*)(&this->font.clip.h) = *(S32*)(&rhs.font.clip.h); - *(S32*)(&this->bounds.x) = *(S32*)(&rhs.bounds.x); - *(S32*)(&this->bounds.y) = *(S32*)(&rhs.bounds.y); - *(S32*)(&this->bounds.w) = *(S32*)(&rhs.bounds.w); - *(S32*)(&this->bounds.h) = *(S32*)(&rhs.bounds.h); + *(S32*)(&this->bounds.x) = *(S32*)(&rhs.bounds.x); + *(S32*)(&this->bounds.y) = *(S32*)(&rhs.bounds.y); + *(S32*)(&this->bounds.w) = *(S32*)(&rhs.bounds.w); + *(S32*)(&this->bounds.h) = *(S32*)(&rhs.bounds.h); - this->flags = rhs.flags; + this->flags = rhs.flags; - this->line_space = rhs.line_space; - this->tab_stop = rhs.tab_stop; - this->left_indent = rhs.left_indent; - this->right_indent = rhs.right_indent; + this->line_space = rhs.line_space; + this->tab_stop = rhs.tab_stop; + this->left_indent = rhs.left_indent; + this->right_indent = rhs.right_indent; - this->cb = rhs.cb; - this->context = rhs.context; - this->texts = rhs.texts; - this->text_sizes = rhs.text_sizes; - this->texts_size = rhs.texts_size; - this->text.text = rhs.text.text; - this->text.size = rhs.text.size; - this->text_hash = rhs.text_hash; + this->cb = rhs.cb; + this->context = rhs.context; + this->texts = rhs.texts; + this->text_sizes = rhs.text_sizes; + this->texts_size = rhs.texts_size; + this->text.text = rhs.text.text; + this->text.size = rhs.text.size; + this->text_hash = rhs.text_hash; - return *this; - } + return *this; + } static void text_render(const jot& j, const xtextbox& tb, F32 x, F32 y); static tag_entry_list read_tag(const substr& s); @@ -207,20 +216,36 @@ struct xtextbox static tag_type* find_format_tag(const substr& s, S32& index); static xtextbox create(); static xtextbox create(const xfont& font, const basic_rect& bounds, U32 flags, - F32 line_space, F32 tab_stop, F32 left_indent, - F32 right_indent); + F32 line_space, F32 tab_stop, F32 left_indent, F32 right_indent) + { + xtextbox r; + r.font = font; + r.bounds = bounds; + r.flags = flags; + r.line_space = line_space; + r.tab_stop = tab_stop; + r.left_indent = left_indent; + r.right_indent = right_indent; + r.texts_size = 0; + r.text_hash = 0; + r.cb = &text_cb; + + return r; + } void set_text(const char* text); void set_text(const char* text, size_t text_size); void set_text(const char** texts, size_t size); void set_text(const char** texts, const size_t* text_sizes, size_t size); layout& temp_layout(bool cache) const; - void render(bool cache) const; + void render(bool cache) const + { + render(temp_layout(cache), 0, -1); + } void render(layout& l, S32 begin_jot, S32 end_jot) const; F32 yextent(bool cache) const; F32 yextent(F32 max, S32& size, bool cache) const; - F32 yextent(F32 max, S32& size, const layout& l, S32 begin_jot, - S32 end_jot) const; + F32 yextent(F32 max, S32& size, const layout& l, S32 begin_jot, S32 end_jot) const; }; struct xtextbox::layout @@ -253,7 +278,14 @@ struct xtextbox::layout void render_fill_rect(const basic_rect& bounds, iColor_tag color); -F32 NSCREENX(F32); -F32 NSCREENY(F32); +inline F32 NSCREENX(F32 scale) +{ + return (1.0f / 640) * scale; +} + +inline F32 NSCREENY(F32 scale) +{ + return (1.0f / 480) * scale; +} #endif diff --git a/src/SB/Core/x/xMath2.h b/src/SB/Core/x/xMath2.h index 905dd653d..33b1d9f16 100644 --- a/src/SB/Core/x/xMath2.h +++ b/src/SB/Core/x/xMath2.h @@ -15,9 +15,19 @@ template struct basic_rect basic_rect& assign(T x, T y, T w, T h); basic_rect& contract(T s); - basic_rect& contract(T x, T y, T w, T h); + basic_rect& contract(T x, T y, T w, T h) + { + return expand(-x, -y, -w, -h); + } basic_rect& expand(T s); - basic_rect& expand(T x, T y, T w, T h); + basic_rect& expand(T x, T y, T w, T h) + { + this->x -= x; + this->w += x + w; + this->y -= y; + this->h += y + h; + return *this; + } basic_rect& move(T x, T y); basic_rect& scale(T s); basic_rect& scale(T x, T y); @@ -40,7 +50,7 @@ struct xVec2 xVec2& assign(F32 xy) { - return assign(xy,xy); + return assign(xy, xy); } xVec2& assign(F32 x, F32 y); F32 length() const;