gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit d7265ebb0e80e2bd2c365161a864bede3ac2292c parent 646dd3cdb768b733d4f20beeb4e565abac869885 Author: Toxa <56631470+untoxa@users.noreply.github.com> Date: Sat, 26 Dec 2020 13:43:34 +0300 Merge pull request #113 from bbbbbr/develop_bankpack_fix_rewritefilter Bankpack: Fix incorrect filtering of symbols to rewrite Diffstat:
| M | gbdk-support/bankpack/obj_data.c | 32 | +++++++++++++++++++------------- |
| M | gbdk-support/bankpack/obj_data.h | 1 | + |
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/gbdk-support/bankpack/obj_data.c b/gbdk-support/bankpack/obj_data.c @@ -545,31 +545,37 @@ bool symbol_banked_check_rewrite_ok(char * symbol_name, uint32_t file_id) { bool symbol_modify_and_write_to_file(char * strline_in, FILE * out_file, uint16_t bank_num, uint32_t file_id) { uint32_t c; + uint32_t bank_in = 0; char strmatch[OBJ_NAME_MAX_STR_LEN]; char symbol_name[OBJ_NAME_MAX_STR_LEN]; symbol_match_item * sym_match = (symbol_match_item *)symbol_matchlist.p_array; - // Only rewrite banked symbol entries (include end of line chars) + // Only rewrite banked symbol entries if (strline_in[0] == 'S') { // For lines: S b_<symbol name>... Def0000FF - if (sscanf(strline_in,"S b_%" TOSTR(OBJ_NAME_MAX_STR_LEN) "s Def0000FF", symbol_name)) { - if (symbol_banked_check_rewrite_ok(symbol_name, file_id)) { - fprintf(out_file, "S b_%s Def0000%02x", symbol_name, bank_num); - if (strline_in[(strlen(strline_in)-1)] != '\n') - fprintf(out_file, "\n"); - return true; + if (SYMBOL_REWRITE_RECORDS == sscanf(strline_in,"S b_%" TOSTR(OBJ_NAME_MAX_STR_LEN) "s Def%06x", symbol_name, &bank_in)) { + if (bank_in == BANK_NUM_AUTO) { + if (symbol_banked_check_rewrite_ok(symbol_name, file_id)) { + fprintf(out_file, "S b_%s Def0000%02x", symbol_name, bank_num); + if (strline_in[(strlen(strline_in)-1)] != '\n') + fprintf(out_file, "\n"); + return true; + } } } // For lines: S ___bank_<trailing symbol name>... Def0000FF else { for (c = 0; c < symbol_matchlist.count; c++) { - if (snprintf(strmatch, sizeof(strmatch), "S %s%%" TOSTR(OBJ_NAME_MAX_STR_LEN) "s Def0000FF", sym_match[c].name) > sizeof(strmatch)) + // Prepare a sscanf match test string for the current symbol name + if (snprintf(strmatch, sizeof(strmatch), "S %s%%" TOSTR(OBJ_NAME_MAX_STR_LEN) "s Def%%06x", sym_match[c].name) > sizeof(strmatch)) printf("BankPack: Warning: truncated symbol match string to:%s\n",strmatch); - if (sscanf(strline_in, strmatch, symbol_name)) { - fprintf(out_file, "S %s%s Def0000%02x", sym_match[c].name, symbol_name, bank_num); - if (strline_in[(strlen(strline_in)-1)] != '\n') - fprintf(out_file, "\n"); - return true; + if (SYMBOL_REWRITE_RECORDS == sscanf(strline_in, strmatch, symbol_name, &bank_in)) { + if (bank_in == BANK_NUM_AUTO) { + fprintf(out_file, "S %s%s Def0000%02x", sym_match[c].name, symbol_name, bank_num); + if (strline_in[(strlen(strline_in)-1)] != '\n') + fprintf(out_file, "\n"); + return true; + } } } } diff --git a/gbdk-support/bankpack/obj_data.h b/gbdk-support/bankpack/obj_data.h @@ -10,6 +10,7 @@ #define OBJ_NAME_MAX_STR_LEN 255 #define AREA_LINE_RECORDS 2 // Bank number, Size #define SYMBOL_LINE_RECORDS 2 // Name, DefVal +#define SYMBOL_REWRITE_RECORDS 2 // Name, DefVal typedef struct bank_item {
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.