10 ;RANDOM ATARI, SOURCE CODE 20 ;BY DAVID McINTOSH 30 ;(c)1988, ANTIC PUBLISHING 40 *= $6400 50 PLA 60 LDA #23 70 STA 219 80 LDA #172 90 STA 220 0100 LDA #218 0110 STA 221 0120 LDA #126 0130 STA 222 0140 LDX #4 0150 RND1 0155 LDA 204,X 0160 STA 212,X 0170 DEX 0180 BNE RND1 0185 ; 0190 JSR MULT 0200 JSR MOD231M1 0210 LDX #4 0220 RND2 0225 LDA 228,X 0230 STA 204,X 0240 DEX 0250 BNE RND2 0255 ; 0260 JSR ROTATL 0270 JSR BTOD 0280 RTS 0285 ; 0290 *= 1536 0300 ;MULTIPLY FR0 BY FRE GIVING FR1 0310 MULT 0315 LDY #32 0320 LDA #0 0330 LDX #8 0340 ML1 0345 STA 224,X 0350 DEX 0360 BNE ML1 0365 ; 0370 ML2 0375 LDX #8 0380 CLC 0390 R1 0395 ROL 224,X 0400 DEX 0410 BNE R1 0415 ; 0420 LDX #4 0430 CLC 0440 R2 0445 ROL 218,X 0450 DEX 0460 BNE R2 0465 ; 0470 BCC ML3 0475 ; 0480 JSR ADDER 0490 LDX #4 0500 MLA 0505 BCC ML3 0507 ; 0510 LDA 224,X 0520 ADC #0 0530 STA 224,X 0540 DEX 0550 BNE MLA 0555 ; 0560 ML3 0565 DEY 0570 BNE ML2 0575 ; 0580 RTS 0585 ; 0590 ;ADD FR0 TO FR1 0600 ADDER 0605 CLC 0610 LDX #4 0620 ADDR1 0625 LDA 228,X 0630 ADC 212,X 0640 STA 228,X 0650 DEX 0660 BNE ADDR1 0665 ; 0670 RTS 0675 ; 0680 ;CONVERT 8 BYTES AT FR1 0685 ;TO MOD 2^31-1 0690 MOD231M1 0695 LDA #0 0700 STA 224 0710 ASL 229 0720 LDX #5 0730 MOD1 0735 ROL 223,X 0740 DEX 0750 BNE MOD1 0755 ; 0760 LSR 229 0770 LDY #4 0780 MOD2 0785 LDA 228,Y 0790 ADC 224,Y 0800 STA 228,Y 0810 DEY 0820 BNE MOD2 0825 ; 0830 LDA 224 0840 ADC #0 0850 MOD3 0855 STA 228 0860 ASL 229 0870 ROL 228 0880 LSR 229 0890 LDA 228 0900 BEQ MOD5 0905 ; 0910 ADC 232 0920 STA 232 0930 LDY #3 0940 MOD4 0945 LDA #0 0950 ADC 228,Y 0960 STA 228,Y 0970 DEY 0980 BNE MOD4 0985 ; 0990 LDA #0 1000 BEQ MOD3 1005 ; 1010 MOD5 1015 RTS 1017 ; 1020 ;CONVERT BINARY TO DECIMAL 1030 BTOD 1035 LDY #0 1040 LDA #63 1050 STA (203),Y 1060 LDA #0 1070 INY 1080 STA (203),Y 1090 BD1 1095 JSR MOVE 1100 JSR MUL10 1110 LDA 228 1120 BEQ BD2 1125 ; 1130 LDY #1 1140 BNE BD6 1145 ; 1150 BD2 1155 JSR MOVE 1160 JSR MUL10 1170 LDA 228 1180 BEQ BD4 1185 ; 1190 LDY #1 1200 BNE BD8 1205 ; 1210 BD4 1215 LDY #0 1220 LDA (203),Y 1230 TAX 1240 DEX 1250 TXA 1260 STA (203),Y 1270 BNE BD1 1275 ; 1280 BD5 1285 JSR MOVE 1290 JSR MUL10 1300 LDA 228 1310 BD6 1315 ASL A 1320 ASL A 1330 ASL A 1340 ASL A 1350 STA (203),Y 1360 JSR MOVE 1370 JSR MUL10 1380 BD8 1385 LDA (203),Y 1390 CLC 1400 ADC 228 1410 STA (203),Y 1420 INY 1430 CPY #6 1440 BNE BD5 1445 ; 1450 RTS 1455 ; 1460 ;MOVE FR1 TO FR0 1470 MOVE 1475 LDX #4 1480 MV1 1485 LDA 228,X 1490 STA 212,X 1500 DEX 1510 BNE MV1 1515 ; 1520 RTS 1525 ; 1530 ;MULTIPLY FR0 BY 10 GIVING FR1 1540 ;ASSUMED: FR0 = FR1 1550 MUL10 1555 LDA #0 1560 STA 228 1570 JSR ROTATL 1580 JSR ROTATL 1590 JSR ADDER 1600 LDA 228 1610 ADC #0 1620 STA 228 1630 ;FALL THROUGH TO ROTATL 1640 ;ROTATE LEFT, 1645 ;FROM 227+1 TO 227+5 1650 ROTATL 1655 CLC 1660 LDX #5 1670 ROTL 1675 ROL 227,X 1680 DEX 1690 BNE ROTL 1695 ; 1700 RTS
Back to previous page