mining_pal_pngs = files(
    'damp_rock.png',
    'dirt_tiles.png',
    'everstone.png',
    'fire_stone.png',
    'hard_stone.png',
    'heart_scale.png',
    'heat_rock.png',
    'icy_rock.png',
    'iron_ball.png',
    'light_clay.png',
    'moon_stone.png',
    'odd_keystone.png',
    'oval_stone.png',
    'revive.png',
    'smooth_rock.png',
    'star_piece.png',
    'sun_stone.png',
    'thunderstone.png',
    'water_stone.png',
)

# Extra files added here do not have a distinct palette of their own
mining_pngs_8bpp = mining_pal_pngs
mining_pngs_8bpp += files(
    'armor_fossil.png',
    'blue_shard.png',
    'dome_fossil.png',
    'green_shard.png',
    'large_blue_sphere.png',
    'large_green_sphere.png',
    'large_pale_sphere.png',
    'large_prism_sphere.png',
    'large_red_sphere.png',
    'max_revive.png',
    'moon_stone_90deg.png', # can't be generated by rotating moon_stone.png; image is slightly different
    'plate.png',
    'small_blue_sphere.png',
    'small_green_sphere.png',
    'small_pale_sphere.png',
    'small_prism_sphere.png',
    'small_red_sphere.png',
    'red_shard.png',
    'skull_fossil.png',
    'yellow_shard.png',
)

mining_pngs_8bpp_rotate90 = files(
    'leaf_stone.png',
    'old_amber.png',
    'rare_bone.png',
)

mining_pngs_8bpp_rotate270 = files(
    'claw_fossil.png',
    'helix_fossil.png',
    'root_fossil.png'
)

mining_pal_pngs += mining_pngs_8bpp_rotate90

mining_pngs_4bpp = files(
    'rock_horizontal_line.png',
    'rock_horizontal_rectangle.png',
    'rock_large_square.png',
    'rock_square.png',
    'rock_vertical_line.png',
    'rock_vertical_rectangle.png',
)

mining_pngs_4bpp_rotate90 = files(
    'rock_s_shape.png',
    'rock_z_shape.png',
)

mining_pngs_4bpp_rotate270 = files(
    'rock_T_shape.png',
)

mining_pals = files(
    'red_sphere.pal',
    'blue_sphere.pal',
    'green_sphere.pal',
    'prism_sphere.pal',
    'pale_sphere.pal',
    'rock.pal',
    'fossil.pal',
    'draco_plate.pal',
    'dread_plate.pal',
    'earth_plate.pal',
    'fist_plate.pal',
    'flame_plate.pal',
    'icicle_plate.pal',
    'insect_plate.pal',
    'iron_plate.pal',
    'meadow_plate.pal',
    'mind_plate.pal',
    'splash_plate.pal',
    'sky_plate.pal',
    'spooky_plate.pal',
    'stone_plate.pal',
    'toxic_plate.pal',
    'zap_plate.pal',
)

mining_ncgrs_converted = ncgr_gen.process(mining_pngs_8bpp,
    extra_args: [
        '-sopc',
        '-version101',
        '-convertTo4Bpp',
    ],
)

mining_ncgrs = ncgr_gen.process(mining_pngs_4bpp,
    extra_args: [
        '-sopc',
        '-version101',
    ],
)

mining_ncgrs_converted_rotate90 = ncgr_gen.process(mining_pngs_8bpp_rotate90,
    extra_args: [
        '-sopc',
        '-version101',
        '-convertTo4Bpp',
        '-rotate', '90'
    ],
)

mining_ncgrs_converted_rotate270 = ncgr_gen.process(mining_pngs_8bpp_rotate270,
    extra_args: [
        '-sopc',
        '-version101',
        '-convertTo4Bpp',
        '-rotate', '270',
    ],
)

mining_ncgrs_rotate90 = ncgr_gen.process(mining_pngs_4bpp_rotate90,
    extra_args: [
        '-sopc',
        '-version101',
        '-rotate', '90'
    ],
)

mining_ncgrs_rotate270 = ncgr_gen.process(mining_pngs_4bpp_rotate270,
    extra_args: [
        '-sopc',
        '-version101',
        '-rotate', '270',
    ],
)

mining_nclrs_pngs = nclr_gen.process(mining_pal_pngs,
    extra_args: [
        '-convertTo4Bpp',
    ]
)

mining_nclrs_pals = nclr_gen.process(mining_pals,
    extra_args: [
        '-bitdepth', '4',
    ]
)

mining_order = files('mining.order')
mining_narc = custom_target('mining.narc',
    output: [
        'mining.narc',
        'mining.naix.h',
    ],
    input: [
        mining_ncgrs_converted,
        mining_ncgrs,
        mining_ncgrs_converted_rotate90,
        mining_ncgrs_converted_rotate270,
        mining_ncgrs_rotate90,
        mining_ncgrs_rotate270,
        mining_nclrs_pngs,
        mining_nclrs_pals,
    ],
    command: [
        narc_exe, 'create',
        '--naix',
        '--order', mining_order,
        '--output', '@OUTPUT0@',
        '@PRIVATE_DIR@',
    ]
)

nitrofs_files += mining_narc
naix_headers += mining_narc[1]
