Raspberry Pi is a trademark
of the Raspberry Pi Foundation Tux

XPL0 Programming on the Raspberry Pi

XPL0 on the RPi is about having fun. With it you can make fast graphics programs, like video games.

XPL0 code looks like Pascal but works more like C. It's a hundred times faster than Python.

Version 2.2 solves an incompatibility with NOOBS 2.4.5 for some display modes (notably used by xed and congame). Among the many changes are new intrinsics: Pow, Floor, Ceil, and SetHexDigits. The arrow keys can now operate like push buttons--handy for games. A library with over a hundred commonly used routines is included. Download xplrpi22.zip (526k, 16-Mar-2018)

Version 2.1 plays sound files reliably (by reaping zombies) and mouse pointer routines are built-in. Device 0 displays extended IBM characters like device 6 always has. Intrinsics are declared automatically, and their arguments are checked for validity at compile time. There are also minor bug fixes and adjustments accumulated since version 1.0.

Here are screen shots of some of the example programs included in the zip file:

Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot


The PC version of the XPL0 Programming Language Manual has been revised to describe programming on the Raspberry Pi. Obsolete sections such as segment arrays, interpreted I2L code, and external procedures have been eliminated. Many new intrinsics have been added. Download manual.pdf.

More programs

The following zip files contain XPL0 source code and their corresponding executable files. Instead of compiling the source code, the executable files can be run directly if their execute permission is enabled. The Linux change-mode command will do this, for example: chmod +x textris

screenshot Here's a text editor. Editors are personal things so this one might not appeal to you, but it has made writing programs much easier for some of us. In addition to standard screen-oriented editing it has a powerful command-line macro capability. An unusual feature moves the heavily used Ctrl key to the position of the Caps Lock key, where it was on early keyboards (and where it prevents the affliction known as "Emacs pinky"). The features are all explained in a 25-page manual, as well as in the built-in help screens. You even get the source code so you can change the commands to your liking. Download xed.zip (80k, 16-Mar-2018).

Screen image TeXtris is a cross between Tetris and Scrabble. The idea is to form
words from falling letter tiles. Crammed into the executable file are
the 53,800 official Scrabble words between 3 and 7 letters long.
Download textris.zip (243k, 15-Jun-2017).

image Challenge Matey to a game of chess -- or play against another person
with Matey enforcing the rules. Move pieces with the mouse, specify
skill level, undo bad moves, view Matey's thinking. This is more of an
XPL0 programming example rather than a strong competitor. It rates
about 1100 at its level 4. Download matey.zip (67k, 30-Jun-2017).

image Yer basic shooter...with source of course. Have fun!
Download pede.zip (106k, 11-Jun-2017).

image 8-Across solitaire is similar to but different than Windows Solitaire.
Download 8across.zip (63k, 11-Jun-2017).

Screen image Mahjongg Solitaire.
Venerable Chinese tile game.
3D bamboo-laminated ivory tiles.
Download mahjongg.zip (45k, 16-Nov-2017).

Screenshot This will tell you how late it is while saving lots of money
on Nixie tubes. Download nixieclk.zip (74k, 15-Jun-2017).

Screenshot Here are a couple demo programs from the illusive Lenny Boreal.
The text scroller with its "jumpin' graphics" is a mere two pages of code.
As impressive as that is, it's then incorporated into a much larger demo.
Cubic is a self-referential program that requires its source code to even run.
It must be compiled with the optimizing compiler.
Download cubic.zip (56k, 15-Jun-2017).


Screenshot Although this gizmo can be used to draw ellipses and is called a
"Trammel of Archimedes," it's more commonly known as a "BS Grinder."
You can watch it from any angle while it grinds away, and even get an
x-ray view! Download grinder.zip (34k, 15-Jun-2017).


Here's a recipe for turning a torus into a donut.
Real-Time 3D Rendering in XPL0.
Download torus.zip (129k, 15-Jun-2017).


This model of the solar system shows the effects of lighting, texture
mapping, and Gouraud shading, each of which can be turned off or on.
Download orbs.zip (164k, 15-Jun-2017).


With Dr. Eliza you can discuss your most intimate problems.
Game? Or therapeutic tool?
Classic example of artificial intelligence run amok.
Download eliza.zip (41k, 15-Jun-2017).

Screenshot This program understands English commands such as
"Put the red block on top of the green one."
It's inspired by a much more sophisticated
program called SHRDLU.
Download blkworld.zip (36k, 15-Jun-2017).


image The Mandelbrot set is the set of points C that do not cause Z
to go to infinity when this equation is repeatedly calculated:
Z := Z^2 + C
Z and C are complex numbers. They consist of two values called
real and imaginary....
Download mandel.zip (45k, 15-Jun-2017).

Screenshot Here's a simple version of a raycaster like used in Wolfenstein 3-D.
The essentials are boiled down to six pages of commented code.
Use your mouse to move through the rooms.
Could this be the start of your FPS game?
Download cast.zip (35k, 15-Jun-2017).

Screenshot Spirograph with standard GUI controls.
Download spiro.zip (36k, 15-Jun-2017).

Screenshot Screenshot Here are a couple games for young kids.
Use the arrow keys to load the truck with the
four shapes shown in the upper-right corner.
Once you've mastered that, how many hops
will it take to guide the frog to the pond
(where he can eat a delicious fly)?
Download kidgames.zip (55k, 15-Jun-2017).

Screen images

Here's a selection of maze programs from simple to complex -- rectangular, hexagonal, and spherical, 2D and 3D, inside and out.
Perhaps one of these eight programs will strike your fancy. Download mazemad.zip (46k, 30-Jun-2017).

Screenshot Screenshot Screenshot Screenshot

If you like demo programs, Hugi Magazine shows how to make them in XPL0.
Versions that run on the RPi are here: Download hugidemo.zip (184k, 26-Jun-2017).

Here are some utility programs useful for manipulating program files.
The main one is a cross-reference generator.
Download tools.zip (15k, 26-Jun-2017).

Screenshot 3D Isometric Sokoban sliding box puzzle game with 36 levels.
(Coding sound effects is so much simpler than with the Windows version.)
Download sokoban.zip (66k, 11-Jul-2017).

Screenshot This waterwheel defies expectations by periodically reversing direction.
It demonstrates the Lorenz Attractor, the famous set of equations that
turned the physicist's world into chaos.
Download ww.zip (28k, 16-Jul-2017).

Screenshot Stereo 3D plot of the Lorenz Attractor.
"Can the flap of a butterfly's wing stir up a tornado...?"
A mere 73 lines of XPL0 code.
Download lorenz.zip (23k, 16-Apr-2017).

See also

Getting Started

Detailed Description of XPL0 on the Raspberry Pi

Simplified Assembly Language for the Raspberry Pi

How sieve.xpl Gets Compiled

The XPL0 Programming Language

Sound Library, if needed: libasound.zip (659k).

My version of the PiPad

External links

Wikipedia: Raspberry Pi

Low-level Graphics on Raspberry Pi

ARM assembler in Raspberry Pi

ARM and Thumb Instruction Set Reference Card

Taming The Linux Keyboard

Feedback is always appreciated. Please send email to me at: loren (dot) blaney (at) gmail (dot) com.

Last update: 16-Mar-2018