Subject: spacewar.pa

From: Al Kossow <[email-masked]>
Date: Wed, 16 Jul 1997 15:44:28 PDT

From: Mike Umbricht <[email-masked]>
To: [email-masked]
Message-ID: <[email-masked]>
Subject: Re: pdp-8 PAL8 assembler
Status: R

From: [email-masked] (Al Kossow)
>
>Could you forward a copy of this code to me? tnx..

Here is SPACE.PA

I will send SPACE.CF off in another message.

Enjoy,

-mike

============================= cut here =====================================
/	SPACE WAR
/
/	INTERPLANETARY DEATH AND DESTRUCTION ON YOUR
/	LAB-8
/
/	EVAN SUITS
/
/	THIS VERSION WORKS OFF EITHER THE BLUE RIBBON CONNECTOR OR THE
/	SR.  WHEN THE PROGRAM IS STARTED (AT 0200) OR RESTARTED THE
/	SR WILL BE TESTED AND IF =0000 WILL BE USED FOR THE COMMAND 
/	INPUT.  OTHERWISE, THE BLUE RIBBON CONNECTOR (AX08 * C0-C7 * 
/	XR OPTION ONLY) CONTINGENCY INPUTS WILL BE USED.
/
/	WHEN THE PROGRAM IS STARTED THE TWO SHIPS SHOULD
/	APPEAR ON THE SCREEN WITH SHIP 'ONE' ON THE LEFT, SHIP
/	'TWO' ON THE RIGHT.
/
/	THE COMMAND WORD BIT ASSIGNMENTS ARE:
/
/	SR BIT:		C:	FUNCTION:
/
/	0		0	SHIP ONE ROTATES LEFT
/
/	1		1	SHIP ONE ROTATES RIGHT
/
/	2		2	SHIP ONE ACCELERATES
/
/	3		3	SHIP ONE FIRES
/
/
/
/	8		4	SHIP TWO ROTATES LEFT
/
/	9		5	SHIP TWO ROTATES RIGHT
/
/	10		6	SHIP TWO ACCELERATES
/
/	11		7	SHIP TWO FIRES
/
/
/
/	NOTE THAT TURNING RIGHT AND LEFT SIMULTANEOUSLY THROWS
/	THE SHIP INTO HYPERSPACE.  IN THE CURRENT VERSION THE ODDS
/	ARE IN FAVOR OF YOUR MAKING IT BACK SAFELY.  THE GAME IS OVER
/	WHEN ONE OR BOTH OF THE SHIPS HAVE BEEN DESTROYED AND THE
/	WINNER (IF ANY) IS IN NORMAL SPACE.  WHEN THE WINNER
/	HAS BEEN ANNOUNCED, HIT ANY TTY KEY TO RESTART.
/



/	SYMBOL DEFINITIONS FOR PAL8-PAL10

ZTEN=6342
OTEN=6344

XRIN=6331
XRCL=6334

SKXK=6321
CLXK=6352

DSB=6324

DXC=6301
DYC=6311
DXL=6302
DYL=6312
DIS=6304

CRF=6072
CCF=6052

/
/	THIS PROGRAM RELIES ON THE PROGRAM INTERUPT FACILITY FOR
/	REAL WORLD TIMING PURPOSES.
/

	*0

	0			/EFFECTIVE JMS 0 ON PROGRAM INTERUPT
	JMP I 2			/EXIT IMMEDIATLY TO SERVICE ROUTINE
	INTSER

EMPTY,	0			/THESE LOCATIONS ARE RESERVED FOR
ODT1,	0			/DEBUGGERS, ETC.
ODT2,	0
ODT3,	0

/
/	ALL THE AUTO INDEX REGISTERS ARE NAMED BUT NOT ALL OF
/	THEM ARE USED. THE STATUS OF ANY GIVEN REGISTER CANNOT
/	BE DETERMINED AT ANY TIME EXCEPT BY CAREFUL INSPECTION OF
/	THE CODE.
/

	*10

AUTO10,	0
AUTO11,	0
AUTO12,	0
AUTO13,	0
AUTO14,	0
AUTO15,	0
AUTO16,	0
AUTO17,	0

/
/	THE FOLLOWING ARE THE DATA FILES FOR THE TWO SPACE SHIPS
/	AS WELL AS CERTAIN OTHER PARAMETERS FOR CALCULATING POSITIONS
/	AND SO ON.  THE ORDER OF THE LOCATIONS MUST BE PRESERVED 
/	ALTHOUGH THE SIZE OF THE TABLES MAY BE VARIED
/

	*20

ONEOUT,	0			/IF NON-ZERO CONTAINS REAMINING TIME OF EXPLOSION
ONECNT,	0			/NUMBER OF POINTS IN FIGURE TO BE DISPLAYED
ONEFLG,	0			/IN OR OUT OF NORMAL SPACE
ONETHE,	0			/ANGLE OF ORIENTATION ON SCREEN
ONEVEX,	0			/X COMPONENT OF VELOCITY
ONEVEY,	0			/Y COMPONENT OF VELOCITY
ONEPEX,	0			/X POSITION (12 BITS)
ONEPEY,	0			/Y POSITION (12 BITS)
ONESIN,	0			/SINE OF ANGLE
ONECOS,	0			/COSINE OF ANGLE
ONEFIN,	0			/SET WHEN EXPLOSION DIES OUT

TWOOUT,	0			/SAME CONTENT AND ORDER
TWOCNT,	0			/AS ABOVE
TWOFLG,	0
TWOTHE,	0
TWOVEX,	0
TWOVEY,	0
TWOPEX,	0
TWOPEY,	0
TWOSIN,	0
TWOCOS,	0
TWOFIN,	0

/
/	THESE LOCATIONS ARE USED BY THE "VECTOR GENERATOR" IN 
/	DISPLAYING THE FIGURES.  A FOUR DOT VECTOR WILL BE DRAWN
/	FROM XONE,YONE TO XTWO,YTWO WITH STEPS OF SIZE DIXTEM,DIYTEM
/

XONEDS,	0
YONEDS,	0
XTWODS,	0
YTWODS,	0
DIXTEM,	0
DIYTEM,	0
DISCNT,	0

/
/	THE NEXT LOCATIONS ARE USED BY CALPOS TO DO A FAST
/	MULTIPLY TO HELP CALCULATE THE DISPLAY FILES.
/
T10SIN,	0
T20SIN,	0
T30SIN,	0
T10COS,	0
T20COS,	0
T30COS,	0

CALSIN,	0
CALCOS,	0


/
/	NOW COME THE VARIOUS ODDS AND ENDS ONE USUALLY FINDS ON
/	PAGE ZERO
/

SINE,	SINEIN
COSINE,	COSINI
MULT,	MULTI
RSHIFT,	SHIFTR
VECTOR,	DISPLY
CALPOS,	POSCAL
INTWRD,	0
INTCNT,	0
CLOCK,	0
HYPER,	HYPSET
MESOUT,	CHARS
THEADJ,	THEAJI
VEESCL,	VEELIM
ISHFT,	DISHFT
RESET1,	RESE1
GAMOVR,	0
ACCFLG,	0
ACCPER,	-30
MEXP,	-400

PROX,	0
PROY,	0
PROLIF,	-360
BUFTMP,	0
ONEFIL,	DISBUF
TWOFIL,	DISBUF+40

P5,	5
P10,	10
P17,	17
P20,	20
P37,	37
P40,	40
P100,	100
P132,	132
P200,	200
P400,	400
P550,	550
P3777,	3777

M4,	-4
M6,	-6
M10,	-10
M11,	-11
M264,	-264
M200,	-200
M400,	-400
M550,	-550


/
/	THE PROGRAM MAY BE STARTED OR RESTARTED AT ANYTIME AT 0200.
/	THE DATA FILE ON PAGE ZERO IS CLEARED, ALL FLAGS INITIALIZED,
/	AND THE SR EXAMINED.  IF THE SR=0 THE DISPLAY UPDATE ROUTINES
/	ARE SET TO PICK UP THE STATUS WORD FROM THE SR.  IF THE SR
/	DOES NOT EQUAL ZERO, THE STATUS WORD IS READ FROM THE EIGHT
/	CONTINGENCY INPUTS ON THE BLUE RIBBON CONNECTOR OF THE AX08
/	(XR OPTION ONLY).  JUMP IS THEN TO THE DISPLAY
/	FILE UPDATE TO START OFF THE GAME.
/

	*200

START,	CLA CLL  		/START OR RESTART HERE ANY OLD TIME
	LAS			/SR
	SNA CLA
	TAD SWRD		/USE THE SR
	TAD XROPT		/USE THE BLUE RIBBON CONNECTOR
	DCA COLDST		/AND LEAVE IN THE TRAP LOCATION

RESTRT,	CLA CMA
	XRCL
	CLA CLL

	TAD P17			/FIRST CLEAR THE POSITION AND DATA
	DCA AUTO10		/TABLES OF THE TWO SHIPS
	TAD TABLEN
	DCA AUTO11
	DCA I AUTO10
	ISZ AUTO11
	JMP .-2

	TAD STRT1		/SET THE STARTING POSITIONS OF THE
	DCA ONEPEX		/TWO SHIPS
	TAD STRT2
	DCA TWOPEX
	TAD P37			/SET TRIG FUNCTIONS JUST IN CASE
	DCA ONECOS
	TAD P37
	DCA TWOCOS		/ZERO DEGREES IS POINTING STRAIGHT UP
	TAD ACCPER		/SET COUNT FOR VELOCITY INCREASE
	DCA ACCFLG
	DCA ONEFIN		/CLEAR ALL GAME END FLAGS
	DCA TWOFIN
	DCA GAMOVR
	JMS I BUFSET		/RESET ALL PROJECTILE DISPLAY BUFFERS
	TAD P400		/START UP THE CRYSTAL CLOCK IN THE AX08
	ZTEN
	OTEN
	TCF			/CLEAR OTHER REMAINING LIKELY FLAGS
	PCF
	RRB
	CRF
	CCF
	CLA
	JMP COLDST		/AND GO TO IT


/
/	UPDATE IS REACHED WHENEVER THE PROGRAM IS STARTED OR THE
/	CLOCK COUNT OVERFLOWS INDICATING TIME TO RECALCULATE THE
/	THE DISPLAY FILES AND REFRESH THE DISPLAY.  THE INTERUPT
/	COUNT IS RESTORED, THE STATUS WORD IS PICKED UP FROM EITHER
/	THE SR OR BRC, AND THE RECALCULATION PROCESS BEGUN.
/

UPDATE,	CLA CLL			/HERE ON CLOCK COUNT OVERFLOW.
				/START NEXT SWEEP
COLDST,	0			/TRAP TO READ SR OR BRC
	LAS			/HERE FOR SR
	DCA INTWRD		/STORE TEMPORARILY
	TAD INTWRD		/MASK OUT LEFTMOST 4 BITS
	RTR			/FOR NUMBER ONE
	RTR
	AND LFTHAF
	DCA INTTEM		/AND STORE
	TAD INTWRD		/MASK OUT RIGHTMOST BITS FOR NUMBER TWO
	AND RYTHAF
	TAD INTTEM		/ADD TOGETHER
	JMP .+3			/AND CONTINUE

CODST,	XRIN			/HERE FOR BRC - PICK UP AND CLEAR
	XRCL
	DCA INTWRD		/CONTINUE
	TAD M550		/RESTORE INTERUPT COUNT BEFORE NEXT
	DCA INTCNT		/UPDATE
	ION			/GET READY FOR THE NEXT CYCLE
	TAD ACCFLG		/ALLOW VELOCITY INCREASE THIS TIME?
	IAC			/ONLY WHEN ACCFLG=0
	SMA SZA
	TAD ACCPER		/IF ZERO, RESET COUNT
	DCA ACCFLG

	JMP I .+1		/NOW GET DOWN TO WORK.
	ONEUP

BUFSET,	SETBUF
TABLEN,	AUTO17-CALCOS
INTTEM,	0
LFTHAF,	0360
RYTHAF,	0017
STRT1,	1000
STRT2,	-1000
SWRD,	2000-CODST
XROPT,	JMP CODST


/
/	THIS IS THE INTERUPT SERVICE ROUTINE.  MOST OF THE
/	INTERUPTS WILL BE FROM THE CRYSTAL CLOCK WHICH WILL BE
/	COUNTED AND UNLESS THE COUNT OVERFLOWS THE INTERUPT IS
/	DISMISSED IMMEDIATLY.  IF THE COUNT OVER FLOWS, JMP IS TO
/	UPDATE WITH IOF.  
/
/	SPECIAL CASE IS KEYBOARD INTERUPT WHEN THE GAMOVR FLAG IS
/	SET IN WHICH CASE THE GAME IS RESTARTED.  
/
/	UNEXPECTED INTERUPTS ARE COUNTED AND AFTER ENOUGH OF THEM
/	HAPPEN THE PROGRAM HALTS.  IF THIS HAPPENS RELOAD OR FIND THE
/	STRANGE FLAG
/

INTSER,	DCA INTACC		/HERE RIGHT AFTER INTERUPT - STORE
	RAR			/AC AND LINK
	DCA INTLNK		/FOR POSSIBLE CONTINUATION
	SKXK			/WAS IT THE CRYSTAL CLOCK?
	JMP INTBUS		/NO TRY SOMETHING ELSE
	CLXK			/YES CLEAR THE FLAG
	ISZ CLOCK		/AND BUMP CLOCK COUNTER
	NOP			/IGNORE OVERFLOW
	ISZ INTCNT		/TIME FOR AN UPDATE?
	JMP INTRET		/NO, DISMISS THE INTERUPT
	JMP UPDATE		/YES, GO TO IT

INTBUS,	KSF			/HERE ON NON-CLOCK INTERUPT
	JMP .+5			/NOT THE KEYBOARD
	KCC			/CLEAR KEYBOARD FLAG
	TAD GAMOVR		/IS THE GAMEOVER
	SZA CLA
	JMP RESTRT		/YES, RESTART
	TCF			/NO, HELL WITH IT
	ISZ INTGLH		/COUNT ONE BADDIE
	SKP
	HLT			/HALT IF TOO MANY BADDIES

INTRET,	CLA CLL			/HERE TO DISMISS THE INTERUPT
	TAD INTLNK
	RAL
	TAD INTACC
	ION
	JMP I 0

INTACC,	0
INTLNK,	0
INTGLH,	0


/
/	NOW BEGINS THE GREAT UPDATE PROCEEDURE, FIRST FOR SHIP
/	NUMBER ONE (THE DELTA SHAPED SHIP WHICH APPEARS ON
/	THE LEFT AT THE START OF THE GAME).  IF ALIVE THE STATUS
/	WORD (INTWRD) IS TESTED FOR REQUESTS FOR LEFT TURN,
/	RIGHT TURN, THRUST ON, AND LAUNCH PROJECTILE.  THESE ACTIONS
/	MAY OR MAY NOT BE ACTED UPON DEPENDING ON COUNTS AND FLAGS.
/	WHEN THIS IS COMPLETE THE SAME OPERATION IS PERFORMED FOR
/	NUMBER TWO.
/

	*400

ONEUP,	TAD ONEFLG		/FIRST SEE IF IT'S IN NORMAL SPACE
	SNA
	JMP ONEOK		/YES IT IS
	IAC			/NO, BUT IS IT JUST COMING OUT?
	SNA
	TAD ONEFIN		/YES, THROW BACK IN IF ALREADY DESTROYED
	DCA ONEFLG		/OTHERWISE JUST COUNT ONE
	JMP I ITWOUP		/AND GO TO FIX UP NUMBER TWO

ONEOK,	TAD ONEOUT		/IN NORMAL SPACE - IS IT EXPLODING?
	SZA CLA
	JMP ONEFIG		/IF YES, ALLOW NO CONTROLS
	TAD TWOFIN		/HAS THE ENEMY BEEN VANQUISHED?
	SZA CLA
	JMS I ONEWN		/YES, SIGNAL VICTORY
	TAD INTWRD		/NOW BEGIN TEST OF REQUEST
	AND OP300		/LEFT AND RIGHT TURN TOGETHER MEAN HYPERSPACE!
	TAD OM300		/TEST BITS 4 AND 5
	SZA CLA
	JMP ONELEF		/NOPE, CONTINUE
	CMA			/YES, CALL HYPER WITH AC=-1 FOR NUMBER ONE
	JMP I HYPER
ONELEF,	TAD INTWRD		/REQUEST FOR LEFT TURN?
	AND P200		/TEST BIT 4
	SNA CLA
	JMP ONERYT		/NO
	CLA CLL CMA		/YES DECREMENT ANGLE
	JMP ONEFIG

ONERYT,	TAD INTWRD		/HOW ABOUT RIGHT TURN
	AND P100		/TEST BIT 5
	SZA CLA
	IAC			/YES, INCREMENT ANGLE

ONEFIG,	TAD ONETHE		/PICK UP AND ADJUST ANGLE (MAYBE)
	JMS I THEADJ		/BRING BACK WITHIN LIMITS OF TRIG FUNCTIONS
	DCA ONETHE		/AND STORE
	TAD ONETHE		/FIND THEM TRIG FUNCTIONS
	JMS I SINE		/AND STORE ONCE AND FOR ALL
	DCA ONESIN		/IN THE APPROPRIATE PLACES
	TAD ONETHE
	JMS I COSINE
	DCA ONECOS
	TAD ONEOUT		/DO NOT ALLOW THRUST IF EXPLODING
	SZA CLA
	JMP ONEVEL



ONEMOV,	TAD ACCFLG		/ALLOW ANY VELOCITY INCREASE THIS CYCLE?
	SZA CLA
	JMP ONEVEL		/NOPE
	TAD INTWRD		/YES, ANY REQUESTED?
	AND P40			/TEST BIT 6
	SNA CLA
	JMP ONEVEL		/NONE REQUESTED
	TAD ONECOS		/YES, ADD IN VELOCITY INCREMENT DEPENDING 
	TAD ONEVEY		/ON ORIENTATION
	JMS I VEESCL		/BUT DO NOT ALLOW TO EXCEED MAXIMUM
	DCA ONEVEY		/AND STORE
	TAD ONESIN		/DO THE SAME FOR THE OTHER (X) COMPONENT
	TAD ONEVEX
	JMS I VEESCL
	DCA ONEVEX

ONEVEL,	TAD ONEVEX		/NOW UPDATE THE POSITION WITH THE 
	JMS I ISHFT		/VELOCITY COMPONENTS DIVIDED BY 4
	JMS I ISHFT		/THIS MAINTAINS MAXIMUM RESOLUTION
	TAD ONEPEX
	DCA ONEPEX		/IGNORE ANY OVERFLOW
	TAD ONEVEY		/DO THE SAME FOR Y COORDINATE
	JMS I ISHFT		/AND VELOCITY COMPONENT
	JMS I ISHFT
	TAD ONEPEY
	DCA ONEPEY
	TAD ONEOUT		/DO NOT ALLOW PROJECTILE LAUNCH IF
	SZA CLA			/EXPLODING
	JMP I ITWOUP



ONELNC,	TAD LNC1FG		/OTHERWISE, SEE IF RELOAD IS FINISHED
	SNA CLA
	JMP .+3
	ISZ LNC1FG		/NO, CONTINUE RELOADING
	JMP I ITWOUP		/AND EXIT
	TAD INTWRD		/YES, READY TO LAUNCH, TRIGGER BEEN PULLED?
	AND P20			/TEST BIT7
	SNA CLA
	JMP I ITWOUP		/NO, WAIT FOR A BETTER SHOT
				/.....I GUESS.....
	TAD PROLIF		/YES, SET CYCLE COUNT FOR THIS LAUNCH
	DCA I AUTO16		/AUTO16 ALWAYS POINTS AT THE NEXT SLOT IN THE FILE
	TAD ONEVEX		/ADD SHIPS VELOCITY (SCALED OF COURSE)
	JMS I ISHFT		/TO ORIENTATION TO EXTABLISH X VELOCITY
	JMS I RSHIFT		/COMPONENT OF PROJECTILE
	TAD ONESIN
	JMS I RSHIFT		/AND STICK IT IN THE FILE
	DCA I AUTO16
	TAD ONESIN		/MOVE THE LAUNCH POINT OUTSIDE THE
	CLL RTL			/SHIP OF ORIGIN
	TAD ONEPEX
	DCA I AUTO16		/AND STORE X POSITION
	TAD ONEVEY		/NOW DO THE SAME FOR THE Y VELOCITY AND
	JMS I ISHFT		/POSITION
	JMS I RSHIFT
	TAD ONECOS
	JMS I RSHIFT
	DCA I AUTO16
	TAD ONECOS
	CLL RTL
	TAD ONEPEY
	DCA I AUTO16
	TAD M200		/START RELOAD CYCLE
	DCA LNC1FG
	JMS I RESET1		/RESET AUTO16 TO NEXT HOLE

	JMP I .+1		/NOW TO FIX IT UP WITH NUMBER TWO
ITWOUP,	TWOUP

LNC1FG,	0			/PROJECTILE LAUNCH ENABLE

OP300,	300			/HYPERSPACE REQUEST CODE BITS 4 AND 5
OM300,	-300
ONEWN,	ONEWIN			/POINTER TO VICTORY MESSAGE


/
/	HERE BEGINS THE UPDATE PROCEEDURE FOR SHIP NUMBER TWO.
/	OPERATION IS THE SAME AS FOR NUMBER ONE ABOVE.
/

	*600

TWOUP,	TAD TWOFLG		/FIRST SEE IF IT'S IN NORMAL SPACE
	SNA
	JMP TWOOK		/YES, CONTINUE
	IAC			/NO, BUMP COUNT AND TEST FOR REENTRY
	SNA
	TAD TWOFIN		/IF RE-ENTERING THROW BACK OUT IF FINISHED
	DCA TWOFLG		/AND CONTINUE
	JMP I IONEST

TWOOK,	TAD TWOOUT		/HERE WHEN READY TO UPDATE IN NORMAL SPACE
	SZA CLA			/IS IT EXPLODING?
	JMP TWOFIG		/YES DO NOT ALLOW HYPERSPACE
	TAD ONEFIN		/DID WE JUST WIN?
	SZA CLA
	JMS I TWOWN		/YES ENABLE END OF GAME MESSAGE
	TAD INTWRD		/TEST FOR HYPERSPACE REQUEST
	AND OP14
	TAD OM14		/BITS 8 AND 9 MUST BE SET
	SNA CLA
	JMP I HYPER		/8 AND 9 SET. ENTER HYPER ROUTINE WITH AC=0
				/FOR SHIP NUMBER 2
TWOLEF,	TAD INTWRD		/TEST FOR LEFT TURN - BIT 8
	AND P10
	SNA CLA
	JMP TWORYT		/NOT SET
	CLA CLL CMA 		/SET, DECREMENT TWOTHE BY 1 DEGREE
	JMP TWOFIG		/SKIP TEST FOR RIGHT TURN

TWORYT,	CLA CLL IAC RTL		/TEST FOR RIGHT TURN - BIT 9
	AND INTWRD
	SZA CLA
	IAC			/IF SET INCREMENT TWOTHE BY 1 DEGREE

TWOFIG,	TAD TWOTHE		/UPDTAE TWOTHE
	JMS I THEADJ		/BRING TO WITHIN LIMITS OF SINE,COSINE
	DCA TWOTHE		/AND STORE
	TAD TWOTHE
	JMS I SINE		/CALCULATE SINE AND COSINE FUNCTIONS
	DCA TWOSIN		/AND STORE IN DATA TABLE
	TAD TWOTHE
	JMS I COSINE
	DCA TWOCOS
	TAD TWOOUT		/DO NOT ALLOW VELOCITY CHANGE IF EXPLODING
	SZA CLA
	JMP TWOVEL



TWOMOV,	TAD ACCFLG		/NOW FOR ACCELERATION.  TEST TO SEE IF ALLOWED
	SZA CLA			/DURING THIS UPDATE CYCLE
	JMP TWOVEL		/NOPE
	CLL IAC RAL		/YES, TEST FOR BIT 2 SET
	AND INTWRD
	SNA CLA
	JMP TWOVEL		/NOT SET

	TAD TWOSIN		/UPDATE X VELOCITY COMPONENT BY SINE OF
	TAD TWOVEX		/ANGLE OF ORIENTATION
	JMS I VEESCL		/AND SCALE TO NOT EXCEED MAX
	DCA TWOVEX		/UPDATE Y COMPONENT WITH COSINE

	TAD TWOCOS
	TAD TWOVEY
	JMS I VEESCL
	DCA TWOVEY

TWOVEL,	TAD TWOVEX		/NOW UPDATE THE POSITION WITH THE VELOCITY
	JMS I ISHFT		/COMPONENTS/16
	JMS I ISHFT
	TAD TWOPEX
	DCA TWOPEX
	TAD TWOVEY
	JMS I ISHFT
	JMS I ISHFT
	TAD TWOPEY
	DCA TWOPEY
	TAD TWOOUT
	SZA CLA
	JMP I IONEST



TWOLNC,	TAD LNC2FG		/NOW CHECK FOR PROJECTILE LAUNCH. FIRST
	SNA CLA			/TEST TO SEE IF RELOAD COMPLETE
	JMP .+3
	ISZ LNC2FG		/NO, COUNT ONE CYCLE AND EXIT
	JMP I IONEST
	IAC			/YES, TEST TRIGGER BIT 11
	AND INTWRD
	SNA CLA
	JMP I IONEST		/NOT SET, HELL WITH IT

	TAD PROLIF		/OK, SET PROJECTILE LIFE
	DCA I AUTO16		/AUTO16 IS ALWAYS POINTING AT THE NEXT SLOT
	TAD TWOVEX		/ADD SHIPS VELOCITY
	JMS I ISHFT		/(ADJUSTED)
	JMS I RSHIFT
	TAD TWOSIN		/TO THAT OF PROJECTILE  - AGAIN X COMPONENT
	JMS I RSHIFT		/FROM SINE OF ANGLE OF ORIENTATION
	DCA I AUTO16
	TAD TWOSIN		/SET INITIAL POSITION TO BE JUST AHEAD
	CLL RTL			/OF THE SHIP
	TAD TWOPEX		/X COMPONENT
	DCA I AUTO16
	TAD TWOVEY		/NOW THE Y COMPONENTS FROM Y VELOCITY
	JMS I ISHFT		/Y POSITION AND COSINE
	JMS I RSHIFT
	TAD TWOCOS
	JMS I RSHIFT
	DCA I AUTO16
	TAD TWOCOS
	CLL RTL
	TAD TWOPEY
	DCA I AUTO16
	TAD M200
	DCA LNC2FG		/200 CYCLES OF RELOAD
	JMS I RESET1		/DRINK LEADEN DEATH, NUMBER ONE!

	JMP I .+1		/FINAL EXIT TO DISPLAY FILE CALCULATIONS
IONEST,	ONESET

LNC2FG,	0			/RELOAD COUNT

OP14,	14			/HYPERSPACE CODE
OM14,	-14
TWOWN,	TWOWIN


/
/	HERE BEGINS THE DISPLAY CALCULATIONS FOR THE TWO SHIPS.  AT
/	THIS POINT ONLY THE POSITION AND ORIENTATION OF EACH VESSEL
/	IS ONF INTEREST SINCE THE VELOCITY AND ALL THAT HAVE ALREADY
/	BEEN TAKEN CARE OF.  FOR THE BOTH SHIPS THE DISPLAY FILES ARE
/	CALCULATED AS A SERIES OF PAIRS OF X,Y COORDINATES.  BETWEEN
/	EACH PAIR OF POINTS A FOUR POINT VECTOR WILL BE DRAWN.  THE
/	ACTUAL COORDINATES ARE CALCULATED AS DISPLACEMENTS
/	FROM THE CENTRAL PSOTION OF THE SHIP, TAKING INTO ACCOUNT THE
/	ANGLE OF ORIENTATION.  THE FORMULAS FOLLOWED ARE:
/
/	X(POINT)=X(BASE)+X(REL)*COS[THE]+Y(REL)*SINE[THE]
/
/	Y(POINT)=Y(BASE)+Y(REL)*COS[THE]-X(REL)*SINE[THE]
/
/	WHERE SINE[THE] AND COS[THE] ARE THE FUNCTIONS OF THE
/	ANGLE OF ORIENTATION, X(BASE) AND Y(BASE) ARE THE 
/	COORDINATES OF THE SHIPS POSITION AND X(REL) AND Y(REL)
/	CORRESPOND TO DISPLACEMENT PAIRS DEPENDING ON THE SHAPE
/	OF THE FIGURE.  ALL X AND Y RELS LIE WITHIN THE RANGE 0-3 AND
/	THERE FORE ALL NECESSARY DISPLACEMENTS FROM BASE COORDINATES
/	MAY BE CALCULATEDFROM DIFFERENT COMBINATIONS OF T10SIN, T20COS
/	ETC.  THESE VALUES ARE CALCULATED BY A CALL TO POSCAL WITH THE SINE 
/	AND COSINE OF THE ANGLE OF INTEREST IN CALSIN AND CALCOS.
/
/	FOLLOWING THIS METHOD ANY FIGURE DESCRIBABLE WITH A 7 BY 7
/	MATRIX OF POINTS MAY BE QUICKLY CALCULATED.
/
/	BEGINNING AT ONESET DIFFERENT DISPLACEMENT PAIRS ARE CALCULATED
/	AND DEPOSITIED THROUGH AUTO10 TO FORM THE DISPLAY FILE FOR SHIP NUMBER 
ONE.
/

	*1000

ONESET,	CLA CLL			/BEGIN DISPLAY FILE FOR NUMBER ONE
	TAD ONEFLG		/DONT BOTHER IF NOT IN NORMAL SPACE
	SZA CLA
	JMP I ITWOST
	TAD ONESIN		/SET UP FOR MATRIX COMPONENT CALCULATIONS
	DCA CALSIN
	TAD ONECOS
	DCA CALCOS
	JMS I CALPOS		/CALL THE CALCULATOR

/
/	CONSIDER THE 7 BY 7 MATRIX OF DISPLACEMENT POINTS WITH THE
/	CENTER AT 0,0 CORRESPONDING TO THE SHIPS POSITION.  A SERIES
/	OF POINTS IS NOW DESCRIBED AROUND THIS CENTER USING THE
/	MULTIPLES OF THE TRIG FUNCTIONS JUST CALCULATED
/	SO THAT ANY POINT ON THE OUTLINE IS DESCRIBABLE AS X,Y
/	DISPLACED BY X,Y OF THE SHIP ITSELF
/

	TAD ONEFIL		/SET UP AUTO10 AS THE DISPLAY FILE
	DCA AUTO10		/POINTER
	TAD ONEPEX		/THE FIRST POINT OF THE OUTLINE IS
	TAD T30SIN
	DCA I AUTO10		/	0,3	OR TOP CENTER
	TAD ONEPEY
	TAD T30COS
	DCA I AUTO10

	TAD T10COS
	CIA			/THE SECOND IS 
	TAD ONEPEX
	DCA I AUTO10		/	-1,0
	TAD T10SIN		/OR JUST LEFT OF DEAD CENTER
	TAD ONEPEY		/AND SO ON
	DCA I AUTO10

	TAD T30SIN
	TAD T30COS		/THE THIRD POINT IS
	CIA
	TAD ONEPEX		/	-3,-3
	DCA I AUTO10
	TAD T30COS		/OR BOTTOM LEFT HAND CORNER
	CIA
	TAD T30SIN
	TAD ONEPEY
	DCA I AUTO10



	TAD T10SIN
	CIA			/FOURTH POINT
	TAD ONEPEX
	DCA I AUTO10		/	0,-1
	TAD T10COS
	CIA			/OR JUST BELOW CENTER
	TAD ONEPEY
	DCA I AUTO10

FLAM1,	TAD INTWRD		/TEST FOR POWER ON. IF ON, DRAW THE
	AND P40			/FLAME WITH AN EXTRA POINT SOME 
	SNA CLA			/DISTANCE DIRECTLY BELOW THE SHIP
	JMP ONECON		/POWER NOT ON - CONTINUE
	TAD ONEOUT		/DO NOT ALLOW IF EXPLODING
	SZA CLA
	JMP ONECON

	TAD ONFG1		/USE ONFG1 TO TURN THE FLAME ON AND 
	SNA			/OFF TO MAKE IT FLICKER.  DISPLAY THE
	CLA CLL CMA RAL		/FLAME ONE TIME OUT OF THREE
	DCA ONFG1

	ISZ ONFG1
	JMP ONECON		/ONE OUT OF THREE TIMES THIS WILL SKIP

	TAD ONFG2		/VARY ALSO THE LENGHT OF THE FLAME
	CMA			/WITH LONG SHORT LONG SHORT
	DCA ONFG2

	TAD ONFG2		/TIP OF FLAME AT EITHER
	SNA CLA
	TAD T10SIN		/	0,-4	OR
	TAD T30SIN		/	0,-3
	CIA
	TAD ONEPEX
	DCA I AUTO10
	TAD ONFG2
	SNA CLA
	TAD T10COS
	TAD T30COS
	CIA
	TAD ONEPEY
	DCA I AUTO10

	TAD T10SIN
	CIA
	TAD ONEPEX		/RETURN DISPLAY TO 0,-1
	DCA I AUTO10
	TAD T10COS
	CIA
	TAD ONEPEY
	DCA I AUTO10
	CLA CLL CMA RAL		/ADD -2 TO POINT COUNT



ONECON,	TAD M6			/SET POINT COUNT TO -6 OR -8
	DCA ONECNT

	TAD T30SIN		/CONTINUE WITH DISPLAY FILE - THIS POINT
	CIA
	TAD T30COS		/	AT 3,-3
	TAD ONEPEX		/ 
	DCA I AUTO10		/OR LOWER RIGHT HAND CORNER
	TAD T30SIN
	TAD T30COS
	CIA
	TAD ONEPEY
	DCA I AUTO10

	TAD T10COS		/NEXT
	TAD ONEPEX		/ 
	DCA I AUTO10		/	1,0
	TAD T10SIN		/ 
	CIA			/ OR JUST RIGHT OF CENTER
	TAD ONEPEY
	DCA I AUTO10

	TAD T30SIN		/FINALLY BACK TO
	TAD ONEPEX		/ 
	DCA I AUTO10		/	0,3
	TAD T30COS		/ 
	TAD ONEPEY		/ TOP CENTE
	DCA I AUTO10

	JMP I ITWOST		/NOW FOR NUMBER TWO
ITWOST,	TWOSET

ONFG1,	0			/USED TO COUNT FLICKERS
ONFG2,	0			/SHORT OR LONG FLAG


/
/	HERE BEGINS THE DISPLAY FILE GENERATOR FOR SHIP TWO.
/	IT WORKS JUST LIKE THE ONE FOR NUMBER ONE BUT WITH
/	DIFFERENT DISPLACEMENT PAIRS AND TWO EXTRA POINTS
/

	*1200

TWOSET,	CLA CLL			/DONT BOTHER IF NOT IN NORMAL SPACE
	TAD TWOFLG
	SZA CLA
	JMP I IFILDS
	TAD TWOSIN		/SET UP TO HAVE DISPLACEMENT INCREMENTS
	DCA CALSIN		/CALCULATED
	TAD TWOCOS
	DCA CALCOS
	JMS I CALPOS

	TAD TWOFIL		/SET AUTO10 TO POINT TO SECOND DISPLAY
	DCA AUTO10		/FILE
	TAD T30SIN		/FIRST POINT AT
	TAD TWOPEX		/ 
	DCA I AUTO10		/	0,3
	TAD T30COS		/ 
	TAD TWOPEY		/ OR TOP CENTER
	DCA I AUTO10

	TAD T20COS
	CIA
	TAD T20SIN
	TAD TWOPEX
	DCA I AUTO10
	TAD T20SIN
	TAD T20COS		/SECOND POINT
	TAD TWOPEY		/	-2,2
	DCA I AUTO10

	TAD T20COS		/THIRD POINT
	CIA			/	-2,0
	TAD TWOPEX
	DCA I AUTO10
	TAD T20SIN
	TAD TWOPEY
	DCA I AUTO10

	TAD T20COS
	TAD T30SIN
	CIA
	TAD TWOPEX		/FOURTH POINT
	DCA I AUTO10		/	-2,-3
	TAD T30COS
	CIA
	TAD T20SIN
	TAD TWOPEY
	DCA I AUTO10



	TAD T20SIN
	CIA			/NEXT
	TAD TWOPEX		/	0,-2
	DCA I AUTO10
	TAD T20COS
	CIA
	TAD TWOPEY
	DCA I AUTO10

FLAM2,	CLA CLL IAC RAL		/NOW THE FLAME BIT. CHECK FOR POWER ON
	AND INTWRD
	SNA CLA
	JMP TWOCON		/NO, FORGET IT
	TAD TWOOUT		/NOT ALLOWED IF EXPLODING
	SZA CLA
	JMP TWOCON

	TAD TWFG1		/SET THE 1-3 FLICKER AS WITH #1
	SNA
	CLA CLL CMA RAL
	DCA TWFG1

	ISZ TWFG1		/ALSO THE LENGHT VARIATION
	JMP TWOCON

	TAD TWFG2		/EVERY OTHER TIME LONG
	CMA
	DCA TWFG2
				/FLAME TIP AT EITHER
	TAD TWFG2		/	0,-3
	SNA CLA			/OR
	TAD T20SIN		/	0,-5
	TAD T30SIN
	CIA
	TAD TWOPEX
	DCA I AUTO10
	TAD TWFG2
	SNA CLA
	TAD T20COS
	TAD T30COS
	CIA
	TAD TWOPEY
	DCA I AUTO10

	TAD T20SIN		/NOW BACK UP TO THE SHIP
	CIA
	TAD TWOPEX
	DCA I AUTO10
	TAD T20COS
	CIA
	TAD TWOPEY
	DCA I AUTO10

	CLA CLL CMA RAL		/ADD -2 TO POINT COUNT



TWOCON,	TAD M10			/SET POINT COUNT TO -8 OR -10
	DCA TWOCNT

	TAD T30SIN		/CONTINUE WITH DISPLAY FILE
	CIA			/NEXT POINT AT 2,-3
	TAD T20COS
	TAD TWOPEX
	DCA I AUTO10
	TAD T30COS
	TAD T20SIN
	CIA
	TAD TWOPEY
	DCA I AUTO10

	TAD T20COS		/NEXT POINT
	TAD TWOPEX		/ 
	DCA I AUTO10		/	2,0
	TAD T20SIN
	CIA
	TAD TWOPEY
	DCA I AUTO10

	TAD T20COS		/AND THE NEXT AT
	TAD T20SIN
	TAD TWOPEX		/	2,2
	DCA I AUTO10
	TAD T20SIN
	CIA
	TAD T20COS
	TAD TWOPEY
	DCA I AUTO10

	TAD T30SIN
	TAD TWOPEX
	DCA I AUTO10
	TAD T30COS		/AND THE LAST AT
	TAD TWOPEY		/ 
	DCA I AUTO10		/	0,3

	JMP I IFILDS		/NOW TO DISPLAY THE WHOLE MESS
IFILDS,	FILDIS

TWFG1,	0			/FLIK THE FLAME
TWFG2,	0			/LONG OR SHORT


/
/	HERE TO DISPLAY THE TWO SHIPS.  CHECK FIRST FOR COLLISION
/	AND THEN SET THE TWO PAIRS OF COORDENATES FOR THE END
/	POINTS AND CALL THE "VECTOR GENERATOR" TO DRAW THE DOTS
/	IN BETWEEN.  WHEN THE COUNT OVERFLOWS DO THE SAME FOR
/	NUMBER TWO.  THEN EXIT TO DISPLAY ALL THE PROJECTILES.
/

	*1400

FILDIS,	CLA CLL			/ALL SET TO GO
	JMS I COLIDE		/TEST FOR COLLISION FIRST
	DSB 1			/IF NO COLLISION
	TAD ONEFLG		/SKIP NUMBER ONE IF NOT IN NORMAL 
	SZA CLA			/SPACE
	JMP TWODIS

	TAD ONEFIL		/SET UP POINTERS TO DISPLAY FILE
	DCA AUTO10		/FOR NUMBER ONE
	TAD ONECNT		/ALONG WITH VECTOR COUNT
	DCA AUTO11
	TAD I AUTO10		/SET OUT THE FIRST POINT PAIR
	DCA XONEDS
	TAD I AUTO10
	DCA YONEDS
	TAD ONEOUT		/NORMAL DISPLAY OR EXPLOSION?
	SZA CLA
	JMP I IONEEX		/GO ELSE WHERE FOR EXPLOSION

FILONE,	TAD I AUTO10		/STEP TO NEXT PAIR OF POINTS
	DCA XTWODS		/SET X AND Y TO NEW POINT
	TAD I AUTO10
	DCA YTWODS
	JMS I VECTOR		/CALL THE DOT DRAWING MACHINE
	ISZ AUTO11
	SKP			/COUNT 
	JMP TWODIS		/DO NUMBER TWO ON OVERFLOW
	TAD XTWODS		/SWAP POINTS FOR NEXT PAIR
	DCA XONEDS
	TAD YTWODS		/THE GENERATOR DRAWS FROM ONE
	DCA YONEDS		/TOWARDS TWO
	JMP FILONE



TWODIS,	TAD TWOFLG		/HERE TO DO NUMBER TWO
	SZA CLA			/BUT NOT IF IN HYPER SPACE
	JMP I IPRODS

	TAD TWOFIL		/SET UP FILE POINTER AS IN ONE
	DCA AUTO10
	TAD TWOCNT		/AND THE COUNT
	DCA AUTO11
	TAD I AUTO10		/I SUPPOSE THIS COULD BE A SUBROUTINE TOO
	DCA XONEDS
	TAD I AUTO10
	DCA YONEDS
	TAD TWOOUT		/IS IT EXPLODING?
	SZA CLA
	JMP I ITWOEX		/YES, HOW EXCITING

TWDLOP,	TAD I AUTO10		/NO HOW DULL, STICK IN NEXT PAIR OF
	DCA XTWODS		/POINTS
	TAD I AUTO10
	DCA YTWODS		/AND CALL THE VECTOR SEQUENCE
	JMS I VECTOR
	ISZ AUTO11
	JMP .+3

	JMP I .+1		/WHEN COUNT OVERFLOWS GO ON TO 
IPRODS,	PRODIS			/DO THE PROJECTILE THING

	TAD XTWODS		/OTHERWISE SWAP ON TO THE NEXT PAIR 
	DCA XONEDS		/OF POINTS
	TAD YTWODS
	DCA YONEDS
	JMP TWDLOP

COLIDE,	COLLID
IONEEX,	ONEEXP
ITWOEX,	TWOEXP


/
/	THIS IS THE SO CALLED "VECTOR GENERATOR" WHICH DRAWS A 
/	SERIES OF DOTS FROM XONEDS,YONEDS TO XTWODS,YTWODS.
/	THE COORDINATE COMPONENTS ARE DIVIDED INTO FOURTHS  AND
/	FOUR DOTS DRAWN ON THE SCOPE SCREEN.  NOTE THAT NO DOT
/	IS DRAWN AT XONEDS,YONEDS.  THIS IS COMPENSATED FOR ELSEWHERE.
/

DISPLY,	0			/ENTER TO DRAW A FOUR POINT VECTOR
	TAD XONEDS		/FROM XONEDS,YONEDS
	CIA			/TO XTWODS,YTWODS
	TAD XTWODS		/DIVIDE COORDINATE DIFERENCES INTO
	JMS DISHFT		/FOURTHS
	DCA DIXTEM		/AND STORE INCREMENT
	TAD YONEDS
	CIA
	TAD YTWODS
	JMS DISHFT
	DCA DIYTEM
	TAD M4			/FOR FOUR DOTS
	DCA DISCNT

DISLOP,	TAD XONEDS		/ADD INCREMENT TO CURRENT X AND Y
	TAD DIXTEM
	DCA XONEDS		/NOTE THAT THIS ROUTINE DESTROYS
	TAD YONEDS		/XONEDS AND YONEDS
	TAD DIYTEM
	DCA YONEDS
	TAD XONEDS
	RTR			/DIVIDE BY 8 TO FIT SCREEN SIZE
	RAR
	DXC DXL			/SET X VALUE
	CLA
	TAD YONEDS		/DO THE SAME FOR Y
	RTR
	RAR
	DYC DYL DIS		/AT LAST SOMETHING TO SEE!!
	CLA
	ISZ DISCNT		/DONE YET?
	JMP DISLOP		/NOPE
	JMP I DISPLY		/YUP

DISHFT,	0			/A GENERALIZED SHIFT ROUTINE CALLED
	CLL			/FROM EVERYWHERE TO DIVIDE THE
	SPA			/AC BY FOUR WITH AN ASR RIGHT
	CML IAC			/NOTE THAT NEGATIVE NUMBERS ARE
	RAR			/ROUNDED UPWARDS (TOWARD ZERO)
	CLL			/TO MAKE IT COME OUT RIGHT
	SPA
	CML IAC			/EVEN SO THERE ARE SOME ROUNDING ERRORS
	RAR			/SOMEWHERE.  SO MUCH FOR 12 BIT MACHINES
	JMP I DISHFT


/
/	HERE TO DISPLAY ALL THE PROJECTILES AND TEST FOR HITS.
/	THE PROJECTILE DISPLAY FILE IS SEARCHED FOR PROJECTILES WITH
/	NON-ZERO COUNTS AND WHEN ONE IS FOUND THE POSITION IS
/	UPDATED BY THE VELOCITY, THE POINT DISPLAYED AND TESTED FOR
/	A HIT.
/

	*1600

PRODIS,	CLA CLL			/ BEGIN DISPLAY OF THE PROJECTILES
	TAD BUFST		/POINT TO BEGINNING OF DISPLAY FILE
	DCA BUFTMP
	DSB 2			/SET EXTRA BRIGHT FOR SINGLE POINTS

PROLOP,	TAD I BUFTMP		/PICK UP NEXT COUNT
	SNA
	JMP EXPIRE		/THIS ONE IS DEAD - GO TO THE NEXT
	IAC			/INCREMENT COUNT AND REPLACE
	DCA I BUFTMP
	ISZ BUFTMP		/BUMP POINTER TO X VELOCITY
	TAD I BUFTMP
	ISZ BUFTMP		/THEN TO XPOSITION AND UPDATE X POSITION
	TAD I BUFTMP		/WITH THE VELOCITY WHICH IS CONSTANT
	DCA I BUFTMP
	TAD I BUFTMP
	DCA PROX		/AND STORE X POSITION FOR DISPLAY AND TEST
	ISZ BUFTMP		/NOW TO Y POSITION AND VELOCITY
	TAD I BUFTMP
	ISZ BUFTMP
	TAD I BUFTMP		/SAME LITTLE GAME
	DCA I BUFTMP
	TAD I BUFTMP
	DCA PROY		/STORE THE NEW Y VALUE

	TAD PROX		/DISPLAY THE POINT WITH 
	RTR			/THE SAME SHIFT AS FOR THE SHIPS
	RAR			/FOR THE SMALL SCREEN
	DXC DXL
	CLA
	TAD PROY
	RTR			/
	RAR
	DYC DYL DIS		/THERE IT IS!!
	CLA
	JMS I CHKOUT		/TEST  FOR A HIT
	ISZ BUFTMP		/MOVE POINTER ON AND TEST FOR END
	TAD BUFTMP		/OF BUFFER
	TAD BUFLIM
	SZA CLA
	JMP PROLOP		/NOT AT END - CONTINUE

/
/	HERE AT THE END OF THE PROJECTILE DISPLAY.  IF THE GAMOVR
/	FLAG IS SET, GO ON TO THE MESSAGE DISPLAY - VICTORY LAP
/	SECTION.  OTHERWISE PICK UP THE REMAINING CLOCK COUNT
/	TO GIVE THE FANS SOMETHING TO LOOK AT, AND MOVE THE
/	ELECTRON BEAM TO A LOWER CORNER.  THE COUNT DISPLAYED
/	IN THE AC IS THE NUMBER OF 100 USEC CLOCK TICKS REMAINING
/	WHEN THIS CODE IS REACHED BEFORE THE NEXT UPDATE WOULD 
/	BEGIN.  TURNS OUT THAT ROUGHLY 2/3 OF THE CPU IS LEFT
/	OVER SHOULD ANYONE WANT TO DO ANYTHING VERY FANCY.
/

FINISH,	TAD GAMOVR		/IS THIS THE VICTORY LAP OR WHAT?
	SZA CLA
	JMP I ENDGAM		/YES, GO TO PUT UP THE MESSAGE
	TAD M400		/MOVE THE BEAM OFF SCREEN
	DYC DYL
	CLA CLL
	DXC DXL
	TAD INTCNT		/PICK UP THE COUNT
	CIA
	JMP .

ENDGAM,	JOBLOP



EXPIRE,	TAD BUFTMP		/HERE TO ADVANCE THE BUFFER
	TAD P5			/POINTER TO THE NEXT PROJECTILE
	DCA BUFTMP		/UNLESS THE END
	TAD BUFTMP		/OF THE BUFFER
	TAD BUFLIM		/IS REACHED
	SZA CLA			/IN WHICH CASE
	JMP PROLOP		/IT
	JMP FINISH		/QUITS

BUFST,	DISBUF+101
BUFLIM,	-DISBUF-175
CHKOUT,	CHECK

RESE1,	0			/THIS IS CALLED TO SET THE POINTER
	TAD MRES		/(AUTO16) TO THE NEXT FREE SLOT
	DCA RESCNT		/FOR A PROJECTILE LAUNCH. 12 POSSIBLE

RESLOP,	TAD RESPNT		/MOVE THE POINTER TO THE NEXT SLOT
	TAD P5
	DCA RESPNT
	TAD RESPNT		/RESTE IF AT END OF BUFFER
	TAD BUFLIM
	SZA CLA
	JMP RESCON
	TAD BUFST
	DCA RESPNT

RESCON,	TAD I RESPNT		/FIND A HOLE YET?
	SNA CLA
	JMP RESFND		/YES, SET UP AUTO16
	ISZ RESCNT		/NO COUNT
	JMP RESLOP		/AND TRY AGAIN
	HLT			/NO HOLES AT ALL?

RESFND,	CMA			/BACK THE POINTER FOR AUTO INDEXING
	TAD RESPNT
	DCA AUTO16
	JMP I RESE1

MRES,	-14
RESCNT,	0
RESPNT,	0

SETBUF,	0
	CMA			/THIS ROUTINE IS CALLED FROM THE 
	TAD BUFST		/STARTING SEQUENCE TO INITIALIZE ALL
	DCA AUTO16		/THE BUFFER POINTERS AND SO ON
	TAD BUFST
	DCA BUFTMP
	TAD BUFST
	DCA RESPNT
	TAD BUFST
	DCA SETPNT
SETLOP,	DCA I SETPNT
	ISZ SETPNT
	TAD SETPNT
	TAD BUFLIM
	SZA CLA
	JMP SETLOP
	JMP I SETBUF

SETPNT,	0


/
/	THIS HERE NOW THING CHECKS THE COORDINATES OF THE MOST RECENTLY
/	DISPLAYED PROJECTILE AGAINST THOSE OF THE SHIPS ON THE SCREEN.
/	IF WITH A COLLISION LIMIT  A HIT IS RECORDED AND THE LIFE
/	COUNT OF THE PROJECTILE ZEROED TO REMOVE IT.  A HIT SHIP
/	IS SUITABLY FLAGGED
/

	*2000

CHECK,	0			/HERE TO TEST FOR A PROJECTILE HIT
	TAD ONEFLG		/CANT HIT SOMETHING IN HYPERSPACE
	SZA CLA
	JMP CHECK2
	TAD ONEOUT		/OR SOMETHING THAT'S BEEN HIT
	SZA CLA
	JMP CHECK2

	TAD PROX		/CHECK X COORDINATES OF SHIP ONE
	CIA			/AND PROJECTILE
	TAD ONEPEX		/THIS SORT OF THING IS WHY THE
	SPA			/COORDINATES HAVE TO BE MAINTAINED TO 12
	CIA			/BITS
	TAD LIMIT		/CLOSE ENOUGH?
	SMA CLA
	JMP CHECK2		/IF X ISN' CLOSE ENOUGH THEN NO HIT
	TAD PROY		/X WAS CLOSE ENOUGH, HOW ABOUT Y?
	CIA
	TAD ONEPEY
	SPA
	CIA
	TAD LIMIT
	SMA CLA
	JMP CHECK2		/NO HIT

	TAD MEXP		/DEPOSIT EXPLOSION COUNT  IN ONEOUT
	DCA ONEOUT		/ALL THAT IS NECESSARY
	JMS CUTOUT		/REMOVE PROJECTILE



CHECK2,	TAD TWOFLG		/NO HIT ON NUMBER ONE, TRY NUMBER TWO
	SZA CLA
	JMP I CHECK		/BUT NOT IF IN HYPERSPACE
	TAD TWOOUT		/OR IF ALREADY HIT
	SZA CLA
	JMP I CHECK

	TAD PROX		/CHECK X'S FIRST
	CIA
	TAD TWOPEX
	SPA			/GET ABSOLUTE VALUE OF DIFFERENCE
	CIA
	TAD LIMIT		/AND TEST MAGNITUDE AGAINST PROXIMITY
	SMA CLA			/LIMIT
	JMP I CHECK		/NOWHERE NEAR CLOSE

	TAD PROY		/NYAH, NYAH
	CIA			/TRY THE Y'S
	TAD TWOPEY
	SPA
	CIA			/ABSOLUTE VALUE OF DIFFERENCE
	TAD LIMIT
	SMA CLA
	JMP I CHECK		/CLEAN MISS!

	TAD MEXP		/HIT ON TWO - END EVERYTHING BY SETTING
	DCA TWOOUT		/TWOOUT TO NON-ZERO EXPLOSION COUNT
	JMS CUTOUT
	JMP I CHECK		/EXIT AFTER DESTOYING PROJECTILE

LIMIT,	-120			/PROXIMITY LIMIT FOR WHAT CONSTITUTES A HIT

CUTOUT,	0			/THIS ROUTINE ZEROES OUT THE MOST RECENTLY
	TAD M4			/DISPLAYED PROJECTILE BY ZEROEING THE
	TAD BUFTMP		/COUNT
	DCA CUTPNT
	DCA I CUTPNT
	JMP I CUTOUT

CUTPNT,	0


/
/	THIS ROUTINE IS CALLED TO TEST FOR A COLLISION BETWEEN THE
/	TWO SHIPS.  THE COORDINATES OF BOTH ARE COMPARED
/	AND IFF SUFFICIENTLY CLOSE BOTH ARE DESTROYED BY SETTING
/	THEIR EXPLOSION COUNTS NON-ZERO.
/

COLLID,	0			/HERE TO TEST FOR COLLISION
	TAD ONEFLG		/NO TEST IF EITHER SHIP IS IN
	SZA CLA			/HYPERSPACE OR EXPLODING
	JMP I COLLID
	TAD TWOFLG
	SZA CLA
	JMP I COLLID
	TAD ONEOUT
	SZA CLA
	JMP I COLLID
	TAD TWOOUT
	SZA CLA
	JMP I COLLID

	TAD ONEPEX		/BOTH SHIPS AVAILABLE FOR COLLISION
	CIA			/CHECK X COORDINATES FIRST
	TAD TWOPEX
	SPA			/GET ABSOLUTE VALUE OF DIFFERENCE
	CIA
	TAD COLLIM		/CLOSE ENOUGH?
	SMA CLA
	JMP I COLLID		/NOPE, FORGET IT

	TAD ONEPEY		/YES, NOW TRY THE Y COORDINATES
	CIA
	TAD TWOPEY
	SPA
	CIA			/GET MAGNITUDE ONLY
	TAD COLLIM
	SMA CLA			/CLOSE ENOUGH?
	JMP I COLLID
	TAD MEXP		/YES, SET BOTH EXPLOSION COUNTS
	DCA ONEOUT
	TAD MEXP
	DCA TWOOUT
	JMP I COLLID

COLLIM,	-300

/
/	THIS ROUTINE IS CALLED TO SET ONE OF THE TWO SHIPS INTO 
/	HYPERSPACE.  ON ENTRY THE AC=-1 FOR SHIP #1, 0 FOR SHIP
/	NUMBER 2.  THE LOCATION CLOCK IS USED FOR A RANDOM
/	ADDRESS POINTER FROM WHICH WILL BE DRAWN THE 
/	VARIOUS PARAMETERS FOR REENTRY.
/

	*2200

HYPSET,	DCA RTNFLG		/HERE WITH AC=-1 OR 0
	TAD RTNFLG		/SET UP LIST POINTER
	SZA CLA
	TAD ONEDIF		/TO APPROPRIATE SHIP FILE
	TAD TWOLST
	DCA AUTO15

	TAD CLOCK		/SET UP "RANDOM NUMBER GENERATOR"
	DCA AUTO17
	TAD I AUTO17		/PICK UP FIRST THE AMOUNT OF TIME
	AND TIMOUT		/OUT OF NOMAL SPACE LIMITED TO -777
	CIA			/UPDATE CYCLES ( ABOUT 15 SECONDS)
	DCA I AUTO15		/AND STORE IN ONEOUT OR TWO OUT

	TAD I AUTO17		/THE NEXT RANDOM NUMBER BECOMES THE
	JMS I THEADJ		/ANGLE OR ORIENTATION ON REENTRY
	DCA I AUTO15
	TAD I AUTO17		/AND THE NEXT BECOMES THE X VELOCITY 
	JMS VEESET		/COMPONENT
	DCA I AUTO15
	TAD I AUTO17		/AND THEN THE Y COMPONENT
	JMS VEESET
	DCA I AUTO15
	TAD I AUTO17
	DCA I AUTO15

	TAD I AUTO17
	DCA I AUTO15

	TAD I AUTO17		/FINALLY SEE IF RETURN WILL BE SUCCESSFLY
	AND TIMOUT
	TAD MHYP		/ABOUT 3/4 CHANCE
	SMA CLA
	JMP HYPRET		/OK
	TAD RTNFLG		/THIS IS THE ONE TIME IN FOUR.  SET
	SZA CLA			/UP FOR EXPLOSION ON REENTRY
	TAD ONEDIF
	TAD OUTLOC
	DCA VEESET
	TAD MEXP
	DCA I VEESET

HYPRET,	ISZ RTNFLG
	JMP I TWORTN
	JMP I ONERTN

TIMOUT,	777
ONEDIF,	ONEFLG-TWOFLG
TWOLST,	TWOFLG-1
RTNFLG,	0
ONERTN,	TWOUP
TWORTN,	ONESET
OUTLOC,	TWOOUT
MHYP,	-200



VEESET,	0			/HERE TO LIMIT VELOCITY COMPONENTS
	CLL
	SPA			/GET MAGNITUDE
	CML
	AND HM177		/LIMIT TO 177
	SZL CLL
	CIA
	JMP I VEESET		/AND EXIT 

HM177,	177

ONEEXP,	CLA CLL			/HERE TO DISPLAY SHIP NUMBER ONE AS
	TAD ONETHE		/AN EXPLOSION
	TAD INCONE		/FIRST ROTATE IT BY A GOOD DOLLOP
	DCA ONETHE
	JMS I IXPDIS		/THEN CALL THE EXPLOSION GENERATOR
	ISZ ONEOUT		/DONE WITH THE EXPLOSION?
	JMP I NOWTWO		/NO, NORMAL RETURN

	IAC			/YES, SET INTO PSEUDO HYPER SPACE
	DCA ONEFLG
	IAC			/DISABLE RETURN FROM HYPER SPACE
	DCA ONEFIN

	TAD TWOFIN		/IS NUMBER TWO STILL AROUND?
	SNA CLA
	JMP I NOWTWO		/YES, RETURN
	JMP I TIEUP		/NO, TIE BALL GAME


TWOEXP,	CLA CLL			/HERE TO DISPLAY SHIP NUMBER TWO 
	TAD TWOTHE		/AS AN EXPLOSION.  BASH IT AROUND
	TAD INCTWO
	DCA TWOTHE
	JMS I IXPDIS		/THEN DISPLAY IT
	ISZ TWOOUT		/DONE WITH EXPLOSION?
	JMP I NOWPRO		/NO, NORMAL RETURN

	IAC			/YES, SEND INTO PSEUDO HYPER SPACE
	DCA TWOFLG
	IAC			/DISABLE NORMAL RETURN FROM HYPERSPACE
	DCA TWOFIN
				/CHECK NUMBER ONE
	TAD ONEFIN
	SZA CLA			/STILL ALIVE AND WELL?
	JMP I TIEUP		/NO, TIE GAME
	JMP I NOWPRO		/YES, CONTINUE ON
NOWTWO,	TWODIS
NOWPRO,	PRODIS
TIEUP,	NOWIN
IXPDIS,	EXPDIS
INCONE,	55
INCTWO,	55


/
/	HERE TO DISPLAY THE FIGURE POINTED TO BY AUTO10 AS
/	AN EXPLOSION.  THIS WORKS THE SAME WAY AS THE NORMAL
/	DISPLAY ROUTINE EXCEPT THAT THE COORDINATE INCREMENTS
/	ARE INVERTED TURNING THE FIGURE INSIDE OUT FOR S 
/	A SORT OF CLOBBY EXPLOSION.
/

	*2400

EXPDIS,	0			/HERE TO DISPLAY A FIGURE INSIDE OUT
	TAD I AUTO10		/WITH THE POINTERS AND COUNTS ALREADY
	DCA XTWODS		/SET UP BY FILDIS OR TWODIS
	TAD I AUTO10		/STICK NEXT TWO POINTS INTO LINE
	DCA YTWODS

	TAD XTWODS
	CIA			/CALCULATE INCREMENT THE WRONG WAY
	TAD XONEDS
	DCA DIXTEM		/AND STORE
	TAD YTWODS
	CIA
	TAD YONEDS
	DCA DIYTEM		/SAME FOR Y

	TAD M4			/4 DOTS IN THE VECTOR"
	DCA DISCNT		/COULD HAVE CALLED THE OTHER 
				/VECTOR GENERATOR I SUPPOSE
EXPLOP,	TAD XONEDS
	TAD DIXTEM		/ADD X AND Y INCREMENTS TO THE RUNNING
	DCA XONEDS		/TOTALS AND DISPLAY THE RUNNING
	TAD YONEDS		/TOTALS NORMAL SIZE
	TAD DIYTEM
	DCA YONEDS

	TAD XONEDS
	RTR			/COULD MAKE TWICE AS BIG BY NOP-ING
	RAR			/THE RAR'S BUT THE SCREEN IS SMALL ENOUGH
	DXC DXL			/AS IT IS
	CLA
	TAD YONEDS
	RTR
	RAR
	DYC DYL DIS
	CLA
	ISZ DISCNT		/DONE 4 DOTS?
	JMP EXPLOP		/NO

	ISZ AUTO11		/DONE ALL VECTORS IN THE FILE?
	SKP
	JMP I EXPDIS		/YES, EXIT

	TAD XTWODS		/NO SWAP TO NEXT PAIR OF POINTS
	DCA XONEDS
	TAD YTWODS
	DCA YONEDS
	JMP EXPDIS+1


/
/	VEELIM IS THE SCALING ROUTINE FOR VELOCITY COMPONENTS.
/	THE COMPONENTS ARE SCALED TO REMAIN IN THE RANGE 140
/	TO -140.  THIS IS NECESSARY TO AVOID ASTRONOMICAL SPPED
/	BUILDUP ON THE SMALL SCREEN.  UNFORTUNATELY THE X AND Y
/	COMPONENTS ARE SCALED SEPARATELY WHICH GIVES SLIGHT BUT
/	NOTICABLE DISTORTIONS IN DIAGONAL FLIGHT PATHS.  IN THE
/	NORMAL HEAT OF THE BATTLE NO ONE WILL REALLY NOTICE.
/

VEELIM,	0			/ENTER TO SCALE VELOCITY HELD IN
	DCA VEEHLD		/AC
	TAD VEEHLD
	SMA			/BRANCH FOR POSITIVE OR NEGATIV
	JMP VEEPOS
	TAD VEEMAX
	SMA CLA			/GREATER THAN MAXIMUM POSITIVE?
	JMP VEECLR		/NO
	TAD VEEMIN		/I MEAN MAXIMUM NEGATIVE - YES SET
	JMP I VEELIM		/TO MAX NEGATIV

VEEPOS,	TAD VEEMIN		/GREATER THAN MAX?
	SPA CLA
	JMP VEECLR		/NO
	TAD VEEMAX		/YES SET TO MAX
	JMP I VEELIM

VEECLR,	TAD VEEHLD		/IT WAS IN RANGE ALL ALONG
	JMP I VEELIM

VEEHLD,	0
VEEMIN,	-140
VEEMAX,	140

THEAJI,	0			/HERE TO ADJUST THE ANGLE TO A RANGE
	SMA			/0-550 OR 0-360 DEGREES.  THIS IS
	JMP .+3			/NECESSARY TO INSURE THAT PUSHDOWN OVERFLOW
	TAD P550		/WILL NOT HAPPEN IN THE SINE AND COSINE
	JMP .-3			/ROUTINES.  THIS SIMPLY TAKES THE AC 
	TAD M550		/MODULO 360 AND EXITS
	SMA
	JMP .-2
	TAD P550		/FOLLOW IT THROUGH AND SEE IF IT DOESN'T
	JMP I THEAJI


/
/	ONE OF THESE ROUTINE IS ENTERED WHEN A WINNER IS DECLARED.
/	THE ADDRESS OF THE VICTORY MESSAGE IS PLACED IN MESS AND 
/	THE GAMOVR FLAG SET TO CAUSE A BRANCH TO JOBLOP WHEN THE
/	DISPLAY CYCLE IS COMPLETED.  THE ROUTINE WILL THEN DISPLAY
/	THE APPROPRIATE MESSAGE OVER THE REMAINING SHIPS IF
/	ANY UNTIL THE KEYBOARD IS MOLESTED OR THE CLOCK RUNS OUT
/	AND THE NEXT DISPLAY UPDATE CYCLE IS SET.   AT ANY RATE THE
/	PROGRAM WILL REACH HERE ONLY WHEN SOMEONE HAS BITTEN THE
/	INTERGALACTIC DUST.
/

ONEWIN,	0			/THIS IS CALLED WHEN TWOFIN IS SET
	TAD MES1		/AND ONE FIN IS NOT.  SET ONE TO VICTOR
	DCA MESS		/AND SET GAMOVR FLAG
	IAC
	DCA GAMOVR
	JMP I ONEWIN		/THEN RETURN TO UPDATE CYCLE

TWOWIN,	0			/THIS IS CALLED WHEN ONEFIN IS SET
	TAD MES2		/AND TWO FIN IS NOT
	DCA MESS		/SET ALSO GAMOVR
	IAC
	DCA GAMOVR
	JMP I TWOWIN

NOWIN,	TAD MES4		/GET HERE WHEN BOTH ONEFIN AND TWOFIN
	DCA MESS		/ARE SET .
	IAC
	DCA GAMOVR		/NOBODY EVER REALLY WINDS
				/UP THE WINNER IN THESE THINGS
JOBLOP,	DSB 1			/THIS IS ENTERED FROM FINISH WHEN
	TAD MES0		/GAMOVR IS SET AND SERVES TO DISPLAY
	JMS I MESOUT		/THE VICTORY MESSAGE ON THE SCREEN
	TAD MESS		/USING THE CHARACTER GENERATOR SOMEWHAT
	JMS I MESOUT		/FURTHER ON UNTIL THE GAME IS RESTARTED
	TAD MES5		/OR UNTIL THE INTERRUPT COUNT OVERFLOWS
	JMS I MESOUT		/AND THE UPDATE CYCLE IS RESTARTED
	TAD MES3
	JMS I MESOUT
FINITO,	JMP JOBLOP

MES0,	MESS0
MES1,	MESS1
MES2,	MESS2
MES3,	MESS3
MES4,	MESS4
MES5,	MESS5
MESS,	0


/
/	THE FOLLOWING ARE THE SINE AND COSINE ROUTINES CUSTOMIZED
/	FOR THIS PROGRAM FROM ANOTHER I WORKED ON.  CALL EITHER
/	SINE OR COSINE WITH ANGLE IN DEGREES IN AC.  THE ARGUEMENT
/	IS REDUCED THROUGH RECURSION UNTIL BETWEEN 0-89 DEGREES 
/	AND THEN A TABLE LOOKUP DONE TO OBTAIN THE VALUE.  IT TAKES
/	UP A FAIR AMOUNT OF SPACE BUT IT WORKS JUST FASTER
/	THAN SHEEP.  THE COSINE CALL JUST TRANSFORMS THE ARGUEMENT 
/	THROUGH SOME TRIGONOMETRIC GARBAGE AND CALLS THE SINE
/	ROUTINE.  NOTE THAT CALLING EITHER ROUTINE WITH TOO 
/	LARGE AN ARGUEMENT WILL CAUSE PUSHDOWN OVERFLOW AND THEN
/	ALL HELL WILL BREAK LOOSE.  THE ORIGINAL ROUTINE FROM WHICH
/	THIS WAS STOLEN HAD FULL WORD PRECISION.
/

	*6400

SINEIN,	0			/I REALLY CANT BRING MYSELF TO COMMENT
	DCA SINARG		/THIS.  IT'S VERY STRAIGHFORWARD
	TAD SINEIN
	DCA I SINPSH
	ISZ SINPSH
	TAD SINARG
	SZA 
	JMP SINNG2

SINPOP,	CLA CLL CMA
	TAD SINPSH
	DCA SINPSH
	TAD I SINPSH
	DCA SINEIN
	TAD SINARG
	JMP I SINEIN

SINNG2,	SMA
	JMP SINPOS
	CIA
	JMS SINEIN

SINNEG,	CIA
	DCA SINARG
	JMP SINPOP

SINPOS,	TAD M264
	SPA
	JMP .+2
	JMP SINNEG-1
	TAD P132
	SPA
	JMP SINELK
	SZA CLA
	JMP .+3
	TAD P37
	JMP SINNEG+1

	TAD SINARG
	TAD M264
	JMP SINNEG-1

SINELK,	TAD P132
	TAD SINTAB
	DCA SINEIN
	TAD I SINEIN
	DCA SINARG
	JMP SINPOP



SINARG,	0
SINPSH,	SINLST
SINLST,	0
	0
	0
	0
	0
	0

SINTAB,	SINES-1

COSINI,	0
	CIA
	TAD P132
	JMS SINEIN
	JMP I COSINI



SINES,	00	/1
	01	/2
	01	/3
	02	/4
	02	/5
	03	/6
	03	/7
	04	/8
	05	/9
	05	/10
	06	/11
	06	/12
	07	/13
	07	/14
	10	/15
	10	/16
	11	/17
	11	/18
	12	/19
	12	/20
	13	/21
	13	/22
	14	/23
	15	/24
	15	/25
	16	/26
	16	/27
	17	/28
	17	/29
	20	/30
	20	/31
	20	/32
	21	/33
	21	/34
	22	/35
	22	/36
	23	/37
	23	/38
	24	/39
	24	/40
	25	/41
	25	/42
	25	/43
	26	/44
	26	/45
	27	/46
	27	/47
	27	/48
	30	/49
	30	/50
	30	/51
	31	/52
	31	/53
	31	/54
	32	/55
	32	/56
	32	/57
	33	/58
	33	/59
	33	/60
	33	/61
	34	/62
	34	/63
	34	/64
	35	/65
	35	/66
	35	/67
	35	/68
	35	/69
	36	/70
	36	/71
	36	/72
	36	/73
	36	/74
	36	/75
	37	/76
	37	/77
	37	/78
	37	/79
	37	/80
	37	/81
	37	/82
	37	/83
	37	/84
	37	/85
	37	/86
	37	/87
	37	/88
	37	/89



MULTI,	0			/THIS IS STANDARD SINGLE PRECISION
	CLL			/MULTIPLY ROUTINE WHICH WAS ONCE
	SPA			/USED.  I'VE LEFT IT IN SINCE
	CMA CML IAC		/THERE IS LOTS OF CORE LEFT OVER AND
	DCA MULMP1		/MAYBLE SOMEDAY I'LL NEED IT TO PUT
	DCA MULMP5		/IN A SUN OR SOMETHING.  THIS IS THE
	TAD I MULTI		/STANDARD DEC SUBROUTINE WITH DIFFERENT
	SNA			/LABELS
	JMP MULPSN+2
	SPA
	CMA CML IAC
	DCA MULMP2
	TAD MULTHR
	DCA MULMP3

MULMP4,	TAD MULMP1
	RAR
	DCA MULMP1
	TAD MULMP5
	SZL
	TAD MULMP2
	CLL RAR
	DCA MULMP5
	ISZ MULMP3
	JMP MULMP4
	TAD MULMP1
	RAR
MULPSN,	SZL
	JMP MULCMP
	DCA MULMP1
	TAD MULMP5
MULMPZ,	ISZ MULTI
	JMP I MULTI

MULCMP,	CMA CLL IAC
	DCA MULMP1
	TAD MULMP5
	CMA
	SZL
	IAC
	JMP MULMPZ

MULTHR,	7764
MULMP1,	0
MULMP5,	0
MULMP2,	0
MULMP3,	0


/
/	SHIFTR DIVIDES THE AC BY TWO WHETHER POSITIVE OR NEGATIVE
/	AND IS CALLED FROM VARIOUS PLACES.   NOT ENTIRELY MYSTERIOUS
/

SHIFTR,	0
	CLL
	SPA
	CML IAC
	RAR
	JMP I SHIFTR

/
/	POSCAL IS CALLED TO CALCULATE THE COORDINATE INCREMENTS
/	NECESSARY TO PRODUCE THE SHIP FIGURES.  RATHER THAN DOING
/	A LOT OF EXPENSIVE MATH THIS DOES A QUICK PRODUCTION
/	OF 1, 2, AND 3 TIMES THE SIN AND COSINE VALUES FOUND
/	IN CALSIN AND CALCOS LEAVING THEM IN THE TABLE FOR
/	ONESET AND TWOSET.  IF THE SCOPE WERE ANY BETTER
/	THIS PROBABLY WOULDN'T BE NEAR GOOD ENOUGH BUT....
/

POSCAL,	0
	TAD CALSIN

	DCA T10SIN
	TAD T10SIN
	CLL RAL
	DCA T20SIN
	TAD T10SIN
	TAD T20SIN
	DCA T30SIN

	TAD CALCOS

	DCA T10COS
	TAD T10COS
	CLL RAL
	DCA T20COS
	TAD T10COS
	TAD T20COS
	DCA T30COS
	JMP I POSCAL


	*7000

/GENERAL PURPOSE SYMBOL GENERATOR
/
CHARS,	0	/ENTRY TO PLOT CHARACTER STRING
	DCA ADDR	/STORE STRING ADDRESS
	TAD I ADDR	/FETCH DOUBLE CHARACTER
	RTR	/SHIFT
	RTR	/	FOR FIRST
	RTR	/	CHARACTER
	JMS CHAR	/PLOT CHARACTER
	SKP	/NORMAL RETURN -- SKIP
	JMP I CHARS	/TERMINATION RETURN -- EXIT
	TAD I ADDR	/RECALL DOUBLE CHARACTER
	ISZ ADDR	/ADVANCE STRING ADDRESS
	JMS CHAR	/PLOT CHARACTER
	JMP CHARS+2	/NORMAL RETURN -- REPEAT
	JMP I CHARS	/TERMINATION RETURN -- EXIT
/
CHAR,	0	/ENTRY TO PLOT SINGLE CHARACTER
	AND K77	/MASK OUT UPPER BITS
	CLL RAL	/MULTIPLY CODE BY TWO
	TAD TABLE	/ADD TABLE BASE ADDRESS
	DCA POINT	/CONSTRUCT POINTER TO 24-BIT CODE
	CMA	/INITIALIZE COUNTER FOR
	DCA COUNT2	/	TWO PLOT WORDS
	TAD I POINT	/FETCH FIRST PLOT WORD
	ISZ POINT	/INCREMENT POINTER FOR NEXT ONE
	SNA	/SKIP IF NOT SPECIAL CHARACTER
	JMP SPCHAR	/ELSE GO PROCESS IT
	DCA CURPLT	/SAVE CURRENT PLOT BITS
XPLOT,	TAD KM6	/INITIALIZE 6-BIT
	DCA COUNT6	/	COUNTER
	TAD YVALUE	/RESET Y TEMPORARY
	DCA YTEMP	/	VALUE FOR CHARACTER
	TAD XVALUE	/OUTPUT CURRENT
	DXC DXL	/	X-VALUE TO CRT
	TAD XINCR	/INCREMENT
	DCA XVALUE	/	ABSCISSA
YPLOT,	TAD CURPLT	/RECALL CURRENT PLOT BITS
	CLL RAL	/GET NEXT BIT
	DCA CURPLT	/SAVE REMAINING PLOT BITS
	SNL	/SKIP IF POINT TO PLOT
	JMP CNTINU	/ELSE JUMP AHEAD
	TAD YTEMP	/OUTPUT CURRENT
	DYC DYL DIS	/	Y-VALUE TO CRT
	CLA CLL	/CLEAR AC
	TAD CURPLT	/RECALL CURRENT PLOT BITS
	SNA CLA	/SKIP IF POINTS REMAINING
	JMP WRDEND	/ELSE WORD IS FINISHED
CNTINU, TAD YTEMP	/INCREMENT TEMPORARY
	TAD YINCR	/	Y-VALUE FOR NEXT
	DCA YTEMP	/	CHARACTER STEP
	ISZ COUNT6	/SKIP IF 6 BITS PLOTTED
	JMP YPLOT	/ELSE PLOT NEXT ONE
	JMP XPLOT	/GO UPDATE X-VALUE
WRDEND, ISZ COUNT2	/SKIP IF ANOTHER BIT WORD
	JMP EXIT	/ELSE EXIT
	TAD I POINT	/FETCH SECOND BIT WORD
	SZA	/SKIP IF NO PLOT POINTS
	JMP XPLOT-1	/ELSE GO PLOT THEM
EXIT,	TAD XVALUE	/INCREMENT ABSCISSA
	TAD XINCR	/	FOR SPACE BETWEEN
	DCA XVALUE	/	SYMBOLS
	JMP I CHAR	/EXIT FROM CHAR
/
SPCHAR, TAD I POINT	/FETCH TRANSFER VECTOR
	DCA POINT	/STORE AS INDIRECT ADDRESS
	JMP I POINT	/GO TO APPROPRIATE ROUTINE
SPACE,	TAD XINCR	/FETCH BASIC ABSCISSA INCREMENT
	CLL RTL	/MULTIPLY BY FOUR AND
	JMP EXIT	/	GO CREATE SPACE
CRLF,	TAD INITX	/"CARRIAGE RETURN" RESETS X
	DCA XVALUE	/	TO ITS ORIGINAL VALUE
LF,	TAD YINCR	/"LINE FEED"
	CLL RTL	/	DECREMENTS THE
	CLL CIA RAL	/	Y-VALUE BY
	TAD YVALUE	/	EIGHT SCALE
	DCA YVALUE	/	STEPS
	JMP I CHAR	/EXIT FROM CHAR
RESET,	TAD INITX	/"RESET" RESETS
	DCA XVALUE	/	X AND Y TO
	TAD INITY	/	THEIR ORIGINAL
	JMP RESET-2	/	VALUES
TERM,	ISZ CHAR	/TERMINATE CODE CAUSES
	JMP I CHAR	/	EXIT TO P+2
/
INITX,	0	/INITIAL X-VALUE
INITY,	327	/INITIAL Y-VALUE
XVALUE, 0	/CURRENT X-VALUE
YVALUE, 0	/CURRENT Y-VALUE
XINCR,	6	/BASIC X INCREMENT VALUE
YINCR,	10	/BASIC Y INCREMENT VALUE
YTEMP,	0	/TEMPORARY Y-VALUE
CURPLT, 0	/CURRENT PLOT BITS
ADDR,	0	/CURRENT STRING ADDRESS
COUNT6, 0	/6-BIT COUNTER
COUNT2, 0	/2-WORD COUNTER
KM6,	-6	/CONSTANT FOR COUNT6
K77,	77	/CHARACTER CODE MASK
POINT,	0	/TABLE POINTER
/

/
TABLE,	.+1	/TABLE BASE ADDRESS
	0	/SPECIAL CHARACTER (00)
	TERM	/TERMINATION CODE
	7611	/ A
	1176
	7745	/ B
	4532
	3641	/ C
	4122
	7741	/ D
	4136
	7745	/ E
	4541
	7705	/ F
	501
	7741	/ G
	5173
	7710	/ H
	1077
	4177	/ I
	4100
	2040	/ J
	4037
	7714	/ K
	2241
	7740	/ L
	4040
	7702	/ M
	277
	7706	/ N
	3077
	7741	/ O
	4177
	7705	/ P
	502
	3641	/ Q
	6176
	7715	/ R
	2542
	2245	/ S
	5122
	177	/ T
	100
	3740	/ U
	4037
	1720	/ V
	4037
	7730	/ W
	3077
	4136	/ X
	3641
	374	/ Y
	7403
	6151	/ Z
	4543
	7741	/ [
	0
	204	/ \
	1020
	4177	/ ]
	0
	436	/ ^
	400
	0	/SPECIAL CHARACTER (37)
	RESET	/RESET
	0	/SPECIAL CHARACTER (40)
	SPACE	/SPACE
	5600	/ !
	0
	303	/ "
	0
	1477	/ #
	7714
	2277	/ MARKER
	2200
	2313	/ %
	6462
	7777	/ BLOCK
	7777
	300	/ '
	0
	3641	/ (
	0
	4136	/ )
	0
	4040	/ UNDERSCORE (52)
	4040
	1034	/ +
	1000
	0	/SPECIAL CHARACTER (54)
	LF	/LINE FEED
	1010	/ -
	1000
	4000	/ .
	0
	2010	/ /
	402
	3641	/ 0
	4136
	4442	/ 1
	7740
	4261	/ 2
	5146
	2145	/ 3
	5321
	1710	/ 4
	1077
	4745	/ 5
	4531
	7750	/ 6
	5070
	6111	/ 7
	503
	2255	/ 8
	5522
	705	/ 9
	577
	2400	/ :
	0
	0	/SPECIAL CHARACTER (73)
	CRLF	/CARRIAGE RETURN; LINE FEED
	1024	/ >
	4200
	1212	/ =
	1200
	4224	/ <
	1000
	255	/ ?
	300


/
/	HERE FOLLOW THE PACKED ASCII TEXTS FOR THE VARIOUS
/	VICTORY MESSAGES.  PERSONS ADVENTEROUS TO FIND THIS MIGH CARE
/	TO TOGGLE IN SOME CUTE LITTLE MESSAGES OF THEIR OWN.
/

MESS0,	3773
MESS5,	7340
	4040
	4040
	4000

MESS1,	1716
	0500

MESS2,	2427
	1700

MESS3,	2711
	1623
	4100

MESS4,	1617
	0217
	0431
	0000


	*7400

DISBUF,	0

/	THE DISPLAY BUFFERS BEGIN HERE AND EXTEND UP SOMEWHERE TO
/	AROUND 7575 OR SO.
/
/
/
/
/



        $

////////////////////////////
/
/       THIS IS THE END
/
///////////////////////////