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 easily make graphics programs, like video games.

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

To make graphics work on the Pi4 it's necessary to use the legacy driver. To do this, from a command line (not in X Windows) type: sudo raspi-config. Under Advanced Options select GL Driver then select Legacy Original non-GL desktop driver. Reboot.

Version 3.2 now supports multiprocessing -- see What's New below. Download xplrpi32.zip (1284k, 15-Feb-2022).

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

Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot


.

Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot


.

Getting Started

XPL0 on the Raspberry Pi

What's New

XPL0 Programming Language Manual Download manual.pdf.

Beware of Pi 5

Whereas XPL0 runs fine on Raspberry Pi models 1 thru 4, the Pi 5 introduces several incompatibilities.

The 64-bit version of the operating system is completely incompatible with XPL0. However, the latest Bookworm version is also available in 32-bits which provides some compatibility. Text-based programs will run as before but graphics is severely limited.

Around August 2022 a security flaw in Linux was discovered, and the solution was to disable ioctl FBIOPUT_VSCREENINFO. This prevents switching the display resolution and color depth at the user level.

A simple way to check if your version of Linux has had this feature disabled is to run the command: fbset -depth 32 (If this is executed from the desktop, you may need to reboot to restore the display.) Does your display change? Does typing "fbset" show the change in color depth?

If your version of Linux has FBIOPUT_VSCREENINFO disabled, it's still possible to set the resolution and color depth at bootup time by modifying the file /boot/cmdline.txt, for example, by appending 640x480M-32@60 (Use "sudo nano cmdline.txt" but first make a backup copy, for example, sudo cp cmdline.txt cmdlineb.txt)

An obvious incompatibility of the Pi 5 with previous models is its lack of the 3.5 mm phone jack. A less obvious incompatibility is that that omxplayer has been dropped from the OS. This prevents the PlaySoundFile intrinsic in XPL0 from working. The vlc media player is now the standard.

DOSBox provides another way to get around these incompatibilities by running MS-DOS versions of XPL0 programs. DOSBox can be installed with the command: sudo apt install dosbox -y

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 permissions are enabled. The Linux change-mode command will do this, for example: chmod +x textris

Multiprocessing Demo This demonstrates the new multiprocessing features in XPL0.
It simultaneously sorts nine arrays comparing nine different algorithms,
from Quicksort to bubble sort.
Download allsorts.zip (28k, 15-Feb-2022).

Halloween
game Halloween Treat: Little Herbie has donned his costume and is eager for a night of trick-or-treating. Can you guide him through the neighborhoods and collect all the treats? Download treat.zip (37k, 28-Sep-2020).

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).

Screen
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).

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

Screen
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, 2-Sep-2020).
Screenshots

_

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 (66k, 2-Sep-2020).


_

Here's a recipe for turning a torus into a donut.
Real-Time 3D Rendering in XPL0.
Download torus.zip (128k, 2-Sep-2020).


_

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).


_

Screen
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).

Screen
image Screen
image Screen
image
This version pans and zooms through the Mandelbrot set using the mouse.
It uses four processes for a four-times speed increase on a Pi3 or Pi4
(which will also test their cooling capacity).
Download manxome.zip (27k, 15-Feb-2022).

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 (34k, 2-Sep-2020).

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 (47k, 2-Sep-2020).


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).

screenshot XED 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).

screenshot Art is a paint program that makes it easy to create and modify drawings and artwork. It saves images in compact gif files, like used on the Internet, as well as bmp and pcx files. If you're familiar with Deluxe Paint, Art performs many of the same operations and uses many of the same shortcut keys. Commands and drawing tools can be selected from drop-down menus, but it's faster to use the key commands, with one hand on the keyboard and the other on the mouse. Download art.zip (154k, 17-Aug-2023).

examples

examples

See also

Simplified Assembly Language for the Raspberry Pi

How sieve.xpl Gets Compiled

The XPL0 Programming Language

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-Jan-2024