diff --git a/.gitignore b/.gitignore index e54c2d1..6a10363 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ scramble cdi4dc tools/ttf_outline tools/ttf_bitmap +tools/ftdi_transfer k_means_vq *.blend1 *.scramble diff --git a/common.lds b/common.lds index 767f014..e1deb4e 100644 --- a/common.lds +++ b/common.lds @@ -34,7 +34,7 @@ SECTIONS KEEP(*(.ctors.*)) } > p1ram - .bss ALIGN(4) (NOLOAD) : SUBALIGN(4) + .bss ALIGN(4) (NOLOAD) : { *(.bss) *(.bss.*) diff --git a/common.mk b/common.mk index c464027..bb490b9 100644 --- a/common.mk +++ b/common.mk @@ -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 diff --git a/example/aica_gdrom_dft.cpp b/example/aica_gdrom_dft.cpp index 6d85145..9ff76f1 100644 --- a/example/aica_gdrom_dft.cpp +++ b/example/aica_gdrom_dft.cpp @@ -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(&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(gdrom_if.status); - while ((gdrom::status::bsy(gdrom_if.status)) != 0); // wait for drive to become not-busy } - serial::string("length: "); - serial::integer(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); diff --git a/example/macaw.cpp b/example/macaw.cpp index bf122e2..0747173 100644 --- a/example/macaw.cpp +++ b/example/macaw.cpp @@ -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(&_binary_macaw_data_start); - auto size = reinterpret_cast(&_binary_macaw_data_size); + auto src = reinterpret_cast(&_binary_texture_macaw_macaw_data_start); + auto size = reinterpret_cast(&_binary_texture_macaw_macaw_data_size); auto texture = reinterpret_cast(&texture_memory64[texture_memory_alloc::texture.start / 4]); for (uint32_t px = 0; px < size / 3; px++) { uint8_t r = src[px * 3 + 0]; diff --git a/math/geometry.hpp b/math/geometry.hpp index 5d02711..36d50e3 100644 --- a/math/geometry.hpp +++ b/math/geometry.hpp @@ -1,4 +1,4 @@ -#include +#include #include "vec.hpp" diff --git a/math/mat2x2.hpp b/math/mat2x2.hpp index 442ed88..008ca2b 100644 --- a/math/mat2x2.hpp +++ b/math/mat2x2.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include "vec2.hpp" template struct mat; diff --git a/math/mat4x4.hpp b/math/mat4x4.hpp index 1a5c25e..ca8a989 100644 --- a/math/mat4x4.hpp +++ b/math/mat4x4.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include "vec4.hpp" template struct mat; diff --git a/texture/macaw/macaw.data.h b/texture/macaw/macaw.data.h new file mode 100644 index 0000000..f98c35e --- /dev/null +++ b/texture/macaw/macaw.data.h @@ -0,0 +1,5 @@ +#pragma once +#include +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"); diff --git a/texture/macaw/macaw.hpp b/texture/macaw/macaw.hpp deleted file mode 100644 index b1b58c9..0000000 --- a/texture/macaw/macaw.hpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -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");