I just wanted a piece of code that patches BAM file with additional frame sequence because I don't want to overwrite original mapicons.bam, that's all.
Build a new BAM from mapicons.bam. Delete everything in it, but import the new sequence you want to add. The reason for this is that it needs the same palette as the existing BAM. Then save it to mymod/myicons.bam or whatever. Don't compress it but you can use RLE (IIRC this is how mapicons.bam is in the unmodded game).
Then it'd be something like:
COPY_EXISTING mapicons.bam override
INSERT_FILE SOURCE_SIZE ~mymod/myicons.bam~
WRITE_SHORT 0x8 (THIS + newframecount_whatever_that_is_in_the_new_bam)
WRITE_BYTE 0xa (THIS + 1) //new sequence count
It won't be that easy, because we'll have to strip the header and palette data out of the new BAM and maybe mess with the frame lookup table too, but it's a start.