female: add exclusion modifier volume
This commit is contained in:
parent
94c4af8d38
commit
0d91fc9b2c
35
common.mk
35
common.mk
@ -36,7 +36,29 @@ sine.pcm: common.mk
|
||||
synth 100s sin 700 vol -10dB
|
||||
mv $@.raw $@
|
||||
|
||||
%.iso: %.bin ip.bin
|
||||
# %.iso: %.bin ip.bin
|
||||
# mkisofs \
|
||||
# -C 0,11702 \
|
||||
# -sysid "SEGA SEGAKATANA" \
|
||||
# -volid "SAMPLE_GAME_TITLE" \
|
||||
# -volset "SAMPLE_GAME_TITLE" \
|
||||
# -publisher "SEGA ENTERPRISES, LTD." \
|
||||
# -preparer "CRI CD CRAFT VER.2.27" \
|
||||
# -copyright "COPYRIGH.TXT" \
|
||||
# -abstract "ABSTRACT.TXT" \
|
||||
# -biblio "BIBLIOGR.TXT" \
|
||||
# -G ip.bin \
|
||||
# -o $@ \
|
||||
# -graft-points \
|
||||
# /1ST_READ.BIN=./$< \
|
||||
# /=./COPYRIGH.TXT \
|
||||
# /=./ABSTRACT.TXT \
|
||||
# /=./BIBLIOGR.TXT
|
||||
|
||||
zero.bin:
|
||||
dd if=/dev/zero of=$@ bs=2048 count=1
|
||||
|
||||
%.iso: %.bin gdrom_jvm_boot.bin zero.bin
|
||||
mkisofs \
|
||||
-C 0,11702 \
|
||||
-sysid "SEGA SEGAKATANA" \
|
||||
@ -47,13 +69,14 @@ sine.pcm: common.mk
|
||||
-copyright "COPYRIGH.TXT" \
|
||||
-abstract "ABSTRACT.TXT" \
|
||||
-biblio "BIBLIOGR.TXT" \
|
||||
-G ip.bin \
|
||||
-G gdrom_jvm_boot.bin \
|
||||
-o $@ \
|
||||
-graft-points \
|
||||
/1ST_READ.BIN=./$< \
|
||||
/=./COPYRIGH.TXT \
|
||||
/=./ABSTRACT.TXT \
|
||||
/=./BIBLIOGR.TXT
|
||||
/0JVM.BIN=./$< \
|
||||
/1ST_READ.BIN=zero.bin \
|
||||
/=$(LIB)/COPYRIGH.TXT \
|
||||
/=$(LIB)/ABSTRACT.TXT \
|
||||
/=$(LIB)/BIBLIOGR.TXT
|
||||
|
||||
clean:
|
||||
find -P \
|
||||
|
@ -944,6 +944,7 @@ FEMALE_OBJ = \
|
||||
holly/ta_fifo_polygon_converter.o \
|
||||
holly/video_output.o \
|
||||
sh7091/serial.o \
|
||||
maple/maple.o \
|
||||
$(LIBGCC)
|
||||
|
||||
example/female.elf: LDSCRIPT = $(LIB)/main.lds
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <stdint.h>
|
||||
#include <bit>
|
||||
|
||||
#include "holly/background.hpp"
|
||||
#include "holly/core.hpp"
|
||||
@ -22,12 +23,19 @@
|
||||
#include "systembus.hpp"
|
||||
#include "systembus_bits.hpp"
|
||||
|
||||
#include "maple/maple.hpp"
|
||||
#include "maple/maple_host_command_writer.hpp"
|
||||
#include "maple/maple_bus_bits.hpp"
|
||||
#include "maple/maple_bus_commands.hpp"
|
||||
#include "maple/maple_bus_ft0.hpp"
|
||||
|
||||
#include "memorymap.hpp"
|
||||
|
||||
#include "math/vec2.hpp"
|
||||
#include "math/vec3.hpp"
|
||||
#include "math/vec4.hpp"
|
||||
#include "math/mat4x4.hpp"
|
||||
#include "math/geometry.hpp"
|
||||
|
||||
using vec2 = vec<2, float>;
|
||||
using vec3 = vec<3, float>;
|
||||
@ -37,6 +45,9 @@ using mat4x4 = mat<4, 4, float>;
|
||||
#include "model/model.h"
|
||||
#include "model/female/material.h"
|
||||
#include "model/female/model.h"
|
||||
#include "model/female/model_mansion.h"
|
||||
#include "model/female/model_cone.h"
|
||||
#include "model/female/model_cube.h"
|
||||
|
||||
void vbr100()
|
||||
{
|
||||
@ -176,6 +187,45 @@ void interrupt_init()
|
||||
: "r" (sr));
|
||||
}
|
||||
|
||||
static ft0::data_transfer::data_format data[4];
|
||||
|
||||
uint8_t send_buf[1024] __attribute__((aligned(32)));
|
||||
uint8_t recv_buf[1024] __attribute__((aligned(32)));
|
||||
|
||||
void do_get_condition()
|
||||
{
|
||||
auto writer = maple::host_command_writer(send_buf, recv_buf);
|
||||
|
||||
using command_type = maple::get_condition;
|
||||
using response_type = maple::data_transfer<ft0::data_transfer::data_format>;
|
||||
|
||||
auto [host_command, host_response]
|
||||
= writer.append_command_all_ports<command_type, response_type>();
|
||||
|
||||
for (int port = 0; port < 4; port++) {
|
||||
auto& data_fields = host_command[port].bus_data.data_fields;
|
||||
data_fields.function_type = std::byteswap(function_type::controller);
|
||||
}
|
||||
maple::dma_start(send_buf, writer.send_offset,
|
||||
recv_buf, writer.recv_offset);
|
||||
|
||||
for (uint8_t port = 0; port < 4; port++) {
|
||||
auto& bus_data = host_response[port].bus_data;
|
||||
if (bus_data.command_code != response_type::command_code) {
|
||||
return;
|
||||
}
|
||||
auto& data_fields = bus_data.data_fields;
|
||||
if ((std::byteswap(data_fields.function_type) & function_type::controller) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
data[port].analog_coordinate_axis[i]
|
||||
= data_fields.data.analog_coordinate_axis[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void global_polygon_type_1(ta_parameter_writer& writer,
|
||||
uint32_t texture_address,
|
||||
uint32_t list,
|
||||
@ -185,6 +235,7 @@ void global_polygon_type_1(ta_parameter_writer& writer,
|
||||
| list
|
||||
| obj_control::col_type::intensity_mode_1
|
||||
| obj_control::gouraud
|
||||
| obj_control::shadow
|
||||
;
|
||||
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater
|
||||
| cull;
|
||||
@ -218,8 +269,8 @@ static inline vec3 screen_transform(vec3 v)
|
||||
float dim = 480 / 2.0;
|
||||
|
||||
return {
|
||||
v.x / v.z * dim + 640 / 2.0f,
|
||||
v.y / v.z * dim + 480 / 2.0f,
|
||||
v.x / (1.f * v.z) * dim + 640 / 2.0f,
|
||||
v.y / (1.f * v.z) * dim + 480 / 2.0f,
|
||||
1 / v.z,
|
||||
};
|
||||
}
|
||||
@ -279,7 +330,7 @@ static inline void render_tri(ta_parameter_writer& writer,
|
||||
ci);
|
||||
}
|
||||
|
||||
constexpr inline mat4x4 screen_rotation(float theta)
|
||||
constexpr inline mat4x4 screen_rotation(float theta, float x, float y)
|
||||
{
|
||||
//float zt = -0.7853981633974483 + (0.2);
|
||||
float zt = -0.7853981633974483 * 0;
|
||||
@ -309,13 +360,13 @@ constexpr inline mat4x4 screen_rotation(float theta)
|
||||
};
|
||||
|
||||
mat4x4 t = {
|
||||
1, 0, 0, 0,
|
||||
1, 0, 0, 0.0f + x,
|
||||
0, 1, 0, 1,
|
||||
0, 0, 1, 1.2,
|
||||
0, 0, 1, 1.2f + y,
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
|
||||
return t * ry * rx * rz;
|
||||
return ry * t * rx * rz;
|
||||
}
|
||||
|
||||
#define _fsrra(n) (1.0f / (__builtin_sqrtf(n)))
|
||||
@ -326,10 +377,8 @@ static inline float inverse_length(vec3 v)
|
||||
return _fsrra(f);
|
||||
}
|
||||
|
||||
float light_intensity(vec3 light_vec, mat4x4& trans, vec3 n0)
|
||||
float light_intensity(vec3 light_vec, vec3 n)
|
||||
{
|
||||
vec4 n1 = trans * (vec4){n0.x, n0.y, n0.z, 0.f}; // no translation component
|
||||
vec3 n = {n1.x, n1.y, n1.z};
|
||||
float n_dot_l = dot(n, light_vec);
|
||||
|
||||
float intensity = 0.5f;
|
||||
@ -341,6 +390,71 @@ float light_intensity(vec3 light_vec, mat4x4& trans, vec3 n0)
|
||||
return intensity;
|
||||
}
|
||||
|
||||
|
||||
static inline void render_clip_tri(ta_parameter_writer& writer, vec3& light_vec, vec3 * preclip_position, vec3 * preclip_normal)
|
||||
{
|
||||
const vec3 plane_point = {0.f, 0.f, 1.f};
|
||||
const vec3 plane_normal = {0.f, 0.f, 1.f};
|
||||
|
||||
vec3 clip_position[4];
|
||||
vec3 clip_normal[4];
|
||||
int output_length = geometry::clip_polygon_uv<3>(clip_position,
|
||||
clip_normal,
|
||||
plane_point,
|
||||
plane_normal,
|
||||
preclip_position,
|
||||
preclip_normal);
|
||||
|
||||
float ai;
|
||||
float bi;
|
||||
float ci;
|
||||
float di;
|
||||
|
||||
vec3 ap;
|
||||
vec3 bp;
|
||||
vec3 cp;
|
||||
vec3 dp;
|
||||
|
||||
if (output_length >= 3) {
|
||||
// 012
|
||||
ap = screen_transform(clip_position[0]);
|
||||
bp = screen_transform(clip_position[1]);
|
||||
cp = screen_transform(clip_position[2]);
|
||||
|
||||
ai = light_intensity(light_vec, clip_normal[0]);
|
||||
bi = light_intensity(light_vec, clip_normal[1]);
|
||||
ci = light_intensity(light_vec, clip_normal[2]);
|
||||
|
||||
render_tri(writer,
|
||||
ap,
|
||||
bp,
|
||||
cp,
|
||||
ai,
|
||||
bi,
|
||||
ci);
|
||||
}
|
||||
if (output_length >= 4) {
|
||||
// 023
|
||||
dp = screen_transform(clip_position[3]);
|
||||
|
||||
di = light_intensity(light_vec, clip_normal[3]);
|
||||
|
||||
render_tri(writer,
|
||||
ap,
|
||||
cp,
|
||||
dp,
|
||||
ai,
|
||||
ci,
|
||||
di);
|
||||
}
|
||||
}
|
||||
|
||||
static inline vec3 light_trans(mat4x4& trans, vec3 normal)
|
||||
{
|
||||
vec4 n = trans * (vec4){normal.x, normal.y, normal.z, 0.f}; // no translation component
|
||||
return {n.x, n.y, n.z};
|
||||
}
|
||||
|
||||
static inline void transform_quad(ta_parameter_writer& writer, mat4x4& trans, vec3& light_vec, const union quadrilateral * quad, const vertex_position * position, const vertex_normal * normal)
|
||||
{
|
||||
vec3 a = trans * position[quad->v[0].position];
|
||||
@ -348,10 +462,35 @@ static inline void transform_quad(ta_parameter_writer& writer, mat4x4& trans, ve
|
||||
vec3 c = trans * position[quad->v[2].position];
|
||||
vec3 d = trans * position[quad->v[3].position];
|
||||
|
||||
float ai = light_intensity(light_vec, trans, normal[quad->v[0].normal]);
|
||||
float bi = light_intensity(light_vec, trans, normal[quad->v[1].normal]);
|
||||
float ci = light_intensity(light_vec, trans, normal[quad->v[2].normal]);
|
||||
float di = light_intensity(light_vec, trans, normal[quad->v[3].normal]);
|
||||
if (a.z < 0 && b.z < 0 && c.z < 0 && d.z < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 an = light_trans(trans, normal[quad->v[0].normal]);
|
||||
vec3 bn = light_trans(trans, normal[quad->v[1].normal]);
|
||||
vec3 cn = light_trans(trans, normal[quad->v[2].normal]);
|
||||
vec3 dn = light_trans(trans, normal[quad->v[3].normal]);
|
||||
|
||||
if (a.z < 0 || b.z < 0 || c.z < 0 || d.z < 0) {
|
||||
// abd
|
||||
// dbc
|
||||
{
|
||||
vec3 preclip_position[3] = {a, b, d};
|
||||
vec3 preclip_normal[3] = {an, bn, dn};
|
||||
|
||||
render_clip_tri(writer, light_vec, preclip_position, preclip_normal);
|
||||
}
|
||||
{
|
||||
vec3 preclip_position[3] = {d, b, c};
|
||||
vec3 preclip_normal[3] = {dn, bn, cn};
|
||||
|
||||
render_clip_tri(writer, light_vec, preclip_position, preclip_normal);
|
||||
}
|
||||
} else {
|
||||
float ai = light_intensity(light_vec, an);
|
||||
float bi = light_intensity(light_vec, bn);
|
||||
float ci = light_intensity(light_vec, cn);
|
||||
float di = light_intensity(light_vec, dn);
|
||||
|
||||
render_quad(writer,
|
||||
screen_transform(a),
|
||||
@ -363,6 +502,7 @@ static inline void transform_quad(ta_parameter_writer& writer, mat4x4& trans, ve
|
||||
ci,
|
||||
di);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void transform_tri(ta_parameter_writer& writer, mat4x4& trans, vec3& light_vec, const union triangle * tri, const vertex_position * position, const vertex_normal * normal)
|
||||
{
|
||||
@ -370,9 +510,21 @@ static inline void transform_tri(ta_parameter_writer& writer, mat4x4& trans, vec
|
||||
vec3 b = trans * position[tri->v[1].position];
|
||||
vec3 c = trans * position[tri->v[2].position];
|
||||
|
||||
float ai = light_intensity(light_vec, trans, normal[tri->v[0].normal]);
|
||||
float bi = light_intensity(light_vec, trans, normal[tri->v[1].normal]);
|
||||
float ci = light_intensity(light_vec, trans, normal[tri->v[2].normal]);
|
||||
if (a.z < 0 && b.z < 0 && c.z < 0) return;
|
||||
|
||||
vec3 an = light_trans(trans, normal[tri->v[0].normal]);
|
||||
vec3 bn = light_trans(trans, normal[tri->v[1].normal]);
|
||||
vec3 cn = light_trans(trans, normal[tri->v[2].normal]);
|
||||
|
||||
if (a.z < 0 || b.z < 0 || c.z < 0) {
|
||||
vec3 preclip_position[3] = {a, b, c};
|
||||
vec3 preclip_normal[3] = {an, bn, cn};
|
||||
|
||||
render_clip_tri(writer, light_vec, preclip_position, preclip_normal);
|
||||
} else {
|
||||
float ai = light_intensity(light_vec, an);
|
||||
float bi = light_intensity(light_vec, bn);
|
||||
float ci = light_intensity(light_vec, cn);
|
||||
|
||||
render_tri(writer,
|
||||
screen_transform(a),
|
||||
@ -382,32 +534,150 @@ static inline void transform_tri(ta_parameter_writer& writer, mat4x4& trans, vec
|
||||
bi,
|
||||
ci);
|
||||
}
|
||||
}
|
||||
|
||||
void render_female(ta_parameter_writer& writer, const mat4x4& model_trans, const mat4x4& screen)
|
||||
void render_model(ta_parameter_writer& writer, const mat4x4& model_trans, const mat4x4& screen, const struct model * model)
|
||||
{
|
||||
vec3 light_vec = {20, 1, -20};
|
||||
|
||||
mat4x4 trans = screen * model_trans;
|
||||
|
||||
for (int i = 0; i < female_Dreamcast.quadrilateral_count; i++) {
|
||||
const union quadrilateral * quad = &female_Dreamcast_quadrilateral[i];
|
||||
transform_quad(writer, trans, light_vec, quad, female_position, female_normal);
|
||||
for (int j = 0; j < model->object_count; j++) {
|
||||
const struct object * object = model->object[j];
|
||||
|
||||
for (int i = 0; i < object->quadrilateral_count; i++) {
|
||||
const union quadrilateral * quad = &object->quadrilateral[i];
|
||||
transform_quad(writer, trans, light_vec, quad, model->position, model->normal);
|
||||
}
|
||||
|
||||
for (int i = 0; i < female_Dreamcast.triangle_count; i++) {
|
||||
const union triangle * quad = &female_Dreamcast_triangle[i];
|
||||
transform_tri(writer, trans, light_vec, quad, female_position, female_normal);
|
||||
for (int i = 0; i < object->triangle_count; i++) {
|
||||
const union triangle * tri = &object->triangle[i];
|
||||
transform_tri(writer, trans, light_vec, tri, model->position, model->normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void transfer_scene(ta_parameter_writer& writer)
|
||||
void global_modifier_volume(ta_parameter_writer& writer)
|
||||
{
|
||||
const float deg = 0.017453292519943295 / 4;
|
||||
static float theta = deg;
|
||||
const mat4x4 screen = screen_rotation(theta);
|
||||
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
|
||||
| para_control::list_type::opaque_modifier_volume
|
||||
;
|
||||
|
||||
theta += deg;
|
||||
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::volume_instruction::normal_polygon
|
||||
| isp_tsp_instruction_word::culling_mode::no_culling;
|
||||
|
||||
writer.append<ta_global_parameter::modifier_volume>() =
|
||||
ta_global_parameter::modifier_volume(parameter_control_word,
|
||||
isp_tsp_instruction_word
|
||||
);
|
||||
}
|
||||
|
||||
void global_modifier_volume_last_triangle(ta_parameter_writer& writer, uint32_t volume_instruction)
|
||||
{
|
||||
const uint32_t last_parameter_control_word = para_control::para_type::polygon_or_modifier_volume
|
||||
| para_control::list_type::opaque_modifier_volume
|
||||
| obj_control::volume::modifier_volume::last_in_volume;
|
||||
|
||||
const uint32_t last_isp_tsp_instruction_word = volume_instruction
|
||||
| isp_tsp_instruction_word::culling_mode::no_culling;
|
||||
|
||||
writer.append<ta_global_parameter::modifier_volume>() =
|
||||
ta_global_parameter::modifier_volume(last_parameter_control_word,
|
||||
last_isp_tsp_instruction_word);
|
||||
}
|
||||
|
||||
static inline void render_tri_mod(ta_parameter_writer& writer,
|
||||
vec3 ap,
|
||||
vec3 bp,
|
||||
vec3 cp)
|
||||
{
|
||||
writer.append<ta_vertex_parameter::modifier_volume>() =
|
||||
ta_vertex_parameter::modifier_volume(modifier_volume_vertex_parameter_control_word(),
|
||||
ap.x, ap.y, ap.z,
|
||||
bp.x, bp.y, bp.z,
|
||||
cp.x, cp.y, cp.z);
|
||||
}
|
||||
|
||||
void render_inclusion_cube(ta_parameter_writer& writer)
|
||||
{
|
||||
global_modifier_volume(writer);
|
||||
|
||||
const struct object * object = cube_object[0];
|
||||
const vertex_position * position = cube_position;
|
||||
|
||||
float scale = 1000.f;
|
||||
const mat4x4 model = {
|
||||
scale, 0, 0, 0,
|
||||
0, scale, 0, 0,
|
||||
0, 0, scale, 0,
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
|
||||
global_modifier_volume(writer);
|
||||
|
||||
for (int i = 0; i < object->triangle_count - 1; i++) {
|
||||
const union triangle * tri = &object->triangle[i];
|
||||
vec3 a = model * position[tri->v[0].position];
|
||||
vec3 b = model * position[tri->v[1].position];
|
||||
vec3 c = model * position[tri->v[2].position];
|
||||
render_tri_mod(writer,
|
||||
a,
|
||||
b,
|
||||
c);
|
||||
}
|
||||
|
||||
global_modifier_volume_last_triangle(writer, isp_tsp_instruction_word::volume_instruction::inside_last_polygon);
|
||||
|
||||
const union triangle * tri = &object->triangle[object->triangle_count - 1];
|
||||
vec3 a = model * position[tri->v[0].position];
|
||||
vec3 b = model * position[tri->v[1].position];
|
||||
vec3 c = model * position[tri->v[2].position];
|
||||
render_tri_mod(writer,
|
||||
a,
|
||||
b,
|
||||
c);
|
||||
}
|
||||
|
||||
void render_cone(ta_parameter_writer& writer)
|
||||
{
|
||||
const struct object * object = cone_object[0];
|
||||
const vertex_position * position = cone_position;
|
||||
|
||||
float scale = 1.f;
|
||||
const mat4x4 model = {
|
||||
scale, 0, 0, 0,
|
||||
0, scale, 0, 0,
|
||||
0, 0, 0.5, 0.1,
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
|
||||
global_modifier_volume(writer);
|
||||
|
||||
for (int i = 0; i < object->triangle_count - 1; i++) {
|
||||
const union triangle * tri = &object->triangle[i];
|
||||
vec3 a = model * position[tri->v[0].position];
|
||||
vec3 b = model * position[tri->v[1].position];
|
||||
vec3 c = model * position[tri->v[2].position];
|
||||
render_tri_mod(writer,
|
||||
screen_transform(a),
|
||||
screen_transform(b),
|
||||
screen_transform(c));
|
||||
}
|
||||
|
||||
global_modifier_volume_last_triangle(writer, isp_tsp_instruction_word::volume_instruction::outside_last_polygon);
|
||||
|
||||
const union triangle * tri = &object->triangle[object->triangle_count - 1];
|
||||
vec3 a = model * position[tri->v[0].position];
|
||||
vec3 b = model * position[tri->v[1].position];
|
||||
vec3 c = model * position[tri->v[2].position];
|
||||
render_tri_mod(writer,
|
||||
screen_transform(a),
|
||||
screen_transform(b),
|
||||
screen_transform(c));
|
||||
}
|
||||
|
||||
void transfer_scene(ta_parameter_writer& writer, const mat4x4& screen)
|
||||
{
|
||||
// opaque
|
||||
{
|
||||
global_polygon_type_1(writer, texture_memory_alloc.texture.start,
|
||||
@ -421,12 +691,19 @@ void transfer_scene(ta_parameter_writer& writer)
|
||||
0, 0, -scale, translate,
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
render_female(writer, model, screen);
|
||||
render_model(writer, model, screen, &mansion_model);
|
||||
}
|
||||
|
||||
// end of opaque list
|
||||
writer.append<ta_global_parameter::end_of_list>() =
|
||||
ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
|
||||
|
||||
{
|
||||
render_inclusion_cube(writer);
|
||||
render_cone(writer);
|
||||
}
|
||||
// end of modifier volume list
|
||||
writer.append<ta_global_parameter::end_of_list>() =
|
||||
ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
|
||||
}
|
||||
|
||||
void transfer_ta_fifo_texture_memory_32byte(void * dst, void * src, int length)
|
||||
@ -496,6 +773,40 @@ void transfer_palette()
|
||||
*/
|
||||
}
|
||||
|
||||
constexpr inline mat4x4 update_analog(mat4x4& screen)
|
||||
{
|
||||
const float l_ = static_cast<float>(data[0].analog_coordinate_axis[0]) * (1.f / 255.f);
|
||||
const float r_ = static_cast<float>(data[0].analog_coordinate_axis[1]) * (1.f / 255.f);
|
||||
|
||||
const float x_ = static_cast<float>(data[0].analog_coordinate_axis[2] - 0x80) / 127.f;
|
||||
const float y_ = static_cast<float>(data[0].analog_coordinate_axis[3] - 0x80) / 127.f;
|
||||
float x = 0.05f * -x_;
|
||||
float y = 0.05f * y_;
|
||||
|
||||
mat4x4 t = {
|
||||
1, 0, 0, x,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, y,
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
|
||||
float theta = 0;
|
||||
if (l_ > 0.1f) {
|
||||
theta = -0.05f * l_;
|
||||
} else if (r_ > 0.1f) {
|
||||
theta = 0.05f * r_;
|
||||
}
|
||||
|
||||
mat4x4 ry = {
|
||||
cos(theta), 0, sin(theta), 0,
|
||||
0, 1, 0, 0,
|
||||
-sin(theta), 0, cos(theta), 0,
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
|
||||
return t * ry * screen;
|
||||
}
|
||||
|
||||
uint8_t __attribute__((aligned(32))) ta_parameter_buf[1024 * 1024];
|
||||
|
||||
void main()
|
||||
@ -510,14 +821,14 @@ void main()
|
||||
| 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::om_opb::_16x4byte
|
||||
| ta_alloc_ctrl::o_opb::_16x4byte;
|
||||
|
||||
constexpr int render_passes = 1;
|
||||
constexpr struct opb_size opb_size[render_passes] = {
|
||||
{
|
||||
.opaque = 16 * 4,
|
||||
.opaque_modifier = 0,
|
||||
.opaque_modifier = 16 * 4,
|
||||
.translucent = 0,
|
||||
.translucent_modifier = 0,
|
||||
.punch_through = 0
|
||||
@ -530,6 +841,9 @@ void main()
|
||||
|
||||
core_init();
|
||||
|
||||
holly.FPU_SHAD_SCALE = fpu_shad_scale::simple_shadow_enable::intensity_volume_mode
|
||||
| fpu_shad_scale::scale_factor_for_shadows(128);
|
||||
|
||||
system.IML6NRM = istnrm::end_of_render_tsp;
|
||||
|
||||
const int framebuffer_width = 640;
|
||||
@ -558,7 +872,15 @@ void main()
|
||||
transfer_palette();
|
||||
video_output::set_mode_vga();
|
||||
|
||||
do_get_condition();
|
||||
|
||||
mat4x4 screen = screen_rotation(0, 0, 0);
|
||||
|
||||
while (1) {
|
||||
maple::dma_wait_complete();
|
||||
do_get_condition();
|
||||
screen = update_analog(screen);
|
||||
|
||||
ta_polygon_converter_init2(texture_memory_alloc.isp_tsp_parameters[ta].start,
|
||||
texture_memory_alloc.isp_tsp_parameters[ta].end,
|
||||
texture_memory_alloc.object_list[ta].start,
|
||||
@ -568,10 +890,10 @@ void main()
|
||||
tile_width,
|
||||
tile_height);
|
||||
writer.offset = 0;
|
||||
transfer_scene(writer);
|
||||
transfer_scene(writer, screen);
|
||||
ta_polygon_converter_writeback(writer.buf, writer.offset);
|
||||
ta_polygon_converter_transfer(writer.buf, writer.offset);
|
||||
ta_wait_opaque_list();
|
||||
ta_wait_opaque_modifier_volume_list();
|
||||
|
||||
render_done = 0;
|
||||
core_start_render2(texture_memory_alloc.region_array[core].start,
|
||||
@ -583,8 +905,8 @@ void main()
|
||||
asm volatile ("nop");
|
||||
};
|
||||
|
||||
while (spg_status::vsync(holly.SPG_STATUS));
|
||||
while (!spg_status::vsync(holly.SPG_STATUS));
|
||||
holly.FB_R_SOF1 = texture_memory_alloc.framebuffer[ta].start;
|
||||
while (spg_status::vsync(holly.SPG_STATUS));
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ struct texture_memory_alloc {
|
||||
constexpr texture_memory_alloc texture_memory_alloc = {
|
||||
// bus a bus b
|
||||
// 32-bit addresses start end start end
|
||||
.isp_tsp_parameters = {{0x00'0000, 0x07'ffe0}, {0x40'0000, 0x47'ffe0}}, // 5461 textured triangles
|
||||
.isp_tsp_parameters = {{0x00'0000, 0x07'ffc0}, {0x40'0000, 0x47'ffc0}}, // 5461 textured triangles
|
||||
.background = {{0x07'ffe0, 0x08'0000}, {0x47'ffe0, 0x48'0000}},
|
||||
.object_list = {{0x08'0000, 0x0f'ffe0}, {0x48'0000, 0x4f'ffe0}}, // ~122880 object list pointers
|
||||
.object_list = {{0x08'0020, 0x0f'ffe0}, {0x48'0020, 0x4f'ffe0}}, // ~122880 object list pointers
|
||||
.region_array = {{0x10'0000, 0x11'0000}, {0x50'0000, 0x51'0000}}, // ~9 render passes
|
||||
.framebuffer = {{0x11'0000, 0x1b'8c00}, {0x51'0000, 0x5b'8c00}}, // 720x480*2
|
||||
//.framebuffer = {{0x11'0000, 0x23'c000}, {0x51'0000, 0x63'c000}}, // 640x480*4
|
||||
|
7
ip.mk
7
ip.mk
@ -26,3 +26,10 @@ SERIAL_LOAD_OBJ = \
|
||||
|
||||
serial_load_ip.elf: $(IP_OBJ) $(START_OBJ) $(SERIAL_LOAD_OBJ)
|
||||
$(LD) --orphan-handling=error --print-memory-usage -T $(LIB)/ip.lds $^ -o $@
|
||||
|
||||
GDROM_JVM_BOOT_OBJ = \
|
||||
$(LIB)/example/gdrom_jvm_boot.o \
|
||||
$(LIB)/sh7091/serial.o
|
||||
|
||||
gdrom_jvm_boot.elf: $(IP_OBJ) $(START_OBJ) $(GDROM_JVM_BOOT_OBJ)
|
||||
$(LD) --orphan-handling=error --print-memory-usage -T $(LIB)/ip.lds $^ -o $@
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
inline constexpr typename mat<4, 4, T>::row_type const &
|
||||
operator[](int i) const;
|
||||
|
||||
void operator=(const mat<4, 4, T>&) = delete;
|
||||
//void operator=(const mat<4, 4, T>&) = delete;
|
||||
|
||||
};
|
||||
|
||||
|
45
model/female/cube.obj
Normal file
45
model/female/cube.obj
Normal file
@ -0,0 +1,45 @@
|
||||
# Blender 4.2.1 LTS
|
||||
# www.blender.org
|
||||
mtllib cube.mtl
|
||||
o Cube
|
||||
v -1.000000 -1.000000 1.000000
|
||||
v -1.000000 1.000000 1.000000
|
||||
v -1.000000 -1.000000 -1.000000
|
||||
v -1.000000 1.000000 -1.000000
|
||||
v 1.000000 -1.000000 1.000000
|
||||
v 1.000000 1.000000 1.000000
|
||||
v 1.000000 -1.000000 -1.000000
|
||||
v 1.000000 1.000000 -1.000000
|
||||
vn -1.0000 -0.0000 -0.0000
|
||||
vn -0.0000 -0.0000 -1.0000
|
||||
vn 1.0000 -0.0000 -0.0000
|
||||
vn -0.0000 -0.0000 1.0000
|
||||
vn -0.0000 -1.0000 -0.0000
|
||||
vn -0.0000 1.0000 -0.0000
|
||||
vt 0.625000 0.000000
|
||||
vt 0.375000 0.250000
|
||||
vt 0.375000 0.000000
|
||||
vt 0.625000 0.250000
|
||||
vt 0.375000 0.500000
|
||||
vt 0.625000 0.500000
|
||||
vt 0.375000 0.750000
|
||||
vt 0.625000 0.750000
|
||||
vt 0.375000 1.000000
|
||||
vt 0.125000 0.750000
|
||||
vt 0.125000 0.500000
|
||||
vt 0.875000 0.500000
|
||||
vt 0.625000 1.000000
|
||||
vt 0.875000 0.750000
|
||||
s 0
|
||||
f 2/1/1 3/2/1 1/3/1
|
||||
f 4/4/2 7/5/2 3/2/2
|
||||
f 8/6/3 5/7/3 7/5/3
|
||||
f 6/8/4 1/9/4 5/7/4
|
||||
f 7/5/5 1/10/5 3/11/5
|
||||
f 4/12/6 6/8/6 8/6/6
|
||||
f 2/1/1 4/4/1 3/2/1
|
||||
f 4/4/2 8/6/2 7/5/2
|
||||
f 8/6/3 6/8/3 5/7/3
|
||||
f 6/8/4 2/13/4 1/9/4
|
||||
f 7/5/5 5/7/5 1/10/5
|
||||
f 4/12/6 2/14/6 6/8/6
|
4850
model/female/hauntedMansion.obj
Normal file
4850
model/female/hauntedMansion.obj
Normal file
File diff suppressed because it is too large
Load Diff
1473
model/female/lightCone.obj
Normal file
1473
model/female/lightCone.obj
Normal file
File diff suppressed because it is too large
Load Diff
3551
model/female/model_cone.h
Normal file
3551
model/female/model_cone.h
Normal file
File diff suppressed because it is too large
Load Diff
123
model/female/model_cube.h
Normal file
123
model/female/model_cube.h
Normal file
@ -0,0 +1,123 @@
|
||||
const vertex_position cube_position[] = {
|
||||
{-1.000000f, -1.000000f, 1.000000f},
|
||||
{-1.000000f, 1.000000f, 1.000000f},
|
||||
{-1.000000f, -1.000000f, -1.000000f},
|
||||
{-1.000000f, 1.000000f, -1.000000f},
|
||||
{1.000000f, -1.000000f, 1.000000f},
|
||||
{1.000000f, 1.000000f, 1.000000f},
|
||||
{1.000000f, -1.000000f, -1.000000f},
|
||||
{1.000000f, 1.000000f, -1.000000f},
|
||||
};
|
||||
|
||||
const vertex_texture cube_texture[] = {
|
||||
{0.625000f, 0.000000f},
|
||||
{0.375000f, 0.250000f},
|
||||
{0.375000f, 0.000000f},
|
||||
{0.625000f, 0.250000f},
|
||||
{0.375000f, 0.500000f},
|
||||
{0.625000f, 0.500000f},
|
||||
{0.375000f, 0.750000f},
|
||||
{0.625000f, 0.750000f},
|
||||
{0.375000f, 1.000000f},
|
||||
{0.125000f, 0.750000f},
|
||||
{0.125000f, 0.500000f},
|
||||
{0.875000f, 0.500000f},
|
||||
{0.625000f, 1.000000f},
|
||||
{0.875000f, 0.750000f},
|
||||
};
|
||||
|
||||
const vertex_normal cube_normal[] = {
|
||||
{-1.000000f, -0.000000f, -0.000000f},
|
||||
{-0.000000f, -0.000000f, -1.000000f},
|
||||
{1.000000f, -0.000000f, -0.000000f},
|
||||
{-0.000000f, -0.000000f, 1.000000f},
|
||||
{-0.000000f, -1.000000f, -0.000000f},
|
||||
{-0.000000f, 1.000000f, -0.000000f},
|
||||
};
|
||||
|
||||
const union triangle cube_Cube_triangle[] = {
|
||||
{ .v = {
|
||||
{1, 0, 0},
|
||||
{2, 1, 0},
|
||||
{0, 2, 0},
|
||||
}},
|
||||
{ .v = {
|
||||
{3, 3, 1},
|
||||
{6, 4, 1},
|
||||
{2, 1, 1},
|
||||
}},
|
||||
{ .v = {
|
||||
{7, 5, 2},
|
||||
{4, 6, 2},
|
||||
{6, 4, 2},
|
||||
}},
|
||||
{ .v = {
|
||||
{5, 7, 3},
|
||||
{0, 8, 3},
|
||||
{4, 6, 3},
|
||||
}},
|
||||
{ .v = {
|
||||
{6, 4, 4},
|
||||
{0, 9, 4},
|
||||
{2, 10, 4},
|
||||
}},
|
||||
{ .v = {
|
||||
{3, 11, 5},
|
||||
{5, 7, 5},
|
||||
{7, 5, 5},
|
||||
}},
|
||||
{ .v = {
|
||||
{1, 0, 0},
|
||||
{3, 3, 0},
|
||||
{2, 1, 0},
|
||||
}},
|
||||
{ .v = {
|
||||
{3, 3, 1},
|
||||
{7, 5, 1},
|
||||
{6, 4, 1},
|
||||
}},
|
||||
{ .v = {
|
||||
{7, 5, 2},
|
||||
{5, 7, 2},
|
||||
{4, 6, 2},
|
||||
}},
|
||||
{ .v = {
|
||||
{5, 7, 3},
|
||||
{1, 12, 3},
|
||||
{0, 8, 3},
|
||||
}},
|
||||
{ .v = {
|
||||
{6, 4, 4},
|
||||
{4, 6, 4},
|
||||
{0, 9, 4},
|
||||
}},
|
||||
{ .v = {
|
||||
{3, 11, 5},
|
||||
{1, 13, 5},
|
||||
{5, 7, 5},
|
||||
}},
|
||||
};
|
||||
|
||||
const union quadrilateral cube_Cube_quadrilateral[] = {
|
||||
};
|
||||
|
||||
const struct object cube_Cube = {
|
||||
.triangle = &cube_Cube_triangle[0],
|
||||
.quadrilateral = &cube_Cube_quadrilateral[0],
|
||||
.triangle_count = 12,
|
||||
.quadrilateral_count = 0,
|
||||
.material = 0,
|
||||
};
|
||||
|
||||
const struct object * cube_object[] = {
|
||||
&cube_Cube,
|
||||
};
|
||||
|
||||
const struct model cube_model = {
|
||||
.position = cube_position,
|
||||
.texture = cube_texture,
|
||||
.normal = cube_normal,
|
||||
.object = cube_object,
|
||||
.object_count = 1
|
||||
};
|
||||
|
15320
model/female/model_mansion.h
Normal file
15320
model/female/model_mansion.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user