Mario game for the PC with complete source code!

Written by Mike Wiering, 1994


This is a Super Mario Bros. clone with six levels, written in Turbo Pascal. I wrote this game to practice VGA programming. My goal was to create a PC game with parallax scrolling layers that would run smoothly on my 486 computer (25 MHz). I didn't plan to release this Mario game, instead use the engine to make more original games.

However, an old beta version of this Mario game (with only four levels, unfinished) somehow ended up being spread around. I was very surprised to find someone selling disks with my Mario clone at a computer fair years later! I bought one to examine the contents at home. What I saw made me really furious: someone had actually changed the game into shareware, modified the executable, added some doc files and even a registration form, asking people to send $15!

Seeing other people make money from my games like this took away my motivation for games programming for a while. I kept finding this hacked version on shareware CD-ROMs and Internet sites. Finally, I decided to release the complete source code of this game, so people can at least learn from it.

Many people all over the world enjoy this game. I recently found a picture of Tiger Woods playing my Mario game during an interview on television: Tiger Woods playing Mario.

Download and instructions

Here you can download the game and the source code. The game consists of only one tiny executable! You don't need to download anything else. To run the game, you will need a 286 (or better) computer with VGA.

In the game, you can walk with [Left] and [Right] and jump with [Alt]. Hold [Ctrl] down to run faster. You can go down into some pipes by pressing [Down]. Fire with [Space] (aim with [Up] and [Down]). To quit, press [Esc] at any time.

Now there is also joystick support, run mario -j to calibrate.

The source code

The game was originally written in Borland Turbo Pascal 6.0, which supports inline assembly. Because some people don't have TP 6.0, I have also made a version of the source code for TP 5.5, which is available for free at Borland's Museum.

A few notes about the source code

There is no level editor, all the levels are coded in WORLDS.PAS. Each character indicates a block (as can be found in FIGURES.PAS).

All sprites were made with the sprite editor GRED, which is also available in the archive. Sprites have the extensions .000, .001, etc. To edit, for example, type: GRED SWMAR.000 and save it with F4. GRED creates text files with extensions .$00, .$01, etc. that are included in the Pascal source code. This allows the sprites to be located in the code segment, not the data segment (which is limited to 64K in TP).

Mario works with a 320x200 screen mode (chained), with page flipping (see VGA.PAS). The virual screen width is two blocks wider than the screen itself, so when the game scrolls one pixel to the left or right, I draw one complete new block instead of a vertical line from several different blocks (see PLAY.PAS).

Because copying video memory to video memory can be done very fast, I use the remaining video memory to save and restore backgrounds of moving sprites (VGA.PAS).

Parallax scrolling is done in two different ways. In the first level I move the background by only drawing the pixels that change when the arches move. This can be done very fast. The bricks and pillars are done by changing the palette (see BACKGR.PAS).

To compile, type: TPC /M /L MARIO (make all units, use link buffer on disk). If this doesn't work, you either haven't installed Turbo Pascal properly or you are in the wrong directory. Run this command from the directory where you have the source files.

More games

More games by Mike Wiering