git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit c8c0d1048d5abd7a2aebf48f5942f14d41b07d07
parent 0cf82e544c72bfcf92f9542bdc7797ca10960f53
Author: Toxa <untoxa@mail.ru>
Date:   Fri,  1 Mar 2024 14:51:02 +0300

fix <symbol>_tile_pals[] array emission for the bit per pixel depth != 2

Diffstat:
Mgbdk-support/png2asset/maps.cpp2+-
Mgbdk-support/png2asset/metasprites.cpp2+-
Mgbdk-support/png2asset/png_image.h20++++++++++----------
3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/gbdk-support/png2asset/maps.cpp b/gbdk-support/png2asset/maps.cpp @@ -29,7 +29,7 @@ void GetMap( PNG2AssetData* assetData) for(int x = 0; x < (int)assetData->image.w; x += assetData->image.tile_w) { Tile tile(assetData->image.tile_w * assetData->image.tile_h); - assetData->image.ExtractTile(x, y, tile, assetData->args->sprite_mode, assetData->args->export_as_map, assetData->args->use_map_attributes); + assetData->image.ExtractTile(x, y, tile, assetData->args->sprite_mode, assetData->args->export_as_map, assetData->args->use_map_attributes, assetData->args->bpp); size_t idx; unsigned char props; diff --git a/gbdk-support/png2asset/metasprites.cpp b/gbdk-support/png2asset/metasprites.cpp @@ -30,7 +30,7 @@ void GetMetaSprite(int _x, int _y, int _w, int _h, int pivot_x, int pivot_y, PNG for(int x = _x; x < _x + _w && x < (int)assetData->image.w; x += assetData->image.tile_w) { Tile tile(assetData->image.tile_h * assetData->image.tile_w); - if(assetData->image.ExtractTile(x, y, tile, assetData->args->sprite_mode, assetData->args->export_as_map, assetData->args->use_map_attributes)) + if(assetData->image.ExtractTile(x, y, tile, assetData->args->sprite_mode, assetData->args->export_as_map, assetData->args->use_map_attributes, assetData->args->bpp)) { size_t idx; unsigned char props; diff --git a/gbdk-support/png2asset/png_image.h b/gbdk-support/png2asset/png_image.h @@ -51,10 +51,10 @@ public: // This needs separate tile_w and tile_h params since // MSX tile extraction uses it to pull out the 4 sub-tiles - bool ExtractGBTile(int x, int y, int extract_tile_w, int extract_tile_h, Tile& tile, int buffer_offset) + bool ExtractGBTile(int x, int y, int extract_tile_w, int extract_tile_h, Tile& tile, int buffer_offset, int bpp) { // Set the palette to 0 when pals are not stored in tiles to allow tiles to be equal even when their palettes are different - tile.pal = zero_palette ? 0 : data[w * y + x] >> 2; + tile.pal = zero_palette ? 0 : data[w * y + x] >> bpp; bool all_zero = true; for(int j = 0; j < extract_tile_h; ++j) @@ -69,29 +69,29 @@ public: return !all_zero; } - bool ExtractTile_MSX16x16(int x, int y, Tile& tile) + bool ExtractTile_MSX16x16(int x, int y, Tile& tile, int bpp) { // MSX 16x16 sprite tiles are composed of four 8x8 tiles in this order UL, LL, UR, LR bool UL_notempty, LL_notempty, UR_notempty, LR_notempty; // Call these separately since otherwise some get optimized out during // runtime if any single one before it returns false - UL_notempty = ExtractGBTile(x, y, 8, 8, tile, 0); - LL_notempty = ExtractGBTile(x, y + 8, 8, 8, tile, ((8 * 8) * 1)); - UR_notempty = ExtractGBTile(x + 8, y, 8, 8, tile, ((8 * 8) * 2)); - LR_notempty = ExtractGBTile(x + 8, y + 8, 8, 8, tile, ((8 * 8) * 3)); + UL_notempty = ExtractGBTile(x, y, 8, 8, tile, 0, bpp); + LL_notempty = ExtractGBTile(x, y + 8, 8, 8, tile, ((8 * 8) * 1), bpp); + UR_notempty = ExtractGBTile(x + 8, y, 8, 8, tile, ((8 * 8) * 2), bpp); + LR_notempty = ExtractGBTile(x + 8, y + 8, 8, 8, tile, ((8 * 8) * 3), bpp); return (UL_notempty || LL_notempty || UR_notempty || LR_notempty); } - bool ExtractTile(int x, int y, Tile& tile, int sprite_mode, bool export_as_map, bool use_map_attributes) + bool ExtractTile(int x, int y, Tile& tile, int sprite_mode, bool export_as_map, bool use_map_attributes, int bpp) { // Set the palette to 0 when pals are not stored in tiles to allow tiles to be equal even when their palettes are different zero_palette = !(export_as_map && !use_map_attributes); if(sprite_mode == SPR_16x16_MSX) - return ExtractTile_MSX16x16(x, y, tile); + return ExtractTile_MSX16x16(x, y, tile, bpp); else - return ExtractGBTile(x, y, tile_w, tile_h, tile, 0); // No buffer offset for normal tile extraction + return ExtractGBTile(x, y, tile_w, tile_h, tile, 0, bpp); // No buffer offset for normal tile extraction } // private: // bool zero_palette = false;

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.