pcm: add start3

This commit is contained in:
Zack Buhman 2025-06-29 12:11:59 -05:00
parent d69b2245b8
commit 4f6fbe2484
14 changed files with 154 additions and 52 deletions

BIN
pcm/start3.adpcm Normal file

Binary file not shown.

15
pcm/start3.adpcm.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
extern uint32_t _binary_pcm_start3_adpcm_start __asm("_binary_pcm_start3_adpcm_start");
extern uint32_t _binary_pcm_start3_adpcm_end __asm("_binary_pcm_start3_adpcm_end");
extern uint32_t _binary_pcm_start3_adpcm_size __asm("_binary_pcm_start3_adpcm_size");
#ifdef __cplusplus
}
#endif

BIN
pcm/start3.pcm Normal file

Binary file not shown.

BIN
pcm/start3.wav Normal file

Binary file not shown.

View File

@ -45,6 +45,7 @@ namespace cursor {
float dy = static_cast<float>(data.analog_coordinate_axis[3] - 0x80) * 0.015; float dy = static_cast<float>(data.analog_coordinate_axis[3] - 0x80) * 0.015;
state[port_ix].x += dx; state[port_ix].x += dx;
state[port_ix].y += dy; state[port_ix].y += dy;
state[port_ix].a = ft0::data_transfer::digital_button::a(data.digital_button) == 0; state[port_ix].a = ft0::data_transfer::digital_button::a(data.digital_button) == 0;
state[port_ix].b = ft0::data_transfer::digital_button::b(data.digital_button) == 0; state[port_ix].b = ft0::data_transfer::digital_button::b(data.digital_button) == 0;

View File

@ -126,7 +126,10 @@ void graphics_cursor(ta_multiwriter& multi)
para_control::list_type::opaque, para_control::list_type::opaque,
tsp_instruction_word::dst_alpha_instr::zero); tsp_instruction_word::dst_alpha_instr::zero);
const cursor::cursor& c = cursor::state[0]; for (int i = 0; i < 4; i++) {
const cursor::cursor& c = cursor::state[i];
if (!c.active)
continue;
quad_type_0(multi.op, quad_type_0(multi.op,
{c.x - 1, c.y - 1, 10}, {c.x - 1, c.y - 1, 10},
@ -134,6 +137,7 @@ void graphics_cursor(ta_multiwriter& multi)
{c.x + 1, c.y + 1, 10}, {c.x + 1, c.y + 1, 10},
{c.x - 1, c.y + 1, 10}, {c.x - 1, c.y + 1, 10},
0xffffff); 0xffffff);
}
} }
void graphics_event(ta_multiwriter& multi) void graphics_event(ta_multiwriter& multi)

View File

@ -208,6 +208,9 @@ void execute_line(int line_index)
void interrupt() void interrupt()
{ {
if (state.paused)
return;
state.interrupt_clock += 1; state.interrupt_clock += 1;
// execute keyons // execute keyons
for (int ch = 0; ch < 64; ch++) { for (int ch = 0; ch < 64; ch++) {
@ -298,4 +301,20 @@ void init(float clock_multiplier)
printf("tick_rate %d\n", state.tick_rate); printf("tick_rate %d\n", state.tick_rate);
} }
void pause()
{
state.tmp_paused = state.paused;
state.paused = true;
}
void unpause()
{
state.paused = false;
}
void resume()
{
state.paused = state.tmp_paused;
}
} }

View File

@ -21,6 +21,8 @@ struct interpreter_state {
int pattern_index; int pattern_index;
int line_index; int line_index;
int next_line_index; // within the current pattern int next_line_index; // within the current pattern
bool paused;
bool tmp_paused;
struct xm_state xm; struct xm_state xm;
@ -30,5 +32,7 @@ struct interpreter_state {
extern struct interpreter_state state; extern struct interpreter_state state;
void interrupt(); void interrupt();
void init(float clock_multiplier); void init(float clock_multiplier);
void pause();
void unpause();
} }

View File

@ -9,9 +9,6 @@
#include "cursor.hpp" #include "cursor.hpp"
#include "input.hpp" #include "input.hpp"
#include "xm/milkypack01.xm.h"
#include "xm.h"
void vbr100() void vbr100()
{ {
serial::string("vbr100\n"); serial::string("vbr100\n");
@ -59,24 +56,6 @@ void vbr600()
asm volatile ("ldc %0,sr" : : "r" (sr)); asm volatile ("ldc %0,sr" : : "r" (sr));
} }
void load_xm(float clock_multiplier)
{
using namespace interpreter;
int buf = (int)&_binary_xm_milkypack01_xm_start;
static uint8_t __attribute__((aligned(32))) sample_data[1024 * 1024 * 2];
const int sample_data_length = (sizeof (sample_data));
int sample_data_ix = xm_init(&state.xm,
buf,
sample_data,
sample_data_length);
interpreter::init(clock_multiplier);
sound::transfer(sample_data, sample_data_ix);
printf("tick_rate %d\n", state.tick_rate);
}
#include "memorymap.hpp" #include "memorymap.hpp"
#include "holly/texture_memory_alloc9.hpp" #include "holly/texture_memory_alloc9.hpp"
#include "holly/holly.hpp" #include "holly/holly.hpp"
@ -119,9 +98,6 @@ void main()
input::state_init(); input::state_init();
cursor::init(); cursor::init();
const float aica_clock_multiplier = 44.1;
load_xm(aica_clock_multiplier);
//test_pattern(); //test_pattern();
interrupt_init(); interrupt_init();

34
src/playlist.cpp Normal file
View File

@ -0,0 +1,34 @@
#include "xm.h"
#include "xm/milkypack01.xm.h"
const float aica_clock_multiplier = 44.1;
namespace playlist {
static playlist_item playlist[] = {
{
"milkypack01"
}
};
void load_xm(float clock_multiplier, int buf)
{
using namespace interpreter;
static uint8_t __attribute__((aligned(32))) sample_data[1024 * 1024 * 2];
const int sample_data_length = (sizeof (sample_data));
interpreter::pause();
int sample_data_ix = xm_init(&state.xm,
buf,
sample_data,
sample_data_length);
interpreter::init(clock_multiplier);
sound::transfer(sample_data, sample_data_ix);
//printf("tick_rate %d\n", state.tick_rate);
interpreter::resume();
}
}

6
src/playlist.hpp Normal file
View File

@ -0,0 +1,6 @@
namespace playlist {
struct playlist_item {
const char * const name;
const int start;
};
}

View File

@ -32,7 +32,27 @@ static inline float light_intensity(vec3 n, vec3 l)
vec3 light_vec = (vec3){-1, -1, -1} - (vec3){0, 0, 0}; vec3 light_vec = (vec3){-1, -1, -1} - (vec3){0, 0, 0};
static void render_mesh(ta_parameter_writer& writer, const mesh& mesh, const mat4x4& trans, float base_intensity, bool wireframe) using vec3i = vec<3, int>;
static inline vec3i color_lerp(const vec3i& a, const vec3i& b, float f)
{
float dr = b.x - a.x;
float dg = b.y - a.y;
float db = b.z - a.z;
return {
(int)((float)a.x + dr * f),
(int)((float)a.y + dg * f),
(int)((float)a.z + db * f),
};
}
static inline int vec3i_to_int(const vec3i& a)
{
return (a.x << 16) | (a.y << 8) | (a.z << 0);
}
static void render_mesh(ta_parameter_writer& writer, const mesh& mesh, const mat4x4& trans, float base_intensity, bool wireframe, bool diffuse)
{ {
if (wireframe) { if (wireframe) {
global_polygon_untextured(writer, global_polygon_untextured(writer,
@ -58,7 +78,12 @@ static void render_mesh(ta_parameter_writer& writer, const mesh& mesh, const mat
normal_cache[i] = normal_multiply(trans, mesh.polygon_normal[i]); normal_cache[i] = normal_multiply(trans, mesh.polygon_normal[i]);
} }
const int green = (int)(255.f * base_intensity) << 8; const vec3i white = vec3i(0xc0, 0xbe, 0xbc);
const vec3i green = vec3i(0x33, 0xd1, 0x7a);
const int wireframe_color = vec3i_to_int(color_lerp(white, green, base_intensity));
//const int green = (int)(255.f * base_intensity) << 8;
for (int i = 0; i < mesh.polygons_length; i++) { for (int i = 0; i < mesh.polygons_length; i++) {
const polygon& p = mesh.polygons[i]; const polygon& p = mesh.polygons[i];
@ -69,13 +94,13 @@ static void render_mesh(ta_parameter_writer& writer, const mesh& mesh, const mat
vec3 dp = position_cache[p.d]; vec3 dp = position_cache[p.d];
if (wireframe) { if (wireframe) {
line_type_0(writer, ap, bp, green); line_type_0(writer, ap, bp, wireframe_color);
line_type_0(writer, bp, cp, green); line_type_0(writer, bp, cp, wireframe_color);
if (p.d == -1) { if (p.d == -1) {
line_type_0(writer, cp, ap, green); line_type_0(writer, cp, ap, wireframe_color);
} else { } else {
line_type_0(writer, cp, dp, green); line_type_0(writer, cp, dp, wireframe_color);
line_type_0(writer, dp, ap, green); line_type_0(writer, dp, ap, wireframe_color);
} }
} else { } else {
vec2 at = mesh.uv_layers[0][p.uv_index + 0]; vec2 at = mesh.uv_layers[0][p.uv_index + 0];
@ -83,7 +108,7 @@ static void render_mesh(ta_parameter_writer& writer, const mesh& mesh, const mat
vec2 ct = mesh.uv_layers[0][p.uv_index + 2]; vec2 ct = mesh.uv_layers[0][p.uv_index + 2];
vec2 dt = mesh.uv_layers[0][p.uv_index + 3]; vec2 dt = mesh.uv_layers[0][p.uv_index + 3];
float intensity = light_intensity(normal_cache[i], light_vec); float intensity = diffuse ? light_intensity(normal_cache[i], light_vec) : 1.0;
if (p.d == -1) { if (p.d == -1) {
tri_type_7(writer, tri_type_7(writer,
@ -139,19 +164,19 @@ namespace scene::logo {
.rx = 0, .rx = 0,
.ry = pi, .ry = pi,
.s = 0.01, .s = 0.01,
.duration = 1.0 / (5.2 * 60), .duration = 1.0 / (3.670 * 60),
}, },
{ {
.i = 1, .i = 1,
.rx = 0, .rx = 0,
.ry = pi, .ry = pi,
.s = 0.1, .s = 0.1,
.duration = 1.0 / (4.5 * 60), .duration = 1.0 / (10.988 * 60),
}, },
{ {
.i = 1, .i = 1,
.rx = pi / 4, .rx = pi / 4,
.ry = pi + pi / 4, .ry = -(pi - pi / 4),
.s = 0.7, .s = 0.7,
.duration = 1.0 / (10 * 60), .duration = 1.0 / (10 * 60),
}, },
@ -215,10 +240,16 @@ namespace scene::logo {
* rotate_y(k.ry) * rotate_y(k.ry)
* scale((vec3){-1, -1, 1}); * scale((vec3){-1, -1, 1});
render_mesh(multi.op, mesh_thirty_two, trans, k.i, tick < (9.85 * 60)); bool _32_wf = tick < (10.988 * 60);
bool bit_wf = tick < (11.908 * 60);
bool jam_wf = tick < (12.825 * 60);
bool diffuse = tick >= (14.608 * 60);
render_mesh(multi.op, mesh_thirty_two, trans, k.i, _32_wf, diffuse);
if (keyframe_ix > 0) { if (keyframe_ix > 0) {
render_mesh(multi.op, mesh_bit, trans, k.i, tick < (10.85 * 60)); render_mesh(multi.op, mesh_bit, trans, k.i, bit_wf, diffuse);
render_mesh(multi.op, mesh_jam, trans, k.i, tick < (11.85 * 60)); render_mesh(multi.op, mesh_jam, trans, k.i, jam_wf, diffuse);
} }
tick += 1; tick += 1;

View File

@ -2,16 +2,21 @@
#include "../../sound.hpp" #include "../../sound.hpp"
#include "scene/logo/sound.hpp" #include "scene/logo/sound.hpp"
#include "pcm/jingle.adpcm.h" #include "pcm/jingle.adpcm.h"
#include "pcm/start3.adpcm.h"
#include "printf/printf.h" #include "printf/printf.h"
namespace scene::logo::sound { namespace scene::logo::sound {
const static void * start = reinterpret_cast<void *>(&_binary_pcm_jingle_adpcm_start); //const static void * start = reinterpret_cast<void *>(&_binary_pcm_jingle_adpcm_start);
const static int size = reinterpret_cast<int>(&_binary_pcm_jingle_adpcm_size); //const static int size = reinterpret_cast<int>(&_binary_pcm_jingle_adpcm_size);
const static void * start = reinterpret_cast<void *>(&_binary_pcm_start3_adpcm_start);
const static int size = reinterpret_cast<int>(&_binary_pcm_start3_adpcm_size);
const static int sample_count = size * 2; const static int sample_count = size * 2;
const static int loop_length = 65528; const static int loop_length = 65528;
const static int segment_count = sample_count / loop_length; const static int segment_count = sample_count / loop_length;
const static int last_loop = (sample_count % loop_length) & (~0b11);
void init() void init()
{ {
@ -31,7 +36,7 @@ namespace scene::logo::sound {
wait(); aica_sound.channel[0].RR(0x1f); wait(); aica_sound.channel[0].RR(0x1f);
wait(); aica_sound.channel[0].AR(0x1f); wait(); aica_sound.channel[0].AR(0x1f);
wait(); aica_sound.channel[0].OCT(0); wait(); aica_sound.channel[0].OCT(-1);
wait(); aica_sound.channel[0].FNS(0); wait(); aica_sound.channel[0].FNS(0);
wait(); aica_sound.channel[0].DISDL(0xf); wait(); aica_sound.channel[0].DISDL(0xf);
wait(); aica_sound.channel[0].DIPAN(0x0); wait(); aica_sound.channel[0].DIPAN(0x0);
@ -43,6 +48,7 @@ namespace scene::logo::sound {
void interrupt() void interrupt()
{ {
static int segment = 0; static int segment = 0;
static bool last = false;
wait(); wait();
int lp_sgc_eg = aica_sound.common.lp_sgc_eg; int lp_sgc_eg = aica_sound.common.lp_sgc_eg;
@ -60,9 +66,15 @@ namespace scene::logo::sound {
if (aica::lp_sgc_eg::LP(lp_sgc_eg)) { if (aica::lp_sgc_eg::LP(lp_sgc_eg)) {
segment += 1; segment += 1;
if (segment >= segment_count) { if (segment >= segment_count) {
if (last || last_loop == 0) {
wait(); aica_sound.channel[0].KYONB(0); wait(); aica_sound.channel[0].KYONB(0);
wait(); aica_sound.channel[0].KYONEX(1); wait(); aica_sound.channel[0].KYONEX(1);
return; return;
} else {
printf("last loop\n", segment);
last = true;
wait(); aica_sound.channel[0].LEA(last_loop);
}
} }
printf("loop %d\n", segment); printf("loop %d\n", segment);

View File

@ -6,7 +6,7 @@ TEXTURE_OBJ = \
model/32bitlogo/colors.data.o model/32bitlogo/colors.data.o
PCM_OBJ = \ PCM_OBJ = \
pcm/jingle.adpcm.o pcm/start3.adpcm.o
XM_PLAYER_OBJ = \ XM_PLAYER_OBJ = \
$(LIB)/holly/core.o \ $(LIB)/holly/core.o \