example: update several examples

This commit is contained in:
Zack Buhman 2024-01-03 21:50:07 +08:00
parent dcb9f36120
commit 1f6a29f379
26 changed files with 1610 additions and 1321 deletions

View File

@ -3,17 +3,19 @@
#include "align.hpp"
#include "vga.hpp"
#include "holly.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 "holly/texture_memory_alloc.hpp"
#include "memorymap.hpp"
#include "serial.hpp"
#include "geometry/cube.hpp"
#include "math/vec4.hpp"
@ -59,10 +61,14 @@ void transform(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
parameter.append<ta_global_parameter::polygon_type_0>() =
ta_global_parameter::polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
0, // texture_control_word
0, // data_size_for_sort_dma
0 // next_address_for_sort_dma
);
auto& face = cube::faces[face_ix];
constexpr uint32_t strip_length = 3;
@ -116,13 +122,14 @@ void transform(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / z;
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
parameter.append<ta_vertex_parameter::polygon_type_1>() =
ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
color.z // b
);
}
}
@ -163,8 +170,6 @@ void main()
, .punch_through = 0
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
holly.SOFTRESET = 0;
@ -182,8 +187,10 @@ void main()
};
while (1) {
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
640, 480);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
//lights[0].x = cos(theta) * 10;
//lights[0].z = sin(theta) * 10;
@ -195,7 +202,7 @@ void main()
for (uint32_t i = 0; i < cube::num_faces; i++) {
transform(parameter, i, theta, lights);
}
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_opaque_list();
core_start_render(frame_ix, num_frames);

View File

@ -40,7 +40,6 @@ FONT_BITMAP_OBJ = \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o \
serial.o \
sperrypc.data.o
example/font_bitmap.elf: LDSCRIPT = $(LIB)/alt.lds
@ -53,7 +52,6 @@ FONT_OUTLINE_OBJ = \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o \
serial.o \
dejavusansmono.data.o
example/font_outline.elf: LDSCRIPT = $(LIB)/alt.lds
@ -66,7 +64,6 @@ FONT_OUTLINE_PUNCH_THROUGH_OBJ = \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o \
serial.o \
dejavusansmono_mono.data.o
example/font_outline_punch_through.elf: LDSCRIPT = $(LIB)/alt.lds
@ -185,7 +182,6 @@ MACAW_CUBE_RENDER_TO_TEXTURE_OBJ = \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o \
serial.o \
macaw.data.o
example/macaw_cube_render_to_texture.elf: LDSCRIPT = $(LIB)/alt.lds
@ -203,7 +199,7 @@ example/maple_device_request.elf: $(START_OBJ) $(MAPLE_DEVICE_REQUEST_OBJ)
MAPLE_CONTROLLER_OBJ = \
example/maple_controller.o \
vga.o \
serial.o \
sh7091/serial.o \
maple/maple.o
example/maple_controller.elf: LDSCRIPT = $(LIB)/alt.lds
@ -237,7 +233,6 @@ MAPLE_ANALOG_OBJ = \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o \
serial.o \
maple/maple.o
example/maple_analog.elf: LDSCRIPT = $(LIB)/alt.lds

View File

@ -1,20 +1,22 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "holly/core.hpp"
#include "holly/core_bits.hpp"
#include "holly/ta_parameter.hpp"
#include "holly/ta_fifo_polygon_converter.hpp"
#include "holly/texture_memory_alloc.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 "memorymap.hpp"
#include "holly/background.hpp"
#include "holly/region_array.hpp"
#include "holly/ta_bits.hpp"
#include "twiddle.hpp"
#include "serial.hpp"
#include "sperrypc.hpp"
@ -92,25 +94,35 @@ constexpr uint32_t strip_length = (sizeof (strip_vertices)) / (sizeof (struct ve
uint32_t transform(uint32_t * ta_parameter_buf, const char * s, const uint32_t len)
{
auto parameter = ta_parameter_writer(ta_parameter_buf);
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
for (uint32_t string_ix = 0; string_ix < len; string_ix++) {
auto polygon = global_polygon_type_0(texture_address);
polygon.parameter_control_word = para_control::para_type::polygon_or_modifier_volume
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
| obj_control::texture;
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
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
| tsp_instruction_word::texture_u_size::_8 // 8px
| tsp_instruction_word::texture_v_size::_8; // 8px
| tsp_instruction_word::texture_u_size::from_int(8)
| tsp_instruction_word::texture_v_size::from_int(8);
polygon.texture_control_word = texture_control_word::pixel_format::_4bpp_palette
const uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
const uint32_t texture_control_word = texture_control_word::pixel_format::_4bpp_palette
| texture_control_word::scan_order::twiddled
| texture_control_word::texture_address((texture_address + 8 * 8 * (s[string_ix] - ' ')) / 8);
parameter.append<global_polygon_type_0>() = polygon;
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
@ -125,16 +137,18 @@ uint32_t transform(uint32_t * ta_parameter_buf, const char * s, const uint32_t l
y += 240.f;
z = 1.f / (z + 10.f);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
parameter.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,
strip_vertices[i].v,
0x00000000, // base_color
end_of_strip);
0, // base_color
0 // offset_color
);
}
}
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
return parameter.offset;
}
@ -236,8 +250,6 @@ void main()
, .punch_through = 0
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
holly.SOFTRESET = 0;
@ -251,8 +263,10 @@ void main()
const char ana[18] = "A from ana i know";
while (true) {
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
640, 480);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
uint32_t ta_parameter_size = transform(ta_parameter_buf, ana, 17);
ta_polygon_converter_transfer(ta_parameter_buf, ta_parameter_size);
ta_wait_opaque_list();

View File

@ -1,27 +1,27 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "holly/core.hpp"
#include "holly/core_bits.hpp"
#include "holly/ta_parameter.hpp"
#include "holly/ta_fifo_polygon_converter.hpp"
#include "holly/texture_memory_alloc.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 "memorymap.hpp"
#include "holly/background.hpp"
#include "holly/region_array.hpp"
#include "holly/ta_bits.hpp"
#include "twiddle.hpp"
#include "serial.hpp"
#include "palette.hpp"
#include "font/font.hpp"
#include "dejavusansmono.hpp"
#include "sperrypc.hpp"
struct vertex {
float x;
float y;
@ -58,27 +58,35 @@ uint32_t transform(ta_parameter_writer& parameter,
continue;
}
auto polygon = global_polygon_type_0(texture_address);
polygon.parameter_control_word = para_control::para_type::polygon_or_modifier_volume
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
| obj_control::texture;
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::src_alpha
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::src_alpha
| tsp_instruction_word::dst_alpha_instr::one
| tsp_instruction_word::fog_control::no_fog
| tsp_instruction_word::use_alpha
| tsp_instruction_word::texture_u_size::from_int(texture_width)
| tsp_instruction_word::texture_v_size::from_int(texture_height);
polygon.texture_control_word = texture_control_word::pixel_format::_4bpp_palette
const uint32_t texture_control_word = texture_control_word::pixel_format::_4bpp_palette
| texture_control_word::scan_order::twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<global_polygon_type_0>() = polygon;
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
float x = strip_vertices[i].x;
float y = strip_vertices[i].y;
float z = strip_vertices[i].z;
@ -99,11 +107,14 @@ uint32_t transform(ta_parameter_writer& parameter,
u = u / static_cast<float>(texture_width);
v = v / static_cast<float>(texture_height);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_3>() =
ta_vertex_parameter::polygon_type_3(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
u, v,
0x00000000, // base_color
end_of_strip);
0, // base_color
0 // offset_color
);
}
advance += glyph.metrics.horiAdvance;
@ -117,26 +128,34 @@ uint32_t transform2(ta_parameter_writer& parameter,
{
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
auto polygon = global_polygon_type_0(texture_address);
polygon.parameter_control_word = para_control::para_type::polygon_or_modifier_volume
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
| obj_control::texture;
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::src_alpha
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::src_alpha
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog
| tsp_instruction_word::texture_u_size::from_int(texture_width)
| tsp_instruction_word::texture_v_size::from_int(texture_height);
polygon.texture_control_word = texture_control_word::pixel_format::_4bpp_palette
const uint32_t texture_control_word = texture_control_word::pixel_format::_4bpp_palette
| texture_control_word::scan_order::twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<global_polygon_type_0>() = polygon;
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
float x = strip_vertices[i].x;
float y = strip_vertices[i].y;
float z = strip_vertices[i].z;
@ -150,11 +169,14 @@ uint32_t transform2(ta_parameter_writer& parameter,
float u = strip_vertices[i].u;
float v = strip_vertices[i].v;
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_3>() =
ta_vertex_parameter::polygon_type_3(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
u, v,
0x00000000, // base_color
end_of_strip);
0, // base_color
0 // offset_color
);
}
return parameter.offset;
@ -230,8 +252,6 @@ void main()
, .punch_through = 0
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
holly.SOFTRESET = 0;
@ -246,8 +266,10 @@ void main()
const char cabal[27] = "where is this secret cabal";
while (true) {
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
640, 480);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
auto parameter = ta_parameter_writer(ta_parameter_buf);
@ -268,7 +290,7 @@ void main()
cabal, 26,
font->glyph_height * 1);
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_translucent_list();

View File

@ -1,27 +1,27 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "holly/core.hpp"
#include "holly/core_bits.hpp"
#include "holly/ta_parameter.hpp"
#include "holly/ta_fifo_polygon_converter.hpp"
#include "holly/texture_memory_alloc.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 "memorymap.hpp"
#include "holly/background.hpp"
#include "holly/region_array.hpp"
#include "holly/ta_bits.hpp"
#include "twiddle.hpp"
#include "serial.hpp"
#include "palette.hpp"
#include "font/font.hpp"
#include "dejavusansmono_mono.hpp"
#include "sperrypc.hpp"
struct vertex {
float x;
float y;
@ -58,27 +58,34 @@ uint32_t transform(ta_parameter_writer& parameter,
continue;
}
auto polygon = global_polygon_type_0(texture_address);
polygon.parameter_control_word = para_control::para_type::polygon_or_modifier_volume
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
| para_control::list_type::punch_through
| obj_control::col_type::packed_color
| obj_control::texture;
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::src_alpha
| tsp_instruction_word::dst_alpha_instr::one
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::src_alpha
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog
//| tsp_instruction_word::use_alpha
| tsp_instruction_word::texture_u_size::from_int(texture_width)
| tsp_instruction_word::texture_v_size::from_int(texture_height);
polygon.texture_control_word = texture_control_word::pixel_format::_4bpp_palette
const uint32_t texture_control_word = texture_control_word::pixel_format::_4bpp_palette
| texture_control_word::scan_order::twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<global_polygon_type_0>() = polygon;
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
float x = strip_vertices[i].x;
float y = strip_vertices[i].y;
float z = strip_vertices[i].z;
@ -99,11 +106,14 @@ uint32_t transform(ta_parameter_writer& parameter,
u = u / static_cast<float>(texture_width);
v = v / static_cast<float>(texture_height);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_3>() =
ta_vertex_parameter::polygon_type_3(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
u, v,
0x00000000, // base_color
end_of_strip);
0, // base_color
0 // offset_color
);
}
advance += glyph.metrics.horiAdvance;
@ -117,26 +127,34 @@ uint32_t transform2(ta_parameter_writer& parameter,
{
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
auto polygon = global_polygon_type_0(texture_address);
polygon.parameter_control_word = para_control::para_type::polygon_or_modifier_volume
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
| obj_control::texture;
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::src_alpha
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::src_alpha
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog
| tsp_instruction_word::texture_u_size::from_int(texture_width)
| tsp_instruction_word::texture_v_size::from_int(texture_height);
polygon.texture_control_word = texture_control_word::pixel_format::_4bpp_palette
const uint32_t texture_control_word = texture_control_word::pixel_format::_4bpp_palette
| texture_control_word::scan_order::twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<global_polygon_type_0>() = polygon;
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
float x = strip_vertices[i].x;
float y = strip_vertices[i].y;
float z = strip_vertices[i].z;
@ -150,11 +168,14 @@ uint32_t transform2(ta_parameter_writer& parameter,
float u = strip_vertices[i].u;
float v = strip_vertices[i].v;
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_3>() =
ta_vertex_parameter::polygon_type_3(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
u, v,
0x00000000, // base_color
end_of_strip);
0, // base_color
0 // offset_color
);
}
return parameter.offset;
@ -234,8 +255,6 @@ void main()
, .punch_through = 16 * 4
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
holly.SOFTRESET = 0;
@ -251,15 +270,17 @@ void main()
const char cabal[27] = "where is this secret cabal";
while (true) {
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
640, 480);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
auto parameter = ta_parameter_writer(ta_parameter_buf);
transform2(parameter,
font->texture_width, font->texture_height);
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
transform(parameter,
font->texture_width, font->texture_height,
@ -275,7 +296,7 @@ void main()
cabal, 26,
font->glyph_height * 1);
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_punch_through_list();

View File

@ -1,19 +1,21 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly.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/isp_tsp.hpp"
#include "holly/ta_bits.hpp"
#include "holly/region_array.hpp"
#include "holly/background.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "memorymap.hpp"
#include "serial.hpp"
#include "geometry/icosphere.hpp"
#include "geometry/suzanne.hpp"
@ -21,7 +23,7 @@
constexpr float half_degree = 0.01745329f / 2;
#define MODEL suzanne
#define MODEL icosphere
vec3 rotate(const vec3& vertex,
const float theta)
@ -61,16 +63,18 @@ void transform(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
parameter.append<ta_global_parameter::polygon_type_0>() =
ta_global_parameter::polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
0, // texture_control_word
0, // data_size_for_sort_dma
0 // next_address_for_sort_dma
);
auto& face = MODEL::faces[face_ix];
constexpr uint32_t strip_length = 3;
for (uint32_t i = 0; i < strip_length; i++) {
bool end_of_strip = i == strip_length - 1;
// world transform
uint32_t vertex_ix = face[i].vertex;
auto& vertex = MODEL::vertices[vertex_ix];
@ -130,13 +134,15 @@ void transform(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / z;
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_1>() =
ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
color.z // b
);
}
}
@ -156,10 +162,14 @@ void transform2(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
parameter.append<ta_global_parameter::polygon_type_0>() =
ta_global_parameter::polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
0, // texture_control_word
0, // data_size_for_sort_dma
0 // next_address_for_sort_dma
);
constexpr vec3 triangle[] = {
{ 0.f, -1.f, 0.f},
@ -169,7 +179,6 @@ void transform2(ta_parameter_writer& parameter,
constexpr uint32_t strip_length = 3;
for (uint32_t i = 0; i < strip_length; i++) {
bool end_of_strip = i == strip_length - 1;
float x = triangle[i].x;
float y = triangle[i].y;
float z = triangle[i].z;
@ -196,13 +205,15 @@ void transform2(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / z;
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_1>() =
ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
color.z // b
);
}
}
@ -285,7 +296,7 @@ void main()
transform2(parameter, lights[1], {0.f, 1.f, 0.f, 1.f});
transform2(parameter, lights[2], {0.f, 0.f, 1.f, 1.f});
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_opaque_list();
core_start_render(frame_ix, num_frames);

View File

@ -4,12 +4,15 @@
#include "vga.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly.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"
@ -42,12 +45,35 @@ uint32_t transform(uint32_t * ta_parameter_buf,
const uint32_t strip_length)
{
auto parameter = ta_parameter_writer(ta_parameter_buf);
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
parameter.append<global_polygon_type_0>() = global_polygon_type_0(texture_address);
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
| obj_control::texture;
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
| tsp_instruction_word::texture_u_size::from_int(128)
| tsp_instruction_word::texture_v_size::from_int(128);
const uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
const uint32_t texture_control_word = texture_control_word::pixel_format::_565
| texture_control_word::scan_order::non_twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
float x = strip_vertices[i].x;
float y = strip_vertices[i].y;
float z = strip_vertices[i].z;
@ -62,15 +88,18 @@ uint32_t transform(uint32_t * ta_parameter_buf,
y += 240.f;
z = 1.f / (z + 10.f);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.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,
strip_vertices[i].v,
strip_vertices[i].color,
end_of_strip);
0 // offset_color
);
}
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
return parameter.offset;
}
@ -79,7 +108,7 @@ void init_texture_memory(const struct opb_size& opb_size)
{
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
background_parameter(mem->background);
background_parameter(mem->background, 0xff00ff00);
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
@ -128,8 +157,6 @@ void main()
, .punch_through = 0
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
holly.SOFTRESET = 0;
@ -141,7 +168,10 @@ void main()
constexpr uint32_t num_frames = 1;
while (true) {
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc);
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();

View File

@ -1,21 +1,22 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly.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 "holly/texture_memory_alloc.hpp"
#include "memorymap.hpp"
#include "serial.hpp"
#include "macaw.hpp"
struct vertex {
@ -63,12 +64,35 @@ void transform(ta_parameter_writer& parameter,
const vertex * strip_vertices,
const uint32_t strip_length)
{
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
parameter.append<global_polygon_type_0>() = global_polygon_type_0();
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
| obj_control::texture;
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
| tsp_instruction_word::texture_u_size::from_int(128)
| tsp_instruction_word::texture_v_size::from_int(128);
const uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
const uint32_t texture_control_word = texture_control_word::pixel_format::_565
| texture_control_word::scan_order::non_twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
float x = strip_vertices[i].x;
float y = strip_vertices[i].y;
float z = strip_vertices[i].z;
@ -98,12 +122,15 @@ void transform(ta_parameter_writer& parameter,
z = 1 / z;
parameter.append<vertex_polygon_type_0>() =
vertex_polygon_type_0(x, y, z,
//strip_vertices[i].u,
//strip_vertices[i].v,
color,
end_of_strip);
bool end_of_strip = i == strip_length - 1;
parameter.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,
strip_vertices[i].v,
0, // base_color
0 // offset_color
);
}
}
@ -160,8 +187,6 @@ void main()
, .punch_through = 0
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
holly.SOFTRESET = 0;
@ -173,12 +198,16 @@ void main()
constexpr uint32_t num_frames = 1;
while (1) {
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc, 640, 480);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
auto parameter = ta_parameter_writer(ta_parameter_buf);
for (uint32_t i = 0; i < num_faces; i++) {
transform(parameter, cube_faces[i], 4);
}
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_opaque_list();
core_start_render(frame_ix, num_frames);

View File

@ -1,21 +1,22 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly.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 "holly/texture_memory_alloc.hpp"
#include "memorymap.hpp"
#include "serial.hpp"
#include "macaw.hpp"
struct vertex {
@ -67,51 +68,71 @@ void transform(ta_parameter_writer& parameter,
const uint32_t texture_address,
const uint32_t texture_width)
{
auto polygon = global_polygon_type_0(texture_address);
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
| obj_control::texture;
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 texture_control_word = texture_control_word::pixel_format::_565
| texture_control_word::scan_order::non_twiddled
| texture_control_word::texture_address(texture_address / 8);
uint32_t tsp_instruction_word = 0;
switch (texture_width) {
case 32:
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog
| tsp_instruction_word::texture_u_size::_32
| tsp_instruction_word::texture_v_size::_32
| tsp_instruction_word::texture_u_size::from_int(32)
| tsp_instruction_word::texture_v_size::from_int(32)
| tsp_instruction_word::use_alpha;
break;
case 64:
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog
| tsp_instruction_word::texture_u_size::_64
| tsp_instruction_word::texture_v_size::_64
| tsp_instruction_word::texture_u_size::from_int(64)
| tsp_instruction_word::texture_v_size::from_int(64)
| tsp_instruction_word::use_alpha;
break;
case 128:
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog
| tsp_instruction_word::texture_u_size::_128
| tsp_instruction_word::texture_v_size::_128
| tsp_instruction_word::texture_u_size::from_int(128)
| tsp_instruction_word::texture_v_size::from_int(128)
| tsp_instruction_word::use_alpha;
break;
case 256:
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog
| tsp_instruction_word::texture_u_size::_256
| tsp_instruction_word::texture_v_size::_256
| tsp_instruction_word::texture_u_size::from_int(256)
| tsp_instruction_word::texture_v_size::from_int(256)
| tsp_instruction_word::use_alpha;
break;
case 512:
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog
| tsp_instruction_word::texture_u_size::_512
| tsp_instruction_word::texture_v_size::_512
| tsp_instruction_word::texture_u_size::from_int(512)
| tsp_instruction_word::texture_v_size::from_int(512)
| tsp_instruction_word::use_alpha;
break;
default: break;
}
parameter.append<global_polygon_type_0>() = polygon;
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
@ -144,12 +165,14 @@ void transform(ta_parameter_writer& parameter,
z = 1 / z;
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
parameter.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,
strip_vertices[i].v,
color,
end_of_strip);
0, // base_color
0 // offset_color
);
}
}
@ -186,9 +209,10 @@ void render(const uint32_t width, const uint32_t height,
const uint32_t texture_width,
uint32_t * ta_parameter_buf)
{
const uint32_t tiles = (width / 32) * (height / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
width, height);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
width / 32,
height / 32);
auto parameter = ta_parameter_writer(ta_parameter_buf);
for (uint32_t i = 0; i < num_faces; i++) {
@ -197,7 +221,7 @@ void render(const uint32_t width, const uint32_t height,
texture_address,
texture_width);
}
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_opaque_list();
}

View File

@ -4,12 +4,15 @@
#include "vga.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly.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"
@ -43,16 +46,35 @@ uint32_t transform(uint32_t * ta_parameter_buf,
const uint32_t strip_length)
{
auto parameter = ta_parameter_writer(ta_parameter_buf);
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
auto polygon = global_polygon_type_0(texture_address);
polygon.texture_control_word = texture_control_word::pixel_format::_565
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
| obj_control::texture;
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
| tsp_instruction_word::texture_u_size::from_int(128)
| tsp_instruction_word::texture_v_size::from_int(128);
const uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
const uint32_t texture_control_word = texture_control_word::pixel_format::_565
| texture_control_word::scan_order::twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<global_polygon_type_0>() = polygon;
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
float x = strip_vertices[i].x;
float y = strip_vertices[i].y;
float z = strip_vertices[i].z;
@ -67,15 +89,18 @@ uint32_t transform(uint32_t * ta_parameter_buf,
y += 240.f;
z = 1.f / (z + 10.f);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.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,
strip_vertices[i].v,
strip_vertices[i].color,
end_of_strip);
0 // offset_color
);
}
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
return parameter.offset;
}
@ -84,7 +109,7 @@ void init_texture_memory(const struct opb_size& opb_size)
{
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
background_parameter(mem->background);
background_parameter(mem->background, 0xff00ff00);
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
@ -132,8 +157,6 @@ void main()
, .punch_through = 0
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
holly.SOFTRESET = 0;
@ -145,7 +168,10 @@ void main()
constexpr uint32_t num_frames = 1;
while (true) {
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc);
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();

View File

@ -4,17 +4,20 @@
#include "align.hpp"
#include "vga.hpp"
#include "holly.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_vertex_parameter.hpp"
#include "holly/ta_global_parameter.hpp"
#include "holly/ta_bits.hpp"
#include "holly/isp_tsp.hpp"
#include "holly/region_array.hpp"
#include "holly/background.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "memorymap.hpp"
#include "serial.hpp"
#include "sh7091/serial.hpp"
#include "geometry/border.hpp"
#include "geometry/circle.hpp"
@ -57,15 +60,6 @@ void do_get_condition(uint32_t * command_buf,
return;
}
/*
bool a = ft0::data_transfer::digital_button::a(data_fields.data.digital_button);
if (a == 0) {
serial::string("port ");
serial::integer<uint8_t>(port);
serial::string(" `a` press ");
serial::integer<uint8_t>(a);
}
*/
data[port].analog_axis_3 = data_fields.data.analog_axis_3;
data[port].analog_axis_4 = data_fields.data.analog_axis_4;
}
@ -73,7 +67,7 @@ void do_get_condition(uint32_t * command_buf,
void transform(ta_parameter_writer& parameter,
const vec3 * vertices,
const face& face,
const face_vn& face,
const vec4& color,
const vec3& position,
const float scale
@ -91,14 +85,17 @@ void transform(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
parameter.append<ta_global_parameter::polygon_type_0>() =
ta_global_parameter::polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
0, // texture_control_word
0, // data_size_for_sort_dma
0 // next_address_for_sort_dma
);
constexpr uint32_t strip_length = 3;
for (uint32_t i = 0; i < strip_length; i++) {
bool end_of_strip = i == strip_length - 1;
// world transform
uint32_t vertex_ix = face[i].vertex;
@ -131,13 +128,16 @@ void transform(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / z;
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_1>() =
ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
color.z // b
);
}
}
@ -223,7 +223,7 @@ void main()
);
}
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_opaque_list();
core_start_render(frame_ix, num_frames);

View File

@ -4,10 +4,11 @@
#include "align.hpp"
#include "maple/maple.hpp"
#include "maple/maple_impl.hpp"
#include "maple/maple_bus_bits.hpp"
#include "maple/maple_bus_commands.hpp"
#include "maple/maple_bus_ft0.hpp"
#include "serial.hpp"
#include "sh7091/serial.hpp"
uint32_t _command_buf[1024 / 4 + 32] = {0};
uint32_t _receive_buf[1024 / 4 + 32] = {0};
@ -47,10 +48,11 @@ void do_get_condition(uint32_t port)
std::byteswap(function_type::controller));
maple::dma_start(command_buf);
using response_type = struct maple::command_response<data_transfer::data_fields<struct ft0::data_transfer::data_format>>;
auto response = reinterpret_cast<response_type *>(receive_buf);
using response_type = data_transfer<ft0::data_transfer::data_format>;
using command_response_type = struct maple::command_response<response_type::data_fields>;
auto response = reinterpret_cast<command_response_type *>(receive_buf);
auto& bus_data = response->bus_data;
if (bus_data.command_code != data_transfer::command_code) {
if (bus_data.command_code != response_type::command_code) {
return;
}
auto& data_fields = bus_data.data_fields;
@ -69,20 +71,17 @@ void do_get_condition(uint32_t port)
void do_device_request()
{
using response_type = struct maple::command_response<device_status::data_fields>;
constexpr uint32_t response_size = align_32byte(sizeof (response_type));
using command_type = device_request;
using response_type = device_status;
maple::init_host_command_all_ports(command_buf, receive_buf,
device_request::command_code,
(sizeof (device_request::data_fields)), // command_data_size
(sizeof (device_status::data_fields))); // response_data_size
maple::init_host_command_all_ports<command_type, response_type>(command_buf, receive_buf);
maple::dma_start(command_buf);
using command_response_type = struct maple::command_response<response_type::data_fields>;
auto response = reinterpret_cast<command_response_type *>(receive_buf);
for (uint8_t port = 0; port < 4; port++) {
auto response = reinterpret_cast<response_type *>(&receive_buf[response_size * port / 4]);
auto& bus_data = response->bus_data;
auto& data_fields = response->bus_data.data_fields;
auto& bus_data = response[port].bus_data;
auto& data_fields = response[port].bus_data.data_fields;
if (bus_data.command_code != device_status::command_code) {
// the controller is disconnected
} else {

View File

@ -3,15 +3,18 @@
#include "align.hpp"
#include "vga.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly.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/isp_tsp.hpp"
#include "holly/ta_bits.hpp"
#include "holly/region_array.hpp"
#include "holly/background.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "memorymap.hpp"
#include "macaw.hpp"
@ -43,29 +46,60 @@ uint32_t transform(uint32_t * ta_parameter_buf,
bool translucent)
{
auto parameter = ta_parameter_writer(ta_parameter_buf);
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
if (translucent) {
// translucent untextured
auto polygon = global_polygon_type_0();
polygon.parameter_control_word = para_control::para_type::polygon_or_modifier_volume
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
| obj_control::gouraud;
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
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::src_alpha
| tsp_instruction_word::fog_control::no_fog
| tsp_instruction_word::use_alpha;
parameter.append<global_polygon_type_0>() = polygon;
parameter.append<ta_global_parameter::polygon_type_0>() =
ta_global_parameter::polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0, // texture_control_word
0, // data_size_for_sort_dma
0 // next_address_for_sort_dma
);
} else {
// opaque textured
parameter.append<global_polygon_type_0>() = global_polygon_type_0(texture_address);
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
| obj_control::texture;
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
| tsp_instruction_word::texture_u_size::from_int(128)
| tsp_instruction_word::texture_v_size::from_int(128);
const uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
const uint32_t texture_control_word = texture_control_word::pixel_format::_565
| texture_control_word::scan_order::non_twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<ta_global_parameter::polygon_type_0>() =
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++) {
bool end_of_strip = i == strip_length - 1;
float x = strip_vertices[i].x;
float y = strip_vertices[i].y;
float z = strip_vertices[i].z;
@ -80,15 +114,18 @@ uint32_t transform(uint32_t * ta_parameter_buf,
y += 240.f;
z = 1.f / (z + 10.f);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.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,
strip_vertices[i].v,
strip_vertices[i].color,
end_of_strip);
0 // offset_color
);
}
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
return parameter.offset;
}
@ -97,7 +134,7 @@ void init_texture_memory(const struct opb_size& opb_size)
{
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
background_parameter(mem->background);
background_parameter(mem->background, 0xffffff00);
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
@ -142,8 +179,6 @@ void main()
, .punch_through = 0
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
holly.SOFTRESET = 0;
@ -155,7 +190,10 @@ void main()
constexpr uint32_t num_frames = 1;
while (true) {
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
uint32_t ta_parameter_size = 0;
ta_parameter_size += transform(&ta_parameter_buf[ta_parameter_size / 4], strip_vertices, strip_length, 0);
ta_parameter_size += transform(&ta_parameter_buf[ta_parameter_size / 4], strip_vertices, strip_length, 1);

View File

@ -1,19 +1,21 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly.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/isp_tsp.hpp"
#include "holly/ta_bits.hpp"
#include "holly/region_array.hpp"
#include "holly/background.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "memorymap.hpp"
#include "serial.hpp"
#include "geometry/wiffle.hpp"
#include "math/vec4.hpp"
@ -59,16 +61,19 @@ void transform(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
parameter.append<ta_global_parameter::polygon_type_0>() =
ta_global_parameter::polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
0, // texture_control_word
0, // data_size_for_sort_dma
0 // next_address_for_sort_dma
);
auto& face = MODEL::faces[face_ix];
constexpr uint32_t strip_length = 3;
for (uint32_t i = 0; i < strip_length; i++) {
bool end_of_strip = i == strip_length - 1;
// world transform
uint32_t vertex_ix = face[i].vertex;
auto& vertex = MODEL::vertices[vertex_ix];
@ -140,13 +145,15 @@ void transform(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / z;
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_1>() =
ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
color.z // b
);
}
}
@ -166,10 +173,14 @@ void transform2(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
parameter.append<ta_global_parameter::polygon_type_0>() =
ta_global_parameter::polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
0, // texture_control_word
0, // data_size_for_sort_dma
0 // next_address_for_sort_dma
);
constexpr vec3 triangle[] = {
{ 0.f, -1.f, 0.f},
@ -179,7 +190,6 @@ void transform2(ta_parameter_writer& parameter,
constexpr uint32_t strip_length = 3;
for (uint32_t i = 0; i < strip_length; i++) {
bool end_of_strip = i == strip_length - 1;
float x = triangle[i].x;
float y = triangle[i].y;
float z = triangle[i].z;
@ -206,13 +216,15 @@ void transform2(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / z;
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_1>() =
ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(end_of_strip),
x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
color.z // b
);
}
}
@ -295,7 +307,7 @@ void main()
transform2(parameter, lights[1], {0.f, 1.f, 0.f, 1.f});
transform2(parameter, lights[2], {0.f, 0.f, 1.f, 1.f});
parameter.append<global_end_of_list>() = global_end_of_list();
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_opaque_list();
core_start_render(frame_ix, num_frames);

View File

@ -22,7 +22,7 @@ namespace border {
{ -0.000000f, 1.000000f, -0.000000f },
};
constexpr face faces[] = {
constexpr face_vn faces[] = {
{{ 5, 0}, {11, 0}, { 7, 0}},
{{ 4, 0}, {10, 0}, { 9, 0}},
{{ 5, 0}, { 8, 0}, {11, 0}},
@ -37,6 +37,6 @@ namespace border {
{{ 1, 0}, { 3, 0}, { 6, 0}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vn));
}

View File

@ -42,7 +42,7 @@ namespace circle {
{ -0.000000f, 1.000000f, -0.000000f },
};
constexpr face faces[] = {
constexpr face_vn faces[] = {
{{31, 0}, { 0, 0}, { 1, 0}},
{{30, 0}, {31, 0}, { 1, 0}},
{{20, 0}, {13, 0}, {18, 0}},
@ -75,6 +75,6 @@ namespace circle {
{{16, 0}, {17, 0}, {15, 0}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vn));
}

View File

@ -30,7 +30,7 @@ namespace cube {
{ -0.000000f, 1.000000f, -0.000000f },
};
constexpr face faces[] = {
constexpr face_vtn faces[] = {
{{1, 0, 0}, {2, 0, 0}, {0, 1, 0}},
{{3, 1, 1}, {6, 2, 1}, {2, 3, 1}},
{{7, 0, 2}, {4, 3, 2}, {6, 1, 2}},
@ -45,6 +45,6 @@ namespace cube {
{{3, 1, 5}, {1, 0, 5}, {5, 2, 5}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vtn));
}

View File

@ -131,7 +131,7 @@ namespace icosphere {
{ 0.471300f, -0.661700f, 0.583100f },
};
constexpr face faces[] = {
constexpr face_vn faces[] = {
{{ 0, 0}, {13, 0}, {12, 0}},
{{ 1, 1}, {13, 1}, {15, 1}},
{{ 0, 2}, {12, 2}, {17, 2}},
@ -214,6 +214,6 @@ namespace icosphere {
{{13, 79}, { 1, 79}, {14, 79}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vn));
}

View File

@ -1457,7 +1457,7 @@ namespace suzanne {
{ 0.360400f, 0.828300f, 0.429000f },
};
constexpr face faces[] = {
constexpr face_vn faces[] = {
{{ 46, 0}, { 2, 0}, { 44, 0}},
{{ 3, 1}, { 47, 1}, { 45, 1}},
{{ 44, 2}, { 4, 2}, { 42, 2}},
@ -2427,6 +2427,6 @@ namespace suzanne {
{{504, 940}, {322, 940}, {320, 940}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vn));
}

View File

@ -335,7 +335,7 @@ namespace wiffle {
{ 0.500000f, -0.500000f, -0.707100f },
};
constexpr face faces[] = {
constexpr face_vn faces[] = {
{{ 0, 0}, { 1, 0}, { 2, 0}},
{{ 1, 0}, { 3, 0}, { 2, 0}},
{{ 0, 0}, { 4, 0}, { 1, 0}},
@ -914,6 +914,6 @@ namespace wiffle {
{{250, 24}, {153, 24}, {151, 24}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vn));
}

View File

@ -1,3 +1,5 @@
#pragma once
#include <cstdint>
#include "../float_uint32.hpp"
@ -35,6 +37,8 @@ namespace ta_alloc_ctrl {
namespace opb_mode {
constexpr uint32_t increasing_addresses = 0 << 20;
constexpr uint32_t decreasing_addresses = 1 << 20;
constexpr uint32_t bit_mask = 0x1 << 20;
}
namespace pt_opb {
@ -42,6 +46,8 @@ namespace ta_alloc_ctrl {
constexpr uint32_t _8x4byte = 1 << 16;
constexpr uint32_t _16x4byte = 2 << 16;
constexpr uint32_t _32x4byte = 3 << 16;
constexpr uint32_t bit_mask = 0x3 << 16;
}
namespace tm_opb {
@ -49,6 +55,8 @@ namespace ta_alloc_ctrl {
constexpr uint32_t _8x4byte = 1 << 12;
constexpr uint32_t _16x4byte = 2 << 12;
constexpr uint32_t _32x4byte = 3 << 12;
constexpr uint32_t bit_mask = 0x3 << 12;
}
namespace t_opb {
@ -56,6 +64,8 @@ namespace ta_alloc_ctrl {
constexpr uint32_t _8x4byte = 1 << 8;
constexpr uint32_t _16x4byte = 2 << 8;
constexpr uint32_t _32x4byte = 3 << 8;
constexpr uint32_t bit_mask = 0x3 << 8;
}
namespace om_opb {
@ -63,6 +73,8 @@ namespace ta_alloc_ctrl {
constexpr uint32_t _8x4byte = 1 << 4;
constexpr uint32_t _16x4byte = 2 << 4;
constexpr uint32_t _32x4byte = 3 << 4;
constexpr uint32_t bit_mask = 0x3 << 4;
}
namespace o_opb {
@ -70,6 +82,8 @@ namespace ta_alloc_ctrl {
constexpr uint32_t _8x4byte = 1 << 0;
constexpr uint32_t _16x4byte = 2 << 0;
constexpr uint32_t _32x4byte = 3 << 0;
constexpr uint32_t bit_mask = 0x3 << 0;
}
}
@ -85,11 +99,15 @@ namespace ta_yuv_tex_ctrl {
namespace yuv_form {
constexpr uint32_t yuv420 = 0 << 24;
constexpr uint32_t yuv422 = 1 << 24;
constexpr uint32_t bit_mask = 0x1 << 24;
}
namespace yuv_tex {
constexpr uint32_t one_texture = 0 << 16;
constexpr uint32_t multiple_textures = 1 << 16;
constexpr uint32_t bit_mask = 0x1 << 16;
}
constexpr uint32_t yuv_v_size(uint32_t num) { return (num & 0x3f) << 8; }

View File

@ -3,8 +3,8 @@
#include "align.hpp"
#include "sh7091.hpp"
#include "sh7091_bits.hpp"
#include "sh7091/sh7091.hpp"
#include "sh7091/sh7091_bits.hpp"
#include "systembus.hpp"
#include "systembus_bits.hpp"
@ -97,9 +97,11 @@ void init_block_write(uint32_t * command_buf, uint32_t * receive_buf,
void dma_start(uint32_t * command_buf)
{
sh7091.DMAC.DMAOR = DMAOR__DDT // on-demand data transfer mode
| DMAOR__PR__CH2_CH0_CH1_CH3 // priority mode; CH2 > CH0 > CH1 > CH3
| DMAOR__DME; // DMAC master enable
using namespace dmac;
sh7091.DMAC.DMAOR = dmaor::ddt::on_demand_data_transfer_mode /* on-demand data transfer mode */
| dmaor::pr::ch2_ch0_ch1_ch3 /* priority mode; CH2 > CH0 > CH1 > CH3 */
| dmaor::dme::operation_enabled_on_all_channels; /* DMAC master enable */
// clear maple-DMA end status
system.ISTNRM = ISTNRM__END_OF_DMA_MAPLE_DMA;

View File

@ -43,4 +43,34 @@ void init_host_command_all_ports(uint32_t * command_buf, uint32_t * receive_buf,
host_command[3].bus_data.data_fields = data_fields;
}
template <typename C, typename R>
void init_host_command_all_ports(uint32_t * command_buf, uint32_t * receive_buf)
{
using command_type = maple::host_command<typename C::data_fields>;
using response_type = maple::command_response<typename R::data_fields>;
auto host_command = reinterpret_cast<command_type *>(command_buf);
auto response_command = reinterpret_cast<response_type *>(receive_buf);
init_host_command((uint32_t*)&host_command[0], (uint32_t*)&response_command[0],
host_instruction::port_select::a, // destination_port
ap::de::device | ap::port_select::a, C::command_code, (sizeof (typename C::data_fields)),
false); // end_flag
init_host_command((uint32_t*)&host_command[1], (uint32_t*)&response_command[1],
host_instruction::port_select::b, // destination_port
ap::de::device | ap::port_select::b, C::command_code, (sizeof (typename C::data_fields)),
false); // end_flag
init_host_command((uint32_t*)&host_command[2], (uint32_t*)&response_command[2],
host_instruction::port_select::c, // destination_port
ap::de::device | ap::port_select::c, C::command_code, (sizeof (typename C::data_fields)),
false); // end_flag
init_host_command((uint32_t*)&host_command[3], (uint32_t*)&response_command[3],
host_instruction::port_select::d, // destination_port
ap::de::device | ap::port_select::d, C::command_code, (sizeof (typename C::data_fields)),
true); // end_flag
}
}

View File

@ -107,6 +107,12 @@ inline constexpr vec<2, T> operator*(vec<2, T> const& v1, T const& scalar)
return v1 * vec<2, T>(scalar);
}
template <typename T>
inline constexpr vec<2, T> operator*(T const& scalar, vec<2, T> const& v1)
{
return vec<2, T>(scalar) * v1;
}
template <typename T>
inline constexpr vec<2, T> operator/(vec<2, T> const& v1, vec<2, T> const& v2)
{

View File

@ -9,24 +9,29 @@ namespace serial {
void init()
{
using namespace scif;
sh7091.SCIF.SCSCR2 = 0;
sh7091.SCIF.SCSMR2 = 0;
sh7091.SCIF.SCBRR2 = 1; // 520833.3
sh7091.SCIF.SCFCR2 = SCFCR2__TFRST | SCFCR2__RFRST;
sh7091.SCIF.SCFCR2 = scfcr2::tfrst::reset_operation_enabled
| scfcr2::rfrst::reset_operation_enabled;
// tx/rx trigger on 1 byte
sh7091.SCIF.SCFCR2 = 0;
sh7091.SCIF.SCSPTR2 = 0;
sh7091.SCIF.SCLSR2 = 0;
sh7091.SCIF.SCSCR2 = SCSCR2__TE | SCSCR2__RE;
sh7091.SCIF.SCSCR2 = scscr2::te::transmission_enabled
| scscr2::re::reception_enabled;
}
void character(const char c)
{
using namespace scif;
// wait for transmit fifo to become empty
while ((sh7091.SCIF.SCFSR2 & SCFSR2__TDFE) == 0);
while ((sh7091.SCIF.SCFSR2 & scfsr2::tdfe::bit_mask) == 0);
for (int i = 0; i < 100000; i++) {
asm volatile ("nop;");

View File

@ -111,7 +111,7 @@ def generate_vertices(vertices):
else:
assert type(p_c) is Vertex
p = p_c
yield f"{{ {v.x:9f}f, {v.y:9f}f, {v.z:9f}f }},"
yield f"{{ {p.x:9f}f, {p.y:9f}f, {p.z:9f}f }},"
yield "};"
yield ""