#pragma once

#include <grrlib.h>
#include "player.h"
#include "math.h"
#include "level_loading.h"
#include "animation.h"

#define BACKGROUND_SCALE 0.9
#define BG_DIMENSIONS 4
#define BG_CHUNK ((1024/BG_DIMENSIONS) * BACKGROUND_SCALE)

#define FADE_WIDTH 75

#define FADING_OBJ_WIDTH 180
#define FADING_OBJ_PADDING 90

enum Objects {
    PLAYER_OBJECT,
    BASIC_BLOCK,
    CHECKER_EDGE,
    CHECKER_CORNER,
    CHECKER_INS_CORNER,
    CHECKER_FILLER,
    CHECKER_PILLAR_END,
    CHECKER_PILLAR,
    SPIKE,
    GROUND_SPIKE,
    BLUE_GRAVITY_PORTAL,
    YELLOW_GRAVITY_PORTAL,
    CUBE_PORTAL,
    SHIP_PORTAL,
    UNKNOWN_14,
    ROD_BIG,
    ROD_MEDIUM,
    ROD_SMALL,
    DECO_SPIKES_BIG,
    DECO_SPIKES_MEDIUM,
    DECO_SPIKES_SMALL,
    DECO_SPIKES_TINY,
    TRIGGER_FADE_NONE,
    TRIGGER_FADE_UP,
    TRIGGER_FADE_DOWN,
    TRIGGER_FADE_LEFT,
    TRIGGER_FADE_RIGHT,
    TRIGGER_FADE_SCALE_IN,
    TRIGGER_FADE_SCALE_OUT,
    BG_TRIGGER,
    GROUND_TRIGGER,
    START_POS,
    ENABLE_TRAIL,
    DISABLE_TRAIL,
    FAKE_STARTPOS,
    YELLOW_PAD,
    YELLOW_ORB,
    UNKNOWN_37,
    UNKNOWN_38,
    HALF_SPIKE,
    SLAB,
    CHAINS,
    UNKNOWN_42,
    UNKNOWN_43,
    UNKNOWN_44,

    ORANGE_MIRROR_PORTAL,
    BLUE_MIRROR_PORTAL,

    BALL_PORTAL,

    D_CLOUD_BIG,
    D_CLOUD_SMALL,

    PULSING_CIRCLE,
    PULSING_CIRCUNFERENCE,
    PULSING_HEART,
    PULSING_DIAMOND,
    PULSING_STAR,

    TRIGGER_FADE_CIRCLE,
    TRIGGER_FADE_LEFT_SEMICIRCLE,
    TRIGGER_FADE_RIGHT_SEMICIRCLE,
    TRIGGER_FADE_INWARDS,
    TRIGGER_FADE_OUTWARDS,

    PULSING_NOTE,

    WAVY_GROUND_SPIKE,

    S13_SLAB,
    S13_CORNER,
    S13_INSIDE_CORNER,
    S13_RIGHT_EDGE,
    S13_LEFT_EDGE,

    BLUE_PAD,

    S13_UNIT,

    B13_FULL,
    B13_EDGE,
    B13_CORNER,
    B13_INS_CORNER,
    B13_FILLER,
    B13_PILLAR_END,
    B13_PILLAR,

    B14_FULL,
    B14_EDGE,
    B14_CORNER,
    B14_INS_CORNER, // Actually unused slot in the game
    B14_FILLER,
    B14_PILLAR_END,
    B14_PILLAR,

    CHECKER_FULL,
    BLUE_ORB,

    SAW_DECO_BIG,
    SAW_DECO_MEDIUM,
    SAW_DECO_SMALL,

    SAW_BIG,
    SAW_MEDIUM,

    BLACK_FULL,
    BLACK_EDGE,
    BLACK_CORNER,
    BLACK_INS_CORNER,
    BLACK_FILLER,
    BLACK_PILLAR_END,
    BLACK_PILLAR,

    SAW_DECO_TINY,
    SAW_SMALL,

    BIG_PORTAL,
    UNKNOWN_100,
    MINI_PORTAL,
    UNKNOWN_102,

    MEDIUM_SPIKE,

    LINE_TRIGGER,
    OBJ_TRIGGER,

    C15_P2_BIG,
    C15_P2_SMALL,
    UNKNOWN_108,
    UNKNOWN_109,
    C15_P1_SMALL,
    
    UFO_PORTAL,

    UNKNOWN_112,

    SQUARE_SPIKES_BIG,
    SQUARE_SPIKES_MEDIUM,
    SQUARE_SPIKES_SMALL,

    BRICKS_FULL,
    BRICKS_EDGE,
    BRICKS_CORNER,
    BRICKS_INS_CORNER,
    BRICKS_FILLER,
    BRICKS_PILLAR_END,
    BRICKS_PILLAR,

    THORN_01,
    THORN_02,
    THORN_03,
    THORN_04,
    THORN_05,
    THORN_06,

    CLOUD_DECO_MEDIUM,
    CLOUD_DECO_BIG,
    CLOUD_DECO_SMALL,

    D_ARROW,
    D_EXMARK,
    DIAMOND_DECO_SMALL,
    BUSH_GROUND_SPIKE,
    D_QMARK,
    
    WHEEL_BIG,
    WHEEL_MEDIUM,
    WHEEL_SMALL,

    PINK_PAD,
    PINK_ORB,

    SECRET_COIN,
    BREAKABLE_BLOCK,

    FADING_SPIKE,
    FADING_MEDIUM_SPIKE,
    FADING_BLOCK,
    FADING_SLAB,

    PULSING_SQUARE,
    PULSING_TRIANGLE,
    D_CROSS,
    
    SPIKEART_BIG,
    SPIKEART_MEDIUM,
    SPIKEART_SMALL,

    SPIKEWHEEL_BIG,
    SPIKEWHEEL_MEDIUM,
    SPIKEWHEEL_SMALL,

    WAVE_CENTER,
    WAVE_LEFT,
    WAVE_RIGHT,

    B16_FULL,
    B16_EDGE,
    B16_CORNER,
    B16_INS_CORNER,
    B16_EDGE_NO_LINE,
    B16_PILLAR_END,
    B16_PILLAR,
    B16_DLB_INS_CORNER,
    B16_FULL_ALT1,
    B16_FULL_ALT2,

    B16_SLAB,
    B16_SLAB_EDGE,
    B16_SLAB_EDGE_ALT,
    B16_SLAB_CORNER,
    B16_SLAB_INS_CORNER,
    B16_SLAB_BLOCK,
    B16_SMALL_SLAB,
    
    ICE_SPIKE,
    HALF_ICE_SPIKE,
    MEDIUM_ICE_SPIKE,

    CARTWHEEL_BIG,
    CARTWHEEL_MEDIUM,
    CARTWHEEL_SMALL,
    
    BLADE_BIG,
    BLADE_MEDIUM,
    BLADE_SMALL,

    BLADE_ALT_BIG,
    BLADE_ALT_MEDIUM,
    BLADE_ALT_SMALL,

    UNKNOWN_189,

    DIAMOND_DECO_BIG,

    FAKE_SPIKE,

    B16_SLAB_SINGLE,
    B16_FILLER,
    B16_SLAB_INSIDE_CORNER_SMALL,

    MINI_BLOCK,
    MINI_SLAB,

    B16_SLAB_MEDIUM,

    FAKE_HALF_SPIKE,
    FAKE_MEDIUM_SPIKE,

    SLOW_SPEED_PORTAL,
    NORMAL_SPEED_PORTAL,
    FAST_SPEED_PORTAL,
    FASTER_SPEED_PORTAL,

    FADING_SMALL_SLAB,
    FADING_HALF_SPIKE,
    FADING_MINI_BLOCK,

    COLORED_FULL,
    COLORED_EDGE,
    COLORED_CORNER,
    COLORED_INS_CORNER,
    COLORED_FILLER,
    COLORED_PILLAR_END,
    COLORED_PILLAR,

    UNKNOWN_214,

    COLORED_SLAB,
    COLORED_SPIKE,
    COLORED_HALF_SPIKE,
    COLORED_MEDIUM_SPIKE,
    COLORED_MINI_SLAB,
    COLORED_MINI_BLOCK,

    OBJ_2_TRIGGER,

    ROUND_CLOUD_BIG,
    ROUND_CLOUD_MEDIUM,
    ROUND_CLOUD_SMALL,

    ROUND_SWIRVE_LINE,
    ROUND_SWIRVE_CORNER,

    PENTAGON_DECO_EDGE,
    PENTAGON_DECO_CORNER,
    HEXAGON_DECO_EDGE,
    HEXAGON_DECO_CORNER,
    MINI_HEXAGON_DECO_EDGE,
    MINI_HEXAGON_DECO_CORNER,

    LBG_BRICK_BLOCK,
    LBG_BRICK,
    LBG_HALF_BRICK,

    PULSING_BIG_CIRCUNFERENCE,

    LINK_LINE,
    LINK_CORNER,
    LINK_TRIPLE,
    LINK_FULL,
    LINK_END,

    PENTAGON_DECO_INS_CORNER,

    WAVY_PIT_RIGHT, 
    WAVY_PIT_LEFT,

    BRICK,
    HALF_BRICK,

    COLORED_CHECKER_FULL,
    COLORED_CHECKER_EDGE,
    COLORED_CHECKER_CORNER,
    COLORED_CHECKER_INS_CORNER,
    COLORED_CHECKER_FILLER,
    COLORED_CHECKER_PILLAR_END,
    COLORED_CHECKER_PILLAR,
    COLORED_CHECKER_DOUBLE_INS_CORN,

    COLORED_B13_FULL,
    COLORED_B13_EDGE,
    COLORED_B13_CORNER,
    COLORED_B13_INS_CORNER,
    COLORED_B13_FILLER,
    COLORED_B13_PILLAR_END,
    COLORED_B13_PILLAR,

    UNKNOWN_262,

    COLORED_B14_FULL,
    COLORED_B14_EDGE,
    COLORED_B14_CORNER,
    COLORED_B14_FILLER,
    COLORED_B14_PILLAR_END,
    COLORED_B14_PILLAR,

    COLORED_BRICKS_FULL,
    COLORED_BRICKS_EDGE,
    COLORED_BRICKS_CORNER,
    COLORED_BRICKS_INS_CORNER,
    COLORED_BRICKS_FILLER,
    COLORED_BRICKS_PILLAR_END,
    COLORED_BRICKS_PILLAR,

    UNKNOWN_276,

    COLORED_BRICK,
    COLORED_HALF_BRICK,

    LBG_PLAIN,
    LBG_CHECKER,
    LBG_B14,
    LBG_B13,

    MINI_HEXAGON_DECO_TRIPLE,
    MINI_HEXAGON_DECO_FULL,
    MINI_HEXAGON_DECO_SINGLE,

    DUAL_PORTAL,
    DIVORCE_PORTAL,

    UNKNOWN_288,

    CHECKER_SLOPE_45,

    UNKNOWN_290,

    CHECKER_SLOPE_22_66,

    UNKNOWN_292,
    UNKNOWN_293,
    
    B13_SLAB_SLOPE_45,
    B13_SLAB_SLOPE_22_66,
    B13_SLAB_SLOPE_45_CONNECTOR,
    B13_SLAB_SLOPE_22_66_CONNECTOR,

    UNKNOWN_298,

    B13_SLOPE_45,
    
    UNKNOWN_300,
    
    B13_SLOPE_22_66,

    UNKNOWN_302,
    UNKNOWN_303,
    UNKNOWN_304,

    B14_SLOPE_45,
    
    UNKNOWN_306,
    
    B14_SLOPE_22_66,

    UNKNOWN_308,

    BLACK_SLOPE_45,
    
    UNKNOWN_310,
    
    BLACK_SLOPE_22_66,

    UNKNOWN_312,
    UNKNOWN_313,
    UNKNOWN_314,

    B15_SLOPE_45,
    
    UNKNOWN_316,
    
    B15_SLOPE_22_66,

    UNKNOWN_318,
    UNKNOWN_319,
    UNKNOWN_320,

    B16_SLOPE_45,

    UNKNOWN_322,

    B16_SLOPE_22_66,
    B16_SLOPE_45_CONNECTOR,
    B16_SLOPE_22_66_CONNECTOR,

    B16_SLAB_SLOPE_45,
    B16_SLAB_SLOPE_22_66,
    B16_SLAB_SLOPE_45_CONNECTOR,
    B16_SLAB_SLOPE_22_66_CONNECTOR,

    UNKNOWN_330,

    COLORED_SLOPE_45,
    
    UNKNOWN_332,
    
    COLORED_SLOPE_22_66,

    UNKNOWN_334,
    UNKNOWN_335,
    UNKNOWN_336,

    COLORED_CHECKER_SLOPE_45,
    
    UNKNOWN_338,
    
    COLORED_CHECKER_SLOPE_22_66,

    UNKNOWN_340,
    UNKNOWN_341,
    UNKNOWN_342,

    COLORED_B13_SLOPE_45,
    
    UNKNOWN_344,
    
    COLORED_B13_SLOPE_22_66,

    UNKNOWN_346,
    UNKNOWN_347,
    UNKNOWN_348,

    COLORED_B14_SLOPE_45,
    
    UNKNOWN_350,
    
    COLORED_B14_SLOPE_22_66,

    UNKNOWN_352,

    COLORED_B15_SLOPE_45,
    
    UNKNOWN_354,
    
    COLORED_B15_SLOPE_22_66,

    UNKNOWN_356,
    UNKNOWN_357,

    B16_SLAB_SLOPE_22_66_CONNECTOR_2,
    
    UNKNOWN_359,
    UNKNOWN_360,
    UNKNOWN_361,
    UNKNOWN_362,

    GROUND_SPIKE_SLOPE_45,
    GROUND_SPIKE_SLOPE_22_66,
    GROUND_SPIKE_NO_GRADIENT,
    
    WAVY_GROUND_SPIKE_SLOPE_45,
    WAVY_GROUND_SPIKE_SLOPE_22_66,
    WAVY_GROUND_SPIKE_NO_GRADIENT,

    B10_CONT_SLAB,
    B10_CONT_SLAB_EDGE,
    B10_CONT_SLAB_SLOPE_45,
    B10_CONT_SLAB_SLOPE_22_66,
    B10_CONT_SLAB_45_CONNECTOR,
    B10_CONT_SLAB_22_66_CONNECTOR,

    ROTATING_BALL_BIG,
    ROTATING_BALL_MEDIUM,
    ROTATING_BALL_SMALL,
    ROTATING_BALL_TINY,

    // Bunch of empty slots 

    MINI_SPIKE = 392,
    MINI_FAKE_SPIKE,

    ROTATING_HEXAGON_BIG,
    ROTATING_HEXAGON_MEDIUM,
    ROTATING_HEXAGON_TINY,

    DARKBLADE_BIG,
    DARKBLADE_MEDIUM,
    DARKBLADE_SMALL,

    // More empty slots

    PULSING_HEXAGON = 405,

    GRASS_1,
    GRASS_2,
    GRASS_3,

    LINK_B_LINE,
    LINK_B_CORNER,
    LINK_B_TRIPLE,
    LINK_B_FULL,
    LINK_B_END,
    
    GRASS_4,

    SPIKE_WAVE = 419,
    SPIKE_WAVE_END,

    SPIKE_PIT,
    SPIKE_PIT_END,

    // Holy grail of empty slots, thanks robtop

    SEMICIRCLE_PIT = 446,
    SEMICIRCLE_PIT_END,

    SEMICIRCLE_WAVE,
    SEMICIRCLE_WAVE_END,

    PILLAR_BIG,
    PILLAR_MEDIUM,
    PILLAR_SMALL,

    LINK_C_LINE,
    LINK_C_CORNER,
    LINK_C_TRIPLE,
    LINK_C_FULL,
    LINK_C_END,

    COLORED_MINI_SPIKE,
    FADING_MINI_SPIKE,

    D_ARROW_2,

    COLORED_THORN_01,
    COLORED_THORN_02,
    COLORED_THORN_03,
    COLORED_THORN_04,
    COLORED_THORN_05,
    COLORED_THORN_06,

    LAYOUT_BLOCK,
    LAYOUT_LINE,
    LAYOUT_CORNER,
    LAYOUT_PILLAR_END,
    LAYOUT_PILLAR,
    LAYOUT_INSIDE_CORNER,
    LAYOUT_SLOPE_45_CONNECTOR,
    LAYOUT_SLOPE_22_66_CONNECTOR,
    LAYOUT_DENTED_LINE,

    B18_TILESET_1,
    B18_TILESET_2,
    B18_TILESET_3,
    B18_TILESET_4,
    B18_TILESET_5,
    B18_TILESET_6,
    B18_TILESET_7,
    B18_TILESET_SLOPE_45,
    B18_TILESET_SLOPE_22_66,

    B18_TILESET_2_1,
    B18_TILESET_2_2,
    B18_TILESET_2_3,
    B18_TILESET_2_4,
    B18_TILESET_2_5,
    B18_TILESET_2_6,
    B18_TILESET_2_7,
    B18_TILESET_2_SLOPE_45,
    B18_TILESET_2_SLOPE_22_66,

    PULSING_ARROW_3,
    PULSING_BIG_SQUARE,
    PULSING_BIG_SQUARE_OUTLINE,
    PULSING_BIG_CIRCLE,

    CHAIN,
    CHAIN_HOLDER,

    COL_1_SWIRVE,
    COL_1_SWIRVE_CORNER,

    CHECKER_INSIDE_CORNER_NO_WHITE,

    GLOW,
    GLOW_CORNER,
    GLOW_INSIDE_CORNER,

    // 1.9

    PERSP_OUT_1,
    PERSP_OUT_2,
    PERSP_OUT_3,
    PERSP_OUT_4,
    PERSP_OUT_5,
    PERSP_OUT_6,
    PERSP_OUT_7,
    PERSP_OUT_8,
    PERSP_OUT_9,

    PERSP_01_01,
    PERSP_01_02,
    PERSP_01_03,
    PERSP_01_04,
    PERSP_01_05,
    PERSP_01_06,
    PERSP_01_07,
    PERSP_01_08,
    PERSP_01_09,

    PERSP_02_01,
    PERSP_02_02,
    PERSP_02_03,
    PERSP_02_04,
    PERSP_02_05,
    PERSP_02_06,
    PERSP_02_07,
    PERSP_02_08,
    PERSP_02_09,

    PERSP_03_01,
    PERSP_03_02,
    PERSP_03_03,
    PERSP_03_04,
    PERSP_03_05,
    PERSP_03_06,
    PERSP_03_07,
    PERSP_03_08,
    PERSP_03_09,

    PERSP_04_01,
    PERSP_04_02,
    PERSP_04_03,
    PERSP_04_04,
    PERSP_04_05,
    PERSP_04_06,
    PERSP_04_07,
    PERSP_04_08,
    PERSP_04_09,
    
    PERSP_05_01,
    PERSP_05_02,
    PERSP_05_03,
    PERSP_05_04,
    PERSP_05_05,
    PERSP_05_06,
    PERSP_05_07,
    PERSP_05_08,
    PERSP_05_09,

    PERSP_06_01,
    PERSP_06_02,
    PERSP_06_03,
    PERSP_06_04,
    PERSP_06_05,
    PERSP_06_06,
    PERSP_06_07,
    PERSP_06_08,
    PERSP_06_09,

    PERSP_07_01,
    PERSP_07_02,
    PERSP_07_03,
    PERSP_07_04,
    PERSP_07_05,
    PERSP_07_06,
    PERSP_07_07,
    PERSP_07_08,
    PERSP_07_09,

    PERSP_08_01,
    PERSP_08_02,
    PERSP_08_03,
    PERSP_08_04,
    PERSP_08_05,
    PERSP_08_06,
    PERSP_08_07,
    PERSP_08_08,
    PERSP_08_09,

    PERSP_09_01,
    PERSP_09_02,
    PERSP_09_03,
    PERSP_09_04,
    PERSP_09_05,
    PERSP_09_06,
    PERSP_09_07,
    PERSP_09_08,
    PERSP_09_09,

    PERSP_10_01,
    PERSP_10_02,
    PERSP_10_03,
    PERSP_10_04,
    PERSP_10_05,
    PERSP_10_06,
    PERSP_10_07,
    PERSP_10_08,
    PERSP_10_09,

    PERSP_11_01,
    PERSP_11_02,
    PERSP_11_03,
    PERSP_11_04,
    PERSP_11_05,
    PERSP_11_06,
    PERSP_11_07,
    PERSP_11_08,
    PERSP_11_09,

    PERSP_12_01,
    PERSP_12_02,
    PERSP_12_03,
    PERSP_12_04,
    PERSP_12_05,
    PERSP_12_06,
    PERSP_12_07,
    PERSP_12_08,
    PERSP_12_09,

    PERSP_13_01,
    PERSP_13_02,
    PERSP_13_03,
    PERSP_13_04,
    PERSP_13_05,
    PERSP_13_06,
    PERSP_13_07,
    PERSP_13_08,
    PERSP_13_09,

    PERSP_14_01,
    PERSP_14_02,
    PERSP_14_03,
    PERSP_14_04,
    PERSP_14_05,
    PERSP_14_06,
    PERSP_14_07,
    PERSP_14_08,
    PERSP_14_09,

    B19_TILESET_EDGE,
    B19_TILESET_CORNER,
    B19_TILESET_PILLAR_END,
    B19_TILESET_FULL,
    B19_TILESET_PILLAR,
    B19_TILESET_EDGE_CORNER,
    B19_TILESET_INSIDE_FULL,
    B19_TILESET_INSIDE_TRIPLE,
    B19_TILESET_INSIDE_DOUBLE,
    B19_TILESET_NOT_FULL,

    B19_TILESET_SLOPE_45,
    B19_TILESET_SLOPE_22_66,

    BLOCK04_PIECE_01,
    BLOCK04_PIECE_02,
    BLOCK04_PIECE_03,
    BLOCK04_PIECE_04,
    BLOCK04_PIECE_05,
    BLOCK04_PIECE_06,
    BLOCK04_PIECE_07,

    WAVE_PORTAL,

    OUTLINE_MINI_BLOCK,
    OUTLINE_SLAB,
    OUTLINE_SLAB_CENTER,
    OUTLINE_SLAB_EDGE,
    OUTLINE_SLOPE_45,
    OUTLINE_SLOPE_22_66,

    SQUARE_PIT,

    PIXELART_1,
    PIXELART_2,
    PIXELART_3,
    PIXELART_4,
    PIXELART_5,

    FADING_SLOPE_45,
    FADING_SLOPE_22_66,

    DARKCOGWHEEL_BIG,
    DARKCOGWHEEL_MEDIUM,
    DARKCOGWHEEL_SMALL,

    LIGHTBLADE_BIG,
    LIGHTBLADE_MEDIUM,
    LIGHTBLADE_SMALL,

    CHECKER_SLOPE_45_NOOUT,
    CHECKER_SLOPE_22_66_NOOUT,
    
    B13_SLOPE_45_NOOUT,
    B13_SLOPE_22_66_NOOUT,

    B14_SLOPE_45_NOOUT,
    B14_SLOPE_22_66_NOOUT,

    BLACK_SLOPE_45_NOOUT,
    BLACK_SLOPE_22_66_NOOUT,
    
    B15_SLOPE_45_NOOUT,
    B15_SLOPE_22_66_NOOUT,

    B16_SLOPE_45_NOOUT,
    B16_SLOPE_22_66_NOOUT,

    COLOR_SLOPE_45_NOOUT,
    COLOR_SLOPE_22_66_NOOUT,
    
    COLOR_CHECKER_SLOPE_45_NOOUT,
    COLOR_CHECKER_SLOPE_22_66_NOOUT,

    COLOR_B13_SLOPE_45_NOOUT,
    COLOR_B13_SLOPE_22_66_NOOUT,

    COLOR_B14_SLOPE_45_NOOUT,
    COLOR_B14_SLOPE_22_66_NOOUT,
    
    COLOR_B15_SLOPE_45_NOOUT,
    COLOR_B15_SLOPE_22_66_NOOUT,
    
    B18_SLOPE_45_NOOUT,
    B18_SLOPE_22_66_NOOUT,
    
    B18_2_SLOPE_45_NOOUT,
    B18_2_SLOPE_22_66_NOOUT,
    
    B19_SLOPE_45_NOOUT,
    B19_SLOPE_22_66_NOOUT,

    BLOCK04_01_SLOPE_45,
    BLOCK04_01_SLOPE_22_66,
    
    BLOCK04_02_SLOPE_45,
    BLOCK04_02_SLOPE_22_66,
    
    BLOCK04_01_SLOPE_45_NOOUT,
    BLOCK04_01_SLOPE_22_66_NOOUT,
    
    BLOCK04_02_SLOPE_45_NOOUT,
    BLOCK04_02_SLOPE_22_66_NOOUT,

    COL2_TRIGGER,
    COL3_TRIGGER,

    SQUARE_PIT_SHINE,
    SQUARE_PIT_EDGE,
    SQUARE_PIT_EDGE_SHINE,
    
    BLOCK04_PIECE_08,
    BLOCK04_PIECE_09,
    BLOCK04_PIECE_10,
    
    BALL,

    BLOCK04_03_SLOPE_45,
    BLOCK04_03_SLOPE_22_66,
    
    BLOCK04_04_SLOPE_45,
    BLOCK04_04_SLOPE_22_66,
    
    BLOCK04_03_SLOPE_45_NOOUT,
    BLOCK04_03_SLOPE_22_66_NOOUT,
    
    BLOCK04_04_SLOPE_45_NOOUT,
    BLOCK04_04_SLOPE_22_66_NOOUT,
    
    BLOCK04_PIECE_11,
    BLOCK04_PIECE_12,
    BLOCK04_PIECE_13,

    B16_TILSET_EDGE_CORNER,

    PIXELART_6,

    B19_TILESET_CORNER_2,

    FADING_BLADE_BIG,
    FADING_BLADE_MEDIUM,
    FADING_BLADE_SMALL,

    COL4_TRIGGER,
    THREEDL_TRIGGER,

    ROBOT_PORTAL = 745,
    BLUE_TP_PORTAL = 747,
    ORANGE_TP_PORTAL = 749,

    V2_0_TILESET_EDGE = 752,
    V2_0_TILESET_CORNER,
    V2_0_TILESET_INSIDE_CORNER,
    V2_0_TILESET_FILLER,
    V2_0_TILESET_PILLAR_END,
    V2_0_TILESET_PILLAR,
    V2_0_TILESET_DBL_INSIDE_CORNER,
    V2_0_TILESET_FULL,

    UNKNOWN_760,
    UNKNOWN_761,

    V2_0_TILESET_SLOPE_45,
    V2_0_TILESET_SLOPE_22_66,
    V2_0_TILESET_SLOPE_CONNECTOR_45,
    V2_0_TILESET_SLOPE_CONNECTOR_22_66_1,
    V2_0_TILESET_SLOPE_CONNECTOR_22_66_2,

    V2_0_TILESET_SLAB,
    V2_0_TILESET_SLAB_EDGE,
    V2_0_TILESET_SLAB_SLOPE_45,
    V2_0_TILESET_SLAB_SLOPE_22_66,
    V2_0_TILESET_SLAB_SLOPE_CONNECTOR_45,
    V2_0_TILESET_SLAB_SLOPE_CONNECTOR_22_66_1,
    V2_0_TILESET_SLAB_SLOPE_CONNECTOR_22_66_2,

    V2_0_TILESET_2_EDGE = 807,
    V2_0_TILESET_2_EDGE_ALT,
    V2_0_TILESET_2_CORNER,
    V2_0_TILESET_2_CORNER_ALT,
    V2_0_TILESET_2_PILLAR,
    V2_0_TILESET_2_PILLAR_ALT,
    V2_0_TILESET_2_PILLAR_END,
    V2_0_TILESET_2_PILLAR_END_ALT,
    V2_0_TILESET_2_FULL,
    V2_0_TILESET_2_FULL_ALT,

    V2_0_TILESET_2_SLOPE_45,
    V2_0_TILESET_2_SLOPE_45_ALT,
    V2_0_TILESET_2_SLOPE_22_66,
    V2_0_TILESET_2_SLOPE_22_66_ALT,
    V2_0_TILESET_2_SLOPE_CONNECTOR_45,
    V2_0_TILESET_2_SLOPE_CONNECTOR_45_ALT,
    V2_0_TILESET_2_SLOPE_CONNECTOR_22_66,
    V2_0_TILESET_2_SLOPE_CONNECTOR_22_66_ALT,

    BLOCK_7B_CORNER = 841,
    BLOCK_7B_THREE,
    BLOCK_7B_LINE,
    BLOCK_7B_LINE_ALT,
    BLOCK_7B_FOUR,
    BLOCK_7B_PILLAR_END,
    BLOCK_7B_FULL,
    BLOCK_7B_FULL_ALT,

    UNKNOWN_849,

    BLOCK_8_FULL,

    UNKNOWN_851,
    UNKNOWN_852,
    
    BLOCK_8_LINE,
    BLOCK_8_CORNER,
    BLOCK_8_CORNER_2,
    BLOCK_8_CORNER_3,
    BLOCK_8_EDGE,

    UNKNOWN_858,

    BLOCK_8_EDGE_2,

    UNKNOWN_860,

    BLOCK_8_TRIPLE,
    BLOCK_8_TRIPLE_2,
    BLOCK_8_CUADRUPLE,

    UNKNOWN_864,
    UNKNOWN_865,
    UNKNOWN_866,

    BLOCK_9_1,
    BLOCK_9_2,
    BLOCK_9_3,
    BLOCK_9_4,
    BLOCK_9_5,
    BLOCK_9_6,

    BLOCK_9_PART_1,
    BLOCK_9_PART_2,

    UNKNOWN_875,
    UNKNOWN_876,

    BLOCK_9_SLOPE_45,
    BLOCK_9_SLOPE_22_66,

    UNKNOWN_879,

    BLOCK_9B_1,
    BLOCK_9B_2,
    BLOCK_9B_3,
    BLOCK_9B_4,
    BLOCK_9B_5,
    BLOCK_9B_6,
    BLOCK_9B_SLOPE_45,
    BLOCK_9B_SLOPE_22_66,
    BLOCK_9B_SLOPE_45_NO_OUT,
    BLOCK_9B_SLOPE_22_66_NO_OUT,

    BLOCK_9C_1,
    BLOCK_9C_2,

    UNKNOWN_892, // block 9c 3 is skipped for some reason in the textures, maybe this was block 9c 3?
    
    BLOCK_9C_4,
    BLOCK_9C_5,

    BLOCK_9C_SLOPE_45,
    BLOCK_9C_SLOPE_22_66,

    COL_TRIGGER = 899,
    G_2_TRIGGER,
    MOVE_TRIGGER,

    PERSP_08_10,
    BLOCK_5_10,
    BLOCK_5_11,
    BLOCK_5_12,

    D_GRASS_05,

    GRASSART_01,
    GRASSART_02,
    GRASSART_03,
    GRASSART_04,

    BLOCK_5_13,

    UNKNOWN_912,
    UNKNOWN_913,

    TEXT_OBJ,

    V2_0_LINE_TRIGGER,

    PIXEL_BLOCK_1,
    PIXEL_BLOCK_2,

    MONSTER_1,
    BLACK_SLUDGE,

    FIRE_1,
    FIRE_2,

    UNKNOWN_922,

    FIRE_3,
    FIRE_4,

    RAINBOW_ARC_SMALL,
    RAINBOW_ARC_BIG,

    RAINBOW_BLOCK_1,
    RAINBOW_BLOCK_2,
    RAINBOW_BLOCK_3,
    RAINBOW_BLOCK_4,
    RAINBOW_BLOCK_5,
    RAINBOW_BLOCK_6,
    RAINBOW_BLOCK_7,
    RAINBOW_BLOCK_8,
    RAINBOW_BLOCK_9,

    ART_CLOUD_1,
    ART_CLOUD_2,
    ART_CLOUD_3,

    FLOWER,

    DETAIL_GRASS_1,
    DETAIL_GRASS_2,
    DETAIL_GRASS_3,

    PERSP_15_1,
    PERSP_15_2,
    PERSP_15_3,
    PERSP_15_4,
    PERSP_15_5,
    PERSP_15_6,
    PERSP_15_7,
    PERSP_15_8,
    PERSP_15_9,

    BLOCK_5B_1,
    BLOCK_5B_2,
    BLOCK_5B_3,
    BLOCK_5B_4,
    BLOCK_5B_5,
    BLOCK_5B_6,
    BLOCK_5B_7,
    BLOCK_5B_8,

    BLOCK_5B_SLOPE_45,
    BLOCK_5B_SLOPE_22_66,

    UNKNOWN_962,
    UNKNOWN_963,

    BLOCK_5B_CONNECTOR_1,
    BLOCK_5B_CONNECTOR_2,
    BLOCK_5B_CONNECTOR_3,

    BLOCK_5B_SLAB_1,
    BLOCK_5B_SLAB_2,
    
    BLOCK_5B_SLAB_SLOPE_45,
    BLOCK_5B_SLAB_SLOPE_22_66,
    
    BLOCK_5B_SLAB_CONNECTOR_1,
    BLOCK_5B_SLAB_CONNECTOR_2,
    BLOCK_5B_SLAB_CONNECTOR_3,
    BLOCK_5B_10,
    BLOCK_5B_11,
    BLOCK_5B_12,
    BLOCK_5B_13,

    UNKNOWN_978,
    UNKNOWN_979,

    PERSP_17_1,
    PERSP_17_2,
    PERSP_17_3,
    PERSP_17_4,
    PERSP_17_5,
    PERSP_17_6,
    PERSP_17_7,
    PERSP_17_8,
    PERSP_17_9,

    PIT_07_3,
    PIT_07_3_SHINE,
    
    PIT_07_4,
    PIT_07_4_SHINE,

    UNKNOWN_993,
    UNKNOWN_994,
    UNKNOWN_995,
    UNKNOWN_996,

    RING_SEG_01,
    RING_SEG_02,
    RING_SEG_03,
    RING_SEG_04,

    DLINKD_01,
    DLINKD_02,
    DLINKD_03,
    DLINKD_04,
    DLINKD_05,

    PULSE_TRIGGER = 1006,
    ALPHA_TRIGGER = 1007,

    GLOW_MINI_01,
    GLOW_MINI_02,
    GLOW_MINI_03,
    
    GLOW_BIG_01,
    GLOW_BIG_02,
    GLOW_BIG_03,

    RAINBOW_SLOPE_45,
    RAINBOW_SLOPE_22_66,
    RAINBOW_CONNECTOR_1,
    RAINBOW_CONNECTOR_2,
    RAINBOW_CONNECTOR_3,

    FLASH_RING_1,
    FLASH_RING_2,
    FLASH_RING_3,

    GREEN_ORB = 1022,

    UNKNOWN_1023,

    PERSP_16_1,
    PERSP_16_2,
    PERSP_16_3,
    PERSP_16_4,
    PERSP_16_5,
    PERSP_16_6,
    PERSP_16_7,
    PERSP_16_8,
    PERSP_16_9,

    BLOCK_05_SLOPE_45_ALT,
    BLOCK_05_SLOPE_22_66_ALT,
    BLOCK_05_SLOPE_CONNECTOR_1_ALT,
    BLOCK_05_SLOPE_CONNECTOR_2_ALT,

    BLOCK_05B_SLOPE_45_ALT,
    BLOCK_05B_SLOPE_22_66_ALT,
    BLOCK_05B_SLOPE_CONNECTOR_1_ALT,
    BLOCK_05B_SLOPE_CONNECTOR_2_ALT,

    BLOCK_05_SLOPE_45_ALT_2,
    BLOCK_05_SLOPE_22_66_ALT_2,
    BLOCK_05B_SLOPE_45_ALT_2,
    BLOCK_05B_SLOPE_22_66_ALT_2,

    BLOCK_05_16,
    BLOCK_05_17,
    BLOCK_05B_16,
    BLOCK_05B_17,

    TOGGLE_TRIGGER = 1049,

    ANIMATED_WATER_1,
    ANIMATED_WATER_2,
    ANIMATED_WATER_3,
    ANIMATED_LOADING_1,
    ANIMATED_LOADING_2,

    PICKUP_CIRCLE_1,
    PICKUP_CIRCLE_2,
    PICKUP_CIRCLE_3,

    SPIRAL_1,
    SPIRAL_2,
    SPIRAL_3,
    SPIRAL_4,

    BLOCK_7B_7,

    PERSP_18_1,
    PERSP_18_2,
    PERSP_18_3,
    PERSP_18_4,
    PERSP_18_5,
    PERSP_18_6,
    PERSP_18_7,
    PERSP_18_8,
    PERSP_18_9,

    UNKNOWN_1072,
    UNKNOWN_1073,
    UNKNOWN_1074,

    V1_9_TILESET_ALT,
    V1_9_TILESET_ALT_2,
    V1_9_TILESET_ALT_3,

    BLOCK_07_MINIBLOCK,
    BLOCK_07_PLANK,
    BLOCK_07_PLANK_2,
    BLOCK_07_PLANK_3,

    BLOCK_07_EMPTY_1,
    BLOCK_07_EMPTY_2,
    BLOCK_07_EMPTY_3,
    BLOCK_07_EMPTY_4,
    BLOCK_07_EMPTY_5,
    
    BLOCK_07_FRAME_EMPTY_1,
    BLOCK_07_FRAME_EMPTY_2,
    BLOCK_07_FRAME_EMPTY_3,
    BLOCK_07_FRAME_EMPTY_4,

    BLOCK_07_EMPTY_SLOPE_45,
    BLOCK_07_EMPTY_SLOPE_22_66,
    BLOCK_07_EMPTY_CONNECTOR_1,
    BLOCK_07_EMPTY_CONNECTOR_2,

    BLOCK_07_EMPTY_MINIBLOCK,
    BLOCK_07_EMPTY_PLANK,
    BLOCK_07_EMPTY_PLANK_2,
    BLOCK_07_EMPTY_PLANK_3,

    BLOCK_07_BGCOLOR_1,
    BLOCK_07_BGCOLOR_2,
    BLOCK_07_BGCOLOR_3,
    BLOCK_07_BGCOLOR_4,
    BLOCK_07_BGCOLOR_5,
    BLOCK_07_BGCOLOR_6,
    BLOCK_07_BGCOLOR_7,
    BLOCK_07_BGCOLOR_8,
    BLOCK_07_BGCOLOR_9,
    BLOCK_07_BGCOLOR_10,
    BLOCK_07_BGCOLOR_11,
    BLOCK_07_BGCOLOR_1_AGAIN,
    BLOCK_07_BGCOLOR_12,

    BLOCK_07B_BGCOLOR_1,
    BLOCK_07B_BGCOLOR_2,
    BLOCK_07B_BGCOLOR_3,
    BLOCK_07B_BGCOLOR_5,
    BLOCK_07B_BGCOLOR_6,
    BLOCK_07B_BGCOLOR_7,
    BLOCK_07B_BGCOLOR_8,

    UNKNOWN_1119,

    BLOCK_08_TOPCOLOR_1,

    UNKNOWN_1121,

    BLOCK_08_TOPCOLOR_29,
    BLOCK_08_TOPCOLOR_14,
    BLOCK_08_TOPCOLOR_16,
    BLOCK_08_TOPCOLOR_18,
    BLOCK_08_TOPCOLOR_24,
    BLOCK_08_TOPCOLOR_24_02,

    BLOCK_08_TOPCOLOR_22 = 1132,
    BLOCK_08_TOPCOLOR_23,
    BLOCK_08_TOPCOLOR_25,
    BLOCK_08_TOPCOLOR_26,
    BLOCK_08_TOPCOLOR_27,
    BLOCK_08_TOPCOLOR_28,
    BLOCK_08_TOPCOLOR_12,
    BLOCK_08_TOPCOLOR_13,

    BLOCK_G_03,
    BLOCK_G_04,
    BLOCK_G_05,
    BLOCK_G_06,
    BLOCK_G_07,
    BLOCK_G_08,
    BLOCK_G_09,
    BLOCK_G_10,
    BLOCK_G_11,
    BLOCK_G_12,
    BLOCK_G_13,
    BLOCK_G_14,
    BLOCK_G_15,
    BLOCK_G_16,

    SMALL_OUTLINE_1,
    SMALL_OUTLINE_2,
    SMALL_OUTLINE_3,
    SMALL_OUTLINE_4,
    SMALL_OUTLINE_5,

    BLOCK_9B_8,
    BLOCK_9B_9,
    BLOCK_9B_10,

    BLOCK_6_1,
    BLOCK_6_2,
    BLOCK_6_3,
    BLOCK_6_4,
    BLOCK_6_5,
    BLOCK_6_6,
    BLOCK_6_7,
    BLOCK_6_8,
    BLOCK_6_9,
    BLOCK_6_10,
    BLOCK_6_11,
    BLOCK_6_12,
    BLOCK_6_13,
    BLOCK_6_14,
    BLOCK_6_15,
    BLOCK_6_16,
    BLOCK_6_17,
    BLOCK_6_18,
    BLOCK_6_19,
    BLOCK_6_20,
    BLOCK_6_21,
    BLOCK_6_22,
    BLOCK_6_23,
    BLOCK_6_24,
    BLOCK_6_25,

    BLOCK_6_SLOPE_45,
    BLOCK_6_SLOPE_22_66,
    BLOCK_6_SLOPE_CONNECTOR_45,
    BLOCK_6_SLOPE_CONNECTOR_22_66,

    BLOCK_6_OUTLINE_1,
    BLOCK_6_OUTLINE_2,
    BLOCK_6_OUTLINE_3,
    BLOCK_6_OUTLINE_4,
    BLOCK_6_OUTLINE_5,
    BLOCK_6_OUTLINE_6,
    BLOCK_6_OUTLINE_7,
    BLOCK_6_OUTLINE_8,
    BLOCK_6_OUTLINE_9,
    BLOCK_6_OUTLINE_10,
    BLOCK_6_OUTLINE_11,

    OUTLINE_THICK_1,
    OUTLINE_THICK_2,
    OUTLINE_THICK_3,
    OUTLINE_THICK_4,
    OUTLINE_THICK_5,
    OUTLINE_THICK_6,
    OUTLINE_THICK_7,
    OUTLINE_THICK_8,
    OUTLINE_THICK_9,

    OUTLINE_THICKB_1 = 1220,
    OUTLINE_THICKB_2,
    OUTLINE_THICKB_3,
    OUTLINE_THICKB_4,
    OUTLINE_THICKB_5,
    OUTLINE_THICKB_6,
    OUTLINE_THICKB_8,
    OUTLINE_THICKB_9,

    ANIM_WAVE_BASE,

    RAINBOW_BLOCK_10,
    RAINBOW_BLOCK_11,
    RAINBOW_BLOCK_12,
    RAINBOW_BLOCK_13,
    RAINBOW_BLOCK_14,
    RAINBOW_BLOCK_15,
    RAINBOW_BLOCK_16,
    RAINBOW_BLOCK_17,
    RAINBOW_BLOCK_18,
    RAINBOW_BLOCK_19,
    RAINBOW_BLOCK_20,
    RAINBOW_BLOCK_21,

    BLOCK_08_TOPCOLOR_02,
    BLOCK_08_TOPCOLOR_06,
    BLOCK_08_TOPCOLOR_07,
    BLOCK_08_TOPCOLOR_08,
    BLOCK_08_TOPCOLOR_10,
    BLOCK_08_TOPCOLOR_11,

    BLOCK_09D_1,
    BLOCK_09D_2,
    BLOCK_09D_3,
    BLOCK_09D_4,
    BLOCK_09D_5,
    BLOCK_09D_6,
    BLOCK_09D_7,
    BLOCK_09D_8,
    BLOCK_09D_9,

    BLOCK_09D_SLOPE_45,
    BLOCK_09D_SLOPE_22_66,
    
    BLOCK_09D_SLOPE_45_ALT,
    BLOCK_09D_SLOPE_22_66_ALT,

    OUTLINE_OUTER_1,
    OUTLINE_OUTER_2,
    OUTLINE_OUTER_THICK_1,
    OUTLINE_OUTER_THICK_2,
    OUTLINE_OUTER_THICKER_1,
    OUTLINE_OUTER_THICKER_2,

    BLOCK_09_7,
    BLOCK_09_8,

    SPAWN_TRIGGER = 1268,

    GRADIENT_CORNER_1,
    GRADIENT_CORNER_2,
    GRADIENT_CORNER_3,
    GRADIENT_CORNER_4,
    GRADIENT_CORNER_5,
    GRADIENT_CORNER_6,

    KEY_OBJ,
    KEYHOLE,

    BLOCK_09D_10,
    BLOCK_09D_11,
    BLOCK_09D_12,
    BLOCK_09D_13,
    BLOCK_09D_14,
    BLOCK_09D_15,
    BLOCK_09D_16,
    BLOCK_09D_17,
    BLOCK_09D_18,
    BLOCK_09D_19,
    BLOCK_09D_20,
    BLOCK_09D_21,
    BLOCK_09D_22,
    BLOCK_09D_23,

    GLOW_6_1,
    GLOW_6_2,
    GLOW_6_3,

    BLOCK_005_2B,
    BLOCK_005_4B,
    
    BLOCK_005B_2B,
    BLOCK_005B_4B,

    BLOCK_03_ONEMORE,

    BLOCK_05_SLAB_1,
    BLOCK_05_SLAB_2,
    BLOCK_05_SLAB_3,
    BLOCK_05_SLAB_4,
    BLOCK_05_SLAB_5,
    BLOCK_05_THREESLAB,
    BLOCK_05_SLABSLOPE_45,
    BLOCK_05_SLABSLOPE_22_66,
    BLOCK_05_SLABSLOPE_CONNECTOR_1,
    BLOCK_05_SLABSLOPE_CONNECTOR_2,
    BLOCK_05_SLABSLOPE_CONNECTOR_3,

    BLOCK_05C_OUTLINE_1,
    BLOCK_05C_OUTLINE_2,
    BLOCK_05C_OUTLINE_3,
    BLOCK_05C_OUTLINE_4,
    BLOCK_05C_OUTLINE_5,
    BLOCK_05C_OUTLINE_PILLAR_END,
    BLOCK_05C_OUTLINE_SLOPE_45,
    BLOCK_05C_OUTLINE_SLOPE_22_66,
    BLOCK_05C_OUTLINE_SLOPE_CONNECTOR_1,
    BLOCK_05C_OUTLINE_SLOPE_CONNECTOR_2,
    BLOCK_05C_OUTLINE_SLOPE_CONNECTOR_3,

    UNKNOWN_1321,

    BLOCK_06_25,

    UNKNOWN_1323,
    UNKNOWN_1324,

    BLOCK_06_CONNECTOR_3,
    BLOCK_06_CONNECTOR_4,

    MONSTER_2,
    MONSTER_3,

    OBJECT_COUNT = 1329 // 2.0 object count
};

enum ZLayers {
    LAYER_B4 = -3,
    LAYER_B3 = -1,
    LAYER_B2 = 1,
    LAYER_B1 = 3,
    LAYER_T1 = 5,
    LAYER_T2 = 7,
    LAYER_T3 = 9,
    LAYER_T4 = 11,
    LAYER_MAX
};

enum JumpType {
    JUMP_YELLOW_PAD,
    JUMP_YELLOW_ORB,
    JUMP_BLUE_PAD,
    JUMP_BLUE_ORB,
    JUMP_PINK_PAD,
    JUMP_PINK_ORB,
    JUMP_TYPES_COUNT
};

enum ColChannels {
    BG = 1000,
    GROUND,
    LINE,
    THREEDL,
    OBJ,
    P1,
    P2,
    LBG,
    OBJ_BLENDING,
    G2,
    BLACK,
    WHITE,
    LIGHTER,
    LBG_NO_LERP,
    COL_CHANNEL_COUNT
};

enum FadingEffects {
    FADE_NONE,
    FADE_UP,
    FADE_DOWN,
    FADE_RIGHT,
    FADE_LEFT,
    FADE_SCALE_IN,
    FADE_SCALE_OUT,
    FADE_INWARDS,
    FADE_OUTWARDS,
    FADE_CIRCLE_LEFT,
    FADE_CIRCLE_RIGHT,
    FADE_UP_SLOW,
    FADE_DOWN_SLOW,
    FADE_UP_STATIONARY,
    FADE_DOWN_STATIONARY,
    FADE_COUNT
};

enum SpriteSheets {
    SHEET_BLOCKS,
    SHEET_SPEED_PORTALS,
    SHEET_PORTALS,
    SHEET_ANIMATED,
    SHEET_COUNT
};

#define MAX_PULSES_PER_CHANNEL 10

struct ColorChannel {
    Color color;
    Color non_pulse_color;
    float alpha;
    HSV hsv;
    bool blending;
    int copy_color_id;

    int num_pulses;
    Color pulses[MAX_PULSES_PER_CHANNEL];
};

#define MAX_OBJECTS_IN_GROUP 1000

#define MOVE_SPEED_DIVIDER 315

enum HitboxTypes {
    HITBOX_NONE,
    HITBOX_SOLID,
    HITBOX_SPIKE,
    HITBOX_SPECIAL,
    HITBOX_BREAKABLE_BLOCK,
    HITBOX_TRIGGER,
    HITBOX_TYPES
};

typedef struct {
    float x_off;
    float y_off;
    float width;
    float height;
    float radius;
    bool is_circular;
    int type;
} ObjectHitbox;

struct ObjectLayer {
    float x_offset;
    float y_offset;
    u32 col_channel;
    s32 zlayer_offset;
    s8 color_type;
    const u8 *texture;
};

enum ColorTypes {
    COLOR_MAIN,
    COLOR_DETAIL,
    COLOR_UNMOD,
    COLOR_GLOW,
};

typedef struct {
    struct ObjectLayer layers[MAX_OBJECT_LAYERS];
    int spritesheet_layer;
    int def_zlayer;
    int def_zorder;
    u8 num_layers;
    u8 is_trigger:1;
    u8 is_saw:1;
    u8 is_slope:1;
    u8 fades:1;
    u8 has_movement:1;
    u8 frame_animation:1;
    ObjectHitbox hitbox;
} ObjectDefinition;

typedef struct {
    uint32_t key;           // packed sort key
    GDLayerSortable *ptr; 
} SortEntry;

#define BLOCK_SIZE_PX (44.f * screen_factor_y)
#define BASE_SCALE (0.733333 * screen_factor_y)
#define SCALE (BLOCK_SIZE_PX / 30.0f)

#define MAX_VISIBLE_LAYERS 4096

#define COMPLETE_TEXT_IN_TIME 0.5f

#define NUM_COIN_FRAMES 4

extern const struct ObjectLayer player_layer;

extern const struct ObjectLayer secret_coin_layer[NUM_COIN_FRAMES];
extern const struct ObjectLayer user_coin_layer[NUM_COIN_FRAMES];

extern int current_fading_effect;
extern bool p1_trail;

extern struct ColorChannel channels[COL_CHANNEL_COUNT];
extern const ObjectDefinition objects[];

extern GRRLIB_texImg *object_images[OBJECT_COUNT][MAX_OBJECT_LAYERS];

extern int layersDrawn;

extern int beat_pulse;

extern GRRLIB_texImg *prev_tex;

extern GRRLIB_texImg *bg;
extern GRRLIB_texImg *ground;
extern GRRLIB_texImg *ground_l2;
extern GRRLIB_texImg *level_font;

extern AnimationDefinition monster_1_anim;
extern AnimationDefinition monster_2_anim;
extern AnimationDefinition monster_3_anim;

void load_obj_textures(int object);
void unload_obj_textures();

void update_beat();
void draw_end_wall();
void setup_dual();

void load_coin_texture();
void unload_coin_texture();

void get_fade_vars(GameObject *obj, float x, int *fade_x, int *fade_y, float *fade_scale);
int get_fade_value(float x, int right_edge);

void handle_special_hitbox(Player *player, GameObject *obj, ObjectHitbox *hitbox);
float get_mirror_x(float x, float factor);
GRRLIB_texImg *get_coin_particle_texture();

extern GRRLIB_texImg *level_complete_texture;
extern float complete_text_elapsed;

float get_rotated_x_hitbox(float x_offset, float y_offset, float rotation);
float get_rotated_y_hitbox(float x_offset, float y_offset, float rotation);

void draw_all_object_layers();
void draw_background(f32 x, f32 y);
void draw_ground(f32 x, bool is_ceiling);
void load_spritesheet();
void unload_spritesheet();
void handle_objects();
void set_dual_bounds();
void flip_other_player(int current_player);
void do_ball_reflection();
void set_particle_color(int template_id, int r, int g, int b);
bool is_modifiable(int col_channel, int color_type);
void set_intended_ceiling();

bool is_object_unimplemented(int id);
void run_trigger(GameObject *obj);

AnimationDefinition prepare_monster_1_animation();
AnimationDefinition prepare_monster_2_animation();
AnimationDefinition prepare_monster_3_animation();
void put_object_layer(GameObject *obj, float x, float y, GDObjectLayer *layer);
u32 get_layer_color(GameObject *obj, int color_type, int col_channel, float opacity, int def_col_channel);