# lib_bam function library

Dependencies: lib_2da, lib_anon, lib_array, lib_fn, lib_ini, lib_sfo, lib_sugar, lib_tools, lib_ui

## Description

Various editors for BAM files.

## Public functions

bam_get_available_mos_index(current:i)=(value:s) action

Find the first unused filename of form mosxxxx.pvrz (where xxxx is an integer padded to 4 digits), starting with mos0000.pvrz.

This function is exposed (not internal) because it's used in some lib_mos functions.

bam_install_v2(lowest_mos_index:i, bam_name:s, path:s, location:s, locbase:s, pvrz_path:s="MOD_FOLDER/sfo", pvrz_location:s="%location%", pvrz_locbase:s="%locbase%")=() action

Installer for v2 BAMs. Feed it the lowest mos index you want to try, the name and location of the bam file to be installed (given by path/location/locbase), and the location of all the pvrz files associated with the bam (given by pvrz_path,pvrz_location,pvrz_locbase, but defaulting to the bam version in each case)

bam_pad_to_four(arguments:i)=(value:s) action

Given an integer argument<10,000, return a 4-digit string of that number, padded out with zeroes at the start if necessary.

This function is exposed (not internal) because it's used in some lib_mos functions.

bam_patch_colors(suppress_warning:b, condition:f, action:f, bam:s)=() action
bam_patch_colors(condition:f, action:f)=() patch

palette editor for BAMs. "condition" should either be blank, or a function that takes as INT_VAR inputs "green", "red" and "blue" and returns "value", which should be 1 (if the color should be patched) or 0 (if not) "action" should be a function which takes "green", "red", "blue" as inputs and then outputs "green", "red" and "blue"

The action-context version patches an in-game bam. The patch-context version patches the current bam.

## Internal functions

These should not be called from outside the library itself.

bam_compress(dl:i, was_compressed:i)=() patch

bam_decompress()=(was_compressed:s, dl:s) patch

bam_legal_byte(input:i)=(output:s) patch

bam_read_color(offset:i)=(red:s, green:s, blue:s) patch

bam_write_color(red:i, green:i, blue:i, offset:i)=() patch