From fc536bd93a8e413d04ab82bb0d37d81f05133dff Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Sun, 27 Oct 2024 01:17:59 -0500 Subject: [PATCH] example: restore several examples The dump_* examples were removed because the serial_transfer example now handles that use-case more generically. --- example/arm/Makefile | 3 +- example/clipping.cpp | 48 +++-- example/clipping2.cpp | 54 +++-- example/clipping_textured.cpp | 65 +++--- example/cube.cpp | 4 +- example/dump_object_list.cpp | 239 ---------------------- example/dump_ram.cpp | 28 --- example/example.mk | 23 +-- example/font_bitmap.cpp | 12 +- example/font_outline.cpp | 2 +- font/dejavusansmono/dejavusansmono.data.h | 5 + font/dejavusansmono/dejavusansmono.hpp | 5 - font/sperrypc/sperrypc_8x8.data.h | 5 + font/sperrypc/sperrypc_8x8.hpp | 7 - maple/maple_bus_commands.hpp | 2 + regs/gen/generate.py | 11 +- regs/gen/maple_bus_commands.py | 12 +- 17 files changed, 120 insertions(+), 405 deletions(-) delete mode 100644 example/dump_object_list.cpp delete mode 100644 example/dump_ram.cpp create mode 100644 font/dejavusansmono/dejavusansmono.data.h delete mode 100644 font/dejavusansmono/dejavusansmono.hpp create mode 100644 font/sperrypc/sperrypc_8x8.data.h delete mode 100644 font/sperrypc/sperrypc_8x8.hpp diff --git a/example/arm/Makefile b/example/arm/Makefile index 5b855ff..76042d7 100644 --- a/example/arm/Makefile +++ b/example/arm/Makefile @@ -7,7 +7,8 @@ GENERATED ?= AARCH = -march=armv4 -mlittle-endian -CARCH = -mno-thumb-interwork -march=armv4 -mtune=arm7di -mlittle-endian +CARCH = -mno-thumb-interwork -march=armv4 -mlittle-endian +#-mtune=arm7di CFLAGS += -I$(dir $(MAKEFILE_PATH))/../.. CXXFLAGS += -std=c++2a diff --git a/example/clipping.cpp b/example/clipping.cpp index 7b23f46..59645f5 100644 --- a/example/clipping.cpp +++ b/example/clipping.cpp @@ -24,33 +24,32 @@ #include "math/math.hpp" #include "maple/maple.hpp" -#include "maple/maple_impl.hpp" +#include "maple/maple_host_command_writer.hpp" #include "maple/maple_bus_bits.hpp" #include "maple/maple_bus_commands.hpp" #include "maple/maple_bus_ft0.hpp" -uint32_t _command_buf[(1024 + 32) / 4]; -uint32_t _receive_buf[(1024 + 32) / 4]; - static ft0::data_transfer::data_format data[4]; -void do_get_condition(uint32_t * command_buf, - uint32_t * receive_buf) +uint32_t send_buf[1024] __attribute__((aligned(32))); +uint32_t recv_buf[1024] __attribute__((aligned(32))); + +void do_get_condition() { - using command_type = get_condition; - using response_type = data_transfer; + auto writer = maple::host_command_writer(send_buf, recv_buf); - get_condition::data_fields data_fields = { - .function_type = std::byteswap(function_type::controller) - }; + using command_type = maple::get_condition; + using response_type = maple::data_transfer; - const uint32_t command_size = maple::init_host_command_all_ports(command_buf, receive_buf, - data_fields); - using host_response_type = struct maple::host_response; - auto host_response = reinterpret_cast(receive_buf); + auto [host_command, host_response] + = writer.append_command_all_ports(); - maple::dma_start(command_buf, command_size, - receive_buf, maple::sizeof_command(host_response)); + for (int port = 0; port < 4; port++) { + auto& data_fields = host_command[port].bus_data.data_fields; + data_fields.function_type = std::byteswap(function_type::controller); + } + maple::dma_start(send_buf, writer.send_offset, + recv_buf, writer.recv_offset); for (uint8_t port = 0; port < 4; port++) { auto& bus_data = host_response[port].bus_data; @@ -62,8 +61,10 @@ void do_get_condition(uint32_t * command_buf, return; } - data[port].analog_axis_3 = data_fields.data.analog_axis_3; - data[port].analog_axis_4 = data_fields.data.analog_axis_4; + for (int i = 0; i < 6; i++) { + data[port].analog_coordinate_axis[i] + = data_fields.data.analog_coordinate_axis[i]; + } } } @@ -232,9 +233,6 @@ uint32_t _ta_parameter_buf[((32 * 8192) + 32) / 4]; void main() { - uint32_t * command_buf = align_32byte(_command_buf); - uint32_t * receive_buf = align_32byte(_receive_buf); - video_output::set_mode_vga(); // The address of `ta_parameter_buf` must be a multiple of 32 bytes. @@ -267,15 +265,15 @@ void main() float y_pos = 0; while (1) { - do_get_condition(command_buf, receive_buf); + do_get_condition(); ta_polygon_converter_init(opb_size.total(), ta_alloc, 640 / 32, 480 / 32); - float x_ = static_cast(data[0].analog_axis_3 - 0x80) / 127.f; - float y_ = static_cast(data[0].analog_axis_4 - 0x80) / 127.f; + const float x_ = static_cast(data[0].analog_coordinate_axis[2] - 0x80) / 127.f; + const float y_ = static_cast(data[0].analog_coordinate_axis[3] - 0x80) / 127.f; if (x_ > x_pos) x_pos += (0.09f * ((x_ - x_pos) * (x_ - x_pos))); if (x_ < x_pos) x_pos -= (0.09f * ((x_ - x_pos) * (x_ - x_pos))); if (y_ > y_pos) y_pos += (0.09f * ((y_ - y_pos) * (y_ - y_pos))); diff --git a/example/clipping2.cpp b/example/clipping2.cpp index 12b09bd..62ce420 100644 --- a/example/clipping2.cpp +++ b/example/clipping2.cpp @@ -25,33 +25,34 @@ #include "math/geometry.hpp" #include "maple/maple.hpp" -#include "maple/maple_impl.hpp" +#include "maple/maple_host_command_writer.hpp" #include "maple/maple_bus_bits.hpp" #include "maple/maple_bus_commands.hpp" #include "maple/maple_bus_ft0.hpp" #include "sh7091/serial.hpp" -uint32_t _command_buf[(1024 + 32) / 4]; -uint32_t _receive_buf[(1024 + 32) / 4]; - static ft0::data_transfer::data_format data[4]; -void do_get_condition(uint32_t * command_buf, - uint32_t * receive_buf) +uint32_t send_buf[1024] __attribute__((aligned(32))); +uint32_t recv_buf[1024] __attribute__((aligned(32))); + +void do_get_condition() { - using command_type = get_condition; - using response_type = data_transfer; + auto writer = maple::host_command_writer(send_buf, recv_buf); - get_condition::data_fields data_fields = { - .function_type = std::byteswap(function_type::controller) - }; + using command_type = maple::get_condition; + using response_type = maple::data_transfer; - const uint32_t command_size = maple::init_host_command_all_ports(command_buf, receive_buf, data_fields); - using host_response_type = struct maple::host_response; - auto host_response = reinterpret_cast(receive_buf); - maple::dma_start(command_buf, command_size, - receive_buf, maple::sizeof_command(host_response)); + auto [host_command, host_response] + = writer.append_command_all_ports(); + + for (int port = 0; port < 4; port++) { + auto& data_fields = host_command[port].bus_data.data_fields; + data_fields.function_type = std::byteswap(function_type::controller); + } + maple::dma_start(send_buf, writer.send_offset, + recv_buf, writer.recv_offset); for (uint8_t port = 0; port < 4; port++) { auto& bus_data = host_response[port].bus_data; @@ -63,10 +64,10 @@ void do_get_condition(uint32_t * command_buf, return; } - data[port].analog_axis_1 = data_fields.data.analog_axis_1; - data[port].analog_axis_2 = data_fields.data.analog_axis_2; - data[port].analog_axis_3 = data_fields.data.analog_axis_3; - data[port].analog_axis_4 = data_fields.data.analog_axis_4; + for (int i = 0; i < 6; i++) { + data[port].analog_coordinate_axis[i] + = data_fields.data.analog_coordinate_axis[i]; + } } } @@ -209,9 +210,6 @@ uint32_t _ta_parameter_buf[((32 * 8192) + 32) / 4]; void main() { - uint32_t * command_buf = align_32byte(_command_buf); - uint32_t * receive_buf = align_32byte(_receive_buf); - video_output::set_mode_vga(); // The address of `ta_parameter_buf` must be a multiple of 32 bytes. @@ -244,22 +242,22 @@ void main() float y_pos = 0; while (1) { - do_get_condition(command_buf, receive_buf); + do_get_condition(); ta_polygon_converter_init(opb_size.total(), ta_alloc, 640 / 32, 480 / 32); - const float l_ = static_cast(data[0].analog_axis_1) * (1.f / 255.f); - const float r_ = static_cast(data[0].analog_axis_2) * (1.f / 255.f); + const float l_ = static_cast(data[0].analog_coordinate_axis[0]) * (1.f / 255.f); + const float r_ = static_cast(data[0].analog_coordinate_axis[1]) * (1.f / 255.f); const float t_ = ((l_ > r_) ? l_ : -r_) * 3.14f / 2.f; if (t_ > theta) theta += (0.04f * ((t_ - theta) * (t_ - theta))); else theta -= (0.04f * ((t_ - theta) * (t_ - theta))); - const float x_ = static_cast(data[0].analog_axis_3 - 0x80) / 127.f; - const float y_ = static_cast(data[0].analog_axis_4 - 0x80) / 127.f; + const float x_ = static_cast(data[0].analog_coordinate_axis[2] - 0x80) / 127.f; + const float y_ = static_cast(data[0].analog_coordinate_axis[3] - 0x80) / 127.f; if (x_ > x_pos) x_pos += (0.02f * ((x_ - x_pos) * (x_ - x_pos))); else x_pos -= (0.02f * ((x_ - x_pos) * (x_ - x_pos))); if (y_ > y_pos) y_pos += (0.02f * ((y_ - y_pos) * (y_ - y_pos))); diff --git a/example/clipping_textured.cpp b/example/clipping_textured.cpp index f1e8d1c..614c071 100644 --- a/example/clipping_textured.cpp +++ b/example/clipping_textured.cpp @@ -26,40 +26,38 @@ #include "math/geometry.hpp" #include "maple/maple.hpp" -#include "maple/maple_impl.hpp" +#include "maple/maple_host_command_writer.hpp" #include "maple/maple_bus_bits.hpp" #include "maple/maple_bus_commands.hpp" #include "maple/maple_bus_ft0.hpp" #include "twiddle.hpp" -#include "macaw.hpp" - -uint32_t _command_buf[(1024 + 32) / 4]; -uint32_t _receive_buf[(1024 + 32) / 4]; +#include "texture/macaw/macaw.data.h" static ft0::data_transfer::data_format data[4]; -void do_get_condition(uint32_t * command_buf, - uint32_t * receive_buf) +uint32_t send_buf[1024] __attribute__((aligned(32))); +uint32_t recv_buf[1024] __attribute__((aligned(32))); + +void do_get_condition() { - using command_type = get_condition; - using response_type = data_transfer; + auto writer = maple::host_command_writer(send_buf, recv_buf); - get_condition::data_fields data_fields = { - .function_type = std::byteswap(function_type::controller) - }; + using command_type = maple::get_condition; + using response_type = maple::data_transfer; - const uint32_t command_size = maple::init_host_command_all_ports(command_buf, receive_buf, - data_fields); - using host_response_type = struct maple::host_response; - auto host_response = reinterpret_cast(receive_buf); - maple::dma_start(command_buf, command_size, - receive_buf, maple::sizeof_command(host_response)); + auto [host_command, host_response] + = writer.append_command_all_ports(); + + for (int port = 0; port < 4; port++) { + auto& data_fields = host_command[port].bus_data.data_fields; + data_fields.function_type = std::byteswap(function_type::controller); + } + maple::dma_start(send_buf, writer.send_offset, + recv_buf, writer.recv_offset); - using host_response_type = struct maple::host_response; for (uint8_t port = 0; port < 4; port++) { - auto response = reinterpret_cast(receive_buf); - auto& bus_data = response[port].bus_data; + auto& bus_data = host_response[port].bus_data; if (bus_data.command_code != response_type::command_code) { return; } @@ -68,10 +66,10 @@ void do_get_condition(uint32_t * command_buf, return; } - data[port].analog_axis_1 = data_fields.data.analog_axis_1; - data[port].analog_axis_2 = data_fields.data.analog_axis_2; - data[port].analog_axis_3 = data_fields.data.analog_axis_3; - data[port].analog_axis_4 = data_fields.data.analog_axis_4; + for (int i = 0; i < 6; i++) { + data[port].analog_coordinate_axis[i] + = data_fields.data.analog_coordinate_axis[i]; + } } } @@ -229,8 +227,8 @@ void init_texture_memory(const struct opb_size& opb_size) void init_macaw_texture() { - auto src = reinterpret_cast(&_binary_macaw_data_start); - auto size = reinterpret_cast(&_binary_macaw_data_size); + auto src = reinterpret_cast(&_binary_texture_macaw_macaw_data_start); + auto size = reinterpret_cast(&_binary_texture_macaw_macaw_data_size); auto texture = reinterpret_cast(&texture_memory64[texture_memory_alloc::texture.start / 4]); uint16_t temp[size / 3]; @@ -249,9 +247,6 @@ uint32_t _ta_parameter_buf[((32 * 8192) + 32) / 4]; void main() { - uint32_t * command_buf = align_32byte(_command_buf); - uint32_t * receive_buf = align_32byte(_receive_buf); - video_output::set_mode_vga(); init_macaw_texture(); @@ -285,22 +280,22 @@ void main() float y_pos = 0; while (1) { - do_get_condition(command_buf, receive_buf); + do_get_condition(); ta_polygon_converter_init(opb_size.total(), ta_alloc, 640 / 32, 480 / 32); - const float l_ = static_cast(data[0].analog_axis_1) * (1.f / 255.f); - const float r_ = static_cast(data[0].analog_axis_2) * (1.f / 255.f); + const float l_ = static_cast(data[0].analog_coordinate_axis[0]) * (1.f / 255.f); + const float r_ = static_cast(data[0].analog_coordinate_axis[1]) * (1.f / 255.f); const float t_ = ((l_ > r_) ? l_ : -r_) * 3.14f / 2.f; if (t_ > theta) theta += (0.04f * ((t_ - theta) * (t_ - theta))); else theta -= (0.04f * ((t_ - theta) * (t_ - theta))); - const float x_ = static_cast(data[0].analog_axis_3 - 0x80) / 127.f; - const float y_ = static_cast(data[0].analog_axis_4 - 0x80) / 127.f; + const float x_ = static_cast(data[0].analog_coordinate_axis[2] - 0x80) / 127.f; + const float y_ = static_cast(data[0].analog_coordinate_axis[3] - 0x80) / 127.f; if (x_ > x_pos) x_pos += (0.02f * ((x_ - x_pos) * (x_ - x_pos))); else x_pos -= (0.02f * ((x_ - x_pos) * (x_ - x_pos))); if (y_ > y_pos) y_pos += (0.02f * ((y_ - y_pos) * (y_ - y_pos))); diff --git a/example/cube.cpp b/example/cube.cpp index 0f05038..e7d37fd 100644 --- a/example/cube.cpp +++ b/example/cube.cpp @@ -91,7 +91,7 @@ void transform(ta_parameter_writer& parameter, auto l = lights[0] - point; auto n_dot_l = dot(n, l); if (n_dot_l > 0) { - color.x += 0.35 * n_dot_l / (length(n) * length(l)); + color.x += 0.35 * n_dot_l / (magnitude(n) * magnitude(l)); } } @@ -99,7 +99,7 @@ void transform(ta_parameter_writer& parameter, auto l = lights[1] - point; auto n_dot_l = dot(n, l); if (n_dot_l > 0) { - color.y += 0.35 * n_dot_l / (length(n) * length(l)); + color.y += 0.35 * n_dot_l / (magnitude(n) * magnitude(l)); } } diff --git a/example/dump_object_list.cpp b/example/dump_object_list.cpp deleted file mode 100644 index eb9b382..0000000 --- a/example/dump_object_list.cpp +++ /dev/null @@ -1,239 +0,0 @@ -#include - -#include "align.hpp" -#include "holly/video_output.hpp" - -#include "holly/texture_memory_alloc.hpp" -#include "holly/holly.hpp" -#include "holly/core.hpp" -#include "holly/core_bits.hpp" -#include "holly/ta_fifo_polygon_converter.hpp" -#include "holly/ta_parameter.hpp" -#include "holly/ta_global_parameter.hpp" -#include "holly/ta_vertex_parameter.hpp" -#include "holly/ta_bits.hpp" -#include "holly/isp_tsp.hpp" -#include "holly/region_array.hpp" -#include "holly/background.hpp" -#include "memorymap.hpp" - -#include "sh7091/serial.hpp" - -#include "macaw.hpp" - -struct vertex { - float x; - float y; - float z; -}; - -const struct vertex strip_vertices[3] = { - // [ position ] - { -0.5f, 0.5f, 0.f }, // the first two base colors in a - { -0.5f, -0.5f, 0.f }, // non-Gouraud triangle strip are ignored - { 0.5f, 0.5f, 0.f }, -}; -constexpr uint32_t strip_length = (sizeof (strip_vertices)) / (sizeof (struct vertex)); - -const struct vertex quad_verticies[4] = { - { 200.f, 360.f, 0.1f }, - { 200.f, 120.f, 0.1f }, - { 440.f, 120.f, 0.1f }, - { 440.f, 360.f, 0.1f }, -}; - -uint32_t transform(uint32_t * ta_parameter_buf, - const vertex * strip_vertices, - const uint32_t strip_length) -{ - auto parameter = ta_parameter_writer(ta_parameter_buf); - - const uint32_t parameter_control_word = para_control::para_type::sprite -//const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume - | para_control::list_type::opaque - | obj_control::col_type::packed_color; - - const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater - | isp_tsp_instruction_word::culling_mode::no_culling; - - const uint32_t tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one - | tsp_instruction_word::dst_alpha_instr::zero - | tsp_instruction_word::fog_control::no_fog; - - const uint32_t texture_control_word = 0; - - constexpr uint32_t base_color = 0xffff0000; - - /* - parameter.append() = - 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 - ); - - for (uint32_t i = 0; i < strip_length; i++) { - float x = strip_vertices[i].x; - float y = strip_vertices[i].y; - float z = strip_vertices[i].z; - - x *= 240.f; - y *= 240.f; - x += 320.f; - y += 240.f; - z = 1.f / (z + 10.f); - - bool end_of_strip = i == strip_length - 1; - parameter.append() = - ta_vertex_parameter::polygon_type_0(polygon_vertex_parameter_control_word(end_of_strip), - x, y, z, - base_color - ); - } - */ - - parameter.append() = - ta_global_parameter::sprite(parameter_control_word, - isp_tsp_instruction_word, - tsp_instruction_word, - texture_control_word, - base_color, - 0, // offset_color - 0, // data_size_for_sort_dma - 0); // next_address_for_sort_dma - - parameter.append() = - ta_vertex_parameter::sprite_type_0(para_control::para_type::vertex_parameter, - quad_verticies[0].x, - quad_verticies[0].y, - quad_verticies[0].z, - quad_verticies[1].x, - quad_verticies[1].y, - quad_verticies[1].z, - quad_verticies[2].x, - quad_verticies[2].y, - quad_verticies[2].z, - quad_verticies[3].x, - quad_verticies[3].y); - - parameter.append() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list); - - return parameter.offset; -} - -void init_texture_memory(const struct opb_size& opb_size) -{ - auto object_list = &texture_memory32[texture_memory_alloc::object_list.start / 4]; - auto isp_tsp_parameters = &texture_memory32[texture_memory_alloc::isp_tsp_parameters.start / 4]; - - // zeroize - for (uint32_t i = 0; i < 0x00100000 / 4; i++) { - object_list[i] = 0xeeeeeeee; - isp_tsp_parameters[i] = 0xeeeeeeee; - } - - region_array2(640 / 32, // width - 480 / 32, // height - opb_size - ); - background_parameter(0xff222200); -} - -uint32_t _ta_parameter_buf[((32 * (strip_length + 2)) + 32) / 4]; - -union u32_u8 { - uint32_t u32; - uint8_t u8[4]; -}; -static_assert((sizeof (union u32_u8)) == 4); - -void dump() -{ - auto object_list = &texture_memory32[texture_memory_alloc::object_list.start / 4]; - auto isp_tsp_parameters = &texture_memory32[texture_memory_alloc::isp_tsp_parameters.start / 4]; - - constexpr uint32_t screen_ol_size = 8 * 4 * (640 / 32) * (480 / 32); - for (uint32_t i = 0; i < (screen_ol_size + 0x100) / 4; i++) { - union u32_u8 n; - n.u32 = object_list[i]; - - if (((i * 4) & 0x1f) == 0) - serial::character('\n'); - //if (((i * 4) & 0x3f) == 0) - // serial::character('\n'); - - serial::integer(n.u32, ' '); - } - - serial::character('\n'); - serial::character('\n'); - serial::character('\n'); - - for (uint32_t i = 0; i < (0x100) / 4; i++) { - union u32_u8 n; - n.u32 = isp_tsp_parameters[i]; - - if (((i * 4) & 0x1f) == 0) - serial::character('\n'); - - serial::integer(n.u32, ' '); - } -} - -void main() -{ - video_output::set_mode_vga(); - - // The address of `ta_parameter_buf` must be a multiple of 32 bytes. - // This is mandatory for ch2-dma to the ta fifo polygon converter. - uint32_t * ta_parameter_buf = align_32byte(_ta_parameter_buf); - - constexpr uint32_t ta_alloc = ta_alloc_ctrl::pt_opb::no_list - | ta_alloc_ctrl::tm_opb::no_list - | ta_alloc_ctrl::t_opb::no_list - | ta_alloc_ctrl::om_opb::no_list - | ta_alloc_ctrl::o_opb::_8x4byte; - - constexpr struct opb_size opb_size = { .opaque = 8 * 4 - , .opaque_modifier = 0 - , .translucent = 0 - , .translucent_modifier = 0 - , .punch_through = 0 - }; - - holly.SOFTRESET = softreset::pipeline_soft_reset - | softreset::ta_soft_reset; - holly.SOFTRESET = 0; - - core_init(); - init_texture_memory(opb_size); - - uint32_t frame_ix = 0; - - bool dumped = false; - while (true) { - ta_polygon_converter_init(opb_size.total(), - ta_alloc, - 640 / 32, - 480 / 32); - uint32_t ta_parameter_size = transform(ta_parameter_buf, strip_vertices, strip_length); - ta_polygon_converter_transfer(ta_parameter_buf, ta_parameter_size); - ta_wait_opaque_list(); - - core_start_render(frame_ix); - core_wait_end_of_render_video(); - - while (!spg_status::vsync(holly.SPG_STATUS)); - core_flip(frame_ix); - while (spg_status::vsync(holly.SPG_STATUS)); - - frame_ix = (frame_ix + 1) & 1; - - if (frame_ix == 10 && dumped == false) { - dump(); - dumped = true; - } - } -} diff --git a/example/dump_ram.cpp b/example/dump_ram.cpp deleted file mode 100644 index 2eacbd0..0000000 --- a/example/dump_ram.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -#include "memorymap.hpp" - -#include "sh7091/serial.hpp" - -void dump_ram(const volatile uint32_t * mem, const uint32_t len) -{ - uint32_t sum = 0; - for (uint32_t i = 0; i < len; i++) { - uint8_t n = mem[i]; - sum += n; - serial::hexlify(n); - if ((i & 0xf) == 0xf) - serial::character('\n'); - } - serial::character('\n'); - serial::integer(sum); -} - -void main() -{ - // dump the first 64k of system memory - dump_ram(system_memory, 0x10000); - - - while (1); -} diff --git a/example/example.mk b/example/example.mk index bcde2c1..8bc1801 100644 --- a/example/example.mk +++ b/example/example.mk @@ -55,7 +55,7 @@ FONT_BITMAP_OBJ = \ holly/region_array.o \ holly/background.o \ holly/ta_fifo_polygon_converter.o \ - sperrypc_8x8.data.o + font/sperrypc/sperrypc_8x8.data.o example/font_bitmap.elf: LDSCRIPT = $(LIB)/main.lds example/font_bitmap.elf: $(START_OBJ) $(FONT_BITMAP_OBJ) @@ -264,7 +264,7 @@ CLIPPING_TEXTURED_OBJ = \ holly/ta_fifo_polygon_converter.o \ maple/maple.o \ sh7091/serial.o \ - macaw.data.o \ + texture/macaw/macaw.data.o \ $(LIBGCC) example/clipping_textured.elf: LDSCRIPT = $(LIB)/main.lds @@ -381,25 +381,6 @@ INTERRUPT_OBJ = \ example/interrupt.elf: LDSCRIPT = $(LIB)/main.lds example/interrupt.elf: $(START_OBJ) $(INTERRUPT_OBJ) -DUMP_OBJECT_LIST_OBJ = \ - example/dump_object_list.o \ - holly/video_output.o \ - holly/core.o \ - holly/region_array.o \ - holly/background.o \ - holly/ta_fifo_polygon_converter.o \ - sh7091/serial.o - -example/dump_object_list.elf: LDSCRIPT = $(LIB)/main.lds -example/dump_object_list.elf: $(START_OBJ) $(DUMP_OBJECT_LIST_OBJ) - -DUMP_RAM_OBJ = \ - example/dump_ram.o \ - sh7091/serial.o - -example/dump_ram.elf: LDSCRIPT = $(LIB)/main.lds -example/dump_ram.elf: $(START_OBJ) $(DUMP_RAM_OBJ) - SOFTWARE_TA_OBJ = \ example/software_ta.o \ holly/video_output.o \ diff --git a/example/font_bitmap.cpp b/example/font_bitmap.cpp index 25e79f2..a9bd236 100644 --- a/example/font_bitmap.cpp +++ b/example/font_bitmap.cpp @@ -18,7 +18,7 @@ #include "holly/region_array.hpp" #include "twiddle.hpp" -#include "sperrypc_8x8.hpp" +#include "font/sperrypc/sperrypc_8x8.data.h" struct vertex { float x; @@ -184,21 +184,15 @@ inline void inflate_character(const uint8_t * src, const uint8_t c) uint32_t offset = ((8 * 8) / 2) * character_index; - /* union { uint8_t u8[8 * 8]; uint32_t u32[8 * 8 / 4]; } temp2; - twiddle::texure_4bpp(temp2.u8, temp, 8, 8); + twiddle::texture_4bpp(temp2.u8, temp, 8, 8); for (uint32_t i = 0; i < 8 * 8 / 4; i++) { texture[(offset / 4) + i] = temp2.u32[i]; } - */ - - twiddle::texture2<4>(&texture[offset / 4], temp, - 8, - 8 * 8); } void inflate_font(const uint8_t * src) @@ -222,7 +216,7 @@ void main() { video_output::set_mode_vga(); - auto src = reinterpret_cast(&_binary_sperrypc_8x8_data_start); + auto src = reinterpret_cast(&_binary_font_sperrypc_sperrypc_8x8_data_start); inflate_font(src); palette_data(); diff --git a/example/font_outline.cpp b/example/font_outline.cpp index 78eff2c..d01ebf0 100644 --- a/example/font_outline.cpp +++ b/example/font_outline.cpp @@ -20,7 +20,7 @@ #include "palette.hpp" #include "font/font.hpp" -#include "dejavusansmono.hpp" +#include "font/dejavusansmono/dejavusansmono.data.h" struct vertex { float x; diff --git a/font/dejavusansmono/dejavusansmono.data.h b/font/dejavusansmono/dejavusansmono.data.h new file mode 100644 index 0000000..a322085 --- /dev/null +++ b/font/dejavusansmono/dejavusansmono.data.h @@ -0,0 +1,5 @@ +#pragma once +#include +extern uint32_t _binary_font_dejavusansmono_dejavusansmono_data_start __asm("_binary_font_dejavusansmono_dejavusansmono_data_start"); +extern uint32_t _binary_font_dejavusansmono_dejavusansmono_data_end __asm("_binary_font_dejavusansmono_dejavusansmono_data_end"); +extern uint32_t _binary_font_dejavusansmono_dejavusansmono_data_size __asm("_binary_font_dejavusansmono_dejavusansmono_data_size"); diff --git a/font/dejavusansmono/dejavusansmono.hpp b/font/dejavusansmono/dejavusansmono.hpp deleted file mode 100644 index 9a2fb08..0000000 --- a/font/dejavusansmono/dejavusansmono.hpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -extern uint32_t _binary_dejavusansmono_data_start __asm("_binary_dejavusansmono_data_start"); -extern uint32_t _binary_dejavusansmono_data_end __asm("_binary_dejavusansmono_data_end"); -extern uint32_t _binary_dejavusansmono_data_size __asm("_binary_dejavusansmono_data_size"); diff --git a/font/sperrypc/sperrypc_8x8.data.h b/font/sperrypc/sperrypc_8x8.data.h new file mode 100644 index 0000000..b6a77c5 --- /dev/null +++ b/font/sperrypc/sperrypc_8x8.data.h @@ -0,0 +1,5 @@ +#pragma once +#include +extern uint32_t _binary_font_sperrypc_sperrypc_8x8_data_start __asm("_binary_font_sperrypc_sperrypc_8x8_data_start"); +extern uint32_t _binary_font_sperrypc_sperrypc_8x8_data_end __asm("_binary_font_sperrypc_sperrypc_8x8_data_end"); +extern uint32_t _binary_font_sperrypc_sperrypc_8x8_data_size __asm("_binary_font_sperrypc_sperrypc_8x8_data_size"); diff --git a/font/sperrypc/sperrypc_8x8.hpp b/font/sperrypc/sperrypc_8x8.hpp deleted file mode 100644 index 286ea61..0000000 --- a/font/sperrypc/sperrypc_8x8.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -extern uint32_t _binary_sperrypc_8x8_data_start __asm("_binary_sperrypc_8x8_data_start"); -extern uint32_t _binary_sperrypc_8x8_data_end __asm("_binary_sperrypc_8x8_data_end"); -extern uint32_t _binary_sperrypc_8x8_data_size __asm("_binary_sperrypc_8x8_data_size"); diff --git a/maple/maple_bus_commands.hpp b/maple/maple_bus_commands.hpp index 7658c00..fff53bc 100644 --- a/maple/maple_bus_commands.hpp +++ b/maple/maple_bus_commands.hpp @@ -10,6 +10,7 @@ struct device_id { }; static_assert((sizeof (struct device_id)) == 16); + struct device_request { static constexpr uint32_t command_code = 0x1; @@ -278,4 +279,5 @@ struct ar_error { static_assert((sizeof (struct ar_error::data_fields)) == 4); + } diff --git a/regs/gen/generate.py b/regs/gen/generate.py index 2871189..9cb9f43 100644 --- a/regs/gen/generate.py +++ b/regs/gen/generate.py @@ -10,10 +10,14 @@ def should_autonewline(line): def _render(out, lines): indent = " " level = 0 + namespace = 0 for l in lines: if l and (l[0] == "}" or l[0] == ")"): level -= 2 - assert level >= 0, out.getvalue() + if level < 0: + assert namespace >= 0 + namespace -= 1 + level = 0 if len(l) == 0: out.write("\n") @@ -21,7 +25,10 @@ def _render(out, lines): out.write(indent * level + l + "\n") if l and (l[-1] == "{" or l[-1] == "("): - level += 2 + if l.startswith("namespace"): + namespace += 1 + else: + level += 2 if level == 0 and l and l[-1] == ";": if should_autonewline(l): diff --git a/regs/gen/maple_bus_commands.py b/regs/gen/maple_bus_commands.py index 405c1d3..f88b909 100644 --- a/regs/gen/maple_bus_commands.py +++ b/regs/gen/maple_bus_commands.py @@ -159,11 +159,20 @@ def headers(): yield "" yield "#include " yield "" + +def namespace(): + yield "namespace maple {" + yield "" yield "struct device_id {" yield "uint32_t ft;" yield "uint32_t fd[3];" yield "};" yield "static_assert((sizeof (struct device_id)) == 16);" + yield "" + for namespace, data_fields in process(rows): + yield from command_namespace(namespace, data_fields) + yield "" + yield "}" input_file = sys.argv[1] rows = read_input(input_file) @@ -171,6 +180,5 @@ process = new_aggregator() render, out = renderer() render(headers()) -for namespace, data_fields in process(rows): - render(command_namespace(namespace, data_fields)) +render(namespace()) sys.stdout.write(out.getvalue())