example/scanner: add textured background and alternate logo
This commit is contained in:
parent
3ba9a4febc
commit
9dfc378831
@ -1185,6 +1185,7 @@ SCANNER_OBJ = \
|
|||||||
model/scanner/Bones.data.o \
|
model/scanner/Bones.data.o \
|
||||||
model/scanner/Dino.data.o \
|
model/scanner/Dino.data.o \
|
||||||
model/scanner/powervr.data.o \
|
model/scanner/powervr.data.o \
|
||||||
|
model/scanner/powervr_imr.data.o \
|
||||||
model/scanner/smoke.data.o \
|
model/scanner/smoke.data.o \
|
||||||
model/scanner/Surface.data.o \
|
model/scanner/Surface.data.o \
|
||||||
$(LIBGCC)
|
$(LIBGCC)
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include "model/scanner/Bones.data.h"
|
#include "model/scanner/Bones.data.h"
|
||||||
#include "model/scanner/Dino.data.h"
|
#include "model/scanner/Dino.data.h"
|
||||||
#include "model/scanner/powervr.data.h"
|
#include "model/scanner/powervr.data.h"
|
||||||
|
#include "model/scanner/powervr_imr.data.h"
|
||||||
//#include "model/scanner/Scanner.data.h"
|
//#include "model/scanner/Scanner.data.h"
|
||||||
#include "model/scanner/smoke.data.h"
|
#include "model/scanner/smoke.data.h"
|
||||||
#include "model/scanner/Surface.data.h"
|
#include "model/scanner/Surface.data.h"
|
||||||
@ -56,6 +57,8 @@ struct material {
|
|||||||
int dimension;
|
int dimension;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define Mt_LOGO2 (Mt_BACKGROUND + 1)
|
||||||
|
|
||||||
const material materials[] = {
|
const material materials[] = {
|
||||||
[Mt_DINOSAUR] = // 131072 model/scanner/Dino.data
|
[Mt_DINOSAUR] = // 131072 model/scanner/Dino.data
|
||||||
{
|
{
|
||||||
@ -108,8 +111,17 @@ const material materials[] = {
|
|||||||
.offset = 1441792,
|
.offset = 1441792,
|
||||||
.dimension = 256,
|
.dimension = 256,
|
||||||
},
|
},
|
||||||
|
[Mt_LOGO2] = // 524288 model/scanner/powervr_imr.data
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_model_scanner_powervr_imr_data_start,
|
||||||
|
.size = (uint32_t)&_binary_model_scanner_powervr_imr_data_size,
|
||||||
|
.offset = 1572864,
|
||||||
|
.dimension = 512,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool flip_logo = false;
|
||||||
|
|
||||||
static ft0::data_transfer::data_format data[4];
|
static ft0::data_transfer::data_format data[4];
|
||||||
|
|
||||||
uint8_t send_buf[1024] __attribute__((aligned(32)));
|
uint8_t send_buf[1024] __attribute__((aligned(32)));
|
||||||
@ -171,7 +183,7 @@ constexpr uint32_t ta_alloc = 0
|
|||||||
| ta_alloc_ctrl::pt_opb::no_list
|
| ta_alloc_ctrl::pt_opb::no_list
|
||||||
| ta_alloc_ctrl::tm_opb::_32x4byte
|
| ta_alloc_ctrl::tm_opb::_32x4byte
|
||||||
| ta_alloc_ctrl::t_opb::_32x4byte
|
| ta_alloc_ctrl::t_opb::_32x4byte
|
||||||
//| ta_alloc_ctrl::om_opb::_32x4byte
|
| ta_alloc_ctrl::om_opb::no_list
|
||||||
| ta_alloc_ctrl::o_opb::_32x4byte
|
| ta_alloc_ctrl::o_opb::_32x4byte
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -179,7 +191,7 @@ constexpr int ta_cont_count = 1;
|
|||||||
constexpr struct opb_size opb_size[ta_cont_count] = {
|
constexpr struct opb_size opb_size[ta_cont_count] = {
|
||||||
{
|
{
|
||||||
.opaque = 32 * 4,
|
.opaque = 32 * 4,
|
||||||
//.opaque_modifier = 32 * 4,
|
.opaque_modifier = 0,
|
||||||
.translucent = 32 * 4,
|
.translucent = 32 * 4,
|
||||||
.translucent_modifier = 32 * 4,
|
.translucent_modifier = 32 * 4,
|
||||||
.punch_through = 0
|
.punch_through = 0
|
||||||
@ -217,11 +229,9 @@ static inline void pump_events(uint32_t istnrm)
|
|||||||
system.ISTNRM = istnrm::end_of_transferring_opaque_list;
|
system.ISTNRM = istnrm::end_of_transferring_opaque_list;
|
||||||
|
|
||||||
core_in_use = 1;
|
core_in_use = 1;
|
||||||
core_start_render2(texture_memory_alloc.region_array.start,
|
|
||||||
texture_memory_alloc.isp_tsp_parameters.start,
|
holly.FB_W_SOF1 = texture_memory_alloc.framebuffer[framebuffer_ix].start;
|
||||||
texture_memory_alloc.background[0].start,
|
holly.STARTRENDER = 1;
|
||||||
texture_memory_alloc.framebuffer[framebuffer_ix].start,
|
|
||||||
framebuffer_width);
|
|
||||||
|
|
||||||
ta_in_use = 0;
|
ta_in_use = 0;
|
||||||
}
|
}
|
||||||
@ -425,7 +435,7 @@ void global_polygon_modifier_volume_last_in_volume(ta_parameter_writer& writer,
|
|||||||
|
|
||||||
static inline vec3 screen_transform(vec3 v)
|
static inline vec3 screen_transform(vec3 v)
|
||||||
{
|
{
|
||||||
float dim = 480; // * 2.0;
|
float dim = 480 / 2; // * 2.0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
v.x / (1.f * v.z) * dim + 640 / 2.0f,
|
v.x / (1.f * v.z) * dim + 640 / 2.0f,
|
||||||
@ -522,10 +532,17 @@ void transfer_mesh(ta_parameter_writer& writer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (1) {
|
if (1) {
|
||||||
|
if (mesh.nMaterial == Mt_LOGO && flip_logo) {
|
||||||
|
global_polygon_type_N(writer,
|
||||||
|
control,
|
||||||
|
Mt_LOGO2,
|
||||||
|
a);
|
||||||
|
} else {
|
||||||
global_polygon_type_N(writer,
|
global_polygon_type_N(writer,
|
||||||
control,
|
control,
|
||||||
mesh.nMaterial,
|
mesh.nMaterial,
|
||||||
a);
|
a);
|
||||||
|
}
|
||||||
|
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
|
|
||||||
@ -587,15 +604,20 @@ void transfer_mesh(ta_parameter_writer& writer,
|
|||||||
void transfer_scene(ta_parameter_writer& op_writer,
|
void transfer_scene(ta_parameter_writer& op_writer,
|
||||||
ta_parameter_writer& tl_writer,
|
ta_parameter_writer& tl_writer,
|
||||||
ta_parameter_writer& tl_mv_writer,
|
ta_parameter_writer& tl_mv_writer,
|
||||||
const mat4x4& screen_trans)
|
const mat4x4& screen_trans,
|
||||||
|
int tick)
|
||||||
{
|
{
|
||||||
// opaque list
|
// opaque list
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NUM_MESHES; i++) {
|
for (int i = 0; i < NUM_MESHES; i++) {
|
||||||
if (i == M_SCANNER) {
|
if (i == M_SCANNER) {
|
||||||
|
float x = sin((float)tick * 0.01f) * 100.f;
|
||||||
|
|
||||||
|
mat4x4 trans = translate((vec3){0, 0, x}) * rotate_x(sin(tick * 0.001f) * 9.f);
|
||||||
|
|
||||||
transfer_mesh<global_polygon_type_1>(tl_writer,
|
transfer_mesh<global_polygon_type_1>(tl_writer,
|
||||||
tl_mv_writer,
|
tl_mv_writer,
|
||||||
screen_trans,
|
screen_trans * trans,
|
||||||
Mesh[i],
|
Mesh[i],
|
||||||
para_control::list_type::translucent,
|
para_control::list_type::translucent,
|
||||||
para_control::list_type::translucent_modifier_volume,
|
para_control::list_type::translucent_modifier_volume,
|
||||||
@ -609,6 +631,8 @@ void transfer_scene(ta_parameter_writer& op_writer,
|
|||||||
para_control::list_type::translucent | obj_control::shadow,
|
para_control::list_type::translucent | obj_control::shadow,
|
||||||
para_control::list_type::translucent_modifier_volume,
|
para_control::list_type::translucent_modifier_volume,
|
||||||
false); // modifier volume
|
false); // modifier volume
|
||||||
|
} else if (i == M_BACKGROUND) {
|
||||||
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
transfer_mesh<global_polygon_type_1>(op_writer,
|
transfer_mesh<global_polygon_type_1>(op_writer,
|
||||||
op_writer,
|
op_writer,
|
||||||
@ -640,6 +664,14 @@ mat4x4 update_analog(mat4x4& screen_trans)
|
|||||||
const float x_ = static_cast<float>(data[0].analog_coordinate_axis[2] - 0x80) / 127.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;
|
const float y_ = static_cast<float>(data[0].analog_coordinate_axis[3] - 0x80) / 127.f;
|
||||||
|
|
||||||
|
int start = ft0::data_transfer::digital_button::start(data[0].digital_button) == 0;
|
||||||
|
static int last_start = 0;
|
||||||
|
|
||||||
|
if (start && (start != last_start)) {
|
||||||
|
flip_logo = !flip_logo;
|
||||||
|
}
|
||||||
|
last_start = start;
|
||||||
|
|
||||||
float y = -0.05f * x_;
|
float y = -0.05f * x_;
|
||||||
float x = 0.05f * y_;
|
float x = 0.05f * y_;
|
||||||
|
|
||||||
@ -647,7 +679,7 @@ mat4x4 update_analog(mat4x4& screen_trans)
|
|||||||
|
|
||||||
return translate((vec3){0, 0, z}) *
|
return translate((vec3){0, 0, z}) *
|
||||||
screen_trans *
|
screen_trans *
|
||||||
rotate_x(x) *
|
//rotate_x(x) *
|
||||||
rotate_y(y);
|
rotate_y(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,8 +771,12 @@ int main()
|
|||||||
texture_memory_alloc.region_array.start,
|
texture_memory_alloc.region_array.start,
|
||||||
texture_memory_alloc.object_list.start);
|
texture_memory_alloc.object_list.start);
|
||||||
|
|
||||||
background_parameter2(texture_memory_alloc.background[0].start,
|
uint32_t texture_address = texture_memory_alloc.texture.start + materials[Mt_BACKGROUND].offset;
|
||||||
0xff202040);
|
background_parameter_textured(texture_memory_alloc.background[0].start,
|
||||||
|
materials[Mt_BACKGROUND].dimension,
|
||||||
|
materials[Mt_BACKGROUND].dimension,
|
||||||
|
texture_address
|
||||||
|
);
|
||||||
|
|
||||||
ta_parameter_writer op_writer = ta_parameter_writer(ta_parameter_buf1, (sizeof (ta_parameter_buf1)));
|
ta_parameter_writer op_writer = ta_parameter_writer(ta_parameter_buf1, (sizeof (ta_parameter_buf1)));
|
||||||
ta_parameter_writer tl_writer = ta_parameter_writer(ta_parameter_buf2, (sizeof (ta_parameter_buf2)));
|
ta_parameter_writer tl_writer = ta_parameter_writer(ta_parameter_buf2, (sizeof (ta_parameter_buf2)));
|
||||||
@ -748,6 +784,26 @@ int main()
|
|||||||
|
|
||||||
video_output::set_mode_vga();
|
video_output::set_mode_vga();
|
||||||
|
|
||||||
|
{
|
||||||
|
uint32_t region_array_start = texture_memory_alloc.region_array.start;
|
||||||
|
uint32_t isp_tsp_parameters_start = texture_memory_alloc.isp_tsp_parameters.start;
|
||||||
|
uint32_t background_start = texture_memory_alloc.background[0].start;
|
||||||
|
|
||||||
|
holly.REGION_BASE = region_array_start;
|
||||||
|
holly.PARAM_BASE = isp_tsp_parameters_start;
|
||||||
|
|
||||||
|
uint32_t background_offset = background_start - isp_tsp_parameters_start;
|
||||||
|
holly.ISP_BACKGND_T = isp_backgnd_t::tag_address(background_offset / 4)
|
||||||
|
| isp_backgnd_t::tag_offset(0)
|
||||||
|
| isp_backgnd_t::skip(3);
|
||||||
|
holly.ISP_BACKGND_D = _i(1.f/100000.f);
|
||||||
|
|
||||||
|
holly.FB_W_CTRL = fb_w_ctrl::fb_dither
|
||||||
|
| fb_w_ctrl::fb_packmode::_565_rgb_16bit;
|
||||||
|
uint32_t bytes_per_pixel = 2;
|
||||||
|
holly.FB_W_LINESTRIDE = (framebuffer_width * bytes_per_pixel) / 8;
|
||||||
|
}
|
||||||
|
|
||||||
mat4x4 screen_trans = {
|
mat4x4 screen_trans = {
|
||||||
1, 0, 0, 0,
|
1, 0, 0, 0,
|
||||||
0, -1, 0, 0,
|
0, -1, 0, 0,
|
||||||
@ -755,6 +811,8 @@ int main()
|
|||||||
0, 0, 0, 1,
|
0, 0, 0, 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int tick = 0;
|
||||||
|
|
||||||
do_get_condition();
|
do_get_condition();
|
||||||
while (1) {
|
while (1) {
|
||||||
maple::dma_wait_complete();
|
maple::dma_wait_complete();
|
||||||
@ -768,7 +826,10 @@ int main()
|
|||||||
transfer_scene(op_writer,
|
transfer_scene(op_writer,
|
||||||
tl_writer,
|
tl_writer,
|
||||||
tl_mv_writer,
|
tl_mv_writer,
|
||||||
screen_trans);
|
screen_trans,
|
||||||
|
tick);
|
||||||
|
|
||||||
|
tick += 1;
|
||||||
|
|
||||||
while (ta_in_use);
|
while (ta_in_use);
|
||||||
while (core_in_use);
|
while (core_in_use);
|
||||||
|
@ -11,19 +11,80 @@ struct vertex_parameter {
|
|||||||
uint32_t base_color;
|
uint32_t base_color;
|
||||||
}; // ISP_BACKGND_T skip(1)
|
}; // ISP_BACKGND_T skip(1)
|
||||||
|
|
||||||
|
struct textured_vertex_parameter {
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float u;
|
||||||
|
float v;
|
||||||
|
uint32_t base_color;
|
||||||
|
}; // ISP_BACKGND_T skip(3)
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
struct isp_tsp_parameter {
|
struct isp_tsp_parameter {
|
||||||
uint32_t isp_tsp_instruction_word;
|
uint32_t isp_tsp_instruction_word;
|
||||||
uint32_t tsp_instruction_word;
|
uint32_t tsp_instruction_word;
|
||||||
uint32_t texture_control_word;
|
uint32_t texture_control_word;
|
||||||
vertex_parameter vertex[3];
|
T vertex[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert((sizeof (isp_tsp_parameter)) == (4 * 3 + 3) * 4);
|
static_assert((sizeof (isp_tsp_parameter<vertex_parameter>)) == (4 * 3 + 3) * 4);
|
||||||
|
|
||||||
|
void background_parameter_textured(const uint32_t background_start,
|
||||||
|
const int texture_u_size,
|
||||||
|
const int texture_v_size,
|
||||||
|
const uint32_t texture_address)
|
||||||
|
{
|
||||||
|
auto parameter = reinterpret_cast<volatile isp_tsp_parameter<textured_vertex_parameter> *>
|
||||||
|
(&texture_memory32[background_start / 4]);
|
||||||
|
|
||||||
|
parameter->isp_tsp_instruction_word
|
||||||
|
= isp_tsp_instruction_word::texture
|
||||||
|
| isp_tsp_instruction_word::depth_compare_mode::always
|
||||||
|
| isp_tsp_instruction_word::culling_mode::no_culling
|
||||||
|
;
|
||||||
|
|
||||||
|
parameter->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::filter_mode::bilinear_filter
|
||||||
|
| tsp_instruction_word::texture_shading_instruction::decal
|
||||||
|
| tsp_instruction_word::texture_u_size::from_int(texture_u_size)
|
||||||
|
| tsp_instruction_word::texture_v_size::from_int(texture_v_size)
|
||||||
|
;
|
||||||
|
|
||||||
|
parameter->texture_control_word
|
||||||
|
= texture_control_word::pixel_format::_565
|
||||||
|
| texture_control_word::scan_order::twiddled
|
||||||
|
| texture_control_word::texture_address(texture_address / 8);
|
||||||
|
|
||||||
|
parameter->vertex[0].x = 0.f;
|
||||||
|
parameter->vertex[0].y = 480.f;
|
||||||
|
parameter->vertex[0].z = 1.f/100000;
|
||||||
|
parameter->vertex[0].u = 0.0;
|
||||||
|
parameter->vertex[0].v = 1.0;
|
||||||
|
parameter->vertex[0].base_color = 0xffffffff;
|
||||||
|
|
||||||
|
parameter->vertex[1].x = 0.f;
|
||||||
|
parameter->vertex[1].y = 0.f;
|
||||||
|
parameter->vertex[1].z = 1.f/100000;
|
||||||
|
parameter->vertex[1].u = 0.0;
|
||||||
|
parameter->vertex[1].v = 0.0;
|
||||||
|
parameter->vertex[1].base_color = 0xffffffff;
|
||||||
|
|
||||||
|
parameter->vertex[2].x = 639.f;
|
||||||
|
parameter->vertex[2].y = 479.f;
|
||||||
|
parameter->vertex[2].z = 1.f/100000;
|
||||||
|
parameter->vertex[2].u = 1.0;
|
||||||
|
parameter->vertex[2].v = 1.0;
|
||||||
|
parameter->vertex[2].base_color = 0xffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
void background_parameter2(const uint32_t background_start,
|
void background_parameter2(const uint32_t background_start,
|
||||||
const uint32_t color)
|
const uint32_t color)
|
||||||
{
|
{
|
||||||
auto parameter = reinterpret_cast<volatile isp_tsp_parameter *>
|
auto parameter = reinterpret_cast<volatile isp_tsp_parameter<vertex_parameter> *>
|
||||||
(&texture_memory32[background_start / 4]);
|
(&texture_memory32[background_start / 4]);
|
||||||
|
|
||||||
parameter->isp_tsp_instruction_word
|
parameter->isp_tsp_instruction_word
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
void background_parameter_textured(const uint32_t background_start,
|
||||||
|
const int texture_u_size,
|
||||||
|
const int texture_v_size,
|
||||||
|
const uint32_t texture_address);
|
||||||
void background_parameter2(const uint32_t background_start,
|
void background_parameter2(const uint32_t background_start,
|
||||||
const uint32_t color);
|
const uint32_t color);
|
||||||
void background_parameter(const uint32_t color);
|
void background_parameter(const uint32_t color);
|
||||||
|
9
model/scanner/powervr_imr.data
Normal file
9
model/scanner/powervr_imr.data
Normal file
File diff suppressed because one or more lines are too long
15
model/scanner/powervr_imr.data.h
Normal file
15
model/scanner/powervr_imr.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_model_scanner_powervr_imr_data_start __asm("_binary_model_scanner_powervr_imr_data_start");
|
||||||
|
extern uint32_t _binary_model_scanner_powervr_imr_data_end __asm("_binary_model_scanner_powervr_imr_data_end");
|
||||||
|
extern uint32_t _binary_model_scanner_powervr_imr_data_size __asm("_binary_model_scanner_powervr_imr_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
model/scanner/powervr_imr.png
Normal file
BIN
model/scanner/powervr_imr.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
Loading…
x
Reference in New Issue
Block a user