From ac97380328f4541dbe223b543088ff6067349245 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Tue, 28 Jan 2025 02:05:14 -0600 Subject: [PATCH] wip --- example/wiffle_screen_space_store_queue2.cpp | 72 ++++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/example/wiffle_screen_space_store_queue2.cpp b/example/wiffle_screen_space_store_queue2.cpp index a6e5142..35a2a63 100644 --- a/example/wiffle_screen_space_store_queue2.cpp +++ b/example/wiffle_screen_space_store_queue2.cpp @@ -143,6 +143,68 @@ void transfer_scene(float theta) sq_transfer_32byte(ta_fifo_polygon_converter); } +struct vertex { + float x; + float y; + float z; +}; + +// screen space coordinates +const struct vertex quad_vertices[] = { + { 0.f, 0.f, 0.1f }, + { 640.f, 0.f, 0.1f }, + { 640.f, 480.f, 0.1f }, + { 640.f, 480.f, 0.1f }, +}; + +void transfer_quad() +{ + const uint32_t parameter_control_word = para_control::para_type::sprite + | para_control::list_type::opaque + | obj_control::col_type::packed_color; + //| obj_control::gouraud; + + 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; + + const uint32_t base_color = 0xffff0000; + *reinterpret_cast(store_queue) = + 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 + sq_transfer_32byte(ta_fifo_polygon_converter); + + *reinterpret_cast(store_queue) = + ta_vertex_parameter::sprite_type_0(para_control::para_type::vertex_parameter, + quad_vertices[0].x, + quad_vertices[0].y, + quad_vertices[0].z, + quad_vertices[1].x, + quad_vertices[1].y, + quad_vertices[1].z, + quad_vertices[2].x, + quad_vertices[2].y, + quad_vertices[2].z, + quad_vertices[3].x, + quad_vertices[3].y); + sq_transfer_64byte(ta_fifo_polygon_converter); + + *reinterpret_cast(store_queue) = + ta_global_parameter::end_of_list(para_control::para_type::end_of_list); + sq_transfer_32byte(ta_fifo_polygon_converter); +} + void dma_transfer(uint32_t source, uint32_t destination, uint32_t transfers) { using namespace dmac; @@ -282,8 +344,10 @@ void main() holly.FB_W_CTRL = fb_w_ctrl::fb_packmode::_8888_argb_32bit; - system.LMMODE0 = 1; - system.LMMODE1 = 1; // 32-bit + //system.LMMODE0 = 1; + //system.LMMODE1 = 1; // 32-bit + system.LMMODE0 = 0; + system.LMMODE1 = 0; // 64-bit uint32_t * out = (uint32_t *)&texture_memory32[texture_memory_alloc.framebuffer[0].start / 4]; for (int i = 0; i < 640 * 480; i++) { @@ -322,6 +386,7 @@ void main() uint32_t * in = (uint32_t *)&texture_memory64[texture_memory_alloc.texture.start / 4]; uint32_t * framebuffer = (uint32_t *)(0x11000000 + texture_memory_alloc.framebuffer[0].start); + uint32_t * out = (uint32_t *)(0x11000000 + texture_memory_alloc.texture.start + 640 * 480 * 4); while (1) { ta_wait_translucent_list(); @@ -333,7 +398,6 @@ void main() ta_alloc, tile_width, tile_height); - transfer_scene(theta); core_wait_end_of_render_video(); @@ -348,7 +412,7 @@ void main() dma_transfer((uint32_t)in, (uint32_t)inbuf, 640 * 480 * 4 / 32); while ((sh7091.DMAC.CHCR1 & dmac::chcr::te::transfers_completed) == 0); - sobel_fipr_store_queue2(inbuf, framebuffer, temp); + sobel_fipr_store_queue2(inbuf, out, temp); theta += half_degree; frame_ix += 1;