home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 36
/
Commodore_Free_Issue_36_2010_Commodore_Computer_Club.d64
/
c16
< prev
next >
Wrap
Text File
|
2023-02-26
|
9KB
|
371 lines
u
*************************************
Commodore 16 Programming
John Fielden
*************************************
Pools
lines 10 to 40 pay homage to The
Master spare time programmer!
50 states the obvious. (It's become
so obvious now that I nearly removed
all occurrences and resubmitted! -
enough of the silliness.)
60 no.11 relates to the numbers that
we used for err... The pools. (So
clearly we were allowed 1 x on the
form!!)
70 Generate random number between 1
and 52, without the plus 1 zero comes
up. Never fifty-three though -
strange.
80 maketh thy would be prophecy oh!
soulless machine. (With absolutely
no consideration as to if it comes
true!)
90 go round again until the "to"in 60
100 There was a somewhere on one of
the commodore related sites as to
which was the best command. I have
to say, in my view it's this one.
Simply because the better the
program, the more satisfying the end
is.
The Master' teaching
I can only echo memories of learning
in the early days. (A simpler time)
How do we stop repetitive occurrences
of the same number? I was giving up
by the time the TV packed in.
Requires what was a new term. The
Dim statement.55 DimN(52) : REM must
relate to line 70, and equal the max.
range. While the last instruction
could go anywhere before the for next
loop. The order of the next two
statements is critical to the correct
running of the program. let n(x)=1
ifn(x)=1 then go back and choose
another. It should be easy to get the
order even for beginners. Thanks
again to Roy for walking me through
it all those years ago. Without his
help, and the editors kindness these
c16/plus4 pages might not have
happened.
Escape to Window
Another thing I remember getting
nowhere with at the time was a window
within a window. <PRINT" ESC &
<related key>"> didn't work. Having
long since given up on it!
When the answer came I decided to use
it to try to demonstrate the question
above. It goes further by allowing
user input to change the numbers.
("I wonder if I'll win the lottery
that way?????")
from 150 Highlights different ways
of storing numbers. and hints why/
allows experiment to show why the
extra dimension is necessary.
Otherwise self explanatory as it is
similar to above in it's main.
("How do mean it doesn't! ??! ...)
Shush!
... And Shush 2! intend to stop Sound
in its tracks. Either build up a
long time in the former before
pressing. This is less convincing
than the latter where the length of
the Sound is longer. As a back up. On
Shush two. If a normal key press
doesn't work. Press f1 key to switch
off the volume.
This short program was devised when
trying to work out how to stop what a
musician would call 'The slurring of
notes'. My limited experience of
music reading gives insight that both
separate (un-slurred), and "tied" or
slurred. Do have their place. More
Later.
Sound Data
Plays the scale as written in The c16
Manual. For some reason they forgot
the flats and Sharps. Makes good use
of The commands READ, and DATA
statements to avoid having to type in
'SOUND1,note,duration'.
rndsong
There is scope for improvement in
this program. A programmer could add
a rnd duration, and even whether
notes are to be tied. (requires more
rnd statements. Have a go if you
wish or wait for its submission to
this excellent magazine... And we'll
save the line by line account for
then! This time the DATA statements
are for storing so that the rnd
generator can play the notes more
quickly, and without falling foul of
RESTORE and DATA's short comings. It
goes further by actually storing the
music in RAM for replay.
musicprogrammer16
Type in your own commands after line
2000. (Note: May require alteration
elsewhere in the program. It is
currently set to loop. As I wanted
to test whether the computer has a
set maximum that the command:
RESTORE can be used. (I can't
remember whether I've heard this or
read it. But there is a way round it
in any case.)
The manual states a mathematical
formula to derive even more notes.
-even out of range of human hearing!
And just look in Prof. Andrew Colin'
Introduction to programming part1 for
the sharps. Which I am sure you all
have.
Artificial Intelligence is involved
here! The computer reads the
program, but instead of blindly
playing the notes checks what it is
to do with them. (i.e. tied, untied,
change duration, reduce volume etc.)
Quite a clever program. But I've
left it as a copy and complete task.
(hence, again! No line by line write
up... yet?)
Happy Prog'ing
Listing of: EscToWindow.prg
10 REM *ESCAPE TO WINDOW*
20 B=16:DIMBO(B):DIMO(B)
30 PRINT"{SHIFT-+}home{SHIFT--}{SHIFT-+}home{SHIFT--}{SHIFT-+}clr{SHIFT--} ESCAPE TO
WINDOW{SHIFT-+}down{SHIFT--}"
40 PRINT"PROGRAM DESIGN
(C) JOHN FIELDEN{SHIFT-+}down{SHIFT--}"
50 FORJ=1TO20
60 X=INT(RND(1)*B)+1
70 PRINTJ;X
80 NEXTJ
90 PRINT"{SHIFT-+}home{SHIFT--}":CHAR1,12,6,
CHR$(27)+CHR$(84)
100 FORJ=1TOB
110 X=INT(RND(1)*B)+1
120 IFX=0ORBO(X)=XTHEN110
130 PRINT;J,X:BO(X)=X:O(J)=X
140 NEXTJ
150 INPUT"CHANGE";J%
160 IFJ%<1 ORJ%>16THEN150
170 INPUT" TO ";X%
180 O(J%)=X%
190 FORT=1TOB
200 PRINTT;"O ";O(T);"BO ";BO(T)
210 NEXTT
Listing of: musicprogrammer16b.prg
10 REM *PROG. YOUR OWN TUNE*
20 REM *(C) JOHN FIELDEN 2009*
30 SCNCLR:VOL8:VO%=8
40 DIM D(28,1):N=65:U=99:C=32
50 FORJ=1TO28
60 READZ,A
70 D(J,0)=A:D(J,1)=N
80 N=N+1:IFN>71THENN=65
90 NEXTJ
95 REM RESTORE:FORT=1TO28:
READA,B:NEXTT
100 FORL=1 TOU
110 READA,B :REM*VOICE,NOTE,DURATION*
120 READE :REM *INSTRUCTIONS*
130 IF E=0THENVOLVO%:SOUNDA,D(B,0),C
140 IF E>0THEN500
200 NEXTL
490 END
500 REM *SPECIAL NOTES ETC.*
510 IFE=1THENEND
520 IFE=2THENSOUNDA,D(L,0),0
530 IFE=3THENFORR=1TOC:
PRINT"{SHIFT-+}home{SHIFT--}";R,C:NEXTR :
FORR=1TO25 :NEXTR
540 IFE=4THENC=2
550 IFE=5THENC=4
560 IFE=6THENC=8
570 IFE=7THENC=16
580 IFE=8THENC=32
590 IFE=9THENC=64
600 IFE=10THENC=128
640 IFE=30ANDP<30THENFORJ=1TO2500/
INT(P+1):NEXTJ:PRINT"HELLO":
P=P+1:RESTORE2000
650 IFE>19 AND E <29 THENVO%=E-20:
NE=0:GOTO130
890 IFE>3 AND E <11 THENE=0:GOTO130
900 GOTO200
1200 DATA 1,7, 2,118
1210 REM *BOTTOM C ***TO*** B
1300 DATA 3,169, 4,262, 5,345,
6,383,7,453:DATA8,516, 9,571
1310 REM *MIDDLE C ***TO*** B
1400 DATA10,596, 11,643, 12,685,13,
704, 14,739: DATA15,770, 16,798
1410 REM * TOP C ***TO*** B
1500 DATA17,810, 18,834, 19,854,20,86
4,21,881: DATA22,897, 23,911
1510 REM *V. TOP C ***TO*** G
1600 DATA24,917, 25,929, 26,939,27,
944, 28,953
1990 REM *** ACTUAL MUSIC ***
2000 DATA1,8,0 ,1,10,0, 1,9,0,1,28,3,
1,7,0, 1,8,0, 1,28,3, 1,28,30
Listing of: pools.prg
10 REM ************************
20 REM *(C) ROY ... D.E.R. MAN*
30 REM *AS FAR AS I KNOW! *
40 REM ************************
50 PRINT"{SHIFT-+}clr{SHIFT--} POOLS"
60 FORT=1TO11
70 X=INT(RND(1)*52)+1
80 PRINTX
90 NEXTT
100 END
Listing of: rndsong.prg
4 REM K=65:FORJ=1TO4:K=K+1:E$(J)=
CHR$(K):PRINTE$(J):NEXTJ
10 REM SOUND: *RANDOM SONG*
20 VOL8 :LP=99:SCNCLR:TT=35
30 DIM D(28): DIM D$(28):DIM NO%(28)
35 DIM PL(LP,3): JF=64
40 X=65
50 FORJ=1TO28
70 IFX>71THENX=65
80 READA
90 D(J)=A: D$(J)=CHR$(X):NO%(J)=X
93 X=X+1
95 NEXTJ
200 SCNCLR : REM (RANDOM NOTES)
210 CHAR1,0,0,"Q TO END PLAYING":
PRINT
300 FORL=1TOJF
305 PL(L,3)=TT
310 GETA$
400 X=INT(RND(1)*28)
500 IFX=0THEN400
510 PL(L,1)=X:PL(L,2)=NO%(X)
600 SOUND1,D(X),PL(L,3)
700 PRINTL, X,D(X),D$(X)
800 PL(L,0)=D(X)
810 IFA$="Q"THENA%=L:GOTO910
900 NEXTL
910 REM PLAY IT AGAIN SAM?
920 PRINT" KEY 'A' TO LISTEN AGAIN"
930 PRINT" KEY 'B' FOR NEW RANDOM
LEAF"
940 PRINT" ANYTHING ELSE TO EXIT"
950 GETA$:IFA$=""THEN950
960 IFA$="A"THEN990
970 IFA$="B"THEN200
980 GOTO1090
990 SCNCLR : REM REPLAY MEMORY
995 PRINT"REPLAYING, PLEASE WAIT!"
1000 FORJ=1TOJF
1010 SOUND1,PL(J,0),PL(J,3)
1015 PRINTJ;" ";PL(J,1);" ";PL(J,0);
"";CHR$(PL(J,2))
1017 IFA%=JTHEN910
1020 NEXT J
1030 GOTO910
1090 END
1100 RESTORE: REM DATA
1200 DATA 7,118
1300 DATA169,262,345,383,453:
DATA516,571
1400 DATA596,643,685,704,739:
DATA770,798
1500 DATA810,834,854,864,881:
DATA897,911
1600 DATA917,929,939,944,953
Listing of: shush.prg
10 REM SHUSH!
20 SCNCLR:VOL8
25 REM SOUND1,7,7000
30 PRINT"TO GET SILENCE PRESS A KEY!"
40 GETA$
50 SOUND1,7,20
60 IFA$=""THEN40
70 SOUND1,7,0
Listing of: shush2.prg
6 KEY1,"VOL0"+CHR$(13)
10 REM SHUSH! !
20 SCNCLR:VOL8
25 REM SOUND1,7,20
30 PRINT"TO GET SILENCE PRESS A KEY!"
40 REM GETA$
50 SOUND1,7,7000
60 GETKEYA$:REM IFA$=""THEN40
70 SOUND1,7,0
Listing of: sounddata.prg
10 REM SOUND
20 VOL8
30 FORJ=1TO28
40 READA
50 SOUND1,A,35
90 NEXTJ
100 END
2000 RESTORE: REM DATA
2010 DATA 7,118
2020 DATA169,262,345,383,453:
DATA516,571
2030 DATA596,643,685,704,739:
DATA770,798
2040 DATA810,834,854,864,881:
DATA897,911
2050 DATA917,929,939,944,953
=====================================