A.N.A.L.O.G. ISSUE 20 / JULY 1983 / PAGE 35

Bacterion!

16K Cassette or 24K Disk

by Kyle Peacock with Tom Hudson

The year is 2284. The “Robotron Incident” of 2084 has long been forgotten, and the field of genetic engineering has led to the fabrication of synthetic humans. Each fabricated unit is genetically engineered to perform a specific task to perfection.

Fifty years later, through a unanimous vote of the United Nations, these “Syntrons” have been installed into every top political position in the world. Each represents the opinion of the particular government they were assigned. The fate of continents rests in the hands of the Syntrons.

Now the year is 2369. Long-term studies of the Syntrons’ behavioral patterns yield strange results. A genetically invulnerable bacteria has infected the species. The bacteria preys on the cerebral nerves responsible for all higher order brain processes, making the individual deranged and quite unstable.

This bacteria has begun to trickle down to infect the Syntrons’ counterpart: man. Soon, mankind will teeter on the very brink of insanity and demise, unless a means can be found to halt the plague of 2369: Bacterion!

Loading instructions.

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 Bacterion! data statements are listed in hexadecimal (base 16), so the program will fit in 16K cassette systems. This makes typing more difficult, but if you want to play the game…

Listing 2 is the assembly language source code for Bacterion! You do not 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 Bacterion!

Cassette instructions.

  1. Type Listing 1 into your computer using the BASIC cartridge, and verify your typing with C:CHECK (see page 23).
  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 DATA lines are correct, the computer will beep twice and prompt you to “READY CASSETTE AND PRESS RETURN.” 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 of Bacterion!, 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 the game, 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 Bacterion! will load and run automatically.

Disk instructions.

  1. Type Listing 1 into your computer, using the BASIC cartridge, and verify your typing with D:CHECK2 (see page 23).
  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 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 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. Bacterion! will load and run automatically.

Playing the game.

Bacterion! is a game for one or two players. In the two-player mode, both play simultaneously. In this mode, the game is more cooperative than competitive. You must prevent the six (count ’em, six!) different strains of Bacterion from removing the ten cerebral cells from the host Syntron. A cell is inoperative when it is completely removed from the screen.

As a member of BARF (Biological Armament Restriction Force), you are equipped with a miniaturized GEV (Genetic Extermination Vehicle) to aid you in your mission. The vehicle emits high-frequency photons from its nose, capable of vaporizing the Bacterion, while leaving brain tissue and other GEV’s undamaged.

Control over your GEV is accomplished through the joystick. A two-player game will require as many joysticks. Pushing up will cause your GEV to move forward. Moving the stick left or right will cause the vehicle to rotate in the respective direction. Pushing the trigger fires the photonic bursts. Any one player can have up to four high-energy photons on the screen at once. Holding down the trigger fires all available photons in rapid succession. Should your GEV be destroyed by either running into your opponent or being skragged by a Bacterion, you must wait several seconds for another GEV to be injected into the host. Parking or driving your GEV over a brain cell gives it unsure traction, which may cause the vehicle to rotate randomly. Each GEV is internally powered, so there is an unlimited supply of ammunition.

Initially, each Syntron has a unique brain pattern. You may select which of the three top political figures you wish to put “under the knife.” Each individual has a total often cerebral cells. Some cells may be harder to visualize, since there may be two or more on top of one another.

The SELECT button will choose between a one- or two-player game. The OPTION button will choose which political leader you will operate on. Examination of the speed at which the colors change in the word “BACTERION!” on the title screen dictate the brain pattern. The Prime Minister of England, President of the U.S. S.R. and the President of the U.S. are your three available candidates. The START button will begin the game. Pausing or examination of scores is accomplished by pressing the space bar. Pressing the space bar a second time will resume the life-or-death struggle. Each of the six attacking strains are worth from 10 to 60 points, respectively.

Additional credits.

My special thanks goes to Tom Hudson for his assistance in Bacterion! Through the use of his Graphics 7+ handler presented in issue #11, and some custom-made shape-drawing routines, we’ve put together the best (as in #1) two-player public domain assembly language game ever! If you agree or disagree, I’d like to hear it. Drop me a line, care of Kyle Peacock here at the editorial offices of ANALOG.

BASIC Listing

10 REM *** BACTERION ***
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,40:CLOSE #1:END 
160 FOR X=1 TO 2: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,40:PUT #1,85:PUT #1,59: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,39,216,39,255,39,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,40,133,11,24,96
1000 DATA 2065E4A9228D2F02A9288581A9008580A9088583A9008582A000B1809182C8D0F9E681E683A581C940D0EFA90B,831
1010 DATA 850D8503850BA912850C8502850A4C120BA200A90E9D001FCAD0FAA9708D001F8D011FA9F08D021FA94E8D031F,796
1020 DATA 8D6B1FA9208D051FA9108D041FA9308D6D1FA9008D6C1FA9418DC81FA98E8DC71FA91F8DCA1FA9008DC91FA93E,396
1030 DATA 8D2F02A9008D07D4A9038D1DD0A9108D6F02A900AA9D00049D0005CAD0F7A202A90095A995AC95AFCA10F7A910,369
1040 DATA 8580A9208581A200A5809D351BA5819DF51BA900A02791808810FBE8E0C0F010A5801869288580A58169008581,840
1050 DATA 4CBC08A6A4BC7D09A20986B7B9800995E895D4B99E099DC91C9DB51CA90095C0C8CA10E8A20086A88E7D1D8E7E,608
1060 DATA 1D204209A5A5F004E8204209A9018D451E8D1F1E8D201E8D211EA205BD71099DAB13BD6B099DA413BD77099DD9,837
1070 DATA 0ACA10EB4CBC09A9009D691D9D1D1EA9019D461E9D5A1EBD69099D311E9D2D1DBD67099D7D1DA9809D911D602C,103
1080 DATA C30C04342C241C140C0D0B0907050346413C37322D000A1444505C3E4A566244505C4F4F4F4F4955435B3D614F,598
1090 DATA 47574F4F4F4F47574F5D5D5D606060606363634C52585E626266666A6A565A5A5E5E5E5E626266A201869ECA8A,956
1100 DATA 8D05D28D07D28D08D29D00039D00069D00078D1ED0CAD0F1A204AD451E9D1D1E20EB0A9D7D1DAD0AD21004A915,391
1110 DATA D002A9E49D911D20F40AA9008D0F0B85B69D691D9DDD1C9DCD1D9DF11C9D551DADFD0AC9D8B057A90A20FD0AA8,809
1120 DATA 8E100BBD551DF00698DDDD1CF03BE8E005D0F0AE100BB9B51CC9C2B02CA90220FD0A8C110BA8B9E10A9D551DB9,245
1130 DATA DF0AAC110B1879B51C9DB91DB9D40018692C9DA51D989DDD1C4C810AAE100BCE0F0BD0A9A4A5C89820FD0AA8B9,236
1140 DATA 7D1D9DA51DB9911D9DB91DCAE001F0034CDC09A92885B5AE451EBDD80A85B9C905900638E9039DD80AA20CA9FF,604
1150 DATA 9D6E1E95D99DBA1C95C5CAE004D0F1A203AD0AD229F0090A9DC002AD0AD229F01DE70A9DC402CA10E8A90085BC,311
1160 DATA 85BE85BD85BF859E6000000000000015240AF50C0C0A0A0C08080AA96420FD0A18694B60A91020FD0A9D2D1D60,732
1170 DATA 8D0E0BAD0AD2CD0E0B90054A4A4C030B6000000000A9008D01D28D03D220E30E20430FA90185A8859EA906A20C,377
1180 DATA A0F8205CE4A907A20DA056205CE4A9C08D0ED420BA0FA5A3C901D0F7E6A3203E08A5A3C902D0C1ADFC02C921D0,328
1190 DATA 37AD0FD22904F03020430FA5B748A90A85B7A90185A8859E8DFC0220BA0FADFC02C921D0F9AD0FD22904F0F968,687
1200 DATA 85B7A90085A8859E8DFC02C6B31004A90985B3A6B3B5C0D012B5E88588BDC91C8589A901858AA90020401AA909,270
1210 DATA 85B2A6B2B5C0F00320101AC6B210F3A9048DB70DAEB70DBDCD1DF053302E09809DCD1DA902858ABD7D1D38E92C,616
1220 DATA 9DF51D8588BD911D38E91CC9C0B02E9D091E8589BDCD1D297F20401A4C200CDEE11D101EBDF51D8588BD091E85,525
1230 DATA 89A900858ABDCD1D297F20401AAEB70DA9009DCD1DCEB70DADB70DC901D09BA211B5C0F033B5E88588BDC91C85,157
1240 DATA 89A90095C0858A8E6E10204219AE6E10B5D495E88588BDB51C9DC91C8589A903858A8E6E10204219AE6E10CAE0,423
1250 DATA 09D0C4A5B7101320BA0FA901859E8514A613E8E413D0FC4C120BA5B6C903F0034C4B0B20430FEE451EAD451EC9,175
1260 DATA 079051AD0AD229F08DC802A901859E85A820BA0FA5B748A90A85B78514A613E8E413D0FC6885B7A90085A8859E,792
1270 DATA 8DFC0285A085A1859FA205BDAB13C9029003DEAB13BDA413C908900638E9049DA413CA10E6A9018D451E8D1F1E,798
1280 DATA 8D201E8D211E20BC094C4B0BD8A5A80AAABD72108D3002BD73108D3102BD76108D0002BD77108D0102A9008D00,591
1290 DATA D08D01D08D02D08D03D08D04D08D05D08D06D08D07D0A59ED020854DADC4021869108DC402A90485B4202011C6,663
1300 DATA B4A5B4C901D0F52020122076124C5FE4D820BB0E207F0DA59ED01B201417205E18208510209C1720961220CE0D,739
1310 DATA 20FE0D20220E20B2134C62E4A6B73019BDB80D85A2BDC30D85A7A6A28E00D2E88E02D2A5A6F003C6A660A5A785,314
1320 DATA A6EEB60DADB60D2901AABDB40D8D01D28D03D26000A40000A0AAB4BEC8D2DCE6F0FA8C020406080A0C0E101214,141
1330 DATA 01A69FF00FCAC69FBDE20D8D04D2BDF00D8D05D26000ECD8C5B19D8A76634F3B28140100A2A2A2A2A4A4A4A4A4,963
1340 DATA A4A6A6A6A6A1F00FCAC6A1BD120E8D06D2BD1A0E8D07D26000FED4AA7F552B0100A8A8A8A8A8A8A8A6A0F00FCA,880
1350 DATA C6A0BD360E8D04D2BD790E8D05D26000FDF9F5F1EDEAE6E2DEDAD6D3CFCBC7C3BFBCB8B4B0ACA8A5A19D999591,399
1360 DATA 8E8A86827E7B77736F6B6764605C5854504D4945413D3936322E2A26221F1B17130F0B0804008A8A8A8A8A8A8A,57
1370 DATA 8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A8A,267
1380 DATA 8A8A8A8A8A8A8A8A8A8A8A8A8AAD1FD0C907F0048D180F60AD180FC906F009C905F00AC903F03360A2014C120F,188
1390 DATA E6A5A5A5290185A5A213A9009D88169D9C16CA10F7A6A5BD190FAABD1B0F9D8816BD2F0F9D9C16CA10F14C120F,148
1400 DATA E6A4A5A4C903B0F8A20086A38E180F60000A13B0ACA1B9A5B200D100000000B0ACA1B9A5B200D2005050505050,157
1410 DATA 5000000000000050505050505000F8A6A5B4BEF01BAD451E0A0A0A0A1875AD95ADA90075AB95ABA90075A995A9,431
1420 DATA 88D0E5CA10DEA205A4A58A398310AAB5A948290F0950BC7A10999D16684A4A4A4A0950999C16CA10DF18A204A0,288
1430 DATA 02B5A975AA99AF00CACA8810F4A202BC8010B5AF48290F0950997516684A4A4A4A0950997416CA10E6D860A900,125
1440 DATA 8D05D28D07D2859F85A085A160D848AD7D1D8D00D0AD7E1D8D01D0AD7F1D8D02D0AD801D8D03D0AD811D8D07D0,505
1450 DATA 1869028D06D01869028D05D01869028D04D0A9078D0002A9108D0102684048A9008D00D08D01D08D02D08D03D0,419
1460 DATA 8D04D08D05D08D06D08D07D06840488A48A207AD70108D6F10AD6F108D0AD48D17D0AD6F101869028D6F10CA10,977
1470 DATA EBA9658D0002A9108D0102CE7110100EA5A48D7110EE71100E7110EE701068AA684048ADC5028D17D068400000,220
1480 DATA 0000001FEB10C90F2410010D030F051107090B0E0FA204E002B01CBD911DCDC810B00FBC2D1DB9CB109D2D1D20,380
1490 DATA F7124CA710CDCA10B0ECBD7D1DCDC710B00FBC2D1DB9DB109D2D1D20F7124CC310CDC910B0ECCA10C1602C20C8,807
1500 DATA D70807060504030201000F0E0D0C0B0A09000F0E0D0C0B0A09080706050403020170707070468816469C167070,410
1510 DATA 70F0463816B0464C165046B0162046C4162046D8162046EC167070460017707046601646741641EB10A6B4BD69,515
1520 DATA 1DF00160BDDD1C3039A4A5B9691DD02FBD7D1D38F97D1D20E112C5B5B021BD911D38F9911D20E112C5B5B013B9,866
1530 DATA 7D1D8D7F13B9911D8D8013204013A901D0118810C9BDA51D8D7F13BDB91D8D8013A9009D411DAD7F13DD7D1DF0,532
1540 DATA 12B022AD8013DD911DD004A904D074B04A9035AD8013DD911DF066B004A900F062A908D05EAD8013DD911DD004,781
1550 DATA A90CD052B03B9000200512F0069008A90DD043A90ED03FA90FD03B200512F0069008A903D030A902D02CA901D0,128
1560 DATA 28200512F0069008A905D01DA906D019A907D015200512F0069008A90BD00AA90AD006A909D002A9FF9D191D60,208
1570 DATA AD801338FD911D20E1128D8313AD7F1338FD7D1D20E112CD831360C6B81047AE451EBDA31385B8A204BD691DD0,212
1580 DATA 33A90320FD0AA8C8BD191DDD2D1DF024B00E206C12C908B0109849FFA8C83009206C12C908F002B0F098187D2D,937
1590 DATA 1D20E9129D2D1DCAE001D0C360BD191D38FD2D1D4CE112A204DE051D1013AC451EB9AA13BCDD1C10020A0A9D05,90
1600 DATA 1D20F712CAE001D0E360A204BD691DD03EBDDD1C1016BD911DC90F9004C9EB900BE6B6C6B7A9019D691DD023BD,613
1610 DATA 411DD01EBD191D1019BD551DF0149DB91D20EB0A9DA51D20F40ABDDD1C09809DDD1CCAE001D0B860100549FF18,346
1620 DATA 690160100418691060C910900338E91060BD691DD043BD191D303EBC2D1DB984138D8113187D7D1D9D7D1DB994,359
1630 DATA 138D8213187D911D9D911DBDDD1C101C297FA8AD81131879D40099D400AD82131879B51C99B51CA90199C00060,832
1640 DATA DEF11C1029A5B99DF11CBDCD1DD01FBD191D48207711A8689D191DC0FFF00FB96F139DCD1DA90A9DE11DA90E85,98
1650 DATA 9F6001080808040606060207070703050505000000000000FFFEFEFEFEFEFF0001020202020201FEFEFEFF0001,251
1660 DATA 02020202020100FFFEFE0000000000000000000000000000A9048D5814AE5814BC1D1EBD311ED966149006B965,19
1670 DATA 149D311ED9651490F50AA8B978148584B979148585AD58140AA8B96E148586B96F148587A9078D5A14187D911D,737
1680 DATA 8D5B14AC5A14B184AC5B149186CE5B14CE5A1410EEA9078D5914AE5814BD911DAE5914187D5D14A8A9009186CE,467
1690 DATA 591410E9CE5814108DCE5C141028A9048D5C14AAE002B007BD1D1EC907D014BD311EC92FF00DFE311EC92ED006,922
1700 DATA E0029002E6B6CA10DE600000000003FCFDFEFF08090A0B001014181C1F23273000040005000600070003D814E0,23
1710 DATA 14E814F014F8140015081510151815201528153015381540154815501558156015681560157015781580157815,526
1720 DATA 8815901598159015A015A815B015B815C015C815C015D015D815E015E815F015F8150016081610161816201628,329
1730 DATA 16301610101038548244442020101E192120108040201F191010180000C6391810100C040B10F0100B04000C10,80
1740 DATA 101839C60000181010191F204080102021191E1020204444824438101010080484987808040418080898F80402,243
1750 DATA 01300808189C63000020D0080F08D020000000631C18080830010204F898080818040408789884040818002481,381
1760 DATA 812400181842248181244218994224818124429900003C24243C00000066421818426600C3810018180081C33C,180
1770 DATA 42A58181A5423C00182442422418000000183C3C18000000001824241800000018005A5A001800180018A5A518,130
1780 DATA 00182020E4181827040400246618186624000404271818E420200C4090252588400C180099A104184224300219,301
1790 DATA 84A019023024420824A59100180000001818000000000008381C100000000808781E10100008082CE007341010,877
1800 DATA 084A24C00324521089422480012442918142000000004281810000000000008100000000000000000000000000,587
1810 DATA 626163746572696F6E41000000000000B4A8A500B0ACA1A7B5A500AFA600D2D3D6D9000000000000B4A5A1AD00,10
1820 DATA B3A3AFB2A500000000000000000000000000000000000000000000000000000000000000000000000000000000,870
1830 DATA 000000000000000000000000000000000000000000000000000000000000000000002239000000000000000000,961
1840 DATA 00000000EBF9ECE500F0E5E1E3EFE3EB0000000000000000000000003729342800000000000000000000000000,720
1850 DATA F4EFED00E8F5E4F3EFEE00000000000000A1AEA1ACAFA700A3AFADB0B5B4A9AEA70000A6A5BD691DF00BDE691D,694
1860 DATA D0262042094C4617204A17DE7F171018A9039D7F17BC7802BD2D1D18798C1720E9129D2D1D9D311ECA10CD60DE,608
1870 DATA 461E102FBD7802C90EF008C90AF004C906D006DE5A1E4C6717FE5A1EBC5A1EB981179D5A1E9D461EBD461ECD8B,151
1880 DATA 17F00320F71260000002020203040506070808080000000000FFFFFF0001010100000000A6A5BD691DD077A901,784
1890 DATA 8D5B18BD0CD02902F003202118EE5B18BD0CD02904F003202118EE5B18BD0CD02908F003202118EE5B18A0038A,760
1900 DATA 1869013908D0F0032021188810F1CE5D181028A9038D5D18BD04D02901F01CA90220FD0AAC0AD2100549FF1869,744
1910 DATA 01187D2D1D20E9129D2D1D9D311EBD04D02902F0068E5B18202118CA10818D1ED0608C5C18AC5B18B9691DD00D,659
1920 DATA 8AA8203D18AC5B18203D18F6BEAC5C1860B9691DD013A907991D1EA97899691DA900859FA94285A0606868AC5C,373
1930 DATA 18600000002064184CCA18A6A5BD691DD05BB5BAF005D6BA4CC618B5BCC904B04CBD10D0D047F6BCA90785A1A9,805
1940 DATA 0395BAA00CB96E1E300388D0F88C40198A996E1EBC2D1D9848B984130A187D7D1D38E92CAC4019997D1D68992D,281
1950 DATA 1DA8B994130A187D911D38E91CAC401999911DCA109D60A20CBD6E1E306920F712BD7D1DC9A2B03E95D9BD911D,165
1960 DATA C9C0B0359DBA1CA004B9691DD043BD7D1D18693038F97D1DC909B035BD911D18692038F9911DC909B027203D18,879
1970 DATA 8E4119BD6E1EAAF6BEAE41198E4119BD6E1EAAD6BCAE4119A9FF9D6E1E95D99DBA1CD00588C001D0B3A90195C5,610
1980 DATA CAE004D08D600000A689E0C1B02EBD351B8580BDF51B8581A588C9A0B01E2903AAA5884A4A8598A48ABD2D1B39,116
1990 DATA 251B8595BD291BA49831800595918060A58CC589900B38E5898590A9018592D00BA58938E58C8590A9FF8592A5,768
2000 DATA 8BC588900B38E588858FA9018591D00BA58838E58B858FA9FF8591A900858E858DA58FC590900A859385944A85,751
2010 DATA 8E4CCE19A590859385944A858DA593F03DA58E186590B009858EC594900EA58E38E594858EA5891865928589A5,593
2020 DATA 8D18658FB009858DC594900EA58D38E594858DA5881865918588204219C693D0C360A6B2A90095C0858AB5E885,455
2030 DATA 88BDC91C8589A90020401AA6B2B5D4858895E8BDB51C85899DC91CA901858AA90020401A600A0A0A8599A90885,465
2040 DATA 9AA699BCDD1A3034B9851A859BB98D1A859CBD951A859DA58818659B8588A58918659C8589A59AC908F0032042,972
2050 DATA 19A59DF004C69DD0E1E699C69AD0C560000001FF01FF01FFFF010000FF0101FF03020202020202000028000000,178
2060 DATA 000000002800000000000000280000000000000028000000000000002800000000000000280000000000000028,418
2070 DATA 000000000000002800000000000002050307040206FF0000FF00000000000001FF00000000000002FF00000000,510
2080 DATA 000003FF00000000000004FF00000000000005FF00000000000006FF00000000000007FF00000000000055AAFF,320
2090 DATA 3FCFF3FCC0300C0340100401000000000000000000000000000000000000000000000000000000000000000000,425

Assembly Listing

*****************************
*         BACTERION!        *
*     THE PLAGUE OF 2369    *
*             BY            *
*        KYLE PEACOCK       *
*            WITH           *
*         TOM HUDSON        *
*                           *
* ANALOG COMPUTING MAGAZINE *
*****************************

* ATARI MEMORY USAGE

CASINI	EQU $0002 ;RESTART VECTOR
DOSVEC	EQU $000A ;RESTART VECTOR
DOSINI	EQU $000C ;RESTART VECTOR
SDMCTL	EQU $022F ;DMA ENABLE SHADOW
PMBASE	EQU $D407 ;PM BASE REG.
GRACTL	EQU $D01D ;GRAPHICS CONTROL
GPRIOR	EQU $026F ;PRIORITY CONTROL
AUDC1	EQU $D201 ;AUDIO CHANNELS
AUDC2	EQU $D203
AUDC3	EQU $D205
AUDC4	EQU $D207
AUDF1	EQU $D200 ;AUDIO FREQUENCIES
AUDF2	EQU $D202
AUDF3	EQU $D204
AUDF4	EQU $D206
AUDCTL	EQU $D208 ;AUDIO CONTROL
HITCLR	EQU $D01E ;CLEAR COLLISIONS
WSYNC	EQU $D40A ;WAIT FOR HOR SYNC.
RANDOM	EQU $D20A ;RANDOM #s
PCOLR0	EQU $02C0 ;COLOR OF PLR/MIS
COLPF0	EQU $D016 ;PLAYFIELD COLOR #0
COLOR0	EQU $02C4 ;COLOR REGISTERS
COLOR4	EQU $02C8 ;BACKGROUND COLOR
NMIEN	EQU $D40E ;NMI INTER. ENABLE
CH	EQU $02FC ;LAST KEY PRESSED
SKSTAT	EQU $D20F ;KEYBOARD STATUS
RTCLOK	EQU $12	  ;INTERNAL CLOCK
VDSLST	EQU $0200 ;DLI VECTOR
SDLSTL	EQU $0230 ;DLIST VECTOR
HPOSP0	EQU $D000 ;HOR. POS. PLR 0
HPOSP1	EQU $D001 ;HOR. POS. PLR 1
HPOSP2	EQU $D002 ;HOR. POS. PLR 2
HPOSP3	EQU $D003 ;HOR. POS. PLR 3
HPOSM0	EQU $D004 ;HOR. POS. MISS 0
HPOSM1	EQU $D005 ;HOR. POS. MISS 1
HPOSM2	EQU $D006 ;HOR. POS. MISS 2
HPOSM3	EQU $D007 ;HOR. POS. MISS 3
ATRACT	EQU $4D	  ;ATTRACT MODE FLAG
CONSOL	EQU $D01F ;CONSOLE BUTTONS
STICK0	EQU $0278 ;JOYSTICK PORT 0
P0PL	EQU $D00C ;PLR/PLR COLLISIONS
M0PL	EQU $D008 ;MIS/PLR COLLISIONS
P0PF	EQU $D004 ;PLR/PLF COLLISIONS
TRIG0	EQU $D010 ;JOYSTICK BUTTON 0

* ATARI HARDWARE REGISTERS

SETVBV	EQU $E45C ;SET SYS. TIMERS
SYSVBV	EQU $E45F ;1st STAGE VBLANK
XITVBV	EQU $E462 ;X-IT VBLANK
SIOINV	EQU $E465 ;SIO INIT

* PLAYER/MISSILE DATA AREA

PLAYBS	EQU	$0000
MISS	EQU	PLAYBS+0768
PLAY0	EQU	PLAYBS+1024
PLAY1	EQU	PLAYBS+1280
PLAY2	EQU	PLAYBS+1536
PLAY3	EQU	PLAYBS+1792

* DISPLAY DATA AREA

DLIST	EQU	$1F00
DISP	EQU	$2010
DISP2	EQU	$3000

* ZERO PAGE VARIABLES

	ORG	$80

LO	DS 1
HI	DS 1
BALO	DS 1
BAHI	DS 1
DRWLO	DS 1
DRWHI	DS 1
PLLO	DS 1
PLHI	DS 1

*	VARIABLES

* PRIMARY USE IN 'PLOTTER' ROUTINE.

PLOTX	DS 1 ;PLOT X-COORD.
PLOTY	DS 1 ;PLOT Y-COORD.
COLOR	DS 1 ;POINT COLOR.
DRAWX	DS 1 ;DRAWTO X-COORD.
DRAWY	DS 1 ;DRAWTO Y-COORD.
ACCX	DS 1 ;X ACCUM.
ACCY	DS 1 ;Y ACCUM.
DELTAX	DS 1 ;DRAW WORK AREA.
DELTAY	DS 1 ;DRAW WORK AREA.
INCX	DS 1 ;DRAW X INCREMENT.
INCY	DS 1 ;DRAW Y INCREMENT.
COUNTR	DS 1 ;DRAWTO COUNTER.
ENDPT	DS 1 ;DRAWTO ENDPOINT.
HOLD	DS 1 ;WORK AREA.
XWORK	DS 1
YWORK	DS 1
YOFSET	DS 1 ;PLOT Y OFFSET.
SHAPIX	DS 1 ;OBJECT #.
SHAPCT	DS 1 ;OBJECT SHAPE COUNTER.
XI	DS 1 ;OBJECT X INCREMENT.
YI	DS 1 ;OBJECT Y INCREMENT.
LENGTH	DS 1 ;OBJECT (TAKE A GUESS!)

* PRIMARY USE IN 'TEST' ROUTINE.

VSTOP	DS 1  ;STOP VBLANK FLAG.
LSOUND	DS 1  ;LASER SOUND FLAG.
XSOUND	DS 1  ;DETONATION SOUND FLAG.
CSOUND	DS 1  ;CANNON SOUND FLAG.
FREQ	DS 1  ;PULSE SOUND FREQUENCY.
DEMO	DS 1  ;GAME UNDERWAY FLAG.
STRUCT	DS 1  ;CELL STRUCTURE #.
NOPLAY	DS 1  ;# OF PLAYERS.
SDELAY	DS 2  ;PULSE SOUND DELAY.
LISTPT	DS 1  ;DISPLAY LIST POINTER.
SCORE1	DS 2  ;LO-BYTE OF SCORES.
SCORE2	DS 2  ;MD-BYTE OF SCORES.
SCORE3	DS 2  ;HI-BYTE OF SCORES.
TSCR1	DS 3  ;TOTAL SCORE BYTES.
CELNUM	DS 1  ;CELL # BEING DRAWN.
CELREF	DS 1  ;CELL # BEING REFRESHED

* PRIMARY USE IN 'STRAT' ROUTINE.

GEVNUM	DS 1  ;ATTACKING BACTERION! #
FRANGE	DS 1  ;ATTACK PLAYER RADIUS.
GEVESC	DS 1  ;# OF ESCAPED VESSELS.
TOTCEL	DS 1  ;# OF CELLS REMAINING.
TURNT	DS 1  ;BACTERION! TURN TIMERS
FIRETM	DS 1  ;RAM COPY OF 'GEVFRE'

* PRIMARY USE IN 'SHOOT' ROUTINE

FDELAY	DS 2  ;DELAY BETWEEN SHOTS.
NOBULL	DS 2  ;# OF BULLETS FIRED.
NOKILL	DS 2  ;# OF VESSELS KILLED.

* PRIMARY USE IN 'TEST' ROUTINE

CELLMV	DS 20 ;CELL MOVING FLAGs.
CELLNX	DS 20 ;CELL NEW X-COORD.
CELLOX	DS 20 ;CELL OLD X-COORD.

	ORG	$2800
	LOC	$0800

 TITLE 'ONE SHOT INITIALIZER'

	PROC

*	RELOCATE CODE

MOVEIT	JSR SIOINV	;INIT SOUNDS.
	LDA #$22	;INITIALIZE
	STA SDMCTL	;DMA CONTROL.
	LDA #HIGH $2800 ;SET ORIGIN
	STA HI          ;ADDR. IN
	LDA #LOW $2800  ;2-BYTE
	STA LO          ;POINTER.
	LDA #HIGH $0800 ;SET DESTIN-
	STA BAHI        ;ATION IN 2-
	LDA #LOW $0800  ;BYTE
	STA BALO        ;POINTER.
	LDY #$00        ;RESET Y-REG.
MOVELP	LDA (LO),Y      ;MOVE A 256
	STA (BALO),Y    ;BYTE BLOCK
	INY             ;USING Y-REG.
	BNE MOVELP      ;
	INC HI          ;NEXT 256-
	INC BAHI        ;BYTE BLOCK.
	LDA HI          ;
	CMP #$40        ;DONE YET?
	BNE MOVELP      ;NO-KEEPITUP.
	LDA #HIGH TEST	;SNAG ALL
	STA DOSINI+1	;RESET
	STA CASINI+1	;VECTORS
	STA DOSVEC+1	;SO AS TO
	LDA #LOW TEST	;GAIN
	STA DOSINI	;COMPLETE
	STA CASINI	;CONTROL OF
	STA DOSVEC	;THE SYSTEM.
	JMP TEST        ;ALL DONE. START!

*	BUILD GAME BOARD DISPLAY LIST

INIT	LDX #$00	;RESET X-REG.
	LDA #$0E        ;DLIST OPCODE
BDLOOP	STA DLIST,X     ;STORE IT.
	DEX             ;DONE YET?
	BNE BDLOOP      ;NO! GO BACK!
	LDA #$70        ;
	STA DLIST+0     ;INSTALL
	STA DLIST+1     ;REMAINDER OF
	LDA #$F0        ;SPECIAL
	STA DLIST+2     ;DISPLAY
	LDA #$4E        ;LIST OP-
	STA DLIST+3     ;CODES & OP-
	STA DLIST+107   ;ERANDS INTO
	LDA #HIGH DISP  ;DISPLAY
	STA DLIST+5     ;LIST.
	LDA #LOW DISP   ;
	STA DLIST+4     ;
	LDA #HIGH DISP2 ;
	STA DLIST+109   ;
	LDA #LOW DISP2  ;
	STA DLIST+108   ;
	LDA #$41        ;
	STA DLIST+200   ;
	LDA #$8E        ;
	STA DLIST+199   ;
	LDA #HIGH DLIST ;
	STA DLIST+202   ;
	LDA #LOW DLIST  ;
	STA DLIST+201   ;

*	PLAYER/MISSILE INITIALIZATION

	LDA #$3E         ;
	STA SDMCTL       ;DMA ENABLE.
	LDA #HIGH PLAYBS ;PM BASE
	STA PMBASE       ;ADDRESS.
	LDA #$03         ;GRAPHICS
	STA GRACTL       ;CONTROL.
	LDA #$10         ;PRIORITY
	STA GPRIOR       ;REGISTERS.
	LDA #$00         ;CLEAR OUT
	TAX              ;PLAYER 0
:PMSET	STA PLAY0,X      ;& PLAYER 1
	STA PLAY1,X      ;
	DEX              ;ALL DONE?
	BNE :PMSET       ;NO! CONT.

*	CLEAR OUT PLAYERS' SCOREs

	LDX #$02
	LDA #$00	;FILL WITH 0
:CLRS2	STA SCORE1,X
	STA SCORE2+1,X
	STA TSCR1,X
	DEX		;ALL DONE?
	BPL :CLRS2	;NO! CONTINUE

*	CLEAR PLAYFIELD AREA

	LDA #LOW DISP	;I'LL LET
	STA LO		;YOU GUYS
	LDA #HIGH DISP	;FIGURE OUT
	STA HI		;WHAT'S GOING
	LDX #0		;ON HERE!
CDLP	LDA LO
	STA LOTBL,X	;I'M SO LAZY!
	LDA HI
	STA HITBL,X
	LDA #0
	LDY #39
CDLP2	STA (LO),Y
	DEY
	BPL CDLP2
	INX
	CPX #192
	BEQ DOIT
	LDA LO
	CLC
	ADC #40
	STA LO
	LDA HI
	ADC #0
	STA HI
	JMP CDLP

*	SET UP ATOMIC PILE CELLS

DOIT	LDX STRUCT
	LDY STRBSE,X
	LDX #9
	STX TOTCEL
SETCEL	LDA :ICELX,Y ;X-COORDS
	STA CELLOX,X
	STA CELLNX,X
	LDA :ICELY,Y ;Y-COORDS
	STA CELLOY,X
	STA CELLNY,X
	LDA #$00
	STA CELLMV,X ;CELLS NOT MOV-
	INY	     ;ING STATUS.
	DEX
	BPL SETCEL

*	SET UP PLAYERS PROBEs

	LDX #$00   ;FLIP TO GAME
	STX LISTPT ;BOARD SCREEN.
	STX GEVX+0 ;X-COORD.
	STX GEVX+1 ;X-COORD.
	JSR SETPLR ;SET IT UP NOW.
	LDA NOPLAY ;1 PLAYER GAME?
	BEQ SETTYP ;YES! SKIP #2
	INX	   ;NO! SET UP PLR 2.
	JSR SETPLR ;SET IT UP NOW.

*	ATTACKING BACTERION! TYPE

SETTYP	LDA #$01   ;SLOWEST TYPE
	STA TYPES  ;ATTACKS FIRST.
	STA TYPE+2
	STA TYPE+3
	STA TYPE+4

* BACTERION! INITIAL A.I. SPEEDS

	LDX #$05
SETMDB	LDA IMOVDB,X ;MOVEMENT SPEED
	STA MOVEDB,X
	LDA ITURDB,X ;TURN SPEED
	STA TURNDB,X
	LDA IFIRDB,X ;FIRE SPEED
	STA FREBSE,X
	DEX
	BPL SETMDB

	JMP INIT2

*	INITIALIZE GIVEN PLAYER

SETPLR	LDA #$00     ;PLAYER NO LONG-
	STA STOP,X   ;ER DEAD OR EXP-
	STA TYPE,X   ;LODING.
	LDA #$01     ;SET UP FOR
	STA SPEED,X  ;COASTING SPEED.
	STA CSPEED,X ;
	LDA PLRPHS,X ;CORRECT TYPE
	STA PHASE,X  ;OF VESSEL
	STA GEVDIR,X ;PHASE.
	LDA PLRX,X   ;PROPER X-COORD.
	STA GEVX,X   ;
	LDA #128     ;PROPER Y-COORD.
	STA GEVY,X   ;
	RTS          ;ALL DONE...

PLRX	DB 44,195 ;INITIAL X-COORDS
PLRPHS	DB 12,4	  ;INITIAL DIRECTIONS

* BACTERION! INITIAL TURNING DATABASE

ITURDB	DB 52,44,36,28,20,12

* BACTERION! INITIAL MOVING DATABASE

IMOVDB	DB 13,11,09,07,05,03

* BACTERION! INITIAL FIRING TIMES

IFIRDB	DB 70,65,60,55,50,45

* OFFSET DATABASE TO CELL FORMATIONS

STRBSE	DB 0,10,20

* CELLS INITIAL X-COORDS

:ICELX	DB 68,80,92,62,74
	DB 86,98,68,80,92

	DB 79,79,79,79,73
	DB 85,67,91,61,97

	DB 79,71,87,79,79
	DB 79,79,71,87,79

* CELLS INITIAL Y-COORDS

:ICELY	DB 93,93,93,96,96
	DB 96,96,99,99,99

	DB 76,82,88,94,98
	DB 98,102,102,106,106

	DB 86,90,90,94,94
	DB 94,94,98,98,102
 TITLE 'BACTERION! MULTI-INITIALIZER'

INIT2	PROC

*	ALLOW THINGS TO SETTLE DOWN

	LDX #$01  ;STOP VERTICAL
	STX VSTOP ;BLANK ROUTINE.

*	INITIALIZE SOUNDS

	DEX        ;
	TXA        ;
	STA AUDC3  ;TURN OFF SOUND
	STA AUDC4  ;REGISTERS & INIT
	STA AUDCTL ;SOUND CHANNELS.

*	CLEAR PLAYER MISSILE AREA

:ER1	STA MISS,X  ;BACTERION! #1.
	STA PLAY2,X ;BACTERION! #2.
	STA PLAY3,X ;BACTERION! #3.
	STA HITCLR  ;CLEAR COLLISIONS
	DEX
	BNE :ER1

* ENEMY BACTERION!s X,Y,& DIRECTION

	LDX #$04   ;HANDLE ALL.
SETGEV	LDA TYPES  ;GET TYPE OF ATT-
	STA TYPE,X ;ACKING BACTERION.
	JSR PICKX  ;RANDOM X-COORD.
	STA GEVX,X ;STORE IT.
	LDA RANDOM ;RANDOM NUMBER.
	BPL :PLUS1 ;BRANCH IF > 0.
	LDA #21    ;INITIAL Y-COORD.
	BNE :PLUS2 ;BRANCH!
:PLUS1	LDA #228   ;INITIAL Y-COORD.
:PLUS2	STA GEVY,X ;STORE IT.
	JSR PICKDR ;RANDOM DIRECTION.

* ENEMY BACTERION!Rs TARGET CELL

SEL	LDA #$00     ;CLEAR
	STA TRY      ;COUNTERS,
	STA GEVESC   ;# OF ESCAPEES,
	STA STOP,X   ;DEATH STATUS,
	STA GEVCEL,X ;TARGET CELL,
	STA LSRDIR,X ;LASER FLAG,
	STA GEVFRE,X ;FIRE TIME FLAG,
	STA ESCAPE,X ;ESCAPE Y-COORD.

	LDA RANDO ;GET RANDOM #
	CMP #$D8  ;GREATER THAN $D8
	BCS SELIT ;YES, BRANCH!

SEL0	LDA #$0A  ;RANDOM # SEED
	JSR RANDO ;GET RANDOM CELL #
	TAY	  ;STORE IN Y-REG.

	STX :XHOLD   ;SAVE X-REG.
CPICK0	LDA ESCAPE,X ;ESCAPE Y-COORD
	BEQ CPICK1   ;EQUAL 0?
	TYA          ;NO! MOVE Y TO A
	CMP GEVCEL,X ;IS THIS CELL
	BEQ SEL1     ;SPOKEN FOR?
CPICK1	INX          ;NO! MOVE ON
	CPX #$05     ;TO NEXT
	BNE CPICK0   ;BACTERION!
	LDX :XHOLD   ;RESTORE X-REG.

*	HEIST THIS CELL (IN Y-REG.)

	LDA CELLNY,Y ;CELL Y-COORD.
	CMP #194     ;OFF SCREEN?
	BCS SEL1     ;YES! TRY AGAIN.
	LDA #$02     ;RANDOM # SEED.
	JSR RANDO    ;GET RANDOM #.
	STY :YHOLD   ;SAVE Y-REG.
	TAY          ;MOVE # TO ACC.
	LDA ESCDT,Y  ;GET PROPER ES-
	STA ESCAPE,X ;CAPE Y-COORD.
	LDA CELDT,Y  ;GET OFFSET FOR
	LDY :YHOLD   ;LOCKING ON TO
	CLC          ;TOP OR BOTTOM
	ADC CELLNY,Y ;OF CELL & STORE
	STA TARY,X   ;IN TARGET-Y.
	LDA CELLNX,Y ;GET X-COORD OF
	CLC          ;CELL & STORE
	ADC #44      ;IN TARGET-X.
	STA TARX,X   ;
	TYA          ;MAKE THIS CELL
	STA GEVCEL,X ;SPOKEN FOR.
	JMP SEL2     ;HANDLE NEXT.

SEL1	LDX :XHOLD   ;RESTORE X-REG.
	DEC TRY      ;DEC. COUNTERS
	BNE SEL0     ;& BRANCH!

* CAN'T FIND A CELL, ATTACK PLAYERs

SELIT	LDY NOPLAY ;# OF PLAYERS.
	INY        ;ADD ONE.
	TYA        ;RANDOM # SEED.
	JSR RANDO  ;GET RANDOM #.
	TAY        ;MOVE TO Y-REG.
	LDA GEVX,Y ;PLAYER'S X-COORD.
	STA TARX,X ;USE AS TARGET-X.
	LDA GEVY,Y ;PLAYER'S Y-COORD.
	STA TARY,X ;USE AS TARGET-Y.

SEL2	DEX        ;HANDLE NEXT
	CPX #$01   ;BACTERION! (IF
	BEQ :NEXT  ;WE AREN'T DONE.)
	JMP SETGEV ;JUMP TO IT!

*	SET UP RANGE OF ATTACK

:NEXT	LDA #40
	STA FRANGE

*	SET UP FIRING TIME

	LDX TYPES      ;ATTACK TYPE.
	LDA FREBSE-1,X ;GET DATA FROM
	STA FIRETM     ;FIRING DB.
	CMP #$05       ;IS IT < 5?
	BCC PROJT1     ;NO! BRANCH!
	SEC            ;YES! SUBTRACT
	SBC #$03       ;3 & STORE
	STA FREBSE-1,X ;IT IN DB.

*	CLEAR PROJECTILE WORK AREA

PROJT1	LDX #12        ;HANDLE ALL.
	LDA #$FF       ;INACTIVE STATUS.
CLRPRO	STA BULLET,X   ;OWNER.
	STA CELLNX+5,X ;X-COORD.
	STA CELLNY+5,X ;Y-COORD.
	STA CELLMV+5,X ;MOVING.
	DEX            ;HANDLE NEXT
	CPX #$04       ;(IF ANY).
	BNE CLRPRO     ;

*	SET UP COLOR DATABASES

	LDX #$03     ;COUNTER.
:SET1	LDA RANDOM   ;RANDOM #.
	AND #$F0     ;ZAP LO-NIBBLE.
	ORA #$0A     ;& W/DECINAL 10.
	STA PCOLR0,X ;STORE IT.
	LDA RANDOM   ;RANDOM #.
	AND #$F0     ;ZAP LO-NIBBLE.
	ORA :FIELD,X ;OR W/PLAYFIELD.
	STA COLOR0,X ;STORE IT.
	DEX          ;HANDLE NEXT.
	BPL :SET1    ;BRANCH!

	LDA #$00     ;CLEAR.
	STA NOBULL+0 ;# OF BULLETS
	STA NOKILL+0 ;FIRED & # OF
	STA NOBULL+1 ;BACTERIONS!
	STA NOKILL+1 ;VAPORIZED.

	STA VSTOP    ;START VBLANK.

	RTS          ;BUG OFF!!!

* BACTERION! FIRE TIME DATABASE

FREBSE	DB 0,0,0,0,0,0

* OFFSETS TO TOP & BOTTOM OF CELL

CELDT	DB 21,36

* Y-COORDS FOR ESCAPING BACTERION!

ESCDT	DB 10,245

* COLOR LUM. FOR PLAYERS & PLAYFIELDS

:PLAYC	DB $0C,$0C,$0A,$0A
:FIELD	DB $0C,$08,$08,$0A

* PICK A RANDOM X-COORD.

PICKX	LDA #100
	JSR RANDO
	CLC
	ADC #75
	RTS

* PICK A RANDOM DIRECTION (0-15)

PICKDR	LDA #16
	JSR RANDO
	STA GEVDIR,X
	RTS

* PICK A RANDOM # (0 UP TO ACC.)

RANDO	STA HOLDME
	LDA RANDOM
RANDO1	CMP HOLDME
	BCC RANOUT
	LSR A
	LSR A
	JMP RANDO1
RANOUT	RTS

HOLDME	DB 0 ;TEMP STORAGE.
TRY	DB 0 ;COUNTER.
:XHOLD	DB 0 ;X-REG TEMP STORAGE.
:YHOLD	DB 0 ;Y-REG TEMP STORAGE.
 TITLE 'GET THE GAME GOING...'

TEST	PROC

	LDA #$00       ;TURN OFF
	STA AUDC1      ;SOUND
	STA AUDC2      ;REGISTERS.

	JSR :SETP0     ;SET UP TITLE
	JSR ADITUP     ;SCREEN SCORES
	LDA #$01       ;& SHOW TITLE
	STA LISTPT     ;SCREEN.
	STA VSTOP      ;

	LDA #$06       ;SET UP VERT-
	LDX #HIGH VBL  ;ICAL BLANK
	LDY #LOW VBL   ;ROUTINES.
	JSR SETVBV     ;

	LDA #$07       ;SET UP DEF.
	LDX #HIGH DBL  ;VERTICAL
	LDY #LOW DBL   ;BLANK
	JSR SETVBV     ;ROUTINES.

	LDA #$C0       ;SET UP DLI
	STA NMIEN      ;ROUTINES.

:DEMOX	JSR SHUTUP
	LDA DEMO       ;WAIT FOR PUSH
	CMP #$01       ;OF START KEY.
	BNE :DEMOX     ;
	INC DEMO       ;

	JSR INIT       ;INITIALIZE...

*	START OF NEW GAME

SAVE0	LDA DEMO       ;CHANGE STATUS
	CMP #$02       ;OF 'DEMO'
	BNE TEST       ;VARIABLE

*	GAME PAUSED?

	LDA CH         ;IS SPACEBAR
	CMP #$21       ;PRESSED?
	BNE :REFCL     ;YES. IS BAR
	LDA SKSTAT     ;STILL BEING
	AND #$04       ;PRESSED?
	BEQ :REFCL     ;YES-CONTINUE.

	JSR ADITUP     ;ADD UP SCORES

	LDA TOTCEL     ;HOLD # OF
	PHA            ;CELLS LEFT.
	LDA #$0A       ;MAKE WEIRD
	STA TOTCEL     ;SOUND.

	LDA #$01       ;SWITCH TO
	STA LISTPT     ;TITLE SCREEN.
	STA VSTOP
	STA CH         ;WAIT FOR
	JSR SHUTUP     ;SPACEBAR.

:WAIT1	LDA CH         ;IS SPACEBAR
	CMP #$21       ;PRESSED? NO,
	BNE :WAIT1     ;SO WAIT.
:WAIT2	LDA SKSTAT     ;YES. IS BAR
	AND #$04       ;STILL BEING
	BEQ :WAIT2     ;PRESSED?

	PLA            ;RESTORE # OF
	STA TOTCEL     ;CELLS LEFT.

	LDA #$00       ;SWITCH BACK
	STA LISTPT     ;TO PLAYFIELD
	STA VSTOP      ;& CONTINUE...
	STA CH

*   REFRESH CELLS (ONE PER PASS)

:REFCL	DEC CELREF     ;OUT OF CELLS
	BPL GETCEL     ;TO REFRESH?
	LDA #$09       ;YES. START
	STA CELREF     ;AGAIN...
GETCEL	LDX CELREF     ;GET CELL # TO
	LDA CELLMV,X   ;REFRESH & SEE
	BNE GOTCEL     ;IF IT MOVES.

	LDA CELLOX,X   ;CELL X-COORD
	STA PLOTX      ;
	LDA CELLOY,X   ;CELL Y-COORD
	STA PLOTY      ;
	LDA #1         ;SPEC. COLOR
	STA COLOR      ;
	LDA #0         ;SPEC. OBJECT
	JSR OBJECT     ;DRAW IT...

*  DRAW MOVING CELLS (ALL AT ONCE)

GOTCEL	LDA #$09       ;SET UP CELL #
	STA CELNUM     ;TO DRAW.
SAVE1	LDX CELNUM     ;GET CELL #.
	LDA CELLMV,X   ;IS IT BEING
	BEQ SAVE2      ;CARRIED OFF?
	JSR SHOCEL     ;YES. DRAW IT.
SAVE2	DEC CELNUM     ;MOVE ON TO
	BPL SAVE1      ;NEXT CELL.

*  DRAW & ERASE BACTERION! LASERS

	LDA #$04       ;CHECK ALL
	STA LSRCNT     ;VESSELS.
LASER3	LDX LSRCNT     ;IS THIS VES-
	LDA LSRDIR,X   ;SEL FIRING?
	BEQ NXTLSR     ;NO. CONTINUE.
	BMI LASER5     ;YES. ERASE?
	ORA #$80       ;SET UP LASER
	STA LSRDIR,X   ;TO BE ERASED.
	LDA #$02       ;SPECIFY COLOR
	STA COLOR      ;OF LASER.
	LDA GEVX,X     ;GET X-COORD
	SEC            ;OF FIRING 
	SBC #44        ;VESSEL & USE
	STA LASERX,X   ;AS LASER
	STA PLOTX      ;X-COORD.
	LDA GEVY,X     ;GET Y-COORD
	SEC            ;OF FIRING
	SBC #$1C       ;VESSEL & USE
	CMP #192       ;AS LASER
	BCS LASER6     ;Y-COORD. DO
	STA LASERY,X   ;NOT FIRE IF
	STA PLOTY      ;NOT ON-SCREEN
	LDA LSRDIR,X   ;ELSE, DRAW
	AND #$7F       ;FIRING LASER
	JSR OBJECT     ;(DEATH RAY).
	JMP NXTLSR     ;HANDLE NEXT.
LASER5	DEC LSRTME,X   ;TIME TO
	BPL NXTLSR     ;ERASE LASER?
	LDA LASERX,X   ;YES. GET X
	STA PLOTX      ;COORD & Y
	LDA LASERY,X   ;COORD FOR
	STA PLOTY      ;ERASING.
	LDA #$00       ;SPECIFY COLOR
	STA COLOR      ;AS BCKGROUND.
	LDA LSRDIR,X   ;NOW ERASE
	AND #$7F       ;LASER.
	JSR OBJECT     ;
	LDX LSRCNT     ;TURN OFF
LASER6	LDA #$00       ;LASER FOR
	STA LSRDIR,X   ;THIS VESSEL.
NXTLSR	DEC LSRCNT     ;HANDLED ALL
	LDA LSRCNT     ;LASERS? IF
	CMP #$01       ;SO, QUIT.
	BNE LASER3     ;ELSE GO BACK.

*	DRAW & ERASE PROJECTILES

	LDX #17      ;HANDLE ALL.
PROJ5	LDA CELLMV,X ;IS THIS BULLET
	BEQ PROJ6    ;ACTIVE?
	LDA CELLOX,X ;YES. GET X
	STA PLOTX    ;COORD.
	LDA CELLOY,X ;GET Y-COORD.
	STA PLOTY    ;OF BULLET.
	LDA #$00     ;SET UP TO ERASE
	STA CELLMV,X ;THIS BULLET.
	STA COLOR    ;SPECIFY COLOR.
	STX :XHOLD   ;SAVE X-REG.
	JSR PLOTPT   ;ERASE IT NOW!
	LDX :XHOLD   ;RESTORE X-REG.
	LDA CELLNX,X ;GET NEW BULLET
	STA CELLOX,X ;X-COORD & PRE-
	STA PLOTX    ;PARE TO PLOT.
	LDA CELLNY,X ;GET NEW BULLET
	STA CELLOY,X ;Y-COORD & PRE-
	STA PLOTY    ;PARE TO PLOT.
	LDA #$03     ;SPECIFY COLOR
	STA COLOR    ;OF NEW BULLET.
	STX :XHOLD   ;SAVE X-REG.
	JSR PLOTPT   ;DRAW NEW BULLET
	LDX :XHOLD   ;RESTORE X-REG.
PROJ6	DEX          ;MOVE ON TO NEXT
	CPX #$09     ;BULLET. IF NONE
	BNE PROJ5    ;LEFT, QUIT.

*	ALL CELLS GONE?

GAME3	LDA TOTCEL   ;TOTAL # OF
	BPL GAME1    ;CELLS < 0?
	JSR SHUTUP   ;YES. SOUND OFF.
	LDA #$01     ;STOP ALL SCREEN
	STA VSTOP    ;ACTION.
	STA RTCLOK+2 ;SET UP TO
	LDX RTCLOK+1 ;PAUSE FOR
	INX          ;SOME TIME.
HALT	CPX RTCLOK+1 ;IS PAUSE DONE?
	BNE HALT     ;NO. WAIT.
	JMP TEST     ;YES. RESTART.

*BACTERION!s DESTROYED OR OFF SCREEN?

GAME1	LDA GEVESC  ;IS NUMBER OF
	CMP #$03    ;ESCAPED VESSELS
	BEQ GAMEE   ;EQUAL TO THREE?
	JMP SAVE0   ;NO, GO BACK.

GAMEE	JSR ADITUP  ;ADD UP SCORES.

	INC TYPES   ;SET UP NEXT TYPE
	LDA TYPES   ;OF ATTACKING
	CMP #$07    ;BACTERION.
	BCC GAME2   ;

	LDA RANDOM  ;GET RANDOM
	AND #$F0    ;BACKGROUND
	STA COLOR4  ;COLOR.

*	FLIP TO TITLE SCREEN

	LDA #$01     ;STOP ALL SCREEN
	STA VSTOP    ;ACTION & FLIP
	STA LISTPT   ;TO TITLE SCREEN

	JSR SHUTUP   ;SOUNDS OFF.
	LDA TOTCEL   ;SAVE TOTAL #
	PHA          ;OF CELLS LEFT.
	LDA #$0A     ;MAKE WEIRD
	STA TOTCEL   ;TITLE SOUND.

	STA RTCLOK+2 ;PAUSE FOR A
	LDX RTCLOK+1 ;WHILE.
	INX          ;
:PAUSE	CPX RTCLOK+1 ;PAUSE TIME UP?
	BNE :PAUSE   ;NO. WAIT.

	PLA          ;RESTORE TOTAL #
	STA TOTCEL   ;OF CELLS LEFT.

	LDA #$00     ;FLIP TO GAME
	STA LISTPT   ;SCREEN & BEGIN
	STA VSTOP    ;SCREEN ACTION.
	STA CH
	STA XSOUND
	STA CSOUND
	STA LSOUND

* SPEED UP BACTERION! MOVE/TURN RATES

	LDX #$05     ;UPDATE ALL.
FAST1	LDA MOVEDB,X ;IS MOVE RATE AT
	CMP #$02     ;LOWEST LEVEL?
	BCC FAST2    ;YES, CONTINUE.
	DEC MOVEDB,X ;NO. DECREMENT.
FAST2	LDA TURNDB,X ;IS TURN RATE AT
	CMP #08      ;LOWEST LEVEL?
	BCC FAST3    ;YES, CONTINUE.
	SEC          ;NO. DECREMENT.
	SBC #$04     ;
	STA TURNDB,X ;
FAST3	DEX          ;UPDATE NEXT.
	BPL FAST1    ;

	LDA #$01     ;MAKE ATTACKING
GAME2	STA TYPES    ;BACTERION! THE
	STA TYPE+2   ;SLOWEST TYPE
	STA TYPE+3   ;FOR BEGINNING
	STA TYPE+4   ;OF NEW WAVE.

*	SET UP FOR NEXT ATTACK

	JSR INIT2    ;INITIALIZE...
	JMP SAVE0    ;BEGIN AGAIN.

*	VERTICAL BLANK ROUTINE

VBL	CLD            ;CLEAR DECIMAL
	LDA LISTPT     ;RESEED
	ASL A          ;DISPLAY LIST
	TAX            ;VECTORS ACC-
	LDA :LSTDB+0,X ;ORDING TO
	STA SDLSTL+0   ;'LISTPT'
	LDA :LSTDB+1,X ;VARIABLE.
	STA SDLSTL+1   ;DO THE SAME
	LDA :DLIDB+0,X ;THING FOR
	STA VDSLST+0   ;DLI VECTORS.
	LDA :DLIDB+1,X ;
	STA VDSLST+1   ;
	
	LDA #$00    ;MAKE ALL PLAYER/
	STA HPOSP0  ;MISSILE X-COORDS
	STA HPOSP1  ;EQUAL TO ZERO.
	STA HPOSP2  ;THIS PROVIDES A
	STA HPOSP3  ;NICE BORDER AT
	STA HPOSM0  ;THE SCREEN TOP.
	STA HPOSM1  ;THE DLIs HANDLE
	STA HPOSM2  ;PROPER PLACEMENT
	STA HPOSM3  ;OF X-COORDS.

	LDA VSTOP   ;IS SCREEN ACTION
	BNE XITVBL  ;HALTED?

*	KILL ATTRACT MODE

	STA ATRACT

*	FLASH CELLS

	LDA COLOR0  ;KEEP SAME LUM.
	CLC         ;BUT UPDATE
	ADC #$10    ;COLOR.
	STA COLOR0  ;

*	BACTERION! ATTACK STRATEGY

	LDA #$04    ;ALL VESSELS
	STA GEVNUM  ;ATTACK!
VBL2	JSR STRAT   ;NASTY ROUTINE!
	DEC GEVNUM  ;NEXT VESSEL
	LDA GEVNUM  ;ATTACKS!
	CMP #$01    ;ALL DONE?
	BNE VBL2    ;IF NOT, CONT.

*	TURN ENEMY BACTERION!s

	JSR TURN

*	MOVE ENEMY BACTERION!s

	JSR MOVE

XITVBL	JMP SYSVBV

*	DEF. VERTICAL BLANK

DBL	CLD         ;CLEAR DECIMAL

*	READ CONSOLE BUTTONS

	JSR BUTTON

*	PULSE SOUND

	JSR PULSE

	LDA VSTOP   ;ALL SCREEN
	BNE XITDBL  ;ACTION HALTED?

*	READ JOYSTICKS & MOVE PLAYERS

	JSR STICKS  ;PLAYERS MOVING
	JSR SHOOT   ;PLAYERS FIRING

*     DON'T LET ANYONE GO OFF SCREEN

	JSR BOUNDS

*     DID ANYBODY RUN INTO ANYBODY?

	JSR COLLIDE

*     KEEP TRACK OF HEISTED CELLS

	JSR TRACK

*	BACTERION! LASER SOUND

	JSR ZAP

*	PLAYER'S CANNON SOUND

	JSR CANNON

*	DETONATION SOUND

	JSR BOOM

*	DRAW PLAYERS & BACTERION!s

	JSR DRAW

XITDBL	JMP XITVBV   ;ALL DONE.

*	PULSE SOUND ROUTINE

PULSE	LDX TOTCEL   ;GET TOTAL # OF
	BMI PULRTS   ;CELLS LEFT.
	LDA FREQS,X  ;GET ASSOCIATED
	STA FREQ     ;PULSE FREQUENCY
	LDA DELS,X   ;& SOUND DELAY
	STA SDELAY+1 ;TIME. STORE IT.
	LDX FREQ     ;STORE PROPER
	STX AUDF1    ;FREQ. INTO
	INX          ;SOUND REGS. 1
	STX AUDF2    ;AND 2.
	LDA SDELAY   ;DECREMENT DELAY
	BEQ SOUND5   ;TIMER IF NON
	DEC SDELAY   ;ZERO.
PULRTS	RTS          ;RETURN.
SOUND5	LDA SDELAY+1 ;RESTORE DELAY
	STA SDELAY   ;TIME IF ZERO.
	INC FLIP     ;TOGGLE PULSE
	LDA FLIP     ;SOUND GENERATOR
	AND #$01     ;(IF OFF, TURN
	TAX          ;ON. IF ON, TURN
	LDA REG,X    ;OFF.) & STORE
	STA AUDC1    ;INTO PROPER
	STA AUDC2    ;AUDIO CHANNEL
	RTS          ;REGISTERS.

REG	DB $00,$A4   ;AUDIO OFF/ON
FLIP	DB 0	     ;FLIP/FLOP VAR.
LSRCNT	DB 0	     ;LASER COUNTER.

*	PULSE SOUND FREQUENCIES

FREQS	DB 160,170,180,190,200
	DB 210,220,230,240,250,140

*	PULSE SOUND DELAYS

DELS	DB 02,04,06,08,10,12,14
	DB 16,18,20,01

*	BACTERION! LASER SOUND

ZAP	LDX LSOUND  ;IS SOUND ON?
	BEQ ZAPOFF  ;NO. QUIT!
	DEX         ;YES.
	DEC LSOUND  ;GET PROPER
	LDA LFTBL,X ;FREQ. AND STORE
	STA AUDF3   ;INTO REGISTER.
	LDA LCTBL,X ;GET PROPER CHAN.
	STA AUDC3   ;AND STORE.
ZAPOFF	RTS         ;ALL DONE...

*	BACTERION! LASER FREQUENCIES

LFTBL	DB 0,236,216,197,177,157
	DB 138,118,99,79,59,40,20,1

*	BACTERION! LASER CHANNELS

LCTBL	DB $00,$A2,$A2,$A2,$A2,$A4
	DB $A4,$A4,$A4,$A4,$A4,$A6
	DB $A6,$A6

*	PLAYER'S CANNON SOUND

CANNON	LDX CSOUND  ;IS SOUND ON?
	BEQ CANOFF  ;NO. QUIT.
	DEX         ;YES. GET PROPER
	DEC CSOUND  ;FREQUENCY &
	LDA CFTBL,X ;STORE INTO REG.
	STA AUDF4   ;GET PROPER
	LDA CCTBL,X ;CHANNEL & STORE
	STA AUDC4   ;INTO REG.
CANOFF	RTS         ;ALL DONE...

*	CANNON FREQUENCIES

CFTBL	DB 0,254,212,170,127,85,43,1

*	CANNON CHANNELS

CCTBL	DB $00,$A8,$A8,$A8,$A8,$A8
	DB $A8,$A8

*	DETONATION SOUND

BOOM	LDX XSOUND  ;IS SOUND ON?
	BEQ BOMOFF  ;NO. CONTINUE.
	DEX         ;YES. GET PROPER
	DEC XSOUND  ;FREQ. AND STORE
	LDA XFTBL,X ;INTO SOUND
	STA AUDF3   ;REGISTER.
	LDA XCTBL,X ;GET PROPER
	STA AUDC3   ;CHANNEL & STORE.
BOMOFF	RTS         ;ALL DONE...

*	DETONATION FREQUENCIES

XFTBL	DB 0,253,249,245,241,237,234
	DB 230,226,222,218,214,211
	DB 207,203,199,195,191,188
	DB 184,180,176,172,168,165
	DB 161,157,153,149,145,142
	DB 138,134,130,126,123,119
	DB 115,111,107,103,100,96,92
	DB 88,84,80,77,73,69,65,61,57
	DB 54,50,46,42,38,34,31,27,23
	DB 19,15,11,08,04

*	DETONATION CHANNELS

XCTBL	DB $00,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A
	DB $8A,$8A,$8A,$8A,$8A,$8A

*	READ CONSOLE BUTTONS

BUTTON	LDA CONSOL ;CONSOLE SWITCH.
	CMP #$07   ;IS IT PRESSED?
	BEQ :ACTVE ;YES, CONTINUE.
	STA :PREV  ;NO. SAVE IT.
	RTS        ;RETURN.
:ACTVE	LDA :PREV  ;GET CONSOLE VALUE
	CMP #$06   ;START BUTTON ON.
	BEQ :START ;
	CMP #$05   ;SELECT BUTTON ON.
	BEQ :SELCT ;
	CMP #$03   ;OPTION BUTTON ON.
	BEQ :OPTON ;
	RTS        ;CONFUSED! RETURN.

*	START KEY PRESSED!!!

:START	LDX #$01   ;GAME START. UP-
	JMP :ENDBT ;DATE STATUS.

*	SELECT KEY PRESSED!!!

:SELCT	INC NOPLAY ;UPDATE # OF PLAY-
	LDA NOPLAY ;ERS. (1 OR 2)
	AND #$01   ;SAVE IN 'NOPLAY'
	STA NOPLAY ;VARIABLE.

:SETP0	LDX #19      ;CLEAR PLAYERS'
	LDA #00      ;SCORE LINES
:SETP1	STA PLAYR1,X ;BY PLACING
	STA PLAYR2,X ;BLANKS IN ALL
	DEX          ;POSITIONS.
	BPL :SETP1   ;

	LDX NOPLAY   ;GET # PLAYERS.
	LDA :PLINE,X ;DECIDE HOW MANY
	TAX          ;CHARACTERS TO
:SETP2	LDA :LINE1,X ;USE FOR PLAYER
	STA PLAYR1,X ;SCORE LINE &
	LDA :LINE2,X ;INSTALL INTO
	STA PLAYR2,X ;PLAYER SCORE
	DEX          ;LINE. CONTINUE
	BPL :SETP2   ;UNTIL DONE.
	JMP :ENDBT

:OPTON	INC STRUCT   ;CHANGE STRUCT-
	LDA STRUCT   ;URE OF INITIAL
	CMP #$03     ;CELL PATTERN.
	BCS :OPTON   ;RANGE: 0-2.
	LDX #$00	

:ENDBT	STX DEMO  ;UPDATE 'DEMO'
	STX :PREV ;UPDATE PERVIOUS
	RTS       ;ALL DONE...

:PREV	DB	0 ;OLD CONSOLE VALUE.

:PLINE	DB 10,19  ;SCORE LINE CHARA-
	          ;CTERS PER PLAYER.

*	PLAYER 1/PLAYER 2 SCORE LINE

:LINE1	DB 176,172,161,185,165,178
	DB 00,$D1,00,00,00,00,176
	DB 172,161,185,165,178,00,$D2

*	000000/000000 SCORE LINE

:LINE2	DB 00,$50,$50,$50,$50,$50,$50
	DB 00,00,00,00,00,00
	DB $50,$50,$50,$50,$50,$50,00

*	ADD UP SCORES

ADITUP	SED          ;SET DECIMAL.
	LDX NOPLAY   ;# OF PLAYERS.
CALC4	LDY NOKILL,X ;# OF KILLS FOR
	BEQ CALCX    ;THIS PLAYER.
CALC5	LDA TYPES    ;BACTERION! TYPE
	ASL A        ;(1 TO 6) IS
	ASL A        ;MULTIPLIED BY
	ASL A        ;10 & ADDED TO
	ASL A        ;PLAYERS' SCORE
	CLC          ;
	ADC SCORE3,X ;
	STA SCORE3,X ;
	LDA #$00     ;OVERFLOW
	ADC SCORE2,X ;CORRECTION.
	STA SCORE2,X ;
	LDA #$00     ;OVERFLOW
	ADC SCORE1,X ;CORRECTION.
	STA SCORE1,X ;
	DEY          ;HANDLED ALL
	BNE CALC5    ;KILLS?
CALCX	DEX          ;HANDLED ALL
	BPL CALC4    ;PLAYERS?

*	DISPLAY SCORES

	LDX #$05       ;SIX DIGITS.
CALC6	LDY NOPLAY     ;# OF PLAYERS.
	TXA            ;
	AND SCMASK,Y   ;AND IN SCORE
	TAX            ;MASK & GET
	LDA SCORE1,X   ;SCORE DIGIT.
	PHA            ;HOLD IT.
	AND #$0F       ;PLACE '5' IN
	ORA #$50       ;HIGH NIBBLE.
	LDY PUTSCR,X   ;FIND WHERE TO
	STA PLAYR2+1,Y ;PUT & DO SO.
	PLA            ;RESTORE DIGIT
	LSR A          ;& SHIFT INTO
	LSR A          ;LOW-NIBBLE.
	LSR A          ;
	LSR A          ;PLACE '5' IN
	ORA #$50       ;HIGH-NIBBLE
	STA PLAYR2,Y   ;& STORE.
	DEX            ;IF NOT DONE,
	BPL CALC6      ;CONTINUE.

*	ADD UP TEAM SCORE

	CLC            ;CLEAR CARRY
	LDX #$04       ;LOOP VAR.
	LDY #$02       ;LOOP VAR.
CALC7	LDA SCORE1,X   ;ADD UP CON-
	ADC SCORE1+1,X ;SECUTIVE
	STA TSCR1,Y    ;SCORES &
	DEX            ;STORE INTO
	DEX            ;TEAM SCORE
	DEY            ;VARIABLES.
	BPL CALC7      ;CONTINUE.

*	DISPLAY TEAM SCORE

	LDX #$02       ;THREE BYTES.
CALC8	LDY PUTTME,X   ;WHERE TO PUT.
	LDA TSCR1,X    ;TEAM SCORE.
	PHA            ;HOLD IT.
	AND #$0F       ;PUT '5' IN
	ORA #$50       ;HI-NIBBLE.
	STA TEAM2+1,Y  ;STORE DIGIT.
	PLA            ;RESTORE IT.
	LSR A          ;SHIFT HI-
	LSR A          ;NIBBLE TO LO-
	LSR A          ;NIBBLE.
	LSR A          ;PUT '5' IN
	ORA #$50       ;HI-NIBBLE.
	STA TEAM2,Y    ;STORE IT.
	DEX            ;IF NOT DONE,
	BPL CALC8      ;CONTINUE.

	CLD            ;CLEAR DECIMAL
	RTS            ;ALL DONE...

*	TURN OFF SOUND

SHUTUP	LDA #$00    ;DEACTIVATE
	STA AUDC3   ;SOUND REGISTERS
	STA AUDC4   ;3 & 4.
	STA LSOUND  ;DEACTIVATE
	STA XSOUND  ;EXPLOSIONS,
	STA CSOUND  ;CANNON & LASERS.
	RTS         ;ALL DONE...

*	DLI ROUTINES

*	GAME BOARD DLIs

DLI	CLD            ;CLEAR DEC.
	PHA            ;SAVE ACC.
	LDA GEVX+0     ;GET X-COORDS
	STA HPOSP0     ;OF ALL ACTIVE
	LDA GEVX+1     ;VESSELS &
	STA HPOSP1     ;STORE INTO PM
	LDA GEVX+2     ;HORIZONTAL
	STA HPOSP2     ;REGISTERS.
	LDA GEVX+3     ;
	STA HPOSP3     ;
	LDA GEVX+4     ;
	STA HPOSM3     ;
	CLC            ;
	ADC #$02       ;
	STA HPOSM2     ;
	CLC            ;
	ADC #$02       ;
	STA HPOSM1     ;
	CLC            ;
	ADC #$02       ;
	STA HPOSM0     ;
	LDA #LOW DLI2  ;SET UP FOR
	STA VDSLST     ;NEXT DISPLAY
	LDA #HIGH DLI2 ;LIST INTER-
	STA VDSLST+1   ;RUPT REQUEST.
	PLA            ;RESTORE ACC.
	RTI            ;ALL DONE...

DLI2	PHA            ;SAVE ACC.
	LDA #$00       ;MAKE X-COORDS
	STA HPOSP0     ;OF ALL ACTIVE
	STA HPOSP1     ;VESSELS EQUAL
	STA HPOSP2     ;TO ZERO. THIS
	STA HPOSP3     ;PROVIDES A
	STA HPOSM0     ;NICE BORDER
	STA HPOSM1     ;AT THE
	STA HPOSM2     ;BOTTOM.
	STA HPOSM3     ;
	PLA            ;RESTORE ACC.
	RTI            ;ALL DONE...

* TITLE SCREEN DLIs

DLIDLI	PHA		;SAVE ACC.
	TXA		;SAVE THE
	PHA		;X-REG.
	LDX #$07	;LOAD X-REG.
	LDA DSHIFT	;OKAY, NOW
	STA CSHIFT	;I'LL LET
DLIXX	LDA CSHIFT	;YOU GUYS
	STA WSYNC	;FIGURE OUT
	STA COLPF0+1	;HOW I GOT
	LDA CSHIFT	;THAT SUPER
	CLC		;DUPER STU-
	ADC #$02	;PENDOUS
	STA CSHIFT	;FANCY
	DEX		;COLOR CHANGE
	BPL DLIXX	;(SO THERE!)
	LDA #LOW DLIXY  ;SET UP FOR
	STA VDSLST+0	;NEXT DLI
	LDA #HIGH DLIXY	;(IF YOU
	STA VDSLST+1	;DON'T MIND).
	DEC BLAH	;DEC TIMER.
	BPL DLIZZ	;BRANCH!
	LDA STRUCT	;RESET
	STA BLAH	;TIMERS.
	INC BLAH	;INCREMENT
	ASL BLAH	;& SHIFT
	INC DSHIFT	;REGISTERS.
DLIZZ	PLA		;RESTORE
	TAX		;X-REG.
	PLA		;RESTORE ACC.
	RTI		;LATER Y'ALL!

DLIXY	PHA		;SAVE ACC.
	LDA COLOR0+1	;RESTORE OLD
	STA COLPF0+1	;COLOR REG.
	PLA		;RESTORE ACC.
	RTI		;LATER Y'ALL!

:XHOLD	DB	0      ;X-REG. TEMP.
CSHIFT	DB	0      ;COLOR SHIFT.
DSHIFT	DB	0      ;COLOR SHIFT.
BLAH	DB	0      ;DUM TIMER.

:LSTDB	DW	DLIST  ;LO/HI DISPLAY
	DW	DLIST2 ;LIST BYTES.

:DLIDB	DW	DLI    ;LO/HI DLI
	DW	DLIDLI ;BYTES.

*	PLAYER SCORE PLACEMENT BYTES

PUTSCR	DB 1,13,3,15,5,17

*	TEAM SCORE PLACEMENT BYTES

PUTTME	DB 7,9,11

*	SCORE PLACEMENT MASKS

SCMASK	DB $0E,$0F

 TITLE	'OUT OF BOUNDS CHECK'

BOUNDS	PROC

	LDX #$04     ;CHECK EVERYBODY

*	CHECK Y-COORDS

BOUND3	CPX #$02     ;A BACTERION?
	BCS CHECKX   ;IF SO LEAVE IT.
	LDA GEVY,X   ;IS PLAYER OUT
	CMP LOWY     ;OF BOUNDS?
	BCS BOUND5   ;NO, CONTINUE.
BOUND4	LDY GEVDIR,X ;OUT OF BOUNDS!
	LDA REFLEY,Y ;GET REFLEX
	STA GEVDIR,X ;ANGLE & STORE.
	JSR MOVSUB   ;MOVE ONCE MORE
	JMP CHECKX   ;& CHECK X-COORD
BOUND5	CMP HIGHY    ;BOUNDARY.
	BCS BOUND4   ;

*	CHECK X-COORDS

CHECKX	LDA GEVX,X   ;OUT OF BOUNDS
	CMP LOWX     ;ON X-COORDS?
	BCS BOUND7   ;NO, CONTINUE.
BOUND6	LDY GEVDIR,X ;OUT OF BOUNDS!
	LDA REFLEX,Y ;GET REFLEX
	STA GEVDIR,X ;ANGLE & STORE.
	JSR MOVSUB   ;MOVE ONCE MORE
	JMP CHECKY   ;& CHECK NEXT.
BOUND7	CMP HIGHX    ;
	BCS BOUND6   ;
CHECKY	DEX          ;CHECK NEXT
	BPL BOUND3   ;VESSEL.
	RTS          ;ALL DONE.

LOWX	DB	44   ;LOWEST X-COORD
LOWY	DB	32   ;LOWEST Y-COORD
HIGHX	DB	200  ;HIGHEST X-COORD
HIGHY	DB	215  ;HIGHEST Y-COORD

*  REFLEX DIRECTIONS FOR Y-COORDS

REFLEY	DB 08,07,06,05,04,03,02,01
	DB 00,15,14,13,12,11,10,09

*  REFLEX DIRECTIONS FOR X-COORDS

REFLEX	DB 00,15,14,13,12,11,10,09
	DB 08,07,06,05,04,03,02,01

 TITLE 'TITLE SCREEN DISPLAY LIST'

DLIST2	DB $70,$70,$70,$70,$46
	DW PLAYR1
	DB $46
	DW PLAYR2
	DB $70,$70,$70,$F0,$46
	DW TITLE
	DB $B0,$46
	DW TITLE2
	DB $50,$46
	DW NAME1
	DB $20,$46
	DW NAME2
	DB $20,$46
	DW NAME3
	DB $20,$46
	DW NAME4
	DB $70,$70,$46
	DW NAME5
	DB $70,$70,$46
	DW TEAM1
	DB $46
	DW TEAM2
	DB $41
	DW DLIST2

 TITLE 'BACTERION! STRATEGY ROUTINE'

STRAT	PROC

	LDX GEVNUM   ;BACTERION #

*  SHOULD BACTERION! ATTACK PLAYER?

	LDA STOP,X   ;IS BACTERION
	BEQ :CONT    ;IN A COMA?
	RTS          ;YES! QUIT!
:CONT	LDA GEVCEL,X ;CELL IN TOW?
	BMI :CONT2   ;YES! QUIT!
	LDY NOPLAY   ;# OF PLAYERS.
:CONT0	LDA STOP,Y   ;THIS PLR ICED?
	BNE :CONT1   ;YES! CONTINUE!
	LDA GEVX,X   ;IS X-COORD OF
	SEC          ;PLAYER WITHIN
	SBC GEVX,Y   ;ATTACKING
	JSR ABS      ;RANGE?
	CMP FRANGE   ;
	BCS :CONT1   ;NO! QUIT!
	LDA GEVY,X   ;IS Y-COORD OF
	SEC          ;PLAYER WITHIN
	SBC GEVY,Y   ;ATTACKING
	JSR ABS      ;RANGE?
	CMP FRANGE   ;
	BCS :CONT1   ;NO! QUIT!
	LDA GEVX,Y   ;PLR X-COORD IS
	STA :TARX    ;TARGET X-COORD
	LDA GEVY,Y   ;PLR Y-COORD IS
	STA :TARY    ;TARGET Y-COORD
	JSR LASERS   ;SCRAP PLAYER!!!
	LDA #$01     ;BONZI!!!!!
	BNE STRAT2   ;
:CONT1	DEY          ;CHECK NEXT
	BPL :CONT0   ;PLAYER. IF ANY.
:CONT2	LDA TARX,X   ;SAVE TARGET
	STA :TARX    ;X-COORD.
	LDA TARY,X   ;SAVE TARGET
	STA :TARY    ;Y-COORD.
	LDA #$00     ;
STRAT2	STA ATTACK,X ;ATTACK STATUS

*	FIND THE MARK

*	AXIS TESTs

STRAT3	LDA :TARX  ;IS THE TARGET
	CMP GEVX,X ;(RELATIVE TO
	BEQ AXIS5  ;ATTACKING
	BCS AXIS7  ;BACTERION)

	LDA :TARY  ;ON THE X
	CMP GEVY,X ;OR Y AXIS? THAT
	BNE AXIS4  ;IS THE QUESTION!

	LDA #$04   ;WHO EVER HEARD
	BNE QUIT   ;OF CENSORING

AXIS4	BCS QUAD3  ;ASSEMBLY LAN-
	BCC QUAD2  ;GUAGE LISTINGS?

AXIS5	LDA :TARY  ;BACTERION! IS
	CMP GEVY,X ;DEDICATED TO MY
	BEQ EXIT   ;FRIENDS IN GOOD
	BCS AXIS6  ;OLD TEANECK...

	LDA #$00   ;IN CASE YOU
	BEQ QUIT   ;PEOPLE DON'T

AXIS6	LDA #$08   ;KNOW WHO YOU ARE,
	BNE QUIT   ;HERE'S A LIST

AXIS7	LDA :TARY  ;OF CODE-NAMES...
	CMP GEVY,X ;SIR HEX
	BNE AXIS8  ;THE QUAB RUNNER

	LDA #12    ;THE SILICON
	BNE QUIT   ;PIRATE

AXIS8	BCS QUAD4  ;TAI-FIGHTER &
	BCC QUAD1  ;HOME BOY ROGER D.

*	FIRST QUADRANT

QUAD1	JSR DELTAS ;
	BEQ QUAD12 ;
	BCC QUAD13 ;WE KNOW THE TAR-
	LDA #13    ;GET IS IN THE
	BNE QUIT   ;1st QUAD. DECIDE
QUAD12	LDA #14    ;ON A DIRECTION.
	BNE QUIT   ;(13,14,15)
QUAD13	LDA #15    ;
	BNE QUIT   ;BRANCH!

*	SECOND QUADRANT

QUAD2	JSR DELTAS ;
	BEQ QUAD22 ;
	BCC QUAD23 ;WE KNOW THE TAR-
	LDA #03    ;GET IS IN THE
	BNE QUIT   ;2nd QUAD. DECIDE
QUAD22	LDA #02    ;ON A DIRECTION.
	BNE QUIT   ;(1,2,3)
QUAD23	LDA #01    ;
	BNE QUIT   ;BRANCH!

*	THIRD QUADRANT

QUAD3	JSR DELTAS ;
	BEQ QUAD32 ;
	BCC QUAD33 ;WE KNOW THE TAR-
	LDA #05    ;GET IS IN THE
	BNE QUIT   ;3rd QUAD. DECIDE
QUAD32	LDA #06    ;ON A DIRECTION.
	BNE QUIT   ;(5,6,7)
QUAD33	LDA #07    ;
	BNE QUIT   ;BRANCH!

*	FOURTH QUADRANT

QUAD4	JSR DELTAS ;
	BEQ QUAD42 ;
	BCC QUAD43 ;WE KNOW THE TAR-
	LDA #11    ;GET IS IN THE
	BNE QUIT   ;4th QUAD. DECIDE
QUAD42	LDA #10    ;ON A DIRECTION.
	BNE QUIT   ;(9,10,11)
QUAD43	LDA #09    ;
	BNE QUIT   ;BRANCH!

EXIT	LDA #$FF   ;TARGET REACHED

QUIT	STA GEVDES,X ;SAVE DESIRED
	RTS          ;DIRECTION. BYE!

*	CALCULATE COORDINATE DELTAS

DELTAS	LDA :TARY  ;TARGET Y-COORD.
	SEC        ;SUBTRACT FROM
	SBC GEVY,X ;BACTERION Y-CORD.
	JSR ABS    ;ABSOLUTE VALUE.
	STA :DELTA ;SAVE IT.
	LDA :TARX  ;TARGET X-COORD.
	SEC        ;SUBTRACT FROM
	SBC GEVX,X ;BACTERION X-CORD.
	JSR ABS    ;ABSOLUTE VALUE.
	CMP :DELTA ;COMPARE TO Y
	RTS        ;DELTA & RETURN.

*	TURN ENEMY BACTERION!s

TURN	DEC TURNT      ;TIME TO TURN?
	BPL TRTS       ;NO! LATER!
	LDX TYPES      ;RESTORE TURN
	LDA TURNDB-1,X ;TIME FROM
	STA TURNT      ;TURN DATABASE.
	LDX #$04       ;HANDLE ALL.
TURN0	LDA STOP,X     ;VESSEL ICED?
	BNE PL4        ;YES! LATER!

	LDA #$03  ;GET RANDOM AMOUNT
	JSR RANDO ;FOR DIRECTIONAL
	TAY       ;TURN.
	INY       ;

	LDA GEVDES,X ;DESIRED DIRECTION.
	CMP GEVDIR,X ;ACTUAL DIRECTION.
	BEQ PL4      ;IF = QUIT!
	BCS TURNG5   ;ACT. > DES.
	JSR SUBDIR   ;SUB. THE TWO.
	CMP #$08     ;IS DIFF. > 8?
	BCS TURNG6   ;YES! BRANCH!
TURNG4	TYA          ;INVERT AMOUNT
	EOR #$FF     ;OF TURN (MAKE
	TAY          ;IT NEGATIVE)
	INY          ;
	BMI TURNG6   ;BRANCH!
TURNG5	JSR SUBDIR   ;SUB. THE TWO.
	CMP #$08     ;IF DIFF. > 8?
	BEQ TURNG6   ;DIFF = 8!
	BCS TURNG4   ;DIFF > 8!
TURNG6	TYA          ;ADD AMOUNT OF
	CLC          ;TURN TO BAC-
	ADC GEVDIR,X ;TERION'S DIR-
	JSR WRAP     ;ECTION & SAVE.
	STA GEVDIR,X ;

PL4	DEX       ;TURN NEXT
	CPX #$01  ;BACTERION!
	BNE TURN0 ;IF ANY.
TRTS	RTS	  ;BOOGIE OUTTA HERE!

SUBDIR	LDA GEVDES,X ;DESIRED
	SEC          ;SUBTRACTED FROM
	SBC GEVDIR,X ;ACTUAL
	JMP ABS      ;ABSOLUTE VALUE.

*	MOVE ENEMY BACTERION!s

MOVE	LDX #$04       ;HANDLE ALL.
MOVE0	DEC MOVET,X    ;TIME TO MOVE?
	BPL MOVENX     ;NO! LATER!
	LDY TYPES      ;RESTORE MOVE
	LDA MOVEDB-1,Y ;TIMER.
	LDY GEVCEL,X   ;CELL IN TOW?
	BPL MOVE1      ;NO! MOVEFAST!
	ASL A          ;YES! MOVE 4
	ASL A          ;TIMES AS SLOW!
MOVE1	STA MOVET,X    ;SAVE MOVE
	JSR MOVSUB     ;TIMER & MOVE!
MOVENX	DEX            ;HANDLE NEXT
	CPX #$01       ;BACTERION!
	BNE MOVE0      ;IF ANY.
	RTS            ;OTTA HERE...

*	TRACK HEISTED CELLS

TRACK	LDX #$04     ;HANDLE ALL.
TRK0	LDA STOP,X   ;VESSEL ON ICE?
	BNE TRK1     ;YES! BYPASS!

	LDA GEVCEL,X ;CELL IN TOW?
	BPL TRKTRK   ;NO! QUIT!
	LDA GEVY,X   ;IS VESSEL ALL
	CMP #15	     ;THE WAY OFF-
	BCC OFFSCR   ;SCREEN?
	CMP #235     ;
	BCC TRKTRK   ;NO! QUIT!

* SUCCESSFUL HEISTING OF A CELL

OFFSCR	INC GEVESC   ;INC. ESCAPEES
	DEC TOTCEL   ;DEC. # OF CELLS
	LDA #$01     ;HALT THIS
	STA STOP,X   ;BACTERION.
	BNE TRK1     ;BRANCH!

TRKTRK	LDA ATTACK,X ;ATTACKING?
	BNE TRK1     ;YES! SKIP!
	LDA GEVDES,X ;AT TARGET?
	BPL TRK1     ;YES! SKIP!

	LDA ESCAPE,X ;ATTACKING PLR?
	BEQ TRK1     ;YES! BRANCH!
	STA TARY,X   ;NO! SET Y-TARGET

	JSR PICKX    ;PICK RANDOM X-TARGET.
	STA TARX,X   ;SAVE IT.
	JSR PICKDR   ;GET A DIRECTION
	LDA GEVCEL,X ;GIVE CELL A
	ORA #$80     ;HEISTED STATUS.
	STA GEVCEL,X ;

TRK1	DEX      ;HANDLE NEXT
	CPX #$01 ;BACTERION!
	BNE TRK0 ;IF ANY.
	RTS      ;GET LOST LOSER!

* ACCUMULATOR ABSOLUTE VALUE FUNCTION

ABS	BPL RABS
	EOR #$FF
	CLC
	ADC #$01
RABS	RTS

*	DIRECTIONAL WRAP AROUND

WRAP	BPL PWRAP ;DIRECTION > 0?
	CLC       ;NO! ADD 16 TO IT.
	ADC #16   ;
	RTS       ;GET LOST LOSER!
PWRAP	CMP #16   ;DIRECTION < 16?
	BCC WRTS  ;NO! SUBTRACT 16
	SEC       ;FROM IT.
	SBC #16   ;
WRTS	RTS       ;GET LOST LOSER!

*	GENERAL MOVEMENT ANALYSIS

MOVSUB	LDA STOP,X   ;COMATOSE?
	BNE MOV1     ;YES! QUIT!
	LDA GEVDES,X ;TARGET REACHED?
	BMI MOV1     ;YES! QUIT!
	LDY GEVDIR,X ;GET DIRECTION.
	LDA DELX,Y   ;ADD X-COORD ADD
	STA :ADDX    ;ON FOR GIVEN
	CLC          ;DIRECTION.
	ADC GEVX,X   ;
	STA GEVX,X   ;SAVE IT.
	LDA DELY,Y   ;ADD Y-COORD ADD
	STA :ADDY    ;ON FOR GIVEN
	CLC          ;DIRECTION.
	ADC GEVY,X   ;
	STA GEVY,X   ;SAVE IT.
	LDA GEVCEL,X ;CELL IN TOW?
	BPL MOV1     ;NO! QUIT!
	AND #$7F     ;YES!
	TAY          ;
	LDA :ADDX    ;ADD X-COORD ADD
	CLC          ;ON FOR GIVEN
	ADC CELLNX,Y ;DIRECTION TO
	STA CELLNX,Y ;CELL'S X-COORD.
	LDA :ADDY    ;ADD Y-COORD ADD
	CLC          ;ON FOR GIVEN
	ADC CELLNY,Y ;DIRECTION TO
	STA CELLNY,Y ;CELL'S Y-COORD.
	LDA #$01     ;CELL MOVEMENT
	STA CELLMV,Y ;STATUS SET.
MOV1	RTS          ;SEE YA LATER...

* VAPORIZE PLAYERS WITH DEADLY LASERS

LASERS	DEC GEVFRE,X ;FIRE TIMER = 0?
	BPL XITLSR   ;NO! QUIT!
	LDA FIRETM   ;RESTORE FIRE
	STA GEVFRE,X ;TIMER.
	LDA LSRDIR,X ;ALREADY FIRING?
	BNE XITLSR   ;YES! QUIT!
	LDA GEVDES,X ;SAVE DESIRED
	PHA          ;DIRECTION.
	JSR STRAT3   ;GET LASER DIRECTON.
	TAY          ;PUT IN Y-REG.
	PLA          ;RESTORE DESIRED
	STA GEVDES,X ;DIRECTION.
	CPY #$FF     ;LASER AT TARGET?
	BEQ XITLSR   ;YES! QUIT!
	LDA LSRBSE,Y ;FINE TUNE LASER
	STA LSRDIR,X ;DIRECTION.
	LDA #$0A     ;LASER BOLT
	STA LSRTME,X ;LIFETIME.
	LDA #14      ;SET UP LASER
	STA LSOUND   ;SOUND.
XITLSR	RTS          ;JUMP IN A LAKE!

*	LASER DIRECTIONAL FINE TUNING

LSRBSE	DB 1,8,8,8,4,6,6,6,2
	DB 7,7,7,3,5,5,5

:TARX	DB	0 ;X-COORD TARGET
:TARY	DB	0 ;Y-COORD TARGET
:ADDX	DB	0 ;X-COORD ADD ON
:ADDY	DB	0 ;Y-COORD ADD ON
:DELTA	DB	0 ;TAR. Y - ACT. Y

*	X-COORD DIRECTIONAL ADD ONs

DELX	DB +0,-1,-2,-2,-2,-2,-2,-1
	DB +0,+1,+2,+2,+2,+2,+2,+1

*	Y-COORD DIRECTIONAL ADD ONs

DELY	DB -2,-2,-2,-1,+0,+1,+2,+2
	DB +2,+2,+2,+1,+0,-1,-2,-2

*	TURN DATABASE

TURNDB	DB 0,0,0,0,0,0,0

*	MOVEMENT DATABASE

MOVEDB	DB 0,0,0,0,0,0,0

 TITLE 'BACTERION! PM DRAW ROUTINE'

DRAW	PROC

	LDA #$04       ;HANDLE ALL.
	STA COUNT      ;VESSELS (0-4)
DRAW1	LDX COUNT      ;VESSEL #.
	LDY TYPE,X     ;TYPE (0-7).
	LDA PHASE,X    ;SHAPE PHASE.
	CMP INDEX+1,Y  ;PHASE EXCEE-
	BCC DRAW3      ;DED? 
DRAW2	LDA INDEX,Y    ;YES! CORRECT
	STA PHASE,X    ;PHASE.
DRAW3	CMP INDEX,Y    ;PHASE EXCEE-
	BCC DRAW2      ;DED?
	ASL A          ;NO! GET OFF-
	TAY            ;SET TO DATA
	LDA OFFSET,Y   ;FOR THIS
	STA DRWLO      ;PHASE.
	LDA OFFSET+1,Y ;
	STA DRWLO+1    ;
	LDA COUNT      ;FIND WHERE TO
	ASL A          ;PLACE PHASE
	TAY            ;DATA. (DEP-
	LDA PLBSE,Y    ;ENDS ON WHICH
	STA PLLO       ;VESSEL # WE
	LDA PLBSE+1,Y  ;ARE DRAWING).
	STA PLLO+1     ;
	LDA #$07       ;PREPARE TO
	STA PTR1       ;READ 8 BYTES.
	CLC            ;FIND OUT
	ADC GEVY,X     ;WHERE TO PUT
	STA PTR2       ;DATA.
DRAW4	LDY PTR1       ;GET PHASE
	LDA (DRWLO),Y  ;DATA.
	LDY PTR2       ;PUT INTO PM
	STA (PLLO),Y   ;LOCATIONS.
	DEC PTR2       ;RESET
	DEC PTR1       ;POINTERS.
	BPL DRAW4      ;ALL DONE?
	LDA #$07       ;YES! SET UP
	STA COUNT2     ;FOR 8 BYTES.
DRAW5	LDX COUNT      ;BEGIN ERASING
	LDA GEVY,X     ;DATA AT TOP
	LDX COUNT2     ;& BOTTOM OF
	CLC            ;VESSEL. THIS
	ADC ERADD,X    ;ACCOUNTS FOR
	TAY            ;WHEN A VESSEL
	LDA #$00       ;MOVES VERTI-
	STA (PLLO),Y   ;CALLY AS WE
	DEC COUNT2     ;MUST PRE-
	BPL DRAW5      ;VENT DATA
	DEC COUNT      ;OVERLAP.
	BPL DRAW1      ;YEAH SO WHAT!

DRAW6	DEC PHTIME ;DEC PHASE TIMER.
	BPL DRAW7  ;QUIT IF NOT 0.
	LDA #$04   ;RESET PHASE TIMER
	STA PHTIME ;& STORE.

	TAX         ;HANDLE ALL (0-4)
PHS4	CPX #$02    ;A BACTERION?
	BCS PHS5    ;YES! SKIP IT!
	LDA TYPE,X  ;IS IT EXPLODING?
	CMP #$07    ;
	BNE PHS7    ;NO! SKIP IT!
PHS5	LDA PHASE,X ;
	CMP #47	    ;(INDEX+8)-1
	BEQ PHS7    ;
	INC PHASE,X ;INC VESSEL PHASE
	CMP #46	    ;(INDEX+8)-2
	BNE PHS7    ;
	CPX #$02    ;IS VESSEL A
	BCC PHS7    ;PLAYER?
	INC GEVESC  ;NO! INC # OF ESCAPES.
PHS7	DEX         ;MOVE ON TO
	BPL PHS4    ;NEXT...

DRAW7	RTS ;TIME TO BOOGIE...

COUNT	DB 0 ;BYTE DRAW COUNTER
COUNT2	DB 0 ;BYTE DRAW COUNTER
PTR1	DB 0 ;POINTER TO PHASE DATA
PTR2	DB 0 ;POINTER TO PM AREA
PHTIME	DB 3 ;VESSEL PHASE TIMER

*	TOP/BOTTOM ERASURE OFFSETS

ERADD	DB -4,-3,-2,-1,+8,+9,+10,+11

*	INDEX TO VESSEL PHASE DATA

INDEX	DB 0,16,20,24,28,31,35,39,48

*	LO/HI BYTES TO PM AREA

PLBSE	DW PLAY0
	DW PLAY1
	DW PLAY2
	DW PLAY3
	DW MISS

*	OFFSET TO VESSEL PHASE DATA

OFFSET	DW :ROT00	;0
	DW :ROT01
	DW :ROT02
	DW :ROT03
	DW :ROT04
	DW :ROT05
	DW :ROT06
	DW :ROT07
	DW :ROT08
	DW :ROT09
	DW :ROT10
	DW :ROT11
	DW :ROT12
	DW :ROT13
	DW :ROT14
	DW :ROT15

	DW :GEV10	;16
	DW :GEV11
	DW :GEV12
	DW :GEV11

	DW :GEV20	;20
	DW :GEV21
	DW :GEV22
	DW :GEV21

	DW :GEV30	;24
	DW :GEV31
	DW :GEV32
	DW :GEV31

	DW :GEV40	;28
	DW :GEV41
	DW :GEV42

	DW :GEV50	;31
	DW :GEV51
	DW :GEV52
	DW :GEV51

	DW :GEV60	;35
	DW :GEV61
	DW :GEV62
	DW :GEV63

	DW :EXP0	;39
	DW :EXP1
	DW :EXP2
	DW :EXP3
	DW :EXP4
	DW :EXP5
	DW :EXP6
	DW :EXP7
	DW :EXP8

			;48

*	TANK ROTATION 0

:ROT00	DB $10,$10,$10,$38
	DB $54,$82,$44,$44

*	TANK ROTATION 1

:ROT01	DB $20,$20,$10,$1E
	DB $19,$21,$20,$10

*	TANK ROTATION 2

:ROT02	DB $80,$40,$20,$1F
	DB $19,$10,$10,$18

*	TANK ROTATION 3

:ROT03	DB $00,$00,$C6,$39
	DB $18,$10,$10,$0C

*	TANK ROTATION 4

:ROT04	DB $04,$0B,$10,$F0
	DB $10,$0B,$04,$00

*	TANK ROTATION 5

:ROT05	DB $0C,$10,$10,$18
	DB $39,$C6,$00,$00

*	TANK ROTATION 6

:ROT06	DB $18,$10,$10,$19
	DB $1F,$20,$40,$80

*	TANK ROTATION 7

:ROT07	DB $10,$20,$21,$19
	DB $1E,$10,$20,$20

*	TANK ROTATION 8

:ROT08	DB $44,$44,$82,$44
	DB $38,$10,$10,$10

*	TANK ROTATION 9

:ROT09	DB $08,$04,$84,$98
	DB $78,$08,$04,$04

*	TANK ROTATION 10

:ROT10	DB $18,$08,$08,$98
	DB $F8,$04,$02,$01

*	TANK ROTATION 11

:ROT11	DB $30,$08,$08,$18
	DB $9C,$63,$00,$00

*	TANK ROTATION 12

:ROT12	DB $20,$D0,$08,$0F
	DB $08,$D0,$20,$00

*	TANK ROTATION 13

:ROT13	DB $00,$00,$63,$1C
	DB $18,$08,$08,$30

*	TANK ROTATION 14

:ROT14	DB $01,$02,$04,$F8
	DB $98,$08,$08,$18

*	TANK ROTATION 15

:ROT15	DB $04,$04,$08,$78
	DB $98,$84,$04,$08

*	BACTERION! #1

:GEV10	DB $18,$00,$24,$81
	DB $81,$24,$00,$18

:GEV11	DB $18,$42,$24,$81
	DB $81,$24,$42,$18

:GEV12	DB $99,$42,$24,$81
	DB $81,$24,$42,$99

*	BACTERION! #2

:GEV20	DB $00,$00,$3C,$24
	DB $24,$3C,$00,$00

:GEV21	DB $00,$66,$42,$18
	DB $18,$42,$66,$00

:GEV22	DB $C3,$81,$00,$18
	DB $18,$00,$81,$C3

*	BACTERION! #3

:GEV30	DB $3C,$42,$A5,$81
	DB $81,$A5,$42,$3C

:GEV31	DB $00,$18,$24,$42
	DB $42,$24,$18,$00

:GEV32	DB $00,$00,$18,$3C
	DB $3C,$18,$00,$00

*	BACTERION! #4

:GEV40	DB $00,$00,$18,$24
	DB $24,$18,$00,$00

:GEV41	DB $00,$18,$00,$5A
	DB $5A,$00,$18,$00

:GEV42	DB $18,$00,$18,$A5
	DB $A5,$18,$00,$18

*	BACTERION! #5

:GEV50	DB $20,$20,$E4,$18
	DB $18,$27,$04,$04

:GEV51	DB $00,$24,$66,$18
	DB $18,$66,$24,$00

:GEV52	DB $04,$04,$27,$18
	DB $18,$E4,$20,$20

*	BACTERION! #6

:GEV60	DB $0C,$40,$90,$25
	DB $25,$88,$40,$0C

:GEV61	DB $18,$00,$99,$A1
	DB $04,$18,$42,$24

:GEV62	DB $30,$02,$19,$84
	DB $A0,$19,$02,$30

:GEV63	DB $24,$42,$08,$24
	DB $A5,$91,$00,$18

*	DETONATION

:EXP0	DB $00,$00,$00,$18
	DB $18,$00,$00,$00

:EXP1	DB $00,$00,$08,$38
	DB $1C,$10,$00,$00

:EXP2	DB $00,$08,$08,$78
	DB $1E,$10,$10,$00

:EXP3	DB $08,$08,$2C,$E0
	DB $07,$34,$10,$10

:EXP4	DB $08,$4A,$24,$C0
	DB $03,$24,$52,$10

:EXP5	DB $89,$42,$24,$80
	DB $01,$24,$42,$91

:EXP6	DB $81,$42,$00,$00
	DB $00,$00,$42,$81

:EXP7	DB $81,$00,$00,$00
	DB $00,$00,$00,$81

:EXP8	DB $00,$00,$00,$00
	DB $00,$00,$00,$00

*TYPE	- TYPE OF TANK BEING DRAWN
*	  0 - PLAYERS # 1 & 2
*	1-6 - GEVs 1,2,3,4,5,6
*	  7 - DETONATION SEQUENCE
*PHASE	- PHASE # OF BACTERION!s
*      0-15 - PLAYERS # 1 & 2
*     16-19 - BACTERION! # 1
*     20-23 - BACTERION! # 2
*     24-27 - BACTERION! # 3
*     28-30 - BACTERION! # 4
*     31-34 - BACTERION! # 5
*     35-38 - BACTERION! # 6
*     39-48 - EXPLOSION SEQUENCE

 TITLE 'BACTERION TITLE SCREEN'

	PROC

*	BACTERION!

TITLE	DB 0,0,0,0,0
	DB 098,097,099,116,101
	DB 114,105,111,110,065
	DB 0,0,0,0,0

*	THE PLAGUE OF 2369

TITLE2	DB 000,180,168,165,00,176,172
	DB 161,167,181,165,00,175,166
	DB 00,210,211,214,217,00

*	TEAM SCORE

TEAM1	DB 0,0,0,0,0
	DB 180,165,161,173,000
	DB 179,163,175,178,165
	DB 0,0,0,0,0

TEAM2	DB 0,0,0,0,0
	DB 0,0,0,0,0
	DB 0,0,0,0,0
	DB 0,0,0,0,0

PLAYR1	DB 0,0,0,0,0
	DB 0,0,0,0,0
	DB 0,0,0,0,0
	DB 0,0,0,0,0

PLAYR2	DB 0,0,0,0,0
	DB 0,0,0,0,0
	DB 0,0,0,0,0
	DB 0,0,0,0,0

*	BY

NAME1	DB 00,00,00,00,00
	DB 00,00,00,00,34
	DB 57,00,00,00,00
	DB 00,00,00,00,00

*	KYLE PEACOCK

NAME2	DB 0,0,0,0
	DB 235,249,236,229,000,240
	DB 229,225,227,239,227,235
	DB 0,0,0,0

*	WITH

NAME3	DB 0,0,0,0,0,0,0,0
	DB 55,41,52,40
	DB 0,0,0,0,0,0,0,0

*	TOM HUDSON

NAME4	DB 0,0,0,0,0
	DB 244,239,237,000,232
	DB 245,228,243,239,238
	DB 0,0,0,0,0

*	ANALOG COMPUTING

NAME5	DB $00,$00,$A1,$AE,$A1
	DB $AC,$AF,$A7,$00,$A3
	DB $AF,$AD,$B0,$B5,$B4
	DB $A9,$AE,$A7,$00,$00

 TITLE 'JOYSTICK READING'

STICKS	PROC

	LDX NOPLAY   ;# OF PLAYERS

ACT4	LDA STOP,X   ;IS PLAYER DEAD?
	BEQ ACT5     ;NO, CONTINUE.
	DEC STOP,X   ;DEC. DEATH TIME
	BNE NXTACT   ;& CONTINUE.
	JSR SETPLR   ;IF DEATH TIME=0
	JMP NXTACT   ;REINCARNATE.

ACT5	JSR MOVPLR   ;MOVE PLAYER

	DEC TURNIT,X ;DEC. TURN TIME
	BPL NXTACT   ;IF <> 0 CONT.
	LDA #$03     ;RESET TURN
	STA TURNIT,X ;TIME & STORE.

	LDY STICK0,X ;READ JOYSTICK.
	LDA GEVDIR,X ;UPDATE DIRECT-
	CLC          ;ION ACCORDING
	ADC DRHASH,Y ;TO JOYSTICK.
	JSR WRAP     ;TEST FOR WRAP
	STA GEVDIR,X ;AROUND &
	STA PHASE,X  ;SAVE.

NXTACT	DEX          ;HANDLE NEXT
	BPL ACT4     ;PLAYER.
	RTS	     ;ALL DONE...

*	GENERAL MOVEMENT ROUTINE

MOVPLR	DEC SPEED,X  ;TIME TO MOVE?
	BPL RTSMOV   ;NO, CONTINUE.
	LDA STICK0,X ;YES-READ STICK.
	CMP #14	     ;FORWARD MOTION.
	BEQ :MOV4    ;
	CMP #10	     ;FORWARD MOTION.
	BEQ :MOV4    ;
	CMP #06	     ;FORWARD MOTION.
	BNE :MOV5    ;
:MOV4	DEC CSPEED,X ;DEC. MOTION
	JMP :MOV6    ;TIMER.
:MOV5	INC CSPEED,X ;INC. MOTION
:MOV6	LDY CSPEED,X ;TIMER.
	LDA REHASH,Y ;DETECT OVERFLOW
	STA CSPEED,X ;& CORRECT (IF
	STA SPEED,X  ;ANY.) THEN SAVE
	LDA SPEED,X  ;MOTION TIMER.
	CMP DRHASH-1 ;
	BEQ RTSMOV   ;
	JSR MOVSUB   ;MOVE TO CORRECT
RTSMOV	RTS          ;ALL DONE...

TURNIT	DB 0,0	;PLAYERS' TURN TIMER.

*	SPEED LIMITATION DATABASE

REHASH	DB 2,2,2,3,4,5,6,7,8,8,8

*	JOYSTICK/DIRECTION ADD ONS

DRHASH	DB 0,0,0,0,0,-1,-1,-1
	DB 0,+1,+1,+1,0,0,0,0

 TITLE 'COLLISION DETECTION'

COLLIDE	PROC

*	SHIP COLLISION

	LDX NOPLAY ;# OF PLAYERS
COL5	LDA STOP,X ;IS THIS PLR ICED?
	BNE COLXX  ;YES! MOVE ALONG.
	LDA #$01   ;NO! CHECK FOR
	STA IDIE   ;COLLISION...
	LDA P0PL,X ;
	AND #$02   ;PLR/PLR
	BEQ COL7   ;NO COLLISION.
	JSR KILLME ;SMASH! BANG!
COL7	INC IDIE   ;CHECK FOR ANOTHER
	LDA P0PL,X ;COLLISION...
	AND #$04   ;PLR/BACTERION 1
	BEQ COL8   ;NO COLLISION.
	JSR KILLME ;OUCH! CRASH!
COL8	INC IDIE   ;CHECK FOR ANOTHER
	LDA P0PL,X ;COLLISION...
	AND #$08   ;PLR/BACTERION 2
	BEQ COL9   ;NO COLLISION.
	JSR KILLME ;DING! DONG!
COL9	INC IDIE   ;CHECK FOR ANOTHER
	LDY #$03   ;COLLISION
COL10	TXA        ;W/MISSILES...
	CLC        ;
	ADC #$01   ;
	AND M0PL,Y ;PLR/BACTERION 3
	BEQ COL11  ;NO COLLISION...
	JSR KILLME ;BING! ZAP!
COL11	DEY        ;CONTINUE CHECKING
	BPL COL10  ;

*	PLAYERS TOUCHING PODS?

	DEC PODTME   ;TIME TO CHECK?
	BPL COL13    ;NO! GO AWAY!
	LDA #$03     ;RESET POD TIMER
	STA PODTME   ;TO GO AGAIN.
	LDA P0PF,X   ;SMASHED INTO
	AND #$01     ;POD PLAYFIELD?
	BEQ COL13    ;NO! GO AWAY!
	LDA #$02     ;YES! ROTATE
	JSR RANDO    ;RANDOMLY.
	LDY RANDOM   ;ROTATE RIGHT
	BPL COL12    ;OR LEFT?
	EOR #$FF     ;ROTATE RIGHT.
	CLC          ;(CLOCKWISE)
	ADC #$01     ;
COL12	CLC          ;ROTATE LEFT.
	ADC GEVDIR,X ;(COUNTERCLOCK)
	JSR WRAP     ;CHECK FOR WRAP
	STA GEVDIR,X ;AROUND & SAVE
	STA PHASE,X  ;NEW ROTATION.

*	PLAYER HIT BY LASER?

COL13	LDA P0PF,X ;HAS PLAYER
	AND #$02   ;COLLIDED WITH
	BEQ COLXX  ;LASER PLAYFIELD?
	STX IDIE   ;YES! YES! YES!
	JSR KILLME ;VAPORIZE HIM!!!
COLXX	DEX        ;CHECK NEXT
	BPL COL5   ;PLAYER...

	STA HITCLR ;CLEAR COLLISIONS.

	RTS        ;GO AWAY!

*	INSERT DEATH VALUE

KILLME	STY YHOLD    ;SAVE Y-REG.
	LDY IDIE     ;GET WHO DIES!
	LDA STOP,Y   ;ARE THEY AL-
	BNE :KILLX   ;READY DEAD?
	TXA          ;NO! PREPARE
	TAY          ;TO VAPORIZE!
	JSR ZAPIT    ;ASHES TO ASHES!
	LDY IDIE     ;VAPORIZE OTHER
	JSR ZAPIT    ;VESSEL AS WELL!
	INC NOKILL,X ;INC # OF KILLS!
:KILLX	LDY YHOLD    ;RESTORE Y-REG.
	RTS          ;GET LOST!!!

*	CHANGE TO DEATH STATUS

ZAPIT	LDA STOP,Y ;IS THIS VESSEL
	BNE ZAPRTS ;ALREADY ICED!
	LDA #07    ;NO! START VESSEL
	STA TYPE,Y ;DETONATION!!!
	LDA #120   ;GIVE THEM A
	STA STOP,Y ;DEATH STATUS.
	LDA #00    ;TURN OFF BACTER-
	STA LSOUND ;ION! LASER SOUND.
	LDA #66    ;START UP DETONAT-
	STA XSOUND ;ION SOUND.
	RTS        ;BEAT IT!
ZAPRTS	PLA        ;PREMATURE
	PLA        ;RETURN. (PACK
	LDY YHOLD  ;YOUR BAGS AND
	RTS        ;HIT THE ROAD!)

IDIE	DB	0  ;VESSEL # TO DIE.
YHOLD	DB	0  ;Y-REG. STORAGE.
PODTME	DB	0  ;ROTATION TIMER.

 TITLE 'FIRE PLAYER PROJECTILES'

SHOOT	PROC

	JSR FIRST   ;DO THIS FIRST.
	JMP SECOND  ;DO THIS SECOND.

*	INITIALIZE PROJECTILES

FIRST	LDX NOPLAY   ;# OF PLAYERS
SHOOT5	LDA STOP,X   ;IS PLAYER ICED?
	BNE XSHOOT   ;YES! SKIP HIM!
	LDA FDELAY,X ;OK TO FIRE?
	BEQ SHOOT6   ;YES! CONTINUE.
	DEC FDELAY,X ;NO! DEC TIMER.
	JMP XSHOOT   ;SKIP TO NEXT.

SHOOT6	LDA NOBULL,X ;ALL BULLETS
	CMP #$04     ;FIRED ALREADY?
	BCS XSHOOT   ;YES! SKIP HIM.
	LDA TRIG0,X  ;BUTTON PRESSED?
	BNE XSHOOT   ;NO! SKIP HIM.
	INC NOBULL,X ;INC # BULLETS.
	LDA #$07     ;MAKE CANNON
	STA CSOUND   ;FIRING SOUND.
	LDA #$03     ;SET UP FIRING
	STA FDELAY,X ;DELAY.
	LDY #12      ;FIND AN UNUSED
SHOOT7	LDA BULLET,Y ;ARRAY SLOT FOR
	BMI SHOOT8   ;A PROJECTILE.
	DEY          ;DON'T STOP
	BNE SHOOT7   ;UNTIL YOU DO!!!
SHOOT8	STY BSLOT    ;ARRAY SLOT #.
	TXA          ;SAVE WHICH PLR
	STA BULLET,Y ;# WHO FIRED.
	LDY GEVDIR,X ;GET STARTING
	TYA          ;POINT OF PRO-
	PHA          ;JECTILE ACCORD-
	LDA DELX,Y   ;ING TO PLAYER'S
	ASL A        ;ANGLE OF ROT-
	CLC          ;ATION & (OF
	ADC GEVX,X   ;COURSE)
	SEC          ;PLAYER'S
	SBC #44      ;X & Y COORDS.
	LDY BSLOT    ;
	STA GEVX,Y   ;YUP!
	PLA          ;
	STA GEVDIR,Y ;THAT'S WHAT ALL
	TAY          ;THIS CODE DOES.
	LDA DELY,Y   ;
	ASL A        ;I DARE ANYONE
	CLC          ;TO COME UP WITH
	ADC GEVY,X   ;A BETTER PUBLIC
	SEC          ;DOMAIN PROGRAM.
	SBC #$1C     ;(EXCEPT TOM
	LDY BSLOT    ;HUDSON...)
	STA GEVY,Y   ;SO THERE!!!

XSHOOT	DEX        ;MOVE ALONG TO
	BPL SHOOT5 ;NEXT PLAYER.
	RTS        ;GET OUT!

*	MOVE PROJECTILES

SECOND	LDX #12      ;HANDLE ALL.
TRAV5	LDA BULLET,X ;ANYBODY OWN
	BMI XTRAV    ;THIS BULLET?

	JSR MOVSUB   ;YES! MOVE IT!

	LDA GEVX,X     ;OUT OF
	CMP #162       ;BOUNDS?
	BCS :DEACT     ;YES! BYE!
	STA CELLNX+5,X ;
	LDA GEVY,X     ;OUT OF
	CMP #192       ;BOUNDS?
	BCS :DEACT     ;YES! LATER!
	STA CELLNY+5,X ;

	LDY #$04   ;IS THIS BULLET
TRAV6	LDA STOP,Y ;WITHIN RANGE OF
	BNE TRAV7  ;ANY OF THE
	LDA GEVX,X ;BACTERIONS!
	CLC        ;
	ADC #48    ;LETHAL RANGE
	SEC        ;IS WITHIN 
	SBC GEVX,Y ;8 UNITS ON
	CMP #$09   ;EITHER X OR Y
	BCS TRAV7  ;AXIS.
	LDA GEVY,X ;
	CLC        ;
	ADC #$20   ;
	SEC        ;
	SBC GEVY,Y ;
	CMP #$09   ;
	BCS TRAV7  ;

	JSR ZAPIT  ;EXTERMINATE!!!

	STX :XHOLD     ;SAVE X-REG.
	LDA BULLET,X   ;FIND BULLET
	TAX            ;OWNER & INC.
	INC NOKILL,X   ;# OF KILLS.
	LDX :XHOLD     ;RES. X-REG.

:DEACT	STX :XHOLD     ;SAVE X-REG.
	LDA BULLET,X   ;GET BULLET
	TAX            ;OWNER & DEC.
	DEC NOBULL,X   ;# OF BULLETS.
	LDX :XHOLD     ;RES. X-REG.
	LDA #$FF       ;DEACTIVATE
	STA BULLET,X   ;BULLET. (NO
	STA CELLNX+5,X ;OWNER OR X,
	STA CELLNY+5,X ;Y COORDS)
	BNE TRAV8      ;GET OUT!

TRAV7	DEY       ;CHECK FOR COLL-
	CPY #$01  ;ISION WITH NEXT
	BNE TRAV6 ;BACTERION!

TRAV8	LDA #$01       ;BULLET LIVES.
	STA CELLMV+5,X ;MOVE IT.

XTRAV	DEX	  ;MOVE NEXT BULLET.
	CPX #$04  ;OUT OF BULLETS TO
	BNE TRAV5 ;MOVE?
	RTS	  ;YES! BOOGIE...

BSLOT	DB	0 ;UNUSED ARRAY SLOT.
:XHOLD	DB	0 ;X-REG. TEMP STORE.

 TITLE 'BACTERION! GRAPHICS PLOTTER'

*	----------------------
*	GR. 7+ PLOTTER ROUTINE
*	COURTESY OF TOM HUDSON
*	----------------------

PLOTTER	PROC

*	POINT PLOTTER ROUTINE

PLOTPT	LDX	PLOTY	 ;Y-COORD.
	CPX	#193     ;OFFSCREEN?
	BCS	:PBYE    ;YES! QUIT!
	LDA	LOTBL,X  ;NO! GET LO
	STA	LO       ;& HI BYTE
	LDA	HITBL,X  ;OF SCREEN
	STA	HI       ;RAM AREA.
	LDA	PLOTX    ;X-COORD.
	CMP	#160     ;OFFSCREEN?
	BCS	:PBYE    ;YES! QUIT!
	AND	#3       ;PLOT INDEX
	TAX              ;PLACE IN X
	LDA	PLOTX    ;GET PLOTX &
	LSR	A        ;DIVIDE
	LSR	A        ;BY 4.
	STA	YOFSET   ;
	LDY	COLOR    ;GET COLOR &
	LDA	:BMSK2,X ;MASK OFF
	AND	:COLRS,Y ;PIXEL POS.
	STA	HOLD     ;SAVE IT.
	LDA	:BMSK1,X ;MASK OFF PIXEL
	LDY	YOFSET   ;OF ADDR TO BE
	AND	(LO),Y   ;ALTERED.
	ORA	HOLD     ;SET PLOT BITS
	STA	(LO),Y   ;& STORE.
:PBYE	RTS              ;ALL DONE...

*	DRAW FROM/TO ROUTINE

DRAWTO	LDA	DRAWY  ;IS DRAWY
	CMP	PLOTY  ;> PLOTY?
	BCC	:YMNUS ;NO!
	SEC            ;SUB. PLOTY
	SBC	PLOTY  ;FROM DRAWY &
	STA	DELTAY ;SAVE DIFF.
	LDA	#1     ;Y INC. = 1.
	STA	INCY   ;(DOWN)
	BNE	:XVEC  ;BRANCH!
:YMNUS	LDA	PLOTY  ;SUB. DRAWY
	SEC            ;FROM PLOTY &
	SBC	DRAWY  ;SAVE DIFF.
	STA	DELTAY ;
	LDA	#255   ;Y INC. = -1.
	STA	INCY   ;(UP)
:XVEC	LDA	DRAWX  ;IS DRAWX
	CMP	PLOTX  ;> PLOTX?
	BCC	:XMNUS ;NO!
	SEC            ;SUB. DRAWX
	SBC	PLOTX  ;FROM PLOTX
	STA	DELTAX ;& SAVE DIFF.
	LDA	#1     ;X INC. IS 1
	STA	INCX   ;(RIGHT)
	BNE	:VCSET ;BRANCH!
:XMNUS	LDA	PLOTX  ;SUB. DRAWX
	SEC            ;FROM PLOTX
	SBC	DRAWX  ;& SAVE DIFF.
	STA	DELTAX ;
	LDA	#255   ;X INC IS -1
	STA	INCX   ;(LEFT)
:VCSET	LDA	#0     ;ZERO OUT
	STA	ACCY   ;Y-ACC.
	STA	ACCX   ;X-ACC.
	LDA	DELTAX ;IS DELTAX >
	CMP	DELTAY ;DELTAY?
	BCC	:YMAX  ;NO!
	STA	COUNTR ;SAVE DELTAX
	STA	ENDPT  ;IN COUNTR. ENDPT.
	LSR	A      ;DIV. BY 2 &
	STA	ACCY   ;STORE IN Y-ACC.
	JMP	:DRAWG ;START DRAW
:YMAX	LDA	DELTAY ;DELTAY LARGER.
	STA	COUNTR ;STORE IT IN
	STA	ENDPT  ;COUNTR, ENDPT.
	LSR	A      ;DIV BY 2 &
	STA	ACCX   ;STORE IN X-ACC.

*	BEGIN DRAWING TO DESTINATION

:DRAWG	LDA	COUNTR ;IF COUNTR=0...
	BEQ	:DRAWE ;NO DRAW!
:BEGIN	LDA	ACCY   ;ADD DELTAY
	CLC            ;TO Y-ACC.
	ADC	DELTAY ;
	BCS	:OVER1 ;
	STA	ACCY   ;
	CMP	ENDPT  ;AT ENDPNT YET?
	BCC	:BEGN2 ;NO, GO DO X.
	LDA	ACCY   ;SUB. ENDPT
	SEC            ;FROM Y-ACC.
:OVER1	SBC	ENDPT  ;
	STA	ACCY   ;
	LDA	PLOTY  ;AND INC. THE
	CLC            ;Y. POSITION.
	ADC	INCY   ;
	STA	PLOTY  ;
:BEGN2	LDA	ACCX   ;ADD DELTAX TO
	CLC            ;X-ACC.
	ADC	DELTAX ;
	BCS	:OVER2 ;
	STA	ACCX   ;
	CMP	ENDPT  ;AT ENDPT. YET?
	BCC	:PLOTT ;NO, GO PLOT.
	LDA	ACCX   ;SUB. ENDPT
	SEC            ;FROM X-ACC.
:OVER2	SBC	ENDPT  ;
	STA	ACCX   ;
	LDA	PLOTX  ;AND INC.
	CLC            ;PLOT X
	ADC	INCX   ;
	STA	PLOTX  ; 
:PLOTT	JSR	PLOTPT ;PLOT POINT.
	DEC	COUNTR ;MORE TO DRAW?
	BNE	:BEGIN ;YES!
:DRAWE	RTS            ;NO, ALL DONE...

*	DRAW AN INDIVIDUAL CELL

SHOCEL	LDX CELNUM   ;CELL # TO DRAW
	LDA #$00     ;SPECIFY COLOR
	STA CELLMV,X ;& DON'T UPDATE
	STA COLOR    ;AGAIN.
	LDA CELLOX,X ;GET OLD X-COORD
	STA PLOTX    ;& STORE
	LDA CELLOY,X ;GET OLD Y-COORD
	STA PLOTY    ;& STORE
	LDA #$00     ;SPECIFY OBJECT
	JSR OBJECT   ;& DRAW IT...
	LDX CELNUM   ;CELL # TO DRAW
	LDA CELLNX,X ;GET NEW X-COORD
	STA PLOTX    ;& STORE
	STA CELLOX,X ;
	LDA CELLNY,X ;GET NEW Y-COORD
	STA PLOTY    ;& STORE
	STA CELLOY,X ;
	LDA #1       ;SPECIFY COLOR
	STA COLOR    ;OF CELL
	LDA #0       ;SPECIFY OBJECT
	JSR OBJECT   ;& DRAW IT...
	RTS          ;ALL DONE...

*	CELL MOVER

OBJECT	ASL	A	;MULT OBJECT
	ASL	A	;INDEX BY 8
	ASL	A	;TO POINT INTO
	STA	SHAPIX	;SHAPE TABLE
	LDA	#8	;8 LINES MAX
	STA	SHAPCT	;IN SHAPE
DOBLP	LDX	SHAPIX	;GET LINE #
	LDY	OBJDIR,X;& ITS DIRECTION
	BMI	ENDOBJ	;IF $FF ALL DONE
	LDA	PXINC,Y	;GET X INCREMENT
	STA	XI
	LDA	PYINC,Y	;AND Y INCREMENT
	STA	YI
	LDA	OBJLEN,X;AND LINE LENGTH
	STA	LENGTH
PLOTOB	LDA	PLOTX	;INCREMENT
	CLC		;THE X
	ADC	XI	;COORDINATE
	STA	PLOTX	;AND SAVE
	LDA	PLOTY	;INCREMENT
	CLC		;THE Y
	ADC	YI	;COORDINATE
	STA	PLOTY	;AND SAVE
	LDA	SHAPCT	;FIRST LINE?
	CMP	#$08
	BEQ	NOPLT1	;DON'T PLOT IT!
	JSR	PLOTPT	;PLOT POINT
NOPLT1	LDA	LENGTH	;MORE LENGTH?
	BEQ	NOOBJ
	DEC	LENGTH	;DECREASE LENGTH
	BNE	PLOTOB	;YUP!
NOOBJ	INC	SHAPIX	;NEXT LINE
	DEC	SHAPCT	;DONE 8 LINES?
	BNE	DOBLP	;NOPE!
ENDOBJ	RTS		;FINIS!!!

*	SHAPE DATA

PXINC	DB	0,0,1,$FF,1,$FF,1,$FF
PYINC	DB	$FF,1,0,0,$FF,1,1,$FF

*	OBJECT SIDE LENGTHS

OBJLEN	DB	3,2,2,2,2,2,2,0
	DB	0,40,0,0,0,0,0,0
	DB	0,40,0,0,0,0,0,0
	DB	0,40,0,0,0,0,0,0
	DB	0,40,0,0,0,0,0,0
	DB	0,40,0,0,0,0,0,0
	DB	0,40,0,0,0,0,0,0
	DB	0,40,0,0,0,0,0,0
	DB	0,40,0,0,0,0,0,0

*	OBJECT SIDE DIRECTIONS

OBJDIR	DB	2,5,3,7,4,2,6,$FF
	DB	0,0,$FF,0,0,0,0,0
	DB	0,1,$FF,0,0,0,0,0
	DB	0,2,$FF,0,0,0,0,0
	DB	0,3,$FF,0,0,0,0,0
	DB	0,4,$FF,0,0,0,0,0
	DB	0,5,$FF,0,0,0,0,0
	DB	0,6,$FF,0,0,0,0,0
	DB	0,7,$FF,0,0,0,0,0

:COLRS	DB	$00,$55,$AA,$FF
:BMSK1	DB	$3F,$CF,$F3,$FC
:BMSK2	DB	$C0,$30,$0C,$03
:COLR1	DB	$40,$10,$04,$01
LOTBL	DS	192
HITBL	DS	192

CELLNY	DS 20 ;CELL NEW Y-COORD.
CELLOY	DS 20 ;CELL OLD Y-COORD.
GEVCEL	DS 20 ;CELL # BEING HEISTED.

* PRIMARY USE IN 'STRAT' ROUTINE

GEVFRE	DS 20 ;BACTERION! FIRE TIMERS
MOVET	DS 20 ;BACTERION! MOVE TIMERS
GEVDES	DS 20 ;DESIRED DIRECTION.
GEVDIR	DS 20 ;ACTUAL DIRECTION.
ATTACK	DS 20 ;ATTACKING PLAYER FLAG.
ESCAPE	DS 20 ;Y-COORD FOR ESCAPING.
STOP	DS 20 ;BACTERION! ICED FLAG.
GEVX	DS 20 ;BACTERION! X-COORD.
GEVY	DS 20 ;BACTERION! Y-COORD.
TARX	DS 20 ;BACTERION! TARGET-X.
TARY	DS 20 ;BACTERION! TARGET-Y.
LSRDIR	DS 20 ;LASER FIRING DIRECTION
LSRTME	DS 20 ;LASER LIFE TIMER.
LASERX	DS 20 ;LASER X-COORD.
LASERY	DS 20 ;LASER Y-COORD.

* PRIMARY USE IN 'DRAW' ROUTINE.

TYPE	DS 20 ;VESSEL TYPE.
PHASE	DS 20 ;VESSEL PHASE.
TYPES	DS 1  ;ATTACKING TYPE.

* PRIMARY USE IN 'SHOOT' ROUTINE.

SPEED	DS 20 ;SPEED A PLAYER MOVES.
CSPEED	DS 20 ;RAM COPY OF 'SPEED'
BULLET	DS 20 ;BULLET OWNER (0 OR 1)

	END	$2800