The core S-SMP code uses word moves from the IO registers, and has the echo buffer at address 0 so it can use word writes as well. The lack of indexed writing is what allows this to stream 128 K/sec, well over the apparent maximum transfer rate detailed in another post.
Code: Select all
; Stream samples from S-CPU
- movw ya,CPUIO0 ; 5 left
movw 0,ya ; 5
mov CPUIO3,#$80 ; 5 acknowledge
movw ya,CPUIO2 ; 5 right
mov CPUIO3,#0 ; 5 clear acknowledge
movw 2,ya ; 5
movw ya,CPUIO0 ; 5 left
movw 0,ya ; 5
mov CPUIO3,#$80 ; 5 acknowledge
movw ya,CPUIO2 ; 5 right
mov CPUIO3,#0 ; 5 clear acknowledge
movw 2,ya ; 5
bra - ; 4
On the S-CPU side, writing samples is very easy:
Code: Select all
; A,X,Y all 16 bits wide
loop:
; Wait for S-SMP to be ready for more samples
: bit APUIO2
bpl :-
; Write left and right samples. There's time
; to do some table lookups instead of having
; them pre-calculated in x and y.
nop
stx APUIO0
sty APUIO2
; Calculate next samples.
; 486 master clocks available to do so.
...
bra loop
I've been able to write a simple mono real-time FM synthesizer, but it doesn't have volume control as there's not enough time. I figured I'd post this in case anyone did have some actual samples worth outputting. The above code works perfectly, as I've tested it carefully with things like sine waves and various samples. I can put together a complete demo if anyone's interested.