example: refresh

All examples work again, except macaw_multipass--this never worked
entirely, so I'm not worried about fixing it at the moment.
This commit is contained in:
Zack Buhman 2023-12-17 22:45:52 +08:00
parent e4303dbcf1
commit 5c2b45b70d
12 changed files with 72 additions and 22 deletions

View File

@ -2,7 +2,7 @@ MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
DIR := $(dir $(MAKEFILE_PATH)) DIR := $(dir $(MAKEFILE_PATH))
LIB ?= . LIB ?= .
OPT ?= -Os OPT ?= -O3
DEBUG ?= -g -gdwarf-4 DEBUG ?= -g -gdwarf-4
GENERATED ?= GENERATED ?=

View File

@ -120,3 +120,10 @@ MAPLE_VIBRATOR_OBJ = \
example/maple_vibrator.elf: LDSCRIPT = $(LIB)/alt.lds example/maple_vibrator.elf: LDSCRIPT = $(LIB)/alt.lds
example/maple_vibrator.elf: $(START_OBJ) $(MAPLE_VIBRATOR_OBJ) example/maple_vibrator.elf: $(START_OBJ) $(MAPLE_VIBRATOR_OBJ)
SERIAL_TRANSFER_OBJ = \
example/serial_transfer.o \
serial_load.o
example/serial_transfer.elf: LDSCRIPT = $(LIB)/alt.lds
example/serial_transfer.elf: $(START_OBJ) $(SERIAL_TRANSFER_OBJ)

View File

@ -148,7 +148,6 @@ void main()
core_start_render(frame_ix, num_frames); core_start_render(frame_ix, num_frames);
v_sync_out();
v_sync_in(); v_sync_in();
core_wait_end_of_render_video(frame_ix, num_frames); core_wait_end_of_render_video(frame_ix, num_frames);

View File

@ -1,9 +1,8 @@
#include <cstdint> #include <cstdint>
#include "align.hpp" #include "align.hpp"
#include "vga.hpp"
#include "holly/texture_memory_alloc.hpp" #include "vga.hpp"
#include "holly.hpp" #include "holly.hpp"
#include "holly/core.hpp" #include "holly/core.hpp"
#include "holly/core_bits.hpp" #include "holly/core_bits.hpp"
@ -12,6 +11,7 @@
#include "holly/ta_bits.hpp" #include "holly/ta_bits.hpp"
#include "holly/region_array.hpp" #include "holly/region_array.hpp"
#include "holly/background.hpp" #include "holly/background.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "memorymap.hpp" #include "memorymap.hpp"
#include "serial.hpp" #include "serial.hpp"

View File

@ -176,7 +176,6 @@ void main()
core_start_render(frame_ix, num_frames); core_start_render(frame_ix, num_frames);
v_sync_out();
v_sync_in(); v_sync_in();
core_wait_end_of_render_video(frame_ix, num_frames); core_wait_end_of_render_video(frame_ix, num_frames);

View File

@ -105,7 +105,6 @@ void main()
vga(); vga();
while (1) { while (1) {
v_sync_out();
v_sync_in(); v_sync_in();
do_device_request(); do_device_request();
}; };

View File

@ -4,14 +4,14 @@
#include "sh7091_bits.hpp" #include "sh7091_bits.hpp"
#include "cache.hpp" #include "cache.hpp"
#include "load.hpp" #include "serial_load.hpp"
extern uint32_t __bss_link_start __asm("__bss_link_start"); extern uint32_t __bss_link_start __asm("__bss_link_start");
extern uint32_t __bss_link_end __asm("__bss_link_end"); extern uint32_t __bss_link_end __asm("__bss_link_end");
void main() void main()
{ {
cache_init(); cache::init();
uint32_t * start = &__bss_link_start; uint32_t * start = &__bss_link_start;
uint32_t * end = &__bss_link_end; uint32_t * end = &__bss_link_end;

View File

@ -6,8 +6,13 @@
#include "holly.hpp" #include "holly.hpp"
#include "holly/core.hpp" #include "holly/core.hpp"
#include "holly/core_bits.hpp" #include "holly/core_bits.hpp"
#include "holly/ta_parameter.hpp"
#include "holly/ta_fifo_polygon_converter.hpp" #include "holly/ta_fifo_polygon_converter.hpp"
#include "holly/ta_parameter.hpp"
#include "holly/ta_bits.hpp"
#include "holly/background.hpp"
#include "holly/region_array.hpp"
#include "holly/texture_memory_alloc.hpp"
#include "memorymap.hpp"
struct vertex { struct vertex {
float x; float x;
@ -48,34 +53,65 @@ uint32_t transform(uint32_t * ta_parameter_buf)
return parameter.offset; return parameter.offset;
} }
void init_texture_memory(const struct opb_size& opb_size)
{
volatile texture_memory_alloc * mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory);
background_parameter(mem->background);
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 + 64 + 32) + 32) / 4]; uint32_t _ta_parameter_buf[((32 + 64 + 32) + 32) / 4];
void main() void main()
{ {
vga(); 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
};
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset; | softreset::ta_soft_reset;
holly.SOFTRESET = 0; holly.SOFTRESET = 0;
core_init(); core_init();
core_init_texture_memory(); init_texture_memory(opb_size);
// The address of `ta_parameter_buf` must be a multiple of 32 bytes. uint32_t frame_ix = 0;
// This is mandatory for ch2-dma to the ta fifo polygon converter. constexpr uint32_t num_frames = 1;
uint32_t * ta_parameter_buf = align_32byte(_ta_parameter_buf);
while (true) { while (true) {
v_sync_out(); ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc);
v_sync_in();
ta_polygon_converter_init();
uint32_t ta_parameter_size = transform(ta_parameter_buf); uint32_t ta_parameter_size = transform(ta_parameter_buf);
ta_polygon_converter_transfer(ta_parameter_buf, ta_parameter_size); ta_polygon_converter_transfer(ta_parameter_buf, ta_parameter_size);
ta_wait_opaque_list(); ta_wait_opaque_list();
constexpr int frame_ix = 0;
constexpr int num_frames = 0;
core_start_render(frame_ix, num_frames); 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

@ -46,7 +46,18 @@ uint32_t transform(uint32_t * ta_parameter_buf,
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture)); uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
if (translucent) { if (translucent) {
// translucent untextured // translucent untextured
parameter.append<global_polygon_type_0>() = global_polygon_type_0(); 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;
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;
parameter.append<global_polygon_type_0>() = polygon;
} else { } else {
// opaque textured // opaque textured
parameter.append<global_polygon_type_0>() = global_polygon_type_0(texture_address); parameter.append<global_polygon_type_0>() = global_polygon_type_0(texture_address);
@ -100,7 +111,6 @@ uint32_t _ta_parameter_buf[((32 * (strip_length + 2)) * 2 + 32) / 4];
void main() void main()
{ {
vga(); vga();
auto src = reinterpret_cast<const uint8_t *>(&_binary_macaw_data_start); auto src = reinterpret_cast<const uint8_t *>(&_binary_macaw_data_start);
@ -154,7 +164,6 @@ void main()
core_start_render(frame_ix, num_frames); core_start_render(frame_ix, num_frames);
v_sync_out();
v_sync_in(); v_sync_in();
core_wait_end_of_render_video(frame_ix, num_frames); core_wait_end_of_render_video(frame_ix, num_frames);

View File

@ -174,6 +174,7 @@ struct global_polygon_type_0 {
// untextured // untextured
global_polygon_type_0() global_polygon_type_0()
: parameter_control_word( para_control::para_type::polygon_or_modifier_volume : parameter_control_word( para_control::para_type::polygon_or_modifier_volume
| para_control::list_type::opaque
| obj_control::col_type::packed_color ) | obj_control::col_type::packed_color )
, isp_tsp_instruction_word( isp_tsp_instruction_word::depth_compare_mode::always , isp_tsp_instruction_word( isp_tsp_instruction_word::depth_compare_mode::always