# Coronavirus

Copyright © 2020 by Víctor Parada

This is a little game for the 2020 NOMAM's BASIC 10-liners Contest. This program fits in the PUR-80 category, and was written in stock Atari BASIC for the 8-bits ATARI XL/XE.

## Description

Coronavirus is spreading widely and too fast. Lead your population to a safe area within the time.

## Instructions

| Virus is spreading and your population at the bottom of the screen is in danger.
| Use your joystick to lead one group at a time to the safe area at the top of the screen, once you leave the bottom area, you cannot go back.
| Once a group is safe, some more time is added, and you can lead another group.
| You can arrive to any position in the safe area, but following groups should fill the empty spots.
| You can move diagonally to pass through blocking viruses.
| If the group you are leading becomes infected, you die.
| When the time is over, infection becames unstoppable and the game ends.
| You win only when all groups are safe!

## Development of the game

Soon...

## Download and try

Get the CORONAVI.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:

| Symbology: virus=202 player = 47 blocked = 130 pending = 175 saved = 111 dead = 208
    0
| LINE 0: Initialization
    graphics 18
| Enables text mode with 20x12 resolution and 5 colors (4 for text and 1 for background)
    dim v(8),d(8)
| Virus arrays: V(0-8): horizontal position of virus D(0-8): moving direction of the virus
    ? #6;"TIME=999{binary data}"
| Prints game title
    z=adr("{binary data}")
| Joystick's bit table (x*4+y)
    s=40580
| Memory address where playfield data starts, same as s=peek(88)+256*peek(89)+20
    1
| LINE 1: Sets up the playfield
    poke 77,0
| Disables attract mode
    c=s+20
    position 0,11
    for i=0 to 8
| Routine to build the start state of the game
      x=int(rnd(0)*18)+1
      v(i)=x
| Choose a column where to put the virus
      d(i)=1
| Each virus will start moving to the right
      poke c+x,202
| Puts the virus
    2
| LINE 2:
      c=c+20
| Next playfild line's memory address
      print #6;"{binary data}";
    next i
| Prints the first 9*2=18 groups
    print #6;"{binary data}";
| Prints cels 19 and 20, the last one in another (active) color
    o=40799
| Sets current position of active group
    x=19
    y=10
| Sets current coordinates of active group
    n=20
| Sets number of total groups to save
    k=0
| Not killed... yet!
    r=1
| Groups are alive
    f=0
| Frecuency for the player to move
    t=999
| Sets timer
    3
| LINE 3: GAME LOOP
    i=(i+1)*(i<8)
| Selects next virus line (9 lines: from 0 to 8)
    c=s+20+i*20
| Computes memory address for the virus line
    w=v(i)
| Gets current virus horizontal position
    h=(w=0)+(w=19)+(rnd(0)<0.1)
| Decides if the direction of the virus should change
    if h then d(i)=-d(i)
| Changes virus direction if it was decided
    4
| LINE 4:
    p=c+w
| Gets memory address for current virus
    q=p+d(i)
| Gets next memory address for current virus
    k=peek(q)=47
| Is the player in the new position?
    poke p,202*(rnd(0)<0.12)
| Removes the virus from its old position, except if a random trail is left behind
    poke q,202
| Puts the virus in its new position
    v(i)=w+d(i)
| Updates current horizonta position of the virus
    f=f+1
| Increase player frecuency counter
    5
| LINE 5: Updates player's position
    t=t-(t>0)
| Decrease global timer
    j=peek(z+stick(0))
| Reads the joystick
    on f<3 or j=5 or k goto 9
| Skip player movement if is not time to move, joystick was not moved or the player was killed
    f=0
| Resets the player delay
    a=int(j/4)
    b=j-a*4-1
    a=a-1
| Computes movement deltas
    6
| LINE 6:
    p=o
| Makes old position the current one
    w=x+a>=0 and x+a<20
    u=y+b>=0 and y+b<10
| Check for inbound new position
    a=a*(not(y=10 and b+1))
| Horizontal move is prohibited inside bottom line if y=11 and b+1 then a=0
    c=b*u*20
| Computes new vertical movement of the player in the playfield
    o=p+a*w
| Updates horizontally current position in the playfield
    7
| LINE 7:
    h=peek(o+c)<>111
| Unable to move over a saved group
    o=o+c*h
| Updates vertically current position in the playfield
    k=peek(o)=202
| Is there a virus?
    x=x+a*w
| Updates current horizontal coordinate of the player
    poke p,130*(y=10)
| Removes the player from the old location, and fill space fro the bottom line
    y=y+b*u*h
| Updates vertical coordinate of the player
    8
| LINE 8: When a group reaches the top, select the next one
    poke o,47+64*(y=0)
| Moves the player to the new position, making it saved if it reached the top line
    if y=0 then n=n-1
      x=n-1
      y=10
| Saved a group, continue with next group
      r=n>0
| Not last group?
      o=40779+n
      poke o,47*r
| Changes color for the next active group
      t=t+47-n
| Extra time
    9
| LINE 9: End of loops (in a loop)
    position 5,0
    print #6;t;"{binary data}";
| Prints timer
    on k=0 and t>0 and n goto 3
| Game ends when killed, time is over or all groups were rescued
    poke o,208*r
| Kills the group (unless the player wins)
    on strig(0) goto 9
| Wait for the trigger to start a new game
    run
| Restarts the game

Return to my 10-liners page.