What is the BASIC Engine?

250
Figure 1. A BASIC Engine rev1

The BASIC Engine is a very low-cost single-board home computer with advanced 2D color graphics and sound capabilities, roughly comparable to late-1980s or early-1990s computers and video game consoles. It can be built at home without special skills or tools and using readily available components for under 10 Euros in parts, or mass-produced for even less.

What can it do?

Screenshots

screen boot
Figure 2. Boot screen
screen shmup
Figure 3. Shmup demo
screen zork
Figure 4. Text adventure game

Videos

Features

Hardware

  • ESP12-E/F module with ESP8266 SoC and 4 MB flash memory

  • VS23S010 video controller with 128k VRAM and composite video output in PAL or NTSC

  • 5-bit PCM sound from I2S controller

  • MicroSD card slot

  • PS/2 and PS/2-compatible USB keyboard interface

  • PlayStation controller port

  • PCF8575 I/O extender with 16 GPIO pins

  • I2C and SPI busses on I/O expansion connector

  • power supplied via Micro-USB socket or pin header

  • RCA connectors for video and audio

Software

This firmware contains a basic operating system and BASIC interpreter ("Engine BASIC") that allows the BASIC Engine to be used as a stand-alone computer programmable in the BASIC language. It provides easy access to the hardware’s capabilities as well as numerous other features.

Graphics and sound

  • 256-color text and graphics at resolutions from 160x200 up to 460x224 (PAL: 508x240) pixels

  • Software sprites (up to 32 sprites sized up to 32x32 pixels).

  • Scrollable tiled background graphics engine with up to four layers.

  • Wavetable synthesizer and PLAY command that renders music in MML format.

  • Loading and saving of PCX image files to and from video memory.

  • Various text fonts built-in, including an ATI 6x8 font (for up to 76 (PAL: 84) characters per line) and PETSCII.

  • Direct manipulation of video memory and controller registers possible, permitting higher-color screen modes, custom resolutions and other video effects.

Special BASIC language features

  • Structured programming constructs (DO/LOOP, WHILE/WEND, IF/THEN/ELSE/ENDIF blocks).

  • Labels and named procedures with local variables.

  • Numbers are double-precision floating point.

  • String and numeric list types (particularly useful for game programming).

  • Escape codes for PRINT, similar to the control characters in Commodore BASIC.

  • Event handlers (sprite collision, end-of-music, errors, game controller input).

Development features

  • "Screen editor" similar to Commodore BASIC, allowing direct manipulation of on-screen code and commands, while also permitting scrolling within the program in memory.

  • Syntax highlighting and automatic indentation in LIST command.

  • Loading of programs with or without line numbers.

Hardware support

  • ESP8266 CPU core running at 160 MHz, ca. 63kB free memory for BASIC applications.

  • Files can be stored on FAT32 file systems with long file names on MicroSD card as well as the internal flash memory.

  • PlayStation controller support.

  • Support for PS/2 and PS/2-compatible USB keyboards (US, Japanese and German layouts supported).

  • Access to custom hardware add-ons via the 16-pin GPIO extender or I2C bus.

Network support

  • Separate build that provides networking capabilities (cannot be used with tiled BG/sprites and wavetable synthesizer due to resource constraints; both builds can, however, be installed in flash at the same time)

Other features

  • Z-code interpreter for playing interactive fiction games.

  • ASCII text editor.

  • Firmware update from SD card.

  • Customizable color scheme, start-up screen mode and font..

  • Switchable video luminance filter provides sharp high-contrast graphics on LCD screens when turned off and avoids color artifacts on old CRT screens when turned on.

  • Automated test suite adapted from Bywater BASIC.

How to build it

Wonder whether you have the skills to assemble such an intricate device? You probably do, because it’s way easier than you might think! It all depends on the right technique.

For instance, it is possible to solder a 0.5mm-pitch SMD chip using a soldering iron, provided you have decent tools, a steady hand and years of practice.

It is equally possible to solder the exact same chip using solder wire, an 80-euro iron/heat gun combo from eBay and jittery hands, without having ever done that before. It just takes two minutes longer, during which you can contemplate how much time you have saved by not practicing soldering. In Assembly, you can find a video showing the entire process.

Tip
If you use this technique, pretend you have soldered the chips with an iron for maximum street credibility.

But first you have to get your hands on the required parts and tools.

Components

The BASIC Engine does not use any obsolete components that may be difficult to obtain. Nevertheless, you will have to put in at least three orders to get all required parts.

I would recommend to get the circuit board from JLCPCB or Smart Prototyping, the VS23S010D-L chip from TME, and all other parts from AliExpress. AE usually has the lowest price, and this project is all about the cheap.

You will usually have to order more components than you actually intend to use, because

  • they are only offered in larger quantities,

  • you may want to save on shipping in case you decide to build more BASIC Engines,

  • you are likely to break or lose a few parts while building the device, or

  • all of the above.

Note
Unless noted otherwise, all links lead to suppliers and components I have bought myself in the past and that have received the "Good Enough for BASIC Engine" seal of approval. Nevertheless you order at your own risk, and I cannot be held responsible for the quality of the services or products provided to you. I am not affiliated with any of the linked suppliers.

Required components

Qty Name Package Where to get it Links

1

Circuit Board

Any board house

JLCPCB, Smart Prototyping.

1

VS23S010D-L video controller

TME (small quantities), VLSI (for large orders)

TME, VLSI

1

ESP-12F or ESP-12E microcontroller module

AliExpress, eBay, Amazon, various smaller retailers

AliExpress: 1, 2, 3

8

Resistor 10K

1206

Generic part

AliExpress: 1, 2

1

Resistor 1M

1206

Generic part

AliExpress: 1

1

Resistor 75 Ohms

1206

Generic part

AliExpress: 1, 2 (untested supplier)

2

Resistor 1K

1206

Generic part

AliExpress: 1

8

Capacitor 100nF

1206

Generic part

AliExpress: 1, 2, 3, 4

2

Capacitor 56pF

1206

Generic part

AliExpress: 1

1

Electrolytic capacitor 10uF (Revision 1 board only!)

THT

Generic part

AliExpress: 1, 2

2

Electrolytic Capacitor 220uF (Revision 1 board only!)

THT

Generic part

AliExpress: 1

1

Capacitor 10uF (Revision 2 board only!)

1206

Generic part

AliExpress: 1, 2

2

Capacitor 22uF (Revision 2 board only!)

1206

Generic part

AliExpress: 1, 2

2

RCA connectors

THT

Generic, but often overpriced part

AliExpress: 1 (untested supplier); no longer available: red, yellow

1

Micro-USB connector

SMT

Generic, but often overpriced part

AliExpress: 1, 2, 3, 4

1

Regulator AMS1117 3.3V

SOT-223

Generic, sometimes overpriced part

AliExpress: 1; eBay DE: 1

1

74HC04 hex inverter

SOIC-14

Generic part

AliExpress: 1, 2

1

Crystal 3.579545 MHz (NTSC) or 4.433619 MHz (PAL)

HC49-S

Generic part

AliExpress: NTSC, PAL (untested supplier)

1

PS/2 keyboard connector (female)

THT

AliExpress, some distributors

AliExpress: green, purple

You should really have these, but if you can’t get your hands on them right away, you can go ahead and add them later.

Qty Name Package Who can supply it Links

1

Pin header 1x7 (programming header)

Generic part

AliExpress: 1 (1x40 headers, cut them to size)

1

MicroSD socket

SMT

AliExpress, eBay

AliExpress: 1, 2; eBay DE: 1

1

Push button 6x6x4.3 mm

THT

Generic part

AliExpress: 1, 2

1

PCF8575TS I2C I/O extender

SSOP-24

Generic part; AliExpress recommended for price

AliExpress: 1

1

Raspberry Pi 3 case

Generic part

AliExpress: 1, 2, 3, 4, 5

Optional components

If you do not need the functions associated with these parts, you can leave them out, but your BASIC Engine will be slightly less cool.

Qty Name Package Who can supply it Links

1

Pin header 1x3 pins (alternative power supply)

AliExpress recommended for price

see "Pin header 1x7"

1

USB A connector (alternative keyboard connector)

THT

Generic part

AliExpress: 1, 2

1

Pin header 2x20 pins (expansion connector)

AliExpress recommended for price

AliExpress: 1 (2x40 headers, cut them in half)

1

PlayStation controller connector (female)

AliExpress

AliExpress: 1, 2

Ordering the PCB

If you have never had a custom circuit board made, you may find the multitude of options you are presented with on the board house’s ordering page confusing. The good news is that you do not have to worry about most of them, because they have been set to reasonable defaults already.

If you order with JLCPCB or Smart Prototyping using the links above, all you have to do is upload the ZIP file containing the Gerber files that you can find on Github in the PCB repository’s release section (basicengine-gerber-<revision>.zip) and specify the dimensions of the board (85x56 mm). All other options can be left as is.

(Just to be on safe side: At the time of writing these options were: 2 layers, 1.6 mm thickness, HASL with lead, 1oz copper weight, material FR4.)

Tools required

If you have no equipment, these are the items you will need to obtain:

Soldering tools

  • Temperature-controlled soldering iron (recommended: generic 937D+ or similar device from eBay).

  • Heat gun (recommended: generic 858D+ or similar device from eBay).

  • Solder wire (0.5mm with rosin core).

  • A set of pointy-tipped tweezers. (You only need one, but they are cheap, and this way you can find out which style you like best.)

  • Reading glasses (if above 40).

  • A lecture on which ends of the tools get hot (if below 10, or a really big nerd).

These should not set you back more than a hundred euros.

Warning
If you watch too many YouTube videos, you may come across a substance called "solder paste". Stay away from it. It is intended to be used in mass production, and is entirely useless when building things by hand, especially if small-pitch components are involved.
It also gets into every crack and stays there for weeks, while still managing to "go bad" if not stored properly. Oh, and have I mentioned it’s poisonous? Just stay away from it.

Programming tools

These are used to flash the firmware into the microcontroller module.

Qty Name Package Who can supply it Links

1

USB-to-serial converter

AliExpress, eBay

AliExpress: 1, 2

7

Dupont wires female/female (for wiring the converter to the programming header)

AliExpress, eBay

AliExpress: 1 (untested supplier), 2 (untested supplier)

You also need some sort of computer, ideally running Linux, but others may work as well.

Assembly

Even though it uses some small-pitch components, the BASIC Engine has been designed to be easy to assemble.

Check the one-hour silent video below to see how to build a BASIC Engine using a soldering iron, a heat gun, tweezers, solder wire and side cutters, without fancy tools, mad soldering skills and with only a minimal amount of patience:

Soldering up the BASIC Engine
Note
This video shows assembly of a rev1 board. In rev2, the electrolytic capacitors C9, C11 and C12 have been replaced with SMD parts. Also, a 22R resistor is mounted as R6, which should be 75R (see PCB Errata).

PCB Errata

Revision 2 of the PCB contains one error:

  • R6 value is given as "22R", should be "75R".

Revision 1 of the PCB contains two errors:

  • R6 value is given as "22R", should be "75R".

  • C3 and C4 values are given as "10p", should be "56p".

Software installation

Firmware binaries

Binaries are available on Github in the firmware repository. They can be uploaded to the system via the serial port, using esptool:

esptool -cd ck -cb 921600 -cp /dev/ttyUSB0 -ca 0 -cf ttbasic-<version>.bin

If a version of Engine BASIC is already installed, the firmware can be updated from SD card using the command

FLASH "ttbasic-<version>.bin"

Sound font

The sound font file 1mgm.sf2 must be copied to the SD card or the internal flash memory for wavetable synthesizer sound to work.

How to use it

Consult the Engine BASIC Reference Manual to find out how to make the most of the capabilities of Engine BASIC.

BASIC demo programs can be found in the Engine BASIC demos repository.

How to contribute

Source code

Compiling the firmware

The project Makefile uses the Arduino builder to compile the system.

The standard build requires a special ESP8266 Arduino core without networking support that contains a BASIC Engine build target.

The networked version can be built with the standard ESP8266 Arduino core.

History

See the BASIC Engine History page for the whole story.

Contact

If you have any questions or suggestions related to the BASIC Engine, send an e-mail to uli@basicengine.org.