example/macaw: unrot

This commit is contained in:
Zack Buhman 2025-05-22 04:39:44 -05:00
parent 9e58a376bd
commit 3bd28fd814

View File

@ -43,11 +43,10 @@ constexpr uint32_t strip_length = (sizeof (strip_vertices)) / (sizeof (struct ve
static float theta = 0;
constexpr float half_degree = 0.01745329f / 2.f;
uint32_t transform(uint32_t * ta_parameter_buf,
const vertex * strip_vertices,
const uint32_t strip_length)
void transform(ta_parameter_writer& writer,
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::polygon_or_modifier_volume
| para_control::list_type::opaque
| obj_control::col_type::packed_color
@ -67,7 +66,7 @@ uint32_t transform(uint32_t * ta_parameter_buf,
| texture_control_word::scan_order::non_twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<ta_global_parameter::polygon_type_0>() =
writer.append<ta_global_parameter::polygon_type_0>() =
ta_global_parameter::polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
@ -92,7 +91,7 @@ uint32_t transform(uint32_t * ta_parameter_buf,
z = 1.f / (z + 10.f);
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_3>() =
writer.append<ta_vertex_parameter::polygon_type_3>() =
ta_vertex_parameter::polygon_type_3(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
strip_vertices[i].u,
@ -102,9 +101,7 @@ uint32_t transform(uint32_t * ta_parameter_buf,
);
}
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
return parameter.offset;
writer.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
}
void init_texture_memory(const struct opb_size& opb_size)
@ -131,17 +128,15 @@ void copy_macaw_texture()
}
}
uint32_t _ta_parameter_buf[((32 * (strip_length + 2)) + 32) / 4];
// 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[((32 * (strip_length + 2)) + 32) / 4] __attribute__((aligned(32)));
void main()
{
video_output::set_mode_vga();
copy_macaw_texture();
// 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
@ -165,13 +160,18 @@ void main()
uint32_t frame_ix = 0;
uint32_t frame = 0;
ta_parameter_writer writer = ta_parameter_writer(ta_parameter_buf, (sizeof (ta_parameter_buf)));
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);
writer.offset = 0;
transform(writer, strip_vertices, strip_length);
ta_polygon_converter_writeback(writer.buf, writer.offset);
ta_polygon_converter_transfer(writer.buf, writer.offset);
ta_wait_opaque_list();
core_start_render(frame_ix);