Lesson P27+20 - Sound on the SNES / Super Famicom: the SPC700

Programming the SNES - covers hardware via 6502 emulation mode (65816 coming next year!)
Post Reply
User avatar
akuyou
Posts: 300
Joined: Mon Apr 22, 2019 3:19 am

Lesson P27+20 - Sound on the SNES / Super Famicom: the SPC700

Post by akuyou » Mon Sep 02, 2019 9:35 pm



http://www.chibiakumas.com/6502/platform3.php#LessonP27

The SNES has a dedicated sound processor - which is a pain!, unfortunately it's a custom chip which uses a totally different instruction set - which makes it a total F ing pain!

Lets learn how we can 'tame' the SPC700



http://www.chibiakumas.com/6502/platform3.php#LessonP28

OK, the SPC700 now has our driver running on it, and it will make whatever register changes we ask.

Now we can use this to write ChibiSound on the 65816, and get our sound effects playing!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

SleepingBurrito
Posts: 4
Joined: Wed Aug 07, 2019 1:00 pm

Re: Lesson P27+20 - Sound on the SNES / Super Famicom: the SPC700

Post by SleepingBurrito » Mon Sep 16, 2019 1:02 pm

Wow that is a lot to go though. I wonder what other people use for the SPC700. Also was the SPC700 only for the snes, googling it only shows up snes stuff but it may just be them main thing that used it.

beethead
Posts: 3
Joined: Sun Sep 15, 2019 5:07 am

Re: Lesson P27+20 - Sound on the SNES / Super Famicom: the SPC700

Post by beethead » Mon Sep 16, 2019 3:39 pm

SleepingBurrito wrote:
Mon Sep 16, 2019 1:02 pm
Wow that is a lot to go though. I wonder what other people use for the SPC700. Also was the SPC700 only for the snes, googling it only shows up snes stuff but it may just be them main thing that used it.
WLA-DX, bass and Asar assemblers support SPC700 and 65816. Also, there's an SPC700 macro set for CA65. One of the oldest ways was to use Table Assembler with an SPC700 opcode/instruction table which can still be found online. Some of those assemblers use a 6502-like instruction instead of the standard SPC700 mnemonics.

User avatar
akuyou
Posts: 300
Joined: Mon Apr 22, 2019 3:19 am

Re: Lesson P27+20 - Sound on the SNES / Super Famicom: the SPC700

Post by akuyou » Mon Sep 16, 2019 9:21 pm

beethead wrote:
Mon Sep 16, 2019 3:39 pm
WLA-DX, bass and Asar assemblers support SPC700 and 65816. Also, there's an SPC700 macro set for CA65. One of the oldest ways was to use Table Assembler with an SPC700 opcode/instruction table which can still be found online. Some of those assemblers use a 6502-like instruction instead of the standard SPC700 mnemonics.
Thanks for the advice on the Assemblers - using vasm and cobbling together an 'assembler' like I did here wasn't really a good solution, but I was only trying to do a very basic job here and didn't want to source and learn an assembler...

It would have been a big help if I had a SNES emulator with a built in SPC700 debugger - so I could check what the processor was doing... when I was learning and testing the code, I was programming 'blind' - unable to see what the SPC700 CPU was actually doing or if it had crashed.

To help debug it, I would write register values and fixed values to the ports, and print them from the 65816 - so I could figure out what's going on, and check things were working...

It's a shame, the CPU seems a nice processor - but learning a whole CPU just for a sound chip - when a Z80 or regular 6502 feel like they could have done the job was annoying
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

beethead
Posts: 3
Joined: Sun Sep 15, 2019 5:07 am

Re: Lesson P27+20 - Sound on the SNES / Super Famicom: the SPC700

Post by beethead » Wed Sep 18, 2019 8:46 pm

akuyou wrote:
Mon Sep 16, 2019 9:21 pm
It would have been a big help if I had a SNES emulator with a built in SPC700 debugger - so I could check what the processor was doing... when I was learning and testing the code, I was programming 'blind' - unable to see what the SPC700 CPU was actually doing or if it had crashed.
SPC700 debuggers can be found in these emulators.
  • Mesen-S - press ctrl+f.
  • No$sns - press ctrl+t unti you see APU in the bottom right hand corner of the debugger window.
  • bsnes - SMP tab in the debug window.

User avatar
akuyou
Posts: 300
Joined: Mon Apr 22, 2019 3:19 am

Re: Lesson P27+20 - Sound on the SNES / Super Famicom: the SPC700

Post by akuyou » Fri Sep 20, 2019 1:04 am

beethead wrote:
Wed Sep 18, 2019 8:46 pm
SPC700 debuggers can be found in these emulators.
  • Mesen-S - press ctrl+f.
  • No$sns - press ctrl+t unti you see APU in the bottom right hand corner of the debugger window.
  • bsnes - SMP tab in the debug window.
Thanks for the tip... I'll look at Mesen-S as a possible alternative for Snes9x.... unfortunately, it seems my sound example does not work on this emulator, so it looks like I have some more work to do on it!

Update: Fixed... nothing major, was not prepared for the ram not being zeroed... and needed to add a small delay after execution of Sound program after copy... sources will be updated soon
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

beethead
Posts: 3
Joined: Sun Sep 15, 2019 5:07 am

Re: Lesson P27+20 - Sound on the SNES / Super Famicom: the SPC700

Post by beethead » Fri Sep 20, 2019 6:56 pm

You should consider switching to another assembler that supports the SNES's memory model since you're dealing with music and graphics data the first bank will fill up quickly . You're fine using mode 20 in a single bank, $008000-$00FFFF, but beyond the first bank the assembler/linker needs to recognize the next bank starts at $018000. In mode 20, the binary file is written as $008000-$00FFFF, $018000-$01FFFF, $028000-$02FFFF, $0x8000-$0xFFFF, etc... without the lower 32 Kbytes of each bank.

Post Reply

Return to “Super Nintendo Assembly Programming”