The Matrix: Red Pill

Copyright © 2021 by Víctor Parada

REDPILL

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.


Description

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


Instructions

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.
0
LINE 0: Assigns memory space
print "Wait"
Prints a message to manage anxiety
k=1024
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
1
LINE 1: Global initialization
b$(2*k)=b$
b$(2)=b$
Initializes blank string (cont)
r$=b$
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)
r$(513)=r$
Initializes the remaining 75% of random data by copying the first 25%
2 
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)
  i=i+29-int(i/256+rnd(0)*4)*2
next i
Skips some bytes of data by jumping over based on the current zone
sound 0,254,6,1
Enables a background sound
a$=b$
Clears P/M area
3
LINE 3: Game setup
a$(2002)="{binary data}"
Puts a pill over P4
s$=b$
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
4
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
Colors
Red Pill: PAL=36 NTSC=52
poke 708,178
poke 709,182
poke 711,190
Green fonts
5
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
a$(1682,1688)=a$(2002)
a$(1690,1752)=a$(1682)
Builds a stack of pills
x=122
Sets initial horizontal position of the pill in the middle of the playfield
v=10
Total number of pills (lives)
l=0
Initial density level
n=0
Counter for steps in the level
m=0
Total number of steps (score)
6
LINE 6: Game loop
n=(n+1)*(n<120)
Increases the number of level steps (reset to zero for next step)
m=m+1
Increases the number of level steps
w=v>0
Checks for remaining pills
j=stick(0)
Reads the joystick
x=(x+2*((j=7)*(x<180)-(j=11)*(x>64)))*w
Computes next horizontal position within limits, but removes it from screen if there are no more pills
7
LINE 7: Updates playfield
poke 53251,x
Moves P4 (the pill) to the next position
l=l+(n=0)*(l<7)
Moves to next level if a reset in the number of steps is detected
t$=r$(int(rnd(0)*112)*2+1+256*l)
t$(33)=s$
Prepares the next frame by joining of a line of random data and the current screen
s$=t$
Updates the screen from the temp buffer
8
LINE 8: Checks for collisions
i=689+int(x/4)
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)
s$(i,i+2)=b$
Cleans the obstacle under the pill to avoid double collisions
i=1762-v*8
Points to the last pill in the stack
9
LINE 9: Loose a pill and Game Over routine
a$(i,i+6)=b$
Removes a pill from the stack
v=v-1
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
print
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)