sdh@rabbit.UUCP (S. Hawley) (04/21/84)
The following is a nice little assembly language program that demonstrates the power of the subroutines built into Applesoft. It wwas written with a SC 4.0 assembler. Any opcode starting with a '.' is a pseudo-op built into the assembler. You'll have to consult your own assembler manual to find the proper translations. .BS = block storage. Set aside the number of bytes specified (.BS 16 will set aside 16 bytes) .HS = Hex string. The bytes following the op are to be stored as a hex table .EQ = Equate set variable name to a location .OR = Origin. Set begining of program. The program: 'Linear1' 1000 .OR $0800 1010 X1 .EQ $04 1020 Y1 .EQ $05 1030 X2 .EQ $06 1040 Y2 .EQ $07 1050 .EQ $08 1060 TEMP .EQ $09 1070 EX1 .EQ $00 1080 EY1 .EQ $01 1090 EX2 .EQ $02 1100 EY2 .EQ $03 1110 HGR .EQ $F3E2 1120 SETCOL .EQ $F6F0 1130 HPLOT .EQ $F457 1140 HLIN .EQ $F53A 1150 RANDOM .EQ $EFAE 1160 *-------------------------- 1170 BEGIN JMP START1 1180 SHUFFLE.LIST 1190 LDA XTABL1 1200 STA EX1 1210 LDA YTABL1 1220 STA EY1 1230 LDA XTABL2 1240 STA EX2 1250 LDA YTABL2 1260 STA EY2 1270 LDX #$00 1280 .1 LDA XTABL1+1,X 1290 STA XTABL1,X 1300 LDA YTABL1+1,X 1310 STA YTABL1,X 1320 LDA XTABL2+1,X 1330 STA XTABL2,X 1340 LDA YTABL2+1,X Oh, I forgot to mention. The program will generate a moving line pattern similar to that in the game QIX. I disclaim any knowledge of bugs in the program. Steve Hawley <allegra,alice>!rabbit!sdh 1350 STA YTABL2,X 1360 INX 1370 CPX #$0F 1380 BNE .1 1390 LDA X1 1400 STA XTABL1+15 1410 LDA Y1 1420 STA YTABL1+15 1430 LDA X2 1440 STA XTABL2+15 1450 LDA Y2 1460 STA YTABL2+15 1470 RTS 1480 XTABL1 .BS 16 1490 YTABL1 .BS 16 1500 XTABL2 .BS 16 1510 YTABL2 .BS 16 1520 *---------------------------- 1530 CHANGE.COORDS 1540 LDA D1 1550 BNE XMI1 1560 LDA X1 1570 CLC 1580 ADC #$07 1590 BCS A 1600 STA X1 1610 JMP YCNG1 1620 A LDA D1 1630 EOR #$01 1640 STA D1 1650 JMP CHANGE.COORDS 1660 XMI1 LDA X1 1670 SEC 1680 SBC #$07 1690 BCC A 1700 STA X1 1710 YCNG1 LDA D2 1720 BNE YMI1 1730 LDA Y1 1740 CLC 1750 ADC #$05 1760 CMP #$BE 1770 BCS B 1780 STA Y1 1790 JMP CNG2 1800 B LDA D2 1810 EOR #$01 1820 STA D2 1830 JMP YCNG1 1840 YMI1 LDA Y1 1850 SEC 1860 SBC #$05 1870 BCC B 1880 STA Y1 1890 JMP CHNG2 1900 CHNG2 LDA D2 1910 BNE XMI2 1920 LDA X2 1930 CLC 1940 ADC #$08 1950 BCS C 1960 STA X2 1970 JMP YCNG2 1980 C LDA D3 1990 EOR #$01 2000 STA D3 2010 JMP CHNG2 2020 XMI2 LDA X2 2030 SEC 2040 SBC #$08 2050 BCC C 2060 STA X2 2070 YCNG2 LDA D4 2080 BNE YMI2 2090 LDA Y2 2100 CLC 2110 ADC #$06 2120 CMP #$BE 2130 BCS D 2140 STA Y2 2150 RTS 2160 D LDA D4 2170 EOR #$01 2180 STA D4 2190 JMP YCNG2 2200 YMI2 LDA Y2 2210 SEC 2220 SBC #$06 2230 BCC D 2240 STA Y2 2250 RTS 2260 D1 .HS 00 2270 D2 .HS 00 2280 D3 .HS 00 2290 D4 .HS 00 2300 *------------------------ 2310 START1 JSR HGR 2320 BIT $C052 2330 BIT $C010 2340 JSR RANDOM 2350 LDA $CC 2360 STA X1 2370 LDA $CC 2380 STA X2 2390 JSR RANDOM 2400 LDA $CC 2410 AND #$7F 2420 STA Y2 2430 JSR RANDOM 2440 LDA $CC 2450 AND #$7F 2460 STA Y2 2470 LDA #$10 2480 STA TEMP 2490 .1 JSR CHANGE.COORDS 2500 JSR SHUFFLE.LIST 2510 DEC TEMP 2520 BNE .1 2530 .2 LDA #$00 2540 STA COLR 2550 .3 LDA #$04 2560 STA TEMP 2570 .4 JSR CHANGE.COORDS 2580 JSR SHUFFLE.LIST 2590 LDX #$00 2600 JSR SETCOL 2610 LDA EX1 2620 LDY #$00 2630 LDA EY1 2640 JSR HPLOT 2650 LDA EX2 2660 LDY EY2 2670 LDX #$00 2680 JSR HLIN 2690 LDY COLR 2700 LDA COLOR,Y 2710 TAX 2720 JSR SETCOL 2730 LDX X1 2740 LDY #$00 2750 LDA Y1 2760 JSR HPLOT 2770 LDA X2 2780 LDY Y2 2790 LDX #$00 2800 JSR HLIN 2810 LDA $C000 2820 BMI EXIT 2830 DEC TEMP 2850 INC COLR 2860 LDA COLR 2870 CMP #$06 2880 BNE .3 2890 JMP .2 2900 COLOR .HS 020102070506 2910 EXIT BIT $C010 2920 BIT $C051 2930 RTS 2840 BNE .4