aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--f2toxex.c64
-rw-r--r--f2toxex.rst66
-rw-r--r--manftr.rst1
4 files changed, 133 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 4d56cea..0ad36d3 100644
--- a/Makefile
+++ b/Makefile
@@ -14,9 +14,9 @@ CC=gcc
CFLAGS=-Wall $(COPT) -ansi -D_GNU_SOURCE -DVERSION=\"$(VERSION)\"
# BINS and SCRIPTS go in $BINDIR, DOCS go in $DOCDIR
-BINS=a8eol xfd2atr atr2xfd blob2c cart2xex fenders xexsplit xexcat atrsize rom2cart unmac65 axe blob2xex xexamine
+BINS=a8eol xfd2atr atr2xfd blob2c cart2xex fenders xexsplit xexcat atrsize rom2cart unmac65 axe blob2xex xexamine f2toxex
SCRIPTS=dasm2atasm a8utf8
-MANS=a8eol.1 xfd2atr.1 atr2xfd.1 blob2c.1 cart2xex.1 fenders.1 xexsplit.1 xexcat.1 atrsize.1 rom2cart.1 unmac65.1 axe.1 dasm2atasm.1 a8utf8.1 blob2xex.1 xexamine.1
+MANS=a8eol.1 xfd2atr.1 atr2xfd.1 blob2c.1 cart2xex.1 fenders.1 xexsplit.1 xexcat.1 atrsize.1 rom2cart.1 unmac65.1 axe.1 dasm2atasm.1 a8utf8.1 blob2xex.1 xexamine.1 f2toxex.1
DOCS=README equates.inc *.dasm
# All the programs share this version number...
diff --git a/f2toxex.c b/f2toxex.c
new file mode 100644
index 0000000..c2a4934
--- /dev/null
+++ b/f2toxex.c
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "xex.h"
+
+#define SELF "f2toxex"
+
+void version() {
+ printf(SELF " " VERSION "\n");
+}
+
+void usage() {
+ version();
+ printf(" Usage: " SELF " [-h | -v] | infile [outfile]\n");
+}
+
+char *make_outfile(char *infile) {
+}
+
+int main(int argc, char **argv) {
+ int c;
+ char *infile, *outfile;
+
+ while( (c = getopt(argc, argv, "hv")) > 0) {
+ switch(c) {
+ case 'h':
+ usage();
+ exit(0);
+ break;
+ case 'v':
+ version();
+ exit(0);
+ break;
+ default:
+ fprintf(stderr, SELF ": unknown option '-%c'.\n", c);
+ usage();
+ exit(1);
+ break;
+ }
+ }
+
+ if(argc > optind) {
+ infile = argv[optind];
+ optind++;
+ }
+
+ if(argc > optind) {
+ strcpy(outfile, argv[optind]);
+ optind++;
+
+ if(argc > optind)
+ fprintf(stderr, SELF ": "
+ "ignoring extra junk on command line: '%s'.\n", argv[optind]);
+ } else if(strcmp(infile, "-") != 0) {
+ outfile = make_outfile(infile);
+ }
+
+
+ return 0;
+}
diff --git a/f2toxex.rst b/f2toxex.rst
new file mode 100644
index 0000000..85d29a1
--- /dev/null
+++ b/f2toxex.rst
@@ -0,0 +1,66 @@
+.. RST source for f2toxex(1) man page. Convert with:
+.. rst2man.py f2toxex.rst > f2toxex.1
+
+=======
+f2toxex
+=======
+
+-------------------------------------------------------------
+Convert a DASM "-f2" object file to an Atari 8-bit executable
+-------------------------------------------------------------
+
+.. include:: manhdr.rst
+
+SYNOPSIS
+========
+
+f2toxex [ [**-h** | **-v** ] | *infile* [*outfile*] ]
+
+DESCRIPTION
+===========
+
+**f2toxex** converts an object code file created by the **dasm**\(1)
+assembler, using its **-f2** option, to an Atari 8-bit executable
+(.xex file).
+
+*infile* may be **-** to read from standard input. *outfile* may be
+**-** to write to standard output.
+
+If *outfile* is omitted, the output will be written to:
+
+- If reading from standard input, write to standard output.
+
+- If reading from a file whose name ends with an extension, replace
+ the extension with *.xex*.
+
+- Otherwise, append *.xex* to the input filename.
+
+NOTES
+=====
+
+The DASM -f2 output format is described in section **3.3.4** of the
+DASM manual (**dasm.pdf**). It's reproduced here for reference:
+
+ RAS (Random Access Segment). The output file contains one
+ or more hunks. Each hunk consists of a 2 byte origin (little-
+ endian), 2 byte length (little-endian), and that number of data
+ bytes. The hunks occur in the same order as initialized segments
+ in the assembly. There are no restrictions to segment ordering
+ (i.e. reverse indexed ORG statements are allowed). The next hunk
+ begins after the previous hunk's data, until the end of the file.
+
+OPTIONS
+=======
+
+-h
+ Print a short help message and exit.
+
+-v
+ Verbose operation.
+
+EXIT STATUS
+===========
+
+Exit status is zero for success, non-zero for failure.
+
+.. include:: manftr.rst
diff --git a/manftr.rst b/manftr.rst
index 1bcec84..f11f158 100644
--- a/manftr.rst
+++ b/manftr.rst
@@ -20,6 +20,7 @@ SEE ALSO
**blob2xex**\(1),
**cart2xex**\(1),
**dasm2atasm**\(1),
+**f2toxex**\(1),
**fenders**\(1),
**rom2cart**\(1),
**unmac65**\(1),