Accedi
IT
games/sorcery / src / Game / Values.php · commit 613f5fb
<?phpnamespace App\Game;/** The numbers of Sorcery+ as measured in the original program (see the port's MODERN.md). */final class Values{    public const MAP_W = 40;    public const MAP_H = 18;    public const TILE_W = 4;    public const TILE_H = 8;    public const FIELD_W = self::MAP_W * self::TILE_W;   // 160 mode-0 pixels (drawn 2 screen px wide)    public const FIELD_H = self::MAP_H * self::TILE_H;   // 144 lines    public const SPRITE_W = 12;    public const SPRITE_H = 24;    public const ROOM_COUNT = 79;    public const NONE = 0xFF;    public const ROOM_BOSS = 0x1C;    public const ROOM_THRONE = 0x46;    public const ROOM_LABYRINTH = 0x3D;    /** item that opens lock type 1..5 (type 6 never opens) */    public const LOCK_KEY = [0x3B, 0x2B, 0x29, 0x38, 0x44];    public const HIT_Y = 0x12;    public const HIT_X = 9;    public const ENERGY_STEP = 0x32;    public const FLOOR_ROWS = 0x70;    public const BAR_TOTAL = 40 * 64;    public const LAMP_TICKS = 6750;    public const LAMP_MAX = 13500;    // entity kinds (the numbering of the room files)    public const K_EMERGE = 0;    public const K_CHASER = 1;    public const K_WALKER = 2;    public const K_DIVER = 3;    public const K_PATROL = 4;    public const K_FOLLOWER = 5;    public const K_MAGIC_ITEM = 6;    public const K_ITEM_RISING = 7;    public const K_EXPLODING = 8;    public const K_REMAINS = 9;    public const K_FALLING_ITEM = 0x20;    public const K_LANDING = 0x21;    public const K_GROWING_ITEM = 0x22;    public const K_SPELL_RING = 0x23;    public const K_SPELL_CROSS = 0x24;    public const K_REWARD = 0x25;    public const K_REWARD_SHRINK = 0x26;    public const K_REWARD_SPARKLE = 0x27;    public const K_VANISH = 0x28;    public const K_WAIT_SORCERER = 0x29;    public const K_SHOW_SORCERER = 0x2A;    public const K_LAST_FRAME = 0x2B;    public const K_DELAY_ALARM = 0x2C;    public const K_FOLLOW_SCRIPT = 0x2D;    public const K_TIMER_RESTORE = 0x2E;    public const K_FRAME_RESTORE = 0x2F;    public const K_SCENE_1 = 0x30;    public const K_SCENE_2 = 0x31;    public const K_SCENE_3 = 0x32;    public const K_SCENE_4 = 0x33;    public const K_SCENE_5 = 0x34;    public const K_ADVANCE = 0x35;    public const K_FADE_OUT = 0x36;    public const K_NONE = 0x7F;    // player states    public const P_WAIT = 0;    public const P_MATERIALISE = 1;    public const P_FLY = 2;    public const P_FALL = 3;    public const P_DYING = 4;    public const P_SPLASH = 5;    public const P_SINK = 6;    public const P_WAIT2 = 7;    // input bits    public const IN_UP = 1;    public const IN_DOWN = 2;    public const IN_LEFT = 4;    public const IN_RIGHT = 8;    public const IN_ACTION = 0x10;    public const IN_FIRE1 = 0x20;    public const IN_CHEAT = 0x40;    // end reasons    public const END_DROWNED = 1;    public const END_NO_ENERGY = 2;    public const END_NO_TIME = 4;    public const END_WON = 0x40;    public const END_FINISHED = 0x80;    // map cell classes    public const C_EMPTY = 0;    public const C_ANIM = 0x01;    public const C_FIRE = 0x02;    public const C_SOLID = 0x80;    public const C_RIVER = 0x81;    public static function u8(int $v): int    {        return $v & 0xFF;    }    /** |a - b| <= range, written as the original did it with 8 bit wrap-around. */    public static function within(int $a, int $b, int $range): bool    {        return self::u8($a - $b + $range) < 2 * $range + 1;    }}