Topic: Noise generator code
Just in case anyone will need it, came up with a kind of universal noise routine. It is strongly based on utz's noise generator with rlc h. Allows to control pitch, volume, and duration of a noise burst.
ld hl,0 ;noise accumulator
ld de,#2174 ;utz's rand seed
ld bc,#0101 ;noise pitch, #01 highest, #ff (#00 actually) lowest
exx
ld bc,1000 ;noise duration
noise_loop
exx ;4
dec c ;4
jr nz,noise_skip ;7/12
ld c,b ;4
add hl,de ;11
rlc h ;8 utz's noise generator idea
inc d ;4 improves randomness
jp noise_next ;10
noise_skip
jr $+2 ;12
jr $+2 ;12
nop ;4
nop ;4
noise_next
ld a,h ;4
noise_volume=$+1
cp #80 ;7 noise 'volume' here, #80 max, less is lower volume
sbc a,a ;4
out (#fe),a ;11
exx ;4
dec bc ;6
ld a,b ;4
or c ;4
jp nz, noise_loop ;10=106t