|
1 | | -# bas2tap |
2 | | -The utility to convert `BASIC in an ASCII file' to a TAP tape image file, to be loaded into an emulator. Comes complete with portable C source. With full syntax checking! |
| 1 | +BAS2TAP v2.6 (Release 20-01-2013) |
| 2 | +Copyleft (C) 1998-2013 Martijn van der Heide, ThunderWare Research Center. |
| 3 | + |
| 4 | +This program converts 'BASIC in an ASCII file' to a TAP tape image file, to be |
| 5 | +used in a ZX Spectrum emulator. Both 48K and 128K listings are supported. |
| 6 | + |
| 7 | + |
| 8 | +COPYLEFT AND DISCLAIMER |
| 9 | +----------------------- |
| 10 | +This program is free software; you can redistribute it and/or |
| 11 | +modify it under the terms of the GNU General Public License |
| 12 | +as published by the Free Software Foundation; either version 2 |
| 13 | +of the License, or (at your option) any later version. |
| 14 | + |
| 15 | +This program is distributed in the hope that it will be useful, |
| 16 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | +GNU General Public License for more details. |
| 19 | + |
| 20 | +You should have received a copy of the GNU General Public License |
| 21 | +along with this program; if not, write to the Free Software |
| 22 | +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 23 | + |
| 24 | +Remember you can always freely obtain the latest version from |
| 25 | +the utilities section of The World of Spectrum, at: |
| 26 | + http://www.worldofspectrum.org/utilities.html |
| 27 | + |
| 28 | + |
| 29 | +REVISION HISTORY |
| 30 | +---------------- |
| 31 | +1.0 26-03-98: First public release |
| 32 | +1.1 01-04-98: Changes: |
| 33 | + - Added banner. |
| 34 | + - Switch -q does not suppress warnings, but progress indication. |
| 35 | + - Added switch -w to suppress warnings. |
| 36 | + - Added switch -e on popular demand. |
| 37 | + - Empty lines are skipped and only generate a warning. |
| 38 | + - Lines with only a line number generate an error. |
| 39 | + - Numbers can also start with a decimal point (eg. '.5'). |
| 40 | + - Lines no longer require an end-of-line terminator. |
| 41 | + - In-line sequence expansions also remove any trailing |
| 42 | + spaces unless it was between quotes. |
| 43 | + - The created TAP is made valid (although incomplete) if an error |
| 44 | + occurs, unless it was a write error. |
| 45 | +1.2 11-12-98: Changes: |
| 46 | + - Block graphics were encoded rotated by 1. |
| 47 | + - Added full syntax checking, and |
| 48 | + - Added switch -n to disable the syntax checking again. |
| 49 | + - Added expansion sequences '{CAT}' and '{CODE}' with the sole |
| 50 | + purpose of being used as channel name in the OPEN # command. |
| 51 | + - Changed the distribution policy from freeware to Open Source |
| 52 | + Software. |
| 53 | +1.3 04-01-99: Changes: |
| 54 | + - Spaces after strings are now skipped (they are not needed). |
| 55 | + - The 'CLS #' command does exist on the Interface 1 after all. |
| 56 | + - Exponential numbers were raised the wrong way around |
| 57 | + (eg. 25e3 became 0.025 and 25e-3 became 25000). Oooops.... |
| 58 | +1.4 17-05-99: Changes: |
| 59 | + - UDGs used as 'USR "x"' would result in a crash due to 2 |
| 60 | + bad pointers. |
| 61 | + - Complex expressions between brackets as parameter to other |
| 62 | + expression types (eg. ATTR or string slicing) would screw |
| 63 | + up the evaluation. |
| 64 | + - The 'CLS #' command was flagged as being Interface 1 |
| 65 | + specific in the previous version rather than either |
| 66 | + Interface 1 or Opus Discovery (aaargh!) |
| 67 | +1.5 19-05-99: Changes: |
| 68 | + - The 'DIM' command's syntax description was incorrect, so the |
| 69 | + checker didn't like the variable name before the opening |
| 70 | + bracket. |
| 71 | +1.6 23-06-99: Changes: |
| 72 | + - Several problems with array indices! |
| 73 | + - The 'USR' token only accepted a numerical operand. An |
| 74 | + exception was made for UDG expressions '"x"' but constructions |
| 75 | + like 'USR CHR$ a' didn't work. |
| 76 | +1.7 02-11-99: Changes: |
| 77 | + - The DEF FN function requires insertion of evaluation room. |
| 78 | +1.8 09-11-00: Changes: |
| 79 | + - The DEF FN function only requires insertion of evaluation room |
| 80 | + in the parameter area before the '=' token. |
| 81 | + Any bracketed argument would upset the parser. |
| 82 | +1.9 08-12-01: Changes: |
| 83 | + - Forgot to skip the ';' colour token separator in class 9. |
| 84 | + - REM statements should be parsed as-is (except for expansion |
| 85 | + sequences), without taking out multiple spaces or counting |
| 86 | + quotes. |
| 87 | +2.0 11-12-02: Changes: |
| 88 | + - SAVE/LOAD/VERIFY/MERGE DATA didn't work, as the DATA token was |
| 89 | + set to be allowed as keyword only. |
| 90 | + - ERASE ! didn't work, as ERASE was only allowed from the "m" |
| 91 | + channel. |
| 92 | +2.1 22-12-02: Changes: |
| 93 | + - Any alphanumerical expression can be sliced, not only |
| 94 | + variables and direct strings. |
| 95 | + - If the output filename provided on the command line had the |
| 96 | + extension '.TAP', it shouldn't be forced to '.tap'. |
| 97 | +2.2 13-06-03: Changes: |
| 98 | + - Expand sequences PAPER and INK had their codes reversed. |
| 99 | + - Expand sequences BRIGHT and FLASH had their codes reversed. |
| 100 | + - Expand sequences INVERSE and OVER had their codes reversed. |
| 101 | + - Expand sequences {XX} didn't work (missing pointer advance). |
| 102 | + - Expand sequences AT and TAB didn't work and threw a |
| 103 | + warning instead (missing pointer advance). |
| 104 | +2.3 05-07-04: Changes: |
| 105 | + - LET is allowed to write to a substring. |
| 106 | +2.4 24-07-05: Changes: |
| 107 | + - BIN is a number format, not an expression token. |
| 108 | +2.5 06-06-10: Changes: |
| 109 | + - Functions would take "the rest of the expression" as argument |
| 110 | + rather than just the next value. |
| 111 | + - Stronger enforcement of separator tokens (;,') in a PRINT |
| 112 | + statement. |
| 113 | + - The use of 'TO' in string arrays was not accepted. |
| 114 | +2.6 20-01-13: Changes: |
| 115 | + - The PLAY command was not parsed properly. |
| 116 | + |
| 117 | +SYNTAX |
| 118 | +------ |
| 119 | + BAS2TAP [-q] [-w] [-e] [-c] [-aX] [-sX] FileIn [FileOut] |
| 120 | + |
| 121 | +-q goes into quiet mode, suppressing banner and progress indication. |
| 122 | +-w suppress generation of warnings. |
| 123 | +-e write errors to the stdout in stead of the stderr stream. |
| 124 | +-c makes token matching case independant. The drawback is that variables that |
| 125 | + have the same name as a token (eg. 'print') cannot be used, as they will be |
| 126 | + treated as (unexpected) tokens. |
| 127 | +-n disables syntax checking. |
| 128 | +-aX sets the auto-start line to line X. |
| 129 | +-sX sets the TAP block name to X (max 10 characters). |
| 130 | + |
| 131 | +If no output filename is provided, the same name as the input file will be |
| 132 | +used, but with extension `.TAP'. |
| 133 | + |
| 134 | + |
| 135 | +THE CONVERTOR |
| 136 | +------------- |
| 137 | +The following rules apply: |
| 138 | + |
| 139 | +1. One BASIC line must be provided in one ASCII line. |
| 140 | +2. Keywords must appear in upper case (unless switch -c is used). |
| 141 | +3. Keywords that consist of multiple words (eg. `GO TO') must have the space |
| 142 | + in between the words. |
| 143 | +4. Spaces between words are not needed, unless this leads to concatenation |
| 144 | + problems - eg. `PRINTVAL"10"' must appear as `PRINT VAL"10"', while |
| 145 | + `PRINT10' is perfectly acceptable. |
| 146 | +5. Syntax is fully checked according to |
| 147 | + - the normal Spectrum ROM, |
| 148 | + - Interface 1/Microdrive extension, |
| 149 | + - Opus Discovery extension. |
| 150 | + |
| 151 | +The following sequences are expanded in-line: |
| 152 | + |
| 153 | + Chars Expand to |
| 154 | + |
| 155 | + tab character 06 ("print '") |
| 156 | + {XX} XX is 2-digit hex, converts to the Spectrum ASCII value |
| 157 | + {(C)} character 7F (copyright sign) |
| 158 | + {-X} X is 1-8, characters 80-87 (block graphics without shift) |
| 159 | + {+X} X is 1-8, characters 88-8F (block graphics with shift) |
| 160 | + {X} X is `A'-`U', converts to the UDG Spectrum ASCII value |
| 161 | + {CODE} character AF ('CODE') |
| 162 | + {CAT} character CF ('CAT') |
| 163 | + |
| 164 | +Special sequences are (case independant) PAPER, INK, BRIGHT, FLASH, OVER, |
| 165 | +INVERSE, AT and TAB control sequences. They may appear as "{PAPER 3}" to convert |
| 166 | +to the sequence 0x10,0x03. Note that both AT and TAB take 2 operands, which |
| 167 | +should be seperated by a comma (eg. "{AT 1,10}"). |
| 168 | +Notice that these expansions are identical to what SGD and TAPER create when |
| 169 | +saving out BASIC blocks. |
| 170 | + |
| 171 | + |
| 172 | +RECOMPILING THE SOURCE |
| 173 | +---------------------- |
| 174 | +The source is provided in (almost) fully portable ANSI C, the source text is |
| 175 | +written in 132 columns. |
| 176 | + |
| 177 | +If you wish to experiment with different syntax (eg. for a DISCiPLE), you may |
| 178 | +find it useful to set the `__DEBUG__' define. |
| 179 | + |
| 180 | +If you make any fundamental change to the source, you are requested - but not |
| 181 | +obligated - to send the changed source back to me, so that everyone can benefit |
| 182 | +from it. My e-mail address is `mheide@worldofspectrum.org' |
| 183 | + |
| 184 | + |
| 185 | +Enjoy! |
| 186 | + |
| 187 | +Martijn van der Heide |
| 188 | +ThunderWare Research Center |
0 commit comments