Skip to content

Commit

Permalink
Fix remap_tiles_for_output() for -W16 (#57)
Browse files Browse the repository at this point in the history
This commit fixes a bug where the tile data output was squished and
missing even columns when converting a SNES tileset with a `-W 16`
argument.

This commit also fixes a segfault when converting a snes tileset with
`-W 8 -H 16` (when _tile_width is 8 `(cells_per_tile_h - 2)` underflows).
  • Loading branch information
undisbeliever authored Jan 2, 2025
1 parent 9236a2a commit 3691d8c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ std::vector<Tile> Tileset::remap_tiles_for_output(const std::vector<Tile>& tiles

for (unsigned i = 0; i < tiles.size(); ++i) {
unsigned base_pos =
(((i / tiles_per_row) * cells_per_tile_v) * cells_per_row) + ((i % tiles_per_row) << (cells_per_tile_h - 2));
(((i / tiles_per_row) * cells_per_tile_v) * cells_per_row) + ((i % tiles_per_row) * cells_per_tile_h);
const auto ct = tiles[i].crops(8, 8);
for (unsigned cy = 0; cy < cells_per_tile_v; ++cy) {
for (unsigned cx = 0; cx < cells_per_tile_h; ++cx) {
Expand Down

0 comments on commit 3691d8c

Please sign in to comment.