// SPDX-License-Identifier: GPL-3.0-only #include "test_inputs.hpp" #include "ui/game_end_tax_animation.hpp" #include #include #include #include #include using namespace bmh; using namespace bmh::ui; namespace { void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); } void rejected(const std::function& action) { try { action(); } catch (const FormatError&) { return; } throw std::runtime_error("expected malformed animation rejection"); } // Independent native-script expectations are supplied externally; no game-script bytes are embedded. void original_copy(Image& out, const Image& source, unsigned sx, unsigned sy, unsigned dx, unsigned dy, unsigned width, unsigned height) { for (unsigned row=0; row"); if (!*argv[1]) { std::cout << "Original asset test skipped: BMH_DATA not configured\n"; return 77; } const auto assets=load_game_end_tax_animation_assets(argv[1]); check(assets.art.width==248 && assets.art.height==69 && assets.background.width==318 && assets.background.height==207,"configured Original KB17/56 dimensions"); const auto script = read_file(bmh::test::external_input("tax-animation-script.bin")); check(script.size() == 33, "external animation expectation has four complete records"); const auto decoded=decode_tax_animation_script(script); std::array rectangles; std::array ticks, offsets; std::array copy_after_present; for (size_t i = 0; i < 4; ++i) { const auto at = i * 8; rectangles[i] = {script[at+1],script[at+2],script[at+3],script[at+4],script[at+5],script[at+6]}; ticks[i] = script[at+7] > 100 ? script[at+7]-100 : script[at+7]; offsets[i] = unsigned(at+7); copy_after_present[i] = script[at+7] <= 100; } check(assets.steps.size()==4 && decoded.size()==4,"four wait markers define four variants"); for (unsigned i=0; i<4; ++i) { check(assets.steps[i].copies==std::vector{rectangles[i]} && assets.steps[i].wait_ticks==ticks[i] && assets.steps[i].script_offset==offsets[i] && assets.steps[i].copy_after_present==copy_after_present[i],"exact EXE record/wait/presentation sequence"); check(decoded[i].copies==assets.steps[i].copies && decoded[i].wait_ticks==ticks[i] && decoded[i].copy_after_present==copy_after_present[i],"fixed-size script decoding"); } constexpr std::array field255{0,255,0,1,2,3,4,101,255}; const auto field=decode_tax_animation_script(field255); check(field.size()==1 && field[0].copies[0].source_x==255 && field[0].wait_ticks==1 && !field[0].copy_after_present,"255 in rectangle is data,101 is flip-only wait1"); constexpr std::array boundary{100,101,255}; const auto waits=decode_tax_animation_script(boundary); check(waits.size()==2 && waits[0].wait_ticks==100 && waits[0].copy_after_present && waits[1].wait_ticks==1 && !waits[1].copy_after_present,"Source marker100/101 boundary"); rejected([&]{decode_tax_animation_script(std::array{0,1});}); rejected([&]{decode_tax_animation_script(std::array{40});}); std::cout<<"EXE a5118 four rectangles/waits, fixed-length fields and100/101 boundary OK\n"; const Image backdrop(320,240,3); std::array milliseconds{},totals{}; for(size_t i=0;i expected, expected_working; auto base=original_frame(backdrop,assets.background,flat); auto visible=backdrop,working=base; for(size_t i=0;i