// SPDX-License-Identifier: GPL-3.0-only // Interface of the Reality scene motion layer: figure motion and path types, grid and the // functions of reality_motion.cpp. Deliberately independent of GameState and both generators. #pragma once #include #include #include #include "formats/le.hpp" namespace bmh { // RealityFieldScreen consumes positions chosen by the Reality simulation. This owned // input is deliberately independent of GameState and both random generators. struct RealityFigureMotion { bool active = false; int old_x = 0, old_y = 0, next_x = 0, next_y = 0; uint8_t phase = 0; bool operator==(const RealityFigureMotion&) const = default; }; struct RealityMotionInput { std::array figures{}; // 22 players, shadow, ball bool ball_airborne = false; bool numbers = true; // Source RealityMatch_FormatError_ExecutableField == 0 bool operator==(const RealityMotionInput&) const = default; }; struct RealityMotionSprite { int figure = 0, x = 0, y = 0, cell = 0, number = 0; bool away_palette = false; bool operator==(const RealityMotionSprite&) const = default; }; struct RealityMotionFrame { std::array sprites{}; size_t count = 0; bool operator==(const RealityMotionFrame&) const = default; }; struct RealityMotionResult { std::array frames{}; std::array phases_after{}; bool operator==(const RealityMotionResult&) const = default; }; // RealityDirection / Int7. Coordinates use the original 43 by 25 Reality grid. int reality_direction(int x, int y); std::pair reality_project(const LeImage&, int x, int y); RealityMotionResult reality_motion(const RealityMotionInput&, const LeImage&); struct RealityPath { std::array, 51> points{}; size_t count = 0; bool operator==(const RealityPath&) const = default; }; // RealityPath's integer line, including both endpoints. The goal helper uses the // Source's three goal-mouth target rows (11, 12, 13). RealityPath reality_path(int x, int y, int target_x, int target_y); RealityPath reality_goal_path(int x, int y, int goal_x); // Place. Each side has its own occupancy plane: opponents may share a cell, // teammates may not. Ball placement records the previous cell without occupying // either player plane. This is runtime scene state, not a Native save extension. class RealityGrid { public: bool place(int figure, int x, int y, int side); void clear(int x, int y, int side); // caller clears old occupancy before a move void reset_occupancy(); // Source initialization preserves old figure/ball data bool operator==(const RealityGrid&) const = default; void stage_position(int figure, int x, int y); // afb0c/afb23 before occupancy is committed uint8_t occupant(int x, int y, int side) const; std::pair position(int figure) const; std::pair ball() const { return ball_; } std::pair previous_ball() const { return previous_ball_; } private: std::array, 2> occupied_{}; std::array, 24> positions_{}; std::pair ball_{}, previous_ball_{}; }; // Source scene globals persist across matchdays, but are not Native FBM data. struct RealityResidue { bool initialized = false, deflected = false; uint8_t card_kind = 0; int distance = 0; std::array cue_actors{}; RealityGrid grid; bool operator==(const RealityResidue&) const = default; }; } // namespace bmh