PETsoundz - Commodore PET "music" driver. 4mat/orb This was written for Orb's demo "No Pets Allowed". First I made a multiplex one with XM songdata which was nice to edit with but sounded terrible. So instead I wrote this in an hour and it's horrible and unoptimized but sort of works enough. PETsoundz is a 1-channel player which lets you organize 16 patterns (of 16 beats) to form simple songs. You can use up to 16 instruments that have rudimentary length, pitch and waveform effects and the tempo can be alternated between two different values to have 'swing'-style rhythms. PETsoundz plays under vblank (like a normal c64 driver) so you can run fx along with it. It could be far more capable if I used timers but that would take a huge chunk of rastertime and make it even less useful than it is now. There are two source files in the archive: petplayer.asm - A test front-end for hearing your music. petdriver.asm - The actual driver. You just need to include this bit in your demos/games or whatever. The player runs on 3xxx, 4xxx and 8xxx machines. (the display is optimized for 40-column screens) The old 2xxx machines don't use a vblank for timing or something, so you'd have to fix that yourself. Hook the driver into whatever is called once a frame. I haven't tried it on hardware, so again running it on that is all your own risk. Songs: ------ Editing songs is done in the 'songtab' table. Here each byte contains two pieces of information. $xy x = number of times to loop the pattern. (+1 from value) y = the pattern to loop For example : $35 = Play pattern 5 and loop it 4 times. $07 = Play pattern 7 only once. To end a song put an $ff byte, which means you can't loop pattern f 16 times. Patterns: --------- Patterns are edited using two tables, 'pattnotetab' for the actual notes and 'pattinsttab' for the instrument to play the notes on. There's probably a better way of sticking both into one table but whatever. Realistically how long are you going to bother trying this out for? About 10 minutes? Exactly. ;) Each pattern is 16 beats long, you could change that but then you'll need to fix the code as it does a shift to calculate the offsets. 'pattnotetab': From the manual the Commodore PET has 3 octaves, I kept dividing the pitch values to the end so there are 4 in the player. Unfortunately (as with the Plus4) the pitch table starts about an octave below middle C or something, so there is hardly any bass. You could get around this with a timer driver but as I mentioned that's not useful if you want to run any fast demo fx with it. I've replaced the pitches with text so you can make it semi-legible, these are: c c# d d# e f f# g g# a a# b c_1,cs1,d_1,ds1,e_1,f_1,fs1,g_1,gs1,a_1,as1,b_1 - octave 1 c_2,cs2,d_2,ds2,e_2,f_2,fs2,g_2,gs2,a_2,as2,b_2 - octave 2 c_3,cs3,d_3,ds3,e_3,f_3,fs3,g_3,gs3,a_3,as3,b_3 - octave 3 c_4,cs4,d_4,ds4,e_4,f_4,fs4,g_4,gs4,a_4,as4,b_4 - octave 4 So, c in octave 1 = c_1 f sharp in octave 3 = fs3 a in octave 2 = a_2 There are two more features that can be put into a beat: rst - leaves previous note playing. off - switches beeper off for that beat. Each pattern is proceeded by .byte and has a comma between each beat. For example: .byte c_1,g_1,c_1,c_2,f_2,c_1,g_1,c_1,c_1,c_2,rst,c_1,f_2,as1,rst,c_2 'pattinsttab' Each beat is just the instrument number to play at that beat. You can have 16 instruments in a song and you just type 'inX' (where X is a hex value 0-f) to set the instrument. For example: in0 - use instrument 0 in4 - use instrument 4 inf - use instrument f (16) As with the note table each pattern is proceeded by .byte and has a comma between each beat, like so: .byte ine,in3,in8,ine,in2,in3,ine,in8,in3,ine,in8,in3,in2,inc,in3,in3 Instruments: ------------ As well as pitch the Commodore PET has an 'Octave' register that is supposed to be used in combination with pitch to get the desired note. After playing about with this register I found it seems to play other waveforms too, so I've put in a c64-style instrument table you can muck around with and add some timbre. Each instrument has: + a length (in frames) - 'Instlength' table. ($00-$ff) + pitch bend ability (added each frame) - 'Instsweep' table. ($00-$ff) + an 8-frame table - 'Instwavetab' table. ($00-$ff) which can be looped back to any point once it reaches the end. - 'Instrepeat' table. ($00-$07) The Instwavetab table is just a hex value to set in the Octave register on that frame. By default you are supposed to use $0f for notes in the first octave, $33 in the second and $55 for the third and fourth octaves. This might explain why some notes sound quiet using other values but try it yourselves. Setting the register to 0 switches the note off, which can be used for psuedo-echo effects. The Instrepeat table sets the position in the instrument that it loops back to when it reaches 8. If you set it to 7 it won't loop and remain on the last position. Tempo & Restart: ---------------- The tempo can be changed with the 'tempolist' variables. I've put a toggle in that swaps between each of the two tempo values here so you can have swing rhythms if you want. Some examples: .byte $05,$05 - Constant tempo of 5 throughout the song. .byte $05,$06 - A tempo between 5 and 6. .byte $04,$08 - Funktempo. (ugh) .byte $05,$0a - Slow swing. By default when the song loops it goes back to the start. If you need it to loop on a different position look for 'restartsong' in the source and there's a comment on where you can hard code a different value. Can't talk Desperate Housewives is on ------------------------------------- Bye!!!!!!!!!!!!!!!!11!!!!!!!!!! 4mat ( rangerx8000@googlemail.com ) ---------------------------- No Pets Allowed Pet 4032 demo December 15, 2010 4Mat, Ultra, Keops ---------------------------- Our little pre xmas present A Pet 4032 demo This demo features a new video mode for the Pet... For those not having the real machine, you can try Vice emulator with the proper settings (4032, 32 kb ram) or else you will get a message if you start the demo that you need a Pet 4032. Go to the settings menu and select Pet settings. There select the machine to use >4032< The demo also supports a Sid card. You can select the music at startup. To enable the Sid emulation in Vice: Go to settings menu -> Cartridge settings and enable Sid emulation. Things to download: -binaries Sources for the video mode (explanation how it works is included too) and the music replayer are attached to the zip. -Video capture from Vice. Unfortunately we don't know someone with a 50Hz Pet. If someone can capture it would be great. -Video capture of one effect running on a real machine Important This demo works only on a Pet 4032 with >50Hz< ! http://www.orb-demo.net/