/ CHEKMO II
ZZZ=63
/AUTHOR    JOHN E. COMEAU

















/   :::::::::::::::::::::::::::::::
/   :				  :
/   :			  	  :
/   :			          :
/   :		CHEKMO II	  :
/   :	  CHESS PROGRAM  2/74 	  :
/   :				  :
/   :				  :
/   :				  :
/   :::::::::::::::::::::::::::::::




/ FIELD 0  CORE UTILIZATION

/	0000-0177	CONSTANTS AND POINTERS
/	0200-0377	INITIALIZATION
/	0400-4777	THE THINKER PART
/	5000-6377	INPUT/OUTPUT ROUTINES
/	6400-7377	PUSH DOWN LIST AREA
/	7400-7577	BOARD & MISC. TABLES
/	7600-7777	BINARY LOADER PROGRAM
/SYMBOL DEFINITIONS
/MISC. SYMBOLS
PDLS=6400	/BEGINING OF 1000(OCTAL) WORDS RESERVED FOR PUSH DOWN LISTS

/PIECE VALUES DEFINED
DECIMAL
KING=	15^32	/15. RELATIVE TO A PAWNS VALUE
QUEEN=	9^32	/9.0 RELATIVE TO A PAWNS VALUE
ROOK=	5^32	/5.0 RELATIVE TO A PAWNS VALUE
BISHOP=	3^32+10	/3.3 RELATIVE TO A PAWNS VALUE
KNIGHT=	3^32+4	/3.1 RELATIVE TO A PAWNS VALUE
PAWN=	1^32	/1.0 RELATIVE TO A PAWNS VALUE

OCTAL

/PSEUDO INSTRUCTIONS DEFINED
PUSH1=	JMS  I	[PUSH01	/PUSH THE AC INTO PUSH DOWN LIST #1
POP1=	JMS  I	[POP01	/POP THE TOP ENTRY OF PUSH DOWN LIST #1 INTO THE AC
PRINTO=	JMS  I	[MES	/PRINT 6BIT 2CHAR/WORD TEXT AT ADDRESS SPECIFIED IN THE AC
IPDL1=	JMS  I	[IPDL01	/INITIALIZE PUSH DOWN LIST #1
PUSH2=	JMS  I	[PUSHIT	/PUSH THE CONTENTS OF THE AC INTO PUSH DOWN LIST #2
POP2=	JMS  I	[POPIT	/POP THE TOP ENTRY OF PUSH DOWN LIST #2 INTO THE AC
IPDL2=	JMS  I	[PDLIN	/INITIALIZE PUSH DOWN LIST #2
SNO=	JMS  I	[RFOFL	/SKIP NO OVERFLOW (C(AC)>=0 & C(AC8)=0)

/PDP 8/E IOTS DEFINED
CAF= 6007
PSKF=6661
PCLF=6662
PSKE=6663
PSTB=6664
PCIE=6667

/CONDITIONAL ASSEMBLY DEFINITIONS
OS8=1			/NO SPECIAL MEANING TO "^C"
LPTREE=1		/DON'T INCLUDE LINE PRINTER CAPABILITIES
DEBUG=1			/OPT FOR DYNAMIC ERROR DETECTION
RANVAL=1		/NOISY EVALUATIONS PLEASE

/DEFAULT ASSEMBLY DEFINITIONS
IFNDEF	OS8	<OS8=0>		/NON OS8 SYSTEM
IFNDEF	DEBUG	<DEBUG=0>	/DEBUG SWITCH CLEARED
IFNDEF	LPTREE	<LPTREE=0>	/DONT INCLUDE TREE PRINTOUT CAPABILITIES
IFNDEF	RANVAL	<RANVAL=1>	/INCLUDE A SMIDGEN OF RANDOMNESS IN EVALUATIONS

/ABREVIATIONS USED

/ SQR	SQUARE
/ INC	INCREMENT
/ #	NUMBER
/ =	EQUALS
/ -	MINUS, NEGATIVE OR TO
/ &	AND
/ INFO	INFORMATION
/ AC	ACCUMULATOR
/ TEMP	TEMPORARY
/K-SIDE	KING SIDE
/Q-SIDE	QUEEN SIDE
/ LOC	LOCATION
/ CR	CARRIAGE RETURN
/ LF	LINE FEED
/ MSW	MOVE SQUARE WORD
/ MDW	MOVE DATA WORD
/ CHAR	CHARACTER
/ W/	WITH
/ <	LESS THAN
/ >	GREATER THAN
/ PSW	POSITION STATUS WORD
/ ADDR	ADDRESS
/ PDL	PUSH DOWN LIST
/ PDL#1	PUSH DOWN LIST #1
/ PDL#2	PUSH DOWN LIST #2
/ ABS	ABSOLUTE
/ PROM	PROMOTION
/ ARG	ARGUMENT
/ VAL	VALUE

/		MOVE SQUARE WORD(MSW) FORMAT
/
/  -------------------------------------------------------------------------  
/  I     I     I     I     I     I     I     I     I     I     I     I     I
/  I  0  I  1  I  2  I  3  I  4  I  5  I  6  I  7  I  8  I  9  I  10 I  11 I
/  I     I     I     I     I     I     I     I     I     I     I     I     I  
/  -------------------------------------------------------------------------  
/  I                                  I I                                 I  
/   -----------------I----------------- -----------------I-----------------  
/ 
/         SIXBIT ADDRESS OF THE                SIXBIT ADDRESS OF THE   
/	     "FROM SQUARE"			   "TO SQUARE"






/		MOVE DATA WORD(MDW) FORMAT
/  -------------------------------------------------------------------------  
/  I     I     I     I     I     I     I     I     I     I     I     I     I
/  I  0  I  1  I  2  I  3  I  4  I  5  I  6  I  7  I  8  I  9  I  10 I  11 I  
/  I     I     I     I     I     I     I     I     I     I     I     I     I  
/  -------------------------------------------------------------------------  
/     I   I         I I                                 I I               I  
/     I    ----I----   ----------------I----------------   -------I-------   
/     I   
/     I      UNUSED       = THE SIXBIT ADDRESS OF       0 = NORMAL  
/     I      ALLWAYS      THE "TO SQUARE" IF THE        1 = QUEEN SIDE CASTLING 
/     I      EQUALS 0     MOVE IS A 2 SQUARE            2 = KING SIDE CASTLING  
/     I                   PAWN MOVE                     3 = EN PASSANT CAPTURE  
/     I                                                 4 = PAWN PROM. TO KNIGHT
/     I                                                 5 = PAWN PROM. TO BISHOP
/     I                                                 6 = PAWN PROM. TO ROOK
/     I                                                 7 = PAWN PROM. TO QUEEN
/     I  
/     I  
/     I  
/     I  
/ 
/ = 1 IF THIS MOVE 
/ IS A CAPTURE     


*0000
/INTERRUPT!
IFRM,	0000
	JMP  I	.+1
	INTHAN		/ADDRESS OF THE INTERUPT HANDLER
REV,	ZZZ		/LOC 3 HOLDS PROGRAM REVISION #
ODT4,	0000	/LOCATIONS 4, 5, AND 6 ARE RESERVED FOR DEBUGERS
ODT5,	0000
ODT6,	0000

/ ZERO PAGE CONSTANTS
*11
RANDOM,	0000
XR0,	0000
ITMP0,	0000
ITMP1,	0000		/AUTO-INCREMENT TEMPORARY STORAGE
ITMP2,	0000
CLIST,	KBUF-1		/INPUT BUFFER POINTER
LIST2,	0000
TEMP,	0000		/TEMPORARY STORAGE LOCATIONS
TEMP1,	0000		/	    .
TEMP2,	0000		/	    .
TEMP3,	0000		/	    .
TEMP4,	0000		/	    .
TMP,	0000		/TEMPORARY STORAGE
ZOUT,	OUT		/POINTS TO OUTPUT ROUTINE
CHAR,	0000		/TEMP. STORAGE PLACE FOR A CHARACTER
ZCRLF,	CRLF		/POINTS TO CR-LF PRINTING ROUTINE
XXXX,	0000		/TEMPORARY STORAGE
ZBEGIN,	BEGIN		/POINTS TO INPUT INITIATING ROUTINE
CNTCHR,	0000		/CHARACTER COUNT
ISW,	0000		/INPUT SWITCH
ZGETC,	GETC		/POINTS TO INPUT BUFFER READING ROUTINE
PONDIR,	0001		/PAWN DIRECTION CONSTANT
M1,	0000
M2,	0000
M3,	0000
M4,	0000
GN1,	0000		/COMMON STORAGE FOR THE MOVE GENERATION ROUTINES
GN2,	0000		/		.
GN3,	0000		/		.
GN4,	0000		/		.
GNMSW,	0000		/		.
GNMDW,	0000		/		.
FSTRNK,	7777		/-VALUE OF THE FIRST RANK
ZCHKIO,	CHKIO		/POINTS TO IO STALL ROUTINE
WPSW,	0000		/WHITES POSITION STATUS WORD
BPSW,	0000		/BLACKS POSITION STATUS WORD
CPSW,	0000		/ADDRESS OF CURRENT POSITION STATUS WORD IS KEPT HERE
GMAP,	0000
OMAP,	0000
TOMAK1,	0000		/MOVE SQUARE WORD HERE
TOMAK2,	0000		/MOVE DATA WORD HERE
DIR1,	0000
DIR2,	0000
CNTR1,	0000
WKING,	0000		/ADDRESS OF THE WHITE KING IS STORED HERE
BKING,	0000		/ADDRESS OF THE BLACK KING IS STORED HERE
CKING,	0000		/ADRESS OF THE KING BEING TESTED
TKING,	0000		/TEMP STORAGE FOR KING ADDR
LSTMV,	0000		/LOCATION WHICH DESCRIBES THE LAST MOVE MADE IF DOUBLE PAWN MOVE
ZGNMV,	GNMV		/POINTS TO MOVE GENERATION ROUTINE
ZMKMV,	MKMV		/POINTS TO THE MOVE MAKING ROUTINE
ZUNMV,	UNMV		/POINTS TO THE MOVE UNMAKING ROUTINE
ZMAPEC,	MAPEC		/POINTS TO PIECE MAP ROUTINE
PW,	0000		/SET = TO TOTAL VALUE OF ALL PIECES ON THE BOARD BY 'MAPEC'
WHOSE,	0000		/THIS LOC =0 IF IT IS WHITES MOVE, =-1 IF BLACKS
PCNT,	0000		/USED BY CHKATK =# OF PIECES ATTACKING THE SQUARE
PVAL,	0000		/USED BY CHKATK =LEAST VALUABLE ATTACKER
PSQR,	0000		/USED BY CHKATK =ADDRESS OF THE LEAST VALUABLE ATTACKING PIECE
ZSPLIT,	SPLIT		/POINTS TO A SUBROUTINE WHICH SPLITS UP A MSW
ZTSTCH,	TSTCHK		/POINTS TO CHECK TESTING ROUTINE
ZFNL,	TSTCHK		/POINTS TO FINAL LEGAL MOVE VERIFICATION ROUTINE
GNCNT,	0000		/LOC=NUMBER OF MOVES GENERATED BY GNWMV
TOADR,	0000
IOMDW,	0000		/ARGUMENT STORAGE FOR I/O ROUTINES
IOMSW,	0000		/ARGUMENT STORAGE FOR I/O ROUTINES
CMSW,	0000		/CHECKMATE SWITCH
SMSW,	0000		/STALEMATE SWITCH
COMP,	0000
ZLOOKA,	LOOKA		/POINTS TO THE RECURSIVE LOOKAHEAD SUBROUTINE
UVAL1,	0000
CVAL1,	3777
RVAL1,	0000
MVAL1,	0000		/HOLDS MOBILITY VALUE
PLY,	0000		/HOLDS CURRENT RECURSION LEVEL OF THE "LOOKA" SUBROUTINE
DEPTH,	0003		/HOLDS THE MAXIMUM RECURSION LEVEL FOR THE "LOOKA" SUBROUTINE
RDEPTH,	0000
BUG,	0000
RNKKNT,	0000		/TEMP STORAGE FOR BOARD OUTPRINT & BOARD INPUT ROUTINES
FILKNT,	0
PIECE,	0
COLOR,	0
RNKPTR,	0
MOBMOD,	0000
KNGBLK,	0000		/SET BY "GNMV" TO # OF KING MOVES ILLEGAL BECAUSE OF CHECK
MOB0,	0000
MOB1,	0000
CTNEED,	0000
STRATG,	0000		/HOLDS STRATEGIC VALUE
PC01,	0000		/POINTER FOR PUSH DOWN LIST #1
PDLADR,	0000		/POINTER FOR PUSH DOWN LIST #2
IFNZRO	DEBUG<
ENO,	0000
ENOB,	0000
>
WHOWHI,	0000
WHOBLK,	0000
COMTMP,	0000
BOGUS,	0000
DOMAP,	0000
*200
START,	IFNZRO LPTREE	<
	TAD	(OUT
	DCA	ZOUT	/MAKE SURE OUTPUT GOES TO THE TTY
>
	JMS  I	ZCRLF
	PRINTO;	NAME	/PRINT "CHEKMO-II"
	JMS  I	ZCRLF
	DCA	WHOSE
	JMS	SETBRD	/SETUP THE BOARD
COMPN,	DCA	WHOWHI	/RESET SWITCH FOR THE USER TO PLAY WHITE
	DCA	WHOBLK	/RESET SWITCH FOR THE USER TO PLAY BLACK
COMMAN,	IPDL2		/INITIALIZE PUSH DOWN LISTS
	IPDL1
	ISZ	DOMAP	/MAKE SURE A PIECE MAP IS REALY DONE
	JMS	QMATE	/TEST FOR SIDE TO MOVE IN CHECKMATE OR STALEMATE
	TAD	WHOSE	/GET "WHOSE MOVE" SWITCH
	SPA CLA		/IS IT WHITES OR BLACKS MOVE?
	JMP	BLKMVE	/BLACKS
	PRINTO;	MESG23	/PRINT "W. "
	TAD	WHOWHI	/GET THE "WHO PLAYS WHITE" SWITCH
	SZA CLA		/DOES THE COMPUTER PLAY ON BEHALF OF WHITE?
	JMP	CMOVE	/YES
USER,	PRINTO;	MESG24	/PRINT "YOUR MOVE?"
	JMS  I	ZBEGIN	/SETUP TO ACCEPT A LINE OF INPUT
	ION		/ACCEPT IT ANY TIME NOW
	JMS  I	ZCHKIO	/WAIT FOR IT TO FINISH
	JMS  I	ZGETC	/GET 1ST CHAR
	AND	[0077	/ONLY NEED 6 BITS
	RTL CLL		/MOVE THEM TO THE HIGH ORDER 6 BITS
	RTL		/POSITION
	RTL
	DCA	COMTMP	/STORE FOR A WHILE
	JMS  I	ZGETC	/GET 2ND CHAR
	AND	[0077	/ONLY NEED 6 BITS
	TAD	COMTMP	/WE NOW HAVE THE FIRST 2 INPUT CHARS PACKED
	DCA	COMTMP	/6BIT STYLE IN 1 WORD
	TAD	(COMLST-2/ADDRESS-2 OF THE COMMAND LIST
	DCA	XR0	/TO AUTO INDEX REGISTER
NUTHER,	ISZ	XR0	/INC POINTER TO POINT AT A 6BIT COMMAND IN THE COMMAND LIST
	TAD  I	XR0	/GET A LEGAL 6BIT COMMAND
	SNA		/WERE THERE ANY MORE TO GET?
	JMP	UINP	/NO. THE USER MUST BE TRYING TO ENTER A MOVE
	TAD	COMTMP	/YES. COMPARE WITH THE ONE THE USER JUST INPUTED
	SZA CLA		/IS IT A MATCH?
	JMP	NUTHER	/NO. TRY AGAIN
	TAD  I	XR0	/YES. GET THE TRANSFER ADDRESS
	DCA	TEMP
	JMP  I	TEMP	/TRANSFER

COMPW,	ISZ	WHOWHI	/SET SWITCH TO INDICATE THAT WHITE IS PLAYED 
	JMP	COMMAN	/BY THE COMPUTER

COMPB,	ISZ	WHOBLK	/SET THE SWITCH TO INDICATE THAT BLACK IS PLAYED
	JMP	COMMAN	/BY THE COMPUTER

COMBD,	JMS	DISPLAY	/DISPLAY THE BOARD ON THE TELLETYPE
	JMP	COMMAN

COMIP,	JMS	INPUT	/GET THE INPUT OF A POSITION FROM THE TELLETYPE
	JMP	COMPN

UINP,	JMS  I	ZBEGIN	/REINIT THE KEYBOARD BUFFER POINTER
	JMS	INMV	/WAS A LEGAL MOVE TYPED IN?
	SKP CLA		/NO.
	JMP	COMMAN	/YES. IT WAS ALSO MADE BY THE "INMOVE" SUBROUTINE
	TAD	("?	/PRINT A "?"
	JMS  I	ZOUT	/TO INDICATE THE ERROR
	JMS  I	ZCRLF
	JMP	COMMAN	/TRY AGAIN

BLKMVE,	PRINTO;	MESG22	/BRINT "B. "
	TAD	WHOBLK
	SNA CLA		/DOES THE USER PLAY BLACK, OR DOES THE COMPUTER?
	JMP	USER	/THE USER
CMOVE,	CLA		/COMPUTER NOW MAKES A MOVE
	TAD	(3777	/INITIALIZE SEARCH VALUE TO PREVENT PRUNING AT THE FIRST PLY
	DCA	CVAL1
	DCA	PLY	/MAKE SURE PLY # IS 0 BEFORE ENTERING RECURSIVE EVALUATOR
	IFNZRO	LPTREE<
	TAD	(LPTOUT	/SWITCH OUTPUT DEVICE TO LINE PRINTER
	DCA	ZOUT
	JMS  I	ZCRLF
	JMS	DISPLA	/PRINT THE BOARD AT PLY 0
	JMS	TABPLY
>
	CMA CLA
	TAD	DEPTH	/DO A SHORT "PRE ANALYSIS"
	SNA		/UNLESS WE ARE IN "BLITZ MODE" (DEPTH OF 1)
	JMP	CMOVE1	/WHICH WE ARE
	IAC
	DCA	RDEPTH	/SAVE THE REAL DEPTH
	IAC
	DCA	DEPTH	/SET THE DEPTH TO 1 TEMPORARILY
	JMS  I	ZLOOKA	/FIND OUT WHICH MOVE LOOKS THE BEST
	TAD	RDEPTH
	DCA	DEPTH	/RESTORE THE REAL DEPTH
CMOVE1,	JMS  I	ZLOOKA	/FIGURE OUT WHICH MOVE TO MAKE
	IFNZRO	LPTREE<
	TAD	(OUT	/SWITCH OUTPUT DEV. BACK TO TTY
	DCA	ZOUT
>
	TAD	BESTBL
	DCA	IOMSW
	TAD	BESTBL+1
	DCA	IOMDW
	TAD	BESTBL	/GET THE LAST MOVE TO WIN A COMPARE ON PLY #1
	DCA	TOMAK1	/FROM THE TABLE OF BEST MOVES
	TAD	BESTBL+1
	DCA	TOMAK2
	JMS  I	ZMKMV	/MAKE THE MOVE
	JMS	OUTMV	/PRINT OUT THE MOVE JUST MADE
	JMS	GNMVSM	/GENERATE MOVES FOR THE SIDE TO MOVE
	TAD	GNCHEK	/GET # OF ATTACKS ON THE KING
	SZA CLA		/IS THE SIDE TO MOVE IN CHECK?
	TAD	("+	/YES. PRINT A "+" TO INDICATE IT
	JMS  I	ZOUT
	JMS  I	ZCRLF
	JMP	COMMAN

PAGE
/THIS SUBROUTINE GENERATES ALL MOVES FOR A SIDE
/AND STICKS THEM INTO PDL2.
/THIS SUBROUTINE IN ADDITION...
/SETS "GNCNT" TO THE # OF MOVES GENERATED
/SETS "CMSW" TO A NON-ZERO VALUE IF NO MOVES CAN BE GENERATED BECAUSE OF CHECKMATE
/SETS "SMSW" TO A NON-ZERO VALUE IF NO MOVES CAN BE GENERATED BECAUSE OF STALEMATE
/SETS "GNCHEK" TO THE NUMBER OF PIECES ATTACKING THE KING IF THE KING IS IN CHECK
/SETS "KNGBLK" TO THE NUMBER OF ADJACENT SQUARES THE KING CANNOT MOVE
/INTO BECAUSE THAT WOULD PUT HIM IN CHECK
/SETS "MOBMOD" TO THE MOVING SIDES MOBILITY VALUE, BASED ON "GNCNT" AND
/THE NUMBER OF MOVES THAT ARE ILLEGAL BECAUSE THEY DO NOT
/GET THE KING OUT OF CHECK, BUT ARE OTHERWISE LEGAL, MINUS
/50% OF THE TOTAL # OF QUEEN MOVES.
/IF THIS ROUTINE IS CALLED WITH "BOGUS" SET TO A NON-ZERO VALUE
/THIS SUBROUTINE WILL NOT PUT ANY MOVES IN PDL#2 OR TRY TO GENERATE
/EN PASSANT PAWN CAPTURES
/THIS SUBROUTINE SETS BOGUS TO ZERO BEFORE RETURNING
GNMV,	0000
	CLL CLA
	DCA	MOBMOD	/INITIALIZE THE MOBMOD COUNTER
	DCA	KNGBLK	/INITIALIZE THE BLOCKED KING MOVE COUNTER
	DCA	CMSW	/INITIALIZE CHECKMATE SWITCH TO = NO CHECKMATE
	DCA	SMSW	/INITIALIZE STALEMATE SWITCH TO = NO STALEMATE
	DCA	QMVCNT	/INIT QUEEN MOVE COUNTER
	TAD	CKING	/TEST FOR KING IN CHECK
	DCA	TEMP
	JMS	CHKATK	/CALL W/AC CLEAR---FIND ALL ATTACKS ON THE KING
	TAD	PCNT	/GET # OF ATTACKS
	DCA	GNCHEK	/SAVE THE # OF ATTACKS ON THE KING
	DCA	GNCNT	/INITIALIZE GENERATION COUNT = 0
	TAD	BOGUS
	SZA CLA		/ARE WE GOING TO BE PUTTING MOVES IN PDL#2?
	JMP	.+3	/NO. NO NEED FOR MARKERS THEN
	PUSH2		/YES. FIRST THING TO DO IS PUSH 2 BLANK WORDS
	PUSH2		/TO MARK LIST PLACE
	TAD	CKING	/SETUP TO GENERATE KING MOVES
	DCA	CNTR1
	TAD	CNTR1	/SPLIT THE KINGS SQUARES ADDR UP INTO RANK AND FILE #'S
	AND	[0007
	DCA	GN2	/STORE THE FILE #
	TAD	CNTR1
	RTR
	RAR
	AND	[0007
	DCA	GN1	/STORE THE RANK #
	JMS	GKM	/GENERATE THOSE KING MOVES
	TAD	GNCHEK	/GET THE NUMBER OF PIECES PRESENTLY CHECKING THE KING
	RAR CLL		/NO COMMENT
	SZA CLA		/IS THE KING IN DOUBLE CHECK?
	JMP	TSCMSM	/YES. NO USE TRYING TO GENERATE MOVES BY OTHER PIECES
	TAD	BOGUS	/NO.
	SNA CLA		/IS THIS FOR REAL?
	JMS	GNEP	/YES. GENERATE ANY POSIBLE 'EN PASSANT' PAWN CAPTURES NOW
	TAD	GMAP	/ADDRESS-1 OF MAP
	DCA	ITMP2	/STORE IT
NXTSQR,	CLL CLA
	TAD  I	ITMP2	/GET THE ADDRESS OF THE NEXT PIECE
	SNA		/IS IT REALY A PIECE?
	JMP	TSCMSM	/NO. MOVES ARE ALL GENERATED.
	DCA	CNTR1	/YES. STORE ITS ADDRESS
	IAC
	DCA	CTNEED	/INITIALIZE THE CHECK TEST NEED SWITCH
	TAD	CNTR1	/NOW STRIP RANK AND FILE NUMBERS FROM THE ADDRESS
	AND	[0007
	DCA	GN2	/STORE THE FILE NUMBER
	TAD	CNTR1
	RTR
	RAR
	AND	[0007
	DCA	GN1	/STORE THE RANK NUMBER
	TAD  I	CNTR1	/GET THE VALUE OF THE PIECE ON THE SQUARE
	JMS	CLRFIX
	TAD	[-PAWN
	SNA		/IS IT A PAWN?
	JMP	GPM	/YES
	TAD	(PAWN-KNIGHT
	SNA		/IS IT A KNIGHT?
	JMP	GNM	/YES
	TAD	(KNIGHT-BISHOP
	SNA		/IS IT A BISHOP?
	JMP	GBM	/YES
	TAD	(BISHOP-ROOK
	SNA		/IS IT A ROOK?
	JMP	GRM	/YES
	TAD	(ROOK-KING
	SNA		/IS IT A KING?
	JMP	NXTSQR	/YES. TRY NEXT PIECE SINCE KING MOVES HAVE ALLREADY BEEN GENERATED
	TAD	(KING-QUEEN
	SNA		/IS IT A QUEEN?
	JMP	GQM	/YES
	HLT		/NO. SOMTHINGS WRONG HERE !

QMVCNT,	0000
GNCHEK,	0000

TSCMSM,	TAD	QMVCNT	/ADD # OF QUEEN MOVES & QUEEN MOVE REJECTS
	CLL RAR		/DIVIDE BY 2
	TAD	QMVCNT
	CLL RAR		/AC WIL EQUAL 3/4 OF THE # OF QUEEN MOVES & REJECTS
	CIA		/SUBTRACT
	TAD	MOBMOD	/FROM THE MOBILITY MODIFIER
	TAD	GNCNT	/ADD "REAL" MOBILITY IN WITH THE MOBILITY MODIFIER
	DCA	MOBMOD
	DCA	BOGUS
	TAD	GNCNT	/GET # OF MOVES GENERATED
	SZA CLA		/ANY?
	JMP  I	GNMV	/YES: RETURN
	TAD	GNCHEK	/NO. ITS EITHER A CHECKMATE OR STALEMATE POSITION
	SNA		/WAS THE KING IN CHECK?
	ISZ	SMSW	/NO. SET THE STALEMATE SWITCH
	DCA	CMSW	/IF KING WAS IN CHECK (GNCHEK>=1) SET THE CHECKMATE SWITCH
	JMP  I	GNMV	/RETURN

IFNZRO	DEBUG<
/ROUTINE TO ALLOW THE TIMING OF THE "GNMV" SUBROUTINE
/CALLS IT 4000(OCTAL) TIMES, THEN HALTS
TIME,	IPDL2
	IPDL1
	JMS	GNWMV
	ISZ	.+2
	JMP	.-4
	4000		/# OF ITTERATIONS OF THE TIMING LOOP
	HLT
>

/  SNO -- SKIP NO OVERFLOW
/PSEUDO-INSTRUCTION TO TEST FOR RANK OR FILE OVERFLOW.
/EFFECTIVLY SKIPS IF NO OVERFLOW. CALL WITH RANK OR FILE
/NUMBER IN AC. RETURN WITH NUMBER IN AC IF NO OVERFLOW, GARBAGE OTHERWISE
RFOFL,	0000
	SPA		/LESS THAN ZERO?
	JMP  I	RFOFL	/YES. RETURN
	RTR		/SHIFT BIT 8 INTO LINK
	RTR		/IF IT'S SET OVERFLOW HAS OCCURED
	SZL		/GREATER THAN 7?
	JMP  I	RFOFL	/YES. RETURN (WITH A GARBLED ACCUMULATOR)
	RTL
	RTL		/SHIFT THE WORD BACK TO NORMAL
	ISZ	RFOFL	/INC RETURN ADDRESS
	JMP  I	RFOFL	/RETURN
PAGE

/THIS ROUTINE GENERATES ALL THE MOVES OF A 'STRAIGHT LINE' MOVING
/PIECE. ITMP0 MUST BE PRESET TO THE ADDRESS-1 OF THE MOVE GENERATION
/DIRECTION LIST. LCNT MUST BE SET TO MINUS THE NUMBER OF 2-WORD
/ENTRIES IN THAT LIST
LINE,	CLA
	TAD  I	ITMP0	/GET THE VERTICAL DIRECTION
	DCA 	DIR1	/SAVE IT
	TAD  I	ITMP0	/GET THE HORIZINTAL DIRECTION
	DCA 	DIR2	/SAVE THAT ALSO
	TAD	GN1
	DCA	GN3
	TAD	GN2
	DCA	GN4
LINEM,	TAD	GN3	/BUILD SQUARE RANK NUMBER
	TAD	DIR1
	SNO		/IS THAT RANK REALY ON THE BOARD?
	JMP	XXOX	/NO. IT DOES NOT EXIST
	DCA	GN3
	TAD	DIR2
	TAD	GN4
	JMS	XYZ
	JMP	XXOX
	TAD  I	CNTR1	/GET VALUE OF THE MOVING PIECE
	JMS	CLRFIX
	TAD	(-QUEEN
	SNA CLA		/ARE WE TESTING FOR A LEGAL QUEEN MOVE?
	ISZ	QMVCNT	/YES. INC QUEEN MOVE COUNTER
	TAD	GNMSW
	JMS  I	ZFNL	/DO FINAL TEST FOR KING CHECK
	JMP	XOOO	/MOVE ILLEGAL: KING IS IN CHECK
	TAD  I	TOADR	/GET VALUE OF THE 'TO' SQUARE
	SZA CLA		/IS THE MOVE A CAPTURE?
	STL RAR		/YES: SET CAPTURE BIT
	DCA	GNMDW
	JMS	GNSTR	/PUSH THE MOVE INTO THE STACK
XOOO,	TAD  I	TOADR	/GET THE VALUE OF THE PIECE ON THE 'TO SQUARE'
	SNA CLA		/WAS THE MOVE A CAPTURE?
	JMP	LINEM	/NO. COULD BE MORE MOVES IN THIS DIRECTION
XXOX,	CLA		/YES. NO MORE MOVES IN THIS DIRECTION
	ISZ	LCNT	/DONE ALL DIRECTIONS?
	JMP	LINE	/NO. TRY ANOTHER
	JMP	NXTSQR	/YES. DONE WITH THIS PIECE. TRY NEXT
LCNT,	0000

/ROUTINE TO STORE THE MSW AND MDW IN THE PDL
GNSTR,	0000
	ISZ	GNCNT	/INC GENERATION COUNT
	CLA
	TAD	BOGUS
	SZA CLA		/SHOULD THESE MOVES GO INTO PDL#2?
	JMP  I	GNSTR	/NO. DONT PUT ANY THERE!
	TAD	GNMSW	/GET MSW
	PUSH2		/PUSH IT INTO THE LIST
	TAD	GNMDW	/GET THE MDW
	PUSH2		/PUSH IT INTO LIST
	JMP  I	GNSTR	/RETURN

/SUBROUTINE TO TEST IF THE 'TO' SQUARE IS OCCUPIED BY OWN PIECE
/IF NOT SKIP FOR RETURN AND BUILD MSW
XYZ,	0000
	SNO		/DID IT GO OFF THE BOARD?
	JMP  I	XYZ	/YES: RETURN
	DCA	GN4	/NO: SAVE THIS HALF
	JMS	BLDTO	/BUILD 'TO' ADDR
	TAD  I	TOADR	/GET VALUE OF THE 'TO' SQUARE
	JMS	CLRFIX
	SMA SZA CLA	/OCCUPIED BY OWN PIECE?
	JMP  I	XYZ	/YES: RETURN
	JMS	BLDMSW	/NO: BUILD THE MSW
	ISZ	XYZ	/INC RETURN ADDR
	JMP  I	XYZ	/RETURN

GQM,	CLA		/GENERATE QUEEN MOVES
	TAD	[-10 	/DO ALL DIRECTIONS
	DCA	LCNT
	TAD	(OTRX-1	/DIAGONAL  AND  ORTHOGONAL
	DCA	ITMP0
	JMP	LINE

GRM,	CLA		/GENERATE ROOK MOVES
	TAD	(-4	/DO ONLY HALF OF THE DIRECTIONS
	DCA	LCNT
	TAD	(OTR-1	/THE ORTHOGONAL ONES
	DCA	ITMP0
	JMP	LINE

GBM,	CLA		/GENERATE BISHOP MOVES
	TAD	(-4	/DO ONLY HALF OF THE DIRECTIONS
	DCA	LCNT
	TAD	(OTRX-1	/THE DIAGONAL ONES
	DCA	ITMP0
	JMP	LINE

/SUBROUTINE TO BUILD AN MSW. CALL WITH ADDRESS OF THE 'TO SQUARE' IN LOCATION
/'TOADR', AND THE LOCATION OF THE 'FROM SQUARE IN LOCATION "CNTR1". RETURN WITH THE
/NEW MSW IN LOCATION 'GNMSW
BLDMSW,	0000
	CLA
	TAD	TOADR
	AND	[0077	/STRIP THE 'TO SQUARE' ADDRESS DOWN INTO 6BIT
	DCA	GNMSW	/STORE IT TEMPORARILY
	TAD	CNTR1
	AND	[0077	/DO THE SAME FOR THE 'FROM SQUARE' ADDRESS
	RTL CLL		/BUT INSTEAD OF STORING IT,  ROTATE IT INTO BITS 0-5
	RTL
	RTL
	TAD	GNMSW	/NOW PACK THE 6BIT 'TO SQUARE' ADDRESS IN WITH IT
	DCA	GNMSW	/STORE AWAY THE NEW MSW
	JMP  I	BLDMSW	/RETURN

PUSHIT,	0000		/PUSH ROUTINE
	DCA  I	PDLADR	/PUT NEW ITEM ON TOP
	ISZ	PDLADR	/PUSH
	JMS	OFLOW	/TEST FOR LIST OVERLAP
	JMP  I	PUSHIT	/RETURN

POPIT,	0000		/POP ROUTINE
	CLA CMA
	TAD	PDLADR	/MOVE LIST POINTER DOWN
	SMA		/MAKE SURE LIST DOESN'T GO WILD
	HLT		/IT DID! MANY EXTRA POPS
	DCA	PDLADR
	TAD  I	PDLADR	/GRAB THE TOP WORD
	JMP  I	POPIT	/RETURN WITH IT

PUSH01,	0000
	DCA  I	PC01	/PUT NEW ITEM ON TOP
	CMA
	TAD	PC01
	DCA	PC01	/PUSH IT DOWN
	JMS	OFLOW	/TEST FOR PDL OVERFLOW
	JMP  I	PUSH01	/RETURN

POP01,	0000
	ISZ	PC01	/MOVE THE LIST POINTER DOWN
	SKP CLA
	HLT		/LOTS OF EXTRA POPS
	TAD  I	PC01	/GRAB THE WORD ON TOP
	JMP  I	POP01	/RETURN WITH IT

PAGE
/ROUTINE TO GENERATE ALL MOVES OF A KING OR KNIGHT
/CALLED WITH THE MOVE GENERATION LIST ADDRESS-1 IN AC
SNGMV,	0000
	DCA	ITMP0	/STORE THE ADDRESS OF THE LIST
	TAD	[7770
	DCA	SCNT	/THERE ARE 8 DIRECTIONS
	DCA	GNMDW	/INITIALIZE THE MDW
	TAD	GN1
	TAD  I	ITMP0
	SNO		/OFF THE BOARD
	JMP	XXXO-1	/YES TRY ANOTHER DIRECTION
	DCA	GN3
	TAD	GN2
	TAD  I	ITMP0
	JMS	XYZ
	JMP	XXXO
	TAD  I	CNTR1	/GET VALUE OF THE MOVING PIECE
	JMS	CLRFIX
	TAD	(-KING
	SZA CLA		/IS IT A KING?
	JMP	SNGKNT	/NO: ITS A KNIGHT
	TAD	GNMSW	/YES
	JMS	MMOVE	/MAKE THE KING MOVE
	TAD	TOADR
	DCA	TEMP	/TEST FOR AN ATTACK ON THE KINGS NEW SQUARE
	IAC		/AND RETURN AFTER THE FIRST ATTACK IS FOUND
	JMS	CHKATK
	JMS	UMOVE	/UNMAKE THE MOVE
	TAD	PCNT	/NOW WORRY ABOUT LEGAL OR ILLEGAL
	SNA CLA		/WAS THE KING IN CHECK?
	JMP	SNGLGL	/NO. MOVE IS LEGAL
	ISZ	KNGBLK	/YES. INC BLOCKED KING MOVE COUNTER
	JMP	XXXO	/GO TO THE ILLEGAL PLACE
SNGKNT,	TAD	GNMSW
	JMS  I	ZFNL	/DO FINAL CHECK
	JMP	XXXO	/KING IS ATTACKED: KNIGHT MOVE NO GOOD
SNGLGL,	TAD  I	TOADR	/GET VALUE OF THE 'TO' SQUARE
	SZA CLA		/IS THE MOVE A CAPTURE?
	CLA STL RAR	/YES: SET CAPTURE BIT
	TAD	GNMDW
	DCA	GNMDW	/STORE MDW AGAIN
	JMS	GNSTR	/PUSH MOVE INTO LIST
	SKP
	ISZ	ITMP0	/FAILED ON FIRST LIST ELEMENT. PASS OVER SECOND
XXXO,	CLA
	ISZ	SCNT	/TESTED ALL DIRECTIONS?
	JMP	SNGMV+4	/NO. TRY THE NEXT ONE
	JMP  I	SNGMV	/YES. RETURN

SCNT,	0000		/DIRECTION COUNTER


GPM,	CLA		/GENERATE THE MOVES OF A PAWN
	DCA	GNMDW
	TAD	GN2
	DCA	GN4
	TAD	GN1
	JMS	PST
	JMP	GPM1	/MOVING 1 FORWARD BLOCKED: FORGET 2
	TAD	GN1	/MOVING 1 FORWARD IS NOT BLOCKED. NOW TEST FOR 2
	TAD	FSTRNK
	SZA CLA
	JMP	GPM1	/NOT THIS PAWNS FIRST MOVE. CAN'T MOVE 2
	CLA STL RTR
	DCA	GNMDW	/SETUP MDW TO INDICATE DOUBLE PAWN MOVE(TEMPORARY INDICATION)
	TAD	GN3
	JMS	PST
	NOP		/MUST BE HERE CAUSE "PST" SUBROUTINE SOMETIMES RETURNS TO ADDRESS+2 OF THE CALLING JMS
GPM1,	CLA		/NOW TEST CAPTURES
	TAD	GN1
	TAD	PONDIR
	DCA	GN3
	IAC
	TAD	GN2
	DCA	GN4
	TAD	GN4
	AND	[7770
	SZA CLA		/CAN IT CAPTURE TO THE HIGH SIDE?
	JMP	.+2	/NO. IT WAS ON THE EDGE OF THE HIGH SIDE
	JMS	CAPTST
	CLA CMA
	TAD	GN2
	SPA		/CAN IT CAPTURE TO THE LOW SIDE?
	JMP	.+3	/NO. IT WAS ON THE LOW EDGE
	DCA	GN4
	JMS	CAPTST
	JMP	NXTSQR
/FOLLOWING ARE THE MOVE GENERATION DIRECTION LISTS
OTRX,	1		/BISHOP MOVE DIRECTION LIST
	-1

	1
	1

	-1
	-1

	-1
	1

OTR,	1		/ROOK MOVE DIRECTION LIST
	0

	0
	-1

	0
	1

	-1
	0

KNLST,	2		/KNIGHT MOVE DIRECTION LIST
	-1

	2
	1

	1
	2

	-1
	2

	-2
	1

	-2
	-1

	-1
	-2

	1
	-2

PAGE
/GENERATE KING MOVES
GKM,	0000
			/FIRST TRY CASTLING
	IAC CLA		/SETUP MDW TO INDICATE CASTLING
	DCA	GNMDW
	TAD	PONDIR	/BUILD THE ADDRESS OF THE KINGS ORIGINAL SQUARE
	AND	(0070
	TAD	(BOARD+4/KING IS ON FILE E
	DCA	TEMP	/STORE THE ADDRESS OF THE KINGS ORIGINAL SQUARE
	TAD  I	TEMP	/GET THE VALUE OF THE PIECE ON IT
	JMS	CLRFIX
	TAD	(-KING
	SNA CLA		/IS IT A KING?
	JMP	GKM2	/YES
	TAD  I	CPSW	/NO. MAKE 'CPSW' REFLECT THIS
	AND	[0007	/SAVE BITS 9-11 IN CASE HE IS CASTLED
	TAD	(3000	/SET THE "NO MORE CASTLING" BITS
	DCA  I	CPSW	/NO MORE CASTLING
	JMP	GKM1	/BUT NORMAL KING MOVES ARE OK. GENERATE THEM NOW
GKM2,	TAD	TEMP	/CHANGE 'TEMP' TO EQUAL THE ADDRESS OF THE QUEENS ROOK
	AND	[7770	/BY CHANGING THE FILE TO A
	DCA	TEMP	/STORE ADDRESS OF QUEENS ROOK
	TAD  I	CPSW
	RTL		/MOVE 'QUEEN ROOK BIT' INTO AC0
	SPA CLA		/IF ITS SET THE QUEENS ROOK HAS MOVED
	JMP	CAKR	/QUEENS ROOK HAS MOVED ALLREADY: TRY KING SIDE CASTLING
	TAD  I	TEMP	/GET VALUE OF PIECE ON A1(A8)
	JMS	CLRFIX
	TAD	(-ROOK
	SNA CLA		/IS IT A ROOK?
	JMP	.+5	/YES. CONTINUE
	TAD	(1000	/NO. 'QUEEN ROOK BIT' LIED
	TAD  I	CPSW	/CHANGE IT TO GIVE A TRUE INDICATION
	DCA  I	CPSW	/NO MARE CASTLING WITH THE QUEENS ROOK
	JMP	CAKR	/AND TRY KING-SIDE CASTLING
	TAD	GNCHEK	/FIND OUT IF THE KING IS IN CHECK
	SZA CLA		/IS THE KING IN CHECK
	JMP	CAKR	/YES. GO SEE IF THE KINGS ROOK HAS MOVED
	ISZ	TEMP	/NO. INC 'TEMP' SO THAT IT EQUALS THE ADDRESS OF B1(B8)
	TAD  I	TEMP	/GET THE VALUE OF THE SQUARE
	SZA CLA		/IS IT EMPTY?
	JMP	CAKR	/NO. TRY KING-SIDE CASTLING
	ISZ	TEMP	/INC 'TEMP' SO THAT IT EQUALS THE ADDRESS OF C1(C8)
	TAD  I	TEMP	/GET THE VALUE OF THE SQUARE
	SZA CLA		/IS IT EMPTY?
	JMP	CAKR	/NO. TRY KING-SIDE CASTLING
	JMS	CHKATK	/CHECK FOR AN ATTACK ON THAT SQUARE BY AN ENEMY PIECE
	TAD	PCNT	/GET # OF ATTACKS
	SZA CLA		/ANY?
	JMP	CAKR	/YES. Q-SIDE CASTLING ILLEGAL, TRY K-SIDE
	ISZ	TEMP	/INC 'TEMP' TO EQUAL ADDRESS OF D1(D8)
	TAD  I	TEMP	/GET THE SQUARES VALUE
	SZA CLA		/IS IT OCCUPIED?
	JMP	CAKR	/YES. TRY K-SIDE CASTLING INSTEAD
	JMS	CHKATK	/CHECK FOR ATTACKS ON SQUARE D1(D8)
	TAD	PCNT	/GET # OF ATTACKS
	SZA CLA		/ARE THERE ANY?
	JMP	CAKR	/YES. TRY K-SIDE CASTLING
	TAD	PONDIR	/NO. QUEEN SIDE CASTLING IS LEGAL!!
	AND	(7070	/BUILD AN MSW FOR QUEEN SIDE CASTLING
	TAD	(0402
	DCA	GNMSW	/STORE THE NEW MSW
	JMS	GNSTR	/PUSH THE MOVE ONTO PDL2
CAKR,	CLA
	TAD  I	CPSW	/TRY TO GENERATE A KING SIDE CASTLING MOVE
	RAL		/MOVE 'KING ROOK BIT' OF THE PSW INTO AC0
	SPA CLA		/IS IT SET?
	JMP	GKM1	/YES. KINGS ROOK HAS ALLREADY MOVED
	TAD	TEMP	/NO. BUILD ADDRESS OF THE KINGS ROOK
	AND	[7770
	TAD	[0007
	DCA	TEMP
	TAD  I	TEMP	/GET THE VALUE OF THE PIECE ON H1(H8)
	JMS	CLRFIX
	TAD	(-ROOK
	SNA CLA		/IS IT A ROOK?
	JMP	.+5	/YES CONTINUE
	CLA STL RTR	/NO. 'KING ROOK BIT' LIED: FIX IT
	TAD  I	CPSW
	DCA  I	CPSW
	JMP	GKM1	/GO TRY PROPER STYLE KING MOVES
	TAD	GNCHEK	/TEST FOR KING IN CHECK
	SZA CLA		/IS THEKING IN CHECK?
	JMP	GKM1	/YES. GO TRY REGULAR STYLE KING MOVES
	TAD	TEMP	/NO. CONTINUE TRYING FOR KING SIDE CASTLING
	TAD	(-2
	DCA	TEMP	/SET 'TEMP' = THE ADDRESS OF SQUARE E1(E8)
	JMS	CAKR1	/TEST TO SEE IF THE SQUARE IS OCUPIED OR ATTACKED
	ISZ	TEMP	/NO. INC 'TEMP' TO EQUAL THE ADDRESS OF F1(F8)
	JMS	CAKR1	/TEST THE SQUARE FOR OCCUPATION OR ATTACKS
	TAD	PONDIR	/NO. BUILD AN MSW CAUSE KING SIDE CASTLING IS LEGAL!!
	AND	(7070
	TAD	(0406
	DCA	GNMSW
	ISZ	GNMDW	/INC MDW SO THAT IT INDICATES KING SIDE CASTLING
	JMS	GNSTR	/STORE THE MOVE IN PDL2
GKM1,	CLA
	TAD	(OTRX-1	/NOW GENERATE 'NORMAL' KING MOVES
	JMS	SNGMV
	JMP  I	GKM	/RETURN

CAKR1,	0000
	TAD  I	TEMP	/GET THE VALUE OF THE SQUARE
	SZA CLA		/IS THERE A PIECE ON IT?
	JMP	GKM1	/YES. MOVE ON TO NORMAL KING MOVES
	JMS	CHKATK	/NO. TEST FOR ATTACKS ON THAT SQUARE BY ENEMY PIECES
	TAD	PCNT	/GET # OF ATTACKS
	SZA CLA		/ANY?
	JMP	GKM1	/YES.
	JMP  I	CAKR1	/RETURN

GNM,	CLA		/GENERATE KNIGHT MOVES
	TAD	(KNLST-1/GET ADDRESS OF THE KNIGHT MOVE GENERATION LIST
	JMS	SNGMV
	JMP	NXTSQR
PAGE
/SUBROUTINE TO BUILD A 'TO SQUARE' ADDRESS
/RETURN WITH ADDRESS IN LOC 'TOADR'
BLDTO,	0000
	TAD	GN3	/GET RANK # AND ROTATE IT
	RTL CLL		/INTO ITS PROPER PLACE(BITS 6-8)
	RAL
	TAD	GN4	/ADD IN THE FILE #
	TAD	[BOARD	/ADD IN BOARD ADDRESS CONSTANT
	DCA	TOADR	/STORE THE ADDRESS
	JMP  I	BLDTO	/RETURN


/SUBROUTINE TO FIX THE COLOR PROBLEM, AND ALLOW ANY SUBROUTINE
/TO WORK WITH BLACK PIECES AS WELL AS WHITE PIECES
CLRFIX,	0000
COLR,	HLT		/=NOP FOR WHITE, =CIA FOR BLACK
	JMP  I	CLRFIX	/RETURN
/SUBROUTINE TO GENERATE 'EN PASSANT' PAWN CAPTURES
/IF PAWNS MYSTERYOUSLY CHANGE COLOR, THIS ROUTINE IS THE LIKLEY SUSPECT
GNEP,	0000
	CMA CLA		/-1 TO THE AC
	DCA	CTNEED	/ALWAYS TEST FOR KING IN CHECK
	TAD	LSTMV	/GET SOME INFORMATION ON THE LAST MOVE MADE
	AND	(0770	/ISOLATE THE 'DOUBLE PAWN MOVE' INFO
	SNA		/WAS THE LAST MOVE MADE A DOUBLE PAWN MOVE?
	JMP  I	GNEP	/NO. 'EN PASSANT' CAPTURES ARE NOT POSIBLE. RETURN
	RTR CLL		/YES. ROTATE THE INFO(6BIT 'TO ADDRESS') INTO BITS 6-11
	RAR
	TAD	[BOARD	/ADD IN BOARD ADDRESS CONSTANT
	DCA	CNTR1	/STORE THE ADDRESS OF THE CAPTURED PAWN
	TAD	CNTR1
	DCA	GNEPTM	/STORE THE ADDRESS OF THE CAPTURED PAWN
	DCA  I	GNEPTM	/TAKE THE PAWN OFF THE BOARD NOW FOR CONVIENIENCE
	TAD	CNTR1	/BUILD A 'TO RANK' THEN A 'TO ADDRESS'
	RTR CLL		/FIRST ROTATE THE OLD 'TO RANK' INTO BITS 9-11
	RAR
	AND	[0007
	TAD	PONDIR	/NEW 'TO RANK' IS 1 MOVE GREATER THAN THE OLD ONE
	RTL CLL		/ROTATE THE 'TO RANK' BACK INTO PLACE AGAIN
	RAL
	DCA	GNMDW	/STORE IT TEMPORARILY
	TAD	CNTR1	/GET THE ADDRESS OF THE PAWN BEING CAPTURED
	AND	(7707	/CLEAR OUT ROOM FOR THE NEW 'TO RANK'
	TAD	GNMDW	/ADD THE NEW 'TO RANK' IN
	DCA	TOADR	/STORE THE 'TO SQUARE' ADDRESS
	TAD	(4003	/4003 IS THE MDW REPRESENTING AN 'EN PASSANT' CAPTURE
	DCA	GNMDW	/STORE THE NEW MDW
	ISZ	CNTR1	/TRY THE ADDJACENT FILE ON THE HIGH SIDE FIRST
	TAD	CNTR1
	AND	[0007
	SNA CLA		/IS THERE REALY A FILE ON THAT SIDE?
	JMP	GNOTF	/NO. TRY THE OTHER SIDE
	TAD  I	CNTR1	/GET THE VALUE OF THE PIECE ON THE SQUARE
	JMS	CLRFIX
	TAD	[-PAWN
	SZA CLA		/IS IT A PAWN?
	JMP	GNOTF	/NO. TRY THE OTHER ADDJACENT FILE
	JMS	BLDMSW	/YES. MOVE SEEMS OK. BUILD AN MSW FOR IT
	TAD	GNMSW	/LOAD THE MSW INTO THE AC
	JMS  I	ZTSTCH	/TEST IF THE MOVE IS ILLEGAL BY VIRTUE OF KING IN CHECK
	SKP		/IT IS ILLEGAL DONT STORE IT IN THE PUSH DOWN LIST
	JMS	GNSTR	/MOVE IS LEGAL STORE IT IN PDL2
GNOTF,	CLA
	TAD	CNTR1	/GET THE 'FROM SQUARE ADDRESS'
	TAD	(-2	/CHANGE IT TO POINT TO THE  ADDJACENT FILE ON THE OTHER SIDE
	DCA	CNTR1
	TAD	GNEPTM	/NOW TEST IF THAT FILE REALY EXISTS
	AND	[0007	/IF THE FILE IS 0 WE'RE ON THE EDGE
	SNA CLA		/DOES THE FILE REALY EXIST, OR IS THE PAWN ON THE EDGE OF THE BOARD
	JMP	GNEPDN	/DOES NOT EXIST!
	TAD  I	CNTR1	/GET THE VALUE OF THE PIECE ON THAT SQUARE
	JMS	CLRFIX
	TAD	[-PAWN
	SZA CLA		/IS IT A PAWN?
	JMP	GNEPDN	/NO
	JMS	BLDMSW	/YES. BUILD AN MSW
	TAD	GNMSW
	JMS I	ZTSTCH	/IS THE KING IN CHECK IF THAT MOVE IS MADE
	SKP		/YES. DONT STORE THE MOVE IN THE PDL
	JMS	GNSTR	/NO. STORE THE MOVE IN PDL2
GNEPDN,	TAD	[-PAWN
	JMS	CLRFIX
	DCA  I	GNEPTM	/REPLACE THE PAWN THAT WAS REMOVED EARLIER
	JMP  I	GNEP	/RETURN
GNEPTM,	0000		/LOCATION FOR STORAGE OF THE CAPTURED PAWNS ADDRESS

/SUBROUTINE TO MAP THE PIECES IF NECCESARY(IF DOMAP=-1).
/MAP IS IN TWO PARTS, 1 FOR EACH COLOR
/WHITE MAP STARTS AT LOC 7400. BLACK MAP STARTS AT LOC 7424.
/MAP FORMAT-- 1 WORD PER PIECE, REPRESENTING THE ADDRESS OF THAT PIECE
MAPEC,	0000
	CLA CMA
	TAD	[BOARD	/SETUP BOARD ADDRESS
	DCA	ITMP2
	TAD	DOMAP
	SNA CLA		/IS A MAP REALY NECCESARY?
	JMP  I	MAPEC	/NO. RETURN
	DCA	DOMAP
	TAD	(MAP-1	/YES. SETUP MAP OF WHITES PIECE ADDRESSES
	DCA	ITMP0
	TAD	(MAP+23	/SETUP MAP OF BLACK PIECE ADDRESSES
	DCA	ITMP1
	TAD	(-100	/SETUP COUNT FOR 100(OCTAL) SQUARES ON THE BOARD
	DCA	TEMP4
	TAD  I	ITMP2	/GET VALUE OF THE PIECE ON THE SQUARE
	SZA		/IS SQUARE OCCUPIED?
	JMP	MAPOC	/YES
MAPGO,	ISZ	TEMP4	/FINISHED BOARD YET?
	JMP	.-4	/NO. DO MORE SQUARES
	DCA  I	ITMP0	/YES. PUT A 0000 AT THE END OF THE WHITE MAP
	DCA  I	ITMP1	/ALSO AT THE END OF THE BLACK MAP
	JMP  I	MAPEC	/RETURN
MAPOC,	SPA		/IS IT WHITE OR BLACK?
	JMP	MAPOCB	/ITS BLACK
	TAD	(-KING	/ITS WHITE. IS IT A KING?
	SZA CLA
	JMP	.+3	/NO
	TAD	ITMP2	/YES
	DCA	WKING	/STORE ADDRESS OF THE WHITE KING
	TAD	ITMP2
	DCA  I	ITMP0	/PUT IT IN THE WHITE MAP WHATEVER IT IS
	JMP	MAPGO
MAPOCB,	TAD	(KING	/IS IT THE BLACK KING?
	SZA CLA
	JMP	.+3	/NO. PROCEDE NORMALY
	TAD	ITMP2	/YES, GET ITS ADDRESS
	DCA	BKING	/STORE IT
	TAD	ITMP2	/GET THE ADDRESS
	DCA  I	ITMP1	/EITHER WAY, PUT IT IN THE BLACK MAP
	JMP	MAPGO
PAGE
/SUBROUTINE TO CHECK FOR A 'DOUBLE PAWN MOVE', AND MODIFY THE
/MDW IF IT IS. ALSO TEST IF A LEGAL PAWN MOVE IS ALSO A PROMOTING MOVE
/APPROPRIATE ACTION IS TAKEN IF IT IS. IN ANY CASE THIS ROUTINE CALLS
/'GNSTR' TO STORE MSW & MDW IN PDL2
PROMCK,	0000
	CLA
	TAD	GNMDW	/GET THE MOVE DATA WORD
	RTL		/ROTATE AC BIT 1 INTO THE LINK
	SZL CLA		/DOES IT SAY 'DOUBLE PAWN MOVE'?
	JMP	PROM1	/YES. SET THE MDW TO SHOW IT
	TAD	GN3	/BUILD THE RANK OF THE PAWN, IF IT WERE TO BE
	TAD	PONDIR	/MOVED ONE MORE TIME
	SNO		/IS IT STILL ON THE BOARD?
	SKP CLA		/NO: IT'S A PROMOTIMG MOVE
	JMP	PPLSTR	/YES: IT'S NOT A PROMOTING MOVE
	TAD	GNMDW
	TAD	[0004	/SET 'PAWN PROMOTION BIT' (BIT 9) OF THE MDW
	DCA	GNMDW
	JMS	GNSTR	/STORE PROMOTION TO KNIGHT MOVE IN PDL2
	ISZ	GNMDW	/CHANGE MDW TO INDICATE PROMOTION TO A BISHOP
	JMS	GNSTR	/STORE MOVE IN PDL2
	ISZ	GNMDW	/CHANGE MDW TO INDICATE PROMOTION TO A ROOK
	JMS	GNSTR	/STORE MOVE IN PDL2
	ISZ	GNMDW	/CHANGE THE MDW TO INDICATE PROMOTION TO A QUEEN
PPLSTR,	JMS	GNSTR	/STORE MOVE IN PDL2
	JMP  I	PROMCK	/RETURN
PROM1,	CLL RTR		/CLEAR LINK(BIT 1)AND REROTATE THE MDW BACK INTO POSITION
	DCA	GNMDW	/RESTORE THE MDW
	TAD	GNMSW	/NOW GET THE MSW
	AND	[0077	/EXTRACT 'TO SQUARE' INFO
	RTL CLL		/ROTATE THE INFO SO THAT IT FITS IN MDW BITS 3-8
	RAL
	TAD	GNMDW	/ADD IT TO THE MDW
	DCA	GNMDW	/THERES THE NEW MDW!!!
	JMP	PPLSTR	/IF THE PAWN MOVE A DOUBLE MOVE, IT WASN'T QUEENING

/SUBROUTINE TO CHECK FOR LEGAL PAWN CAPTURES
CAPTST,	0000
	JMS	BLDTO	/BUILD THE ADDRESS OF THE 'TO' SQUARE
	TAD  I	TOADR	/GET THE VALUE OF THE SQUARE
	JMS	CLRFIX
	SMA CLA		/IS IT AN ENEMY PIECE?
	JMP  I	CAPTST	/YES. CAN ONLY CAPTURE OPPOSING PIECES
	JMS	BLDMSW	/NO. CAPTURE SEEMS LEGAL. BUILD AN MSW
	CLA STL RAR	/BUILD AN MDW WHICH INDICATES CASTLING
	DCA	GNMDW
	TAD	GNMSW	/FINAL TEST FOR MOVE LEGALITY COMING UP
	JMS  I	ZFNL	/IS KING IN CHECK?
	JMP  I	CAPTST	/YES: MOVE ILLEGAL
	JMS	PROMCK	/NO: CHECK FOR PROMOTION
	JMP  I	CAPTST	/RETURN

PST,	0000
	TAD	PONDIR
	DCA	GN3
	JMS	BLDTO	/BUILD THE 'TO' ADDR
	TAD  I	TOADR	/GET VALUE OF 'TO' SQUARE
	SZA CLA		/IS THE SQUARE OCCUPIED?
	JMP  I	PST	/YES, MOVE NO GOOD
	JMS	BLDMSW	/NO. PACK IT INTO 12 BITS.
	TAD	GNMSW
	JMS  I	ZFNL	/IS KING IN CHECK?
	SKP		/YES: MOVE NO GOOD
	JMS	PROMCK	/MOVE IS LEGAL. CHECK FOR PAWN PROMOTION
	ISZ	PST	/INC RETURN ADDRESS IF "TO" SQUARE WAS NOT OCCUPIED
	JMP  I	PST

/TEST FOR LEGAL KNIGHT CAPTURE: 
ISLNM,	CLA CLL CMA
	RAL		/AC WILL=-2
	DCA	TOOS
	TAD	M1	/COMPARE RANKS
	CIA
	TAD	M3
	SMA
	CIA
	IAC
	SNA
	JMP	.+5
	IAC
	SZA CLA
	JMP	BATAK
	ISZ	TOOS
	TAD	M2
	CIA
	TAD	M4
	SMA
	CIA
	IAC
	SNA
	JMP	.+5
	IAC
	SZA CLA
	JMP	BATAK
	ISZ	TOOS
	SKP
	JMP	BATAK
	ISZ	TOOS
	JMP	BATAK
	JMP	GATAK
TOOS,	0000
	
PDLIN,	0000		/INITIALIZE THE LIST
	CLA
	TAD	(PDLS
	DCA	PDLADR	/INITIALIZE LIST ADDRESS
	JMP  I	PDLIN	/RETURN

IPDL01,	0000		/INITIALIZE PUSH DOWN LIST #1
	CLA
	TAD	(PDLS+777
	DCA	PC01
	JMP  I	IPDL01	/RETURN

/SUBROUTINE TO TEST FOR PUSH DOWN LIST OVERFLOW
OFLOW,	0000
	TAD	PC01	/GET ADDR OF BOTTOM PDL#1
	CIA		/COMPARE IT WITH
	TAD	PDLADR	/THE ADDR OF BOTTOM PDL#2
	SZA CLA		/ARE THEY THE SAME?
	JMP  I	OFLOW	/NO. RETURN.
/PUSH DOWN LIST HAS OVERFLOWED!!!!!
	IFNZRO	LPTREE<
	TAD	(OUT
	DCA	ZOUT	/MAKE SURE OUTPUT GOES TO THE TTY
>
	PRINTO;	MESG26	/PRINT "I RESIGN"
	JMS  I	ZCRLF
	HLT
MESG26,	TEXT \I RESIGN\

PAGE

/CHECK FOR LEGAL KING MOVE
ISLKM,	CLA
	TAD	M1
	CIA
	TAD	M3
	SMA
	CIA
	SZA
	IAC
	SZA CLA
	JMP	BATAK
	TAD	M2
	CIA
	TAD	M4
	SMA
	CIA
	SZA
	IAC
	SNA CLA
	JMP	GATAK
	JMP	BATAK

/ROUTINE TO CHECK FOR PIECES IN THE MOVE ROW
ROW,	0000
	CLA
	TAD	M1
	CIA
	TAD	M3
	RAL CLL		/GET THE SIGN
	SZA CLA
	TAD	(10
	SZL
	CIA
	DCA	TEMP3
	TAD	M4
	CIA
	TAD	M2
	RAL CLL		/GET THE SIGN
	SZA CLA
	IAC
	SNL
	CIA
	TAD	TEMP3
	DCA	TMP
	TAD	TMATK	/GET THE SQUARE OF THE ATTACKER
	DCA	TEMP3	/COPY IT SO WE DONT HAVE TO DESTROY THE ORIGINAL
MIDLIN,	TAD	TEMP3	/SET TO NEXT SQUARE
	TAD	TMP
	DCA	TEMP3
	TAD	TEMP3	/COMPARE IT WITH THE ATTACKED SQUARE
	CIA
	TAD	TEMP
	SNA CLA		/ARE THEY THE SAME?
	JMP  I	ROW	/YES RETURN
	TAD  I	TEMP3	/NO. GET THE VALUE OF THE PIECE ON THE SQUARE
	SNA CLA		/IS THE SQUARE EMPTY?
	JMP	MIDLIN	/YES- KEEP GOING UNTIL WE FIND ONE THAT ISN'T
	ISZ	ROW	/NO. ITS NOT A LEGAL ATTACK--INC RETURN ADDRESS
	JMP  I	ROW	/RETURN

/CHECK FOR LEGAL BISHOP MOVE
SUBR1,	0000
	CLA
	TAD	M1
	CIA
	TAD	M3
	SMA
	CIA
	DCA	TEMP3
	TAD	M2
	CIA
	TAD	M4
	SPA
	CIA
	TAD	TEMP3
	SZA CLA		/ARE BOTH SQUARES ON THE SAME DIAGONAL?
	JMP  I	SUBR1	/NO
	JMS	ROW	/YES. FIND OUT IF ANY PIECES ARE BLOCKING THAT DIAGONAL
	ISZ	SUBR1	/NONE FOUND -- INC RETURN ADDRESS
	JMP  I	SUBR1	/RETURN

/CHECK FOR LEGAL ROOK MOVE
SUBR2,	0000
	CLA
	TAD	M1
	CIA
	TAD	M3
	SNA CLA
	JMP	.+6	/SAME RANK. FORGET FILE
	TAD	M2
	CIA
	TAD	M4
	SZA CLA
	JMP  I	SUBR2	/BOTH RANK AND FILE CHANGED?!
	JMS	ROW
	ISZ	SUBR2	/NO PIECES IN THE WAY-- INC RETURN ADDRESS
	JMP  I	SUBR2

/CHECK FOR LEGAL QUEEN MOVE
/GO TO 'GATAK' IF IT IS
ISLQM,	JMS	SUBR2	/CHECK FOR A QUEEN MOVE 'ROOK STYLE'
	SKP		/NOT FOUND
	JMP	GATAK	/FOUND
	JMS	SUBR1	/IF NOT CHECK FOR BISHOP STYLE QUEEN MOVE
	JMP	BATAK	/NIETHER ONE
	JMP	GATAK	/FOUND BISHOP STYLE QUEEN MOVE

ISLBM,	CLA
	JMS	SUBR1
	JMP	BATAK
	JMP	GATAK

ISLRM,	CLA
	JMS	SUBR2
	JMP	BATAK
	JMP	GATAK

PAGE


/SUBROUTINE TO TEST IF A SQUARE IS ATTACKED BY A PIECE.
/ALSO FINDS OUT HOW MANY ATTACKERS, AND THE VALUE OF THE LEAST VALUABLE ATTACKER
/CALL WITH ADDRESS OF SQUARE TO BE TESTED IN LOCATION 'TEMP'
/ALSO PONDIR AND COLR SET IN REVERSE OF THE ATTACKERS
/AND THE ATTACKERS PIECE LIST ADDRESS-1 IN LOC 'OMAP'
/RETURNS WITH NUMBER OF ATTACKERS IN LOC. 'PCNT', THE ADDRESS
/OF THE LEATST VALUABLE ATTACKER IN LOC "PSQR" AND VALUE OF THE LEAST
/VALUABLE ATTACKER IN LOC. 'PVAL'
/IF THE VALUE OF THE LEAST VALUABLE ATTACKER, AND THE # OF ATTACKERS
/IS NOT IMPORTANT, CALL WITH AC NOT =0
/RETURN IN THIS CASE IS DIRECTLY AFTER THE FIRST ATTACK IS FOUND
CHKATK,	0000
	DCA	CKMODE	/SET RETURN MODE SWITCH
	CLA CMA
	DCA	TMATK	/INITIALIZE SWITCH ENABLING 1 LOOPBACK IN THE PAWN SECTION
	DCA	PCNT	/INITIALIZE PIECE COUNT
	DCA	PVAL	/INITIALIZE PIECE VALUE TO 0
	DCA	PSQR	/INIT PIECE ADDRESS
	TAD	TEMP	/GET SQUARE TO BE CHECKED
	AND	[0007	/EXTRACT THE FILE #
	DCA	M4	/RECORD IT
	TAD	TEMP	/GET SQUARE ADDR AGAIN
	RTR CLL		/ROTATE RIGHT 3 BITS SO THAT THE RANK CAN
	RAR		/BE EXTRACTED IN A SIMILAR MANNER
	AND	[0007
	DCA	M3	/STORE RANK #
	TAD	PONDIR	/CHECK FOR AN ATTACK BY A PAWN
	TAD	M3
	SNO		/IMPOSIBLE RANK?
	JMP	TAG1	/YES. FORGET PAWN ATTACKS
	DCA	M1	/NO. SAVE THE RANK
	IAC CLA		/NOW BUILD A FILE
TAG0,	TAD	M4
	SNO		/IS THAT FILE REALY ON THE BOARD?
	JMP	TAG3	/NO.
	RTR CLL		/YES: PASTE TOGETHER THE ADDRESS OF THIS HYPOTHETICAL PAWN
	RAR
	TAD	M1
	RTL
	RAL
	TAD	[BOARD	/ADD IN BOARD ADDRESS CONSTANT
	DCA	TEMP1	/VOLIA! STORE THE ADDRESS
	TAD  I	TEMP1	/GET THE VALUE OF THE PIECE AT THAT ADDR
	JMS	CLRFIX
	TAD	(PAWN
	SZA CLA		/PER CHANCE A PAWN?
	JMP	TAG3	/NO: TRY NEXT PIECE 
TAG2,	ISZ	PCNT	/YES. ITS A PAWN ATTACK. INC PIECE COUNT
	TAD  I	TEMP1	/SET LOWEST VALUED ATTACKING PIECE VALUE = PAWN
	DCA	PVAL
	TAD	TEMP1	/ALSO SET THE ADDRESS OF THE LOWEST ATTACKING PIECE
	DCA	PSQR	/EQUAL TO THE ADDRESS OF THE PAWN
	TAD	CKMODE	/TEST FOR 'FAST RETURN' MODE
	SZA CLA
	JMP  I	CHKATK	/RETURN NOW
TAG3,	ISZ	TMATK	/TESTED FOR PAWNS ON BOTH ADJACENT FILES?
	JMP	TAG1	/YES
	CMA CLA		/NO. LOOP BACK FOR THE OTHER FILE
	JMP	TAG0
TMATK,	0000
CKMODE,	0000
TMATK1,	0000
TAG1,	CLA
	TAD	OMAP	/GET ADDRESS-1 OF THE ATTACKERS PIECE MAP
	DCA	TOMAK1
BATAK,	ISZ	TOMAK1	/INC THE PIECE TABLE ADDRESS
	TAD  I	TOMAK1	/GET THE ADDRESS OF THE PIECE
	SNA		/IS IT REALY A PIECE, OR IS THE SQUARE BLANK?
	JMP  I	CHKATK	/BLANK. TABLE EXAUSTED:RETURN
	DCA	TMATK	/NO. SOMTHINGS THERE. STORE ITS ADDRESS
	TAD	TMATK	/GET THE ATTACKERS SQR ADDR
	CIA
	TAD	TEMP	/COMPARE WITH THE ATTACKED SQUARS ADDRESS
	SNA CLA		/ARE THEY THE SAME?
	JMP	BATAK	/YES.PIECES CANNOT ATTACK THEMSELVES
	TAD  I	TMATK
	JMS	CLRFIX
	TAD	(PAWN
	SNA CLA		/IS IT A PAWN?
	JMP	BATAK	/YES, DONE PAWNS ALLREADY, TRY NEXT PIECE
	TAD	TMATK	/NO GET SQUARE ADDRESS
	AND	[0007	/EXTRACT THE FILE
	DCA	M2	/STORE IT
	TAD	TMATK	/GET ADDRESS AGAIN
	RTR		/ROTATE RANK # INTO BITS 9-11
	RAR
	AND	[0007	/ISOLATE RANK INFO
	DCA	M1	/STORE IT
	TAD  I	TMATK	/GET THE VALUE OF THE PIECE AGAIN
	JMS	CLRFIX
	TAD	(ROOK	/NOW IDENTIFY IT
	SNA		/IS IT A ROOK?
	JMP	ISLRM	/YES
	TAD	(-ROOK+BISHOP
	SNA		/IS IT A BISHOP?
	JMP	ISLBM	/YES
	TAD	(-BISHOP+KNIGHT
	SNA		/IS IT A KNIGHT?
	JMP	ISLNM	/YES
	TAD	(-KNIGHT+KING
	SNA		/IS IT A KING?
	JMP	ISLKM	/YES
	TAD	(-KING+QUEEN
	SNA CLA		/IS IT A QUEEN?
	JMP	ISLQM	/YES
	JMP	BATAK	/NO? WHATEVER WAS THERE MUST HAVE MOVED! PLEASE TO IGNORE.

/WE REACH HERE IF AN ATTACK ON THE SQUARE IN QUESTION IS FOUND
GATAK,	ISZ	PCNT	/INC ATTACK COUNTER
	TAD	CKMODE	/TEST FOR FAST RETURN
	SZA CLA		/'FAST RETURN' MODE?
	JMP  I	CHKATK	/YES. RETURN NOW
	CMA CLA
	TAD	PCNT
	SNA CLA		/IS THIS THE FIRST ATTACK FOUND?
	JMP	TAG4	/YES. DONT COMPARE
	TAD  I	TMATK	/NOW COMPARE THE VALUE OF THIS ATTACKING PIECE
	CIA		/WITH THE LOWEST VALUED ATTACKER FOUND SO FAR
	TAD	PVAL
	JMS	CLRFIX
	SMA CLA		/IS THE VALUE OF THIS PIECE LOWER?
	JMP	BATAK	/NO
TAG4,	TAD  I	TMATK	/YES. REPLACE THE OLD VALUE WITH THIS ONE
	DCA	PVAL
	TAD	TMATK
	DCA	PSQR
	JMP	BATAK

PAGE

/TEST FOR KING IN CHECK BY MOVING A PIECE AND CALLING CHKATK
/CALL WITH MSW IN AC, AND THE KINGS ADDRESS IN "CKING"
/RETURN TO THE ADDRESS+1 OF THE CALLING JMS IF THE KING IS IN CHECK
/RETURN TO THE ADDRESS+2 OF THE CALLING JMS IF THE KING IS NOT IN CHECK
TSTCHK,	0000
	DCA	MMUMTM	/STORE THE MSW FOR THE MOMENT
	TAD	GNCHEK	/GET # OF ATTACKS ON THE KING
	SZA CLA		/WAS THE KING IN CHECK?
	JMP	TSTCH1	/YES. DO A COMPLETE TEST FOR KING IN CHECK
	TAD	CTNEED
	SPA		/HAVE WE DETERMINED THAT A CHECK TEST IS NESCESARY?
	JMP	TSTCH1	/YES. DO ONE
	SNA CLA		/NO. HAVE WE DETERMINED THAT IT IS NOT?
	JMP	TSTCH2	/YES. DONT DO ONE THEN
	DCA	CTNEED	/NO. DETERMINE THAT NOW
	TAD	CKING
	DCA	TEMP
	TAD	CNTR1
	DCA	TMATK
	TAD	TEMP
	RTR CLL
	RAR
	AND	[0007
	DCA	M3
	TAD	TEMP
	AND	[0007
	DCA	M4
	TAD	CNTR1
	RTR CLL
	RAR
	AND	[0007
	DCA	M1
	TAD	CNTR1
	AND	[0007
	DCA	M2
	JMS	SUBR1
	SKP
	JMP	TSTCH1
	JMS	SUBR2
	JMP	TSTCH2
TSTCH1,	CLA CMA
	DCA	CTNEED	/SET CHECK TEST NEED SWITCH
	TAD	MMUMTM	/GET THE MSW BACK AGAIN
	JMS	MMOVE
	TAD	CKING	/ADDRESS TO TEST FOR ATTACK
	DCA	TEMP
	IAC		/RETURN AFTER FIRST ATTACK IS FOUND
	JMS	CHKATK
	JMS	UMOVE	/PUT THE PIECE BACK WHERE IT BELONGS
	TAD	PCNT	/GET # OF ATTACKS
	SNA		/ANY?
TSTCH2,	ISZ	TSTCHK	/NO. INC RETURN ADDRESS
	SNA CLA		/I'LL ASK AGAIN: WERE THERE ANY?
	JMP  I	TSTCHK	/NO. RETURN
	TAD	GNCHEK
	SZA CLA		/WAS IT A CHECK REPLY?
	ISZ	MOBMOD	/TALLY ONE MORE ILLEGAL BY VIRTUE OF KING IN CHECK
	JMP  I	TSTCHK

/SUBROUTINE TO MAKE A SIMPLE TYPE MOVE
/CALL WITH MSW IN AC
MMOVE,	0000
	DCA	MMUMT1	/STORE THE MSW
	TAD	MMUMT1
	JMS  I	ZSPLIT	/SPLIT THE MSW UP INTO 'TO' AND 'FROM' SQUARE ADDRESSES
	TAD  I	TEMP1	/GET VALUE  OF CAPTURED PIECE
	DCA	MMUMTM	/STORE IT
	TAD  I	TEMP2	/MOVE THE PIECE
	DCA  I	TEMP1	/ONTO ITS NEW SQR
	DCA  I	TEMP2	/CLEAR OUT OLD SQR
	JMP  I	MMOVE

/SUBROUTINE TO UMMAKE SIMPLE TYPE MOVES
/AS MADE BY THE MMOVE SUBROUTINE
UMOVE,	0000
	CLA
	TAD	MMUMT1	/GET THE MSW
	JMS  I	ZSPLIT	/SPLIT IT UP INTO 'TO' AND 'FROM' SQUARE ADDRESSES
	TAD  I	TEMP1	/GET VALUE OF THE PIECE BEING UNMOVED
	DCA  I	TEMP2	/PUT IT BACK ON ITS ORIGINAL SQUARE
	TAD	MMUMTM
	DCA  I	TEMP1	/RESTORE CAPTURED PIECE
	JMP  I	UMOVE
MMUMTM,	0000
MMUMT1,	0000

/SUBROUTINE TO GENERATE ALL MOVES FOR WHITE
GNWMV,	0000
	CMA CLA		/SETUP FIRST RANK CONSTANT
	DCA	FSTRNK
	JMS  I	ZMAPEC	/MAP THE PIECES
	TAD	(NOP	/SETUP COLOR COMPLIMENTOR
	DCA	COLR
	IAC		/SETUP PAWN DIRECTION CONSTANT
	DCA	PONDIR
	TAD	WKING	/SAVE THE ADDRESS OF THE WHITE KING
	DCA	CKING
	TAD	(MAP-1	/SETUP ADDRESS OF WHITE PIECE MAP
	DCA	GMAP
	TAD	(MAP+23	/SETUP ADDRESS OF BLACK PIECE MAP
	DCA	OMAP
	TAD	(WPSW	/SETUP CURRENT PSW ADDRESS
	DCA	CPSW
	JMS  I	ZGNMV	/GENERATE THE MOVES
	JMP  I	GNWMV	/RETURN


/SUBROUTINE TO GENERATE ALL MOVES FOR BLACK
GNBMV,	0000
	CMA CLA		/SETUP THE PAWN DIRECTION CONSTANT
	DCA	PONDIR
	JMS  I	ZMAPEC	/MAP THE PIECES
	TAD	[CIA	/SETUP COLOR COMPLIMENTOR
	DCA	COLR
	TAD	BKING	/SAVE THE ADDRESS OF THE BLACK KING
	DCA	CKING
	TAD	(7772	/SETUP FIRST RANK CONSTANT
	DCA	FSTRNK
	TAD	(MAP+23	/SETUP ADDRESS OF BLACK PIECE MAP
	DCA	GMAP
	TAD	(MAP-1	/SETUP ADDRESS OF WHITE PIECE MAP
	DCA	OMAP
	TAD	(BPSW	/SETUP POSITION STATUS WORD ADDRESS
	DCA	CPSW
	JMS  I	ZGNMV	/GENERATE THE MOVES
	JMP  I	GNBMV	/RETURN

PAGE

/SUBROUTINE TO TEST FOR WHITE ATTACKS
/CALL WITH ADDRESS OF THE SQUARE TO BE TESTED IN AC
TSTWAT,	0000
	DCA	TEMP
	TAD	[CIA
	DCA	COLR
	CLA CMA
	DCA	PONDIR
	TAD	(MAP-1	/ADDRESS-1 OF MAP OF ATTACKING PIECES
	DCA	OMAP
	JMS	CHKATK	/DO THE TEST
	JMP  I	TSTWAT	/RETURN

/SUBROUTINE TO TEST FOR BLACK ATTACKS ON ANY SQUARE
/CALL WITH THE ADDRESS OF THE SQUARE TO BE TESTED IN AC
TSTBAT,	0000
	DCA	TEMP	/STORE ADDRESS OF SQUARE TO BE TESTED
	TAD	(NOP
	DCA	COLR
	CLA IAC
	DCA	PONDIR
	TAD	(MAP+23	/ADDRESS-1 OF THE BLACK PIECE MAP
	DCA	OMAP
	JMS	CHKATK	/DO THE TEST
	JMP  I	TSTBAT	/RETURN



/SUBROUTINE TO MAKE A MOVE. CALLED WITH MSW IN LOCATION 'TOMAK1'
/AND MDW IN LOCATION 'TOMAK2'
MKMV,	0000
	CLA CLL
	ISZ	DOMAP	/SET SWITCH INDICATING THAT A PIECE MAP IS NESSECARY
	IFNZRO	DEBUG<
	JMS	TSTBRD	/TEST BOARD
>
	TAD	TOMAK1
	PUSH1		/SAVE THE MSW
	TAD	TOMAK1	/GET THE MSW
	JMS  I	ZSPLIT	/SPLIT  THE MSW UP INTO A 'TO' AND A 'FROM' ADDRESSES
	TAD	TOMAK2	/MDW TO AC
	SMA CLA		/IS THE MOVE A CAPTURE?
	JMP	MKMV1	/NO.
	TAD  I	TEMP1	/YES. SAVE ITS VALUE IN
	PUSH1		/THE PUSH DOWN LIST
	TAD  I	TEMP1	/GET VAL OF CAPTURED PIECE
	CIA		/SUBTRACT IT FROM THE
	TAD	PW	/TOTAL VALUE OF THE BOARD
	DCA	PW
MKMV1,	TAD  I	TEMP2	/NOW PHYSICALY MOVE THE PIECE
	DCA  I	TEMP1	/ONTO ITS NEW SQUARE
	DCA  I	TEMP2	/REMOVE THE PIECE FROM ITS OLD SQUARE
	TAD	WPSW	/SAVE WHITES POSITION STATUS WORD
	PUSH1
	TAD	BPSW	/SAVE BLACKS POSITION STATUS WORD
	PUSH1
	TAD	LSTMV
	PUSH1		/SAVE THE 'LSTMV' INFORMATION
	TAD	TOMAK2	/INSTALL NEW INFORMATION ON THE LAST(THIS) MOVE MADE
	DCA	LSTMV
	TAD	TOMAK2
	AND	[0007
	SNA		/IS THIS ONE OF THE SPECIAL TYPES OF MOVES?
	JMP	MKMVDN	/NO. ALL DONE SO RETURN
	TAD	(JMP 	.+2	/YES. BUILD A 'JMP' TO THE PROPER SPECIAL CASE HANDLER
	DCA	.+1
	HLT		/PUT THE JUMP HERE
/A JMP TO  ONE OF THE FOLLOWING 7 INSTRUCTIONS WAS EXECUTED
/BY THE PREVIOUS INSTRUCTION
	JMP	MKQSC	/MAKE A QUEEN SIDE CASTLING MOVE
	JMP	MKKSC	/MAKE A KING SIDE CASTLING MOVE
	JMP	MKEP	/EN PASANT
	TAD	(KNIGHT-BISHOP	/PROMOTING TO A KNIGHT
	TAD	(BISHOP-ROOK	/PROMOTING TO A BISHOP
	TAD	(ROOK-QUEEN	/PROMOTING TO A ROOK
	TAD	(QUEEN		/PROMOTE TO A QUEEN
	DCA	TEMP3	/STORE ABS VALUE OF THE PROM PIECE
	TAD  I	TEMP1	/GET THE VALUE OF THE PROMOTEING PAWN
	CIA		/SUBTRACT IT FROM THE
	TAD	PW	/TOTAL VALUE OF THE BOARD
	DCA	PW
	TAD  I	TEMP1	/GET THE VAL OF THE MOVING PAWN
	RAL		/LOAD THE SIGN INTO THE LINK
	CLA
	TAD	TEMP3	/GET ABS VALUE OF PROM PIECE
	SZL		/WAS THE PROMOTING PAWN BLACK?
	CIA		/YES. MAKE THE PROMOTION PIECE BLACK ALSO
	DCA  I	TEMP1	/PLACE THE NEW PIECE ON THE BOARD
	TAD  I	TEMP1	/ADD THE VALUE OF THE NEW PIECE
	TAD	PW	/IN WITH THE TOTAL VALUE
	DCA	PW
	JMP	MKMVDN

MKQSC,	TAD	TEMP1	/IT'S QUEENS SIDE CASTLING
	AND	[7770
	DCA	TEMP2	/STORE THE ADDR OF QUEENS ROOK BEFORE CASTLING
	TAD	TEMP2
	TAD	(3
	DCA	TEMP1	/STORE ADDRESS OF ROOKS NEW SQUARE
MKCA1,	TAD  I	TEMP2	/LOAD AC WITH VALUE OF THE ROOK
	DCA  I	TEMP1	/PUT THE ROOK DOWN ON ITS NEW SQR
	DCA  I	TEMP2	/REMOVE THE ROOK FROM ITS OLD SQR
	TAD  I	TEMP1	/GET COLOR OF CASTLING SIDE
	SPA		/IS IT BLACK?
	ISZ	BPSW	/YES. SET BIT 11 OF HIS PSW
	SMA CLA		/OR IS IT WHITE?
	ISZ	WPSW	/YES. SET BIT 11 OF HIS PSW
	JMP	MKMVDN

MKKSC,	TAD	TEMP1	/BUILD ADDRESS OF THE
	IAC		/KINGS ROOK
	DCA	TEMP2	/STORE THE ADDR OF KINGS ROOK BEFORE CASTLING
	TAD	(-5	/BUILD THE ADDRESS OF THE ROOKS
	JMP	MKCA1-3	/NEW SQUARE

MKEP,	TAD	TEMP2	/IT'S AN 'EN PASSANT' CAPTURE
	AND	[7770	/BUILD ADDRESS OF THE PAWN THAT WAS TAKEN
	DCA	TEMP3
	TAD	TEMP1
	AND	[0007
	TAD	TEMP3
	DCA	TEMP3
	TAD  I	TEMP3	/SUBTRACT THE PAWNS VALUE
	CIA		/FROM THE TOTAL
	TAD	PW
	DCA	PW
	DCA  I	TEMP3	/REMOVE CAPTURED PAWN FROM THE BOARD
MKMVDN,	IFNZRO	DEBUG	<
	JMS	TSTBRD	/TEST BOARD VALUE
>
	TAD	WHOSE	/NOW THAT THE MOVE IS MADE
	CMA		/COMPLIMENT
	DCA	WHOSE	/THE "WHOSE MOVE" SWITCH
	JMP  I	MKMV	/AND RETURN

PAGE


/SUBROUTINE TO UNMAKE A MOVE  MADE BY THE 'MKMV' ROUTINE
/LIKE THE 'MKMV' SUBROUTINE 'UNMV' IS COLOR INDEPENDENT- USES NO 'CLRFIX'
UNMV,	0000
	CLA CLL
	ISZ	DOMAP	/SET SWITCH FOR OBSOLETE PIECE MAP
	IFNZRO	DEBUG<
	JMS	TSTBRD	/MAKE SURE BOARD VALUE IS OK
>
	TAD	LSTMV	/GET THE MDW FOR THE LAST(THIS) MOVE MADE
	DCA	TOMAK2
	POP1		/GET THE OLD 'LSTMV' INFO
	DCA	LSTMV	/RESTORE IT
	POP1		/RESTORE BLACKS PSW
	DCA	BPSW
	POP1		/RESTORE WHITES PSW
	DCA	WPSW
	TAD	TOMAK2	/GET THE MDW FOR THE MOVE
	SPA CLA		/IS IT A CAPTURE?
	POP1		/YES. GET THE VALUE OF THE CAPTURED PIECE
	DCA	TEMP3	/STORE IT
	POP1		/GET THE OLD MSW
	DCA	TOMAK1	/STORE THE MSW
	TAD	TOMAK1	/BACK AGAIN
	JMS  I	ZSPLIT	/UNPACK THE MSW AND BUILD THE 'TO' AND 'FROM' ADDRESSES
	TAD  I	TEMP1	/GET THE MOVED PIECE AND
	IFNZRO	DEBUG<	
	SNA		/IS IT STILL THERE?
	HLT		/BUG!!!
>
	DCA  I	TEMP2	/PUT IT BACK ON ITS OLD SQUARE
	TAD	TEMP3
	DCA  I	TEMP1	/RESTORE THE VALUE OF THE CAPTURED PIECE(OR EMPTY SQUARE)
	TAD	TEMP3	/ADD VAL OF CAPTURED PIECE
	TAD	PW	/BACK IN WITH THE TOTAL
	DCA	PW
	TAD	TOMAK2
	AND	[0007
	SNA		/WAS THE MOVE A SPECIAL TYPE?
	JMP	UNMVDN	/NO. RETURN
	TAD	(JMP	.+2
	DCA	.+1
	HLT		/THE JUMP GOES HERE
/A JUMP TO ONE OF THE FOLLOWING 7 LOCATIONS WAS
/EXECUTED BY THE PREVIOUS INSTRUCTION
	JMP	UNQSC	/UNMAKE A QUEEN SIDE CASTLING MOVE
	JMP	UNKSC	/UNMAKE KING SIDE CASTLING MOVE
	JMP	UNEP	/UNMAKE AN EN PASSANT CAPTURE
	JMP	UNQP
	JMP	UNQP
	JMP	UNQP
UNQP,	TAD  I	TEMP2	/PAWN PROM. MOVE
	CIA		/SUBTRACT PROMOTION VALUE
	TAD	PW	/FROM THE TOTAL
	DCA	PW
	TAD  I	TEMP2	/GET VALUE OF THE PROMOTION PIECE
	SMA CLA		/WHICH COLOR IS MOVING?
	TAD	(PAWN+PAWN	/WHITE IS MOVING.
	TAD	[-PAWN
	DCA  I	TEMP2	/RESTORE THE PROMOTION PIECE BACK TO A PAWN
	TAD  I	TEMP2	/ADD THE VAL OF THE PAWN
	TAD	PW	/IN WITH THE TOTAL VALUE
	DCA	PW
	JMP	UNMVDN

UNKSC,	TAD	TEMP2	/BUILD ADDR OF ROOKS 'POST CASTLING' SQUARE 
	IAC		/BY ADDING +1 TO THE KINGS 'PRE CASTLING' SQUARE ADDRESS
	DCA	TEMP2	/STORE IT
UNKS1,	TAD	TEMP2	/BUILD ADDRESS OF THE ROOKS 'PRE CASTLING' SQUARE ADDR
	TAD	(2	/BY ADDING +2 TO ITS 'POST-CASTLING' SQUARE ADDR
	DCA	TEMP1	/STORE ROOKS PRE CASTLING SQUARE ADDRESS
	TAD  I	TEMP2	/GET THE ROOKS VALUE
	DCA  I	TEMP1	/PLACE THE ROOK BACK ON ITS 'PRE CASTLING' SQUARE
	DCA  I	TEMP2	/REMOVE IT FROM ITS 'POST CASTLING SQUARE'
	JMP	UNMVDN

UNQSC,	TAD	TEMP1	/BUILD THE ADDR OF THE ROOKS 'POST CASTLING SQUARE
	IAC		/BY ADDING +1 TO THE KINGS 'POST CASTLING' SQUARE ADDRESS
	DCA	TEMP2	/STORE IT
	TAD	(-5	/BUILD THE ADDRESS OF THE ROOKS 'PRE CASTLING SQUARE'
	JMP	UNKS1	/SAME AS KING SIDE EXCEPT OVER 5 FILES
UNEP,	TAD	TEMP1	/BUILD THE ADDRESS OF THE CAPTURED PAWN
	AND	[0007	/TAKE THE FILE OF THE 'TO SQUARE'
	DCA	TEMP3	/STORE THE TO SQUARE' FILE #
	TAD	TEMP2	/AND EVERYTHING BUT THE FILE #
	AND	[7770	/FROM THE FROM SQUARE ADDRESS
	TAD	TEMP3	/ADD THEN TOGEATHER
	DCA	TEMP3	/STORE
	TAD  I	TEMP2	/GET THE VALUE OF THE CAAPTURING PAWN
	CIA		/MAKE THE VALUE THAT OF AN OPOSITE COLORED PAWN
	DCA  I	TEMP3	/REPLACE THE PAWN THAT WAS TAKEN 'EN PASSANT'
	TAD  I	TEMP3	/ADD PAWNS VALUE
	TAD	PW	/IN WITH THE TOTAL
	DCA	PW
UNMVDN,	IFNZRO	DEBUG	<
	JMS	TSTBRD	/VERIFY BOARD VALUE
>
	TAD	WHOSE	/NOW THAT THE MOVE IS UNMADE
	CMA		/COMPLIMENT
	DCA	WHOSE	/THE "WHOSE MOVE" SWITCH
	JMP  I	UNMV	/RETURN

/SUBROUTINE TO SPLIT A MSW UP LEAVING THE ADDRESS
/OF THE 'TO' SQUARE IN LOC 'TEMP1' AND THE ADDRESS OF THE 'FROM'
/SQUARE IN LOC. 'TEMP2'. CALL WITH MSW IN AC
SPLIT,	0000
	DCA	TEMP1
	TAD	TEMP1	/FIRST BUILD THE 'FROM' SQUARE ADDRESS
	RTR CLL
	RTR
	RTR
	AND	[0077	/MASK OUT THE GARBAGE IN BITS 0-5
	TAD	[BOARD	/ADD IN BOARD ADDRESS CONSTANT
	DCA	TEMP2	/STORE 'FROM' SQUARE ADDRESS
	TAD	TEMP1	/NOW FOR THE 'TO' SQUARE.
	AND	[0077	/MASK OUT BITS 0-5
	TAD	[BOARD	/ADD IN BOARD ADDRESS CONSTANT
	DCA	TEMP1	/STORE THE ADDRESS OF THE 'TO' SQUARE
	JMP  I	SPLIT	/RETURN

/SUBROUTINE TO RETURN THE PLY#-1 IN THE AC.
/IF THE PLY # IS 8 OR GREATER,  7 IS RETURNED, AND THE LINK IS SET
/IF PLY # <8 THE LINK IS RETURNED CLEAR
PLYCHP,	0000
	CLA STL
	TAD	PLY	/GET PLY #
	TAD	[7770	/SUBTRACT 8
	SMA		/IS PLY # 8 OR GREATER ?
	CLA		/YES. PRETEND IT WAS 8
	TAD	[0007	/RESTORE AC VALUE TO PLY#-1
	JMP  I	PLYCHP	/RETURN

	IFNZRO	DEBUG	<
/SUBROUTINE TO GET AN OLD BOARD VALUE FROM PDL#1 AND COMPARE IT WITH THE CURRENT
/BOARD VALUE. TO VERIFY THE "MKMV" AND "UNMV" SUBROUTINES
TSTBRD,	0000
	CLA
	TAD	PW
	DCA	TEMP1
	JMS	BRDVAL	/GET CURRENT BOARD VALUE
	CIA
	TAD	TEMP1
	SZA CLA		/ARE THEY THE SAME?
	HLT		/NO. ERROR SOMEWHERE
	JMP  I	TSTBRD	/ALL IS WELL
>
PAGE


/SUBROUTINE TO COMPARE THE AC WITH LOCATION 'COMP'
/RETURN NORMALY IF THEY ARE EQUAL
/RETURN TO THE ADDRESS+2 OF THE JMS IF THE AC IS LARGER
/RETURN TO THE ADDRESS+3 OF THE JMS IF 'COMP' IS LARGER
COMPAR,	0000
	CIA
	DCA	COMPAC	/STORE THE COMPLIMENT OF THE AC
	TAD	COMPAC	/COMPARE THE AC WITH 'COMP'
	TAD	COMP
	SNA CLA		/ARE THEY EQUAL?
	JMP  I	COMPAR	/YES. RETURN NORMALY
	TAD	COMPAC	/NO. GET COMPLIMENT OF THE AC AGAIN
	SPA SNA CLA	/WAS THE AC POSITIVE?
	JMP	XXAP	/YES. AC WAS POSITIVE
	TAD	COMP	/NEGATIVE
	SMA		/IS 'COMP' POSITIVE?
	JMP	XXCL	/YES. 'COMP' IS LARGER ALSO
	TAD	COMPAC	/NO. BOTH ARE NEGATIVE
	SPA CLA		/BUT WHICH IS THE LARGER?
	JMP	XXAL	/THE AC IS THE LARGER
	JMP	XXCL	/'COMP' IS THE LARGER
XXAP,	TAD	COMP	/THE AC WAS POSITIVE
	SPA		/TEST 'COMP' FOR ITS SIGN
	JMP	XXAL	/'COMP' IS NEGATIVE, AND THEREFORE LARGER
	TAD	COMPAC
	SMA CLA
XXCL,	ISZ	COMPAR	/'COMP' IS LARGER
XXAL,	ISZ	COMPAR	/AC IS LARGER
	CLA
	JMP  I	COMPAR	/RETURN
COMPAC,	0000

/SUBROUTINE TO TALLY UP THE VALUES OF ALL PIECES ON THE BOARD
/STORE THE RESULT IN LOC "PW", AND IN THE AC  ON RETURN
BRDVAL,	0000
	CLA
	TAD	(-100	/INITIALIZE FOR 64 SQUARES
	DCA	TEMP
	TAD	(BOARD-1/ADDRESS-1 OF BOARD
	DCA	ITMP1	/TO AUTO INDEX REG
	TAD  I	ITMP1
	ISZ	TEMP	/DONE ALL SQUARES?
	JMP	.-2	/NO DO ANNOTHER
	DCA	PW	/YES. STORE BOARD VALUE
	TAD	PW	/ALSO LOAD INTO AC
	JMP  I	BRDVAL	/RETURN

PRNCNT,	0000

EVAL,	0000
	CLA
	IFNZRO RANVAL<
	TAD  I	RANDOM	/INTRODUCE A RANDOM VARIATION INTO THIS EVALUATION
	AND	(0001	/LET IT BE NO GREATER THAN +1
>
	DCA	STRATG
	JMS	BREV	/DO A BACK RANK EVALUATION
	JMS	COEV	/DO A CENTER OCCUPATION EVALUATION
	JMS	CASTEV	/EVALUATE CASTLING STATUS
	TAD	PW	/ADD THE VALUE OF ALL PIECES ON THE BOARD
	TAD	STRATG	/ADD IN STRATEGICAL VALUE
	JMS	LCLRFX	/DO A COLOR FIX
	DCA	STRATG	/STORE
	JMS	MOBGET	/GET MOBILITY VALUE
	TAD	STRATG	/ADD IT IN WITH THE TOTAL
	DCA	STRATG	/STORE
/UPCOMING IS A MINI ALPHA BETA PRUNER
/SINCE THE "HIEP" PART OF THE EVALUATION IS TIME CONSUMING
/AND IT ONLY SERVES TO MAKE THE EVALUATION RETURNED LESS
/FAVORABLE FOR THE SIDE TO THAT JUST MOVED, IT IS BOTH
/WISE AND PROFITABLE TO TRY SAVE TIME THIS WAY
	TAD	STRATG
	JMS	PLYFIX
	DCA	COMP	/LOAD SOFTWARE COMPARE REGISTER
	TAD	UVAL1
	JMS	PLYFIX
	JMS	COMPARE/COMPARE VALUES
	JMP	EVAL2	/THEY ARE EQUAL. PRUNE
	JMP	EVAL1	/"HIEP" EVALUATION IS NESSECARY
	JMP	EVAL2	/NO "HIEP" NESSECARY(GOOD)
EVAL1,	JMS	HIEP	/GET THE CONTROVERSIAL VALUE
	JMS	LCLRFX
	TAD	STRATG
	JMP  I	EVAL	/RETURN

EVAL2,	IFNZRO LPTREE<
	TAD	("_	/SIGNAL THAT A MINI-PRUNE WAS DONE
	JMS  I	ZOUT
>
	TAD	STRATG	/GET VALUE
	JMP  I	EVAL	/RETURN

/SUBROUTINE TO GET THE MOBILITY VALUE FOR THIS POINT IN
/THE ANALYSIS
/RETURN WITH VALUE IN THE AC
MOBGET,	0000
	CLA
	TAD	MOB0
	SZA CLA		/DO SE HAVE ANY RELIABLE INFORMATION AT HAND ALREADY?
	JMP	MOBGE1	/YES. USE IT
	ISZ	BOGUS	/NO. GET SOME NOW
	TAD	GNCNT	/SAVE COUNTERS WE ARE ABOUT TO MODIFY
	PUSH1
	TAD	MOBMOD
	PUSH1
	JMS	GNBMV	/DO A PSEUDO MOVE GENERATION
	TAD	MOBMOD	/GET MOBILITY VALUE FOR BLACK
	DCA	MOBGTM	/SAVE FOR THE MOMENT
	ISZ	BOGUS
	JMS	GNWMV	/DO ANOTHER PSUEDO MOVE GENERATION
	TAD	MOBGTM	/SUBTRACT BLACKS MOBILITY VALUE
	CIA
	TAD	MOBMOD	/FROM WHITES
	JMS	LCLRFX
	DCA	MOBGTM	/STORE VALUE FOR THE MOMENT
	POP1		/RESTORE THE COUNTERS THAT WE DESTROYED
	DCA	MOBMOD
	POP1
	DCA	GNCNT
	TAD	MOBGTM	/GET VALUE BACK AGAIN
	JMP  I	MOBGET	/RETURN
MOBGE1,	TAD	MOBMOD	/GET MOBILITY VALUE FOR THIS LEVEL
	SNA		/IS THERE ONE FOR THIS LEVEL?
	TAD	MOB0	/NO. USE THE ONE FOR 2 PLYS BACK
	CIA
	TAD	MOB1
	CIA
	JMS	PLYFIX
	JMP  I	MOBGET	/RETURN
MOBGTM,	0000

PAGE
/THIS IS THE RECURSIVE LOOKAHEAD SUBROUTINE
/SEARCHES THE GAME TREE "DEPTH" PLYS DEEP. LOACTION "PLY"
/HOLDS THE CURRENT RECURSION LEVEL, OR DEPTH LEVEL OF THE SEARCH
/AND MUST BE SET TO = 0, BEFORE THIS ROUTINE IS CALLED FOR THE FIRST TIME
/SETTING "CVAL1" TO -3777 BEFORE CALLING THIS ROUTINE FOR THE FIRST TIME 
/IS ALSO NICE, TO PREVENT ALPHA-BETA PRUNING AT LEVEL #1
/THIS ROUTINE ASSUMES THAT THE COMPUTER HAS WHITE, BUT THE "LCLRFX" SUBROUTINE
/ALLOWS THE COMPUTER TO PLAY BLACK, BY SETING LOCATION "LCLRFX"+1 TO EQUAL
/A CIA INSTRUCTION
LOOKA,	0000
	CLA CLL
	TAD	LOOKA	/GET RETURN ADDRESS
	PUSH1		/SAVE IT IN PDL#1
	ISZ	PLY	/INC PLY NUMBER
	CMA CLA		/-1 TO AC
	TAD	PLY
	SZA CLA		/IS THIS THE FIRST PLY?
	JMP	LOOKA1	/NO
	TAD	WHOSE	/YES. SETUP "LCLRFX"
	SMA CLA		/WHICH COLOR ARE WE TO LOOK AHEAD ON BEHALF OF?
	TAD	(NOP-CIA/WHITE
	TAD	[CIA	/BLACK
	DCA	LCLRFX+1
	DCA	MOBMOD	/INITIALIZE MOBILITY VALUES
	DCA	MOB0
	DCA	MOB1
	DCA	ENO	/SET EVALUATION COUNTER TO 0
LOOKA1,	TAD	UVAL1	/SAVE THE OLD "UPPER LEVEL VALUE"
	PUSH1		/IN PDL#1
	TAD	CVAL1	/THE OLD "CURRENT LEVEL VALUE"
	DCA	UVAL1	/BECOMES THE NEW "UPPER LEVEL VALUE"
	TAD	PLYFIX+1	/SAVE PLY COMPENSATOR VALUE
	PUSH1
	TAD	GNCNT	/SAVE GENERATION COUNTER
	PUSH1		/IN PDL#1
	TAD	STRATG	/SAVE STRATEGIC VALUE
	PUSH1
	DCA	GNCNT	/CLEAR OUT GENERATION COUNTER, IN CASE NO MOVES ARE GENERATED
	TAD	MOB0	/SAVE MOBILITY OF THE LEVEL 2 ABOVE THIS ONE
	PUSH1
	TAD	MOB1	/BUMP ALL THE LEVELS BY 1
	DCA	MOB0
	TAD	MOBMOD
	DCA	MOB1
	DCA	MOBMOD	/!!!BUG OF AUG 13 FIXED!!!/
	IFNZRO	DEBUG	<
	TAD	PDLADR	/PUSH A MARKER SO THAT PDL#2 CAN BE VERIFIED
	PUSH1
	TAD	PC01	/PUSH A MARKER SO THAT PDL#1 CAN BE
	PUSH1		/VERIFIED TO BE IN LINE
>
	TAD	PLY	/BUILD A NEW PLY COMPENSATOR. FIRST GET PLY #
	RAR		/EVEN/ODD BIT TO LINK
	SZL CLA		/IS PLY #  EVEN ?
	TAD	(NOP-CIA/NO. BUILD A NOP INSTRUCTION
	TAD	[CIA
	DCA	PLYFIX+1
	TAD	PLY	/PLY # TO AC
	CIA		/COMPARE AGAINST
	TAD	DEPTH	/THE MAXIMUM DEPTH
	SPA CLA		/DOES CURRENT PLY# EXCCEDE THE MAX DEPTH #?
	JMP	LEVAL	/YES. DO A STATIC EVALUATION OF THE POSITION
LKFUR,	TAD	(-3777	/NO. BUILD A STARTING VALUE FOR THIS LEVEL
	JMS	PLYFIX
	DCA	CVAL1	/INITIALIZE VALUE FOR THIS LEVEL
	JMS	GNMVSM	/GENERATE THE MOVES OF THE SIDE WHOSE MOVE IT IS
	TAD	CMSW	/GIT CHECKMATE SWITCH
	SZA CLA		/IS SIDE TO MOVE IN CHECKMATE?
	JMP	LKCM	/YES. DO SOMTHING
	TAD	SMSW	/GET STALEMATE SWITCH
	SZA CLA		/IS THE SIDE TO MOVE IN STALEMATE?
	JMP	LKSM	/YES. DO SOMTHING
	JMS	PRUNE	/ONLY CONSIDER "GOOD" MOVES
PICK,	POP2		/POP A MOVE OUT OF PDL2
	DCA	TOMAK2	/STORE THE MDW
	POP2
	SNA		/IS IT A MOVE OR THE END OF THE LIST?
	JMP	LKAD	/ITS THE END OF THE LIST.
	DCA	TOMAK1	/ITS A MOVE--STORE THE MSW
IFNZRO	LPTREE	<
	TAD	TOMAK1
	DCA	IOMSW
	TAD	TOMAK2
	DCA	IOMDW
	JMS	OUTMV	/PRINT OUT THE MOVE
	JMS	SPACE	/ALSO A SPACE SO THAT THE NEXT TAB STOP IS REACHED
>
	JMS  I	ZMKMV	/MAKE THE MOVE
	JMS  I	ZLOOKA	/PEER FURTHER INTO THE MURKY DEPTHS OF THE GAME TREE
	IFNZRO	LPTREE<
	JMS  I	ZCRLF	/PRINT A CARRIAGE RETURN
>
	JMS  I	ZUNMV	/UNMAKE THE MOVE
	JMP	COMPMV	/GO DO A COMPARE

/SUBROUTINE TO POP OUT A GROUP OF MOVES FROM PDP#2
POPOUT,	0000
	CLA
	POP2		/OUT MDW
	POP2		/OUT MSW
	SZA CLA		/IS IT AN MSW OR IS IT THE END  OF THE MOVES MARKER?
	JMP	.-3	/IST AN MSW. GO POP OUT ANOTHER MOVE
	JMP  I	POPOUT	/END. RETURN

/SUBROUTINE TO GENERATE THE MOVES OF THE SIDE WHOSE TURN IT IS TO MOVE
/AS INDICATED BY THE "WHOSE" SWITCH
/RETURN WITH THE MOVES IN PDL#2, AND THE AC CLEARED
GNMVSM,	0000
	CLA
	TAD	WHOSE	/GET "WHOSE MOVE" SWITCH
	SMA CLA		/IS IT WHITES MOVE?
	JMS	GNWMV	/YES. GENERATE WHITES MOVES
	TAD	WHOSE
	SPA CLA		/OR IS IT BLACKS MOVE?
	JMS	GNBMV	/YES. GENERATE BLACKS MOVES
	JMP  I	GNMVSM	/RETURN
PAGE

COMPMV,	CLA
IFNZRO	LPTREE	<
	JMS	TABPLY	/TAB TO COLOMN "PLY"
	TAD	RVAL1
	JMS	OCTOUT
	TAD	CVAL1
	JMS	OCTOUT	/PRINT THE VALUE TO BEAT
>
	TAD	RVAL1	/GET VALUE RETURNED
	JMS	PLYFIX	/FIX W/RESPECT TO PLY NUMBER
	DCA	COMP	/LOAD SOFTWARE COMPARE REGISTER WITH IT
	TAD	CVAL1	/GET CURRENT VALUE FOR THIS LEVEL
	JMS	PLYFIX	/FIX W/RESPECT TO PLY #
	JMS	COMPAR	/COMPARE IT WITH THE RETURNED VALUE NOW IN COMPARE REGISTER
	JMP	JMPICK	/THEY ARE EQUAL:
	JMP	JMPICK	/UNFAVORABLE COMPARE: GO ON TO NEXT MOVE
RPLACE,	TAD	RVAL1	/HAIL NEW "BEST MOVE VALUE"
	DCA	CVAL1	/STORE NEW "BEST MOVE VALUE"
	IFNZRO	LPTREE	<
	TAD	("*
	JMS  I	ZOUT	/THE RETURN MOVE WON INDICATION
>
	JMS	SETPNT
	TAD	TOMAK1	/MSW
	DCA  I	XR0	/INTO "BEST MOVE" TABLE
	TAD	TOMAK2	/MDW
	DCA  I	XR0	/INTO THE "BEST MOVE" TABLE

			/COMING UP IS THE "ALPHA BETA PRUNER"
			/IT CHECKS IF THE NEW "BEST VALUE" FOR THIS LEVEL
			/IS COMPETITIVE WITH THE "BEST VALUE" ON THE LEVEL ABOVE
ALPHAB,	CLA
	TAD	CVAL1	/GET CURRENT LEVEL VALUE
	JMS	PLYFIX	/COMPLIMENT IF THIS IS AN EVEN PLY
	DCA	COMP	/LOAD COMPARE REGISTER WITH IT
	TAD	UVAL1	/GET THE VALUE OF THE LEVEL ABOVE
	JMS	PLYFIX
	JMS	COMPAR	/COMPARE WITH THE CURRENT LEVEL VALUE IN THE COMPARE REGISTER
	JMP	ALPHAP	/EQUAL MEANS PRUNE
	JMP	JMPICK	/SORRY. THE VALUE WOULD STILL BE COMPETITIVE ON THE LEVEL ABOVE
ALPHAP,	JMS	POPOUT	/REMOVE ALL OTHER MOVES ON THIS LEVEL
	TAD	PLY	/FOR DEBUG
	CLA CLL
	IFNZRO	LPTREE<
	TAD	("!
	JMS  I	ZOUT	/PRINT INDICATION FOR PRUNE
>
	JMP	LKAD	/YES. GO SET RETURN VALUE

JMPICK,	IFNZRO	LPTREE	<
	JMS  I	ZCRLF	/CARRIAGE RETURN
	JMS	TABPLY	/TAD TO COLOMN # "PLY"
>
	CLA
	JMP	PICK

SAVBRD,	ROOK
	KNIGHT
	BISHOP
	QUEEN
	KING
	BISHOP
	KNIGHT
	ROOK
	PAWN
	PAWN
	PAWN
	PAWN
	PAWN
	PAWN
	PAWN
	PAWN
BESTBL,	ZBLOCK	30	/TABLE TO HOLD THE LAST "BEST MOVE" ON ANY LEVEL

/SUBROUTINE TO SET AUTO-INDEX REG "XRO0" TO POINT TO
/THE WORD BEFORE THE 2WORD ENTRY IN THE "BESTBL" COROSPONDING WITH THIS PLY
SETPNT,	0000
	CLA
	TAD	PLY	/GET PLY #
	CLL RAL		/MULT TIMES 2 WORDS IN EACH ENTRY
	TAD	ADCON	/ADD IN ADDRESS CONSTANT
	DCA	XR0	/STORE ADDR AS ADVERTISED
	JMP  I	SETPNT	/RETURN
ADCON,	BESTBL-3
	-PAWN
	-PAWN
	-PAWN
	-PAWN
	-PAWN
	-PAWN
	-PAWN
	-PAWN
	-ROOK
	-KNIGHT
	-BISHOP
	-QUEEN
	-KING
	-BISHOP
	-KNIGHT
	-ROOK

PAGE

LKAD,	CLA		/FINISHED GENERATING & EXPLORING MOVES ON THIS LEVEL
	TAD	CVAL1	/SET RETURN VALUE = THIS LEVELS VALUE
	DCA	RVAL1
	JMP	DONE	/PREPARE TO RETURN

LKSM,	CLA		/ITS A STALEMATE!
	IFNZRO	LPTREE<
	TAD	("=
	JMS  I	ZOUT	/PRINTOUT STALEMATE INDICATION
>
	DCA	RVAL1	/SET RETURN VALUE TO TOTALY EVEN GAME ( 0 )
	JMP	LKXM	/TAKE SAME RETURN PATH AS A CHECKMATE NOW

/COME HERE TO RETURN FROM THE "LOOKA" SUBROUTINE
DONE,	CLA CMA		/-1 TO AC
	TAD	PLY	/DECREMENT PLY #
	DCA	PLY
	TAD	UVAL1	/RESTORE VARIOUS DATA TO ITS STATE BEFORE CALLING
	DCA	CVAL1
	IFNZRO	DEBUG	<
	POP1		/POP OUT PDL#1 VERIFIER WORD
	CIA		/SHOULD BE SAME ON EXIT AS WAS ON ENTRY
	TAD	PC01
	SZA		/AFTER COMPLIMENTING, SHOULD BE 0. IS IT?
	HLT		/NO. SURE GLAD I PUT THIS TEST IN!
	POP1		/DO THE SAME THING FOR PDL#2
	CIA
	TAD	PDLADR
	SZA		/IS PDL#2 IN LINE?
	HLT		/NO. AMOUNT OFF IS IN THE AC
>
	TAD	MOB1
	DCA	MOBMOD	/RESTORE MOBMOD COUNTER
	TAD	MOB0
	DCA	MOB1
	POP1
	DCA	MOB0
	POP1
	DCA	STRATG	/RESTORE STRATEGIC VALUE
	POP1
	DCA	GNCNT	/RESTORE OLD MOVE GENERATION COUNTER
	POP1		/POP OFF OLD PLY COMPENSATOR VALUE
	DCA	PLYFIX+1	/RESTORE IT
	POP1
	DCA	UVAL1	/RESTORE "UPPER LEVEL VALUE"
	POP1		/POP OFF RETURN ADDRESS
	DCA	TEMP	/RESTORE IT
	JMP  I	TEMP	/RETURN FROM "LOOKA" SUBROUTINE

LKCM,	CLA		/ITS A CHECKMATE.
	IFNZRO	LPTREE<
	TAD	("+
	JMS  I	ZOUT	/PRINT CHECKMATE INDICATION
>
	TAD	PLY	/SUBTRACT PLY # FROM
	TAD	(-3740	/VALUE FOR RETURN VALUE
	JMS	PLYFIX	/RETURN VALUE IS POSITIVE IF THIS IS AN EVEN PLY
	DCA	RVAL1
LKXM,	POP2		/POP THE 2 MARKER WORDS OFF OF PDL2
	POP2		/THAT "GNMV" PUT THERE
	JMP	DONE	/READY TO RETURN

/COLOR FIXING SUBROUTINE EXCLUSIVLY FOR THE "LOOKA" SUBROUTINE.
/FIXES COLOR WITH RESPECT TO PLY EVEN/ODD
PLYFIX,	0000
	CIA		/=NOP IF PLY IS ODD, OR TO = CIA IF PLY IS EVEN
	JMP  I	PLYFIX	/RETURN

/GENERAL PURPOSE COLOR FIXING ROUTINE
/SET "LCLRFX"+1 ONLY ONCE A PROGRAM INITIALIZATION TIME. SET IT TO
/EQUAL A "NOP" INSTRUCTION IF THE COMPUTER HAS WHITE, SET IT TO A
/"CIA" INSTRUSTION IF THE COMPUTER HAS BLACK
LCLRFX,	0000
	NOP		/COMPUTER HAS: WHITE="NOP", BLACK="CIA"
	JMP  I	LCLRFX	/RETURN

/STATIC EVALUATION ROUTINE
LEVAL,	CLA CLL
	JMS  I	ZMAPEC	/MAP PIECES
	TAD	WHOSE	/GET "WHOSE MOVE SWITCH"
	SMA CLA		/IS IT WHITES OR BLACKS?
	JMP	.+4	/WHITES
	TAD	BKING	/BLACKS. GET BLACKS KING ADDRESS
	JMS	TSTWAT	/FIND OUT IF IT IS ATTACKED
	JMP	.+3
	TAD	WKING	/GET WHITES KINGS ADDRESS
	JMS	TSTBAT	/FIND OUT IF IT IS ATTACKED
	TAD	PCNT	/GET # OF ATTACKERS
	SZA CLA		/IS THE KING IN CHECK?
	JMP	LKFUR	/YES. LOOK AHEAD 1 MORE MOVE
IFNZRO	LPTREE	<
	TAD	("#
	JMS  I	ZOUT	/PRINT EVALUATION INDICATOR
	ISZ	ENO	/INC EVALUATION #
	TAD	ENO	/FIND OUT IF IT IS OF SPECIAL INTREST
	CIA		/BY TESTING TO SE IF IT IS THE SAME
	TAD	ENOB	/AS "ENOB"
	SNA CLA		/IS IT?
	NOP		/YES. A BREAKPOINT FOR ODT MAY BE PLACED HERE
	TAD	ENO	/PRINT OUT THE EVALUATION #
	JMS	OCTNFM
>
	JMS	EVAL	/GET AN EVALUATION
	DCA	RVAL1	/SETUP RETURN VALUE
	JMP	DONE	/READY TO RETURN


/SUBROUTINE TO PRUNE UNDESIRABLE MOVES OUT OF THE TREE BEFORE THEY CREATE
/HUGE BRANCHES. WHAT TYPES OF MOVES ARE DESIRABLE AND UNDESIRABLE AT ANY GIVEN
/PLY, IS DETERMINED BY THE TABLE AT LOCATION "PRNPRO"
/THIS ROUTINE SHOULD SET "PRNCNT" TO THE NUMBER OF MOVES PRUNED
PRUNE,	0000
	CLA
	DCA	PRNCNT	/INIT PRUNED MOVE COUNTER TO 0
	TAD	GNCHEK	/GET # OF CHECKS ON THE KING
	SZA		/IS THE KING IN CHECK?
	JMP  I	PRUNE	/NO. DONT PRUNE ANY MOVES
	JMS	PLYCHP	/GET PLY #
	TAD	(JMP  I	.+3	/BUILD A JMP I  TO THE PROPER PRUNE PROCEDURE
	DCA	.+1	/PUT THE JMP I  DOWN SO THAT IT MAY BE EXECUTED
	HLT		/JMP GOES HERE

PRNPRO,	PPA		/PRUNE PROCEDURE FOR PLY 1
	PPB		/PRUNE PROCEDURE FOR PLY 2
	PPB		/PRUNE PROCEDURE FOR PLY 3
	PPB		/PRUNE PROCEDURE FOR PLY 4 
	PPB		/PRUNE PROCEDURE FOR PLY 5 
	PPB		/PRUNE PROCEDURE FOR PLY 6 
	PPB		/PRUNE PROCEDURE FOR PLY 7 
	PPB		/PRUNE PROCEDURE FOR PLY 8 OR GREATER

PPA,	JMS	BSTOP	/COUNT ON A "PRE-ANALYSIS"
PPZ,	JMP  I	PRUNE	/RETURN

PPB,	JMS	HIEP	/FIND OUT THE VALUE OF THE MOST FAVORABLE EN PRISE PIECE CAPTURE
	SNA CLA		/DOES A FAVORABLE ONE EXIST?
	JMP	.+4	/NO. COUNT ON THE ENTRY IN "BESTBL"
	JMS	SETPNT	/YES. SETUP POINTER FOR THE INSERTION
	TAD	HIEPMS	/OF THE EN PRISE PIECE CAPTURE MSW
	DCA  I	XR0	/INTO THE "BESTBL"
	JMS	BSTOP	/IF IT EXISTS, BSTOP WILL INSURE THAT IT IS LOOKED AT FIRST
	JMP  I	PRUNE	/RETURN
PAGE
/SUBROUTINE TO SCAN THROUGH THE LAST BUNCH OF MOVES IN PDL#2
/IF A MOVE EXISTS, WHICH HAS THE SAME MSW AS THE LAST "BEST MOVE"
/ON THIS PLY, THAT MOVE IS SWAPED WITH THE MOVE ON THE TOP OF THE LIST
BSTOP,	0000
	JMS	SETPNT
	TAD  I	XR0
	CIA
	DCA	TEMP2
	TAD	GNCNT
	CIA
	TAD	PRNCNT
	SNA 		/ANY MOVES TO RUMMAGE THRU?
	JMP  I	BSTOP	/NO. RETURN
	DCA	TEMP	/SETUP COUNT
	TAD	TEMP
	CLL RAL		/MULT TIMES 2 WORDS PER MOVE
	TAD	PDLADR
	DCA	TEMP1
BSTOP1,	TAD  I	TEMP1	/GET AN MSW
	IFNZRO	DEBUG	<
	SNA		/DOES IT LOOK LIKE AN MSW
	HLT		/NOT IF ITS 0 IT DOESNT
>
	TAD	TEMP2
	SNA CLA		/IS IT A MATCH?
	JMP	BSTOP2	/YES!! GO SWAP IT WITH THE MOVE ON TOP
	ISZ	TEMP1	/BUMP POINTER BY 2 TO POINT TO THE NEXT MSW
	ISZ	TEMP1
	ISZ	TEMP	/COMPARED AGAINST ALL MOVES?
	JMP	BSTOP1	/NO. DO ANOTHER
	JMP  I	BSTOP	/YES. RETURN
BSTOP2,	TAD	PDLADR
	TAD	(-2
	DCA	TEMP
	TAD  I	TEMP
	DCA  I	TEMP1
	TAD	TEMP2
	CIA
	DCA  I	TEMP
	ISZ	TEMP
	ISZ	TEMP1
	TAD  I	TEMP1
	DCA	XR0
	TAD  I	TEMP
	DCA  I	TEMP1
	TAD	XR0
	DCA  I	TEMP
	JMP  I	BSTOP


/SUBROUTINE TO EVALUATE THE BACK RANK
/TO FIND OUT WHAT'S NOT DEVELOPED, AND RETURN A VALUE FOR DEVELOPMENT
BREV,	0000
	CLA
	TAD	(NOP
	DCA	BREV2	/SETUP TO DO THE WHITE SIDE FIRST
	JMS	BREV1	/DO AN EVALUATION
	CIA		/NEGATE THE VALUE FOR WHITES SIDE
	TAD	STRATG
	DCA	STRATG
	TAD	[CIA
	DCA	BREV2	/SETUP TO DO THE BLACK SIDE
	TAD	(70	/RANK 8
	JMS	BREV1	/DO THE BLACK EVALUATION
	TAD	STRATG
	DCA	STRATG
	JMP  I	BREV	/RETURN WITH IT

BREV1,	0000
	TAD	(BOARD-1/CONSTANT FOR BOARD ADDRESS
	DCA	ITMP0
	DCA	TEMP2	/INIT MINOR PIECE COUNTER
	TAD	[7770	/COUNT FOR 10 SQUARES ON THE BACK RANK
	DCA	TEMP1
	TAD  I	ITMP0	/GET THE PIECES VALUE
BREV2,	HLT		/COMPLIMENT IT IF IT IS BLACK
	TAD	(-KNIGHT
	SNA		/IS IT A KNIGHT?
	ISZ	TEMP2	/YES. INC MINOR PIECE COUNTER
	TAD	(KNIGHT-BISHOP
	SNA CLA		/IS IT A BISHOP?
	ISZ	TEMP2	/YES. INC MINOR PIECE COUNTER
	ISZ	TEMP1	/DONE ALL 8 SQUARES YET?
	JMP	BREV2-1	/NO. GO BACK AND DO ANOTHER
	TAD	TEMP2	/ADD IN # OF MINOR PIECES
	RAL CLL		/MULT TIMES 2
	RAL CLL		/MULT TIMES 2 AGAIN (2*2=4)
	JMP  I	BREV1	/RETURN WITH RANK EVALUATION IN THE AC
/
/CENTER OCCUPATION EVALUATOR
COEV,	0000
	CLA
	TAD	(-4	/SETUP COUNT FOR 4 CENTER SQUARES
	DCA	TEMP1
	TAD	(TAD  I  COTB	/SETUP TO ACCESS ADDRESSES OF THE 4 CENTER SQUARES
	DCA	COEV1
COEV1,	HLT		/GET SQUARES VALUE
	SNA		/IS IT OCCUPIED
	JMP	COEV2	/NO. TEST TO SEE IF DONE
	SMA CLA		/IS IT A WHITE PIECE?
	TAD	(10	/VALUE WILL BE +4
	TAD	(-4	/OR -4 IF IT IS BLACK
	TAD	STRATG	/ADD TO THE CENTER OCCUPATION VALUE
	DCA	STRATG
COEV2,	ISZ	COEV1	/INC INSTRUCTION SO THAT IT REFFRENCES THE NEXT CENTER SQUARE
	ISZ	TEMP1	/DONE ALL 4 SQUARES YET?
	JMP	COEV1	/NO. DO ANOTHER
	TAD	TEMP	/YES. GET FINAL VALUE
	JMP  I	COEV	/AND RETURN

/ADDRESSES OF THE 4 CENTER SQUARES
COTB,	BOARD+33
	BOARD+34
	BOARD+43
	BOARD+44

/CASTLING STATUS EVALUATOR
CASTEV,	0000
	CLA
	TAD	WPSW
	RAR		/MOVE "CASTLED BIT" INTO LINK
	SZL CLA		/HAS WHITE CASTLED?
	TAD	(10	/YES ADD TO STRATEGIC VALUE
	TAD	STRATG
	DCA	STRATG
	TAD	BPSW
	RAR		/MOVE "CASTLED BIT" TO THE LINK
	SZL CLA		/HAS BLACK CASTLED YET?
	TAD	[7770	/YES. SUBTRACT POINTS FROM THE STRATEGIC VALUE
	TAD	STRATG
	DCA	STRATG
	JMP  I	CASTEV	/RETURN

PAGE
/SUBROUTINE TO TEST IF A PIECE IS EN PRISE
/CALL WITH THE ADDRESS OF THE SQUARE TO BE TESTED IN THE AC
/IF THE PIECE IS EN PRISE, RETURN WITH THE PREDICTED EXCHANGE
/LOSS IN THE AC, IF NOT 0 IS RETURNED
/THE ADDRESS OF THE SQUARE IS RETURNED IN "ENPRAD"
/RETURN WITH ADDR OF ATTACKER IN "ENPSQR"
/RETURN WITH ADDR OF THE LEAST VALUABLE DEFENDER IN "PSQR"
/RETURN WITH THE # OF ATTACKERS IN "ENPCNT"
/RETURN WITH THE # OF DEFENDERS IN "PCNT"
ENPRIS,	0000
	DCA	ENPRAD	/SAVE ADDR OF EN PRIS SQUARE
	JMS  I	ZMAPEC	/MAKE SURE PIECE MAP IS UP TO DATE
	TAD  I	ENPRAD
	SNA		/IS THERE A PIECE ON IT?
	JMP  I	ENPRIS	/NO. IDIOT! CONSIDER YOURSELF SAVED
	SMA CLA		/YES. IS IT WHITE OR BLACK?
	JMP	ENPRWH	/ITS WHITE
	TAD	ENPRAD	/BLACK. FIND OUT ABOUT WHITES ATTACKS
	JMS	TSTWAT
	TAD	PVAL
	DCA	ENPVAL	/SAVE VALUE OF SMALEST ATTACKER
	TAD	PCNT
	SNA		/ANY ATTACKERS?
	JMP  I	ENPRIS	/NO.RETURN
	DCA	ENPCNT	/SAVE # OF ATTACKERS
	TAD	PSQR
	DCA	ENPSQR	/SAVE ADDR OF LEAST VALUABLE ATTACKER
	TAD	ENPRAD	/FIND OUT ABOUT DEFENDERS NOW
	JMS	TSTBAT
	JMP	ENPR0	/ALL DONE SETTING UP. GO TO THE BUISINESS PART
ENPRWH,	TAD	ENPRAD	/FIND OUT ABOUT BLACK ATTACKS
	JMS	TSTBAT
	TAD	PVAL
	CIA
	DCA	ENPVAL	/SAVE VALUE OF LEAST VALUABLE ATTACKER
	TAD	PSQR
	DCA	ENPSQR	/SAVE ADDR OF LEAST VALUABLE ATTACKER
	TAD	PCNT
	SNA		/ANY ATTACKERS?
	JMP  I	ENPRIS	/NO. RETURN
	DCA	ENPCNT	/STORE # OF ATTACKERS
	TAD	ENPRAD	/FIND OUT ABOUT WHITES DEFENCE
	JMS	TSTWAT
	TAD	PVAL
	CIA		/COMPLIMENT VALUE OF LEAST VALUABLE DEFENDER
	DCA	PVAL
ENPR0,	TAD	ENPCNT	/GET # OF ATTACKERS
	CIA
	TAD	PCNT	/COMPARE WITH # OF DEFENDERS
	SMA CLA		/MORE ATTACKERS THAN DEFENDERS?
	JMP	ENPR1	/NO.
	TAD	PCNT	/# OF DEFENDERS
	CLL RAR
	SZA CLA		/MORE THAN 1 DEFENDER?
	JMP	ENPR1	/YES. TOO COMPLICATED TO PREDICT THE SWAP ALL THE WAY DOWN
	SNL CLA		/NO. ARE THERE ANY DEFENDERS AT ALL?
	JMP	ENPR2	/NO. ITS EN PRISE ALL RIGHT
	TAD  I	ENPRAD	/YES. ITS EXACTLY 1 DEFENDER
	JMS	CLRFIX
	TAD	PVAL	/ADD VALUE OF DEFENDER PLUS OBJECT
	TAD	ENPVAL	/COMPARE WITH THE ATTACKERS VALUE
	SMA CLA		/IS ATTACKER SMALLER THAN DEFENDER PLUS OBJECT?
	JMP	ENPR3	/NO. THE OBJECT IS NOT EN PRISE
	TAD	PVAL	/-D
	TAD	ENPVAL	/+A
	SPA SNA CLA	/IS DEFENDER SMALLER THAN ATTACKER?
	JMP	ENPR2	/NO. HE WONT CAPTURE BACK THEN
	TAD	PVAL	/YES
	TAD	ENPVAL
	JMS	CLRFIX
ENPR2,	TAD  I	ENPRAD
	CIA
	JMP  I	ENPRIS	/RETURN
ENPR1,	CLA
	TAD  I	ENPRAD	/COMPARE VALUE OF OBJECT
	JMS	CLRFIX
	TAD	ENPVAL	/WITH THE VALUE OF THE ATTACKER
	SMA		/IS THE ATTACKERS VALUE SMALLER?
ENPR3,	CLA		/NO. PIECE IS NOT EN PRISE
	CIA
	JMS	CLRFIX
	JMP  I	ENPRIS	/RETURN
ENPRAD,	0000
ENPVAL,	0000
ENPSQR,	0000
ENPCNT,	0000
	IFNZRO DEBUG<
/TEST OF THE "ENPRIS" ROUTINE
TESTEP,	JMS	INPUT
	JMS  I	ZMAPEC
	TAD	[BOARD
	DCA	TSTTMP
	TAD	(7700
	DCA	TSTCNT
TEP2,	TAD	TSTTMP
	JMS	ENPRIS
	SNA		/IS IT EN PRIS?
	JMP	TEP1	/NO
	JMS	OCTOUT
	JMS	SPACE
	TAD	TSTTMP
	JMS	OUTSQR
	JMS  I	ZCRLF
TEP1,	ISZ	TSTTMP
	ISZ	TSTCNT
	JMP	TEP2
	HLT
	JMP	TESTEP
TSTTMP,	0000
TSTCNT,	0000
>
PAGE
/SUBROUTINE TO RETURN THE EXCHANGE VALUE OF THE HIGHEST EN PRISE
/PIECE THAT CAN BE TAKEN BY THE SIDE TO MOVE
/ADDED IN WITH THE VALUE IS A 10 POINT "PENALTY" FOR EACH ADDITIONAL EN PRISE PIECE
/THAT CAN BE TAKEN
/THE VALUE IS RETURNED IN SUCH A WAY THAT IT CAN SIMPLY BE ADDED
/TO THE  EVALUATION
/CALL WITH AC CLEAR TO USE NORMALY
/THIS ROUTINE CALCULATES WHOSE MOVE IT IS BY EXAMINING LOCATION "WHOSE"
HIEP,	0000
	CLA
	TAD	WHOSE
	SPA CLA		/IS IT WHITES MOVE OR BLACKS?
	TAD	(NOP-CIA	/BLACKS - SET "HIEPX"=NOP
	TAD	[CIA	/WHITES - SET "HIEPX"=CIA
	DCA	HIEPX	/SEE
	DCA	HIEPVL	/INIT VALUE TO 0
	DCA	HIEPCN	/INIT COUNT TO 0
	JMS  I	ZMAPEC	/MAKE SURE THE PIECE MAP IS UP TO DATE
	TAD	(-12
	JMS	HIEPFX
	TAD	(MAP+12	/BUILD THE ADDR OF THE PIECE MAP(WHICHEVER ONE IT IS)
	DCA	HMAPAD
HIEP1,	CLA
	TAD  I	HMAPAD	/GET PIECE ADDR
	ISZ	HMAPAD	/INC MAP ADDRESS POINTER
	SNA		/DONE ALL PIECES YET?
	JMP	HIEP2	/YES
	DCA	HIEPTM	/STORE ADDR FOR THE MOMENT
	TAD  I	HIEPTM	/GET THE PIECES VALUE
	JMS	HIEPFX
	TAD	(-KING	/COMPARE IT WITH THAT OF A KING
	SNA CLA		/IS IT A KING?
	JMP	HIEP1	/YES. KINGS CANT BE SWAPED ANYWAYS
	TAD	HIEPTM	/NO. GET THE PIECES ADDR
	JMS	ENPRIS	/FIND OUT IF IT IS ENPRIS
	SNA		/IS IT?
	JMP	HIEP1	/NO. TRY THE NEXT ONE
	DCA	HIEPTM	/YES. SAVE THE EXCHANGE VALUE
	ISZ	HIEPCN	/INC EN PRIS PIECE COUNTER
	TAD	HIEPVL	/GET BEST VALUE SO FAR
	CIA
	TAD	HIEPTM	/COMPARE IT WITH THE ONE JUST AQUIRED
	JMS	HIEPFX
	SMA CLA		/IS THE ONE WE JUST GOT BIGGER?
	JMP	HIEP1	/NO. GO TRY ANOTHER PIECE
	TAD	HIEPTM	/YES.MAKE THE ONE WE JUST GOT THE NEW VALUE TO BEAT
	DCA	HIEPVL
	TAD	ENPSQR	/BUILD MSW FOR THE MOVE TO CAPTURE THIS EN PRISE PIECE
	AND	[0077	/"FROM SQUARE" IS THAT OF THE
	RTL CLL		/LEAST VALUABLE ATTACKER
	RTL
	RTL
	DCA	HIEPTM
	TAD	ENPRAD	/"TO SQUARE" IS THAT OF THE PIECE ITSELF
	AND	[0077
	TAD	HIEPTM	/COMBINE "TO" AND "FROM" 6BIT ADDRESSES
	DCA	HIEPMS	/INTO ONE CONVIENIENT MSW
	JMP	HIEP1	/GO TRY ANOTHER PIECE
HIEP2,	CLA CMA
	TAD	HIEPCN	/GET # OF EN PRISE PIECES
	SPA		/WERE THERE ANY?
	CLA		/NO
	CLL RTL
	RAL		/MULT TIMES 8 AND INCLUDE IN THE VALUE RETURNED
	CIA
	JMS	HIEPFX
	TAD	HIEPVL	/GET THE EXCHANGE VALUE
	JMP  I	HIEP	/RETURN

HIEPFX,	0000
HIEPX,	HLT		/NOP,BLACKS MOVE/CIA,WHITES MOVE
	JMP  I	HIEPFX

HIEPVL,	0000
HIEPTM,	0000
HIEPCN,	0000
HIEPMS,	0000
HMAPAD,	0000


/SUBROUTINE TO SETUP THE BOARD
SETBRD,	0000
	CLA CLL
	TAD	(-100	/IST PUT ALL OF THE PIECES ON THE BOARD
	DCA	TEMP	/SETUP A COUNT FOR 64 SQUARES
	TAD	(BOARD-1
	DCA	ITMP0	/BOARD ADDRESS TO AUTO INDEX REG
	TAD	(SAVBRD-1
	DCA	ITMP1	/SAVED BOARD ADDRESS TO AUTO-INDEX REG
	TAD  I	ITMP1	/MOVE FROM THE SAVED BOARD AREA
	DCA  I	ITMP0	/TO THE WORKING AREA
	ISZ	TEMP	/DONE 64 SQUARES YET?
	JMP	.-3	/NO. DO MORE
	TAD	(-40	/NOW CLEAR OUT THE MIDDLE
	DCA	TEMP
	TAD	(BOARD+17
	DCA	ITMP1
	DCA  I	ITMP1
	ISZ	TEMP	/CLEARED OUT 32 SQUARES YET?
	JMP	.-2	/NO. DO 1 MORE
	DCA	LSTMV
	DCA	WPSW	/ENABLE CASTLING BY WHITE
	DCA	BPSW	/AND BY BLACK
	DCA	PW	/INITIALIZE TOTAL PIECE VALUE
	JMP  I	SETBRD	/RETURN

COMTM,	IAC		/TOURNAMENT MODE SETTING
	IAC
COMBM,	IAC		/BLITZ MODE SETTING
	DCA	DEPTH	/DEPTH=3 FOR TOURNAMENT MODE, DEPTH=1 FOR BLITZ MODE
	JMP	COMMAN

PAGE

/THIS IS THE INTERRUPT HANDLING ROUTINE
INTHAN,	DCA	ACHOLD	/SAVE ACCUMULATOR
	RAL		/LINK TO AC11
	DCA	LKHOLD	/SAVE LINK
	KSF		/KEYBOARD INTERRUPT?
	HLT		/NO. UNEXPLANED INTERRUPT. PRESS START (CLEAR&CONT) TO CLEAR FLAGS
	KRB		/YES. GET THE CHAR
	SNA		/IS IT A NULL CHARACTER ?
	JMP	RTINT	/YES. IGNOR IT TOTALY
	AND	(0177	/MAKE SURE BIT 4 IS SET IN
	TAD	(200	/CASE OF A PARITY TTY
	DCA	CHAR	/NOW STORE THE CHAR. FOR EASY ACCESS
	TAD	ISW	/GET INPUT IN PROGRESS SWITCH
	SNA CLA		/IS IT SET?
	JMP	RTINT	/NO. RETURN AND FORGET THAT THIS HAPPENED
	TAD	CHAR	/LOAD IT BACK INTO THE AC
	JMS  I	ZOUT	/ECCO IT
	TAD	CHAR	/TEST IF IT IS TO BE IGNORED
	TAD	(-240
	SNA CLA		/IS IT A SPACE ?
	JMP	RTINT	/YES. IGNOR IT
	ISZ	CNTCHR	/TOO MUCH INPUT?
	SKP		/NO
	JMP	UGO	/YES. PRINT "^U", REINITIALIZE, AND TRY AGAIN
	TAD	CHAR	/LOAD THE CHAR BACK INTO THE AC AGAIN
	TAD	(-215	/FIND OUT IF IT IS A SPECIAL CHARACTER (CR OR RUBOUT)
	SNA		/IS IT A CR?
	JMP 	LINDUN	/YES! HE'S DONE TYPING THE INPUT LINE
	TAD	(215-377
	SNA		/IS IT A RUBOUT CHAR?
	JMP	RUBGO	/YES. DELETE THE LAST CHAR TYPED
	TAD	(377-225	/NO
	SNA CLA		/IS IT A CONTROL-U?
	JMP	UGO	/YES. DELETE A WHOLE LINE
	TAD	CHAR	/NO.
IFNZRO OS8<
	TAD	(-203
	SNA CLA		/IS CHAR A CONTROL-C  ?
	JMP	MONITR	/YES
	TAD	CHAR	/NO. GET ITS VALUE BACK AGAIN
>
	DCA  I	CLIST	/STORE THE CHAR. IN THE KEYBOARD BUFFER
RTINT,	TAD	LKHOLD	/RESTORE THE LINK TO ITS PRE-INTERRUPT STATE
	CLL RAR
	TAD	ACHOLD	/RESTORE ACCUMULATOR
	RMF		/AND THE MEMORY FIELDS
	ION		/WITH INTERRUPT ENABLED,
	JMP  I	IFRM	/RETURN TO MAIN PROGRAM
ACHOLD,	0000		/HOLD AC AFTER INTERRUPT
LKHOLD,	0000		/HOLD LINK AFTER INTERRUPT

LINDUN,	DCA  I	CLIST	/MARK THE END OF INPUT WITH A 0000 CHAR. IN BUFFER
	TAD	(KBUF-1	/REINITIALIZE THE KEYBOARD BUFFER
	DCA	CLIST
	DCA	ISW	/CLEAR THE INPUT SWITCH
	JMS  I	ZCRLF	/PRINT A CARRIAGE RETURN-LINE FEED
	JMP	RTINT	/RETURN

LNOGO,	JMS  I	ZCRLF	/PRINT A CARRIAGE RETURN LINE FEED
	JMS  I	ZBEGIN	/REINITIALIZE INPUT BUFFER
	JMP	RTINT	/RETURN FROM THE LAST INTERRUPT

/IO STALL SUBROUTINE: RETURN WHEN INPUT IS DONE
CHKIO,	0000
	CLA
	TAD	ISW	/GET THE INPUT SWITCH
	ISZ	RANDOM	/INCREMENT THE RANDOM NUMBER
	SZA CLA		/IS INPUT DONE?
	JMP	.-4	/NO: CHECK AGAIN
	IOF		/DONT NEED THIS ANYMORE
	JMP  I	CHKIO	/YES: RETURN

RUBGO,	CLA
	TAD	(KBUF-1
	CIA
	TAD	CLIST
	SNA CLA		/ARE WE AT THE BEGINING OF A LINE ALLREADY?
	JMP	LNOGO	/YES.
	TAD	("\	/NO. PRINT A "\" CHAR
	JMS  I	ZOUT
	CMA CLA		/NOW MOVE BACK THE BUFFER POINTER
	TAD	CLIST
	DCA	CLIST
	JMP	RTINT	/RETURN FROM INTERUPT

UGO,	CLA
	PRINTO;	MESG21	/PRINT A "^U"
	JMP	LNOGO	/GO SETUP FOR A NEW LINE

/FOLLOWING IS THE LEGAL  COMMAND LIST
/IT CONSISTS OF A NUMBER OF 2WORD ENTRIES
/THE 1ST WORD IN EACH ENTRY IS THE 6BIT REPRESENTATION(NEGATED FOR EASY COMPARING)
/OF A 2 CHARACTER COMMAND
/THE 2ND WORD CONTAINS THE ADDRESS TO GO TO IF THAT COMMAND IS TYPED
COMLST,	-2027;	COMPW	/PW - PLAY WHITE
	-2002;	COMPB	/PB - PLAY BLACK
	-2016;	COMPN	/PN - PLAY NIETHER WHITE OR BLACK
	-0204;	COMBD	/BD - DISPLAY THE POSITION
	-1120;	COMIP	/IP - INPUT A POSITION
	-2205;	START	/RE - RESET  (RESIGN)
	-1526;	CMOVE	/MV - MOVE
	-2313;	COMSK	/SK - SKIP A MOVE
	-0215;	COMBM	/BM - BLITZ MODE
	-2415;	COMTM	/TM - TOURNAMENT
	IFNZRO	LPTREE <
	-1424;	COMLT	/LT - OUTPUT TREE TO LINE PRINTER(LP08)
>
	-0000;	0000	/END OF COMMAND LIST

MESG14,	TEXT \STALEMATE\
MESG24,	TEXT \YOUR MOVE? \

PAGE

/MESSAGE PRINTING SUBROUTINE--CALL WITH ADDR OF MESSAGE IN AC
/RETURN WITH THE AC CLEAR
/IF CALLED WITH THE AC IS CLEAR THE ADDRESS OF THE MESSAGE IS TAKEN FROM THE WORD
/AT THE ADDRESS+1 OF THE CALL TO THIS SUBROUTINE, AND THE RETURN ADDRESS
/IS THE ADDRESS+2 OF THE CALLING JMS
MES,	0000
	SZA		/IS THE ADDRESS OF THE MESSAGE IN THE AC?
	JMP	.+3	/YES. DONT BOTHER GETTING IT FROM THE WORD FOLLOWING THE JMS
	TAD  I	MES	/NO. BOTHER PLEASE
	ISZ	MES	/AND INC THE RETURN ADDRESS
	DCA	TEMP	/STORE THE ADDRESS OF THE MASSAGE
MES2,	TAD  I	TEMP	/GRAB 2 CHARS. PACKED INTO 1 WORD
	RTR
	RTR
	RTR
	JMS	TYPO	/PRINT CHAR IN BITS 0-5
	TAD  I	TEMP
	JMS	TYPO	/PRINT CHAR IN BITS 6-11
	ISZ	TEMP	/NEXT WORD PLEASE
	JMP	MES2

TYPO,	0000
	AND	[0077	/CLEAROUT BITS BELONGING TO THE OTHER CHAR.
	SNA		/IS IT A NULL CHARACTER?
	JMP  I	MES	/YES: RETURN
	TAD	[-40	/NO. CONVERT IT TO 8 BIT
	SPA
	TAD	(100
	TAD	(240
	JMS  I	ZOUT	/NOW PRINT IT
	JMP  I	TYPO

/PRINTOUT SUBROUTINE--SINGLE CHARACTER
OUT,	0000
	TLS		/FIRST PRINT THE CHAR
	TSF		/WAIT FOR THE FLAG TO RETURN
	JMP	.-1	/NOT YET IT HASN'T
	TCF		/CLEAR FLAG TO AVOID TELLEPRINTER INTERUPTS
	CLA
	JMP  I	OUT	/RETURN

/CARRIAGE RETURN & LINE FEED SUBROUTINE
CRLF,	0000
	CLA
	TAD	(215
	JMS  I	ZOUT	/PRINT THE CR
	JMS  I	ZOUT	/AND A NULL
	TAD	(212
	JMS  I	ZOUT	/PRINT THE LF
	JMS  I	ZOUT	/PRINT A COUPLE OF NULL FILLER CHARS IN CASE SOMEONE
	JMS  I	ZOUT	/TRYS TO USE A FANCY VIDEO-SCREEN TERMINAL
	JMP  I	CRLF	/RETURN

/INITIALIZE INPUT
BEGIN,	0000
	CLA IAC
	DCA	ISW	/SET THE 'INPUT IN PROGRESS' SWITCH
	TAD	(KBUF-1	/INITIALIZE THE KEYBOARD BUFFER POINTER
	DCA	CLIST
	TAD	(-30
	DCA	CNTCHR	/30 CHARACTERS MAXIMUM
	KCC		/REINITIALZE THE KEYBOARD FLAG
	JMP  I	BEGIN	/RETURN

/GET A CHARACTER FROM THE INPUT BUFFER
/IGNOR  "-" AND ":" CHARACTERS
GETC,	0000
	CLA
	TAD  I	CLIST	/TAKE A CHAR. OUT OF THE BUFFER
	DCA	TEMP	/MAKE IT EASILY REACHED
	TAD	TEMP	/FIND OUT IF THE CHAR SHOULD BE IGNORED
	TAD	(-"-
	SNA		/IS IT A MINUS SIGN?
	JMP	GETC+1	/YES. IGNOR IT
	TAD	("--":	/NO. TEST FOR A COLON
	SNA CLA		/IS IT A COLON?
	JMP	GETC+1	/YES. IGNOR IT
	TAD	TEMP	/NO. LOAD IT BACK INTO AC
	JMP  I	GETC	/RETURN

/SUBROUTINE TO PRINT A "SIGNED OCTAL" NUMBER
OCTOUT,	0000
	DCA	TEMP
	JMS	SPACE	/PRINT A LEADING SPACE
	TAD	TEMP
	SPA CLA		/IS IT A NEGATIVE #?
	TAD	("--" 	/YES PRINT A MINUS SIGN
	TAD	(" 
	JMS  I	ZOUT
	TAD	TEMP	/GET # AGAIN
	SPA		/IS IT NEGATIVE?
	CIA		/YES. MAKE POSITIVE
	JMS	OCTNFM	/PRINT IN OCTAL
	JMP  I	OCTOUT	/RETURN

/SUBROUTINE TO PRINT OUT AN OCTAL NUMBER WITH NO FORMATING
OCTNFM,	0000
	RAL		/ROTATE INTO POSITION
	DCA	TEMP
	TAD	(-4
	DCA	TEMP1	/SETUP COUNT FOR 4 DIGITS
OCTMID,	TAD	TEMP
	RAL
	RTL
	DCA	TEMP
	TAD	TEMP
	AND	[0007
	TAD	("0
	JMS I	ZOUT
	ISZ	TEMP1
	JMP	OCTMID
	JMP  I	OCTNFM	/RETURN

/SUBROUTINE TO PRINT A SPACE CHARACTER
SPACE,	0000
	CLA
	TAD	(240	/LOAD AC WITH SPACE CODE
	JMS  I	ZOUT	/SEND IT OUT
	JMP  I	SPACE	/RETURN

IFNZRO	OS8	<
/PRINT A "^C" AND RETURN TO THE OS8 MONITOR
MONITR,	CLA
	PRINTO;	MESG18	/PRINT "^C"
	CIF CDF	0	/MONITOR IS IN FIELD 0
	JMP  I	(7600	/GO TO MONITOR
>

IFNZRO	LPTREE	<
/SUBROUTINE TO TAB OVER TO COLOMN # "PLY"
TABPLY,	0000
	CLA
	TAD	PLY	/GET PLY #
	SNA		/IS IT ZERO?
	IAC		/YES. DO ONE TAB ANYWAYS
	CIA
	DCA	CMBCNT	/SETUP COLOMN COUNTER
	PRINTO;	MESG19	/PRINT 8 SPACES
	ISZ	CMBCNT	/TABBED ENOUGH PLACES YET?
	JMP	.-3	/NO. TAB AGAIN
	JMP  I	TABPLY	/YES. RETURN
CMBCNT,	0000
>
PAGE

/SUBROUTINE TO TRY TO INTERPERT THE CONTENTS OF THE KEYBOARD
/BUFFER AS A MOVE TYPED IN USING MODIFIED
/ALGEBREIC NOTATION, TEST THE MOVES LEGALITY, AND MAKE THE
/MOVE ON THE BOARD
/IF INPUT IS NOT A LEGAL MOVE RETURN IS TO THE ADDRESS+1
/OF THE CALLING JMS  AND THE AC  MAY NOT BE CLEARED
INMV,	0000
	CLA
	DCA	IOMSW	/INITIALIZE MSW AND MDW
	DCA	IOMDW
	JMS  I	ZGETC	/GET A CHARACTER
	JMS	ISA2H	/IS IT A LETTER "A" TO "H" ?
	JMP	INCA	/NO. MOVE MUST BE CASTLING
	TAD	(-301
	RTL CLL
	RTL
	RTL
	JMS	INPAK	/STORE THIS CHAR AND GET NEXT
	JMS	IS128	/IS IT A NUMBER "1" TO "8" ?
	JMP  I	INMV	/NO: BAD INPUT, TAKE ERROR RETURN
	TAD	(-261
	RTR CLL		/ROTATE BITS 9-11 INTO THE 'FROM RANK' POSITION
	RTR
	JMS	INPAK	/PACK IT INTO MSW AND GET NEXT CHAR
	JMS	ISA2H	/IS IT A LETTER "A" TO "H" ?
	JMP  I	INMV	/NO. TAKE ERROR RETURN
	TAD	(-301
	JMS	INPAK
	JMS	IS128	/IS IT A NUMBER "1" TO "8" ?
	JMP  I	INMV	/NO. TAKE ERROR RETURN
	TAD	(-261
	RTL CLL		/YES. ROTATE BITS 9-11 INTO THE 'TO RANK' POSITION
	RAL
	JMS	INPAK
	TAD	(-"=
	SZA CLA		/IS IT AN EQUAL SIGN?
	JMP	INMID-1	/NO. INPUT FINISHED, CHECK FOR LEGALITY
	NOP		/YES. HE SAYS IT'S A PAWN PROMOTION
	JMS  I	ZGETC	/GET THE LETTER OF THE PROMOTION PIECE
	TAD	(-"Q
	SNA		/IS IT A QUEEN?
	JMP	IPPQ	/YES
	TAD	("Q-"R
	SNA		/IS IT A ROOK?
	JMP	IPPR	/YES
	TAD	("R-"B
	SNA		/IS IT A BISHOP?
	JMP	IPPB	/YES
	TAD	("B-"N
	SNA		/IS IT A KNIGHT?
	JMP	IPPN	/YES
	JMP  I	INMV	/NO. NONE OF THE ABOVE. TAKE ERROR RETURN
IPPQ,	IAC
IPPR,	IAC
IPPB,	IAC
IPPN,	TAD	(0004
	DCA	IOMDW
	JMP	INMID-1

INCA,	TAD	(-"O
	SZA CLA		/COULD IT BE CASTLING?
	JMP  I	INMV	/NO TAKE ERROR RETURN
	JMS  I	ZGETC	/IT MUST BE CASTLING, GET NEXT CHAR
	TAD	(-"O
	SZA CLA		/IS IT AN "O" ?
	JMP  I	INMV	/NO. TAKE ERROR RETURN
	TAD	PONDIR	/YES. THE MOVE IS CASTLING CALCULATE THE 8TH RANK
	AND	(7070	/AND USE IT TO HELP BUILD AN MSW

	TAD	(0406	/KING ALWAYS STARTS FROM FILE 4
	DCA	IOMSW
	JMS  I	ZGETC	/GET ANOTHER CHAR
	TAD	(-"O	/ANOTHER "O" MEANS QUEEN SIDE CASTLING
	SZA		/IS IT QUEENS SIDE?
	JMP	INMID-1	/NO. INPUT DONE. CHECK FOR LEGALITY
	TAD	(-4	/YES. CHANGE 'TO FILE' TO C
	TAD	IOMSW
	DCA	IOMSW
	JMS	GNMVSM	/GENERATE THE MOVES OF THE SIDE TO MOVE
INMID,	POP2		/POP OFF AN MDW
	DCA	TOMAK2	/STORE IT
	POP2		/POP OFF AN MSW
	SNA		/IS IT AN MSW OR THE END OF THE LIST?
	JMP  I	INMV	/END OF LIST AND MOVE NOT FOUND, TAKE ERROR RETURN
	CIA
	TAD	IOMSW	/COMPARE THE MSW WITH THE ONE HE INPUTED
	SZA CLA		/MATCH?
	JMP	INMID	/NO: TRY NEXT
	TAD	IOMSW	/YES
	DCA	TOMAK1	/STORE THE MSW
	TAD	IOMDW	/GET THE INPUTED MDW
	SNA CLA		/IS IT = 0  ?
	JMP	INMID2	/YES. MOVE IS LEGAL
	TAD	TOMAK2
	AND	[0007	/CLEAR IRRELEVENT BITS
	CIA
	TAD	IOMDW
	SZA CLA		/DO THE IMPORTANT PARTS OF THE MDW'S MATCH?
	JMP	INMID	/NO TRY NEXT MOVE FOR A MATCK
INMID2,	JMS  I	ZMKMV	/MAKE THE MOVE
	IPDL1		/REINITIALIZE PUSH DOWN LIST #1
	JMS	POPOUT	/REINITIALIZE PDL2
	ISZ	INMV	/NORMAL RETURN IS TO THE ADDRESS+2 OF THE CALLING JMS
	JMP  I	INMV	/RETURN

/SUBROUTINE USED BY INMV. ADDS NEW COMPONENT TO  'IOMSW'
/ALSO GETS NEXT CHAR FROM THE BUFFER, AND RETURN WITH ITS VALUE IN THE AC
INPAK,	0000
	TAD	IOMSW
	DCA	IOMSW
	JMS  I	ZGETC
	JMP  I	INPAK

MESG18,	TEXT \^C\
MESG15,	TEXT \O-O-O\
NAME,	TEXT \CHEKMO-II\

PAGE
/SUBROUTINE TO OUTPUT A MOVE IN MODIFIED ALGEBREIC NOTATION
/CALL WITH MSW IN 'IOMSW', AND MDW IN 'IOMDW'
OUTMV,	0000
	CLA
	TAD	(" 
	DCA	IOCH1
	TAD	(" 
	DCA	IOCH2
	TAD	IOMDW
	AND	[0007	/BUILD A JUMP
	TAD	(JMP  .+3
	DCA	.+1
	HLT		/A JUMP TO ONE OF THE NEXT 8 INSTRUCTIONS IS PLACED HERE

	JMP	OUTSTD	/STANDARD OUTPUT FOR NORMAL MOVES
	JMP	OUTQCA	/QUEEN-SIDE CASTLING
	JMP	OUTKCA	/KING-SIDE CASTLING
	JMP	OUTSTD	/STANDARD OUTPUT FOR 'EN PASSANT' CAPTURES
	TAD	("N-"B	/PRIMOTE TO A KNIGHT
	TAD	("B-"R	/PROMOTE TO A BISHOP
	TAD	("R-"Q	/PROMOTE TO A ROOK
	TAD	("Q	/PROMOTE TO A QUEEN
	DCA	IOCH2
	TAD	("=	/PRINT AN EQUAL SIGN BEFORE LETTER OF THE PROMOTION PIECE
	DCA	IOCH1
OUTSTD,	CLA		/DO STANDARD OUTPUT
	TAD	IOMSW	/GET THE MSW FOR THE MOVE TO BE OUTPUT
	RTR		/ROTATE THE 'FROM FILE' BITS INTO AC 9-11
	RTR
	RTR
	JMS	OUTSQR	/OUTPUT THE "FROM" SQUARE COORDINATES
	TAD	IOMDW	/TEST TO SEE IF MOVE IS A CAPTURE
	SPA CLA		/IS IT?
	TAD	(":-"-	/YES: OUTPUT A ":" INSTEAD OF A "-"
	TAD	("-	/LOAD AC WITH THE CODE FOR A DASH
	JMS  I	ZOUT	/OUTPUT IT
	TAD	IOMSW	/GET MSW
	JMS	OUTSQR	/OUTPUT THE "TO" SQUARE COORDINATES
	TAD	IOCH1	/THIS IS A SPACE UNLESS MOVE IS A PAWN PROMOTION
	JMS  I	ZOUT
	TAD	IOCH2	/THIS IS A SPACE UNLESS MOVE IS A PAWN PROMOTION
	JMS  I	ZOUT	/PRINT THE LAST CHARACTER AND,
	JMP  I	OUTMV	/RETURN

/SUBROUTINE TO OUTPUT THE COORDINATES OF A SQUARE
/CALL WITH SQUARE # IN AC BITS 6-11
OUTSQR,	0000
	DCA	IOTMP	/SAVE  SQR #
	TAD	IOTMP
	AND	[0007	/CLEAR BITS 0-8
	TAD	(301	/OUTPUT FILE AS A CHARACTER "A" TO "H"
	JMS  I	ZOUT
	TAD	IOTMP	/GET MSW
	RTR		/MOVE RANK INTO BITS 9-11
	RAR
	AND	[0007
	TAD	(261	/BUILD A CHARACTER "1" TO "8"
	JMS  I	ZOUT	/OUTPUT IT
	JMP  I	OUTSQR	/RETURN

OUTKCA,	IAC		/PASS OVER THE FIRST "O-" OF THE QUEEN SIDE CASTLING MESSAGE
OUTQCA,	TAD	(MESG15	/GET ADDRESS OF THE QUEEN SIDE CASTLING MESSAGE
	PRINTO		/TYPE THE MESSAGE
	JMP  I	OUTMV	/RETURN
IOCH1,	0000
IOCH2,	0000
IOTMP,	0000

/SUBROUTINE TO CHECK FOR A CHARACTER FROM "1" TO "8". SKIP IF IT IS
/CALL W/CHARACTER IN AC, RETURN SAME WAY
IS128,	0000
	TAD	(-"1
	SPA		/GREATER OR EQUAL TO "1"?
	JMP	.+4	/NO. DON'T SKIP
	TAD	[7770
	SPA CLA		/LESS THAN "8"?
	ISZ	IS128	/YES. INC RETURN ADDRESS
	CLA
	TAD	TEMP	/LOAD THE CHARACTER BACK INTO THE AC
	JMP  I	IS128	/RETURN

/SUBROUTINE TO CHECK FOR A CHARACTER FROM "A" TO "H"
/CALL W/CHARACTER IN AC, RETURN SAME
/SUBROUTINE EFFECTS A SKIP IF CHAR IS BETWEEN "A" AND "H"
ISA2H,	0000
	TAD	(-"A
	SPA		/IS IT >= "A" ?
	JMP	.+4	/NO. DONT SKIP
	TAD	[7770
	SPA CLA		/IS IT <= "H" ?
	ISZ	ISA2H	/YES. INC RETURN ADDRESS
	CLA
	TAD	TEMP	/GET CHAR BACK
	JMP  I	ISA2H	/RETURN

/SUBROUTINE TO TEST FOR CHECKMATE OR STALEMATE
QMATE,	0000
	JMS	GNMVSM	/GENERATE THE MOVES OF THE SIDE WHOSE MOVE IT IS
	JMS	POPOUT	/DONT NEED THE MOVES JUST THE INFO ON THEM
	TAD	GNCNT	/GET # OF MOVES GENERATED
	SZA CLA		/ANY?
	JMP  I	QMATE	/YES. RETURN
	TAD	CMSW	/NO. GET CHECKMATE SWITCH
	SNA CLA		/IS IT SET?
	TAD	(-MESG9+MESG14	/NO. GET ADDR OF STALEMATE MESSAGE
	TAD	(MESG9	/ADD ADDR OF CHECKMATE MESAGE
	PRINTO		/PRINT THE MESSAGE OUT
	JMS  I	ZCRLF
	JMS	DISPLA	/PRINTOUT THE FINAL POSITION
	JMP	START	/START A NEW GAME


	IFNZRO	LPTREE <
COMLT,	TAD	LTSW
	CMA
	DCA	LTSW
	JMP	COMMAN
>
COMSK,	TAD	WHOSE	/COMPLIMENT THE "WHOSE MOVE" SWITCH
	CMA		/SO THAT SOMEONE MISSES A MOVE
	DCA	WHOSE
	DCA	LSTMV	/DISABLE EN PASSANT PAWN CAPTURES FOR THE NEXT MOVE
	JMP	COMMAN

PAGE
MESG19,	TEXT \        \
MESG21,	TEXT \^U\

IFNZRO	LPTREE	<
/SUBROUTINE TO OUTPUT A CHARACTER TO THE LINE PRINTER
/CALL WITH THE CHAR. IN THE AC, RETURN WITH THE AC CLEARED
LPTOUT,	0000
	SNA		/TRYING TO PRINT A NULL CHAR ?
	JMP  I	LPTOUT	/YES. DONT BOTHER, JUST RETURN
	DCA	LPTMP	/STORE THE CHAR JUST FOR A MOMENT
	TAD	LTSW	/GET TREE PRINTOUT SWITCH
	SNA CLA		/IS IT SET?
	JMP  I	LPTOUT	/NO. DO NO OUTPUT TO THE LINE PRINTER
	LAS		/READ SWITCHES
	SMA CLA		/SWITCH 0 SET?
	JMP  I	LPTOUT	/NO. DO NOT OUTPUT TO LINE PRINTER
	TAD	LPTMP	/YES.
	PSKE		/ERROR?
	SKP		/NO. CONTINUE
	JMP	.-2	/YES. WAIT FOR THE ERROR TO GO AWAY
	PSKF		/IS THE PRINTER READY TO ACCEPT THE CHAR?
	JMP	.-1	/NO. TEST AGAIN, AND AGAIN
	PCLF PSTB	/YES. PRINT IT
	CLA		/GET READY TO RETURN
	PCIE		/CLEAR LINE PRINTER INTERUPT FLAG
	JMP  I	LPTOUT	/RETURN
LPTMP,	0000		/TEMP STORAGE FOR LINE PRINTER ROUTINE
LTSW,	0000		/TREE PRINTOUT SWITCH
>
/ CHESSBOARD PRINTER

DISPLAY,0
	JMS  I	ZCRLF	/PRINT A BLANK LINE
	TAD (BOARD+70-1
	DCA RNKPTR	/POINT TO TOP RANK
	TAD [7770
	DCA RNKKNT	/SET UP FOR 8 RANKS
RNKLUP,	TAD RNKPTR
	DCA XR0		/POINT TO BEFORE LEFTMOST SQUARE IN RANK
	TAD [7770
	DCA FILKNT	/SET UP FOR 8 SQUARES PER RANK
	JMP RL1
RL2,	TAD (240
	JMS I ZOUT
RL1,	DCA COLOR	/SET COLOR TO ZERO
	TAD I XR0	/GET PIECE
	SNA		/IS SQUARE OCCUPIED?
	JMP EMPTY	/NO
	SPA		/YES
	ISZ COLOR	/SET COLOR TO 1 IF BLACK PIECE
	SPA
	CIA		/TAKE ABSOLUTE VALUE OF PIECE
	TAD [-PAWN
	SNA		/IS IT A PAWN?
	JMP DP		/YES
	TAD (PAWN-KNIGHT/NO
	SNA		/IS IT A KNIGHT?
	JMP DN		/YES
	TAD (KNIGHT-BISHOP/NO
	SNA		/IS IT A BISHOP?
	JMP DB		/YES
	TAD (BISHOP-ROOK/NO
	SNA		/IS IT A ROOK?
	JMP DR		/YES
	TAD (ROOK-QUEEN	/NO
	SNA		/IS IT HER MAJESTY?
	JMP DQ		/YES
	TAD (QUEEN-KING	/NO
	SNA CLA		/IS IT HIS HIGHNESS?
	JMP DK		/YES
	TAD ("?-"P	/IT'S AN UNKNOWN PIECE
DP,	TAD ("P-"N
DN,	TAD ("N-"B
DB,	TAD ("B-"R
DR,	TAD ("R-"K
DK,	TAD ("K-"Q
DQ,	TAD ("Q
	DCA PIECE	/SAVE PIECE
	TAD COLOR	/WHICH COLOR PIECE IS IT?
	SZA CLA
	TAD ("B-"W	/BLACK
	TAD ("W		/WHITE
	JMS I ZOUT	/PRINT COLOR OF PIECE
	TAD PIECE
	JMS I ZOUT	/PRINT NAME OF PIECE
	JMP NEXT
EMPTY,	TAD XR0
	RTR
	RAR
	AND [0007	/ISOLATE RANK
	TAD XR0		/ADD IN FILE
	RAR		/PUT PARITY IN LINK
	SZL CLA		/WHITE OR BLACK SQUARE?
	TAD ("--"*	/WHITE
	TAD ("*		/BLACK
	DCA PIECE
	TAD PIECE
	JMS I ZOUT
	TAD PIECE
	JMS I ZOUT
NEXT,	ISZ FILKNT	/AT END OF RANK?
	JMP RL2		/NO, GO ON TO NEXT SQUARE
	JMS I ZCRLF	/YES, GO TO NEXT RANK
	TAD RNKPTR
	TAD [7770
	DCA RNKPTR
	ISZ RNKKNT	/WAS THIS THE LAST RANK?
	JMP RNKLUP	/NO, PROCEED TO NEXT RANK
	JMS I ZCRLF	/AN EXTRA CRLF FOR GOOD LUCK
	JMP I DISPLAY	/RETURN

PAGE

/CHESS POSITION INPUTTER
/INPUT A LINE AT A TIME IN FORSYTH NOTATION
/
/ POSIBLE ERRORS....
/ 1?	TRYING TO PUT TOO MUCH STUFF ON A RANK
/ 2?	INCOMPLETE RANK SPECIFICATION(NOT ENOUGH STUFF)
/ 3?	UNKNOWN PIECE LETTER
/ 4?	PIECE COLOR NOT "W" OR "B"

INPUT,	0
	JMS I ZCRLF
	TAD (BOARD+70-1
	DCA RNKPTR
	TAD [7770
	DCA RNKKNT	/SET UP FOR 8 RANKS
RNLUP,	TAD RNKPTR
	DCA XR0
	TAD	(">
	JMS  I	ZOUT	/PRINT A ">" TO INDIACTE READYNESS FOR INPUT
	TAD	(7767
	DCA FILKNT
	JMS I ZBEGIN	/SETUP TO READ A LINE OF INPUT
	ION		/GO !
	JMS I ZCHKIO
RL3,	JMS I ZGETC	/READ A CHARACTER
	SNA		/AT END OF LINE?
	JMP EOL		/YES
	JMS I (IS128	/IS CHAR A DIGIT?
	JMP LETTR	/NO
	TAD (-260	/YES, CONVERT TO DIGIT
	CIA
	DCA COLOR
	JMS	CHK	/TEST FOR TOO ENOUGH STUFF ON THIS RANK ALREADY
	DCA I XR0
	ISZ COLOR
	JMP .-3
	JMP RL3

LETTR,	TAD (-"B
	SNA		/IS IT A BLACK PIECE?
	JMP BLP		/YES
	TAD ("B-"W
	SZA CLA		/IS IT A WHITE PIECE?
	JMP ERR4	/NOT "B" OR "W"
WHP,	STA
BLP,	DCA COLOR
	JMS CHK
	JMS I ZGETC	/GET PIECE NAME
	TAD (-"B
	SNA		/IS IT A BISHOP?
	JMP GB		/YES
	TAD ("B-"N	/NO
	SNA		/IS IT A KNIGHT?
	JMP GN		/YES
	TAD ("N-"P	/NO
	SNA		/IS IT A PAWN?
	JMP GP		/YES
	TAD ("P-"R	/NO
	SNA		/IS IT A ROOK?
	JMP GR		/YES
	TAD ("R-"K	/NO
	SNA		/IT IT A KING?
	JMP GK		/YES
	TAD ("K-"Q	/NO
	SNA		/IT IT A QUEEN?
	JMP GQ		/YES
	TAD ("Q-"S	/NO
	SNA CLA		/IS IT A SPRINGER?
	JMP GN		/YES, ACCEPT AS KNIGHT
	JMP ERR3	/UNKNOWN PIECE

GP,	TAD (PAWN-KNIGHT
GN,	TAD (KNIGHT-BISHOP
GB,	TAD (BISHOP-ROOK
GR,	TAD (ROOK-QUEEN
GQ,	TAD (QUEEN-KING
GK,	TAD (KING
	ISZ COLOR	/WHICH COLOR
	CIA		/COMPLEMENT VALUE IF BLACK
	DCA I XR0	/STORE AWAY PIECE
	JMP RL3		/REITERATE

EOL,	ISZ	FILKNT	/WERE 8 SQUARES INPUTTED?
	JMP ERR2	/NO, TOO FEW SQUARES
	TAD RNKPTR
	TAD [7770
	DCA RNKPTR	/POINT TO NEXT RANK
	ISZ RNKKNT	/WAS THIS LAST RANK?
	JMP RNLUP	/NO
	DCA	BPSW	/YES. INITIALIZE POSITION STATUS WORDS
	DCA	WPSW	/TO ALLOW CASTLING
	DCA	LSTMV	/DISSALLOW EN PASSANT PAWN CAPTURES FOR THE NEXT MOVE
	JMS	BRDVAL	/THEN FIGURE OUT ITS VALUE
/<<DANGER>>    THE AC MIGHT NOT EQUAL ZERO NOW!
	JMS I ZCRLF	/LET GUY KNOW HE'S THROUGH
	JMS	DISPLA	/PRINT OUT THE BOARD JUST INPUTED
	JMP I INPUT	/RETURN

ERR4,	IAC
ERR3,	IAC
ERR2,	IAC
ERR1,	TAD (61
	JMS I ZOUT
	TAD ("?
	JMS I ZOUT
	JMS I ZCRLF
	JMP RNLUP

CHK,	0
	ISZ	FILKNT	/IS THIS RANK FULL ALREADY?
	JMP  I	CHK	/NO. KEEP GOING
	JMP	ERR1	/YES. SIGNAL ERROR

MESG9,	TEXT \CHECKMATE\
MESG22,	TEXT \B. \
MESG23,	TEXT \W. \

PAGE
*7400
/TABLE AREA

MAP,	ZBLOCK	50	/50 WORDS RESERVED FOR PIECE MAP

KBUF,	ZBLOCK	30	/30 WORDS RESERVED FOR THE KEYBOARD BUFFER

/ THE BOARD

BOARD,	IFNZRO	.&0077<?BOARD MUST OCCUPY 1ST OR 2ND HALF OF A PAGE ?>


        ROOK
        KNIGHT
        BISHOP
	QUEEN
        KING
        BISHOP
        KNIGHT
        ROOK

        PAWN
        PAWN
        PAWN
        PAWN
        PAWN
        PAWN
        PAWN
        PAWN

ZBLOCK  40

        -PAWN
        -PAWN
        -PAWN
        -PAWN
        -PAWN
        -PAWN
        -PAWN
        -PAWN

        -ROOK
        -KNIGHT
        -BISHOP
        -QUEEN
        -KING
        -BISHOP
        -KNIGHT
        -ROOK

$&$
SAID FARMER BROWN
WHOSE BALD
ON TOP
WISH I COULD
ROTATE THE CROP
BURMA SHAVE

CHEKMO-II WAS WRITTEN, PRODUCED AND DIRECTED BY:	JOHN E. COMEAU

