git.y1.nz

gbdk-2020

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

commit b9169861fc9e8d24aa9a6c1a4a13afc3d8b40b3c
parent dd05ae2c54f34a06a87ff624b530a60f5e8405d6
Author: Toxa <56631470+untoxa@users.noreply.github.com>
Date:   Fri,  1 Aug 2025 09:44:46 +0300

Merge pull request #803 from RodrigoCard/gbcompress-includeguards

Include guards for h files generated with gbcompress
Diffstat:
Mgbdk-support/gbcompress/files_c_source.c13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/gbdk-support/gbcompress/files_c_source.c b/gbdk-support/gbcompress/files_c_source.c @@ -188,13 +188,13 @@ bool file_write_c_output_from_buffer(char * filename, uint8_t * p_buf, uint32_t // If Bank Num is set add a .h bank ref if (bank_num != BANK_NUM_ROM_UNSET) { + fprintf(file_out, "#pragma bank %d\n\n", bank_num); fprintf(file_out, "#include <gbdk/platform.h>\n\n"); - fprintf(file_out, "#pragma bank %d\n", bank_num); fprintf(file_out, "BANKREF(%s)\n\n", var_name); } // Array entry with variable name - fprintf(file_out, "\n\n%s unsigned char %s[] = {", (var_is_const) ? "const" : "", var_name); + fprintf(file_out, "%s unsigned char %s[] = {", (var_is_const) ? "const" : "", var_name); for (i = 0; i < data_len; i++) { @@ -227,7 +227,10 @@ bool file_write_c_output_from_buffer(char * filename, uint8_t * p_buf, uint32_t FILE * file_out = fopen(filename, "w"); if (file_out) { - + // Include guards + fprintf(file_out, "#ifndef GBCOMPRESS_%s_H\n", var_name); + fprintf(file_out, "#define GBCOMPRESS_%s_H\n\n", var_name); + // If Bank Num is set add a .h bank ref if (bank_num != BANK_NUM_ROM_UNSET) { fprintf(file_out, "#include <gbdk/metasprites.h>\n\n"); @@ -238,7 +241,9 @@ bool file_write_c_output_from_buffer(char * filename, uint8_t * p_buf, uint32_t fprintf(file_out, "#define %s_sz_decomp %d\n", var_name, size_decompressed); // array entry with variable name - fprintf(file_out, "\n\nextern %s unsigned char %s[];\n\n", (var_is_const) ? "const" : "", var_name); + fprintf(file_out, "\nextern %s unsigned char %s[];\n\n", (var_is_const) ? "const" : "", var_name); + + fprintf(file_out, "#endif"); fclose(file_out); }

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