Compare commits

..

3 Commits

26 changed files with 835 additions and 75 deletions

View File

@ -17,6 +17,9 @@
namespace cursor { namespace cursor {
float mouse_speed = 1.0;
float stick_speed = 1.0;
struct cursor state[4]; struct cursor state[4];
void init() void init()
@ -41,13 +44,14 @@ namespace cursor {
auto& data = data_fields.data; auto& data = data_fields.data;
float dx = static_cast<float>(data.analog_coordinate_axis[2] - 0x80) * 0.015; float dx = static_cast<float>(data.analog_coordinate_axis[2] - 0x80) * stick_speed * 0.108;
float dy = static_cast<float>(data.analog_coordinate_axis[3] - 0x80) * 0.015; float dy = static_cast<float>(data.analog_coordinate_axis[3] - 0x80) * stick_speed * 0.108;
state[port_ix].x += dx; state[port_ix].x += dx;
state[port_ix].y += dy; state[port_ix].y += dy;
state[port_ix].a = ft0::data_transfer::digital_button::a(data.digital_button) == 0; state[port_ix].a = ft0::data_transfer::digital_button::a(data.digital_button) == 0;
state[port_ix].b = ft0::data_transfer::digital_button::b(data.digital_button) == 0; state[port_ix].b = ft0::data_transfer::digital_button::b(data.digital_button) == 0;
state[port_ix].start = ft0::data_transfer::digital_button::start(data.digital_button) == 0;
state[port_ix].active = true; state[port_ix].active = true;
} else if ((port.function_type & function_type::pointing) != 0 && port.host_response_data_transfer_ft9 != nullptr) { } else if ((port.function_type & function_type::pointing) != 0 && port.host_response_data_transfer_ft9 != nullptr) {
@ -56,12 +60,13 @@ namespace cursor {
if ((std::byteswap(data_fields.function_type) & function_type::pointing) == 0) if ((std::byteswap(data_fields.function_type) & function_type::pointing) == 0)
continue; continue;
auto& data = data_fields.data; auto& data = data_fields.data;
float dx = static_cast<float>(data.analog_coordinate_axis[0] - 0x200) * 0.65; float dx = static_cast<float>(data.analog_coordinate_axis[0] - 0x200) * mouse_speed * 0.95;
float dy = static_cast<float>(data.analog_coordinate_axis[1] - 0x200) * 0.65; float dy = static_cast<float>(data.analog_coordinate_axis[1] - 0x200) * mouse_speed * 0.95;
state[port_ix].x += dx; state[port_ix].x += dx;
state[port_ix].y += dy; state[port_ix].y += dy;
state[port_ix].a = ft9::data_transfer::digital_button::a(data.digital_button) == 0; state[port_ix].a = ft9::data_transfer::digital_button::a(data.digital_button) == 0;
state[port_ix].b = ft9::data_transfer::digital_button::b(data.digital_button) == 0; state[port_ix].b = ft9::data_transfer::digital_button::b(data.digital_button) == 0;
state[port_ix].start = ft9::data_transfer::digital_button::w(data.digital_button) == 0;
state[port_ix].active = true; state[port_ix].active = true;
} }

View File

@ -2,12 +2,16 @@
namespace cursor { namespace cursor {
extern float mouse_speed;
extern float stick_speed;
struct cursor { struct cursor {
bool active; bool active;
float x; float x;
float y; float y;
bool a; bool a;
bool b; bool b;
bool start;
}; };
extern struct cursor state[4]; extern struct cursor state[4];

View File

@ -35,6 +35,9 @@ volatile int next_frame = 0;
static volatile int framebuffer_ix = 0; static volatile int framebuffer_ix = 0;
static volatile int next_frame_ix = 0; static volatile int next_frame_ix = 0;
static void * pt_buf = nullptr;
static int pt_offset = 0;
static void * op_buf = nullptr; static void * op_buf = nullptr;
static int op_offset = 0; static int op_offset = 0;
@ -69,8 +72,8 @@ void graphics_interrupt(uint32_t istnrm)
ta_polygon_converter_transfer(op_buf, op_offset); ta_polygon_converter_transfer(op_buf, op_offset);
} }
if (istnrm & istnrm::end_of_transferring_opaque_list) { if (istnrm & istnrm::end_of_transferring_translucent_list) {
system.ISTNRM = istnrm::end_of_transferring_opaque_list; system.ISTNRM = istnrm::end_of_transferring_translucent_list;
core_in_use = 1; core_in_use = 1;
core_start_render2(texture_memory_alloc.region_array.start, core_start_render2(texture_memory_alloc.region_array.start,
@ -137,7 +140,7 @@ void graphics_init()
scaler_init(); scaler_init();
core_init(); core_init();
core_param_init(); core_param_init();
//spg_set_mode_640x480(); spg_set_mode_640x480();
framebuffer_init(); framebuffer_init();
background_parameter2(texture_memory_alloc.background[1].start, background_parameter2(texture_memory_alloc.background[1].start,
@ -160,7 +163,7 @@ void graphics_scene_init(const opb_size * opb_size)
void graphics_cursor(ta_multiwriter& multi) void graphics_cursor(ta_multiwriter& multi)
{ {
global_polygon_untextured(multi.op, global_polygon_untextured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
@ -182,7 +185,7 @@ void graphics_event(ta_multiwriter& multi)
multi.op.offset = 0; multi.op.offset = 0;
multi.pt.offset = 0; multi.pt.offset = 0;
if (scene::current_scene == &scene::scenes[scene::id::tracker]) { if (scene::current_scene == &scene::scenes[scene::id::tracker] || scene::current_scene == &scene::scenes[scene::id::options]) {
graphics_cursor(multi); graphics_cursor(multi);
} }
assert(scene::current_scene->transfer != nullptr); assert(scene::current_scene->transfer != nullptr);

View File

@ -104,15 +104,17 @@ void test_pattern()
void main() void main()
{ {
printf("main\n");
serial::init(0); serial::init(0);
printf("main\n");
sound::init(); sound::init();
//bool emulator = detect_emulator(); //bool emulator = detect_emulator();
//printf("emulator %d\n", emulator); //printf("emulator %d\n", emulator);
printf("graphics_init\n");
graphics_init(); graphics_init();
scene::scene_init(scene::id::logo); //scene::scene_init(scene::id::logo);
printf("scene_init\n");
scene::scene_init(scene::id::tracker);
printf("state_init\n");
input::state_init(); input::state_init();
cursor::init(); cursor::init();
@ -122,8 +124,8 @@ void main()
system.IML6NRM = istnrm::end_of_render_tsp system.IML6NRM = istnrm::end_of_render_tsp
| istnrm::v_blank_in | istnrm::v_blank_in
| istnrm::end_of_transferring_punch_through_list | istnrm::end_of_transferring_translucent_list
| istnrm::end_of_transferring_opaque_list; | istnrm::end_of_transferring_punch_through_list;
system.IML4EXT = istext::aica; system.IML4EXT = istext::aica;

View File

@ -15,13 +15,13 @@ namespace scene::emulator {
const struct scene::scene scene = { const struct scene::scene scene = {
.ta_alloc = ta_alloc_ctrl::pt_opb::_32x4byte .ta_alloc = ta_alloc_ctrl::pt_opb::_32x4byte
| ta_alloc_ctrl::tm_opb::no_list | ta_alloc_ctrl::tm_opb::no_list
| ta_alloc_ctrl::t_opb::no_list | ta_alloc_ctrl::t_opb::_32x4byte
| ta_alloc_ctrl::om_opb::no_list | ta_alloc_ctrl::om_opb::no_list
| ta_alloc_ctrl::o_opb::_32x4byte, | ta_alloc_ctrl::o_opb::no_list,
.opb_size = { .opb_size = {
.opaque = 32 * 4, .opaque = 0,
.opaque_modifier = 0, .opaque_modifier = 0,
.translucent = 0, .translucent = 32 * 4,
.translucent_modifier = 0, .translucent_modifier = 0,
.punch_through = 32 * 4 .punch_through = 32 * 4
}, },
@ -90,7 +90,7 @@ namespace scene::emulator {
draw_paragraph(multi.pt, color); draw_paragraph(multi.pt, color);
global_polygon_untextured(multi.op, global_polygon_untextured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
quad_type_0(multi.op, quad_type_0(multi.op,

View File

@ -59,14 +59,14 @@ static void render_mesh(ta_parameter_writer& writer, const mesh& mesh, const mat
{ {
if (wireframe) { if (wireframe) {
global_polygon_untextured(writer, global_polygon_untextured(writer,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
} else { } else {
uint32_t texture_size = tsp_instruction_word::texture_u_size::from_int(8) uint32_t texture_size = tsp_instruction_word::texture_u_size::from_int(8)
| tsp_instruction_word::texture_v_size::from_int(8); | tsp_instruction_word::texture_v_size::from_int(8);
global_polygon_intensity(writer, global_polygon_intensity(writer,
para_control::list_type::opaque, para_control::list_type::translucent,
texture::offset::logo, texture::offset::logo,
texture_size, texture_size,
texture_control_word::pixel_format::_565); texture_control_word::pixel_format::_565);
@ -136,13 +136,13 @@ namespace scene::logo {
const struct scene::scene scene = { const struct scene::scene scene = {
.ta_alloc = ta_alloc_ctrl::pt_opb::no_list .ta_alloc = ta_alloc_ctrl::pt_opb::no_list
| ta_alloc_ctrl::tm_opb::no_list | ta_alloc_ctrl::tm_opb::no_list
| ta_alloc_ctrl::t_opb::no_list | ta_alloc_ctrl::t_opb::_32x4byte
| ta_alloc_ctrl::om_opb::no_list | ta_alloc_ctrl::om_opb::no_list
| ta_alloc_ctrl::o_opb::_32x4byte, | ta_alloc_ctrl::o_opb::no_list,
.opb_size = { .opb_size = {
.opaque = 32 * 4, .opaque = 0,
.opaque_modifier = 0, .opaque_modifier = 0,
.translucent = 0, .translucent = 32 * 4,
.translucent_modifier = 0, .translucent_modifier = 0,
.punch_through = 0 .punch_through = 0
}, },

423
src/scene/options/scene.cpp Normal file
View File

@ -0,0 +1,423 @@
#include "holly/ta_bits.hpp"
#include "holly/background.hpp"
#include "holly/holly.hpp"
#include "scene/scene.hpp"
#include "scene/options/scene.hpp"
#include "widget/button_label_tl.hpp"
#include "widget/left_aligned.hpp"
#include "widget/top_aligned.hpp"
#include "widget/label_tl.hpp"
#include "graphics_primitive.hpp"
#include "cursor.hpp"
#include "framebuffer.hpp"
#include "graphics.hpp"
#include "ta_parameter.hpp"
#include "sound.hpp"
#include "aica/aica.hpp"
#include "sh7091/sh7091_bits.hpp"
#define __length(c) ((sizeof (c)) / (sizeof (c[0])))
const static uint32_t alpha = 0xcf000000;
static int mvol = 0;
static int int_mouse_speed = 20;
static int int_stick_speed = 20;
void position_left()
{
printf("left\n");
int startx = holly.VO_STARTX & 0x3ff;
int hbend = (holly.SPG_HBLANK >> 16) & 0x3ff;
if (startx > hbend) {
holly.VO_STARTX = startx - 1;
}
}
void position_right()
{
printf("right\n");
int startx = holly.VO_STARTX & 0x3ff;
int hbstart = (holly.SPG_HBLANK >> 0) & 0x3ff;
if (startx < hbstart) {
holly.VO_STARTX = startx + 1;
}
}
void position_up()
{
printf("up\n");
int starty = holly.VO_STARTY & 0x3ff;
int vbend = (holly.SPG_VBLANK >> 16) & 0x3ff;
if (starty > vbend) {
holly.VO_STARTY = starty - 1;
}
}
void position_down()
{
printf("down\n");
int starty = holly.VO_STARTY & 0x3ff;
int vbstart = (holly.SPG_VBLANK >> 0) & 0x3ff;
if (starty < vbstart) {
holly.VO_STARTY = starty + 1;
}
}
void resolution_640x480()
{
uint32_t sr;
asm volatile ("stc sr,%0" : "=r" (sr));
sr |= sh::sr::imask(15);
asm volatile ("ldc %0,sr" : : "r" (sr));
printf("640x480\n");
spg_set_mode_640x480();
framebuffer.px_width = 640;
framebuffer.px_height = 480;
framebuffer_init();
graphics_scene_init(&scene::current_scene->opb_size);
sr &= ~sh::sr::imask(15);
asm volatile ("ldc %0,sr" : : "r" (sr));
}
void resolution_720x480()
{
uint32_t sr;
asm volatile ("stc sr,%0" : "=r" (sr));
sr |= sh::sr::imask(15);
asm volatile ("ldc %0,sr" : : "r" (sr));
printf("720x480\n");
spg_set_mode_720x480();
framebuffer.px_width = 720;
framebuffer.px_height = 480;
framebuffer_init();
graphics_scene_init(&scene::current_scene->opb_size);
sr &= ~sh::sr::imask(15);
asm volatile ("ldc %0,sr" : : "r" (sr));
}
void mvol_plus()
{
mvol += 1;
if (mvol > 0xf)
mvol = 0xf;
wait(); aica_sound.common.MVOL(mvol);
}
void mvol_minus()
{
mvol -= 1;
if (mvol < 0)
mvol = 0;
wait(); aica_sound.common.MVOL(mvol);
}
void mouse_speed_plus()
{
int_mouse_speed += 1;
if (int_mouse_speed > 99)
int_mouse_speed = 99;
cursor::mouse_speed = (float)int_mouse_speed / 20.0;
}
void mouse_speed_minus()
{
int_mouse_speed -= 1;
if (int_mouse_speed < 1)
int_mouse_speed = 1;
cursor::mouse_speed = (float)int_mouse_speed / 20.0;
}
void stick_speed_plus()
{
int_stick_speed += 1;
if (int_stick_speed > 99)
int_stick_speed = 99;
cursor::stick_speed = (float)int_stick_speed / 20.0;
}
void stick_speed_minus()
{
int_stick_speed -= 1;
if (int_stick_speed < 1)
int_stick_speed = 1;
cursor::stick_speed = (float)int_stick_speed / 20.0;
}
namespace scene::options {
widget::button_label_tl up_button(31, 0, 30, 30, "\x18", position_up);
widget::button_label_tl down_button(31, 0, 30, 30, "\x19", position_down);
widget::button_label_tl right_button(30, 30, "\x1a", position_right);
widget::button_label_tl left_button(30, 30, "\x1b", position_left);
widget::button_label_tl _640x480_button(100, 46, "640x480", resolution_640x480);
widget::button_label_tl _720x480_button(100, 46, "720x480", resolution_720x480);
widget::button_label_tl mouse_minus_button(30, 30, "-", mouse_speed_minus);
widget::button_label_tl mouse_plus_button(30, 30, "+", mouse_speed_plus);
widget::button_label_tl stick_minus_button(30, 30, "-", stick_speed_minus);
widget::button_label_tl stick_plus_button(30, 30, "+", stick_speed_plus);
widget::button_label_tl master_volume_minus_button(30, 30, "-", mvol_minus);
widget::button_label_tl master_volume_plus_button(30, 30, "+", mvol_plus);
widget::widget spacer(30, 30);
widget::label_tl position1_label(15 * glyph::hori_advance, 20, "screen position");
widget::label_tl mouse_speed_label(11 * glyph::hori_advance, 20, "mouse speed");
widget::label_tl stick_speed_label(11 * glyph::hori_advance, 20, "stick speed");
widget::label_tl master_volume_label(13 * glyph::hori_advance, 20, "master volume");
widget::label_tl resolution_label(10, 0, 10 * glyph::hori_advance, 20, "resolution");
widget::widget * row1_children[] = {
//&spacer,
&up_button,
};
int row1_length = __length(row1_children);
widget::widget * row2_children[] = {
&left_button,
&spacer,
&right_button,
};
int row2_length = __length(row2_children);
widget::widget * row3_children[] = {
// &spacer,
&down_button,
};
int row3_length = __length(row3_children);
widget::left_aligned row1(15, 0, 1, row1_children, row1_length);
widget::left_aligned row2(15, 0, 1, row2_children, row2_length);
widget::left_aligned row3(15, 0, 1, row3_children, row3_length);
widget::widget * position_children[] = {
&position1_label,
&row1,
&row2,
&row3,
};
int position_length = __length(position_children);
widget::top_aligned position(0, 0, 1, position_children, position_length);
widget::widget * resolution_children[] = {
&resolution_label,
&_640x480_button,
&_720x480_button,
};
int resolution_length = __length(resolution_children);
widget::top_aligned resolution(0, 0, 1, resolution_children, resolution_length);
widget::widget * video_children[] = {
&resolution,
&position,
};
int video_length = __length(video_children);
widget::left_aligned video(0, 0, 20, video_children, video_length);
widget::widget * mouse_speed_row1_children[] = {
&mouse_minus_button,
&mouse_plus_button,
};
int mouse_speed_row1_length = __length(mouse_speed_row1_children);
widget::left_aligned mouse_speed_row1(0, 0, 30, mouse_speed_row1_children, mouse_speed_row1_length);
widget::widget * mouse_speed_children[] = {
&mouse_speed_label,
&mouse_speed_row1,
};
int mouse_speed_length = __length(mouse_speed_children);
widget::top_aligned mouse_speed(0, 0, 1, mouse_speed_children, mouse_speed_length);
widget::widget * stick_speed_row1_children[] = {
&stick_minus_button,
&stick_plus_button,
};
int stick_speed_row1_length = __length(stick_speed_row1_children);
widget::left_aligned stick_speed_row1(0, 0, 30, stick_speed_row1_children, stick_speed_row1_length);
widget::widget * stick_speed_children[] = {
&stick_speed_label,
&stick_speed_row1,
};
int stick_speed_length = __length(stick_speed_children);
widget::top_aligned stick_speed(0, 0, 1, stick_speed_children, stick_speed_length);
widget::widget * master_volume_row1_children[] = {
&master_volume_minus_button,
&master_volume_plus_button,
};
int master_volume_row1_length = __length(master_volume_row1_children);
widget::left_aligned master_volume_row1(0, 0, 30, master_volume_row1_children, master_volume_row1_length);
widget::widget * master_volume_children[] = {
&master_volume_label,
&master_volume_row1,
};
int master_volume_length = __length(master_volume_children);
widget::top_aligned master_volume(0, 0, 1, master_volume_children, master_volume_length);
widget::widget * controls_children[] = {
&mouse_speed,
&stick_speed,
};
int controls_length = __length(controls_children);
widget::left_aligned controls(0, 0, 15, controls_children, controls_length);
widget::widget * top_children[] = {
&video,
&controls,
&master_volume,
};
int top_length = __length(top_children);
widget::top_aligned top(0, 0, 20, top_children, top_length);
const struct scene::scene scene = {
.ta_alloc = ta_alloc_ctrl::pt_opb::_32x4byte
| ta_alloc_ctrl::tm_opb::no_list
| ta_alloc_ctrl::t_opb::_32x4byte
| ta_alloc_ctrl::om_opb::no_list
| ta_alloc_ctrl::o_opb::no_list,
.opb_size = {
.opaque = 0,
.opaque_modifier = 0,
.translucent = 32 * 4,
.translucent_modifier = 0,
.punch_through = 32 * 4
},
.transfer = transfer,
.interrupt = interrupt,
.init = init,
.done = done
};
void update()
{
for (int i = 0; i < 4; i++) {
cursor::cursor& c = cursor::state[i];
if (c.active && c.a) {
widget::widget * w = top.pick(c.x, c.y);
if (w != nullptr) {
w->click();
}
}
}
}
void draw_corners(ta_parameter_writer& writer)
{
global_polygon_translucent(writer);
quad_type_0(writer,
{0, 0, 0.5},
{10, 0, 0.5},
{10, 10, 0.5},
{0, 10, 0.5},
alpha | 0xff0000);
float x = framebuffer.px_width - 10;
float y = framebuffer.px_height - 10;
quad_type_0(writer,
{0 + x, 0, 0.5},
{10 + x, 0, 0.5},
{10 + x, 10, 0.5},
{0 + x, 10, 0.5},
alpha | 0x00ff00);
quad_type_0(writer,
{0, 0 + y, 0.5},
{10, 0 + y, 0.5},
{10, 10 + y, 0.5},
{0, 10 + y, 0.5},
alpha | 0x0000ff);
quad_type_0(writer,
{0 + x, 0 + y, 0.5},
{10 + x, 0 + y, 0.5},
{10 + x, 10 + y, 0.5},
{0 + x, 10 + y, 0.5},
alpha | 0xffffff);
}
void draw_shroud(ta_parameter_writer& writer)
{
global_polygon_translucent(writer);
quad_type_0(writer,
{0, 0, 0.5},
{(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);
}
void draw_values(ta_parameter_writer& writer)
{
transfer_global_polygon_glyph(writer);
// mouse speed
transfer_integer(writer, int_mouse_speed,
53, 182, 10.0 / 10.0,
2, ' ',
0xffffff);
// stick speed
transfer_integer(writer, int_stick_speed,
188, 182, 10.0 / 10.0,
2, ' ',
0xffffff);
// master volume
transfer_integer(writer, mvol,
52, 254, 10.0 / 10.0,
2, ' ',
0xffffff);
}
void transfer(ta_multiwriter& multi)
{
update();
top.draw(multi);
draw_corners(multi.op);
draw_shroud(multi.op);
draw_values(multi.pt);
}
void interrupt()
{
}
void init()
{
/*
background_parameter2(texture_memory_alloc.background[1].start,
0x110012);
holly.VO_BORDER_COL = 0x110012;
*/
top.freeze(15, 15);
wait();
mvol = 0xc;
}
int done()
{
return -1;
}
}

View File

@ -0,0 +1,12 @@
namespace scene::options {
extern const struct scene::scene scene;
void transfer(ta_multiwriter& multi);
void interrupt();
void init();
int done();
}

View File

@ -4,6 +4,7 @@
#include "scene/tracker/scene.hpp" #include "scene/tracker/scene.hpp"
#include "scene/logo/scene.hpp" #include "scene/logo/scene.hpp"
#include "scene/emulator/scene.hpp" #include "scene/emulator/scene.hpp"
#include "scene/options/scene.hpp"
#include "sh7091/sh7091_bits.hpp" #include "sh7091/sh7091_bits.hpp"
@ -12,6 +13,7 @@ namespace scene {
[id::tracker] = tracker::scene, [id::tracker] = tracker::scene,
[id::logo] = logo::scene, [id::logo] = logo::scene,
[id::emulator] = emulator::scene, [id::emulator] = emulator::scene,
[id::options] = options::scene,
}; };
const scene * current_scene = nullptr; const scene * current_scene = nullptr;

View File

@ -8,7 +8,8 @@ namespace scene {
enum scene_type { enum scene_type {
tracker, tracker,
logo, logo,
emulator emulator,
options
}; };
} }

View File

@ -49,7 +49,7 @@ void draw(ta_multiwriter& multi, int x, int y)
int xi = x + offset - 2; int xi = x + offset - 2;
global_polygon_untextured(multi.op, global_polygon_untextured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
transfer_horizontal_border(multi.op, xi, y, width_per_col * channels_per_row); transfer_horizontal_border(multi.op, xi, y, width_per_col * channels_per_row);
@ -57,7 +57,7 @@ void draw(ta_multiwriter& multi, int x, int y)
for (int col = 0; col < channels_per_row; col++) { for (int col = 0; col < channels_per_row; col++) {
global_polygon_untextured(multi.op, global_polygon_untextured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
transfer_vertical_border(multi.op, xi, y, height_per_row); transfer_vertical_border(multi.op, xi, y, height_per_row);
@ -85,7 +85,7 @@ void draw(ta_multiwriter& multi, int x, int y)
} }
global_polygon_untextured(multi.op, global_polygon_untextured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
transfer_vertical_border(multi.op, xi, y, height_per_row); transfer_vertical_border(multi.op, xi, y, height_per_row);

View File

@ -41,7 +41,7 @@ namespace scene::tracker::cover {
| tsp_instruction_word::dst_alpha_instr::zero; | tsp_instruction_word::dst_alpha_instr::zero;
global_polygon_textured(multi.op, global_polygon_textured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
texture::offset::cover1, texture::offset::cover1,
texture_size, texture_size,
texture_control_word::pixel_format::_565); texture_control_word::pixel_format::_565);

View File

@ -156,7 +156,7 @@ namespace scene::tracker::metadata {
draw_values(multi.pt, x_values + 3, y + 3); draw_values(multi.pt, x_values + 3, y + 3);
global_polygon_untextured(multi.op, global_polygon_untextured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
draw_border(multi.op, x_values, y); draw_border(multi.op, x_values, y);

View File

@ -342,7 +342,7 @@ void draw(ta_multiwriter& multi, float x, float y)
draw_lines(multi.pt, x, y); draw_lines(multi.pt, x, y);
global_polygon_untextured(multi.op, global_polygon_untextured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
draw_borders(multi.op, x, y); draw_borders(multi.op, x, y);

View File

@ -21,9 +21,11 @@
#include "tracklist.hpp" #include "tracklist.hpp"
#include "cover.hpp" #include "cover.hpp"
#include "scene/options/scene.hpp"
#include "cursor.hpp" #include "cursor.hpp"
void play_click() static void play_click()
{ {
using namespace interpreter; using namespace interpreter;
printf("play\n"); printf("play\n");
@ -32,25 +34,25 @@ void play_click()
interpreter::unpause(); interpreter::unpause();
} }
void pause_click() static void pause_click()
{ {
printf("pause\n"); printf("pause\n");
interpreter::pause(); interpreter::pause();
} }
void prev_click() static void prev_click()
{ {
printf("prev\n"); printf("prev\n");
playlist::prev(); playlist::prev();
} }
void next_click() static void next_click()
{ {
printf("next\n"); printf("next\n");
playlist::next(); playlist::next();
} }
void rrr_click() static void rrr_click()
{ {
using namespace interpreter; using namespace interpreter;
printf("rr\n"); printf("rr\n");
@ -59,28 +61,28 @@ void rrr_click()
state.reverse = true; state.reverse = true;
} }
void rr_click() static void rr_click()
{ {
using namespace interpreter; using namespace interpreter;
printf("rr\n"); printf("rr\n");
state.current_tick_rate = state.current_tick_rate * 23 / 22; state.current_tick_rate = state.current_tick_rate * 23 / 22;
} }
void ff_click() static void ff_click()
{ {
using namespace interpreter; using namespace interpreter;
printf("ff\n"); printf("ff\n");
state.current_tick_rate = state.current_tick_rate * 22 / 23; state.current_tick_rate = state.current_tick_rate * 22 / 23;
} }
void fff_click() static void fff_click()
{ {
using namespace interpreter; using namespace interpreter;
printf("fff\n"); printf("fff\n");
state.current_tick_rate = state.current_tick_rate / 2; state.current_tick_rate = state.current_tick_rate / 2;
} }
void repeat_click() static void repeat_click()
{ {
using namespace interpreter; using namespace interpreter;
printf("repeat\n"); printf("repeat\n");
@ -146,16 +148,19 @@ widget::left_aligned top(0, 0, 20, top_children, top_length);
namespace scene::tracker { namespace scene::tracker {
static bool options = false;
static bool last_start[4] = {};
const struct scene::scene scene = { const struct scene::scene scene = {
.ta_alloc = ta_alloc_ctrl::pt_opb::_32x4byte .ta_alloc = ta_alloc_ctrl::pt_opb::_32x4byte
| ta_alloc_ctrl::tm_opb::no_list | ta_alloc_ctrl::tm_opb::no_list
| ta_alloc_ctrl::t_opb::no_list | ta_alloc_ctrl::t_opb::_32x4byte
| ta_alloc_ctrl::om_opb::no_list | ta_alloc_ctrl::om_opb::no_list
| ta_alloc_ctrl::o_opb::_32x4byte, | ta_alloc_ctrl::o_opb::no_list,
.opb_size = { .opb_size = {
.opaque = 32 * 4, .opaque = 0,
.opaque_modifier = 0, .opaque_modifier = 0,
.translucent = 0, .translucent = 32 * 4,
.translucent_modifier = 0, .translucent_modifier = 0,
.punch_through = 32 * 4 .punch_through = 32 * 4
}, },
@ -171,6 +176,8 @@ namespace scene::tracker {
0x110012); 0x110012);
holly.VO_BORDER_COL = 0x110012; holly.VO_BORDER_COL = 0x110012;
::scene::options::init();
float y = 8 + ((glyph::vert_advance + 5) * 2) + 8; float y = 8 + ((glyph::vert_advance + 5) * 2) + 8;
top.freeze(5, y); top.freeze(5, y);
playlist::next(); playlist::next();
@ -189,6 +196,18 @@ namespace scene::tracker {
} }
} }
void update_start()
{
for (int i = 0; i < 4; i++) {
cursor::cursor& c = cursor::state[i];
if (c.active) {
if (c.start && c.start != last_start[i])
options = !options;
last_start[i] = c.start;
}
}
}
void draw_button_labels(ta_parameter_writer& writer) void draw_button_labels(ta_parameter_writer& writer)
{ {
using namespace interpreter; using namespace interpreter;
@ -244,25 +263,23 @@ namespace scene::tracker {
void transfer(ta_multiwriter& multi) void transfer(ta_multiwriter& multi)
{ {
update(); update_start();
metadata::draw(multi, 5, 8); metadata::draw(multi, 5, 8);
top.draw(multi); top.draw(multi);
draw_button_labels(multi.pt); draw_button_labels(multi.pt);
tracklist::draw(multi, top.width + 5, 5); tracklist::draw(multi, top.width + 5, 5);
float y = top.y() + top.height + 5; float y = top.y() + top.height + 5;
channel_status::draw(multi, 5, y); channel_status::draw(multi, 5, y);
cover::draw(multi, 480, 8); cover::draw(multi, 480, 8);
y += channel_status::height + 10; y += channel_status::height + 10;
notes::draw(multi, 5, y); notes::draw(multi, 5, y);
if (options) {
::scene::options::transfer(multi);
} else {
update();
}
} }
int done() int done()

View File

@ -99,7 +99,7 @@ namespace scene::tracker::tracklist {
draw_middle_line(multi.op, x, y + 3); draw_middle_line(multi.op, x, y + 3);
global_polygon_untextured(multi.op, global_polygon_untextured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
float yi = y + glyph::vert_advance + 3; float yi = y + glyph::vert_advance + 3;

View File

@ -93,14 +93,37 @@ static inline void global_polygon_untextured(ta_parameter_writer& writer, uint32
const uint32_t tsp_instruction_word = tsp_instruction_word::texture_shading_instruction::modulate const uint32_t tsp_instruction_word = tsp_instruction_word::texture_shading_instruction::modulate
| tsp_instruction_word::src_alpha_instr::one | tsp_instruction_word::src_alpha_instr::one
| dst_alpha | dst_alpha
| tsp_instruction_word::fog_control::no_fog | tsp_instruction_word::fog_control::no_fog;
| tsp_instruction_word::texture_u_size::from_int(128)
| tsp_instruction_word::texture_v_size::from_int(256);
const uint32_t texture_address = texture_memory_alloc.texture.start; const uint32_t texture_control_word = 0;
const uint32_t texture_control_word = texture_control_word::pixel_format::_4bpp_palette
| texture_control_word::scan_order::twiddled writer.append<ta_global_parameter::polygon_type_0>() =
| texture_control_word::texture_address(texture_address / 8); ta_global_parameter::polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
texture_control_word,
0, // data_size_for_sort_dma
0 // next_address_for_sort_dma
);
}
static inline void global_polygon_translucent(ta_parameter_writer& writer)
{
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
| para_control::list_type::translucent
| obj_control::col_type::packed_color
;
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater_or_equal
| isp_tsp_instruction_word::culling_mode::no_culling;
const uint32_t tsp_instruction_word = tsp_instruction_word::texture_shading_instruction::modulate_alpha
| tsp_instruction_word::src_alpha_instr::src_alpha
| tsp_instruction_word::dst_alpha_instr::inverse_src_alpha
| tsp_instruction_word::use_alpha
| tsp_instruction_word::fog_control::no_fog;
const uint32_t texture_control_word = 0;
writer.append<ta_global_parameter::polygon_type_0>() = writer.append<ta_global_parameter::polygon_type_0>() =
ta_global_parameter::polygon_type_0(parameter_control_word, ta_global_parameter::polygon_type_0(parameter_control_word,

View File

@ -94,7 +94,7 @@ namespace widget {
void button::draw(ta_multiwriter& multi) void button::draw(ta_multiwriter& multi)
{ {
global_polygon_untextured(multi.op, global_polygon_untextured(multi.op,
para_control::list_type::opaque, para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
draw_shadow(multi.op); draw_shadow(multi.op);

View File

@ -0,0 +1,31 @@
#include "button_label_tl.hpp"
#include "graphics_primitive.hpp"
namespace widget {
const static float label_depth = 10.0 / 5.0;
const static int label_color = 0xffffff;
const static float label_shadow_depth = 10.0 / 6.0;
const static int label_shadow_color = 0x000000;
void button_label_tl::draw_label(ta_parameter_writer& writer) 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);
}
void button_label_tl::draw(ta_multiwriter& multi)
{
transfer_global_polygon_glyph(multi.pt);
draw_label(multi.pt);
button_tl::draw(multi);
}
}

View File

@ -0,0 +1,22 @@
#pragma once
#include "holly/ta_parameter.hpp"
#include "widget/button_tl.hpp"
namespace widget {
struct button_label_tl : button_tl {
const char * const label;
const int label_length;
inline button_label_tl(float _width, float _height, const char * label, void (* const _on_click)())
: button_tl(0, 0, _width, _height, _on_click), label(label), label_length(str_length(label))
{ }
inline button_label_tl(float _x, float _y, float _width, float _height, const char * label, void (* const _on_click)())
: button_tl(_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;
};
}

120
src/widget/button_tl.cpp Normal file
View File

@ -0,0 +1,120 @@
#include "widget/button_tl.hpp"
#include "ta_parameter.hpp"
#include "graphics_primitive.hpp"
namespace widget {
const static int alpha = 0x8000000;
const static float shadow_depth = 10.0 / 10.0;
const static int shadow_color = alpha | 0x0000000;
const static float lowlight_depth = 10.0 / 9.0;
const static int lowlight_color = alpha | 0x0c0d0d;
const static float highlight_depth = 10.0 / 8.0;
const static int highlight_color = alpha | 0x353a3a;
const static int highlight_click_color = alpha | 0x141616;
const static float background_depth = 10.0 / 7.0;
const static int background_color = 0x282c2c;
void button_tl::draw_shadow(ta_parameter_writer& writer) const
{
{
float x0 = x() + 1;
float x1 = x() + width - 1;
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},
shadow_color);
}
{
float x0 = x();
float x1 = x() + width;
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},
shadow_color);
}
}
void button_tl::draw_lowlight(ta_parameter_writer& writer) 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},
lowlight_color);
}
void button_tl::draw_highlight(ta_parameter_writer& writer) const
{
float x0 = x() + 1;
float x1 = x() + width - 2;
float y0 = y() + 1;
float y1 = y() + height - 2;
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},
color);
}
void button_tl::draw_background(ta_parameter_writer& writer) 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},
background_color);
}
void button_tl::draw(ta_multiwriter& multi)
{
global_polygon_untextured(multi.op,
para_control::list_type::translucent,
tsp_instruction_word::dst_alpha_instr::zero);
draw_shadow(multi.op);
draw_lowlight(multi.op);
draw_highlight(multi.op);
draw_background(multi.op);
widget::draw(multi);
}
void button_tl::click()
{
if (click_state == click_type::release && on_click != nullptr)
on_click();
widget::click();
}
}

29
src/widget/button_tl.hpp Normal file
View File

@ -0,0 +1,29 @@
#pragma once
#include "holly/ta_parameter.hpp"
#include "ta_multiwriter.hpp"
#include "widget/widget.hpp"
namespace widget {
struct button_tl : widget {
using widget::draw;
void (* const on_click)();
inline button_tl(float _width, float _height, void (* const _on_click)())
: widget(0, 0, _width, _height), on_click(_on_click)
{ }
inline button_tl(float _x, float _y, float _width, float _height, void (* const _on_click)())
: 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 click() override;
};
}

View File

@ -19,6 +19,8 @@ namespace widget {
float cy = y() + height / 2 - glyph::vert_advance / 2 + y_offset; 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, label_color);
transfer_string(writer, value, cx + 1, cy + 1, label_shadow_depth, label_shadow_color);
} }
void label::draw(ta_multiwriter& multi) void label::draw(ta_multiwriter& multi)

34
src/widget/label_tl.cpp Normal file
View File

@ -0,0 +1,34 @@
#include "widget/label_tl.hpp"
#include "ta_parameter.hpp"
#include "graphics_primitive.hpp"
namespace widget {
const static float label_depth = 10.0 / 5.0;
const static int label_color = 0xa7a7a7;
const static float label_shadow_depth = 10.0 / 6.0;
const static int label_shadow_color = 0x000000;
void label_tl::draw_label(ta_parameter_writer& writer) 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 + 1, cy + 1, label_shadow_depth, label_shadow_color);
}
void label_tl::draw(ta_multiwriter& multi)
{
transfer_global_polygon_glyph(multi.pt);
draw_label(multi.pt);
widget::draw(multi);
}
}

23
src/widget/label_tl.hpp Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include "holly/ta_parameter.hpp"
#include "ta_multiwriter.hpp"
#include "widget/widget.hpp"
namespace widget {
struct label_tl : widget {
const char * const value;
const int value_length;
inline label_tl(float _width, float _height, const char * value)
: widget(0, 0, _width, _height), value(value), value_length(str_length(value))
{ }
inline label_tl(float _x, float _y, float _width, float _height, const char * value)
: 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;
};
}

View File

@ -16,6 +16,20 @@ PCM_OBJ = \
pcm/start3.adpcm.o \ pcm/start3.adpcm.o \
pcm/dk.adpcm.o pcm/dk.adpcm.o
SCENE_OBJ = \
src/scene/logo/scene.o \
src/scene/logo/sound.o \
src/scene/emulator/scene.o \
src/scene/emulator/sound.o \
src/scene/scene.o \
src/scene/tracker/channel_status.o \
src/scene/tracker/cover.o \
src/scene/tracker/notes.o \
src/scene/tracker/scene.o \
src/scene/tracker/metadata.o \
src/scene/tracker/tracklist.o \
src/scene/options/scene.o
XM_PLAYER_OBJ = \ XM_PLAYER_OBJ = \
$(LIB)/holly/core.o \ $(LIB)/holly/core.o \
$(LIB)/holly/region_array.o \ $(LIB)/holly/region_array.o \
@ -40,23 +54,16 @@ XM_PLAYER_OBJ = \
src/main.o \ src/main.o \
src/malloc.o \ src/malloc.o \
src/playlist.o \ src/playlist.o \
src/scene/logo/scene.o \
src/scene/logo/sound.o \
src/scene/emulator/scene.o \
src/scene/emulator/sound.o \
src/scene/scene.o \
src/scene/tracker/channel_status.o \
src/scene/tracker/cover.o \
src/scene/tracker/notes.o \
src/scene/tracker/scene.o \
src/scene/tracker/metadata.o \
src/scene/tracker/tracklist.o \
src/sound.o \ src/sound.o \
src/texture.o \ src/texture.o \
src/widget/button.o \ src/widget/button.o \
src/widget/button_label.o \ src/widget/button_label.o \
src/widget/button_icon.o \ src/widget/button_icon.o \
src/widget/label.o \
src/widget/button_tl.o \
src/widget/button_label_tl.o \
src/widget/label_tl.o \
src/xm.o src/xm.o
xm_player.elf: LDSCRIPT = $(LIB)/main.lds xm_player.elf: LDSCRIPT = $(LIB)/main.lds
xm_player.elf: $(START_OBJ) $(XM_PLAYER_OBJ) $(TEXTURE_OBJ) $(XM_OBJ) $(PCM_OBJ) $(LIBGCC) xm_player.elf: $(START_OBJ) $(XM_PLAYER_OBJ) $(SCENE_OBJ) $(TEXTURE_OBJ) $(XM_OBJ) $(PCM_OBJ) $(LIBGCC)