← All spotlightsPrograms / Development

Spotlight › 2BASIC

2BASIC

A BASIC interpreter in a window. Type numbered lines, type RUN, and the program draws, plays sounds, asks questions in dialog boxes or runs a game.

Six lines and RUN
Recorded in real time in QEMU on a modern Mac. The typing is sent to the emulator at about nine keys a second.
Program lines
Up to 288
Games and examples
3 and 5
Smallest PC tested
128KB

01 / What it is

What it is

BASIC is the programming language most home computers of the early 1980s started up in. You typed a line with a number in front of it and the computer kept it. You typed LIST to see the program and RUN to run it. A line typed without a number ran at once.

2BASIC works the same way, in an os8088 window. Its programs use whole numbers, one-dimensional arrays, FOR loops, GOSUB and IF. They can draw lines, boxes, circles and bitmaps, and play notes on the PC speaker or an FM sound card such as the AdLib. They can show a message box or ask for input, and build one form of up to 12 labels, buttons and check boxes that the program waits on for clicks. A program can keep up to 32 small values between runs.

2BRES comes with it. It is an editor for resource packs: files of 16-by-16 sprites, pictures, text and number tables that a program loads by name. The Blackjack game's cards are one such pack.

2BASIC was written by techdistractions for os8088. This release brings it up to date with the current system.

02 / On the screen

On the screen

Blackjack, VGA
2BASIC's Blackjack on VGA, a green table with the dealer's queen of clubs and a face-down card, the player's ace of hearts, five of spades and eight of diamonds, a total of 14, and a bank of 90 with a bet of 10.
Blackjack, one of the three games on the disk, written in 2BASIC. H takes a card and S stands. QEMU.
99 Things, VGA
2BASIC's 99 Things on VGA: a five-by-five grid of small coloured pictures of houses, birds, swans, trees, skulls and leaves, a yellow target box showing a bird, and a timer at 3 seconds.
99 Things: click every picture that matches the target before time runs out. QEMU.
2BRES, VGA
2BRES on VGA with Blackjack's CARDS.RES open: a resource list holding CARDS, of type SPRITES1, and a details pane showing 53 sprites and a large preview of sprite 0, the letter A and a spade.
2BRES with the Blackjack cards open: 53 sprites in one named bank. QEMU.
HELP, VGA
The 2BASIC console on VGA after typing HELP: a quick help listing the editing commands, the BASIC statements, the graphics commands, forms, sound and the resource commands.
HELP lists the commands; HELP and a command's name shows its syntax and an example. QEMU.
A form, Hercules
2BASIC on a Hercules screen in black and white running FORMS.BAS: a small window titled Example Form with an Options group, the text Click checkbox or done, an Enable option check box and a Done button.
The forms example on Hercules. The program waits for the click and reads the check box. MartyPC's IBM 5150.

03 / How it works

How it works

2BASIC is written in 8086 assembly language, like the rest of os8088. The package is 20KB and 2BRES is under 9KB.

A running program does not take over the machine. The interpreter runs it in a background task, one statement at a time, and gives the rest of the system a turn after each one. The window can still be moved, other programs keep running, and Esc or Ctrl+C stops the program.

The window keeps a program's drawing commands, so its picture is drawn again when another window has been dragged over it or the window changes size. DRAWBEGIN and DRAWEND group a batch of drawing into one update.

It draws in colour on VGA and EGA and in black and white on CGA and Hercules. Its own test programs were run on an emulated 4.77 MHz IBM PC, on the 128KB machine os8088's small kernel is made for, and on the protected-mode kernel for the 286 and later.

04 / What it does not do

What it does not do

Whole numbers only. There are no fractions. Numbers are 16-bit signed integers, from -32,768 to 32,767.

Small programs. Up to 288 lines and 4,864 bytes of program text, 512 array elements in all, and one form and one resource pack at a time.

It is not Microsoft's BASIC. The commands are its own, and programs written for GW-BASIC or QBasic need changes to run.

05 / Run 2BASIC

Run 2BASIC

  1. Get the 2BASIC disk from the release zip, in PROGRAMS/2BASIC/, in the size your drive takes. It is also on the live USB and CD, in a 2BASIC folder, and on The Wire.

  2. Boot the system disk, put the 2BASIC disk in drive B and open it.

  3. Double-click 2BASIC.O88. Type HELP for the command list.

  4. Type LOAD "\GAMES\BLACKJAK" and then RUN to play Blackjack. On the live media the path starts \2BASIC\GAMES.