mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Merge pull request #513 from JL2210/disable-padding-option
Add option to disable padding in rgblink
This commit is contained in:
@@ -27,6 +27,7 @@ extern uint8_t padValue;
|
|||||||
extern bool is32kMode;
|
extern bool is32kMode;
|
||||||
extern bool beVerbose;
|
extern bool beVerbose;
|
||||||
extern bool isWRA0Mode;
|
extern bool isWRA0Mode;
|
||||||
|
extern bool disablePadding;
|
||||||
|
|
||||||
/* Helper macro for printing verbose-mode messages */
|
/* Helper macro for printing verbose-mode messages */
|
||||||
#define verbosePrint(...) do { \
|
#define verbosePrint(...) do { \
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ uint8_t padValue; /* -p */
|
|||||||
bool is32kMode; /* -t */
|
bool is32kMode; /* -t */
|
||||||
bool beVerbose; /* -v */
|
bool beVerbose; /* -v */
|
||||||
bool isWRA0Mode; /* -w */
|
bool isWRA0Mode; /* -w */
|
||||||
|
bool disablePadding; /* -x */
|
||||||
|
|
||||||
static uint32_t nbErrors = 0;
|
static uint32_t nbErrors = 0;
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ FILE *openFile(char const *fileName, char const *mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Short options */
|
/* 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
|
* Equivalent long options
|
||||||
@@ -108,6 +109,7 @@ static struct option const longopts[] = {
|
|||||||
{ "version", no_argument, NULL, 'V' },
|
{ "version", no_argument, NULL, 'V' },
|
||||||
{ "verbose", no_argument, NULL, 'v' },
|
{ "verbose", no_argument, NULL, 'v' },
|
||||||
{ "wramx", no_argument, NULL, 'w' },
|
{ "wramx", no_argument, NULL, 'w' },
|
||||||
|
{ "nopad", no_argument, NULL, 'x' },
|
||||||
{ NULL, no_argument, NULL, 0 }
|
{ NULL, no_argument, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,7 +119,7 @@ static struct option const longopts[] = {
|
|||||||
static void printUsage(void)
|
static void printUsage(void)
|
||||||
{
|
{
|
||||||
fputs(
|
fputs(
|
||||||
"Usage: rgblink [-dtVvw] [-l script] [-m map_file] [-n sym_file]\n"
|
"Usage: rgblink [-dtVvwx] [-l script] [-m map_file] [-n sym_file]\n"
|
||||||
" [-O overlay_file] [-o out_file] [-p pad_value] [-s symbol]\n"
|
" [-O overlay_file] [-o out_file] [-p pad_value] [-s symbol]\n"
|
||||||
" <file> ...\n"
|
" <file> ...\n"
|
||||||
"Useful options:\n"
|
"Useful options:\n"
|
||||||
@@ -126,6 +128,7 @@ static void printUsage(void)
|
|||||||
" -n, --sym <path> set the output symbol list file\n"
|
" -n, --sym <path> set the output symbol list file\n"
|
||||||
" -o, --output <path> set the output file\n"
|
" -o, --output <path> set the output file\n"
|
||||||
" -p, --pad <value> set the value to pad between sections with\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"
|
" -V, --version print RGBLINK version and exits\n"
|
||||||
"\n"
|
"\n"
|
||||||
"For help, use `man rgblink' or go to https://rednex.github.io/rgbds/\n",
|
"For help, use `man rgblink' or go to https://rednex.github.io/rgbds/\n",
|
||||||
@@ -199,6 +202,11 @@ int main(int argc, char *argv[])
|
|||||||
case 'w':
|
case 'w':
|
||||||
isWRA0Mode = true;
|
isWRA0Mode = true;
|
||||||
break;
|
break;
|
||||||
|
case 'x':
|
||||||
|
disablePadding = true;
|
||||||
|
/* implies tiny mode */
|
||||||
|
is32kMode = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
printUsage();
|
printUsage();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|||||||
@@ -175,11 +175,15 @@ static void writeBank(struct SortedSection *bankSections, uint16_t baseOffset,
|
|||||||
bankSections = bankSections->next;
|
bankSections = bankSections->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!disablePadding) {
|
||||||
while (offset < size) {
|
while (offset < size) {
|
||||||
putc(overlayFile ? getc(overlayFile) : padValue, outputFile);
|
putc(overlayFile ? getc(overlayFile)
|
||||||
|
: padValue,
|
||||||
|
outputFile);
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a ROM file to the output.
|
* Writes a ROM file to the output.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
.Nd Game Boy linker
|
.Nd Game Boy linker
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl dtVvw
|
.Op Fl dtVvwx
|
||||||
.Op Fl l Ar linker_script
|
.Op Fl l Ar linker_script
|
||||||
.Op Fl m Ar map_file
|
.Op Fl m Ar map_file
|
||||||
.Op Fl n Ar sym_file
|
.Op Fl n Ar sym_file
|
||||||
@@ -102,6 +102,14 @@ Print the version of the program and exit.
|
|||||||
Verbose: enable printing more information to standard error.
|
Verbose: enable printing more information to standard error.
|
||||||
.It Fl w , Fl Fl wramx
|
.It Fl w , Fl Fl wramx
|
||||||
Expand the WRAM0 section size from 4 KiB to the full 8 KiB assigned to WRAM and prohibit the use of WRAMX sections.
|
Expand the WRAM0 section size from 4 KiB to the full 8 KiB assigned to WRAM and prohibit the use of WRAMX sections.
|
||||||
|
.It Fl x , Fl Fl nopad
|
||||||
|
Disables padding the end of the final file.
|
||||||
|
This option automatically enables
|
||||||
|
.Fl t .
|
||||||
|
You can use this when not not making a ROM.
|
||||||
|
When making a ROM, be careful that not using this is not a replacement for
|
||||||
|
.Xr rgbfix 1 Ap s Fl p
|
||||||
|
option!
|
||||||
.El
|
.El
|
||||||
.Sh EXAMPLES
|
.Sh EXAMPLES
|
||||||
All you need for a basic ROM is an object file, which can be made into a ROM image like so:
|
All you need for a basic ROM is an object file, which can be made into a ROM image like so:
|
||||||
|
|||||||
Reference in New Issue
Block a user