Extracting Graphics from DONKEY.BAS: A Journey Back to 1981

Cfir Aguston
3 min readJan 24, 2025

--

In the early 1980s, as personal computers began finding their way into homes and offices, software served as both a tool and a showcase for what these machines could do. One such piece of software was DONKEY.BAS, a simple yet iconic game created by Bill Gates and Neil Konzen. Bundled with IBM PCs running Microsoft BASIC, DONKEY.BAS was a simple driving game where players controlled a car, avoiding donkeys on the road. While modest in complexity, it became a cultural touchstone, demonstrating the potential of personal computing at a time when graphical user interfaces were not so fancy.

Fast forward more than 40 years, I decided to reconstruct the original graphics of this game from its BASIC source code.

The whole DONKEY.BAS game is implemented with approximately 130 lines of BASIC code. Among these lines, the following quickly caught my attention:

1790 DRAW "S8C3"
1800 DRAW"BM12,1r3m+1,3d2R1ND2u1r2d4l2u1l1"
1810 DRAW"d7R1nd2u2r3d6l3u2l1d3m-1,1l3"
1820 DRAW"m-1,-1u3l1d2l3u6r3d2nd2r1u7l1d1l2"
1830 DRAW"u4r2d1nd2R1U2"
1840 DRAW"M+1,-3"
1850 DRAW"BD10D2R3U2M-1,-1L1M-1,1"
1860 DRAW"BD3D1R1U1L1BR2R1D1L1U1
1870 DRAW"BD2BL2D1R1U1L1BR2R1D1L1U1
1880 DRAW"BD2BL2D1R1U1L1BR2R1D1L1U1
...
1950 DRAW"S08"
1960 DRAW "BM14,18"
1970 DRAW"M+2,-4R8M+1,-1U1M+1,+1M+2,-1
1980 DRAW"M-1,1M+1,3M-1,1M-1,-2M-1,2"
1990 DRAW"D3L1U3M-1,1D2L1U2L3D2L1U2M-1,-1"
2000 DRAW"D3L1U5M-2,3U1"

What are these DRAW commands and what the encrypted strings after it actually mean?

The DRAW command in BASIC introduced a simple, compact language often referred to as GML (Graphics Macro Language) for creating vector graphics. Each command in GML corresponds to a specific drawing action or cursor movement:

  • U, D, L, R: Move the cursor Up, Down, Left, and Right, respectively.
  • M: Move to absolute or relative location.
  • C: Change the drawing color.
  • S: Set the drawing scale.
  • B: Move the cursor without drawing.

Most of the commands include a numeric parameter to define distances or scales, for example:

  • R3 moves the cursor 3 units to the right.
  • M+1,-1 moves the cursor digonically relative to its current location.

These commands were an efficient way to create shapes and patterns, especially when memory and computational resources were limited.

To unlock the graphics of DONKEY.BAS, I implemented a GML parser in C using SDL2 for rendering. The parser interprets GML strings, executing drawing commands in sequence to recreate the original visuals of the game.

Running the parser with the DONKEY.BAS DRAW commands revealed the graphics:

Lines 1790–1880: Car
Lines 1950–2000: Donkey

Mission accomplished!

The GML parser source code is on GitHub:

cfiraguston/GML_Draw: GML (Graphics Macro Language) Drawer

The GML syntax was a brilliant solution for generating graphics on early personal computers, bridging the gap between textual and graphical programming in an era when system resources were highly constrained. It is amazing how with a few lines of code some complex graphics could be created, and DONKEY.BAS is a good example for this.

--

--

Cfir Aguston
Cfir Aguston

No responses yet