Posted By
MMS on 2019-07-20 11:47:03
| SID handling in BASIC on Plus/4
Fun: we already have a nice SID card. And supported by the emulators too. But did not speak too much how to handle them easily, just listening to demos (and some games).
I just found a nice BASIC codes, so herewith I share with you, some of you may have some use of it
Testing the three channels. If you set in emulation the SID address to $D400, it works.
http://ploguechipsounds.blogspot.com/2010/05/one-page-basic-sid-benchmark.html
120 v(0)=DEC("D400"):v(1)=DEC("D407"):v(2)=DEC("D40e"):REM C64 SID 52272,54279, 54286 channel low bytes 125 REM +4 v(0)=DEC("FD40"):v(1)=DEC("FD47"):v(2)=DEC("FD4e"):REM +4 relocated channel low bytes 130 vo=DEC("D418"):REM vo=DEC("FD58") for plus/4 SID. volume register 132 poke vo,15:REM volume to 15 135 for i=0to2 140 poke v(i)+3,8:poke v(i)+1,0 150 poke v(i)+5,8:poke v(i)+6,198:next 160 for a=16to128 step16:for i=0to2 170 if a>64 then poke v(i)+3,0 180 poke v(i)+4,a+1 190 for f=0to254 step2:poke v(i)+1,f:next f 200 poke v(i)+4,a:for w=0to200:next w 210 poke v(i)+4,8:poke v(i)+1,0 220 next i,a:a=1 230 for i=0to2:poke v(i)+1,255 240 poke vo,(a*16)+15: poke vo-1,2^i:REM filter and channel switching 250 poke v(i)+4,129 260 for f=0to255: pokevo-2,f:next f:REM filter cutoff frequency 270 poke v(i)+4,136:nexti 280 a=a*2:if a<8 then goto 230 310 poke vo-1,0:REM switch off channels
SID basics in BASIC :-) All details: https://www.c64-wiki.com/wiki/SID SID SID+4 value volume $D418 $FD58 0 - 15 channel en. $D417 $FD58 0 - 7 (0-2 bit 1-1 channel) FRQ LowB ch1 $D400 $FD40 ch2 $D407 $FD07 ch3 $D40E $FDE FRQ HighB LowB+1 Eh, this editor eats my formatting :-(
for waveforms and ADSR registers please lookup C64Wiki page. Much more structured.
Simple Music in BASIC What about the music playback?
There is a neat and very compact music player routine in BASIC made by Jim Butterfield. Very simple and understandable. It has some limitation (limited lenght of notes), but it works. You need to set in Emulator the SID address to $D400 base address! Or modify the code as above (in Emu, or by the NST card's jumper)
Just load with ",8", it will load to $1001, and will run directly, as it has no C64 specific settings / POKEs. http://retro64.altervista.org/ProgrammingExamples/m4_yankee.d64
Very detailed review of this code done here by retro64: http://retro64.altervista.org/blog/commodore-64-sid-music-programming-with-basic-playing-a-simple-three-voices-tune/
Little more complex SID music player routine in BASIC Retro64 highlighted the improvement possibilities of the previous player, and he made it.
You can download here the improved BASIC code (creates first an array, less stuttering playback, longer notes allowed, etc), and without any modification it work PREFECTLY on our machine with $D400 setting You need to set in Emulator the SID address to $D400 base address! Or modify the code as above (in Emu, or by the NST card's jumper)
Nice to hear such a good music in our BASIC too :-)
http://retro64.altervista.org/ProgrammingExamples/BASIC_3voices_example.d64
Very simple to use, and this SID music seems less heavy on the CPU, as the TED music, and you have no "plop" sound between the notes.
Certainly changing the inital address to $FD40 or $FE80, it will become compatible with any SID cards we have on Plus/4. (but NST SID-card can be set to "D400" address too)
From that point onwards, even nice title music is possible in our BASIC code, certainly just after giving the credits :-)
Have fun! MMS
|