A.N.A.L.O.G. ISSUE 12 / JULY 1983 / PAGE 110

Livewire!

16K cassette 24K disk

by Tom Hudson

Before I start, I would like to thank all the readers who wrote letters to A.N.A.L.O.G. about my last assembly-language game, Fill ’Er Up! Your kind remarks certainly made all the hard work worthwhile. It is also gratifying to see all the reader-submitted modifications to the program. This is why A.N.A.L.O.G. contains assembly-language source code listings whenever possible — to challenge readers to go beyond what they read, and in the process, learn more about their computers.

This brings me to an important point: Even though A.N.A.L.O.G. prints commented assembly source code, space does not permit a complete discussion of a program’s inner workings. In order to do this, a documentation package similar to APX’s Source Code for Eastern Front (1941) would be needed. In such a package, the program author would provide in-depth documentation, memory maps, and so on.

If enough interest is shown, A.N.A.L.O.G. will publish a detailed documentation package for selected feature programs. If you would be interested in seeing such packages, just drop a postcard in the mail to me here at A.N.A.L.O.G. I welcome any comments or suggestions, such as the inclusion of the source files on a diskette, etc. There’s no obligation, of course — we’d just like to hear your opinions.

So much for introductions. Let’s get on to this issue’s public-domain game program, Livewire!

Typing the program.

Before you go hacking away at your keyboard, let’s take a quick look at the listings accompanying this article.

Listing 1 is the main data and data checking routine. This listing is used to create both the disk and cassette versions of Livewire!. As with Fill ’Er Up!, the data statements are listed in hexadecimal (base 16) to allow it to run in a 16K cassette system. It’s a necessary evil.

Listing 2 should be added to Listing 1 if you are using a 410 cassette recorder.

Listing 3 should be added to Listing 1 if you are using a disk drive.

Listing 4 is the assembly-language source code for Livewire!, created with the ATARI Macro Assembler. You DO NOT have to type in Listing 4 to play the game! It is provided for those readers interested in seeing how the program works.

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

Cassette Instructions

  1. Type Listing 1 into your computer. If you have C:CHECK (Issue 11), use it to verify your typing. This will save headaches later.
  2. After Listing 1 has been correctly typed into your computer, type in Listing 2. The program lines will automatically merge with Listing 1. Make sure these lines were typed correctly. It’s a good idea to CSAVE the entire program at this point.
  3. Type RUN and press RETURN. The program will begin checking the DATA lines, printing the line number as it checks each one. It will alert you if it finds any problems. Fix incorrect lines and re-RUN the program if necessary until all errors are eliminated.
  4. When all the data lines are correct, the program will ask you to “READY TAPE AND PRESS RETURN.” Place a blank tape in your recorder, press RECORD and PLAY simultaneously and press RETURN. The message “WRITING FILE” will appear and the program will create a boot tape version of Livewire!, printing each data line number as it goes. When the READY prompt reappears, you’re ready to load the game. Make sure your BASIC program has been CSAVEd before continuing.
  5. To play Livewire!, rewind the tape created by the BASIC program to the beginning. Turn your computer OFF and remove any cartridges. Press PLAY on your recorder, then turn your computer ON while holding down the START key. The computer will BEEP once. Press RETURN and Livewire! will load and run automatically.

Disk Instructions

  1. Type Listing 1 into your computer. If you have D:CHECK II (Issue 10), use it to verify your typing.
  2. After Listing 1 is correctly typed into your computer, type in Listing 3. The lines will automatically merge with Listing 1. It’s a good idea to SAVE the entire BASIC program after you’re done typing.
  3. Type RUN and press RETURN. The program will begin verifying the DATA lines, printing the line number as it checks each one. It will alert you if it finds any problems. Fix incorrect lines and re-RUN the program if necessary until all errors are eliminated.
  4. When all the data lines are correct, the program will ask you to “INSERT DISK WITH DOS, PRESS RETURN.” Place a disk with DOS m drive 1 and press RETURN. The message “WRITING FILE” will appear and the program will create an AUTORUN.SYS file, printing each data line number as it goes. When the READY prompt reappears, you’re ready to play the game. Make sure your BASIC program has been SAVEd before continuing.
  5. To play Livewire!, place the disk containing the AUTORUN.SYS file into drive 1 . Turn the computer OFF, remove any cartridges and turn the computer back ON. Livewire! will load and run automatically.

Playing the game.

It’s not every day that you get a chance to venture inside your computer. Prepare yourself, because Livewire! pits you against the horrible dangers that lurk inside that seemingly peaceful plastic enclosure.

In Livewire!, you are a logic probe on a mission to rid your computer of harmful electronic faults. You sit atop various circuit junctions (which just happen to spell “LIVEWIRE”) as the enemies of your computer climb up the circuit lines toward you. There are 64 levels in the game, each one more difficult than the last.

You can use either a joystick or paddle to play Livewire!, but a paddle is recommended. Choose the desired controller with the SELECT key, then press START to begin playing.

Use your controller to move along the rim of the circuit. Your controller button fires up to six deadly electron bursts at a time, which destroy the enemy electronic faults on contact. Keep alert, because the enemies can also fire electron bursts at YOU!

In a tight situation, the space bar will destroy all enemy objects on the circuit. Use this weapon wisely, as you are allowed only one use of the space bar “zap” per circuit grid.

Points are awarded for the destruction of each enemy object. The current score is shown at the lower left of the screen. You begin each game with 3 lives (shown to the right of the score), with bonus lives awarded every 20,000 points. The current level number is shown at the lower right of the screen.

The ESC key will pause the game at any time. Press the ESC key a second time to continue game play.

Know your enemy.

The enemies in Livewire! are not aliens, monsters or any other tangible threat. They are electronic impulses, out to systematically destroy your computer.

ARCS are clever objects which unpredictably jump from one circuit line to another. They are worth 50 points each.


SURGES rise up the circuit grid toward you, then change direction, heading back toward the buttom. If they are not destroyed before they hit the bottom, they create another ARC. SURGES are worth 100 points.


TRANSIENTS are nasty objects which appear and disappear at random as they rise up the circuit. When they are invisible, they cannot be destroyed by your electron bursts, but they can still destroy you! Be particularly careful if the transients become invisible near the top of the circuit. TRANSIENTS are worth 150 points.


VOLTAGE SPIKES aren’t particularly dangerous until they reach the top of the circuit. When they do, they turn into SHORTS, described below. If you destroy a VOLTAGE SPIKE before it reaches the top of the circuit, it is worth 200 points.


RESISTANCES are perhaps the most dangerous enemy of all. They CANNOT BE DESTROYED by electron bursts. In fact, any shots which hit them are immediately bounced back at the logic probe! The only way to destroy a RESISTANCE is to use the space bar “zap” feature. When destroyed, a RESISTANCE is worth 250 points.


SHORTS are started by VOLTAGE SPIKES when they reach the rim of the circuit. Up to 4 of these enemies may be present at one time. Shorts are different from other objects in that they follow the rim of the circuit at random. They will destroy you on contact, so be very cautious when they are present. SHORTS can only be destroyed by the space bar “zap” feature, and are worth 400 points.

Final Comments

Livewire! is a difficult game, but it can be mastered. Cautious players will last longer than “daredevils,” as is true with most games on the market today. I invite any comments, suggestions or modifications readers care to send in, and will be happy to print useful modifications in future issues.

Listing 1.

1 REM *** LIVEWIRE ***
10 DATA 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,10,11,12,13,14,15
20 DIM DAT$(91),HEX(22):FOR X=0 TO 22:READ N:HEX(X)=N:NEXT X:LINE=990:RESTORE 1000:TRAP 60:? "CHECKING DATA"
25 LINE=LINE+10:? "LINE:";LINE:READ DAT$:IF LEN(DAT$)<>90 THEN 110
28 DATLIN=PEEK(183)+PEEK(184)*256:IF DATLIN<>LINE THEN ? "LINE ";LINE;" MISSING!":END 
30 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)
35 IF PASS=2 THEN PUT #1,BYTE:NEXT X:READ CHKSUM:GOTO 25
40 TOTAL=TOTAL+BYTE:NEXT X:READ CHKSUM:IF TOTAL=CHKSUM THEN 25
50 GOTO 110
60 IF PEEK(195)<>6 THEN 110
100 ? "WRITING FILE":PASS=2:LINE=990:RESTORE 1000:TRAP 60:GOTO 25
110 ? "BAD DATA: LINE ";LINE:END 
1000 DATA 70F0704E00080E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E,1096
1010 DATA 0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E4E00100E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E,1778
1020 DATA 0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E,2408
1030 DATA 0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E80004703214100207070707070,3748
1040 DATA 70704763217070461321704723213046332170703046432141AF2048A5C68D0AD48D1DD0A5C58D00D4A9E98D00,8122
1050 DATA 02A9208D0102684048A90A8D0AD48D16D0A9748D17D0A9288D18D0A93D8D00D46840000000000000000000006C,11720
1060 DATA 766C000000212E212C2F2700232F2D303534292E27000000006C697665776972650000000000A2B90000B4AFAD,14340
1070 DATA 00A8B5A4B3AFAE0000000000EAEFF9F3F4E9E3EB000000000000000000F0E1E4E4ECE500000000000000000000,18671
1080 DATA 0000000000000000000000D82065E4A900A27F9580CA10FBA90185A585A4A9438DCA20A9218DCB20A9008D2F02,22765
1090 DATA 8D0ED48D08D28D1ED08DC802A2039D582ECA10FAA2059D682ECA10FAA20295D895DBCA10F9A2079D0C2ECA10FA,28295
1100 DATA A205BD03219D6821CA10F7A91DA2059D862ECA10FA208D25208A26A90685BEA90285D085C8202C26A90585B8A9,33151
1110 DATA 0A85B9A9AF8D3002A9208D3102A0EBA228A907205CE4A9008D07D4208B2CA9748DC402A9C48DC502A90A8DC602,38125
1120 DATA A9348DC702A93D8D2F02A9038D1DD0A9C08D0ED4A9118D6F02A90F8DC1028DC2028DC302A9168DC002AD1FD029,43000
1130 DATA 01D00AAD1FD02901F0F94C7B22AD1FD02902D0E8A5CE186901290185CEAABD912F8DCA20BD932F8DCB20A91E20,48088
1140 DATA 83264C4522A9008D3002A9208D3102A90085A4A901858485B220A12CA5C72907AABDB42D85CC203826209B26A5,52487
1150 DATA B1D0FCA5BDF00320AF25854DA5B6D0038D01D0A5A9D075A5CD85A9A205BD682E9D6E2EA9009D682ECA10F2A5DE,58556
1160 DATA F00985DC205A25A90085DEA205A90015E5CA10FBA20415DFCA10FBC900F04DA205B5E5D031AD0AD22907C905B0,63950
1170 DATA F7A8B9DF00F02238E90199DF00989D742EAD0AD2290FC90FF0F79D802EA91E9D862EA9019D7A2E95E5CA10C820,69526
1180 DATA 5B23202C25AD1FD0C907F0034C73214CA222A5C7C93FF01618690185C72907D004E6E4E6E4F8A5A518690185A5,74658
1190 DATA D84C8922A5AA186901C906D005A9FF85AA6085AAA6AAB5E5F0EABD862EC9029039AD0AD2290FD032AD0C2ED004,80275
1200 DATA A000F007AD0D2ED024A001BD862E4A992C2EBD802E991C2E0A0A0A0A99242EA9FF99142EA91585D1A901990C2E,84426
1210 DATA A9008584207924A6AABD6E2EF01A205526A6AABC742EB94E2E85DCB9532E85DD205A25A6AA4C2724BD862E38FD,89491
1220 DATA 7A2E9D862E3042C91ED004E6E1D03AC90AD00CBD742EC903D005A9FF9D7A2EBD742EC902D014AD0AD22901A8BD,94796
1230 DATA 802E18792731C90FB0039D802EBD742EAABD8C2E85842079244C5B23A90095E5A91585D2BD862E1042BD802EC5,99572
1240 DATA 95D006A90185BDD035BD742EC901D02EA003B9582EF0058810F83022BD802E0A0A0A0A186908995C2EA9019958,103946
1250 DATA 2EAD0AD2290199602EAD0AD2293F99642E4C5B23A6AABD802E0A0A0A0A85B0BD862E4AB0151865B0A8B9A03185,108404
1260 DATA 8285B3B9A032858385B44CBB241865B0A8B9A0311879A1316A858285B3B9A0321879A1326A858385B4A91E38FD,113958
1270 DATA 862E4A29FE0A0AA8A200B9012F9D912EC8E8E008D0F4A6AABD742E0A0A0A85ABA90885AFA6ABBDB12EA83040B9,119274
1280 DATA 992E85ADB9A12E85AEBDD92EA8B9912E85ACA5821865AD8582A5831865AE8583A5ABF00320BC2CA5831865AE85,125065
1290 DATA 83A5ABF00320BC2CC6AC10D9E6ABC6AFD0B860A203BD582EF023BC602EBD5C2E18792531C9F0B0089D5C2EDE64,130797
1300 DATA 2E100DAD0AD2293F9D642E29019D602ECA10D560A000F8A5DA1865DD85DA84DDA5D965DC85D984DCA5D865DB85,136620
1310 DATA D884DBD8208D25A5D8C5D0D00C20A325F8A5D0186902D885D060A91085A6A200A000B9D800204026E8E8C8C003,142456
1320 DATA D0F360A5C8C905F005E6C8202C2660208A26A207A9001D0C2ECAD0FAC900D0F2A2039D582ECA10FAA9008584A9,147930
1330 DATA 0585AA207924A6AAA91E9D862EA9019D7A2EAD0AD2290FC90FF0F79D802EC6AA10E1A90F8DC0028D01D2AD0AD2,153150
1340 DATA 291F8D00D2A906208326CEC002ADC0028D01D2D0E8A5C8F014C6C8202C26A93C208326A90085BDA9168DC00260,158188
1350 DATA 68684C7321A99085A6A5C8A20720402660A05084A6A5A5A20E85A7290F05A69D0421A5A74A4A4A4A05A69D0321,162753
1360 DATA 60A4B5A900A20E990005C8CAD0F9A5B318693D8D01D0A5B418691AA884B5A20DBD402E990005C8CA10F6A90185,168020
1370 DATA B66085A3A5A3D0FC60A90085D185D285D3A2079D00D2CA10FA60A90185A4208A26A92085C5A90085C6A2039D58,173892
1380 DATA 2ECA10FAA2079D0C2ECA10FA208B2C8593A90685BEA5C74A4A4AAABDBC2D8DC402BDC42D8DC502BDCC2D8DC602,179317
1390 DATA BDA92E85CDA5C72907AABDD42D85DFBDDC2D85E0BDE42D85E1BDEC2D85E2BDF42D85E3A204B5DF1865E495DFCA,186238
1400 DATA 10F6A5CC0A0A0A0A85C985CAAAA91085CBBD952F8582BDF52F8583BD55308585BDB5308586ADC402F00620BC2C,191816
1410 DATA 201F2DC6CBF007E6CAA6CA4C1927A6C986CAA90F85CBBD952F8582BDF52F8583BD962F85851865826A8590BDF6,197853
1420 DATA 2F85861865836A8591A90F38E5CB859220BE28ADC402F00620BC2C201F2DC6CBF007E6CAA6CA4C4B27A6C986CA,203350
1430 DATA A90F85CB8593BD55308582BDB5308583BD563085851865826A8590BDB63085861865836A8591A90F38E5CB8592,208921
1440 DATA 20BE28ADC402F00620BC2C201F2DC6CBF007E6CAA6CA4C9527A9008597AABDA0318D8F31BDAF318D9F31207728,214191
1450 DATA A697A000B98F319DA031E8C8C010D0F4A697BDA0328D8F31BDAF328D9F31207728A697A000B98F319DA032E8C8,220159
1460 DATA C010D0F4A697BDA0338D8F31BDAF338D9F31207728A697A000B98F319DA033E8C8C010D0F4A697BDA0348D8F31,226189
1470 DATA BDAF348D9F31207728A697A000B98F319DA034E8C8C010D0F4A5971869108597C9F0F0034CD927A93D85C5A903,231953
1480 DATA 85C6A90085A460A910859A85994A859BA9008598A698BD8F31A699187D8F316AA69B9D8F31A59818659A859865,237537
1490 DATA 9AC911B00C8599A59B18659A859B4C8428A59A4A859A85994AF005859B4C802860A5920A0A0A0A186593AAA590,242533
1500 DATA 9DA031A5919DA032A593D014A5829DA033A5839DA034A5859DAF33A5869DAF3460A9CF8D0002A9208D0102D8A5,248149
1510 DATA A9F002C6A9A5A3F002C6A3A5B6F002C6B6A5BDF0034C002BA5A4F0034C62E4ADFC02C91CD009A5B149FF85B14C,254446
1520 DATA 5229C921D028A5B2F024C6B2A205A9019D682ECA10FAA203BD582EF00EA5DEF818690485DED8A9009D582ECA10,259917
1530 DATA EAA9008DFC02A5B1F011A9008D01D28D03D28D05D28D07D24C62E4A5D1F010C6D1A6D1BD3E318D02D2BD29318D,265790
1540 DATA 03D2A5D2F010C6D2A6D2BD68318D04D2BD53318D05D2A5D3F010C6D3A6D3BD86318D06D2BD7D318D07D2ADC202,272029
1550 DATA 1869108DC2028DC30229FC8DC702C6BFD017AD902ED004A902D002A9008D902EAD0AD2091F293F85BFE6BCA5BC,277192
1560 DATA C903D00AA90085BCE6B7E6B8E6B9A59DF005C69D4C312AA904859DA5CEF006AD7C024C002AAD8402D02FA5BEF0,283089
1570 DATA 2BA207BD0C2EF003CAD0F8C6BEA9019D0C2EA91585D1A9009D2C2EA5959D1C2E0A0A0A0A9D242EA9019D142EA5,287552
1580 DATA CEF00FAD70024A4A4A4AC90F3022A90ED01EA594F005C6944C002BA9028594AE7802A595187DFC2D3004C90FD0,292322
1590 DATA 02A595C595F006A20986D385950A0A0A0AAAAD0CD0290CF007A90185BD4C852CBDA03118693D8D00D0A496BDA0,297276
1600 DATA 321869208596A900A20F99F803C8CA10F9A90F85BAA90085BBA5B7290FAAA5BADD712F900BDD812FB006AABD41,302643
1610 DATA 2F85BBA5B8290FAAA5BADD712F900DDD812FB008AABD512F05BB85BBA5B9290FAAA5BADD712F900DDD812FB008,308100
1620 DATA AABD612F05BB85BBA5961865BA38E908A8A5BB990004C6BA10A1A5A2F005C6A24C0F2BE6A1A90185A2E6A0A5A0,313913
1630 DATA 2901A8B9362E859EBE342E869CA903859FBD0C2ED0034CE32BA69FB4D4B9FF023D3C2E99FF02B900033D3C2E99,318789
1640 DATA 0003B901033D3C2E990103A69CA5A12901D00ABD2C2E187D142E9D2C2EBD142E3043A005B9682ED039B9E500F0,322743
1650 DATA 34B9742EC904D005AD902EF028B9802EDD1C2ED020B9862E4A38FD2C2EF004C9FE9012B9742EF008A90199682E,327864
1660 DATA 4CF02BA9FF9D142E8810BFBD2C2EF046C910F042187D242EAABDA031BCA032186940A69F9D04D098186920A894,333038
1670 DATA D4B9FF021D382E99FF02B900031D382E990003B901031D382E990103C69FC69CA69CE49EF0264C242BA9009D0C,337375
1680 DATA 2EE0029002E6BEBD2C2ED010BD142E100BBD1C2EC595D004A90185BD4CE32BE6C2A5C24A2901A8B9233185C4A5,342487
1690 DATA C22901A8A90785C1A90085C0A90185C3B91531859CA900A6C3BC1731A20991C0C8CA10FAA69CBD582EF02EBD5C,348107
1700 DATA 2EAABDA033BCA03418693EA6C39D02D09818691C9D1731A8A6C4A90485CFBD193191C0C891C0C8CAC6CF10F2C6,354023
1710 DATA C33007C6C1E69C4C362C8D1ED04C62E4A900AA9D00039D00049D00059D00069D0007CAD0EE60A9088581A90085,358639
1720 DATA 80A214A00098918088D0FBCAD00160E6814CAB2CA5830A8580A9002A8581068026810680268106802681068026,363401
1730 DATA 81A9001865808580A90865818581A5822903AAA5824A4A85A8A8B1803D172DDD1B2DF015A484BD172D390F2D85,368094
1740 DATA 8FBD132DA4A83180058F9180600055AAFF3FCFF3FCC0300C0340100401A586C583900B38E583858AA901858CD0,373251
1750 DATA 0BA58338E586858AA9FF858CA585C582900B38E5828589A901858BD00BA58238E5858589A9FF858BA900858885,379321
1760 DATA 87A589C58A900A858D858E4A85884C762DA58A858D858E4A8587A58DF039A58818658A8588C58E900EA58838E5,385091
1770 DATA 8E8588A58318658C8583A5871865898587C58E900EA58738E58E8587A58218658B858220BC2CC68DD0C7600001,390578
1780 DATA 020304010503C43674F654060026860C365626C698189846A8368418C638000000000406080A0000000608090A,392949
1790 DATA 0B080A0C0E1012141606080A0B0C0E0F10000004080A0C0E10000000000001010100FFFFFF0000000000000000,394004
1800 DATA 0000000000000000000000000000000000000000000000000000000000000000000000000307FF03030C30C0FC,394779
1810 DATA F3CF3F282828925428101028549228282802020001015000500050000000000000000000000000000000000000,396350
1820 DATA 000000000000000000000000000000000000000000000000000000000000000000000203020302000000000000,396362
1830 DATA 0000000001FF01FF01FFFF010000FF0101FF120F0E0C0B0A0907040301020005FF000405000600FF0000000506,398545
1840 DATA 040701FF00060003010207FF0004060507050604FF030707070707000003070707070000000303030303070000,399469
1850 DATA 020303030303000001010103010103000000000000010101000000010102020200000101010202020001010202,399523
1860 DATA 020203000101020202030301020202020203030102020203030304010202030303040410101010101010100808,399747
1870 DATA 080808080808000000008040201008040201000000000000010102020408102040408080000000010203040506,400521
1880 DATA 07080706050403020111100F0E0D0C0B0A090A0B0C0D0E0F10435321210E0E0E0E0E0E0E0E1A2733404B586471,401656
1890 DATA 0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E141A20262B313B454E54595F656B71715840270E0E0E1B1B0E0E0E27,403378
1900 DATA 4058710E0E0E0E0E1D2B3A4654627171717171716A64717164524130200E0E0E0E0E0E1222344658697B8D8D8D,406529
1910 DATA 8D8D8D8D8D8D1219222A323A434B535B646C747D858D12273B5065798D8D8D8D7965503B271212121212122335,410219
1920 DATA 47596A7C8D8D8D8D8D1231506F8D847B72727B848D6F5031128D6E503D261212121212122B445C758D37373737,414069
1930 DATA 373737373A3C3E40424446493737373737373737373737373737373737393A3B3B3C3D3F414344454546474949,416787
1940 DATA 44403C37373739393737373C40444937373737373A3D3F414346494949494949484649494643403D3A37373737,419613
1950 DATA 373743474A4D5154575A5A5A5A5A5A5A5A5A3C3E414447494C4E515356595C5E616343494D5054585A5A5A5A58,423265
1960 DATA 54504D49434343434343474A4D5053565A5A5A5A5A434A50565A5957565657595A56504A435A55504B47434343,426822
1970 DATA 434343494E52565A0002000088502050882020F82020040902FE01FF00A1A1A2A2A3A3A4A4A5A5A6A6A7A7A8A8,431431
1980 DATA A9A9AAAA00C2A6B498A68A987C8A6E7C606E52604452364428004141424243434444454546464747484849494A,435765
1990 DATA 4A0050287850A078C8A0F0C818F0401868409068CC9000A1A1A2A2A3A3A4A400141E141E141E141E0000000000,439855

CHECKSUM DATA
(See p.46)

1 DATA 2,955,686,427,745,192,617,894,445,496,549,150,272,322,389,7141
1030 DATA 993,671,946,775,962,932,662,276,400,422,663,103,693,416,588,9496
1180 DATA 176,598,508,578,666,412,121,344,64,519,438,515,463,28,305,5735
1330 DATA 390,169,936,204,236,668,846,422,616,396,89,494,357,417,326,6566
1480 DATA 274,201,274,482,387,131,433,351,554,524,200,303,292,583,336,5325
1630 DATA 439,58,287,349,291,241,358,401,262,869,113,126,272,395,135,4597

Listing 2.

2 REM *** CASSETTE VERSION ***
65 IF PASS=2 THEN CLOSE #1:END 
70 ? "READY CASSETTE AND PRESS RETURN";:OPEN #1,8,128,"C:":RESTORE 200:FOR X=1 TO 35:READ N:PUT #1,N:NEXT X
200 DATA 0,36,221,31,255,31,169,60,141,2,211,169,0,141,231,2,133,14,169,56,141,232,2,133,15,169,115
210 DATA 133,10,169,33,133,11,24,96
2000 DATA 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,439855
2010 DATA 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,439855

Listing 3.

2 REM *** DISK VERSION ***
65 IF PASS=2 THEN PUT #1,224:PUT #1,2:PUT #1,225:PUT #1,2:PUT #1,115:PUT #1,33:CLOSE #1:END 
70 ? "INSERT DISK WITH DOS, PRESS RETURN";:DIM IN$(1):INPUT IN$:OPEN #1,8,0,"D:AUTORUN.SYS"
90 PUT #1,255:PUT #1,255:PUT #1,0:PUT #1,32:PUT #1,142:PUT #1,49

Listing 4.

;	===========================
;		      LIVEWIRE
;	===========================

;	===========================
;	  WRITTEN BY: TOM HUDSON
;	A.N.A.L.O.G. COMPUTING #12
;	===========================

;	---------------
;	PAGE ZERO USAGE
;	---------------

	ORG	$80

LO	DS	1
HI	DS	1
PLOTX	DS	1	;PLOT X VALUE
PLOTY	DS	1	;PLOT Y VALUE
COLOR	DS	1	;PLOT COLOR
DRAWX	DS	1	;DRAWTO X
DRAWY	DS	1	;DRAWTO Y
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	;DRAW ENDPOINT
HOLD	DS	1	;WORK AREA
XWORK	DS	1
YWORK	DS	1
GRID	DS	1	;GRID # WORK
OFFSET	DS	1	;GRID OFFSET
PMTIME	DS	1	;PLAYER MOVE TIMER
PLRGRD	DS	1	;PLAYER GRID#
PLRY	DS	1	;PLAYER Y POS.
GRIDNO	DS	1	;GRID #
LAST	DS	1	;GRID...
NEXT	DS	1	;DIVIDE...
STEP	DS	1	;WORK...
DEST	DS	1	;AREAS
VBXHLD	DS	1	;X HOLD
PFTIME	DS	1	;PLAYER FIRE TIMER
ENDVAL	DS	1	;WORK AREA
MISNUM	DS	1	;MISSILE #
PRFLIP	DS	1	;PROJ. FLIP FLAG
PRADVT	DS	1	;PROJ. MOVE TIMER
PRADV1	DS	1	;PROJ. TIMER
TIMER	DS	1	;GENERAL TIMER
INTRFG	DS	1	;INTRO FLAG
BCDLVL	DS	1	;LEVEL #
SHCOLR	DS	1	;CHAR. COLOR
SHOBYT	DS	1	;CHAR. BYTE POS.
YOFSET	DS	1	;PLOT Y OFFSET
OBTIM1	DS	1	;OBJECT MOVE TIMER
OBJNUM	DS	1	;OBJECT #
SHAPIX	DS	1	;OBJ. SHAPE INDEX
LENGTH	DS	1	;OBJ. LENGTH
XI	DS	1	;OBJ. X INCREMENT
YI	DS	1	;OBJ. Y INCREMENT
SHAPCT	DS	1	;OBJ. SHAPE CNT.
HLDGRD	DS	1	;OBJ. GRID WORK
PAUFLG	DS	1	;PAUSE FLAG
ZAP	DS	1	;ZAP FLAG
SAVEX	DS	1	;WORK AREA
SAVEY	DS	1	;WORK AREA
FLASHY	DS	1	;OBJ. FLASH POS.
FLTIME	DS	1	;FLASH TIME
SP1IX	DS	1	;PLAYER...
SP2IX	DS	1	;SHAPE...
SP3IX	DS	1	;INDEX...
SPIX	DS	1	;AREAS
PLTBYT	DS	1	;PLYR. IMAGE BYTE
PSCNT	DS	1	;PLYR. SHAPE COUNT
KILPLR	DS	1	;KILL PLYR FLAG
PAVAIL	DS	1	;# PROJ. AVAILABLE
TRANTM	DS	1	;TRANSIENT TIMER
DESTLO	DS	1	;DESTINATION...
DESTHI	DS	1	;ADDRESS
SHFLIP	DS	1	;SHORT FLIP FLAG
DESTNM	DS	1	;SHORT PLYR #
CPYST	DS	1	;SHORT IMAGE START
DMAC1	DS	1	;DMA CTRL WORK
GRAC1	DS	1	;GRAPHICS CTRL WK.
GRIDIX	DS	1	;GRID INDEX
LIVES	DS	1	;LIVES LEFT
GRDADJ	DS	1	;GRID...
GRDWK	DS	1	;DRAW...
GRDWK2	DS	1	;WORK...
GRDNUM	DS	1	;AREAS
OBJSPD	DS	1	;OBJ. SPEED
JOYPAD	DS	1	;STICK/PADDLE
CPYCNT	DS	1	;SHORT COPY CNT.
BONUS	DS	1	;BONUS VALUE
FIRSOU	DS	1	;FIRE SOUND COUNT
OBDSOU	DS	1	;OBJ. DEATH SOUND
MOVSOU	DS	1	;PLYR MOVE SOUND
PRYHLD	DS	4	;PROJ. Y HOLDS
SCORE	DS	3	;SCORE
SCOADD	DS	3	;SCORE ADD VALUE
MISCAD	DS	1	;MISC. SCORE ADD
NUMOBJ	DS	5	;OBJECTS LEFT
DIFF	DS	1	;DIFFICULTY ADJUST
OBJPRS	DS	6	;OBJ PRESENT FLAGS

;	--------------------
;	MISCELLANEOUS MEMORY
;	--------------------

PMAREA	=	$0000	;P/M AREA
MISSLS	=	PMAREA+768
PL0	=	PMAREA+1024
PL1	=	PMAREA+1280
PL2	=	PMAREA+1536
PL3	=	PMAREA+1792
DISP	=	$0800	;DISPLAY

;	--------------
;	SYSTEM EQUATES
;	--------------

VDSLST	=	$200	;DLI VECTOR
WSYNC	=	$D40A	;WAIT/SYNC
PTRIG0	=	$27C	;PADDLE TRIG.
POT0	=	$270	;PADDLE 0
KEY	=	$2FC	;KEYBOARD
CONSOL	=	$D01F	;CONSOLE BUTTONS
PMBASE	=	$D407	;P/M BASE ADDR
RANDOM	=	$D20A	;RANDOM #
SETVBV	=	$E45C	;VBLANK SET
XITVBV	=	$E462	;VBLANK EXIT
COLBK	=	$2C8	;COLORS
COLPF0	=	$2C4
COLPF1	=	$2C5
COLPF2	=	$2C6
COLPF3	=	$2C7
AUDC1	=	$D201	;AUDIO CONTROL
AUDC2	=	$D203
AUDC3	=	$D205
AUDC4	=	$D207
AUDF1	=	$D200	;AUDIO FREQUENCY
AUDF2	=	$D202
AUDF3	=	$D204
AUDF4	=	$D206
AUDCTL	=	$D208	;MAIN AUDIO CTRL.
PRIOR	=	$026F	;PRIORITY
ATTRAC	=	$4D	;ATTRACT MODE
DMACTL	=	$22F	;DMA CONTROL
DLISTL	=	$230	;DISP. LIST
GRACTL	=	$D01D	;GRAPHICS CTRL.
NMIEN	=	$D40E	;INTERRUPT ENABLE
COLPM0	=	$2C0	;PLAYER COLORS
COLPM1	=	$2C1
COLPM2	=	$2C2
COLPM3	=	$2C3
HPOSP0	=	$D000	;PLAYER POSITIONS
HPOSP1	=	$D001
HPOSP2	=	$D002
HPOSP3	=	$D003
HPOSM0	=	$D004	;MISSILE POSITIONS
HITCLR	=	$D01E	;COLLISION CLEAR
P0PL	=	$D00C	;PL0 TO PLAYER COLL.
STICK	=	$278	;JOYSTICK
STRIG	=	$284	;STICK TRIGGER

	ORG	$2000

;	----------------------
;	MAIN GAME DISPLAY LIST
;	----------------------

DLIST	DB	$70,$F0,$70,$4E
	DW	DISP
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E
	DB	$4E
	DW	DISP+$800
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E,$E
	DB	$E,$E,$E,$E,$E,$E,$E
	DB	$80,$00
	DB	$47
	DW	INFOLN
	DB	$41
	DW	DLIST

;	-------------------------
;	TITLE SCREEN DISPLAY LIST
;	-------------------------

TITLDL	DB	$70,$70,$70,$70,$70,$70
	DB	$70,$47
	DW	LASTSC
	DB	$70,$70,$46
	DW	MAGMSG
	DB	$70,$47
	DW	TITLE
	DB	$30,$46
	DW	AUTHOR
	DB	$70,$70,$30,$46
CONTRL	DW	JOYMSG
	DB	$41
	DW	TITLDL

;	-----------------------
;	DISPLAY LIST INTERRUPTS
;	-----------------------

DLI1	PHA		;SAVE ACCUM
	LDA	GRAC1	;GET GR. CTRL
	STA	WSYNC	;WAIT FOR SYNC
	STA	GRACTL	;STORE IT
	LDA	DMAC1	;GET AND SAVE
	STA	$D400	;DMA CTRL
	LDA	#DLI2&255	;POINT...
	STA	VDSLST	;TO...
	LDA	#DLI2/256	;NEXT...
	STA	VDSLST+1	;DLI!
	PLA		;GET ACCUM
	RTI		;AND EXIT!

DLI2	PHA		;SAVE ACCUM
	LDA	#$0A	;GET WHITE
	STA	WSYNC	;WAIT FOR SYNC
	STA	$D016	;PUT IN COLOR 0
	LDA	#$74	;PUT BLUE...
	STA	$D017	;IN COLOR 1
	LDA	#$28	;PUT ORANGE...
	STA	$D018	;IN COLOR 2
	LDA	#$3D	;SET UP...
	STA	$D400	;DMA CTRL
	PLA		;GET ACCUM.
	RTI		;AND EXIT

;	---------------
;	SCREEN MESSAGES
;	---------------

INFOLN	DB	0,0,0,0,0,0,0,0
	DB	0,0,$6C,$76,$6C,0,0,0
MAGMSG	DB	$21,$2E,$21,$2C,$2F,$27
	DB	0,$23,$2F,$2D,$30,$35
	DB	$34,$29,$2E,$27
TITLE	DB	0,0,0,0,$6C,$69,$76,$65
	DB	$77,$69,$72,$65,0,0,0,0
AUTHOR	DB	0,$A2,$B9,0,0,$B4,$AF
	DB	$AD,0,$A8,$B5,$A4,$B3
	DB	$AF,$AE,0
JOYMSG	DB	0,0,0,0,$EA,$EF,$F9,$F3
	DB	$F4,$E9,$E3,$EB,0,0,0,0
PADMSG	DB	0,0,0,0,0,$F0,$E1,$E4
	DB	$E4,$EC,$E5,0,0,0,0,0
LASTSC	DB	0,0,0,0,0,0,0,0
	DB	0,0,0,0,0,0,0,0

;	----------
;	PROG START
;	----------

LIVE	CLD
	JSR	$E465	;INIT SOUND
	LDA	#0	;CLEAR PAGE 0
	LDX	#127
CPAGE0	STA	$80,X
	DEX
	BPL	CPAGE0
	LDA	#1	;INIT...
	STA	BCDLVL	;LEVEL #
	STA	INTRFG	;SET INTRO FLAG
	LDA	#JOYMSG&255	;DEFAULT...
	STA	CONTRL	;CONTROL...
	LDA	#JOYMSG/256	;IS...
	STA	CONTRL+1	;STICK!
	LDA	#0	;INIT...
	STA	DMACTL	;DMA
	STA	NMIEN	;INTERRUPTS
	STA	AUDCTL	;AUDIO
	STA	HITCLR	;COLLISION
	STA	COLBK	;BACKGND COLOR
	LDX	#3	;CLEAR SHORTS
CLRSHO	STA	SHORTF,X
	DEX
	BPL	CLRSHO
	LDX	#5	;ZERO OBJECT...
CLRDED	STA	OBDEAD,X	;CLR DEAD TABLE
	DEX
	BPL	CLRDED
	LDX	#2	;ZERO SCORE
CLRSCO	STA	SCORE,X
	STA	SCOADD,X
	DEX
	BPL	CLRSCO
	LDX	#7
CLRPRJ	STA	PROJAC,X	;CLEAR PROJ.
	DEX
	BPL	CLRPRJ
	LDX	#5
MOVSCO	LDA	INFOLN,X	;COPY SCORE...
	STA	LASTSC+5,X	;TO LAST...
	DEX		;SCORE LINE
	BPL	MOVSCO
	LDA	#29	;SET ALL...
	LDX	#5	;OBJECTS TO...
INIOBS	STA	OBJSEG,X	;SEGMENT # 29
	DEX
	BPL	INIOBS
	JSR	SHOSCO	;SHOW SCORE
	JSR	SNDOFF	;NO SOUNDS
	LDA	#6	;6 PROJECTILES
	STA	PAVAIL	;AVAILABLE
	LDA	#2	;SET...
	STA	BONUS	;BONUS=20000
	STA	LIVES	;2 EXTRA LIVES
	JSR	SHOLIV	;SHOW LIVES LEFT
	LDA	#5	;SET UP...
	STA	SP2IX	;PLAYER...
	LDA	#10	;SHAPE...
	STA	SP3IX	;INDEXES
	LDA	#TITLDL&255	;POINT TO...
	STA	DLISTL	;TITLE...
	LDA	#TITLDL/256	;DISPLAY...
	STA	DLISTL+1	;LIST
	LDY	#VBI&255	;POINT TO...
	LDX	#VBI/256	;VERTICAL...
	LDA	#7	;BLANK...
	JSR	SETVBV	;INTERRUPT
	LDA	#PMAREA/256	;SET UP P/M...
	STA	PMBASE	;BASE ADDRESS
	JSR	PMCLR	;CLEAR P/M
	LDA	#$74	;PUT BLUE...
	STA	COLPF0	;IN COLOR 0
	LDA	#$C4	;PUT GREEN...
	STA	COLPF1	;IN COLOR 1
	LDA	#$0A	;PUT WHITE...
	STA	COLPF2	;IN COLOR 2
	LDA	#$34	;PUT RED...
	STA	COLPF3	;IN COLOR 3
	LDA	#$3D	;SET UP...
	STA	DMACTL	;DMA,
	LDA	#3	;GRAPHICS,
	STA	GRACTL	;AND
	LDA	#$C0	;INTERRUPT...
	STA	NMIEN	;ENABLE
	LDA	#$11	;SET P/M...
	STA	PRIOR	;PRIORITY
	LDA	#$0F	;PUT WHITE...
	STA	COLPM1	;IN PLAYER 1,
	STA	COLPM2	;PLAYER 2
	STA	COLPM3	;AND 3
	LDA	#$16	;PUT YELLOW...
	STA	COLPM0	;IN PLAYER 0

;	------------
;	INTRO SCREEN
;	------------

INTRO	LDA	CONSOL	;START KEY...
	AND	#1	;PRESSED?
	BNE	CKSEL	;NO!
GOCHEK	LDA	CONSOL	;START KEY...
	AND	#1	;RELEASED?
	BEQ	GOCHEK	;NO, WAIT.
	JMP	DIGIN	;GO DIG IN!!
CKSEL	LDA	CONSOL	;SELECT KEY...
	AND	#2	;PRESSED?
	BNE	INTRO	;NAW, LOOP BACK.
	LDA	JOYPAD	;TOGGLE...
	CLC		;STICK/PADDLE...
	ADC	#1	;INDICATOR...
	AND	#1
	STA	JOYPAD
	TAX
	LDA	JPLO,X	;AND SHOW...
	STA	CONTRL	;CONTROLLER...
	LDA	JPHI,X	;MESSAGE...
	STA	CONTRL+1	;ON SCREEN!
	LDA	#30	;30 JIFFY...
	JSR	WAIT	;WAIT!
	JMP	INTRO	;AND LOOP.

;	---------------------------
;	HERE'S WHERE PROGRAM STARTS
;	---------------------------

DIGIN	LDA	#DLIST&255	;POINT TO...
	STA	DLISTL	;GAME...
	LDA	#DLIST/256	;DISPLAY...
	STA	DLISTL+1	;LIST
	LDA	#0	;NO LONGER IN...
	STA	INTRFG	;INTRO
FOREVR	LDA	#1	;WE WANT...
	STA	COLOR	;COLOR 1
	STA	ZAP	;RESET ZAP.
	JSR	CLRSC	;CLEAR SCREEN
	LDA	GRIDIX	;GET GRID#
	AND	#7	;FIND WHICH...
	TAX		;GRID SHAPE...
	LDA	GRDTBL,X	;TO DRAW...
	STA	GRDNUM	;AND STORE
	JSR	SHOLVL	;SHOW LEVEL#
	JSR	DRGRID	;DRAW GRID!
CONWT	LDA	PAUFLG	;WE PAUSED?
	BNE	CONWT	;YUP, LOOP.
	LDA	KILPLR	;PLAYER DEAD?
	BEQ	PLIVE	;NOPE!
	JSR	DECLIV	;ONE LESS LIFE!
PLIVE	STA	ATTRAC	;CANCEL ATTRACT!
	LDA	FLTIME	;FLASH GOING?
	BNE	NOFEND	;YES! STORE...
	STA	HPOSP1	;FLASH POSITION!
NOFEND	LDA	OBTIM1	;OBJECTS MOVING?
	BNE	NOOHAN	;NOT YET!
	LDA	OBJSPD	;RESET MOVE...
	STA	OBTIM1	;TIMER

;	----------------------
;	COPY OBJECT KILL TABLE
;	----------------------

	LDX	#5	;THIS SECTION
COPDED	LDA	OBDEAD,X	;COPIES THE
	STA	OBDED2,X	;OBJECT KILL
	LDA	#0	;TABLE WHICH IS
	STA	OBDEAD,X	;SET UP BY THE
	DEX		;PROJECTILE
	BPL	COPDED	;HANDLER

	LDA	MISCAD	;MISC.SCORE?
	BEQ	NOMSCO	;NO!
	STA	SCOADD+1	;SET SCORE ADD...
	JSR	ADDSCO	;AND ADD IT!
	LDA	#0	;THEN RESET THE
	STA	MISCAD	;ADD VALUE.
NOMSCO	LDX	#5	;THIS SECTION
	LDA	#0	;TALLIES ALL
CKOBLV	ORA	OBJPRS,X	;OBJECTS THAT
	DEX		;ARE ALIVE
	BPL	CKOBLV
	LDX	#4	;NOW TALLY
CKOBWT	ORA	NUMOBJ,X	;ALL OBJECTS
	DEX		;THAT ARE NOT
	BPL	CKOBWT	;ON GRID YET
	CMP	#0	;ANY OBJECTS?
	BEQ	LVLEND	;NO, END OF LEVEL!

	LDX	#5	;IS OBJECT
GENNOL	LDA	OBJPRS,X	;PRESENT?
	BNE	NXTOGN	;YES, TRY NEXT.
TRYTYP	LDA	RANDOM	;LET'S TRY TO
	AND	#7	;START UP A
	CMP	#5	;NEW OBJECT
	BCS	TRYTYP	;GET A TYPE
	TAY		;ANY OF THAT
	LDA	NUMOBJ,Y	;TYPE WAITING?
	BEQ	NXTOGN	;NO, TRY NEXT
	SEC		;DECREMENT #
	SBC	#1	;OF OBJECTS
	STA	NUMOBJ,Y	;WAITING.
	TYA		;THEN SET
	STA	OBJTYP,X	;OBJECT TYPE.
NEWGRD	LDA	RANDOM	;GET A RANDOM
	AND	#$0F	;SUB-GRID
	CMP	#15	;NUMBER
	BEQ	NEWGRD
	STA	OBJGRD,X	;AND SAVE IT
	LDA	#30	;PUT OBJECT AT
	STA	OBJSEG,X	;FAR END OF GRID
	LDA	#1	;SET UP...
	STA	OBJINC,X	;OBJ. INCREMENT
	STA	OBJPRS,X	;OBJECT PRESENT
NXTOGN	DEX		;LOOP BACK TO DO
	BPL	GENNOL	;NEXT OBJECT

	JSR	OBJHAN	;HANDLE OBJECTS
	JSR	SHOHAN	;HANDLE SHORTS

NOOHAN	LDA	CONSOL	;ANY CONSOLE
	CMP	#7	;KEYS PRESSED?
	BEQ	JCONWT	;NOPE!
	JMP	LIVE	;YES, RESTART GAME
JCONWT	JMP	CONWT	;INDIRECT JUMP
LVLEND	LDA	GRIDIX	;ARE WE ON
	CMP	#63	;GRID #63?
	BEQ	NOGRDI	;YES, DON'T INC!
	CLC		;INCREMENT
	ADC	#1	;GRID #
	STA	GRIDIX	;AND SAVE IT.
	AND	#7	;ADD 2 TO
	BNE	NODIFI	;DIFFICULTY IF
	INC	DIFF	;ON A MULTIPLE
	INC	DIFF	;OF 8 GRIDS.
NODIFI	SED		;INCREMENT
	LDA	BCDLVL	;BCD LEVEL #
	CLC
	ADC	#1
	STA	BCDLVL
	CLD		;NOW GO TO
NOGRDI	JMP	FOREVR	;DRAW NEW GRID.

;	--------------
;	OBJECT HANDLER
;	--------------

OBJHAN	LDA	OBJNUM	;INCREMENT
	CLC		;OBJECT #
	ADC	#1
	CMP	#6	;DONE?
	BNE	STONUM	;NO, CONTINUE.
	LDA	#$FF	;RESET
	STA	OBJNUM	;OBJECT #
	RTS		;AND EXIT.
STONUM	STA	OBJNUM	;SAVE OBJ #
OBHLP1	LDX	OBJNUM	;GET OBJ #
	LDA	OBJPRS,X	;OBJ PRESENT?
	BEQ	OBJHAN	;NO!
OBLIVE	LDA	OBJSEG,X	;WITHIN 2 UNITS
	CMP	#2	;OF RIM?
	BCC	NOOBFI	;YES, DON'T FIRE
	LDA	RANDOM	;RANDOM CHANCE
	AND	#$0F	;OF SHOOTING
	BNE	NOOBFI	;DON'T SHOOT
	LDA	PROJAC	;PROJ. 0 ACTIVE?
	BNE	TRYPR1	;YES, IGNORE!
	LDY	#0	;FORCE BRANCH
	BEQ	STOBFI	;TO STORE IT
TRYPR1	LDA	PROJAC+1	;PROJ. 1 ACTIVE?
	BNE	NOOBFI	;YES, NO FIRE
	LDY	#1	;SET INDEX
STOBFI	LDA	OBJSEG,X	;INITIALIZE
	LSR	A	;PROJECTILE
	STA	PROJSG,Y	;SEGMENT #
	LDA	OBJGRD,X	;AND
	STA	PROGRD,Y	;SUB-GRID #
	ASL	A	;MULTIPLY
	ASL	A	;BY
	ASL	A	;16
	ASL	A	;AND
	STA	PROJGN,Y	;SAVE INDEX!
	LDA	#$FF	;SET INCREMENT
	STA	PROINC,Y	;(TOWARD RIM)
	LDA	#21	;START THE
	STA	FIRSOU	;FIRE SOUND
	LDA	#1	;AND
	STA	PROJAC,Y	;PROJECTILE
NOOBFI	LDA	#0	;SET COLOR 0
	STA	COLOR	;TO ERASE OBJECT
	JSR	DRWOBJ	;AND ERASE IT
	LDX	OBJNUM
	LDA	OBDED2,X	;OBJ DEAD?
	BEQ	NOOKIL	;YES! START
	JSR	FLASH	;DEATH FLASH
	LDX	OBJNUM
	LDY	OBJTYP,X	;GET OBJECT TYPE
	LDA	POINT1,Y	;GET POINTS
	STA	SCOADD+1	;AND READY
	LDA	POINT2,Y	;THE SCORE
	STA	SCOADD+2	;ADD VALUE
	JSR	ADDSCO	;ADD TO SCORE!
	LDX	OBJNUM
	JMP	KILOBJ	;THEN KILL OBJ.
NOOKIL	LDA	OBJSEG,X	;INCREMENT
	SEC		;OBJECT'S
	SBC	OBJINC,X	;SEGMENT
	STA	OBJSEG,X	;POSITION
	BMI	KILOBJ	;PAST RIM!
	CMP	#30	;TYPE 3 PAST END?
	BNE	NOTOT3	;NOPE!
	INC	NUMOBJ+2	;START TYPE 2
	BNE	KILOBJ	;FORCE BRANCH
NOTOT3	CMP	#10	;AT TYPE 3 TURN?
	BNE	OBHLP2	;NO!
	LDA	OBJTYP,X	;IS IT
	CMP	#3	;TYPE 3?
	BNE	OBHLP2	;NO!
	LDA	#$FF	;REVERSE OBJECT
	STA	OBJINC,X	;INCREMENT
OBHLP2	LDA	OBJTYP,X	;IS OBJECT
	CMP	#2	;TYPE 2?
	BNE	SETHUE	;NO, SET COLOR
	LDA	RANDOM	;GET RANDOM
	AND	#1	;DIRECTION
	TAY		;FOR TYPE 2
	LDA	OBJGRD,X	;AND
	CLC		;ADD OR
	ADC	ADDSB1,Y	;SUBTRACT 1
	CMP	#15	;PAST LIMIT?
	BCS	SETHUE	;YES!
	STA	OBJGRD,X	;SAVE NEW POS.
SETHUE	LDA	OBJTYP,X	;GET OBJ. TYPE
	TAX		;AND GET
	LDA	OBJHUE,X	;COLOR #
	STA	COLOR	;SAVE IT
	JSR	DRWOBJ	;AND DRAW OBJECT!
	JMP	OBJHAN	;DO NEXT ONE

KILOBJ	LDA	#0	;OBJECT IS NO
	STA	OBJPRS,X	;LONGER ALIVE
	LDA	#21	;SET UP
	STA	OBDSOU	;DEATH SOUND
	LDA	OBJSEG,X	;CHECK
	BPL	JOBHAN	;FOR A
	LDA	OBJGRD,X	;COLLISION
	CMP	PLRGRD	;WITH PLAYER
	BNE	CKSHOR	;NO HIT
	LDA	#1	;HIT,
	STA	KILPLR	;KILL PLAYER!
	BNE	JOBHAN       ;NEXT OBJECT
CKSHOR	LDA	OBJTYP,X	;OBJECT
	CMP	#1	;TYPE 1?
	BNE	JOBHAN	;NOPE!
	LDY	#3	;TRY SHORT:
TRYSHO	LDA	SHORTF,Y	;SHORT AVAILABLE?
	BEQ	INISHO	;YUP!
	DEY		;KEEP...
	BPL	TRYSHO	;TRYING!
	BMI	JOBHAN	;NO SHORT AVAIL!
INISHO	LDA	OBJGRD,X	;MULTIPLY THE
	ASL	A	;OBJECT'S
	ASL	A	;SUB-GRID #
	ASL	A	;BY 16...
	ASL	A
	CLC
	ADC	#8	;AND ADD 8 FOR
	STA	SHORTX,Y	;THE SHORT INDEX
	LDA	#1	;SHORT IS
	STA	SHORTF,Y	;ALIVE!
	LDA	RANDOM	;RANDOMIZE...
	AND	#1	;SHORT...
	STA	SHORTD,Y	;DIRECTION
	LDA	RANDOM	;AND THAT...
	AND	#$3F	;DIRECTION'S...
	STA	SHORTT,Y	;TIME!
JOBHAN	JMP	OBJHAN	;NEXT OBJECT

DRWOBJ	LDX	OBJNUM	;GET OBJECT #
	LDA	OBJGRD,X	;GET SUB-GRID #
	ASL	A	;MULTIPLY
	ASL	A	;BY 16...
	ASL	A
	ASL	A
	STA	HLDGRD	;AND SAVE.
	LDA	OBJSEG,X	;DIVIDE
	LSR	A	;SEGMENT BY 2
	BCS	ODDSEG	;PROCESS ODD #
	CLC		;IT'S EVEN, ADD
	ADC	HLDGRD	;GRID INDEX
	TAY		;PUT IN Y REG.
	LDA	SEGX,Y	;GET OBJECT'S
	STA	PLOTX	;X POSITION
	STA	SAVEX	;AND SAVE
	LDA	SEGY,Y	;GET OBJECT'S
	STA	PLOTY	;Y POSITION
	STA	SAVEY	;AND SAVE
	JMP	ODDSKP	;SKIP ODD ROUTINE
ODDSEG	CLC		;IT'S ODD, ADD
	ADC	HLDGRD	;GRID INDEX
	TAY		;PUT IN Y REG.
	LDA	SEGX,Y	;GET OBJECT'S
	CLC		;X POS, ADD
	ADC	SEGX+1,Y	;NEXT X POS.
	ROR	A	;GET AVERAGE
	STA	PLOTX	;PUT IN PLOT X
	STA	SAVEX	;AND SAVE
	LDA	SEGY,Y	;GET OBJECT'S
	CLC		;Y POS, ADD
	ADC	SEGY+1,Y	;NEXT Y POS.
	ROR	A	;GET AVERAGE
	STA	PLOTY	;PUT IN PLOT Y
	STA	SAVEY	;AND SAVE
ODDSKP	LDA	#30	;NOW CALCULATE
	SEC		;THE OBJECT'S
	SBC	OBJSEG,X	;SIZE BASED ON
	LSR	A	;ITS POSITION
	AND	#$FE	;ON THE GRID
	ASL	A
	ASL	A
	TAY		;PUT INDEX IN Y
	LDX	#0	;NOW COPY PART
COPYSZ	LDA	SIZTBL,Y	;OF THE SIZE
	STA	SIZEWK,X	;TABLE TO A
	INY		;SIZE WORK AREA
	INX		;THIS TABLE HOLDS
	CPX	#8	;8 SIZE VALUES
	BNE	COPYSZ	;BASED ON DIST.
	LDX	OBJNUM	;GET OBJECT #
	LDA	OBJTYP,X	;AND ITS TYPE
	ASL	A	;AND MULTIPLY
	ASL	A	;BY 8 FOR AN
	ASL	A	;INDEX INTO
	STA	SHAPIX	;THE SHAPE TABLE
	LDA	#8	;MAX 8 LINES IN
	STA	SHAPCT	;EACH OBJECT
DOBLP	LDX	SHAPIX	;GET LINE#
	LDA	OBJDIR,X	;& ITS DIRECTION
	TAY		;A NEGATIVE #
	BMI	ENDOBJ	;INDICATES END
	LDA	PXINC,Y	;GET X INCREMENT
	STA	XI	;OF LINE,
	LDA	PYINC,Y	;Y INCREMENT
	STA	YI	;OF LINE,
	LDA	OBJLEN,X	;ABSOLUTE LENGTH
	TAY		;OF LINE THEN
	LDA	SIZEWK,Y	;SCALED LENGTH
	STA	LENGTH	;AND STORE!
PLOTOB	LDA	PLOTX	;THIS SECTION
	CLC		;ADJUSTS THE
	ADC	XI	;X AND Y PLOT
	STA	PLOTX	;VALUES...
	LDA	PLOTY
	CLC
	ADC	YI
	STA	PLOTY
	LDA	SHAPIX	;DON'T PLOT
	BEQ	NOPLT1	;FIRST LINE!
	JSR	PLOTCL	;PLOT POINT
NOPLT1	LDA	PLOTY	;INCREMENT Y
	CLC		;AGAIN TO ADJUST
	ADC	YI	;FOR GR. 7+
	STA	PLOTY	;ASPECT RATIO
	LDA	SHAPIX	;DON'T PLOT
	BEQ	NOPLT2	;FIRST LINE
	JSR	PLOTCL	;PLOT POINT
NOPLT2	DEC	LENGTH	;END OF LINE?
	BPL	PLOTOB	;NOPE!
	INC	SHAPIX	;NEXT LINE
	DEC	SHAPCT	;LAST LINE?
	BNE	DOBLP	;NOT YET!
ENDOBJ	RTS		;ALL DONE!

;	-------------
;	SHORT HANDLER
;	-------------

SHOHAN	LDX	#3	;MAX. 4 SHORTS
SHHANL	LDA	SHORTF,X	;SHORT ALIVE?
	BEQ	HANNXS	;NO, DO NEXT
	LDY	SHORTD,X	;GET SHORT DIR.
	LDA	SHORTX,X	;GET X POS.
	CLC		;AND ADJUST
	ADC	ADDSUB,Y	;POSITION
	CMP	#240	;ON GRID?
	BCS	RESSHD	;NO! DON'T MOVE
	STA	SHORTX,X	;OK, SAVE POS.
	DEC	SHORTT,X	;DIRECTION CHANGE?
	BPL	HANNXS	;NO!
RESSHD	LDA	RANDOM	;GET A RANDOM
	AND	#$3F	;DIRECTION TIME
	STA	SHORTT,X	;0-63 & SAVE
	AND	#1	;RANDOM DIRECTION
	STA	SHORTD,X	;0-1 & SAVE
HANNXS	DEX		;MORE SHORTS?
	BPL	SHHANL	;YUP!
	RTS		;ALL DONE!

;	------------
;	ADD TO SCORE
;	------------

ADDSCO	LDY	#0	;GET ZERO
	SED		;SET DECIMAL MODE
	LDA	SCORE+2	;THIS SECTION
	CLC		;INCREMENTS
	ADC	SCOADD+2	;THE 3-DIGIT
	STA	SCORE+2	;SCORE USING
	STY	SCOADD+2	;THE 3-DIGIT
	LDA	SCORE+1	;SCORE ADD
	ADC	SCOADD+1	;AREA, THEN
	STA	SCORE+1	;ZEROS OUT
	STY	SCOADD+1	;THE
	LDA	SCORE	;SCORE ADD
	ADC	SCOADD	;AREA USING
	STA	SCORE	;THE
	STY	SCOADD	;Y REGISTER.
	CLD		;CLR DECIMAL MODE
	JSR	SHOSCO	;SHOW SCORE
	LDA	SCORE	;IS SCORE AT
	CMP	BONUS	;BONUS LEVEL?
	BNE	NOBONS	;SORRY!
	JSR	INCLIV	;BONUS, ADD LIFE!
	SED		;SET DECIMAL
	LDA	BONUS	;GET OLD BONUS
	CLC		;ADD 20000
	ADC	#2	;TO IT
	CLD		;CLR DECIMAL
	STA	BONUS	;AND SAVE BONUS
NOBONS	RTS		;FINIS!

;	----------
;	SHOW SCORE
;	----------

SHOSCO	LDA	#$10	;SET UP COLOR
	STA	SHCOLR	;BYTE FOR SHOW
	LDX	#0	;ZERO X
	LDY	#0	;& Y REGS
SSCOLP	LDA	SCORE,Y	;GET SCORE BYTE
	JSR	SHOBCD	;SHOW IT
	INX		;INCREMENT SHOW
	INX		;POS. BY 2
	INY		;NEXT SCORE BYTE
	CPY	#3	;DONE?
	BNE	SSCOLP	;NOT YET!
	RTS		;ALL DONE!

;	---------------
;	INCREMENT LIVES
;	---------------

INCLIV	LDA	LIVES	;DO WE HAVE
	CMP	#5	;5 LIVES NOW?
	BEQ	NOMOLV	;YUP, NO INC!
	INC	LIVES	;ONE MORE LIFE
	JSR	SHOLIV	;SHOW IT
NOMOLV	RTS		;AND EXIT!

;	---------------
;	DECREMENT LIVES
;	---------------

DECLIV	JSR	SNDOFF	;NO SOUND

;	---------------------------
;	WAIT FOR PROJECTILES TO END
;	---------------------------

WAITPD	LDX	#7	;8 PROJECTILES
	LDA	#0	;ZERO TALLY
CKPRLV	ORA	PROJAC,X	;CHECK ALL
	DEX		;PROJECTILES
	BNE	CKPRLV	;FOR ACTIVITY
	CMP	#0	;ANY ACTIVE?
	BNE	WAITPD	;YES! WAIT MORE!

;	-----------
;	STOP SHORTS
;	-----------

	LDX	#3	;4 SHORTS (0-3)
STPSHO	STA	SHORTF,X	;TURN OFF
	DEX		;ALL OF 'EM
	BPL	STPSHO	;LOOP UNTIL DONE

;	--------------------------
;	PUT OBJECTS AT END OF GRID
;	--------------------------

	LDA	#0	;ERASE
	STA	COLOR	;COLOR
	LDA	#5	;ERASE ALL 6
	STA	OBJNUM	;OBJECTS
ERSOBJ	JSR	DRWOBJ	;ERASE IT!
	LDX	OBJNUM	;GET OBJECT #
	LDA	#30	;PLACE AT
	STA	OBJSEG,X	;SEG #30
	LDA	#1	;SET UP MOVE
	STA	OBJINC,X	;INCREMENT
RNDOBG	LDA	RANDOM	;GET RANDOM
	AND	#$0F	;SUB-GRID #
	CMP	#$0F	;0-14
	BEQ	RNDOBG
	STA	OBJGRD,X
	DEC	OBJNUM	;MORE OBJECTS?
	BPL	ERSOBJ	;YEAH, DO 'EM
	LDA	#$0F	;SHOW PLAYER
	STA	COLPM0	;DEATH HERE
	STA	AUDC1	;START SOUND
MOREWT	LDA	RANDOM	;SET RANDOM
	AND	#$1F	;DEATH SOUND
	STA	AUDF1	;FREQUENCY
	LDA	#6	;WAIT 0.1 SEC
	JSR	WAIT
	DEC	COLPM0	;DEC BRIGHTNESS
	LDA	COLPM0	;NOW SET
	STA	AUDC1	;DEATH VOLUME
	BNE	MOREWT	;MORE WAIT
	LDA	LIVES	;MORE LIVES?
	BEQ	DEAD	;NO MORE LIFE!
	DEC	LIVES	;ONE LESS LIFE
	JSR	SHOLIV	;SHOW IT
	LDA	#60	;WAIT 1 SEC
	JSR	WAIT
	LDA	#0	;RESET PLAYER
	STA	KILPLR	;KILL FLAG
	LDA	#$16	;AND
	STA	COLPM0	;PLAYER COLOR
	RTS		;AND EXIT!
DEAD	PLA		;ALL DEAD, PULL
	PLA		;RETURN ADDR.
	JMP	LIVE	;AND RESTART GAME

;	----------
;	SHOW LIVES
;	----------

SHOLIV	LDA	#$90	;SELECT DISPLAY
	STA	SHCOLR	;COLOR
	LDA	LIVES	;GET LIVES
	LDX	#7	;7TH CHAR ON LINE
	JSR	SHOBCD	;SHOW IT!
	RTS		;AND EXIT

;	----------
;	SHOW LEVEL
;	----------

SHOLVL	LDY	#$50	;SELECT DISPLAY
	STY	SHCOLR	;COLOR
	LDA	BCDLVL	;GET LEVEL#
	LDX	#14	;14TH CHAR

;	----------------
;	BCD CHAR DISPLAY
;	----------------

SHOBCD	STA	SHOBYT	;SAVE CHARACTER
	AND	#$0F	;GET NUM 1
	ORA	SHCOLR	;ADD COLOR
	STA	INFOLN+1,X	;SHOW IT
	LDA	SHOBYT	;GET CHAR.
	LSR	A	;SHIFT RIGHT
	LSR	A	;TO GET
	LSR	A	;NUM 2
	LSR	A
	ORA	SHCOLR	;ADD COLOR
	STA	INFOLN,X	;SHOW IT
	RTS		;AND EXIT!

;	----------------------
;	FLASH OBJECT WHEN DEAD
;	----------------------

FLASH	LDY	FLASHY	;GET Y POS.
	LDA	#0	;GET READY TO
	LDX	#14	;CLEAR OLD FLASH
CLFLSH	STA	PL1,Y	;ZERO OUT EACH
	INY		;BYTE OF FLASH
	DEX		;DONE YET?
	BNE	CLFLSH	;NO, LOOP.
	LDA	SAVEX	;GET OBJECT'S
	CLC		;X POS. AND
	ADC	#61	;ADD 61 FOR
	STA	HPOSP1	;FLASH HORIZ.
	LDA	SAVEY	;GET Y POS AND
	CLC		;ADD 26 FOR
	ADC	#26	;FLASH VERT.
	TAY		;POSITION
	STY	FLASHY	;AND SAVE
	LDX	#13	;FLASH = 14 BYTES
SEFLSH	LDA	FLBYTE,X	;GET IMAGE
	STA	PL1,Y	;PUT IN PLAYER 1
	INY		;NEXT P/M BYTE
	DEX		;NEXT IMAGE BYTE
	BPL	SEFLSH	;LOOP.
	LDA	#1	;SET FLASH
	STA	FLTIME	;DURATION
	RTS		;ALL DONE!

;	----------
;	TIME DELAY
;	----------

WAIT	STA	TIMER	;SET TIMER
WAITLP	LDA	TIMER	;TIMER = 0?
	BNE	WAITLP	;NOPE!
	RTS		;TIMER FINISHED!

;	---------------
;	TURN SOUNDS OFF
;	---------------

SNDOFF	LDA	#0	;ZERO OUT:
	STA	FIRSOU	;FIRE SOUND
	STA	OBDSOU	;OBJ DEATH SOUND
	STA	MOVSOU	;PLYR MOVE SOUND
	LDX	#7	;ZERO ALL:
SNDOF2	STA	AUDF1,X	;AUDIO REGISTERS
	DEX
	BPL	SNDOF2
	RTS		;AND EXIT

;	---------
;	DRAW GRID
;	---------

DRGRID	LDA	#1	;TELL INTERRUPT
	STA	INTRFG	;IT'S INTRO
	JSR	SNDOFF	;TURN OFF SOUND
	LDA	#$20	;TURN OFF TOP
	STA	DMAC1	;OF SCREEN BY
	LDA	#0	;SHUTTING OFF
	STA	GRAC1	;DMA & GRAPHICS
	LDX	#3	;TURN OFF SHORTS
CLSHRT	STA	SHORTF,X
	DEX
	BPL	CLSHRT
	LDX	#7	;TURN OFF
CLPRJC	STA	PROJAC,X	;ALL PROJECTILES
	DEX
	BPL	CLPRJC
	JSR	PMCLR	;CLEAR P/M AREA
	STA	OFFSET	;ZERO OFFSET
	LDA	#6	;SET 6 PROJECT.
	STA	PAVAIL	;AVAILABLE
	LDA	GRIDIX	;GET GRID #
	LSR	A	;DIVIDE
	LSR	A	;BY
	LSR	A	;8
	TAX		;LOAD APPROPRIATE
	LDA	C0TBL,X	;GRID COLOR
	STA	COLPF0
	LDA	C1TBL,X	;OBJECT COLOR 1
	STA	COLPF1
	LDA	C2TBL,X	;OBJECT COLOR 2
	STA	COLPF2
	LDA	OBSTBL,X	;OBJECT SPEED
	STA	OBJSPD
	LDA	GRIDIX	;GET GRID
	AND	#7	;SHAPE INDEX
	TAX		;LOAD:
	LDA	OBCNT0,X	;TYPE 0
	STA	NUMOBJ	;OBJECT COUNT
	LDA	OBCNT1,X	;TYPE 1
	STA	NUMOBJ+1	;OBJECT COUNT
	LDA	OBCNT2,X	;TYPE 2
	STA	NUMOBJ+2	;OBJECT COUNT
	LDA	OBCNT3,X	;TYPE 3
	STA	NUMOBJ+3	;OBJECT COUNT
	LDA	OBCNT4,X	;TYPE 4
	STA	NUMOBJ+4	;OBJECT COUNT
	LDX	#4	;ADJUST ALL
DIFFAD	LDA	NUMOBJ,X	;OBJECT COUNTS
	CLC		;BY ADDING
	ADC	DIFF	;DIFFICULTY
	STA	NUMOBJ,X	;AND SAVE
	DEX
	BPL	DIFFAD
	LDA	GRDNUM	;GET GRID #
	ASL	A	;MULTIPLY
	ASL	A	;BY 16
	ASL	A
	ASL	A
	STA	GRDADJ	;SAVE
	STA	GRDWK	;SAVE
	TAX		;SET X INDEX
	LDA	#16	;LOAD 16 BYTES
	STA	GRDWK2
GRDLIN	LDA	CX,X	;GET CLOSE X
	STA	PLOTX
	LDA	CY,X	;GET CLOSE Y
	STA	PLOTY
	LDA	FX,X	;GET FAR X
	STA	DRAWX
	LDA	FY,X	;GET FAR Y
	STA	DRAWY
	LDA	COLPF0	;INVISIBLE?
	BEQ	NOGRD1	;YES, DON'T DRAW
	JSR	PLOTCL	;PLOT CLOSE POINT
	JSR	DRAW	;DRAW TO FAR
NOGRD1	DEC	GRDWK2	;CONTINUE DRAWING
	BEQ	GRDBO1	;UNTIL ALL 16
	INC	GRDWK	;LINES ARE DONE
	LDX	GRDWK
	JMP	GRDLIN
GRDBO1	LDX	GRDADJ	;NOW DRAW 15
	STX	GRDWK	;CLOSE GRID
	LDA	#15	;BORDER LINES
	STA	GRDWK2
GRDBL1	LDA	CX,X	;GET CLOSE X
	STA	PLOTX
	LDA	CY,X	;GET CLOSE Y
	STA	PLOTY
	LDA	CX+1,X	;NEXT CLOSE X
	STA	DRAWX
	CLC		;FIND POINT
	ADC	PLOTX	;BETWEEN THEM
	ROR	A
	STA	XWORK	;AND SAVE IT!
	LDA	CY+1,X	;NEXT CLOSE Y
	STA	DRAWY
	CLC		;FIND POINT
	ADC	PLOTY	;BETWEEN THEM
	ROR	A
	STA	YWORK	;AND SAVE IT!
	LDA	#15	;SET UP A WORK
	SEC		;AREA TO HOLD
	SBC	GRDWK2	;THE POINTS
	STA	GRID	;BETWEEN LINES
	JSR	GRIDSV	;AND SAVE THEM
	LDA	COLPF0	;INVISIBLE GRID?
	BEQ	NOGRD2	;YES, DON'T DRAW
	JSR	PLOTCL	;PLOT CLOSE POINT1
	JSR	DRAW	;DRAW TO POINT 2
NOGRD2	DEC	GRDWK2	;MORE LINES?
	BEQ	GRDBO2	;NO!
	INC	GRDWK	;INCREMENT TO
	LDX	GRDWK	;NEXT LINE
	JMP	GRDBL1	;AND LOOP
GRDBO2	LDX	GRDADJ	;NOW DRAW 15
	STX	GRDWK	;FAR GRID
	LDA	#15	;BORDER LINES
	STA	GRDWK2
	STA	OFFSET	;AND SET OFFSET
GRDBL2	LDA	FX,X	;GET FAR X
	STA	PLOTX
	LDA	FY,X	;GET FAR Y
	STA	PLOTY
	LDA	FX+1,X	;NEXT FAR X
	STA	DRAWX
	CLC		;AND FIND
	ADC	PLOTX	;MIDPOINT
	ROR	A	;BETWEEN THEM
	STA	XWORK	;AND SAVE IT!
	LDA	FY+1,X	;NEXT FAR Y
	STA	DRAWY
	CLC		;AND FIND
	ADC	PLOTY	;MIDPOINT
	ROR	A	;BETWEEN THEM
	STA	YWORK	;AND SAVE IT!
	LDA	#15	;USE THE SAME
	SEC		;WORK AREA
	SBC	GRDWK2	;TO HOLD THE
	STA	GRID	;MIDPOINTS
	JSR	GRIDSV	;AND SAVE THEM
	LDA	COLPF0	;INVISIBLE GRID?
	BEQ	NOGRD3	;YES, DON'T DRAW
	JSR	PLOTCL	;PLOT FAR POINT 1
	JSR	DRAW	;DRAW TO POINT 2
NOGRD3	DEC	GRDWK2	;MORE LINES?
	BEQ	GENCOO	;NO!
	INC	GRDWK	;INCREMENT TO
	LDX	GRDWK	;NEXT LINE
	JMP	GRDBL2	;AND LOOP

;	-----------------------------
;	NOW GENERATE COORDINATE TABLE
;
;	THIS SECTION BUILDS THE SEGX,
;	SEGY, RIMX AND RIMY TABLES.
;	THE SEGX&Y TABLES ARE POINTS
;	UP AND DOWN THE GRID FOR PRO-
;	JECTILES AND OBJECTS.  THE
;	RIMX&Y TABLES ARE FOR THE
;	POSITIONING OF SHORTS.
;	-----------------------------

GENCOO	LDA	#0
	STA	GRIDNO
DIVCTL	TAX
	LDA	SEGX,X	;SET UP SEGWK
	STA	SEGWK	;WITH END
	LDA	SEGX+15,X	;COORDINATES
	STA	SEGWK+16
	JSR	DIVIDE	;DIVIDE SEGWK
	LDX	GRIDNO
	LDY	#0
COPY1	LDA	SEGWK,Y	;COPY SEGWK
	STA	SEGX,X	;TABLE TO SEGX
	INX
	INY
	CPY	#16
	BNE	COPY1
;NOW THE Y COORDS
	LDX	GRIDNO
	LDA	SEGY,X	;SET UP SEGWK
	STA	SEGWK	;WITH END
	LDA	SEGY+15,X	;COORDINATES
	STA	SEGWK+16
	JSR	DIVIDE	;DIVIDE SEGWK
	LDX	GRIDNO
	LDY	#0
COPY2	LDA	SEGWK,Y	;COPY SEGWK
	STA	SEGY,X	;TABLE TO SEGY
	INX
	INY
	CPY	#16
	BNE	COPY2

;	----------------------------
;	NOW GENERATE RIM COORDINATES
;	----------------------------

	LDX	GRIDNO
	LDA	RIMX,X	;SET UP SEGWK
	STA	SEGWK	;WITH END
	LDA	RIMX+15,X	;COORDINATES
	STA	SEGWK+16
	JSR	DIVIDE	;DIVIDE SEGWK
	LDX	GRIDNO
	LDY	#0
COPY3	LDA	SEGWK,Y	;COPY SEGWK
	STA	RIMX,X	;TABLE TO RIMX
	INX
	INY
	CPY	#16
	BNE	COPY3
;NOW THE RIM Y COORDS
	LDX	GRIDNO
	LDA	RIMY,X	;SET UP SEGWK
	STA	SEGWK	;WITH END
	LDA	RIMY+15,X	;COORDINATES
	STA	SEGWK+16
	JSR	DIVIDE	;DIVIDE SEGWK
	LDX	GRIDNO
	LDY	#0
COPY4	LDA	SEGWK,Y	;COPY SEGWK
	STA	RIMY,X	;TABLE TO RIMY
	INX
	INY
	CPY	#16
	BNE	COPY4
	LDA	GRIDNO	;DO ALL 15
	CLC		;GRID LINES
	ADC	#16
	STA	GRIDNO
	CMP	#240	;ALL DONE?
	BEQ	ENDDVC	;YOU BET!
	JMP	DIVCTL	;LOOP BACK!
ENDDVC	LDA	#$3D	;RESTART
	STA	DMAC1	;THE DISPLAY
	LDA	#$03	;AFTER GRID
	STA	GRAC1	;IS DRAWN
	LDA	#0	;NO MORE
	STA	INTRFG	;INTRO STATUS
	RTS		;FINIS!

;	-------------------------------
;	DIVIDE SEGWK TABLE
;
;	THIS ROUTINE EXAMINES THE FIRST
;	AND LAST BYTES IN THE SEGWK
;	TABLE AND FILLS THE BYTES IN
;	BETWEEN WITH AN EVEN TRANSITION
;	FROM ONE ENDPOINT TO THE OTHER
;	-------------------------------

DIVIDE	LDA	#16
	STA	STEP
	STA	NEXT
	LSR	A
	STA	DEST
DIVLP2	LDA	#0
	STA	LAST
DIVLP1	LDX	LAST
	LDA	SEGWK,X
	LDX	NEXT
	CLC
	ADC	SEGWK,X
	ROR	A
	LDX	DEST
	STA	SEGWK,X
	LDA	LAST
	CLC
	ADC	STEP
	STA	LAST
	ADC	STEP
	CMP	#17
	BCS	NOSTEP
	STA	NEXT
	LDA	DEST
	CLC
	ADC	STEP
	STA	DEST
	JMP	DIVLP1
NOSTEP	LDA	STEP
	LSR	A
	STA	STEP
	STA	NEXT
	LSR	A
	BEQ	ENDDIV
	STA	DEST
	JMP	DIVLP2
ENDDIV	RTS

;	--------------------
;	GRID COORDINATE SAVE
;	--------------------

GRIDSV	LDA	GRID
	ASL	A	;*2
	ASL	A	;*4
	ASL	A	;*8
	ASL	A	;*16
	CLC		;ADD THE
	ADC	OFFSET	;OFFSET VALUE
	TAX		;SAVE IN INDEX
	LDA	XWORK	;GET X WORK
	STA	SEGX,X	;AND SAVE
	LDA	YWORK	;GET Y WORK
	STA	SEGY,X	;AND SAVE
	LDA	OFFSET	;DON'T CONTINUE
	BNE	SAVEND	;IF OFFSET >0
	LDA	PLOTX	;GET PLOTX
	STA	RIMX,X	;AND SAVE
	LDA	PLOTY	;GET PLOTY
	STA	RIMY,X	;AND SAVE
	LDA	DRAWX	;GET DRAWX
	STA	RIMX+15,X	;AND SAVE
	LDA	DRAWY	;GET DRAWY
	STA	RIMY+15,X	;AND SAVE
SAVEND	RTS		;ALL DONE!

;	----------------------
;	VERTICAL BLANK ROUTINE
;	----------------------

VBI	LDA	#DLI1&255	;POINT TO
	STA	VDSLST	;FIRST
	LDA	#DLI1/256	;DISPLAY LIST
	STA	VDSLST+1	;INTERRUPT
	CLD		;CLR DECIMAL MODE
	LDA	OBTIM1	;THIS SECTION
	BEQ	NOOBTD	;PROCESSES
	DEC	OBTIM1	;ALL TIMERS
NOOBTD	LDA	TIMER
	BEQ	NOTIMR
	DEC	TIMER
NOTIMR	LDA	FLTIME
	BEQ	NOFTIM
	DEC	FLTIME
NOFTIM	LDA	KILPLR	;PLAYER DEAD?
	BEQ	CHKINT	;NO, CONTINUE!
	JMP	VBCONT	;SKIP PLAYER STUFF
CHKINT	LDA	INTRFG	;IN INTRO?
	BEQ	NOTINT	;NO, CONTINUE!
	JMP	XITVBV	;EXIT IF INTRO
NOTINT	LDA	KEY	;GET KEYBOARD
	CMP	#$1C	;PAUSE (ESC)?
	BNE	CKZAP	;NO, CHECK ZAP
	LDA	PAUFLG	;GET PAUSE FLAG
	EOR	#$FF	;AND FLIP
	STA	PAUFLG	;AND STORE
	JMP	ENDKEY	;DONE W/KEY
CKZAP	CMP	#$21	;SPACE BAR?
	BNE	ENDKEY	;NAW, DONE W/KEY
	LDA	ZAP	;USED ZAP YET?
	BEQ	ENDKEY	;YES, NO ZAP
	DEC	ZAP	;ZAP NOW USED
	LDX	#5	;TIME TO KILL
	LDA	#1	;ALL OBJECTS
ZAPOBJ	STA	OBDEAD,X
	DEX
	BPL	ZAPOBJ
	LDX	#3	;AND KILL
ZAPSHO	LDA	SHORTF,X	;ALL SHORTS
	BEQ	NOSKIL
	LDA	MISCAD	;ALSO SET
	SED		;MISCELLANEOUS
	CLC		;SCORE ADD
	ADC	#4	;FOR 400 POINTS
	STA	MISCAD	;FOR EACH SHORT
	CLD
	LDA	#0	;KILL
	STA	SHORTF,X	;SHORT
NOSKIL	DEX
	BPL	ZAPSHO
ENDKEY	LDA	#0	;CLEAR
	STA	KEY	;KEYPRESS.
	LDA	PAUFLG	;PAUSED?
	BEQ	NOPAU	;NO, CONTINUE
	LDA	#0	;TURN OFF
	STA	AUDC1	;ALL SOUNDS
	STA	AUDC2	;DURING
	STA	AUDC3	;THE
	STA	AUDC4	;PAUSE
	JMP	XITVBV	;THEN EXIT
NOPAU	LDA	FIRSOU	;FIRE SOUND ON?
	BEQ	NOFSND	;NO!
	DEC	FIRSOU	;DEC COUNTER
	LDX	FIRSOU	;PUT IN INDEX
	LDA	FIRFRQ,X	;GET FREQUENCY
	STA	AUDF2
	LDA	FIRCTL,X	;GET CONTROL
	STA	AUDC2
NOFSND	LDA	OBDSOU	;OBJ DEATH SOUND?
	BEQ	NOOSND	;NO!
	DEC	OBDSOU	;DEC COUNTER
	LDX	OBDSOU	;PUT IN INDEX
	LDA	OBDFRQ,X	;GET FREQUENCY
	STA	AUDF3
	LDA	OBDCTL,X	;GET CONTROL
	STA	AUDC3
NOOSND	LDA	MOVSOU	;MOVE SOUND?
	BEQ	CYCCOL	;NO!
	DEC	MOVSOU	;DEC COUNTER
	LDX	MOVSOU	;PUT IN INDEX
	LDA	MOVFRQ,X	;GET FREQUENCY
	STA	AUDF4
	LDA	MOVCTL,X	;GET CONTROL
	STA	AUDC4
CYCCOL	LDA	COLPM2	;CYCLE
	CLC		;PLAYER 2
	ADC	#16	;COLOR
	STA	COLPM2	;SAVE IN P/M 2
	STA	COLPM3	;AND IN P/M 3
	AND	#$FC	;ALSO PUT IN
	STA	COLPF3	;PF3 FOR MISSILES
	DEC	TRANTM	;TRANSIENT TIME
	BNE	NOTRAN	;NO CHANGE
	LDA	OBJHUE+4	;FLIP
	BNE	TRAN1	;TRANSIENT
	LDA	#2	;HUE
	BNE	STOTRN	;TO EITHER
TRAN1	LDA	#0	;0 OR 2
STOTRN	STA	OBJHUE+4
	LDA	RANDOM
	ORA	#$1F	;RESET
	AND	#$3F	;THE
	STA	TRANTM	;TRANSIENT TIME
NOTRAN	INC	PSCNT	;INC PLYR TIMER
	LDA	PSCNT	;READY TO
	CMP	#3	;CHANGE SHAPE?
	BNE	NOPSIN	;NOT YET!
	LDA	#0	;BETTER RESET
	STA	PSCNT	;INDEX
	INC	SP1IX	;AND INCREMENT
	INC	SP2IX	;ALL SHAPE
	INC	SP3IX	;INDEXES!
NOPSIN	LDA	PFTIME	;SEE IF WE'RE
	BEQ	FIRE	;READY TO CHECK
	DEC	PFTIME	;IF PLAYER IS
	JMP	CHKPMV	;SHOOTING
FIRE	LDA	#4	;RESET FIRE
	STA	PFTIME	;TIMER
	LDA	JOYPAD	;USING STICK?
	BEQ	RDSTRG	;YES!
	LDA	PTRIG0	;GET PADL TRIGGER
	JMP	CMPTRG	;CHECK IT
RDSTRG	LDA	STRIG	;GET STICK TRIGGER
CMPTRG	BNE	CHKPMV	;NOT FIRING!
	LDA	PAVAIL	;ANY PROJ AVAIL?
	BEQ	CHKPMV	;NO!
	LDX	#7	;FIND AN
PRSCAN	LDA	PROJAC,X	;AVAILABLE
	BEQ	GOTPRN	;PROJECTILE
	DEX
	BNE	PRSCAN
GOTPRN	DEC	PAVAIL	;1 LESS AVAILABLE
	LDA	#1	;IT'S NOW
	STA	PROJAC,X	;ACTIVE
	LDA	#21	;START UP
	STA	FIRSOU	;FIRE SOUND
	LDA	#0	;INITIALIZE
	STA	PROJSG,X	;SEGMENT # TO 0
	LDA	PLRGRD	;SET UP
	STA	PROGRD,X	;PROJ GRID#
	ASL	A	;AND
	ASL	A	;MULTIPLY
	ASL	A	;BY 16
	ASL	A
	STA	PROJGN,X	;FOR INDEX
	LDA	#1	;INITIALIZE
	STA	PROINC,X	;PROJ INCREMENT
CHKPMV	LDA	JOYPAD	;USING STICK?
	BEQ	GOSTIK	;YES!
	LDA	POT0	;GET PADDLE
	LSR	A	;DIVIDE BY
	LSR	A	;16 TO GET
	LSR	A	;USABLE VALUE
	LSR	A
	CMP	#15	;> 14?
	BMI	STOPOS	;NO, GO STORE
	LDA	#14	;MAX. IS 14
	BNE	STOPOS	;AND GO STORE
GOSTIK	LDA	PMTIME	;READY FOR STICK?
	BEQ	RDSTIK	;YES!
	DEC	PMTIME	;DEC TIMER
JVBC	JMP	VBCONT	;JMP TO CONTINUE
RDSTIK	LDA	#2	;RESET STICK TIMER
	STA	PMTIME	;TO 2 JIFFIES
	LDX	STICK	;GET STICK
	LDA	PLRGRD	;GET PLYR GRID #
	CLC		;ADD THE
	ADC	STKADD,X	;DIRECTION INC
	BMI	SAMPOS	;IF <0 REJECT
	CMP	#15	;IF <15...
	BNE	STOPOS	;USE IT!
SAMPOS	LDA	PLRGRD	;GET GRID#
STOPOS	CMP	PLRGRD	;SAME AS LAST?
	BEQ	NOPSTO	;YES, DON'T STORE
	LDX	#9	;START UP
	STX	MOVSOU	;MOVE SOUND
	STA	PLRGRD	;SAVE GRID#
NOPSTO	ASL	A	;MULTIPLY
	ASL	A	;BY 16 FOR
	ASL	A	;POSITION
	ASL	A	;INDEX
	TAX
	LDA	P0PL
	AND	#$0C	;HIT P2/P3?
	BEQ	NOHSHO	;NO!
	LDA	#1	;OOPS! HIT SHORT!
	STA	KILPLR	;KILL PLAYER
	JMP	VBEND	;AND EXIT VBLANK
NOHSHO	LDA	SEGX,X	;GET PLAYER'S
	CLC		;X POSITION AND
	ADC	#61	;ADJUST FOR P/M
	STA	HPOSP0	;AND SAVE
	LDY	PLRY	;HOLD OLD Y POS
	LDA	SEGY,X	;GET NEW Y POS
	CLC		;ADJUST FOR P/M
	ADC	#32	;BY ADDING 32
	STA	PLRY	;SET Y POS
	LDA	#0	;CLEAR OUT
	LDX	#15	;OLD PLAYER
CLRPS	STA	PL0-8,Y	;IMAGE
	INY
	DEX
	BPL	CLRPS
	LDA	#15	;NOW COPY
	STA	SPIX	;16-BYTE
SPLOOP	LDA	#0	;PLAYER IMAGE
	STA	PLTBYT	;TO PLAYER 0
	LDA	SP1IX
	AND	#15
	TAX
	LDA	SPIX
	CMP	SPTBL,X
	BCC	NOSP1
	CMP	EPTBL,X
	BCS	NOSP1
	TAX
	LDA	PN1,X	;GET IMAGE 1
	STA	PLTBYT	;AND SAVE
NOSP1	LDA	SP2IX
	AND	#15
	TAX
	LDA	SPIX
	CMP	SPTBL,X
	BCC	NOSP2
	CMP	EPTBL,X
	BCS	NOSP2
	TAX
	LDA	PN2,X
	ORA	PLTBYT	;ADD IMAGE 2
	STA	PLTBYT	;AND SAVE
NOSP2	LDA	SP3IX
	AND	#15
	TAX
	LDA	SPIX
	CMP	SPTBL,X
	BCC	NOSP3
	CMP	EPTBL,X
	BCS	NOSP3
	TAX
	LDA	PN3,X
	ORA	PLTBYT	;ADD IMAGE 3
	STA	PLTBYT	;AND SAVE
NOSP3	LDA	PLRY
	CLC
	ADC	SPIX
	SEC
	SBC	#8
	TAY
	LDA	PLTBYT	;GET IMAGE BYTE
	STA	PL0,Y	;PUT IN P/M AREA
	DEC	SPIX	;MORE IMAGE?
	BPL	SPLOOP	;YES!
VBCONT	LDA	PRADV1	;ADVANCE PROJ?
	BEQ	SETPRA	;YES!
	DEC	PRADV1	;NO, DEC TIMER
	JMP	FLIPIT	;GO FLIP DISPLAY
SETPRA	INC	PRADVT
	LDA	#1	;SET ADVANCE
	STA	PRADV1	;TIMER

;	------------------------------
;	THIS SECTION FLIP-FLOPS THE 4
;	MISSILES IN ORDER TO ALLOW THE
;	DISPLAY OF 8 PROJECTILES.  AS
;	A RESULT, SOME FLICKER CAN BE
;	OBSERVED.
;	------------------------------

FLIPIT	INC	PRFLIP	;INC FLIP INDEX
	LDA	PRFLIP	;GET INDEX
	AND	#1	;MAKE 0/1
	TAY		;SAVE IN Y
	LDA	PREND,Y	;GET # OF LAST
	STA	ENDVAL	;PROJECTILE
	LDX	PRSTRT,Y	;GET # OF FIRST
	STX	VBXHLD	;PROJECTILE
	LDA	#3	;START W/MISSILE
	STA	MISNUM	;NUMBER 3
PROJLP	LDA	PROJAC,X	;IS PROJ. ACTIVE?
	BNE	GOTPRJ	;YOU BET.
	JMP	CKPEND	;TRY ANOTHER
GOTPRJ	LDX	MISNUM	;GET MISSILE #
	LDY	PRYHLD,X	;GET LAST POSITION
	LDA	MISSLS-1,Y	;ERASE OLD
	AND	MISLOF,X	;PROJECTILE
	STA	MISSLS-1,Y	;IMAGE
	LDA	MISSLS,Y
	AND	MISLOF,X
	STA	MISSLS,Y
	LDA	MISSLS+1,Y
	AND	MISLOF,X
	STA	MISSLS+1,Y
	LDX	VBXHLD
	LDA	PRADVT	;READY TO
	AND	#1	;ADVANCE PROJ?
	BNE	NOPADV	;NOT YET
	LDA	PROJSG,X	;GET PROJ SEG#
	CLC		;AND
	ADC	PROINC,X	;ADD INCREMENT
	STA	PROJSG,X	;THEN SAVE
NOPADV	LDA	PROINC,X	;ENEMY SHOT?
	BMI	NOOHCK	;NO OBJ HIT CHECK
	LDY	#5
OBKILP	LDA	OBDEAD,Y	;ALREADY DEAD?
	BNE	NXTOCK	;YES!
	LDA	OBJPRS,Y	;OBJECT THERE?
	BEQ	NXTOCK	;NO!
	LDA	OBJTYP,Y	;TRANSIENT?
	CMP	#4
	BNE	NOTRNC	;NO!
	LDA	OBJHUE+4	;INVISIBLE?
	BEQ	NXTOCK	;YES!
NOTRNC	LDA	OBJGRD,Y	;SAME GRID #
	CMP	PROGRD,X	;AS PROJ?
	BNE	NXTOCK	;NO!
	LDA	OBJSEG,Y	;SAME SEG #
	LSR	A
	SEC
	SBC	PROJSG,X	;AS PROJ?
	BEQ	HITOBJ
	CMP	#254
	BCC	NXTOCK	;NO!
HITOBJ	LDA	OBJTYP,Y	;RESISTOR?
	BEQ	CGPRDR	;YES!
	LDA	#1	;KILL OBJECT
	STA	OBDEAD,Y
	JMP	KILLPR	;AND PROJ.
CGPRDR	LDA	#$FF	;PROJ NOW HEADING
	STA	PROINC,X	;FOR PLAYER!
NXTOCK	DEY		;NEXT OBJECT
	BPL	OBKILP	;MORE TO DO!
NOOHCK	LDA	PROJSG,X	;IS PROJ SEG# =0?
	BEQ	KILLPR	;YES, KILL IT!
	CMP	#16	;=16?
	BEQ	KILLPR	;YES, KILL IT!
	CLC		;NOW ADD PROJ
	ADC	PROJGN,X	;GRID INDEX
	TAX		;AND GET
	LDA	SEGX,X	;X COORD
	LDY	SEGY,X	;AND Y COORD
	CLC		;ADD 64 TO
	ADC	#64	;X COORD FOR
	LDX	MISNUM	;P/M HORIZ
	STA	HPOSM0,X	;AND SAVE
	TYA		;GET Y
	CLC		;ADD 32 TO
	ADC	#32	;Y COORD FOR
	TAY		;P/M VERT
	STY	PRYHLD,X	;AND SAVE.
	LDA	MISSLS-1,Y	;NOW DRAW
	ORA	MISLON,X	;PROJECTILE IN
	STA	MISSLS-1,Y	;NEW POSITION
	LDA	MISSLS,Y
	ORA	MISLON,X
	STA	MISSLS,Y
	LDA	MISSLS+1,Y
	ORA	MISLON,X
	STA	MISSLS+1,Y
CKPEND	DEC	MISNUM	;NEXT MISSILE #
	DEC	VBXHLD	;NEXT PROJ.
	LDX	VBXHLD
	CPX	ENDVAL	;DONE?
	BEQ	SHORTS	;YES!
	JMP	PROJLP	;DO NEXT PROJ.
KILLPR	LDA	#0	;KILL PROJ.
	STA	PROJAC,X
	CPX	#2	;ENEMY PROJ?
	BCC	NOAVIN	;YES DON'T INC
	INC	PAVAIL	;ANOTHER AVAIL
NOAVIN	LDA	PROJSG,X 	;SEGMENT 0?
	BNE	NOKILP	;NO!
	LDA	PROINC,X	;TOWARD RIM?
	BPL	NOKILP	;NO!
	LDA	PROGRD,X	;SAME GRID...
	CMP	PLRGRD	;AS PLAYER?
	BNE	NOKILP	;NO!
	LDA	#1	;THE PLAYER
	STA	KILPLR	;IS DEAD!
NOKILP	JMP	CKPEND	;NEXT PROJ.

;	------------------------------
;	THIS SECTION HANDLES SHORTS.
;	2 PLAYERS ARE USED TO SHOW A
;	MAXIMUM OF 4 SHORTS, SO SOME
;	FLICKER MAY BE OBSERVED.
;	------------------------------

SHORTS	INC	SHFLIP	;TOGGLE FLIP
	LDA	SHFLIP	;MASK FLIP
	LSR	A	;TO EITHER
	AND	#1	;0 OR 1
	TAY		;PUT IN Y
	LDA	CPYSTN,Y	;AND GET IMAGE
	STA	CPYST	;TO USE (+/X)
	LDA	SHFLIP	;GET FLIP,
	AND	#1	;MASK AND
	TAY		;PUT IN Y
	LDA	#PL3/256	;PUT PLAYER 3
	STA	DESTHI	;IN DESTINATION
	LDA	#PL3&255	;ADDRESS
	STA	DESTLO	;HI & LO
	LDA	#1	;SET DEST #
	STA	DESTNM
	LDA	SHSTRT,Y	;GET START
	STA	VBXHLD	;SHORT #
SHORLP	LDA	#0
	LDX	DESTNM
	LDY	SHYHLD,X	;GET LAST INDEX
	LDX	#9	;NOW ERASE
ERSSHO	STA	(DESTLO),Y	;PREVIOUS
	INY		;SHORT
	DEX
	BPL	ERSSHO
	LDX	VBXHLD
	LDA	SHORTF,X	;SHORT ALIVE?
	BEQ	NXTSHO	;NO!
	LDA	SHORTX,X	;GET INDEX OF
	TAX		;SHORT'S POS.
	LDA	RIMX,X	;GET X COORD
	LDY	RIMY,X	;AND Y COORD
	CLC
	ADC	#62	;ADJUST X
	LDX	DESTNM	;GET PLAYER#
	STA	HPOSP2,X	;AND STORE
	TYA
	CLC
	ADC	#28	;ADJUST Y
	STA	SHYHLD,X	;SAVE IT
	TAY
	LDX	CPYST
	LDA	#4
	STA	CPYCNT
SHOCOP	LDA	SHOIMG,X	;NOW COPY
	STA	(DESTLO),Y	;SHORT IMAGE
	INY		;TO P/M
	STA	(DESTLO),Y	;AREA
	INY
	DEX
	DEC	CPYCNT
	BPL	SHOCOP
NXTSHO	DEC	DESTNM	;MORE?
	BMI	VBEND	;NO, EXIT!
	DEC	DESTHI	;NEXT PLAYER
	INC	VBXHLD
	JMP	SHORLP	;LOOP BACK.
VBEND	STA	HITCLR	;CLEAR COLLISION
	JMP	XITVBV	;VBI DONE! (WHEW!)

;	---------------------
;	CLEAR PLAYER-MISSILES
;	---------------------

PMCLR	LDA	#0	;PUT 255
	TAX		;ZEROS IN
PMCLP	STA	MISSLS,X	;EACH P/M
	STA	PL0,X	;AREA
	STA	PL1,X
	STA	PL2,X
	STA	PL3,X
	DEX
	BNE	PMCLP
	RTS		;FINIS!

;	------------
;	CLEAR SCREEN
;	------------
CLRSC	LDA	#DISP/256	;INITIAL
	STA	HI	;DISPLAY
	LDA	#DISP&255	;ADDRESS
	STA	LO	;WORK AREA
	LDX	#20	;CLEAR 20 GROUPS
CLRSC2	LDY	#0	;OF 256 BYTES
	TYA		;(5120 BYTES)
CLRSC3	STA	(LO),Y
	DEY
	BNE	CLRSC3
	DEX
	BNE	CLRSC4
	RTS
CLRSC4	INC	HI
	JMP	CLRSC2

;	----------------------
;	GR. 7+ PLOTTER ROUTINE
;	(SEE A.N.A.L.O.G. #11)
;	----------------------

PLOTCL	LDA	PLOTY	;MULT. Y BY 32:
	ASL	A
	STA	LO
	LDA	#0
	ROL	A
	STA	HI	;*2
	ASL	LO
	ROL	HI	;*4
	ASL	LO
	ROL	HI	;*8
	ASL	LO
	ROL	HI	;*16
	ASL	LO
	ROL	HI	;*32
	LDA	#DISP&255 ;ADD THE DISPLAY
	CLC		;ADDRESS TO GET
	ADC	LO	;THE ACTUAL
	STA	LO	;ADDRESS OF THE
	LDA	#DISP/256 ;BYTE THAT WILL
	ADC	HI	;BE ALTERED FOR
	STA	HI	;THE PLOT.
	LDA	PLOTX	;MASK PLOTX FOR
	AND	#3	;PLOT INDEX,
	TAX		;PLACE IN X.
	LDA	PLOTX	;GET PLOTX AND
	LSR	A	;DIVIDE
	LSR	A	;BY 4,
	STA	YOFSET
	TAY
	LDA	(LO),Y
	AND	BMASK2,X
	CMP	COLOR1,X
	BEQ	PABORT
	LDY	COLOR	;GET COLOR
	LDA	BMASK2,X	;AND MASK OFF
	AND	COLORS,Y	;PIXEL POSITION
	STA	HOLD	;SAVE IT,
	LDA	BMASK1,X	;MASK OFF PIXEL
	LDY	YOFSET	;OF THE ADDRESS
	AND	(LO),Y	;TO BE ALTERED
	ORA	HOLD	;SET THE PLOT
	STA	(LO),Y	;BITS AND STORE!
PABORT	RTS		;FINIS!

;	----------------
;	PLOT MASK TABLES
;	----------------

COLORS	DB	$00,$55,$AA,$FF
BMASK1	DB	$3F,$CF,$F3,$FC
BMASK2	DB	$C0,$30,$0C,$03
COLOR1	DB	$40,$10,$04,$01

;	------------
;	DRAW HANDLER
;	------------

DRAW	LDA	DRAWY
	CMP	PLOTY	;IS DRAWY>PLOTY?
	BCC	YMINUS	;NO!
	SEC		;SUBTRACT
	SBC	PLOTY	;PLOTY FROM DRAWY
	STA	DELTAY	;AND SAVE DIFFERENCE.
	LDA	#1	;Y INCREMENT
	STA	INCY	;= 1 (DOWN)
	BNE	XVEC	;BRANCH!
YMINUS	LDA	PLOTY	;SUBTRACT
	SEC		;DRAWY
	SBC	DRAWY	;FROM PLOTY
	STA	DELTAY	;AND SAVE DIFFERENCE.
	LDA	#255	;Y INCREMENT
	STA	INCY	;= -1 (UP)
XVEC	LDA	DRAWX	;IS DRAWX
	CMP	PLOTX	;> PLOTX?
	BCC	XMINUS	;NO!
	SEC		;SUBTRACT
	SBC	PLOTX	;PLOTX FROM DRAWX
	STA	DELTAX	;AND SAVE DIFFERENCE.
	LDA	#1	;X INCREMENT
	STA	INCX	;IS 1 (RIGHT)
	BNE	VECSET	;BRANCH!
XMINUS	LDA	PLOTX	;SUBTRACT
	SEC		;DRAWX FROM
	SBC	DRAWX	;PLOTX
	STA	DELTAX	;AND SAVE DIFFERENCE.
	LDA	#255	;X INCREMENT
	STA	INCX	;IS -1 (LEFT)
VECSET	LDA	#0	;ZERO OUT:
	STA	ACCY	;Y ACCUMULATOR
	STA	ACCX	;X ACCUMULATOR
	LDA	DELTAX	;IS DELTAX>
	CMP	DELTAY	;DELTAY?
	BCC	YMAX	;NO!
	STA	COUNTR	;SAVE DELTAX
	STA	ENDPT	;IN COUNTR, ENDPT.
	LSR	A	;DIVIDE BY 2 AND
	STA	ACCY	;STORE IN Y ACCUM.
	JMP	DRAWGO	;START DRAW
YMAX	LDA	DELTAY	;DELTAY LARGER,
	STA	COUNTR	;STORE IT IN
	STA	ENDPT	;COUNTR, ENDPT.
	LSR	A	;DIVIDE BY 2 AND
	STA	ACCX	;STORE IN X ACCUM.

;	-----------------------
;	NOW WE START THE ACTUAL
;	DRAWTO FUNCTION!
;	-----------------------

DRAWGO	LDA	COUNTR	;IF COUNTR=0...
	BEQ	DRWEND	;NO DRAW!
BEGIN	LDA	ACCY	;ADD DELTAY
	CLC		;TO Y ACCUMULATOR
	ADC	DELTAY
	STA	ACCY
	CMP	ENDPT	;AT ENDPOINT YET?
	BCC	BEGIN2	;NO, GO DO X.
	LDA	ACCY	;SUBTRACT ENDPT
	SEC		;FROM Y ACCUMULATOR
	SBC	ENDPT
	STA	ACCY
	LDA	PLOTY	;AND INCREMENT
	CLC		;THE Y POSITION!
	ADC	INCY
	STA	PLOTY
BEGIN2	LDA	ACCX	;ADD DELTAX TO
	CLC		;X ACCUMULATOR
	ADC	DELTAX
	STA	ACCX
	CMP	ENDPT	;AT ENDPOINT YET?
	BCC	PLOTIT	;NO, GO PLOT.
	LDA	ACCX	;SUBTRACT ENDPT
	SEC		;FROM X ACCUMULATOR
	SBC	ENDPT
	STA	ACCX
	LDA	PLOTX	;AND INCREMENT
	CLC		;PLOT X
	ADC	INCX
	STA	PLOTX
PLOTIT	JSR	PLOTCL	;PLOT THE POINT!
	DEC	COUNTR	;MORE TO DRAW?
	BNE	BEGIN	;YES!
DRWEND	RTS		;NO, EXIT!

;	------------------
;	MISCELLANEOUS DATA
;	------------------

GRDTBL	DB	0,1,2,3,4,1,5,3
;		L,I,V,E,W,I,R,E

;	COLORS (0=GRID, 1=OBJ1 2=OBJ2)

C0TBL	DB	$C4,$36,$74,$F6
	DB	$54,$06,$00,$26
C1TBL	DB	$86,$0C,$36,$56
	DB	$26,$C6,$98,$18
C2TBL	DB	$98,$46,$A8,$36
	DB	$84,$18,$C6,$38

;	OBJECT COUNT TABLES (DIFFICULTY)

OBCNT0	DB	0,0,0,0,4,6,8,10
OBCNT1	DB	0,0,0,6,8,9,10,11
OBCNT2	DB	8,10,12,14,16,18,20,22
OBCNT3	DB	6,8,10,11,12,14,15,16
OBCNT4	DB	0,0,4,8,10,12,14,16

;	STICK ADD VALUES

STKADD	DB	0,0,0,0,0,1,1,1
	DB	0,$FF,$FF,$FF,0,0,0,0

;	PROJECTILE DATA

PROJAC	DB	0,0,0,0,0,0,0,0
PROINC	DS	8
PROGRD	DS	8
PROJGN	DS	8
PROJSG	DS	8
PRSTRT	DB	3,7
PREND	DB	$FF,3
MISLON	DB	$03,$0C,$30,$C0
MISLOF	DB	$FC,$F3,$CF,$3F

;	FLASH (OBJECT DEATH) DATA

FLBYTE	DB	$28,$28,$28,$92,$54,$28,$10
	DB	$10,$28,$54,$92,$28,$28,$28
;	OBJECT POINTS (250,200,50,100,150)

POINT1	DB	$02,$02,$00,$01,$01
POINT2	DB	$50,$00,$50,$00,$50

;	SHORT DATA

SHORTF	DS	4
SHORTX	DS	4
SHORTD	DS	4
SHORTT	DS	4

;	OBJECT DATA

OBDEAD	DS	6
OBDED2	DS	6
OBJTYP	DS	6
OBJINC	DS	6
OBJGRD	DS	6
OBJSEG	DS	6
OBJHUE	DB	2,3,2,3,2
SIZEWK	DB	0,0,0,0,0,0,0,0
PXINC	DB	0,0,1,$FF,1,$FF,1,$FF
PYINC	DB	$FF,1,0,0,$FF,1,1,$FF
OBSTBL	DB	18,15,14,12
	DB	11,10,9,7
OBJDIR	DB	4,3,1,2,0,5,$FF,0
	DB	4,5,0,6,0,$FF,0,0
	DB	0,5,6,4,7,1,$FF,0
	DB	6,0,3,1,2,7,$FF,0
	DB	4,6,5,7,5,6,4,$FF
OBJLEN	DB	3,7,7,7,7,7,0,0
	DB	3,7,7,7,7,0,0,0
	DB	3,3,3,3,3,7,0,0
	DB	2,3,3,3,3,3,0,0
	DB	1,1,1,3,1,1,3,0
SIZTBL	DB	0,0,0,0,0,1,1,1
	DB	0,0,0,1,1,2,2,2
	DB	0,0,1,1,1,2,2,2
	DB	0,1,1,2,2,2,2,3
	DB	0,1,1,2,2,2,3,3
	DB	1,2,2,2,2,2,3,3
	DB	1,2,2,2,3,3,3,4
	DB	1,2,2,3,3,3,4,4

;	PLAYER SHAPES

PN1	DB	$10,$10,$10,$10,$10,$10,$10,$10
	DB	$08,$08,$08,$08,$08,$08,$08,$08
PN2	DB	$00,$00,$00,$00,$80,$40,$20,$10
	DB	$08,$04,$02,$01,$00,$00,$00,$00
PN3	DB	$00,$00,$01,$01,$02,$02,$04,$08
	DB	$10,$20,$40,$40,$80,$80,$00,$00

;	SHAPE START/END POINTS

SPTBL	DB	0,1,2,3,4,5,6,7
	DB	8,7,6,5,4,3,2,1
EPTBL	DB	17,16,15,14,13,12,11,10
	DB	9,10,11,12,13,14,15,16

;	JOYSTICK/PADDLE MESSAGE POINTERS

JPLO	DB	JOYMSG&255,PADMSG&255
JPHI	DB	JOYMSG/256,PADMSG/256

;GRID DATA TABLES

CX	DB	14,14,14,14,14,14,14,14
	DB	26,39,51,64,75,88,100,113
	DB	14,14,14,14,14,14,14,14
	DB	14,14,14,14,14,14,14,14
	DB	14,20,26,32,38,43,49,59
	DB	69,78,84,89,95,101,107,113
	DB	113,88,64,39,14,14,14,27
	DB	27,14,14,14,39,64,88,113
	DB	14,14,14,14,14,29,43,58
	DB	70,84,98,113,113,113,113,113
	DB	113,106,100,113,113,100,82,65
	DB	48,32,14,14,14,14,14,14


CY	DB	18,34,52,70,88,105,123,141
	DB	141,141,141,141,141,141,141,141
	DB	18,25,34,42,50,58,67,75
	DB	83,91,100,108,116,125,133,141
	DB	18,39,59,80,101,121,141,141
	DB	141,141,121,101,80,59,39,18
	DB	18,18,18,18,18,35,53,71
	DB	89,106,124,141,141,141,141,141
	DB	18,49,80,111,141,132,123,114
	DB	114,123,132,141,111,80,49,18
	DB	141,110,80,61,38,18,18,18
	DB	18,18,18,43,68,92,117,141

FX	DB	55,55,55,55,55,55,55,55
	DB	58,60,62,64,66,68,70,73
	DB	55,55,55,55,55,55,55,55
	DB	55,55,55,55,55,55,55,55
	DB	55,57,58,59,59,60,61,63
	DB	65,67,68,69,69,70,71,73
	DB	73,68,64,60,55,55,55,57
	DB	57,55,55,55,60,64,68,73
	DB	55,55,55,55,55,58,61,63
	DB	65,67,70,73,73,73,73,73
	DB	73,72,70,73,73,70,67,64
	DB	61,58,55,55,55,55,55,55

FY	DB	67,71,74,77,81,84,87,90
	DB	90,90,90,90,90,90,90,90
	DB	60,62,65,68,71,73,76,78
	DB	81,83,86,89,92,94,97,99
	DB	67,73,77,80,84,88,90,90
	DB	90,90,88,84,80,77,73,67
	DB	67,67,67,67,67,71,74,77
	DB	80,83,86,90,90,90,90,90
	DB	67,74,80,86,90,89,87,86
	DB	86,87,89,90,86,80,74,67
	DB	90,85,80,75,71,67,67,67
	DB	67,67,67,73,78,82,86,90

SHSTRT	DB	0,2
SHYHLD	DS	2
SHOIMG	DB	$88,$50,$20,$50,$88
	DB	$20,$20,$F8,$20,$20
CPYSTN	DB	4,9

ADDSUB	DB	2,$FE	;ADD/SUB. 2
ADDSB1	DB	1,$FF	;ADD/SUB. 1

;	SOUND DATA

FIRCTL	DB	$00,$A1,$A1,$A2,$A2,$A3
	DB	$A3,$A4,$A4,$A5,$A5,$A6
	DB	$A6,$A7,$A7,$A8,$A8,$A9
	DB	$A9,$AA,$AA
FIRFRQ	DB	0,194,166,180,152,166
	DB	138,152,124,138,110,124
	DB	96,110,82,96,68,82
	DB	54,68,40

OBDCTL	DB	$00,$41,$41,$42,$42,$43
	DB	$43,$44,$44,$45,$45,$46
	DB	$46,$47,$47,$48,$48,$49
	DB	$49,$4A,$4A
OBDFRQ	DB	0,80,40,120,80,160
	DB	120,200,160,240,200,24
	DB	240,64,24,104,64,144
	DB	104,204,144

MOVCTL	DB	$00,$A1,$A1,$A2,$A2,$A3
	DB	$A3,$A4,$A4
MOVFRQ	DB	0,20,30,20,30,20,30,20,30

;	DATA TABLES

SEGWK	DS	17
SEGX	DS	256
SEGY	DS	256
RIMX	DS	256
RIMY	DS	256

	END	LIVE
A.N.A.L.O.G. ISSUE 13 / SEPTEMBER 1983 / PAGE 43

Livewire Paddle Default

by Tom Hudson

Recently we received a letter from Joseph J. Wisehart of Worthington, Ohio. He writes:

“I want to thank you for giving us Fill ’Er Up and now the incredible Livewire. I’m glad that there are dedicated people like you that put a large amount of your time and effort into a project so your readers can enjoy themselves. I must admit I bought my ATARI 400 for games only, but since have gotten very interested in programming. I am a very inexperienced programmer, but since dabbling with programming I have become increasingly appreciative of the people who write both game and utility programs. I always play Livewire with a paddle and was wondering if you could help me with a problem. When the game is first turned on the JOYSTICK option is first and after each game I have to push SELECT then the START key. Is there a simple program change that would make the PADDLE option come up on the title page first?”

“Thank you for the many happy hours you and A.N.A.L.O.G. have given our family.”

The change to make Livewire default to paddles on startup is simple. The program listings below replace the old cassette and disk change listings from the original article. Just add these to the first listing in the article and RUN the program. These do not check the data, so it’s a good idea to make these changes after the program runs properly with the old cassette and disk changes.

2 REM *** CASSETTE VERSION ***
20 DIM DAT$(91),HEX(22):FOR X=0 TO 22:READ N:HEX(X)=N:NEXT X:GOTO 70
40 TOTAL=TOTAL+BYTE:NEXT X:READ CHKSUM:GOTO 25
65 IF PASS=2 THEN CLOSE #1:END 
70 ? "READY CASSETTE AND PRESS RETURN";:OPEN #1,8,128,"C:":RESTORE 200:FOR X=1 TO 45:READ N:PUT #1,N:NEXT X
200 DATA 0,36,211,31,245,31,169,60,141,2,211,169,0,141,231,2,133,14,169,56,141,232,2,133,15,169,115
210 DATA 133,10,169,33,133,11,24,96
220 DATA 133,206,169,83,141,202,32,76,139,33
1080 DATA 0000000000000000000000D82065E4A900A27F9580CA10FBA90185A585A44CF61FCA20A9218DCB20A9008D2F02,22765
2000 DATA 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,439855
2010 DATA 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,439855
2 REM *** DISK VERSION ***
20 DIM DAT$(91),HEX(22):FOR X=0 TO 22:READ N:HEX(X)=N:NEXT X:GOTO 70
40 TOTAL=TOTAL+BYTE:NEXT X:READ CHKSUM:GOTO 25
65 IF PASS=2 THEN PUT #1,224:PUT #1,2:PUT #1,225:PUT #1,2:PUT #1,115:PUT #1,33:CLOSE #1:END 
70 ? "INSERT DISK WITH DOS, PRESS RETURN";:DIM IN$(1):INPUT IN$:OPEN #1,8,0,"D:AUTORUN.SYS"
90 RESTORE 90:FOR X=1 TO 16:READ N:PUT #1,N:NEXT X:DATA 255,255,246,31,142,49,133,206,169,83,141,202,32,76,139,33
1080 DATA 0000000000000000000000D82065E4A900A27F9580CA10FBA90185A585A44CF61FCA20A9218DCB20A9008D2F02,22765