From f66bd670faea539bf9c4fcede0708415563e691f Mon Sep 17 00:00:00 2001 From: Egor Date: Sun, 20 Aug 2023 21:13:11 +0300 Subject: [PATCH] thanm: minor cleanup after merge --- NEWS | 6 +++--- extlib/thtypes | 2 +- thanm/thanm.c | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 980541e..5a1403f 100644 --- a/NEWS +++ b/NEWS @@ -10,12 +10,12 @@ What's new in thtk master - New thanm spec format. See for more details. The old format is not supported anymore. Use thanm.old for it. - Game version now must be specified, just as with other tools. -- Support for TH18, TH185, TH19 has been added. +- Support for TH18, TH185, TH19 (full) has been added. - Support th143/bestshot.anm #### thanm.old - Will be removed in the next release. -- Support for TH18, TH185, TH19 has been added. +- Support for TH18, TH185, TH19 (trial) has been added. TH19 creation won't work, though. Use the new thanm instead. - You can now specify the version for the -l command. This is required for correct dumping of TH18, TH185. @@ -46,7 +46,7 @@ What's new in thtk master - Add -j option for converting strings between Shift-JIS and UTF-8. #### thdat -- Automatic version detection now supports th165, th17, th18 and th185. +- Automatic version detection now supports th165, th17, th18, th185, th19. - Detection works better with renamed files. - Support for TH18, TH185, TH19 has been added. - Improve extraction speed. diff --git a/extlib/thtypes b/extlib/thtypes index 896b7b7..f186e16 160000 --- a/extlib/thtypes +++ b/extlib/thtypes @@ -1 +1 @@ -Subproject commit 896b7b7996216f883420b57029b85f577a45ce27 +Subproject commit f186e1610cde229ece36becfb10bb5f63d8affcd diff --git a/thanm/thanm.c b/thanm/thanm.c index 05ce98e..116870a 100644 --- a/thanm/thanm.c +++ b/thanm/thanm.c @@ -1069,8 +1069,8 @@ anm_read_file( assert(header->rt_textureslot == 0); assert(header->zero3 == 0); - //if(header->version == 8) - // assert(header->lowresscale == 0 || header->lowresscale == 1); + if(header->version == 8) + assert((header->lowresscale&0xFE) == 0); /* Low byte can only be 0 or 1. High byte is used by TH19 */ /* Lengths, including padding, observed are: 16, 32, 48. */ entry->name = anm_get_name(archive, (const char*)map + header->nameoffset); @@ -1175,7 +1175,8 @@ anm_read_file( (thtx_header_t*)(map + header->thtxoffset); assert(util_strcmp_ref(thtx->magic, stringref("THTX")) == 0); assert(thtx->zero == 0); - //assert(thtx->w * thtx->h * format_Bpp(thtx->format) <= thtx->size); + /* NEWHU: 19 */ + assert(version == 19 || thtx->w * thtx->h * format_Bpp(thtx->format) <= thtx->size); assert( thtx->format == FORMAT_BGRA8888 || thtx->format == FORMAT_RGB565 || @@ -1478,7 +1479,7 @@ anm_extract( /* Then there's nothing to extract. */ return; } - + anm_entry_t* entry; list_for_each(&anm->entries, entry) { if (entry->header->hasdata && entry->name == name) { @@ -1508,8 +1509,8 @@ anm_extract( } } } - } - + } + png_write(name, &image); free(image.data); } @@ -1815,7 +1816,7 @@ anm_defaults( free(img_buf); fprintf(stderr, "%s: not a PNG or JFIF file. Image files must be encoded in PNG or JFIF for Touhou 19\n", entry->name); exit(1); - } + } entry->data = img_buf; continue; @@ -2111,7 +2112,7 @@ main( int command = -1; FILE* in; - + anm_archive_t* anm; #ifdef HAVE_LIBPNG anm_entry_t* entry; @@ -2336,7 +2337,7 @@ main( current_input = argv[1]; anm = anm_create(argv[1], symbolfp, version); - + if (symbolfp) fclose(symbolfp);