Compare commits
2 Commits
1dbae5713f
...
eb45b65895
Author | SHA1 | Date | |
---|---|---|---|
eb45b65895 | |||
ee2235c632 |
@ -11,7 +11,7 @@
|
|||||||
#include "holly/ta_global_parameter.hpp"
|
#include "holly/ta_global_parameter.hpp"
|
||||||
#include "holly/ta_parameter.hpp"
|
#include "holly/ta_parameter.hpp"
|
||||||
#include "holly/ta_vertex_parameter.hpp"
|
#include "holly/ta_vertex_parameter.hpp"
|
||||||
#include "holly/texture_memory_alloc3.hpp"
|
#include "holly/texture_memory_alloc5.hpp"
|
||||||
#include "holly/video_output.hpp"
|
#include "holly/video_output.hpp"
|
||||||
|
|
||||||
#include "systembus.hpp"
|
#include "systembus.hpp"
|
||||||
@ -1470,7 +1470,7 @@ mat4x4 update_analog(const mat4x4& screen)
|
|||||||
0, 0, 0, 1,
|
0, 0, 0, 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
float yt = 0.05f * x_;
|
float yt = -0.05f * x_;
|
||||||
float xt = 0.05f * y_;
|
float xt = 0.05f * y_;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1547,8 +1547,122 @@ void transfer_font()
|
|||||||
printf("font_base %d actual %d\n", font_base, offset);
|
printf("font_base %d actual %d\n", font_base, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vbr100()
|
||||||
|
{
|
||||||
|
serial::string("vbr100\n");
|
||||||
|
interrupt_exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
void vbr400()
|
||||||
|
{
|
||||||
|
serial::string("vbr400\n");
|
||||||
|
interrupt_exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
const int framebuffer_width = 640;
|
||||||
|
const int framebuffer_height = 480;
|
||||||
|
const int tile_width = framebuffer_width / 32;
|
||||||
|
const int tile_height = framebuffer_height / 32;
|
||||||
|
|
||||||
|
constexpr uint32_t ta_alloc = 0
|
||||||
|
| ta_alloc_ctrl::pt_opb::_16x4byte
|
||||||
|
| ta_alloc_ctrl::tm_opb::no_list
|
||||||
|
| ta_alloc_ctrl::t_opb::no_list
|
||||||
|
| ta_alloc_ctrl::om_opb::_16x4byte
|
||||||
|
| ta_alloc_ctrl::o_opb::no_list;
|
||||||
|
|
||||||
|
constexpr int ta_cont_count = 1;
|
||||||
|
constexpr struct opb_size opb_size[ta_cont_count] = {
|
||||||
|
{
|
||||||
|
.opaque = 0,
|
||||||
|
.opaque_modifier = 16 * 4,
|
||||||
|
.translucent = 0,
|
||||||
|
.translucent_modifier = 0,
|
||||||
|
.punch_through = 16 * 4
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static volatile int ta_in_use = 0;
|
||||||
|
static volatile int core_in_use = 0;
|
||||||
|
static volatile int next_frame = 0;
|
||||||
|
static volatile int framebuffer_ix = 0;
|
||||||
|
static volatile int next_frame_ix = 0;
|
||||||
|
|
||||||
|
static inline void pump_events(uint32_t istnrm)
|
||||||
|
{
|
||||||
|
if (istnrm & istnrm::v_blank_in) {
|
||||||
|
system.ISTNRM = istnrm::v_blank_in;
|
||||||
|
|
||||||
|
next_frame = 1;
|
||||||
|
holly.FB_R_SOF1 = texture_memory_alloc.framebuffer[next_frame_ix].start;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (istnrm & istnrm::end_of_render_tsp) {
|
||||||
|
system.ISTNRM = istnrm::end_of_render_tsp
|
||||||
|
| istnrm::end_of_render_isp
|
||||||
|
| istnrm::end_of_render_video;
|
||||||
|
|
||||||
|
next_frame_ix = framebuffer_ix;
|
||||||
|
framebuffer_ix += 1;
|
||||||
|
if (framebuffer_ix >= 3) framebuffer_ix = 0;
|
||||||
|
|
||||||
|
core_in_use = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (istnrm & istnrm::end_of_transferring_opaque_modifier_volume_list) {
|
||||||
|
system.ISTNRM = istnrm::end_of_transferring_opaque_modifier_volume_list;
|
||||||
|
|
||||||
|
core_in_use = 1;
|
||||||
|
core_start_render2(texture_memory_alloc.region_array.start,
|
||||||
|
texture_memory_alloc.isp_tsp_parameters.start,
|
||||||
|
texture_memory_alloc.background[0].start,
|
||||||
|
texture_memory_alloc.framebuffer[framebuffer_ix].start,
|
||||||
|
framebuffer_width);
|
||||||
|
|
||||||
|
ta_in_use = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vbr600()
|
||||||
|
{
|
||||||
|
uint32_t sr;
|
||||||
|
asm volatile ("stc sr,%0" : "=r" (sr));
|
||||||
|
sr |= sh::sr::imask(15);
|
||||||
|
asm volatile ("ldc %0,sr" : : "r" (sr));
|
||||||
|
//serial::string("imask\n");
|
||||||
|
|
||||||
|
//check_pipeline();
|
||||||
|
|
||||||
|
if (sh7091.CCN.EXPEVT == 0 && sh7091.CCN.INTEVT == 0x320) {
|
||||||
|
uint32_t istnrm = system.ISTNRM;
|
||||||
|
uint32_t isterr = system.ISTERR;
|
||||||
|
|
||||||
|
if (isterr) {
|
||||||
|
serial::string("isterr: ");
|
||||||
|
serial::integer<uint32_t>(system.ISTERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
pump_events(istnrm);
|
||||||
|
|
||||||
|
sr &= ~sh::sr::imask(15);
|
||||||
|
asm volatile ("ldc %0,sr" : : "r" (sr));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
serial::string("vbr600\n");
|
||||||
|
interrupt_exception();
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
sh7091.TMU.TSTR = 0; // stop all timers
|
||||||
|
sh7091.TMU.TOCR = tmu::tocr::tcoe::tclk_is_external_clock_or_input_capture;
|
||||||
|
sh7091.TMU.TCR0 = tmu::tcr0::tpsc::p_phi_256; // 256 / 50MHz = 5.12 μs ; underflows in ~1 hour
|
||||||
|
sh7091.TMU.TCOR0 = 0xffff'ffff;
|
||||||
|
sh7091.TMU.TCNT0 = 0xffff'ffff;
|
||||||
|
sh7091.TMU.TSTR = tmu::tstr::str0::counter_start;
|
||||||
|
|
||||||
serial::init(0);
|
serial::init(0);
|
||||||
|
|
||||||
total_tri_count = count_face_triangles();
|
total_tri_count = count_face_triangles();
|
||||||
@ -1558,56 +1672,30 @@ int main()
|
|||||||
transfer_font();
|
transfer_font();
|
||||||
palette_data<3>();
|
palette_data<3>();
|
||||||
|
|
||||||
constexpr uint32_t ta_alloc = 0
|
|
||||||
| ta_alloc_ctrl::pt_opb::_16x4byte
|
|
||||||
| ta_alloc_ctrl::tm_opb::no_list
|
|
||||||
| ta_alloc_ctrl::t_opb::no_list
|
|
||||||
| ta_alloc_ctrl::om_opb::_16x4byte
|
|
||||||
| ta_alloc_ctrl::o_opb::no_list;
|
|
||||||
|
|
||||||
constexpr int ta_cont_count = 1;
|
|
||||||
constexpr struct opb_size opb_size[ta_cont_count] = {
|
|
||||||
{
|
|
||||||
.opaque = 0,
|
|
||||||
.opaque_modifier = 16 * 4,
|
|
||||||
.translucent = 0,
|
|
||||||
.translucent_modifier = 0,
|
|
||||||
.punch_through = 16 * 4
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
system.IML6NRM = istnrm::end_of_render_tsp;
|
system.IML6NRM = istnrm::end_of_render_tsp
|
||||||
|
| istnrm::v_blank_in
|
||||||
|
| istnrm::end_of_transferring_opaque_modifier_volume_list;
|
||||||
|
|
||||||
const int framebuffer_width = 640;
|
|
||||||
const int framebuffer_height = 480;
|
|
||||||
const int tile_width = framebuffer_width / 32;
|
|
||||||
const int tile_height = framebuffer_height / 32;
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
region_array_multipass(tile_width,
|
region_array_multipass(tile_width,
|
||||||
tile_height,
|
tile_height,
|
||||||
opb_size,
|
opb_size,
|
||||||
ta_cont_count,
|
ta_cont_count,
|
||||||
texture_memory_alloc.region_array[i].start,
|
texture_memory_alloc.region_array.start,
|
||||||
texture_memory_alloc.object_list[i].start);
|
texture_memory_alloc.object_list.start);
|
||||||
|
|
||||||
background_parameter2(texture_memory_alloc.background[i].start,
|
background_parameter2(texture_memory_alloc.background[0].start,
|
||||||
0xff202040);
|
0xff202040);
|
||||||
}
|
|
||||||
|
|
||||||
ta_parameter_writer writer = ta_parameter_writer(ta_parameter_buf, (sizeof (ta_parameter_buf)));
|
ta_parameter_writer writer = ta_parameter_writer(ta_parameter_buf, (sizeof (ta_parameter_buf)));
|
||||||
|
|
||||||
video_output::set_mode_vga();
|
video_output::set_mode_vga();
|
||||||
|
|
||||||
int ta = 0;
|
|
||||||
int core = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
mat4x4 trans1 = {
|
mat4x4 trans1 = {
|
||||||
1.0, 0.0, 0.000, -1123.0,
|
1.0, 0.0, 0.000, -1123.0,
|
||||||
@ -1632,41 +1720,25 @@ int main()
|
|||||||
do_get_condition();
|
do_get_condition();
|
||||||
|
|
||||||
trans = update_analog(trans);
|
trans = update_analog(trans);
|
||||||
|
|
||||||
mat4x4 trans_inv = inverse(trans);
|
mat4x4 trans_inv = inverse(trans);
|
||||||
|
writer.offset = 0;
|
||||||
|
transfer_scene(writer, trans, trans_inv);
|
||||||
|
|
||||||
ta_polygon_converter_init2(texture_memory_alloc.isp_tsp_parameters[ta].start,
|
while (ta_in_use);
|
||||||
texture_memory_alloc.isp_tsp_parameters[ta].end,
|
while (core_in_use);
|
||||||
texture_memory_alloc.object_list[ta].start,
|
ta_in_use = 1;
|
||||||
texture_memory_alloc.object_list[ta].end,
|
ta_polygon_converter_init2(texture_memory_alloc.isp_tsp_parameters.start,
|
||||||
|
texture_memory_alloc.isp_tsp_parameters.end,
|
||||||
|
texture_memory_alloc.object_list.start,
|
||||||
|
texture_memory_alloc.object_list.end,
|
||||||
opb_size[0].total(),
|
opb_size[0].total(),
|
||||||
ta_alloc,
|
ta_alloc,
|
||||||
tile_width,
|
tile_width,
|
||||||
tile_height);
|
tile_height);
|
||||||
|
|
||||||
writer.offset = 0;
|
|
||||||
transfer_scene(writer, trans, trans_inv);
|
|
||||||
ta_polygon_converter_writeback(writer.buf, writer.offset);
|
ta_polygon_converter_writeback(writer.buf, writer.offset);
|
||||||
ta_polygon_converter_transfer(writer.buf, writer.offset);
|
ta_polygon_converter_transfer(writer.buf, writer.offset);
|
||||||
//serial::integer<uint32_t>(writer.offset);
|
|
||||||
//serial::integer<uint32_t>(typen_tri_count);
|
|
||||||
//serial::string("wait_pt\n");
|
|
||||||
ta_wait_opaque_modifier_volume_list();
|
|
||||||
//ta_wait_opaque_list();
|
|
||||||
|
|
||||||
render_done = 0;
|
while (next_frame)
|
||||||
core_start_render2(texture_memory_alloc.region_array[core].start,
|
next_frame = 0;
|
||||||
texture_memory_alloc.isp_tsp_parameters[core].start,
|
|
||||||
texture_memory_alloc.background[core].start,
|
|
||||||
texture_memory_alloc.framebuffer[core].start,
|
|
||||||
framebuffer_width);
|
|
||||||
//serial::string("wait_render\n");
|
|
||||||
while (render_done == 0) {
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ BSP_20KDM2_OBJ = \
|
|||||||
printf/printf.o \
|
printf/printf.o \
|
||||||
printf/unparse.o \
|
printf/unparse.o \
|
||||||
printf/parse.o \
|
printf/parse.o \
|
||||||
interrupt.o \
|
|
||||||
maple/maple.o \
|
maple/maple.o \
|
||||||
font/font_bitmap.o \
|
font/font_bitmap.o \
|
||||||
font/verite_8x16/verite_8x16.data.o \
|
font/verite_8x16/verite_8x16.data.o \
|
||||||
|
32
holly/texture_memory_alloc5.hpp
Normal file
32
holly/texture_memory_alloc5.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
struct texture_memory_alloc__start_end {
|
||||||
|
uint32_t start;
|
||||||
|
uint32_t end;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct texture_memory_alloc {
|
||||||
|
struct texture_memory_alloc__start_end isp_tsp_parameters;
|
||||||
|
struct texture_memory_alloc__start_end object_list;
|
||||||
|
struct texture_memory_alloc__start_end region_array;
|
||||||
|
struct texture_memory_alloc__start_end framebuffer[3];
|
||||||
|
struct texture_memory_alloc__start_end background[2];
|
||||||
|
struct texture_memory_alloc__start_end texture;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr texture_memory_alloc texture_memory_alloc = {
|
||||||
|
// 32-bit addresses start end start end
|
||||||
|
.isp_tsp_parameters = {0x000000, 0x11bfe0},
|
||||||
|
.object_list = {0x400000, 0x495fe0},
|
||||||
|
.region_array = {0x11c000, 0x12c000},
|
||||||
|
.framebuffer = {{0x496000, 0x52c000},
|
||||||
|
{0x12c000, 0x1c2000},
|
||||||
|
{0x52c000, 0x5c2000}},
|
||||||
|
.background = {{0x1c2000, 0x1c2020},
|
||||||
|
{0x5c2000, 0x5c2020}},
|
||||||
|
// 64-bit addresses
|
||||||
|
.texture = {0x384040, 0x800000}
|
||||||
|
};
|
115
interrupt.cpp
115
interrupt.cpp
@ -1,53 +1,15 @@
|
|||||||
#include "sh7091/sh7091.hpp"
|
#include "interrupt.hpp"
|
||||||
#include "sh7091/sh7091_bits.hpp"
|
|
||||||
#include "sh7091/serial.hpp"
|
|
||||||
#include "sh7091/vbr.hpp"
|
|
||||||
|
|
||||||
#include "systembus.hpp"
|
|
||||||
#include "systembus_bits.hpp"
|
|
||||||
|
|
||||||
void vbr100()
|
void vbr100()
|
||||||
{
|
{
|
||||||
serial::string("vbr100\n");
|
serial::string("vbr100\n");
|
||||||
serial::string("expevt ");
|
interrupt_exception();
|
||||||
serial::integer<uint16_t>(sh7091.CCN.EXPEVT);
|
|
||||||
serial::string("intevt ");
|
|
||||||
serial::integer<uint16_t>(sh7091.CCN.INTEVT);
|
|
||||||
serial::string("tra ");
|
|
||||||
serial::integer<uint16_t>(sh7091.CCN.TRA);
|
|
||||||
|
|
||||||
uint32_t spc;
|
|
||||||
uint32_t ssr;
|
|
||||||
asm volatile ("stc spc,%0" : "=r" (spc));
|
|
||||||
asm volatile ("stc ssr,%0" : "=r" (ssr));
|
|
||||||
serial::string("spc ");
|
|
||||||
serial::integer(spc);
|
|
||||||
serial::string("ssr ");
|
|
||||||
serial::integer(ssr);
|
|
||||||
|
|
||||||
while (1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vbr400()
|
void vbr400()
|
||||||
{
|
{
|
||||||
serial::string("vbr400\n");
|
serial::string("vbr400\n");
|
||||||
serial::string("expevt ");
|
interrupt_exception();
|
||||||
serial::integer<uint16_t>(sh7091.CCN.EXPEVT);
|
|
||||||
serial::string("intevt ");
|
|
||||||
serial::integer<uint16_t>(sh7091.CCN.INTEVT);
|
|
||||||
serial::string("tra ");
|
|
||||||
serial::integer<uint16_t>(sh7091.CCN.TRA);
|
|
||||||
|
|
||||||
uint32_t spc;
|
|
||||||
uint32_t ssr;
|
|
||||||
asm volatile ("stc spc,%0" : "=r" (spc));
|
|
||||||
asm volatile ("stc ssr,%0" : "=r" (ssr));
|
|
||||||
serial::string("spc ");
|
|
||||||
serial::integer(spc);
|
|
||||||
serial::string("ssr ");
|
|
||||||
serial::integer(ssr);
|
|
||||||
|
|
||||||
while (1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int render_done = 0;
|
int render_done = 0;
|
||||||
@ -68,78 +30,11 @@ void vbr600()
|
|||||||
| istnrm::end_of_render_isp
|
| istnrm::end_of_render_isp
|
||||||
| istnrm::end_of_render_video;
|
| istnrm::end_of_render_video;
|
||||||
render_done = 1;
|
render_done = 1;
|
||||||
|
serial::string("eor\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
serial::string("vbr600\n");
|
serial::string("vbr600\n");
|
||||||
serial::string("expevt ");
|
interrupt_exception();
|
||||||
serial::integer<uint16_t>(sh7091.CCN.EXPEVT);
|
|
||||||
serial::string("intevt ");
|
|
||||||
serial::integer<uint16_t>(sh7091.CCN.INTEVT);
|
|
||||||
serial::string("tra ");
|
|
||||||
serial::integer<uint16_t>(sh7091.CCN.TRA);
|
|
||||||
|
|
||||||
serial::string("istnrm: ");
|
|
||||||
serial::integer<uint32_t>(system.ISTNRM);
|
|
||||||
serial::string("isterr: ");
|
|
||||||
serial::integer<uint32_t>(system.ISTERR);
|
|
||||||
|
|
||||||
uint32_t spc;
|
|
||||||
uint32_t ssr;
|
|
||||||
asm volatile ("stc spc,%0" : "=r" (spc));
|
|
||||||
asm volatile ("stc ssr,%0" : "=r" (ssr));
|
|
||||||
serial::string("spc ");
|
|
||||||
serial::integer(spc);
|
|
||||||
serial::string("ssr ");
|
|
||||||
serial::integer(ssr);
|
|
||||||
|
|
||||||
while (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void interrupt_init()
|
|
||||||
{
|
|
||||||
system.IML2NRM = 0;
|
|
||||||
system.IML2ERR = 0;
|
|
||||||
system.IML2EXT = 0;
|
|
||||||
|
|
||||||
system.IML4NRM = 0;
|
|
||||||
system.IML4ERR = 0;
|
|
||||||
system.IML4EXT = 0;
|
|
||||||
|
|
||||||
system.IML6NRM = 0;
|
|
||||||
system.IML6ERR = 0;
|
|
||||||
system.IML6EXT = 0;
|
|
||||||
|
|
||||||
system.ISTERR = 0xffffffff;
|
|
||||||
system.ISTNRM = 0xffffffff;
|
|
||||||
|
|
||||||
sh7091.CCN.INTEVT = 0;
|
|
||||||
sh7091.CCN.EXPEVT = 0;
|
|
||||||
|
|
||||||
uint32_t vbr = reinterpret_cast<uint32_t>(&__vbr_link_start) - 0x100;
|
|
||||||
serial::string("vbr ");
|
|
||||||
serial::integer<uint32_t>(vbr);
|
|
||||||
serial::string("vbr100 ");
|
|
||||||
serial::integer<uint32_t>(reinterpret_cast<uint32_t>(&vbr100));
|
|
||||||
|
|
||||||
asm volatile ("ldc %0,vbr"
|
|
||||||
:
|
|
||||||
: "r" (vbr));
|
|
||||||
|
|
||||||
uint32_t sr;
|
|
||||||
asm volatile ("stc sr,%0"
|
|
||||||
: "=r" (sr));
|
|
||||||
serial::string("sr ");
|
|
||||||
serial::integer<uint32_t>(sr);
|
|
||||||
|
|
||||||
sr &= ~sh::sr::bl; // BL
|
|
||||||
sr &= ~sh::sr::imask(15); // imask
|
|
||||||
|
|
||||||
serial::string("sr ");
|
|
||||||
serial::integer<uint32_t>(sr);
|
|
||||||
|
|
||||||
asm volatile ("ldc %0,sr"
|
|
||||||
:
|
|
||||||
: "r" (sr));
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,86 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "sh7091/sh7091.hpp"
|
||||||
|
#include "sh7091/sh7091_bits.hpp"
|
||||||
|
#include "sh7091/serial.hpp"
|
||||||
|
#include "sh7091/vbr.hpp"
|
||||||
|
|
||||||
|
#include "systembus.hpp"
|
||||||
|
#include "systembus_bits.hpp"
|
||||||
|
|
||||||
extern int render_done;
|
extern int render_done;
|
||||||
|
|
||||||
void interrupt_init();
|
void interrupt_init();
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void interrupt_exception()
|
||||||
|
{
|
||||||
|
serial::string("expevt ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.EXPEVT);
|
||||||
|
serial::string("intevt ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.INTEVT);
|
||||||
|
serial::string("tra ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.TRA);
|
||||||
|
|
||||||
|
serial::string("istnrm: ");
|
||||||
|
serial::integer<uint32_t>(system.ISTNRM);
|
||||||
|
serial::string("isterr: ");
|
||||||
|
serial::integer<uint32_t>(system.ISTERR);
|
||||||
|
|
||||||
|
uint32_t spc;
|
||||||
|
uint32_t ssr;
|
||||||
|
asm volatile ("stc spc,%0" : "=r" (spc));
|
||||||
|
asm volatile ("stc ssr,%0" : "=r" (ssr));
|
||||||
|
serial::string("spc ");
|
||||||
|
serial::integer(spc);
|
||||||
|
serial::string("ssr ");
|
||||||
|
serial::integer(ssr);
|
||||||
|
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void interrupt_init()
|
||||||
|
{
|
||||||
|
system.IML2NRM = 0;
|
||||||
|
system.IML2ERR = 0;
|
||||||
|
system.IML2EXT = 0;
|
||||||
|
|
||||||
|
system.IML4NRM = 0;
|
||||||
|
system.IML4ERR = 0;
|
||||||
|
system.IML4EXT = 0;
|
||||||
|
|
||||||
|
system.IML6NRM = 0;
|
||||||
|
system.IML6ERR = 0;
|
||||||
|
system.IML6EXT = 0;
|
||||||
|
|
||||||
|
system.ISTERR = 0xffffffff;
|
||||||
|
system.ISTNRM = 0xffffffff;
|
||||||
|
|
||||||
|
sh7091.CCN.INTEVT = 0;
|
||||||
|
sh7091.CCN.EXPEVT = 0;
|
||||||
|
|
||||||
|
uint32_t vbr = reinterpret_cast<uint32_t>(&__vbr_link_start) - 0x100;
|
||||||
|
serial::string("vbr ");
|
||||||
|
serial::integer<uint32_t>(vbr);
|
||||||
|
serial::string("vbr100 ");
|
||||||
|
serial::integer<uint32_t>(reinterpret_cast<uint32_t>(&vbr100));
|
||||||
|
|
||||||
|
asm volatile ("ldc %0,vbr"
|
||||||
|
:
|
||||||
|
: "r" (vbr));
|
||||||
|
|
||||||
|
uint32_t sr;
|
||||||
|
asm volatile ("stc sr,%0"
|
||||||
|
: "=r" (sr));
|
||||||
|
serial::string("sr ");
|
||||||
|
serial::integer<uint32_t>(sr);
|
||||||
|
|
||||||
|
sr &= ~sh::sr::bl; // BL
|
||||||
|
sr &= ~sh::sr::imask(15); // imask
|
||||||
|
|
||||||
|
serial::string("sr ");
|
||||||
|
serial::integer<uint32_t>(sr);
|
||||||
|
|
||||||
|
asm volatile ("ldc %0,sr"
|
||||||
|
:
|
||||||
|
: "r" (sr));
|
||||||
|
}
|
||||||
|
70
tools/texture_memory_allocator.py
Normal file
70
tools/texture_memory_allocator.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import struct
|
||||||
|
|
||||||
|
with open("texture_memory_write_64_read_32.bin", "rb") as f:
|
||||||
|
buf = memoryview(f.read())
|
||||||
|
|
||||||
|
lookup = [
|
||||||
|
struct.unpack("<I", buf[i*4:i*4+4])[0] & 0x7fff_ffff
|
||||||
|
for i in range(8 * 1024 * 1024 // 4)
|
||||||
|
]
|
||||||
|
#for n in lookup:
|
||||||
|
# print(f"{n:08x}")
|
||||||
|
|
||||||
|
allocations = {
|
||||||
|
"isp_tsp_parameters" : (0x11_c000 , 32 ),
|
||||||
|
"object_list" : (0x09_6000 , 32 ),
|
||||||
|
|
||||||
|
"region_array" : (0x01_0000 , 0 ),
|
||||||
|
"framebuffer0" : (0x09_6000 , 0 ),
|
||||||
|
|
||||||
|
"framebuffer1" : (0x09_6000 , 0 ),
|
||||||
|
"framebuffer2" : (0x09_6000 , 0 ),
|
||||||
|
|
||||||
|
"background0" : (0x00_0040 , 32 ),
|
||||||
|
"background1" : (0x00_0040 , 32 ),
|
||||||
|
}
|
||||||
|
|
||||||
|
def gen_allocations():
|
||||||
|
acc = [0x00_0000, 0x40_0000]
|
||||||
|
acc_i = 0
|
||||||
|
|
||||||
|
for name, (size, pad) in allocations.items():
|
||||||
|
start = acc[acc_i]
|
||||||
|
end = start + size - pad
|
||||||
|
yield name, (start, end)
|
||||||
|
acc[acc_i] += size
|
||||||
|
acc_i = int(not acc_i)
|
||||||
|
|
||||||
|
def print_alloc():
|
||||||
|
for name, (start, end) in gen_allocations():
|
||||||
|
print(name, f"{start:06x}", f"{end:06x}")
|
||||||
|
|
||||||
|
print_alloc()
|
||||||
|
|
||||||
|
def allocate_bitmap(mem, lookup, start, end):
|
||||||
|
word_s = start // 4
|
||||||
|
end_s = end // 4
|
||||||
|
for i in range(word_s, end_s):
|
||||||
|
addr64 = lookup[i]
|
||||||
|
assert mem[addr64] == 0, (mem[addr64], i, addr64)
|
||||||
|
mem[addr64] = (1 << 31) | i
|
||||||
|
|
||||||
|
mem64 = [0] * (0x80_0000 // 4)
|
||||||
|
for name, (start, end) in gen_allocations():
|
||||||
|
allocate_bitmap(mem64, lookup, start, end)
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
im = Image.new("RGB", (1024, 2048))
|
||||||
|
width, height = im.size
|
||||||
|
for y in range(height):
|
||||||
|
for x in range(width):
|
||||||
|
color = (255, 128, 0) if mem64[y * 1024 + x] != 0 else (0, 255, 0)
|
||||||
|
im.putpixel((x, y), color)
|
||||||
|
|
||||||
|
im.save("map.png")
|
||||||
|
texture_address = None
|
||||||
|
for i in reversed(range(len(mem64))):
|
||||||
|
if mem64[i] != 0:
|
||||||
|
texture_address = (i + 1) * 4
|
||||||
|
break
|
||||||
|
print(f"texture {texture_address:06x}")
|
Loading…
x
Reference in New Issue
Block a user