Maurer Rose patterns based on slightly modified code I posted the other day
This version allows you to input the values for N and D. Then it displays the results, and waits for a keypress. Once you hit a key it will return to the text screen and ask for new values.
Here are a couple examples:
Values 2,29
Values 6,71
0 POKE65497,0:SX=144:SY=56:SZ=64:CX=320:CY=192
5 HSCREEN0:INPUT"ENTER VALUES FOR N,D";N,D
6 IF N=0 OR D=0 THEN 5
REM XO,YO = ORIGIN
10 XO=160:YO=96:PI=22/7:HSCREEN 2
REM DW = DRAW WIDTH
REM T=THETA
20 DW = 1 : HCOLOR 14
30 FOR T = 0 TO 360
40 K = T * D * PI / 180
50 R = 96 * SIN(N * K)
60 X = XO - R * COS(K)
70 Y = YO - R * SIN(K)
80 HLINE-(X, Y),PSET
90 NEXT
100 IF INKEY$="" THEN 100 ELSE 5
Past this into the program to let the computer randomly choose patterns for you.
ReplyDelete5 N=RND(360):D=RND(360)
6
100 FORI=1TO1000:NEXTI:GOTO5
Full random pattern generation with HD6309 and multiply patch code
ReplyDeleteREM ZERO THE TIMER FOR BENCHMARKING, ENABLE HIGH SPEED MODE
0 TIMER=0:POKE 65497,0
REM GET BASIC TOPRAM POINTER, SUBTRACT SIZE OF USER CODE
1 AD=PEEK(116)*256+PEEK(117)-24
REM RESERVE MEMORY FOR USR CODE
2 CLEAR 100,AD
REM VARIABLES ERASED BY CLEAR, SO REDO AD, POKE USR CODE INTO RAM
3 AD=PEEK(116)*256+PEEK(117):FOR I=0 TO 23:READ B$:A=VAL("&H"+B$):POKE AD+I,A:NEXT
REM DEFINE USR ROUTINES
4 DEFUSR0=AD:DEFUSR1=AD+12
REM ENABLE 6309 NATIVE MODE
5 A=USR0(0)
REM INSTALL MULTIPY PATCH
6 GOSUB 10000
10 SX=144:SY=56:SZ=64:CX=320:CY=192
11 N=RND(360):D=RND(360)
REM XO,YO = ORIGIN
12 XO=160:YO=96:PI=22/7:HSCREEN 2
REM DW = DRAW WIDTH
REM T=THETA
20 DW = 1 : HCOLOR 14
30 FOR T = 0 TO 360
40 K = T * D * PI / 180
50 R = 96 * SIN(N * K)
60 X = XO - R * COS(K)
70 Y = YO - R * SIN(K)
80 HLINE-(X, Y),PSET
90 NEXT
100 FORI=1TO1000:NEXTI:GOTO11
REM USR functions to enable/disable 6309 native mode
9000 DATA CC,FF,FF,10,4F,5D,26,03,11,3D,01,39,CC,FF,FF,10,4F,5D,26,03,11,3D,00,39
REM COCO3 HARDWARE MULTIPLY PATCH.
REM JUST ADD A GOSUB 10000 AT THE TOP OF YOUR CODE TO ADD IT
REM ADDRESS WE ARE STORING THE MULTIPLY PATCH IN RAM
10000 AD=VAL("&HFA0C")
REM POKE THE MULTIPLY PATCH INTO RAM.
10001 FORI=0 TO 64:READ B$:A=VAL("&H"+B$):POKE AD+I,A:NEXT
REM MAKE BASIC JUMP TO OUR MULTIPY INSTEAD OF USING IT'S CODE. $BB00 JMP $FA0C
10002 POKE VAL("&HBB02"),VAL("&H7E"):POKE VAL("&HBB03"),VAL("&HFA"):POKE VAL("&HBB04"),VAL("&H0C")
10003 RETURN
10005 DATA 32,79,E7,60,96,60,3D,ED,63,E6,60,96,5E,3D,ED,61,E6,60,96,5D
10006 DATA 3D,ED,65,E6,60,96,5F,3D,E3,62,ED,62,EC,65,E9,61,89,00,ED,60
10007 DATA EC,63,D3,15,97,16,D7,63,EC,61,D9,14,99,13,DD,14,A6,60,89,00
10008 DATA 97,13,32,67,39
To add a 5 second pause between patterns (no matter what speed the emulator is set to), add these lines. The TIMER is based on interrupts from the VDG which happen at a constant speed no matter how fast the CPU is clocked.
ReplyDelete100 TIMER=0
110 IF TIMER < 300 THEN 110 ELSE 11
And finally, some additional changes. Some are for CoCo 1/2
ReplyDeleteREM SHOULD BE LIKE THIS TO MAKE CHANGING RESOLUTIONS EASIER
12 XO=320/2:YO=192/2:PI=22/7:HSCREEN 2
50 R = YO * SIN(N * K)
REM COCO 1/2 CHANGES
REM COCO 1/2 HIGH SPEED MODE
0 TIMER=0:POKE 65495,0
REM REMOVE MULTIPLY PATCH FOR COCO 1/2
6
REM TO MANUALLY ENTER VALUES
11 INPUT"ENTER VALUES FOR N,D";N,D
REM TO RANDOMLY GENERATE VALUES
11 N=RND(360):D=RND(360)
12 XO=256/2:YO=192/2:PI=22/7:PMODE4,1:PCLS1:SCREEN1,0
20 DW = 1 : COLOR 0
80 LINE-(X, Y),PSET