npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bas2tap

v0.0.1-alpha.4

Published

Emscripten conversion for bas2tap which converts BASIC to a TAP tape file.

Downloads

11

Readme

bas2tap

Emscripten conversion for bas2tap which converts BASIC to a TAP tape file.

This package converts 'BASIC in an ASCII file' to a TAP tape image file, to be used in a ZX Spectrum emulator.

Usage

npm install bas2tap
import bas2tap from "bas2tap";

const tap = bas2tap('10 PRINT "Hello"');

Build library

Note that you need to have the Emscripten SDK installed and available on path.

Install & activate emsdk from Emscripten:

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk/
git pull
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh

Build the library:

npm install
npm run build
npm run test

Licenses

BAS2TAP.C

Copyleft (C) 1998-2013 ThunderWare Research Center, written by Martijn van der Heide.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

emscripten-fs-example

MIT License

Copyright (c) 2018 Damián Silvani

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

emscripten-bas2tap

Copyright (c) 2022 Steven Robertson

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

BAS2TAP.C notes

Revision History

1.0  26-03-98: First public release
1.1  01-04-98: Changes:
               - Added banner.
               - Switch -q does not suppress warnings, but progress indication.
               - Added switch -w to suppress warnings.
               - Added switch -e on popular demand.
               - Empty lines are skipped and only generate a warning.
               - Lines with only a line number generate an error.
               - Numbers can also start with a decimal point (eg. '.5').
               - Lines no longer require an end-of-line terminator.
               - In-line sequence expansions also remove any trailing
                 spaces unless it was between quotes.
               - The created TAP is made valid (although incomplete) if an error
                 occurs, unless it was a write error.
1.2  11-12-98: Changes:
               - Block graphics were encoded rotated by 1.
               - Added full syntax checking, and
               - Added switch -n to disable the syntax checking again.
               - Added expansion sequences '{CAT}' and '{CODE}' with the sole
                 purpose of being used as channel name in the OPEN # command.
               - Changed the distribution policy from freeware to Open Source
                 Software.
1.3  04-01-99: Changes:
               - Spaces after strings are now skipped (they are not needed).
               - The 'CLS #' command does exist on the Interface 1 after all.
               - Exponential numbers were raised the wrong way around
                 (eg. 25e3 became 0.025 and 25e-3 became 25000). Oooops....
1.4  17-05-99: Changes:
               - UDGs used as 'USR "x"' would result in a crash due to 2
                 bad pointers.
               - Complex expressions between brackets as parameter to other
                 expression types (eg. ATTR or string slicing) would screw
                 up the evaluation.
               - The 'CLS #' command was flagged as being Interface 1
                 specific in the previous version rather than either
                 Interface 1 or Opus Discovery (aaargh!)
1.5  19-05-99: Changes:
               - The 'DIM' command's syntax description was incorrect, so the
                 checker didn't like the variable name before the opening
                 bracket.
1.6  23-06-99: Changes:
               - Several problems with array indices!
               - The 'USR' token only accepted a numerical operand. An
                 exception was made for UDG expressions '"x"' but constructions
                 like 'USR CHR$ a' didn't work.
1.7  02-11-99: Changes:
               - The DEF FN function requires insertion of evaluation room.
1.8  09-11-00: Changes:
               - The DEF FN function only requires insertion of evaluation room
                 in the parameter area before the '=' token.
                 Any bracketed argument would upset the parser.
1.9  08-12-01: Changes:
               - Forgot to skip the ';' colour token separator in class 9.
               - REM statements should be parsed as-is (except for expansion
                 sequences), without taking out multiple spaces or counting
                 quotes.
2.0  11-12-02: Changes:
               - SAVE/LOAD/VERIFY/MERGE DATA didn't work, as the DATA token was
                 set to be allowed as keyword only.
               - ERASE ! didn't work, as ERASE was only allowed from the "m"
                 channel.
2.1  22-12-02: Changes:
               - Any alphanumerical expression can be sliced, not only
                 variables and direct strings.
               - If the output filename provided on the command line had the
                 extension '.TAP', it shouldn't be forced to '.tap'.
2.2  13-06-03: Changes:
               - Expand sequences PAPER and INK had their codes reversed.
               - Expand sequences BRIGHT and FLASH had their codes reversed.
               - Expand sequences INVERSE and OVER had their codes reversed.
               - Expand sequences {XX} didn't work (missing pointer advance).
               - Expand sequences AT and TAB didn't work and threw a
                 warning instead (missing pointer advance).
2.3  05-07-04: Changes:
               - LET is allowed to write to a substring.
2.4  24-07-05: Changes:
               - BIN is a number format, not an expression token.
2.5  06-06-10: Changes:
               - Functions would take "the rest of the expression" as argument
                 rather than just the next value.
               - Stronger enforcement of separator tokens (;,') in a PRINT
                 statement.
               - The use of 'TO' in string arrays was not accepted.
2.6  20-01-13: Changes:
               - The PLAY command was not parsed properly.

Syntax

  BAS2TAP [-q] [-w] [-e] [-c] [-aX] [-sX] FileIn [FileOut]

-q  goes into quiet mode, suppressing banner and progress indication.
-w  suppress generation of warnings.
-e  write errors to the stdout in stead of the stderr stream.
-c  makes token matching case independant. The drawback is that variables that
    have the same name as a token (eg. 'print') cannot be used, as they will be
    treated as (unexpected) tokens.
-n  disables syntax checking.
-aX sets the auto-start line to line X.
-sX sets the TAP block name to X (max 10 characters).

If no output filename is provided, the same name as the input file will be used, but with extension .TAP.

The Convertor

The following rules apply:

  1. One BASIC line must be provided in one ASCII line.
  2. Keywords must appear in upper case (unless switch -c is used).
  3. Keywords that consist of multiple words (eg. GO TO) must have the space in between the words.
  4. Spaces between words are not needed, unless this leads to concatenation problems - eg. PRINTVAL"10" must appear as PRINT VAL"10", while PRINT10 is perfectly acceptable.
  5. Syntax is fully checked according to
    • the normal Spectrum ROM,
    • Interface 1/Microdrive extension,
    • Opus Discovery extension.

The following sequences are expanded in-line:

   Chars   Expand to

   tab     character 06     ("print '")
   {XX}    XX is 2-digit hex, converts to the Spectrum ASCII value
   {(C)}   character 7F     (copyright sign)
   {-X}    X is 1-8, characters 80-87 (block graphics without shift)
   {+X}    X is 1-8, characters 88-8F (block graphics with shift)
   {X}     X is `A'-`U', converts to the UDG Spectrum ASCII value
   {CODE}  character AF     ('CODE')
   {CAT}   character CF     ('CAT')

Special sequences are (case independent) PAPER, INK, BRIGHT, FLASH, OVER, INVERSE, AT and TAB control sequences. They may appear as "{PAPER 3}" to convert to the sequence 0x10,0x03. Note that both AT and TAB take 2 operands, which should be seperated by a comma (eg. "{AT 1,10}"). Notice that these expansions are identical to what SGD and TAPER create when saving out BASIC blocks.

Compiling The Source

The source is provided in (almost) fully portable ANSI C, the source text is written in 132 columns.

If you wish to experiment with different syntax (eg. for a DISCiPLE), you may find it useful to set the __DEBUG__ define.

If you make any fundamental change to the source, you are requested - but not obligated - to send the changed source back to me, so that everyone can benefit from it. My e-mail address is [email protected]

Enjoy!

Martijn van der Heide ThunderWare Research Center

Building notes for the library

Build dependencies:

  • gcc
  • cmake
  • emscripten

Clone the repository and run npm run build to build the library. You can then run npm run test to test it (check bas2tap.test.js). Also, npm run build:debug builds the project without optimizations.