'Z E N
'

DECLARE FUNCTION rand% (max%)
DECLARE SUB mouth ()
DECLARE SUB background (mode$)

' Quotes from ZEN
DIM quotes$(20)
quotes$(1) = ""
quotes$(2) = "State course and speed"
quotes$(3) = "Standard by six"
quotes$(4) = "Battle computers on line"
quotes$(5) = "Activate the force wall"
quotes$(6) = "Standby the teleport"
quotes$(7) = "Federation pursuit ships approaching"
quotes$(8) = "That information is not available"
quotes$(9) = "Flight time 94 minutes at current speed"
quotes$(10) = "Confirmed"
quotes$(11) = "Clear the neutron blasters for firing"
quotes$(12) = ""
quotes$(13) = ""
quotes$(14) = ""
quotes$(15) = ""
quotes$(16) = ""
quotes$(17) = ""
quotes$(18) = ""
quotes$(19) = ""
quotes$(20) = ""



' Colour codes for screen mode 0
DIM colours%(4)
colours%(1) = 7  'white
colours%(2) = 8  'gray
colours%(3) = 15 'bright white
colours%(4) = 0  'black

' Character codes for blocks
DIM blocks%(4)
blocks%(1) = 176
blocks%(2) = 177
blocks%(3) = 178
blocks%(4) = 219

' Array to hold random screen positions
DIM rows%(100), columns%(100)


SCREEN 0, 0: CLS
RANDOMIZE TIMER

DO
  CALL background("draw")
  CALL mouth: SLEEP 1
  CALL background("erase")
LOOP

SUB background (mode$)

SHARED colours%()
SHARED blocks%()
SHARED rows%(), columns%()

RANDOMIZE seed%

IF mode$ = "draw" THEN

'Background/draw
FOR q = 1 TO 50
row% = rand(24): rows%(q) = row%
col% = rand(80): columns%(q) = col%
colour% = colours%(rand(3))
block% = blocks%(rand(4))
LOCATE row%, col%
COLOR colour%, 0
PRINT CHR$(block%);
NEXT

ELSE ' mode$="erase"

'Background/erase
COLOR 0, 0
FOR q = 1 TO 50
row% = rows%(q)
col% = columns%(q)
LOCATE row%, col%
PRINT "#";
NEXT

END IF

END SUB

'Animate "mouth", include black blocks
SUB mouth

SHARED colours%()
SHARED blocks%()
SHARED quotes$()

FOR col% = 20 TO 60
LOCATE 12, col%
COLOR colours%(rand(4)), 0
PRINT CHR$(blocks%(rand(4)));
NEXT

FOR col% = 20 TO 60
LOCATE 13, col%
COLOR colours%(rand(4)), 0
PRINT CHR$(blocks%(rand(4)));
NEXT

COLOR 15, 0
q$ = quotes$(rand(20))
left% = (80 - LEN(q$)) / 2
right% = 80 - left% - LEN(q$)
LOCATE 25, 1: PRINT SPACE$(left%); q$; SPACE$(right%);


END SUB

FUNCTION rand% (max%)
rand = 1 + INT(RND * max%)
END FUNCTION

