need help with SPC700

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
need help with SPC700
by on (#61861)
I've been programming the Super Nintendo for more than a year but I never touched the SPC700 side. I recently downloaded byuu's spcas and I tried to compile a little square wave demo to an .spc file, but I'm not quite sure if spcas compatable with .spc files or does it work only on .smc files?

I want to make sure my spc700 code works on the spc700, before I use it to test my spc loading code. That way I would know which one is working and which one isn't.


Code:
mov a,#$00
mov $f2,a
mov x,#$ff
mov $f3,x
mov a,#$01
mov $f2,a
mov $f3,x
mov a,#$02
mov $f2,a
mov a,#$00
mov $f3,a
mov a,#$03
mov $f2,a
mov a,#$01
mov $f3,a
mov a,#$04
mov $f2,a
mov a,#$00
mov $f3,a
mov a,#$07
mov $f2,a
mov a,#$1f
mov $f3,a
mov a,#$0c
mov $f2,a
mov a,#$7f
mov $f3,a
mov a,#$1c
mov $f2,a
mov a,#$7f
mov $f3,a
mov a,#$5d
mov $f2,a
mov a,#$02
mov $f3,a


org $0200

sample_directory:

dw $0400


org $0400

square_wave:

db $b3 $ff $ff $ff $ff $00 $00 $00 $00
Re: need help with SPC700
by on (#61866)
Best practice, is to use $0000-01FF as ram, end the code section with a loop of some sort, even if it is a jump to self type infinite loop. In regards to the sample directory, you indicated a looping sample, yet you didn't define the loop address within the sample directory.

In other words, here is the revised code.

Code:
org $0200
mov a,#$00
mov $f2,a
mov x,#$ff
mov $f3,x
mov a,#$01
mov $f2,a
mov $f3,x
mov a,#$02
mov $f2,a
mov a,#$00
mov $f3,a
mov a,#$03
mov $f2,a
mov a,#$01
mov $f3,a
mov a,#$04
mov $f2,a
mov a,#$00
mov $f3,a
mov a,#$07
mov $f2,a
mov a,#$1f
mov $f3,a
mov a,#$0c
mov $f2,a
mov a,#$7f
mov $f3,a
mov a,#$1c
mov $f2,a
mov a,#$7f
mov $f3,a
mov a,#$5d
mov $f2,a
mov a,#$02
mov $f3,a

endless_loop:
bra endless_loop

org $0300

sample_directory:

dw $0400 $0400


org $0400

square_wave:

db $b3 $ff $ff $ff $ff $00 $00 $00 $00

by on (#61868)
I'm also having trouble understanding how to load routines to the spc700 side. Every document I find says something completely different.

by on (#61873)
When I was messing with it I found it more useful to disassemble the SPC's boot ROM. It's only 64 bytes, and that way you can know what is really going on - it's a lot simpler than it sounded in any docs that I remember reading. Even then I think I wrote some code that only half-worked, and I just used someone else's loader to quit wasting time on it. If it's that much easier, you could do that too and just put on your own custom loader (the built-in one kind of sucks, unless there is some kind of trick to it that I don't know of).

by on (#61874)
OK, I just wrote and tested a really simple source code example of how to play a beep. It includes very useful routines for uploading to the SPC that make it hard to screw that part up. I highly recommend them, as they eliminate lots of gotchas when using the SPC. Their usage is well-commented (scroll down in the source file to see them).
snes_play_tone.s

This is the SPC-700 code (wdsp is a macro I use that writes a value to a DSP register):

wdsp flg,$20
wdsp kon,0
wdsp koff,$FF
wdsp dir,>directory ; high byte of directory

wdsp vvoll,$7F
wdsp vvolr,$7F
wdsp vpitchl,$00
wdsp vpitchh,$02
wdsp vsrcn,0
wdsp vadsr0,$C3
wdsp vadsr1,$2F
wdsp vgain,$CF

wdsp koff,0
wdsp non,0
wdsp eon,0
wdsp mvoll,$7F
wdsp mvolr,$7F
wdsp evoll,0
wdsp evolr,0

wdsp kon,$01

I notice that my sample has two BRR blocks, because I believe you set the loop flag on the SECOND block. Anyway, this code works on my SNES at reset.

by on (#61887)
How does the mapping system on spcas work? I'm trying to compile it to address $308000 in the 65816's space, and $0200 in the spc700's space, but it's not showing up when I look for it in a hex editor.