Skip to content

timex-sinclair-projects/zmakebas-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zmakebas (Python)

A Python 3 port of zmakebas — a tool that converts text files containing ZX Spectrum, ZX81, or TS2068 BASIC programs into binary program files.

This is a faithful port of the C original (public domain by Russell Marks, 1998, with contributions by many others). It produces byte-for-byte identical output to the C version.

Requirements

  • Python 3.6 or later
  • No external dependencies

Installation

From PyPI

pip install zmakebas

From source

git clone https://github.com/YOUR_USERNAME/zmakebas-py.git
cd zmakebas-py
pip install .

Standalone

Just copy zmakebas.py anywhere — it's a single file with no dependencies.

chmod +x zmakebas.py
./zmakebas.py [options] [input_file]

Usage

zmakebas [-hlp3rv] [-a startline] [-i incr] [-n speccy_filename] [-o output_file] [-s line] [input_file]
Option Description
-a Auto-start line (or @label in label mode)
-h Show help
-i Line number increment in label mode (default: 2)
-l Use labels instead of line numbers
-n Spectrum filename in TAP header (up to 10 chars)
-o Output file (default: out.tap)
-p ZX81 mode — output .p file
-r Output raw headerless file
-3 Output +3DOS file
-s Starting line number in label mode (default: 10)
-v Show version

By default, input comes from stdin and output goes to out.tap.

Output formats

Flag Format Typical extension
(default) TAP file .tap
-r Raw headerless any
-p ZX81 .p
-3 +3DOS .bas

Input format

Write BASIC as you would type it into a 128K Spectrum, with these extras:

  • Lines starting with # are comments (not included in output)
  • Blank lines are ignored
  • Keywords are case-insensitive (print, PRINT, pRiNt all work)
  • Use \ at end of line to continue on the next line
  • Escape sequences for UDGs (\a through \u), block graphics (\:., \'', etc.), copyright symbol (\*), and literal character codes (\{0x42})
  • Use backtick (`) for the pound sign

Labels mode (-l)

Omit line numbers and use @label: to define labels, @label to reference them:

goto @foo
print "not seen"
@foo: print "hello world"

Examples

# Standard TAP file
zmakebas -a 10 -o demo.tap -n "demo" examples/demo.bas

# Using labels
zmakebas -i 10 -a 10 -l -o demolbl.tap -n "demolbl" examples/demolbl.bas

# +3DOS format
zmakebas -a 10 -3 -o next.bas examples/zx-next-demo.bas

# ZX81 .p file
zmakebas -a 10 -p -o demo.p examples/zx81-basic-demo.bas

History

The original zmakebas was written in C by Russell Marks in 1998 and placed in the public domain. It has since been extended by many contributors to support ZX81, ZX Spectrum Next, TS2068, and Spectranet.

This Python port was created to improve portability — no C compiler needed, runs anywhere Python 3 is available.

License

Public domain, following the original.

Releases

Packages

Contributors

Languages