Compare commits

..

No commits in common. "1cfbda2dcdce39d52a10914d1044a859ffa09194" and "549254615ef3db4c9b2a79374b6d56d2022e8cca" have entirely different histories.

75 changed files with 1627 additions and 11477 deletions

3
.gitignore vendored
View File

@ -12,5 +12,4 @@ __pycache__
*.gch
scramble
cdi4dc
tools/ttf_outline
*.blend1
tools/ttf_outline

34
cache.cpp Normal file
View File

@ -0,0 +1,34 @@
#include "type.hpp"
#include "sh7091.hpp"
#include "sh7091_bits.hpp"
#include "cache.hpp"
extern volatile reg32 sh7091_ic_a[256][(1 << 5) / 4] __asm("sh7091_ic_a");
extern volatile reg32 sh7091_oc_a[512][(1 << 5) / 4] __asm("sh7091_oc_a");
namespace cache {
void init()
{
for (int i = 0; i < 256; i++) {
sh7091_ic_a[i][0] = 0;
}
for (int i = 0; i < 512; i++) {
sh7091_oc_a[i][0] = 0;
}
sh7091.CCN.CCR = CCR__ICI // instruction cache invalidate
| CCR__ICE // instruction cache enable
| CCR__OCI // operand cache invalidate
| CCR__OCE // operand cache enable
// | CCR__CB // enable copy-back mode for the P1 area
;
sh7091.CCN.MMUCR = 0;
asm volatile ("nop;nop;nop;nop;nop;nop;nop;nop;");
}
}

View File

@ -2,7 +2,7 @@ MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
DIR := $(dir $(MAKEFILE_PATH))
LIB ?= .
OPT ?= -O2
OPT ?= -O3
DEBUG ?= -g -gdwarf-4
GENERATED ?=
@ -55,7 +55,7 @@ IP_OBJ = \
START_OBJ = \
start.o \
runtime.o \
sh7091/cache.o
cache.o
%.bin.o: %.bin
$(BUILD_BINARY_O)
@ -130,33 +130,18 @@ audio.pcm:
%.data.o: %.data
$(BUILD_BINARY_O)
regs/%.csv: regs/%.ods
libreoffice --headless -convert-to csv:"Text - txt - csv (StarCalc)":44,34,76,,,,true --outdir regs/ $<
maple/maple_bus_commands.hpp: regs/maple_bus_commands.csv regs/gen/maple_bus_commands.py
python regs/gen/maple_bus_commands.py $< > $@
maple/maple_bus_bits.hpp: regs/maple_bus_bits.csv regs/gen/core_bits.py
python regs/gen/core_bits.py $< > $@
holly/core_bits.hpp: regs/core_bits.csv regs/gen/core_bits.py
python regs/gen/core_bits.py $< > $@
holly/holly.hpp: regs/holly.csv regs/gen/holly.py
python regs/gen/holly.py $< > $@
holly/ta_global_parameter.hpp: regs/global_parameter_format.csv regs/gen/ta_parameter_format.py
python regs/gen/ta_parameter_format.py $< ta_global_parameter > $@
holly/ta_vertex_parameter.hpp: regs/vertex_parameter_format.csv regs/gen/ta_parameter_format.py
python regs/gen/ta_parameter_format.py $< ta_vertex_parameter > $@
sh7091/sh7091.hpp: regs/sh7091.csv regs/gen/sh7091.py
python regs/gen/sh7091.py $< > $@
sh7091/sh7091_bits.hpp: regs/sh7091_bits.csv regs/gen/core_bits.py
python regs/gen/core_bits.py $< > $@
clean:
find -P \
-regextype posix-egrep \

View File

@ -1,319 +0,0 @@
#include <cstdint>
#include <bit>
#include "align.hpp"
#include "vga.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 "sh7091/serial.hpp"
#include "geometry/circle.hpp"
#include "math/vec4.hpp"
#include "math/math.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"
uint32_t _command_buf[1024 / 4 + 32];
uint32_t _receive_buf[1024 / 4 + 32];
static ft0::data_transfer::data_format data[4];
void do_get_condition(uint32_t * command_buf,
uint32_t * receive_buf)
{
using command_type = get_condition;
using response_type = data_transfer<ft0::data_transfer::data_format>;
get_condition::data_fields data_fields = {
.function_type = std::byteswap(function_type::controller)
};
maple::init_host_command_all_ports<command_type, response_type>(command_buf, receive_buf,
data_fields);
maple::dma_start(command_buf);
using command_response_type = struct maple::command_response<response_type::data_fields>;
for (uint8_t port = 0; port < 4; port++) {
auto response = reinterpret_cast<command_response_type *>(receive_buf);
auto& bus_data = response[port].bus_data;
if (bus_data.command_code != response_type::command_code) {
return;
}
auto& data_fields = bus_data.data_fields;
if ((data_fields.function_type & std::byteswap(function_type::controller)) == 0) {
return;
}
data[port].analog_axis_3 = data_fields.data.analog_axis_3;
data[port].analog_axis_4 = data_fields.data.analog_axis_4;
}
}
vec3 intersection(vec3& a, vec3& b, vec3& n)
{
const float t = (-dot(n, a)) / dot(n, b - a);
return a + t * (b - a);
}
void transform(ta_parameter_writer& parameter,
const vec3 * vertices,
const face_vn& face,
const vec4& color,
const vec3& position,
const bool enable_clipping
)
{
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
| para_control::list_type::opaque
| obj_control::col_type::floating_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;
constexpr uint32_t strip_length = 3;
vec3 points[strip_length * 2];
uint32_t positive = 0;
uint32_t negative = 0;
vec3 plane_normal = {-1.f, 0.f, 0.f};
// object transform and clip
for (uint32_t i = 0; i < strip_length; i++) {
uint32_t vertex_ix = face[i].vertex;
auto vertex = vertices[vertex_ix];
vertex = (vertex * 0.5f);
// rotate 90° around the X axis
float x = vertex.x;
float y = vertex.z;
float z = vertex.y;
// object transform
x += position.x; // object space
y += position.y; // object space
z += position.z; // object space
// clip
auto point = vec3(x, y, z);
float distance = dot(plane_normal, point);
if ((!enable_clipping) || distance > 0.0f) {
points[0 + positive] = point;
positive += 1;
} else { // is negative (or intersects)
points[(strip_length - 1) - negative] = point;
negative += 1;
}
}
uint32_t num_tris = 0;
if ((!enable_clipping) || positive == 3) {
num_tris = 1;
// nothing to clip
} else if (positive == 0) {
num_tris = 0;
// clip everything
} else if (positive == 1) {
num_tris = 1;
auto& A = points[0]; // positive
auto& B = points[1]; // negative
auto& C = points[2]; // negative
/*
// A
// /\
// / \
// -AB----AC--
// / \
// B________C
*/
auto AB_ = intersection(A, B, plane_normal);
auto AC_ = intersection(A, C, plane_normal);
points[0] = A;
points[1] = AC_;
points[2] = AB_;
} else if (positive == 2) {
num_tris = 2;
auto& A = points[0]; // positive
auto& B = points[1]; // positive
auto& C = points[2]; // negative
// A _____ B
// \ /
//--AC---BC--
// \ /
// \/
// C
auto AC_ = intersection(A, C, plane_normal);
auto BC_ = intersection(B, C, plane_normal);
points[0] = A;
points[1] = B;
points[2] = AC_;
points[3] = B;
points[4] = BC_;
points[5] = AC_;
}
for (uint32_t j = 0; j < num_tris; j++) {
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
);
for (uint32_t i = 0; i < strip_length; i++) {
float x = points[3 * j + i].x;
float y = points[3 * j + i].y;
float z = points[3 * j + i].z;
// camera transform
z += 1;
// screen space transform
x *= 240.f;
y *= 240.f;
x += 320.f;
y += 240.f;
z = 1 / 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,
1.0f, // alpha
(i == 0) ? 1.0f : 0.0f, // r
(i == 1) ? 1.0f : 0.0f, // g
(i == 2) ? 1.0f : 0.0f // b
);
}
}
}
void init_texture_memory(const struct opb_size& opb_size)
{
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
background_parameter(mem->background, 0xff220000);
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
640 / 32, // width
480 / 32, // height
opb_size
);
}
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);
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::_16x4byte;
constexpr struct opb_size opb_size = { .opaque = 16 * 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;
constexpr uint32_t num_frames = 1;
float theta = 0;
float x_pos = 0;
float y_pos = 0;
while (1) {
do_get_condition(command_buf, receive_buf);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
float x_ = static_cast<float>(data[0].analog_axis_3 - 0x80) / 127.f;
float y_ = static_cast<float>(data[0].analog_axis_4 - 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)));
if (y_ < y_pos) y_pos -= (0.09f * ((y_ - y_pos) * (y_ - y_pos)));
auto parameter = ta_parameter_writer(ta_parameter_buf);
for (uint32_t i = 0; i < circle::num_faces; i++) {
/*
transform(parameter,
circle::vertices,
circle::faces[i],
vec4{1.0f, 0.5f, 0.5f, 0.0f} * (((i/1.2f) * (1.f / circle::num_faces)) + (1.f/1.2f)), // color
{x_pos * 2, y_pos * 2, 1.0f}, // position
false // clipping
);
*/
transform(parameter,
circle::vertices,
circle::faces[i],
{1.0f, 1.0f, 0.0f, 0.0f}, // color
{x_pos * 2, y_pos * 2, 0.0f}, // position
true // clipping
);
}
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);
v_sync_in();
core_wait_end_of_render_video(frame_ix, num_frames);
frame_ix += 1;
theta += (2.f * pi) / 720.f;
}
}

View File

@ -1,294 +0,0 @@
#include <cstdint>
#include <bit>
#include "align.hpp"
#include "vga.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 "sh7091/serial.hpp"
#include "geometry/triangle.hpp"
#include "geometry/circle.hpp"
#include "math/vec4.hpp"
#include "math/math.hpp"
#include "math/geometry.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"
uint32_t _command_buf[1024 / 4 + 32];
uint32_t _receive_buf[1024 / 4 + 32];
static ft0::data_transfer::data_format data[4];
void do_get_condition(uint32_t * command_buf,
uint32_t * receive_buf)
{
using command_type = get_condition;
using response_type = data_transfer<ft0::data_transfer::data_format>;
get_condition::data_fields data_fields = {
.function_type = std::byteswap(function_type::controller)
};
maple::init_host_command_all_ports<command_type, response_type>(command_buf, receive_buf,
data_fields);
maple::dma_start(command_buf);
using command_response_type = struct maple::command_response<response_type::data_fields>;
for (uint8_t port = 0; port < 4; port++) {
auto response = reinterpret_cast<command_response_type *>(receive_buf);
auto& bus_data = response[port].bus_data;
if (bus_data.command_code != response_type::command_code) {
return;
}
auto& data_fields = bus_data.data_fields;
if ((data_fields.function_type & std::byteswap(function_type::controller)) == 0) {
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;
}
}
constexpr vec3 colors[] = {
{1.f, 0.5f, 0.f},
{0.f, 1.0f, 0.f},
{0.f, 0.5f, 1.f},
{1.f, 0.0f, 1.f},
};
void transform1(ta_parameter_writer& parameter,
const vec3& v,
const vec3& c,
bool end_of_strip)
{
float x = v.x;
float y = v.y;
float z = v.z;
// camera transform
z += 1;
// screen space transform
x *= 240.f;
y *= 240.f;
x += 320.f;
y += 240.f;
z = 1 / 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,
1.0f, // alpha
c.r,
c.g,
c.b
);
}
void transform(ta_parameter_writer& parameter,
const vec3 * vertices,
const face_vn& face,
const vec4& color,
const vec3& position,
const float theta,
const bool enable_clipping
)
{
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
| para_control::list_type::opaque
| obj_control::col_type::floating_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;
constexpr uint32_t strip_length = 3;
vec3 points[strip_length];
// object transform and clip
for (uint32_t i = 0; i < strip_length; i++) {
uint32_t vertex_ix = face[i].vertex;
auto vertex = vertices[vertex_ix];
vertex = (vertex * 0.5f);
// rotate 90° around the X axis
//float x = vertex.x;
//float y = vertex.z;
//float z = vertex.y;
float x = vertex.x * cos(theta) - vertex.z * sin(theta);
float y = vertex.x * sin(theta) + vertex.z * cos(theta);
float z = vertex.y;
// object transform
x += position.x; // object space
y += position.y; // object space
z += position.z; // object space
// clip
points[i] = vec3(x, y, z);
}
const vec3 plane_point = {0.f, 0.f, 0.f};
const vec3 plane_normal = {-1.f, 0.f, 0.f};
vec3 output[4];
int output_length = geometry::clip_polygon<3>(output, plane_point, plane_normal, &points[0]);
if (output_length >= 3) {
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
);
transform1(parameter, output[0], colors[0], false);
transform1(parameter, output[1], colors[1], false);
transform1(parameter, output[2], colors[2], true);
}
if (output_length >= 4) {
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
);
transform1(parameter, output[0], colors[0], false);
transform1(parameter, output[2], colors[2], false);
transform1(parameter, output[3], colors[3], true);
}
/*
A B
D C
*/
}
void init_texture_memory(const struct opb_size& opb_size)
{
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
background_parameter(mem->background, 0xff220000);
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
640 / 32, // width
480 / 32, // height
opb_size
);
}
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);
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::_16x4byte;
constexpr struct opb_size opb_size = { .opaque = 16 * 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;
constexpr uint32_t num_frames = 1;
float theta = 0;
float x_pos = 0;
float y_pos = 0;
while (1) {
do_get_condition(command_buf, receive_buf);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
const float l_ = static_cast<float>(data[0].analog_axis_1) * (1.f / 255.f);
const float r_ = static_cast<float>(data[0].analog_axis_2) * (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<float>(data[0].analog_axis_3 - 0x80) / 127.f;
const float y_ = static_cast<float>(data[0].analog_axis_4 - 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)));
else y_pos -= (0.02f * ((y_ - y_pos) * (y_ - y_pos)));
auto parameter = ta_parameter_writer(ta_parameter_buf);
for (uint32_t i = 0; i < circle::num_faces; i++) {
transform(parameter,
circle::vertices,
circle::faces[i],
{1.0f, 1.0f, 0.0f, 0.0f}, // color
{x_pos * 2, y_pos * 2, 0.0f}, // position
theta,
true // clipping
);
}
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);
v_sync_in();
core_wait_end_of_render_video(frame_ix, num_frames);
frame_ix += 1;
}
}

View File

@ -3,24 +3,23 @@
#include "align.hpp"
#include "vga.hpp"
#include "holly/holly.hpp"
#include "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/geometry.hpp"
#include "geometry/cube.hpp"
#include "math/vec4.hpp"
using vec4 = vec<4, float>;
constexpr float half_degree = 0.01745329f / 2;
vec3 rotate(const vec3& vertex, float theta)
@ -60,14 +59,10 @@ void transform(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
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
);
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
auto& face = cube::faces[face_ix];
constexpr uint32_t strip_length = 3;
@ -121,14 +116,13 @@ void transform(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / 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,
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z // b
);
color.z, // b
end_of_strip);
}
}
@ -169,6 +163,8 @@ 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;
@ -186,10 +182,8 @@ void main()
};
while (1) {
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
640, 480);
//lights[0].x = cos(theta) * 10;
//lights[0].z = sin(theta) * 10;
@ -201,7 +195,7 @@ void main()
for (uint32_t i = 0; i < cube::num_faces; i++) {
transform(parameter, i, theta, lights);
}
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_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,6 +40,7 @@ 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
@ -52,6 +53,7 @@ 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
@ -64,6 +66,7 @@ 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
@ -143,38 +146,11 @@ MODIFIER_VOLUME_WITH_TWO_VOLUMES_OBJ = \
holly/core.o \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o \
wolf.data.o \
macaw.data.o \
maple/maple.o \
$(LIBGCC)
holly/ta_fifo_polygon_converter.o
example/modifier_volume_with_two_volumes.elf: LDSCRIPT = $(LIB)/alt.lds
example/modifier_volume_with_two_volumes.elf: $(START_OBJ) $(MODIFIER_VOLUME_WITH_TWO_VOLUMES_OBJ)
HEART_OBJ = \
example/heart.o \
vga.o \
holly/core.o \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o
example/heart.elf: LDSCRIPT = $(LIB)/alt.lds
example/heart.elf: $(START_OBJ) $(HEART_OBJ)
VIEWING_SYSTEM_OBJ = \
example/viewing_system.o \
vga.o \
holly/core.o \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o \
$(LIBGCC)
example/viewing_system.elf: LDSCRIPT = $(LIB)/alt.lds
example/viewing_system.elf: $(START_OBJ) $(VIEWING_SYSTEM_OBJ)
MACAW_CUBE_OBJ = \
example/macaw_cube.o \
vga.o \
@ -194,37 +170,12 @@ 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
example/macaw_cube_render_to_texture.elf: $(START_OBJ) $(MACAW_CUBE_RENDER_TO_TEXTURE_OBJ)
CLIPPING_OBJ = \
example/clipping.o \
vga.o \
holly/core.o \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o \
maple/maple.o
example/clipping.elf: LDSCRIPT = $(LIB)/alt.lds
example/clipping.elf: $(START_OBJ) $(CLIPPING_OBJ)
CLIPPING2_OBJ = \
example/clipping2.o \
vga.o \
holly/core.o \
holly/region_array.o \
holly/background.o \
holly/ta_fifo_polygon_converter.o \
maple/maple.o \
sh7091/serial.o \
$(LIBGCC)
example/clipping2.elf: LDSCRIPT = $(LIB)/alt.lds
example/clipping2.elf: $(START_OBJ) $(CLIPPING2_OBJ)
MAPLE_DEVICE_REQUEST_OBJ = \
example/maple_device_request.o \
vga.o \
@ -237,7 +188,7 @@ example/maple_device_request.elf: $(START_OBJ) $(MAPLE_DEVICE_REQUEST_OBJ)
MAPLE_CONTROLLER_OBJ = \
example/maple_controller.o \
vga.o \
sh7091/serial.o \
serial.o \
maple/maple.o
example/maple_controller.elf: LDSCRIPT = $(LIB)/alt.lds
@ -271,6 +222,7 @@ 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
@ -282,10 +234,3 @@ SERIAL_TRANSFER_OBJ = \
example/serial_transfer.elf: LDSCRIPT = $(LIB)/alt.lds
example/serial_transfer.elf: $(START_OBJ) $(SERIAL_TRANSFER_OBJ)
INTERRUPT_OBJ = \
example/interrupt.o \
serial.o
example/interrupt.elf: LDSCRIPT = $(LIB)/alt.lds
example/interrupt.elf: $(START_OBJ) $(INTERRUPT_OBJ)

View File

@ -1,22 +1,20 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "vga.hpp"
#include "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/ta_fifo_polygon_converter.hpp"
#include "holly/texture_memory_alloc.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"
@ -94,35 +92,25 @@ 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++) {
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;
auto polygon = global_polygon_type_0(texture_address);
polygon.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;
polygon.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
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(8)
| tsp_instruction_word::texture_v_size::from_int(8);
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<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
);
polygon.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;
for (uint32_t i = 0; i < strip_length; i++) {
bool end_of_strip = i == strip_length - 1;
@ -137,18 +125,16 @@ 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<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
);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
strip_vertices[i].u,
strip_vertices[i].v,
0x00000000, // base_color
end_of_strip);
}
}
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_end_of_list();
return parameter.offset;
}
@ -250,6 +236,8 @@ 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;
@ -263,10 +251,8 @@ void main()
const char ana[18] = "A from ana i know";
while (true) {
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
640, 480);
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/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "vga.hpp"
#include "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/ta_fifo_polygon_converter.hpp"
#include "holly/texture_memory_alloc.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,35 +58,27 @@ uint32_t transform(ta_parameter_writer& parameter,
continue;
}
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;
auto polygon = global_polygon_type_0(texture_address);
polygon.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;
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater
| isp_tsp_instruction_word::culling_mode::no_culling;
polygon.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);
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);
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<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
);
polygon.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;
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;
@ -107,14 +99,11 @@ uint32_t transform(ta_parameter_writer& parameter,
u = u / static_cast<float>(texture_width);
v = v / static_cast<float>(texture_height);
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,
0, // base_color
0 // offset_color
);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
u, v,
0x00000000, // base_color
end_of_strip);
}
advance += glyph.metrics.horiAdvance;
@ -128,34 +117,26 @@ uint32_t transform2(ta_parameter_writer& parameter,
{
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
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;
auto polygon = global_polygon_type_0(texture_address);
polygon.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;
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater
| isp_tsp_instruction_word::culling_mode::no_culling;
polygon.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);
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);
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<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
);
polygon.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;
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;
@ -169,14 +150,11 @@ uint32_t transform2(ta_parameter_writer& parameter,
float u = strip_vertices[i].u;
float v = strip_vertices[i].v;
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,
0, // base_color
0 // offset_color
);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
u, v,
0x00000000, // base_color
end_of_strip);
}
return parameter.offset;
@ -252,6 +230,8 @@ 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;
@ -266,10 +246,8 @@ void main()
const char cabal[27] = "where is this secret cabal";
while (true) {
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
640, 480);
auto parameter = ta_parameter_writer(ta_parameter_buf);
@ -290,7 +268,7 @@ void main()
cabal, 26,
font->glyph_height * 1);
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_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/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "vga.hpp"
#include "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/ta_fifo_polygon_converter.hpp"
#include "holly/texture_memory_alloc.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,34 +58,27 @@ uint32_t transform(ta_parameter_writer& parameter,
continue;
}
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;
auto polygon = global_polygon_type_0(texture_address);
polygon.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;
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater
| isp_tsp_instruction_word::culling_mode::no_culling;
polygon.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);
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);
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<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
);
polygon.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;
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;
@ -106,14 +99,11 @@ uint32_t transform(ta_parameter_writer& parameter,
u = u / static_cast<float>(texture_width);
v = v / static_cast<float>(texture_height);
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,
0, // base_color
0 // offset_color
);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
u, v,
0x00000000, // base_color
end_of_strip);
}
advance += glyph.metrics.horiAdvance;
@ -127,34 +117,26 @@ uint32_t transform2(ta_parameter_writer& parameter,
{
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
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;
auto polygon = global_polygon_type_0(texture_address);
polygon.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;
polygon.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);
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);
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<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
);
polygon.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;
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;
@ -168,14 +150,11 @@ uint32_t transform2(ta_parameter_writer& parameter,
float u = strip_vertices[i].u;
float v = strip_vertices[i].v;
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,
0, // base_color
0 // offset_color
);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
u, v,
0x00000000, // base_color
end_of_strip);
}
return parameter.offset;
@ -255,6 +234,8 @@ 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;
@ -270,17 +251,15 @@ void main()
const char cabal[27] = "where is this secret cabal";
while (true) {
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
640, 480);
auto parameter = ta_parameter_writer(ta_parameter_buf);
transform2(parameter,
font->texture_width, font->texture_height);
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_end_of_list();
transform(parameter,
font->texture_width, font->texture_height,
@ -296,7 +275,7 @@ void main()
cabal, 26,
font->glyph_height * 1);
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_end_of_list();
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_punch_through_list();

View File

@ -1,333 +0,0 @@
#include <cstdint>
#include "align.hpp"
#include "vga.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/region_array.hpp"
#include "holly/background.hpp"
#include "holly/isp_tsp.hpp"
#include "memorymap.hpp"
#include "geometry/heart.hpp"
#include "math/vec3.hpp"
#include "math/vec4.hpp"
#include "math/mat4x4.hpp"
using mat4x4 = mat<4, 4, float>;
constexpr float pi = 3.141592653589793;
struct rotation_weights {
float drx;
float dry;
float drz;
};
// randomly generated numbers
constexpr rotation_weights weights[16] = {
{-0.8154296875, 0.8583984375, -0.498046875},
{0.322265625, 0.6796875, 0.3251953125},
{-0.2626953125, -0.7744140625, 0.37109375},
{0.5830078125, 0.42578125, 0.5546875},
{0.9140625, 0.7568359375, -0.037109375},
{0.8974609375, 0.103515625, -0.2666015625},
{0.8427734375, -0.4091796875, -0.365234375},
{0.162109375, -0.603515625, 0.4248046875},
{-0.47265625, -0.73828125, -0.4912109375},
{-0.921875, 0.4609375, 0.2216796875},
{0.400390625, -0.5634765625, -0.3232421875},
{0.896484375, 0.26953125, -0.951171875},
{0.541015625, 0.90625, 0.640625},
{0.5927734375, -0.361328125, 0.21875},
{-0.9267578125, -0.9423828125, 0.4580078125},
{0.16796875, 0.3662109375, 0.603515625},
};
// randomly generated numbers
float lighting_weights[16] = {
0.7314453125,
0.44921875,
0.259765625,
0.3232421875,
0.1015625,
0.2529296875,
0.8662109375,
0.5439453125,
0.1337890625,
0.041015625,
0.6298828125,
0.30859375,
0.517578125,
0.6259765625,
0.283203125,
0.982421875,
};
struct model_transform {
float x;
float y;
float z;
float rx;
float ry;
float rz;
model_transform()
: x(0.f)
, y(0.f)
, z(0.f)
, rx(0.f)
, ry(0.f)
, rz(0.f)
{ }
};
struct model_transform models[] = {
};
inline mat4x4 rotate_x(float t)
{
return mat4x4(1.f, 0.f, 0.f, 0.f,
0.f, cos(t), -sin(t), 0.f,
0.f, sin(t), cos(t), 0.f,
0.f, 0.f, 0.f, 1.f
);
}
inline mat4x4 rotate_y(float t)
{
return mat4x4( cos(t), 0.f, sin(t), 0.f,
0.f, 1.f, 0.f, 0.f,
-sin(t), 0.f, cos(t), 0.f,
0.f, 0.f, 0.f, 1.f
);
}
inline mat4x4 rotate_z(float t)
{
return mat4x4(cos(t), -sin(t), 0.f, 0.f,
sin(t), cos(t), 0.f, 0.f,
0.f, 0.f, 1.f, 0.f,
0.f, 0.f, 0.f, 1.f
);
}
inline mat4x4 translate(float x, float y, float z)
{
return mat4x4(1.f, 0.f, 0.f, x,
0.f, 1.f, 0.f, y,
0.f, 0.f, 1.f, z,
0.f, 0.f, 0.f, 1.f
);
}
vec3 _transform(const vec4& point)
{
float x = point.x;
float y = point.y;
float z = point.z;
// camera transform
z += 4;
// perspective
x = x / z;
y = y / z;
// screen space transform
x *= 240.f;
y *= 240.f;
x += 320.f;
y += 240.f;
z = 1 / z;
return {x, y, z};
}
void transform_model(ta_parameter_writer& parameter,
const position__color * vertices,
const vec3 * normals,
const face_vn * faces,
const uint32_t num_faces,
const model_transform& mt,
const float lighting_weight)
{
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
| para_control::list_type::opaque
| obj_control::col_type::floating_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 mat4x4 mat = translate(mt.x, mt.y, mt.z) * rotate_z(mt.rz) * rotate_y(mt.ry) * rotate_x(mt.rx);
constexpr uint32_t strip_length = 3;
for (uint32_t face_ix = 0; face_ix < num_faces; face_ix++) {
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
);
auto& face = faces[face_ix];
for (uint32_t i = 0; i < strip_length; i++) {
// world transform
uint32_t vertex_ix = face[i].vertex;
auto& vertex = vertices[vertex_ix].position;
auto& color = vertices[vertex_ix].color;
auto point = mat * vec4(vertex);
uint32_t normal_ix = face[i].normal;
auto& normal = normals[normal_ix];
auto n = mat * vec4(normal);
vec4 light = {0.f, 0.f, 40.f, 1.f};
auto l = light - point;
auto n_dot_l = dot(n, l);
vec3 c(0.f, 0.f, 0.f);
c.r += color.r * 0.1;
c.g += color.g * 0.1;
c.b += color.b * 0.1;
if (n_dot_l > 0) {
float intensity = n_dot_l / (length(n) * length(l));
c.r += color.r * intensity * lighting_weight;
c.g += color.g * intensity * lighting_weight;
c.b += color.b * intensity * lighting_weight;
}
auto screen = _transform(point);
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),
screen.x,
screen.y,
screen.z,
1.0f, // alpha
c.r, // red
c.g, // green
c.b // blue
);
}
}
}
void init_texture_memory(const struct opb_size& opb_size)
{
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
background_parameter(mem->background, 0xff220000);
holly.VO_BORDER_COL = 0x00220000;
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
640 / 32, // width
480 / 32, // height
opb_size
);
}
uint32_t _ta_parameter_buf[((32 * 8192) + 32) / 4];
void main()
{
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::_16x4byte;
constexpr struct opb_size opb_size = { .opaque = 16 * 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;
constexpr uint32_t num_frames = 1;
float theta = 0;
model_transform mt[16] = {};
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 4; y++) {
int ix = y * 4 + x;
mt[ix].x = -8.f + 5.f * static_cast<float>(x);
mt[ix].y = -7.5f + 5.f * static_cast<float>(y);
mt[ix].z = 6.f;
mt[ix].rx = (-8.f + static_cast<float>(ix)) * -pi / 16;
mt[ix].ry = (-8.f + static_cast<float>(ix)) * ix * -pi / 16;
mt[ix].rz = (-8.f + static_cast<float>(ix)) * ix * -pi / 16;
}
}
while (true) {
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
auto parameter = ta_parameter_writer(ta_parameter_buf);
{ // plane
for (uint32_t i = 0; i < 16; i++) {
transform_model(parameter,
heart::vertices,
heart::normals,
heart::faces,
heart::num_faces,
mt[i],
(1.f + sin(theta * 2 * lighting_weights[i])) * 0.5f);
// update model
auto& weight = weights[i];
mt[i].rx += weight.drx / 50.f;
mt[i].ry += weight.dry / 50.f;
mt[i].rz += weight.drz / 50.f;
}
}
// end of opaque 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);
v_sync_in();
core_wait_end_of_render_video(frame_ix, num_frames);
constexpr float half_degree = 0.01745329f / 2;
theta += half_degree;
frame_ix += 1;
}
}

View File

@ -1,21 +1,19 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly/holly.hpp"
#include "vga.hpp"
#include "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"
@ -23,7 +21,7 @@
constexpr float half_degree = 0.01745329f / 2;
#define MODEL icosphere
#define MODEL suzanne
vec3 rotate(const vec3& vertex,
const float theta)
@ -63,18 +61,16 @@ void transform(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
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
);
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
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];
@ -134,15 +130,13 @@ void transform(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / 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
);
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
}
}
@ -162,14 +156,10 @@ void transform2(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
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
);
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
constexpr vec3 triangle[] = {
{ 0.f, -1.f, 0.f},
@ -179,6 +169,7 @@ 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;
@ -205,15 +196,13 @@ void transform2(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / 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
);
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
}
}
@ -296,7 +285,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<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_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,15 +4,12 @@
#include "vga.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "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"
@ -41,39 +38,16 @@ 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)
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
| 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
);
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
parameter.append<global_polygon_type_0>() = global_polygon_type_0(texture_address);
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;
@ -88,18 +62,15 @@ uint32_t transform(uint32_t * ta_parameter_buf,
y += 240.f;
z = 1.f / (z + 10.f);
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,
0 // offset_color
);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
strip_vertices[i].u,
strip_vertices[i].v,
strip_vertices[i].color,
end_of_strip);
}
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_end_of_list();
return parameter.offset;
}
@ -108,14 +79,14 @@ void init_texture_memory(const struct opb_size& opb_size)
{
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
background_parameter(mem->background, 0xff00ff00);
background_parameter(mem->background);
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
640 / 32, // width
480 / 32, // height
opb_size
);
(offsetof (struct texture_memory_alloc, object_list)),
640 / 32, // width
480 / 32, // height
opb_size
);
}
void copy_macaw_texture()
@ -145,20 +116,22 @@ void main()
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::tm_opb::no_list
| ta_alloc_ctrl::t_opb::no_list
| ta_alloc_ctrl::om_opb::no_list
| ta_alloc_ctrl::o_opb::_16x4byte;
constexpr struct opb_size opb_size = { .opaque = 16 * 4
, .opaque_modifier = 0
, .translucent = 0
, .translucent_modifier = 0
, .punch_through = 0
};
, .opaque_modifier = 0
, .translucent = 0
, .translucent_modifier = 0
, .punch_through = 0
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
| softreset::ta_soft_reset;
holly.SOFTRESET = 0;
core_init();
@ -168,10 +141,7 @@ void main()
constexpr uint32_t num_frames = 1;
while (true) {
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc);
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,22 +1,21 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "vga.hpp"
#include "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 {
@ -64,35 +63,12 @@ void transform(ta_parameter_writer& parameter,
const vertex * strip_vertices,
const uint32_t strip_length)
{
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
);
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
parameter.append<global_polygon_type_0>() = global_polygon_type_0();
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;
@ -122,15 +98,12 @@ void transform(ta_parameter_writer& parameter,
z = 1 / 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,
0, // base_color
0 // offset_color
);
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);
}
}
@ -187,6 +160,8 @@ 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;
@ -198,16 +173,12 @@ void main()
constexpr uint32_t num_frames = 1;
while (1) {
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc, 640, 480);
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<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_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,22 +1,21 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "vga.hpp"
#include "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 {
@ -68,71 +67,51 @@ void transform(ta_parameter_writer& parameter,
const uint32_t texture_address,
const uint32_t texture_width)
{
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;
auto polygon = global_polygon_type_0(texture_address);
switch (texture_width) {
case 32:
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(32)
| tsp_instruction_word::texture_v_size::from_int(32)
| tsp_instruction_word::use_alpha;
polygon.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::use_alpha;
break;
case 64:
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(64)
| tsp_instruction_word::texture_v_size::from_int(64)
| tsp_instruction_word::use_alpha;
polygon.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::use_alpha;
break;
case 128:
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)
| tsp_instruction_word::use_alpha;
polygon.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::use_alpha;
break;
case 256:
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(256)
| tsp_instruction_word::texture_v_size::from_int(256)
| tsp_instruction_word::use_alpha;
polygon.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::use_alpha;
break;
case 512:
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(512)
| tsp_instruction_word::texture_v_size::from_int(512)
| tsp_instruction_word::use_alpha;
polygon.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::use_alpha;
break;
default: break;
}
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
);
parameter.append<global_polygon_type_0>() = polygon;
for (uint32_t i = 0; i < strip_length; i++) {
bool end_of_strip = i == strip_length - 1;
@ -165,14 +144,12 @@ void transform(ta_parameter_writer& parameter,
z = 1 / 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,
0, // base_color
0 // offset_color
);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
strip_vertices[i].u,
strip_vertices[i].v,
color,
end_of_strip);
}
}
@ -209,10 +186,9 @@ void render(const uint32_t width, const uint32_t height,
const uint32_t texture_width,
uint32_t * ta_parameter_buf)
{
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
width / 32,
height / 32);
const uint32_t tiles = (width / 32) * (height / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc,
width, height);
auto parameter = ta_parameter_writer(ta_parameter_buf);
for (uint32_t i = 0; i < num_faces; i++) {
@ -221,7 +197,7 @@ void render(const uint32_t width, const uint32_t height,
texture_address,
texture_width);
}
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_end_of_list();
ta_polygon_converter_transfer(ta_parameter_buf, parameter.offset);
ta_wait_opaque_list();
}

View File

@ -4,15 +4,12 @@
#include "vga.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "holly/holly.hpp"
#include "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"
@ -46,35 +43,16 @@ uint32_t transform(uint32_t * ta_parameter_buf,
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
| 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<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
);
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
| texture_control_word::scan_order::twiddled
| texture_control_word::texture_address(texture_address / 8);
parameter.append<global_polygon_type_0>() = polygon;
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;
@ -89,18 +67,15 @@ uint32_t transform(uint32_t * ta_parameter_buf,
y += 240.f;
z = 1.f / (z + 10.f);
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,
0 // offset_color
);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
strip_vertices[i].u,
strip_vertices[i].v,
strip_vertices[i].color,
end_of_strip);
}
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_end_of_list();
return parameter.offset;
}
@ -109,7 +84,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, 0xff00ff00);
background_parameter(mem->background);
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
@ -157,6 +132,8 @@ 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;
@ -168,10 +145,7 @@ void main()
constexpr uint32_t num_frames = 1;
while (true) {
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc);
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,20 +4,17 @@
#include "align.hpp"
#include "vga.hpp"
#include "holly/holly.hpp"
#include "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 "sh7091/serial.hpp"
#include "serial.hpp"
#include "geometry/border.hpp"
#include "geometry/circle.hpp"
@ -60,6 +57,15 @@ 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;
}
@ -67,7 +73,7 @@ void do_get_condition(uint32_t * command_buf,
void transform(ta_parameter_writer& parameter,
const vec3 * vertices,
const face_vn& face,
const face& face,
const vec4& color,
const vec3& position,
const float scale
@ -85,17 +91,14 @@ void transform(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
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
);
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
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;
@ -128,16 +131,13 @@ void transform(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / 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
);
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
}
}
@ -223,7 +223,7 @@ void main()
);
}
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_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,11 +4,10 @@
#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 "sh7091/serial.hpp"
#include "serial.hpp"
uint32_t _command_buf[1024 / 4 + 32] = {0};
uint32_t _receive_buf[1024 / 4 + 32] = {0};
@ -48,11 +47,10 @@ void do_get_condition(uint32_t port)
std::byteswap(function_type::controller));
maple::dma_start(command_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);
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);
auto& bus_data = response->bus_data;
if (bus_data.command_code != response_type::command_code) {
if (bus_data.command_code != data_transfer::command_code) {
return;
}
auto& data_fields = bus_data.data_fields;
@ -71,17 +69,20 @@ void do_get_condition(uint32_t port)
void do_device_request()
{
using command_type = device_request;
using response_type = device_status;
using response_type = struct maple::command_response<device_status::data_fields>;
constexpr uint32_t response_size = align_32byte(sizeof (response_type));
maple::init_host_command_all_ports<command_type, response_type>(command_buf, receive_buf);
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::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& bus_data = response[port].bus_data;
auto& data_fields = response[port].bus_data.data_fields;
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;
if (bus_data.command_code != device_status::command_code) {
// the controller is disconnected
} else {

View File

@ -1,5 +1,4 @@
#include <cstdint>
#include <bit>
#include "align.hpp"
#include "vga.hpp"
@ -23,94 +22,9 @@
#include "math/vec3.hpp"
#include "math/vec4.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 "macaw.hpp"
#include "wolf.hpp"
#include "twiddle.hpp"
static ft0::data_transfer::data_format data[4];
void do_get_condition(uint32_t * command_buf,
uint32_t * receive_buf)
{
using command_type = get_condition;
using response_type = data_transfer<ft0::data_transfer::data_format>;
get_condition::data_fields data_fields = {
.function_type = std::byteswap(function_type::controller)
};
maple::init_host_command_all_ports<command_type, response_type>(command_buf, receive_buf,
data_fields);
maple::dma_start(command_buf);
using command_response_type = struct maple::command_response<response_type::data_fields>;
for (uint8_t port = 0; port < 4; port++) {
auto response = reinterpret_cast<command_response_type *>(receive_buf);
auto& bus_data = response[port].bus_data;
if (bus_data.command_code != response_type::command_code) {
return;
}
auto& data_fields = bus_data.data_fields;
if ((data_fields.function_type & std::byteswap(function_type::controller)) == 0) {
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;
}
}
struct rot_pos {
float theta;
float x;
float y;
};
vec3 _transform(const vec3& point,
const uint32_t scale)
{
float x = point.x;
float y = point.y;
float z = point.z;
x *= scale;
y *= scale;
z *= scale;
// world transform
y += 2.0f;
x *= 0.8;
y *= 0.8;
z *= 0.8;
// camera transform
z += 4;
// perspective
x = x / z;
y = y / z;
// screen space transform
x *= 240.f;
y *= 240.f;
x += 320.f;
y += 240.f;
z = 1 / z;
return {x, y, z};
}
vec3 _transform(const vec3& point,
const uint32_t scale,
const struct rot_pos& rot_pos)
const float theta)
{
float x = point.x;
float y = point.y;
@ -118,13 +32,10 @@ vec3 _transform(const vec3& point,
float t;
// object transform
t = z * cos(rot_pos.theta) - x * sin(rot_pos.theta);
x = z * sin(rot_pos.theta) + x * cos(rot_pos.theta);
t = z * cos(theta) - x * sin(theta);
x = z * sin(theta) + x * cos(theta);
z = t;
x += rot_pos.x;
z += rot_pos.y;
x *= scale;
y *= scale;
z *= scale;
@ -163,47 +74,31 @@ uint32_t argb8888(const vec4& color)
void transform_polygon(ta_parameter_writer& parameter,
const vec3 * vertices,
const vec2 * texture,
const face& face,
const float scale,
const vec4& color0,
const vec4& color1,
const struct rot_pos& rot_pos)
const float theta)
{
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::shadow
| obj_control::volume::polygon::with_two_volumes
| obj_control::texture;
| obj_control::volume::polygon::with_two_volumes;
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);
uint32_t texture_address0 = (offsetof (struct texture_memory_alloc, texture)) + 128 * 128 * 2 * 0;
uint32_t texture_address1 = (offsetof (struct texture_memory_alloc, texture)) + 128 * 128 * 2 * 1;
const uint32_t texture_control_word_0 = texture_control_word::pixel_format::_565
| texture_control_word::scan_order::twiddled
| texture_control_word::texture_address(texture_address0 / 8);
const uint32_t texture_control_word_1 = texture_control_word::pixel_format::_565
| texture_control_word::scan_order::twiddled
| texture_control_word::texture_address(texture_address1 / 8);
| tsp_instruction_word::fog_control::no_fog;
parameter.append<ta_global_parameter::polygon_type_3>() =
ta_global_parameter::polygon_type_3(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word, // tsp_instruction_word_0
texture_control_word_0, // texture_control_word_0
tsp_instruction_word, // tsp_instruction_word_1
texture_control_word_1, // texture_control_word_1
tsp_instruction_word, // tsp_instruction_word_0
0, // texture_control_word_0
tsp_instruction_word, // tsp_instruction_word_1
0, // texture_control_word_1
0, // data_size_for_sort_dma
0 // next_address_for_sort_dma
);
@ -213,26 +108,17 @@ void transform_polygon(ta_parameter_writer& parameter,
// world transform
uint32_t vertex_ix = face[i].vertex;
auto& vertex = vertices[vertex_ix];
auto point = _transform(vertex, scale, rot_pos);
uint32_t texture_ix = face[i].texture;
auto& uv = texture[texture_ix];
auto point = _transform(vertex, scale, theta);
bool end_of_strip = i == strip_length - 1;
parameter.append<ta_vertex_parameter::polygon_type_11>() =
ta_vertex_parameter::polygon_type_11(polygon_vertex_parameter_control_word(end_of_strip),
point.x,
point.y,
point.z,
uv.u,
uv.v,
argb8888(color0), // base_color_0
0, // offset_color_0
uv.u,
uv.v,
argb8888(color1), // base_color_1
0 // offset_color_1
);
parameter.append<ta_vertex_parameter::polygon_type_9>() =
ta_vertex_parameter::polygon_type_9(polygon_vertex_parameter_control_word(end_of_strip),
point.x,
point.y,
point.z,
argb8888(color0),
argb8888(color1)
);
}
}
@ -264,9 +150,9 @@ void transform_modifier_volume(ta_parameter_writer& parameter,
auto& _a = vertices[ix_a];
auto& _b = vertices[ix_b];
auto& _c = vertices[ix_c];
auto a = _transform(_a, scale);
auto b = _transform(_b, scale);
auto c = _transform(_c, scale);
auto a = _transform(_a, scale, 0.f);
auto b = _transform(_b, scale, 0.f);
auto c = _transform(_c, scale, 0.f);
if (i == (num_faces - 1)) {
const uint32_t last_parameter_control_word = para_control::para_type::polygon_or_modifier_volume
@ -304,64 +190,15 @@ void init_texture_memory(const struct opb_size& opb_size)
);
}
void
load_texture(const uint8_t * src,
const uint32_t size,
const uint32_t ix)
{
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory64);
uint16_t temp[size / 3];
for (uint32_t px = 0; px < size / 3; px++) {
uint8_t r = src[px * 3 + 0];
uint8_t g = src[px * 3 + 1];
uint8_t b = src[px * 3 + 2];
uint16_t rgb565 = ((r / 8) << 11) | ((g / 4) << 5) | ((b / 8) << 0);
temp[px] = rgb565;
}
twiddle::texture(&mem->texture[(128 * 128 * 2 * ix) / 2], temp, 128, 128);
}
void update_rot_pos(struct rot_pos& rot_pos)
{
const float l_pos = static_cast<float>(data[0].analog_axis_1) * (1.f / 255.f);
const float r_pos = static_cast<float>(data[0].analog_axis_2) * (1.f / 255.f);
const float x_pos = static_cast<float>(data[0].analog_axis_3 - 0x80) * (0.5f / 127.f);
const float y_pos = static_cast<float>(data[0].analog_axis_4 - 0x80) * (0.5f / 127.f);
const float rotation = (l_pos > r_pos) ? (l_pos) : (-r_pos);
constexpr float half_degree = 0.01745329f / 2;
rot_pos.x += x_pos / 10.f;
rot_pos.y += y_pos / 10.f;
rot_pos.theta += rotation * half_degree * 10.f;
}
uint32_t _ta_parameter_buf[((32 * 8192) + 32) / 4];
uint32_t _command_buf[1024 / 4 + 32];
uint32_t _receive_buf[1024 / 4 + 32];
void main()
{
vga();
auto src0 = reinterpret_cast<const uint8_t *>(&_binary_macaw_data_start);
auto size0 = reinterpret_cast<const uint32_t>(&_binary_macaw_data_size);
auto src1 = reinterpret_cast<const uint8_t *>(&_binary_wolf_data_start);
auto size1 = reinterpret_cast<const uint32_t>(&_binary_wolf_data_size);
load_texture(src0, size0, 0);
load_texture(src1, size1, 1);
// 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);
uint32_t * command_buf = align_32byte(_command_buf);
uint32_t * receive_buf = align_32byte(_receive_buf);
constexpr uint32_t ta_alloc = ta_alloc_ctrl::pt_opb::no_list
| ta_alloc_ctrl::tm_opb::no_list
@ -387,31 +224,26 @@ void main()
uint32_t frame_ix = 0;
constexpr uint32_t num_frames = 1;
struct rot_pos rot_pos = { 0.f, 0.f, 0.f };
float theta = 0;
while (true) {
do_get_condition(command_buf, receive_buf);
update_rot_pos(rot_pos);
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
auto parameter = ta_parameter_writer(ta_parameter_buf);
{ // plane
vec4 color0 = {1.0, 0.9, 0.9, 0.9};
vec4 color1 = {1.0, 0.9, 0.9, 0.9};
vec4 color0 = {1.0, 0.9, 0.4, 0.2};
vec4 color1 = {1.0, 0.2, 0.9, 0.9};
float scale = 2.f;
for (uint32_t i = 0; i < plane::num_faces; i++) {
transform_polygon(parameter,
plane::vertices,
plane::texture,
plane::faces[i],
scale,
color0,
color1,
rot_pos);
theta);
}
/*
@ -446,6 +278,8 @@ void main()
v_sync_in();
core_wait_end_of_render_video(frame_ix, num_frames);
constexpr float half_degree = 0.01745329f / 2;
theta += half_degree;
frame_ix += 1;
}
}

View File

@ -1,9 +1,9 @@
#include <cstdint>
#include "sh7091/sh7091.hpp"
#include "sh7091/sh7091_bits.hpp"
#include "sh7091/cache.hpp"
#include "sh7091.hpp"
#include "sh7091_bits.hpp"
#include "cache.hpp"
#include "serial_load.hpp"
extern uint32_t __bss_link_start __asm("__bss_link_start");
@ -22,15 +22,13 @@ void main()
load_init();
while (1) {
using namespace scif;
while ((sh7091.SCIF.SCFSR2 & scfsr2::tdfe::bit_mask) == 0) {
while ((sh7091.SCIF.SCFSR2 & SCFSR2__TDFE) == 0) {
// wait
}
while ((scfdr2::receive_data_bytes(sh7091.SCIF.SCFDR2)) > 0) {
while ((sh7091.SCIF.SCFDR2 & 0b11111) > 0) {
uint8_t c = sh7091.SCIF.SCFRDR2;
load_recv(c);
}
sh7091.SCIF.SCFSR2 = sh7091.SCIF.SCFSR2 & (~scfsr2::rdf::bit_mask);
sh7091.SCIF.SCFSR2 = sh7091.SCIF.SCFSR2 & (~SCFSR2__RDF);
}
}

View File

@ -3,18 +3,15 @@
#include "align.hpp"
#include "vga.hpp"
#include "holly/holly.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "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"
@ -46,60 +43,29 @@ 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
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;
auto polygon = global_polygon_type_0();
polygon.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;
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater
| isp_tsp_instruction_word::culling_mode::no_culling;
polygon.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;
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<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
);
parameter.append<global_polygon_type_0>() = polygon;
} else {
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
);
// opaque textured
parameter.append<global_polygon_type_0>() = global_polygon_type_0(texture_address);
}
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;
@ -114,18 +80,15 @@ uint32_t transform(uint32_t * ta_parameter_buf,
y += 240.f;
z = 1.f / (z + 10.f);
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,
0 // offset_color
);
parameter.append<vertex_polygon_type_3>() =
vertex_polygon_type_3(x, y, z,
strip_vertices[i].u,
strip_vertices[i].v,
strip_vertices[i].color,
end_of_strip);
}
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_end_of_list();
return parameter.offset;
}
@ -134,7 +97,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, 0xffffff00);
background_parameter(mem->background);
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
@ -179,6 +142,8 @@ 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;
@ -190,10 +155,7 @@ void main()
constexpr uint32_t num_frames = 1;
while (true) {
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc);
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,223 +0,0 @@
#include <cstdint>
#include "align.hpp"
#include "vga.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/region_array.hpp"
#include "holly/background.hpp"
#include "holly/isp_tsp.hpp"
#include "memorymap.hpp"
#include "geometry/geometry.hpp"
#include "geometry/suzanne2.hpp"
#include "geometry/plane2.hpp"
#include "viewing_system/view_space.hpp"
#include "viewing_system/screen_space.hpp"
uint32_t _ta_parameter_buf[((32 * 8192) + 32) / 4];
struct viewer {
vec3 position;
vec3 orientation;
float azimuth;
float colatitude;
};
void ta_upload(ta_parameter_writer& parameter,
const position__color * vertices,
const face_vtn * faces,
const uint32_t num_faces,
const mat4x4 world_transform,
const mat4x4 screen_transform
)
{
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
| para_control::list_type::opaque
| obj_control::col_type::floating_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;
for (uint32_t face_ix = 0; face_ix < num_faces; face_ix++) {
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
);
auto& face = faces[face_ix];
constexpr uint32_t strip_length = 3;
mat4x4 transform = screen_transform * world_transform;
for (uint32_t i = 0; i < strip_length; i++) {
const uint32_t vertex_ix = face[i].vertex;
auto& position = vertices[vertex_ix].position;
auto& color = vertices[vertex_ix].color;
vec4 vertex = { position.x,
position.y,
position.z,
1.0f };
// in three-dimensional screen space
vec4 v = transform * vertex;
float x = v.x / v.w;
float y = -v.y / v.w;
float z = v.w / v.z;
x = x * 240.f + 320.f;
y = y * 240.f + 240.f;
// perspective divide
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,
1.0f, // alpha
color.r, // red
color.g, // green
color.b // blue
);
}
}
}
void init_texture_memory(const struct opb_size& opb_size)
{
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
background_parameter(mem->background, 0xff220000);
holly.VO_BORDER_COL = 0x00220000;
region_array2(mem->region_array,
(offsetof (struct texture_memory_alloc, object_list)),
640 / 32, // width
480 / 32, // height
opb_size
);
}
void main()
{
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::_16x4byte;
constexpr struct opb_size opb_size = { .opaque = 16 * 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);
float delta = 0;
uint32_t frame_ix = 0;
constexpr uint32_t num_frames = 1;
while (true) {
viewer viewer {
.position = {0.f, -1.f, -2.f},
.orientation = {0.f, -1.f, 0.f}, // approximate "up" orientation
.azimuth = 0,
.colatitude = pi / 4.f * sin(delta) * 0.9f,
};
const vec3 plane_normal = view_space::viewing_direction(viewer.azimuth, viewer.colatitude);
const vec3 up_vector = view_space::project_vector_to_plane(plane_normal, viewer.orientation);
const mat4x4 view_space_transform = view_space::transformation_matrix(viewer.position, plane_normal, up_vector);
const mat4x4 perspective_transform = screen_space::transformation_matrix(1.f, // the z-coordinate of the view window
100.f, // the z-coordinate of the far clip plane
1.f // the dimension of the square view window
);
const mat4x4 screen_transform = perspective_transform * view_space_transform;
ta_polygon_converter_init(opb_size.total(),
ta_alloc,
640 / 32,
480 / 32);
auto parameter = ta_parameter_writer(ta_parameter_buf);
{
constexpr mat4x4 world_transform = { 1.f, 0.f, 0.f, 0.f,
0.f, 1.f, 0.f, 0.f,
0.f, 0.f, 1.f, 3.f,
0.f, 0.f, 0.f, 1.f };
ta_upload(parameter,
suzanne::vertices,
suzanne::faces,
suzanne::num_faces,
world_transform,
screen_transform
);
}
{
constexpr mat4x4 world_transform = { 0.1f, 0.f, 0.f, 0.f,
0.f, 0.1f, 0.f, 1.2f,
0.f, 0.f, 0.1f, 3.f,
0.f, 0.f, 0.f, 1.f };
ta_upload(parameter,
plane::vertices,
plane::faces,
plane::num_faces,
world_transform,
screen_transform
);
}
// end of opaque 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);
v_sync_out();
core_wait_end_of_render_video(frame_ix, num_frames);
frame_ix += 1;
delta += pi * 2 / 360;
}
}

View File

@ -1,21 +1,19 @@
#include <cstdint>
#include "align.hpp"
#include "vga.hpp"
#include "holly/holly.hpp"
#include "vga.hpp"
#include "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"
@ -61,19 +59,16 @@ void transform(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
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
);
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
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];
@ -145,15 +140,13 @@ void transform(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / 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
);
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
}
}
@ -173,14 +166,10 @@ void transform2(ta_parameter_writer& parameter,
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
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
);
parameter.append<global_polygon_type_0>() = global_polygon_type_0(parameter_control_word,
isp_tsp_instruction_word,
tsp_instruction_word,
0);
constexpr vec3 triangle[] = {
{ 0.f, -1.f, 0.f},
@ -190,6 +179,7 @@ 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;
@ -216,15 +206,13 @@ void transform2(ta_parameter_writer& parameter,
y += 240.f;
z = 1 / 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
);
parameter.append<vertex_polygon_type_1>() =
vertex_polygon_type_1(x, y, z,
color.w, // alpha
color.x, // r
color.y, // g
color.z, // b
end_of_strip);
}
}
@ -307,7 +295,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<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
parameter.append<global_end_of_list>() = global_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

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

View File

@ -37,12 +37,12 @@ namespace circle {
{ 0.382683f, 0.000000f, -0.923880f },
{ 0.195090f, 0.000000f, -0.980785f },
};
constexpr vec3 normals[] = {
{ -0.000000f, 1.000000f, -0.000000f },
};
constexpr face_vn faces[] = {
constexpr face faces[] = {
{{31, 0}, { 0, 0}, { 1, 0}},
{{30, 0}, {31, 0}, { 1, 0}},
{{20, 0}, {13, 0}, {18, 0}},
@ -74,7 +74,7 @@ namespace circle {
{{17, 0}, {14, 0}, {15, 0}},
{{16, 0}, {17, 0}, {15, 0}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vn));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
}

View File

@ -13,14 +13,14 @@ namespace cube {
{ 1.000000f, -1.000000f, -1.000000f },
{ 1.000000f, 1.000000f, -1.000000f },
};
constexpr vec2 texture[] = {
{ 1.000000f, 1.000000f },
{ 1.000000f, 0.000000f },
{ 0.000000f, 1.000000f },
{ 0.000000f, 0.000000f },
};
constexpr vec3 normals[] = {
{ -1.000000f, -0.000000f, -0.000000f },
{ -0.000000f, -0.000000f, -1.000000f },
@ -29,8 +29,8 @@ namespace cube {
{ -0.000000f, -1.000000f, -0.000000f },
{ -0.000000f, 1.000000f, -0.000000f },
};
constexpr face_vtn faces[] = {
constexpr face 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}},
@ -44,7 +44,7 @@ namespace cube {
{{6, 2, 4}, {4, 3, 4}, {0, 1, 4}},
{{3, 1, 5}, {1, 0, 5}, {5, 2, 5}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vtn));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
}

View File

@ -5,30 +5,15 @@
#include "math/vec2.hpp"
#include "math/vec3.hpp"
#include "math/vec4.hpp"
#include "math/mat4x4.hpp"
using vec2 = vec<2, float>;
using vec3 = vec<3, float>;
using vec4 = vec<4, float>;
using mat4x4 = mat<4, 4, float>;
struct vertex__texture__normal {
uint16_t vertex;
uint16_t texture;
uint16_t normal;
};
struct vertex__normal {
uint16_t vertex;
uint16_t normal;
};
struct position__color {
vec3 position;
vec3 color;
};
using face_vtn = vertex__texture__normal[3];
using face_vn = vertex__normal[3];
using face = vertex__texture__normal[3];

Binary file not shown.

View File

@ -1,247 +0,0 @@
#pragma once
#include "geometry.hpp"
namespace heart {
constexpr position__color vertices[] = {
{ { 0.000000f, 0.400000f, -0.707107f}, { 1.000000f, 0.611800f, 0.211800f} },
{ { 0.144430f, -0.400000f, -0.831470f}, { 1.000000f, 0.000000f, 0.674500f} },
{ { 0.144430f, 0.400000f, -0.831470f}, { 1.000000f, 0.611800f, 0.215700f} },
{ { 0.317317f, -0.400000f, -0.923880f}, { 1.000000f, 0.000000f, 0.670600f} },
{ { 0.317317f, 0.400000f, -0.923880f}, { 1.000000f, 0.611800f, 0.211800f} },
{ { 0.504910f, -0.400000f, -0.980785f}, { 1.000000f, 0.011800f, 0.670600f} },
{ { 0.504910f, 0.400000f, -0.980785f}, { 1.000000f, 0.611800f, 0.211800f} },
{ { 0.700000f, -0.400000f, -1.000000f}, { 1.000000f, 0.000000f, 0.670600f} },
{ { 0.700000f, 0.400000f, -1.000000f}, { 1.000000f, 0.611800f, 0.211800f} },
{ { 0.895090f, -0.400000f, -0.980785f}, { 1.000000f, 0.000000f, 0.898000f} },
{ { 0.895090f, 0.400000f, -0.980785f}, { 1.000000f, 0.235300f, 0.843100f} },
{ { 1.082684f, -0.400000f, -0.923879f}, { 1.000000f, 0.023500f, 0.909800f} },
{ { 1.082684f, 0.400000f, -0.923879f}, { 1.000000f, 0.611800f, 0.211800f} },
{ { 1.255570f, -0.400000f, -0.831469f}, { 1.000000f, 0.329400f, 0.866600f} },
{ { 1.255570f, 0.400000f, -0.831469f}, { 1.000000f, 0.615700f, 0.219600f} },
{ { 1.407107f, -0.400000f, -0.707107f}, { 1.000000f, 0.282300f, 0.886200f} },
{ { 1.407107f, 0.400000f, -0.707107f}, { 1.000000f, 0.580400f, 0.384300f} },
{ { 1.531470f, -0.400000f, -0.555570f}, { 1.000000f, 0.282300f, 0.886200f} },
{ { 1.531470f, 0.400000f, -0.555570f}, { 1.000000f, 0.051000f, 0.600000f} },
{ { 1.623880f, -0.400000f, -0.382683f}, { 1.000000f, 0.282300f, 0.886200f} },
{ { 1.623880f, 0.400000f, -0.382683f}, { 1.000000f, 0.051000f, 0.603900f} },
{ { 1.680785f, -0.400000f, -0.195090f}, { 1.000000f, 0.615700f, 0.674500f} },
{ { 1.680785f, 0.400000f, -0.195090f}, { 1.000000f, 0.035300f, 0.776400f} },
{ { 1.700000f, -0.400000f, 0.000000f}, { 1.000000f, 0.623600f, 0.666700f} },
{ { 1.700000f, 0.400000f, 0.000000f}, { 0.988200f, 0.003900f, 0.996000f} },
{ { 1.680785f, -0.400000f, 0.195090f}, { 1.000000f, 0.000000f, 0.909800f} },
{ { 1.680785f, 0.400000f, 0.195090f}, { 0.843100f, 0.011800f, 0.956800f} },
{ { 1.623879f, -0.400000f, 0.382684f}, { 1.000000f, 0.011800f, 0.909800f} },
{ { 1.623879f, 0.400000f, 0.382684f}, { 0.611800f, 0.239200f, 0.976400f} },
{ { 1.531470f, -0.400000f, 0.555570f}, { 1.000000f, 0.643200f, 0.619700f} },
{ { 1.531470f, 0.400000f, 0.555570f}, { 0.611800f, 0.231400f, 0.976400f} },
{ { 1.407107f, 0.400000f, 0.707107f}, { 0.572500f, 0.235300f, 0.976400f} },
{ { 0.000000f, -0.400000f, -0.707107f}, { 1.000000f, 0.000000f, 0.670600f} },
{ {-0.000000f, 0.400000f, 2.121320f}, { 0.000000f, 0.807800f, 1.000000f} },
{ {-0.000000f, -0.400000f, 2.121320f}, { 1.000000f, 0.921500f, 0.000000f} },
{ { 1.407107f, -0.400000f, 0.707107f}, { 1.000000f, 0.780400f, 0.415700f} },
{ {-0.144430f, -0.400000f, -0.831470f}, { 0.901900f, 0.439200f, 0.603900f} },
{ {-0.144430f, 0.400000f, -0.831470f}, { 1.000000f, 0.611800f, 0.211800f} },
{ {-0.317317f, -0.400000f, -0.923880f}, { 0.670600f, 0.745100f, 0.603900f} },
{ {-0.317317f, 0.400000f, -0.923880f}, { 1.000000f, 0.607900f, 0.235300f} },
{ {-0.504910f, -0.400000f, -0.980785f}, { 0.235300f, 0.976400f, 0.196100f} },
{ {-0.504910f, 0.400000f, -0.980785f}, { 1.000000f, 0.047100f, 0.913700f} },
{ {-0.700000f, -0.400000f, -1.000000f}, { 0.403900f, 0.917600f, 0.360800f} },
{ {-0.700000f, 0.400000f, -1.000000f}, { 1.000000f, 0.000000f, 0.909800f} },
{ {-0.895090f, -0.400000f, -0.980785f}, { 0.403900f, 0.917600f, 0.360800f} },
{ {-0.895090f, 0.400000f, -0.980785f}, { 1.000000f, 0.000000f, 0.909800f} },
{ {-1.082683f, -0.400000f, -0.923880f}, { 0.262700f, 0.968600f, 0.223500f} },
{ {-1.082683f, 0.400000f, -0.923880f}, { 1.000000f, 0.117600f, 0.956800f} },
{ {-1.255570f, -0.400000f, -0.831470f}, { 0.560800f, 0.831300f, 0.505900f} },
{ {-1.255570f, 0.400000f, -0.831470f}, { 1.000000f, 0.000000f, 0.956800f} },
{ {-1.407107f, -0.400000f, -0.707107f}, { 0.776400f, 0.996000f, 0.090200f} },
{ {-1.407107f, 0.400000f, -0.707107f}, { 1.000000f, 0.117600f, 0.956800f} },
{ {-1.531470f, -0.400000f, -0.555570f}, { 0.878400f, 0.941100f, 0.305900f} },
{ {-1.531470f, 0.400000f, -0.555570f}, { 1.000000f, 0.000000f, 0.956800f} },
{ {-1.623880f, -0.400000f, -0.382683f}, { 0.882300f, 0.933300f, 0.325500f} },
{ {-1.623880f, 0.400000f, -0.382683f}, { 0.984300f, 1.000000f, 0.019600f} },
{ {-1.680785f, -0.400000f, -0.195090f}, { 0.745100f, 0.878400f, 0.458900f} },
{ {-1.680785f, 0.400000f, -0.195090f}, { 0.698000f, 0.741200f, 0.639300f} },
{ {-1.700000f, -0.400000f, -0.000000f}, { 0.219600f, 0.768600f, 0.639300f} },
{ {-1.700000f, 0.400000f, -0.000000f}, { 0.254900f, 1.000000f, 0.003900f} },
{ {-1.680785f, -0.400000f, 0.195090f}, { 0.051000f, 0.203900f, 0.980400f} },
{ {-1.680785f, 0.400000f, 0.195090f}, { 0.251000f, 1.000000f, 0.003900f} },
{ {-1.623879f, -0.400000f, 0.382683f}, { 0.054900f, 0.223500f, 0.976400f} },
{ {-1.623879f, 0.400000f, 0.382683f}, { 0.251000f, 1.000000f, 0.003900f} },
{ {-1.531470f, -0.400000f, 0.555570f}, { 0.098000f, 0.423500f, 0.901900f} },
{ {-1.531470f, 0.400000f, 0.555570f}, { 0.251000f, 1.000000f, 0.003900f} },
{ {-1.407107f, 0.400000f, 0.707107f}, { 0.254900f, 1.000000f, 0.007800f} },
{ {-1.407107f, -0.400000f, 0.707107f}, { 0.105900f, 0.203900f, 0.980400f} },
};
constexpr vec3 normals[] = {
{ -0.652500f, -0.000000f, -0.757800f },
{ -0.471400f, -0.000000f, -0.881900f },
{ -0.290300f, -0.000000f, -0.956900f },
{ -0.098000f, -0.000000f, -0.995200f },
{ 0.098000f, -0.000000f, -0.995200f },
{ 0.290300f, -0.000000f, -0.956900f },
{ 0.471400f, -0.000000f, -0.881900f },
{ 0.634400f, -0.000000f, -0.773000f },
{ 0.773000f, -0.000000f, -0.634400f },
{ 0.881900f, -0.000000f, -0.471400f },
{ 0.956900f, -0.000000f, -0.290300f },
{ 0.995200f, -0.000000f, -0.098000f },
{ 0.995200f, -0.000000f, 0.098000f },
{ 0.956900f, -0.000000f, 0.290300f },
{ 0.881900f, -0.000000f, 0.471400f },
{ 0.773000f, -0.000000f, 0.634400f },
{ -0.000000f, 1.000000f, -0.000000f },
{ -0.000000f, -1.000000f, -0.000000f },
{ 0.708900f, -0.000000f, 0.705300f },
{ 0.652500f, -0.000000f, -0.757800f },
{ -0.634400f, -0.000000f, -0.773000f },
{ -0.773000f, -0.000000f, -0.634400f },
{ -0.881900f, -0.000000f, -0.471400f },
{ -0.956900f, -0.000000f, -0.290300f },
{ -0.995200f, -0.000000f, -0.098000f },
{ -0.995200f, -0.000000f, 0.098000f },
{ -0.956900f, -0.000000f, 0.290300f },
{ -0.881900f, -0.000000f, 0.471400f },
{ -0.773000f, -0.000000f, 0.634400f },
{ -0.708900f, -0.000000f, 0.705300f },
};
constexpr face_vn faces[] = {
{{ 0, 0}, { 1, 0}, {32, 0}},
{{ 2, 1}, { 3, 1}, { 1, 1}},
{{ 4, 2}, { 5, 2}, { 3, 2}},
{{ 6, 3}, { 7, 3}, { 5, 3}},
{{ 8, 4}, { 9, 4}, { 7, 4}},
{{10, 5}, {11, 5}, { 9, 5}},
{{12, 6}, {13, 6}, {11, 6}},
{{14, 7}, {15, 7}, {13, 7}},
{{16, 8}, {17, 8}, {15, 8}},
{{18, 9}, {19, 9}, {17, 9}},
{{20, 10}, {21, 10}, {19, 10}},
{{22, 11}, {23, 11}, {21, 11}},
{{24, 12}, {25, 12}, {23, 12}},
{{26, 13}, {27, 13}, {25, 13}},
{{28, 14}, {29, 14}, {27, 14}},
{{30, 15}, {35, 15}, {29, 15}},
{{ 0, 16}, {18, 16}, {10, 16}},
{{ 1, 17}, {17, 17}, {25, 17}},
{{31, 18}, {34, 18}, {35, 18}},
{{35, 17}, {34, 17}, {32, 17}},
{{33, 16}, {31, 16}, { 0, 16}},
{{36, 19}, { 0, 19}, {32, 19}},
{{38, 6}, {37, 6}, {36, 6}},
{{40, 5}, {39, 5}, {38, 5}},
{{42, 4}, {41, 4}, {40, 4}},
{{44, 3}, {43, 3}, {42, 3}},
{{46, 2}, {45, 2}, {44, 2}},
{{48, 1}, {47, 1}, {46, 1}},
{{50, 20}, {49, 20}, {48, 20}},
{{52, 21}, {51, 21}, {50, 21}},
{{54, 22}, {53, 22}, {52, 22}},
{{56, 23}, {55, 23}, {54, 23}},
{{58, 24}, {57, 24}, {56, 24}},
{{60, 25}, {59, 25}, {58, 25}},
{{62, 26}, {61, 26}, {60, 26}},
{{64, 27}, {63, 27}, {62, 27}},
{{67, 28}, {65, 28}, {64, 28}},
{{39, 16}, {55, 16}, {63, 16}},
{{67, 17}, {50, 17}, {42, 17}},
{{34, 29}, {66, 29}, {67, 29}},
{{67, 17}, {32, 17}, {34, 17}},
{{33, 16}, { 0, 16}, {66, 16}},
{{ 0, 0}, { 2, 0}, { 1, 0}},
{{ 2, 1}, { 4, 1}, { 3, 1}},
{{ 4, 2}, { 6, 2}, { 5, 2}},
{{ 6, 3}, { 8, 3}, { 7, 3}},
{{ 8, 4}, {10, 4}, { 9, 4}},
{{10, 5}, {12, 5}, {11, 5}},
{{12, 6}, {14, 6}, {13, 6}},
{{14, 7}, {16, 7}, {15, 7}},
{{16, 8}, {18, 8}, {17, 8}},
{{18, 9}, {20, 9}, {19, 9}},
{{20, 10}, {22, 10}, {21, 10}},
{{22, 11}, {24, 11}, {23, 11}},
{{24, 12}, {26, 12}, {25, 12}},
{{26, 13}, {28, 13}, {27, 13}},
{{28, 14}, {30, 14}, {29, 14}},
{{30, 15}, {31, 15}, {35, 15}},
{{ 4, 16}, { 2, 16}, { 0, 16}},
{{ 0, 16}, {31, 16}, {30, 16}},
{{30, 16}, {28, 16}, {26, 16}},
{{26, 16}, {24, 16}, {22, 16}},
{{22, 16}, {20, 16}, {18, 16}},
{{18, 16}, {16, 16}, {14, 16}},
{{14, 16}, {12, 16}, {10, 16}},
{{10, 16}, { 8, 16}, { 6, 16}},
{{ 6, 16}, { 4, 16}, { 0, 16}},
{{ 0, 16}, {30, 16}, {26, 16}},
{{26, 16}, {22, 16}, {18, 16}},
{{18, 16}, {14, 16}, {10, 16}},
{{10, 16}, { 6, 16}, { 0, 16}},
{{ 0, 16}, {26, 16}, {18, 16}},
{{35, 17}, {32, 17}, { 1, 17}},
{{ 1, 17}, { 3, 17}, { 5, 17}},
{{ 5, 17}, { 7, 17}, { 9, 17}},
{{ 9, 17}, {11, 17}, {13, 17}},
{{13, 17}, {15, 17}, {17, 17}},
{{17, 17}, {19, 17}, {21, 17}},
{{21, 17}, {23, 17}, {25, 17}},
{{25, 17}, {27, 17}, {29, 17}},
{{29, 17}, {35, 17}, { 1, 17}},
{{ 1, 17}, { 5, 17}, { 9, 17}},
{{ 9, 17}, {13, 17}, {17, 17}},
{{17, 17}, {21, 17}, {25, 17}},
{{25, 17}, {29, 17}, { 1, 17}},
{{ 1, 17}, { 9, 17}, {17, 17}},
{{31, 18}, {33, 18}, {34, 18}},
{{36, 19}, {37, 19}, { 0, 19}},
{{38, 6}, {39, 6}, {37, 6}},
{{40, 5}, {41, 5}, {39, 5}},
{{42, 4}, {43, 4}, {41, 4}},
{{44, 3}, {45, 3}, {43, 3}},
{{46, 2}, {47, 2}, {45, 2}},
{{48, 1}, {49, 1}, {47, 1}},
{{50, 20}, {51, 20}, {49, 20}},
{{52, 21}, {53, 21}, {51, 21}},
{{54, 22}, {55, 22}, {53, 22}},
{{56, 23}, {57, 23}, {55, 23}},
{{58, 24}, {59, 24}, {57, 24}},
{{60, 25}, {61, 25}, {59, 25}},
{{62, 26}, {63, 26}, {61, 26}},
{{64, 27}, {65, 27}, {63, 27}},
{{67, 28}, {66, 28}, {65, 28}},
{{ 0, 16}, {37, 16}, {39, 16}},
{{39, 16}, {41, 16}, {43, 16}},
{{43, 16}, {45, 16}, {47, 16}},
{{47, 16}, {49, 16}, {51, 16}},
{{51, 16}, {53, 16}, {55, 16}},
{{55, 16}, {57, 16}, {59, 16}},
{{59, 16}, {61, 16}, {63, 16}},
{{63, 16}, {65, 16}, {66, 16}},
{{66, 16}, { 0, 16}, {39, 16}},
{{39, 16}, {43, 16}, {47, 16}},
{{47, 16}, {51, 16}, {55, 16}},
{{55, 16}, {59, 16}, {63, 16}},
{{63, 16}, {66, 16}, {39, 16}},
{{39, 16}, {47, 16}, {55, 16}},
{{36, 17}, {32, 17}, {67, 17}},
{{67, 17}, {64, 17}, {62, 17}},
{{62, 17}, {60, 17}, {58, 17}},
{{58, 17}, {56, 17}, {54, 17}},
{{54, 17}, {52, 17}, {50, 17}},
{{50, 17}, {48, 17}, {46, 17}},
{{46, 17}, {44, 17}, {42, 17}},
{{42, 17}, {40, 17}, {38, 17}},
{{38, 17}, {36, 17}, {67, 17}},
{{67, 17}, {62, 17}, {58, 17}},
{{58, 17}, {54, 17}, {50, 17}},
{{50, 17}, {46, 17}, {42, 17}},
{{42, 17}, {38, 17}, {67, 17}},
{{67, 17}, {58, 17}, {50, 17}},
{{34, 29}, {33, 29}, {66, 29}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vn));
}

View File

@ -1,234 +0,0 @@
# Blender 3.3.6
# www.blender.org
o Heart
v 0.000000 0.400000 -0.707107 1.0000 0.6118 0.2118
v 0.144430 -0.400000 -0.831470 1.0000 0.0000 0.6745
v 0.144430 0.400000 -0.831470 1.0000 0.6118 0.2157
v 0.317317 -0.400000 -0.923880 1.0000 0.0000 0.6706
v 0.317317 0.400000 -0.923880 1.0000 0.6118 0.2118
v 0.504910 -0.400000 -0.980785 1.0000 0.0118 0.6706
v 0.504910 0.400000 -0.980785 1.0000 0.6118 0.2118
v 0.700000 -0.400000 -1.000000 1.0000 0.0000 0.6706
v 0.700000 0.400000 -1.000000 1.0000 0.6118 0.2118
v 0.895090 -0.400000 -0.980785 1.0000 0.0000 0.8980
v 0.895090 0.400000 -0.980785 1.0000 0.2353 0.8431
v 1.082684 -0.400000 -0.923879 1.0000 0.0235 0.9098
v 1.082684 0.400000 -0.923879 1.0000 0.6118 0.2118
v 1.255570 -0.400000 -0.831469 1.0000 0.3294 0.8666
v 1.255570 0.400000 -0.831469 1.0000 0.6157 0.2196
v 1.407107 -0.400000 -0.707107 1.0000 0.2823 0.8862
v 1.407107 0.400000 -0.707107 1.0000 0.5804 0.3843
v 1.531470 -0.400000 -0.555570 1.0000 0.2823 0.8862
v 1.531470 0.400000 -0.555570 1.0000 0.0510 0.6000
v 1.623880 -0.400000 -0.382683 1.0000 0.2823 0.8862
v 1.623880 0.400000 -0.382683 1.0000 0.0510 0.6039
v 1.680785 -0.400000 -0.195090 1.0000 0.6157 0.6745
v 1.680785 0.400000 -0.195090 1.0000 0.0353 0.7764
v 1.700000 -0.400000 0.000000 1.0000 0.6236 0.6667
v 1.700000 0.400000 0.000000 0.9882 0.0039 0.9960
v 1.680785 -0.400000 0.195090 1.0000 0.0000 0.9098
v 1.680785 0.400000 0.195090 0.8431 0.0118 0.9568
v 1.623879 -0.400000 0.382684 1.0000 0.0118 0.9098
v 1.623879 0.400000 0.382684 0.6118 0.2392 0.9764
v 1.531470 -0.400000 0.555570 1.0000 0.6432 0.6197
v 1.531470 0.400000 0.555570 0.6118 0.2314 0.9764
v 1.407107 0.400000 0.707107 0.5725 0.2353 0.9764
v 0.000000 -0.400000 -0.707107 1.0000 0.0000 0.6706
v -0.000000 0.400000 2.121320 0.0000 0.8078 1.0000
v -0.000000 -0.400000 2.121320 1.0000 0.9215 0.0000
v 1.407107 -0.400000 0.707107 1.0000 0.7804 0.4157
v -0.144430 -0.400000 -0.831470 0.9019 0.4392 0.6039
v -0.144430 0.400000 -0.831470 1.0000 0.6118 0.2118
v -0.317317 -0.400000 -0.923880 0.6706 0.7451 0.6039
v -0.317317 0.400000 -0.923880 1.0000 0.6079 0.2353
v -0.504910 -0.400000 -0.980785 0.2353 0.9764 0.1961
v -0.504910 0.400000 -0.980785 1.0000 0.0471 0.9137
v -0.700000 -0.400000 -1.000000 0.4039 0.9176 0.3608
v -0.700000 0.400000 -1.000000 1.0000 0.0000 0.9098
v -0.895090 -0.400000 -0.980785 0.4039 0.9176 0.3608
v -0.895090 0.400000 -0.980785 1.0000 0.0000 0.9098
v -1.082683 -0.400000 -0.923880 0.2627 0.9686 0.2235
v -1.082683 0.400000 -0.923880 1.0000 0.1176 0.9568
v -1.255570 -0.400000 -0.831470 0.5608 0.8313 0.5059
v -1.255570 0.400000 -0.831470 1.0000 0.0000 0.9568
v -1.407107 -0.400000 -0.707107 0.7764 0.9960 0.0902
v -1.407107 0.400000 -0.707107 1.0000 0.1176 0.9568
v -1.531470 -0.400000 -0.555570 0.8784 0.9411 0.3059
v -1.531470 0.400000 -0.555570 1.0000 0.0000 0.9568
v -1.623880 -0.400000 -0.382683 0.8823 0.9333 0.3255
v -1.623880 0.400000 -0.382683 0.9843 1.0000 0.0196
v -1.680785 -0.400000 -0.195090 0.7451 0.8784 0.4589
v -1.680785 0.400000 -0.195090 0.6980 0.7412 0.6393
v -1.700000 -0.400000 -0.000000 0.2196 0.7686 0.6393
v -1.700000 0.400000 -0.000000 0.2549 1.0000 0.0039
v -1.680785 -0.400000 0.195090 0.0510 0.2039 0.9804
v -1.680785 0.400000 0.195090 0.2510 1.0000 0.0039
v -1.623879 -0.400000 0.382683 0.0549 0.2235 0.9764
v -1.623879 0.400000 0.382683 0.2510 1.0000 0.0039
v -1.531470 -0.400000 0.555570 0.0980 0.4235 0.9019
v -1.531470 0.400000 0.555570 0.2510 1.0000 0.0039
v -1.407107 0.400000 0.707107 0.2549 1.0000 0.0078
v -1.407107 -0.400000 0.707107 0.1059 0.2039 0.9804
vn -0.6525 -0.0000 -0.7578
vn -0.4714 -0.0000 -0.8819
vn -0.2903 -0.0000 -0.9569
vn -0.0980 -0.0000 -0.9952
vn 0.0980 -0.0000 -0.9952
vn 0.2903 -0.0000 -0.9569
vn 0.4714 -0.0000 -0.8819
vn 0.6344 -0.0000 -0.7730
vn 0.7730 -0.0000 -0.6344
vn 0.8819 -0.0000 -0.4714
vn 0.9569 -0.0000 -0.2903
vn 0.9952 -0.0000 -0.0980
vn 0.9952 -0.0000 0.0980
vn 0.9569 -0.0000 0.2903
vn 0.8819 -0.0000 0.4714
vn 0.7730 -0.0000 0.6344
vn -0.0000 1.0000 -0.0000
vn -0.0000 -1.0000 -0.0000
vn 0.7089 -0.0000 0.7053
vn 0.6525 -0.0000 -0.7578
vn -0.6344 -0.0000 -0.7730
vn -0.7730 -0.0000 -0.6344
vn -0.8819 -0.0000 -0.4714
vn -0.9569 -0.0000 -0.2903
vn -0.9952 -0.0000 -0.0980
vn -0.9952 -0.0000 0.0980
vn -0.9569 -0.0000 0.2903
vn -0.8819 -0.0000 0.4714
vn -0.7730 -0.0000 0.6344
vn -0.7089 -0.0000 0.7053
s 0
f 1//1 2//1 33//1
f 3//2 4//2 2//2
f 5//3 6//3 4//3
f 7//4 8//4 6//4
f 9//5 10//5 8//5
f 11//6 12//6 10//6
f 13//7 14//7 12//7
f 15//8 16//8 14//8
f 17//9 18//9 16//9
f 19//10 20//10 18//10
f 21//11 22//11 20//11
f 23//12 24//12 22//12
f 25//13 26//13 24//13
f 27//14 28//14 26//14
f 29//15 30//15 28//15
f 31//16 36//16 30//16
f 1//17 19//17 11//17
f 2//18 18//18 26//18
f 32//19 35//19 36//19
f 36//18 35//18 33//18
f 34//17 32//17 1//17
f 37//20 1//20 33//20
f 39//7 38//7 37//7
f 41//6 40//6 39//6
f 43//5 42//5 41//5
f 45//4 44//4 43//4
f 47//3 46//3 45//3
f 49//2 48//2 47//2
f 51//21 50//21 49//21
f 53//22 52//22 51//22
f 55//23 54//23 53//23
f 57//24 56//24 55//24
f 59//25 58//25 57//25
f 61//26 60//26 59//26
f 63//27 62//27 61//27
f 65//28 64//28 63//28
f 68//29 66//29 65//29
f 40//17 56//17 64//17
f 68//18 51//18 43//18
f 35//30 67//30 68//30
f 68//18 33//18 35//18
f 34//17 1//17 67//17
f 1//1 3//1 2//1
f 3//2 5//2 4//2
f 5//3 7//3 6//3
f 7//4 9//4 8//4
f 9//5 11//5 10//5
f 11//6 13//6 12//6
f 13//7 15//7 14//7
f 15//8 17//8 16//8
f 17//9 19//9 18//9
f 19//10 21//10 20//10
f 21//11 23//11 22//11
f 23//12 25//12 24//12
f 25//13 27//13 26//13
f 27//14 29//14 28//14
f 29//15 31//15 30//15
f 31//16 32//16 36//16
f 5//17 3//17 1//17
f 1//17 32//17 31//17
f 31//17 29//17 27//17
f 27//17 25//17 23//17
f 23//17 21//17 19//17
f 19//17 17//17 15//17
f 15//17 13//17 11//17
f 11//17 9//17 7//17
f 7//17 5//17 1//17
f 1//17 31//17 27//17
f 27//17 23//17 19//17
f 19//17 15//17 11//17
f 11//17 7//17 1//17
f 1//17 27//17 19//17
f 36//18 33//18 2//18
f 2//18 4//18 6//18
f 6//18 8//18 10//18
f 10//18 12//18 14//18
f 14//18 16//18 18//18
f 18//18 20//18 22//18
f 22//18 24//18 26//18
f 26//18 28//18 30//18
f 30//18 36//18 2//18
f 2//18 6//18 10//18
f 10//18 14//18 18//18
f 18//18 22//18 26//18
f 26//18 30//18 2//18
f 2//18 10//18 18//18
f 32//19 34//19 35//19
f 37//20 38//20 1//20
f 39//7 40//7 38//7
f 41//6 42//6 40//6
f 43//5 44//5 42//5
f 45//4 46//4 44//4
f 47//3 48//3 46//3
f 49//2 50//2 48//2
f 51//21 52//21 50//21
f 53//22 54//22 52//22
f 55//23 56//23 54//23
f 57//24 58//24 56//24
f 59//25 60//25 58//25
f 61//26 62//26 60//26
f 63//27 64//27 62//27
f 65//28 66//28 64//28
f 68//29 67//29 66//29
f 1//17 38//17 40//17
f 40//17 42//17 44//17
f 44//17 46//17 48//17
f 48//17 50//17 52//17
f 52//17 54//17 56//17
f 56//17 58//17 60//17
f 60//17 62//17 64//17
f 64//17 66//17 67//17
f 67//17 1//17 40//17
f 40//17 44//17 48//17
f 48//17 52//17 56//17
f 56//17 60//17 64//17
f 64//17 67//17 40//17
f 40//17 48//17 56//17
f 37//18 33//18 68//18
f 68//18 65//18 63//18
f 63//18 61//18 59//18
f 59//18 57//18 55//18
f 55//18 53//18 51//18
f 51//18 49//18 47//18
f 47//18 45//18 43//18
f 43//18 41//18 39//18
f 39//18 37//18 68//18
f 68//18 63//18 59//18
f 59//18 55//18 51//18
f 51//18 47//18 43//18
f 43//18 39//18 68//18
f 68//18 59//18 51//18
f 35//30 34//30 67//30

View File

@ -47,7 +47,7 @@ namespace icosphere {
{ -0.425323f, 0.850654f, -0.309011f },
{ 0.162456f, 0.850654f, -0.499995f },
};
constexpr vec3 normals[] = {
{ 0.102400f, -0.943500f, 0.315100f },
{ 0.700200f, -0.661700f, 0.268000f },
@ -130,8 +130,8 @@ namespace icosphere {
{ 0.187600f, -0.794700f, 0.577300f },
{ 0.471300f, -0.661700f, 0.583100f },
};
constexpr face_vn faces[] = {
constexpr face faces[] = {
{{ 0, 0}, {13, 0}, {12, 0}},
{{ 1, 1}, {13, 1}, {15, 1}},
{{ 0, 2}, {12, 2}, {17, 2}},
@ -213,7 +213,7 @@ namespace icosphere {
{{12, 78}, {13, 78}, {14, 78}},
{{13, 79}, { 1, 79}, {14, 79}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vn));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
}

View File

@ -1,31 +0,0 @@
#pragma once
#include "geometry.hpp"
namespace plane {
constexpr position__color vertices[] = {
{ {-10.000000f, 0.000000f, -10.000000f}, { 0.011800f, 1.000000f, 1.000000f} },
{ {10.000000f, 0.000000f, -10.000000f}, { 1.000000f, 0.003900f, 0.066700f} },
{ {-10.000000f, 0.000000f, 10.000000f}, { 0.019600f, 1.000000f, 0.019600f} },
{ {10.000000f, 0.000000f, 10.000000f}, { 1.000000f, 0.952900f, 0.011800f} },
};
constexpr vec2 texture[] = {
{ 1.000000f, 0.000000f },
{ 0.000000f, 1.000000f },
{ 0.000000f, 0.000000f },
{ 1.000000f, 1.000000f },
};
constexpr vec3 normals[] = {
{ -0.000000f, -1.000000f, -0.000000f },
};
constexpr face_vtn faces[] = {
{{1, 0, 0}, {2, 1, 0}, {0, 2, 0}},
{{1, 0, 0}, {3, 3, 0}, {2, 1, 0}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vtn));
}

View File

@ -1,15 +0,0 @@
# Blender 3.3.6
# www.blender.org
o Plane
v -10.000000 0.000000 -10.000000 0.0118 1.0000 1.0000
v 10.000000 0.000000 -10.000000 1.0000 0.0039 0.0667
v -10.000000 0.000000 10.000000 0.0196 1.0000 0.0196
v 10.000000 0.000000 10.000000 1.0000 0.9529 0.0118
vn -0.0000 -1.0000 -0.0000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
vt 1.000000 1.000000
s 0
f 2/2/1 3/3/1 1/1/1
f 2/2/1 4/4/1 3/3/1

View File

@ -512,7 +512,7 @@ namespace suzanne {
{ 0.859375f, -0.382813f, 0.382812f },
{ -0.859375f, -0.382812f, 0.382813f },
};
constexpr vec3 normals[] = {
{ 0.661700f, 0.202600f, -0.721900f },
{ -0.661700f, 0.202600f, -0.721900f },
@ -1456,108 +1456,108 @@ namespace suzanne {
{ -0.360400f, 0.828300f, 0.429000f },
{ 0.360400f, 0.828300f, 0.429000f },
};
constexpr face_vn faces[] = {
{{ 46, 0}, { 2, 0}, { 44, 0}},
{{ 3, 1}, { 47, 1}, { 45, 1}},
{{ 44, 2}, { 4, 2}, { 42, 2}},
{{ 5, 3}, { 45, 3}, { 43, 3}},
{{ 2, 4}, { 6, 4}, { 4, 4}},
{{ 7, 5}, { 3, 5}, { 5, 5}},
{{ 0, 6}, { 8, 6}, { 2, 6}},
{{ 9, 7}, { 1, 7}, { 3, 7}},
{{ 10, 8}, { 14, 8}, { 8, 8}},
{{ 15, 9}, { 11, 9}, { 9, 9}},
{{ 8, 10}, { 16, 10}, { 6, 10}},
{{ 17, 11}, { 9, 11}, { 7, 11}},
{{ 20, 12}, { 16, 12}, { 14, 12}},
{{ 21, 13}, { 17, 13}, { 19, 13}},
{{ 22, 14}, { 14, 14}, { 12, 14}},
{{ 23, 15}, { 15, 15}, { 21, 15}},
{{ 22, 16}, { 26, 16}, { 20, 16}},
{{ 27, 17}, { 23, 17}, { 21, 17}},
{{ 26, 18}, { 18, 18}, { 20, 18}},
{{ 27, 19}, { 19, 19}, { 29, 19}},
{{ 32, 20}, { 28, 20}, { 26, 20}},
{{ 33, 21}, { 29, 21}, { 31, 21}},
{{ 34, 22}, { 26, 22}, { 24, 22}},
{{ 35, 23}, { 27, 23}, { 33, 23}},
{{ 36, 24}, { 32, 24}, { 34, 24}},
{{ 37, 25}, { 33, 25}, { 39, 25}},
{{ 38, 26}, { 30, 26}, { 32, 26}},
{{ 39, 27}, { 31, 27}, { 41, 27}},
{{ 44, 28}, { 40, 28}, { 38, 28}},
{{ 45, 29}, { 41, 29}, { 43, 29}},
{{ 46, 30}, { 38, 30}, { 36, 30}},
{{ 47, 31}, { 39, 31}, { 45, 31}},
{{ 36, 32}, { 48, 32}, { 46, 32}},
{{ 37, 33}, { 49, 33}, { 51, 33}},
{{ 34, 34}, { 50, 34}, { 36, 34}},
{{ 35, 35}, { 51, 35}, { 53, 35}},
{{ 24, 36}, { 52, 36}, { 34, 36}},
{{ 25, 37}, { 53, 37}, { 55, 37}},
{{ 22, 38}, { 54, 38}, { 24, 38}},
{{ 23, 39}, { 55, 39}, { 57, 39}},
{{ 22, 40}, { 58, 40}, { 56, 40}},
{{ 59, 41}, { 23, 41}, { 57, 41}},
{{ 12, 42}, { 62, 42}, { 58, 42}},
{{ 63, 43}, { 13, 43}, { 59, 43}},
{{ 10, 44}, { 64, 44}, { 62, 44}},
{{ 65, 45}, { 11, 45}, { 63, 45}},
{{ 0, 46}, { 48, 46}, { 64, 46}},
{{ 49, 47}, { 1, 47}, { 65, 47}},
{{ 60, 48}, { 64, 48}, { 48, 48}},
{{ 49, 49}, { 65, 49}, { 61, 49}},
{{ 62, 50}, { 64, 50}, { 60, 50}},
{{ 61, 51}, { 65, 51}, { 63, 51}},
{{ 60, 52}, { 58, 52}, { 62, 52}},
{{ 63, 53}, { 59, 53}, { 61, 53}},
{{ 60, 54}, { 56, 54}, { 58, 54}},
{{ 59, 55}, { 57, 55}, { 61, 55}},
{{ 60, 56}, { 54, 56}, { 56, 56}},
{{ 57, 57}, { 55, 57}, { 61, 57}},
{{ 60, 58}, { 52, 58}, { 54, 58}},
{{ 55, 59}, { 53, 59}, { 61, 59}},
{{ 60, 60}, { 50, 60}, { 52, 60}},
{{ 53, 61}, { 51, 61}, { 61, 61}},
{{ 60, 62}, { 48, 62}, { 50, 62}},
{{ 51, 63}, { 49, 63}, { 61, 63}},
{{173, 64}, { 90, 64}, { 88, 64}},
{{174, 65}, { 90, 65}, {175, 65}},
{{171, 66}, { 88, 66}, { 86, 66}},
{{172, 67}, { 89, 67}, {174, 67}},
{{ 84, 68}, {171, 68}, { 86, 68}},
{{172, 69}, { 85, 69}, { 87, 69}},
{{ 82, 70}, {169, 70}, { 84, 70}},
{{170, 71}, { 83, 71}, { 85, 71}},
{{ 80, 72}, {167, 72}, { 82, 72}},
{{168, 73}, { 81, 73}, { 83, 73}},
{{ 78, 74}, {145, 74}, {163, 74}},
{{146, 75}, { 79, 75}, {164, 75}},
{{ 93, 76}, {145, 76}, { 91, 76}},
{{ 94, 77}, {146, 77}, {148, 77}},
{{ 93, 78}, {149, 78}, {147, 78}},
{{150, 79}, { 94, 79}, {148, 79}},
{{ 97, 80}, {149, 80}, { 95, 80}},
{{ 98, 81}, {150, 81}, {152, 81}},
{{ 99, 82}, {151, 82}, { 97, 82}},
{{100, 83}, {152, 83}, {154, 83}},
{{101, 84}, {153, 84}, { 99, 84}},
{{102, 85}, {154, 85}, {156, 85}},
{{101, 86}, {157, 86}, {155, 86}},
{{158, 87}, {102, 87}, {156, 87}},
{{105, 88}, {157, 88}, {103, 88}},
{{106, 89}, {158, 89}, {160, 89}},
{{107, 90}, {159, 90}, {105, 90}},
{{108, 91}, {160, 91}, {162, 91}},
{{ 66, 92}, {161, 92}, {107, 92}},
{{ 66, 93}, {162, 93}, { 67, 93}},
{{127, 94}, {161, 94}, {109, 94}},
{{128, 95}, {162, 95}, {160, 95}},
{{127, 96}, {157, 96}, {159, 96}},
{{158, 97}, {128, 97}, {160, 97}},
{{155, 98}, {178, 98}, {125, 98}},
{{156, 99}, {179, 99}, {158, 99}},
constexpr face faces[] = {
{{46, 0}, { 2, 0}, {44, 0}},
{{ 3, 1}, {47, 1}, {45, 1}},
{{44, 2}, { 4, 2}, {42, 2}},
{{ 5, 3}, {45, 3}, {43, 3}},
{{ 2, 4}, { 6, 4}, { 4, 4}},
{{ 7, 5}, { 3, 5}, { 5, 5}},
{{ 0, 6}, { 8, 6}, { 2, 6}},
{{ 9, 7}, { 1, 7}, { 3, 7}},
{{10, 8}, {14, 8}, { 8, 8}},
{{15, 9}, {11, 9}, { 9, 9}},
{{ 8, 10}, {16, 10}, { 6, 10}},
{{17, 11}, { 9, 11}, { 7, 11}},
{{20, 12}, {16, 12}, {14, 12}},
{{21, 13}, {17, 13}, {19, 13}},
{{22, 14}, {14, 14}, {12, 14}},
{{23, 15}, {15, 15}, {21, 15}},
{{22, 16}, {26, 16}, {20, 16}},
{{27, 17}, {23, 17}, {21, 17}},
{{26, 18}, {18, 18}, {20, 18}},
{{27, 19}, {19, 19}, {29, 19}},
{{32, 20}, {28, 20}, {26, 20}},
{{33, 21}, {29, 21}, {31, 21}},
{{34, 22}, {26, 22}, {24, 22}},
{{35, 23}, {27, 23}, {33, 23}},
{{36, 24}, {32, 24}, {34, 24}},
{{37, 25}, {33, 25}, {39, 25}},
{{38, 26}, {30, 26}, {32, 26}},
{{39, 27}, {31, 27}, {41, 27}},
{{44, 28}, {40, 28}, {38, 28}},
{{45, 29}, {41, 29}, {43, 29}},
{{46, 30}, {38, 30}, {36, 30}},
{{47, 31}, {39, 31}, {45, 31}},
{{36, 32}, {48, 32}, {46, 32}},
{{37, 33}, {49, 33}, {51, 33}},
{{34, 34}, {50, 34}, {36, 34}},
{{35, 35}, {51, 35}, {53, 35}},
{{24, 36}, {52, 36}, {34, 36}},
{{25, 37}, {53, 37}, {55, 37}},
{{22, 38}, {54, 38}, {24, 38}},
{{23, 39}, {55, 39}, {57, 39}},
{{22, 40}, {58, 40}, {56, 40}},
{{59, 41}, {23, 41}, {57, 41}},
{{12, 42}, {62, 42}, {58, 42}},
{{63, 43}, {13, 43}, {59, 43}},
{{10, 44}, {64, 44}, {62, 44}},
{{65, 45}, {11, 45}, {63, 45}},
{{ 0, 46}, {48, 46}, {64, 46}},
{{49, 47}, { 1, 47}, {65, 47}},
{{60, 48}, {64, 48}, {48, 48}},
{{49, 49}, {65, 49}, {61, 49}},
{{62, 50}, {64, 50}, {60, 50}},
{{61, 51}, {65, 51}, {63, 51}},
{{60, 52}, {58, 52}, {62, 52}},
{{63, 53}, {59, 53}, {61, 53}},
{{60, 54}, {56, 54}, {58, 54}},
{{59, 55}, {57, 55}, {61, 55}},
{{60, 56}, {54, 56}, {56, 56}},
{{57, 57}, {55, 57}, {61, 57}},
{{60, 58}, {52, 58}, {54, 58}},
{{55, 59}, {53, 59}, {61, 59}},
{{60, 60}, {50, 60}, {52, 60}},
{{53, 61}, {51, 61}, {61, 61}},
{{60, 62}, {48, 62}, {50, 62}},
{{51, 63}, {49, 63}, {61, 63}},
{{173, 64}, {90, 64}, {88, 64}},
{{174, 65}, {90, 65}, {175, 65}},
{{171, 66}, {88, 66}, {86, 66}},
{{172, 67}, {89, 67}, {174, 67}},
{{84, 68}, {171, 68}, {86, 68}},
{{172, 69}, {85, 69}, {87, 69}},
{{82, 70}, {169, 70}, {84, 70}},
{{170, 71}, {83, 71}, {85, 71}},
{{80, 72}, {167, 72}, {82, 72}},
{{168, 73}, {81, 73}, {83, 73}},
{{78, 74}, {145, 74}, {163, 74}},
{{146, 75}, {79, 75}, {164, 75}},
{{93, 76}, {145, 76}, {91, 76}},
{{94, 77}, {146, 77}, {148, 77}},
{{93, 78}, {149, 78}, {147, 78}},
{{150, 79}, {94, 79}, {148, 79}},
{{97, 80}, {149, 80}, {95, 80}},
{{98, 81}, {150, 81}, {152, 81}},
{{99, 82}, {151, 82}, {97, 82}},
{{100, 83}, {152, 83}, {154, 83}},
{{101, 84}, {153, 84}, {99, 84}},
{{102, 85}, {154, 85}, {156, 85}},
{{101, 86}, {157, 86}, {155, 86}},
{{158, 87}, {102, 87}, {156, 87}},
{{105, 88}, {157, 88}, {103, 88}},
{{106, 89}, {158, 89}, {160, 89}},
{{107, 90}, {159, 90}, {105, 90}},
{{108, 91}, {160, 91}, {162, 91}},
{{66, 92}, {161, 92}, {107, 92}},
{{66, 93}, {162, 93}, {67, 93}},
{{127, 94}, {161, 94}, {109, 94}},
{{128, 95}, {162, 95}, {160, 95}},
{{127, 96}, {157, 96}, {159, 96}},
{{158, 97}, {128, 97}, {160, 97}},
{{155, 98}, {178, 98}, {125, 98}},
{{156, 99}, {179, 99}, {158, 99}},
{{153, 100}, {125, 100}, {123, 100}},
{{154, 101}, {126, 101}, {156, 101}},
{{151, 102}, {123, 102}, {121, 102}},
@ -1573,7 +1573,7 @@ namespace suzanne {
{{113, 111}, {176, 111}, {163, 111}},
{{176, 112}, {114, 112}, {164, 112}},
{{161, 113}, {111, 113}, {109, 113}},
{{162, 114}, {112, 114}, { 67, 114}},
{{162, 114}, {112, 114}, {67, 114}},
{{111, 115}, {177, 115}, {182, 115}},
{{177, 116}, {112, 116}, {183, 116}},
{{180, 117}, {177, 117}, {176, 117}},
@ -1590,24 +1590,24 @@ namespace suzanne {
{{168, 128}, {131, 128}, {185, 128}},
{{189, 129}, {186, 129}, {143, 129}},
{{189, 130}, {187, 130}, {188, 130}},
{{186, 131}, { 68, 131}, {184, 131}},
{{187, 132}, { 68, 132}, {188, 132}},
{{130, 133}, { 68, 133}, {129, 133}},
{{131, 133}, { 68, 133}, {185, 133}},
{{186, 131}, {68, 131}, {184, 131}},
{{187, 132}, {68, 132}, {188, 132}},
{{130, 133}, {68, 133}, {129, 133}},
{{131, 133}, {68, 133}, {185, 133}},
{{141, 134}, {190, 134}, {143, 134}},
{{191, 135}, {142, 135}, {144, 135}},
{{194, 136}, {141, 136}, {139, 136}},
{{195, 137}, {142, 137}, {193, 137}},
{{196, 138}, {139, 138}, {138, 138}},
{{197, 139}, {140, 139}, {195, 139}},
{{ 70, 140}, {138, 140}, {137, 140}},
{{ 70, 141}, {138, 141}, {197, 141}},
{{143, 142}, { 69, 142}, {189, 142}},
{{144, 143}, { 69, 143}, {191, 143}},
{{190, 144}, {207, 144}, { 69, 144}},
{{70, 140}, {138, 140}, {137, 140}},
{{70, 141}, {138, 141}, {197, 141}},
{{143, 142}, {69, 142}, {189, 142}},
{{144, 143}, {69, 143}, {191, 143}},
{{190, 144}, {207, 144}, {69, 144}},
{{191, 145}, {207, 145}, {206, 145}},
{{ 70, 146}, {199, 146}, {196, 146}},
{{200, 147}, { 70, 147}, {197, 147}},
{{70, 146}, {199, 146}, {196, 146}},
{{200, 147}, {70, 147}, {197, 147}},
{{196, 148}, {201, 148}, {194, 148}},
{{202, 149}, {197, 149}, {195, 149}},
{{201, 150}, {192, 150}, {194, 150}},
@ -1626,14 +1626,14 @@ namespace suzanne {
{{144, 163}, {211, 163}, {213, 163}},
{{186, 164}, {212, 164}, {143, 164}},
{{187, 165}, {213, 165}, {166, 165}},
{{208, 166}, {165, 166}, { 80, 166}},
{{208, 166}, {165, 166}, {80, 166}},
{{209, 167}, {166, 167}, {213, 167}},
{{214, 168}, {212, 168}, {208, 168}},
{{215, 169}, {213, 169}, {211, 169}},
{{ 78, 170}, {210, 170}, {214, 170}},
{{211, 171}, { 79, 171}, {215, 171}},
{{78, 170}, {210, 170}, {214, 170}},
{{211, 171}, {79, 171}, {215, 171}},
{{129, 172}, {221, 172}, {130, 172}},
{{129, 173}, {222, 173}, { 71, 173}},
{{129, 173}, {222, 173}, {71, 173}},
{{132, 174}, {221, 174}, {219, 174}},
{{222, 175}, {133, 175}, {220, 175}},
{{134, 176}, {219, 176}, {217, 176}},
@ -1646,8 +1646,8 @@ namespace suzanne {
{{227, 181}, {218, 181}, {229, 181}},
{{219, 140}, {224, 140}, {226, 140}},
{{225, 182}, {220, 182}, {227, 182}},
{{ 71, 183}, {224, 183}, {221, 183}},
{{ 71, 184}, {225, 184}, {223, 184}},
{{71, 183}, {224, 183}, {221, 183}},
{{71, 184}, {225, 184}, {223, 184}},
{{223, 185}, {228, 185}, {224, 185}},
{{229, 186}, {223, 186}, {225, 186}},
{{224, 187}, {228, 187}, {226, 187}},
@ -1704,74 +1704,74 @@ namespace suzanne {
{{282, 238}, {254, 238}, {260, 238}},
{{231, 239}, {279, 239}, {281, 239}},
{{280, 240}, {232, 240}, {282, 240}},
{{ 66, 241}, {283, 241}, { 72, 241}},
{{284, 242}, { 66, 242}, { 72, 242}},
{{66, 241}, {283, 241}, {72, 241}},
{{284, 242}, {66, 242}, {72, 242}},
{{107, 243}, {285, 243}, {283, 243}},
{{286, 244}, {108, 244}, {284, 244}},
{{103, 245}, {285, 245}, {105, 245}},
{{104, 246}, {286, 246}, {288, 246}},
{{101, 247}, {287, 247}, {103, 247}},
{{102, 248}, {288, 248}, {290, 248}},
{{ 99, 249}, {289, 249}, {101, 249}},
{{99, 249}, {289, 249}, {101, 249}},
{{100, 250}, {290, 250}, {292, 250}},
{{ 99, 251}, {293, 251}, {291, 251}},
{{99, 251}, {293, 251}, {291, 251}},
{{294, 252}, {100, 252}, {292, 252}},
{{ 95, 253}, {293, 253}, { 97, 253}},
{{ 96, 254}, {294, 254}, {296, 254}},
{{ 95, 255}, {297, 255}, {295, 255}},
{{298, 256}, { 96, 256}, {296, 256}},
{{ 93, 257}, {299, 257}, {297, 257}},
{{300, 258}, { 94, 258}, {298, 258}},
{{95, 253}, {293, 253}, {97, 253}},
{{96, 254}, {294, 254}, {296, 254}},
{{95, 255}, {297, 255}, {295, 255}},
{{298, 256}, {96, 256}, {296, 256}},
{{93, 257}, {299, 257}, {297, 257}},
{{300, 258}, {94, 258}, {298, 258}},
{{308, 259}, {337, 259}, {307, 259}},
{{308, 260}, {338, 260}, {328, 260}},
{{307, 261}, {335, 261}, {306, 261}},
{{307, 262}, {336, 262}, {338, 262}},
{{306, 263}, {339, 263}, {305, 263}},
{{306, 264}, {340, 264}, {336, 264}},
{{ 88, 265}, {305, 265}, {339, 265}},
{{305, 266}, { 89, 266}, {340, 266}},
{{ 86, 267}, {339, 267}, {333, 267}},
{{340, 268}, { 87, 268}, {334, 268}},
{{ 84, 269}, {333, 269}, {329, 269}},
{{334, 270}, { 85, 270}, {330, 270}},
{{ 82, 271}, {329, 271}, {331, 271}},
{{330, 272}, { 83, 272}, {332, 272}},
{{88, 265}, {305, 265}, {339, 265}},
{{305, 266}, {89, 266}, {340, 266}},
{{86, 267}, {339, 267}, {333, 267}},
{{340, 268}, {87, 268}, {334, 268}},
{{84, 269}, {333, 269}, {329, 269}},
{{334, 270}, {85, 270}, {330, 270}},
{{82, 271}, {329, 271}, {331, 271}},
{{330, 272}, {83, 272}, {332, 272}},
{{329, 273}, {337, 273}, {331, 273}},
{{338, 274}, {330, 274}, {332, 274}},
{{333, 275}, {335, 275}, {329, 275}},
{{334, 276}, {336, 276}, {340, 276}},
{{331, 277}, {327, 277}, {325, 277}},
{{332, 278}, {328, 278}, {338, 278}},
{{ 80, 279}, {331, 279}, {325, 279}},
{{332, 280}, { 81, 280}, {326, 280}},
{{80, 279}, {331, 279}, {325, 279}},
{{332, 280}, {81, 280}, {326, 280}},
{{341, 281}, {214, 281}, {208, 281}},
{{342, 282}, {215, 282}, {344, 282}},
{{325, 283}, {208, 283}, { 80, 283}},
{{325, 283}, {208, 283}, {80, 283}},
{{326, 284}, {209, 284}, {342, 284}},
{{214, 285}, {345, 285}, { 78, 285}},
{{214, 285}, {345, 285}, {78, 285}},
{{215, 286}, {346, 286}, {344, 286}},
{{345, 287}, { 91, 287}, { 78, 287}},
{{346, 288}, { 92, 288}, {300, 288}},
{{323, 289}, {303, 289}, { 76, 289}},
{{345, 287}, {91, 287}, {78, 287}},
{{346, 288}, {92, 288}, {300, 288}},
{{323, 289}, {303, 289}, {76, 289}},
{{324, 290}, {303, 290}, {352, 290}},
{{351, 291}, { 77, 291}, {303, 291}},
{{352, 292}, { 77, 292}, {350, 292}},
{{ 77, 293}, {347, 293}, {304, 293}},
{{348, 294}, { 77, 294}, {304, 294}},
{{351, 291}, {77, 291}, {303, 291}},
{{352, 292}, {77, 292}, {350, 292}},
{{77, 293}, {347, 293}, {304, 293}},
{{348, 294}, {77, 294}, {304, 294}},
{{304, 295}, {327, 295}, {308, 295}},
{{328, 296}, {304, 296}, {308, 296}},
{{327, 297}, {341, 297}, {325, 297}},
{{328, 298}, {342, 298}, {348, 298}},
{{295, 299}, {317, 299}, {309, 299}},
{{318, 300}, {296, 300}, {310, 300}},
{{315, 301}, { 76, 301}, { 75, 301}},
{{316, 302}, { 76, 302}, {324, 302}},
{{315, 301}, {76, 301}, {75, 301}},
{{316, 302}, {76, 302}, {324, 302}},
{{357, 303}, {302, 303}, {301, 303}},
{{358, 304}, {302, 304}, {356, 304}},
{{302, 305}, {353, 305}, { 74, 305}},
{{354, 306}, {302, 306}, { 74, 306}},
{{ 74, 307}, {315, 307}, { 75, 307}},
{{316, 308}, { 74, 308}, { 75, 308}},
{{302, 305}, {353, 305}, {74, 305}},
{{354, 306}, {302, 306}, {74, 306}},
{{74, 307}, {315, 307}, {75, 307}},
{{316, 308}, {74, 308}, {75, 308}},
{{291, 309}, {361, 309}, {363, 309}},
{{362, 310}, {292, 310}, {364, 310}},
{{363, 311}, {367, 311}, {365, 311}},
@ -1792,14 +1792,14 @@ namespace suzanne {
{{364, 326}, {358, 326}, {366, 326}},
{{291, 327}, {359, 327}, {289, 327}},
{{292, 328}, {360, 328}, {364, 328}},
{{359, 329}, {301, 329}, { 73, 329}},
{{359, 329}, {301, 329}, {73, 329}},
{{360, 330}, {301, 330}, {358, 330}},
{{285, 331}, {289, 331}, {283, 331}},
{{286, 332}, {290, 332}, {288, 332}},
{{283, 333}, {359, 333}, { 73, 333}},
{{360, 334}, {284, 334}, { 73, 334}},
{{ 72, 335}, {283, 335}, { 73, 335}},
{{ 73, 336}, {284, 336}, { 72, 336}},
{{283, 333}, {359, 333}, {73, 333}},
{{360, 334}, {284, 334}, {73, 334}},
{{72, 335}, {283, 335}, {73, 335}},
{{73, 336}, {284, 336}, {72, 336}},
{{295, 337}, {361, 337}, {293, 337}},
{{296, 338}, {362, 338}, {310, 338}},
{{309, 339}, {367, 339}, {361, 339}},
@ -1958,74 +1958,74 @@ namespace suzanne {
{{504, 487}, {314, 487}, {322, 487}},
{{319, 488}, {503, 488}, {389, 488}},
{{504, 489}, {320, 489}, {390, 489}},
{{ 46, 490}, { 0, 490}, { 2, 490}},
{{ 3, 491}, { 1, 491}, { 47, 491}},
{{ 44, 492}, { 2, 492}, { 4, 492}},
{{ 5, 493}, { 3, 493}, { 45, 493}},
{{ 2, 494}, { 8, 494}, { 6, 494}},
{{ 7, 495}, { 9, 495}, { 3, 495}},
{{ 0, 496}, { 10, 496}, { 8, 496}},
{{ 9, 497}, { 11, 497}, { 1, 497}},
{{ 10, 498}, { 12, 498}, { 14, 498}},
{{ 15, 499}, { 13, 499}, { 11, 499}},
{{ 8, 500}, { 14, 500}, { 16, 500}},
{{ 17, 501}, { 15, 501}, { 9, 501}},
{{ 20, 502}, { 18, 502}, { 16, 502}},
{{ 21, 503}, { 15, 503}, { 17, 503}},
{{ 22, 504}, { 20, 504}, { 14, 504}},
{{ 23, 505}, { 13, 505}, { 15, 505}},
{{ 22, 506}, { 24, 506}, { 26, 506}},
{{ 27, 507}, { 25, 507}, { 23, 507}},
{{ 26, 508}, { 28, 508}, { 18, 508}},
{{ 27, 509}, { 21, 509}, { 19, 509}},
{{ 32, 510}, { 30, 510}, { 28, 510}},
{{ 33, 511}, { 27, 511}, { 29, 511}},
{{ 34, 512}, { 32, 512}, { 26, 512}},
{{ 35, 513}, { 25, 513}, { 27, 513}},
{{ 36, 514}, { 38, 514}, { 32, 514}},
{{ 37, 515}, { 35, 515}, { 33, 515}},
{{ 38, 516}, { 40, 516}, { 30, 516}},
{{ 39, 517}, { 33, 517}, { 31, 517}},
{{ 44, 518}, { 42, 518}, { 40, 518}},
{{ 45, 519}, { 39, 519}, { 41, 519}},
{{ 46, 520}, { 44, 520}, { 38, 520}},
{{ 47, 521}, { 37, 521}, { 39, 521}},
{{ 36, 522}, { 50, 522}, { 48, 522}},
{{ 37, 523}, { 47, 523}, { 49, 523}},
{{ 34, 524}, { 52, 524}, { 50, 524}},
{{ 35, 525}, { 37, 525}, { 51, 525}},
{{ 24, 526}, { 54, 526}, { 52, 526}},
{{ 25, 527}, { 35, 527}, { 53, 527}},
{{ 22, 528}, { 56, 528}, { 54, 528}},
{{ 23, 529}, { 25, 529}, { 55, 529}},
{{ 22, 530}, { 12, 530}, { 58, 530}},
{{ 59, 531}, { 13, 531}, { 23, 531}},
{{ 12, 532}, { 10, 532}, { 62, 532}},
{{ 63, 533}, { 11, 533}, { 13, 533}},
{{ 10, 534}, { 0, 534}, { 64, 534}},
{{ 65, 535}, { 1, 535}, { 11, 535}},
{{ 0, 536}, { 46, 536}, { 48, 536}},
{{ 49, 537}, { 47, 537}, { 1, 537}},
{{173, 538}, {175, 538}, { 90, 538}},
{{174, 539}, { 89, 539}, { 90, 539}},
{{171, 540}, {173, 540}, { 88, 540}},
{{172, 541}, { 87, 541}, { 89, 541}},
{{ 84, 542}, {169, 542}, {171, 542}},
{{172, 543}, {170, 543}, { 85, 543}},
{{ 82, 544}, {167, 544}, {169, 544}},
{{170, 545}, {168, 545}, { 83, 545}},
{{ 80, 546}, {165, 546}, {167, 546}},
{{168, 547}, {166, 547}, { 81, 547}},
{{ 78, 548}, { 91, 548}, {145, 548}},
{{146, 549}, { 92, 549}, { 79, 549}},
{{ 93, 550}, {147, 550}, {145, 550}},
{{ 94, 551}, { 92, 551}, {146, 551}},
{{ 93, 552}, { 95, 552}, {149, 552}},
{{150, 553}, { 96, 553}, { 94, 553}},
{{ 97, 554}, {151, 554}, {149, 554}},
{{ 98, 555}, { 96, 555}, {150, 555}},
{{ 99, 556}, {153, 556}, {151, 556}},
{{100, 557}, { 98, 557}, {152, 557}},
{{46, 490}, { 0, 490}, { 2, 490}},
{{ 3, 491}, { 1, 491}, {47, 491}},
{{44, 492}, { 2, 492}, { 4, 492}},
{{ 5, 493}, { 3, 493}, {45, 493}},
{{ 2, 494}, { 8, 494}, { 6, 494}},
{{ 7, 495}, { 9, 495}, { 3, 495}},
{{ 0, 496}, {10, 496}, { 8, 496}},
{{ 9, 497}, {11, 497}, { 1, 497}},
{{10, 498}, {12, 498}, {14, 498}},
{{15, 499}, {13, 499}, {11, 499}},
{{ 8, 500}, {14, 500}, {16, 500}},
{{17, 501}, {15, 501}, { 9, 501}},
{{20, 502}, {18, 502}, {16, 502}},
{{21, 503}, {15, 503}, {17, 503}},
{{22, 504}, {20, 504}, {14, 504}},
{{23, 505}, {13, 505}, {15, 505}},
{{22, 506}, {24, 506}, {26, 506}},
{{27, 507}, {25, 507}, {23, 507}},
{{26, 508}, {28, 508}, {18, 508}},
{{27, 509}, {21, 509}, {19, 509}},
{{32, 510}, {30, 510}, {28, 510}},
{{33, 511}, {27, 511}, {29, 511}},
{{34, 512}, {32, 512}, {26, 512}},
{{35, 513}, {25, 513}, {27, 513}},
{{36, 514}, {38, 514}, {32, 514}},
{{37, 515}, {35, 515}, {33, 515}},
{{38, 516}, {40, 516}, {30, 516}},
{{39, 517}, {33, 517}, {31, 517}},
{{44, 518}, {42, 518}, {40, 518}},
{{45, 519}, {39, 519}, {41, 519}},
{{46, 520}, {44, 520}, {38, 520}},
{{47, 521}, {37, 521}, {39, 521}},
{{36, 522}, {50, 522}, {48, 522}},
{{37, 523}, {47, 523}, {49, 523}},
{{34, 524}, {52, 524}, {50, 524}},
{{35, 525}, {37, 525}, {51, 525}},
{{24, 526}, {54, 526}, {52, 526}},
{{25, 527}, {35, 527}, {53, 527}},
{{22, 528}, {56, 528}, {54, 528}},
{{23, 529}, {25, 529}, {55, 529}},
{{22, 530}, {12, 530}, {58, 530}},
{{59, 531}, {13, 531}, {23, 531}},
{{12, 532}, {10, 532}, {62, 532}},
{{63, 533}, {11, 533}, {13, 533}},
{{10, 534}, { 0, 534}, {64, 534}},
{{65, 535}, { 1, 535}, {11, 535}},
{{ 0, 536}, {46, 536}, {48, 536}},
{{49, 537}, {47, 537}, { 1, 537}},
{{173, 538}, {175, 538}, {90, 538}},
{{174, 539}, {89, 539}, {90, 539}},
{{171, 540}, {173, 540}, {88, 540}},
{{172, 541}, {87, 541}, {89, 541}},
{{84, 542}, {169, 542}, {171, 542}},
{{172, 543}, {170, 543}, {85, 543}},
{{82, 544}, {167, 544}, {169, 544}},
{{170, 545}, {168, 545}, {83, 545}},
{{80, 546}, {165, 546}, {167, 546}},
{{168, 547}, {166, 547}, {81, 547}},
{{78, 548}, {91, 548}, {145, 548}},
{{146, 549}, {92, 549}, {79, 549}},
{{93, 550}, {147, 550}, {145, 550}},
{{94, 551}, {92, 551}, {146, 551}},
{{93, 552}, {95, 552}, {149, 552}},
{{150, 553}, {96, 553}, {94, 553}},
{{97, 554}, {151, 554}, {149, 554}},
{{98, 555}, {96, 555}, {150, 555}},
{{99, 556}, {153, 556}, {151, 556}},
{{100, 557}, {98, 557}, {152, 557}},
{{101, 558}, {155, 558}, {153, 558}},
{{102, 559}, {100, 559}, {154, 559}},
{{101, 560}, {103, 560}, {157, 560}},
@ -2034,8 +2034,8 @@ namespace suzanne {
{{106, 563}, {104, 563}, {158, 563}},
{{107, 564}, {161, 564}, {159, 564}},
{{108, 565}, {106, 565}, {160, 565}},
{{ 66, 566}, { 67, 566}, {161, 566}},
{{ 66, 567}, {108, 567}, {162, 567}},
{{66, 566}, {67, 566}, {161, 566}},
{{66, 567}, {108, 567}, {162, 567}},
{{127, 568}, {159, 568}, {161, 568}},
{{128, 569}, {110, 569}, {162, 569}},
{{127, 570}, {178, 570}, {157, 570}},
@ -2056,10 +2056,10 @@ namespace suzanne {
{{146, 585}, {164, 585}, {114, 585}},
{{113, 586}, {180, 586}, {176, 586}},
{{176, 587}, {181, 587}, {114, 587}},
{{161, 588}, { 67, 588}, {111, 588}},
{{161, 588}, {67, 588}, {111, 588}},
{{162, 589}, {110, 589}, {112, 589}},
{{111, 590}, { 67, 590}, {177, 590}},
{{177, 591}, { 67, 591}, {112, 591}},
{{111, 590}, {67, 590}, {177, 590}},
{{177, 591}, {67, 591}, {112, 591}},
{{180, 592}, {182, 592}, {177, 592}},
{{181, 593}, {176, 593}, {177, 593}},
{{134, 594}, {136, 594}, {175, 594}},
@ -2074,23 +2074,23 @@ namespace suzanne {
{{168, 603}, {170, 603}, {131, 603}},
{{189, 130}, {188, 130}, {186, 130}},
{{189, 604}, {144, 604}, {187, 604}},
{{186, 132}, {188, 132}, { 68, 132}},
{{187, 605}, {185, 605}, { 68, 605}},
{{130, 133}, {184, 133}, { 68, 133}},
{{131, 133}, {129, 133}, { 68, 133}},
{{186, 132}, {188, 132}, {68, 132}},
{{187, 605}, {185, 605}, {68, 605}},
{{130, 133}, {184, 133}, {68, 133}},
{{131, 133}, {129, 133}, {68, 133}},
{{141, 606}, {192, 606}, {190, 606}},
{{191, 607}, {193, 607}, {142, 607}},
{{194, 608}, {192, 608}, {141, 608}},
{{195, 609}, {140, 609}, {142, 609}},
{{196, 610}, {194, 610}, {139, 610}},
{{197, 611}, {138, 611}, {140, 611}},
{{ 70, 612}, {196, 612}, {138, 612}},
{{143, 613}, {190, 613}, { 69, 613}},
{{144, 614}, {189, 614}, { 69, 614}},
{{70, 612}, {196, 612}, {138, 612}},
{{143, 613}, {190, 613}, {69, 613}},
{{144, 614}, {189, 614}, {69, 614}},
{{190, 144}, {205, 144}, {207, 144}},
{{191, 145}, { 69, 145}, {207, 145}},
{{ 70, 615}, {198, 615}, {199, 615}},
{{200, 616}, {198, 616}, { 70, 616}},
{{191, 145}, {69, 145}, {207, 145}},
{{70, 615}, {198, 615}, {199, 615}},
{{200, 616}, {198, 616}, {70, 616}},
{{196, 617}, {199, 617}, {201, 617}},
{{202, 618}, {200, 618}, {197, 618}},
{{201, 619}, {203, 619}, {192, 619}},
@ -2110,12 +2110,12 @@ namespace suzanne {
{{186, 633}, {165, 633}, {212, 633}},
{{187, 634}, {144, 634}, {213, 634}},
{{208, 635}, {212, 635}, {165, 635}},
{{209, 636}, { 81, 636}, {166, 636}},
{{209, 636}, {81, 636}, {166, 636}},
{{214, 637}, {210, 637}, {212, 637}},
{{215, 638}, {209, 638}, {213, 638}},
{{ 78, 639}, {163, 639}, {210, 639}},
{{211, 640}, {164, 640}, { 79, 640}},
{{129, 641}, { 71, 641}, {221, 641}},
{{78, 639}, {163, 639}, {210, 639}},
{{211, 640}, {164, 640}, {79, 640}},
{{129, 641}, {71, 641}, {221, 641}},
{{129, 642}, {131, 642}, {222, 642}},
{{132, 643}, {130, 643}, {221, 643}},
{{222, 644}, {131, 644}, {133, 644}},
@ -2129,8 +2129,8 @@ namespace suzanne {
{{227, 650}, {220, 650}, {218, 650}},
{{219, 140}, {221, 140}, {224, 140}},
{{225, 182}, {222, 182}, {220, 182}},
{{ 71, 183}, {223, 183}, {224, 183}},
{{ 71, 184}, {222, 184}, {225, 184}},
{{71, 183}, {223, 183}, {224, 183}},
{{71, 184}, {222, 184}, {225, 184}},
{{223, 651}, {230, 651}, {228, 651}},
{{229, 652}, {230, 652}, {223, 652}},
{{182, 653}, {180, 653}, {233, 653}},
@ -2185,74 +2185,74 @@ namespace suzanne {
{{282, 700}, {232, 700}, {254, 700}},
{{231, 701}, {233, 701}, {279, 701}},
{{280, 702}, {234, 702}, {232, 702}},
{{ 66, 703}, {107, 703}, {283, 703}},
{{284, 704}, {108, 704}, { 66, 704}},
{{66, 703}, {107, 703}, {283, 703}},
{{284, 704}, {108, 704}, {66, 704}},
{{107, 705}, {105, 705}, {285, 705}},
{{286, 706}, {106, 706}, {108, 706}},
{{103, 707}, {287, 707}, {285, 707}},
{{104, 708}, {106, 708}, {286, 708}},
{{101, 709}, {289, 709}, {287, 709}},
{{102, 710}, {104, 710}, {288, 710}},
{{ 99, 711}, {291, 711}, {289, 711}},
{{99, 711}, {291, 711}, {289, 711}},
{{100, 712}, {102, 712}, {290, 712}},
{{ 99, 713}, { 97, 713}, {293, 713}},
{{294, 714}, { 98, 714}, {100, 714}},
{{ 95, 715}, {295, 715}, {293, 715}},
{{ 96, 716}, { 98, 716}, {294, 716}},
{{ 95, 717}, { 93, 717}, {297, 717}},
{{298, 718}, { 94, 718}, { 96, 718}},
{{ 93, 719}, { 91, 719}, {299, 719}},
{{300, 720}, { 92, 720}, { 94, 720}},
{{99, 713}, {97, 713}, {293, 713}},
{{294, 714}, {98, 714}, {100, 714}},
{{95, 715}, {295, 715}, {293, 715}},
{{96, 716}, {98, 716}, {294, 716}},
{{95, 717}, {93, 717}, {297, 717}},
{{298, 718}, {94, 718}, {96, 718}},
{{93, 719}, {91, 719}, {299, 719}},
{{300, 720}, {92, 720}, {94, 720}},
{{308, 721}, {327, 721}, {337, 721}},
{{308, 722}, {307, 722}, {338, 722}},
{{307, 723}, {337, 723}, {335, 723}},
{{307, 724}, {306, 724}, {336, 724}},
{{306, 725}, {335, 725}, {339, 725}},
{{306, 726}, {305, 726}, {340, 726}},
{{ 88, 727}, { 90, 727}, {305, 727}},
{{305, 728}, { 90, 728}, { 89, 728}},
{{ 86, 729}, { 88, 729}, {339, 729}},
{{340, 730}, { 89, 730}, { 87, 730}},
{{ 84, 731}, { 86, 731}, {333, 731}},
{{334, 732}, { 87, 732}, { 85, 732}},
{{ 82, 733}, { 84, 733}, {329, 733}},
{{330, 734}, { 85, 734}, { 83, 734}},
{{88, 727}, {90, 727}, {305, 727}},
{{305, 728}, {90, 728}, {89, 728}},
{{86, 729}, {88, 729}, {339, 729}},
{{340, 730}, {89, 730}, {87, 730}},
{{84, 731}, {86, 731}, {333, 731}},
{{334, 732}, {87, 732}, {85, 732}},
{{82, 733}, {84, 733}, {329, 733}},
{{330, 734}, {85, 734}, {83, 734}},
{{329, 735}, {335, 735}, {337, 735}},
{{338, 736}, {336, 736}, {330, 736}},
{{333, 737}, {339, 737}, {335, 737}},
{{334, 738}, {330, 738}, {336, 738}},
{{331, 739}, {337, 739}, {327, 739}},
{{332, 740}, {326, 740}, {328, 740}},
{{ 80, 741}, { 82, 741}, {331, 741}},
{{332, 742}, { 83, 742}, { 81, 742}},
{{80, 741}, {82, 741}, {331, 741}},
{{332, 742}, {83, 742}, {81, 742}},
{{341, 743}, {343, 743}, {214, 743}},
{{342, 744}, {209, 744}, {215, 744}},
{{325, 745}, {341, 745}, {208, 745}},
{{326, 746}, { 81, 746}, {209, 746}},
{{326, 746}, {81, 746}, {209, 746}},
{{214, 747}, {343, 747}, {345, 747}},
{{215, 748}, { 79, 748}, {346, 748}},
{{345, 749}, {299, 749}, { 91, 749}},
{{346, 750}, { 79, 750}, { 92, 750}},
{{215, 748}, {79, 748}, {346, 748}},
{{345, 749}, {299, 749}, {91, 749}},
{{346, 750}, {79, 750}, {92, 750}},
{{323, 751}, {351, 751}, {303, 751}},
{{324, 752}, { 76, 752}, {303, 752}},
{{351, 753}, {349, 753}, { 77, 753}},
{{352, 754}, {303, 754}, { 77, 754}},
{{ 77, 755}, {349, 755}, {347, 755}},
{{348, 756}, {350, 756}, { 77, 756}},
{{324, 752}, {76, 752}, {303, 752}},
{{351, 753}, {349, 753}, {77, 753}},
{{352, 754}, {303, 754}, {77, 754}},
{{77, 755}, {349, 755}, {347, 755}},
{{348, 756}, {350, 756}, {77, 756}},
{{304, 757}, {347, 757}, {327, 757}},
{{328, 758}, {348, 758}, {304, 758}},
{{327, 759}, {347, 759}, {341, 759}},
{{328, 760}, {326, 760}, {342, 760}},
{{295, 761}, {297, 761}, {317, 761}},
{{318, 762}, {298, 762}, {296, 762}},
{{315, 763}, {323, 763}, { 76, 763}},
{{316, 764}, { 75, 764}, { 76, 764}},
{{315, 763}, {323, 763}, {76, 763}},
{{316, 764}, {75, 764}, {76, 764}},
{{357, 765}, {355, 765}, {302, 765}},
{{358, 766}, {301, 766}, {302, 766}},
{{302, 767}, {355, 767}, {353, 767}},
{{354, 768}, {356, 768}, {302, 768}},
{{ 74, 769}, {353, 769}, {315, 769}},
{{316, 770}, {354, 770}, { 74, 770}},
{{74, 769}, {353, 769}, {315, 769}},
{{316, 770}, {354, 770}, {74, 770}},
{{291, 771}, {293, 771}, {361, 771}},
{{362, 772}, {294, 772}, {292, 772}},
{{363, 773}, {361, 773}, {367, 773}},
@ -2274,7 +2274,7 @@ namespace suzanne {
{{291, 789}, {363, 789}, {359, 789}},
{{292, 790}, {290, 790}, {360, 790}},
{{359, 791}, {357, 791}, {301, 791}},
{{360, 792}, { 73, 792}, {301, 792}},
{{360, 792}, {73, 792}, {301, 792}},
{{285, 793}, {287, 793}, {289, 793}},
{{286, 794}, {284, 794}, {290, 794}},
{{283, 795}, {289, 795}, {359, 795}},
@ -2426,7 +2426,7 @@ namespace suzanne {
{{319, 939}, {321, 939}, {503, 939}},
{{504, 940}, {322, 940}, {320, 940}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vn));
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
#pragma once
#include "geometry.hpp"
namespace triangle {
constexpr vec3 vertices[] = {
{ -1.000000f, 0.000000f, 0.000000f },
{ 1.000000f, 0.000000f, 1.000000f },
{ 1.000000f, 0.000000f, -1.000000f },
};
constexpr vec2 texture[] = {
{ 0.000000f, 0.000000f },
{ 1.000000f, 0.000000f },
{ 1.000000f, 1.000000f },
};
constexpr vec3 normals[] = {
{ -0.000000f, 1.000000f, -0.000000f },
};
constexpr face_vtn faces[] = {
{{0, 0, 0}, {1, 1, 0}, {2, 2, 0}},
};
constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face_vtn));
}

View File

@ -1,12 +0,0 @@
# Blender 3.3.6
# www.blender.org
o Triangle
v -1.000000 0.000000 0.000000
v 1.000000 0.000000 1.000000
v 1.000000 0.000000 -1.000000
vn -0.0000 1.0000 -0.0000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
s 0
f 1/1/1 2/2/1 3/3/1

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
#include "float_uint32.hpp"
#include "memorymap.hpp"
#include "systembus.hpp"
#include "systembus_bits.hpp"
#include "../float_uint32.hpp"
#include "core_bits.hpp"
#include "../holly.hpp"
#include "../memorymap.hpp"
#include "../systembus.hpp"
#include "../systembus_bits.hpp"
#include "texture_memory_alloc.hpp"
#include "holly.hpp"
#include "core.hpp"
#include "core_bits.hpp"
#include "background.hpp"
#include "region_array.hpp"

View File

@ -1,5 +1,3 @@
#pragma once
#include <cstdint>
#include "../float_uint32.hpp"
@ -53,24 +51,24 @@ namespace fb_r_ctrl {
namespace vclk_div {
constexpr uint32_t pclk_vclk_2 = 0 << 23;
constexpr uint32_t pclk_vclk_1 = 1 << 23;
constexpr uint32_t bit_mask = 0x1 << 23;
}
constexpr uint32_t fb_strip_buf_en = 1 << 22;
constexpr uint32_t fb_stripsize(uint32_t num) { return (num & 0x3e) << 16; }
constexpr uint32_t fb_chroma_threshold(uint32_t num) { return (num & 0xff) << 8; }
constexpr uint32_t fb_concat(uint32_t num) { return (num & 0x3) << 4; }
namespace fb_depth {
constexpr uint32_t _0555_rgb_16bit = 0 << 2;
constexpr uint32_t _0565_rgb_16bit = 1 << 2;
constexpr uint32_t _888_rgb_24bit_packed = 2 << 2;
constexpr uint32_t _0888_rgb_32bit = 3 << 2;
constexpr uint32_t bit_mask = 0x3 << 2;
}
constexpr uint32_t fb_line_double = 1 << 1;
constexpr uint32_t fb_enable = 1 << 0;
}
@ -79,7 +77,7 @@ namespace fb_w_ctrl {
constexpr uint32_t fb_alpha_threshold(uint32_t num) { return (num & 0xff) << 16; }
constexpr uint32_t fb_kval(uint32_t num) { return (num & 0xff) << 8; }
constexpr uint32_t fb_dither = 1 << 3;
namespace fb_packmode {
constexpr uint32_t _0555_krgb_16bit = 0 << 0;
constexpr uint32_t _565_rgb_16bit = 1 << 0;
@ -88,7 +86,7 @@ namespace fb_w_ctrl {
constexpr uint32_t _888_rgb_24bit_packed = 4 << 0;
constexpr uint32_t _0888_krgb_32bit = 5 << 0;
constexpr uint32_t _8888_argb_32bit = 6 << 0;
constexpr uint32_t bit_mask = 0x7 << 0;
}
}
@ -133,25 +131,25 @@ namespace fpu_shad_scale {
namespace simple_shadow_enable {
constexpr uint32_t parameter_selection_volume_mode = 0 << 8;
constexpr uint32_t intensity_volume_mode = 1 << 8;
constexpr uint32_t bit_mask = 0x1 << 8;
}
constexpr uint32_t scale_factor_for_shadows(uint32_t num) { return (num & 0xff) << 0; }
}
namespace fpu_cull_val {
inline uint32_t culling_comparison_value(float num) { return _i(__builtin_fabsf(num));; }
constexpr uint32_t culling_comparison_value(float num) { return _i(__builtin_fabsf(num));; }
}
namespace fpu_param_cfg {
namespace region_header_type {
constexpr uint32_t type_1 = 0 << 21;
constexpr uint32_t type_2 = 1 << 21;
constexpr uint32_t bit_mask = 0x1 << 21;
}
constexpr uint32_t tsp_parameter_burst_threshold(uint32_t num) { return (num & 0x3f) << 14; }
constexpr uint32_t isp_parameter_burst_threshold(uint32_t num) { return (num & 0x3f) << 8; }
constexpr uint32_t pointer_burst_size(uint32_t num) { return (num & 0xf) << 4; }
@ -162,31 +160,31 @@ namespace half_offset {
namespace tsp_texel_sampling_position {
constexpr uint32_t top_left = 1 << 2;
constexpr uint32_t center = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace tsp_pixel_sampling_position {
constexpr uint32_t top_left = 1 << 1;
constexpr uint32_t center = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace fpu_pixel_sampling_position {
constexpr uint32_t top_left = 1 << 0;
constexpr uint32_t center = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
namespace fpu_perp_val {
inline uint32_t perpendicular_triangle_compare(float num) { return _i(__builtin_fabsf(num));; }
constexpr uint32_t perpendicular_triangle_compare(float num) { return _i(__builtin_fabsf(num));; }
}
namespace isp_backgnd_d {
inline uint32_t background_plane_depth(float num) { return _i(num) & 0xfffffff0; }
constexpr uint32_t background_plane_depth(float num) { return _i(num) & 0xfffffff0; }
}
namespace isp_backgnd_t {
@ -222,18 +220,18 @@ namespace sdram_arb_cfg {
constexpr uint32_t isp_pointer_data = 0x9 << 18;
constexpr uint32_t isp_parameters = 0xa << 18;
constexpr uint32_t crt_controller = 0xb << 18;
constexpr uint32_t bit_mask = 0xf << 18;
}
namespace arbiter_priority_control {
constexpr uint32_t priority_arbitration_only = 0x0 << 16;
constexpr uint32_t override_value_field = 0x1 << 16;
constexpr uint32_t round_robin_counter = 0x2 << 16;
constexpr uint32_t bit_mask = 0x3 << 16;
}
constexpr uint32_t arbiter_crt_page_break_latency_count_value(uint32_t num) { return (num & 0xff) << 8; }
constexpr uint32_t arbiter_page_break_latency_count_value(uint32_t num) { return (num & 0xff) << 0; }
}
@ -289,15 +287,15 @@ namespace spg_trigger_pos {
namespace spg_hblank_int {
constexpr uint32_t hblank_in_interrupt(uint32_t reg) { return (reg >> 16) & 0x3ff; }
namespace hblank_int_mode {
constexpr uint32_t output_equal_line_comp_val = 0x0 << 12;
constexpr uint32_t output_every_line_comp_val = 0x1 << 12;
constexpr uint32_t output_every_line = 0x2 << 12;
constexpr uint32_t bit_mask = 0x3 << 12;
}
constexpr uint32_t line_comp_val(uint32_t num) { return (num & 0x3ff) << 0; }
}
@ -310,41 +308,41 @@ namespace spg_control {
namespace csync_on_h {
constexpr uint32_t hsync = 0 << 9;
constexpr uint32_t csync = 1 << 9;
constexpr uint32_t bit_mask = 0x1 << 9;
}
namespace sync_direction {
constexpr uint32_t input = 0 << 8;
constexpr uint32_t output = 1 << 8;
constexpr uint32_t bit_mask = 0x1 << 8;
}
constexpr uint32_t pal = 1 << 7;
constexpr uint32_t ntsc = 1 << 6;
constexpr uint32_t force_field2 = 1 << 5;
constexpr uint32_t interlace = 1 << 4;
constexpr uint32_t spg_lock = 1 << 3;
namespace mcsync_pol {
constexpr uint32_t active_low = 0 << 2;
constexpr uint32_t active_high = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace mvsync_pol {
constexpr uint32_t active_low = 0 << 1;
constexpr uint32_t active_high = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace mhsync_pol {
constexpr uint32_t active_low = 0 << 0;
constexpr uint32_t active_high = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
@ -375,17 +373,17 @@ namespace text_control {
namespace code_book_endian {
constexpr uint32_t little_endian = 0 << 17;
constexpr uint32_t big_endian = 1 << 17;
constexpr uint32_t bit_mask = 0x1 << 17;
}
namespace index_endian {
constexpr uint32_t little_endian = 0 << 16;
constexpr uint32_t big_endian = 1 << 16;
constexpr uint32_t bit_mask = 0x1 << 16;
}
constexpr uint32_t bank_bit(uint32_t num) { return (num & 0x1f) << 8; }
constexpr uint32_t stride(uint32_t num) { return (num & 0x1f) << 0; }
}
@ -394,7 +392,7 @@ namespace vo_control {
constexpr uint32_t pclk_delay_reset = 1 << 21;
constexpr uint32_t pclk_delay(uint32_t num) { return (num & 0xf) << 16; }
constexpr uint32_t pixel_double = 1 << 8;
namespace field_mode {
constexpr uint32_t use_field_flag_from_spg = 0x0 << 4;
constexpr uint32_t use_inverse_of_field_flag_from_spg = 0x1 << 4;
@ -405,30 +403,30 @@ namespace vo_control {
constexpr uint32_t field_1_when_hsync_becomes_active_in_the_middle_of_the_vsync_active_edge = 0x6 << 4;
constexpr uint32_t field_2_when_hsync_becomes_active_in_the_middle_of_the_vsync_active_edge = 0x7 << 4;
constexpr uint32_t inverted_at_the_active_edge_of_vsync = 0x8 << 4;
constexpr uint32_t bit_mask = 0xf << 4;
}
constexpr uint32_t blank_video = 1 << 3;
namespace blank_pol {
constexpr uint32_t active_low = 0 << 2;
constexpr uint32_t active_high = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace vsync_pol {
constexpr uint32_t active_low = 0 << 1;
constexpr uint32_t active_high = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace hsync_pol {
constexpr uint32_t active_low = 0 << 0;
constexpr uint32_t active_high = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
@ -446,10 +444,10 @@ namespace scaler_ctl {
namespace field_select {
constexpr uint32_t field_1 = 0 << 18;
constexpr uint32_t field_2 = 1 << 18;
constexpr uint32_t bit_mask = 0x1 << 18;
}
constexpr uint32_t interlace = 1 << 17;
constexpr uint32_t horizontal_scaling_enable = 1 << 16;
constexpr uint32_t vertical_scale_factor(uint32_t num) { return (num & 0xffff) << 0; }
@ -461,7 +459,7 @@ namespace pal_ram_ctrl {
constexpr uint32_t rgb565 = 1 << 0;
constexpr uint32_t argb4444 = 2 << 0;
constexpr uint32_t argb8888 = 3 << 0;
constexpr uint32_t bit_mask = 0x3 << 0;
}
}

View File

@ -1,5 +1,3 @@
#pragma once
#include <cstdint>
#include "../float_uint32.hpp"
@ -37,53 +35,41 @@ 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 {
constexpr uint32_t no_list = 0 << 16;
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 {
constexpr uint32_t no_list = 0 << 12;
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 {
constexpr uint32_t no_list = 0 << 8;
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 {
constexpr uint32_t no_list = 0 << 4;
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 {
constexpr uint32_t no_list = 0 << 0;
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;
}
}
@ -99,17 +85,13 @@ 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; }
constexpr uint32_t yuv_u_size(uint32_t num) { return (num & 0x3f) << 0; }
}

View File

@ -1,13 +1,13 @@
#include <cstdint>
#include "systembus.hpp"
#include "systembus_bits.hpp"
#include "sh7091/sh7091.hpp"
#include "sh7091/sh7091_bits.hpp"
#include "core_bits.hpp"
#include "ta_bits.hpp"
#include "holly.hpp"
#include "../holly.hpp"
#include "../systembus.hpp"
#include "../systembus_bits.hpp"
#include "../sh7091.hpp"
#include "../sh7091_bits.hpp"
#include "texture_memory_alloc.hpp"
#include "ta_fifo_polygon_converter.hpp"
@ -79,25 +79,23 @@ void ta_polygon_converter_transfer(volatile uint32_t * buf, uint32_t size)
volatile uint32_t _dummy = sh7091.DMAC.CHCR2;
(void)_dummy;
using namespace dmac;
/* start a new CH2-DMA transfer from "system memory" to "TA FIFO polygon converter" */
sh7091.DMAC.CHCR2 = 0; /* disable DMA channel */
sh7091.DMAC.SAR2 = reinterpret_cast<uint32_t>(&buf[0]); /* start address, must be aligned to a CHCHR__TS-sized (32-byte) boundary */
sh7091.DMAC.DMATCR2 = dmatcr::transfer_count(size / 32); /* transfer count, in CHCHR__TS-sized (32-byte) units */
sh7091.DMAC.CHCR2 = chcr::dm::destination_address_fixed
| chcr::sm::source_address_incremented
| chcr::rs::resource_select(0b0010) /* external request, single address mode;
external address space external device */
| chcr::tm::cycle_burst_mode /* transmit mode */
| chcr::ts::_32_byte /* transfer size */
| chcr::de::channel_operation_enabled;
sh7091.DMAC.SAR2 = reinterpret_cast<uint32_t>(&buf[0]); /* start address, must be aligned to a CHCHR__TS-sized (32-byte) boundary */
sh7091.DMAC.DMATCR2 = DMATCR2__TRANSFER_COUNT(size / 32); /* transfer count, in CHCHR__TS-sized (32-byte) units */
sh7091.DMAC.CHCR2 = CHCR2__DM__DESTINATION_ADDRESS_FIXED
| CHCR2__SM__SOURCE_ADDRESS_INCREMENTED
| CHCR2__RS(0b0010) /* external request, single address mode;
external address space external device */
| CHCR2__TM__BURST_MODE /* transmit mode */
| CHCR2__TS__32_BYTE /* transfer size */
| CHCR2__DE; /* DMAC (channel) enable */
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 */
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 */
system.C2DSTAT = C2DSTAT__ADDRESS(0x10000000); /* CH2-DMA destination address */
system.C2DLEN = CD2LEN__LENGTH(size); /* CH2-DMA length (must be a multiple of 32) */
system.C2DLEN = CD2LEN__LENGTH(size) ; /* CH2-DMA length (must be a multiple of 32) */
system.C2DST = 1; /* CH2-DMA start (an 'external' request from SH7091's perspective) */
// wait for CH2-DMA completion

View File

@ -3,8 +3,8 @@
#include "align.hpp"
#include "sh7091/sh7091.hpp"
#include "sh7091/sh7091_bits.hpp"
#include "sh7091.hpp"
#include "sh7091_bits.hpp"
#include "systembus.hpp"
#include "systembus_bits.hpp"
@ -97,11 +97,9 @@ void init_block_write(uint32_t * command_buf, uint32_t * receive_buf,
void dma_start(uint32_t * command_buf)
{
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 */
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
// clear maple-DMA end status
system.ISTNRM = ISTNRM__END_OF_DMA_MAPLE_DMA;

View File

@ -43,34 +43,4 @@ 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

@ -1,119 +0,0 @@
#include <functional>
#include "vec.hpp"
namespace geometry {
template <int L, typename T>
vec<L, T> line_plane_intersection(const vec<L, T>& plane_point, // p0
const vec<L, T>& plane_normal, // n
const vec<L, T>& line_start, // l0
const vec<L, T>& line_end
)
{
const auto line_vector = line_end - line_start; // l
const T intersection = // d
dot(plane_point - line_start, plane_normal)
/ dot(line_vector, plane_normal);
return line_start + line_vector * intersection;
}
template <int L, typename T>
T clip_boundary(const vec<L, T>& plane_point, // X
const vec<L, T>& plane_normal, // Nc
const vec<L, T>& line_point
)
{
return dot(plane_normal, line_point - plane_point);
}
template <typename T>
inline T positive_modulo(T a, T b)
{
return (a % b + b) % b;
}
template <int polygon_len, int L, typename T>
inline int clip_polygon1(vec<L, T> * output,
const vec<L, T> plane_point,
const vec<L, T> plane_normal,
const vec<L, T> * polygon,
const int ix_s,
const int ix_f,
const bool last_inside)
{
const vec<L, T>& s = polygon[ix_s];
const vec<L, T>& f = polygon[ix_f];
bool this_inside = 0.f < clip_boundary<L, T>(plane_point,
plane_normal,
f);
int length = 0;
switch ((last_inside << 1) | (this_inside << 0)) {
case 0b00: // no output
length = 0;
break;
case 0b01: // I, F
length = 2;
{
auto i = line_plane_intersection<L, T>(plane_point, plane_normal, s, f);
*output++ = i;
*output++ = f;
}
break;
case 0b10: // I
length = 1;
{
auto i = line_plane_intersection<L, T>(plane_point, plane_normal, s, f);
*output++ = i;
}
break;
case 0b11: // F
length = 1;
*output++ = f;
break;
}
bool end_of_polygon = ix_f == (polygon_len - 1);
if (!end_of_polygon) {
return length +
clip_polygon1<polygon_len, L, T>(output,
plane_point,
plane_normal,
polygon,
ix_f,
ix_f + 1,
this_inside);
} else {
return length;
}
}
template <int polygon_len, int L, typename T>
int clip_polygon(vec<L, T> * output,
const vec<L, T>& plane_point,
const vec<L, T>& plane_normal,
const vec<L, T> * polygon
)
{
const vec<L, T> f = polygon[polygon_len - 1];
// It would be nice to remove the extra dot product, but the
// alternative seems likely uglier.
bool this_inside = 0.f < clip_boundary<L, T>(plane_point,
plane_normal,
f);
return clip_polygon1<polygon_len, L, T>(output,
plane_point,
plane_normal,
polygon,
polygon_len - 1, // ix_s
0, // ix_f
this_inside);
}
}

View File

@ -26,5 +26,3 @@ constexpr float sin(const float n) noexcept
{
return __builtin_sinf(n);
}
constexpr float pi = 3.141592653589793;

View File

@ -107,12 +107,6 @@ 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

@ -112,12 +112,6 @@ inline constexpr vec<3, T> operator*(vec<3, T> const& v1, T const& scalar)
return v1 * vec<3, T>(scalar);
}
template <typename T>
inline constexpr vec<3, T> operator*(T const& scalar, vec<3, T> const& v1)
{
return vec<3, T>(scalar) * v1;
}
template <typename T>
inline constexpr vec<3, T> operator/(vec<3, T> const& v1, vec<3, T> const& v2)
{
@ -139,14 +133,6 @@ inline constexpr T dot(vec<3, T> const& v1, vec<3, T> const& v2)
return tmp.x + tmp.y + tmp.z;
}
template <typename T>
inline constexpr vec<3, T> cross(vec<3, T> const& v1, vec<3, T> const& v2)
{
return vec<3, T>(v1.y * v2.z - v2.y * v1.z,
v1.z * v2.x - v2.z * v1.x,
v1.x * v2.y - v2.x * v1.y);
}
template <typename T>
inline constexpr vec<3, T> functor1(T (&func) (T const& x), vec<3, T> const& v)
{

View File

@ -18,7 +18,6 @@ struct vec<4, T>
inline constexpr vec();
inline constexpr vec(T scalar);
inline constexpr vec(T _x, T _y, T _z, T _w);
inline constexpr vec(const vec<3, T>& v);
constexpr inline vec<4, T> operator-() const;
inline constexpr T const& operator[](int i) const;
@ -42,11 +41,6 @@ inline constexpr vec<4, T>::vec(T _x, T _y, T _z, T _w)
: x(_x), y(_y), z(_z), w(_w)
{}
template <typename T>
inline constexpr vec<4, T>::vec(const vec<3, T>& v)
: x(v.x), y(v.y), z(v.z), w(1.f)
{}
template <typename T>
constexpr inline vec<4, T> vec<4, T>::operator-() const
{
@ -123,12 +117,6 @@ inline constexpr vec<4, T> operator*(vec<4, T> const& v1, T const& scalar)
return v1 * vec<4, T>(scalar);
}
template <typename T>
inline constexpr vec<4, T> operator*(T const& scalar, vec<4, T> const& v1)
{
return vec<4, T>(scalar) * v1;
}
template <typename T>
inline constexpr vec<4, T> operator/(vec<4, T> const& v1, vec<4, T> const& v2)
{

View File

@ -18,19 +18,11 @@ def parse_bit_number(s):
assert '-' not in s
return int(s, 10)
def parse_bit_set(s, split_char):
assert len(list(c for c in s if c == split_char)) == 1
left, right = map(parse_bit_number, s.split(split_char, maxsplit=1))
assert left > right, (left, right)
return left, right
def parse_bit_range(s):
if '-' in s:
left, right = parse_bit_set(s, '-')
left, right = map(parse_bit_number, s.split('-', maxsplit=1))
assert left > right, (left, right)
return set(range(right, left+1))
elif ',' in s:
left, right = parse_bit_set(s, ',')
return set([right, left])
else:
num = parse_bit_number(s)
return set([num])
@ -49,7 +41,7 @@ def aggregate_enums(aggregated_rows):
for row in aggregated_rows:
bits = parse_bit_range(row["bits"])
assert row["bit_name"] != "", row
assert row["bit_name"] != ""
if row["enum_name"] == "":
assert_unique_ordered(bits)
non_enum.append(row)
@ -58,7 +50,7 @@ def aggregate_enums(aggregated_rows):
assert_unique_ordered(bits)
non_enum.append(row["enum_name"])
else:
assert enum_bits[row["enum_name"]] == bits, row
assert enum_bits[row["enum_name"]] == bits
enum_bits[row["enum_name"]] = bits
enum_aggregated[row["enum_name"]].append(row)
@ -72,7 +64,6 @@ class enum:
@dataclass
class register:
block: Union[None, str]
name: str
defs: list[Union[dict, enum]]
@ -88,17 +79,9 @@ def aggregate_all_enums(aggregated):
return row_or_string
else:
assert False, (row_or_string, type(row_or_string))
defs = [resolve(aggregate) for aggregate in non_enum]
if 'block' in rows[0]:
blocks = set(row['block'] for row in rows)
assert len(blocks) == 1, blocks
block_name = next(iter(blocks))
out.append(
register(block_name, register_name, defs))
else:
out.append(
register(None, register_name, defs))
out.append(
register(register_name,
[resolve(aggregate) for aggregate in non_enum]))
return out
'''
@ -124,26 +107,19 @@ def aggregate_all_enums(aggregated):
'''
def mask_from_bits(bits):
h, l = max(bits), min(bits)
mask = 2 ** ((h - l) + 1) - 1
mask = 2 ** len(bits) - 1
return mask
def parse_value(value):
return eval(value)
def escape(bit_name):
if bit_name[0] in {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}:
return '_' + bit_name
else:
return bit_name
def render_read_only(bit_def):
assert bit_def["value"] == ""
assert bit_def["mask"] == ""
bits = parse_bit_range(bit_def["bits"])
mask_value = mask_from_bits(bits)
yield (
f"constexpr uint32_t {escape(bit_def['bit_name'])}(uint32_t reg) {{ "
f"constexpr uint32_t {bit_def['bit_name']}(uint32_t reg) {{ "
f"return (reg >> {min(bits)}) & {hex(mask_value)};"
" }"
)
@ -169,7 +145,7 @@ def render_mask(bit_def):
bits = parse_bit_range(bit_def["bits"])
if mask.startswith("float_"):
yield (
f"inline uint32_t {escape(bit_def['bit_name'])}(float num) {{ "
f"constexpr uint32_t {bit_def['bit_name']}(float num) {{ "
f"return {render_float_mask(mask)};"
" }"
)
@ -179,7 +155,7 @@ def render_mask(bit_def):
assert mask_value & mask_from_bits(bits) == mask_value, (mask_value, mask_from_bits(bits))
yield (
f"constexpr uint32_t {escape(bit_def['bit_name'])}(uint32_t num) {{ "
f"constexpr uint32_t {bit_def['bit_name']}(uint32_t num) {{ "
f"return (num & {hex(mask_value)}) << {min(bits)};"
" }"
)
@ -187,9 +163,9 @@ def render_mask(bit_def):
def render_value(bit_def):
assert bit_def["mask"] == ""
bits = parse_bit_range(bit_def["bits"])
assert parse_value(bit_def["value"]) <= mask_from_bits(bits), (bit_def["value"], mask_from_bits(bits), bits)
assert parse_value(bit_def["value"]) <= mask_from_bits(bits), bit_def["value"]
bit_ix = min(bits)
yield f"constexpr uint32_t {escape(bit_def['bit_name'])} = {bit_def['value']} << {bit_ix};"
yield f"constexpr uint32_t {bit_def['bit_name']} = {bit_def['value']} << {bit_ix};"
def render_defs(bit_def):
if bit_def["value"] != "":
@ -236,23 +212,9 @@ def render_register(register):
yield ""
def render_registers(registers):
last_block = None
for register in registers:
if register.block != last_block:
assert register.block is not None
if last_block is not None:
yield '}' # end of previous namespace
yield ""
yield f'namespace {register.block.lower()} {{'
if register.block is None:
assert last_block is None
last_block = register.block
yield from render_register(register)
if last_block is not None:
yield '}' # end of block namespace
def header():
yield "#pragma once"
yield ""

View File

@ -45,12 +45,13 @@ def new_writer():
def terminate():
nonlocal last_block
nonlocal first_address
nonlocal stack
if last_block is not None:
yield "};"
for address, name in stack:
yield f"static_assert((offsetof (struct {last_block.lower()}_reg, {name})) == {hex(address - first_address)});"
yield f"static_assert((offsetof (struct {last_block.lower()}_reg, {name})) == {hex(address)});"
yield ""
stack = []
@ -67,16 +68,15 @@ def new_writer():
_address = int(row["address"], 16)
assert _offset <= 0xff
assert _address <= 0xffff
offset_address = (_offset << 16)
address = offset_address | (_address << 0)
address = (_offset << 16) | (_address << 0)
size = int(row["size"], 10)
name = row["name"]
description = row["description"]
if block != last_block:
yield from terminate()
first_address = offset_address
last_address = offset_address
first_address = 0 # hmm...
last_address = 0
size_total = 0
reserved_num = 0
yield f"struct {block.lower()}_reg {{"

Binary file not shown.

View File

@ -1,293 +0,0 @@
"block","register_name","enum_name","bits","bit_name","value","mask","description"
"CCN","PTEH",,"31-10","VPN",,,"Virtual Page Number"
"CCN","PTEH",,"7-0","ASID",,,"Address space identifier"
,,,,,,,
"CCN","PTEL",,"28-10","PPN",,,"Physical page number"
"CCN","PTEL","V","8","invalid","0",,"Validity"
"CCN","PTEL","V","8","valid","1",,"Validity"
"CCN","PTEL","SZ","7,4","1_kbyte_page","0b0000",,"Page size"
"CCN","PTEL","SZ","7,4","4_kbyte_page","0b0001",,"Page size"
"CCN","PTEL","SZ","7,4","64_kbyte_page","0b1000",,"Page size"
"CCN","PTEL","SZ","7,4","1_mbyte_page","0b1001",,"Page size"
"CCN","PTEL","PR","6-5","read_only_in_privileged_mode","0b00",,"Protection key data"
"CCN","PTEL","PR","6-5","read_write_in_privileged_mode","0b01",,"Protection key data"
"CCN","PTEL","PR","6-5","read_only_in_privileged_and_user_mode","0b10",,"Protection key data"
"CCN","PTEL","PR","6-5","read_write_in_privileged_and_user_mode","0b11",,"Protection key data"
"CCN","PTEL","C","3","not_cacheable","0",,"Cacheability bit"
"CCN","PTEL","C","3","cacheable","1",,"Cacheability bit"
"CCN","PTEL","D","2","write_has_not_been_performed","0",,"Dirty bit"
"CCN","PTEL","D","2","write_has_been_performed","1",,"Dirty bit"
"CCN","PTEL","SH","1","pages_are_shared_by_processes","0",,"Share status bit"
"CCN","PTEL","SH","1","pages_are_not_shared_by_processes","1",,"Share status bit"
"CCN","PTEL","WT","0","copy_back_mode","0",,"Write-through bit"
"CCN","PTEL","WT","0","write_through_mode","1",,"Write-through bit"
,,,,,,,
"CCN","MMUCR",,"31-26","LRUI",,,"Least recently used ITLB"
"CCN","MMUCR",,"23-18","URB",,,"UTLB replace boundary"
"CCN","MMUCR",,"15-10","URC",,,"UTLB replace counter"
"CCN","MMUCR","SQMD","9","user_privileged_access_possible","0",,"Store queue mode bit"
"CCN","MMUCR","SQMD","9","privileged_access_possible","1",,"Store queue mode bit"
"CCN","MMUCR","SV","8","multiple_virtual_memory_mode","0",,"Single virtual mode bit"
"CCN","MMUCR","SV","8","single_virtual_memory_mode","1",,"Single virtual mode bit"
"CCN","MMUCR","TI","2","invalidate_all_utlb_itlb_bits","1",,"TLB invalidate"
"CCN","MMUCR","AT","0","mmu_disabled","0",,"Address translation bit"
"CCN","MMUCR","AT","0","mmu_enabled","1",,"Address translation bit"
,,,,,,,
"CCN","BASRA",,"7-0","basa",,"0xff",
,,,,,,,
"CCN","BASRB",,"7-0","basa",,"0xff",
,,,,,,,
"CCN","CCR","IIX","15","address_bits_12_5_used_for_ic_entry_selection","0",,"IC index enable"
"CCN","CCR","IIX","15","address_bits_25_and_11_5_used_for_ic_entry_selection","1",,"IC index enable"
"CCN","CCR","ICI","11","clear_v_bits_of_all_ic_entries","1",,"IC invalidation"
"CCN","CCR","ICE","8","ic_not_used","0",,"IC enable"
"CCN","CCR","ICE","8","ic_used","1",,"IC enable"
"CCN","CCR","OIX","7","address_bits_13_5_used_for_oc_entry_selection","0",,"OC index enable"
"CCN","CCR","OIX","7","address_bits_25_and_12_5_used_for_oc_entry_selection","1",,"OC index enable"
"CCN","CCR","ORA","5","16_kbytes_used_as_cache","0",,"OC RAM enable"
"CCN","CCR","ORA","5","8_kbytes_used_as_cache_8_kbytes_used_as_ram","1",,"OC RAM enable"
"CCN","CCR","OCI","3","clear_v_and_u_bits_of_all_oc_entries","1",,"OC invalidation"
"CCN","CCR","CB","2","write_through_mode","0",,"Copy-back enable"
"CCN","CCR","CB","2","copy_back_mode","1",,"Copy-back enable"
"CCN","CCR","WT","1","copy_back_mode","0",,"Write-through enable"
"CCN","CCR","WT","1","write_through_mode","1",,"Write-through enable"
"CCN","CCR","OCE","0","oc_not_used","0",,"OC enable"
"CCN","CCR","OCE","0","oc_used","1",,"OC enable"
,,,,,,,
"CCN","TRA",,"9-2","imm",,,
,,,,,,,
"CCN","EXPEVT",,"11-0","exception_code",,,
,,,,,,,
"CCN","INTEVT",,"11-0","exception_code",,,
,,,,,,,
"CCN","PTEA","TC","3","area_5_is_used","0",,"Timing control bit"
"CCN","PTEA","TC","3","area_6_is_used","1",,"Timing control bit"
"CCN","PTEA","SA","2-0","undefined","0b000",,"Space attribute bits"
"CCN","PTEA","SA","2-0","variable_size_io_space","0b001",,"Space attribute bits"
"CCN","PTEA","SA","2-0","8_bit_io_space","0b010",,"Space attribute bits"
"CCN","PTEA","SA","2-0","16_bit_io_space","0b011",,"Space attribute bits"
"CCN","PTEA","SA","2-0","8_bit_common_memory_space","0b100",,"Space attribute bits"
"CCN","PTEA","SA","2-0","16_bit_common_memory_space","0b101",,"Space attribute bits"
"CCN","PTEA","SA","2-0","8_bit_attribute_memory_space","0b110",,"Space attribute bits"
"CCN","PTEA","SA","2-0","16_bit_attribute_memory_space","0b111",,"Space attribute bits"
,,,,,,,
"CCN","QACR0",,"4-2","area",,"0b111",
,,,,,,,
"CCN","QACR1",,"4-2","area",,"0b111",
,,,,,,,
"DMAC","DMATCR",,"23-0","transfer_count",,"0xffffff",
,,,,,,,
"DMAC","CHCR","SSA","31-29","reserved_in_pcmcia_access","0b000",,
"DMAC","CHCR","SSA","31-29","dynamic_bus_sizing_io_space","0b001",,
"DMAC","CHCR","SSA","31-29","8_bit_io_space","0b010",,
"DMAC","CHCR","SSA","31-29","16_bit_io_space","0b011",,
"DMAC","CHCR","SSA","31-29","8_bit_common_memory_space","0b100",,
"DMAC","CHCR","SSA","31-29","16_bit_common_memory_space","0b101",,
"DMAC","CHCR","SSA","31-29","8_bit_attribute_memory_space","0b110",,
"DMAC","CHCR","SSA","31-29","16_bit_attribute_memory_space","0b111",,
"DMAC","CHCR","STC","28","c5_space_wait_cycle_selection","0",,
"DMAC","CHCR","STC","28","c6_space_wait_cycle_selection","1",,
"DMAC","CHCR","DSA","27-25","reserved_in_pcmcia_access","0b000",,
"DMAC","CHCR","DSA","27-25","dynamic_bus_sizing_io_space","0b001",,
"DMAC","CHCR","DSA","27-25","8_bit_io_space","0b010",,
"DMAC","CHCR","DSA","27-25","16_bit_io_space","0b011",,
"DMAC","CHCR","DSA","27-25","8_bit_common_memory_space","0b100",,
"DMAC","CHCR","DSA","27-25","16_bit_common_memory_space","0b101",,
"DMAC","CHCR","DSA","27-25","8_bit_attribute_memory_space","0b110",,
"DMAC","CHCR","DSA","27-25","16_bit_attribute_memory_space","0b111",,
"DMAC","CHCR","DTC","24","c5_space_wait_cycle_selection","0",,
"DMAC","CHCR","DTC","24","c6_space_wait_cycle_selection","1",,
"DMAC","CHCR","DS","19","low_level_detection","0",,
"DMAC","CHCR","DS","19","falling_edge_detection","1",,
"DMAC","CHCR","RL","18","drak_is_an_active_high","0",,
"DMAC","CHCR","RL","18","drak_is_an_active_low","1",,
"DMAC","CHCR","AM","17","dack_is_output_in_read_cycle","0",,
"DMAC","CHCR","AM","17","dack_is_output_in_write_cycle","1",,
"DMAC","CHCR","AL","16","active_high_output","0",,
"DMAC","CHCR","AL","16","active_low_output","1",,
"DMAC","CHCR","DM","15-14","destination_address_fixed","0b00",,
"DMAC","CHCR","DM","15-14","destination_address_incremented","0b01",,
"DMAC","CHCR","DM","15-14","destination_address_decremented","0b10",,
"DMAC","CHCR","SM","13-12","source_address_fixed","0b00",,
"DMAC","CHCR","SM","13-12","source_address_incremented","0b01",,
"DMAC","CHCR","SM","13-12","source_address_decremented","0b10",,
"DMAC","CHCR","RS","11-8","resource_select",,"0b1111",
"DMAC","CHCR","TM","7","cycle_steal_mode","0",,
"DMAC","CHCR","TM","7","cycle_burst_mode","1",,
"DMAC","CHCR","TS","6-4","64_bit","0b000",,
"DMAC","CHCR","TS","6-4","8_bit","0b001",,
"DMAC","CHCR","TS","6-4","16_bit","0b010",,
"DMAC","CHCR","TS","6-4","32_bit","0b011",,
"DMAC","CHCR","TS","6-4","32_byte","0b100",,
"DMAC","CHCR","IE","2","interrupt_request_not_generated","0",,
"DMAC","CHCR","IE","2","interrupt_request_generated","1",,
"DMAC","CHCR","TE","1","transfers_not_completed","0",,
"DMAC","CHCR","TE","1","transfers_completed","1",,
"DMAC","CHCR","DE","0","channel_operation_disabled","0",,
"DMAC","CHCR","DE","0","channel_operation_enabled","1",,
,,,,,,,
"DMAC","DMAOR","DDT","15","normal_dma_mode","0",,
"DMAC","DMAOR","DDT","15","on_demand_data_transfer_mode","1",,
"DMAC","DMAOR","PR","9-8","ch0_ch1_ch2_ch3","0b00",,
"DMAC","DMAOR","PR","9-8","ch0_ch2_ch3_ch1","0b01",,
"DMAC","DMAOR","PR","9-8","ch2_ch0_ch1_ch3","0b10",,
"DMAC","DMAOR","PR","9-8","round_robin","0b11",,
"DMAC","DMAOR","AE","2","no_address_error__dma_transfer_enabled","0",,
"DMAC","DMAOR","AE","2","address_error__dma_transfer_disabled","1",,
"DMAC","DMAOR","NMIF","1","no_nmi__dma_transfer_enabled","0",,
"DMAC","DMAOR","NMIF","1","nmi__dma_transfer_disabled","1",,
"DMAC","DMAOR","DME","0","operation_disabled_on_all_channels","0",,
"DMAC","DMAOR","DME","0","operation_enabled_on_all_channels","1",,
,,,,,,,
"INTC","ICR","NMIL","15","pin_input_level_is_low","0",,
"INTC","ICR","NMIL","15","pin_input_level_is_high","1",,
"INTC","ICR","MAI","14","interrupts_enabled_while_nmi_pin_is_low","0",,
"INTC","ICR","MAI","14","interrupts_disabled_while_nmi_pin_is_low","1",,
"INTC","ICR","NMIB","9","interrupt_requests_witheld","0",,
"INTC","ICR","NMIB","9","interrupt_requests_detected","1",,
"INTC","ICR","NMIE","8","interrupt_on_falling_edge_of_nmi","0",,
"INTC","ICR","NMIE","8","interrupt_on_rising_edge_of_nmi","1",,
"INTC","ICR","IRLM","7","level_encoded_interrupt_requests","0",,
"INTC","ICR","IRLM","7","independent_interrupt_request","1",,
,,,,,,,
"INTC","IPRA",,"15-12","TMU0",,"0b1111",
"INTC","IPRA",,"11-8","TMU1",,"0b1111",
"INTC","IPRA",,"7-4","TMU2",,"0b1111",
"INTC","IPRA",,"3-0","RTC",,"0b1111",
,,,,,,,
"INTC","IPRB",,"15-12","WDT",,"0b1111",
"INTC","IPRB",,"11-8","REF",,"0b1111",
"INTC","IPRB",,"7-4","SCI1",,"0b1111",
,,,,,,,
"INTC","IPRC",,"15-12","GPIO",,"0b1111",
"INTC","IPRC",,"11-8","DMAC",,"0b1111",
"INTC","IPRC",,"7-4","SCIF",,"0b1111",
"INTC","IPRC",,"3-0","UDI",,"0b1111",
,,,,,,,
"TMU","TOCR","TCOE","0","tclk_is_external_clock_or_input_capture","0",,"Timer Clock Pin Control"
"TMU","TOCR","TCOE","0","tclk_is_on_chip_rtc","1",,"Timer Clock Pin Control"
,,,,,,,
"TMU","TSTR","STR2","2","counter_start","1",,"Counter Start 2"
"TMU","TSTR","STR1","1","counter_start","1",,"Counter Start 1"
"TMU","TSTR","STR0","0","counter_start","1",,"Counter Start 0"
,,,,,,,
"TMU","TCR0",,"8","UNF","1",,"Underflow Flag"
"TMU","TCR0",,"5","UNIE","1",,"Underflow Interrupt Control"
"TMU","TCR0","CKEG","4-3","rising","0b00",,"Clock Edge"
"TMU","TCR0","CKEG","4-3","falling","0b01",,"Clock Edge"
"TMU","TCR0","CKEG","4-3","rising_falling","0b10",,"Clock Edge"
"TMU","TCR0","TPSC","2-0","p_phi_4","0b000",,"Timer Prescaler"
"TMU","TCR0","TPSC","2-0","p_phi_16","0b001",,"Timer Prescaler"
"TMU","TCR0","TPSC","2-0","p_phi_64","0b010",,"Timer Prescaler"
"TMU","TCR0","TPSC","2-0","p_phi_256","0b011",,"Timer Prescaler"
"TMU","TCR0","TPSC","2-0","p_phi_1024","0b100",,"Timer Prescaler"
"TMU","TCR0","TPSC","2-0","rtc_output","0b110",,"Timer Prescaler"
"TMU","TCR0","TPSC","2-0","external","0b111",,"Timer Prescaler"
,,,,,,,
"TMU","TCR1",,"8","UNF","1",,"Underflow Flag"
"TMU","TCR1",,"5","UNIE","1",,"Underflow Interrupt Control"
"TMU","TCR1","CKEG","4-3","rising","0b00",,"Clock Edge"
"TMU","TCR1","CKEG","4-3","falling","0b01",,"Clock Edge"
"TMU","TCR1","CKEG","4-3","rising_falling","0b10",,"Clock Edge"
"TMU","TCR1","TPSC","2-0","p_phi_4","0b000",,"Timer Prescaler"
"TMU","TCR1","TPSC","2-0","p_phi_16","0b001",,"Timer Prescaler"
"TMU","TCR1","TPSC","2-0","p_phi_64","0b010",,"Timer Prescaler"
"TMU","TCR1","TPSC","2-0","p_phi_256","0b011",,"Timer Prescaler"
"TMU","TCR1","TPSC","2-0","p_phi_1024","0b100",,"Timer Prescaler"
"TMU","TCR1","TPSC","2-0","rtc_output","0b110",,"Timer Prescaler"
"TMU","TCR1","TPSC","2-0","external","0b111",,"Timer Prescaler"
,,,,,,,
"TMU","TCR2",,"9","ICPF","1",,"Input Capture Interrupt Flag"
"TMU","TCR2",,"8","UNF","1",,"Underflow Flag"
"TMU","TCR2","ICPE","7-6","disabled","0b00",,"Input Capture Control"
"TMU","TCR2","ICPE","7-6","enabled","0b10",,"Input Capture Control"
"TMU","TCR2","ICPE","7-6","enabled_with_interrupts","0b11",,"Input Capture Control"
"TMU","TCR2",,"5","UNIE","1",,"Underflow Interrupt Control"
"TMU","TCR2","CKEG","4-3","rising","0b00",,"Clock Edge"
"TMU","TCR2","CKEG","4-3","falling","0b01",,"Clock Edge"
"TMU","TCR2","CKEG","4-3","rising_falling","0b10",,"Clock Edge"
"TMU","TCR2","TPSC","2-0","p_phi_4","0b000",,"Timer Prescaler"
"TMU","TCR2","TPSC","2-0","p_phi_16","0b001",,"Timer Prescaler"
"TMU","TCR2","TPSC","2-0","p_phi_64","0b010",,"Timer Prescaler"
"TMU","TCR2","TPSC","2-0","p_phi_256","0b011",,"Timer Prescaler"
"TMU","TCR2","TPSC","2-0","p_phi_1024","0b100",,"Timer Prescaler"
"TMU","TCR2","TPSC","2-0","rtc_output","0b110",,"Timer Prescaler"
"TMU","TCR2","TPSC","2-0","external","0b111",,"Timer Prescaler"
,,,,,,,
"SCIF","SCSMR2","CHR","6","8_bit_data","0",,
"SCIF","SCSMR2","CHR","6","7_bit_data","1",,
"SCIF","SCSMR2","PE","5","parity_disabled","0",,
"SCIF","SCSMR2","PE","5","parity_enabled","1",,
"SCIF","SCSMR2","OE","4","even_parity","0",,
"SCIF","SCSMR2","OE","4","odd_parity","1",,
"SCIF","SCSMR2","STOP","3","1_stop_bit","0",,
"SCIF","SCSMR2","STOP","3","2_stop_bits","1",,
"SCIF","SCSMR2","CKS","1-0","p_phi_clock","0b00",,
"SCIF","SCSMR2","CKS","1-0","p_phi_4_clock","0b01",,
"SCIF","SCSMR2","CKS","1-0","p_phi_16_clock","0b10",,
"SCIF","SCSMR2","CKS","1-0","p_phi_64_clock","0b11",,
,,,,,,,
"SCIF","SCSCR2","TIE","7","transmit_fifo_data_empty_interrupt_disabled","0",,
"SCIF","SCSCR2","TIE","7","transmit_fifo_data_empty_interrupt_enabled","1",,
"SCIF","SCSCR2","RIE","6","request_disabled","0",,
"SCIF","SCSCR2","RIE","6","request_enabled","1",,
"SCIF","SCSCR2","TE","5","transmission_disabled","0",,
"SCIF","SCSCR2","TE","5","transmission_enabled","1",,
"SCIF","SCSCR2","RE","4","reception_disabled","0",,
"SCIF","SCSCR2","RE","4","reception_enabled","1",,
"SCIF","SCSCR2","REIE","3","requests_disabled","0",,
"SCIF","SCSCR2","REIE","3","requests_enabled","1",,
"SCIF","SCSCR2","CKE1","1","sck2_pin_functions_as_input_pin","0",,
"SCIF","SCSCR2","CKE1","1","sck2_pin_functions_as_clock_input","1",,
,,,,,,,
"SCIF","SCFSR2","PER3_0","15-12","number_of_parity_errors",,,
"SCIF","SCFSR2","FER3_0","11-8","number_of_framing_errors",,,
"SCIF","SCFSR2","ER","7","no_framing_error_or_parity_error","0",,
"SCIF","SCFSR2","ER","7","framing_error_or_parity_error","1",,
"SCIF","SCFSR2","TEND","6","transmission_in_progress","0",,
"SCIF","SCFSR2","TEND","6","transmission_has_ended","1",,
"SCIF","SCFSR2","TDFE","5","transmit_data_bytes_does_exceed_trigger","0",,
"SCIF","SCFSR2","TDFE","5","transmit_data_bytes_does_not_exceed_trigger","1",,
"SCIF","SCFSR2","BRK","4","break_not_received","0",,
"SCIF","SCFSR2","BRK","4","break_received","1",,
"SCIF","SCFSR2","FER","3","no_framing_error","0",,
"SCIF","SCFSR2","FER","3","framing_error","1",,
"SCIF","SCFSR2","PER","2","parity_error","0",,
"SCIF","SCFSR2","PER","2","no_parity_error","1",,
"SCIF","SCFSR2","RDF","1","receive_data_bytes_less_than_receive_trigger","0",,
"SCIF","SCFSR2","RDF","1","receive_data_bytes_greater_than_or_equal_receive_trigger","1",,
"SCIF","SCFSR2","DR","0","reception_is_in_progress","0",,
"SCIF","SCFSR2","DR","0","no_further_data_has_arrived","1",,
,,,,,,,
"SCIF","SCFCR2","RTRG","7-6","trigger_on_1_byte","0b00",,
"SCIF","SCFCR2","RTRG","7-6","trigger_on_4_bytes","0b01",,
"SCIF","SCFCR2","RTRG","7-6","trigger_on_8_bytes","0b10",,
"SCIF","SCFCR2","RTRG","7-6","trigger_on_14_byte","0b11",,
"SCIF","SCFCR2","TTRG","5-4","trigger_on_8_bytes","0b00",,
"SCIF","SCFCR2","TTRG","5-4","trigger_on_4_bytes","0b01",,
"SCIF","SCFCR2","TTRG","5-4","trigger_on_2_bytes","0b10",,
"SCIF","SCFCR2","TTRG","5-4","trigger_on_1_bytes","0b11",,
"SCIF","SCFCR2","MCE","3","modem_signals_disabled","0",,
"SCIF","SCFCR2","MCE","3","modem_signals_enabled","1",,
"SCIF","SCFCR2","TFRST","2","reset_operation_disabled","0",,
"SCIF","SCFCR2","TFRST","2","reset_operation_enabled","1",,
"SCIF","SCFCR2","RFRST","1","reset_operation_disabled","0",,
"SCIF","SCFCR2","RFRST","1","reset_operation_enabled","1",,
"SCIF","SCFCR2","LOOP","0","loopback_test_disabled","0",,
"SCIF","SCFCR2","LOOP","0","loopback_test_enabled","1",,
,,,,,,,
"SCIF","SCFDR2",,"12-8","transmit_data_bytes",,,
"SCIF","SCFDR2",,"4-0","receive_data_bytes",,,
,,,,,,,
"SCIF","SCSPTR2","RTSIO","7","rtsdt_not_output_to_rts2","0",,
"SCIF","SCSPTR2","RTSIO","7","rtsdt_output_to_rts2","1",,
"SCIF","SCSPTR2","RTSDT","6","input_output_data_is_low_level","0",,
"SCIF","SCSPTR2","RTSDT","6","input_output_data_is_high_level","1",,
"SCIF","SCSPTR2","CTSIO","5","ctsdt_is_not_output_to_cts2","0",,
"SCIF","SCSPTR2","CTSIO","5","ctsdt_is_output_to_cts2","1",,
"SCIF","SCSPTR2","CTSDT","4","input_output_data_is_low_level","0",,
"SCIF","SCSPTR2","CTSDT","4","input_output_data_is_high_level","1",,
"SCIF","SCSPTR2","SPB2IO","1","spb2dt_is_not_output_to_txd2","0",,
"SCIF","SCSPTR2","SPB2IO","1","spb2dt_is_output_to_txd2","1",,
"SCIF","SCSPTR2","SPB2DT","0","input_output_data_is_low_level","0",,
"SCIF","SCSPTR2","SPB2DT","0","input_output_data_is_high_level","1",,
1 block register_name enum_name bits bit_name value mask description
2 CCN PTEH 31-10 VPN Virtual Page Number
3 CCN PTEH 7-0 ASID Address space identifier
4
5 CCN PTEL 28-10 PPN Physical page number
6 CCN PTEL V 8 invalid 0 Validity
7 CCN PTEL V 8 valid 1 Validity
8 CCN PTEL SZ 7,4 1_kbyte_page 0b0000 Page size
9 CCN PTEL SZ 7,4 4_kbyte_page 0b0001 Page size
10 CCN PTEL SZ 7,4 64_kbyte_page 0b1000 Page size
11 CCN PTEL SZ 7,4 1_mbyte_page 0b1001 Page size
12 CCN PTEL PR 6-5 read_only_in_privileged_mode 0b00 Protection key data
13 CCN PTEL PR 6-5 read_write_in_privileged_mode 0b01 Protection key data
14 CCN PTEL PR 6-5 read_only_in_privileged_and_user_mode 0b10 Protection key data
15 CCN PTEL PR 6-5 read_write_in_privileged_and_user_mode 0b11 Protection key data
16 CCN PTEL C 3 not_cacheable 0 Cacheability bit
17 CCN PTEL C 3 cacheable 1 Cacheability bit
18 CCN PTEL D 2 write_has_not_been_performed 0 Dirty bit
19 CCN PTEL D 2 write_has_been_performed 1 Dirty bit
20 CCN PTEL SH 1 pages_are_shared_by_processes 0 Share status bit
21 CCN PTEL SH 1 pages_are_not_shared_by_processes 1 Share status bit
22 CCN PTEL WT 0 copy_back_mode 0 Write-through bit
23 CCN PTEL WT 0 write_through_mode 1 Write-through bit
24
25 CCN MMUCR 31-26 LRUI Least recently used ITLB
26 CCN MMUCR 23-18 URB UTLB replace boundary
27 CCN MMUCR 15-10 URC UTLB replace counter
28 CCN MMUCR SQMD 9 user_privileged_access_possible 0 Store queue mode bit
29 CCN MMUCR SQMD 9 privileged_access_possible 1 Store queue mode bit
30 CCN MMUCR SV 8 multiple_virtual_memory_mode 0 Single virtual mode bit
31 CCN MMUCR SV 8 single_virtual_memory_mode 1 Single virtual mode bit
32 CCN MMUCR TI 2 invalidate_all_utlb_itlb_bits 1 TLB invalidate
33 CCN MMUCR AT 0 mmu_disabled 0 Address translation bit
34 CCN MMUCR AT 0 mmu_enabled 1 Address translation bit
35
36 CCN BASRA 7-0 basa 0xff
37
38 CCN BASRB 7-0 basa 0xff
39
40 CCN CCR IIX 15 address_bits_12_5_used_for_ic_entry_selection 0 IC index enable
41 CCN CCR IIX 15 address_bits_25_and_11_5_used_for_ic_entry_selection 1 IC index enable
42 CCN CCR ICI 11 clear_v_bits_of_all_ic_entries 1 IC invalidation
43 CCN CCR ICE 8 ic_not_used 0 IC enable
44 CCN CCR ICE 8 ic_used 1 IC enable
45 CCN CCR OIX 7 address_bits_13_5_used_for_oc_entry_selection 0 OC index enable
46 CCN CCR OIX 7 address_bits_25_and_12_5_used_for_oc_entry_selection 1 OC index enable
47 CCN CCR ORA 5 16_kbytes_used_as_cache 0 OC RAM enable
48 CCN CCR ORA 5 8_kbytes_used_as_cache_8_kbytes_used_as_ram 1 OC RAM enable
49 CCN CCR OCI 3 clear_v_and_u_bits_of_all_oc_entries 1 OC invalidation
50 CCN CCR CB 2 write_through_mode 0 Copy-back enable
51 CCN CCR CB 2 copy_back_mode 1 Copy-back enable
52 CCN CCR WT 1 copy_back_mode 0 Write-through enable
53 CCN CCR WT 1 write_through_mode 1 Write-through enable
54 CCN CCR OCE 0 oc_not_used 0 OC enable
55 CCN CCR OCE 0 oc_used 1 OC enable
56
57 CCN TRA 9-2 imm
58
59 CCN EXPEVT 11-0 exception_code
60
61 CCN INTEVT 11-0 exception_code
62
63 CCN PTEA TC 3 area_5_is_used 0 Timing control bit
64 CCN PTEA TC 3 area_6_is_used 1 Timing control bit
65 CCN PTEA SA 2-0 undefined 0b000 Space attribute bits
66 CCN PTEA SA 2-0 variable_size_io_space 0b001 Space attribute bits
67 CCN PTEA SA 2-0 8_bit_io_space 0b010 Space attribute bits
68 CCN PTEA SA 2-0 16_bit_io_space 0b011 Space attribute bits
69 CCN PTEA SA 2-0 8_bit_common_memory_space 0b100 Space attribute bits
70 CCN PTEA SA 2-0 16_bit_common_memory_space 0b101 Space attribute bits
71 CCN PTEA SA 2-0 8_bit_attribute_memory_space 0b110 Space attribute bits
72 CCN PTEA SA 2-0 16_bit_attribute_memory_space 0b111 Space attribute bits
73
74 CCN QACR0 4-2 area 0b111
75
76 CCN QACR1 4-2 area 0b111
77
78 DMAC DMATCR 23-0 transfer_count 0xffffff
79
80 DMAC CHCR SSA 31-29 reserved_in_pcmcia_access 0b000
81 DMAC CHCR SSA 31-29 dynamic_bus_sizing_io_space 0b001
82 DMAC CHCR SSA 31-29 8_bit_io_space 0b010
83 DMAC CHCR SSA 31-29 16_bit_io_space 0b011
84 DMAC CHCR SSA 31-29 8_bit_common_memory_space 0b100
85 DMAC CHCR SSA 31-29 16_bit_common_memory_space 0b101
86 DMAC CHCR SSA 31-29 8_bit_attribute_memory_space 0b110
87 DMAC CHCR SSA 31-29 16_bit_attribute_memory_space 0b111
88 DMAC CHCR STC 28 c5_space_wait_cycle_selection 0
89 DMAC CHCR STC 28 c6_space_wait_cycle_selection 1
90 DMAC CHCR DSA 27-25 reserved_in_pcmcia_access 0b000
91 DMAC CHCR DSA 27-25 dynamic_bus_sizing_io_space 0b001
92 DMAC CHCR DSA 27-25 8_bit_io_space 0b010
93 DMAC CHCR DSA 27-25 16_bit_io_space 0b011
94 DMAC CHCR DSA 27-25 8_bit_common_memory_space 0b100
95 DMAC CHCR DSA 27-25 16_bit_common_memory_space 0b101
96 DMAC CHCR DSA 27-25 8_bit_attribute_memory_space 0b110
97 DMAC CHCR DSA 27-25 16_bit_attribute_memory_space 0b111
98 DMAC CHCR DTC 24 c5_space_wait_cycle_selection 0
99 DMAC CHCR DTC 24 c6_space_wait_cycle_selection 1
100 DMAC CHCR DS 19 low_level_detection 0
101 DMAC CHCR DS 19 falling_edge_detection 1
102 DMAC CHCR RL 18 drak_is_an_active_high 0
103 DMAC CHCR RL 18 drak_is_an_active_low 1
104 DMAC CHCR AM 17 dack_is_output_in_read_cycle 0
105 DMAC CHCR AM 17 dack_is_output_in_write_cycle 1
106 DMAC CHCR AL 16 active_high_output 0
107 DMAC CHCR AL 16 active_low_output 1
108 DMAC CHCR DM 15-14 destination_address_fixed 0b00
109 DMAC CHCR DM 15-14 destination_address_incremented 0b01
110 DMAC CHCR DM 15-14 destination_address_decremented 0b10
111 DMAC CHCR SM 13-12 source_address_fixed 0b00
112 DMAC CHCR SM 13-12 source_address_incremented 0b01
113 DMAC CHCR SM 13-12 source_address_decremented 0b10
114 DMAC CHCR RS 11-8 resource_select 0b1111
115 DMAC CHCR TM 7 cycle_steal_mode 0
116 DMAC CHCR TM 7 cycle_burst_mode 1
117 DMAC CHCR TS 6-4 64_bit 0b000
118 DMAC CHCR TS 6-4 8_bit 0b001
119 DMAC CHCR TS 6-4 16_bit 0b010
120 DMAC CHCR TS 6-4 32_bit 0b011
121 DMAC CHCR TS 6-4 32_byte 0b100
122 DMAC CHCR IE 2 interrupt_request_not_generated 0
123 DMAC CHCR IE 2 interrupt_request_generated 1
124 DMAC CHCR TE 1 transfers_not_completed 0
125 DMAC CHCR TE 1 transfers_completed 1
126 DMAC CHCR DE 0 channel_operation_disabled 0
127 DMAC CHCR DE 0 channel_operation_enabled 1
128
129 DMAC DMAOR DDT 15 normal_dma_mode 0
130 DMAC DMAOR DDT 15 on_demand_data_transfer_mode 1
131 DMAC DMAOR PR 9-8 ch0_ch1_ch2_ch3 0b00
132 DMAC DMAOR PR 9-8 ch0_ch2_ch3_ch1 0b01
133 DMAC DMAOR PR 9-8 ch2_ch0_ch1_ch3 0b10
134 DMAC DMAOR PR 9-8 round_robin 0b11
135 DMAC DMAOR AE 2 no_address_error__dma_transfer_enabled 0
136 DMAC DMAOR AE 2 address_error__dma_transfer_disabled 1
137 DMAC DMAOR NMIF 1 no_nmi__dma_transfer_enabled 0
138 DMAC DMAOR NMIF 1 nmi__dma_transfer_disabled 1
139 DMAC DMAOR DME 0 operation_disabled_on_all_channels 0
140 DMAC DMAOR DME 0 operation_enabled_on_all_channels 1
141
142 INTC ICR NMIL 15 pin_input_level_is_low 0
143 INTC ICR NMIL 15 pin_input_level_is_high 1
144 INTC ICR MAI 14 interrupts_enabled_while_nmi_pin_is_low 0
145 INTC ICR MAI 14 interrupts_disabled_while_nmi_pin_is_low 1
146 INTC ICR NMIB 9 interrupt_requests_witheld 0
147 INTC ICR NMIB 9 interrupt_requests_detected 1
148 INTC ICR NMIE 8 interrupt_on_falling_edge_of_nmi 0
149 INTC ICR NMIE 8 interrupt_on_rising_edge_of_nmi 1
150 INTC ICR IRLM 7 level_encoded_interrupt_requests 0
151 INTC ICR IRLM 7 independent_interrupt_request 1
152
153 INTC IPRA 15-12 TMU0 0b1111
154 INTC IPRA 11-8 TMU1 0b1111
155 INTC IPRA 7-4 TMU2 0b1111
156 INTC IPRA 3-0 RTC 0b1111
157
158 INTC IPRB 15-12 WDT 0b1111
159 INTC IPRB 11-8 REF 0b1111
160 INTC IPRB 7-4 SCI1 0b1111
161
162 INTC IPRC 15-12 GPIO 0b1111
163 INTC IPRC 11-8 DMAC 0b1111
164 INTC IPRC 7-4 SCIF 0b1111
165 INTC IPRC 3-0 UDI 0b1111
166
167 TMU TOCR TCOE 0 tclk_is_external_clock_or_input_capture 0 Timer Clock Pin Control
168 TMU TOCR TCOE 0 tclk_is_on_chip_rtc 1 Timer Clock Pin Control
169
170 TMU TSTR STR2 2 counter_start 1 Counter Start 2
171 TMU TSTR STR1 1 counter_start 1 Counter Start 1
172 TMU TSTR STR0 0 counter_start 1 Counter Start 0
173
174 TMU TCR0 8 UNF 1 Underflow Flag
175 TMU TCR0 5 UNIE 1 Underflow Interrupt Control
176 TMU TCR0 CKEG 4-3 rising 0b00 Clock Edge
177 TMU TCR0 CKEG 4-3 falling 0b01 Clock Edge
178 TMU TCR0 CKEG 4-3 rising_falling 0b10 Clock Edge
179 TMU TCR0 TPSC 2-0 p_phi_4 0b000 Timer Prescaler
180 TMU TCR0 TPSC 2-0 p_phi_16 0b001 Timer Prescaler
181 TMU TCR0 TPSC 2-0 p_phi_64 0b010 Timer Prescaler
182 TMU TCR0 TPSC 2-0 p_phi_256 0b011 Timer Prescaler
183 TMU TCR0 TPSC 2-0 p_phi_1024 0b100 Timer Prescaler
184 TMU TCR0 TPSC 2-0 rtc_output 0b110 Timer Prescaler
185 TMU TCR0 TPSC 2-0 external 0b111 Timer Prescaler
186
187 TMU TCR1 8 UNF 1 Underflow Flag
188 TMU TCR1 5 UNIE 1 Underflow Interrupt Control
189 TMU TCR1 CKEG 4-3 rising 0b00 Clock Edge
190 TMU TCR1 CKEG 4-3 falling 0b01 Clock Edge
191 TMU TCR1 CKEG 4-3 rising_falling 0b10 Clock Edge
192 TMU TCR1 TPSC 2-0 p_phi_4 0b000 Timer Prescaler
193 TMU TCR1 TPSC 2-0 p_phi_16 0b001 Timer Prescaler
194 TMU TCR1 TPSC 2-0 p_phi_64 0b010 Timer Prescaler
195 TMU TCR1 TPSC 2-0 p_phi_256 0b011 Timer Prescaler
196 TMU TCR1 TPSC 2-0 p_phi_1024 0b100 Timer Prescaler
197 TMU TCR1 TPSC 2-0 rtc_output 0b110 Timer Prescaler
198 TMU TCR1 TPSC 2-0 external 0b111 Timer Prescaler
199
200 TMU TCR2 9 ICPF 1 Input Capture Interrupt Flag
201 TMU TCR2 8 UNF 1 Underflow Flag
202 TMU TCR2 ICPE 7-6 disabled 0b00 Input Capture Control
203 TMU TCR2 ICPE 7-6 enabled 0b10 Input Capture Control
204 TMU TCR2 ICPE 7-6 enabled_with_interrupts 0b11 Input Capture Control
205 TMU TCR2 5 UNIE 1 Underflow Interrupt Control
206 TMU TCR2 CKEG 4-3 rising 0b00 Clock Edge
207 TMU TCR2 CKEG 4-3 falling 0b01 Clock Edge
208 TMU TCR2 CKEG 4-3 rising_falling 0b10 Clock Edge
209 TMU TCR2 TPSC 2-0 p_phi_4 0b000 Timer Prescaler
210 TMU TCR2 TPSC 2-0 p_phi_16 0b001 Timer Prescaler
211 TMU TCR2 TPSC 2-0 p_phi_64 0b010 Timer Prescaler
212 TMU TCR2 TPSC 2-0 p_phi_256 0b011 Timer Prescaler
213 TMU TCR2 TPSC 2-0 p_phi_1024 0b100 Timer Prescaler
214 TMU TCR2 TPSC 2-0 rtc_output 0b110 Timer Prescaler
215 TMU TCR2 TPSC 2-0 external 0b111 Timer Prescaler
216
217 SCIF SCSMR2 CHR 6 8_bit_data 0
218 SCIF SCSMR2 CHR 6 7_bit_data 1
219 SCIF SCSMR2 PE 5 parity_disabled 0
220 SCIF SCSMR2 PE 5 parity_enabled 1
221 SCIF SCSMR2 OE 4 even_parity 0
222 SCIF SCSMR2 OE 4 odd_parity 1
223 SCIF SCSMR2 STOP 3 1_stop_bit 0
224 SCIF SCSMR2 STOP 3 2_stop_bits 1
225 SCIF SCSMR2 CKS 1-0 p_phi_clock 0b00
226 SCIF SCSMR2 CKS 1-0 p_phi_4_clock 0b01
227 SCIF SCSMR2 CKS 1-0 p_phi_16_clock 0b10
228 SCIF SCSMR2 CKS 1-0 p_phi_64_clock 0b11
229
230 SCIF SCSCR2 TIE 7 transmit_fifo_data_empty_interrupt_disabled 0
231 SCIF SCSCR2 TIE 7 transmit_fifo_data_empty_interrupt_enabled 1
232 SCIF SCSCR2 RIE 6 request_disabled 0
233 SCIF SCSCR2 RIE 6 request_enabled 1
234 SCIF SCSCR2 TE 5 transmission_disabled 0
235 SCIF SCSCR2 TE 5 transmission_enabled 1
236 SCIF SCSCR2 RE 4 reception_disabled 0
237 SCIF SCSCR2 RE 4 reception_enabled 1
238 SCIF SCSCR2 REIE 3 requests_disabled 0
239 SCIF SCSCR2 REIE 3 requests_enabled 1
240 SCIF SCSCR2 CKE1 1 sck2_pin_functions_as_input_pin 0
241 SCIF SCSCR2 CKE1 1 sck2_pin_functions_as_clock_input 1
242
243 SCIF SCFSR2 PER3_0 15-12 number_of_parity_errors
244 SCIF SCFSR2 FER3_0 11-8 number_of_framing_errors
245 SCIF SCFSR2 ER 7 no_framing_error_or_parity_error 0
246 SCIF SCFSR2 ER 7 framing_error_or_parity_error 1
247 SCIF SCFSR2 TEND 6 transmission_in_progress 0
248 SCIF SCFSR2 TEND 6 transmission_has_ended 1
249 SCIF SCFSR2 TDFE 5 transmit_data_bytes_does_exceed_trigger 0
250 SCIF SCFSR2 TDFE 5 transmit_data_bytes_does_not_exceed_trigger 1
251 SCIF SCFSR2 BRK 4 break_not_received 0
252 SCIF SCFSR2 BRK 4 break_received 1
253 SCIF SCFSR2 FER 3 no_framing_error 0
254 SCIF SCFSR2 FER 3 framing_error 1
255 SCIF SCFSR2 PER 2 parity_error 0
256 SCIF SCFSR2 PER 2 no_parity_error 1
257 SCIF SCFSR2 RDF 1 receive_data_bytes_less_than_receive_trigger 0
258 SCIF SCFSR2 RDF 1 receive_data_bytes_greater_than_or_equal_receive_trigger 1
259 SCIF SCFSR2 DR 0 reception_is_in_progress 0
260 SCIF SCFSR2 DR 0 no_further_data_has_arrived 1
261
262 SCIF SCFCR2 RTRG 7-6 trigger_on_1_byte 0b00
263 SCIF SCFCR2 RTRG 7-6 trigger_on_4_bytes 0b01
264 SCIF SCFCR2 RTRG 7-6 trigger_on_8_bytes 0b10
265 SCIF SCFCR2 RTRG 7-6 trigger_on_14_byte 0b11
266 SCIF SCFCR2 TTRG 5-4 trigger_on_8_bytes 0b00
267 SCIF SCFCR2 TTRG 5-4 trigger_on_4_bytes 0b01
268 SCIF SCFCR2 TTRG 5-4 trigger_on_2_bytes 0b10
269 SCIF SCFCR2 TTRG 5-4 trigger_on_1_bytes 0b11
270 SCIF SCFCR2 MCE 3 modem_signals_disabled 0
271 SCIF SCFCR2 MCE 3 modem_signals_enabled 1
272 SCIF SCFCR2 TFRST 2 reset_operation_disabled 0
273 SCIF SCFCR2 TFRST 2 reset_operation_enabled 1
274 SCIF SCFCR2 RFRST 1 reset_operation_disabled 0
275 SCIF SCFCR2 RFRST 1 reset_operation_enabled 1
276 SCIF SCFCR2 LOOP 0 loopback_test_disabled 0
277 SCIF SCFCR2 LOOP 0 loopback_test_enabled 1
278
279 SCIF SCFDR2 12-8 transmit_data_bytes
280 SCIF SCFDR2 4-0 receive_data_bytes
281
282 SCIF SCSPTR2 RTSIO 7 rtsdt_not_output_to_rts2 0
283 SCIF SCSPTR2 RTSIO 7 rtsdt_output_to_rts2 1
284 SCIF SCSPTR2 RTSDT 6 input_output_data_is_low_level 0
285 SCIF SCSPTR2 RTSDT 6 input_output_data_is_high_level 1
286 SCIF SCSPTR2 CTSIO 5 ctsdt_is_not_output_to_cts2 0
287 SCIF SCSPTR2 CTSIO 5 ctsdt_is_output_to_cts2 1
288 SCIF SCSPTR2 CTSDT 4 input_output_data_is_low_level 0
289 SCIF SCSPTR2 CTSDT 4 input_output_data_is_high_level 1
290 SCIF SCSPTR2 SPB2IO 1 spb2dt_is_not_output_to_txd2 0
291 SCIF SCSPTR2 SPB2IO 1 spb2dt_is_output_to_txd2 1
292 SCIF SCSPTR2 SPB2DT 0 input_output_data_is_low_level 0
293 SCIF SCSPTR2 SPB2DT 0 input_output_data_is_high_level 1

Binary file not shown.

View File

@ -1,6 +1,6 @@
#include <cstdint>
#include "sh7091/cache.hpp"
#include "cache.hpp"
extern uint32_t __bss_link_start __asm("__bss_link_start");
extern uint32_t __bss_link_end __asm("__bss_link_end");

View File

@ -9,29 +9,24 @@ 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::reset_operation_enabled
| scfcr2::rfrst::reset_operation_enabled;
sh7091.SCIF.SCFCR2 = SCFCR2__TFRST | SCFCR2__RFRST;
// tx/rx trigger on 1 byte
sh7091.SCIF.SCFCR2 = 0;
sh7091.SCIF.SCSPTR2 = 0;
sh7091.SCIF.SCLSR2 = 0;
sh7091.SCIF.SCSCR2 = scscr2::te::transmission_enabled
| scscr2::re::reception_enabled;
sh7091.SCIF.SCSCR2 = SCSCR2__TE | SCSCR2__RE;
}
void character(const char c)
{
using namespace scif;
// wait for transmit fifo to become empty
while ((sh7091.SCIF.SCFSR2 & scfsr2::tdfe::bit_mask) == 0);
while ((sh7091.SCIF.SCFSR2 & SCFSR2__TDFE) == 0);
for (int i = 0; i < 100000; i++) {
asm volatile ("nop;");
@ -48,7 +43,7 @@ void string(const char * s)
}
template <typename T>
void integer(const T n, const char end)
void integer(const T n)
{
constexpr uint32_t length = (sizeof (T)) * 2;
char num_buf[length + 1];
@ -56,21 +51,11 @@ void integer(const T n, const char end)
num_buf[length] = 0;
string("0x");
string(num_buf);
character(end);
}
template <typename T>
void integer(const T n)
{
return integer(n, '\n');
string("\n");
}
template void integer<uint32_t>(uint32_t param);
template void integer<uint16_t>(uint16_t param);
template void integer<uint8_t>(uint8_t param);
template void integer<uint32_t>(uint32_t param, char end);
template void integer<uint16_t>(uint16_t param, char end);
template void integer<uint8_t>(uint8_t param, char end);
}

View File

@ -6,9 +6,6 @@ void character(const char c);
void string(const char * s);
template <typename T>
void integer(const T n, const char end);
template <typename T>
void integer(const T n);

View File

@ -1,8 +1,8 @@
#include <cstdint>
#include "sh7091/sh7091.hpp"
#include "sh7091/sh7091_bits.hpp"
#include "holly/holly.hpp"
#include "sh7091.hpp"
#include "sh7091_bits.hpp"
#include "holly.hpp"
enum load_command {
CMD_NONE,
@ -48,8 +48,7 @@ void debug(const char * s)
{
char c;
while ((c = *s++)) {
using namespace scif;
while ((sh7091.SCIF.SCFSR2 & scfsr2::tdfe::bit_mask) == 0);
while ((sh7091.SCIF.SCFSR2 & SCFSR2__TDFE) == 0);
sh7091.SCIF.SCFTDR2 = (uint8_t)c;
}
}

View File

@ -90,9 +90,9 @@ struct bsc_reg {
reg8 _pad7[2];
reg16 GPIOIC; /* GPIO interrupt control register */
reg8 _pad8[1048502];
reg32 SDMR2[16384]; /* Synchronous DRAM mode registers */
reg8 SDMR2[65536]; /* Synchronous DRAM mode registers */
reg8 _pad9[196608];
reg32 SDMR3[16384]; /* Synchronous DRAM mode registers */
reg8 SDMR3[65536]; /* Synchronous DRAM mode registers */
};
static_assert((offsetof (struct bsc_reg, BCR1)) == 0x0);

View File

@ -1,36 +0,0 @@
#include "type.hpp"
#include "sh7091.hpp"
#include "sh7091_bits.hpp"
#include "cache.hpp"
extern volatile reg32 sh7091_ic_a[256][(1 << 5) / 4] __asm("sh7091_ic_a");
extern volatile reg32 sh7091_oc_a[512][(1 << 5) / 4] __asm("sh7091_oc_a");
namespace cache {
void init()
{
for (int i = 0; i < 256; i++) {
sh7091_ic_a[i][0] = 0;
}
for (int i = 0; i < 512; i++) {
sh7091_oc_a[i][0] = 0;
}
using namespace ccn::ccr;
sh7091.CCN.CCR = ici::clear_v_bits_of_all_ic_entries // instruction cache invalidate
| ice::ic_used // instruction cache enable
| oci::clear_v_and_u_bits_of_all_oc_entries // operand cache invalidate
| oce::oc_used // operand cache enable
// | cb::copy_back_mode // enable copy-back mode for the P1 area
;
sh7091.CCN.MMUCR = ccn::mmucr::at::mmu_disabled;
asm volatile ("nop;nop;nop;nop;nop;nop;nop;nop;");
}
}

View File

@ -1,822 +0,0 @@
#pragma once
#include <cstdint>
#include "../float_uint32.hpp"
namespace ccn {
namespace pteh {
constexpr uint32_t VPN(uint32_t reg) { return (reg >> 10) & 0x3fffff; }
constexpr uint32_t ASID(uint32_t reg) { return (reg >> 0) & 0xff; }
}
namespace ptel {
constexpr uint32_t PPN(uint32_t reg) { return (reg >> 10) & 0x7ffff; }
namespace v {
constexpr uint32_t invalid = 0 << 8;
constexpr uint32_t valid = 1 << 8;
constexpr uint32_t bit_mask = 0x1 << 8;
}
namespace sz {
constexpr uint32_t _1_kbyte_page = 0b0000 << 4;
constexpr uint32_t _4_kbyte_page = 0b0001 << 4;
constexpr uint32_t _64_kbyte_page = 0b1000 << 4;
constexpr uint32_t _1_mbyte_page = 0b1001 << 4;
constexpr uint32_t bit_mask = 0xf << 4;
}
namespace pr {
constexpr uint32_t read_only_in_privileged_mode = 0b00 << 5;
constexpr uint32_t read_write_in_privileged_mode = 0b01 << 5;
constexpr uint32_t read_only_in_privileged_and_user_mode = 0b10 << 5;
constexpr uint32_t read_write_in_privileged_and_user_mode = 0b11 << 5;
constexpr uint32_t bit_mask = 0x3 << 5;
}
namespace c {
constexpr uint32_t not_cacheable = 0 << 3;
constexpr uint32_t cacheable = 1 << 3;
constexpr uint32_t bit_mask = 0x1 << 3;
}
namespace d {
constexpr uint32_t write_has_not_been_performed = 0 << 2;
constexpr uint32_t write_has_been_performed = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace sh {
constexpr uint32_t pages_are_shared_by_processes = 0 << 1;
constexpr uint32_t pages_are_not_shared_by_processes = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace wt {
constexpr uint32_t copy_back_mode = 0 << 0;
constexpr uint32_t write_through_mode = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
namespace mmucr {
constexpr uint32_t LRUI(uint32_t reg) { return (reg >> 26) & 0x3f; }
constexpr uint32_t URB(uint32_t reg) { return (reg >> 18) & 0x3f; }
constexpr uint32_t URC(uint32_t reg) { return (reg >> 10) & 0x3f; }
namespace sqmd {
constexpr uint32_t user_privileged_access_possible = 0 << 9;
constexpr uint32_t privileged_access_possible = 1 << 9;
constexpr uint32_t bit_mask = 0x1 << 9;
}
namespace sv {
constexpr uint32_t multiple_virtual_memory_mode = 0 << 8;
constexpr uint32_t single_virtual_memory_mode = 1 << 8;
constexpr uint32_t bit_mask = 0x1 << 8;
}
namespace ti {
constexpr uint32_t invalidate_all_utlb_itlb_bits = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace at {
constexpr uint32_t mmu_disabled = 0 << 0;
constexpr uint32_t mmu_enabled = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
namespace basra {
constexpr uint32_t basa(uint32_t num) { return (num & 0xff) << 0; }
}
namespace basrb {
constexpr uint32_t basa(uint32_t num) { return (num & 0xff) << 0; }
}
namespace ccr {
namespace iix {
constexpr uint32_t address_bits_12_5_used_for_ic_entry_selection = 0 << 15;
constexpr uint32_t address_bits_25_and_11_5_used_for_ic_entry_selection = 1 << 15;
constexpr uint32_t bit_mask = 0x1 << 15;
}
namespace ici {
constexpr uint32_t clear_v_bits_of_all_ic_entries = 1 << 11;
constexpr uint32_t bit_mask = 0x1 << 11;
}
namespace ice {
constexpr uint32_t ic_not_used = 0 << 8;
constexpr uint32_t ic_used = 1 << 8;
constexpr uint32_t bit_mask = 0x1 << 8;
}
namespace oix {
constexpr uint32_t address_bits_13_5_used_for_oc_entry_selection = 0 << 7;
constexpr uint32_t address_bits_25_and_12_5_used_for_oc_entry_selection = 1 << 7;
constexpr uint32_t bit_mask = 0x1 << 7;
}
namespace ora {
constexpr uint32_t _16_kbytes_used_as_cache = 0 << 5;
constexpr uint32_t _8_kbytes_used_as_cache_8_kbytes_used_as_ram = 1 << 5;
constexpr uint32_t bit_mask = 0x1 << 5;
}
namespace oci {
constexpr uint32_t clear_v_and_u_bits_of_all_oc_entries = 1 << 3;
constexpr uint32_t bit_mask = 0x1 << 3;
}
namespace cb {
constexpr uint32_t write_through_mode = 0 << 2;
constexpr uint32_t copy_back_mode = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace wt {
constexpr uint32_t copy_back_mode = 0 << 1;
constexpr uint32_t write_through_mode = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace oce {
constexpr uint32_t oc_not_used = 0 << 0;
constexpr uint32_t oc_used = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
namespace tra {
constexpr uint32_t imm(uint32_t reg) { return (reg >> 2) & 0xff; }
}
namespace expevt {
constexpr uint32_t exception_code(uint32_t reg) { return (reg >> 0) & 0xfff; }
}
namespace intevt {
constexpr uint32_t exception_code(uint32_t reg) { return (reg >> 0) & 0xfff; }
}
namespace ptea {
namespace tc {
constexpr uint32_t area_5_is_used = 0 << 3;
constexpr uint32_t area_6_is_used = 1 << 3;
constexpr uint32_t bit_mask = 0x1 << 3;
}
namespace sa {
constexpr uint32_t undefined = 0b000 << 0;
constexpr uint32_t variable_size_io_space = 0b001 << 0;
constexpr uint32_t _8_bit_io_space = 0b010 << 0;
constexpr uint32_t _16_bit_io_space = 0b011 << 0;
constexpr uint32_t _8_bit_common_memory_space = 0b100 << 0;
constexpr uint32_t _16_bit_common_memory_space = 0b101 << 0;
constexpr uint32_t _8_bit_attribute_memory_space = 0b110 << 0;
constexpr uint32_t _16_bit_attribute_memory_space = 0b111 << 0;
constexpr uint32_t bit_mask = 0x7 << 0;
}
}
namespace qacr0 {
constexpr uint32_t area(uint32_t num) { return (num & 0x7) << 2; }
}
namespace qacr1 {
constexpr uint32_t area(uint32_t num) { return (num & 0x7) << 2; }
}
}
namespace dmac {
namespace dmatcr {
constexpr uint32_t transfer_count(uint32_t num) { return (num & 0xffffff) << 0; }
}
namespace chcr {
namespace ssa {
constexpr uint32_t reserved_in_pcmcia_access = 0b000 << 29;
constexpr uint32_t dynamic_bus_sizing_io_space = 0b001 << 29;
constexpr uint32_t _8_bit_io_space = 0b010 << 29;
constexpr uint32_t _16_bit_io_space = 0b011 << 29;
constexpr uint32_t _8_bit_common_memory_space = 0b100 << 29;
constexpr uint32_t _16_bit_common_memory_space = 0b101 << 29;
constexpr uint32_t _8_bit_attribute_memory_space = 0b110 << 29;
constexpr uint32_t _16_bit_attribute_memory_space = 0b111 << 29;
constexpr uint32_t bit_mask = 0x7 << 29;
}
namespace stc {
constexpr uint32_t c5_space_wait_cycle_selection = 0 << 28;
constexpr uint32_t c6_space_wait_cycle_selection = 1 << 28;
constexpr uint32_t bit_mask = 0x1 << 28;
}
namespace dsa {
constexpr uint32_t reserved_in_pcmcia_access = 0b000 << 25;
constexpr uint32_t dynamic_bus_sizing_io_space = 0b001 << 25;
constexpr uint32_t _8_bit_io_space = 0b010 << 25;
constexpr uint32_t _16_bit_io_space = 0b011 << 25;
constexpr uint32_t _8_bit_common_memory_space = 0b100 << 25;
constexpr uint32_t _16_bit_common_memory_space = 0b101 << 25;
constexpr uint32_t _8_bit_attribute_memory_space = 0b110 << 25;
constexpr uint32_t _16_bit_attribute_memory_space = 0b111 << 25;
constexpr uint32_t bit_mask = 0x7 << 25;
}
namespace dtc {
constexpr uint32_t c5_space_wait_cycle_selection = 0 << 24;
constexpr uint32_t c6_space_wait_cycle_selection = 1 << 24;
constexpr uint32_t bit_mask = 0x1 << 24;
}
namespace ds {
constexpr uint32_t low_level_detection = 0 << 19;
constexpr uint32_t falling_edge_detection = 1 << 19;
constexpr uint32_t bit_mask = 0x1 << 19;
}
namespace rl {
constexpr uint32_t drak_is_an_active_high = 0 << 18;
constexpr uint32_t drak_is_an_active_low = 1 << 18;
constexpr uint32_t bit_mask = 0x1 << 18;
}
namespace am {
constexpr uint32_t dack_is_output_in_read_cycle = 0 << 17;
constexpr uint32_t dack_is_output_in_write_cycle = 1 << 17;
constexpr uint32_t bit_mask = 0x1 << 17;
}
namespace al {
constexpr uint32_t active_high_output = 0 << 16;
constexpr uint32_t active_low_output = 1 << 16;
constexpr uint32_t bit_mask = 0x1 << 16;
}
namespace dm {
constexpr uint32_t destination_address_fixed = 0b00 << 14;
constexpr uint32_t destination_address_incremented = 0b01 << 14;
constexpr uint32_t destination_address_decremented = 0b10 << 14;
constexpr uint32_t bit_mask = 0x3 << 14;
}
namespace sm {
constexpr uint32_t source_address_fixed = 0b00 << 12;
constexpr uint32_t source_address_incremented = 0b01 << 12;
constexpr uint32_t source_address_decremented = 0b10 << 12;
constexpr uint32_t bit_mask = 0x3 << 12;
}
namespace rs {
constexpr uint32_t resource_select(uint32_t num) { return (num & 0xf) << 8; }
constexpr uint32_t bit_mask = 0xf << 8;
}
namespace tm {
constexpr uint32_t cycle_steal_mode = 0 << 7;
constexpr uint32_t cycle_burst_mode = 1 << 7;
constexpr uint32_t bit_mask = 0x1 << 7;
}
namespace ts {
constexpr uint32_t _64_bit = 0b000 << 4;
constexpr uint32_t _8_bit = 0b001 << 4;
constexpr uint32_t _16_bit = 0b010 << 4;
constexpr uint32_t _32_bit = 0b011 << 4;
constexpr uint32_t _32_byte = 0b100 << 4;
constexpr uint32_t bit_mask = 0x7 << 4;
}
namespace ie {
constexpr uint32_t interrupt_request_not_generated = 0 << 2;
constexpr uint32_t interrupt_request_generated = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace te {
constexpr uint32_t transfers_not_completed = 0 << 1;
constexpr uint32_t transfers_completed = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace de {
constexpr uint32_t channel_operation_disabled = 0 << 0;
constexpr uint32_t channel_operation_enabled = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
namespace dmaor {
namespace ddt {
constexpr uint32_t normal_dma_mode = 0 << 15;
constexpr uint32_t on_demand_data_transfer_mode = 1 << 15;
constexpr uint32_t bit_mask = 0x1 << 15;
}
namespace pr {
constexpr uint32_t ch0_ch1_ch2_ch3 = 0b00 << 8;
constexpr uint32_t ch0_ch2_ch3_ch1 = 0b01 << 8;
constexpr uint32_t ch2_ch0_ch1_ch3 = 0b10 << 8;
constexpr uint32_t round_robin = 0b11 << 8;
constexpr uint32_t bit_mask = 0x3 << 8;
}
namespace ae {
constexpr uint32_t no_address_error__dma_transfer_enabled = 0 << 2;
constexpr uint32_t address_error__dma_transfer_disabled = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace nmif {
constexpr uint32_t no_nmi__dma_transfer_enabled = 0 << 1;
constexpr uint32_t nmi__dma_transfer_disabled = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace dme {
constexpr uint32_t operation_disabled_on_all_channels = 0 << 0;
constexpr uint32_t operation_enabled_on_all_channels = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
}
namespace intc {
namespace icr {
namespace nmil {
constexpr uint32_t pin_input_level_is_low = 0 << 15;
constexpr uint32_t pin_input_level_is_high = 1 << 15;
constexpr uint32_t bit_mask = 0x1 << 15;
}
namespace mai {
constexpr uint32_t interrupts_enabled_while_nmi_pin_is_low = 0 << 14;
constexpr uint32_t interrupts_disabled_while_nmi_pin_is_low = 1 << 14;
constexpr uint32_t bit_mask = 0x1 << 14;
}
namespace nmib {
constexpr uint32_t interrupt_requests_witheld = 0 << 9;
constexpr uint32_t interrupt_requests_detected = 1 << 9;
constexpr uint32_t bit_mask = 0x1 << 9;
}
namespace nmie {
constexpr uint32_t interrupt_on_falling_edge_of_nmi = 0 << 8;
constexpr uint32_t interrupt_on_rising_edge_of_nmi = 1 << 8;
constexpr uint32_t bit_mask = 0x1 << 8;
}
namespace irlm {
constexpr uint32_t level_encoded_interrupt_requests = 0 << 7;
constexpr uint32_t independent_interrupt_request = 1 << 7;
constexpr uint32_t bit_mask = 0x1 << 7;
}
}
namespace ipra {
constexpr uint32_t TMU0(uint32_t num) { return (num & 0xf) << 12; }
constexpr uint32_t TMU1(uint32_t num) { return (num & 0xf) << 8; }
constexpr uint32_t TMU2(uint32_t num) { return (num & 0xf) << 4; }
constexpr uint32_t RTC(uint32_t num) { return (num & 0xf) << 0; }
}
namespace iprb {
constexpr uint32_t WDT(uint32_t num) { return (num & 0xf) << 12; }
constexpr uint32_t REF(uint32_t num) { return (num & 0xf) << 8; }
constexpr uint32_t SCI1(uint32_t num) { return (num & 0xf) << 4; }
}
namespace iprc {
constexpr uint32_t GPIO(uint32_t num) { return (num & 0xf) << 12; }
constexpr uint32_t DMAC(uint32_t num) { return (num & 0xf) << 8; }
constexpr uint32_t SCIF(uint32_t num) { return (num & 0xf) << 4; }
constexpr uint32_t UDI(uint32_t num) { return (num & 0xf) << 0; }
}
}
namespace tmu {
namespace tocr {
namespace tcoe {
constexpr uint32_t tclk_is_external_clock_or_input_capture = 0 << 0;
constexpr uint32_t tclk_is_on_chip_rtc = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
namespace tstr {
namespace str2 {
constexpr uint32_t counter_start = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace str1 {
constexpr uint32_t counter_start = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace str0 {
constexpr uint32_t counter_start = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
namespace tcr0 {
constexpr uint32_t UNF = 1 << 8;
constexpr uint32_t UNIE = 1 << 5;
namespace ckeg {
constexpr uint32_t rising = 0b00 << 3;
constexpr uint32_t falling = 0b01 << 3;
constexpr uint32_t rising_falling = 0b10 << 3;
constexpr uint32_t bit_mask = 0x3 << 3;
}
namespace tpsc {
constexpr uint32_t p_phi_4 = 0b000 << 0;
constexpr uint32_t p_phi_16 = 0b001 << 0;
constexpr uint32_t p_phi_64 = 0b010 << 0;
constexpr uint32_t p_phi_256 = 0b011 << 0;
constexpr uint32_t p_phi_1024 = 0b100 << 0;
constexpr uint32_t rtc_output = 0b110 << 0;
constexpr uint32_t external = 0b111 << 0;
constexpr uint32_t bit_mask = 0x7 << 0;
}
}
namespace tcr1 {
constexpr uint32_t UNF = 1 << 8;
constexpr uint32_t UNIE = 1 << 5;
namespace ckeg {
constexpr uint32_t rising = 0b00 << 3;
constexpr uint32_t falling = 0b01 << 3;
constexpr uint32_t rising_falling = 0b10 << 3;
constexpr uint32_t bit_mask = 0x3 << 3;
}
namespace tpsc {
constexpr uint32_t p_phi_4 = 0b000 << 0;
constexpr uint32_t p_phi_16 = 0b001 << 0;
constexpr uint32_t p_phi_64 = 0b010 << 0;
constexpr uint32_t p_phi_256 = 0b011 << 0;
constexpr uint32_t p_phi_1024 = 0b100 << 0;
constexpr uint32_t rtc_output = 0b110 << 0;
constexpr uint32_t external = 0b111 << 0;
constexpr uint32_t bit_mask = 0x7 << 0;
}
}
namespace tcr2 {
constexpr uint32_t ICPF = 1 << 9;
constexpr uint32_t UNF = 1 << 8;
namespace icpe {
constexpr uint32_t disabled = 0b00 << 6;
constexpr uint32_t enabled = 0b10 << 6;
constexpr uint32_t enabled_with_interrupts = 0b11 << 6;
constexpr uint32_t bit_mask = 0x3 << 6;
}
constexpr uint32_t UNIE = 1 << 5;
namespace ckeg {
constexpr uint32_t rising = 0b00 << 3;
constexpr uint32_t falling = 0b01 << 3;
constexpr uint32_t rising_falling = 0b10 << 3;
constexpr uint32_t bit_mask = 0x3 << 3;
}
namespace tpsc {
constexpr uint32_t p_phi_4 = 0b000 << 0;
constexpr uint32_t p_phi_16 = 0b001 << 0;
constexpr uint32_t p_phi_64 = 0b010 << 0;
constexpr uint32_t p_phi_256 = 0b011 << 0;
constexpr uint32_t p_phi_1024 = 0b100 << 0;
constexpr uint32_t rtc_output = 0b110 << 0;
constexpr uint32_t external = 0b111 << 0;
constexpr uint32_t bit_mask = 0x7 << 0;
}
}
}
namespace scif {
namespace scsmr2 {
namespace chr {
constexpr uint32_t _8_bit_data = 0 << 6;
constexpr uint32_t _7_bit_data = 1 << 6;
constexpr uint32_t bit_mask = 0x1 << 6;
}
namespace pe {
constexpr uint32_t parity_disabled = 0 << 5;
constexpr uint32_t parity_enabled = 1 << 5;
constexpr uint32_t bit_mask = 0x1 << 5;
}
namespace oe {
constexpr uint32_t even_parity = 0 << 4;
constexpr uint32_t odd_parity = 1 << 4;
constexpr uint32_t bit_mask = 0x1 << 4;
}
namespace stop {
constexpr uint32_t _1_stop_bit = 0 << 3;
constexpr uint32_t _2_stop_bits = 1 << 3;
constexpr uint32_t bit_mask = 0x1 << 3;
}
namespace cks {
constexpr uint32_t p_phi_clock = 0b00 << 0;
constexpr uint32_t p_phi_4_clock = 0b01 << 0;
constexpr uint32_t p_phi_16_clock = 0b10 << 0;
constexpr uint32_t p_phi_64_clock = 0b11 << 0;
constexpr uint32_t bit_mask = 0x3 << 0;
}
}
namespace scscr2 {
namespace tie {
constexpr uint32_t transmit_fifo_data_empty_interrupt_disabled = 0 << 7;
constexpr uint32_t transmit_fifo_data_empty_interrupt_enabled = 1 << 7;
constexpr uint32_t bit_mask = 0x1 << 7;
}
namespace rie {
constexpr uint32_t request_disabled = 0 << 6;
constexpr uint32_t request_enabled = 1 << 6;
constexpr uint32_t bit_mask = 0x1 << 6;
}
namespace te {
constexpr uint32_t transmission_disabled = 0 << 5;
constexpr uint32_t transmission_enabled = 1 << 5;
constexpr uint32_t bit_mask = 0x1 << 5;
}
namespace re {
constexpr uint32_t reception_disabled = 0 << 4;
constexpr uint32_t reception_enabled = 1 << 4;
constexpr uint32_t bit_mask = 0x1 << 4;
}
namespace reie {
constexpr uint32_t requests_disabled = 0 << 3;
constexpr uint32_t requests_enabled = 1 << 3;
constexpr uint32_t bit_mask = 0x1 << 3;
}
namespace cke1 {
constexpr uint32_t sck2_pin_functions_as_input_pin = 0 << 1;
constexpr uint32_t sck2_pin_functions_as_clock_input = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
}
namespace scfsr2 {
namespace per3_0 {
constexpr uint32_t number_of_parity_errors(uint32_t reg) { return (reg >> 12) & 0xf; }
constexpr uint32_t bit_mask = 0xf << 12;
}
namespace fer3_0 {
constexpr uint32_t number_of_framing_errors(uint32_t reg) { return (reg >> 8) & 0xf; }
constexpr uint32_t bit_mask = 0xf << 8;
}
namespace er {
constexpr uint32_t no_framing_error_or_parity_error = 0 << 7;
constexpr uint32_t framing_error_or_parity_error = 1 << 7;
constexpr uint32_t bit_mask = 0x1 << 7;
}
namespace tend {
constexpr uint32_t transmission_in_progress = 0 << 6;
constexpr uint32_t transmission_has_ended = 1 << 6;
constexpr uint32_t bit_mask = 0x1 << 6;
}
namespace tdfe {
constexpr uint32_t transmit_data_bytes_does_exceed_trigger = 0 << 5;
constexpr uint32_t transmit_data_bytes_does_not_exceed_trigger = 1 << 5;
constexpr uint32_t bit_mask = 0x1 << 5;
}
namespace brk {
constexpr uint32_t break_not_received = 0 << 4;
constexpr uint32_t break_received = 1 << 4;
constexpr uint32_t bit_mask = 0x1 << 4;
}
namespace fer {
constexpr uint32_t no_framing_error = 0 << 3;
constexpr uint32_t framing_error = 1 << 3;
constexpr uint32_t bit_mask = 0x1 << 3;
}
namespace per {
constexpr uint32_t parity_error = 0 << 2;
constexpr uint32_t no_parity_error = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace rdf {
constexpr uint32_t receive_data_bytes_less_than_receive_trigger = 0 << 1;
constexpr uint32_t receive_data_bytes_greater_than_or_equal_receive_trigger = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace dr {
constexpr uint32_t reception_is_in_progress = 0 << 0;
constexpr uint32_t no_further_data_has_arrived = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
namespace scfcr2 {
namespace rtrg {
constexpr uint32_t trigger_on_1_byte = 0b00 << 6;
constexpr uint32_t trigger_on_4_bytes = 0b01 << 6;
constexpr uint32_t trigger_on_8_bytes = 0b10 << 6;
constexpr uint32_t trigger_on_14_byte = 0b11 << 6;
constexpr uint32_t bit_mask = 0x3 << 6;
}
namespace ttrg {
constexpr uint32_t trigger_on_8_bytes = 0b00 << 4;
constexpr uint32_t trigger_on_4_bytes = 0b01 << 4;
constexpr uint32_t trigger_on_2_bytes = 0b10 << 4;
constexpr uint32_t trigger_on_1_bytes = 0b11 << 4;
constexpr uint32_t bit_mask = 0x3 << 4;
}
namespace mce {
constexpr uint32_t modem_signals_disabled = 0 << 3;
constexpr uint32_t modem_signals_enabled = 1 << 3;
constexpr uint32_t bit_mask = 0x1 << 3;
}
namespace tfrst {
constexpr uint32_t reset_operation_disabled = 0 << 2;
constexpr uint32_t reset_operation_enabled = 1 << 2;
constexpr uint32_t bit_mask = 0x1 << 2;
}
namespace rfrst {
constexpr uint32_t reset_operation_disabled = 0 << 1;
constexpr uint32_t reset_operation_enabled = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace loop {
constexpr uint32_t loopback_test_disabled = 0 << 0;
constexpr uint32_t loopback_test_enabled = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
namespace scfdr2 {
constexpr uint32_t transmit_data_bytes(uint32_t reg) { return (reg >> 8) & 0x1f; }
constexpr uint32_t receive_data_bytes(uint32_t reg) { return (reg >> 0) & 0x1f; }
}
namespace scsptr2 {
namespace rtsio {
constexpr uint32_t rtsdt_not_output_to_rts2 = 0 << 7;
constexpr uint32_t rtsdt_output_to_rts2 = 1 << 7;
constexpr uint32_t bit_mask = 0x1 << 7;
}
namespace rtsdt {
constexpr uint32_t input_output_data_is_low_level = 0 << 6;
constexpr uint32_t input_output_data_is_high_level = 1 << 6;
constexpr uint32_t bit_mask = 0x1 << 6;
}
namespace ctsio {
constexpr uint32_t ctsdt_is_not_output_to_cts2 = 0 << 5;
constexpr uint32_t ctsdt_is_output_to_cts2 = 1 << 5;
constexpr uint32_t bit_mask = 0x1 << 5;
}
namespace ctsdt {
constexpr uint32_t input_output_data_is_low_level = 0 << 4;
constexpr uint32_t input_output_data_is_high_level = 1 << 4;
constexpr uint32_t bit_mask = 0x1 << 4;
}
namespace spb2io {
constexpr uint32_t spb2dt_is_not_output_to_txd2 = 0 << 1;
constexpr uint32_t spb2dt_is_output_to_txd2 = 1 << 1;
constexpr uint32_t bit_mask = 0x1 << 1;
}
namespace spb2dt {
constexpr uint32_t input_output_data_is_low_level = 0 << 0;
constexpr uint32_t input_output_data_is_high_level = 1 << 0;
constexpr uint32_t bit_mask = 0x1 << 0;
}
}
}

101
sh7091_bits.hpp Normal file
View File

@ -0,0 +1,101 @@
#define CCR__IIX (1 << 15)
#define CCR__ICI (1 << 11)
#define CCR__ICE (1 << 8)
#define CCR__OIX (1 << 7)
#define CCR__ORA (1 << 5)
#define CCR__OCI (1 << 4)
#define CCR__CB (1 << 2)
#define CCR__WT (1 << 1)
#define CCR__OCE (1 << 0)
#define PDTRA__MASK (0b11 << 8)
#define PDTRA__VGA (0b00 << 8)
#define PDTRA__RESERVED (0b01 << 8)
#define PDTRA__RGB (0b10 << 8)
#define PDTRA__AV (0b11 << 8)
#define SCFCR2__TFRST (1 << 2)
#define SCFCR2__RFRST (1 << 1)
#define SCSCR2__TE (1 << 5)
#define SCSCR2__RE (1 << 4)
#define SCFSR2__ER (1 << 7) /* read error */
#define SCFSR2__TEND (1 << 6) /* transmit end */
#define SCFSR2__TDFE (1 << 5) /* transmit fifo data empty */
#define SCFSR2__BRK (1 << 4) /* break detect */
#define SCFSR2__FER (1 << 3) /* framing error */
#define SCFSR2__PER (1 << 2) /* parity error */
#define SCFSR2__RDF (1 << 1) /* receive FIFO data full */
#define SCFSR2__DR (1 << 0) /* receive data ready */
#define DMAOR__DDT (1 << 15) /* on-demand data transfer mode */
/* priority mode */
#define DMAOR__PR__CH0_CH1_CH2_CH3 (0b11 << 8)
#define DMAOR__PR__CH0_CH2_CH3_CH1 (0b01 << 8)
#define DMAOR__PR__CH2_CH0_CH1_CH3 (0b10 << 8)
#define DMAOR__PR__ROUND_ROBIN (0b11 << 8)
#define DMAOR__AE (1 << 2) /* address error flag; clear-only */
#define DMAOR__NMIF (1 << 1) /* non-maskable interrupt flag; clear-only */
#define DMAOR__DME (1 << 0) /* DMAC master enable */
/* source address space attribute specification */
#define CHCR2__SSA__RESERVED_IN_PCMCIA_ACCESS (0b000 << 29)
#define CHCR2__SSA__DYNAMIC_BUS_SIZING_IO_SPACE (0b001 << 29)
#define CHCR2__SSA__8BIT_IO_SPACE (0b010 << 29)
#define CHCR2__SSA__16BIT_IO_SPACE (0b011 << 29)
#define CHCR2__SSA__8BIT_COMMON_MEMORY_SPACE (0b100 << 29)
#define CHCR2__SSA__16BIT_COMMON_MEMORY_SPACE (0b101 << 29)
#define CHCR2__SSA__8BIT_ATTRIBUTE_MEMORY_SPACE (0b110 << 29)
#define CHCR2__SSA__16BIT_ATTRIBUTE_MEMORY_SPACE (0b111 << 29)
/* source address wait control select */
#define CHCR2__STC__C5_SPACE_WAIT_CYCLE_SELECTION (0 << 28)
#define CHCR2__STC__C6_SPACE_WAIT_CYCLE_SELECTION (1 << 28)
/* destination address space attribute specification */
#define CHCR2__DSA__RESERVED_IN_PCMCIA_ACCESS (0b000 << 25)
#define CHCR2__DSA__DYNAMIC_BUS_SIZING_IO_SPACE (0b001 << 25)
#define CHCR2__DSA__8BIT_IO_SPACE (0b010 << 25)
#define CHCR2__DSA__16BIT_IO_SPACE (0b011 << 25)
#define CHCR2__DSA__8BIT_COMMON_MEMORY_SPACE (0b100 << 25)
#define CHCR2__DSA__16BIT_COMMON_MEMORY_SPACE (0b101 << 25)
#define CHCR2__DSA__8BIT_ATTRIBUTE_MEMORY_SPACE (0b110 << 25)
#define CHCR2__DSA__16BIT_ATTRIBUTE_MEMORY_SPACE (0b111 << 25)
/* destination address wait control select */
#define CHCR2__DTC__C5_SPACE_WAIT_CYCLE_SELECTION (0 << 24)
#define CHCR2__DTC__C6_SPACE_WAIT_CYCLE_SELECTION (1 << 24)
/* DREQ select */
#define CHCR2__DS__LOW_LEVEL_DETECTION (0 << 19)
#define CHCR2__DS__FALLING_EDGE_DETECTION (1 << 19)
/* request check level */
#define CHCR2__RL__DRAK_IS_AN_ACTIVE_HIGH_OUTPUT (0 << 18)
#define CHCR2__RL__DRAK_IS_AN_ACTIVE_LOW_OUTPUT (1 << 18)
/* acknowledge mode */
#define CHCR2__AM__DACK_IS_OUTPUT_IN_READ_CYCLE (0 << 17)
#define CHCR2__AM__DACK_IS_OUTPUT_IN_WRITE_CYCLE (1 << 17)
/* acknowledge level */
#define CHCR2__AL__ACTIVE_HIGH_OUTPUT (0 << 16)
#define CHCR2__AL__ACTIVE_LOW_OUTPUT (1 << 16)
/* destination address mode */
#define CHCR2__DM__DESTINATION_ADDRESS_FIXED (0b00 << 14)
#define CHCR2__DM__DESTINATION_ADDRESS_INCREMENTED (0b01 << 14)
#define CHCR2__DM__DESTINATION_ADDRESS_DECREMENTED (0b10 << 14)
/* source address mode */
#define CHCR2__SM__SOURCE_ADDRESS_FIXED (0b00 << 12)
#define CHCR2__SM__SOURCE_ADDRESS_INCREMENTED (0b01 << 12)
#define CHCR2__SM__SOURCE_ADDRESS_DECREMENTED (0b10 << 12)
/* resource select */
#define CHCR2__RS(n) (((n) & 0b1111) << 8)
/* transmit mode */
#define CHCR2__TM__CYCLE_STEAL_MODE (0 << 7)
#define CHCR2__TM__BURST_MODE (1 << 7)
/* transmit size */
#define CHCR2__TS__64_BIT (0b000 << 4)
#define CHCR2__TS__8_BIT (0b001 << 4)
#define CHCR2__TS__16_BIT (0b010 << 4)
#define CHCR2__TS__32_BIT (0b011 << 4)
#define CHCR2__TS__32_BYTE (0b100 << 4)
#define CHCR2__IE (1 << 2) /* interrupt enable */
#define CHCR2__TE (1 << 1) /* transfer end; clear only */
#define CHCR2__DE (1 << 0) /* DMAC (channel) enable */
#define DMATCR2__TRANSFER_COUNT(n) (((n) & 0xffffff) << 0)

View File

@ -1,7 +1,6 @@
import math
from dataclasses import dataclass
import sys
from typing import Union
from generate import renderer
@ -14,30 +13,18 @@ class Vertex:
y: float
z: float
@dataclass(frozen=True)
class Color:
r: float
g: float
b: float
@dataclass(frozen=True)
class TextureCoordinate:
u: float
v: float
@dataclass
class VertexNormal:
vertex: int
normal: int
@dataclass
class VertexTextureNormal:
vertex: int
texture: int
normal: int
Face = Union[tuple[VertexTextureNormal, VertexTextureNormal, VertexTextureNormal],
tuple[VertexNormal, VertexNormal, VertexNormal]]
Face = tuple[VertexTextureNormal, VertexTextureNormal, VertexTextureNormal]
name = None
@ -47,17 +34,10 @@ def parse_object(line):
return name.lower()
def parse_vertex(line):
h, *xyz_rgb = line.split()
h, *xyz = line.split()
assert h == 'v' or h == 'vn'
if h == 'vn':
assert len(xyz_rgb) == 3
if h == 'v':
assert len(xyz_rgb) == 6 or len(xyz_rgb) == 3
coords = list(map(float, xyz_rgb))
if len(xyz_rgb) == 6:
return Vertex(*coords[0:3]), Color(*coords[3:6])
else:
return Vertex(*coords[0:3])
assert len(xyz) == 3
return Vertex(*map(float, xyz))
def parse_texture_coordinate(line):
h, *uv = line.split()
@ -67,7 +47,7 @@ def parse_texture_coordinate(line):
def maybe_int(i, offset):
if i.strip() == "":
return None
assert False
else:
return int(i) + offset
@ -82,36 +62,14 @@ def parse_face(line):
maybe_int(iix, offset=-1)
for iix in ix
]
assert vertex_ix is not None
assert normal_ix is not None
if uv_ix is None:
return VertexNormal(vertex_ix, normal_ix)
else:
return VertexTextureNormal(vertex_ix, uv_ix, normal_ix)
return VertexTextureNormal(vertex_ix, uv_ix, normal_ix)
return tuple(map(parse_ixs, tri))
def vertex_type(vertices):
types = set(type(v) for v in vertices)
assert len(types) == 1, types
if type(vertices[0]) is tuple:
return "position__color"
elif type(vertices[0]) is Vertex:
return "vec3"
else:
assert False, type(verticies[0])
def generate_vertices(vertices):
type_str = vertex_type(vertices)
yield f"constexpr {type_str} vertices[] = {{"
for p_c in vertices:
if type(p_c) is tuple:
p, c = p_c
yield f"{{ {{{p.x:9f}f, {p.y:9f}f, {p.z:9f}f}}, {{{c.r:9f}f, {c.g:9f}f, {c.b:9f}f}} }},"
else:
assert type(p_c) is Vertex
p = p_c
yield f"{{ {p.x:9f}f, {p.y:9f}f, {p.z:9f}f }},"
yield "constexpr vec3 vertices[] = {"
for v in vertices:
yield f"{{ {v.x:9f}f, {v.y:9f}f, {v.z:9f}f }},"
yield "};"
yield ""
@ -129,42 +87,26 @@ def generate_texture_coordinates(texture_coordinates):
yield "};"
yield ""
def face_type_str(face_type):
if face_type is VertexNormal:
return "face_vn"
elif face_type is VertexTextureNormal:
return "face_vtn"
else:
assert False, face_type
def generate_faces(faces, face_type):
def face_coords(vtn):
if face_type is VertexNormal:
return [vtn.vertex, vtn.normal]
elif face_type is VertexTextureNormal:
return [vtn.vertex, vtn.texture, vtn.normal]
else:
assert False, face_type
def generate_faces(faces):
max_ix = max(
i
for f in faces
for vtn in f
for i in face_coords(vtn)
for i in [vtn.vertex, vtn.texture, vtn.normal]
)
align = 1 + math.floor(math.log(max_ix) / math.log(10))
type_str = face_type_str(face_type)
yield f"constexpr {type_str} faces[] = {{"
yield "constexpr face faces[] = {"
def align_vtn(vtn):
return ", ".join(str(ix).rjust(align) for ix in face_coords(vtn))
return ", ".join(str(ix).rjust(align) for ix in [vtn.vertex, vtn.texture, vtn.normal])
for f in faces:
inner = ", ".join(f"{{{align_vtn(vtn)}}}" for vtn in f)
yield f"{{{inner}}},"
yield "};"
yield ""
yield f"constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof ({type_str}));"
yield "constexpr uint32_t num_faces = (sizeof (faces)) / (sizeof (face));"
yield ""
def generate_namespace(vertices, texture_coordinates, normals, faces, face_type):
def generate_namespace(vertices, texture_coordinates, normals, faces):
global name
assert name is not None
yield "#pragma once"
@ -174,10 +116,9 @@ def generate_namespace(vertices, texture_coordinates, normals, faces, face_type)
yield f"namespace {name} {{"
yield from generate_vertices(vertices)
if texture_coordinates != []:
yield from generate_texture_coordinates(texture_coordinates)
yield from generate_texture_coordinates(texture_coordinates)
yield from generate_normals(normals)
yield from generate_faces(faces, face_type)
yield from generate_faces(faces)
yield "}"
@ -222,14 +163,10 @@ def main():
else:
pass
face_types = set(type(vtn) for f in faces for vtn in f)
assert len(face_types) == 1, face_types
face_type = next(iter(face_types))
if face_type is VertexTextureNormal:
texture_coordinates, faces = merge_texture_coordinates(texture_coordinates, faces)
texture_coordinates, faces = merge_texture_coordinates(texture_coordinates, faces)
render, out = renderer()
render(generate_namespace(vertices, texture_coordinates, normals, faces, face_type))
render(generate_namespace(vertices, texture_coordinates, normals, faces))
sys.stdout.write(out.getvalue())
if __name__ == '__main__':

14
vga.cpp
View File

@ -1,8 +1,8 @@
#include <cstdint>
#include "sh7091/sh7091.hpp"
#include "sh7091/sh7091_bits.hpp"
#include "holly/holly.hpp"
#include "sh7091.hpp"
#include "sh7091_bits.hpp"
#include "holly.hpp"
#include "holly/core_bits.hpp"
#include "aica.hpp"
#include "memorymap.hpp"
@ -10,16 +10,14 @@
#include "vga.hpp"
#include "rgb.hpp"
/*
uint32_t get_cable_type()
{
// set all pins to input
/* set all pins to input */
sh7091.BSC.PCTRA = 0;
// get cable type from pins 9 + 8
/* get cable type from pins 9 + 8 */
return sh7091.BSC.PDTRA & PDTRA__MASK;
}
*/
void vga1()
{
@ -119,6 +117,8 @@ void v_sync_out()
void vga()
{
get_cable_type();
holly.SOFTRESET = softreset::sdram_if_soft_reset
| softreset::pipeline_soft_reset
| softreset::ta_soft_reset;

View File

@ -1,15 +0,0 @@
#include "geometry/geometry.hpp"
namespace screen_space {
constexpr mat4x4 transformation_matrix(const float d, // the z-coordinate of the view window and the near clip plane
const float f, // the z-coordnate of the far clip plane
const float h // the dimension of the square view window
)
{
return { d/h, 0.f, 0.f , 0.f ,
0.f, d/h, 0.f , 0.f ,
0.f, 0.f, f/(f-d), -d*f/(f-d),
0.f, 0.f, 1.f , 0.f };
}
}

View File

@ -1,44 +0,0 @@
#include "geometry/geometry.hpp"
namespace view_space {
constexpr vec3 viewing_direction(const float azimuth,
const float colatitude
)
{
const float x = sin(colatitude) * cos(azimuth);
const float y = sin(colatitude) * sin(azimuth);
const float z = cos(colatitude);
return {x, y, z};
}
constexpr vec3 project_vector_to_plane(const vec3& n, // N: plane normal
const vec3& v_ // V': approximate "up" orientation
)
{
return v_ - dot(v_, n) * n;
}
constexpr mat4x4 transformation_matrix(const vec3& c, // C: in world space, the position of the viewer
const vec3& n, // N: in world space, the viewing direction
const vec3& v_ // V': approximate "up" orientation
)
{
const vec3 v = project_vector_to_plane(n, v_);
const vec3 u = cross(n, v);
const mat4x4 t = { 1.f, 0.f, 0.f, -c.x,
0.f, 1.f, 0.f, -c.y,
0.f, 0.f, 1.f, -c.z,
0.f, 0.f, 0.f, 1.f };
const mat4x4 r = { u.x, u.y, u.z, 0.f,
v.x, v.y, v.z, 0.f,
n.x, n.y, n.z, 0.f,
0.f, 0.f, 0.f, 1.f };
return r * t;
}
}

254
wolf.data

File diff suppressed because one or more lines are too long

View File

@ -1,5 +0,0 @@
#include <cstdint>
extern uint32_t _binary_wolf_data_start __asm("_binary_wolf_data_start");
extern uint32_t _binary_wolf_data_end __asm("_binary_wolf_data_end");
extern uint32_t _binary_wolf_data_size __asm("_binary_wolf_data_size");

BIN
wolf.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 575 KiB