Do not export BG0 tile descriptors ith the mask bit set if there is only one layer defined

This commit is contained in:
Lucas Scharenbroich 2021-10-26 21:19:37 -05:00
parent 3b8bf652e1
commit 3f2a9bd8d4

View File

@ -197,6 +197,9 @@ function findAnimatedTiles(tileset) {
return animations;
}
// Global reference object
let GLOBALS = {};
/**
* Command line arguments
*
@ -246,6 +249,13 @@ async function main(argv) {
// Load up any/all tilesets
const tileSets = await Promise.all(doc.tilesets.map(tileset => loadTileset(workdir, tileset)));
// Create a global reference object
GLOBALS = {
outdir,
tileSets,
tileLayers
};
// Save all of the tilesets
let bg0TileSet = null;
@ -398,7 +408,7 @@ function convertTileID(tileId, tileset) {
// The tileId starts at one, but the tile set starts at zero. It's ok when we export,
// because a special zero tile is inserted, but we have to manually adjust here
const mask_bit = !tileset[tileIndex - 1].isSolid;
const mask_bit = (!tileset[tileIndex - 1].isSolid) && (GLOBALS.tileLayers.length !== 1);
// Build up a partial set of control bits
let control_bits = (mask_bit ? GTE_MASK_BIT : 0) + (hflip ? GTE_HFLIP_BIT : 0) + (vflip ? GTE_VFLIP_BIT : 0);