Chickens on the Freeway

Copyright © 2022 by Víctor Parada

Chickens on the Freeway

This is a little game for the 2022 NOMAM's BASIC 10-liners Contest. This program fits in the PUR-120 category, and it was written using FastBasic 4.5.2 for the 8-bits ATARI XL/XE. Development started on 2022-03-16, and it took 1+2 days. The final version's date is 2020-03-18.

UPDATE: It obtained the 3rd place of 13 entries in the category.


Description

Chickens must go to the other side of the freeway. Who will help more of them?


Instructions

FREEWAY start This is a game for two players, so two joysticks are required.
There is a 10 lanes freeway in front of the chickens, and you must guide them to the other side as many times as you can in a little more than 2 minutes.
Press [START] to begin.
FREEWAY move Use the joystick to move a chicken.
The joystick in port 1 moves the chicken at the left, and the joystick in port 2 moves the one at the right.
You can move only forward o backward, not to the left or right.
FREEWAY hit If a car hits a chicken, it will go back a couple of lanes. Beware, another car could hit it again while recovering.
FREEWAY score When a chicken reaches the other side, you will score 1 point, and another chicken will appear at the bottom.
FREEWAY finishing When 2 minutes has been completed, the scores will flash, and only few seconds remain.
FREEWAY end The game is over when the freeway is freezed.
The player who scored the most is the winner.

Development of the game

Freeway is a game created by David Crane for the Atari 2600 VCS console, published in 1981 by Activision. It was ported to the A8 by Glurk and released two weeks ago, using enhanced graphics to get more colorful cars and detailed chickens.

2600 Freeway

David Crane's Freeway for the 2600

A8 Freeway

Glurk's Freeway for the A8

I thought that this game could be simplified to fit in a tenliner, so I build a quick proof of concept in FastBasic, but in some hours I got a working version of the first variation of the game, the one with only one car per lane.

Prototype 1

Freeway with 10 lanes PoC

Prototype 2

Adding the chickens.

The next day, I had to optimize the code to make it fit in 10 lines of 120 chars each, but during the code revision I found that it could be enhanced a bit to make it more challenging. I also fixed some sound effects and colors, and modified the double lines to be continuous just because I like them in that way, and that allowed me to reuse them for the shoulders. The timers were also adjusted in order to use the same amount of time than the original game, for both PAL and NTSC versions.

Prototype 3

Final prototype

In order to not be mistaken with the A8 port, I changed the name to "Chickens on the Freeway".


Download and try

Get the FREEWAY.ATR file and set it as drive 1 in a real Atari. Turn the computer on and the game should start after the loading completes. Two joysticks are required, one for each player.


The code

The abbreviated BASIC code is the following:

The full and expanded BASIC listing is:


Chickens on the Freeway
(c) 2022 Víctor Parada
2022-03-17

45056 = $B000 = Charset -> PMBASE
46080 = $B400 = PM0 PMADR(0)
48480 = $BD60 = DList DPEEK(560)
48512 = $BD80 = Screen DPEEK(88)
graphics 8
Clears the top 8K of RAM
graphics 17
Sets 20x24 4-color text mode
move $E080,$B080,80
Builds a custom charset.
Copies digit bitmaps from ROM
move adr("{binary data}")+1,$B00E,10
Adds segmented and continuous lines
poke 756,$B0
Activates the new charset
move adr("{binary data}")+1,704,9
Sets the color palette (PAL)
mset $BDD0,20,65
move $BDD0,$BDF8,300
mset $BDA8,20,66
mset $BF38,20,66
mset $BE70,20,130
Builds the playfield (freeway)
poke $BD63,198
poke $BD67,134
move $BD67,$BD69,18
Adds interrupts to the display list
z=215
Just a constant to save some bytes in the listing
pmgraphics 1
Initializes P/M graphics mode with single scanline resolution
- P0: Left chicken
- P1: Right chicken
- P2: Stripe of cars
data p() byte = "{binary data}"
data q() byte = "{binary data}"
data r() = 0,-1,-2,-3,-4,-5,5,4,3,2,1
Freeway arrays
- P(): horizontal position of a car in the lane
- Q(): Color of each car
- R(): Speed of every car (negative ones go to the left)
Strings has a leading byte (blank bitmap, not used)
a=$B679
move adr("{binary data}")+1,a,26
Sets up car bitmaps in the highway
a=pmadr(2)+121 -> both left lines in the center of the freeway.
-move a-48,a-64,64
move a+16,a+32,64
Copies cars from the left lane to the 4 corresponding right lanes
dli set d = p wsync into $D002,
  q wsync into $D014,
  0 wsync wsync wsync wsync wsync wsync wsync wsync into $D014
Sets the DLI to position and color each car
dli d
Activates the DLI
dim s(2),t(2),n(2),o(2)
Players arrays
S(): height of the chicken
T(): timer while moving back after been hit, including a delay before getting the movement control
N(): Timer for the FX when a player reaches the top
O(): Score of the player
pmhpos 0,88
pmhpos 1,160
Initializes the horizontal position of both chickens
b=adr("{binary data}")+1
Chicken bitmaps, including extra white to remove previous height of the player.
Images are standard, walking and been hit
move b,$B4D7,10
move b,$B5D7,10
Displays the chickens at the bottom
do
MAIN LOOP
  poke 708,42
Restores the score color
  repeat
  until peek(53279)=6
Waits for START key
  poke 77,0
Disables ATRACT mode
  for i=0 to 1
Sets up the players
    j=pmadr(i)
$D400+256*i
    mset j,256,0
Cleans the player area for the chickens
    s(i)=z
Sets the current height at the bottom
    t(i)=0
    n(i)=0
    o(i)=0
Resets timers and score
    position 4+10*i,0
    print #6,"0 "
    move b,j+z,10
  next i
Prints the corresponding zero score
  poke 20,0
  dpoke 18,0
Resets system timer
  repeat
GAME LOOP
    if peek(19)>23 then poke 708,
      peek(708)+4
Flashes the score for the last few seconds
    pause
Waits for VBLANK
    poke $D01E,0
Clears P/M collisions
    for i=1 to 10
Computes next position of each car
      p(i)=((p(i)+128+r(i)) mod 168)+40
    next i
Limits the position to the visible area of the playfield plus 8 bits of margin
    pause
Waits for another VBLANK to allow the screen to be completely drawn
    for i=0 to 1
For each player
      if peek($D00C+i) and t(i)<11
Hit by a car? Allows also while in the delay
        t(i)=29
      endif
Starts the push down animation
      j=t(i)
Checks the time counter
      if j
Is the animation going on?
        if j>11
Not in delay mode?
          sound i+2,9+(j mod 6),10,8
Chirps!
          s(i)=s(i)+2
Move down 2 scanlines
          if s(i)>z then s(i)=z
Limited by the bottom/initial position
          move b+20*(j&1),
            pmadr(i)+s(i),10
Displays first and third bitmaps for the animation, one at a time
        elif j=11
          sound i+2
        endif
No chirps when the delay starts
        dec t(i)
Updates the timer
      else
Check if the player needs to be updated
        j=stick(i)
Read the joystick
        k=((j=13)-(j=14))*2
Calculates the step for the movement
        if k
Moved?
          sound i,200+16*i,10,3
Step FX
          j=s(i)+k
Calculates the player's new position
          if j<43
Reached the top?
            n(i)=15
Starts celebration FX
            inc o(i)
Increases score
            position 4+10*i,0
            print #6,o(i)
Displays new score
            mset pmadr(i)+j,12,0
Removes player
            j=z
Sets player at the start position
          elif j>z
            j=z
          endif
Limits the moving down to the bottom/start position
          move b+10*(j&2>0),
            pmadr(i)+j,12
Displays the player in the new position
          s(i)=j
Saves the new player position
          sound i
        endif
      endif
Shuts up the step FX
      if n(i)
        sound i+2,78+4*i,12,n(i)-1
        dec n(i)
      endif
    next i
Sound FX when a chicken arrives to the top
  until peek(19)>26
Game is over after a couple of minutes
$2000 = 2:15 -> 32 (NTSC)
$1B00 = 2:18 -> 27 (PAL)
  sound
Shuts up pending FX.
loop
Returns to main loop:

Return to my 10-liners page.

© 2022 by Víctor Parada - 2022-03-18 (updated: 2022-03-09)