Fix intro FLIC brightness, 120/9 fps A/V sync, and authentic INTRO.EXE audio script

This commit is contained in:
Luxferre committed 2026-12-01 16:12:57 +02:00
1 parent 7673e25883
commit 5c2ac8e70f
9 files changed
+264 -38

No files matched your search

+19 -2
View File
@@ -11,6 +11,7 @@
#include "core/vfs.hpp"
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <filesystem>
@@ -263,12 +264,28 @@ int main() {
CHECK(flic.open(vfs));
CHECK(flic.width() == 320 && flic.height() == 200);
CHECK(flic.num_frames() == 548);
int decoded_frames = 0;
CHECK(std::abs(flic.fps() - (120.0f / 9.0f)) < 1e-4f);
CHECK(flic.step_frame());
const std::vector<uint8_t> frame1_rgba = flic.rgba();
uint8_t max_rgb = 0;
for (size_t i = 0; i + 3 < frame1_rgba.size(); i += 4) {
max_rgb = std::max({max_rgb, frame1_rgba[i], frame1_rgba[i + 1], frame1_rgba[i + 2]});
}
CHECK(max_rgb >= 200);
int decoded_frames = 1;
while (flic.step_frame()) {
++decoded_frames;
}
CHECK(decoded_frames == 548);
std::cout << "[PASS] Intro FLIC decoded all " << decoded_frames << " frames\n";
flic.reset();
CHECK(flic.step_frame());
CHECK(flic.current_frame() == 1);
CHECK(flic.rgba() == frame1_rgba);
std::cout << "[PASS] Intro FLIC decoded all " << decoded_frames
<< " frames (fps=" << flic.fps() << ", max_rgb=" << int(max_rgb) << ")\n";
} else {
std::cout << "[INFO] Optional DATA/INTRO.DAT not present; skipping intro FLIC check\n";
}
+35
View File
@@ -299,6 +299,41 @@ int main() {
CHECK(off_st.finite_ok && off_st.rms < 0.001f);
}
// 8. Intro SFX looping & targeted stop commands
{
eng.stop_music();
eng.set_engine_state(false, 0.0f, false, 0.0f);
eng.set_pitstop_state(false, false, 1.0f);
std::vector<float> settle(12000 * 2, 0.0f);
eng.mix_offline(settle.data(), 12000);
// HELEHIT.WAV (0-based idx 5, 0.702s) looped should still sound after 1.0s
eng.play_intro_sfx(5, 0.85f, true);
std::vector<float> first_sec(48000 * 2, 0.0f);
eng.mix_offline(first_sec.data(), 48000);
std::vector<float> quarter_sec(12000 * 2, 0.0f);
eng.mix_offline(quarter_sec.data(), 12000);
BufferStats loop_st = measure_buffer(quarter_sec, "Intro SFX looped (past sample end)");
CHECK(loop_st.finite_ok && loop_st.rms > 0.01f);
eng.stop_intro_sfx(5);
std::vector<float> silence_buf(4800 * 2, 0.0f);
eng.mix_offline(silence_buf.data(), 4800);
BufferStats stop_st = measure_buffer(silence_buf, "Intro SFX targeted stop");
CHECK(stop_st.finite_ok && stop_st.peak == 0.0f);
eng.play_intro_sfx(7, 0.62f, true); // FIRE.WAV
eng.play_intro_sfx(12, 0.62f, true); // SMALLCAR.WAV
eng.mix_offline(quarter_sec.data(), 12000);
BufferStats multi_st = measure_buffer(quarter_sec, "Intro SFX multi-voice loop");
CHECK(multi_st.finite_ok && multi_st.rms > 0.01f);
eng.stop_intro_sfx(-1);
eng.mix_offline(silence_buf.data(), 4800);
BufferStats stop_all_st = measure_buffer(silence_buf, "Intro SFX stop all");
CHECK(stop_all_st.finite_ok && stop_all_st.peak == 0.0f);
}
std::cout << "[PASS] AudioEngine, OPL3 FM, SoundFont SBK, Normalization & Limiter validated\n";
return 0;
}