diff --git a/src/CRE/Glitter/effect.cpp b/src/CRE/Glitter/effect.cpp index 48a903d4..4daf8e97 100644 --- a/src/CRE/Glitter/effect.cpp +++ b/src/CRE/Glitter/effect.cpp @@ -17,7 +17,7 @@ namespace Glitter { Effect::Data::Data(GLT) : appear_time(), life_time(), start_time(), ext_anim(), flags(), emission(), seed() { - color = { 0xFF, 0xFF, 0xFF, 0xFF }; + color = 0xFFFFFFFF; name_hash = GLT_VAL != Glitter::FT ? hash_murmurhash_empty : hash_fnv1a64m_empty; ext_anim_is_x = GLT_VAL == Glitter::X; diff --git a/src/CRE/Glitter/glitter.hpp b/src/CRE/Glitter/glitter.hpp index 6cca70bd..a61745d6 100644 --- a/src/CRE/Glitter/glitter.hpp +++ b/src/CRE/Glitter/glitter.hpp @@ -17,6 +17,7 @@ #include "../../KKdLib/txp.hpp" #include "../../KKdLib/vec.hpp" #include "../GL/uniform_buffer.hpp" +#include "../color.hpp" #include "../file_handler.hpp" #include "../frame_rate_control.hpp" #include "../static_var.hpp" @@ -651,7 +652,7 @@ namespace Glitter { int32_t appear_time; int32_t life_time; int32_t start_time; - vec4u8 color; + color4u8 color; bool ext_anim_is_x; union { Effect::ExtAnim * ext_anim; diff --git a/src/CRE/Glitter/render_group.cpp b/src/CRE/Glitter/render_group.cpp index af3469f1..d10966aa 100644 --- a/src/CRE/Glitter/render_group.cpp +++ b/src/CRE/Glitter/render_group.cpp @@ -234,7 +234,7 @@ namespace Glitter { particle->StepUVParticle(GLT_VAL, rend_elem, delta_frame, random_ptr); rend_elem->disp = true; - rend_elem->color = { -1.0f, -1.0f, -1.0f, -1.0f }; + rend_elem->color = -1.0f; bool disp = true; if (particle->data.data.sub_flags & PARTICLE_SUB_USE_CURVE) @@ -597,7 +597,7 @@ namespace Glitter { particle->StepUVParticle(rend_elem, delta_frame, random_ptr); rend_elem->disp = true; - rend_elem->color = { -1.0f, -1.0f, -1.0f, -1.0f }; + rend_elem->color = -1.0f; bool disp = true; float_t color_scale = -1.0f; diff --git a/src/CRE/auth_2d.cpp b/src/CRE/auth_2d.cpp index cf8af2fe..a89554f1 100644 --- a/src/CRE/auth_2d.cpp +++ b/src/CRE/auth_2d.cpp @@ -272,7 +272,7 @@ void AetComp::put_number_sprite(int32_t value, int32_t max_digits, aet_layout_data::aet_layout_data() : width(), height() { mat = mat4_identity; opacity = 1.0f; - color = { 0xFF, 0xFF, 0xFF, 0xFF }; + color = 0xFFFFFFFF; mode = RESOLUTION_MODE_HD; } @@ -1001,7 +1001,7 @@ void AetObj::DispSprite(const mat4& mat, const aet_layer* layer, args.index = index; args.layer = layer_index; args.prio = prio; - vec4_to_vec4u8(color * 255.0f, args.color); + args.color = color; args.resolution_mode_screen = dst_mode; args.resolution_mode_sprite = dst_mode; if (flags & AET_FLIP_H) @@ -1047,7 +1047,7 @@ void AetObj::DispSpriteSource(const mat4& mat, const aet_layer* layer, args.index = index; args.layer = layer_index; args.prio = prio; - vec4_to_vec4u8(color * 255.0f, args.color); + args.color = color; args.resolution_mode_screen = dst_mode; args.resolution_mode_sprite = dst_mode; if (flags & AET_FLIP_H) @@ -1088,7 +1088,7 @@ void AetObj::DispSpriteSource(const mat4& mat, const aet_layer* layer, vec4 _color = this->color; _color.w = opacity * _color.w * this->opacity; - vec4_to_vec4u8(_color * 255.0f, spr_args.color); + spr_args.color = _color; spr::SprArgs* v52 = spr::put_sprite(spr_args, spr_db); spr::SprArgs* v53 = spr::put_sprite(args, spr_db); @@ -1221,9 +1221,9 @@ void AetLyo::DispLayer(const mat4& mat, const aet_layer* layer, const aet_video* video = layer->item.video; data.width = (float_t)video->width; data.height = (float_t)video->height; - data.color.x = video->color[0]; - data.color.y = video->color[1]; - data.color.z = video->color[2];; + data.color.r = video->color[0]; + data.color.g = video->color[1]; + data.color.b = video->color[2];; data.opacity = opacity; data.mode = dst_mode; comp->Add(layer->name, data); diff --git a/src/CRE/auth_2d.hpp b/src/CRE/auth_2d.hpp index 3e1e2ab7..f747a53f 100644 --- a/src/CRE/auth_2d.hpp +++ b/src/CRE/auth_2d.hpp @@ -8,6 +8,7 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/database/aet.hpp" #include "../KKdLib/vec.hpp" +#include "color.hpp" #include "frame_rate_control.hpp" #include "sprite.hpp" @@ -76,7 +77,7 @@ struct aet_layout_data { float_t width; float_t height; float_t opacity; - vec4u8 color; + color4u8 color; resolution_mode mode; aet_layout_data(); diff --git a/src/CRE/clear_color.cpp b/src/CRE/clear_color.cpp index 742129a5..7f5b8145 100644 --- a/src/CRE/clear_color.cpp +++ b/src/CRE/clear_color.cpp @@ -5,15 +5,13 @@ #include "clear_color.hpp" -vec4u8 clear_color; +color4u8 clear_color; bool set_clear_color; vec4 get_clear_color() { if (!set_clear_color) return 0.0f; - vec4 _clear_color; - vec4u8_to_vec4(clear_color, _clear_color); - return _clear_color * (float_t)(1.0 / 255.0); + return clear_color; } diff --git a/src/CRE/clear_color.hpp b/src/CRE/clear_color.hpp index 6f290c40..a2de72c9 100644 --- a/src/CRE/clear_color.hpp +++ b/src/CRE/clear_color.hpp @@ -7,8 +7,9 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/vec.hpp" +#include "color.hpp" -extern vec4u8 clear_color; +extern color4u8 clear_color; extern bool set_clear_color; extern vec4 get_clear_color(); diff --git a/src/CRE/color.cpp b/src/CRE/color.cpp new file mode 100644 index 00000000..84c73179 --- /dev/null +++ b/src/CRE/color.cpp @@ -0,0 +1,22 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "color.hpp" + +const color4u8 color_black = 0xFF000000; +const color4u8 color_grey = 0xFF7F7F7F; +const color4u8 color_white = 0xFFFFFFFF; +const color4u8 color_red = 0xFF0000FF; +const color4u8 color_green = 0xFF00FF00; +const color4u8 color_blue = 0xFFFF0000; +const color4u8 color_cyan = 0xFFFFFF00; +const color4u8 color_magenta = 0xFFFF00FF; +const color4u8 color_yellow = 0xFF00FFFF; +const color4u8 color_dark_red = 0xFF00007F; +const color4u8 color_dark_green = 0xFF007F00; +const color4u8 color_dark_blue = 0xFF7F0000; +const color4u8 color_dark_cyan = 0xFF7F7F00; +const color4u8 color_dark_magenta = 0xFF7F007F; +const color4u8 color_dark_yellow = 0xFF007F7F; diff --git a/src/CRE/color.hpp b/src/CRE/color.hpp new file mode 100644 index 00000000..b1b7fa25 --- /dev/null +++ b/src/CRE/color.hpp @@ -0,0 +1,59 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../KKdLib/default.hpp" +#include "../KKdLib/vec.hpp" + +struct color4u8 { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + + inline color4u8() : r(), g(), b(), a() { + + } + + inline color4u8(uint8_t x, uint8_t y, uint8_t z, uint8_t w) : r(x), g(y), b(z), a(w) { + + } + + inline color4u8(uint32_t value) { + r = (uint8_t)(value & 0xFF); + g = (uint8_t)((value >> 8) & 0xFF); + b = (uint8_t)((value >> 16) & 0xFF); + a = (uint8_t)((value >> 24) & 0xFF); + } + + inline color4u8(vec4 value) { + vec4i _value = vec4i::store_xmm(_mm_cvtps_epi32(vec4::load_xmm(vec4::clamp(value, 0.0f, 1.0f) * 255.0f))); + r = (uint8_t)_value.x; + g = (uint8_t)_value.y; + b = (uint8_t)_value.z; + a = (uint8_t)_value.w; + } + + inline operator vec4() const { + return vec4::store_xmm(_mm_cvtepi32_ps(vec4i::load_xmm(vec4i(r, g, b, a)))) * (1.0f / 255.0f); + } +}; + +extern const color4u8 color_black; +extern const color4u8 color_grey; +extern const color4u8 color_white; +extern const color4u8 color_red; +extern const color4u8 color_green; +extern const color4u8 color_blue; +extern const color4u8 color_cyan; +extern const color4u8 color_magenta; +extern const color4u8 color_yellow; +extern const color4u8 color_dark_red; +extern const color4u8 color_dark_green; +extern const color4u8 color_dark_blue; +extern const color4u8 color_dark_cyan; +extern const color4u8 color_dark_magenta; +extern const color4u8 color_dark_yellow; diff --git a/src/CRE/draw_object.cpp b/src/CRE/draw_object.cpp index 8f6835ff..bcb218e4 100644 --- a/src/CRE/draw_object.cpp +++ b/src/CRE/draw_object.cpp @@ -93,9 +93,7 @@ namespace mdl { vec4 g_material_state_emission = rctx->obj_batch.g_material_state_emission; vec4 g_material_state_shininess = rctx->obj_batch.g_material_state_shininess; - vec4 color; - vec4u8_to_vec4(etc->color, color); - color *= (float_t)(1.0 / 255.0); + vec4 color = etc->color; vec4 ambient; *(vec3*)&ambient = *(vec3*)&color * 0.5f; diff --git a/src/CRE/render_context.cpp b/src/CRE/render_context.cpp index a68e3f78..2a3c2e16 100644 --- a/src/CRE/render_context.cpp +++ b/src/CRE/render_context.cpp @@ -226,7 +226,7 @@ namespace mdl { void EtcObj::init(EtcObjType type) { this->type = type; - color = { 0xFF, 0xFF, 0xFF, 0xFF }; + color = 0xFFFFFFFF; //fog = false; constant = false; switch (type) { @@ -2699,7 +2699,7 @@ namespace mdl { return; data->init_etc(this, mat, etc); - if (etc->color.w == 0xFF) { + if (etc->color.a == 0xFF) { if ((obj_flags & OBJ_SHADOW) != 0) mdl::DispManager::entry_list((mdl::ObjType)(OBJ_TYPE_SHADOW_CHARA + shadow_type), data); mdl::DispManager::entry_list(OBJ_TYPE_OPAQUE, data); diff --git a/src/CRE/render_context.hpp b/src/CRE/render_context.hpp index c13c7f85..507fd869 100644 --- a/src/CRE/render_context.hpp +++ b/src/CRE/render_context.hpp @@ -15,6 +15,7 @@ #include "light_param/wind.hpp" #include "light_param.hpp" #include "camera.hpp" +#include "color.hpp" #include "gl_state.hpp" #include "light_param.hpp" #include "object.hpp" @@ -393,7 +394,7 @@ namespace mdl { }; EtcObjType type; - vec4u8 color; + color4u8 color; //bool fog; bool constant; // Added Data data; diff --git a/src/CRE/sprite.cpp b/src/CRE/sprite.cpp index a3f13e71..192ac1f7 100644 --- a/src/CRE/sprite.cpp +++ b/src/CRE/sprite.cpp @@ -52,7 +52,7 @@ public: struct sprite_draw_vertex { vec3 pos; vec2 uv[2]; - vec4u8 color; + color4u8 color; }; struct sprite_draw_param { @@ -204,7 +204,7 @@ namespace spr { void SprArgs::Reset() { kind = SPR_KIND_NORMAL; id = {}; - color = { 0xFF, 0xFF, 0xFF, 0xFF }; + color = 0xFFFFFFFF; attr = (SprAttr)0; blend = 0; index = -1; @@ -290,7 +290,7 @@ namespace spr { return sc_vec; } - void put_cross(const mat4& mat, vec4u8 color_x, vec4u8 color_y, vec4u8 color_z) { + void put_cross(const mat4& mat, color4u8 color_x, color4u8 color_y, color4u8 color_z) { vec3 v5 = { 0.0f, 0.0f, 0.0f }; vec3 v6; mat4_mult_vec3_trans(&mat, &v5, &v6); @@ -318,13 +318,13 @@ namespace spr { return sprite_manager->PutSprite(args, spr_db); } - void put_sprite_3d_line(vec3 p1, vec3 p2, vec4u8 color) { + void put_sprite_3d_line(vec3 p1, vec3 p2, color4u8 color) { vec2 sc_p1 = proj_sprite_3d_line(p1, true); vec2 sc_p2 = proj_sprite_3d_line(p2, true); spr::put_sprite_line(sc_p1, sc_p2, RESOLUTION_MODE_MAX, SPR_PRIO_DEBUG, color, 0); } - void put_sprite_line(vec2 p1, vec2 p2, resolution_mode mode, spr::SprPrio prio, vec4u8 color, int32_t layer) { + void put_sprite_line(vec2 p1, vec2 p2, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer) { spr::SprArgs args; args.trans.x = p1.x; args.trans.y = p1.y; @@ -340,7 +340,7 @@ namespace spr { sprite_manager->PutSprite(args, 0); } - void put_sprite_multi(rectangle rect, resolution_mode mode, spr::SprPrio prio, vec4u8 color, int32_t layer) { + void put_sprite_multi(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer) { spr::SprArgs args; args.trans.x = rect.pos.x; args.trans.y = rect.pos.y; @@ -356,7 +356,7 @@ namespace spr { sprite_manager->PutSprite(args, 0); } - void put_sprite_rect(rectangle rect, resolution_mode mode, spr::SprPrio prio, vec4u8 color, int32_t layer) { + void put_sprite_rect(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer) { spr::SprArgs args; args.trans.x = rect.pos.x; args.trans.y = rect.pos.y; @@ -1204,7 +1204,7 @@ namespace spr { if (args.kind == SPR_KIND_LINE) return; - const vec4u8 color = args.color; + const color4u8 color = args.color; if (font) draw_sprite_scale(&args); diff --git a/src/CRE/sprite.hpp b/src/CRE/sprite.hpp index 9ea21fd7..f387bb54 100644 --- a/src/CRE/sprite.hpp +++ b/src/CRE/sprite.hpp @@ -11,6 +11,7 @@ #include "../KKdLib/database/sprite.hpp" #include "../KKdLib/mat.hpp" #include "../KKdLib/vec.hpp" +#include "color.hpp" #include "render_context.hpp" #include "resolution_mode.hpp" #include "texture.hpp" @@ -144,7 +145,7 @@ namespace spr { struct SpriteVertex { vec3 pos; vec2 uv; - vec4u8 color; + color4u8 color; }; struct SprArgs { @@ -167,7 +168,7 @@ namespace spr { SprKind kind; IDUnion id; - vec4u8 color; + color4u8 color; SprAttr attr; int32_t blend; int32_t index; @@ -204,13 +205,13 @@ namespace spr { vec2 proj_sprite_3d_line(vec3 vec, bool offset); - void put_cross(const mat4& mat, vec4u8 color_x, vec4u8 color_y, vec4u8 color_z); + void put_cross(const mat4& mat, color4u8 color_x, color4u8 color_y, color4u8 color_z); void put_rgb_cross(const mat4& mat); spr::SprArgs* put_sprite(const spr::SprArgs& args, const sprite_database* spr_db); - void put_sprite_3d_line(vec3 p1, vec3 p2, vec4u8 color); - void put_sprite_line(vec2 p1, vec2 p2, resolution_mode mode, spr::SprPrio prio, vec4u8 color, int32_t layer); - void put_sprite_multi(rectangle rect, resolution_mode mode, spr::SprPrio prio, vec4u8 color, int32_t layer); - void put_sprite_rect(rectangle rect, resolution_mode mode, spr::SprPrio prio, vec4u8 color, int32_t layer); + void put_sprite_3d_line(vec3 p1, vec3 p2, color4u8 color); + void put_sprite_line(vec2 p1, vec2 p2, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer); + void put_sprite_multi(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer); + void put_sprite_rect(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer); void put_sprite_triangles(SpriteVertex* vert, size_t num, resolution_mode mode, SprPrio prio, int32_t spr_id, int32_t layer, const sprite_database* spr_db); } diff --git a/src/CRE/static_var.cpp b/src/CRE/static_var.cpp index 306b4247..5690a15a 100644 --- a/src/CRE/static_var.cpp +++ b/src/CRE/static_var.cpp @@ -42,22 +42,6 @@ const mat3 sv_ypbpr_to_rgb = { { 1.57480f, -0.46812f, 0.00000f }, }; -const vec4u8 color_black = { 0x00, 0x00, 0x00, 0xFF }; -const vec4u8 color_grey = { 0x7F, 0x7F, 0x7F, 0xFF }; -const vec4u8 color_white = { 0xFF, 0xFF, 0xFF, 0xFF }; -const vec4u8 color_red = { 0xFF, 0x00, 0x00, 0xFF }; -const vec4u8 color_green = { 0x00, 0xFF, 0x00, 0xFF }; -const vec4u8 color_blue = { 0x00, 0x00, 0xFF, 0xFF }; -const vec4u8 color_cyan = { 0x00, 0xFF, 0xFF, 0xFF }; -const vec4u8 color_magenta = { 0xFF, 0x00, 0xFF, 0xFF }; -const vec4u8 color_yellow = { 0xFF, 0xFF, 0x00, 0xFF }; -const vec4u8 color_dark_red = { 0x7F, 0x00, 0x00, 0xFF }; -const vec4u8 color_dark_green = { 0x00, 0x7F, 0x00, 0xFF }; -const vec4u8 color_dark_blue = { 0x00, 0x00, 0x7F, 0xFF }; -const vec4u8 color_dark_cyan = { 0x00, 0x7F, 0x7F, 0xFF }; -const vec4u8 color_dark_magenta = { 0x7F, 0x00, 0x7F, 0xFF }; -const vec4u8 color_dark_yellow = { 0x7F, 0x7F, 0x00, 0xFF }; - void sv_anisotropy_set(int32_t value) { sv_anisotropy = 1 << (int32_t)roundf(log2f((float_t)clamp_def(value, 1, sv_max_texture_max_anisotropy))); if (sv_anisotropy != sv_old_anisotropy) diff --git a/src/CRE/static_var.hpp b/src/CRE/static_var.hpp index dbbdfcde..23b1cb52 100644 --- a/src/CRE/static_var.hpp +++ b/src/CRE/static_var.hpp @@ -109,22 +109,6 @@ extern const vec3 sv_rgb_to_luma; extern const mat3 sv_rgb_to_ypbpr; extern const mat3 sv_ypbpr_to_rgb; -extern const vec4u8 color_black; -extern const vec4u8 color_grey; -extern const vec4u8 color_white; -extern const vec4u8 color_red; -extern const vec4u8 color_green; -extern const vec4u8 color_blue; -extern const vec4u8 color_cyan; -extern const vec4u8 color_magenta; -extern const vec4u8 color_yellow; -extern const vec4u8 color_dark_red; -extern const vec4u8 color_dark_green; -extern const vec4u8 color_dark_blue; -extern const vec4u8 color_dark_cyan; -extern const vec4u8 color_dark_magenta; -extern const vec4u8 color_dark_yellow; - extern void sv_anisotropy_set(int32_t value); extern float_t get_anim_frame_speed(); extern float_t get_delta_frame(); diff --git a/src/CRE/task_effect.cpp b/src/CRE/task_effect.cpp index bb5ae4bd..aba43c0d 100644 --- a/src/CRE/task_effect.cpp +++ b/src/CRE/task_effect.cpp @@ -2068,8 +2068,8 @@ void ripple_emit::sub_1403587C0(const vec3 a2, const vec3 a3, float_t a4, struc_ int32_t v37 = (int32_t)(a4 * 60.0f); int32_t v27 = v33 >= v37 ? v37 : v33; - vec4u8 v19a = { 0x08, 0x00, 0x00, (uint8_t)v19 }; - vec4u8 v29 = { (uint8_t)v27, 0x00, 0x00, (uint8_t)(int32_t)(v24 * 1275.0f) }; + color4u8 v19a = { 0x08, 0x00, 0x00, (uint8_t)v19 }; + color4u8 v29 = { (uint8_t)v27, 0x00, 0x00, (uint8_t)(int32_t)(v24 * 1275.0f) }; for (float_t i = 0.0f; i < v23; i += 0.03f) { if (v24 > 0.0f) { @@ -2130,7 +2130,7 @@ void ripple_emit::sub_14035AAE0() { v1.data.vertex[i].z = ((rand_state_array_get_float(4) - 0.5f) * v10 + emitter_list[i].y) * emit_pos_scale; v1.data.color[i] = rand_state_array_get_float(4) < 0.5f - ? vec4u8(0x00, 0x00, 0x00, 0xFF) : vec4u8(0x00, 0x00, 0x00, 0xFF); + ? color4u8(0x00, 0x00, 0x00, 0xFF) : color4u8(0x00); v1.data.count++; } @@ -3058,18 +3058,18 @@ static void draw_ripple_emit(render_context* rctx, struc_101* data) { { size_t count = data->count; vec3* vertex = data->vertex; - vec4u8* color = data->color; + color4u8* color = data->color; const size_t vtx_count = (size_t)count * 0x06; vec3* vtx_data = force_malloc_s(vec3, vtx_count); for (size_t i = count; i; i--, vtx_data += 6, vertex++, color++) { - vtx_data[0] = { vertex->x, vertex->z, (float_t)color->w }; - vtx_data[1] = { vertex->x, vertex->z, (float_t)color->w }; - vtx_data[2] = { vertex->x, vertex->z, (float_t)color->w }; - vtx_data[3] = { vertex->x, vertex->z, (float_t)color->w }; - vtx_data[4] = { vertex->x, vertex->z, (float_t)color->w }; - vtx_data[5] = { vertex->x, vertex->z, (float_t)color->w }; + vtx_data[0] = { vertex->x, vertex->z, (float_t)color->a }; + vtx_data[1] = { vertex->x, vertex->z, (float_t)color->a }; + vtx_data[2] = { vertex->x, vertex->z, (float_t)color->a }; + vtx_data[3] = { vertex->x, vertex->z, (float_t)color->a }; + vtx_data[4] = { vertex->x, vertex->z, (float_t)color->a }; + vtx_data[5] = { vertex->x, vertex->z, (float_t)color->a }; } vtx_data -= vtx_count; diff --git a/src/CRE/task_effect.hpp b/src/CRE/task_effect.hpp index e142eec6..693c1e7a 100644 --- a/src/CRE/task_effect.hpp +++ b/src/CRE/task_effect.hpp @@ -367,7 +367,7 @@ struct struc_101 { int32_t ripple_emit_uniform; int32_t count; vec3* vertex; - vec4u8* color; + color4u8* color; float_t size; int32_t field_24; }; @@ -375,7 +375,7 @@ struct struc_101 { struct ripple_emit_draw_data { struc_101 data; vec3 vertex[16]; - vec4u8 color[16]; + color4u8 color[16]; ripple_emit_draw_data(); }; diff --git a/src/ReDIVA/classes/graphics/background_color.cpp b/src/ReDIVA/classes/graphics/background_color.cpp index 39620181..9952a46e 100644 --- a/src/ReDIVA/classes/graphics/background_color.cpp +++ b/src/ReDIVA/classes/graphics/background_color.cpp @@ -51,17 +51,13 @@ void graphics_background_color_imgui(class_data* data) { color_edit_flags |= ImGuiColorEditFlags_NoDragDrop; ImGui::GetContentRegionAvailSetNextItemWidth(); - vec4 _clear_color; - vec4u8_to_vec4(clear_color, _clear_color); - _clear_color *= (float_t)(1.0 / 255.0); - if (ImGui::ColorEdit4("##Background Color", (float_t*)&_clear_color, color_edit_flags)) { - _clear_color = vec4::clamp(_clear_color, 0.0f, 1.0f) * 255.0f; - vec4_to_vec4u8(_clear_color, clear_color); - } + vec4 _clear_color = clear_color; + if (ImGui::ColorEdit4("##Background Color", (float_t*)&_clear_color, color_edit_flags)) + clear_color = _clear_color; ImGui::Checkbox("Set Clear Color", &set_clear_color); if (ImGui::ButtonEnterKeyPressed("Reset Color")) { - clear_color = { 0x60, 0x60, 0x60, 0xFF }; + clear_color = 0xFF606060; set_clear_color = true; } diff --git a/src/ReDIVA/data_test/auth_3d_test.cpp b/src/ReDIVA/data_test/auth_3d_test.cpp index c3b9b546..bbf35237 100644 --- a/src/ReDIVA/data_test/auth_3d_test.cpp +++ b/src/ReDIVA/data_test/auth_3d_test.cpp @@ -105,7 +105,7 @@ bool Auth3dTestTask::Init() { obj_sets.shrink_to_fit(); rctx_ptr->render_manager.shadow_ptr->self_shadow = true; - clear_color = { 0x99, 0x99, 0x99, 0x00 }; + clear_color = 0x00999999; task_stage_load_task("A3D_STAGE"); object_storage_load_set(aft_data, aft_obj_db, effcmn_obj_set); return true; diff --git a/src/ReDIVA/data_test/glitter_test.cpp b/src/ReDIVA/data_test/glitter_test.cpp index 759a1f45..15407da9 100644 --- a/src/ReDIVA/data_test/glitter_test.cpp +++ b/src/ReDIVA/data_test/glitter_test.cpp @@ -57,7 +57,7 @@ bool TaskDataTestGlitterParticle::Init() { Glitter::glt_particle_manager->draw_all_mesh = false; dtm_stg_load(0); - clear_color = { 0x60, 0x60, 0x60, 0xFF }; + clear_color = 0xFF606060; camera* cam = rctx_ptr->camera; cam->reset(); @@ -137,7 +137,7 @@ void TaskDataTestGlitterParticle::Disp() { if (show_grid) { mdl::EtcObj etc = {}; etc.init(mdl::ETC_OBJ_GRID); - etc.color = { 0x00, 0x00, 0x00, 0xFF }; + etc.color = 0xFF000000; etc.data.grid.w = 50; etc.data.grid.h = 50; etc.data.grid.ws = 50; diff --git a/src/ReDIVA/data_test/motion_test.cpp b/src/ReDIVA/data_test/motion_test.cpp index b1d43cf7..60eb21de 100644 --- a/src/ReDIVA/data_test/motion_test.cpp +++ b/src/ReDIVA/data_test/motion_test.cpp @@ -92,7 +92,7 @@ DataTestMot::~DataTestMot() { } bool DataTestMot::Init() { - clear_color = { 0x60, 0x60, 0x60, 0xFF }; + clear_color = 0xFF606060; set_clear_color = true; camera* cam = rctx_ptr->camera; @@ -321,7 +321,7 @@ bool DataTestMot::Ctrl() { } bool DataTestMot::Dest() { - clear_color = { 0x00, 0x00, 0x00, 0xFF }; + clear_color = 0xFF000000; set_clear_color = true; dtm_mot_array[0].DelTask(); diff --git a/src/ReDIVA/dw.cpp b/src/ReDIVA/dw.cpp index 08ad3829..217b06c5 100644 --- a/src/ReDIVA/dw.cpp +++ b/src/ReDIVA/dw.cpp @@ -49,36 +49,36 @@ namespace dw_gui_detail { } struct dw_gui_colors { - vec4u8 background; - vec4u8 foreground; - vec4u8 selection_background; - vec4u8 selection_foreground; - vec4u8 selection_inactive_background; - vec4u8 selection_inactive_foreground; - vec4u8 disable_background; - vec4u8 disable_foreground; - vec4u8 title_background; - vec4u8 title_foreground; - vec4u8 title_inactive_background; - vec4u8 title_inactive_foreground; - vec4u8 active_border_color; - vec4u8 inactive_border_color; - vec4u8 focus_border_color; - vec4u8 border_color; - vec4u8 border_light_color; - vec4u8 border_dark_color; - vec4u8 popup_background; - vec4u8 popup_foreground; - vec4u8 popup_selection_background; - vec4u8 popup_selection_foreground; - vec4u8 menu_background; - vec4u8 menu_foreground; - vec4u8 menu_selection_background; - vec4u8 menu_selection_foreground; - vec4u8 button_background; - vec4u8 button_foreground; - vec4u8 button_disable_background; - vec4u8 button_disable_foreground; + color4u8 background; + color4u8 foreground; + color4u8 selection_background; + color4u8 selection_foreground; + color4u8 selection_inactive_background; + color4u8 selection_inactive_foreground; + color4u8 disable_background; + color4u8 disable_foreground; + color4u8 title_background; + color4u8 title_foreground; + color4u8 title_inactive_background; + color4u8 title_inactive_foreground; + color4u8 active_border_color; + color4u8 inactive_border_color; + color4u8 focus_border_color; + color4u8 border_color; + color4u8 border_light_color; + color4u8 border_dark_color; + color4u8 popup_background; + color4u8 popup_foreground; + color4u8 popup_selection_background; + color4u8 popup_selection_foreground; + color4u8 menu_background; + color4u8 menu_foreground; + color4u8 menu_selection_background; + color4u8 menu_selection_foreground; + color4u8 button_background; + color4u8 button_foreground; + color4u8 button_disable_background; + color4u8 button_disable_foreground; }; static dw_gui_colors dw_gui_colors_default = { diff --git a/src/ReDIVA/game_state.cpp b/src/ReDIVA/game_state.cpp index 1ffaadf1..ebb9fced 100644 --- a/src/ReDIVA/game_state.cpp +++ b/src/ReDIVA/game_state.cpp @@ -1365,7 +1365,7 @@ bool SubGameState::DataTestObj::Dest() { } bool SubGameState::DataTestStg::Init() { - clear_color = { 0x60, 0x60, 0x60, 0xFF }; + clear_color = 0xFF606060; camera* cam = rctx_ptr->camera; cam->reset(); @@ -1382,7 +1382,7 @@ bool SubGameState::DataTestStg::Ctrl() { } bool SubGameState::DataTestStg::Dest() { - clear_color = { 0x00, 0x00, 0x00, 0xFF }; + clear_color = 0xFF000000; dtw_stg->Hide(); dtm_stg->DelTask(); @@ -1432,7 +1432,7 @@ bool SubGameState::DataTestSpr::Dest() { } bool SubGameState::DataTestAet::Init() { - clear_color = { 0x60, 0x60, 0x60, 0xFF }; + clear_color = 0xFF606060; dtm_aet_load(); return true; } @@ -1442,7 +1442,7 @@ bool SubGameState::DataTestAet::Ctrl() { } bool SubGameState::DataTestAet::Dest() { - clear_color = { 0x00, 0x00, 0x00, 0xFF }; + clear_color = 0xFF000000; dtm_aet_unload(); return true; } diff --git a/src/ReDIVA/print_work.cpp b/src/ReDIVA/print_work.cpp index c43a42b8..599f7a33 100644 --- a/src/ReDIVA/print_work.cpp +++ b/src/ReDIVA/print_work.cpp @@ -7,18 +7,18 @@ #include "../KKdLib/str_utils.hpp" PrintWork::PrintWork() : clip(), layer(), field_28(), line_length() { - color = { 0xFF, 0xFF, 0xFF, 0xFF }; - fill_color = { 0x80, 0x80, 0x80, 0xFF }; - this->clip_data.size = 0i64; + color = 0xFFFFFFFF; + fill_color = 0xFF808080; prio = spr::SPR_PRIO_DEFAULT; - layer = 0; resolution_mode = RESOLUTION_MODE_HD; - field_28 = 0; - line_length = 0i64; font = font_info_default_get(); empty_char = '\x25\xA1'; } +void PrintWork::DrawLine(vec2 pos[2]) { + spr::put_sprite_line(pos[0], pos[1], resolution_mode, prio, color, layer); +} + font_char PrintWork::GetCharData(wchar_t c) { font_char font_c = {}; if (!font->get_char_data(c, &font_c)) diff --git a/src/ReDIVA/print_work.hpp b/src/ReDIVA/print_work.hpp index 00295f20..b5f1f175 100644 --- a/src/ReDIVA/print_work.hpp +++ b/src/ReDIVA/print_work.hpp @@ -34,8 +34,8 @@ namespace app { struct PrintWork { - vec4u8 color; - vec4u8 fill_color; + color4u8 color; + color4u8 fill_color; bool clip; rectangle clip_data; spr::SprPrio prio; @@ -50,6 +50,7 @@ struct PrintWork { PrintWork(); + void DrawLine(vec2 pos[2]); font_char GetCharData(wchar_t c); vec2 GetTextSize(const wchar_t* str, size_t length); vec2 GetTextSize(const wchar_t* str_begin, const wchar_t* str_end); diff --git a/src/ReDIVA/pv_game/pv_game.cpp b/src/ReDIVA/pv_game/pv_game.cpp index c8fbb2aa..9db5347e 100644 --- a/src/ReDIVA/pv_game/pv_game.cpp +++ b/src/ReDIVA/pv_game/pv_game.cpp @@ -369,7 +369,7 @@ void pv_game_data::reset() { pv_data.field_2BF30 = -1; pv_data.field_2BF38 = 0; pv_data.music_playing = false; - pv_data.pv_game->data.play_data.lyrics_color = { 0xFF, 0xFF, 0xFF, 0xFF }; + pv_data.pv_game->data.play_data.lyric_color = 0xFFFFFFFF; pv_data.play = true; pv_data.field_2BF50 = 0; pv_data.field_2BFD5 = false; @@ -3877,7 +3877,7 @@ void pv_game::reset() { memset(data.play_data.lyric, 0, sizeof(data.play_data.lyric)); data.play_data.lyric_set = false; - data.play_data.lyrics_color = { 0xFF, 0xFF, 0xFF, 0xFF }; + data.play_data.lyric_color = 0xFFFFFFFF; memset(data.field_2CE9C, 0, sizeof(data.field_2CE9C)); data.field_2CF1C = 0; @@ -4225,12 +4225,11 @@ void pv_game::set_item_mask(size_t performer, size_t item, bool value) { items_mask[performer].arr[item] = value; } -void pv_game::set_lyric(int32_t lyric_index, vec4u8 lyric_color) { +void pv_game::set_lyric(int32_t lyric_index, color4u8 lyric_color) { memset(data.play_data.lyric, 0, sizeof(data.play_data.lyric)); data.play_data.lyric_set = false; - data.play_data.lyrics_color = sub_14013C8C0()->sub_1400E7910() < 4 - ? lyric_color : vec4u8(0xFF, 0xFF, 0xFF, 0xFF); + data.play_data.lyric_color = sub_14013C8C0()->sub_1400E7910() < 4 ? lyric_color : 0xFFFFFFFF; if (lyric_index < 0) return; diff --git a/src/ReDIVA/pv_game/pv_game.hpp b/src/ReDIVA/pv_game/pv_game.hpp index a80851c1..60af0b7b 100644 --- a/src/ReDIVA/pv_game/pv_game.hpp +++ b/src/ReDIVA/pv_game/pv_game.hpp @@ -423,7 +423,7 @@ struct pv_game { void set_eyes_adjust(pv_game_chara* chr); void set_item(size_t performer, rob_chara_pv_data_item& value); void set_item_mask(size_t performer, size_t item, bool value); - void set_lyric(int32_t lyric_index, vec4u8 lyric_color); + void set_lyric(int32_t lyric_index, color4u8 lyric_color); void set_module(size_t performer, int32_t module); void set_osage_init(const pv_game_chara& chr); bool set_pv_param_post_process_bloom_data(bool set, int32_t id, float_t duration); diff --git a/src/ReDIVA/pv_game/pv_game_play_data.hpp b/src/ReDIVA/pv_game/pv_game_play_data.hpp index 086e3c08..8226c1bb 100644 --- a/src/ReDIVA/pv_game/pv_game_play_data.hpp +++ b/src/ReDIVA/pv_game/pv_game_play_data.hpp @@ -217,7 +217,7 @@ struct pv_game_play_data { float_t field_5F4; char lyric[76]; bool lyric_set; - vec4u8 lyrics_color; + color4u8 lyric_color; bool field_64C; int32_t field_650; float_t field_654; diff --git a/src/ReDIVA/pv_game/pv_game_pv_data.cpp b/src/ReDIVA/pv_game/pv_game_pv_data.cpp index 7562076a..0949f8fc 100644 --- a/src/ReDIVA/pv_game/pv_game_pv_data.cpp +++ b/src/ReDIVA/pv_game/pv_game_pv_data.cpp @@ -942,8 +942,8 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, } break; case DSC_FT_LYRIC: { int32_t lyric_index = (int32_t)data[0]; - vec4u8 color = *(vec4u8*)&data[1]; - color = { color.z, color.y, color.x, color.w }; + color4u8 color = *(uint32_t*)&data[1]; + color = { color.b, color.g, color.r, color.a }; pv_game->set_lyric(lyric_index, color); } break; case DSC_FT_MUSIC_PLAY: { @@ -2434,7 +2434,7 @@ void pv_game_pv_data::init(::pv_game* pv_game, bool music_play) { shad->blur_filter_enable[1] = 0x1; } - pv_game->data.play_data.lyrics_color = { 0xFF, 0xFF, 0xFF, 0xFF }; + pv_game->data.play_data.lyric_color = 0xFFFFFFFF; field_0 = true; chara_id = 0; diff --git a/src/ReDIVA/render.cpp b/src/ReDIVA/render.cpp index bf5c2805..6c186e63 100644 --- a/src/ReDIVA/render.cpp +++ b/src/ReDIVA/render.cpp @@ -935,7 +935,7 @@ static render_context* render_context_load() { ImGui_ImplOpenGL3_Init("#version 430"); lock_unlock(imgui_context_lock); - clear_color = { 0x60, 0x60, 0x60, 0xFF }; + clear_color = 0xFF606060; set_clear_color = true; chara_index charas[6];