#ifndef GAME_BG_H #define GAME_BG_H #include #include "game_state.h" struct BackgroundContext { int bg_main_id = -1; int bg_sub_id = -1; // Fixed-point (8.8) scroll accumulators for smooth 60fps drift uint16_t scroll_main_x_fp = 0; uint16_t scroll_main_y_fp = 0; uint16_t scroll_sub_x_fp = 0; uint16_t scroll_sub_y_fp = 0; // Animation frame counter & timers uint8_t anim_phase = 0; uint16_t anim_phase_fp = 0; // Fixed-point (8.8) phase accumulator uint8_t pulse_timer = 0; // Triggered when an apple is eaten // Cached state to optimize updates bool hard_mode = false; bool is_cursed = false; bool game_over = false; Scene scene = Scene::Menu; }; void bg_setup(BackgroundContext &bg_ctx, int top_console_bg_id, int bottom_console_bg_id); void bg_update(BackgroundContext &bg_ctx, const GameState &state, uint8_t frame); void bg_trigger_pulse(BackgroundContext &bg_ctx); void bg_set_scene(BackgroundContext &bg_ctx, Scene scene, bool hard_mode); #endif // GAME_BG_H