A.N.A.L.O.G. ISSUE 23 / OCTOBER 1984 / PAGE 39

Fire Bug

16K Cassette or 24K Disk

by Tom Hudson and Kyle Peacock

You say you want action? You say you want great sound effects, great graphics, good playability and, above all, fine scrolling? What’s that? You say you want all that and more for your three dollars? No problem. Here’s a little something Tom and I threw together in three weeks that should satisfy all your honking and tooting.

Typing it in.

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

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

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

Follow the instructions below to make either a cassette or disk version ot Fire Bug.

Cassette instructions.

  1. Type Listing 1 into your computer using the BASIC cartridge and verity your typing with C:CHECK (see page 25).
  2. Type RUN and press RETURN. The program will begin and ask:
    MAKE CASSETTE (0) OR DISK (1)? Type 0 and press RETURN. The program will begin checking the DATA statements, printing the line number of each as it goes. It will alert you if it finds any problems. Fix any incorrect lines and re-RUN the program, if necessary, until all errors are eliminated.
  3. When all of your DATA lines are correct, the computer will beep twice and prompt you to READY CASSETTE AND PRESS RETURN. Now, insert a blank cassette in your recorder, press the RECORD and PLAY buttons simultaneously and hit RETURN. The message WRITING FILE will appear, and the program will create a machine language boot tape version of Fire Bug, 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 Fire Bug 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 25).
  2. Type RUN and press RETURN. The program will ask:
    MAKE CASSETTE (0) OR DISK (1)? Type I 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. Fire Bug will load and run automatically.

Playing the game.

Fire Bug is a one-player game that requires a joystick in port one. To begin the game, press the START key while the opening credits are being displayed. (Tom and I had a hard time deciding whose name would go first.) You can select which level you wish to start on by pressing the corresponding number, 1 through 9. Pausing of the game is accomplished by pressing the spacebar. Hitting the spacebar a second time will resume the game.

Many years ago, a species of insect inhabited the subterranean chambers of Earth. Here, the “fire” species flourished for some four million years. Every two thousand years, the entire population expired, with the exception of one female. This female Fire Bug served as guardian over the dispersed fire nests of the underground. For eighty years, she defended these nests and their immature eggs from natural predators. Capable of emitting small, lethal “sparks,” she combed Earth’s interior with an ever-watchful eye. Such an instinct kept her species alive for aeons before man emerged on the surface of the world.

Now the Fire Bug is threatened with extinction. Man’s nuclear wastes have infested the soil and mutated the predators of the Fire Bug into hideous, unstoppable bug-eating machines. These new super predators have the capacity to reproduce at astounding rates. Should they happen upon a Fire Bug nest, escape for the fire eggs is doubtful, if not impossible.

As fate would have it, you are the last remaining female Fire Bug. You must defend the nests and pave the way for your species’ next generation. To further outline your eighty-year objective, the following illustrations will help you distinguish friend from foe.

            
          
            
                
              
          
                
              
          
This is your Fire Bug. It has the capability to burrow tunnels and fire sparks. Burrowing through the soil requires greater effort, thus your Fire Bug will travel more slowly through soil than through already existing tunnels. Coming in contact with any of the enemy predators will lead to instant vaporization. Use your Fire Bug carefully; you only have five lives!



          

              
              

          
This is a spark. It will destroy a predator or create a partial tunnel. They have a limited range, which is usually just beyond the screens edge. The small bar graph at the bottom of the screen dictates how many sparks remain to you. Sparks regenerate one every two seconds while the Fire Bug is burrowing. The regeneration rate is one every four seconds while standing still or traveling through an already existing tunnel.

          
              
          
                
                
          
              
          
This is a fire egg. Initially, several eggs will be grouped in a small fire nest. Fire eggs do not have the capability to create their own tunnels; they will, however, travel through already existing ones. These eggs make a delightful snack for a lucky predator. The innocent “tweets” of a perishing egg would bring tears to any Fire Bug’s eye. Should all the fire eggs be destroyed or eaten, the fire species will terminate, and the game will end.

          
            
        
          
            
              
              
            
This is a proximity bomb, a product of man’s nuclear waste. It is highly unstable. Should your Fire Bug tunnel next to or shoot past a proximity bomb, the device will detonate shortly thereafter. Being caught in the explosion radius is just as lethal as being chewed by a predator. Caution should be exercised with this nuclear trash, as closely grouped bombs may set off a chain reaction.

        
          
          
                  
                
        
        
          
This is a super predator, class one. They have the capability to create their own tunnels. They thrive on fire eggs, as well as Fire Bugs. They can be destroyed by a spark or the debris of a detonating proximity bomb. During mating season, should two of these bugs come in contact with one another, they will create four class two predators. Mating season occurs once every one hundred seconds.

            
              
          
        
        
      
    
    
This is a super predator, class two. They follow the same rules and restrictions as their class one counterparts. Should two class two bugs come in contact with one another, they will create four class one predators. The gurgling sound of mating predators strikes fear into a Fire Bug’s heart.



This month’s public domain assembly language game should keep you busy for thirty days. Next month, Tom and I will be taking the BASIC spotlight with BASIC Training and Bopotron! Don’t miss it. Aloha!

BASIC listing.

10 REM *** FIREBUG ***
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,36:CLOSE #1:END 
160 FOR X=1 TO 92: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,36:PUT #1,251:PUT #1,54: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,7,255,7,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,36,133,10,169,8,133,11,24,96
1000 DATA A9248589A9088581A90085888580A000B188918088D0F9E681E689A589C938D0ED4C2408A9228D2F02A90485C7,700
1010 DATA A90185BBA90185CD8D06D08D07D085BF201013A906A20BA0AC205CE4A907A20CA068205CE4A9C08D0ED4AD1FD0,938
1020 DATA C907F0068D69094C5708AD6909C906F02CAD0FD22904F0E5ADFC02A208DD6009F005CA10F830D686BBE6BB86BD,465
1030 DATA E6BD20D21A20E112A9FF8DFC024C5708A9008D6909204910A90085BF85CDAD1FD0C907F0034C3108ADFC02C921,450
1040 DATA D026AD0FD22904F01FA90185BF8DFC02201013ADFC02C921D0F9AD0FD22904F0F9A90085BF8DFC02A5DFD007A9,76
1050 DATA 0185DF206519A5E0D007A90385E0202318A5D9D00F20380BA5A2F004A90BD002A90885D9A5D8F010A5CAD00CA9,400
1060 DATA 3C85CAC6C9D004A90085D8A5BEF0034CA508A5BC4AC9109002A90FAABD500985BE20880920161AA5E4D014E6BC,812
1070 DATA F8A5BD18690185BDD820D21A2004134C9F084CA50814131211100F0E0D0C0B0A09080706051F1E1A181D1B3335,368
1080 DATA 3000A5988590A5998591201C19C6E3300920DD1A2004134C9F082004134C3108A90085E4A21D86D5BD1E05D003,441
1090 DATA 4C310ABD5A05858EBD7805858FA000B18EDD0005F018A9009D1E05A90C38FD000529060A0A0A859F20951A4C31,251
1100 DATA 0AA9008D69138D6B13A5D8D008A901BC0005996113A90385D6A4D6BD5A0518795913858EBD7805795D13858FA0,883
1110 DATA 00B18E297F85D3A8B96113F012B97413C9FFD00BA5D69D3C05206C0A4C310AC6D610C9A90485D2BD3C051005AD,915
1120 DATA 0AD229039D3C0520410A1009C6D210EAA9FF9D3C05A6D5BD1E05F002E6E4CA30034C8E0960A8BD5A0518795913,421
1130 DATA 858EBD7805795D13858FA000B18E297F85D3A8B96113D003A9FF60B97413CD0AD290F5BD5A058588BD78058589,981
1140 DATA A900A89188C8918888BD0005918EC8186901918EA58E9D5A05A58F9D7805A5D3DD0005F0034C2D0BA9009D1E05,801
1150 DATA BD0005C908D008A90785A3A90AD006A90785A4A90885D7A90385D6A4D6A58E187959138588A58F795D138589A0,980
1160 DATA 00B188297FC901F04AC906F054C908F042C90AF03EC90CF048C90FF036A21DBD1E05F00ECA10F8A90185D8A964,494
1170 DATA 85C94C2A0BA9019D1E05A9FF9D3C05A5889D5A05A5899D7805A5D79D00059188186901C89188C6D630034CBE0A,275
1180 DATA A90060C906D0F9686868684C6A09A5988588A5998589A000B188C906F002D030AE7802BC8713100160A5981879,376
1190 DATA 5913858EA599795D13858FA000B18EC901F0E8C90CF0E4C90FB0E0C9069009C90EF00568684C6A09C900F00AC9,907
1200 DATA 0EF006A90185A2D004A90085A2A90E9188C8918888A906918EC8186901918EA58E8598A58F859960D8A207AD0A,318
1210 DATA D229559D8804CA10F5A5CD0AAABD850C8D3002BD860C8D3102A9918D0002A90C8D0102CE350E102DAD0AD2293F,629
1220 DATA 090F8D350EEE340EAD340E29010A0AAABD890C8D990EBD8A0C8D9A0EBD8B0C8DA10EBD8C0C8DA20EA5BFD05885,29
1230 DATA 4DCE320E1030AD7802C90FD004A200F002A6A2BD2F0E8D320EEE330EAD330E2901F013A6B9BDE00EC914D007E0,630
1240 DATA 1DF006E6B9E8DEE00EA5CAF002C6CAA5E0F002C6E0A5DFF002C6DFA5BEF002C6BEA5D9F002C6D920751420940F,513
1250 DATA 4C5FE4D8207215A5BFD01220DF0C20080D204D0D20720D20910D20BE0D4C62E4360E8A0E440F6C0F6C0F440F48,9
1260 DATA 8A489848A904A23FA4CE8D0AD48E00D48C1AD08D09D4A9B88D0002A90C8D010268A868AA684048ADC8028D0AD4,9
1270 DATA 8D1AD0AD2F028D00D4A9D48D0002A90C8D0102684048A9E08D0AD48D09D46840A5A2F013CE310E101FA9038D31,598
1280 DATA 0EA6BABD7802C90FD007A9008D01D2F00AA9468D01D2A9DC8D00D260A6A31007A9008D03D2F00DBD3D0D8D02D2,648
1290 DATA A9A48D03D2C6A3A6A4100BA5A31014A9008D03D2F00DBD450D8D02D2A9A48D03D2C6A460F0A050000F5FAFFFD2,192
1300 DATA 8C46002D73B9FFA6C81009A5A31004A5A430CF60BD680D8D02D2A9A68D03D2C6C8600008101820282F373F47A6,785
1310 DATA A51006A9008D05D260BD8A0D8D04D2A9AA8D05D2C6A56012396188B0D7FFA6A61005A5A530DD60BDA80D8D04D2,169
1320 DATA A98C8D05D2C6A660F4E8DCD1C5BAAEA2978B8074685D51463A2E23170C00A6DE1011A93020E50DA5A61007A5A5,570
1330 DATA 10034C760D60BDEC0D8D04D2A98A8D05D2C6DEAD0AD229708D360E8D370E6000FDF9F5F1EDEAE6E2DEDAD6D3CF,816
1340 DATA CBC7C3BFBCB8B4B0ACA8A5A19D9995918E8A86827E7B77736F6B6764605C5854504D4945413D3936322E2A2622,156
1350 DATA 1F1B17130F0B0804783C0000000000303030303030C61C0F44B00E740000740000740000740000740000740000,957
1360 DATA 740000740000740000740000740000740000740000740000740000740000740000740000740000540000C4B00E,935
1370 DATA 00C4E00E200641360E7070707070471C0F707046300F70476C0F7046580F7047440F70707046800F7046080F41,247
1380 DATA 8A0E01010101010101010101010101010101010101010101010101010101010101010101010101010101010101,442
1390 DATA 010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000,447
1400 DATA 404040404040406C766C5A808080A2B5A7B39A8000000000000066697265006275670000000000000000000000,414
1410 DATA 3732293434252E00223900000000000000000000B4AFAD00A8B5A4B3AFAE000000000000000000000000000006,413
1420 DATA 0000000000000000000000000000EBF9ECE500F0E5E1E3EFE3EB000000000000616E616C6F6700636F6D707574,274
1430 DATA 696E670000A00DA9138DC60FA5C00AAABDC80FC9FFD002A200BDC70F1865C199360EBDC80F690099370EE8E898,365
1440 DATA 186903A8CEC60F10DA600000208020002180210022802200238023002480240025802500268026002780270028,46
1450 DATA 802800298029002A802A002B802B002C802C002D802D002E802E002F802F003080300031803100328032003380,583
1460 DATA 33003480340035803500368036003780370038803800398039003A803A003B803B003C803C003D803D003E803E,296
1470 DATA 003F803FFFFFA9048589A20D86DDA6DDBDC51385888A0A0A0AAAA000BDD3139188E8C8C008D0F5C6DD10E3A900,208
1480 DATA 85BA85A185A085C3A202959A959DCA10F9A90185C485D0A95485C5A92B85C6A90385CF85D1A20486E3A5BB85BC,702
1490 DATA 85BDBD261395E8CA10F8A93E8D2F02A9008D07D4A9038D1DD0A9218D6F02A9F08D0CD0A9288D06D0A9CC8D07D0,136
1500 DATA A900AA9D0003E0C9B00BE0309007A9F09D0003A900CAD0EB201013A20186BF8EFC02CACA86A386A486A586A686,736
1510 DATA DE86C8A5C385C1A5C485C0A90085A7A203A9FF95B1CA10F9A213A9149DEA0ECA10FAA91D85B9A2008A0AA8B9C7,136
1520 DATA 0F8580B9C80F8581C9FFF013A07FA90420431418690291808810F3E84C1F11A200A000BD3513996F14E8C8C006,20
1530 DATA D0F4AD6F1485CBAD701485CC205714A000989180AD6F14CD7114D008AC7014CC7214F014186D73148D6F14AD70,63
1540 DATA 14186D74148D70144C5311E02490B8A6BCE00B9002A20ABD2A1385DCAAA93A2043141869030AA8B9C70F85809D,542
1550 DATA 9605B9C80F85819DFA05A9732043141869060901A8B180F0D7C90FF0D3A90F9180186901C891808898187D9605,566
1560 DATA 9D9605A9FF9D5E06CA10B8A200BDC80FC9FFF0158581BDC70F8580A001989180A07F9180E8E84CE511CACABDC7,894
1570 DATA 0F8580BDC80F8581ADC70F8586ADC80F8587A07FA901918091868810F920A71A20D21A20DD1AA21DA9009D1E05,880
1580 DATA CA10FAA203A9019D1E05A9FF9D3C05BD97139D7805858FBD9B139D5A05858EA9089D0005A000918EC818690191,589
1590 DATA 80CA10D4A90085D8A5BC38E9014A4A4A85E5A90338E5E585E7AABDC11385E585D485E6A6E7BDB9138588BDBD13,39
1600 DATA 8589A20CA588187D9F13858EA4E699C206A5897DAC13858F99F606A901992A07A000A90C918EC8186901918EC6,247
1610 DATA E6CA10D3C6E710C1A9208599858FA9838598858EA906A000918EC8186901918E20E112A90085BF60AD0AD229F0,944
1620 DATA 090285CEA204AD0AD229F01D21139DC402CA10F2ADC5028DC2028DC30260A514186946C514D0FC4CE2102065E4,913
1630 DATA A207A9009D00D2CA10FA8D08D260080A080400000405060709131D27313B454F59633F0C3F1F0001400C401F00,474
1640 DATA 013F213F34000140214034000129203E200100412056200100800280FEFF0000FF010001010101010000000000,313
1650 DATA 01000100000000E00040404040FF00FF00FF00FF00FF00000000FFFFFFFFFFFFFF01FFFFFF03FF0200FF2E3030,278
1660 DATA 31BF3945BF008080FE02827E7E8204FC00000000FFFF00FF00FF0000FFFF011F5F1F5F283838280C1926330008,224
1670 DATA 10182028707880A0A8B0B8C00000000000000000AAAAFFFFFFFFAAAA1001000440000140001001400400110040,592
1680 DATA 0100044001001010010040011000040000000000000000010401020B2F2F0A40100580E0F8F8A0FF6666666666,761
1690 DATA 66FFFF646464646464FFFF606060606060FFFF404040404040FFFF000000000000FFF0108D5614AD0AD2CD5614,925
1700 DATA 90054A4A4C4B1460008E5614A5CC0AAABDC70F1865CB8580BDC80F8581AE561460000000000000A599CD590EB0,122
1710 DATA 04A900F007CD680E900AA9018D6E15A2048E7015AD7015F041AD6E15D018C6A11038A5C0C5C4D005E6A14CD014,138
1720 DATA A90785A1C6C04CCA14E6A1A5A1C908901CA5C0C5C6D005C6A14CD014A90085A1E6C0CE70154CD514A9008D7015,998
1730 DATA A5A18D05D4AD580E297F8D6D15A598297F38ED6D15C91E9004A900F006C90FB00AA9018D6F15A90C8D7115AD71,685
1740 DATA 15F041AD6F15F01CE6A0A5A0C9049034A5C1C5C3D005C6A04C4115A90085A0C6C14C3B15C6A0101CA5C1C5C5D0,554
1750 DATA 05E6A04C4115A90385A0E6C1CE71154C4615A9008D7115A5A08D04D4A6BABC7802C00FF00ACC6215F005B95E15,619
1760 DATA 85E88C62156000030101000200020003000000000000A5C78DDD15AEDD15B4E8B5EDD9E1159005B9E01595EDD9,989
1770 DATA E01590F60AA8B9F315858AB9F415858BADDD150AA8B9E915858CB9EA15858DA00FB18A918C8810F9CEDD1510C1,96
1780 DATA CEDE151010A5CF8DDE15A6BABD7802C90FF002E6EDCEDF15100CA5D18DDF15A6C7F6EDCAD0FB60000303000408,781
1790 DATA 0C10151F25283004400450046004900443165316631653167316831693168316A316B316C316B316D316E316F3,951
1800 DATA 16E3160317131723173317431753176317731783179317A3179317831773176317B317C317D317E317D317C317,328
1810 DATA F317031813180C0209C235CA3502308060835CA35C8003020902F50AF502C08060805FA05F800C02090235CA35,942
1820 DATA C2308060805CA35C830C3319999919330CC0002398982300C033331999991933330000209B9B200000CC331999,621
1830 DATA 991933CC00002398982300000300C82626C8000330CC64666664CC30000008E6E6080000CCCC64666664CCCC00,514
1840 DATA 00C82626C8000033CC64666664CC330235CA35C209020C805CA35C8360803002F50AF502090203805FA05F8060,529
1850 DATA 80C0C235CA350209020C835CA35C80608030300C02090932C00000038C606080300C00F00E09090E30300C0CB0,681
1860 DATA 6060B00F000000F20909020C0C30308060608F000003000239C902030000C080636C8000C00C03020939C20000,301
1870 DATA 0000836C6080C030000000010108A020080A204040000000000000010128080000202840400000000000000109,644
1880 DATA 0200000000806040000000000002090100000000000040608000000008280101000000000000404028200020A0,676
1890 DATA 0801010000000000004040200A08000000ABAB000000000000EAEA00000000000E28280E00000000B02828B000,214
1900 DATA 000032020808023200008C802020808C00C2020200000202C28380800000808083000000020200000000000080,236
1910 DATA 8000000000000104040100000000401010400000000300303000030000C0000C0C00C0002029184C7E18C6D0D0,981
1920 DATA 50A90385D0A6BABD10D0D045B5A7C905B03FADEA0EC918F038A203B5B1C9FFF006CA10F74C7D18E6A7A59895A9,298
1930 DATA A59995ADA5E895B1A91495B5A90685A5A6B9FEE00EBDE00EC918D008A5B9C90AF002C6B960A203B5B1C9FFD003,836
1940 DATA 4C0419B5A98584B5AD8585A000B184C912F004C911D007A90E9184C89184B5B11009A9FF95B1C6A74C0419A8B5,430
1950 DATA A9187914198584B5AD7918198585A000B184297FF026C90EF02248A98095B168C901F02DC90FF029C90CF02520,553
1960 DATA 0B19A9119184C89184A91585A6D015A9129184C81869019184200B19D6B51004A901D0C9CA30034C801860A584,254
1970 DATA 95A9A58595AD608002FE80FF00FF00A90085DAA94285DEA91185DBA5DAC90D900738E90DA00084DBAAA590187D,147
1980 DATA 9F138592A5917DAC138593A000A5DB9192C89192205A19E6DAA5DAC91AD0CB60A203A0FF88D0FDCAD0F860A6DC,865
1990 DATA BD5E06C9FFD04CBD96058594BDFA058595A000B194C90FF016C90CD007A9809D5E06D02FA90F9194A910C89194,600
2000 DATA D01FA003A594187959138596A595795D13859784C2A000B196C912F004C906D00AA93C9D5E06CA10AA3008A4C2,671
2010 DATA 8830F64C9819A6DCBD5E063044BD96058590BDFA058591A000B190D004A90FD004A98051909190C81869019190,7
2020 DATA A9008D06D2A9888D07D2DE5E06D015A9008D07D2A9809D5E0686DD84C2201C19A6DDA4C2CA10B460A6E586E6BD,781
2030 DATA 2A07D0034C721ABDC2068588BDF6068589A000B188C90CF015C6D4300CA9009D2A07A90985C84C721A68684C82,559
2040 DATA 09A90385D2AD0AD22903A8BDC20618795913858EBDF606795D13858FA000B18EF00CC90EF008C6D210DBCA10A3,773
2050 DATA 60A90E9188C8918888A90C918EC8186901918EA58E9DC206A58F9DF6064C721AA000F818A202B59A759D959A94,288
2060 DATA 9DCA10F5D8A91085E1A200A000B99A0020BD1AE8E8C8C003D0F36085E2290F05E19D090FA5E24A4A4A4A05E19D,881
2070 DATA 080F60A05084E1A5BDA20B4CBD1AA5E3300509908D1B0F60000000000000000000000000000000000000000000,292

Assembly listing

	.OPT	NO	LIST
;
; *************************
; *        FIREBUG        *
; *    by Kyle Peacock    *
; *     &  Tom Hudson     *
; *   ANALOG  Computing   *
; *  All Rights Reserved  *
; *************************
;
;  Redefined Characters by
;    Jon Bell -- 6/26/84
;
; CONSTANTS
;
GAMESET	=	$0400	;CHARACTER SET
PLAYBS	=	$00	;P/M BASE ADDR.
SCREENBASE	=	$2000	;BOARD RAM.
MISS	=	PLAYBS+768	;MISSILEs
BOMB	=	15
;
; ZERO PAGE USAGE
;
	*=	$80
LO	*=	*+2	;2-BYTE POINTERS
BMB	*=	*+2
ZLO	*=	*+2	;Z-PAGE POINTER.
LOW	*=	*+2	;Z-PGAE POINTER.
HLO	*=	*+2
DRWLO	*=	*+2	;CHAR DATA PNTR.
PLLO	*=	*+2	;CHAR WORK PNTR.
ADL	*=	*+2
ELO	*=	*+2
ELO2	*=	*+2
BLO	*=	*+2
BLO2	*=	*+2
BUGL	*=	*+2	;FIREBUG X & Y.
SCORE	*=	*+3	;BCD SCORE VALUE
SCOADD	*=	*+3	;SCORE ADD VALUE
HBIT	*=	*+1	;HSCROL RAM COPY
VBIT	*=	*+1	;VSCROL RAM COPY
DIGGIN	*=	*+1	;DIGGING FLAG
CHANGE1	*=	*+1	;MATING SOUND 1.
CHANGE2	*=	*+1	;MATING SOUND 2.
BULLNOISE	*=	*+1	;BULLET NOISE
BOOMNOISE	*=	*+1	;BULLET NOISE
NOBULL	*=	*+2	;SPARKS FIRED.
BULLX	*=	*+4	;SPARK X-COORD.
BULLY	*=	*+4	;SPARK Y-COORD.
BULLDIR	*=	*+4	;SPARK DIRECT.
BULLTIME	*=	*+4	;SPARK LIFE
BULLPNT	*=	*+1	;BAR LINE PNTR.
PLAYNO	*=	*+1	;PLAYER UP.
STARTLEVEL	*=	*+1	;STARTING LVL.
LEVEL	*=	*+1	;CURRENT LEVEL
BCDLVL	*=	*+1	;BCD LEVEL #
TIMER	*=	*+1	;GENERAL TIMER
VSTOP	*=	*+1	;HALT FLAG.
YPOINT	*=	*+1	;BOARD Y-COORD.
XPOINT	*=	*+1	;BOARD X-COORD.
YTEMP	*=	*+1	;Y-REG TEMP HOLD
MINX	*=	*+1	;MIN X VALUE
MINY	*=	*+1	;MIN Y VALUE
MAXX	*=	*+1	;MAX X VALUE
MAXY	*=	*+1	;MAX Y VALUE
MAXBUGS	*=	*+1	;# OF CHARs
EATNOISE	*=	*+1	;EATING SOUND
GENTIM	*=	*+1	;MATING TIMER
GENCTR	*=	*+1	;MATING COUNTER
XCOORD	*=	*+1	;X COORDINATE
YCOORD	*=	*+1	;Y COORDINATE
LISTPOINT	*=	*+1	;D-LIST PNTR.
NEWBACK	*=	*+1	;BOARD B-COLOR.
MOVETIME	*=	*+1	;MOVEMENT TIMER.
FIRETIME	*=	*+1	;FIRING TIMER.
PHASETIME	*=	*+1	;PHASE TIMER.
ETRY	*=	*+1
OLDVAL	*=	*+1	;OLD CHAR
EGGS	*=	*+1	;BABY COUNT
ENIX	*=	*+1	;ENEMY INDEX
GNEWIX	*=	*+1	;GENERATION INDX
NEWTYP	*=	*+1	;NEW ENEMY TYPE
GENFLG	*=	*+1	;MATING FLAG
BUGTIM	*=	*+1	;BUG TIMER
EXPPH	*=	*+1	;EXPLOSION PHASE
EXPCHR	*=	*+1	;EXPL. CHARACTER
BOMBCT	*=	*+1	;# OF BOMBS
XTEMP	*=	*+1	;X SAVE AREA
EXNOISE	*=	*+1	;EXPLOSION SOUND
ARMTIM	*=	*+1	;BOMB ARM TIMER
BULTIM	*=	*+1	;BULLET TIMER
SHCOLR	*=	*+1	;TEXT COLOR
SHOBYT	*=	*+1	;TEXT CHAR
LIVES	*=	*+1	;# OF BUGS LEFT
ECOUNT	*=	*+1	;# OF BABIES
EGGTOT	*=	*+1	;# OF EGGS
EGGIX	*=	*+1	;BABY INDEX
EGROUP	*=	*+1	;BABY GROUP #
TYPE	*=	*+5	;CHAR. TYPE.
PHASE	*=	*+5	;CHAR. PHASE.
;
; RAM USAGE
;
	*=	$0500
ETYP	*=	*+30	;ENEMY TYPE
EACT	*=	*+30	;ENEMY ACTIVE
EDIR	*=	*+30	;ENEMY DIRECTION
EADL	*=	*+30	;ENEMY ADDR LO
EADH	*=	*+30	;ENEMY ADDR HI
BOMBL	*=	*+100	;BOMB ADDR LO
BOMBH	*=	*+100	;BOMB ADDR HI
ARMED	*=	*+100	;BOMB ARMED FLAG
EGGL	*=	*+52	;BABY ADDR LO
EGGH	*=	*+52	;BABY ADDR HI
EGGACT	*=	*+52	;BABY ACTIVE
; **********************
; * MASTER EQUATE FILE *
; **********************
;
; I/O Routines
;
DSKINV	=	$E453
SIOINV	=	$E465
;
; Operating System Equates
;
CASINI	=	$02
DOSVEC	=	$0A
DOSINI	=	$0C
ATRACT	=	$4D
POKMSK	=	$10
BRKKEY	=	$11
RTCLOK	=	$12
VDSLST	=	$0200
VIMIRQ	=	$0216
CDTMV1	=	$0218
CDTMV2	=	$021A
CDTMV3	=	$021C
CDTMV4	=	$021E
CDTMV5	=	$0220
CDTMA1	=	$0226
CDTMA2	=	$0228
CDTMF3	=	$022A
CDTMF4	=	$022C
CDTMF5	=	$022E
SRTIMR	=	$022B
SDMCTL	=	$022F
SDLSTL	=	$0230
SDLSTH	=	$0231
SSKCTL	=	$0232
LPENH	=	$0234
LPENV	=	$0235
GPRIOR	=	$026F
PADDL0	=	$0270
STICK0	=	$0278
STICK1	=	$0279
STRIG0	=	$0284
SHFLK	=	$02BE
PCOLR0	=	$02C0
COLOR0	=	$02C4
COLOR1	=	$02C5
COLOR2	=	$02C6
COLOR3	=	$02C7
COLOR4	=	$02C8
MEMLO	=	$02E7
CHART	=	$02F3
CHBAS	=	$02F4
CH	=	$02FC
DDEVIC	=	$0300
DUNIT	=	$0301
DCOMND	=	$0302
DSTATS	=	$0303
DBUFLO	=	$0304
DBUFHI	=	$0305
DTIMLO	=	$0306
DBYTLO	=	$0308
DBYTHI	=	$0309
DAUX1	=	$030A
DAUX2	=	$030B
ICCOM	=	$0342
ICBAL	=	$0344
ICBAH	=	$0345
ICBLL	=	$0348
ICBLH	=	$0349
ICAX1	=	$034A
ICAX2	=	$034B
CIOV	=	$E456
SIOV	=	$E465
SETVBV	=	$E45C
SYSVBV	=	$E45F
XITVBV	=	$E462
OSRETN	=	$E474
CLICK	=	$FCD8
;
; Hardware Registers
;
HPOSP0	=	$D000
HPOSP1	=	$D001
HPOSP2	=	$D002
HPOSP3	=	$D003
M0PF	=	$D000
M1PF	=	$D001
M2PF	=	$D002
M3PF	=	$D003
HPOSM0	=	$D004
HPOSM1	=	$D005
HPOSM2	=	$D006
HPOSM3	=	$D007
P0PF	=	$D004
P1PF	=	$D005
P2PF	=	$D006
P3PF	=	$D007
M0PL	=	$D008
M1PL	=	$D009
M2PL	=	$D00A
M3PL	=	$D00B
P0PL	=	$D00C
P1PL	=	$D00D
P2PL	=	$D00E
P3PL	=	$D00F
SIZEP0	=	$D008
SIZEP1	=	$D009
SIZEP2	=	$D00A
SIZEP3	=	$D00B
SIZEM	=	$D00C
GRAFP0	=	$D00D
GRAFP1	=	$D00E
GRAFP2	=	$D00F
GRAFP3	=	$D010
TRIG0	=	$D010
GRAFM	=	$D011
COLPM0	=	$D012
COLPM1	=	$D013
COLPM2	=	$D014
COLPM3	=	$D015
COLPF0	=	$D016
COLPF1	=	$D017
COLPF2	=	$D018
COLPF3	=	$D019
COLBK	=	$D01A
PRIOR	=	$D01B
VDELAY	=	$D01C
GRACTL	=	$D01D
HITCLR	=	$D01E
CONSOL	=	$D01F
POT0	=	$D200
AUDF1	=	$D200
AUDF2	=	$D202
AUDF3	=	$D204
AUDF4	=	$D206
AUDC1	=	$D201
AUDC2	=	$D203
AUDC3	=	$D205
AUDC4	=	$D207
AUDCTL	=	$D208
ALLPOT	=	$D208
KBCODE	=	$D209
STIMER	=	$D209
RANDOM	=	$D20A
SERIN	=	$D20A
SKREST	=	$D20A
POTGO	=	$D20B
SEROUT	=	$D20C
IRQEN	=	$D20E
IRQST	=	$D20E
SKCTL	=	$D20F
SKSTAT	=	$D20F
PORTA	=	$D300
DMACTL	=	$D400
CHACTL	=	$D401
DLISTL	=	$D402
DLISTH	=	$D403
HSCROL	=	$D404
VSCROL	=	$D405
PMBASE	=	$D407
CHBASE	=	$D409
WSYNC	=	$D40A
VCOUNT	=	$D40B
PENH	=	$D40C
PENV	=	$D40D
NMIEN	=	$D40E
NMIRES	=	$D40F
NMIST	=	$D40F
;
	*=	$0800	;prog start
;
; *****************************
; *     FIREBUG IGNITION      *
; * Tom Hudson & Kyle Peacock *
; *****************************
;
	.LOCAL
;
BICFLICK
	LDA	#$24	;RELOCATE PROG
	STA	HLO+1	;TO $0800
	LDA	#$08	;FROM $2400
	STA	LO+1	;(DISK ONLY)
	LDA	#0
	STA	HLO
	STA	LO
RELOC1	LDY	#0
RELOC2	LDA	(HLO),Y
	STA	(LO),Y
	DEY
	BNE	RELOC2
	INC	LO+1
	INC	HLO+1
	LDA	HLO+1
	CMP	#$38
	BNE	RELOC1
	JMP	DIGIN
DIGIN
	LDA	#$22	;TURN ON...
	STA	SDMCTL	;SCREEN
	LDA	#$04	;NUMBER OF CHARs
	STA	MAXBUGS	;TO MANIPULATE.
	LDA	#$01	;STARTING LEVEL
	STA	STARTLEVEL	;IS ONE.
IGNITE
	LDA	#$01	;SET UP.
	STA	LISTPOINT	;DISPLAY LIST.
	STA	HPOSM2	;PLACE BORDERS
	STA	HPOSM3	;OFFSCREEN.
	STA	VSTOP	;HALT VBLANK.
	JSR	SOUNDOFF	;SOUNDS OFF.
	LDA	#$06	;SET ACC.
	LDX	#VBLANK/256	;HI ADDR.
	LDY	#VBLANK&255	;LO ADDR.
	JSR	SETVBV	;VBLANK INIT.
	LDA	#$07	;SET ACC.
	LDX	#DBLANK/256	;HI ADDR
	LDY	#DBLANK&255	;LO ADDR.
	JSR	SETVBV	;DBLANK INIT.
	LDA	#$C0	;SET ACC.
	STA	NMIEN	;ENABLE DLIs
?NOPRESS
	LDA	CONSOL	;GET CONSOLE.
	CMP	#7	;UNTOUCHED?
	BEQ	?PRESS	;IF =0 BRANCH!
	STA	?PREV	;SAVE CONSOLE.
	JMP	?NOPRESS	;JUMP ON IT!
?PRESS
	LDA	?PREV	;PREV. CONSOLE.
	CMP	#6	;START PRESSED?
	BEQ	?VAROOM	;IF =6 BRANCH!
	LDA	SKSTAT	;KEYBOARD KEY
	AND	#$04	;STILL PRESSED?
	BEQ	?NOPRESS	;IF =0 BRANCH!
	LDA	CH	;GET CHARACTER.
	LDX	#$08	;SET INDEX-X.
?NUMCOMP
	CMP	?NUMBASE,X	;IS CHAR A #?
	BEQ	?GOTANUM	;YES! BRANCH!
	DEX		;NO. RESET PNTR.
	BPL	?NUMCOMP	;HANDLE ALL.
	BMI	?NOPRESS	;NO #s PRESSED.
?GOTANUM
	STX	STARTLEVEL	;SAVE START-
	INC	STARTLEVEL	;ING LEVEL #.
	STX	BCDLVL
	INC	BCDLVL
	JSR	SHOLVL
	JSR	SETCOLORS
	LDA	#$FF	;RESET KEYBOARD
	STA	CH	;CHARACTER.
	JMP	?NOPRESS	;JUMP ON IT.
?VAROOM
	LDA	#$00
	STA	?PREV	;RESET PREVIOUS.
	JSR	INIT	;INITIALIZE
NEWLVL
	LDA	#$00	;CLEAR.
	STA	VSTOP	;START VBLANK.
	STA	LISTPOINT	;SET DISPLAY.
MAINLN
;
; GAME PAUSED?
;
	LDA	CONSOL	;CONSOLE BUTTON.
	CMP	#$07	;UNTOUCHED?
	BEQ	?PCHECK	;YES. BRANCH!
	JMP	IGNITE	;RESTART ALL!!!
?PCHECK
	LDA	CH	;IS KEYBOARD
	CMP	#$21	;SPACEBAR?
	BNE	?PAUSE	;IF NOT, BRANCH!
	LDA	SKSTAT	;STILL HOLDING
	AND	#$04	;DOWN KEY?
	BEQ	?PAUSE	;IF YES, BRANCH!
	LDA	#$01
	STA	VSTOP	;HALT VBLANK.
	STA	CH	;CLEAR CHAR.
	JSR	SOUNDOFF	;SOUNDS OFF.
?WAIT
	LDA	CH	;IF SPACEBAR
	CMP	#$21	;PRESSED?
	BNE	?WAIT	;NO. BRANCH!
?WAITMORE
	LDA	SKSTAT	;IS SPACEBAR
	AND	#$04	;STILL HELD?
	BEQ	?WAITMORE	;YES, BRANCH!
	LDA	#$00	;CLEAR
	STA	VSTOP	;START VBLANK.
	STA	CH	;RESET CHAR.
?PAUSE
	LDA	ARMTIM	;TIMER ELAPSED?
	BNE	CHKBUL	;NO! BRANCH!
	LDA	#1	;RESET TIMER.
	STA	ARMTIM
	JSR	ARMBOM	;SUBROUTINE.
CHKBUL
	LDA	BULTIM	;TIMER ELAPSED?
	BNE	CHKBUG	;NO! BRANCH!
	LDA	#3	;RESET TIMER.
	STA	BULTIM
	JSR	SPARK	;SUBROUTINE.
CHKBUG	LDA	BUGTIM	;TIMER UP?
	BNE	NOFBMV	;NO! BRANCH!
	JSR	MOVBUG	;SUBROUTINE.
	LDA	DIGGIN	;RESET TIMER
	BEQ	?EIGHT
	LDA	#11	;DIGGING.
	BNE	?GOTSPD
?EIGHT
	LDA	#8	;NOT DIGGING.
?GOTSPD
	STA	BUGTIM	;SAVE TIMER.
NOFBMV
	LDA	GENFLG	;MATING SEASON?
	BEQ	NOGTST	;YES!
	LDA	GENCTR	;SECOND ELAPSED?
	BNE	NOGTST	;NO!
	LDA	#60	;SET TIMER TO
	STA	GENCTR	;1 SECOND
	DEC	GENTIM	;1 LESS SECOND
	BNE	NOGTST	;NOT ZERO!
	LDA	#0	;TIME TO START
	STA	GENFLG	;MATING SEASON!
NOGTST
	LDA	TIMER	;TIMER ELAPSED?
	BEQ	DOENMY	;YES, DO ENEMIES
	JMP	MAINLN	;NO! BRANCH!
DOENMY	LDA	LEVEL	;RESET ENEMY
	LSR	A	;BUG MOVEMENT
	CMP	#16	;TIMER ACCORDING
	BCC	?GOTNEW	;TO LEVEL OF
	LDA	#15	;GAME.
?GOTNEW
	TAX		;[LEVEL 30 MAX.]
	LDA	ENSPEED,X
	STA	TIMER	;SAVE TIMER.
	JSR	ENMOVE	;MOVE ENEMIES
	JSR	BMOVE	;MOVE BABIES
	LDA	ECOUNT	;ANY ENEMIES?
	BNE	GAMECONT	;YES!
	INC	LEVEL	;NO ENEMIES,
	SED		;ADVANCE LEVEL
	LDA	BCDLVL
	CLC
	ADC	#1
	STA	BCDLVL
	CLD		;HERE TOM?!?
	JSR	SHOLVL	;SHOW NEW LEVEL
	JSR	INIT3	;RE-INIT
	JMP	NEWLVL	;AND PLAY!
GAMECONT
	JMP	MAINLN	;LOOP BACK!
ENSPEED
	.BYTE	20,19,18,17,16,15
	.BYTE	14,13,12,11,10,9
	.BYTE	8,7,6,5
?NUMBASE
	.BYTE	$1F,$1E,$1A,$18,$1D
	.BYTE	$1B,$33,$35,$30
?PREV	.BYTE	0
;
; *****************************
; * FIREBUG DEATH/ENEMY MOVER *
; *       BY Tom Hudson       *
; *****************************
;
;FIREBUG DEATH
;
DEAD	LDA	BUGL	;SET EXPLOSION
	STA	ELO	;POSITION = TO
	LDA	BUGL+1	;BUG'S LAST
	STA	ELO+1	;POSITION
	JSR	EXPLOD	;BOOM!!!
	DEC	LIVES	;1 LESS LIFE
	BMI	GAMOVR	;GAME OVER IF <0
	JSR	SHOLIV	;SHOW LIVES
	JSR	INIT3	;RE-INIT LEVEL
	JMP	NEWLVL	;AND RESTART!
;
;GAME OVER!
;
GAMOVR
	JSR	INIT3	;RE-INIT
	JMP	IGNITE	;AND SHOW TITLE
;
;ENEMY MOVER
;
ENMOVE	LDA	#0	;ZERO...
	STA	ECOUNT	;ENEMY COUNT
	LDX	#29	;30 ENEMIES MAX
ENLP	STX	ENIX	;SAVE INDEX
	LDA	EACT,X	;ACTIVE?
	BNE	ACTIVE	;YES!
	JMP	NXTEN	;NO, NEXT ENEMY
ACTIVE	LDA	EADL,X	;GET...
	STA	ADL	;ENEMY'S...
	LDA	EADH,X	;ADDRESS...
	STA	ADL+1	;IN POINTER
	LDY	#0	;GET THE CHAR...
	LDA	(ADL),Y	;FROM DISPLAY
	CMP	ETYP,X	;ENEMY OK?
	BEQ	ENMYOK	;YES!
	LDA	#0	;UH-OH, HE'S NO
	STA	EACT,X	;LONGER ACTIVE!
	LDA	#12	;GET ENEMY'S
	SEC		;SCORE VALUE
	SBC	ETYP,X
	AND	#$06
	ASL	A
	ASL	A
	ASL	A	;AND PUT IN...
	STA	SCOADD+2	;ADD VALUE
	JSR	ADDSCO	;ADD TO SCORE
	JMP	NXTEN	;NEXT ENEMY!
ENMYOK	LDA	#0	;RESET MOVEMENT
	STA	OK+8	;TO CHARS 8
	STA	OK+10	;AND 10
	LDA	GENFLG	;MATING SEASON?
	BNE	GENDUN	;NO!
	LDA	#1	;SET...
	LDY	ETYP,X	;ENEMY TYPE'S...
	STA	OK,Y	;OK FLAG
;
;PRIORITY MOVE CHECK
;
GENDUN	LDA	#3	;TRY 4 DIRS.
	STA	GNEWIX	;SAVE IN INDEX
PRILP	LDY	GNEWIX	;GET INDEX
	LDA	EADL,X	;ADD...
	CLC		;DIRECTION...
	ADC	DIRADL,Y	;OFFSET...
	STA	ADL	;TO...
	LDA	EADH,X	;ENEMY'S...
	ADC	DIRADH,Y	;ADDRESS
	STA	ADL+1
	LDY	#0	;LOAD THE BYTE..
	LDA	(ADL),Y	;IN THAT DIR.
	AND	#$7F	;MASK HI BIT
	STA	OLDVAL	;SAVE OLD VALUE
	TAY		;CHAR # IN Y
	LDA	OK,Y	;CAN WE GO THERE?
	BEQ	NOPRI	;NO!
	LDA	CHANCE,Y	;GET CHANCE
	CMP	#$FF	;100% CHANCE?
	BNE	NOPRI	;NO!
	LDA	GNEWIX	;GET DIRECTION,
	STA	EDIR,X	;SAVE DIRECTION,
	JSR	EXMOVE	;MOVE ENEMY!
	JMP	NXTEN	;NEXT ENEMY
NOPRI	DEC	GNEWIX	;NEXT DIRECTION
	BPL	PRILP	;KEEP CHECKIN'
;
;NO PRIORITY MOVE, SO LET'S TRY
;A RANDOM DIRECTION!
;
ETRYLP	LDA	#4	;TRY 5 DIRS.
	STA	ETRY	;SAVE INDEX
GETDIR	LDA	EDIR,X	;GET OLD DIR.
	BPL	SETDIR	;IT'S MOVING!
	LDA	RANDOM	;RANDOMIZE A
	AND	#3	;DIRECTION
SETDIR	STA	EDIR,X	;SAVE DIR.
	JSR	DIRCHK	;IS THAT DIR OK?
	BPL	NXTEN	;YES!
	DEC	ETRY	;NEXT DIR.
	BPL	GETDIR	;AND LOOP BACK
	LDA	#$FF	;DIDN'T MOVE!
	STA	EDIR,X
NXTEN	LDX	ENIX	;GET ENEMY INDEX
	LDA	EACT,X	;ACTIVE?
	BEQ	EDEAD	;NO!
	INC	ECOUNT	;1 MORE ENEMY
EDEAD	DEX		;NEXT ENEMY
	BMI	ENDONE	;IF <0, FINISHED
	JMP	ENLP	;LOOP BACK.
ENDONE	RTS		;ALL DONE!
;
;DIRECTION CHECK SUBROUTINE
;
DIRCHK	TAY		;MOVE DIR. TO Y
	LDA	EADL,X	;NOW ADD...
	CLC		;DIRECTION...
	ADC	DIRADL,Y	;OFFSET...
	STA	ADL	;TO ENEMY'S...
	LDA	EADH,X	;POSITION
	ADC	DIRADH,Y
	STA	ADL+1
	LDY	#0	;GET THE BYTE...
	LDA	(ADL),Y	;FROM DISPLAY
	AND	#$7F	;MASK HI BIT
	STA	OLDVAL	;SAVE OLD CHAR
	TAY		;GET CHAR IN Y
	LDA	OK,Y	;CAN ENEMY MOVE?
	BNE	OKMOVE	;YES!
NOMOVE	LDA	#$FF	;NO!
	RTS		;RETURN
OKMOVE	LDA	CHANCE,Y	;GET CHANCE
	CMP	RANDOM	;MOVE OK?
	BCC	NOMOVE	;NO!
EXMOVE	LDA	EADL,X	;GET ENEMY'S
	STA	HLO	;OLD ADDRESS
	LDA	EADH,X
	STA	HLO+1
	LDA	#0	;ERASE OLD...
	TAY		;ENEMY IMAGE
	STA	(HLO),Y
	INY
	STA	(HLO),Y
	DEY
	LDA	ETYP,X	;GET ENEMY CHAR,
	STA	(ADL),Y	;PUT ON SCREEN
	INY
	CLC
	ADC	#1
	STA	(ADL),Y
	LDA	ADL	;UPDATE ENEMY...
	STA	EADL,X	;ADDRESS TABLE
	LDA	ADL+1
	STA	EADH,X
	LDA	OLDVAL	;GET OLD CHAR
	CMP	ETYP,X	;SAME AS ENEMY?
	BEQ	GENIT	;YES, GENERATE!!
	JMP	NOGEN	;NO, DON'T GEN.
GENIT	LDA	#0	;ENEMY NOT...
	STA	EACT,X	;ACTIVE ANYMORE
;
;THIS CODE GENERATES A NEW
;GROUP OF ENEMY OBJECTS
;
	LDA	ETYP,X	;GET ENEMY TYPE
	CMP	#8	;TYPE 8?
	BNE	TYP10	;NO, TYPE 10!
	LDA	#7	;TURN ON...
	STA	CHANGE1	;CHANGE SOUND 1
	LDA	#10	;GEN TYPE 10
	BNE	GNEW	;GENERATE 'EM!
TYP10	LDA	#7	;TURN ON...
	STA	CHANGE2	;CHANGE SOUND 2
	LDA	#8	;GEN TYPE 8
GNEW	STA	NEWTYP	;SAVE NEW TYPE
	LDA	#3	;GEN. 4 ENEMIES
	STA	GNEWIX	;SAVE IN INDEX
GNEWLP	LDY	GNEWIX	;GET INDEX
	LDA	ADL	;GET ENEMY ADDR,
	CLC		;ADD...
	ADC	DIRADL,Y	;DIRECTION...
	STA	HLO	;ADDRESS...
	LDA	ADL+1	;OFFSET
	ADC	DIRADH,Y
	STA	HLO+1
	LDY	#0	;GET THE CHAR...
	LDA	(HLO),Y	;FROM DISPLAY
	AND	#$7F	;MASK HI BIT
	CMP	#1	;BORDER?
	BEQ	NONEW	;CAN'T GEN IT!
	CMP	#6	;FIREBUG?
	BEQ	KILL	;KILL HIM!
	CMP	#8	;ENEMY TYPE 8?
	BEQ	NONEW	;CAN'T GEN!
	CMP	#10	;ENEMY TYPE 10?
	BEQ	NONEW	;CAN'T GEN!
	CMP	#12	;BABY BUG?
	BEQ	KILL	;KILL IT!
	CMP	#15	;BOMB?
	BEQ	NONEW	;CAN'T GENERATE
	LDX	#29	;SCAN FOR...
SCANEW	LDA	EACT,X	;INACTIVE ENEMY
	BEQ	GOTNEW	;GOT ONE!
	DEX		;TRY NEXT SLOT
	BPL	SCANEW	;KEEP TRYING
	LDA	#1	;NONE AVAILABLE!
	STA	GENFLG	;MATING OVER
	LDA	#100	;WAIT 100...
	STA	GENTIM	;SECONDS.
	JMP	MOVEOK	;PROCEED
GOTNEW	LDA	#1	;SET ENEMY AS...
	STA	EACT,X	;ACTIVE
	LDA	#$FF	;SET UP FOR...
	STA	EDIR,X	;NO DIRECTION
	LDA	HLO	;SAVE ENEMY...
	STA	EADL,X	;ADDRESS
	LDA	HLO+1
	STA	EADH,X
	LDA	NEWTYP	;GET NEW TYPE
	STA	ETYP,X	;SAVE IN TABLE
	STA	(HLO),Y	;PUT ENEMY...
	CLC		;ON SCREEN!
	ADC	#1
	INY
	STA	(HLO),Y
NONEW	DEC	GNEWIX	;NEXT GEN.
	BMI	MOVEOK	;ALL DONE!
	JMP	GNEWLP	;LOOP IF MORE
MOVEOK	LDA	#0	;STATUS=0 (OK)
	RTS		;RETURN!
NOGEN	CMP	#6	;HIT FIREBUG?
	BNE	MOVEOK	;NO, MOVE OK.
KILL	PLA		;REMOVE...
	PLA		;OLD...
	PLA		;STACK...
	PLA		;ENTRIES,
	JMP	DEAD	;KILL BUG!!!
;
; ****************************
; * FIREBUG MOVEMENT ROUTINE *
; *      BY Tom Hudson       *
; ****************************
;
MOVBUG	LDA	BUGL	;GET AND SAVE...
	STA	HLO	;FIREBUG ADDRESS
	LDA	BUGL+1
	STA	HLO+1
	LDY	#0	;GET THAT...
	LDA	(HLO),Y	;DISPLAY BYTE
	CMP	#6	;BUG OK?
	BEQ	BUGLIV	;YUP!
	BNE	KILBUG	;UH-OH! KILL HIM
BUGLIV
	LDX	STICK0	;GET STICK
	LDY	SDIR,X	;AND DIRECTION
	BPL	TRYBMV	;TRY TO MOVE
NOBMV	RTS		;NO MOVE!
TRYBMV	LDA	BUGL	;ADD...
	CLC		;DIRECTION...
	ADC	DIRADL,Y	;OFFSET...
	STA	ADL	;TO...
	LDA	BUGL+1	;BUG'S...
	ADC	DIRADH,Y	;ADDRESS
	STA	ADL+1
	LDY	#0	;GET THAT...
	LDA	(ADL),Y	;DISPLAY BYTE
	CMP	#1	;BORDER?
	BEQ	NOBMV	;CAN'T GO THERE!
	CMP	#12	;BABY?
	BEQ	NOBMV	;CAN'T GO THERE!
	CMP	#15	;BOMB?
	BCS	NOBMV	;CAN'T GO THERE!
	CMP	#6	;DIRT/TRAIL?
	BCC	OKBMV	;GO AHEAD!
	CMP	#14	;BUG TRAIL?
	BEQ	OKBMV	;GO AHEAD!
KILBUG	PLA		;MUST BE ENEMY!
	PLA		;CLEAR STACK,
	JMP	DEAD	;KILL BUG!
OKBMV	CMP	#0	;ENEMY TRAIL?
	BEQ	NOTDIG	;NO DIGGING!
	CMP	#14	;BUG TRAIL?
	BEQ	NOTDIG	;NO DIGGING!
	LDA	#1	;SET DIGGING...
	STA	DIGGIN	;SOUND FLAG
	BNE	DRWBUG	;AND DRAW BUG
NOTDIG	LDA	#0	;TURN OFF...
	STA	DIGGIN	;DIGGING SOUND
DRWBUG	LDA	#14	;ERASE BUG...
	STA	(HLO),Y	;WITH BUG TRAIL
	INY
	STA	(HLO),Y
	DEY
	LDA	#6	;DRAW BUG...
	STA	(ADL),Y	;IN NEW...
	INY		;LOCATION
	CLC
	ADC	#1
	STA	(ADL),Y
	LDA	ADL	;UPDATE BUG'S
	STA	BUGL	;ADDRESS
	LDA	ADL+1
	STA	BUGL+1
	RTS		;ALL DONE!
; ******************************
; * FIREBUG INTERRUPTS & SOUND *
; *      BY Kyle Peacock       *
; ******************************
;
	.LOCAL
;
VBLANK
	CLD		;CHILL DECIMAL.
;
; RANDOMIZE DETONATION
;
	LDX	#7	;CHANGE 8 BYTES.
?JUNKIT
	LDA	RANDOM	;RANDOM #
	AND	#$55	;MASK FOR PF#0.
	STA	GAMESET+[8*17],X	;SAVE.
	DEX		;HANDLE NEXT.
	BPL	?JUNKIT	;NOT DONE-BRANCH
;
; SET UP CORRECT DISPLAY LIST
;
	LDA	LISTPOINT	;D-LIST PNTR.
	ASL	A	;MULTIPLY BY 2.
	TAX		;MOVE A TO X.
	LDA	?DLISTBASE,X	;LET'S
	STA	SDLSTL	;PAINT THE
	LDA	?DLISTBASE+1,X	;GANG-
	STA	SDLSTL+1	;GREEN, & EAT
	LDA	#GAMEDLI1&255	;FRANKS &
	STA	VDSLST	;BEANS.
	LDA	#GAMEDLI1/256	;C.B.I. IS
	STA	VDSLST+1	;ON THE MOVE.
;
; CHANGE TITLE SCREEN
;
	DEC	?SWITCHTIME	;DEC TIMER.
	BPL	?SWITCHDONE	;>0 BRANCH!
	LDA	RANDOM	;RANDOM #
	AND	#$3F	;MASK BITS 7 & 6
	ORA	#$0F	;ADD BITS 0-3.
	STA	?SWITCHTIME	;SAVE TIMER.
	INC	?FLOPFLIP	;INC NAME
	LDA	?FLOPFLIP	;TOGGLE FLAG.
	AND	#$01	;EXAMINE BIT 0.
	ASL	A	;MULTIPLY BY 2.
	ASL	A	;MULTIPLY BY 4.
	TAX		;MOVE A TO X.
	LDA	?SWITCHBASE,X	;GET ADDR
	STA	SWITCH1	;OF NAME DATA
	LDA	?SWITCHBASE+1,X	;AND
	STA	SWITCH1+1	;PLACE INTO
	LDA	?SWITCHBASE+2,X	;PROPER
	STA	SWITCH2	;AREA OF DISPLAY
	LDA	?SWITCHBASE+3,X	;LIST.
	STA	SWITCH2+1
?SWITCHDONE
;
; HALT ATTRACT MODE?
;
	LDA	VSTOP	;VBLANK HALTED?
	BNE	?VDONE	;YES!
	STA	ATRACT	;ATTRACT MODE.
;
; SPARK REGENERATION
;
	DEC	?REGEN	;TIME UP?
	BPL	?REGEND	;IF >0 BRANCH!
	LDA	STICK0	;GET JOYSTICK.
	CMP	#15	;CENTERED?
	BNE	?GENSET1	;NO! BRANCH!
	LDX	#$00	;CLEAR INDEX.
	BEQ	?GENSET2	;BRANCH!
?GENSET1
	LDX	DIGGIN	;BUG IN DIRT?
?GENSET2
	LDA	?GENSET,X	;REGENERATION RATE.
	STA	?REGEN	;SAVE TIMER.
	INC	?FLIPFLOP	;INC TOGGLE
	LDA	?FLIPFLOP	;FLAG.
	AND	#$01	;EXAMINE BIT 0.
	BEQ	?REGEND	;IF EVEN-BRANCH!
	LDX	BULLPNT	;GET POINTER.
	LDA	BULLETLINE,X	;DETERMINE
	CMP	#20	;IF WE SHOULD
	BNE	?BULLSET	;MODIFY THIS
	CPX	#29	;CHARACTER OR
	BEQ	?REGEND	;MOVE TO NEXT.
	INC	BULLPNT	;MOVE TO NEXT
	INX		;CHARACTER.
?BULLSET
	DEC	BULLETLINE,X	;MODIFY.
?REGEND
;
; DECREMENT COUNT DOWN TIMERS
;
	LDA	GENCTR
	BEQ	?NOGENT
	DEC	GENCTR
?NOGENT
	LDA	BULTIM	;TIMER = 0?
	BEQ	?NOBUL	;YES. BRANCH!
	DEC	BULTIM	;NO. DECREMENT.
?NOBUL
	LDA	ARMTIM	;TIMER = 0?
	BEQ	?NOAT	;YES. BRANCH!
	DEC	ARMTIM	;NO. DECREMENT.
?NOAT
	LDA	TIMER	;TIMER = 0?
	BEQ	?NOTIME	;YES. BRANCH!
	DEC	TIMER	;NO. DECREMENT.
?NOTIME
	LDA	BUGTIM	;TIMER = 0?
	BEQ	?NOBTIM	;YES. BRANCH!
	DEC	BUGTIM	;NO. DECREMENT.
?NOBTIM
;
; FINE SCROLLING (REVISITED)
;
	JSR	SCROLL
?VDONE
;
; UPDATE LMS POINTERS
;
	JSR	SHIFTER
;
; VERTICAL BLANK DONE
;
	JMP	SYSVBV
;
; ***************************
; * DEFERRED VERTICAL BLANK *
; ***************************
;
DBLANK
	CLD		;CHILL DECIMAL
;
; UPDATE CHARACTER SET
;
	JSR	DRAW
	LDA	VSTOP	;DBLANK HALTED?
	BNE	?DDONE	;IF <>0 BRANCH!
;
; DIGGING SOUND
;
	JSR	DIGSOUND
;
; BUG TRANSFORMATION SOUNDs
;
	JSR	TRANSFORM
;
; FIRE EGG EATEN SOUND
;
	JSR	CHOMP
;
; SPARK FIRING SOUND
;
	JSR	POPGUN
;
; DETONATION SOUND
;
	JSR	KABOOM
;
; BOMB DETONATION SOUND
;
	JSR	BOOMBOX
;
; DEF. VERTICAL BLANK DONE
;
?DDONE
	JMP	XITVBV
;
; POINTERS' DATABASES
;
?DLISTBASE
	.WORD	GAMELIST
	.WORD	TITLELIST
?SWITCHBASE
	.WORD	TITLE2
	.WORD	TITLE4
	.WORD	TITLE4
	.WORD	TITLE2
;
; ****************
; * FIREBUG DLIs *
; ****************
;
GAMEDLI1
	PHA		;SAVE ACC.
	TXA		;MOVE X TO A.
	PHA		;SAVE ACC.
	TYA		;MOVE Y TO A.
	PHA		;SAVE ACC.
	LDA	#GAMESET/256	;BUG CHRs
	LDX	#$3F	;DMA CONTROL.
	LDY	NEWBACK	;BACKGROUND.
	STA	WSYNC	;SAVE IT.
	STX	DMACTL	;SAVE IT.
	STY	COLBK	;SAVE IT.
	STA	CHBASE	;SAVE IT.
	LDA	#GAMEDLI2&255	;LOAD UP
	STA	VDSLST	;FOR NEXT DLI.
	LDA	#GAMEDLI2/256	;SAVE NEXT
	STA	VDSLST+1	;DLI ADDRESS.
	PLA		;RESTORE ACC.
	TAY		;MOVE A TO Y.
	PLA		;RESTORE ACC.
	TAX		;MOVE A TO X.
	PLA		;RESTORE ACC.
	RTI		;BOGGIE BABY...
GAMEDLI2
	PHA		;SAVE ACC.
	LDA	COLOR4	;BACKGROUND.
	STA	WSYNC	;SAVE IT.
	STA	COLBK	;SAVE IT.
	LDA	SDMCTL	;OLD DMA CONTROL
	STA	DMACTL	;IS RESTORED.
	LDA	#GAMEDLI3&255	;SET UP
	STA	VDSLST	;FOR NEXT
	LDA	#GAMEDLI3/256	;DLI ADDR.
	STA	VDSLST+1	;SAVE IT.
	PLA		;RESTORE ACC.
	RTI		;BOGGIE BABY...
GAMEDLI3
	PHA		;SAVE ACC.
	LDA	#$E0	;OLD CHR SET.
	STA	WSYNC	;SAVE IT.
	STA	CHBASE	;SAVE IT.
	PLA		;RESTORE ACC.
	RTI		;BOGGIE BABY...
;
; DIGGING SOUND ROUTINE
;
DIGSOUND
	LDA	DIGGIN	;BUG IN DIRT?
	BEQ	?DIGOFF	;IF = 0 BRANCH!
	DEC	?DIGTIME	;DEC TIMER.
	BPL	?DIGDONE	;IF >0 BRANCH!
	LDA	#$03	;RESET DIGGING
	STA	?DIGTIME	;TIMER.
	LDX	PLAYNO	;PLAYER NUMBER.
	LDA	STICK0,X	;READ JOYSTICK.
	CMP	#15	;CENTERED?
	BNE	?DIGON	;<> 15 - BRANCH!
?DIGOFF
	LDA	#$00	;CLEAR.
	STA	AUDC1	;SOUND CHANNEL.
	BEQ	?DIGDONE	;BRANCH!
?DIGON
	LDA	#$46	;SET UP
	STA	AUDC1	;SOUND CHANNEL 1
	LDA	#220	;SET UP
	STA	AUDF1	;SOUND FREQ 1.
?DIGDONE
	RTS		;BEAM ME UP...
;
; BUG TRANSFORMATION SOUND
;
TRANSFORM
	LDX	CHANGE1	;1st SOUND ON?
	BPL	TRAN1	;IF >0 BRANCH!
	LDA	#$00	;SOUND OFF.
	STA	AUDC2	;CHANNEL 2.
	BEQ	TRAN2	;BRANCH!
TRAN1
	LDA	?CHANGE1,X	;GET CORRECT
	STA	AUDF2	;FREQ & SAVE.
	LDA	#$A4	;SET UP CORRECT
	STA	AUDC2	;SOUND CHANNEL.
	DEC	CHANGE1	;DEC POINTER.
TRAN2
	LDX	CHANGE2	;2nd SOUND ON?
	BPL	TRAN3	;IF >0 BRANCH!
	LDA	CHANGE1	;SOUND 1 OFF?
	BPL	TRAN4	;IF >0 BRANCH!
?DEACT2
	LDA	#$00	;SOUND OFF.
	STA	AUDC2	;CHANNEL 2.
	BEQ	TRAN4	;BRANCH!
TRAN3
	LDA	?CHANGE2,X	;GET CORRECT
	STA	AUDF2	;FREQ & SAVE.
	LDA	#$A4	;SET UP CORRECT
	STA	AUDC2	;SOUND CHANNEL.
	DEC	CHANGE2	;DEC POINTER.
TRAN4
	RTS		;BAMF!
?CHANGE1
	.BYTE	240,160,80,0
	.BYTE	15,95,175,255
?CHANGE2
	.BYTE	210,140,70,0
	.BYTE	45,115,185,255
;
; FIRE EGG EATEN SOUND
;
CHOMP
	LDX	EATNOISE	;SOUND ON?
	BPL	?CHOMPON	;IF >0 BRANCH!
	LDA	CHANGE1	;CHANGE 1 ON?
	BPL	?CHOMPOFF	;IF >0 BRANCH!
	LDA	CHANGE2	;CHANGE 2 ON?
	BMI	?DEACT2	;IF >0 BRANCH!
?CHOMPOFF
	RTS		;BOGGIE...
?CHOMPON
	LDA	?CHOMPF,X	;GET SOUND
	STA	AUDF2	;FREQ & SAVE.
	LDA	#$A6	;SET CORRECT
	STA	AUDC2	;SOUND CHANNEL.
	DEC	EATNOISE	;DEC POINTER.
	RTS		;LATER Y'ALL!
?CHOMPF
	.BYTE	0,8,16,24,32
	.BYTE	40,47,55,63,71
;
; SPARK FIRING SOUND
;
POPGUN
	LDX	BULLNOISE	;SOUND ON?
	BPL	?SHOOTIT	;IF >0 BRANCH!
?CHILLOUT
	LDA	#$00	;CLEAR SOUND
	STA	AUDC3	;CHANNEL 3.
	RTS		;LATER...
?SHOOTIT
	LDA	?SHOOTF,X	;GET CORRECT
	STA	AUDF3	;FREQ & SAVE.
	LDA	#$AA	;SET UP CORRECT
	STA	AUDC3	;SOUND CHANNEL.
	DEC	BULLNOISE	;DEC POINTER.
?SHOTIT
	RTS		;LATER...
?SHOOTF
	.BYTE	18,57,97,136
	.BYTE	176,215,255
;
; DETONATION SOUND
;
KABOOM
	LDX	BOOMNOISE	;SOUND ON?
	BPL	?BOOMIT	;IF >0 BRANCH!
	LDA	BULLNOISE	;BULLET ON?
	BMI	?CHILLOUT	;IF <0 BRANCH!
	RTS		;LATER...
?BOOMIT
	LDA	?BOOMF,X	;GET CORRECT
	STA	AUDF3	;FREQ & SAVE.
	LDA	#$8C	;GET CORRECT
	STA	AUDC3	;SOUND CHANNEL.
	DEC	BOOMNOISE	;DEC POINTER.
?BOOMED
	RTS		;LATER (MUCH!)
?BOOMF
	.BYTE	244,232,220,209
	.BYTE	197,186,174,162
	.BYTE	151,139,128,116
	.BYTE	104,93,81,70,58
	.BYTE	46,35,23,12,0
;
; BOMB DETONATION SOUND
;
BOOMBOX
	LDX	EXNOISE	;SOUND ON?
	BPL	?ZAPON	;IF >0 BRANCH!
	LDA	#$30	;ADJUST DISPLAY
	JSR	?DSET	;LIST.
	LDA	BOOMNOISE	;EXPLOSION?
	BPL	?ZAPOFF	;IF >0 BRANCH!
	LDA	BULLNOISE	;BULLET?
	BPL	?ZAPOFF	;IF >0 BRANCH!
	JMP	?CHILLOUT	;CHILLY BE.
?ZAPOFF
	RTS		;CHILL OUT.
?ZAPON
	LDA	EXF,X	;GET CORRECT
	STA	AUDF3	;FREQ & SAVE.
	LDA	#$8A	;GET CORRECT
	STA	AUDC3	;SOUND CHANNEL.
	DEC	EXNOISE	;DEC POINTER.
	LDA	RANDOM	;RANDOM #
	AND	#$70	;MASK 4,5,6.
?DSET
	STA	GAMELIST	;SAVE INTO DIS-
	STA	GAMELIST+1	;PLAY LIST.
	RTS		;CHILLY BE Y'ALL
EXF
	.BYTE	0,253,249,245,241,237
	.BYTE	234,230,226,222,218
	.BYTE	214,211,207,203,199
	.BYTE	195,191,188,184,180
	.BYTE	176,172,168,165,161
	.BYTE	157,153,149,145,142
	.BYTE	138,134,130,126,123
	.BYTE	119,115,111,107,103
	.BYTE	100,96,92,88,84,80
	.BYTE	77,73,69,65,61,57,54
	.BYTE	50,46,42,38,34,31,27
	.BYTE	23,19,15,11,8,4
?GENSET
	.BYTE	120,60
?DIGTIME	.BYTE	0
?REGEN	.BYTE	0
?FLIPFLOP	.BYTE	0
?FLOPFLIP	.BYTE	0
?SWITCHTIME	.BYTE	0
; *************************
; * FIREBUG DISPLAY LISTS *
; *    BY Kyle Peacock    *
; *************************
;
	.LOCAL
;
; GAME BOARD DISPLAY LIST
;
GAMELIST
	.BYTE	$30,$30,$30
	.BYTE	$30,$30,$30
	.BYTE	$C6
	.WORD	STATUSLINE
	.BYTE	$44
	.WORD	BLANKLINE
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
DLISTSTART
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
DLISTEND
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$74,0,0
	.BYTE	$54,0,0
	.BYTE	$C4
	.WORD	BLANKLINE
	.BYTE	$00,$C4
	.WORD	BULLETLINE
	.BYTE	$20,$06,$41
	.WORD	GAMELIST
;
; TITLE SCREEN DISPLAY LIST
;
TITLELIST
	.BYTE	$70,$70,$70,$70,$70
	.BYTE	$47
	.WORD	STATUSLINE
	.BYTE	$70,$70,$46
	.WORD	TITLE1
	.BYTE	$70,$47
SWITCH1
	.WORD	TITLE4
	.BYTE	$70,$46
	.WORD	TITLE3
	.BYTE	$70,$47
SWITCH2
	.WORD	TITLE2
	.BYTE	$70,$70,$70,$46
	.WORD	TITLE5
	.BYTE	$70,$46
	.WORD	BULLETLINE+40
	.BYTE	$41
	.WORD	TITLELIST
;
; BORDER LINE CHARACTERS
;
BLANKLINE
	.BYTE	1,1,1,1,1,1,1,1,1,1
	.BYTE	1,1,1,1,1,1,1,1,1,1
	.BYTE	1,1,1,1,1,1,1,1,1,1
	.BYTE	1,1,1,1,1,1,1,1,1,1
	.BYTE	1,1,1,1,1,1,1,1
;
; SPARK BAR GRAPH
;
BULLETLINE
	.BYTE	0,0,0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,0,0
;
; CREDITS & WHAT-NOT
;
SCOLIN
	.SBYTE	+$40,"       LVL:"
	.SBYTE	+$80,"   BUGS: "
STATUSLINE
	.SBYTE	"      fire"
	.SBYTE	" bug      "
TITLE1
	.SBYTE	"     WRITT"
	.SBYTE	"EN BY     "
TITLE2
	.SBYTE	"     TOM H"
	.SBYTE	"UDSON     "
TITLE3
	.SBYTE	"         &"
	.SBYTE	"          "
TITLE4
	.SBYTE	"    kyle p"
	.SBYTE	"eacock    "
TITLE5
	.SBYTE	"  analog c"
	.SBYTE	"omputing  "
; *************************
; * DISPLAY LIST MODIFIER *
; *    BY Kyle Peacock    *
; *************************
;
	.LOCAL
;
SHIFTER
	LDY	#13	;D-LIST INDEX.
	LDA	#19	;# OF LINES TO
	STA	?COUNT	;MODIFY LMSs.
	LDA	YPOINT	;GET Y-COORD.
	ASL	A	;MULTIPLY BY 2.
	TAX		;USE AS INDEX.
?GET
	LDA	SCREENBYTES+1,X	;END OF
	CMP	#$FF	;SCREEN RAM?
	BNE	?PASS1	;YES! BRANCH!
	LDX	#$00	;CLEAR X-REG.
?PASS1
	LDA	SCREENBYTES,X	;GET
	CLC		;SCREEN RAM &
	ADC	XPOINT	;ADD X-COORD.
	STA	GAMELIST,Y	;& SAVE.
	LDA	SCREENBYTES+1,X	;ALSO
	ADC	#$00	;ADD TO HI-BYTE
	STA	GAMELIST+1,Y	;& SAVE.
	INX		;INCREMENT POIN-
	INX		;TERS FOR NEXT
	TYA		;LMS OPERAND
	CLC		;TRANSFER.
	ADC	#$03
	TAY
	DEC	?COUNT	;ALL LINES DONE?
	BPL	?GET	;NO! BRANCH!
	RTS		;LATER Y'ALL!!!
?COUNT
	.BYTE	0	;COUNTER
;
; *****************************
; * FIREBUG SCREEN MEMORY MAP *
; *****************************
;
SCREENBYTES
	.WORD	SCREENBASE+[0*128]
	.WORD	SCREENBASE+[1*128]
	.WORD	SCREENBASE+[2*128]
	.WORD	SCREENBASE+[3*128]
	.WORD	SCREENBASE+[4*128]
	.WORD	SCREENBASE+[5*128]
	.WORD	SCREENBASE+[6*128]
	.WORD	SCREENBASE+[7*128]
	.WORD	SCREENBASE+[8*128]
	.WORD	SCREENBASE+[9*128]
	.WORD	SCREENBASE+[10*128]
	.WORD	SCREENBASE+[11*128]
	.WORD	SCREENBASE+[12*128]
	.WORD	SCREENBASE+[13*128]
	.WORD	SCREENBASE+[14*128]
	.WORD	SCREENBASE+[15*128]
	.WORD	SCREENBASE+[16*128]
	.WORD	SCREENBASE+[17*128]
	.WORD	SCREENBASE+[18*128]
	.WORD	SCREENBASE+[19*128]
	.WORD	SCREENBASE+[20*128]
	.WORD	SCREENBASE+[21*128]
	.WORD	SCREENBASE+[22*128]
	.WORD	SCREENBASE+[23*128]
	.WORD	SCREENBASE+[24*128]
	.WORD	SCREENBASE+[25*128]
	.WORD	SCREENBASE+[26*128]
	.WORD	SCREENBASE+[27*128]
	.WORD	SCREENBASE+[28*128]
	.WORD	SCREENBASE+[29*128]
	.WORD	SCREENBASE+[30*128]
	.WORD	SCREENBASE+[31*128]
	.WORD	SCREENBASE+[32*128]
	.WORD	SCREENBASE+[33*128]
	.WORD	SCREENBASE+[34*128]
	.WORD	SCREENBASE+[35*128]
	.WORD	SCREENBASE+[36*128]
	.WORD	SCREENBASE+[37*128]
	.WORD	SCREENBASE+[38*128]
	.WORD	SCREENBASE+[39*128]
	.WORD	SCREENBASE+[40*128]
	.WORD	SCREENBASE+[41*128]
	.WORD	SCREENBASE+[42*128]
	.WORD	SCREENBASE+[43*128]
	.WORD	SCREENBASE+[44*128]
	.WORD	SCREENBASE+[45*128]
	.WORD	SCREENBASE+[46*128]
	.WORD	SCREENBASE+[47*128]
	.WORD	SCREENBASE+[48*128]
	.WORD	SCREENBASE+[49*128]
	.WORD	SCREENBASE+[50*128]
	.WORD	SCREENBASE+[51*128]
	.WORD	SCREENBASE+[52*128]
	.WORD	SCREENBASE+[53*128]
	.WORD	SCREENBASE+[54*128]
	.WORD	SCREENBASE+[55*128]
	.WORD	SCREENBASE+[56*128]
	.WORD	SCREENBASE+[57*128]
	.WORD	SCREENBASE+[58*128]
	.WORD	SCREENBASE+[59*128]
	.WORD	SCREENBASE+[60*128]
	.WORD	SCREENBASE+[61*128]
	.WORD	SCREENBASE+[62*128]
	.WORD	SCREENBASE+[63*128]
	.WORD	$FFFF
; *****************************
; *  FIREBUG INITIALIZATION   *
; * Tom Hudson & Kyle Peacock *
; *****************************
;
; ************************
; * ONE SHOT INITIALIZER *
; ************************
;
	.LOCAL
;
INIT
;
;SET UP CHARACTERS
;
	LDA	#$04	;CHSET START
	STA	HLO+1	;PUT IN POINTER
	LDX	#13	;14 CHARS...
	STX	XTEMP	;TO LOAD
CHLOOP
	LDX	XTEMP	;GET CHAR #
	LDA	CSTRT,X	;AND START ADDR
	STA	HLO	;PUT IN POINTER
	TXA		;NOW...
	ASL	A	;MULT...
	ASL	A	;POINTER...
	ASL	A	;BY 8,
	TAX		;USE AS INDEX
	LDY	#0	;START CHAR COPY
CHL2
	LDA	CDATA,X	;GET CHAR DATA
	STA	(HLO),Y	;MOVE TO CHSET
	INX		;NEXT CHAR BYTE
	INY		;NEXT SET BYTE
	CPY	#8	;DONE 8?
	BNE	CHL2	;NO, LOOP BACK
	DEC	XTEMP	;NEXT CHAR
	BPL	CHLOOP	;LOOP IF MORE
;
; GENERAL VARIABLE SETTING
;
	LDA	#$00	;CLEAR
	STA	PLAYNO	;PLAYER #.
	STA	VBIT	;RAM VSCROL
	STA	HBIT	;RAM HSCROL
	STA	MINX	;MIN. X-COORD.
	LDX	#2
CSCLP	STA	SCORE,X	;SCORES
	STA	SCOADD,X	;& STUFF.
	DEX
	BPL	CSCLP
	LDA	#$01	;SET w/ 1.
	STA	MINY	;MIN Y-COORD.
	STA	FIRETIME	;FIRING.
	LDA	#84
	STA	MAXX	;MAX X-COORD.
	LDA	#43
	STA	MAXY	;MAX Y-COORD.
	LDA	#$03	;CHARACTER UP-
	STA	MOVETIME	;DATA TIMER.
	STA	PHASETIME
	LDX	#$04	;SET UP.
	STX	LIVES	;# OF LIVES
	LDA	STARTLEVEL
	STA	LEVEL	;STARTING LEVEL
	STA	BCDLVL	;STARTING LEVEL
?TYPESET
	LDA	?TYPEBASE,X	;CHARACTER
	STA	TYPE,X	;TYPE SETTING.
	DEX		;SET THEM ALL.
	BPL	?TYPESET
;
; PLAYER/MISSILE INITIALIZATION
;
	LDA	#$3E
	STA	SDMCTL	;DMA.
	LDA	#PLAYBS/256
	STA	PMBASE	;ADDRESS.
	LDA	#$03	;GRAPHICS
	STA	GRACTL	;CONTROL.
	LDA	#$21	;PRIORITY
	STA	GPRIOR	;REG.
	LDA	#$F0	;MISSILES 2 & 3
	STA	SIZEM	;ARE 4X SIZE.
	LDA	#$28	;MISSILE 2 X.
	STA	HPOSM0+2
	LDA	#$CC	;MISSILE 3 X.
	STA	HPOSM0+3
	LDA	#$00	;CLEAR OUT
	TAX
?PMSET
	STA	MISS,X	;MISSILES.
	CPX	#$C9	;INSTALL
	BCS	?PMSET2	;PLAYFIELD
	CPX	#$30	;BORDER
	BCC	?PMSET2	;INTO MISSILES
	LDA	#$F0
	STA	MISS,X	;2 AND 3.
	LDA	#$00
?PMSET2
	DEX		;ALL DONE?
	BNE	?PMSET	;NO! CONT.
;
; ************************
; * MULTIPLE INITIALIZER *
; ************************
;
INIT2
	JSR	SOUNDOFF
	LDX	#$01
	STX	VSTOP	;HALT VBLANK.
	STX	CH	;STUFF CHAR.
;
; GENERAL VARIABLE SETTING
;
	DEX
	DEX
	STX	CHANGE1	;TURN OFF
	STX	CHANGE2	;ALL SOUND
	STX	BULLNOISE	;RAM VARIA-
	STX	BOOMNOISE	;BLES.
	STX	EXNOISE
	STX	EATNOISE
	LDA	MINX	;SET LMS OPER-
	STA	XPOINT	;ANDS TO UPPER
	LDA	MINY	;LEFT OF BOARD.
	STA	YPOINT
	LDA	#$00	;NO SPARKS ARE
	STA	NOBULL	;ACTIVE.
	LDX	#$03
?SETBULL
	LDA	#$FF	;CLEAR SPARK
	STA	BULLDIR,X	;WORK AREA.
	DEX
	BPL	?SETBULL
	LDX	#19	;SET SPARK LINE
	LDA	#20	;TO FULL
?SETBULL2	;		CAPACITY.
	STA	BULLETLINE+10,X
	DEX
	BPL	?SETBULL2
	LDA	#29	;SET BULLET
	STA	BULLPNT	;POINTER.
;
; FILL PLAY AREA WITH DIRT
;
	LDX	#$00	;CLEAR X-REG.
?FILL1
	TXA		;MOVE X TO A.
	ASL	A	;MULTIPLY BY 2.
	TAY		;MOVE A TO Y.
	LDA	SCREENBYTES,Y
	STA	LO	;GET SCREEN
	LDA	SCREENBYTES+1,Y
	STA	LO+1	;ADDRESS.
	CMP	#$FF	;AT RAM END?
	BEQ	?FILL3	;YES! BRANCH!
	LDY	#127	;SET FOR FILL.
?FILL2
	LDA	#$04	;GET RANDOM #
	JSR	RANDO	;(0 UP TO ACC-1)
	CLC		;ADD TWO TO
	ADC	#$02	;VALUE IN ACC.
	STA	(LO),Y	;STORE IT.
	DEY		;HANDLE NEXT.
	BPL	?FILL2	;BRANCH!
	INX		;NEXT RAM AREA.
	JMP	?FILL1	;JUMP ON IT!
?FILL3
;
; PLACE PRE-PROGRAMMED TUNNELS
;
	LDX	#$00	;CLEAR X-REG.
?VECSET
	LDY	#$00	;CLEAR Y-REG.
?VECSET2
	LDA	?VECTORS,X	;GET VECTOR
	STA	?INITX,Y	;INITIAL X.
	INX		;GET ADDITIONAL
	INY		;VECTOR INFO.
	CPY	#$06	;LAST DATA BYTE?
	BNE	?VECSET2	;NO! BRANCH!
?VECPLOT
	LDA	?INITX	;GET INITIAL X.
	STA	XCOORD	;SAVE IT.
	LDA	?INITY	;GET INITAIL Y.
	STA	YCOORD	;SAVE IT.
	JSR	XYFIND	;FIND RAM LOC.
	LDY	#$00	;CLEAR Y-REG.
	TYA		;MOVE Y TO A.
	STA	(LO),Y	;STORE IN MEM.
	LDA	?INITX	;IS X VECTOR AT
	CMP	?FINALX	;DESTINATION?
	BNE	?VECRESET	;NO! BRANCH!
	LDY	?INITY	;IS Y VECTOR AT
	CPY	?FINALY	;DESTINATION?
	BEQ	?NEXTVEC	;YES! BRANCH!
?VECRESET
	CLC		;ADD X-DELTA
	ADC	?DELTAX	;TO X VECTOR.
	STA	?INITX	;SAVE IT.
	LDA	?INITY	;ADD Y-DELTA
	CLC		;TO Y VECTOR.
	ADC	?DELTAY
	STA	?INITY	;SAVE IT.
	JMP	?VECPLOT	;PLOT NEXT.
?NEXTVEC
	CPX	#[6*6]	;6 VECTORS
	BCC	?VECSET	;NEXT VECTOR.
;
; PLACE PROXIMITY BOMBS
;
	LDX	LEVEL	;GET LEVEL #.
	CPX	#11	;IS IT >10 ?
	BCC	?NUMBMB	;NO! BRANCH!
	LDX	#10	;SET 10 AS MAX.
?NUMBMB
	LDA	?NUMPROX-1,X	;GET # OF
	STA	BOMBCT	;BOMBS FOR LEVEL
	TAX		;& SAVE IN X.
?PLACEBOMBS
	LDA	#58	;GET RANDOM #
	JSR	RANDO	;(0 UP TO ACC-1)
	CLC		;THEN ADD THREE.
	ADC	#$03
	ASL	A	;MULTIPLY BY 2.
	TAY		;MOVE A TO Y.
	LDA	SCREENBYTES,Y
	STA	LO	;GET SCREEN RAM
	STA	BOMBL,X
	LDA	SCREENBYTES+1,Y
	STA	LO+1	;Y-COORDINATE.
	STA	BOMBH,X
	LDA	#115	;GET RANDOM #.
	JSR	RANDO	;(0 TO ACC-1)
	CLC		;NOW ADD SIX.
	ADC	#$06
	ORA	#$01	;BIT 0 ON.
	TAY		;MOVE TO Y.
	LDA	(LO),Y	;GET LOCATION
	BEQ	?PLACEBOMBS	;TUNNEL!
	CMP	#BOMB
	BEQ	?PLACEBOMBS	;IT'S A BOMB!
	LDA	#BOMB	;BOMB CHARACTER.
	STA	(LO),Y	;STORE IN RAM.
	CLC		;STORE NEIGH-
	ADC	#1	;BORING CHARA-
	INY		;CTER IN ADJA-
	STA	(LO),Y	;CENT LOCATION.
	DEY		;ADD CORRECT
	TYA		;VALUE INTO
	CLC		;BOMB DATABASE
	ADC	BOMBL,X	;& SAVE BOMB'S
	STA	BOMBL,X	;X & Y COORDS.
	LDA	#$FF	;RESET BOMB
	STA	ARMED,X	;WITH 255.
	DEX		;HANDLE NEXT.
	BPL	?PLACEBOMBS
;
; PLACE BORDERS
;
	LDX	#$00	;CLEAR X.
?BOARD1
	LDA	SCREENBYTES+1,X	;AT END
	CMP	#$FF	;OF SCR BYTES?
	BEQ	?BOARD2	;YES! BRANCH!
	STA	LO+1	;SAVE RAM LOC.
	LDA	SCREENBYTES,X
	STA	LO	;BOTH LO & HI.
	LDY	#$01	;BORDER CHAR.
	TYA		;MOVE Y TO A.
	STA	(LO),Y	;STORE IT.
	LDY	#127
	STA	(LO),Y	;STORE IT.
	INX		;MOVE TO NEXT
	INX		;SCREEN RAM.
	JMP	?BOARD1	;JUMP ON IT.
?BOARD2
	DEX		;SCREEN RAM
	DEX		;END.
	LDA	SCREENBYTES,X
	STA	LO	;GET LAST 1/2
	LDA	SCREENBYTES+1,X
	STA	LO+1	;& FIRST 1/2
	LDA	SCREENBYTES
	STA	LOW	;PAGE & SAVE
	LDA	SCREENBYTES+1
	STA	LOW+1	;THEIR LOCS.
	LDY	#127	;LOAD POINTER.
	LDA	#$01	;BORDER CHAR.
?BOARD3
	STA	(LO),Y	;SAVE INTO RAM
	STA	(LOW),Y	;AT TOP & BOTTOM
	DEY		;OF BOARD.
	BPL	?BOARD3	;HANDLE ALL...
	JSR	SHOSCO	;SHOW SCORE
	JSR	SHOLVL	;SHOW LEVEL
	JSR	SHOLIV	;SHOW LIVES
;
;RESET ALL ENEMIES
;
	LDX	#29	;CLEAR ALL 30
	LDA	#0	;ZERO OUT...
CLEN	STA	EACT,X	;ACTIVE FLAG
	DEX		;NEXT ENEMY
	BPL	CLEN	;LOOP UNTIL DONE
;
;NOW INITIALIZE 4 ENEMIES
;
	LDX	#3	;4 OF 'EM
IELP	LDA	#1	;SET...
	STA	EACT,X	;ACTIVE FLAG
	LDA	#$FF	;GIVE IT...
	STA	EDIR,X	;RANDOM DIRECTION
	LDA	ENSTH,X	;GET ADDRESS...
	STA	EADH,X	;OF EACH...
	STA	ADL+1	;ENEMY...
	LDA	ENSTL,X	;AND SAVE!
	STA	EADL,X
	STA	ADL
	LDA	#8	;SET UP AS...
	STA	ETYP,X	;TYPE 8
	LDY	#0	;AND DRAW...
	STA	(ADL),Y	;ON DISPLAY
	INY
	CLC
	ADC	#1
	STA	(LO),Y
	DEX		;NEXT ENEMY
	BPL	IELP	;LOOP IF MORE
	LDA	#0	;START UP IN...
	STA	GENFLG	;MATING SEASON!
;
;INIT EGGS
;
	LDA	LEVEL	;GET LEVEL
	SEC		;AND DECREMENT
	SBC	#1	;BY 1,
	LSR	A	;DIVIDE BY 8,
	LSR	A
	LSR	A
	STA	EGGTOT	;SAVE A MINUTE,
	LDA	#3	;GET 3,
	SEC		;SUBTRACT TEMP
	SBC	EGGTOT	;FROM IT,
	STA	EGROUP	;SAVE # OF NESTS
	TAX		;USE AS INDEX...
	LDA	IEGGCT,X	;GET BABY COUNT
	STA	EGGTOT	;AND SAVE...
	STA	EGGS	;IN WORK...
	STA	EGGIX	;AREAS
IEGGL1	LDX	EGROUP	;GET NEXT COUNT
	LDA	EGGSTL,X	;GET ADDRESS...
	STA	HLO	;OF NEST CENTER
	LDA	EGGSTH,X
	STA	HLO+1
	LDX	#12	;13 BABIES
IEGGL2	LDA	HLO	;GET NEST ADDR...
	CLC		;AND ADD...
	ADC	EADDL,X	;DIRECTION...
	STA	ADL	;OFFSET
	LDY	EGGIX
	STA	EGGL,Y
	LDA	HLO+1
	ADC	EADDH,X
	STA	ADL+1
	STA	EGGH,Y
	LDA	#1	;ACTIVATE...
	STA	EGGACT,Y	;BABY
	LDY	#0
	LDA	#12	;AND DRAW...
	STA	(ADL),Y	;BABY...
	INY		;ON SCREEN!
	CLC
	ADC	#1
	STA	(ADL),Y
	DEC	EGGIX	;NEXT INDEX
	DEX		;NEXT BABY
	BPL	IEGGL2	;LOOP IF MORE
	DEC	EGROUP	;NEXT NEST
	BPL	IEGGL1	;LOOP IF MORE
;
;PLACE FIREBUG
;
	LDA	# >SCREENBASE+131
	STA	BUGL+1
	STA	ADL+1
	LDA	# <SCREENBASE+131
	STA	BUGL	;SAVE FIREBUG'S
	STA	ADL	;INITIAL ADDRESS
	LDA	#6	;GET BUG CHAR.
	LDY	#0	;AND DRAW...
	STA	(ADL),Y	;ON SCREEN
	INY
	CLC
	ADC	#1
	STA	(ADL),Y
	JSR	SETCOLORS
	LDA	#$00	;START...
	STA	VSTOP	;VBLANK AGAIN!
	RTS		;INIT DONE!
;
; COLOR SELECTION
;
SETCOLORS
	LDA	RANDOM	;RANDOM #.
	AND	#$F0	;CLEAR LO-NIBBLE
	ORA	#$02	;BIT 1 ON.
	STA	NEWBACK	;SAVE IT.
	LDX	#$04	;HANDLE 4 REGs.
?SETCOLORS
	LDA	RANDOM	;RANDOM #.
	AND	#$F0	;CLEAR LO-NIB.
	ORA	?ORBASE,X	;TURN ON BITS.
	STA	COLOR0,X	;SAVE IT.
	DEX		;HANDLE ALL...
	BPL	?SETCOLORS
	LDA	COLOR0+1	;GET COLOR FOR
	STA	PCOLR0+2	;BORDER MISS-
	STA	PCOLR0+3	;ILES.
	RTS
;
; MOMENTARY PAUSE
;
INIT3
	LDA	RTCLOK+2	;SYSTEM CLOCK.
	CLC		;ONE SECOND
	ADC	#70	;PAUSE...
?INIT3
	CMP	RTCLOK+2	;1 SEC UP?
	BNE	?INIT3	;NO! BRANCH!
	JMP	INIT2	;YES! WHOOSH!!!
;
; SOUND REGISTER INITIALIZATION
;
SOUNDOFF
	JSR	SIOINV	;INIT SOUNDS.
	LDX	#$07	;HANDLE ALL.
	LDA	#$00	;STUFF ZERO.
?SOUNDOFF
	STA	AUDF1,X	;INTO REGISTER.
	DEX		;ALL DONE?
	BPL	?SOUNDOFF	;NO! BRANCH!
	STA	AUDCTL	;STUFF CONTROL.
	RTS		;BEAM ME UP...
;
?ORBASE
	.BYTE	$08,$0A,$08,$04,$00
?TYPEBASE
	.BYTE	0,4,5,6,7
?NUMPROX
	.BYTE	9,19,29,39,49
	.BYTE	59,69,79,89,99
?VECTORS
	.BYTE	63,12,63,31,0,1
	.BYTE	64,12,64,31,0,1
	.BYTE	63,33,63,52,0,1
	.BYTE	64,33,64,52,0,1
	.BYTE	41,32,62,32,1,0
	.BYTE	65,32,86,32,1,0
DIRADL	.BYTE	128,2,128,254
DIRADH	.BYTE	$FF,0,0,$FF
OK	.BYTE	1,0,1,1,1,1,1,0
	.BYTE	0,0,0,0,1,0,1,0
	.BYTE	0,0,0
CHANCE	.BYTE	224,0,64,64,64
	.BYTE	64,255,0,255,0
	.BYTE	255,0,255,0,255,0
	.BYTE	0,0,0
SDIR	.BYTE	$FF,$FF,$FF,$FF
	.BYTE	$FF,$FF,$FF,1
	.BYTE	$FF,$FF,$FF,3
	.BYTE	$FF,2,0,$FF
ENSTH	.BYTE	>SCREENBASE+3775
	.BYTE	>SCREENBASE+4153
	.BYTE	>SCREENBASE+4165
	.BYTE	>SCREENBASE+4543
ENSTL	.BYTE	<SCREENBASE+3775
	.BYTE	<SCREENBASE+4153
	.BYTE	<SCREENBASE+4165
	.BYTE	<SCREENBASE+4543
EADDL	.BYTE	0,128,128,254,2,130
	.BYTE	126,126,130,4,252,0,0
EADDH	.BYTE	0,0,255,255,0,255
	.BYTE	0,255,0,0,255,255,1
EGGSTL	.BYTE	<SCREENBASE+2079
	.BYTE	<SCREENBASE+6239
	.BYTE	<SCREENBASE+6175
	.BYTE	<SCREENBASE+2143
EGGSTH	.BYTE	>SCREENBASE+2079
	.BYTE	>SCREENBASE+6239
	.BYTE	>SCREENBASE+6175
	.BYTE	>SCREENBASE+2143
IEGGCT	.BYTE	12,25,38,51
CSTRT	.BYTE	0,8,16,24,32,40,112
	.BYTE	120,128,160,168,176
	.BYTE	184,192
CDATA	.BYTE	0,0,0,0,0,0,0,0
	.BYTE	170,170,255,255
	.BYTE	255,255,170,170
	.BYTE	16,1,0,4,64,0,1,64
	.BYTE	0,16,1,64,4,0,17,0
	.BYTE	64,1,0,4,64,1,0,16
	.BYTE	16,1,0,64,1,16,0,4
	.BYTE	0,0,0,0,0,0,0,0
	.BYTE	1,4,1,2,11,47,47,10
	.BYTE	64,16,5,128
	.BYTE	224,248,248,160
	.BYTE	255,102,102,102
	.BYTE	102,102,102,255
	.BYTE	255,100,100,100
	.BYTE	100,100,100,255
	.BYTE	255,96,96,96
	.BYTE	96,96,96,255
	.BYTE	255,64,64,64
	.BYTE	64,64,64,255
	.BYTE	255,0,0,0
	.BYTE	0,0,0,255
;
; ***************************
; * RANDOM NUMBER GENERATOR *
; ***************************
;
RANDO
	BEQ	?RET	;IF = 0 BRANCH.
	STA	?HOLD	;SAVE ACC.
	LDA	RANDOM	;GET RANDOM #.
?RAN1
	CMP	?HOLD	;IS IT < ACC?
	BCC	?RET	;YES! BRANCH!
	LSR	A	;NO. DIVIDE BY
	LSR	A	;TWO. TRY AGAIN.
	JMP	?RAN1	;JUMP ON IT!
?RET
	RTS		;BOGGIE...
?HOLD
	.BYTE	0	;TEMP STORAGE.
;
; ***************************
; * X & Y COORDINATE TRACER *
; ***************************
;
XYFIND
	STX	?HOLD	;SAVE X-REG.
	LDA	YCOORD	;GET Y-COORD.
	ASL	A	;MULTIPLY BY 2.
	TAX		;MOVE A TO X.
	LDA	SCREENBYTES,X	;GET RAM
	CLC		;BYTE & ADD
	ADC	XCOORD	;X-COORD.
	STA	LO	;SAVE IT.
	LDA	SCREENBYTES+1,X
	STA	LO+1	;GET HI BYTE.
	LDX	?HOLD	;RESTORE X-REG.
	RTS		;BAMF!!!
?INITX	.BYTE	0
?INITY	.BYTE	0
?FINALX	.BYTE	0
?FINALY	.BYTE	0
?DELTAX	.BYTE	0
?DELTAY	.BYTE	0
; ***********************
; * FINE SCROLL CONTROL *
; *   BY Kyle Peacock   *
; *    [WHO ELSE?!?]    *
; ***********************
;
	.LOCAL
;
SCROLL
	LDA	BUGL+1	;BUG AT SCREEN
	CMP	DLISTSTART+2	;TOP?
	BCS	?VTEST1	;NO! BRANCH!
	LDA	#$00	;YES! CLEAR &
	BEQ	?VSET	;BRANCH!
?VTEST1
	CMP	DLISTEND+2	;BUG AT BOTTOM?
	BCC	?VSCROLL	;NO! BRANCH!
	LDA	#$01	;YES! SET.
?VSET
	STA	?VDIR	;SAVE VERT.FLAG
	LDX	#4	;SET VERT SCROLL
	STX	?VCOUNT	;DISTANCE.
?VSCROLL
	LDA	?VCOUNT	;SCROLL NOW?
	BEQ	?VSTORE	;IF NOT, BRANCH.
	LDA	?VDIR	;GET DIRECTION
	BNE	?DOWN	;TO SCROLL IN.
?UP
	DEC	VBIT	;DEC RAM VSCROL.
	BPL	?VSTORE	;IF >0 BRANCH.
?UP1
	LDA	YPOINT	;GET Y-COORD.
	CMP	MINY	;AT BOARD TOP?
	BNE	?UP2	;NO! BRANCH!
	INC	VBIT	;YES! HALT
	JMP	?VHALT	;SCROLL. BRANCH.
?UP2
	LDA	#$07	;RESET RAM COPY
	STA	VBIT	;OF VSCROL.
	DEC	YPOINT	;DEC Y-COORD.
	JMP	?VDEC	;JUMP ON IT!
?DOWN
	INC	VBIT	;INC RAM VSCROL
	LDA	VBIT	;IF <8 BRANCH.
	CMP	#$08
	BCC	?VSTORE
	LDA	YPOINT	;GET Y-COORD.
	CMP	MAXY	;AT BOARD BOTTOM?
	BNE	?DOWN2	;NO! BRANCH!
	DEC	VBIT	;YES! HALT
	JMP	?VHALT	;SCROLL. BRANCH.
?DOWN2
	LDA	#$00	;RESET RAM COPY
	STA	VBIT	;OF VSCROL.
	INC	YPOINT	;INC Y-COORD.
?VDEC
	DEC	?VCOUNT	;DEC VERT
	JMP	?VSTORE	;SCROLL COUNT.
?VHALT
	LDA	#$00	;HALT VERT
	STA	?VCOUNT	;SCROLL COUNT.
?VSTORE
	LDA	VBIT	;GET RAM COPY &
	STA	VSCROL	;SAVE IN OS.
	LDA	DLISTSTART+1	;TEST TO
	AND	#$7F	;SEE IF BUG IS
	STA	?HOLD	;TOO FAR LEFT
	LDA	BUGL	;OR TOO FAR
	AND	#$7F	;RIGHT OF SCREEN
	SEC		;CENTER.
	SBC	?HOLD
	CMP	#30	;VALUE < 30?
	BCC	?HTEST2	;YES! BRANCH!
	LDA	#$00	;TOO FAR RIGHT.
	BEQ	?HSET	;BRANCH!
?HTEST2
	CMP	#15	;VALUE > 14?
	BCS	?HSCROLL	;YES! BRANCH!
	LDA	#$01	;TOO FAR LEFT.
?HSET
	STA	?HDIR	;SAVE DIRECTION.
	LDA	#12	;SET HORT SCROLL
	STA	?HCOUNT	;DISTANCE.
?HSCROLL
	LDA	?HCOUNT	;HORT SCROLL?
	BEQ	?HSTORE	;NO! BRANCH!
	LDA	?HDIR	;YES! GET SCROLL
	BEQ	?RIGHT	;DIRECTION.
?LEFT
	INC	HBIT	;INC RAM HSCROL.
	LDA	HBIT	;IS IT > 3?
	CMP	#$04
	BCC	?HSTORE	;NO! BRANCH!
	LDA	XPOINT	;AT LEFT EDGE?
	CMP	MINX
	BNE	?LEFT2	;NO! BRANCH!
	DEC	HBIT	;RESET HSCROL
	JMP	?HHALT	;& HALT SCROLL.
?LEFT2
	LDA	#$00	;RESET HSCROL
	STA	HBIT	;RAM COPY.
	DEC	XPOINT	;DEC X-COORD.
	JMP	?HDEC	;JUMP ON IT!
?RIGHT
	DEC	HBIT	;DEC RAM HSCROL
	BPL	?HSTORE	;IF >0 BRANCH!
	LDA	XPOINT	;GET X-COORD.
	CMP	MAXX	;AT RIGHT EDGE?
	BNE	?RIGHT2	;NO! BRANCH!
	INC	HBIT	;RESET HSCROL
	JMP	?HHALT	;& HALT SCROLL.
?RIGHT2
	LDA	#$03	;RESET RAM
	STA	HBIT	;HSCROL &
	INC	XPOINT	;INC X-COORD.
?HDEC
	DEC	?HCOUNT	;DEC HORT SCROLL
	JMP	?HSTORE	;COUNT.
?HHALT
	LDA	#$00	;HALT HORT
	STA	?HCOUNT	;SCROLL COUNT.
?HSTORE
	LDA	HBIT	;SAVE RAM HSCROL
	STA	HSCROL	;INTO OS.
	LDX	PLAYNO	;GET JOYSTICK
	LDY	STICK0,X	;POSITION.
	CPY	#15	;CENTERED?
	BEQ	?SCROLLDONE	;YES-BRANCH.
	CPY	?PREVIOUS	;UNTOUCHED?
	BEQ	?SCROLLDONE	;YES-BRANCH.
	LDA	?TYPESET-5,Y	;UPDATE
	STA	TYPE	;BUG FACING.
?SCROLLDONE
	STY	?PREVIOUS	;SAVE STICK.
	RTS		;CHOW BABY...
?PREVIOUS
	.BYTE	0	;PREVIOUS STICK
?TYPESET	;		BUG HEADINGS
	.BYTE	3,1,1,0,2,0,2,0,3,0
?HOLD
	.BYTE	0	;TEMP STORAGE
?VDIR
	.BYTE	0	;VERT DIRECTION
?HDIR
	.BYTE	0	;HORT DIRECTION
?VCOUNT
	.BYTE	0	;VERTICAL COUNT
?HCOUNT
	.BYTE	0	;HORIZONTAL COUNT
; ************************
; * FIREBUG DRAW ROUTINE *
; *   BY  Kyle Peacock   *
; ************************
;
	.LOCAL
;
DRAW
	LDA	MAXBUGS	;# OF CHARS TO
	STA	?COUNT	;MODIFY.
?DRAW1
	LDX	?COUNT	;GET COUNTER.
	LDY	TYPE,X	;CHARACTER TYPE.
	LDA	PHASE,X	;TYPE PHASE.
	CMP	?INDEX+1,Y	;PHASE EXCEEDED?
	BCC	?DRAW3	;NO! BRANCH!
?DRAW2
	LDA	?INDEX,Y	;RESET WITH
	STA	PHASE,X	;PROPER PHASE.
?DRAW3
	CMP	?INDEX,Y	;CORRECT PHASE?
	BCC	?DRAW2	;NO! BRANCH!
	ASL	A	;PHASE TIMES 2.
	TAY		;MOVE A TO Y.
	LDA	?OFFSET,Y	;ADDR OF CHAR
	STA	DRWLO	;DATA (LO BYTE)
	LDA	?OFFSET+1,Y	;HI BYTE OF
	STA	DRWLO+1	;CHAR DATA.
	LDA	?COUNT	;GET COUNTER.
	ASL	A	;MULTIPLY BY 2.
	TAY		;MOVE A TO Y.
	LDA	?PLAYBASE,Y	;DESTINATION
	STA	PLLO	;LO BYTE
	LDA	?PLAYBASE+1,Y	;&
	STA	PLLO+1	;HI BYTE.
	LDY	#15	;MOVE 16 BYTES.
?DRAW4
	LDA	(DRWLO),Y	;GET DATA.
	STA	(PLLO),Y	;SAVE DATA.
	DEY		;NEXT BYTE.
	BPL	?DRAW4	;ALL DONE?
	DEC	?COUNT	;NEXT CHARACTER.
	BPL	?DRAW1	;ALL DONE?
	DEC	?PHTIME	;DEC TIMER.
	BPL	?DRAW7	;IF >0 BRANCH!
	LDA	MOVETIME	;RESET PHASE
	STA	?PHTIME	;TIMER.
	LDX	PLAYNO	;PLAYER NUMBER.
	LDA	STICK0,X	;GET JOYSTICK.
	CMP	#15	;CENTERED?
	BEQ	?DRAW7	;YES! BRANCH!
	INC	PHASE	;INC FIREBUG PHASE.
?DRAW7
	DEC	?PHTIME+1	;DEC TIMER.
	BPL	?DRAW9	;IF >0 BRANCH.
	LDA	PHASETIME	;RESET TIMER.
	STA	?PHTIME+1	;SAVE IT.
	LDX	MAXBUGS	;# OF CHARs
?DRAW8
	INC	PHASE,X	;UPDATE PHASES.
	DEX		;HANDLE NEXT.
	BNE	?DRAW8	;ALL DONE?
?DRAW9
	RTS		;ZOOOOOOM!!!
?COUNT
	.BYTE	0	;COUNTER
?PHTIME
	.BYTE	3,3	;TIMERS
;
?INDEX	;		CHARACTER INDEX
	.BYTE	0,4,8,12,16
	.BYTE	21,31,37,40
;
?PLAYBASE
	.WORD	[GAMESET+48]
	.WORD	[GAMESET+64]
	.WORD	[GAMESET+80]
	.WORD	[GAMESET+96]
	.WORD	[GAMESET+144]
;
?OFFSET
	.WORD	FIREBUGUP1
	.WORD	FIREBUGUP2
	.WORD	FIREBUGUP3
	.WORD	FIREBUGUP2
	.WORD	FIREBUGRIGHT1
	.WORD	FIREBUGRIGHT2
	.WORD	FIREBUGRIGHT3
	.WORD	FIREBUGRIGHT2
	.WORD	FIREBUGLEFT1
	.WORD	FIREBUGLEFT2
	.WORD	FIREBUGLEFT3
	.WORD	FIREBUGLEFT2
	.WORD	FIREBUGDOWN1
	.WORD	FIREBUGDOWN2
	.WORD	FIREBUGDOWN3
	.WORD	FIREBUGDOWN2
	.WORD	?BUG11
	.WORD	?BUG12
	.WORD	?BUG13
	.WORD	?BUG14
	.WORD	?BUG15
	.WORD	?BUG21
	.WORD	?BUG22
	.WORD	?BUG23
	.WORD	?BUG24
	.WORD	?BUG25
	.WORD	?BUG26
	.WORD	?BUG25
	.WORD	?BUG24
	.WORD	?BUG23
	.WORD	?BUG22
	.WORD	?EGG1
	.WORD	?EGG2
	.WORD	?EGG3
	.WORD	?EGG4
	.WORD	?EGG3
	.WORD	?EGG2
	.WORD	BULLET1
	.WORD	BULLET2
	.WORD	BULLET3
FIREBUGUP1
	.BYTE	12,2,9,194,53,202,53,2
	.BYTE	48,128,96,131,92,163,92,128
FIREBUGUP2
	.BYTE	3,2,9,2,245,10,245,2
	.BYTE	192,128,96,128,95,160,95,128
FIREBUGUP3
	.BYTE	12,2,9,2,53,202,53,194
	.BYTE	48,128,96,128,92,163,92,131
FIREBUGRIGHT1
	.BYTE	12,51,25,153,153,25,51,12
	.BYTE	192,0,35,152,152,35,0,192
FIREBUGRIGHT2
	.BYTE	51,51,25,153,153,25,51,51
	.BYTE	0,0,32,155,155,32,0,0
FIREBUGRIGHT3
	.BYTE	204,51,25,153,153,25,51,204
	.BYTE	0,0,35,152,152,35,0,0
FIREBUGLEFT1
	.BYTE	3,0,200,38,38,200,0,3
	.BYTE	48,204,100,102,102,100,204,48
FIREBUGLEFT2
	.BYTE	0,0,8,230,230,8,0,0
	.BYTE	204,204,100,102,102,100,204,204
FIREBUGLEFT3
	.BYTE	0,0,200,38,38,200,0,0
	.BYTE	51,204,100,102,102,100,204,51
FIREBUGDOWN1
	.BYTE	2,53,202,53,194,9,2,12
	.BYTE	128,92,163,92,131,96,128,48
FIREBUGDOWN2
	.BYTE	2,245,10,245,2,9,2,3
	.BYTE	128,95,160,95,128,96,128,192
FIREBUGDOWN3
	.BYTE	194,53,202,53,2,9,2,12
	.BYTE	131,92,163,92,128,96,128,48
?BUG11
	.BYTE	48,12,2,9,9,50,192,0
	.BYTE	0,3,140,96,96,128,48,12
?BUG12
	.BYTE	0,240,14,9,9,14,48,48
	.BYTE	12,12,176,96,96,176,15,0
?BUG13
	.BYTE	0,0,242,9,9,2,12,12
	.BYTE	48,48,128,96,96,143,0,0
?BUG14
	.BYTE	3,0,2,57,201,2,3,0
	.BYTE	0,192,128,99,108,128,0,192
?BUG15
	.BYTE	12,3,2,9,57,194,0,0
	.BYTE	0,0,131,108,96,128,192,48
?BUG21
	.BYTE	0,0,0,1,1,8,160,32
	.BYTE	8,10,32,64,64,0,0,0
?BUG22
	.BYTE	0,0,0,1,1,40,8,0
	.BYTE	0,32,40,64,64,0,0,0
?BUG23
	.BYTE	0,0,0,1,9,2,0,0
	.BYTE	0,0,128,96,64,0,0,0
?BUG24
	.BYTE	0,0,2,9,1,0,0,0
	.BYTE	0,0,0,64,96,128,0,0
?BUG25
	.BYTE	0,8,40,1,1,0,0,0
	.BYTE	0,0,0,64,64,40,32,0
?BUG26
	.BYTE	32,160,8,1,1,0,0,0
	.BYTE	0,0,0,64,64,32,10,8
?EGG1
	.BYTE	0,0,0,171,171,0,0,0
	.BYTE	0,0,0,234,234,0,0,0
?EGG2
	.BYTE	0,0,14,40,40,14,0,0
	.BYTE	0,0,176,40,40,176,0,0
?EGG3
	.BYTE	0,50,2,8,8,2,50,0
	.BYTE	0,140,128,32,32,128,140,0
?EGG4
	.BYTE	194,2,2,0,0,2,2,194
	.BYTE	131,128,128,0,0,128,128,131
BULLET1
	.BYTE	0,0,0,2,2,0,0,0
	.BYTE	0,0,0,128,128,0,0,0
BULLET2
	.BYTE	0,0,1,4,4,1,0,0
	.BYTE	0,0,64,16,16,64,0,0
BULLET3
	.BYTE	0,3,0,48,48,0,3,0
	.BYTE	0,192,0,12,12,0,192,0
;
; ***************************
; * FIREBUG CHARACTER USAGE *
; ***************************
;
;   CHAR #  REDEFINED CHARACTER
;
;       0       BLANK
;       1       BORDER
;       2       DIRT
;       3       DIRT
;       4       DIRT
;       5       DIRT
;     6 & 7     PLAYER'S FIREBUG
;     8 & 9     ENEMY BUG #1
;    10 & 11    ENEMY BUG #2
;    12 & 13    BABY FIREBUG
;      14       FIREBUG TRAIL
;    15 & 16    PROXIMITY BOMB
;      17       EXPLOSION
;    18 & 19    FIREBUG SPARK
;20,21,22,23,24 SPARK BARLINE
; *************************
; * FIREBUG SPARK HANDLER *
; *    BY Kyle Peacock    *
; *************************
;
	.LOCAL
;
SPARK
	JSR	STARTSPARK	;FIRING.
	JMP	MOVESPARK	;MOVING.
STARTSPARK
	DEC	FIRETIME	;DEC TIMER.
	BNE	?RETURN	;IF <>0 BRANCH!
	LDA	#$03	;RESET TIMER.
	STA	FIRETIME	;SAVE IT.
	LDX	PLAYNO	;GET PLAYER #.
	LDA	TRIG0,X	;GET TRIGGER.
	BNE	?RETURN	;IF <>0 BRANCH!
	LDA	NOBULL,X	;FIRED BULLETS.
	CMP	#$05	;IF >=5,
	BCS	?RETURN	;BRANCH!
	LDA	BULLETLINE+10	;CHECK BAR
	CMP	#24	;LINE.
	BEQ	?RETURN	;IF CHR=24 BRANCH!
	LDX	#$03	;SET UP X.
?SEARCH
	LDA	BULLDIR,X	;THIS BULLET
	CMP	#$FF	;ACTIVE?
	BEQ	?FOUND	;NO! BRANCH!
	DEX		;YES, CHECK NEXT
	BPL	?SEARCH	;WORK AREA.
	JMP	?RETURN	;NONE AVAILABLE.
?FOUND
	INC	NOBULL	;INC BULLETS FIRED.
	LDA	BUGL	;FIREBUG'S LO
	STA	BULLX,X	;ADDRESS.
	LDA	BUGL+1	;FIREBUG'S HI
	STA	BULLY,X	;ADDRESS.
	LDA	TYPE	;GET FIREBUG'S
	STA	BULLDIR,X	;DIRECTION.
	LDA	#20	;SET SPARK LIFE.
	STA	BULLTIME,X	;SAVE IT.
	LDA	#6	;SET UP FIRING
	STA	BULLNOISE	;SOUND EFFECT.
	LDX	BULLPNT	;DEC BAR LINE OF
	INC	BULLETLINE,X	;REMAINING
	LDA	BULLETLINE,X	;SPARKS.
	CMP	#24	;[DON'T ALLOW
	BNE	?RETURN	;SPARK EJECTION
	LDA	BULLPNT	;IF NO SPARKS
	CMP	#10	;ARE ON BAR
	BEQ	?RETURN	;LINE.]
	DEC	BULLPNT	;DEC POINTER.
?RETURN
	RTS		;GET OUT!!!
MOVESPARK
	LDX	#$03	;HANDLE ALL.
?SPARKY
	LDA	BULLDIR,X	;SPARK DIRECT.
	CMP	#$FF	;IS IT $FF?
	BNE	?SPARKS	;NO! BRANCH!
	JMP	?NEXTBULL	;HANDLE NEXT.
?SPARKS
	LDA	BULLX,X	;GET BULLET LO.
	STA	ZLO	;SAVE IT.
	LDA	BULLY,X	;GET BULLET HI.
	STA	ZLO+1	;SAVE IT.
	LDY	#$00	;CLEAR Y-REG.
	LDA	(ZLO),Y	;GET CHAR.
	CMP	#18	;BULLET?
	BEQ	?BLANK	;YES. BRANCH!
	CMP	#17	;EXPLOSION?
	BNE	?NOBLANK	;YES! BRANCH!
?BLANK
	LDA	#14	;FIREBUG TRAIL.
	STA	(ZLO),Y	;SAVE IT.
	INY		;INC POINTER.
	STA	(ZLO),Y	;SAVE IT.
?NOBLANK
	LDA	BULLDIR,X	;SPARK DIRECT.
	BPL	?REDRAW	;IF >0 BRANCH!
	LDA	#$FF	;TURN OFF SPARK.
	STA	BULLDIR,X	;SAVE IT.
	DEC	NOBULL	;DEC FIRED SPARKS.
	JMP	?NEXTBULL	;HANDLE NEXT.
?REDRAW
	TAY		;MOVE A TO Y.
	LDA	BULLX,X	;GET SPARK LO.
	CLC		;CLEAR CARRY.
	ADC	?LOADD,Y	;DIRECTION ADD.
	STA	ZLO	;SAVE IT.
	LDA	BULLY,X	;GET SPARK HI.
	ADC	?HIADD,Y	;DIRECTION ADD.
	STA	ZLO+1	;SAVE IT.
	LDY	#$00	;CLEAR Y-REG.
	LDA	(ZLO),Y	;GET CHARACTER.
	AND	#$7F	;CLEAR BIT 7.
	BEQ	?GO	;IF =0 BRANCH!
	CMP	#14	;IS IT =14?
	BEQ	?GO	;YES! BRANCH!
?STOP
	PHA		;SAVE CHARACTER.
	LDA	#$80	;BIT 7 ON.
	STA	BULLDIR,X	;SAVE IT.
	PLA		;RESTORE CHAR.
	CMP	#1	;BORDER?
	BEQ	?NEXTBULL	;YES! BRANCH!
	CMP	#15	;BOMB?
	BEQ	?NEXTBULL	;YES! BRANCH!
	CMP	#12	;BABY FIREBUG?
	BEQ	?NEXTBULL	;YES! BRANCH!
	JSR	?POSITION	;SAVE NEW X&Y.
	LDA	#17	;EXPLOSION.
	STA	(ZLO),Y	;SAVE IT.
	INY		;INC POINTER.
	STA	(ZLO),Y	;SAVE IT.
	LDA	#21	;TURN ON DETO-
	STA	BOOMNOISE	;NATION SOUND.
	BNE	?NEXTBULL	;BRANCH!
?GO
	LDA	#18	;BULLET.
	STA	(ZLO),Y	;SAVE IT.
	INY		;INC POINTER.
	CLC		;INC CHAR.
	ADC	#$01
	STA	(ZLO),Y	;SAVE IT.
	JSR	?POSITION	;SAVE NEW X&Y.
	DEC	BULLTIME,X	;DEC LIFETIME.
	BPL	?NEXTBULL	;IF >0 BRANCH!
	LDA	#$01	;FORCED HALT.
	BNE	?STOP	;BRANCH!
?NEXTBULL
	DEX		;DEC POINTER.
	BMI	?RETURN2	;IF <0 BRANCH!
	JMP	?SPARKY	;JUMP ON IT.
?RETURN2
	RTS		;LATER Y'ALL...
?POSITION
	LDA	ZLO	;GET NEW LO.
	STA	BULLX,X	;SAVE IT.
	LDA	ZLO+1	;GET NEW HI.
	STA	BULLY,X	;SAVE IT.
	RTS		;PLEASE LEAVE!!!
;
; DIRECTIONAL ADD ONs
;
?LOADD
	.BYTE	128,2,254,128
?HIADD
	.BYTE	255,0,255,0
;
; *********************
; * EXPLOSION ROUTINE *
; *   BY Tom Hudson   *
; *********************
;
EXPLOD	LDA	#0	;RESET...
	STA	EXPPH	;EXP. PHASE
	LDA	#66	;AND START...
	STA	EXNOISE	;EXP. SOUND
EXPDLP	LDA	#17	;SET UP...
	STA	EXPCHR	;EXPLOSION CHAR.
	LDA	EXPPH	;GET PHASE
	CMP	#13	;>12?
	BCC	PH1	;NO, PHASE 1
	SEC		;ADJUST INDEX...
	SBC	#13	;FOR PHASE 2
	LDY	#0	;AND SET UP...
	STY	EXPCHR	;ERASE CHARACTER
PH1	TAX		;PUT PHASE IN X
	LDA	ELO	;AND ADD...
	CLC		;EXPLOSION...
	ADC	EADDL,X	;ADDRESS...
	STA	ELO2	;OFFSET...
	LDA	ELO+1	;FOR THE BYTE...
	ADC	EADDH,X	;TO BE...
	STA	ELO2+1	;CHANGED!
	LDY	#0	;NOW PUT...
	LDA	EXPCHR	;EXPLOSION CHAR.
	STA	(ELO2),Y	;ONTO DISPLAY
	INY
	STA	(ELO2),Y
	JSR	WAIT	;WAIT A LITTLE
	INC	EXPPH	;NEXT PHASE
	LDA	EXPPH	;GET PHASE
	CMP	#26	;ALL DONE?
	BNE	EXPDLP	;NO, LOOP BACK!
	RTS		;BYE!
;
;TIME DELAY ROUTINE
;
WAIT	LDX	#$03	;THIS ROUTINE
XLOOP	LDY	#$FF	;WASTES A LITTLE
YLOOP	DEY		;TIME SO THE
	BNE	YLOOP	;EXPLOSIONS
	DEX		;CAN BE SEEN.
	BNE	XLOOP
	RTS
;
; ***************************
; * PROXIMITY BOMB HANDLERS *
; *      BY Tom Hudson      *
; ***************************
;
ARMBOM	LDX	BOMBCT	;GET # OF BOMBS
ARMLP	LDA	ARMED,X	;GET ARMED FLAG
	CMP	#$FF	;ARMED YET?
	BNE	NXTBOM	;YES!
	LDA	BOMBL,X	;GET BOMB...
	STA	BLO	;ADDRESS...
	LDA	BOMBH,X	;AND SAVE IT
	STA	BLO+1
	LDY	#0	;GET CHAR...
	LDA	(BLO),Y	;FROM DISPLAY
	CMP	#15	;IS IT BOMB?
	BEQ	DONARM	;YUP, IT'S OK.
	CMP	#12	;IS IT BABY?
	BNE	SETARM	;NO, ARM IT!
	LDA	#$80	;THIS CORRECTS A
	STA	ARMED,X	;SMALL PROBLEM,
	BNE	NXTBOM	;DISABLING BOMB
SETARM	LDA	#15	;RESTORE...
	STA	(BLO),Y	;BOMB GRAPHIC...
	LDA	#16	;ON DISPLAY
	INY
	STA	(BLO),Y
	BNE	ARMIT	;SET ARM TIMER
DONARM	LDY	#3	;SCAN 4 DIRS.
ARMSCAN	LDA	BLO	;ADD...
	CLC		;DIRECTION...
	ADC	DIRADL,Y	;OFFSET...
	STA	BLO2	;TO BOMB...
	LDA	BLO+1	;ADDRESS
	ADC	DIRADH,Y
	STA	BLO2+1
	STY	YTEMP	;SAVE Y REG.
	LDY	#0	;GET DESIRED...
	LDA	(BLO2),Y	;DIRECTION BYTE
	CMP	#18	;SPARK?
	BEQ	ARMIT	;YES, ARM IT!
	CMP	#6	;FIREBUG?
	BNE	NOARM	;NO!
ARMIT	LDA	#60	;1 SECOND DELAY
	STA	ARMED,X	;ARM IT!
NXTBOM	DEX		;NEXT BOMB
	BPL	ARMLP	;LOOP IF MORE
	BMI	DECBT	;NOW HANDLE TIME
NOARM	LDY	YTEMP	;RESTORE Y REG
	DEY		;NEXT DIRECTION
	BMI	NXTBOM	;NO MORE DIRS!
	JMP	ARMSCAN	;LOOP IF MORE
;
;HANDLE BOMB TIMERS, DETONATE
;
DECBT	LDX	BOMBCT	;GET # OF BOMBS
DBLP	LDA	ARMED,X	;IS IT ARMED?
	BMI	NOTARM	;NOT ARMED!
	LDA	BOMBL,X	;LOAD POINTER...
	STA	ELO	;WITH BOMB'S...
	LDA	BOMBH,X	;ADDRESS
	STA	ELO+1
	LDY	#0	;GET THE BYTE...
	LDA	(ELO),Y	;FROM DISPLAY
	BNE	BLOW1	;IT'S OK.
	LDA	#15	;RESTORE IMAGE
	BNE	BLOW2
BLOW1
	LDA	#$80	;TOGGLE HI BIT
	EOR	(ELO),Y	;TO FLASH BOMB
BLOW2
	STA	(ELO),Y	;RE-DRAW BOMB
	INY
	CLC
	ADC	#1
	STA	(ELO),Y
	LDA	#$00	;SET FUSE...
	STA	AUDF4	;FREQUENCY
	LDA	#$88	;TURN ON...
	STA	AUDC4	;FUSE SOUND!
	DEC	ARMED,X	;DEC TIMER
	BNE	NOTARM	;NO EXPLOSION YET
	LDA	#$00	;TURN OFF...
	STA	AUDC4	;FUSE SOUND
	LDA	#$80	;MARK THE BOMB...
	STA	ARMED,X	;INACTIVE
	STX	XTEMP	;SAVE X REG.
	STY	YTEMP	;SAVE Y REG.
	JSR	EXPLOD	;BOOM!!!
	LDX	XTEMP	;RESTORE X
	LDY	YTEMP	;RESTORE Y
NOTARM	DEX		;NEXT BOMB
	BPL	DBLP	;LOOP IF MORE
	RTS		;BYE!
;
; **********************
; * BABY FIREBUG MOVER *
; *   BY Tom Hudson    *
; **********************
;
BMOVE	LDX	EGGTOT	;GET BABY COUNT
EGGLP	STX	EGGIX	;SAVE INDEX
	LDA	EGGACT,X	;IS IT ACTIVE?
	BNE	EACTIVE	;YES!
	JMP	NXTEGG	;NO, NEXT BABY.
EACTIVE	LDA	EGGL,X	;GET...
	STA	HLO	;BABY ADDRESS...
	LDA	EGGH,X	;AND SAVE IT
	STA	HLO+1
	LDY	#0	;GET BABY'S...
	LDA	(HLO),Y	;SCREEN BYTE
	CMP	#12	;IS IT OK?
	BEQ	EGGOK	;YES!
	DEC	EGGS	;NO, KILL ONE
	BMI	ALLDEAD	;ALL DEAD!
	LDA	#0	;MARK BABY...
	STA	EGGACT,X	;INACTIVE
	LDA	#9	;START EATING...
	STA	EATNOISE	;SOUND
	JMP	NXTEGG	;DO NEXT ONE
ALLDEAD	PLA		;CLEAR...
	PLA		;STACK,
	JMP	GAMOVR	;GAME OVER!!!
EGGOK	LDA	#3	;TRY 4 DIRS.
	STA	ETRY	;SAVE INDEX
EGGDLP	LDA	RANDOM	;GET RANDOM...
	AND	#3	;DIRECTION 0-3
	TAY		;PUT IN Y REG.
	LDA	EGGL,X	;GET...
	CLC		;BABY ADDRESS...
	ADC	DIRADL,Y	;AND ADD...
	STA	ADL	;DIRECTION...
	LDA	EGGH,X	;OFFSET
	ADC	DIRADH,Y
	STA	ADL+1
	LDY	#0	;GET CHARACTER
	LDA	(ADL),Y	;FROM SCREEN
	BEQ	MOVEGG	;IT'S TUNNEL!
	CMP	#14	;BUG TUNNEL?
	BEQ	MOVEGG	;YES!
NEDIR	DEC	ETRY	;NEXT DIRECTION
	BPL	EGGDLP	;LOOP IF MORE
NXTEGG	DEX		;NEXT BABY
	BPL	EGGLP	;LOOP IF MORE
	RTS		;ALL DONE!
MOVEGG	LDA	#14	;ERASE BABY...
	STA	(HLO),Y	;USING CHAR 14
	INY		;(BUG TRAIL)
	STA	(HLO),Y
	DEY
	LDA	#12	;DRAW BABY...
	STA	(ADL),Y	;IN NEW...
	INY		;LOCATION
	CLC
	ADC	#1
	STA	(ADL),Y
	LDA	ADL	;UPDATE BABY'S
	STA	EGGL,X	;ADDRESS
	LDA	ADL+1
	STA	EGGH,X
	JMP	NXTEGG	;AND LOOP!
;
; *************************
; * SCOREKEEPING ROUTINES *
; *     BY Tom Hudson     *
; *************************
;
;ADD TO SCORE
;
ADDSCO	LDY	#0	;ZERO Y REG.
	SED		;DECIMAL MODE
	CLC		;CLEAR CARRY
	LDX	#2	;DO 3 DIGITS
ASCLP	LDA	SCORE,X	;GET DIGIT
	ADC	SCOADD,X	;ADD INCREMENT
	STA	SCORE,X	;SAVE DIGIT
	STY	SCOADD,X	;CLEAR INCREMENT
	DEX		;NEXT DIGIT
	BPL	ASCLP	;LOOP IF MORE
	CLD		;NO MORE DECIMAL
;
;SHOW SCORE
;
SHOSCO	LDA	#$10	;COLOR 0
	STA	SHCOLR	;SAVE IT
	LDX	#0	;DISPLAY INDEX
	LDY	#0	;DIGIT #
SSCOLP	LDA	SCORE,Y	;GET DIGIT
	JSR	SHOBCD	;SHOW ON SCREEN
	INX		;NEXT SCREEN POS
	INX		;(INC TWICE)
	INY		;NEXT DIGIT
	CPY	#3	;DONE ALL 3?
	BNE	SSCOLP	;NO!
	RTS		;ALL DONE!
;
;SHOW 2 BCD DIGITS
;
SHOBCD	STA	SHOBYT	;SAVE BCD BYTE
	AND	#$0F	;GET LOW DIGIT
	ORA	SHCOLR	;ADD COLOR
	STA	SCOLIN+1,X	;SHOW IT!
	LDA	SHOBYT	;GET BCD BYTE
	LSR	A	;GET HI DIGIT
	LSR	A
	LSR	A
	LSR	A
	ORA	SHCOLR	;ADD COLOR
	STA	SCOLIN,X	;SHOW IT!
	RTS		;ALL DONE!
;
;SHOW CURRENT LEVEL
;
SHOLVL	LDY	#$50	;COLOR 1
	STY	SHCOLR	;SAVE COLOR
	LDA	BCDLVL	;GET LEVEL #
	LDX	#11	;PUT IN 11TH BYTE
	JMP	SHOBCD	;SHOW IT!
;
;SHOW # OF LIVES
;
SHOLIV	LDA	LIVES	;GET # OF LIVES
	BMI	ENDSHO	;<0!!
	ORA	#$90	;ADD COLOR 3
	STA	SCOLIN+19	;SHOW IT!
ENDSHO
	RTS		;ALL DONE!