File: zmakebas.1

package info (click to toggle)
zmakebas 1.2-1.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 108 kB
  • ctags: 48
  • sloc: ansic: 738; makefile: 29; sh: 23
file content (237 lines) | stat: -rw-r--r-- 8,663 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
.\" -*- nroff -*-
.\"
.\" zmakebas - convert text file into Spectrum Basic program
.\" Public domain by Russell Marks, 1998.
.\"
.\" zmakebas.1 - man page
.\"
.TH zmakebas 1 "1st May, 2004" "Version 1.2" "Retrocomputing Tools"
.\"
.\"------------------------------------------------------------------
.\"
.SH NAME
zmakebas \- convert text file into Spectrum Basic program
.\"
.\"------------------------------------------------------------------
.\"
.SH SYNOPSIS
.PD 0
.B zmakebas
.RB [ -hlr ]
.RB [ -a
.IR startline ]
.RB [ -i
.IR incr ]
.RB [ -n
.IR speccy_filename ]
.RB [ -o
.IR output_file ]
.RB [ -s
.IR line ]
.RI [ input_file ]
.P
.PD 1
.\"
.\"------------------------------------------------------------------
.\"
.SH DESCRIPTION
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'.
.PP
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.
.PP
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.
.\"
.\"------------------------------------------------------------------
.\"
.SH OPTIONS
.TP
.I -a
make the generated file auto-start from line
.IR startline .
If `-l' was specified, this can be a label, but don't forget to
include the initial `@' to point this out.
.TP
.I -h
give help on command line options.
.TP
.I -i
in labels mode, set line number increment (default 2).
.TP
.I -l
use labels rather than line numbers.
.TP
.I -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).
.TP
.I -o
output to
.I output_file
rather than the default `out.tap'. Use `-' as the filename to output
on stdout.
.TP
.I -r
write a raw headerless Basic file, rather than the default .TAP file.
.TP
.I -s
in labels mode, set starting line number (default 10).
.\"
.\"------------------------------------------------------------------
.\"
.SH "INPUT FORMAT"
The input should be much as you would type into a speccy (a 128, to be
precise), with the following exceptions:
.PP
Lines starting with `#' are ignored. This allows you to insert
comments which are not copied into the output Basic file.
.PP
Blank lines are ignored.
.PP
Case is ignored in keywords - `print', `PRINT', and `pRiNt' are
equivalent.
.PP
You can optionally use `randomise' as an alternative to `randomize'.
.PP
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.)
.PP
You can get a pound sign (character 96 on a speccy) by using a
backquote (`).
.PP
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.
.PP
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.
.PP
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:
.PP
goto @foo
.br
print "not seen"
.br
@foo: print "hello world"
.PP
Now the output:
.PP
10 GO TO 14
.br
12 PRINT "not seen"
.br
14 PRINT "hello world"
.PP
Note that case
.I is
significant for labels; `foo' and `FOO' are different.
.\"
.\"------------------------------------------------------------------
.\"
.SH BUGS
There's almost no syntax checking. To do this would require a complete
parser, which would be overkill I think. What's wrong with ``C
Nonsense in BASIC'' as a syntax check, anyway? :-)
.PP
Excess spaces are removed everywhere other than in strings and rem
statements. I think this is generally what you'd want, but it could be
seen as a bad thing I s'pose.
.PP
Labels are substituted even in string literals. That's arguably a
feature not a bug - the problem is, the label name has to be followed
by whitespace or a colon or EOL when referenced, which is fine for
more normal references but is less than ideal for references in
strings.
.PP
In the label-using mode, two passes are made over the input, which
usually means the input must be from a file. If you like making
one-liner Basic programs with `echo' and the like, I'm afraid you'll
have to use line numbers. :-)
.PP
The inline floating-point numbers which have to be generated are not
always
.I exactly
the same as the speccy would generate - but they usually are, and even
when they're not the difference is extremely small and due to rounding
error on the speccy's part. For example, 0.5 is encoded by the speccy
as 7F 7F FF FF FF (exponent -1, mantissa approx. 0.9999999997672) and
by zmakebas as 80 00 00 00 00 (exponent 0, mantissa 0.5).
.PP
zmakebas has most of the same (parsing) problems, relative to the
original basic editor, that the 128 editor has. Specifically, you
can't use variable names which clash with reserved words, so e.g. `ink
ink' doesn't work; and certain tightly-packed constructions you might
expect to work, like `chr$a', don't (you need a space or bracket after
CHR$). These can be more of a problem with zmakebas though, due to the
lack of syntax checking.
.PP
The way tokenisation is done is sub-optimal, to say the least. If you
ran this code on a Z80, even the 128 editor's tokenisation would seem
quick in comparison. (Here's a hint of the full horror of it - program
lines take exponentially longer to tokenise the longer they are.)
However, since I never had a conversion take more than about a second
on my old 486 (it took a second for a 10k program), it hardly seems
worth the effort of fixing.
.PP
zmakebas has no problem with translating BIN numbers of more than 16
bits, unlike the speccy, though numbers with more than 32 significant
bits can only be approximated, and on machines where `unsigned long'
is no more than 32 bits they'll be
.I very
approximate. :-) (If this sounds confusing, you should note that BIN
numbers are translated when entered, and only the 5-byte inline form
is dealt with at runtime. This also explains why the speccy tolerates
the `bin 0x...' construction.)
.PP
On machines without FP hardware, zmakebas will be rather slow (this is
due to the need to generate inline FP numbers).
.PP
Since Basic is an acronym, pedants will doubtless insist I should
write it as `BASIC'. But we live in a world with `laser' etc., and at
least I can be bothered to capitalise the thing, right? :-)
.\"
.\"------------------------------------------------------------------
.\"
.SH "SEE ALSO"
.IR fuse "(1),"
.IR xz80 "(1),"
.IR xzx "(1)"
.\"
.\"------------------------------------------------------------------
.\"
.SH AUTHOR
Russell Marks (russell.marks@ntlworld.com).