Journey to the Golden Mothership

Copyright © 2020 by Víctor Parada

Journey to the Golden Mothership

This is a little game for the 2020 NOMAM's BASIC 10-liners Contest. This program fits in the "stock" PUR-80 category, and it was written using Atari BASIC for the 8-bits ATARI XL/XE. Development started on 2019-03-29, and it took 3+2 days. The final version's date is 2020-02-09.

UPDATE: It obtained the 6th place of 87 entries in the category.


Description

As the commander, guide your ship safely to visit all your squad's motherships, and reach the golden one before running out of energy.


Instructions

MOMSHIP start Your ship starts at the left side of the galaxy. The mothership is at the right side. Some asteroids are in between them. There is a energy indicator on top.
MOMSHIP flights Use your joystick to drive your ship giving momentum in any direction. To slow down, give some momentum in the opposite direction.
MOMSHIP next one Each time you arrive to a mothership, you must start another journey to the next one, with more asteroids on the road.
MOMSHIP golden Your mission is completed if you can reach the Golden Mothership before you run out of energy.
MOMSHIP fail You fail your mission if you hit an asteroid or go out of the bounds of the galaxy. Press FIRE button to start a new mission.

Development of the game

For 2019's BASIC tenliner contest, I put all my effort in the PUR-80 category, which is the most challenging category for an 800XL machine, as Atari BASIC is not as powerful as other BASICs for the Atari, and it is slow running programs. Still, I put all my creativity to work and tried tricks that would allow things to be done in a non-traditional way to increase speed on the playfield and achieve engaging action games.

The year before, I hacked the DIM statement to align strings with specific memory addresses and use BASIC's powerful strings syntax and operation, in order to move Player/Missile objects on screen just by assigning substrings. With that experience, I improved the technique and wrote some interesting pieces of code that were released in 2019, but some others remained as a projects or prototypes, and this game was one of those, because it was almost ready, but the sound effects were missing, and I was not comfortable with it.

I started writing this game with the idea taken from an older project of a spaceship that must go through different obstacles (levels) to reach its destination. The new concept in this version was to include inertia to add difficulty. As soon as I got a working prototype, I found that almost all the available programming space was used, so I have to decide on which game elements to preserve and which ones to discard.

Instead of moving enemies, I put some fixed "asteroids" in the field, and the enemy became the objective to reach, which will be moving arround. To simplify the code, instead of checking for border limits, I surrounded the playfield with a line, and use the same collision detection routine to detect a crash. To add difficulty, I thought about a timer and more obstacles. Finally, both elements were combined, and the objective was fixed at the right side of the playfield, moving up an down. Instead of a numeric counter, I used the bottom line as a progress bar.

MOMSHIP proto 1

Moving with inertia through obstacles.

MOMSHIP proto 2

Adding a destination to reach and a timer.

The small concept went alive: repeat the trip, but with more asteroids each time. Instead of to reset the playfield, more asteroids were randomly added, the mothership (with a bitmap) only changed its color, and the ship returned to the opposite side at the inverted vertical location of the mothership. As I didn't have enough coding space, instead of setting a color to every game element, I assigned the default colors to asteroids, borders and timer, and used the proper COLOR statement when required.

MOMSHIP proto 3

Measuring time to reach the objective.

MOMSHIP proto 4

New bitmaps.

At the moment, the code used less than 800 bytes (80 chars in 10 lines), but the statements did not fit on every line, extending to 11 or 12 lines. After many optimizations, I could get a source of 10 lines only. I also changed the bitmaps, again, but was I happy? No, because it only had a sound effect at the end of each round or a crash (same SOUND instruction with dynamic parameters based on current status). The deadline for the contest was here and, as I said at the beginning of this section, I didn't submit it.

<
MOMSHIP proto 5

Final (unreleased) version

When 2020's contest was opened for submissions, I took the source code and I analized it again with a fresh mind. I could code in a different way how the joystick was read, which saved me a bunch of bytes, and allowed me to reorganize the lines to open a space for an extra SOUND instruction: a propeller-like sound when the joystick is moved. I was happy now.

<
MOMSHIP proto 6

Final version with sound FX...


Download and try

Get the MOMSHIP.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.


The code

The abbreviated BASIC code is the following:

The full and expanded BASIC listing is:

0
LINE 0: Initializes strings for P/M control
dim x$(1),f$(32767-adr(x$)),a$(1792),b$(256)
Reserves memory for game elements data, forcing A$ to be at page 128 ($80) matching PMBASE
a$="{null char}"
a$(1792)=a$
a$(2)=a$
Clears P/M area
m=1100
Vertical position of Mothership (relative to PMBASE)
1
LINE 1: Initializes screen
graphics 23
Set screen to graphics mode 2 (ANTIC 7) without text window
poke 54279,128
Sets PMBASE at $8000=32768
poke 623,2
GPRIOR=2: P0 over playfield over P3
poke 559,58
SDMCTL=2+32+8+16: One line resolution players only (no missiles) in standard playfield
poke 53277,2
GRACTL=2: Players only, no missiles
z=adr("{binary string}")
Joystick's bit table (x*4+y)
2
LINE 2: GAME LOOP
poke 707,91
Color for ship
d=1
Initial movment direction of Mothership
l=0
Initial level
t=0
Timer
?#6;"{binary char}"
color 2
plot 0,0
drawto 159,0
color 3
drawto 159,95
drawto 0,95
drawto 0,0
Initializes the playfield with a timer bar on top
3
LINE 3: LEVEL LOOP
l=l+1
Sets current level number
poke 704,210-l*15
Sets the color of the mothership basend on level number
poke 53259,0
P3 in normal width
poke 53256,1
P0 in double width
poke 53248,190
Horizontal position of mothership P0
b$=a$
Removes the ship from the playfield
poke 53278,0
Cleans the collision registers
4
LINE 4: Completes level initialization
color 1
for i=0 to 9
  plot rnd(0)*149+9,rnd(0)*93+1
next i
color 3
Adds 10 asteroids to the playfield
x=49
y=1270-m
Initial position of the ship
v=0
w=0
Initial speed and direction
poke 77,0
Resets ATRACT counter
5
LINE 5: NAVIGATION LOOP
j=peek(z+stick(0))
Checks for the joystick movement
sound 0,j,8,j<>5
Propeller sound if joystick is moved
a=int(j/4)
b=j-a*4-1
a=a-1
computes the movement direction on each axis
v=v+a*(abs(v+a)<3)
Increases or decreases horizontal speed
6
LINE 6: Computes mothership movement
w=w+b*(abs(w+b)<3)
Increases or decreases vertical speed
h=(m=1064)+(m=1230)+(rnd(0)<0.03)
Decides if the direction of the mothership should change
d=d*(h=0)-d*(h>0)
Changes mothership direction if it was decided
poke 20,0
Resets internal timer
7
LINE 7: Moves the ship and updates the timer bar
on peek(20)=0 goto 7
Forces a VBLANK to detect a collision
x=x+v
y=y+w
Next position of the ship
poke 53251,x
b$(y)="{binary string}"
Puts the ship in its new position
t=t+1
plot t/9,0
Decreases the timer bar
8
LINE 8: Moves the momship and check collisions
m=m+d
a$(m)="{binary string}"
Moves the mothership to a new vertical position.
r=t>1426
At time limit?
f=9
Prepares a sound FX
c=l<12
Checks for the golden mothership
s=peek(53263)>0
Arrive to mothership?
k=peek(53255)>0
Detects a collision between the ship and an asteroid or border
9
LINE 9: End of navigation, level and game loops
on s+k+r=0 goto 5
Loops if no collision was detected and time is not over
f=f-(f>0)
sound 0,160,10+2*k,f
on f>0 goto 9
Makes a sound with decreasing volume
on c*s+1 goto 2+7*strig(0),3
Loops to lines 2 or 3 depending on the finished level, or loops in same line 9 waiting for the the trigger

Return to my 10-liners page.

© 2020 by Víctor Parada - 2020-02-08 (updated: 2020-08-15)