diff options
-rw-r--r-- | blob2xex.1 | 19 | ||||
-rw-r--r-- | blob2xex.c | 18 | ||||
-rw-r--r-- | blob2xex.rst | 17 |
3 files changed, 34 insertions, 20 deletions
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "BLOB2XEX" 1 "2024-05-03" "0.2.1" "Urchlay's Atari 8-bit Tools" +.TH "BLOB2XEX" 1 "2024-05-16" "0.2.1" "Urchlay's Atari 8-bit Tools" .SH NAME blob2xex \- Create Atari 8-bit executables from arbitrary data .\" RST source for blob2xex(1) man page. Convert with: @@ -44,8 +44,12 @@ more files of arbitrary data. Each input file will become a separate segment in the binary load file. A run address can be added with the \fB\-r\fP option. .sp -Each input file \fIrequires\fP a \fB\-l\fP \fIloadaddr\fP option, to set the -load address. Optionally, init addresses can be included, per\-segment +The first input file \fIrequires\fP a \fB\-l\fP \fIloadaddr\fP option, to set the +load address. Further input files can have their load addresses set +with \fB\-l\fP, also. If an input file lacks a load address, it will +load at the next address after the previous file\(aqs ending address. +.sp +Optionally, init addresses can be included, per\-segment (\fB\-i\fP). Also, using \fB\-o\fP and \fB\-s\fP, it\(aqs possible to include only part of the input file. To read from standard input, use \fB\-\fP for the \fIinfile\fP\&. @@ -71,6 +75,11 @@ A space is required between an option and its argument; use e.g. \fB\-l 0x2000\f not \fB\-l0x2000\fP\&. .INDENT 0.0 .TP +.B \-l \fIloadaddr\fP +Required; set the load address of the next \fIinfile\fP\&. The first \fIinfile\fP +\fBmust\fP be preceded by a \fB\-l\fP option; it\(aqs optional for the 2nd and +further files. +.TP .B \-r \fIrunaddr\fP Optional; set the run address. Default is no run address. Since a \&.xex file can only have one run address, there\(aqs no point in giving @@ -78,10 +87,6 @@ multiple \fB\-r\fP options. If you do, the last one will be used. This option should be first on the command line (right after \fIoutfile\fP), or at least must occur before any \fIinfile\fP\&. .TP -.B \-l \fIloadaddr\fP -Required; set the load address of the next \fIinfile\fP\&. Each \fIinfile\fP -\fBmust\fP be preceded by a \fB\-l\fP option. -.TP .B \-i \fIinitaddr\fP Optional; set an init address, to be executed after the next segment loads. Default is no init address. @@ -134,7 +134,7 @@ int write_segment( } fclose(infh); - return(1); + return(seg.len); } void usage() { @@ -148,6 +148,7 @@ void usage() { int main(int argc, char **argv) { char *outfile = 0, *infile = 0; int i, loadaddr = -1, runaddr = -1, initaddr = -1, offset = 0, size = DEFAULT_SIZE, *param = 0; + int bytes = 0, was_file = 0; int segcount = 0, incount = 0; outfile = argv[1]; @@ -172,6 +173,7 @@ int main(int argc, char **argv) { if(!arg[0]) continue; /* skip empty args */ if(param) { /* previous option needs an argument */ + was_file = 0; if(param == &offset) { if( (offset = get_offset(arg) ) < 0 ) exit(1); @@ -181,6 +183,7 @@ int main(int argc, char **argv) { } param = 0; } else if(arg[0] == '-' && arg[1] != '\0') { + was_file = 0; infile = 0; switch(arg[1]) { case 'l': param = &loadaddr; break; @@ -196,26 +199,27 @@ int main(int argc, char **argv) { break; } } else { + was_file = 1; if(loadaddr == -1) { - fprintf(stderr, SELF ": input filename without load address (-l): %s\n", arg); - segcount = 0; - break; + fprintf(stderr, SELF ": at least one load address (-l) is required.\n"); + exit(1); } infile = arg; incount++; - if(write_segment(infile, outfile, loadaddr, initaddr, offset, size)) { + if( (bytes = write_segment(infile, outfile, loadaddr, initaddr, offset, size)) ) { segcount++; + loadaddr += bytes; } else { segcount = 0; break; } infile = 0; - loadaddr = -1; initaddr = -1; offset = 0; size = DEFAULT_SIZE; + initaddr = -1; offset = 0; size = DEFAULT_SIZE; } } if(incount) { - if(segcount && ((param || (loadaddr >= 0) || (initaddr >= 0)) || + if(segcount && ((param || !was_file || (initaddr >= 0)) || (offset != 0) || (size != DEFAULT_SIZE))) { fprintf(stderr, SELF ": " diff --git a/blob2xex.rst b/blob2xex.rst index 125772c..a3161ab 100644 --- a/blob2xex.rst +++ b/blob2xex.rst @@ -24,8 +24,12 @@ more files of arbitrary data. Each input file will become a separate segment in the binary load file. A run address can be added with the **-r** option. -Each input file *requires* a **-l** *loadaddr* option, to set the -load address. Optionally, init addresses can be included, per-segment +The first input file *requires* a **-l** *loadaddr* option, to set the +load address. Further input files can have their load addresses set +with **-l**, also. If an input file lacks a load address, it will +load at the next address after the previous file's ending address. + +Optionally, init addresses can be included, per-segment (**-i**). Also, using **-o** and **-s**, it's possible to include only part of the input file. To read from standard input, use **-** for the *infile*. @@ -52,6 +56,11 @@ OPTIONS A space is required between an option and its argument; use e.g. **-l 0x2000**, not **-l0x2000**. +-l *loadaddr* + Required; set the load address of the next *infile*. The first *infile* + **must** be preceded by a **-l** option; it's optional for the 2nd and + further files. + -r *runaddr* Optional; set the run address. Default is no run address. Since a .xex file can only have one run address, there's no point in giving @@ -59,10 +68,6 @@ not **-l0x2000**. option should be first on the command line (right after *outfile*), or at least must occur before any *infile*. --l *loadaddr* - Required; set the load address of the next *infile*. Each *infile* - **must** be preceded by a **-l** option. - -i *initaddr* Optional; set an init address, to be executed after the next segment loads. Default is no init address. |