BASTEXT

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
FORMAT SELECTION
BASIC SELECTION
BEHAVIOURAL OPTIONS
EXAMPLES
SEE ALSO
BUGS
VERSION INFORMATION
AUTHOR

NAME

bastext - convert Commodore BASIC to text

SYNOPSIS

bastext -i|-o [-f TYPE] [-b MODE] [-a] [-s] [-d filename] filename(s)
bastext
-h

DESCRIPTION

BasText is a program that is used to convert between binary (tokenized) BASIC files from the Commodore C64 and C128 to a clean ASCII text format that is human and machine readable, as well as transportable via electronic mail. This program is designed to be compatible with tok64, while extending the support for Commodore BASIC extensions and dialects.

The following Commodore BASIC versions and extensions are supported by BasText:

Commodore BASIC 2.0 (PET/VIC-20/C64)
Commodore BASIC 3.5 (C16/+4)
Commodore BASIC 4.0 (PET)
Commodore BASIC 7.0 (C128)
Software Unlimited’s Graphics52 for Commodore 64
Riska BV’s The Final Cartridge III for Commodore 64
Rick Simon’s BASIC 7.1 for Commodore 128
VIC Super Expander for VIC-20

BasText tries to autodetect the Commodore BASIC dialect used in the file it is processing. At the moment, this is done by checking the starting address of the file. These starting addresses are recognized, and interpreted (addresses written in hexadecimal):

0401

VIC-20 BASIC 2.0 (3K RAM expansion) or Commodore PET BASIC 2.0

0801

Commodore 64 BASIC 2.0

1001

Commodore 16/Plus 4 BASIC 3.5 (or unexpanded VIC-20 BASIC 2.0)

1201

VIC-20 BASIC 2.0 (8K RAM expansion)

132D

Commodore 128 BASIC 7.1 extension by Rick Simon. This file is a combined file, with both the BASIC 7.1 extension binary, and the BASIC source in one file (saved with BASIC 7.1’s ESAVE command). The preamble will be ignored, and the file will be interpreted as BASIC 7.1.

1C01

Commodore 128 BASIC 7.0

4001

Commodore 128 BASIC 7.0 saved with graphics mode enabled.

OPTIONS

One of the three mode selectors must be given:

-i

Set input mode (converting from binary Commodore tokenized BASIC to text).

-o

Set output mode (converting from text to binary Commodore tokenized BASIC).

-h

Shows a brief help screen, with an overview of the available options.

FORMAT SELECTION

The -f option selects the format of the input and output files:

-f t64

Enable T64 (Commodore 64 emulator tape archive) mode. When in input mode, this means that instead of the specified file names being binary Commodore BASIC files, they are T64 archives. When in output mode, this means that instead of writing the binary Commodore BASIC files to files in the current directory, they will be written to a T64 archive named bastext.t64 in the current directory. If the archive already exists, it will be appended to. The default directory size for the bastext.t64 file is 30 entries. If you try to add more files to it, the program will abort with an error message. The default directory size is controlled in the t64.h file.

-f d64

Enable D64 (Commodore 1541 disk image file) mode. When in input mode, this means that instead of the specified file names being binary Commodore BASIC files, they are D64 images. Ignored in output mode.

-f p00

Enable P00 (PC64 emulator container file) mode. The Commodore BASIC files are written to the current directory but get a PC64 container header written to them and a file extension of .p00 added. This parameter is ignored in input mode, as it will auto-detect the .p00 container format.

BASIC SELECTION

The -b option selects the BASIC dialect to use; if not specified, the format is detected automatically, unless otherwise mentioned:

-b 2.0

Force Commodore BASIC 2.0 interpretation of all programs.

-b 3.5

Force Commodore C16/+4 BASIC 3.5 interpretation of all programs.

-b 4.0

Force Commodore PET BASIC 4.0 interpretation of all programs. This must be specified both in input mode, as these tokens are incompatible with the 3.5 and 7.0 tokens. In output mode, the tokpet header will enable Commodore PET 4.0 mode, but -b 4.0 must be specified if the text file uses a standard tok64 header.

-b 7.0

Force Commodore 128 BASIC 7.0 interpretation of all programs.

-b 7.1

Force Commodore 128 BASIC 7.1 extension interpretation of all programs.

-b TFC3

Force Commodore 64 The Final Cartridge III BASIC extension interpretation of all programs. (See also BUGS).

-b 52

Force Commodore 64 Graphics52 BASIC extension interpretation of all programs.

-b X16

Enable Commander X16 BASIC support. This must be specified in input mode to properly detokenize Commander X16 BASIC binary. In output mode, the tokx16 header will enable Commander X16 BASIC mode no matter which BASIC mode has been selected, but -b x16 must be specified if the text file uses a standard tok64 header.

-b Super

Enable VIC-20 Super Expander support. This must be specified both in input and output mode, as bastext for compatibility reasons selects the Commodore 64 Graphics52 expansion by default.

BEHAVIOURAL OPTIONS

-a

Convert all input files, not only those that have a "recognized" starting address (input mode only).

-s

Maintain strict compatibility with tok64. This means that BasText´s "extended" escape codes for charactes 92 (British pound), 95 (left arrow), 160-192 (shift space to shift asterisk), 219-221 (shift plus, commodore minus and shift minus), and 223 (commodore asterisk), will be printed as three-digit numeric escape codes, not as textual escapes. The "strict" mode will not, however, undo the problems with tok64’s "uppercase in quoted strings"-bug (see under BUGS).

-d filename

Selects the filename to write the output to. If the filename is not given, or is given as "-", the listings will be output on the standard output device (normally the console).

Please note that the MS-DOS and OS/2 versions (EMX compiled) and Windows versions (Visual C) uses / (slash) as parameter character.

EXAMPLES

bastext -i sample.prg

Converts sample.prg to text, and displays it on the standard output.

bastext -i -s -d programs.txt *.prg

Converts all Commodore BASIC binary files with a .prg extension to text, writing it to programs.txt in the current directory, while maintaining tok64 compatibility.

bastext -ift64 *.t64 | more

Converts all files in all T64 archives (with filename suffix .t64) in the current directory into listings, displaying them one page at a time.

bastext -ob7.0 programs.txt

Converts all programs in the programs.txt text file into Commodore BASIC 7.0 programs.

SEE ALSO

http://cbm.6502.org/
http://www.baltissen.org/newhtm/project64.htm

BUGS

tok64 seems to parse uppercase characters in quoted strings incorrectly. It converts them into characters in the range of 97-122, whereas a Commodore computer (and BasText) usually uses the "shadow" range of 193-208. This will not look any different when used on a Commodore computer, but it will make the binaries differ, and could make a difference if the program needs the correct PETSCII values. The problem will appear when you convert the program in one direction with BasText and in the other with tok64, not when using the same program in both directions.

BasText does not yet support the "bare" format that tok64 normally outputs (without the start tok64 header).

VERSION INFORMATION

This documentation covers version 1.2 of BasText.

AUTHOR

BASTEXT was written by Peter Krefting. If you have bug-reports or questions, mail them to peter@softwolves.pp.se

A Softwolves Software (tm) Release in 2026.

This program is released under the GNU General Public License version 2.