This repository contains reading/writing code for the goofy formats that NetBattle Arena uses (they're real goofy!).
metapng is a PNG image with arbitrary metadata, stored in the zTXt
chunk with the private use "compression scheme" 0xFF
, with the keywords MPNG:<field name>
. The zTXt
chunk is used over the tEXt
and iTXt
chunk as it allows arbitrary binary data: tEXt
expects Latin-1 and iTXt
expects UTF-8: technically, the zTXt
chunk expects the decompression output to be Latin-1, but we're able to fudge this by using a compression scheme constant that's not recognized by any program today.
oggloop
oggloop is a looping Ogg file, a la RPG Maker. The loop information is contained in the comment section under two tags labeled LOOPSTART
and LOOPLENGTH
. The value is an integer denoting the start of the loop and the length of the loop in number of samples.
pngatlas
pngatlas is a metapng file that contains region information in the atlas
metapng field. The value of the field is compressed with zlib, and of the format x:int6be y:int64be w:int64be h:int64be
. We use big endian here because the rest of the PNG format uses big endian, and it feels wrong to switch to little endian for this field.
pngsheet
pngsheet is a PNG file that contains a sprite sheet with animations. It additionally contains two metadata chunks, a supplementary palette in sPLT
and an animation control section in zTXt
with the keyword fsctrl
and "compression scheme" 0xFF
.
For BN6 rips, the sPLT
section is expected to contain groups of 16 colors.
The fsctrl
section is structured as follows:
left: int16
top: int16
right: int16
bottom: int16
originX: int16
originY: int16
delay: uint8
action: 0x00 "next" | 0x01 "loop" | 0x03 "stop"
Each animation is delimited by a non-"next" action.