git.y1.nz

gbdk-2020

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

commit 339410f4df50540baee8336bd73e83c500046749
parent 5ed7455470c431b0bf1482d6e457dfb3ebb8afcf
Author: Toxa <untoxa@mail.ru>
Date:   Wed,  3 Feb 2021 15:55:46 +0300

Merge branch 'develop' of https://github.com/Zal0/gbdk-2020 into develop

Diffstat:
Mgbdk-lib/examples/gb/metasprites/metasprites.c7++++++-
Mgbdk-lib/include/gb/metasprites.h7++++---
Mgbdk-support/png2mtspr/png2mtspr.cpp12++++++++++--
3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/gbdk-lib/examples/gb/metasprites/metasprites.c b/gbdk-lib/examples/gb/metasprites/metasprites.c @@ -34,7 +34,12 @@ void main(void) { set_sprite_tile(0, 0); // show bkg and sprites - SHOW_BKG; SPRITES_8x16; SHOW_SPRITES; + SHOW_BKG; SHOW_SPRITES; + #if sprite_TILE_H == 16 + SPRITES_8x16; + #else + SPRITES_8x8; + #endif // init 2 joypads joypad_init(1, &joypads); diff --git a/gbdk-lib/include/gb/metasprites.h b/gbdk-lib/include/gb/metasprites.h @@ -29,6 +29,7 @@ static void __hide_metasprite(UINT8 id); * @param base_sprite start hardware sprite * @param x absolute x coordinate of the sprite * @param y absolute y coordinate of the sprite + * @return number of hardware sprites used to draw this metasprite **/ inline UBYTE move_metasprite(const metasprite_t * metasprite, UINT8 base_tile, UINT8 base_sprite, UINT8 x, UINT8 y) { __current_metasprite = metasprite; @@ -39,19 +40,19 @@ inline UBYTE move_metasprite(const metasprite_t * metasprite, UINT8 base_tile, U inline UBYTE move_metasprite_vflip(const metasprite_t * metasprite, UINT8 base_tile, UINT8 base_sprite, UINT8 x, UINT8 y) { __current_metasprite = metasprite; __current_base_tile = base_tile; - return __move_metasprite_vflip(base_sprite, x, y); + return __move_metasprite_vflip(base_sprite, x - 8, y); } inline UBYTE move_metasprite_hflip(const metasprite_t * metasprite, UINT8 base_tile, UINT8 base_sprite, UINT8 x, UINT8 y) { __current_metasprite = metasprite; __current_base_tile = base_tile; - return __move_metasprite_hflip(base_sprite, x, y); + return __move_metasprite_hflip(base_sprite, x, y - ((LCDC_REG & 0x04U) ? 16 : 8) ); } inline UBYTE move_metasprite_hvflip(const metasprite_t * metasprite, UINT8 base_tile, UINT8 base_sprite, UINT8 x, UINT8 y) { __current_metasprite = metasprite; __current_base_tile = base_tile; - return __move_metasprite_hvflip(base_sprite, x, y); + return __move_metasprite_hvflip(base_sprite, x - 8, y - ((LCDC_REG & 0x04U) ? 16 : 8)); } /** diff --git a/gbdk-support/png2mtspr/png2mtspr.cpp b/gbdk-support/png2mtspr/png2mtspr.cpp @@ -147,8 +147,8 @@ bool FindTile(const Tile& t, unsigned char& idx, unsigned char& props) void GetMetaSprite(int _x, int _y, int _w, int _h, int pivot_x, int pivot_y) { - unsigned char last_x = _x + pivot_x - 4; - unsigned char last_y = _y + pivot_y - (tile_h == 8 ? 4 : 8); + unsigned char last_x = _x + pivot_x; + unsigned char last_y = _y + pivot_y; sprites.push_back(MetaSprite()); MetaSprite& mt_sprite = sprites.back(); @@ -288,6 +288,13 @@ int main(int argc, char *argv[]) return 1; } + fprintf(file, "//AUTOGENERATED FILE FROM png2mtspr\n"); + fprintf(file, "#define %s_TILE_H %d\n", data_name.c_str(), tile_h); + fprintf(file, "#define %s_WIDTH %d\n", data_name.c_str(), sprite_w); + fprintf(file, "#define %s_HEIGHT %d\n", data_name.c_str(), sprite_h); + fprintf(file, "#define %s_PIVOT_X %d\n", data_name.c_str(), pivot_x); + fprintf(file, "#define %s_PIVOT_Y %d\n", data_name.c_str(), pivot_y); + fprintf(file, "\n"); fprintf(file, "extern const UINT8 %s_data[%d];\n", data_name.c_str(), tiles.size() * tile_h * 2); fprintf(file, "extern const metasprite_t* const %s_metasprites[%d];\n", data_name.c_str(), sprites.size()); @@ -300,6 +307,7 @@ int main(int argc, char *argv[]) return 1; } + fprintf(file, "//AUTOGENERATED FILE FROM png2mtspr\n\n"); fprintf(file, "#include <gb/gb.h>\n"); fprintf(file, "#include <gb/metasprites.h>\n"); fprintf(file, "\n");

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