Tiny BASIC in Python
Dress up in your best corduroy suit or patterned jumper, it’s time for some disco, so put the Bee Gees latest 45 on the turn table and let’s get coding like your grandparents!
OK, you really don’t have to dress in the epitome of 1970s fashions, do the bump, or listen to disco, but you will enjoy programming like it’s 1976! Tiny BASIC in Python (tbp) is an implementation of the Tiny BASIC language that ran on the Intel 8080, the Motorola 6800, and the MOS Technologies 6502 processors and fit into 4K of memory.
Obviously, tbp is humongous compared to the original, but it served as a way for me to learn about the infrastructure of programming languages.
It is a full-featured programming environment for the Tiny BASIC language. It also includes a full debugger, a linter, and complete documentation, which you are now reading. It’s also the first project I’ve ever done in Python.
Any problems/confusion? Please file an issue in the repository. I thank you kindly in advance!
Some Usage Hints
The links on the left of this page have detailed discussion of installation, usage, the Tiny BASIC language, and the tbp command language that controls the programming environment.
When using tbp, use the %help
command to get links to the documentation, and help on the tbp command language.
Prompts and Command Line Editing
In tbp you will see various command line prompts.
tbp:>
- The normal tbp prompt where you can enter both the Tiny BASIC language and the tbp command language.[A]?
- This prompt says a program is asking you for input with theINPUT
Tiny BASIC statement.DEBUG(420):>
- When you stop at a breakpoint, this prompt shows the line number you stopped on. In this case, it is line420
in your Tiny BASIC program. See the tbp debugger documentation for details about the debugger commands and help debugging.
The tbp command line uses Python’s readline module on macOS and Linux, and pyreadline3 on Windows, so all the normal editing, copy, paste, and arrow keys work.
Example Programs
The examples directory holds sample Tiny BASIC programs for your enjoyment. Some of these programs come from other sources and I provide links back to the original code. The original developers hold the copyrights to their work. In a few minor cases I had to slightly change the program to work under tbp, which I documented in comments at the top of the file. I appreciate and thank the others who wrote these programs and shared them. 1
- adventure.tbp
- Tiny Adventure game from The First Book of Tiny BASIC Programs by Tom Pittman. This is a complicated game so read the documentation before playing.
- deep.tbp
- A test program for the tbp debugger that generates a deep call stack.
- eurphoria.tbp
- Kingdom of Euphoria game from The First Book of Tiny BASIC Programs by Tom Pittman.
- fib.tbp
- Generates Fibonacci numbers. From the excellent Marco’s Retrobits.
- fizzbuzz.tbp
- An implementation of Fizz Buzz from the always fascinating Rosetta Code. The original implementation is here. I updated the code to use line numbers.
- fizzbuzz2.tbp
- Another implementation of Fizz Buzz from Winston (Winny) Weinert’s very cool implementation of Tiny BASIC in Racket.
- gotoheck.tbp
- A test program for the tbp debugger that implements all sorts of
GOTO
/GOSUB
statements.
- A test program for the tbp debugger that implements all sorts of
- life.tbp
- Conway’s Game of Life from Tom Pittman’s Tiny BASIC site.
- lintdemo.tbp
- A modified version of the Sum of Squares and Cube Digits (see below) to demonstrate tbp’s
%lint
command.
- A modified version of the Sum of Squares and Cube Digits (see below) to demonstrate tbp’s
- pas.tbp
- A fantastic implementation of Pascal’s Triangle by Winston (Winny) Weinert’s for his implementation of Tiny BASIC in Racket.
- prime-decomp.tbp
- An implementation if integer factorization originally from Rosetta Code. I changed the program to make the output cooler.
- rand.tbp
- One of the examples from the Tiny BASIC User Manual that shows 64 random numbers.
- sq-cu-digits.tbp
- A program from Rosetta Code that finds and shows here all positive integers n less than 100 where, the sum of the digits of the square of n is prime, and the sum of the digits of the cube of n is also prime.
- srps.tbp
- My SASSY Rock, Paper, Scissors game. Made with Tiny BASIC AI. (Can I get funding now that I mentioned AI?)
- tbp.tbp
- A program to print the Tiny BASIC in Python logo because you can never look at it enough.
- tflash.tbp
- The original FLASHCARD program from The First Book of Tiny BASIC Programs
- tic-tac-toe.tbp
- The original tic-tac-toe game from the January 19, 1977, issue of the Homebrew Computer Club Newsletter by Tom Pittman.
- ttt-c.tbp
- The compressed version of the tic-tac-toe game from the January 19, 1977, issue of the Homebrew Computer Club Newsletter by Tom Pittman.
-
Note that I am not a lawyer but feel it was OK to share other’s work like this. If that’s not a correct interpretation, let me know as soon as possible, and I will remove any requested by the authors. ↩