A.N.A.L.O.G. ISSUE 33 / AUGUST 1985 / PAGE 39

Syntron

16K Cassette or Disk

by Jon Snyder

You were just a renegade space traveler, but as you passed the planet Syntron, your ship malfunctioned, and you were forced to land. Now, as you leave your ship, you notice that you aren’t alone…you’re surrounded by menacing and deadly Syntroids. Survival is your only concern.

Typing it in.

Before typing anything, look at the listings accompanying this article.

Listing 1 is the BASIC data and data checking routine. This listing is used to create both cassette and disk versions of Syntron. The data statements are listed in hexadecimal (base 16), so the program will fit in 16K cassette systems.

Listing 2 is the assembly language source code for the game of Syntron, created with the OSS MAC/65 assembler. You don’t have to type this listing to play the game! It is included for those readers interested in assembly language.

Follow the instructions below to make either a cassette or disk version of Syntron.

Cassette instructions.

  1. Type Listing 1 into your computer using the BASIC cartridge and verify your typing with Unicheck (see page 15).
  2. Type RUN and press RETURN. The program will begin and ask:
    MAKE CASSETTE (0) OR DISK (1)? Type 0 and press RETURN. The program will begin checking the DATA statements, printing the line number of each as it goes. It will alert you if it finds any problems. Fix any incorrect lines and re-RUN the program, if necessary, until all errors are eliminated.
  3. When all of your DATA lines are correct, the computer will beep twice and prompt you to READY CASSETTE AND PRESS RETURN. Now, insert a blank cassette in your recorder, press the RECORD and PLAY buttons simultaneously and hit RETURN. The message WRITING FILE will appear, and the program will create a machine language boot tape version, printing each DATA line number as it goes. When the READY prompt appears, the game is recorded and ready to play CSAVE the BASIC program onto a separate tape before continuing.
  4. To play, rewind the tape created by the BASIC program to the beginning. Turn your computer OFF and remove all cartridges. Press the PLAY button on your recorder and turn ON your computer while holding down the START key. If you have a 600 or 800XL computer, you must hold the START and OPTION keys when you turn on the power. The computer will “beep” once. Hit the RETURN key, and Syntron will load and run automatically.

Disk instructions.

  1. Type Listing 1 into your computer, using the BASIC cartridge and verify your typing with Unicheck (see page 15).
  2. Type RUN and press RETURN. The program will ask:
    MAKE CASSETTE (0) OR DISK (1)? Type 1 and press RETURN. The program will begin checking the DATA lines, printing the line number of each statement as it goes. It will alert you if it finds any problems. Fix incorrect lines and re-RUN the program, if necessary, until all errors are eliminated.
  3. When all the DATA lines are correct, you will be prompted to INSERT DISK WITH DOS, PRESS RETURN. Put a disk containing DOS 2.0S into drive #1 and press RETURN. The message WRITING FILE will appear, and the program will create an AUTORUN.SYS file on the disk, displaying each DATA line number as it goes. When the READY prompt appears, the game is ready to play Be sure that the BASIC program is SAVEd before continuing.
  4. To play the game, insert the disk containing the AUTORUN.SYS file into drive #1. Turn your computer OFF, remove all cartridges and turn the computer back ON. Syntron will load and run automatically.

How to play Syntron.

Syntron is a game for one or two players using joysticks. Select the level of difficulty (level 1 = easy, level 2 = medium, 3 = hard) by pressing the OPTION key until the desired value appears. Use the SELECT key to toggle between one- and two-player games. Press START to begin play.

In single-player mode, one joystick is used to control both player movement and shooting. With the trigger button released, the joystick controls the player’s movement about the screen. With the trigger pressed, the joystick fires the player’s gun in any of eight directions. Remember, single-player mode does not allow you to move and fire at the same time. In two-player mode, the joystick in port 1 controls movement, while the joystick in port 2 handles firing direction.

There are three types of Syntroids. The red ones, worth 70 points, are destroyed by a single shot. Hitting a blue Syntrek turns it into a red Syntroid and yields 40 points. The green Syntris is valued at 20 points and turns into a Syntrek when hit.

Completing the tenth wave (and every ten afterwards) will give you a 10,000-point bonus.

Syntroids do not shoot, but all are deadly to the touch — and up to seventy aliens may appear in one wave. The most fun can be had with two players working as a team. One controls the direction; the other, shooting. To pause the game, press the SPACE BAR. Pressing any other key resumes the game.


Jon Snyder is a senior in high school. He’s had an Atari 800 for about 2½ years and started working in assembly language about a year ago. He finds that assembly is more satis/ying to work with than BASIC — and not that hard to learn.


Listing 1.
BASIC listing.

10 REM *** SYNTRON ***
20 TRAP 20:? "MAKE CASSETTE (0), OR DISK (1)";:INPUT DSK:IF DSK>1 THEN 20
30 TRAP 40000:DATA 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,10,11,12,13,14,15
40 DIM DAT$(91),HEX(22):FOR X=0 TO 22:READ N:HEX(X)=N:NEXT X:LINE=990:RESTORE 1000:TRAP 120:? "CHECKING DATA"
50 LINE=LINE+10:? "LINE:";LINE:READ DAT$:IF LEN(DAT$)<>90 THEN 220
60 DATLIN=PEEK(183)+PEEK(184)*256:IF DATLIN<>LINE THEN ? "LINE ";LINE;" MISSING!":END 
70 FOR X=1 TO 89 STEP 2:D1=ASC(DAT$(X,X))-48:D2=ASC(DAT$(X+1,X+1))-48:BYTE=HEX(D1)*16+HEX(D2)
80 IF PASS=2 THEN PUT #1,BYTE:NEXT X:READ CHKSUM:GOTO 50
90 TOTAL=TOTAL+BYTE:IF TOTAL>999 THEN TOTAL=TOTAL-1000
100 NEXT X:READ CHKSUM:IF TOTAL=CHKSUM THEN 50
110 GOTO 220
120 IF PEEK(195)<>6 THEN 220
130 IF PASS=0 THEN 170
140 IF  NOT DSK THEN 160
150 PUT #1,224:PUT #1,2:PUT #1,225:PUT #1,2:PUT #1,0:PUT #1,32:CLOSE #1:END 
160 FOR X=1 TO 28:PUT #1,0:NEXT X:CLOSE #1:END 
170 IF  NOT DSK THEN 200
180 ? "INSERT DISK WITH DOS, PRESS RETURN";:DIM IN$(1):INPUT IN$:OPEN #1,8,0,"D:AUTORUN.SYS"
190 PUT #1,255:PUT #1,255:PUT #1,0:PUT #1,32:PUT #1,187:PUT #1,39:GOTO 210
200 ? "READY CASSETTE AND PRESS RETURN";:OPEN #1,8,128,"C:":RESTORE 230:FOR X=1 TO 40:READ N:PUT #1,N:NEXT X
210 ? :? "WRITING FILE":PASS=2:LINE=990:RESTORE 1000:TRAP 120:GOTO 50
220 ? "BAD DATA: LINE ";LINE:END 
230 DATA 0,16,216,31,255,31,169,0,141,47,2,169,60,141,2,211,169,0,141,231,2,133,14,169,56,141,232,2
240 DATA 133,15,169,0,133,10,169,32,133,11,24,96
1000 DATA A213A9009D000ACA10FAA2809500E8D0FB2065E4A90285A120A325203924201025A99185808D3002A9278D3102,549
1010 DATA 85812049274C5A25A5AD0D8402F037AD7802C908B00AA588C9C0B010E688900CC90CB008A588C9399002C688AD,645
1020 DATA 78024AB009A589C930900EC689604AB008A589C9C4B002E68960A489A200864DBD8C20990004C8E8E00D90F4A5,178
1030 DATA 888D00D060007E81A5814224183C3C1866008A1869058587A9008586B4A9C89186C8918660205F24A200A48FA5,856
1040 DATA 8218691485829002E683E88AD9000C90EEB9010C18658285829002E683A00060A6ADD005AD8402D029BD7802C9,985
1050 DATA 0FF0228597A202B598D017A5889594A5979598209920A58918690695A9A9D785A360CA10E260A202B598F01EC9,757
1060 DATA 09B004F6949006C90CB002D6942902D005F6A94C2B21B5986AB002D6A9CA10DB60A58838E92D4A4A4A858AA589,29
1070 DATA 38E91F4A4A4A858B60A200868F85A0202F2120AC20B182F040858E85A0A48FAD0AD21048B9010CC58AB018A582,14
1080 DATA 69018584A583690020DF21D01F20E621FE010C4C9421A58238E9018584A583E90020DF21D00620E621DE010CE6,773
1090 DATA 8FE68FA58FC59290ACA5A0D04C68684CB626B9000CC58BB018A58269148584A583690020DF21D0D720E621FE00,448
1100 DATA 0C4C9421A58238E9148584A583E90020DF21D0BE20E621DE000C4C94218585A000B184609182A58E9184A68F60,682
1110 DATA A9078587A202B5A98586A003B90E2291868810F8B5949D01D0C687CA10E86000181800A202869BB594F03038E9,963
1120 DATA 2D4A4A4A858CB5A938E9204A4A4A858D205F24A48CA200A58218691485829002E683E8E48D90F0B182F0032053,163
1130 DATA 22A69BCA10C58D1ED060A900A69B95949598BD05D06AB0E9B182C942D011A90785A6203A23A9459182A91485A2,809
1140 DATA C691C983D00FA90485A6A90A85A2A9429182203A23C9C4D00FA90285A6A9839182203A23A90A85A260AD04D0F0,273
1150 DATA FAA9A08D03D28D01D2207323C69D10196868A208BD31239DCE0ACA10F720FD232073232049274C5A25A90F8DC0,991
1160 DATA 02A90D8D00D2A21420F023CAD0FAACC002888C01D28CC002D0ECA219A9418D00D2A9488D01D220F023A90A8D00,298
1170 DATA D220F023CAD0E8A9FC8DC002205324206824203924207420A5A4859CA5910A85922095248D1ED0A9008D01D2AA,345
1180 DATA 20F023E8D0FA6027212D25002F362532AD0B0A1865A68D0B0AA204BD070AC91A900EE90A9D070AFE060AE002D0,305
1190 DATA 02E69DCA10E860A5A3F00CE6A3F0098D02D2A9468D03D260A9A0D0F8A900A202959495989D01D0CA10F660A5A2,473
1200 DATA F0E8C6A2F00BA9118D00D2A94C8D01D260A9A0D0F8201222205E2320072120EF21E69FA59F2903D0EC20F023AD,873
1210 DATA FC02C921F0F9209F22A92D8D0F0AA91D8D100AA59D09108D110A208223203520207420E6A7A5A72907D00620D4,64
1220 DATA 20201A24E693A59325A5D0AF2044214C9923A003A99038E901D0FB88D0F860A28220F02320F02320F0238E00D2,339
1230 DATA 8EC402E8D0EE8E01D2A9088D1FD060A900858F202F2120AC20B182C945D004A9009182E68FE68FA58FC59290E6,160
1240 DATA 60A489A2008A990004E8C8E00DD0F7A9788589A97685888D1ED060A900A899140A99000BC8D0F7A9008582A90A,678
1250 DATA 858360205F24A215D00AA901A0009182A0139182A58218691485829002E683CA10E8A013A90199140A99B80B88,341
1260 DATA 10F560A200AD0AD2291FC916B0F7C90AF0F3C90BF0EFC90CF0EBC90290E79D000CE8E8E49290DEA200AD0AD229,591
1270 DATA 0F1869029D010CE8E8E49290EFA900858F20AC20B182F009C692C692C6914C0525A59CC9C8B00AE69CA5900A0A,137
1280 DATA C59C9011AD0AD2291FC59CB004A9C4D006A983D002A9429182E68FE68FA58FC59290C160A200A9088DF402BD00,993
1290 DATA E09D0008BD00E19D0009E8D0F1A227BD32259D0808CA10F760FFFFFFFFFFFFFFFFE7A5E7663C3C3C667EDBFF3C,565
1300 DATA 183C3C18183C7EDBFF7E1866A5184299994218A520D525205324206824207027A5900A0A0A18691485A8A5A10A,398
1310 DATA 0A0A0A1865A885924A8591A5A4859C209524A5900A0A0A0A0904859E8DC402203924207420A20020F023E8D0FA,643
1320 DATA 4C9923A9038D1DD0A93E8D2F02A9FC8DC002A90E8DC1028DC2028DC302A9008D07D4A900A89900049900059900,162
1330 DATA 06990007C8D0F160205324A206A90F8DC402BD89269D2E0ABD97269D920ABD90269DCE0ACA10EBA20CBD9E269D,96
1340 DATA 530ACA10F7A203A9009D00D0CA10FAA5A109108DA90AA5AD1869118DE50AA20ABDAB269D800BCA10F7AD1FD0C9,300
1350 DATA 05D018E6ADA5AD290185AD1869118DE50AA23120F023CA10FA30E1C903D01CE6A1A5A1C904D004A90185A11869,578
1360 DATA 108DA90AA23120F023CA10FA30C16AB0BE8D1ED0A9008D03D28D02D28D01D2A59E8DC402A205A9109D070ACA10,626
1370 DATA FA8D020A8D030A6073796E74726F6E706C6179657273006C6576656C00E2F980EAEFEE80F3EEF9E4E5F2303225,386
1380 DATA 3333003334213234A2008E03D28E01D2ADC402859E203924207323A20ABD28279D690ABD33279D910ACA10F1A9,496
1390 DATA A68D01D2A59E8DC402A590C90AD035A900859046A5A20ABD3E279DB90ACA10F7E69DA90085A6EE080A203A23A2,815
1400 DATA 02BDC5021869209DC502CA10F4A5AC18691085AC8DC80220FD238D1ED04C5D2573796E74726F6E6F6964730064,547
1410 DATA 657374726F79656400222F2E3533001110101010A904859DA9008590859385AC8DC802A93F85A5A906859EA937,795
1420 DATA 8DC502A9878DC602A9C78DC70260A900EE030AE69085A4A590C90AD011A9328DC802A9108D030AEE020AA9CD85,80
1430 DATA A46070707046000A06060606060606060606060606060606060606060606064191270000000000000000000000,143
1440 REM * 1980 BYTES

Listing 2.
Assembly listing.

;---------------------
;SYNTRON by Jon Snyder
;---------------------
;
;Page Zero variables
;
	*=	$80
;
DLST	.DS	2
SCRST	.DS	2
SCRS1	.DS	2
PM	.DS	2
HPOS0	.DS	1	;Horiz. pos.-PM0
VER0	.DS	1	;Vert. pos.
TEMPX	.DS	1	;Holds Horiz.
YHLD	.DS	1	;Holds Vert.
XHOLD	.DS	1
YHOLD	.DS	1
CHARHLD	.DS	1
MNUM	.DS	1	;Counter
WAVE	.DS	1	;Wave no.
ALN	.DS	1	;No. of Syn.'s
WX4	.DS	1	;(WAVE*4)+20
OVMM	.DS	1	;counter
HPLR	.DS	3	;hpos of bullets
FHLD	.DS	1	;holds stick(1)
MDIR	.DS	3	;way bullet shot
CTKP	.DS	1	;X reg. holder
ALPER	.DS	1	;Syn's per wave
MEN	.DS	1	;No. of men
S708	.DS	1	;Stores loc.708
OVET	.DS	1	;Counter
ANYLF	.DS	1	;Flag
MNNUM	.DS	1	;Level holder
HTSND	.DS	1	;Stores
BSHT	.DS	1	;sounds
SALR	.DS	1	;Value in ALPER
WV10	.DS	1	;AND #WV10
PTS	.DS	1	;Store Syn value
OVSF	.DS	1	;Counter
MNHLD	.DS	1
PVER	.DS	3	;Vpos of Bullet
S712	.DS	1	;Holds background
TEAM	.DS	1
;
;Player and Chset area
;
	*=	0
;
PMAREA	.DS	$0400
PM0	.DS	$0100
PM1	.DS	$0100
PM2	.DS	$0100
PM3	.DS	$0100
CSET	.DS	$0200
SCRN	.DS	$0200
MAREA	.DS	$0100
;
;Shadow registers
;
ATRACT	=	77
SDMCTL	=	$022F
SDLSTL	=	$0230
STICK0	=	$0278
STRIG0	=	$0284
COLOR0	=	$02C4
COLOR1	=	$02C5
COLOR2	=	$02C6
COLOR3	=	$02C7
COLOR4	=	$02C8
PCOLR0	=	$02C0
CHBAS	=	$02F4
CH	=	$02FC
;
;Hardware registers
;
HPOSP0	=	$D000
P0PF	=	$D004
P1PF	=	$D005
GRACTL	=	$D01D
HITCLR	=	$D01E
CONSOL	=	$D01F
AUDF1	=	$D200
AUDC1	=	$D201
RANDOM	=	$D20A
PMBAS	=	$D407
SIOINV	=	$E465
;
;Character set equates
;
WALL	=	$01
SYNTROID	=	$42
SYNTREK	=	$83
SYNTRI	=	$C4
SYNDED	=	$45
;
;Program starts here...
;
	*=	$2000
;
GAME	LDX	#19
	LDA	#0
CLTOP	STA	SCRN,X	;Clear out top
	DEX		;line of screen
	BPL	CLTOP
	LDX	#$80	;Clear top half
CLZ	STA	$00,X	;of page zero
	INX
	BNE	CLZ
	JSR	SIOINV	;Init sound
	LDA	#2	;Default level
	STA	MNNUM
	JSR	PMSETUP	;Set up P/M's
	JSR	BLPL0	;Put Pl.0 in mid
	JSR	CHSET	;Set up chset
	LDA	# <DLIST	;GR.1 DL
	STA	DLST	;location
	STA	SDLSTL
	LDA	# >DLIST
	STA	SDLSTL+1
	STA	DLST+1
	JSR	NWGM
	JMP	WSETUP	;Set up a wave
;
;Check joystick for player movement
;
STCHK	LDA	TEAM	;# players
	ORA	STRIG0
	BEQ	STRTS
	LDA	STICK0
	CMP	#8	;Right?
	BCS	ST1
	LDA	HPOS0
	CMP	#192
	BCS	ST2
	INC	HPOS0
	BCC	ST2
ST1	CMP	#12	;Left?
	BCS	ST2
	LDA	HPOS0
	CMP	#57
	BCC	ST2
	DEC	HPOS0
ST2	LDA	STICK0	;Up?
	LSR	A
	BCS	ST3
	LDA	VER0
	CMP	#48
	BCC	STRTS
	DEC	VER0
	RTS
ST3	LSR	A	;Down?
	BCS	STRTS
	LDA	VER0
	CMP	#196
	BCS	STRTS
	INC	VER0
STRTS	RTS
;
;Draw your man (Player0)
;
PLTPL	LDY	VER0
	LDX	#0	;Turns off
	STX	ATRACT	;attract mode
P1	LDA	MUN,X	;Draw PL.0
	STA	PM0,Y
	INY
	INX
	CPX	#13
	BCC	P1
	LDA	HPOS0
	STA	HPOSP0
	RTS
;
MUN	.BYTE	0,126,129,165,129,66
	.BYTE	36,24,60,60,24,102,0
;
;The STR's erase their respective
;bullets from a former position
;STR0-blanks out former position
;of PM to jmp it to new location.
;
STR0	TXA
	CLC
	ADC	# >PM1
	STA	PM+1
	LDA	#0
	STA	PM
	LDY	PVER,X
	INY
	STA	(PM),Y
	INY
	STA	(PM),Y
	RTS
;
;Find position of syntronoids
;using MAREA bytes
;
EPLOT	JSR	SET18
	LDX	#0	;Draws monsters
	LDY	MNUM	;using figures
EPL1	LDA	SCRST	;from MAREA
	CLC
	ADC	#20
	STA	SCRST
	BCC	EPL2
	INC	SCRST+1
EPL2	INX
	TXA
	CMP	MAREA,Y	;Find vert.bytes
	BCC	EPL1
	LDA	MAREA+1,Y
	CLC
	ADC	SCRST	;Add horiz pos
	STA	SCRST
	BCC	EPL3
	INC	SCRST+1
EPL3	LDY	#0
	RTS
;
;Bullet fired? If so,make it go
;the way the stick is pushed
;
STFIR	LDX	TEAM	;# Players
	BNE	S1
	LDA	STRIG0
	BNE	S4
S1	LDA	STICK0,X	;Stick 0 or 1
	CMP	#15	;pressed?
	BEQ	S4	;No. skip next
	STA	FHLD	;STA strig-FHLD
	LDX	#2
S2	LDA	MDIR,X	;Tells way to go
	BNE	S3	;Its gone somwhr
	LDA	HPOS0	;No dir., so put
	STA	HPLR,X	;Pl.x at Pl.0
	LDA	FHLD
	STA	MDIR,X	;Put STICK here
	JSR	STR0
	LDA	VER0	;Put vpos of
	CLC		;pl.x
	ADC	#6	;at
	STA	PVER,X	;pl.0's position
	LDA	#215	;Set bullet snd
	STA	BSHT
	RTS
S3	DEX		;Check next PM
	BPL	S2	;All chked? No.
S4	RTS
;
;Move the bullet to next position
;
MVPL	LDX	#2
MV1	LDA	MDIR,X	;BULLET X moved?
	BEQ	XIN	;No,so skip this
	CMP	#9
	BCS	LT	;No move right
	INC	HPLR,X	;Move right
	BCC	DW	;JMP past LEFT
LT	CMP	#12
	BCS	DW	;No move left
	DEC	HPLR,X	;Move left
DW	AND	#$02	;Moved down?
	BNE	UP	;No dwn,try up
	INC	PVER,X	;Move down,then
	JMP	XIN	;jmp past up
UP	LDA	MDIR,X
	ROR	A	;Move anyway up?
	BCS	XIN	;No up,go to XIN
	DEC	PVER,X	;Move up
XIN	DEX		;next PM
	BPL	MV1
	RTS
;
;Convert position of PM0 to
;that of a GR.1 character
;
CONV	LDA	HPOS0
	SEC
	SBC	#45
	LSR	A
	LSR	A
	LSR	A
	STA	TEMPX	;=(HPOS0-48)/8
	LDA	VER0	;Vert.conversion
	SEC
	SBC	#31
	LSR	A
	LSR	A
	LSR	A
	STA	YHLD	;=(VER0-31)/8
	RTS
;
;MMOV-move Syntronoid characters
;
MMOV	LDX	#0
	STX	MNUM
	STA	ANYLF
MM1	JSR	CONV	;Find Pl.0
	JSR	EPLOT	;find Syn. pos.
	LDA	(SCRST),Y	;Syn. here?
	BEQ	JMM1	;No.
	STA	CHARHLD	;Store SYN type
	STA	ANYLF	;Wave not over
	LDY	MNUM
	LDA	RANDOM	;Flip coin H or
	BPL	VERT	;V course to PM0
	LDA	MAREA+1,Y
	CMP	TEMPX	;Where is PM0?
	BCS	LFT
	LDA	SCRST	;SYN moves right
	ADC	#1
	STA	SCRS1
	LDA	SCRST+1
	ADC	#0
	JSR	SETADR
	BNE	JMM1
	JSR	REPLOT
	INC	MAREA+1,X
	JMP	JMM1
LFT	LDA	SCRST	;SYN moves LEFT
	SEC
	SBC	#1
	STA	SCRS1
	LDA	SCRST+1
	SBC	#0
	JSR	SETADR
	BNE	JMM1
	JSR	REPLOT
	DEC	MAREA+1,X
JMM1	INC	MNUM	;INC twice to
	INC	MNUM	;chk next SYN.
	LDA	MNUM
	CMP	WX4	;All SYN's chked
	BCC	MM1	;no!
	LDA	ANYLF	;ANY SYN's LeFt?
	BNE	RETN	;Yes
	PLA		;None left-POP
	PLA		;stack twice
	JMP	WVOV	;Wave is over
;
VERT	LDA	MAREA,Y	;Vertical
	CMP	YHLD
	BCS	UP1
	LDA	SCRST	;PM0 below SYN.
	ADC	#20
	STA	SCRS1
	LDA	SCRST+1
	ADC	#0
	JSR	SETADR
	BNE	JMM1
	JSR	REPLOT
	INC	MAREA,X
	JMP	JMM1
UP1	LDA	SCRST	;PM0 above SYN.
	SEC
	SBC	#20
	STA	SCRS1
	LDA	SCRST+1
	SBC	#0
	JSR	SETADR
	BNE	JMM1
	JSR	REPLOT
	DEC	MAREA,X
	JMP	JMM1
;
SETADR	STA	SCRS1+1
	LDY	#0
	LDA	(SCRS1),Y
	RTS
;
REPLOT	STA	(SCRST),Y	;Erase
	LDA	CHARHLD	;Plot 1 up
	STA	(SCRS1),Y
	LDX	MNUM
RETN	RTS
;
;Draw bullets
;
PLBUL	LDA	# >PM3
	STA	PM+1
	LDX	#2
PB0	LDA	PVER,X
	STA	PM
	LDY	#3
PB1	LDA	BULTS,Y
	STA	(PM),Y
	DEY
	BPL	PB1
	LDA	HPLR,X
	STA	HPOSP0+1,X
	DEC	PM+1
	DEX
	BPL	PB0
	RTS
;
BULTS	.BYTE	0,24,24,0
;
;Check-Has bullet hit a SYNTRON
;
CHK	LDX	#2
CH1	STX	CTKP
	LDA	HPLR,X	;If bullet off-
	BEQ	INCHK	;screen, skip
	SEC		;Bullets to
	SBC	#45	;playfield
	LSR	A
	LSR	A
	LSR	A
	STA	XHOLD
	LDA	PVER,X	;Find vpos
	SEC		;of bullet on
	SBC	#32	;a GR.1 screen
	LSR	A
	LSR	A
	LSR	A
	STA	YHOLD
	JSR	SET18	;Reset SCRST
	LDY	XHOLD
	LDX	#0
CH3	LDA	SCRST	;Find the
	CLC		;right part
	ADC	#20	;of GR.1 screen
	STA	SCRST
	BCC	CH3A
	INC	SCRST+1
CH3A	INX
	CPX	YHOLD
	BCC	CH3
	LDA	(SCRST),Y	;Anything?
	BEQ	INCHK	;Nothing!
	JSR	WHIT	;SYNTRON THERE!
INCHK	LDX	CTKP	;Next bullet
	DEX		;Done checking?
	BPL	CH1	;No.
	STA	HITCLR
	RTS
WHIT	LDA	#0	;Erase bullet
	LDX	CTKP	;from screen.
	STA	HPLR,X
	STA	MDIR,X
	LDA	P1PF,X	;LDA col. reg.
	ROR	A	;if bullet hits
	BCS	INCHK	;wall,return
	LDA	(SCRST),Y
	CMP	#SYNTROID
	BNE	WH3
	LDA	#7	;Syntroid hit,
	STA	PTS	;worth 70 points
	JSR	SCORE
	LDA	#SYNDED	;Syntroids
	STA	(SCRST),Y	;remains
	LDA	#20	;Expl. noise
	STA	HTSND
	DEC	ALN	;1 less SYNTRON
WH3	CMP	#SYNTREK
	BNE	WH4
	LDA	#4	;Hit,he's
	STA	PTS	;worth 40!
	LDA	#10
	STA	HTSND
	LDA	#SYNTROID	;Turn syntrek
	STA	(SCRST),Y	;into syntroid
	JSR	SCORE
WH4	CMP	#SYNTRI
	BNE	WH5
	LDA	#2	;Syntri hit,
	STA	PTS	;worth 20!
	LDA	#SYNTREK	;He becomes
	STA	(SCRST),Y	;syntrek.
	JSR	SCORE
	LDA	#10
	STA	HTSND
WH5	RTS
;
;Check- Is your man hit?
;
PCOL	LDA	P0PF
	BEQ	WH5	;No, RETURN
	LDA	#160	;You're hit!
	STA	AUDC1+2	;Some sound
	STA	AUDC1
	JSR	BLMIS	;Reset player
	DEC	MEN	;1 less man
	BPL	DTHC	;Men gone? No.
	PLA
	PLA		;Yes-game over
	LDX	#8
GM1	LDA	OVER,X	;"GAME OVER"
	STA	SCRN+206,X
	DEX
	BPL	GM1
	JSR	LDLAY	;Flash-Delay
	JSR	BLMIS	;Clear bullets
	JSR	NWGM	;Reset game
	JMP	WSETUP
DTHC	LDA	#15	;Player fizzles
	STA	PCOLR0
	LDA	#13
	STA	AUDF1
BPC1	LDX	#20
PC1	JSR	DLAY	;Small delay
	DEX
	BNE	PC1
	LDY	PCOLR0
	DEY
	STY	AUDC1
	STY	PCOLR0
	BNE	BPC1
	LDX	#25
PC2	LDA	#65	;Tone-65
	STA	AUDF1
	LDA	#72
	STA	AUDC1	;SOUND 0,X,10,8
	JSR	DLAY
	LDA	#10
	STA	AUDF1
	JSR	DLAY
	DEX
	BNE	PC2
	LDA	#252
	STA	PCOLR0
	JSR	CLR	;Clear screen
	JSR	DRWALL	;Draw walls
	JSR	BLPL0
	JSR	PLTPL	;PM0 to middle
	LDA	SALR	;Proportion
	STA	ALPER	;of aliens
	LDA	ALN
	ASL	A
	STA	WX4
	JSR	PLTSYN	;Plot SYN's
	STA	HITCLR	;Clr collisions
	LDA	#0	;Sound off
	STA	AUDC1
	TAX
PC4	JSR	DLAY	;A Delay
	INX
	BNE	PC4
	RTS
;
OVER	.SBYTE	"GAME OVER"
;
;Adds to and displays score
;
SCORE	LDA	SCRN+11
	CLC
	ADC	PTS
	STA	SCRN+11
	LDX	#4
SCO1	LDA	SCRN+7,X
	CMP	#26	;internal "9"+1
	BCC	SCO2
	SBC	#10
	STA	SCRN+7,X
	INC	SCRN+6,X
	CPX	#2	;If over 10000
	BNE	SCO2	;multiple- get
	INC	MEN	;a free life
SCO2	DEX
	BPL	SCO1
	RTS
;
;Sound of a fired bullet
;
BNOI	LDA	BSHT
	BEQ	BN4
	INC	BSHT
	BEQ	BN2
	STA	AUDF1+2
	LDA	#70
BN3	STA	AUDC1+2
BN4	RTS
BN2	LDA	#160
	BNE	BN3
;
;BLMIS resets bullets when
;you're killed, gmov, or new game
;
BLMIS	LDA	#0
	LDX	#2
BI1	STA	HPLR,X
	STA	MDIR,X
	STA	HPOSP0+1,X
	DEX
	BPL	BI1
	RTS
;
;Sound of a hit monster
;
MSND	LDA	HTSND
	BEQ	BN4
	DEC	HTSND
	BEQ	MS2
	LDA	#17
	STA	AUDF1
	LDA	#76
MS3	STA	AUDC1
	RTS
MS2	LDA	#160	;Turn off So.0
	BNE	MS3
;
;Main loop
;
MAIN	JSR	CHK	;Bullet to SYN.
	JSR	BNOI	;Bullet noise
	JSR	MVPL	;Move PM0
	JSR	PLBUL	;Draw bullets
	INC	OVET	;OVET used so
	LDA	OVET	;bullets go
	AND	#$03	;faster than PM0
	BNE	MAIN
	JSR	DLAY
PAUSE	LDA	CH	;Is SPACE BAR
	CMP	#33	;hit?
	BEQ	PAUSE	;Yes, so pause
	JSR	PCOL	;Your man hit?
	LDA	#45	;Internal M
	STA	SCRN+15
	LDA	#29	;Internal =
	STA	SCRN+16
	LDA	MEN
	ORA	#16
	STA	SCRN+17
	JSR	MSND
	JSR	STCHK	;Stick check
	JSR	PLTPL	;Plot PM0
	INC	OVSF	;OVSF spaces
	LDA	OVSF	;bullets apart
	AND	#$07
	BNE	NXT
	JSR	STFIR
	JSR	ERDED
NXT	INC	OVMM	;OVMM slows
	LDA	OVMM	;syntronoids
	AND	WV10
	BNE	MAIN
	JSR	MMOV
	JMP	MAIN	;Re-execute loop
;
;Delay-sets general game speed
;
DLAY	LDY	#3
	LDA	#$90
MN1	SEC
	SBC	#1
	BNE	MN1
	DEY
	BNE	MN1
	RTS
LDLAY	LDX	#130	;Long delay
LD1	JSR	DLAY
	JSR	DLAY
	JSR	DLAY
	STX	AUDF1
	STX	COLOR0
	INX
	BNE	LD1
	STX	AUDC1
	LDA	#8
	STA	CONSOL
	RTS
;
;Erase any SYNDED character
;
ERDED	LDA	#0
	STA	MNUM
ERD1	JSR	CONV
	JSR	EPLOT
	LDA	(SCRST),Y
	CMP	#SYNDED
	BNE	ERD2
	LDA	#0
	STA	(SCRST),Y
ERD2	INC	MNUM
	INC	MNUM
	LDA	MNUM
	CMP	WX4
	BCC	ERD1
	RTS
;
;Reset player0 to center of screen
;
BLPL0	LDY	VER0
	LDX	#0
	TXA
BL1	STA	PM0,Y
	INX
	INY
	CPX	#13
	BNE	BL1
	LDA	#120
	STA	VER0
	LDA	#118
	STA	HPOS0
	STA	HITCLR	;Clear collisons
	RTS
;
;Clear screen
;
CLR	LDA	#0
	TAY
CLR1	STA	SCRN+20,Y
	STA	SCRN+256,Y
	INY
	BNE	CLR1
;
;Reset SCRST to top of GR.1 scrn
;
SET18	LDA	# <SCRN
	STA	SCRST
	LDA	# >SCRN
	STA	SCRST+1
	RTS
;
;Draws walls-Color in loc. 708
;
DRWALL	JSR	SET18
	LDX	#21
	BNE	DR1A
DR1	LDA	#WALL	;Vertical walls
	LDY	#0
	STA	(SCRST),Y
	LDY	#19
	STA	(SCRST),Y
DR1A	LDA	SCRST
	CLC
	ADC	#20
	STA	SCRST
	BCC	DR2
	INC	SCRST+1
DR2	DEX
	BPL	DR1
	LDY	#19
DR3	LDA	#WALL
	STA	SCRN+20,Y
	STA	SCRN+$01B8,Y
	DEY
	BPL	DR3
	RTS
;
;Plot monsters in random positions
;
PLTSYN	LDX	#0
PLT1	LDA	RANDOM
	AND	#$1F
	CMP	#22	;not at 22 down
	BCS	PLT1
	CMP	#10
	BEQ	PLT1
	CMP	#11
	BEQ	PLT1
	CMP	#12
	BEQ	PLT1
	CMP	#2
	BCC	PLT1
	STA	MAREA,X	;Store location
	INX		;at MAREA
	INX
	CPX	WX4
	BCC	PLT1
	LDX	#0
PLT2	LDA	RANDOM	;Random horiz.
	AND	#$0F
	CLC
	ADC	#2
	STA	MAREA+1,X
	INX
	INX
	CPX	WX4
	BCC	PLT2
	LDA	#0
	STA	MNUM
PLST	JSR	EPLOT
	LDA	(SCRST),Y	;Something
	BEQ	PLT3	;already there?
	DEC	WX4	;YES,-1 Syn.
	DEC	WX4
	DEC	ALN	;WX4/2
	JMP	PLT4
PLT3	LDA	ALPER
	CMP	#200	;At Wave 10?
	BCS	SPEC	;Yes!
	INC	ALPER
	LDA	WAVE
	ASL	A
	ASL	A
	CMP	ALPER	;Chk proportions
	BCC	REG	;Syntroids now!
SPEC	LDA	RANDOM
	AND	#$1F
	CMP	ALPER
	BCS	GAL2	;> store syntrek
	LDA	#SYNTRI	;< Store syntri
	BNE	REG1
GAL2	LDA	#SYNTREK
	BNE	REG1
REG	LDA	#SYNTROID
REG1	STA	(SCRST),Y
PLT4	INC	MNUM	;Check next 2
	INC	MNUM	;bytes
	LDA	MNUM
	CMP	WX4
	BCC	PLST
	RTS
;
;Redefine character set
;
CHSET	LDX	#0	;Character set
	LDA	# >CSET
	STA	CHBAS
CS1	LDA	$E000,X	;Put ROM set
	STA	CSET,X	;in RAM
	LDA	$E100,X
	STA	CSET+256,X
	INX
	BNE	CS1
	LDX	#39
CS3	LDA	ALIS,X	;Redefine to
	STA	CSET+8,X	;make SYN.'s
	DEX
	BPL	CS3
	RTS
;
ALIS	.BYTE	255,255,255,255
	.BYTE	255,255,255,255
	.BYTE	231,165,231,102
	.BYTE	60,60,60,102
	.BYTE	126,219,255,60
	.BYTE	24,60,60,24
	.BYTE	24,60,126,219
	.BYTE	255,126,24,102
	.BYTE	165,24,66,153
	.BYTE	153,66,24,165
;
;This sets up a wave-JSR START
;is accessed only at a new game
;
WSETUP	JSR	START
W1	JSR	CLR
	JSR	DRWALL
	JSR	WAVSCR	;Which wave?
	LDA	WAVE	;Find no. of
	ASL	A	;syn.'s that
	ASL	A	;go on this wave
	ASL	A
	CLC
	ADC	#20
	STA	MNHLD
	LDA	MNNUM
	ASL	A
	ASL	A
	ASL	A
	ASL	A
	CLC
	ADC	MNHLD
	STA	WX4	;To read-ALN*2
	LSR	A
	STA	ALN
	LDA	SALR
	STA	ALPER
	JSR	PLTSYN	;plot Syn's
	LDA	WAVE	;Find
	ASL	A	;color
	ASL	A
	ASL	A
	ASL	A	;of
	ORA	#4
	STA	S708	;walls
	STA	COLOR0
	JSR	BLPL0	;Reset your man
	JSR	PLTPL	;Draw Pl.0
	LDX	#0
LOOP	JSR	DLAY	;Delay
	INX
	BNE	LOOP
	JMP	MAIN
;
;Set up P/M graphics
;
PMSETUP	LDA	#3	;Turn on P/M's
	STA	GRACTL
	LDA	#62	;DMA
	STA	SDMCTL
	LDA	#252	;Pl.0 color
	STA	PCOLR0
	LDA	#14	;Bullets colors-
	STA	PCOLR0+1	;white!
	STA	PCOLR0+2
	STA	PCOLR0+3
	LDA	# >PMAREA	;Location of
	STA	PMBAS	;P/M Table
	LDA	#0
	TAY
CLPM	STA	PM0,Y	;Clear P/M
	STA	PM1,Y	;areas
	STA	PM2,Y
	STA	PM3,Y
	INY
	BNE	CLPM
	RTS
;
;Title screen-Check start key
;
START	JSR	CLR
	LDX	#6
	LDA	#15
	STA	COLOR0
SA1	LDA	TITL,X	;"SYNTRON"
	STA	SCRN+46,X
	LDA	LEVL,X	;" LEVEL "
	STA	SCRN+146,X
	LDA	PLRL,X	;"PLAYERS"
	STA	SCRN+206,X
	DEX
	BPL	SA1
	LDX	#12
SA2	LDA	CRED,X	;By Jon Snyder
	STA	SCRN+83,X
	DEX
	BPL	SA2
	LDX	#3
	LDA	#0
PUT0	STA	HPOSP0,X	;Set bullet
	DEX		;locations to 0
	BPL	PUT0
	LDA	MNNUM
	ORA	#16	;Put level no.
	STA	SCRN+169
	LDA	TEAM
	CLC
	ADC	#17
	STA	SCRN+229
	LDX	#10
SA4	LDA	PRSA,X	;"PRESS START"
	STA	SCRN+384,X
	DEX
	BPL	SA4
SELECT	LDA	CONSOL	;Special keys
	CMP	#5	;SELECT pressed?
	BNE	OPTION	;No.
	INC	TEAM
	LDA	TEAM
	AND	#1
	STA	TEAM
	CLC		;Put # players
	ADC	#17
	STA	SCRN+229	;on screen
	LDX	#49
SDL1	JSR	DLAY
	DEX
	BPL	SDL1
	BMI	SELECT
OPTION	CMP	#3	;OPTION pressed?
	BNE	STT2	;No.
	INC	MNNUM
	LDA	MNNUM
	CMP	#4
	BNE	STT1
	LDA	#1
	STA	MNNUM
STT1	CLC		;Put level no.
	ADC	#16
	STA	SCRN+169	;on screen
	LDX	#49
SDL	JSR	DLAY
	DEX
	BPL	SDL
	BMI	SELECT
STT2	ROR	A	;Start key hit?
	BCS	SELECT	;No!
	STA	HITCLR	;Clear collis.'s
	LDA	#0
	STA	AUDC1+2	;and sounds
	STA	AUDF1+2
	STA	AUDC1
	LDA	S708
	STA	COLOR0
	LDX	#5
	LDA	#16	;Put 0's at
STT3	STA	SCRN+7,X	;score locations
	DEX
	BPL	STT3
	STA	SCRN+2
	STA	SCRN+3
	RTS
;
TITL	.SBYTE	"syntron"
PLRL	.SBYTE	"players"
LEVL	.SBYTE	" level "
CRED	.SBYTE	+$80,"by jon snyder"
PRSA	.SBYTE	"PRESS START"
;
;End of a wave
;
WVOV	LDX	#0
	STX	AUDC1+2
	STX	AUDC1
	LDA	COLOR0
	STA	S708
	JSR	BLPL0	;Clear Pl.0
	JSR	BLMIS	;and bullets
	LDX	#10
OV1	LDA	SYNT,X	;"SYNTRONOIDS"
	STA	SCRN+105,X
	LDA	DSTR,X	;"DESTROYED"
	STA	SCRN+145,X
	DEX
	BPL	OV1
	LDA	#166
	STA	AUDC1
	LDA	S708
	STA	COLOR0
	LDA	WAVE
	CMP	#10	;10 waves done?
	BNE	KD
	LDA	#0	;Yes!
	STA	WAVE
	LSR	WV10	;Speed up action
	LDX	#10
RGN	LDA	BONUS,X	;Region X
	STA	SCRN+185,X
	DEX
	BPL	RGN
	INC	MEN
	LDA	#0
	STA	PTS
	INC	SCRN+8
	JSR	SCORE
	LDX	#2
NWCL	LDA	COLOR1,X	;Change
	CLC		;color of Syn.'s
	ADC	#32
	STA	COLOR1,X
	DEX
	BPL	NWCL
	LDA	S712
	CLC
	ADC	#16
	STA	S712
	STA	COLOR4
KD	JSR	LDLAY
	STA	HITCLR
	JMP	W1
;
SYNT	.SBYTE	"syntronoids"
DSTR	.SBYTE	" destroyed "
BONUS	.SBYTE	"BONUS 10000"
;
;Reset for a new game
;
NWGM	LDA	#4	;Reset men
	STA	MEN
	LDA	#0	;Reset wave
	STA	WAVE
	STA	OVMM
	STA	S712
	STA	COLOR4
	LDA	#$3F
	STA	WV10
	LDA	#6
	STA	S708
	LDA	#55	;Reset Syn.
	STA	COLOR1	;colors
	LDA	#135
	STA	COLOR2
	LDA	#199
	STA	COLOR3
	RTS
;
;Puts wave no. at upper left
;
WAVSCR	LDA	#0
	INC	SCRN+3
	INC	WAVE
	STA	SALR
	LDA	WAVE
	CMP	#10
	BNE	WV2
	LDA	#50	;10th Wave!
	STA	COLOR4
	LDA	#16
	STA	SCRN+3
	INC	SCRN+2
	LDA	#205	;Makes all
	STA	SALR	;syntris appear!
WV2	RTS
;
DLIST	.BYTE	$70,$70,$70,$46
	.WORD	SCRN
	.BYTE	6,6,6,6,6,6,6,6
	.BYTE	6,6,6,6,6,6,6,6
	.BYTE	6,6,6,6,6,6,6,$41
	.WORD	DLIST
;
	*=	$02E0
	.WORD	GAME
	.END