ght             P : put on a ring       c : Chuck somethingJ   b : down and left            t : take off armour     C : Call somethingH   n : down and right           T : take off ring       M : enter magic.H   . : stand still              i : inventory           m : define macro1   f<dir> & Shft<dir> :         w : put on armour-   move in <dir> until          ? : this info0   you can't move               g : get a weapon5   any further             ctrl-R : show last message0   you find something.                    name length = 11 ,
              max l     = 15 ,
              xzero     = 232 ,
              yzero     = 10,
              start mouth = 3,
              max shown = 8,
              Ctrl Y Event = 0,
              User Abort = 2


%recordformat pr( %integer x, y, dx, dy, drn, chge, steps, colour)
%record(pr) %array players, initplayers ( 0 : 3 )
%record(pr)%name PMan == players(0), p1 == players(1), p2 == players(2),
                 p3 == players(3), p

%string (30) League File
%byte Munch = 0
%byte Munch Time = 1
%byte Deelay = 0
%const %byte Munch Max = 5
%const %byte %array PM (Up:LLeft,0:1,0:1) =
{Up}     137, 138, 131, 139,
{RRight} 131, 132, 131, 133,
{Down}   140, 141, 131, 142,
{LLeft}  134, 135, 136, 135

%const %short %array Dir (MsNone:MsLMR) = -1,Lleft,Up,-1,Rright,-1,-1,Down
%const %integer Flash1=143, Flash2=Flash1+2
%short dgx,dgy,dgxx,dgyy
%const %integer MaxGrid = 608
%const %short %array Grid (0:MaxGrid) =
     264,42,408,42,440,42,456,42,488,42,632,42,264,58,344,58,360,58,408,58,
     488,58,536,58,552,58,632,58,232,90,264,90,296,90,312,90,392,90,440,90,
     456,90,504,90,584,90,600,90,632,90,664,90,232,106,264,106,344,106,360,106,
     392,106,504,106,536,106,552,106,632,106,664,106,264,138,296,138,
     344,138,408,138,440,138,456,138,488,138,552,138,600,138,632,138,
     264,154,312,154,344,154,408,154,488,154,552,154,584,154,632,154,
     232,186,312,186,344,186,360,186,392,186,440,186,456,186,504,186,
     536,186,552,186,584,186,664,186,392,202,504,202,392,234,504,234,
     232,250,312,250,344,250,360,250,408,250,488,250,536,250,552,250,
     584,250,664,250,232,282,312,282,344,282,360,282,408,282,{}411,282,
     {}485,282,488,282,440,282,456,282,440,298,456,298,
     536,282,552,282,584,282,664,282,392,298,{}411,298,
     {}485,298,504,298,360,330,408,330,440,330,456,330,488,330,536,330,
     232,346,312,346,360,346,408,346,488,346,536,346,584,346,664,346,
     264,378,312,378,392,378,440,378,456,378,504,378,584,378,632,378,
     264,394,312,394,344,394,360,394,392,394,504,394,536,394,552,394,
     584,394,632,394,264,426,312,426,344,426,408,426,440,426,456,426,
     488,426,552,426,584,426,632,426,264,458,312,458,344,458,408,458,
     488,458,552,458,584,458,632,458,440,490,456,490,232,90,232,106,
     232,186,232,250,232,282,232,346,264,42,264,58,264,90,264,106,
     264,138,264,154,264,378,264,394,264,426,264,458,296,90,296,138,
     312,90,312,154,312,186,312,250,312,282,312,346,312,378,312,394,
     312,426,312,458,344,58,344,106,344,138,344,154,344,186,344,250,
     344,282,344,394,344,426,344,458,360,58,360,106,360,186,360,250,
     360,282,360,330,360,346,360,394,392,90,392,106,392,186,392,202,
     392,234,392,298,392,378,392,394,408,42,408,58,408,138,408,154,
     408,250,408,282,408,330,408,346,408,426,408,458,{}411,282,{}411,298,
     440,42,440,90,440,138,440,186,440,330,440,378,440,426,440,490,
     456,42,456,90,456,138,456,186,456,330,456,378,456,426,456,490,
     {}485,282,{}485,298,440,282,440,298,456,282,456,298,
     488,42,488,58,488,138,488,154,488,250,488,282,
     488,330,488,346,488,426,488,458,504,90,504,106,504,186,504,202,
     504,234,504,298,504,378,504,394,536,58,536,106,536,186,536,250,
     536,282,536,330,536,346,536,394,552,58,552,106,552,138,552,154,
     552,186,552,250,552,282,552,394,552,426,552,458,584,90,584,154,
     584,186,584,250,584,282,584,346,584,378,584,394,584,426,584,458,
     600,90,600,138,632,42,632,58,632,90,632,106,632,138,632,154,
     632,378,632,394,632,426,632,458,664,90,664,106,664,186,664,250,
     664,282,664,346,
     9999
%integer dgLL=Addr(Grid),dgTemp

%integerarray position info ( 0:27, 0:30 )

%integer      total dots , mouth , xcur ,i , dead ghosts , chasing ,
              speed , timer , score , high score , card , j , hgt

%constintegerarray colour(0:3) = yellow, red , magenta , green

%constintegerarray alldrn (0:3) = 16 , 32 , 64 , 128

%constintegerarray opposite dir ( 0:3 ) = 2 , 3 , 0 , 1

%string ( name length ) user

%constintegerarray legal position (1:29) = %c
2_1111111111111000 ,
2_1000000000010000 ,
2_1000000000010000 ,
2_1111110011110000 ,
2_0010010010000000 ,              
2_0010010010000000 ,
2_1110011111111000 ,
2_1000010000010000 ,
2_1000010000010000 ,
2_1111111111110000 ,
2_0000010010000000 ,
2_0000010010000000 ,
2_0000010011111000 ,
2_0000010010000000 ,
2_0000010010000000 ,
2_1111111110000000 ,
2_0000010010000000 ,
2_0000010010000000 ,
2_0000010011111000 ,
2_0000010000010000 ,
2_0000010000010000 ,
2_1111110011110000 ,
2_1000010010000000 ,
2_1000010010000000 ,
2_1111111111111000 ,
2_1000010000010000 ,
2_1000010000010000 ,
2_1000010000010000 ,
2_1111111111110000 

@16_01108 %integerfn  FCOMM(%integer cn,%string(255)s)
@16_01110 %integerfn  FCOMMR(%integer c,%string(255)p,%bytename b,%integer max)

%string (255) %fn Current Directory
   %string (255) Me
   %integer I = 1

   Length (Me) = Fcommr ('F'<<8, "", Charno (Me, 1), 255)
   I = I + 1 %while Charno (Me, I) # ' '
   Length (Me) = I - 1
   %result = String (Addr (Me))
%end
%string (255) %fn Current User
   %string (7) This Dir, This User
   %integer I

   %on 3,4,9 %start
      %result = ""
   %finish

   This Dir  = Current Directory
   I = Fcomm ('J'<<8,"")
   This User = Current Directory
   I = Fcomm ('J'<<8, This dir)
   %result = String (Addr (This User))
%end
!!%include "useful:whodat.inc"

%integerfn xreal ( %integer x )

%result = ( x << 4 ) + xzero

%end 

%integerfn yreal ( %integer y )

%result = ( y << 4 ) + yzero

%end

%routine Draw Grid (%integer Col)
%label D
   Set Colour (Col)
   *Move.l dgLL,a1
C: *Cmpi.w #9999,(a1)
   *Beq D
   *Move.w (a1)+,dgx
   *Move.w (a1)+,dgy
   *Move.w (a1)+,dgxx
   *Move.w (a1)+,dgyy
   *Move.l a1,dgTemp
   %if dgx = dgxx %then Fill (dgx-1,dgy,dgxx+1,dgyy) %elsec
                        Fill (dgx,dgy-1,dgxx,dgyy+1)
   *Move.l dgTemp,a1
   *Bsr C
D:
%end

%integerfn read status ( %integer x , y , stat )
   %result = position info ( x , y ) & stat
%end

%routine  clear status (%integer x , y , stat )
   position info ( x , y ) = position info ( x , y ) & (\stat)
%end

%routine set status ( %integer x , y , stat )
   position info ( x , y ) = position info ( x , y ) ! stat 
%end

%integerfn valid position ( %integer x ,y )
   %if x >= 14 %then x = 13 - ( x - 14 )
   %result = legal position ( y ) >> ( 16 - x ) & 1
%end

%routine draw dot ( %integer x , y )
   disable ( \invert)
   set colour ( 8 )
   circle ( xreal ( x ) , yreal ( y ) , 2 )
%end

%routine power dot ( %integer x , y )
   disable ( \invert )
   set colour ( 8 )
   circle ( xreal ( x ) , yreal ( y ) , 6 )
%end

%integerfn distance x ( %record (pr) %name a , b )
   %result = (a_x -b_x)<<4 + a_dx - b_dx
%end

%integerfn distance y ( %record (pr) %name a , b )
   %result = (a_y - b_y)<<4 + a_dy - b_dy
%end

%routine init1
 %integer x , y , k 
 total dots = 0
 %for x = 0 , 1 , 27 %cycle
      position info ( x , y ) = 2 %for y = 0 , 1 , 30
 %repeat
 set status ( 0 , 16 , legal ) ; set status ( 27 , 16 , legal )
 %for x = 1 , 1 , 26 %cycle
     %for y = 1 , 1, 29 %cycle
          %if valid position ( x , y ) = 1 %start
              total dots = total dots + 1
              set status ( x , y , legal )
              set status ( x , y , dot pt )
          %finish
      %repeat
 %repeat
  %for x = 0, 1, 27 %cycle
    %for y = 11, 1, 21 %cycle
      %if x # 6 %and x # 21 %then clear status( x , y , dot pt )
    %repeat
  %repeat
  clear status(13, 7, dot pt ); clear status(14, 7, dot pt )
  %for x = 0, 1, 27 %cycle
    %for y = 0, 1, 30 %cycle
         clear status(x, y, taken pt ) %if read status ( x , y , dot pt ) # 0
    %repeat
  %repeat
 clear status ( 1 , 7 , dot pt ) ; set status ( 1 , 7 , power pt ) 
 clear status ( 1 , 27 , dot pt ) ; set status ( 1 ,27 , power pt )
 clear status ( 26 , 7 , dot pt ) ; set status ( 26 , 7 , power pt )
 clear status ( 26 , 27 , dot pt ) ; set status ( 26 , 27 , power pt )
 %for x = 0 , 1 , 27 %cycle
      %for y = 0 , 1 , 29 %cycle
          draw dot ( x , y ) %if read status ( x , y , dot pt ) # 0
          power dot ( x , y ) %if read status ( x , y , power pt ) # 0
      %repeat
 %repeat
  %for x = 1, 1, 26 %cycle
    %for y = 1, 1, 29 %cycle
      k = 0
      %if read status(x, y, legal)#0 %start
         %if read status(x, y+1, legal)#0 %then %c
           set status(x, y, alldrn(0)) %and k = k+1
         %if read status(x+1, y, legal)#0 %then %c
           set status(x, y, alldrn(1)) %and K = k+1
         %if read status(x, y-1, legal)#0 %then %c
           set status(x, y, alldrn(2)) %and k = k+1
         %if read status(x-1, y, legal)#0 %then %c
           set status(x, y, alldrn(3)) %and K = K+1
         %if k>2 %then set status(x, y, dirgt2)
       %finish
     %repeat
   %repeat
   %for i = 1, 2, 3 %cycle
     set status(0, 16, alldrn(i))
     set status(26, 16, alldrn(i))
   %repeat
   ! Below is the movement allowed inside the cage
   set status(11, 17, alldrn(2)); set status(11, 16, alldrn(2))
   set status(11, 15, alldrn(1)); set status(12, 15, alldrn(0))
   set status(12, 16, alldrn(0)); set status(12, 17, alldrn(0))
   set status(12, 18, alldrn(0))
   set status(16, 17, alldrn(2)); set status(16, 16, alldrn(2))
   set status(16, 15, alldrn(3)); set status(15, 15, alldrn(3))
   set status(14, 15, alldrn(3)); set status(13, 15, alldrn(0))
   set status(13, 16, alldrn(0)); set status(13, 17, alldrn(1))
   set status(14, 17, alldrn(2)); set status(14, 16, alldrn(1))
   set status(15, 16, alldrn(0)); set status(15, 17, alldrn(0))
   set status(15, 18, alldrn(0))
   total dots = total dots - 54

%end

%routine draw player ( %integer colour, %record (pr) %name p)
   %integer pattern
   %if p == PMan %start
      disable (0)
      set colour (colour)
      %if p_drn = up %or p_drn = down %then %c
         at ( xreal ( p_x ) - 16 ,   %c
              yreal ( p_y ) + p_dy - 10 )  %c
      %else  %c
         at ( xreal ( p_x ) - 16 + p_dx ,  %c
              yreal ( p_y) - 10 )
      show symbol ( PM(p_drn, Munch, 0) )
      show symbol ( PM(p_drn, Munch, 1) )
   %else
      disable ( \colour )
      set colour ( colour )
      disable ( 8 ) %if colour = Black
      %if p_drn = up %or p_drn = down %then %c
         at ( xreal ( p_x ) - 16 ,   %c
              yreal ( p_y ) + p_dy - 10 )  %c
      %else  %c
         at ( xreal ( p_x ) - 16 + p_dx ,  %c
              yreal ( p_y) - 10 )
      show symbol ( 129 )
      show symbol ( 130 )
   %finish
%end

%routine set men up
   %record (pr) %name p
   p == initplayers(0)
   p_x = 13
   p_y = 7
   p_dx = 8
   p_dy = 0
   p_drn = 1
   p_steps = 4
   p_colour = Yellow
   p == initplayers(1)
   p_x = 13
   p_y = 16
   p_dx = 8
   p_dy = 0
   p_drn = rright
   p_steps = 4
   p_chge = 1
   p_colour = red
   p == initplayers(2)
   p_x = 12
   p_y = 16
   p_dx = 0
   p_dy = 0
   p_drn = up
   p_steps = 4
   p_chge = 1
   p_colour = magenta
   p == initplayers(3)
   p_x = 15
   p_y = 16
   p_dx = 0
   p_dy = 0
   p_drn = 2
   p_chge = rright
   p_steps = 4
   p_colour = green
%end

%predicate can die(%record (pr) %name p)
   %integer dx, dy
   dx = distance x ( PMan , p )
   dy = distance y ( PMan , p )
   %if dx # 0 %and dy # 0 %then %false
   %if dx = 0 %start  
     %true %if | dy | < 16
     %false
   %finish
   %if |dx|<16 %then %true
   %false
%end

%predicate valid move ( %record (pr) %name p, %integer dir )
 %if read status ( p_x, p_y, alldrn( dir ) ) = 0 %c
 %then %false
 %true
%end

 %routine move player ( %record (pr) %name p, %integer direc )
  %integer i
  draw player ( black, p)
  %switch a, b( 0:3 )
  %if direc = -1 %then direc = p_drn
  %if p_dx = 0 %and p_dy = 0 %start

    %if valid move(p, direc) %then p_drn = direc

    %if valid move(p, p_drn) %start

       ->a(p_drn)
       a(0):p_dy = p_steps
           ->enda
       a(1):p_dx = p_steps
           ->enda
       a(2):p_dy = 16-(p_steps)
           p_y = p_y-1
           ->enda
       a(3):p_dx = 16-(p_steps)
           p_x = p_x-1
           %if p_x = -1 %then p_x = 26
       enda:
    %finish
  %else
    ->b(p_drn)
    b(0):p_dy = p_dy+p_steps
         %if p_dy >= 16 %start
           p_dy = 0; p_y = p_y+1
         %finish
         ->endb
    b(1):p_dx = p_dx+p_steps
         %if p_dx >= 16 %start
           p_dx = 0; p_x = p_x+1
           %if p_x = 27 %then p_x = 0
         %finish
         ->endb
    b(2):p_dy = p_dy-p_steps
         ->endb
    b(3):p_dx = p_dx-p_steps
    endb:
  %finish
  Munch = 1 - Munch %if P == Pman %and Munch Time = 0
  draw player (p_colour, p) 
  set colour ( Black )
  i=xreal(0)-19
  fill(i,yreal(14),xreal(0)-2,yreal(18))
  fill(xreal(27)+2,yreal(14),xreal(28),yreal(18))

 %end

%integerfn one in between (%record (pr) %name p, %integer axis)
   %record (pr) %name pi
   %integer i
   %if axis = 0 %start
     %for i = 1, 1, 3 %cycle        
       pi == players (i)
       %if pi ## p %and pi_x = pman_x %start
         %if p_y <= pi_y <= pman_y %or %c
             p_y >= pi_y >= pman_y %then %result = i
       %finish
     %repeat
     %result = 0
   %finish
   %for i = 1, 1, 3 %cycle          
     pi == players(i)
     %if pi ## p %and pi_y = pman_y %start
       %if p_x <= pi_x <= pman_x %or %c
           p_x >= pi_x >= pman_x %then %result = i
     %finish
   %repeat
   %result = 0
 %end

%routine adjustdrn(%record (pr) %name p)
 %owninteger i = 0
 %integer drna, drnb, dx, dy, a, b, c, d, middle
 dx = distance x (p,pman)
 dy = distance y (p,pman)
 a = 0; b = 1; c = 2; d = 3          
 %if p_chge<0 %then %start
   a = 2; b = 3; c = 0; d = 1        
 %finishelsestart            
   %if |dx| = 0 %and |dy|<150 %start
     %if card>1 %start       
       middle = one in between(p,0)
       %if middle = 1 %start
         %if p == p2 %then dx = -150 %else dx = 150
       %else %if middle#0
         %if p == p1 %then dx = -150 %else dx = 150
       %finish
     %else        
         %if p == p2 %then dx = -150 %else %if p == p1 %then dx = -150
     %finish
   %else %if |dy| = 0 %and |dx|<150
     %if card>1 %then %start
       middle = one in between(p, 1)
       %if middle = 1 %start
         %if p == p2 %then dy = -150 %else dy = 150
       %else %if middle#0
         %if p == p1 %then dy = -150 %else dy = 150
       %finish
     %else
         %if p == p2 %then dy = -150 %else %if p == p1 %then dy = 150
     %finish
   %finish
 %finish
 %if dx>0 %start
   %if valid move(p, d) %then drna = d %else drna = -1
 %finish                    
 %if dx<0 %start            
   %if valid move(p, b) %then drna = b %else drna = -1
 %finish
 %if dx = 0 %then drna = -1
 %if dy>0 %start
   %if valid move(p, c) %then drnb = c %else drnb = -1
 %finish
 %if dy<0 %start
   %if valid move(p, a) %then drnb = a %else drnb = -1
 %finish
 %if dy = 0 %then drnb = -1
 %if |dx| >= |dy| %or drnb = -1 %start
   %if drna#-1 %start
     %if drna # opposite dir (p_drn) %start
       p_drn = drna 
       %return              
     %else %if dy = 0
       p_drn = drna
       %return
     %finish
   %finish
 %finish
 %if drnb#-1 %start
   %if drnb# opposite dir (p_drn) %start
     p_drn = drnb
     %return
   %else %if dx = 0
     p_drn = drnb
     %return
   %finish
 %finish
 %cycle
   %if valid move(p, i) %and i # opposite dir (p_drn) %start
     p_drn = i        
    %return                   
   %finish
   i = i+1
   i = 0 %if i = 4
 %repeat
%end

%routine move(%record (pr) %name p)
 %byte moose
 %integer i
 -> man %if p == pman
 move player (p, -1)         
 %if p_dx = 0 %and p_dy = 0 %start
   %if p_chge = -1 %or (p_x = 0 %and p_y = 16) %c
       %or (p_x = 26 %and p_y = 16) %c
       %then p_steps = 2 %else p_steps = 4
   %if read status (p_x, p_y, dirgt2 )#0 %or %c
     p_chge = -1 %start
     adjustdrn(p) 
   %else %if %not(valid move(p, p_drn))
     %for i = 0, 1, 3 %cycle   
       %if read status (p_x, p_y, alldrn(i))#0 %c
       %and i # opposite dir (p_drn) %then %exit
     %repeat
     p_drn = i
   %finish
 %finish
 %return
man:Munch Time = Munch Time + 1
    Munch Time = 0 %if Munch Time >= Munch Max
    moose = mouse buttons
    move player (PMan,Dir(Moose))
    %if Pman_dx = 0 %and Pman_dy = 0 %start
     %if read status(Pman_x, Pman_y, taken pt ) = 0 %then %start
       %if read status(Pman_x, Pman_y, dot pt ) # 0 %start
         score = score+1     
       %else               
         score = score+5     
         %if speed>0 %start
           chasing = -1        
           players(i)_chge = -1 %for i = 1, 1, 3
           %for i = 1, 1, 3 %cycle
               players( i )_colour = blue
           %repeat
           timer = speed     
         %finish 
       %finish
       total dots = total dots - 1
       set status(Pman_x, Pman_y, taken pt )
     %finish     
   %finish
%end

%routine draw men ( %integer men no , colour )

 %integer i

 at ( 10 , 454 )
 set colour (colour )
 %return %if men no = 0
 men no = max shown %if men no > max shown
 %for i = 1 , 1 , men no - 1 %cycle
      show symbol ( 131 )
      show symbol ( 132 )
!      xpos = xpos + 2 
 %repeat

%end

%routine show number ( %integer x , y , scre )
   %integer power10 , l , j , dump
   power10 = 100000
   l = 0
   at ( x , y ) %if x >= 0
   %for j = 1, 1, 6 %cycle
      dump = 0                  
      %cycle
         %exit %if scre < power10
         scre = scre  - power10
         dump = dump+1          
      %repeat
      %if dump>0 %then l = 1
      show symbol ( dump + '0' ) %if l = 1  
      power10  = power10 //  10
   %repeat
%end


%routine print score ( %string(255) s , %integer scre , hgt )

 %integer i

   scre = scre * 10 %if hgt = 435
   disable ( 0 )
   at ( 15 , hgt )
   set colour ( Black )
   show symbol ( GDel ) %for i = 1,1,13
   set colour ( White )
   at ( 15 , hgt )
   show string ( s )
   show number ( -1 , -1 , scre )
%end

%routine Kill PacMan
%integer x,y,c
   Disable(0)
   Draw Player (0, PMan)
   x = xreal(Pman_x)
   y = yreal(Pman_y)
   c = Players (0)_Colour
   %for i = 10,-1,1 %cycle
      Wait (35 + Int Pt(Deelay*0.62))
      Set Colour (Black)
      Circle (x,y,i+1)
      Set Colour (c)
      Circle (x,y,i)
   %repeat
   Set Colour (Black)
   Circle (x,y,1)
   Set Colour (c)
   At (x-16,y-10);ShowSymbol(Flash1);ShowSymbol(Flash1+1)
   Wait (40);Set Colour (Black)
   At (x-16,y-10);ShowSymbol(Flash1);ShowSymbol(Flash1+1)
   Set Colour (c)
   At (x-16,y-10);ShowSymbol(Flash2);ShowSymbol(Flash2+1)
   Wait (40);Set Colour (Black)
   At (x-16,y-10);ShowSymbol(Flash2);ShowSymbol(Flash2+1)
%end

%routine move all
%record (pr) %name P
  %integer i, next high, oldscore, j
  card = 0    
  speed = 140             
  players(i) = Initplayers(i) %for i = 0,1,3
  next high = 500
  old score = 0
  score = 0                
  mouth = start mouth                
  draw men ( mouth , yellow)
  %cycle
    %if card # 0 %start
      draw player (Black, pman)
      Munch = 0
      draw player (pman_Colour, pman)
      %for i = 1,1,4 %cycle
        Draw Grid (White)
        Wait (260)
        Draw Grid (Blue)
        Wait (260)
      %repeat      
    %finish
    new card                
    i = 0                  
    %cycle
      P == Players(i)
      Wait (Int Pt(Deelay*0.62))
      move(p)              
      %if i # 0 %and can die (p) %start
        %if p_chge = -1 %start
            draw player (black,p) 
            draw player (Black, pman)
            Munch = 0
            draw player (pman_Colour, pman)
            dead ghosts = dead ghosts + 1
            score = score + ( ( 1 << dead ghosts ) * 10 )
            Wait (433)
            players(i) = Initplayers(i)
        %finish %else %start
            disable ( 0 )
            draw player (black, players(j) ) %for j = 0 , 1 , 3
            Kill PacMan
            players(j) = Initplayers(j) %for j = 0,1,3
            draw men ( mouth , Black )
            mouth = mouth - 1
            draw men ( mouth , yellow)
            Wait (433)
        %finish
        %if mouth = 0 %then %return
      %finish
      %if i = 0 %start
        %if chasing = -1 %start
          timer = timer-1    
          %if timer<60 %start
            %for j = 1, 1, 3 %cycle
              P == Players(j)
              %if p_chge = -1 %start
                p_colour = colour (j) %if timer = 30 %or timer = 20 %c
                %or timer = 10 %or timer = 0
                p_colour = blue %if timer = 25 %or timer = 15 %c
                %or timer = 5
                p_chge = 1 %if timer = 0
              %finish      
            %repeat        
            %if timer = 0 %then dead ghosts = 0 %and chasing = 1
          %finish 
        %finish
        %if oldscore#score %start
          oldscore = score
          print score ( "Score = ",score,435 )
          %if score >= next high %start
            %if next high = 500 %then next high = 1000 %elsec
               next high = next high + 1000
            mouth = mouth+1
            draw men (mouth , yellow)
          %finish          
        %finish            
        %if total dots = 0 %then %exit
      %finish              
      i = (i+1)&3   
    %repeat
  %repeat
%end

%routine tell first idiot
  printstring(nls.nls."         PacMan".nls.nls)
  printstring("  Mouse Left     :  Man Left".nls)
  printstring("  Mouse Right    :  Man Right".nls)
  printstring("  Mouse Middle   :  Man Up".nls)
  printstring("  All Three      :  Man Down".nls.nls)
  Printstring("  Any Mouse Button for 'Default' between Games".nls)
  Printstring("  Ctrl-Y to Start New Game".nls)
  Printstring("  0-9 for Skill, any other Key to Quit".nls.nls.nls)
%end

%routine tell second idiot

  Printsymbol (27); PrintSymbol('t')
  Printstring ("  Skill Level (0-9 , ")
  Write(Deelay,0)
  PrintString(" default) : ")
  %cycle
     i = Test Symbol
     j = Mouse Buttons
  %repeat %until i # -1 %or j # MsNone
  i = Deelay + '0' %if j # MsNone %or i = 10
  %if i < '0' %or i > '9' %start
     %signal %event Ctrl Y Event, User Abort
  %finish
  Deelay = i - '0'
  League File = "games:PacLeague".Itos(Deelay,0)
  Print Symbol (i)
  PrintSymbol(13)
%end

%routine write name ( %string(name length ) str )

 set colour ( Black )
 disable ( 0 )
 at ( 15 , 480 )
 show symbol ( GDel ) %for i = 1,1,name length
 set colour ( White )
 at ( 15 , 480 )
 show string ( str )

%end

%routine league table (%string (name length) this name, %integer this score)

   %const %integer max league = max l
   %string (31) %array names  (1:max league)
   %integer     %array scores (1:max league)
   %string (31) name
   %integer update flag = 0, flag, number = 0, pointer, sym , hgt

   %on 3,4,9 %start
      -> done read
   %finish

   open input (1, League File)
   select input (1)

   Read (GameNo)

   %while number <= max league %cycle
      read (pointer)
      number = number + 1
      scores (number) = pointer
      read symbol (sym) %until sym = nl
      read line(names (number))
   %repeat
done read:

   close input
   select input (0)

   %if number < max league %start
      number = number + 1

      flag = 1
      %for pointer = number - 1, -1, 1 %cycle
         %if scores (pointer) < this score %start
            scores (pointer + 1) = scores (pointer)
            names  (pointer + 1) = names  (pointer)
         %finish %else %start
            flag = pointer + 1
            %exit
         %finish
      %repeat

      scores (flag) = this score
      names  (flag) = this name
      update flag = 1
   %finish %else %start
      %if this score > scores (number) %start
         update flag = 1
         flag = 1
         %for pointer = number - 1, -1, 1 %cycle
            %if scores (pointer) < this score %start
               scores (pointer + 1) = scores (pointer)
               names  (pointer + 1) = names  (pointer)
            %finish %else %start
               flag = pointer + 1
               %exit
            %finish
         %repeat
         scores (flag) = this score
         names  (flag) = this name
      %finish
   %finish

   disable ( 0 )
   hgt = ( 11 * max league ) + 13
   set colour ( black )
   fill ( 5 , hgt - ( 11 * max league ) - 3 , 5 + ( 9 * 14 ) , hgt + 12 )
   %for pointer = 1, 1, number %cycle
       set colour ( white )
       show number ( 7 , hgt , pointer )
       name = names( pointer )
       name = substring ( names ( pointer ) , 1 , 4 ) %c
       %if length ( names(pointer)) > 4
       name = name." " %while length ( name ) < 4
       name = " ".name %if pointer < 10
       set colour ( red )
       show string ( " ".name." " )
       set colour ( green )
       show number ( -1 , -1 , scores (  pointer ) )
       hgt = hgt - 12
   %repeat


      open output (1, League File)
      select output (1)
   
      %if This Score = -1 %then Write (GameNo,0) %else Write (GameNo+1,0)
      Newline
      %for pointer = 1, 1, number %cycle
         write (scores (pointer),0); space; new line
         print string (names (pointer)); new line
      %repeat
      close output
      select output (0)
      select input  (0)

%end

%routine new card
%integer i
   card = card + 1
   speed = speed - 20 %if speed > 0
   speed = 70 %if speed < 70
   Munch Time = 0
   Munch = 1
   draw player ( black, pman)
   players(0) = initplayers(0)
   Munch = 0
   %for i = 1 , 1 , 3 %cycle
        p == players (i)
        draw player ( black, p)
        players(i) = initplayers(i)
        draw player ( p_colour, p)
   %repeat
   draw player (pman_colour, pman)
   init1
   dead ghosts = 0
   chasing = 1
   Wait (62)
   print score ( "Card = ",card,410 )

%end

%routine SS (%integer i)
   Set Colour (Red)
   Show Symbol2 (i)
   Set Colour (Yellow)
   Show Symbol2 (i+1)
   Set Colour (Blue)
   Show Symbol2 (i+2)
   Set Colour (White)
   Show Symbol (i+3)
%end

%on %event Ctrl Y Event %start
   Printsymbol (27); Printsymbol (118)
   Half Clear (0)
   %if Event_Sub = User Abort %start
      Quote ("")
      i = FComm ('M' << 8, "") %if User = "Anon"
      -> EOP
   %else
      write (event_line,0) ; new line
      Quote ("")
      i = FComm ('M' << 8, "") %if User = "Anon"
      -> EOP
      -> New Game
   %finish
%finish

Setup
User = Current User; To Lower (User); CharNo(User,1) = CharNo(User,1)&95
%if User = "" %then User = "Anon" %and i = FComm ('L' << 8, "Pub")
Quote (Pass)
Read Font ("games:pacfont")
score = 0
card = 0
%if APM Level = 1.5 %start
   mix colour (63-i,31,31-(i*i//31)&31,0) %for i = 31,-1,0
   mix colour (95-i,0,31-(i*i//31)&31,31) %for i = 31,-1,0
%finish
set terminal mode ( nopage + noecho + single)
set men up
New Game:
Clear All
tell first idiot
%cycle
   tell second idiot
   hgt = ( 11 * max l ) + 39
   Set Colour (Black); Fill (15,360,15+9*14,447)
   Set Colour (White)
   At (15,435); Show String ("Score = 0")
   At (15,410); Show String ("Card = 0")
   %if APM Level = 1.5 %start
      %for i = 0,1,19 %cycle
         set colour (32+i)
         HLine (20,115,255-i)
         HLine (20,115,235-i)
         set colour (64+i)
         HLine (60,75,215-i)
      %repeat
      at (20,236)
      Set Colour (Black)
      Showsymbol (i) %for i = 183,1,188
      At (20,216)
      Showsymbol (i) %for i = 189,1,194
      At (60,196)
      Showsymbol (Deelay+195)
   %else
      at (20,236);SS(147);SS(151);SS(155);SS(159);SS(151);SS(163)
      at (20,216);SS(167);SS(171);SS(151);SS(175);SS(179);SS(171)
      Set Colour (Black); Fill (60,196,75,215)
      at (60,196);SS(4*Deelay+205)
   %finish
   Draw Grid (Blue)
   init1
   write name ( user )  
   league table ( "",-1 )
   Set Colour (White); At (15,385); Show String ("Game = ".Itos(GameNo,0))
   move all             
   league table ( user , score * 10)
%repeat
EOP:
%endofprogram
