restore macaw example

This commit is contained in:
Zack Buhman 2024-10-23 08:07:22 -05:00
parent b133879f7e
commit 3bf80b521a
10 changed files with 42 additions and 36 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ scramble
cdi4dc
tools/ttf_outline
tools/ttf_bitmap
tools/ftdi_transfer
k_means_vq
*.blend1
*.scramble

View File

@ -34,7 +34,7 @@ SECTIONS
KEEP(*(.ctors.*))
} > p1ram
.bss ALIGN(4) (NOLOAD) : SUBALIGN(4)
.bss ALIGN(4) (NOLOAD) :
{
*(.bss)
*(.bss.*)

View File

@ -2,7 +2,7 @@ MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
DIR := $(dir $(MAKEFILE_PATH))
LIB ?= .
OPT ?= -O2
OPT ?= -Og
GENERATED ?=
AARCH = --isa=sh4 --little
@ -80,13 +80,13 @@ sine.pcm: common.mk
/=./COPYRIGH.TXT \
/=./ABSTRACT.TXT \
/=./BIBLIOGR.TXT \
/=./REIGN.PCM \
/=./PILLAR.PCM \
/=./RIDDLE.PCM \
/=./PRELUDE.PCM \
/=./CLOCKTOW.PCM \
/=./ELEC.PCM \
/=./ECCLESIA.PCM
/=./pcm/REIGN.PCM \
/=./pcm/PILLAR.PCM \
/=./pcm/RIDDLE.PCM \
/=./pcm/PRELUDE.PCM \
/=./pcm/CLOCKTOW.PCM \
/=./pcm/ELEC.PCM \
/=./pcm/ECCLESIA.PCM
%.cdi: %.iso
./cdi4dc $< $@ >/dev/null

View File

@ -206,14 +206,17 @@ void * memset(void * dest, int c, size_t n)
return dest;
}
static fft::complex comp[samples_per_line * 2];
static fft::complex comp[samples_per_line * 8];
void render_column(int col, int x, const uint32_t * buf)
int render_column(int col, int x, const uint32_t * buf)
{
uint32_t offset = texture_memory_alloc::texture.start + 0;
auto texture = reinterpret_cast<volatile uint32_t *>(&texture_memory64[offset / 4]);
const int16_t * src = &((int16_t *)(buf))[col * samples_per_line * 2];
const int16_t * src = &((int16_t *)(buf))[col * samples_per_line / 2];
if ((src) >= (int16_t*)&buf[(chunk_size - samples_per_line * 2)/4])
return 0; // FIXME: this is a hack
fft::int16_to_complex(src, samples_per_line * 2, comp);
fft::fft(comp, samples_per_line * 2);
for (int32_t y = 0; y < samples_per_line; y++) {
@ -229,24 +232,27 @@ void render_column(int col, int x, const uint32_t * buf)
value |= v << shift;
texture[ix / 4] = value;
}
return 1;
}
void render();
void texture_init();
void aica_step(uint32_t& chunk_index, const uint32_t gdrom_buf[2][chunk_size / 4])
void aica_step(uint32_t& chunk_index, const uint32_t gdrom_buf[2][chunk_size / 4 * 2])
{
{ // wait for interrupt from arm
int col = 0;
while ((system.ISTEXT & (1 << 1)) == 0) {
if (step_time >= 0) {
int32_t dt = step_start - (int32_t)sh7091.TMU.TCNT0;
if (step_time * col / lines_per_chunk < dt) {
render_column(col, __x, gdrom_buf[!chunk_index]);
render();
col += 1;
__x += 1;
if (step_time * col / (lines_per_chunk * 4) < dt) {
int inc = render_column(col, __x, gdrom_buf[!chunk_index]);
col += inc;
__x += inc;
__x %= samples_per_line;
if (col % 2)
render();
}
}
};
@ -362,14 +368,9 @@ uint32_t gdrom_cd_read2(uint16_t * buf,
length += byte_count;
gdrom_read_data(buf, byte_count);
serial::string("status: ");
serial::integer<uint8_t>(gdrom_if.status);
while ((gdrom::status::bsy(gdrom_if.status)) != 0); // wait for drive to become not-busy
}
serial::string("length: ");
serial::integer<uint32_t>(length);
return length;
}
@ -466,7 +467,7 @@ struct extent gdrom_find_file()
serial::string(dr->file_identifier, dr->length_of_file_identifier);
serial::character('\n');
const char filename[] = "ELEC.PCM;1";
const char filename[] = "RIDDLE.PCM;1";
bool equal = str_equal(dr->file_identifier, dr->length_of_file_identifier,
filename, (sizeof (filename)) - 1);
@ -603,7 +604,9 @@ void render()
void main()
{
serial::init(4);
memset(&comp, 0, (sizeof (comp)));
serial::init(0);
holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset;
@ -646,7 +649,7 @@ void main()
gdrom_unlock();
const auto extent = gdrom_find_file();
uint32_t gdrom_buf[2][chunk_size / 4];
uint32_t gdrom_buf[2][(chunk_size / 4) * 2] = {0};
gdrom_read_chunk(gdrom_buf[chunk_index], extent.location + segment_index, sectors_per_chunk);
next_segment(extent, segment_index);

View File

@ -17,7 +17,7 @@
#include "holly/video_output.hpp"
#include "memorymap.hpp"
#include "macaw.hpp"
#include "texture/macaw/macaw.data.h"
struct vertex {
float x;
@ -110,13 +110,13 @@ void init_texture_memory(const struct opb_size& opb_size)
480 / 32, // height
opb_size
);
background_parameter(0xff00ff00);
background_parameter(0xff004400);
}
void copy_macaw_texture()
{
auto src = reinterpret_cast<const uint8_t *>(&_binary_macaw_data_start);
auto size = reinterpret_cast<const uint32_t>(&_binary_macaw_data_size);
auto src = reinterpret_cast<const uint8_t *>(&_binary_texture_macaw_macaw_data_start);
auto size = reinterpret_cast<const uint32_t>(&_binary_texture_macaw_macaw_data_size);
auto texture = reinterpret_cast<volatile uint16_t *>(&texture_memory64[texture_memory_alloc::texture.start / 4]);
for (uint32_t px = 0; px < size / 3; px++) {
uint8_t r = src[px * 3 + 0];

View File

@ -1,4 +1,4 @@
#include <functional>
#include <tuple>
#include "vec.hpp"

View File

@ -1,6 +1,7 @@
#pragma once
#include <utility>
#include "vec2.hpp"
template <int R, int C, typename T>
struct mat;

View File

@ -1,6 +1,7 @@
#pragma once
#include <utility>
#include "vec4.hpp"
template <int R, int C, typename T>
struct mat;

View File

@ -0,0 +1,5 @@
#pragma once
#include <cstdint>
extern uint32_t _binary_texture_macaw_macaw_data_start __asm("_binary_texture_macaw_macaw_data_start");
extern uint32_t _binary_texture_macaw_macaw_data_end __asm("_binary_texture_macaw_macaw_data_end");
extern uint32_t _binary_texture_macaw_macaw_data_size __asm("_binary_texture_macaw_macaw_data_size");

View File

@ -1,5 +0,0 @@
#include <cstdint>
extern uint32_t _binary_macaw_data_start __asm("_binary_macaw_data_start");
extern uint32_t _binary_macaw_data_end __asm("_binary_macaw_data_end");
extern uint32_t _binary_macaw_data_size __asm("_binary_macaw_data_size");