summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-04 22:08:56 +0100
committerskal <pascal.massimino@gmail.com>2026-02-04 22:08:56 +0100
commitdd9d3013d260f27f86b268c203a290f91431d8e5 (patch)
tree7ca8bb5e4c2eb2bff3736992e899e6ce676c6234 /src/main.cc
parent91933ce05ba157dc549d52ed6c00c71c457fca05 (diff)
feat: Optional sequence end times and comprehensive effect documentation
This milestone implements several key enhancements to the sequencing system and developer documentation: ## Optional Sequence End Times (New Feature) - Added support for explicit sequence termination via [time] syntax - Example: SEQUENCE 0 0 [30.0] forcefully ends all effects at 30 seconds - Updated seq_compiler.cc to parse optional [time] parameter with brackets - Added end_time_ field to Sequence class (default -1.0 = no explicit end) - Modified update_active_list() to check sequence end time and deactivate all effects when reached - Fully backward compatible - existing sequences work unchanged ## Comprehensive Effect Documentation (demo.seq) - Documented all effect constructor parameters (standard: device, queue, format) - Added runtime parameter documentation (time, beat, intensity, aspect_ratio) - Created detailed effect catalog with specific behaviors: * Scene effects: HeptagonEffect, ParticlesEffect, Hybrid3DEffect, FlashCubeEffect * Post-process effects: GaussianBlurEffect, SolarizeEffect, ChromaAberrationEffect, ThemeModulationEffect, FadeEffect, FlashEffect - Added examples section showing common usage patterns - Documented exact parameter behaviors (e.g., blur pulsates 0.5x-2.5x, flash triggers at intensity > 0.7, theme cycles every 8 seconds) ## Code Quality & Verification - Audited all hardcoded 1280x720 dimensions throughout codebase - Verified all shaders use uniforms.resolution and uniforms.aspect_ratio - Confirmed Effect::resize() properly updates width_/height_ members - No issues found - dimension handling is fully dynamic and robust ## Files Changed - tools/seq_compiler.cc: Parse [end_time], generate set_end_time() calls - src/gpu/effect.h: Added end_time_, set_end_time(), get_end_time() - src/gpu/effect.cc: Check sequence end time in update_active_list() - assets/demo.seq: Comprehensive syntax and effect documentation - Generated files updated (timeline.cc, assets_data.cc, music_data.cc) This work establishes a more flexible sequencing system and provides developers with clear documentation for authoring demo timelines. handoff(Claude): Optional sequence end times implemented, effect documentation complete, dimension handling verified. Ready for next phase of development.
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/main.cc b/src/main.cc
index 2d630ac..42adf6b 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -12,6 +12,7 @@
#endif
#include "generated/assets.h" // Include generated asset header
#include "gpu/gpu.h"
+#include "gpu/demo_effects.h" // For GetDemoDuration()
#include "platform.h"
#include "util/math.h"
#include <cmath>
@@ -227,6 +228,9 @@ int main(int argc, char** argv) {
int last_width = platform_state.width;
int last_height = platform_state.height;
+ // Get demo duration from sequence file (or -1 if not specified)
+ const float demo_duration = GetDemoDuration();
+
while (!platform_should_close(&platform_state)) {
platform_poll(&platform_state);
@@ -239,6 +243,14 @@ int main(int argc, char** argv) {
double current_time = platform_state.time + seek_time; // Offset logic time
+ // Auto-exit when demo finishes (if duration is specified)
+ if (demo_duration > 0.0f && current_time >= demo_duration) {
+#if !defined(STRIP_ALL)
+ printf("Demo finished at %.2f seconds. Exiting...\n", current_time);
+#endif
+ break;
+ }
+
update_game_logic(current_time);
float aspect_ratio = platform_state.aspect_ratio;
@@ -247,9 +259,21 @@ int main(int argc, char** argv) {
float raw_peak = synth_get_output_peak();
float visual_peak = fminf(raw_peak * 8.0f, 1.0f);
- // float beat = fmodf((float)current_time * DEMO_BPM / 60.0f, 1.0f); // Use
- // tracker BPM
- float beat = fmodf((float)current_time * g_tracker_score.bpm / 60.0f, 1.0f);
+ // Calculate beat information for synchronization
+ float beat_time = (float)current_time * g_tracker_score.bpm / 60.0f;
+ int beat_number = (int)beat_time;
+ float beat = fmodf(beat_time, 1.0f); // Fractional part (0.0 to 1.0)
+
+#if !defined(STRIP_ALL)
+ // Print beat/time info periodically for identifying sync points
+ static float last_print_time = -1.0f;
+ if (current_time - last_print_time >= 0.5f) { // Print every 0.5 seconds
+ printf("[T=%.2f, Beat=%d, Frac=%.2f, Peak=%.2f]\n",
+ (float)current_time, beat_number, beat, visual_peak);
+ last_print_time = (float)current_time;
+ }
+#endif /* !defined(STRIP_ALL) */
+
gpu_draw(visual_peak, aspect_ratio, (float)current_time, beat);
audio_update();
}