Last active
May 29, 2017 12:59
-
-
Save BalorPrice/1c8910635a7fd2bd23519760ba0b6709 to your computer and use it in GitHub Desktop.
SAM coupé conversion of One-Page BASIC SID Benchmark in Plogue R&D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; +++++++++++++++++++++ | |
; SID TEST 3: 28-May-17 | |
; +++++++++++++++++++++ | |
; Conversion of one-page basic SID benchmark by Plogue R&D | |
; http://ploguechipsounds.blogspot.co.uk/2010/05/one-page-basic-sid-benchmark.html | |
; Compiled with PYZ80 | |
dump 1,0 | |
autoexec | |
org 32768 | |
di | |
auto.main: | |
@set_sid_base: | |
; v(0)=54272 ; voice 1 base | |
; v(1)=54279 ; voice 2 base | |
; v(2)=54286 ; voice 3 base | |
ld c,&d4 ; SID controleld with OUT (C),r with B=register to set | |
@set_master_volume: | |
; poke 54296,15 ; Set master volume control | |
ld b,24 | |
ld a,&0f | |
out (c),a | |
@init_sid: | |
; for i=0 to 2 ; Repeat for 3 voices | |
ld d,0 | |
@init_loop: | |
; poke v(i)+3,8 ; Pulse width to 50% duty cycle | |
ld a,3 | |
add d | |
ld b,a | |
ld a,8 | |
out (c),a | |
; poke v(i)+1,0 ; Reset frequency value MSB (LSB ignored) | |
ld b,d | |
inc b | |
xor a | |
out (c),a | |
; poke v(i)+5,8 ; Set attack/decay to &08 ie immediate attack | |
ld a,5 | |
add d | |
ld b,a | |
ld a,8 | |
out (c),a | |
; poke v(i)+6,198 ; Set sustain/release to &c6 ie 3/4 volume sustain | |
ld a,6 | |
add d | |
ld b,a | |
ld a,198 | |
out (c),a | |
; next i ; Loop to next voice | |
ld a,7 ; Pre-multiply by 7 for correct offsets | |
add d | |
ld d,a | |
cp 21 | |
jp nz,@-init_loop | |
@test_waveforms: | |
; for a=16 to 128 step 16 ; Test all combinations of triangle, sawtooth, pulse waves | |
ld e,16 ; Noise tested uncombined only. | |
@waveform_loop: | |
; for i=0 to 2 ; Test each voice separately in each combination | |
ld d,0 | |
@voice_loop: | |
; if a>64 then pokev(i)+3,0 ; If noise on, set duty cycle to 0% (turn off pulse wave output) | |
bit 7,e | |
jp z,@+start_note | |
@duty_cycle_0: | |
ld a,3 | |
add d | |
ld b,a | |
xor a | |
out (c),a | |
@start_note: | |
; pokev(i)+4,a+1 ; Start note (bit 0 of control register for gate) | |
ld a,4 | |
add d | |
ld b,a | |
inc e | |
out (c),e | |
dec e | |
@sweep_frequencies: | |
; for f=0 to 254 step 2 ; Sweep through frequencies by changing MSB only | |
ld b,d | |
inc b | |
xor a | |
@sweep_freq_loop: | |
; poke v(i)+1,f | |
out (c),a | |
call auto.delay ; Added in to slow Z80 | |
; next f | |
inc a | |
inc a | |
jp nz,@-sweep_freq_loop | |
@release_note: | |
; pokev(i)+4,a ; Ungate to release part of note | |
ld a,4 | |
add d | |
ld b,a | |
out (c),e | |
@delay: | |
; for w=0 to 200 ; Wait for note to sound | |
; next w | |
call auto.delay | |
; poke v(i)+4,8 ; Set test bit for control reg (why?) | |
ld a,8 | |
out (c),a | |
; poke v(i)+1,0 ; Reset frequency value | |
ld b,d | |
inc b | |
xor a | |
out (c),a | |
; next i ; Repeat for each voice | |
ld a,7 | |
add d | |
ld d,a | |
cp 21 | |
jp nz,@-voice_loop | |
; next a ; repeat for each waveform combination | |
ld a,16 | |
add e | |
ld e,a | |
cp 128+16 | |
jp nz,@-waveform_loop | |
@test_eq: | |
; a=1 | |
ld e,16 ; Loop for each eq type (low pass, band pass, high pass) | |
; loop: (line 230) | |
@eq_loop: | |
; for i=0 to 2 ; loop for each voice | |
ld d,0 | |
@init_voice: | |
ld a,1 ; set the 2^i line to run easily. | |
ld (@+voice+1),a | |
@voice_loop: | |
; poke v(i)+1,255 ; Reset frequency | |
ld b,d | |
inc b | |
ld a,255 | |
out (c),a | |
; poke 54296,(a*16)+15 ; Set EQ type and leave volume at full | |
ld b,24 | |
ld a,15 | |
add e | |
out (c),a | |
; poke 54295,2^i ; Set voice (bit 0-2) to send through filter | |
@voice: ld a,1 | |
ld b,23 | |
out (c),a | |
add a | |
ld (@-voice+1),a ; update voice for next loop | |
; poke v(i)+4,129 ; Set noise + gate | |
ld a,d | |
add 4 | |
ld b,a | |
ld a,%10000001 | |
out (c),a | |
@sweep_filter: | |
; for f=0 to 255 ; Sweep filter settings, most significant 7 of 10 bits | |
xor a | |
ld b,22 | |
@filter_loop: | |
; poke 54294,f | |
out (c),a | |
call auto.delay | |
; next f | |
inc a | |
cp 0 | |
jp nz,@-filter_loop | |
; poke v(i)+4,136 ; Set control gate to noise + test bit | |
ld a,4 | |
add d | |
ld b,a | |
ld a,%10001000 | |
out (c),a | |
; next i ; next voice | |
ld a,7 | |
add d | |
ld d,a | |
cp 21 | |
jp nz,@-voice_loop | |
@next_eq_type: | |
; a=a*2 | |
sla e ; next EQ type | |
; if a<8 then goto 230 | |
bit 7,e | |
jp z,@-eq_loop | |
@end: | |
; poke 54295,0 ; Master volume off to end | |
ld b,23 | |
xor a | |
out (c),a | |
ret | |
auto.delay: | |
push bc | |
ld b,3 | |
@delay_loop: | |
for 2048,nop ; !! Complete guess at timings | |
dec b | |
jp nz,@-delay_loop | |
pop bc | |
ret | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment