	PROGRAM KINGS
C
C	PROGRAMED BY DAVE THORSON
C	BASED ON THE GAME "ALL THE KING'S MEN" BY PARKER BROTHERS, 1979
C
C	GAME EXPLANATION FOUND IN SUBROUTINE HELP
C
	COMMON CLEAR
	LOGICAL*1 ARR(8,7)
	LOGICAL*1 CLEAR(6),NAME(16),OUT(4)
	DATA CLEAR/"33,"131,"40,"40,"33,"153/
	DATA OUT/"33,"131,"57,"45/
	CALL TERM
	IPLAY=-1  !  SET FOR HELP FILE AT START OF GAME
1	WRITE(5,2) CLEAR
2	FORMAT(X,6A1//
     CT50,'  *  *  *  *'/
     CT50,'  |\/ \/ \/|'/
     CT50,'  |........|'/
     CT50,'  |::::::::|'///
     CT50,'    A L L'//T50,'     the'//T50,'  K I N G ''S'//T50,'    M E
     C N'/////T51,' programmed'/T51,'     by'/T51,'Dave Thorson')
	CALL KNIGHT(1)
	WRITE(5,301)
301	FORMAT(////' Do you need instructions ?'/'    Y/N-',$)
	READ(5,3,END=200) ANS
3	FORMAT(A1)
	CALL ARM
	T=SECNDS(0.0)
1000	IF(SECNDS(T).GT.1.) GOTO 1001
	GOTO 1000
1001	IF(ANS.EQ.'Y') GOTO 10
	IF(ANS.EQ.'N') GOTO 11
	WRITE(5,4)
4	FORMAT(///' You have entered a character other than'/
     C' N or Y, or your terminal is set for lower case letters.'/
     C' Program terminating.'//)
	GOTO 200
10	CALL CLEAN(2)
302	FORMAT(X,4A1,60X)
	CALL HELP(ARR,IPLAY)
C	INITIALIZE GAME:
	DO 14 I=1,8
	DO 14 J=1,7
	ARR(I,J)="40  ! BLANK
14	CONTINUE
11	DO 15 I=1,7
	ARR(2,I)='a'
	ARR(7,I)='A'
15	CONTINUE
	ARR(1,2)='n'
	ARR(1,3)='n'
	ARR(1,4)='k'
	ARR(1,5)='n'
	ARR(1,6)='n'
	ARR(8,2)='N'
	ARR(8,3)='N'
	ARR(8,4)='K'
	ARR(8,5)='N'
	ARR(8,6)='N'
	IPLAY=0
17	CALL CLEAN(1)
	WRITE(5,16)
16	FORMAT(' Player 1 uses upper-'/' case symbols [A,N,K].'/
     C' Player 2 uses lower-'/' case symbols [a,n,k].'/
     C' A,a-Archer; N,n-Knight; K,k-King'//
     C' (enter a 0 below to continue'/' an existing game)'//
     C' Who will start the game ?'/' 1 or 2 (or 0): ',$)
	READ(5,3,END=200) ANS
	IF(ANS.EQ.'1') IPLAY=1
	IF(ANS.EQ.'2') IPLAY=2
	IF(ANS.NE.'0') GOTO 18
	WRITE(5,19)
19	FORMAT(' What is the name of the'/' file where your old'/
     C' game is stored ?'/)
	READ(5,20,END=200) NAME
20	FORMAT(16A1)
	CALL ASSIGN(1,NAME,16)
	READ(1,21) IPLAY,ARR
21	FORMAT(7X,I2/56A1)
	CALL CLOSE(1)
18	IF(IPLAY.EQ.0) GOTO 17
12	CALL BOARD(ARR)
13	CALL MOVES(IPLAY,ARR)
	I=IPLAY
	IF(I.EQ.1) IPLAY=2
	IF(I.EQ.2) IPLAY=1
	GOTO 13
200	STOP'-- program terminated'
	END
C
C
C
	SUBROUTINE MOVES(IPLAY,ARR)
	LOGICAL*1 ARR(8,7),C,D
	LOGICAL*1 TOP(4),OUT(4)
	DATA TOP,OUT/"33,"131,"40,"40,"33,"131,"40,"40/
1	CALL CLEAN(0)
	WRITE(5,2) TOP,IPLAY
2	FORMAT(X,4A1,'Player ',I1,', it is now your'/
     C' turn.  Enter your starting'/
     C' position as R,C: ',$)
5	READ(5,3,END=100,ERR=90) I1,I2
3	FORMAT(2I5)
	IF(I1+I2.NE.0) GOTO 7
	CALL BOARD(ARR)
	GOTO 1
7	IF(I1.LT.1.OR.I1.GT.8) GOTO 90
	IF(I2.LT.1.OR.I2.GT.7) GOTO 90
	C=ARR(I1,I2)
	IF(C.GT.'@') GOTO 10
	WRITE(5,4) I1,I2
4	FORMAT(' Alas, you fool no one, there'/
     C' is no man at ',I1,',',I1,'.'/' Try again: ',$)
	GOTO 5
10	IF(IPLAY.EQ.1.AND.C.GT.'N') GOTO 50 ! MOVING WRONG PIECES
	IF(IPLAY.EQ.2.AND.C.LT.'O'.AND.C.GT.'@') GOTO 55 ! DITTO
	OUT(3)=30+I1*3
	OUT(4)=69+I2*5
	WRITE(5,11) OUT   !  REPLACE MOVED PIECE WITH *
11	FORMAT(X,4A1,'*')
19	CALL CLEAN(0)
16	IF(C.EQ.'K'.OR.C.EQ.'k') WRITE(5,12)
	IF(C.EQ.'A'.OR.C.EQ.'a') WRITE(5,13)
	IF(C.EQ.'N'.OR.C.EQ.'n') WRITE(5,14)
12	FORMAT(' To which locatation do you'/
     C' wish to move your King ?'/
     C' R,C: ',$)
13	FORMAT(' Where is your Archer going'/
     C' to end up ?   R,C: ',$)
14	FORMAT(' Which square are you moving'/
     C' your Knight to ?    R,C: ',$)
128	READ(5,3,END=100,ERR=90) I3,I4
	IF(I3+I4.NE.0) GOTO 15
	CALL BOARD(ARR)
	GOTO 1
15	IF(I3.LT.1.OR.I3.GT.8) GOTO 90
	IF(I4.LT.1.OR.I4.GT.7) GOTO 90
	ID=0  !  CLEAR FLAG
	IF(C.EQ.'N'.OR.C.EQ.'n') GOTO 20
	ID=-2  !  FLAG FOR ROUTINE CHECK: NOT A KNIGHT
	IF(IABS(I1-I3).GT.1) GOTO 90
	IF(IABS(I2-I4).GT.1) GOTO 90
C
C	CHECK IF DIRECTION OF MOVE IS LEGAL
20	CALL CHECK(ARR,I1,I2,I3,I4,ID)
	IF(ID.GT.-1) GOTO 25 !  MOVE VALID
	IF(ID.EQ.-1) WRITE(5,26) I1,I2
26	FORMAT(' You can''t move that'/' direction from ',I1,',',I1/
     C' Try again: ',$)
	IF(ID.EQ.-2) WRITE(5,127)
127	FORMAT(' You can''t move that far;'/' someone is in your'/
     C' way.  Try again: ',$)
	IF(ID.EQ.-3) WRITE(5,126)
126	FORMAT(' An attempt to escape from'/' the board has been'/
     C' averted.  Try again: ',$)
	GOTO 128
C
C	ASSUME MOVE WAS LEGAL.
25	D=ARR(I3,I4)
	IF(D.LT.'A') GOTO 29
	IF(D.GT.'N'.AND.C.GT.'N') GOTO 60
	IF(D.LT.'O'.AND.D.GE.'A'.AND.IPLAY.EQ.1) GOTO 60
	IF(D.EQ.'A'.OR.D.EQ.'a') WRITE(5,21)
	IF(D.EQ.'N'.OR.D.EQ.'n') WRITE(5,22)
	IF(D.NE.'K'.AND.D.NE.'k') GOTO 30
21	FORMAT(' You have captured an Archer.')
22	FORMAT(' You have captured a Knight.')
	WRITE(5,23) IPLAY
23	FORMAT(///' Congratulations player ',I1,','/
     C/' you have won the game !'//)
	ISTOP=1  !  END GAME SOON
	GOTO 29
C	CLEAR * FROM BOARD
30	T=SECNDS(0.0)  ! DELAY LOOP:
28	IF(SECNDS(T).GT.2.) GOTO 29
	GOTO 28
29	WRITE(5,31) OUT
31	FORMAT(X,4A1,' ')
	ARR(I1,I2)="40
	ARR(I3,I4)=C
	OUT(3)=30+I3*3
	OUT(4)=69+I4*5
	WRITE(5,32) OUT,C
32	FORMAT(X,4A1,A1)
	IF(ISTOP.NE.1) RETURN
	OUT(3)="55
	OUT(4)=' '
	WRITE(5,52) OUT
52	FORMAT(X,4A1)
	STOP '-- game ended'
50	WRITE(5,51)
51	FORMAT(' Watch it, player 1. Your'/
     C' pieces are marked by A, N and K.'/
     C' You''re moving the wrong ones !'//
     C' Try again: ',$)
	GOTO 5
55	WRITE(5,56)
56	FORMAT(' Player 2, you''re moving'/
     C' the wrong pieces !!! Your pieces'/
     C' are marked by  a, n and k.'//
     C' Try again: ',$)
	GOTO 5
60	WRITE(5,61)
61	FORMAT(//' Fool !!!  You attempt'/
     C' to capture your own man !'/
     C' Try again:')
	GOTO 16
90	CALL HELP(ARR,IPLAY)
	GOTO 1
100	STOP'-- game aborted'
	END
C
C
C
	SUBROUTINE HELP(ARR,IPLAY)
	LOGICAL*1 NAME(16)
	LOGICAL*1 ARR(8,7)
	CALL CLEAN(0)
	WRITE(5,1)
1	FORMAT(' ****  HELP FILE  ****'//' Leave this file at any'/
     C' time by entering an X;'/' <CR> will bring more'/
     C' information to the screen.'//' ALL THE KING''S MEN is'/
     C' a game similar to chess.'/' Each player starts with'/
     C' a King, 4 Knights, and'/' 7 Archers.  Knights'/
     C' may move any number of'/' spaces in a STRAIGHT'/
     C' line; all other men may'/' move only ONE space.')
	READ(5,2,END=100) ANS
2	FORMAT(A1)
	IF(ANS.EQ.'X') GOTO 99
	IF(ANS.EQ.'S') GOTO 98
	CALL CLEAN(1)
	WRITE(5,3)
3	FORMAT(' All men may move in'/' any direction but'/
     C' can ONLY move in the'/' directions marked on'/
     C' the game board in the'/' area they are moving from.'/
     C' Only one piece may be moved'/
     C' per turn, and no piece is'/' allowed to jump over another.')
	READ(5,2,END=100) ANS
	IF(ANS.EQ.'X') GOTO 99
	IF(ANS.EQ.'S') GOTO 98
	CALL CLEAN(0)
	WRITE(5,4)
4	FORMAT(' The object of the game'/' is, of course, to capture'/
     C' your opponent''s King.'/' Kings and all other men'/
     C' are captured by landing'/' on them.  You cannot'/
     C' capture your own men.'//' Unlike chess, one King'/
     C' can capture the other.')
	READ(5,2,END=100) ANS
	IF(ANS.EQ.'X') GOTO 99
	IF(ANS.EQ.'S') GOTO 98
	CALL CLEAN(0)
	WRITE(5,5)
5	FORMAT(' Moves are described by'/' entering the start'/
     C' and ending locations of'/' the piece to be moved.'/
     C' Enter the row and column'/' as 8,3 for example.'/
     C' Movement restrictions are'/' defined by the lines'/
     C' exiting each ( ) on the'/' board.  Note that sideways moves'/
     C' are indicated by a single -,'/' vertical by a |, and'/
     C' diagonal moves by a / or \.'//'      -(1)- (2)--(3)-'/
     C' Above, moves are possible from'/' 1 to 2, 3 to 2, and 2 to 3.')
	READ(5,2,END=100) ANS
	IF(ANS.EQ.'X') GOTO 99
	IF(ANS.EQ.'S') GOTO 98
	CALL CLEAN(1)
	WRITE(5,60)
60	FORMAT(
     C' Here, the Knight(N) can move'/' to all the spots marked with'/
     C' a +, and the Archer(A) can only'/' move to those marked by a *'/
     C/'  ( )- ( )- (A) -( )--(+)'/
     C'   | \  |  / | \/   \  |'/
     C'     /       | /  |    |'/
     C'  ( )  (*)--(*)  (*)--(+)'/
     C'   |    |    |    |  /'/
     C'   | /  |    |    |    |'/
     C'  (+)  (+)--(+) -(+)--(N)'//
     C' These are the only spots these'/' pieces can reach in one'/
     C' move.  Note that this is not'/' a part of the real game'/
     C' board.  *''s will appear in'/' the game to show you'/
     C' you''re moving from.')
	READ(5,2,END=100) ANS
	IF(ANS.EQ.'X') GOTO 99
	IF(ANS.EQ.'S') GOTO 98
	CALL CLEAN(1)
	WRITE(5,6)
6	FORMAT(' Should the screen become'/' cluttered from too'/
     C' much writing, enter a'/' <CR> or 0,0 for your'/
     C' move.  This will clear'/' the screen and redraw'/
     C' the board.  This also'/' will start your turn'/
     C' over; just in case you'/' should pick the wrong'/
     C' starting position this'/' lets you correct it.')
	READ(5,2,END=100) ANS
	IF(ANS.EQ.'X') GOTO 99
	IF(ANS.EQ.'S') GOTO 98
	CALL CLEAN(1)
	WRITE(5,7)
7	FORMAT(' If you should run out'/' of time and wish to'/
     C' save the game for a'/' later time, come to'/
     C' this help file and'/' enter the word SAVE.'/
     C' You can get to this help'/' file by entering an'/
     C' impossible move, such as'/' -1 or A, etc.  From here,'/
     C' a <CR> will return you to'/' the game.')
	READ(5,2,END=100) ANS
98	IF(IPLAY.GE.0) GOTO 30
	CALL CLEAN(0)
	GOTO 99
30	IF(ANS.EQ.'X') GOTO 99
	IF(ANS.NE.'S') GOTO 99
	CALL CLEAN(1)
11	WRITE(5,8)
8	FORMAT(' SAVING ROUTINE.'//' Enter below the name'/
     C' of a storage file, up to'/' 16 characters:')
	READ(5,9) NAME
9	FORMAT(16A1)
	CALL CLEAN(0)
	WRITE(5,10) NAME
10	FORMAT(' Your file is called'/5X,16A1/
     C' Enter X to change this.'/' To use this file next'/
     C' time you restart this'/' game, enter zero (0) for'/
     C' the starting player at'/' the beginning of the'/
     C' game.')
	READ(5,2,END=100) ANS
	IF(ANS.EQ.'X') GOTO 11
	CALL ASSIGN(1,NAME,16)
	WRITE(1,12) IPLAY,ARR
12	FORMAT(X,'PLAYER',I2,' IS NEXT TO MOVE'/56A1)
	CALL CLOSE(1)
	WRITE(5,97)
97	FORMAT(' (---- game suspended ----)'//)
	GOTO 100
99	CALL CLEAN(2)
	RETURN
100	STOP'-- game aborted'
	END
C
C
C
	SUBROUTINE CLEAN(K)
C	ROUTINE TO CLEAN UP LEFT SIDE OF SCREEN
	LOGICAL*1 TOP(4),MID(4)
	DATA TOP,MID/"33,"131,"40,"40,"33,"131,"52,"40/
	IF(K.EQ.0) WRITE(5,1) TOP,TOP
1	FORMAT(X,4A1,10(37X/),35X,4A1)
	IF(K.EQ.1) WRITE(5,2) TOP,TOP
2	FORMAT(X,4A1,20(37X/),35X,4A1)
	IF(K.EQ.2) WRITE(5,1) MID,TOP
	RETURN
	END
C
C
C
	SUBROUTINE BOARD(ARR)
	COMMON CLEAR
	LOGICAL*1 ARR(8,7)
C	ROUTINE TO WRITE BOARD
	LOGICAL*1 CLEAR(6),OUT(4)
	DATA OUT/"33,"131,"40,"40/
	WRITE(5,1) CLEAR
1	FORMAT(X,6A1,'             
     C                             1    2    3    4    5    6    7'/
     CT39,'1   ( )--( )--( )--( )--( )--( )- ( ) '/
     CT42,'  |    |    |    |    |    |    |  '/
     CT42,'  |  \      |         |         |  '/
     CT39,'2   ( )  ( )--( )--( )--( )--( )  ( ) '/
     CT42,'  |    |    |    |    |    |    |  '/
     CT42,'  |    |  \   /     \   /  |    |  '/
     CT39,'3   ( )--( )- ( ) -( )- ( ) -( )--( ) '/
     CT42,'  |    |  /   \     /   \       |  '/
     CT42,'    /       |  \ | /  |    |    |  '/
     CT39,'4   ( )--( )- ( )--( )- ( )--( )- ( ) '/
     CT42,'    \       |  / | \  |    |    |  ')
	WRITE(5,2)
2	FORMAT(
     CT42,'  |    |    |  \ | /  |       \    '/
     CT39,'5   ( ) -( )--( ) -( )--( ) -( )--( ) '/
     CT42,'  |    |    |  / | \  |       /    '/
     CT42,'  |       \   /     \   /  |    |  '/
     CT39,'6   ( )--( )- ( ) -( )- ( ) -( )--( ) '/
     CT42,'  |    |  /   \     /   \  |    |  '/
     CT42,'  |    |    |    |    |    |    |  '/
     CT39,'7   ( )  ( )--( )--( )--( )--( )  ( ) '/
     CT42,'  |         |         |      \  |  '/
     CT42,'  |    |    |    |    |    |    |  '/
     CT39,'8   ( ) -( )--( )--( )--( )--( )--( ) ')
	DO 3 I=1,8
	DO 3 J=1,7
	OUT(3)=30+I*3
	OUT(4)=69+J*5
	WRITE(5,4) OUT,ARR(I,J)
3	CONTINUE
4	FORMAT(X,4A1,A1)
	RETURN
	END
C
C
C
	SUBROUTINE CHECK(ARR,I1,I2,I3,I4,ID)
C	ROUTINE TO CHECK IF DIRECTION OF MOVE IS LEGAL
C	AND IF MOVED PIECE DOESN'T JUMP ANOTHER PIECE (ONLY APPLICABLE
C	TO KNIGHTS -- OTHERS CAN ONLY MOVE ONE SPACE)
	LOGICAL*1 ARR(8,7)
	DOUBLEPRECISION IRR(8,7),A
	LOGICAL*1 B(8)
	EQUIVALENCE (A,B(1))
	DATA IRR/
     C'NNNNYNYN','NYNNNNYN','NYNNYNYN','NNYNYNNY',
     C'NYNNNNYN','NYNNYNYN','NYNNNNYN','NYNNNNNN',
     C'NNNYYNYN','YNNNYNYN','NYNYYNYN','NNNYYNNN',
     C'NYNYYNYN','NNNYYNYN','NYNNYNNN','NYNYYNNN',
     C'NNNYYNYN','NYNYYNYN','YNYNNYNY','NYNNYNYN',
     C'NYNYNNYN','YNYNNYNY','NYNYYNYN','NYNYYNNN',
     C'NNNYYNYN','NNNYYNYN','NNNYYNNN','YYYYYYYY',
     C'YYYYYYYY','NNNYYNNN','NYNYYNNN','NYNYYNNN',
     C'NNNYYNYN','NYNYYNYN','YNYNNYNY','NYNNYNYN',
     C'NYNYNNYN','YNYNNYNY','NYNYYNYN','NYNYYNNN',
     C'NNNYYNYN','NNNYNNYN','NYNYYNNN','NYNYYNYN',
     C'NNNYYNNN','NYNYYNYN','NYNYNNNY','NYNYYNNN',
     C'NNNNNNYN','NYNNNNYN','NYNYNNYN','NYNNNNYN',
     C'YNNYNYNN','NYNYNNYN','NYNNNNYN','NYNYNNNN'/
C
C	IRR CONTAINS POSSIBLE DIRECTIONS FROM EACH SQUARE
C	STRUCTURE IS ROW 1-4,4-8 PROGRESSING COLUMNS 1-7 EACH PAIR OF
C	LINES ABOVE.  FOR WORD 'abcdefgh', A Y IN POSITION d WOULD MEAN
C	IT IS POSSIBLE TO TRAVEL IN DIRECTION 4 FROM THAT SQUARE.
C	                              1 2 3
C	DETERMINE DIRECTION OF MOVE:  4( )5
C	                              6 7 8
C
	IC=ID  ! SAVE ID IN CASE IT'S A KNIGHT (-2 MEANS IT'S NOT)
	IY=0
	IX=0
	JY=I1-I3
	JX=I4-I2
C	CHECK FOR NON-45/NON-90 DEGREE MOVES:
C	JX + JY MUST EQUAL 0, JX, JY, 2JX OR 2JY IF MOVE IS OK.
	K=JX+JY
	IF(K.EQ.0.OR.K.EQ.JX.OR.K.EQ.JY.OR.K.EQ.2*JX.OR.K.EQ.2*JY)
     CGOTO 399
	ID=-1
	GOTO 400
399	IF(JY.GT.0) IY=1
	IF(JY.LT.0) IY=-1
	IF(JX.GT.0) IX=1
	IF(JX.LT.0) IX=-1
	K=IY+IX  !                              0 +1 +2
C	K WILL EQUAL -2 TO 2 FOR DIRECTIONS:   -1(  )+1
C	                                       -2 -1  0
C	THEN WE NEED TO RESOLVE DUPLICATION CONFLICTS:
	IF(I3.LT.I1) ID=K+1
	IF(I3.EQ.I1) ID=K/2.+4.51  !  GIVES 4.01 OR 5.01 GIVING 4 OR 5
	IF(I3.GT.I1) ID=K+8
	A=IRR(I1,I2)  ! GET CURRENT SQUARE
	IF(B(ID).EQ.'N') ID=-1  !  SET FLAG TO INDICATE BAD MOVE
400	IF(IC.EQ.-2) GOTO 21  ! RETURN
C	HAVE A KNIGHT: CHECK IF HE'S TRYING TO TROMPLE SOMEONE.
C	TRAVERSE THE POSITIONS ARRAY, ARR.
	K=IABS(JY)
	L=IABS(JX)
	M=K !  M IS MAX OF ABS. VALUES OF MOVE IN Y OR X DIRECTIONS
	IF(L.GT.K) M=L
	IF(M.EQ.1) GOTO 21  !  MUST BE MOVING ONLY 1 SPACE
	J1=I1
	J2=I2
	DO 10 I=1,M-1
	J1=J1-IY
	J2=J2+IX
	IF(J1.GT.8.OR.J1.LT.1.OR.J2.GT.7.OR.J2.LT.1) GOTO 35
	IF(ARR(J1,J2).GT."100) GOTO 20
10	CONTINUE
	GOTO 21  !  NOTHING IN THE WAY
20	ID=-2
21	RETURN
35	ID=-3 !  TRIED TO GO OFF BOARD
	GOTO 21
	END
C
C
C
	SUBROUTINE KNIGHT(K)
C	GRAPHICS ROUTINE FOR START OF GAME
	LOGICAL*1 OUT(4),A
	DATA OUT/"33,"131,"40,"40/
	OUT(3)="40
	IF(K.EQ.2) GOTO 300
	WRITE(5,1) OUT
1	FORMAT(X,4A1////
     C'   ****'/'  **  ****   ...'/'         **/    \'/
     CT11,'/    =='/T11,'|      |'/T11,'\------/'/T10,'/========\'/
     CT9,'|'/T9,'|  \       |'/T9,'|   \'/T9,'|')
300	A='|'
	OUT(4)=56
	WRITE(5,2) OUT
2	FORMAT(X,4A1,'/\')
10	DO 3 I=1,9
	OUT(3)=OUT(3)+1
	WRITE(5,4) OUT,A,A
3	CONTINUE
4	FORMAT(X,4A1,2A1)
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-2
	WRITE(5,5) OUT
5	FORMAT(X,4A1,'/ --|')
	OUT(3)=OUT(3)+1
	WRITE(5,6) OUT
6	FORMAT(X,4A1,'| ==/')
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-1
	WRITE(5,7) OUT
7	FORMAT(X,4A1,'/  /')
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)+2
	WRITE(5,8) OUT
8	FORMAT(X,4A1,'/')
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-1
	WRITE(5,8) OUT
	RETURN
	END
C
C
C
	SUBROUTINE ARM
	LOGICAL*1 OUT(4),A
	DATA OUT/"33,"131,"40,"40/
	A=' '
	OUT(4)=56
	WRITE(5,2) OUT
2	FORMAT(X,4A1,'  ')
10	DO 3 I=1,9
	OUT(3)=OUT(3)+1
	WRITE(5,4) OUT,A,A
3	CONTINUE
4	FORMAT(X,4A1,2A1)
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-2
	WRITE(5,9) OUT
5	FORMAT(X,4A1,'/ --|')
	OUT(3)=OUT(3)+1
	WRITE(5,9) OUT
6	FORMAT(X,4A1,'| ==/')
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-1
	WRITE(5,9) OUT
7	FORMAT(X,4A1,'/  /')
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)+2
	WRITE(5,9) OUT
8	FORMAT(X,4A1,'/')
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-1
	WRITE(5,9) OUT
9	FORMAT(X,4A1,6X)
	A='/'
	OUT(3)="40
	OUT(4)=56
C	WRITE(5,2) OUT
C2	FORMAT(X,4A1,'/\')
	OUT(4)=OUT(4)+11
	DO 13 I=1,9
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-1
	WRITE(5,4) OUT,A,A
13	CONTINUE
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-2
	WRITE(5,5) OUT
	OUT(3)=OUT(3)+1
	WRITE(5,6) OUT
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-2
	WRITE(5,7) OUT
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)+1
	WRITE(5,8) OUT
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-2
	WRITE(5,8) OUT
	A=' '
	OUT(3)="40
	OUT(4)=56
C	WRITE(5,2) OUT
C2	FORMAT(X,4A1,'  ')
	OUT(4)=OUT(4)+11
	DO 23 I=1,9
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-1
	WRITE(5,9) OUT,A,A
23	CONTINUE
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-2
	WRITE(5,9) OUT
	OUT(3)=OUT(3)+1
	WRITE(5,9) OUT
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-2
	WRITE(5,9) OUT
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)+1
	WRITE(5,9) OUT
	OUT(3)=OUT(3)+1
	OUT(4)=OUT(4)-2
	WRITE(5,9) OUT
C
C	FINAL POSITION:
	OUT(4)=48
	OUT(3)=46
	WRITE(5,25) OUT
25	FORMAT(X,4A1,'.....')
	OUT(3)=47
	OUT(4)=47
	WRITE(5,26) OUT
26	FORMAT(X,4A1,'. /::::}}}}}}}}}}}}}}}}}}}}}}}}}}}}}>>')
	OUT(3)=48
	OUT(4)=37
	WRITE(5,27) OUT
27	FORMAT(X,4A1,'   \     - - -~~~')
	OUT(4)=48
	OUT(3)=46
	WRITE(5,9) OUT
	OUT(3)=47
	OUT(4)=47
	WRITE(5,28) OUT
28	FORMAT(X,4A1,40X)
	OUT(3)=48
	OUT(4)=37
	WRITE(5,9) OUT
	CALL KNIGHT(2)
	RETURN
	END
C
C
C
	SUBROUTINE TERM
	COMMON CLEAR
	LOGICAL*1 CLEAR(6)
1	WRITE(5,2)
2	FORMAT(///' What type of terminal are you using ?'/
     C'   A) ADDS Regent 100'/'   B) Digital VT100'/
     C'   C) Digital VT52 (decscope)'/
     C'   D) Hardcopy or Graphics'//' Enter A,B,C or D: ',$)
	READ(5,3,END=10) ANS
3	FORMAT(A1)
	IF(ANS.EQ.'A'.OR.ANS.EQ.'a') GOTO 11
	IF(ANS.EQ.'B'.OR.ANS.EQ.'b') GOTO 15
	IF(ANS.EQ.'C'.OR.ANS.EQ.'c') GOTO 20
	IF(ANS.NE.'D'.AND.ANS.NE.'d') GOTO 1
	WRITE(5,5)
5	FORMAT(' This game is designed only for the CRT terminals'/
     C' listed.  Results are unpredictable on other devices.')
10	CALL CLOSE(5)
11	RETURN
15	WRITE(5,16) "33  ! SWITCH VT100 TO VT-52 COMPATIBLE MODE
16	FORMAT(X,A1,'[?2l'/'+      ')
20	CLEAR(6)='J'    ! VT-52 COMPATIBLE
	GOTO 11
	END
