I did implement the viznut waveforms for the VIC-20. It was full of nasty surprises for sure, given the difficulty of making well timed 6502 code (added cycles here and there depending on code/vars locations), and really lacking debug tools. Even worse, VICE has some weird audio filtering going on, and MAME does not support expanded RAM for VIC (5K default model only), so I was not able to hear the sound properly, and my test code didn't fit to run in MAME.
It worked in the end, however, it wasn't much suitable for music. The thing is that these waveforms always contains 8 zeroes and 8 ones, just arranged in different ways. So it can't do the usual 50-25-12-7 duty cycle, or arbitrary bit patterns of PET, it just adds high pitched harmonics into square wave. So a special arrangement for music is a must, that would mostly rely of square wave and emphasize some parts using waveforms.
Here is the key part of the code (waveform_table there is to attempt to arrange waveforms in order from regular bold square to the thinest one):
set_pitch_and_wave:
pha
tya
bne :+
sta <PV_WAVE_PREV,x
lda #$7e
sta VIC20_LOW,x
pla
rts
:
asl a
tay
lda waveform_table,y
iny
cmp PV_WAVE_PREV,x
beq @skip_wave
sta PV_WAVE_PREV,x
sta PV_WAVE_PTN
lda #$7e
sta VIC20_LOW,x
lda waveform_table,y
ldy #100/5 ;delay t-states/5
:
dey
bne :-
tay
@loop:
lda <PV_WAVE_PTN ;3
and #$80 ;2
ora wavecnt_table,x ;4+
sta VIC20_LOW,x ;4+
asl <PV_WAVE_PTN ;5
lda <PV_WAVE_PTN ;3
nop ;2
nop ;2
nop ;2
dey ;2
bne @loop ;2/3=32t
@skip_wave:
pla
tay
lda (PV_NOTE_TABLE),y
sta VIC20_LOW,x
rts
wavecnt_table:
.byte $7d,$7b,$79
waveform_table:
.byte %11000000,3 ;00
.byte %10010000,6 ;14
.byte %10100000,5 ;09
.byte %10100000,4 ;12
.byte %10110000,6 ;11
.byte %10110000,5 ;07
.byte %10000000,2 ;01
.byte %10000000,3 ;04
.byte %11010000,5 ;08
.byte %10101000,6 ;13
.byte %10010000,5 ;06
.byte %11100000,4 ;03
.byte %10110000,4 ;02
.byte %11000000,5 ;10
.byte %10000000,4 ;05
.byte %00000000,0 ;15
In fact, I think I'll release the whole sound code sometime later. Released album code contains most of it anyways, it only missing VIC-20, C64 and NES dependent parts.