The Matrix: Red Pill

Copyright © 2021 by Víctor Parada


This is a little game for the 2021 NOMAM's BASIC 10-liners Contest. This program fits in the "stock" PUR-80 category, and it was written in Atari BASIC for the 8-bits ATARI XL/XE. Development started on 2021-03-17, and it took 4 days. The final version's date is 2021-03-25.

UPDATE: It obtained the 19th place of 66 entries in the category.


You have chosen the red pill... Now you need to find the path to enter The Matrix.


REDPILL start Wait about 15 seconds while The Matrix is being loaded...
REDPILL move Use the joystick to move your pill though the Matrix code. You can move only to the left and to the right.
REDPILL opponent Avoid highlighted code! Being hit by those it will cost you a pill. You only have ten pills in total.
REDPILL density At first, there won't be many highlighted chars, but they will increase as the time goes.
REDPILL score When you run out of pills, The Matrix will be halted and a score will be displayed. Press RETURN key to try again.

Development of the game

I always liked the intro screen of The Matrix trilogy. That green rain was originally made from Japanese characters, but it evolved over time. I once thought it might be a good game theme, and finally gave it a try!

Matrix title screen

The Matrix title screen

The idea was to build a vertical scroller, where the highlihted chars are the dangerous ones and they must be avoided. This should be a very simple theme and I decided to use Atari BASIC language to go for a PUR-80 entry in the contest.

As Atari BASIC is slow and it does not provide statements to manage P/M graphics, I decided to use the same trick I used in other games like Deep Canyon and Journey to the Golden Mothership: to define some string variables and change the system pointers to use the data directly from the variables. By assigning data to them using string operations, I could change the screen buffer and the players bitmaps for P/M graphics. To speed up things, the random patterns had to be precalculated and stored in another string before the game start.

Atari's charset looks weird when the fonts are displayed in ANTIC 4 text mode, and I thought that if I change playfield colors (PF0 to PF2) to different shades of green, it could mimic the ones from the rain. To highlight some of the chars, PF3 could be the brightest one, and to make it appear, the char should be displayed in inverse video (chars from 128 to 255 from the ATASCII table). To make the columns clear, I left a space between chars. After some tests, I found that better looking fonts would be displayed when PF2 is visually removed from the screen by assigning it the same black color than the background.

The next step was to choose the graphics for the player. Flying Neo? Running Neo? Nebuchadnezzar? Nope... I decided to use a very simple and iconic element of this saga: the Red Pill. It could be placed vertically, but I decided that it was better to place it horizontally, because it has to be wide to avoid keeping it in the empty columns, and not to big to be able to find a path. I added this rolling pill to the running prototype and got a good looking concept of game.

REDPILL proto 1

Prototype of the "green rain"

REDPILL proto 2

A rolling Red Pill

As the screen was in ANTIC 4 mode, it could not be posible to add a readable score area without wasting precious coding space, so I decided to print the final score in a new screen at the end of the game. For the same reason, I thought that a graphic bar could be a way to represent how much damage has been received by hits against the highlighted chars to finish the game, and then I thought that instead of an horizontal line of pixels using chars or a vertical one at the margin using a missile object, it could be better to put a stack of pills, recycling the player's bitmap in another player object. I needed some extra space for the stack, so I changed the playfiled to be narrow, this is 32 bytes only per line instead of 40 bytes.

I added lots of things to get a better looking rain, with clear characters to be avoided, but I quickly run out of coding space. To fit it in only 80 characters, I had to discard many of them. There was no room for a nice sound effect for collisions and only one type of bright character was selected.

When this game was almost ready, I thought that it could be interesting another version for two players... and I made a prototype with two pills: Red and Blue!!! Continue reading...

DISCLAIMER: This game is based on characters created by the Wachowski sisters, and it was developed without their supervision.

Download and try

Get the REDPILL.ATR file and set it as drive 1 in a real Atari (or emulator). Turn on the computer and the game should start after loading. A joystick in port 1 is required.

A note for NTSC users: This game was programmed for PAL computers. If you want to play in NTSC systems, you can LOAD and RUN a modified copy of the game called "NTSC.BAS" that it is also included in the ATR file.

The code

The abbreviated BASIC code is the following:

The full and expanded BASIC listing is:

The Matrix - Red Pill

(c) 2021 by Victor Parada G.
LINE 0: Assigns memory space
print "Wait"
Prints a message to manage anxiety
Defines a constant to save source code space
dim t$(k),f$(15*k-adr(t$)),a$(2*k),s$(k),r$(2*k),b$(2*k)
Reserves memory for game elements data, forcing A$ to be at page 64 ($40) matching PMBASE
T$: Temporary buffer to create next frame
F$: Just a filler to force next variable be at memory address 16384
A$: Manages P/M data (2K for single scanline resolution)
S$: Screen data (forcing Display List to point here)
R$: Precalculated random data (8 blocks of 256 bytes with different density of obstacles for 8 levels)
B$: Blank data (used to initialize other string variables)
b$="{ATASCII zero}"
Initializes blank string
LINE 1: Global initialization
Initializes blank string (cont)
Clears random data
for i=0 to 510 step 2
  poke 19*k+i,rnd(0)*127
next i
Initializes only 25% of random data (for setup speed)
Initializes the remaining 75% of random data by copying the first 25%
More global initialization
for i=0 to 2046
Puts the obstacles over the random data
  poke 19*k+i,138
Puts an obstacle with high bit set (inverse video to enable PF4)
next i
Skips some bytes of data by jumping over based on the current zone
sound 0,254,6,1
Enables a background sound
Clears P/M area
LINE 3: Game setup
a$(2002)="{binary data}"
Puts a pill over P4
Clears the screen memory
graphics 28
Sets screen to graphics mode 12 (ANTIC 4) without text window
poke 39812,0
poke 39813,72
Changes Display List pointer to screen buffer
poke 54279,64
Sets PMBASE to P/M buffer
poke 559,57
Sets SDMCTL=1+32+8+16: One line resolution players only (no missiles) in narrow playfield
LINE 4: More game setup
poke 623,1
Sets GPRIOR=1: Players over playfield
poke 53277,2
Sets GRACTL=2: Players only, no missiles
poke 706,36
poke 707,36
Red Pill: PAL=36 NTSC=52
poke 708,178
poke 709,182
poke 711,190
Green fonts
LINE 5: Last touches to game setup
poke 710,0
Hides the most visible pixels of fonts by setting black as the background, so strange fonts are displayed
Builds a stack of pills
Sets initial horizontal position of the pill in the middle of the playfield
Total number of pills (lives)
Initial density level
Counter for steps in the level
Total number of steps (score)
LINE 6: Game loop
Increases the number of level steps (reset to zero for next step)
Increases the number of level steps
Checks for remaining pills
Reads the joystick
Computes next horizontal position within limits, but removes it from screen if there are no more pills
LINE 7: Updates playfield
poke 53251,x
Moves P4 (the pill) to the next position
Moves to next level if a reset in the number of steps is detected
Prepares the next frame by joining of a line of random data and the current screen
Updates the screen from the temp buffer
LINE 8: Checks for collisions
Computes the screen buffer area under the pill
poke 53250,192*w
Puts the column of remaining pills on screen, if there are any:
on peek(53255)<w*8 goto 6
Retpeats game loop if there is no collision between P4 and PF4 (and a pill is on screen)
Cleans the obstacle under the pill to avoid double collisions
Points to the last pill in the stack
LINE 9: Loose a pill and Game Over routine
Removes a pill from the stack
Decreases the number of pills
poke 53278,0
Cleans the collision registers
poke 77,0
Resets the attract mode counter
on w goto 6
Repeats the game loop if there are pills
print "Score: ";m
Prints the score (automatically returns to graphics mode 0, with P/M previously moved out of screen to avoid ANTIC garbage)
input #16,t$
Waits for [RETURN] key to restart
goto 3
Repeats from the level initialization

Return to my 10-liners page.

© 2021 by Víctor Parada - 2021-03-25 (updated: 2021-04-10)