You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read tiles that will be used to convert this image, and that will always be given the first IDs.
170
+
.Arinput_tiles
171
+
must contain tile data in
172
+
.Dqraw
173
+
format, as generated through the
174
+
.Flo
175
+
option.
176
+
.Pp
177
+
If used together with
178
+
.Flo ,
179
+
then the image can contain tiles not in
180
+
.Arinput_tiles .
181
+
Otherwise, the image must be able to be generated using
182
+
.Emonly
183
+
the tiles from
184
+
.Arinput_tiles ,
185
+
and thus generate different tile data.
186
+
The former is more useful if you want several images to share a given set of tiles, such as different levels sharing a single tileset; the latter, if you want to control more precisely the numeric IDs of specific tiles.
187
+
.Pp
188
+
If more than one color palette is in use, it is also
189
+
.Systrongly
190
+
advised to dump it together with the tile data, and to pass it using
191
+
.FlcCmgbc:NsArinput_palette .
192
+
This is because
193
+
.Nm
194
+
may not pack the palettes the same way that it did when generating
195
+
.Arinput_tiles .
196
+
See
197
+
.SxEXAMPLES
198
+
for an example of how to use this.
167
199
.ItFlLArslice , Fl\-sliceArslice
168
200
Only process a given rectangle of the image.
169
201
This is useful for example if the input image is a sheet of some sort, and you want to convert each cel individually.
@@ -637,7 +669,13 @@ without needing an input image.
637
669
.Pp
638
670
.Dl$rgbgfx-c'#fff,#ff0,#f80,#000'-pcolors.pal
639
671
.Pp
640
-
TODO: more examples.
672
+
The following will convert two levels using the same tileset, and error out of any of the level images contain tiles not in the tileset.
// by caching the full tile data anyway, so we might as well.)
964
976
UniqueTiles tiles;
965
977
978
+
if (!options.inputTileset.empty()) {
979
+
File inputTileset;
980
+
if (!inputTileset.open(options.inputTileset, std::ios::in | std::ios::binary)) {
981
+
fatal("Failed to open \"%s\": %s", options.inputTileset.c_str(), strerror(errno));
982
+
}
983
+
984
+
std::array<uint8_t, 16> tile;
985
+
size_tconst tileSize = options.bitDepth * 8;
986
+
for (;;) {
987
+
// It's okay to cast between character types.
988
+
size_t len = inputTileset->sgetn(reinterpret_cast<char *>(tile.data()), tileSize);
989
+
if (len == 0) { // EOF!
990
+
break;
991
+
} elseif (len != tileSize) {
992
+
fatal(
993
+
"\"%s\" does not contain a multiple of %zu bytes; is it actually tile data?",
994
+
options.inputTileset.c_str(),
995
+
tileSize
996
+
);
997
+
} elseif (len == 8) {
998
+
// Expand the tile data to 2bpp.
999
+
for (size_t i = 8; i--;) {
1000
+
tile[i * 2 + 1] = 0;
1001
+
tile[i * 2] = tile[i];
1002
+
}
1003
+
}
1004
+
1005
+
auto [tileID, matchType] = tiles.addTile(std::move(tile));
1006
+
switch (matchType) {
1007
+
case TileData::NOPE:
1008
+
break;
1009
+
case TileData::HFLIP:
1010
+
case TileData::VFLIP:
1011
+
case TileData::VHFLIP:
1012
+
if (!options.allowMirroring) {
1013
+
break;
1014
+
}
1015
+
[[fallthrough]];
1016
+
case TileData::EXACT:
1017
+
error("The input tileset contains tiles that were deduplicated; please check that your deduplication flags (`-u`, `-m`) are consistent with what was used to generate the input tileset");
1018
+
}
1019
+
}
1020
+
}
1021
+
966
1022
for (auto [tile, attr] : zip(png.visitAsTiles(), attrmap)) {
967
-
auto [tileID, matchType] = tiles.addTile(tile, palettes[mappings[attr.protoPaletteID]]);
1023
+
auto [tileID, matchType] = tiles.addTile({tile, palettes[mappings[attr.protoPaletteID]]});
1024
+
1025
+
if (matchType == TileData::NOPE && options.output.empty()) {
1026
+
error("Tile at (%" PRIu32 ", %" PRIu32 ") is not within the input tileset, and `-o` was not given!", tile.x, tile.y);
0 commit comments