10 *FX225,129 20 DIM CODE 2000 30 int1=&80:int2=&84:mod=&80:div=&82 40 divisor=&7E:store=&70 50 sign1=&8E:sign2=&8F 60 rdeg=&88:sdeg=&89:cdeg=&8A 70 posneg=&8B:tabloc=&8C 80 rsign=&72:ssign=&73:csign=&74 90 rstore=&75:sstore=&77:cstore=&79 100 table=&900 110 : 120 FOR I%=4 TO 7 STEP3 122 O%=CODE 130 P%=&2800 140 [OPTI% 150 .mainloop 160 JSR tra_int:JSR plus 170 JSR check360:JSR trint_a 180 : 190 LDA &404:STA int1 200 LDA &405:STA int1+1 210 LDA &40C:STA int1+2 220 LDA &40D:STA int1+3 230 JSR multiply:JSR check360:JSR cast 240 LDA int1:STA rstore 250 LDA int1+1:STA rstore+1 260 LDA posneg:STA rsign 270 : 280 JSR tra_int:JSR check360:JSR cast 290 LDA int1:STA sstore 300 LDA int1+1:STA sstore+1 310 LDA posneg:STA ssign 320 : 330 JSR tra_int 340 LDA #90:STA int2 350 LDA #0:STA int2+1 360 STA int2+2:STA int2+3 370 JSR plus:JSR check360:JSR cast 380 LDA int1:STA cstore 390 LDA int1+1:STA cstore+1 400 LDA posneg:STA csign 410 : 420 LDA rstore:STA int1+2 430 LDA rstore+1:STA int1+3 440 JSR multiply:JSR ror18 480 LDA rsign:CMP csign:BNE cpos 490 JSR negate 500 .cpos 510 LDA int1:STA cstore 520 LDA int1+1:STA cstore+1 530 : 540 LDA sstore:STA int1 550 LDA sstore+1:STA int1+1 560 LDA rstore:STA int1+2 570 LDA rstore+1:STA int1+3 580 JSR multiply:JSR ror18 600 LDA rsign:CMP ssign:BNE spos 610 JSR negate 620 .spos 630 LDA int1:STA sstore 640 LDA int1+1:STA sstore+1 642 JSR plot 644 : 660 JSR tra_int 670 LDA int1+3:BEQ t2:JMP mainloop 672 .t2 680 LDA int1+2:BEQ t3:JMP mainloop 690 .t3 700 LDA int1+1:BEQ t4:JMP mainloop 710 .t4 720 LDA int1:BEQ t5:JMP mainloop 722 .t5 730 \"Back to basic 740 RTS 750 .trint_a 760 LDX #8:LDY #0 770 .trnloop1 780 LDA int1,Y:STA &404,Y 790 INY:DEX:BNE trnloop1 800 RTS 810 .tra_int 820 LDX #8:LDY #0 830 .trnloop2 840 LDA &404,Y:STA int1,Y 850 INY:DEX:BNE trnloop2 860 RTS 870 .plot 880 LDA #25:JSR &FFEE 890 LDA #5 :JSR &FFEE 900 LDA sstore:JSR &FFEE 910 LDA sstore+1:JSR &FFEE 920 LDA cstore:JSR &FFEE 930 LDA cstore+1:JSR &FFEE 940 RTS 950 .cast 960 JSR minus180:JSR minus90 970 \"table+(deg*4) 974 ASL int1:ROL int1+1 975 ASL int1:ROL int1+1 1030 LDA #table DIV &100:STA int2+1 1040 LDA #table MOD &100:STA int2 1050 LDA #0:STA int2+2:STA int2+3 1060 JSR plus 1080 LDA int1:STA tabloc 1090 LDA int1+1:STA tabloc+1 1100 LDY #3 1110 .fetch 1120 LDA (tabloc),Y:STA int1,Y 1130 DEY:BPL fetch 1150 RTS 1160 .minus90 1170 LDA int1:CMP #&5A 1180 BEQ nomin:BCC nomin 1190 .min90 1200 LDA #&4C:STA int2 1210 LDA #&FF:STA int2+1 1220 STA int2+2:STA int2+3 1240 JSR plus:JSR negate 1250 RTS 1260 .minus180 1270 LDA #0:STA posneg 1280 LDA int1+1:BNE min180 1290 LDA int1:CMP #&B4 1300 BEQ nomin:BCC nomin 1310 .min180 1320 LDA #&4C:STA int2 1330 LDA #&FF:STA int2+1 1340 STA int2+2:STA int2+3 1350 JSR plus 1360 LDA #&FF:STA posneg 1370 .nomin 1380 RTS 1390 .plus 1400 CLC 1410 LDA int1 :ADC int2 :STA int1 1420 LDA int1+1:ADC int2+1:STA int1+1 1430 LDA int1+2:ADC int2+2:STA int1+2 1440 LDA int1+3:ADC int2+3:STA int1+3 1450 RTS 1460 .ror18 1470 LDY #17 1480 .ro1 1490 CLC 1500 ROR int1+3 1510 ROR int1+2 1520 ROR int1+1 1530 ROR int1 1540 DEY 1550 BNE ro1 1560 RTS 1570 .neglow 1580 SEC 1590 LDA #0:SBC int1 :STA int1 1600 LDA #0:SBC int1+1:STA int1+1 1610 RTS 1620 .neghigh 1630 SEC 1640 LDA #0:SBC int1+2:STA int1+2 1650 LDA #0:SBC int1+3:STA int1+3 1660 RTS 1670 .negate 1680 SEC 1690 LDA #0:SBC int1 :STA int1 1700 LDA #0:SBC int1+1:STA int1+1 1710 LDA #0:SBC int1+2:STA int1+2 1720 LDA #0:SBC int1+3:STA int1+3 1730 RTS 1740 .check360 1750 LDA int1+2:BNE more 1760 LDA int1+3:BNE more 1770 LDA int1+1:CMP #&01:BCC less 1780 BNE more 1790 LDA int1 :CMP #&68:BCC less 1800 \ beq less 1810 .more 1820 JSR mod360 1830 .less 1840 RTS 1850 .mod360 1860 LDA #&68:STA divisor 1870 LDA #&01:STA divisor+1 1880 LDA int1+3:BPL pos1 1890 LDA #&01:STA sign1 1900 .pos1 1910 JSR divmod 1920 LDA #0:STA int1+2:STA int1+3 1930 LDA sign1:BEQ pos2 1940 JSR negate 1950 .pos2 1960 LDA #0:STA sign1 1970 RTS 1980 \"32bit / 16bit 1990 \"16bit div 16bit mod 2000 .divmod 2010 LDY #0 2020 STY store 2030 LDA int1 2040 LDY int1+2 2050 STY int1 2060 ASL A 2070 STA int1+2 2080 LDA int1+1 2090 LDY int1+3 2100 STY int1+1 2110 ROL A 2120 STA int1+3 2130 LDX #&10 2140 .dv1 2150 ROL int1 2160 ROL int1+1 2170 ROL store 2180 SEC 2190 LDA int1 2200 SBC divisor 2210 TAY 2220 LDA int1+1 2230 SBC divisor+1 2240 PHA 2250 LDA store 2260 SBC #0 2270 PLA 2280 BCC dv2 2290 STY int1 2300 STA int1+1 2310 .dv2 2320 ROL int1+2 2330 ROL int1+3 2340 DEX 2350 BNE dv1 2360 RTS 2370 .multiply 2380 LDA int1+1:BPL not1 2390 LDA #1:STA sign1:JSR neglow 2400 .not1 2410 LDA int1+3:BPL not2 2420 LDA #1:STA sign2:JSR neghigh 2430 .not2 2440 JSR mult 2450 LDA sign1:CMP sign2:BEQ not3 2460 JSR negate 2470 .not3 2480 LDA #0:STA sign1:STA sign2 2490 RTS 2500 \"16bit * 16bit = 32bit 2510 .mult 2520 LDA int1+2 2530 STA store 2540 LDA int1+3 2550 STA store+1 2560 LDY #0:TYA 2570 STA int1+2 2580 CLC 2590 LDX #&11 2600 BNE ml2 2610 .ml1 2620 BCC ml2 2630 PHA 2640 CLC 2650 LDA int1+2 2660 ADC store 2670 STA int1+2 2680 PLA 2690 ADC store+1 2700 .ml2 2710 ROR A 2720 ROR int1+2 2730 ROR int1+1 2740 ROR int1 2750 DEX 2760 BNE ml1 2770 STA int1+3 2780 RTS 2990 .T% 3010 ]NEXT 3020 : 3030 : 3040 REM"LOAD SIN TABLE 3050 FOR I%=0 TO 90 3060 READ D%:!(&900+I%*4)=D% 3070 NEXT 3080 : 3130 OSCLI("SAVE BCOD "+STR$~(CODE)+" +"+STR$~(O%-CODE)+" "+STR$~(mainloop)) 3140 : 3150 REM"SIN(X)*2^13 3160 DATA0,142,285,428,571 3170 DATA713,856,998,1139 3180 DATA1281,1422,1562,1702 3190 DATA1842,1981,2119,2257 3200 DATA2394,2531,2666,2801 3210 DATA2935,3068,3200,3331 3220 DATA3461,3590,3718,3845 3230 DATA3970,4095,4218,4340 3240 DATA4460,4580,4697,4814 3250 DATA4929,5042,5154,5264 3260 DATA5373,5480,5586,5689 3270 DATA5791,5891,5990,6086 3280 DATA6181,6274,6365,6454 3290 DATA6541,6626,6709,6790 3300 DATA6869,6946,7021,7093 3310 DATA7164,7232,7298,7362 3320 DATA7423,7483,7540,7594 3330 DATA7647,7697,7745,7790 3340 DATA7833,7874,7912,7948 3350 DATA7981,8012,8041,8067 3360 DATA8090,8111,8130,8146 3370 DATA8160,8171,8180,8186 3380 DATA8190,8192