zmakebas1
Convert text file into spectrum basic program
Usage
zmakebas [-hlr]
[-a
startline]
[-i
incr]
[-n
speccy_filename]
[-o
output_file]
[-s
line]
[input_file]
Overview
zmakebas converts a Spectrum Basic program written as a text file into an actual speccy Basic file (as a .TAP file, or optionally a raw headerless file). By default, input comes from stdin, and output goes to `out.tap'.
Using zmakebas rather than (say) writing the Basic in an emulator means you can write using a nicer editor, and can use tools which work on text files, etc. Also, with the `-l' option you can write without line numbers, using labels in their place where necessary.
The program was originally intended to be used simply to make little loader programs, so they wouldn't have to be sourceless binaries. However, I went to a fair amount of effort to make sure it'd work for bigger, more serious programs too, so you can also use it for that kind of thing.
Options
-
-a -
make the generated file auto-start from line startline. If `-l' was specified, this can be a label, but don't forget to include the initial `@' to point this out.
-
-h -
give help on command line options.
-
-i -
in labels mode, set line number increment (default 2).
-
-l -
use labels rather than line numbers.
-
-n -
specify filename to use in .TAP file (up to 10 chars), i.e. the filename the speccy will see. Default is a blank filename (10 spaces).
-
-o -
output to output_file rather than the default `out.tap'. Use `-' as the filename to output on stdout.
-
-r -
write a raw headerless Basic file, rather than the default .TAP file.
-
-s -
in labels mode, set starting line number (default 10).
Input format
The input should be much as you would type into a speccy (a 128, to be precise), with the following exceptions:
Lines starting with `#' are ignored. This allows you to insert comments which are not copied into the output Basic file.
Blank lines are ignored.
Case is ignored in keywords - `print', `PRINT', and `pRiNt' are equivalent.
You can optionally use `randomise' as an alternative to `randomize'.
You can get hex numbers by using `bin' with a C-style hex number, e.g. to get 1234h you'd use `bin 0x1234'. (It appears in exactly that form in the speccy listing, though, so don't use it if you want to be able to edit the output program on a speccy.)
You can get a pound sign (character 96 on a speccy) by using a backquote (`).
One input line normally equals one line of Basic, but you can use backslash as the last character of a line to continue the statement(s) on the next input line.
Rather than literally inserting block graphics characters and UDGs as you would on a speccy, you should use an escape sequence. These begin with a backslash (`\'). To get a UDG, follow this backslash with the UDG's letter, in the range `a' to `u' (`t' and `u' will only have the desired effect if the program is run on a 48k speccy or in 48k mode, though); both upper and lowercase work. To get the copyright symbol, follow it with `*'. To get a block graphics character, follow it with a two-character `drawing' of it using spaces, dots, apostrophes and/or colons. (For example, you'd get character 135 with `\':', and character 142 with `\:.'.) To get a literal `@', follow it with `@'. (This is needed only if the `-l' option was given, but works whether it was or not.) To specify a literal eight-bit character code to dump into the Basic output file directly (to use for embedded colour control codes and the like), use braces and a C-syntax number e.g. `\{42}' for decimal, and `\{0x42}' for hex. Finally, as usual with such things, you can get a literal backslash by following the first backslash with another.
If the `-l' option was given, line numbers must be omitted. Instead these are automatically generated in the output, and you can use labels where necessary as substitute line numbers for `goto' commands etc. A label is defined with the text `@label:' at the beginning of a line (possibly preceded by whitespace). It can be referred to (before or after) with `@label'. Any printable ASCII character other than colon and space can be used in a label name. Here's an example of how labels work, showing both the input and (listing of) the output - first, the input:
goto @foo
print "not seen"
@foo: print "hello world"
Now the output:
10 GO TO 14
12 PRINT "not seen"
14 PRINT "hello world"
Note that case is significant for labels; `foo' and `FOO' are different.
Releases
10 releases since Debian 4.0 (Etch); the text changed 2 times.