/* pop_demo — запись level 0: смена команд и прерывание любым вводом. */ #include #include "tcheck.h" #include "pop_demo.h" static int8_t moves[255]; static uint8_t moves_n; static uint8_t any_key; static uint8_t fight_ai; uint8_t hitp_curr; uint8_t pop_demo_kid_ai(void) __banked { return fight_ai; } void pop_ctrl_auto_move(int8_t move) __banked { moves[moves_n++] = move; } uint8_t kbd_raw_any_down(void) { return any_key; } TC_TEST(replays_sdlpop_move_table) { uint8_t done = 0; moves_n = 0; fight_ai = 0; hitp_curr = 4; pop_demo_begin(); TC_FALSE(pop_demo_tick()); TC_EQ(moves_n, 1); TC_EQ(moves[0], 0); /* t=1, запись {0, nothing} */ while (moves_n < 14) { TC_FALSE(pop_demo_tick()); } TC_EQ(moves[1], 1); /* t=2, запись {1, forward} */ TC_EQ(moves[11], 1); /* t=12 всё ещё forward */ TC_EQ(moves[12], 0); /* t=13, запись {0x0D, nothing} */ while (!done) done = pop_demo_tick(); TC_EQ(moves_n, 254); /* SDLPoP останавливает demo_time на FE */ TC_EQ(moves[253], -1); /* хвост после записи {0xE9, -1} */ } TC_TEST(fight_ai_pauses_scripted_moves) { moves_n = 0; fight_ai = 1; hitp_curr = 4; pop_demo_begin(); TC_FALSE(pop_demo_tick()); TC_EQ(moves_n, 0); /* во время боя demo_time не идёт */ fight_ai = 0; TC_FALSE(pop_demo_tick()); TC_EQ(moves_n, 1); TC_EQ(moves[0], 0); /* первый scripted тик не потерян */ } TC_TEST(death_stops_demo_before_combat_ai) { moves_n = 0; fight_ai = 1; hitp_curr = 0; pop_demo_begin(); TC_TRUE(pop_demo_tick()); TC_EQ(moves_n, 0); } TC_TEST(any_raw_key_interrupts_demo) { any_key = 0; TC_FALSE(pop_demo_user_input()); any_key = 1; TC_TRUE(pop_demo_user_input()); } void main(void) { TC_RUN(replays_sdlpop_move_table); TC_RUN(fight_ai_pauses_scripted_moves); TC_RUN(death_stops_demo_before_combat_ai); TC_RUN(any_raw_key_interrupts_demo); }