ref: 8b1351fc3ea510cf56c072a65ac526e73604b6d3
parent: d6cd5823e3053bbcf356715e3a4933aa6f94c6f0
author: JL2210 <[email protected]>
date: Mon Apr 13 05:57:00 EDT 2020
Add option to disable padding in rgblink Fixes #307 RGBFIX can handle padding, so there's no reason why we can't add an option to disable padding in rgblink. Signed-off-by: JL2210 <[email protected]>
--- a/include/link/main.h
+++ b/include/link/main.h
@@ -27,6 +27,7 @@
extern bool is32kMode;
extern bool beVerbose;
extern bool isWRA0Mode;
+extern bool disablePadding;
/* Helper macro for printing verbose-mode messages */
#define verbosePrint(...) do { \
--- a/src/link/main.c
+++ b/src/link/main.c
@@ -34,6 +34,7 @@
bool is32kMode; /* -t */
bool beVerbose; /* -v */
bool isWRA0Mode; /* -w */
+bool disablePadding; /* -x */
static uint32_t nbErrors = 0;
@@ -83,7 +84,7 @@
}
/* Short options */
-static char const *optstring = "dl:m:n:O:o:p:s:tVvw";
+static char const *optstring = "dl:m:n:O:o:p:s:tVvwx";
/*
* Equivalent long options
@@ -108,6 +109,7 @@
{ "version", no_argument, NULL, 'V' },
{ "verbose", no_argument, NULL, 'v' },
{ "wramx", no_argument, NULL, 'w' },
+ { "nopad", no_argument, NULL, 'x' },
{ NULL, no_argument, NULL, 0 }
};
@@ -126,6 +128,7 @@
" -n, --sym <path> set the output symbol list file\n"
" -o, --output <path> set the output file\n"
" -p, --pad <value> set the value to pad between sections with\n"
+" -x, --nopad disable padding of output binary\n"
" -V, --version print RGBLINK version and exits\n"
"\n"
"For help, use `man rgblink' or go to https://rednex.github.io/rgbds/\n",
@@ -198,6 +201,11 @@
break;
case 'w':
isWRA0Mode = true;
+ break;
+ case 'x':
+ disablePadding = true;
+ /* implies tiny mode */
+ is32kMode = true;
break;
default:
printUsage();
--- a/src/link/output.c
+++ b/src/link/output.c
@@ -175,9 +175,13 @@
bankSections = bankSections->next;
}
- while (offset < size) {
- putc(overlayFile ? getc(overlayFile) : padValue, outputFile);
- offset++;
+ if (!disablePadding) {
+ while (offset < size) {
+ putc(overlayFile ? getc(overlayFile)
+ : padValue,
+ outputFile);
+ offset++;
+ }
}
}