/*****************************************************************

                     ONLINE   FOOTBALL
                       version 1.3
                  written by Matt English
                   copyright 1-10-1994

                    CNet v2.63 Conversion 
                     by Charles Johnston
                           1-16-94

               A Game especially designed for
                          BBBBS
                    which was written by
                    Richard Lee Stockton

        You are welcome to use this on your BBBBS
       system as long as my name is not removed from
       this code, or the main program screen & you make
       no money from this game.

   CONVERSIONS : !!!!!!!!
   You are given permission to convert this program to ANY
   other BBS system, Amiga or IBM, as long as:

   1. You leave my name in the code and on the main program screen.
       (Leaving my name burried in the docs doesn't count!)
   2. You have never written a game that says "ONLY TO BE
       USED ON xxxxx BBS SYSTEM". ( I really, really hate that!)
   3. You make no money from this game.

   TO ALL SYSOPS:
    If you use this program, a call to my BBS would be nice!
    (If you've never called.)
    The Alternative BBS (503) 761-3043

*******************************************************************/

options results
call carrier
FF='0C'x  /* FormFeed */
CR='0D'x  /* Carraige Return */
SIGNAL ON IOERR
SIGNAL ON SYNTAX
SIGNAL ON BREAK_C
SIGNAL ON BREAK_E
transmit '@4'
bbspath='pfiles:'
address command'C:resident C:sort add'


if ~show('L','rexxsupport.library') then do
 addlib('rexxsupport.library',0,-30,0)
 end

origsecs = time('r')     /* This sets the timer */

bbsidentify name
bbsname=result

Getuser 1
line = result
parse var line first second third fourth
if second ~= '' & third ~= '' & fourth ~= '' then username = first||'_'||second||'_'||third||'_'fourth
if second ~= '' & third ~= '' & fourth = ''  then username = first||'_'||second||'_'||third
if second ~= '' & third  = '' then username = first||'_'||second
if second = '' then username = first
if length(username)>15 then username=left(username,15,'')

datapath = bbspath'OLFB/'
if ~exists(datapath'Players') then call makedir(datapath'Players')
if ~exists(datapath'Games') then call makedir(datapath'Games')
if ~exists(datapath'Stats') then call makedir(datapath'Stats')
PlayerPath = datapath'Players/'
GamesPath = datapath'Games/'
StatsPath = datapath'Stats/'

if ~exists(StatsPath'Stats.date') then do
 call open(Tstats1,StatsPath'Stats.date','w')
 call writeln(TStats1,date())
 call close(Tstats1)
 end
if ~exists(StatsPath'Stats.1') then do i = 1 to 9
 call open(Tempstat,statspath'Stats.'i,'w')
 call writeln(TempStat,'0 AMIGA 0 0 0 0 0 0 0 0 0')
 call close(TempStat)
 end

pic0 = datapath'pics/Intro.ansic'
pic01 = datapath'pics/Intro.Ansibw'
pic02 = datapath'pics/Intro.AsciiC'
pic03 = datapath'pics/Intro.AsciiBW'
pic1 = datapath'pics/Main.ANSIC'
pic2 = datapath'pics/Main.ANSIbw'
pic3 = datapath'pics/Main.ASCIIC'
pic4 = datapath'pics/Main.ASCIIbw'

       /* colors off unless colorflag=1 */

do i = 0 to 7
 pen.i = ''
 bak.i = ''
 end
getuser 28
colorflag=result
IF colorflag~=0 THEN    /* let's see some color!*/
 DO i = 0 to 7
  pen.i = '[3'i'm'
  bak.i = '[4'i'm'
  end

default = '[0m'
CLS = '[H[J'
UNL = '[4m'
BOLD='[1m'
i = random(1,999,time('S')) /* initalize random number generator */

/* Screen positions */

puserscore='[4;25H'
pusername='[4;8H' /* Spot for star and blank and name */
pamiscore='[5;25H'
paminame='[5;8H'
pdown='[4;46H'
pytg='[5;45H'
pyl='[6;45H'
pquarter='[4;68H'
pplaynum='[5;66H'
pvisitgoal='[8;8H'
pball='[9;13H'  /* Position of the ball line at the visit goal */
ppromptln='[22;10H'
poptln='[17;1H'
pplay='[15;2H'
psb='[2;1H'
pfield='[7;1H'
pmain='[1;1H'
pmainc='[2;1H'

transmit CLS
transmit CR
transmit CR
call sad'Loading Amiga Online Football, Please wait...'
transmit cr
address command'c:copy 'datapath'plays ram:plays ALL quiet'
CALL DELAY (50)
if ~exists(PlayerPath||Username) then call NewPlayer
call LoadUserData
if exists(GamesPath||username'.save') then do
 transmit cr
 transmit' Welcome back to Online FootBall!'cr
 transmit cr
 transmit' You last played FootBall on 'lastplay''cr
 transmit cr
 transmit' Would you like to continue your last game?'cr
 sendstring "(Y,n) >"
 query ; answer=upper(result)
 answer = strip(left(answer,1))
 if answer ~= N then call LoadGame
 if answer = N then do
  transmit cr
  transmit' All aborted games count as losses in your Stats!'cr
  transmit' NOW, would you like to continue your last game?'cr
  sendstring' (Y,n) > '
  query; answer=upper(result)
  answer = strip(left(answer,1))
  if answer ~= 'N' then call LoadGame
  else do
   call forfeit
   call ShowIntro
   call NewGame
   signal main
   end
  end
 call showintro
 end
 else do
 call ShowIntro
 call Newgame
 end
signal Main

ShowIntro:
call carrier
transmit cls
transmit cr
if GMode = 1 then thispic = pic0
if GMode = 2 then thispic = pic01
if GMode = 3 then thispic = pic02
if GMode = 4 then thispic = pic03
call open(title,thispic,'r')
do until eof(title)
 tline = readln(title)
 transmit tline
 end
call close(title)
call delay(150)
call pressreturn
transmit cls
transmit cr
transmit' Would you like to see the OLFB Stat Sheet?'cr
sendstring "(Y,n) >"
query ; answer=upper(result)
answer = strip(left(answer,1))
if answer ~= 'N' then call ViewStats
transmit cls
return

  /* Main program body follows */

MAIN:
call carrier
 oldym = ym
 call drawfield
 call scoreboard
 call moveball
 call movepoles
 DO FOREVER
  CALL CONTROL
  END

COINTOSS:
call carrier
 transmit ''CR
 transmit''CR
 CALL SAD' Tossing coin for first posession'
 transmit cr
 CALL DELAY(50)
 TC = RANDOM(1,2)
 IF TC = 1 THEN DO
  CALL SAD 'Amiga wins the toss, Amiga ball on his own 20 yard line'
  POS = AMIGA
  DEF = USERNAME
  YM = 80
  OYM = 80
  oldym = 80
  YTG = 10
  CALL YMCONV
  END
 ELSE DO
  POS = USERNAME
  DEF = AMIGA
  CALL SAD 'Amiga loses the toss!! Your ball on your own 20 yard line'
  YM = 20
  OYM = 20
  oldym = 20
  YTG = 10
  CALL YMCONV
  END
 CALL PRESSRETURN
 transmit cls
RETURN

call drawfield

CONTROL:
call carrier
 PUNTED = 0
 skip = 0
 if playnum > 95 & playnum < 101 then do
  transmit pplay||cr
  transmit cr
  playsleft = 100 - playnum
  if playsleft > 1 then call sad'ONLY 'playsleft' plays left in the game!'
  if playsleft = 0 then call sad'LAST PLAY OF THE GAME!!'
  call delay(150)
  call clrlow
  end
 if playnum > 100 then do
  gamedone = 1
  signal gameover
  end
 if playnum > 45 & playnum < 51 then do
  transmit pplay||cr
  transmit cr
  playsleft = 50 - playnum
  if playsleft > 1 then do
   call sad' 'pen.3'Only 'playsleft' plays left until HALFTIME!'default''
   if origPOS = username then call sad' 'username' won the coin toss, so after the half it''s AMIGA''s ball.'
   else call sad' AMIGA won the coin toss, so it''ll be your ball after the half!'
   end
  if playsleft = 1 then do
   call sad' 'pen.3'Only 'playsleft' play left until HALFTIME!'default''
   if origPOS = username then call sad' 'username' won the coin toss, so after the half it''s AMIGA''s ball.'
   else call sad' AMIGA won the coin toss, so it''ll be your ball after the half!'
   end
  if playsleft = 0 then call sad''pen.4'LAST PLAY OF THE HALF!!'default''
  call delay(150)
  call clrlow
  end
 if playnum = 51 then call halftime
 if dwn = 0 then dwn = 1
 SELECT
  WHEN DWN < 4 & POS = USERNAME THEN CALL MENUA
  WHEN DWN < 4 & POS = AMIGA THEN CALL MENUB
  WHEN DWN = 4 & POS = USERNAME & YM < 65 THEN CALL MENUC
  WHEN DWN = 4 & POS = AMIGA & YM > 35 THEN CALL MENUD
  WHEN DWN = 4 & POS = USERNAME & YM > 64 THEN CALL MENUE
  WHEN DWN = 4 & POS = AMIGA & YM < 36 THEN CALL MENUF
  WHEN DWN > 4 THEN DO
   call cop
   oym = ym
   oldym = ym
   op = ''
   dp = ''
   call yardcontrol
   call ymconv
   call movepoles
   call scoreboard
   skip = 1
   end
  END
 if skip ~= 1 then do
  call clrlow
  CALL PLAYCONV
  if punted = 1 | punted = 2 then do
   if punted = 2 then do
    if pos = AMIGA then do
     YM = 20
     YL = 20
     OYM = 20
     YTG= 10
     end
    else do
     YM = 80
     YL = 20
     OYM = 80
     YTG = 10
     end
    call cop
    call clrlow
    call ymconv
    call scoreboard
    call movepoles
    return
    end
   if punted = 1 then do
    call cop
    call clrlow
    call ymconv
    call scoreboard
    call movepoles
    return
    end
   end
  CALL YARDCONTROL
  CALL YMCONV
  if justchanged = 1 then justchanged = 0
  else call pressreturn
  call moveball
  if dwn ~= 5 then call movepoles
  if dwn ~= 5 then call scoreboard
  call clrlow
  CALL TDOWN
  CALL TBACK
  end
RETURN

COP:
call carrier
 justchanged = 1
 call clrlow
 transmit pplay||cr
 transmit cr
 CALL SAD'****** CHANGE OF POSESSION ******'
 transmit CR
 transmit CR
 call delay(200)
 call clrlow
 SELECT
  WHEN POS = USERNAME THEN DO
   POS = AMIGA
   DEF = USERNAME
   DWN = 0
   YTG = 10
   OYM = YM
   YG = 0
   END
  WHEN POS = AMIGA THEN DO
   POS = USERNAME
   DEF = AMIGA
   DWN = 0
   YTG = 10
   OYM = YM
   YG = 0
   END
  END
RETURN

/*----1ST - 3RD DWN USERS BALL ----------------------------------------*/

MENUA:
call carrier
 GUESS = ''
 transmit ''poptln' 1. Run up the middle          H. Help'CR
 transmit ' 2. Run around the end         Q. Quit'CR
 transmit ' 3. Short pass'CR
 transmit ' 4. Long pass'CR
 transmit CR
 DP = ''
 OP = ''
 DP = RANDOM(1,4)
 RNDP = ''
 sendstring 'ENTER YOUR PLAY: '
 query; guess=upper(result)
 guess = upper(left(guess,1))
 if guess = 'H' then do
  op = ''
  dp = ''
  rndp = ''
  guess = ''
  call helpmenu
  skip = 1
  return
  end
 if guess = 'Q' then call bye
 if GUESS < '1' | Guess > '4' | ~datatype(guess,'w') THEN do
  call clrlow
  skip = 1
  return
  END
 OP = Guess
RETURN

/*-------------1ST - 3RD DWN AMIGAS BALL----------------------------*/

MENUB:
call carrier
 GUESS = ''
 transmit''poptln'1. Defend against the run up the middle      H. Help'CR
 transmit' 2. Defend against the run around the end     Q. Quit'CR
 transmit' 3. Defend against the short pass'CR
 transmit' 4. Defend against the long pass'CR
 transmit CR
 OP = ''
 OP = RANDOM(1,4)
 RNDP = ''
 sendstring 'ENTER YOUR PLAY: '
 query; guess= upper(result)
 guess = upper(left(guess,1))
 if guess = H then do
  op = ''
  dp = ''
  rndp = ''
  guess = ''
  call helpmenu
  skip = 1
  return
  end
 if guess = Q then call bye
 if GUESS < 1 | Guess > 4 | ~datatype(guess,'w') THEN do
  call clrlow
  skip = 1
  return
  END
 DP = guess
RETURN

/*----------------4TH DWN USERS BALL MORE THAN 35 YDS OUT-------------*/

MENUC:
call carrier
 GUESS = ''
 OP = ''
 DP = ''
 RNDP = ''
 transmit ''poptln' 1. Go for the first down      H. Help'CR
 transmit ' 2. Punt the ball              Q. Quit'CR
 transmit CR
 PP = RANDOM(1,10)
 SELECT
  WHEN YTG > 9 & PP = 10 THEN DP = 1
  WHEN YTG < 10 & YTG > 6 & PP > 8 THEN DP = 1
  WHEN YTG < 7 & YTG > 4 & PP > 6 THEN DP = 1
  WHEN YTG < 5 & YTG > 2 & PP > 3 THEN DP = 1
  WHEN YTG < 3 & PP > 2 THEN DP =1
  OTHERWISE DP = 2
  END
 sendstring 'ENTER YOUR PLAY: '
 query; guess= upper(result)
 guess = upper(left(guess,1))
 if guess = H then do
  op = ''
  dp = ''
  rndp = ''
  guess = ''
  call helpmenu
  skip = 1
  return
  end
 if guess = Q then call bye
 if GUESS < 1 | Guess > 2 | ~datatype(guess,'w') THEN do
  call clrlow
  skip = 1
  return
  END
 OP = Guess + 4
 DP = DP + 4
RETURN

/*----------------4TH DWN AMIGAS BALL MORE THAN 35 YDS OUT------------*/

MENUD:
call carrier
 GUESS = ''
 OP = ''
 DP = ''
 RNDP = ''
 PP = ''
 transmit ''poptln' 1. Defend against a first down attempt      H. Help'CR
 transmit ' 2. I think he will punt, try to block it.   Q. Quit'CR
 transmit CR
 PP = RANDOM(1,10)
 SELECT
  WHEN YTG > 9 & PP = 10 THEN OP = 1
  WHEN YTG < 10 & YTG > 6 & PP > 8 THEN OP = 1
  WHEN YTG < 7 & YTG > 4 & PP > 6 THEN OP = 1
  WHEN YTG < 5 & YTG > 2 & PP > 3 THEN OP = 1
  WHEN YTG < 3 & PP > 2 THEN OP =1
  OTHERWISE OP = 2
  END
 sendstring 'ENTER YOUR PLAY: '
 query; guess= upper(result)
 guess = upper(left(guess,1))
 if guess = H then do
  op = ''
  dp = ''
  rndp = ''
  guess = ''
  call helpmenu
  skip = 1
  return
  end
 if guess = Q then call bye
 if GUESS < 1 | Guess > 2 | ~datatype(guess,'w') THEN do
  call clrlow
  skip = 1
  return
  END
 DP = Guess + 4
 OP = OP + 4
RETURN

/*--------------- 4TH DWN USERS BALL 35 OR LESS YARDS OUT--------------*/

MENUE:
call carrier
 GUESS = ''
 OP = ''
 DP = ''
 RNDP = ''
 transmit ''poptln'1. Go for the first down      H. Help'CR
 transmit ' 2. Punt the ball              Q. Quit'CR
 transmit ' 3. Try for the field goal'CR
 transmit CR
 PP = RANDOM(1,10)
 SELECT
  WHEN YTG < 12 & YTG > 9 & PP = 10 THEN dp = 1
  WHEN YTG < 10 & YTG > 6 & PP > 8 THEN dp = 1
  WHEN YTG < 7 & YTG > 4 & PP > 6 THEN dp = 1
  WHEN YTG < 5 & YTG > 2 & PP > 3 THEN dp = 1
  WHEN YTG < 3 & PP > 2 THEN dp =1
  OTHERWISE dp = 2
  END
 sendstring 'ENTER YOUR PLAY: '
 query; guess= upper(result)
 guess = upper(left(guess,1)) 
 if guess = H then do
  rndp = ''
  guess = ''
  call helpmenu
  skip = 1
  return
  end
 if guess = Q then call bye
 if GUESS < 1 | Guess > 3 | ~datatype(guess,'w') THEN do
  call clrlow
  skip = 1
  return
  end
 Select
  WHEN GUESS = 1 THEN op = 7
  WHEN GUESS = 2 THEN op = 6
  WHEN GUESS = 3 THEN op = 8
  OTHERWISE CALL MENUE
  END
 SELECT
  WHEN dp = 1 THEN dp = 5
  WHEN dp = 2 THEN dp = 6
  END
 if op = 7 & dp = 5 then do
  RNDO = RANDOM(1,4)
  OP = RNDO
  DP = RNDO
  end
RETURN

/*---------------4TH DWN AMIGAS BALL 35 OR LESS YARDS OUT-------------*/

MENUF:
call carrier
 GUESS = ''
 OP = ''
 DP = ''
 RNDP = ''
 transmit ''poptln' 1. Defend against the first down        H. Help'CR
 transmit ' 2. Watch for the punt                   Q. Quit'CR
 transmit ' 3. He''s gonna try for the field goal'CR
 transmit CR
 PP = RANDOM(1,10)
 SELECT
  WHEN YTG < 5 & YTG > 2 & PP > 3 & YL > 20 THEN op = 1
  WHEN YTG < 3 & PP > 2 & YL > 20 THEN op =1
  OTHERWISE CALL FGORPUNT
  END
 sendstring 'ENTER YOUR PLAY: '
 query; guess= upper(result)
 guess = upper(left(guess,1))
 if guess = H then do
  rndp = ''
  guess = ''
  call helpmenu
  skip = 1
  return
  end
 if guess = Q then call bye
 if GUESS < 1 | Guess > 3 | ~datatype(guess,'w') THEN do
  call clrlow
  skip = 1
  return
  end
 SELECT
  WHEN GUESS = 1 THEN dp = 5
  WHEN GUESS = 2 THEN dp = 6
  WHEN GUESS = 3 THEN dp = 6
  OTHERWISE CALL MENUF
  END
 SELECT
  WHEN op = 1 THEN op = 7
  WHEN op = 2 THEN op = 6
  WHEN op = 3 THEN op = 8
  OTHERWISE CALL MENUF
  END
 if op = 7 & dp = 5 then do
  RNDO = RANDOM(1,4)
  OP = RNDO
  DP = RNDO
  end
RETURN

PLAYCONV:
call carrier
 if pos = username then do
  if op = 1 | op = 2 then gameruns = gameruns + 1
  if op = 3 | op = 4 then gamePAtt = GamePatt + 1
  end
 else do
  if op = 1 | op = 2 then Agameruns = Agameruns + 1
  if op = 3 | op = 4 then AgamePAtt = AGamePatt + 1
  end
 playnum = playnum + 1
 if playnum > 25 & playnum < 51 then qrtr = 2
 if playnum > 50 & playnum < 76 then qrtr = 3
 if playnum > 75 then qrtr = 4
 done = 0
 x = 0
 transmit pplay||CR
 call open(pfile,'Ram:plays/'op||dp,'r')
 randlimit = readln(pfile)
 rndp = random(1,randlimit)
 tplay = op||dp||rndp
 do until line = tplay
  line = readln(pfile)
  line = strip(line)
  if eof(pfile) then do
   call close(pfile)
   playnum = playnum - 1
   call sad'Tell the Sysop that play number 'tplay' seems to be missing!'
   call pressreturn
   call clrlow
   signal control
   end
  end
 if op = 8 then do
  if dp = 5 then PF = 1
  else PF = 0
  do 3
   line = readln(pfile)
   call sad line
   end
  call close(pfile)
  call fgodds
  call pressreturn
  call clrlow
  call cop
  call moveball
  call movepoles
  return
  end
 statline = readln(pfile)
 statline = strip(statline)
 parse var statline start stop sign .
 if ~datatype(start,'W') then do
  if strip(start) = 'I' then do
   if pos = username then gameints = gameints + 1
   else Agameints = Agameints + 1
   do y = 1 to 3
    pline.y = readln(pfile)
    call sad pline.y
    end
   call close(pfile)
   y = ''
   if op = 3 then yardspassed = random(5,20)
   else yardspassed = random(17,40)
   if pos = username then do
    if ym + yardspassed > 99 then yardspassed = 99 - ym
    end
   if pos = AMIGA then do
    if yardspassed > ym then yardspassed = YM - 1
    end
   call sad' OH NO!! Interception!'
   call sad'That pass went 'yardspassed' yards.'
   call pressreturn
   if pos = username then ym = ym + yardspassed
   else ym = ym - yardspassed
   call clrlow
   call moveball
   transmit pplay||cr
   IRB = random(4,25)
   if pos = username then do
    if YM - irb < 1 then IRB = YM
    end
   else do
    if ym + IRB > 99 then IRB = 100 - YM
    end
   if pos = username then defplayer = 'AMIGA'
   else defplayer = username
   call sad'The 'defplayer' player clinches on to the ball!'
   call sad'He makes a quick turn left, side steps a tackle'
   call sad'He''s got a death grip on that ball!'
   call sad'He went 'IRB' yards on the Runback!'
   call sad'The 'defplayer' player waves at the cameras'
   call sad'as he makes his way off the field.'
   call pressreturn
   if pos = username then ym = ym - irb
   else ym = ym + irb
   call clrlow
   call moveball
   call cop
   end
  if strip(start) = 'P' then do
   do y = 1 to 3
    pline.y = readln(pfile)
    call sad pline.y
    end
   call close(pfile)
   y = ''
   call pressreturn
   call clrlow
   if dp = 5 then yrp = Random(35,60)
   else yrp = random(25,40)
   rbr = random(1,4)
   call puntcontrol
   return
   end
   call close(pfile)
   yg = 0
   return
   end
  if start ~= 0 then yg = random(start,stop)
  if POS = Username & yg + ym > 99 then yg = 100 - ym
  if POS = Amiga & ym - YG < 1 then yg = YM
  if start = 0 then yg = 0

  if pos = username then do
   if op = 1 | op = 2 then GamerYards = GameRYards + yg
   if op = 3 | op = 4 & yg > 0 then GamePC = GamePC + 1
   end
  else do
   if op = 1 | op = 2 then AGamerYards = AGameRYards + yg
   if op = 3 | op = 4 & yg > 0 then AGamePC = AGamePC + 1
   end

  do until done = 1
   x = x + 1
   line.x = readln(pfile)
   line.x = strip(line.x)
   if line.x = 'END' then do
    x = x - 1
    done = 1
    end
   end
  call close(pfile)
  if yg = 0 then x = x + 2
   do y = 1 to x - 2
   call sad line.y
   end
  a = y
  b = y+1
  if yg ~=0 then resultline = line.a' 'yg' 'line.b
  if yg ~=0 then call sad resultline
  if sign = '-' then yg = -yg
RETURN

FGORPUNT:
call carrier
 RNFGD = RANDOM(1,100)
 SELECT
  WHEN YL < 36 & YL > 30 & RNFGD < 21 THEN OP = 3
  WHEN YL < 31 & YL > 25 & RNFGD < 35 THEN OP = 3
  WHEN YL < 26 & YL > 20 & RNFGD < 51 THEN OP = 3
  WHEN YL < 21 & YL > 15 & RNFGD < 61 THEN OP = 3
  WHEN YL < 16 & YL > 10 & RNFGD < 76 THEN OP = 3
  WHEN YL < 11 & YL > 5 & RNFGD < 91 THEN OP = 3
  WHEN YL < 6 & YL > 0 & RNFGD < 96 THEN OP = 3
  OTHERWISE OP = 2
  END
RETURN

TBACK:
call carrier
 SELECT
  WHEN POS = USERNAME & YM < 1 THEN DO
   call clrlow
   transmit pplay||cr
   transmit cr
   CALL SAD' TOUCHBACK!!!!!!'
   transmit cr
   call sad'Amiga scores 2 points!'
   call sad'Amiga''s ball on his own 20.'
   call pressreturn
   call clrlow
   SCA = SCA + 2
   CALL COP
   YM = 80
   DWN = 0
   OYM = 80
   YL = 20
   call scoreboard
   call moveball
   call movepoles
   END
  WHEN POS = AMIGA & YM > 99 THEN DO
   call clrlow
   transmit pplay||cr
   transmit cr
   CALL SAD'  TOUCHBACK!!!!!!'
   transmit cr
   call sad'You score 2 points!'
   call sad'Your ball on your own 20.'
   call pressreturn
   call clrlow
   SCU = SCU + 2
   CALL COP
   YM = 20
   DWN = 0
   OYM = 20
   YL = 20
   call scoreboard
   call moveball
   call movepoles
   END
  OTHERWISE RETURN
  END
RETURN

TDOWN:
call carrier
 if POS = USERNAME & YM > '99' THEN DO
  transmit pplay||cr
  CALL SAD''username' SCORES!!!!  TOUCHDOWN!!!!!'
  SCU = SCU + 6
  CALL EXTRAPOINTU
  YM = 80
  YL = 20
  call cop
  call moveball
  call movepoles
  call scoreboard
  call clrlow
  transmit pplay||cr
  call sad'It''ll be AMIGA''s ball on his own 20 yardline.'
  call delay(100)
  call clrlow
  Return
  END
 if POS = AMIGA & YM ~> 0  THEN DO
  transmit pplay||cr
  CALL SAD'AMIGA SCORES!!!!!       TOUCHDOWN!!!!!'
  SCA = SCA + 6
  CALL EXTRAPOINTA
  ym = 20
  yl = 20
  call cop
  call moveball
  call movepoles
  call scoreboard
  call clrlow
  transmit pplay||cr
  call sad'It''ll be your ball on the 20 yardline.'
  call delay(100)
  call clrlow
  END
RETURN

EXTRAPOINTU:
call carrier
 EXP = RANDOM(1,10)
 CALL SAD'Ready to attempt the extra point!'
 CALL PRESSRETURN
 call clrlow
 transmit pplay||cr
 SELECT
  WHEN EXP < 9 THEN DO
   CALL SAD' The kick is in the air,.........ITS GOOD!!!!!'
   SCU = SCU + 1
   END
  OTHERWISE CALL SAD' Oh no its off to the right.....NO GOOD!!!!'
  END
 call pressreturn
 call clrlow
RETURN

EXTRAPOINTA:
call carrier
 EXP = RANDOM(1,10)
 CALL SAD'Ready to attempt the extra point!'
 CALL PRESSRETURN
 call clrlow
 transmit pplay||cr
 SELECT
  WHEN EXP < 9 THEN DO
   CALL SAD'The kick is in the air,.........ITS GOOD!!!!!'
   SCA = SCA + 1
   END
  OTHERWISE CALL SAD'Oh no its off to the right.....NO GOOD!!!!'
  END
 call pressreturn
 call clrlow
RETURN

SCOREBOARD:
call carrier
 sbuname = left(username,14,"-")
 sbaname = left('AMIGA',14,"-")
 sbuscore = right(scu,3)
 sbascore = right(sca,3)
 if pos = username then do
  if Oym > 89 then sbytg = ' G'
  else sbytg = right(ytg,2)
  end
 if pos = Amiga then do
  if OYM < 11 then sbytg = ' G'
  else sbytg = right(ytg,2)
  end
 sbyl = right(yl,2)
 sbplaynum = right(playnum,3)
 if dwn = 0 then dwn = 1
 if pos = username then do
  sbuname = ''bak.3''pen.2'* 'sbuname''default''
  sbaname = ''bak.3''pen.7'  'sbaname''default''
  end
 if pos = AMIGA then do
  sbuname = ''bak.3''pen.7'  'sbuname''default''
  sbaname = ''bak.3''pen.2'* 'sbaname''default''
  end
 transmit''pusername''sbuname''
 transmit paminame||sbaname
 transmit puserscore||sbuscore
 transmit pamiscore||sbascore
 transmit pdown||dwn
 transmit pytg||sbytg
 transmit pyl||sbyl
 transmit pquarter||qrtr
 transmit pplaynum||sbplaynum
RETURN

MOVEBALL:
call carrier
 if YM < 1 then YM = 0
 if YM > 99 then YM = 100
 if YM = oldym then do
  spot = trunc(ym/2) + 13
  if ym = 1 then spot = 14
  transmit '[10;'spot'H'bak.2||fbsym||default
  oldym = ym
  return
  end
 if ym > oldym then do z = oldym to ym
  spot = trunc(z/2) + 13
  oldspot = spot-1
  transmit '[10;'spot'H'bak.2||fbsym||default
  rem = oldspot//5
  if rem ~= 3 then transmit '[10;'oldspot'H'bak.2' 'default
  else transmit '[10;'oldspot'H'vertansi
  end
 if ym < oldym then do z = oldym to ym by -1
  spot = trunc(z/2) + 13
  oldspot = spot+1
  transmit '[10;'spot'H'bak.2||fbsym||default
  rem = oldspot//5
  if rem ~= 3 then transmit '[10;'oldspot'H'bak.2' 'default
  else transmit '[10;'oldspot'H'vertansi
  end
 oldym = ym
RETURN

/*----------------CONVERT YARD MARK TO YARD LINE--------------------*/

YMCONV:
call carrier
 SELECT
  WHEN YM < 50 THEN YL = YM
  WHEN YM > 50 THEN YL = 100 - YM
  OTHERWISE YL = YM
  END
RETURN

YARDCONTROL:
call carrier
 SELECT
  WHEN POS = USERNAME THEN YG = YG
  WHEN POS = AMIGA THEN YG = -YG
  END
 YM = YM + YG
 SELECT
  WHEN POS = USERNAME & YM - OYM > 9 THEN DO
   DWN = 1
   YTG = 10
   OYM = YM
   END
  WHEN POS = USERNAME & YM - OYM < 10 THEN DO
   DWN = DWN + 1
   YTG = (OYM + 10) - YM
   END
  WHEN POS = AMIGA & OYM - YM > 9 THEN DO
   DWN = 1
   YTG = 10
   OYM = YM
   END
  WHEN POS = AMIGA & OYM - YM < 10 THEN DO
   DWN = DWN + 1
   YTG = YM - (OYM - 10)
   END
  END
 PUNTED = 0
RETURN

movepoles:
call carrier
 if pos = username then do
  spaces = OYM/2
  spaces = trunc(spaces)
  spaces = spaces + 5
  if spaces < 1 then spaces = 0
  if spaces > 54 then spaces = 54
  blanks = bak.2||Copies(" ",spaces)||default
  call clrflag
  transmit pvisitgoal||blanks||flagstr
  end
 else do
  spaces = OYM/2
  spaces = trunc(spaces)
  spaces = spaces
  if spaces < 1 then spaces = 0
  if spaces > 49 then spaces = 49
  blanks = bak.2||Copies(" ",spaces)||default
  call clrflag
  transmit pvisitgoal||blanks||flagstr
  end
Return

SAD: /* transmit DELAY CENTER TEXT*/
 PARSE ARG string
 transmit CENTER(string,75)||CR
 CALL DELAY(75)
RETURN

PUNTCONTROL:
call carrier
 SELECT
  WHEN POS = USERNAME & (YRP + YM) > 99 THEN DO
   transmit pplay||cr
   CALL SAD'Wow that one went out of the end zone!!'
   transmit CR
   CALL SAD'That''ll make it Amiga''s ball on the 20!!!'
   call pressreturn
   YM = 100
   call moveball
   YM = 80
   call moveball
   call clrlow
   PUNTED = 2
   END
  WHEN POS = USERNAME & (YRP + YM) < 100 THEN DO
   transmit pplay||cr
   CALL SAD' The punt went airborn 'YRP' yards!!!'
   call pressreturn
   ym = (yrp + YM)
   call moveball
   call clrlow
   IF RBR = 1 THEN CALL PUNTRBBD
   IF RBR = 2 THEN CALL PUNTRBGD
   IF RBR = 3 THEN CALL PUNTRBAV
   IF RBR = 4 THEN CALL FAIRCATCH
   call pressreturn
   YM = YM - RYRB
   call moveball
   call clrlow
   OYM = YM
   YG = 0
   DWN = 0
   YTG = 10
   PUNTED = 1
   END
  WHEN POS = AMIGA & (YM - YRP) < 1 THEN DO
   transmit pplay||cr
   CALL SAD' Wow that one went out of the end zone!!'
   transmit CR
   CALL SAD' That''ll make it 'USERNAME' ball on the 20!!!'
   call pressreturn
   ym = 0
   call moveball
   ym = 20
   call moveball
   call clrlow
   PUNTED = 2
   END
  WHEN POS = AMIGA & (YM - YRP) > 0 THEN DO
   transmit pplay||cr
   CALL SAD'The ball is in the air!!!'
   CALL SAD'The ball went 'YRP' yards!!!'
   call pressreturn
   ym = (ym - yrp)
   call moveball
   call clrlow
   IF RBR = 1 THEN CALL PUNTRBBD
   IF RBR = 2 THEN CALL PUNTRBGD
   IF RBR = 3 THEN CALL PUNTRBAV
   IF RBR = 4 THEN CALL FAIRCATCH
   call pressreturn
   YM = YM + RYRB
   call moveball
   call clrlow
   OYM = YM
   YG = 0
   DWN = 0
   YTG = 10
   PUNTED = 1
   YG = 0
   END
  END
RETURN

PUNTRBGD:
call carrier
 RYRB = RANDOM(10,25)
 transmit pplay||cr
 CALL SAD'He made a nice catch and here''s the runback'
 CALL DELAY(50)
 CALL SAD'The 'DEF' players are really blocking good!!!'
 CALL SAD'The ball carrier shakes past two tacklers!!!!!!!'
 SELECT
  WHEN POS = USERNAME & ((YRP + YM) - RYRB) < 1 THEN DO
   CALL SAD'He''s gonna run it back all the way!!!'
   END
  WHEN POS = AMIGA & (YM - YRP) + RYRB > 99 THEN DO
   CALL SAD' He scrambles down field!!'
   CALL SAD' He''s gonna take it into the end zone!!!'
   END
  OTHERWISE CALL SAD' Wow, he''ll get 'RYRB' yards on the runback.'
  END
RETURN

PUNTRBBD:
call carrier
 RYRB = RANDOM(2,5)
 transmit pplay||cr
 CALL SAD'The punt is caught and here''s the runback'
 CALL DELAY(50)
 CALL SAD'Uh oh, the 'POS' players got down field fast!!!'
 CALL SAD'The ball carrier is hit hard!!!!'
 CALL SAD'He''ll only get 'RYRB' yards on the runback.'
RETURN

PUNTRBAV:
call carrier
 RYRB = RANDOM(5,15)
 transmit pplay||cr
 CALL SAD'Ok they''ve caught the ball and are gonna run it back!'
 CALL SAD'He''s got quick feet!'
 CALL DELAY(100)
 SELECT
  WHEN POS = USERNAME & ((YRP + YM) - RYRB) < 1 THEN DO
   CALL SAD'He''s gonna run it back all the way!!!'
   END
  WHEN POS = AMIGA & (YM - YRP) + RYRB > 99 THEN DO
   CALL SAD'HE SCRAMBLES DOWN FieLD!!'
   CALL SAD'He''s gonna take it into the end zone!!!'
   END
  OTHERWISE CALL SAD'That''ll be 'RYRB' Yards on the runback.'
  END
RETURN

FAIRCATCH:
call carrier
 RYRB = 0
 transmit pplay||cr
 CALL SAD'The punt receiver is signaling for a fair catch.'
 CALL DELAY(50)
 transmit CR
 CALL SAD'Ok lets go the other way!!'
 transmit CR
RETURN

/*            FIELD GOAL ODDS CALCULATION */

FGODDS:
call carrier
 FGRN = RANDOM(1,100)
 SELECT
  WHEN PF = 1 THEN FGN = FGRN - 10
  OTHERWISE FGN = FGRN
  END
 SELECT
  WHEN YL < 36 & YL > 30 & FGN < 21 THEN CALL FGGOOD
  WHEN YL < 31 & YL > 25 & FGN < 36 THEN CALL FGGOOD
  WHEN YL < 26 & YL > 20 & FGN < 50 THEN CALL FGGOOD
  WHEN YL < 21 & YL > 15 & FGN < 60 THEN CALL FGGOOD
  WHEN YL < 16 & YL > 10 & FGN < 75 THEN CALL FGGOOD
  WHEN YL < 11 & YL > 5 & FGN < 90 THEN CALL FGGOOD
  WHEN YL < 6 & YL > 0 & FGN < 95 THEN CALL FGGOOD
  OTHERWISE CALL FGBAD
  END
 PF = 0
RETURN

FGGOOD:
call carrier
 CALL SAD'The ball''s sailing through the air'
 CALL SAD'It''s far enough'
 CALL SAD'Dead center!!!   *** IT''S GOOD ***'
 SELECT
  WHEN POS = USERNAME THEN DO
   SCU = SCU + 3
   YM = 80
   END
  OTHERWISE DO
   SCA = SCA + 3
   YM = 20
   END
  END
RETURN

FGBAD:
call carrier
 CALL SAD'The kick is airborn'
 CALL SAD'It''s a high kick..'
 CALL SAD' Oops.. off to the side  **** NO GOOD! ****'
RETURN

clrlow:
 transmit pplay
 do 7
  transmit'                                                                           'cr
  end
return

clrflag:
 transmit pvisitgoal||bak.2||copies(" ",60)
 return

PressReturn:
call carrier
 sendstring ''ppromptln'Press [RETURN] To Continue..'
 query; junk=result
 transmit ppromptln'                               'cr
return

TRANSMIT:
call carrier
 PARSE ARG string
 transmit string||CR
RETURN

drawfield:
call carrier
       /* colors off unless colors = 1 */

do i = 0 to 7
 pen.i = ''
 bak.i = ''
 end

IF colors = 1 THEN    /* let's see some color!*/
 DO i = 0 to 7
  pen.i = '[3'i'm'
  bak.i = '[4'i'm'
  end

 if GMode = 1 | Gmode = 2 then do
  if colors = 1 then GMode = 1
  else Gmode = 2
  fbsym = D2C(233)
  vertansi = D2C(179)
  vertansi = pen.7||bak.2||BOLD||vertansi||default
  flag = d2c(251)
  end
 else do
  if colors = 1 then GMode = 3
  else Gmode = 4
  fbsym = '*'
  vertansi = '|'
  vertansi = pen.7||bak.2||vertansi||default
  flag = '!'
  end
 flagstr = pen.0||bak.2||flag'    'flag||default
 transmit pmain'    'pen.6'           Online Football version 1.3 by Matt English'default''cr
 transmit pen.5 '                 CNet Conversion by Charles Johnston'default''cr
 if GMode = 1 then mainpic = pic1
 if GMode = 2 then mainpic = pic2
 if GMode = 3 then mainpic = pic3
 if GMode = 4 then mainpic = pic4
 call open(pic,mainpic,'r')
 do until eof(pic)
  line = readln(pic)
  transmit line||cr
  end
 call close(pic)
return

loadsb:
call carrier
 transmit psb
 call open(sbpic,'dh0:temp/scoreboard.ansi','r')
 do until eof(sbpic)
  line = readln(sbpic)
  transmit'      'line||cr
  end
 call close(sbpic)
return

LoadGame:
call carrier
 transmit cr
 transmit' Loading your saved game, Stand by...'cr
 transmit cr
 call open(gData,GamesPath||Username'.save','r')
 SCA = readln(gData)
 SCU = readln(gdata)
 Playnum = readln(gdata)
 Qrtr = readln(gdata)
 yl = readln(gData)
 yg = readln(gdata)
 ym = readln(gdata)
 oym = readln(gdata)
 dwn = readln(gdata)
 ytg = readln(gdata)
 gameints = readln(gdata)
 gameruns = readln(gdata)
 Posline = readln(gdata)
 if posline = 'U' then pos = username
 if posline = 'A' then pos = AMIGA
 GamePatt = readln(gdata)
 GamePC = readln(gdata)
 Gameryards = readln(gdata)
 Agameints = readln(gdata)
 Agameruns = readln(gdata)
 AGamePatt = readln(gdata)
 AGamePC = readln(gdata)
 AGameryards = readln(gdata)
 origPOS = readln(gdata)
 if origPOS = '' then origPOS = 'AMIGA'
 call close(gdata)
 transmit cls
return

SaveGame:
call carrier
 transmit cls
 transmit' Saving your game data, Stand by...'cr
 transmit cr
 call open(gData,GamesPath||Username'.save','w')
 call writeln(gdata,SCA)
 call writeln(gdata,SCU)
 call writeln(gdata,Playnum)
 call writeln(gdata,Qrtr)
 call writeln(gdata,yl)
 call writeln(gdata,'0')
 call writeln(gdata,ym)
 call writeln(gdata,oym)
 call writeln(gdata,dwn)
 call writeln(gdata,ytg)
 call writeln(gdata,gameints) /* Interceptions thrown this game */
 call writeln(gdata,gameruns) /* user running plays this game */
 if POS = username then posline = 'U'
 if POS = AMIGA then posline = 'A'
 call writeln(gdata,posline)
 call writeln(gdata,GamePAtt)  /* Passes Attempted this game */
 call writeln(gdata,GamePC)    /* Passes completed this game */
 call writeln(gdata,gameryards)  /* Yards ran (dede said) this game */
 call writeln(gdata,Agameints) /* Interceptions thrown this game-- Amiga */
 call writeln(gdata,Agameruns) /* user running plays this game-- Amiga */
 call writeln(gdata,AGamePAtt)  /* Passes Attempted this game -- Amiga*/
 call writeln(gdata,AGamePC)    /* Passes completed this game -- Amiga*/
 call writeln(gdata,Agameryards)  /* Yards ran (dede said) this game -- Amiga */
 call writeln(gdata,origPOS)
 call close(gdata)
return

LoadUserData:
call carrier
 call open(Udata,PlayerPath||Username,'r')
 GMode = readln(Udata)  /* Graphics mode */
 if gmode = 1 | gmode = 3 then colors = 1
 else colors = 0
 lastplay = readln(UData)
 call close(Udata)
return

NewPlayer:
call carrier

 transmit' A New Player! Welcome to the GridIron!!'cr
 transmit cr
 transmit' This game is very easy to play and we hope you''ll'cr
 transmit' find it quite fun!'cr
 transmit cr
 transmit' For best results, we suggest you use a Term program that'cr
 transmit' supports IBM style ANSI graphics. Most terms do.'cr
 transmit' This game will still work fine either way.'cr
 transmit cr
 call pressreturn
 transmit cls
 transmit' NComm Users: NComm DOES support IBM ANSI! Change your'cr
 transmit' characterset in the menu(and the phonebook) to "IBM".'cr
 transmit cr

 transmit' You can play this game in B&W or Color!'cr
 transmit' Your setting here, doesn''t effect your setting on the MAIN BBS.'cr
 transmit cr
 sendstring ' Do you want to play the game in color? (Y,n) > '
 query; wantcolor = upper(result)
 wantcolor = strip(left(wantcolor,1))
 if wantcolor = 'N' then colors = 0
 else colors = 1
 if colors = 1 then do
  transmit' [33mColor [34mmode [35mactivated![0m'cr
  transmit' You can change this setting from the help menu'cr
  transmit' inside the game at anytime!'cr
  end
 else do
  transmit' Black and White mode activated!'cr
  transmit' You can change this setting from the help menu'cr
  transmit' inside the game at anytime!'cr
  end
 transmit cr
 transmit cr

 transmit' Now we''ll look at a test screen to determine which graphics'cr
 transmit' your term supports.'cr
 call pressreturn
 call testansi
 transmit cls
 transmit cr
 transmit' OK, If you ever want to change your graphics or color setting'cr
 transmit' or need Game Instructions, choose "Help" from the game menu..'cr
 transmit cr
 transmit'                Hope you enjoy the game!!'cr
 call open(Udata,PlayerPath||Username,'w')
 call writeln(Udata,GMode)  /* Graphics mode */
 call writeln(Udata,date())
 call close(Udata)
 do i = 1 to 9
  call open(Tempstat,statspath'Stats.'i,'a')
  call writeln(TempStat,'0 'username' 0 0 0 0 0 0 0 0 0')
  call close(TempStat)
  address command'C:copy 'statspath'stats.'i' RAM:Stats.'i' quiet'
  end
 transmit cr
 transmit' Sorting the Stat Sheets...'cr
 call sortstats
 call pressreturn
 transmit cls
return

TestAnsi:
call carrier
 transmit cls
 if colors = 1 then testpic = datapath'pics/Testpic.c'
 else testpic = datapath'pics/Testpic.bw'
 call open(pic,testpic,'r')
 do until eof(pic)
  line = readln(pic)
  transmit line||cr
  end
 call close(pic)
 transmit' Which Football field looks better to you?'cr
 transmit' 1. TOP'cr
 transmit' 2. BOTTOM'cr
 transmit cr
 sendstring ' #1 or #2 > '
 query; ch=result
 ch = strip(left(ch,1))
 if ch = 1 & colors = 1 then Gmode = 1
 if ch = 1 & colors ~=1 then Gmode = 2
 if ch = 2 & colors = 1 then Gmode = 3
 if ch = 2 & colors ~=1 then Gmode = 4
 if ch ~=1 & ch ~= 2 then call TestAnsi
Return

NewGame:
call carrier
 CALL COINTOSS
 SCA = 0  /* Score Amiga */
 SCU = 0  /* Score User */
 playnum = 1
 Qrtr = 1
 yl = 20
 yg = 0
 dwn = 0
 ytg = 10
 gameints = 0
 gameruns = 0
 GamePatt = 0
 GamePC = 0
 GameRyards = 0
 Agameints = 0
 Agameruns = 0
 AGamePatt = 0
 AGamePC = 0
 AGameRyards = 0
 origPOS = POS
Return

HelpMenu:
call carrier
 transmit cls
 transmit cr
 transmit' What would you like to do ?'cr
 transmit cr
 transmit' 1. Change the graphics'cr
 if colors = 1 then transmit' 2. Change to Black and White mode'cr
 else transmit' 2. Change to Color mode'cr
 transmit' 3. Read the instructions'cr
 transmit' 4. Look at the Stats Sheet'cr
 transmit cr



 sendstring ' Your Choice > '
 query; choice=result
 choice = strip(left(choice,1))
 if choice = 1 then call testansi
 if choice = 2 then do
  if colors = 0 then do
   colors = 1
   transmit' [33mOK, [34mColor [35mmode [36mactivated..[0m'cr
   call delay(150)
   end
  else do
   colors = 0
   transmit' OK, Black and White mode activated..'cr
   call delay(150)
   end
  end
 if choice = 3 then call help
 if choice = 4 then call viewstats
 transmit cls
 call drawfield
 call scoreboard
 call moveball
 call movepoles
return

HalfTime:
call carrier
 transmit cls
 transmit cr
 do 3
  call sad'HalfTime'
  call delay(100)
  transmit cr
  end
 call sad'Time to pop some corn & get another beer..'
 call delay(100)
 transmit cr
 call sad'Imagine Cheerleaders dancing and bands playing..'
 transmit cr
 call delay(400)
 call sad'OK, It''s over now.. Time to play!!'cr
 transmit cr
 if origPOS = AMIGA then do
  call sad'It''ll be your ball on your own 20!!'
  yl = 20
  ym = 20
  OYM = 20
  oldym = 20
  POS = username
  def = 'AMIGA'
  dwn = 1
  ytg = 10
  yg = 0
  end
 else do
  call sad'It''s gonna be AMIGA''s ball on his own 20!!'
  yl = 20
  ym = 80
  OYM = 80
  oldym = 80
  POS = 'AMIGA'
  def = username
  dwn = 1
  ytg = 10
  yg = 0
  end
 call delay(100)
 transmit cls
 call drawfield
 call scoreboard
 call moveball
 call movepoles
return

HELP:
call carrier
 transmit cls
 transmit'            Online Football Version 1.3 by Matt English'cr
 transmit'         CNet v2.63 Conversion by Charles Johnston 1-16-94'cr
 transmit cr
 transmit'  This game is quite simple. It is based on the world famous'cr
 transmit' game of FOOTBALL!! So if ya know a little about football, 'cr
 transmit' it''ll help but is not necessary.'cr
 transmit'  All the options available should be fairly obvious and will'cr
 transmit' be displayed where appropriate.'CR
 transmit cr
 transmit'  THE OBJECT: To be the BEST in each category on the Stat Sheet!'cr
 transmit cr
 transmit' What''s different from REAL Football?'cr
 transmit' >  There are no Kick-offs.. After a TD or field goal, the ball will be'cr
 transmit'   placed on the 20 yard line.'cr
 transmit' >  Field goals can only be attempted on 4th Dwn when you are within'cr
 transmit'   35 yards of the goal line.'cr
 transmit' > Quarters are 25 plays long.'cr
 transmit' >  Who ever doesn''t win the coin toss at the beggining of the game,'cr
 transmit'   will get the ball at the beggining of the 3rd Quarter.'cr
 transmit' >  Whenever you decide to quit, your game stats will be saved'cr
 transmit'   and you can continue later.'cr
 transmit' > Game stats are always updated on disk but are only DISPLAYED' 
 transmit'   for COMPLETED games. There are 100 plays in a complete game'
 transmit cr
 transmit cr
 sendstring' Return = Continue'
 query; junk=result
 transmit cls
 transmit cr
 transmit'  PS: In the event of a dispute, the ref is always right!!'cr
 transmit cr
 sendstring' Return = Continue'
 query; junk=result
 transmit cls
 call drawfield
 call scoreboard
 call moveball
 call movepoles
Return

Forfeit:
  found = 0
  call open(stats,StatsPath'Stats.1','r')
  do until found = 2
   testline = readln(stats)
   if word(testline,2) = username | word(testline,2) = 'AMIGA' then do
    if word(testline,2) = username then do
     GWon = word(testline,3)     /* Games won */
     GLost = word(testline,4)    /* GamesLost */
     PassAtt = word(testline,5)  /* Passes Attempted */
     PassC = word(testline,6)    /* Passes Completed */
     Intthr = word(testline,7)    /* Interceptions Thrown */
     RunP = word(testline,8)     /* RunPlays */
     Ryards = word(testline,9)   /* Running yardage total */
     AverRun = word(testline,10)  /* Average yardage run play */
     yourhiscore = word(testline,11)   /* Highest Score */
     found = found + 1
     end
    if word(testline,2) = 'AMIGA' then do
     AGWon = word(testline,3)     /* Games won */
     AGLost = word(testline,4)    /* GamesLost */
     APassAtt = word(testline,5)  /* Passes Attempted */
     APassC = word(testline,6)    /* Passes Completed */
     AIntthr = word(testline,7)    /* Interceptions Thrown */
     ARunP = word(testline,8)     /* RunPlays */
     ARyards = word(testline,9)   /* Running yardage total */
     AAverRun = word(testline,10)  /* Average yardage run play */
     Ayourhiscore = word(testline,11)   /* Highest Score */
     found = found + 1
     end
    end
   end
  call close(stats)
  found = 0
  AGWon = AGWon + 1
  GLost = GLost + 1
  do t = 1 to 9
   call open(stats,StatsPath'Stats.'t,'r')
   call open(temp,'Ram:stats.'t,'w')
   do until eof(stats)
    statline = readln(stats)
    if statline = '' then leave
    if word(statline,2) ~= 'AMIGA' & word(statline,2) ~= username then call writeln(temp,statline)
    end
   call close(stats)
   select
    when t = 1 then do
     sortname = GWon
     sortnameA = AGWon
     end
    when t = 2 then do
     sortname = GLost
     sortnameA = AGLost
     end
    when t = 3 then do
     sortname = PassAtt
     sortnameA = APassAtt
     end
    when t = 4 then do
     sortname = PassC
     sortnameA = APassC
     end
    when t = 5 then do
     sortname = IntThr
     sortnameA = AIntThr
     end
    when t = 6 then do
     sortname = RunP
     sortnameA = ARunP
     end
    when t = 7 then do
     sortname = RYards
     sortnameA = ARYards
     end
    when t = 8 then do
     sortname = (AverRun * 1000)
     sortnameA = (AAverRun * 1000)
     end
    when t = 9 then do
     sortname = yourhiscore
     sortnameA = Ayourhiscore
     end
    end
   call writeln(temp,sortname' 'username' 'Gwon' 'GLost' 'PassAtt' 'PassC' 'IntThr' 'RunP' 'RYards' 'AverRun' 'yourhiscore)
   call writeln(temp,sortnameA' AMIGA 'AGwon' 'AGLost' 'APassAtt' 'APassC' 'AIntThr' 'ARunP' 'ARYards' 'AAverRun' 'Ayourhiscore)
   call close(temp)
   end
  say cr
  say' Sorting the Stat Sheets...'cr
  call sortstats
return


ViewStats:
call carrier
 transmit cls
 if GMode = 1 then statpic = datapath'pics/Stats.ANSIc'
 if GMode = 2 then statpic = datapath'pics/Stats.ANSIbw'
 if GMode = 3 then statpic = datapath'pics/Stats.ASCIIc'
 if GMode = 4 then statpic = datapath'pics/Stats.ASCIIbw'
 if GMode < 3 then do
  dbar = d2c(186)
  sbar = d2c(179)
  end
 else do
  DBar = bak.6||pen.0||BOLD'|'default
  sbar = bak.6||pen.0||BOLD'|'default
  end
 pfirststat = '[5;2H'
 pstatprompt = '[22;8H'
 pstatdate = '[4;9H'
 call open(pic,statpic,'r')
 do until eof(pic)
  line = readln(pic)
  transmit line||cr
  end
 call close(pic)
 call open(howlong,statspath'Stats.date','r')
 startdate = readln(howlong)
 call close(howlong)
 transmit pstatdate||bak.6'Since 'startdate||default||CR
 call displayStats 1
 do until statnumber = 'Q'
  call pullstat
  if statnumber = 'Q' then leave
  else call displaystats statnumber
  end
 transmit cls
return

pullstat:
call carrier
 transmit''pstatprompt'                                                        'cr
 sendstring ''pstatprompt'Enter the number to sort by, or "Q" to Quit > '
 query; statnumber=upper(result)
 transmit pfirststat||cr
 call clearstat
 transmit''pstatprompt'                                                        'cr
 statnumber = strip(left(statnumber,1))
 select
  When statnumber = 'Q' then RETURN
  When statnumber = '' then statnumber = 1
  When datatype(statnumber,'W') then do
   if statnumber > 0 & statnumber < 10 then RETURN
   else call pullstat
   end
  otherwise call pullstat
  end
return

DisplayStats:
call carrier
 arg Statnumber
 call open(file,StatsPath'Stats.'statnumber,'r')
 lnum = 0
 do until eof(file)
  lnum = lnum + 1
  sline.lnum = readln(file)
  end
 call close(file)
 transmit pfirststat||cr
 do i = 1 to lnum
  if i//11 = 0 then call statbreak
  if keepgoin = 'S' then do
   keepgoin = ''
   Leave i
   end
  if i = lnum then do
   sline.i = '  'pen.0||bak.6||DBar'   'DBar||pen.3'End of List'default
   transmit sline.i||cr
   Leave i
   end
  else do
   parse var sline.i . Sname GW GL PA PC IT RP RY AVR HS
   statnum = bak.6||pen.0||left(i,3)
   SName = bak.6||pen.0||left(Sname,19)
   GW = left(GW,4)
   GL = left(GL,4)
   PA = left(PA,5)
   PC = left(PC,5)
   IT = left(IT,4)
   RP = left(RP,5)
   RY = left(RY,5)
   AVR = left(AVR,5)
   HS = left(HS,4)
   do hh = 1 to 9
    if hh = statnumber then do
     select
      when hh = 1 then HiStat.hh = pen.2||BOLD||GW||default||bak.6||pen.0||SBar
      when hh = 2 then HiStat.hh = pen.2||BOLD||GL||default||bak.6||pen.0||SBar
      when hh = 3 then HiStat.hh = pen.2||BOLD||PA||default||bak.6||pen.0||SBar
      when hh = 4 then HiStat.hh = pen.2||BOLD||PC||default||bak.6||pen.0||SBar
      when hh = 5 then HiStat.hh = pen.2||BOLD||IT||default||bak.6||pen.0||SBar
      when hh = 6 then HiStat.hh = pen.2||BOLD||RP||default||bak.6||pen.0||SBar
      when hh = 7 then HiStat.hh = pen.2||BOLD||RY||default||bak.6||pen.0||SBar
      when hh = 8 then HiStat.hh = pen.2||BOLD||AVR||default||bak.6||pen.0||SBar
      when hh = 9 then HiStat.hh = pen.2||BOLD||HS||default||bak.6||pen.0
      end
     end
    else do
     select
      when hh = 1 then HiStat.hh = bak.6||pen.0||GW||SBar
      when hh = 2 then HiStat.hh = bak.6||pen.0||GL||SBar
      when hh = 3 then HiStat.hh = bak.6||pen.0||PA||SBar
      when hh = 4 then HiStat.hh = bak.6||pen.0||PC||SBar
      when hh = 5 then HiStat.hh = bak.6||pen.0||IT||SBar
      when hh = 6 then HiStat.hh = bak.6||pen.0||RP||SBar
      when hh = 7 then HiStat.hh = bak.6||pen.0||RY||SBar
      when hh = 8 then HiStat.hh = bak.6||pen.0||AVR||SBar
      when hh = 9 then HiStat.hh = bak.6||pen.0||HS||default
      end
     end
    end
   transmit'   'pen.0||bak.6||DBar||statnum||Dbar||Sname||SBar||HiStat.1||HiStat.2||HiStat.3||HiStat.4||HiStat.5||HiStat.6||HiStat.7||HiStat.8||HiStat.9||Default||CR
   end
  end
 transmit pstatprompt||cr
return

StatBreak:
call carrier
 transmit pstatprompt'                                                    'cr
 sendstring ''pstatprompt'Return = Continue, "S" = Stop > '
 query; keepgoin=upper(result)
 keepgoin = strip(left(keepgoin,1))
 transmit pstatprompt'                                                    'cr
 transmit pfirststat||cr
 call clearstat
return

clearstat:
 do 11
  transmit'   'pen.0||bak.6||DBar'   'DBar'                   'sbar'    'sbar'    'sbar'     'sbar'     'sbar'    'sbar'     'sbar'     'sbar'     'sbar'    'default||cr
  end
 transmit pfirststat||cr
return

GameOver:
call carrier

 transmit cls
 if gamedone = 1 then do
  found = 0
  call open(stats,StatsPath'Stats.1','r')
  do until found = 2
   testline = readln(stats)
   if word(testline,2) = username | word(testline,2) = 'AMIGA' then do
    if word(testline,2) = username then do
     GWon = word(testline,3)     /* Games won */
     GLost = word(testline,4)    /* GamesLost */
     PassAtt = word(testline,5)  /* Passes Attempted */
     PassC = word(testline,6)    /* Passes Completed */
     Intthr = word(testline,7)    /* Interceptions Thrown */
     RunP = word(testline,8)     /* RunPlays */
     Ryards = word(testline,9)   /* Running yardage total */
     AverRun = word(testline,10)  /* Average yardage run play */
     yourhiscore = word(testline,11)   /* Highest Score */
     found = found + 1
     end
    if word(testline,2) = 'AMIGA' then do    /* Amiga stats */
     AGWon = word(testline,3)     /* Games won */
     AGLost = word(testline,4)    /* GamesLost */
     APassAtt = word(testline,5)  /* Passes Attempted */
     APassC = word(testline,6)    /* Passes Completed */
     AIntthr = word(testline,7)    /* Interceptions Thrown */
     ARunP = word(testline,8)     /* RunPlays */
     ARyards = word(testline,9)   /* Running yardage total */
     AAverRun = word(testline,10)  /* Average yardage run play */
     Ayourhiscore = word(testline,11)   /* Highest Score */
     found = found + 1
     end
    end
   end
  call close(stats)
  found = 0
  PassAtt = PassAtt + GamePatt
  APassAtt = APassAtt + AGamePatt
  PassC = PassC + GamePC
  APassC = APassC + AGamePC
  IntThr = IntThr + Gameints
  AIntThr = AIntThr + AGameints
  RunP = RunP + GameRuns
  ARunP = ARunP + AGameRuns
  RYards = RYards + GameRyards
  ARYards = ARYards + AGameRyards
  AverRun = Ryards/Runp
  AverRun = trunc(AverRun,3)
  AAverRun = ARyards/ARunp
  AAverRun = trunc(AAverRun,3)
  if SCU > yourhiscore then yourhiscore = SCU
  if SCA > Ayourhiscore then Ayourhiscore = SCA
  transmit cr
  transmit'  The Game is OVER!!!'cr
  transmit cr
  if SCA > SCU then do
   GLost = Glost + 1
   AGWon = AGWon + 1
   transmit' Sorry, you let the computer beat you!!'cr
   transmit cr
   transmit' You should try again after your team heals up!!'cr
   end
  if SCA < SCU then do
   GWon = Gwon + 1
   AGLost = AGLost + 1
   transmit' CONGRATULATIONS!! You beat one tough team today!'cr
   transmit cr
   transmit' The AMIGA will sort his RAM chips and be ready next time!!'cr
   end
  if SCA = SCU then do
   transmit' All that hard work and the best you could do was tie!!'cr
   transmit cr
   transmit' The AMIGA was just toying with you.. Try again when you get the guts!'cr
   end
  if exists(Gamespath||Username'.save') then call delete(Gamespath||Username'.save')

  do t = 1 to 9
   call open(stats,StatsPath'Stats.'t,'r')
   call open(temp,'Ram:stats.'t,'w')
   do until eof(stats)
    statline = readln(stats)
    if statline = '' then leave
    if word(statline,2) ~= username & word(statline,2) ~= 'AMIGA' then call writeln(temp,statline)
    end
   call close(stats)
   select
    when t = 1 then do
     sortname = GWon
     sortnameA = AGWon
     end
    when t = 2 then do
     sortname = GLost
     sortnameA = AGLost
     end
    when t = 3 then do
     sortname = PassAtt
     sortnameA = APassAtt
     end
    when t = 4 then do
     sortname = PassC
     sortnameA = APassC
     end
    when t = 5 then do
     sortname = IntThr
     sortnameA = AIntThr
     end
    when t = 6 then do
     sortname = RunP
     sortnameA = ARunP
     end
    when t = 7 then do
     sortname = RYards
     sortnameA = ARYards
     end
    when t = 8 then do
     sortname = (AverRun * 1000)
     sortnameA = (AAverRun * 1000)
     end
    when t = 9 then do
     sortname = yourhiscore
     sortnameA = Ayourhiscore
     end
    end
   call writeln(temp,sortname' 'username' 'Gwon' 'GLost' 'PassAtt' 'PassC' 'IntThr' 'RunP' 'RYards' 'AverRun' 'yourhiscore)
   call writeln(temp,sortnameA' AMIGA 'AGwon' 'AGLost' 'APassAtt' 'APassC' 'AIntThr' 'ARunP' 'ARYards' 'AAverRun' 'Ayourhiscore)
   call close(temp)
   end
  transmit cr
  transmit' Sorting the Stat Sheets...'cr
  call sortstats
  end
 call open(Udata,PlayerPath||Username,'w')
 call writeln(Udata,GMode)  /* Graphics mode */
 call writeln(UData,date())
 call close(Udata)

 transmit cr
 if gamedone = 1 then do
  transmit' Would ya like to see the OLFB Stat Sheet?'cr
  sendstring ' (Y,n) > '
  query; answer=upper(result)
  answer = strip(left(answer,1))
  if answer ~= 'N' then call viewstats
  transmit cr
  sendstring ' Wanna play again? (y,n) > '
  query; again=upper(result)
  again = strip(left(again,1))
  if again ~= 'Y' then do
   call saveudata
   call gone
   end
  transmit cls
  gamedone = 0
  call newgame
  signal main
  end
 gamedone = 0
return

getversion:
  ADDRESS COMMAND 'version >RAM:VERSION'
  x=OPEN(f,'RAM:VERSION','R')
  line=READLN(f)
  CALL CLOSE(f)
  CALL DELETE('RAM:VERSION')
  ksversion=STRIP(WORD(line,3))
RETURN

SORTSTATS:
 call getversion

 do zz = 1 to 9
  if ksversion >= 37.175 then address command'C:sort Ram:Stats.'zz' Ram:Stats.'zz' NUMERIC'
  else address command'C:sort Ram:Stats.'zz' Ram:Stats.'zz''
  end

 do y = 1 to 9
  spot = 0
  if y ~= 2 & y ~= 5 then do
   call open(sorted,'RAM:Stats.'y,'r')
   do until eof(sorted)
    spot = spot + 1
    line = readln(sorted)
    if line = '' then do
     spot = spot - 1
     leave
     end
    rline.spot = line
    end
   call close(sorted)
   call open(sorted,'RAM:Stats.'y,'w')
   do a = 1 to spot
    b = (spot+1) - a
    call writeln(sorted,rline.b)
    end
   call close(sorted)
   end
  end

 do z = 1 to 9
  address command'C:Copy Ram:Stats.'z' 'StatsPath'Stats.'z' Quiet'
  call delete('Ram:Stats.'z)
  end

RETURN

BYE:
 transmit cls
 transmit cr
 sendstring ' You really wanna Quit? (Y,n) > '
 query; it=upper(result)
 it = strip(left(it,1))
 if it = 'N' then do
  transmit cls
  signal main
  end
 transmit cr
 transmit' Would ya like to see the OLFB Stat Sheet?'cr
 sendstring ' (Y,n) > '
 query; answer=upper(result)
 answer = strip(left(answer,1))
 if answer ~= 'N' then call viewstats
 call SaveUdata
 call out

CARRIER:                                                      
getcarrier ; carrier = result ; if carrier = 'FALSE' then exit
return

/* Procedures for handeling Errors, Logging off and/or Quiting */

IOERR:
 TRANSMIT 'Line:' SIGL '   Error Code:' RC
 TRANSMIT '*I/O ERROR*  External program error.  PLEASE notify SYSOP.'
 call delay(200)
 signal OUT

SYNTAX:
 TRANSMIT 'Line:' SIGL '   Error Code:' RC
 TRANSMIT '*SYNTAX ERROR*  External program error.  PLEASE notify SYSOP.'
 call delay(200)
 signal OUT

/* exit back to bbs */

SaveUdata:
 call open(Udata,PlayerPath||Username,'w')
 call writeln(Udata,GMode)  /* Graphics mode */
 call writeln(UData,date())
 call close(Udata)
return

BREAK_C:
BREAK_E:
OUT:
 call savegame
 call saveUdata
 call gone

GONE:
address command'c:delete ram:plays ALL quiet'

TRANSMIT CR''CR'Returning to 'bbsname

exit