diff --git a/Makefile b/Makefile index dc39c65..13337ce 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: xm_player.elf -OPT = -O2 +OPT = -O3 MAKEFILE_PATH := $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST))))) LIB ?= $(MAKEFILE_PATH)/dreamcast diff --git a/src/alpha.hpp b/src/alpha.hpp new file mode 100644 index 0000000..cb32aa0 --- /dev/null +++ b/src/alpha.hpp @@ -0,0 +1,4 @@ +#pragma once + +//static constexpr uint32_t alpha = 0xcf000000; +static constexpr uint32_t alpha = 0x80000000; diff --git a/src/main.cpp b/src/main.cpp index d2c7dde..9f2b5d6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -131,8 +131,8 @@ void main() system.IML4EXT = istext::aica; static uint8_t op_buf[1024 * 1024] __attribute__((aligned(32))); - static uint8_t pt_buf[1024 * 1024] __attribute__((aligned(32))); - static uint8_t tl_buf[1024 * 1024 / 2] __attribute__((aligned(32))); + static uint8_t pt_buf[1024 * 1024 / 2] __attribute__((aligned(32))); + static uint8_t tl_buf[1024 * 1024 / 4] __attribute__((aligned(32))); ta_multiwriter multi(ta_parameter_writer(op_buf, (sizeof (op_buf))), ta_parameter_writer(pt_buf, (sizeof (pt_buf))), ta_parameter_writer(tl_buf, (sizeof (tl_buf)))); diff --git a/src/scene/options/scene.cpp b/src/scene/options/scene.cpp index 1d83313..54c8767 100644 --- a/src/scene/options/scene.cpp +++ b/src/scene/options/scene.cpp @@ -17,9 +17,9 @@ #include "framebuffer.hpp" #include "graphics.hpp" -#define __length(c) ((sizeof (c)) / (sizeof (c[0]))) +#include "alpha.hpp" -uint32_t alpha = 0xcf000000; +#define __length(c) ((sizeof (c)) / (sizeof (c[0]))) void position_left() { @@ -293,13 +293,13 @@ namespace scene::options { {(float)framebuffer.px_width, 0, 0.5}, {(float)framebuffer.px_width, (float)framebuffer.px_height, 0.5}, {0, (float)framebuffer.px_height, 0.5}, - alpha | 0x202020); + (0xc0 << 24) | 0x202020); } void transfer(ta_multiwriter& multi) { update(); - top.draw(multi); + top.draw(multi, true); draw_corners(multi.tl); draw_shroud(multi.tl); } diff --git a/src/scene/tracker/scene.cpp b/src/scene/tracker/scene.cpp index cd454c8..aac5a08 100644 --- a/src/scene/tracker/scene.cpp +++ b/src/scene/tracker/scene.cpp @@ -280,7 +280,7 @@ namespace scene::tracker { update_start(); metadata::draw(multi, 5, 8); - top.draw(multi); + top.draw(multi, false); draw_button_labels(multi.pt); tracklist::draw(multi, top.width + 5, 5); float y = top.y() + top.height + 5; diff --git a/src/widget/button.cpp b/src/widget/button.cpp index 34af26a..55803b3 100644 --- a/src/widget/button.cpp +++ b/src/widget/button.cpp @@ -3,23 +3,25 @@ #include "ta_parameter.hpp" #include "graphics_primitive.hpp" +#include "alpha.hpp" + namespace widget { const static float shadow_depth = 1.0 / 10.0; - const static int shadow_color = 0x0000000; + const static int shadow_color = alpha | 0x0000000; const static float lowlight_depth = 1.0 / 9.0; - const static int lowlight_color = 0x0c0d0d; + const static int lowlight_color = alpha | 0x0c0d0d; const static float highlight_depth = 1.0 / 8.0; - const static int highlight_color = 0x353a3a; + const static int highlight_color = alpha | 0x353a3a; - const static int highlight_click_color = 0x141616; + const static int highlight_click_color = alpha | 0x141616; const static float background_depth = 1.0 / 7.0; - const static int background_color = 0x282c2c; + const static int background_color = alpha | 0x282c2c; - void button::draw_shadow(ta_parameter_writer& writer) const + void button::draw_shadow(ta_parameter_writer& writer, float dm) const { { float x0 = x() + 1; @@ -27,10 +29,10 @@ namespace widget { float y0 = y(); float y1 = y() + height; quad_type_0(writer, - {x0, y0, shadow_depth}, - {x1, y0, shadow_depth}, - {x1, y1, shadow_depth}, - {x0, y1, shadow_depth}, + {x0, y0, shadow_depth * dm}, + {x1, y0, shadow_depth * dm}, + {x1, y1, shadow_depth * dm}, + {x0, y1, shadow_depth * dm}, shadow_color); } { @@ -39,29 +41,29 @@ namespace widget { float y0 = y() + 1; float y1 = y() + height - 1; quad_type_0(writer, - {x0, y0, shadow_depth}, - {x1, y0, shadow_depth}, - {x1, y1, shadow_depth}, - {x0, y1, shadow_depth}, + {x0, y0, shadow_depth * dm}, + {x1, y0, shadow_depth * dm}, + {x1, y1, shadow_depth * dm}, + {x0, y1, shadow_depth * dm}, shadow_color); } } - void button::draw_lowlight(ta_parameter_writer& writer) const + void button::draw_lowlight(ta_parameter_writer& writer, float dm) const { float x0 = x() + 1; float x1 = x() + width - 1; float y0 = y() + 1; float y1 = y() + height - 1; quad_type_0(writer, - {x0, y0, lowlight_depth}, - {x1, y0, lowlight_depth}, - {x1, y1, lowlight_depth}, - {x0, y1, lowlight_depth}, + {x0, y0, lowlight_depth * dm}, + {x1, y0, lowlight_depth * dm}, + {x1, y1, lowlight_depth * dm}, + {x0, y1, lowlight_depth * dm}, lowlight_color); } - void button::draw_highlight(ta_parameter_writer& writer) const + void button::draw_highlight(ta_parameter_writer& writer, float dm) const { float x0 = x() + 1; float x1 = x() + width - 2; @@ -70,42 +72,50 @@ namespace widget { int color = (click_state == click_type::release) ? highlight_color : highlight_click_color; quad_type_0(writer, - {x0, y0, highlight_depth}, - {x1, y0, highlight_depth}, - {x1, y1, highlight_depth}, - {x0, y1, highlight_depth}, + {x0, y0, highlight_depth * dm}, + {x1, y0, highlight_depth * dm}, + {x1, y1, highlight_depth * dm}, + {x0, y1, highlight_depth * dm}, color); } - void button::draw_background(ta_parameter_writer& writer) const + void button::draw_background(ta_parameter_writer& writer, float dm) const { float x0 = x() + 2; float x1 = x() + width - 2; float y0 = y() + 2; float y1 = y() + height - 2; quad_type_0(writer, - {x0, y0, background_depth}, - {x1, y0, background_depth}, - {x1, y1, background_depth}, - {x0, y1, background_depth}, + {x0, y0, background_depth * dm}, + {x1, y0, background_depth * dm}, + {x1, y1, background_depth * dm}, + {x0, y1, background_depth * dm}, background_color); } - void button::draw(ta_multiwriter& multi) + void button::draw(ta_multiwriter& multi, bool translucent) { - global_polygon_untextured(multi.op, - para_control::list_type::opaque, - tsp_instruction_word::dst_alpha_instr::zero); + ta_parameter_writer& writer = translucent ? multi.tl : multi.op; - draw_shadow(multi.op); + if (translucent) { + global_polygon_untextured(multi.op, + para_control::list_type::opaque, + tsp_instruction_word::dst_alpha_instr::zero); + } else { + global_polygon_translucent(multi.tl); + } - draw_lowlight(multi.op); + float dm = translucent ? 10 : 1; - draw_highlight(multi.op); + draw_shadow(writer, dm); - draw_background(multi.op); + draw_lowlight(writer, dm); - widget::draw(multi); + draw_highlight(writer, dm); + + draw_background(writer, dm); + + widget::draw(multi, translucent); } void button::click() diff --git a/src/widget/button.hpp b/src/widget/button.hpp index 4b12b04..8b3a0b5 100644 --- a/src/widget/button.hpp +++ b/src/widget/button.hpp @@ -18,11 +18,11 @@ namespace widget { : widget(_x, _y, _width, _height), on_click(_on_click) { } - void draw_shadow(ta_parameter_writer& writer) const; - void draw_lowlight(ta_parameter_writer& writer) const; - void draw_highlight(ta_parameter_writer& writer) const; - void draw_background(ta_parameter_writer& writer) const; - void draw(ta_multiwriter& multi) override; + void draw_shadow(ta_parameter_writer& writer, float dm) const; + void draw_lowlight(ta_parameter_writer& writer, float dm) const; + void draw_highlight(ta_parameter_writer& writer, float dm) const; + void draw_background(ta_parameter_writer& writer, float dm) const; + void draw(ta_multiwriter& multi, bool translucent) override; void click() override; }; diff --git a/src/widget/button_icon.cpp b/src/widget/button_icon.cpp index 3d905d4..c37930f 100644 --- a/src/widget/button_icon.cpp +++ b/src/widget/button_icon.cpp @@ -10,7 +10,7 @@ namespace widget { const static float icon_shadow_depth = 1.0 / 5.5; const static int icon_shadow_color = 0x100000; - void button_icon::draw_icon(ta_parameter_writer& writer) const + void button_icon::draw_icon(ta_parameter_writer& writer, float dm) const { float y_offset = (float)(click_state != click_type::release); @@ -21,16 +21,18 @@ namespace widget { icons::global_polygon_icon(writer); - icons::draw(writer, icon_type, cx, cy, icon_depth, icon_color); + icons::draw(writer, icon_type, cx, cy, icon_depth * dm, icon_color); if (click_state == click_type::release) - icons::draw(writer, icon_type, cx + 1, cy + 1, icon_shadow_depth, icon_shadow_color); + icons::draw(writer, icon_type, cx + 1, cy + 1, icon_shadow_depth * dm, icon_shadow_color); } - void button_icon::draw(ta_multiwriter& multi) + void button_icon::draw(ta_multiwriter& multi, bool translucent) { - draw_icon(multi.pt); + float dm = translucent ? 10 : 1; - button::draw(multi); + draw_icon(multi.pt, dm); + + button::draw(multi, translucent); } } diff --git a/src/widget/button_icon.hpp b/src/widget/button_icon.hpp index 881ee68..c9d84d8 100644 --- a/src/widget/button_icon.hpp +++ b/src/widget/button_icon.hpp @@ -18,7 +18,7 @@ namespace widget { : button(_x, _y, _width, _height, _on_click), icon_type(icon_type) { } - void draw_icon(ta_parameter_writer& writer) const; - void draw(ta_multiwriter& multi) override; + void draw_icon(ta_parameter_writer& writer, float dm) const; + void draw(ta_multiwriter& multi, bool translucent) override; }; } diff --git a/src/widget/button_label.cpp b/src/widget/button_label.cpp index 16c59c1..50959ef 100644 --- a/src/widget/button_label.cpp +++ b/src/widget/button_label.cpp @@ -10,22 +10,24 @@ namespace widget { const static float label_shadow_depth = 1.0 / 6.0; const static int label_shadow_color = 0x000000; - void button_label::draw_label(ta_parameter_writer& writer) const + void button_label::draw_label(ta_parameter_writer& writer, float dm) const { float y_offset = (float)(click_state != click_type::release); float cx = x() + width / 2 - (glyph::hori_advance * label_length) / 2; float cy = y() + height / 2 - glyph::vert_advance / 2 + y_offset; - transfer_string(writer, label, cx, cy, label_depth, label_color); + transfer_string(writer, label, cx, cy, label_depth * dm, label_color); } - void button_label::draw(ta_multiwriter& multi) + void button_label::draw(ta_multiwriter& multi, bool translucent) { transfer_global_polygon_glyph(multi.pt); - draw_label(multi.pt); + float dm = translucent ? 10 : 1; - button::draw(multi); + draw_label(multi.pt, dm); + + button::draw(multi, translucent); } } diff --git a/src/widget/button_label.hpp b/src/widget/button_label.hpp index ddb0f5b..88b1955 100644 --- a/src/widget/button_label.hpp +++ b/src/widget/button_label.hpp @@ -16,7 +16,7 @@ namespace widget { : button(_x, _y, _width, _height, _on_click), label(label), label_length(str_length(label)) { } - void draw_label(ta_parameter_writer& writer) const; - void draw(ta_multiwriter& multi) override; + void draw_label(ta_parameter_writer& writer, float dm) const; + void draw(ta_multiwriter& multi, bool translucent) override; }; } diff --git a/src/widget/container.hpp b/src/widget/container.hpp index f37d04a..9be5dc5 100644 --- a/src/widget/container.hpp +++ b/src/widget/container.hpp @@ -23,10 +23,10 @@ namespace widget { } } - void draw(ta_multiwriter& multi) + void draw(ta_multiwriter& multi, bool translucent) { for (int i = 0; i < length; i++) { - children[i]->draw(multi); + children[i]->draw(multi, translucent); } } diff --git a/src/widget/label.cpp b/src/widget/label.cpp index bb9f397..8d1e524 100644 --- a/src/widget/label.cpp +++ b/src/widget/label.cpp @@ -11,22 +11,26 @@ namespace widget { const static float label_shadow_depth = 1.0 / 6.0; const static int label_shadow_color = 0x000000; - void label::draw_label(ta_parameter_writer& writer) const + void label::draw_label(ta_parameter_writer& writer, float dm) const { float y_offset = 0; float cx = x() + width / 2 - (glyph::hori_advance * value_length) / 2; float cy = y() + height / 2 - glyph::vert_advance / 2 + y_offset; - transfer_string(writer, value, cx, cy, label_depth, label_color); + transfer_string(writer, value, cx, cy, label_depth * dm, label_color); + + transfer_string(writer, value, cx + 1, cy + 1, label_shadow_depth * dm, label_shadow_color); } - void label::draw(ta_multiwriter& multi) + void label::draw(ta_multiwriter& multi, bool translucent) { transfer_global_polygon_glyph(multi.pt); - draw_label(multi.pt); + float dm = translucent ? 10 : 1; - widget::draw(multi); + draw_label(multi.pt, dm); + + widget::draw(multi, translucent); } } diff --git a/src/widget/label.hpp b/src/widget/label.hpp index 50c31dc..dde925e 100644 --- a/src/widget/label.hpp +++ b/src/widget/label.hpp @@ -17,7 +17,7 @@ namespace widget { : widget(_x, _y, _width, _height), value(value), value_length(str_length(value)) { } - void draw_label(ta_parameter_writer& writer) const; - void draw(ta_multiwriter& multi) override; + void draw_label(ta_parameter_writer& writer, float dm) const; + void draw(ta_multiwriter& multi, bool translucent) override; }; } diff --git a/src/widget/widget.hpp b/src/widget/widget.hpp index fc737c7..953654c 100644 --- a/src/widget/widget.hpp +++ b/src/widget/widget.hpp @@ -34,7 +34,7 @@ namespace widget { : bounding_box(_x, _y, _width, _height), click_state(click_type::release) { } - inline virtual void draw(ta_multiwriter& multi) + inline virtual void draw(ta_multiwriter& multi, bool translucent) { if (click_state == click_type::press) click_state = click_type::down;