summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/main.cc b/src/main.cc
index fb0b412..75143c0 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -130,12 +130,15 @@ float* generate_tone(float *buffer, float freq) {
int main(int argc, char **argv) {
bool fullscreen_enabled = false;
+ double seek_time = 0.0;
#ifndef STRIP_ALL
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--fullscreen") == 0) {
fullscreen_enabled = true;
- break;
+ } else if (strcmp(argv[i], "--seek") == 0 && i + 1 < argc) {
+ seek_time = atof(argv[i + 1]);
+ i++;
}
}
#else
@@ -166,12 +169,9 @@ int main(int argc, char **argv) {
double last_beat_time = 0.0;
int beat_count = 0;
- while (!platform_should_close()) {
- platform_poll();
-
- double current_time = platform_get_time();
- if (current_time - last_beat_time > SECONDS_PER_BEAT / 2.0) { // 8th notes
- last_beat_time = current_time;
+ auto update_game_logic = [&](double t) {
+ if (t - last_beat_time > SECONDS_PER_BEAT / 2.0) { // 8th notes
+ last_beat_time = t; // Sync to t
const int step = beat_count % 16;
@@ -203,6 +203,34 @@ int main(int argc, char **argv) {
++beat_count;
}
+ };
+
+#ifndef STRIP_ALL
+ if (seek_time > 0.0) {
+ printf("Seeking to %.2f seconds...\n", seek_time);
+
+ // Simulate audio/game logic
+ // We step at ~60hz
+ const double step = 1.0/60.0;
+ for (double t = 0.0; t < seek_time; t += step) {
+ update_game_logic(t);
+ audio_render_silent((float)step);
+ }
+
+ // Simulate Visuals
+ gpu_simulate_until((float)seek_time);
+ }
+#endif
+
+ // Start real audio
+ audio_start();
+
+ while (!platform_should_close()) {
+ platform_poll();
+
+ double current_time = platform_get_time() + seek_time; // Offset logic time
+
+ update_game_logic(current_time);
int width, height;
glfwGetFramebufferSize(platform_get_window(), &width, &height);
@@ -221,4 +249,4 @@ int main(int argc, char **argv) {
gpu_shutdown();
platform_shutdown();
return 0;
-}
+} \ No newline at end of file