We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

N-SPC Engine/Kemco

From SnesLab
Revision as of 18:44, 14 November 2020 by KungFuFurby (talk | contribs) (Adding volume fade documentation with its output)
Jump to: navigation, search

Go back to N-SPC Engine

Kemco is the first company outside of Nintendo themselves to release a game using their own variant of N-SPC (that being Bombuzal). The main customization that they did was to have the CPUIO registers play sounds on specific channels, and only the channels on the phase list specified to be used by the corresponding CPUIO register would be used. One other CPUIO register was allocated mainly to perform volume fades.

Game Name Version VCMD Table Location ($E0 and up) ROM Offset
Bombuzal 1.0 0x10EB, relative to 0x102B 0x04807A
Lagoon 2.0 0x1156, relative to 0x1096 0x0D80A4 (all versions)
Drakkhen 3.0 0x129E, relative to 0x11DE 0x1C805C (all versions)
Ka-blooey 3.0 0x129E, relative to 0x11DE 0x048080
First Samurai 3.1 0x129E, relative to 0x11DE 0x0DB15E (all versions)
Phalanx - The Enforce Fighter A-144 3.1 0x129E, relative to 0x11DE 0x1EB23E (all versions)
Super Drakkhen/Dragon View 3.1 0x129E, relative to 0x11DE 0x09B6F6 (all versions)
Super Full Metal 3.1 0x129E, relative to 0x11DE 0x0C80B6
X Zone 3.1 0x129E, relative to 0x11DE 0x0FAEE6 (all versions)
Kid Klown in Crazy Chase 4.0 0x12A1, relative to 0x11E1 0x1EC1E0 (all versions)

The raw build sorting notes can be found here.

Communication with the SNES

Each CPUIO register has an individual use.

CPUIO0 ($2140/$F4)

This register always controls which sound ID will play out of channels 1-6, regardless of which sound driver version is used. It also supports the source build's N-SPC/Kankichi commands. TODO output

CPUIO1 ($2141/$F5)

This register controls which sound ID will play of of the following channel IDs, depending on the version...

  • V1.0, V3.0: Channels 7-8
  • V2.0, V4.0: Channel 7

TODO output

CPUIO2 ($2142/$F6)

Only used in V2.0 and V4.0. This register always controls which sound ID will play out of channel 8. TODO output

CPUIO3 ($2143/$F7)

Never used in V2.0. It does output a value, though: namely, whatever you sent in $2142/$F6.
This CPUIO register is used to perform volume fades on either the note volumes of channels 1-8 or the MVOL DSP registers (The EVOL DSP registers are modified as well, but they get overwritten shortly afterwards). The values supported depend on the sound driver version.

Commands (V1.0)

Command ID Description
$00-$9F Acknowledge
$A0 Halt Volume Operations (Channels 1-6)
$A1 Fade Out (Channels 1-6)
$A2 Fade In (Channels 1-6)
$A3 Zero Volume (Channels 1-6)
$A4 Volume Restore (Channels 7-8)
$A5 Halt Volume Operations (Channels 7-8)
$A6 Fade Out (Channels 7-8)
$A7 Fade In (Channels 7-8)
$A8 Zero Volume (Channels 7-8)
$A9 Volume Restore (Channels 7-8)
$AA-$FF Acknowledge

Commands (V3.0-V4.0)

Command ID Description Versions Supported
$00-$7F Acknowledge
$80 Halt Volume Operations (Channels 1-6) V3.0-V3.1
$81 Fade Out (Channels 1-6) V3.0-V3.1
$82 Fade In (Channels 1-6) V3.0-V3.1
$83 Zero Volume (Channels 1-6) V3.0-V3.1
$84 Volume Restore (Channels 1-6) V3.0-V3.1
$85-$9F Acknowledge
$A0 Halt Volume Operations (Channels 7-8) V3.0-V3.1
$A1 Fade Out (Channels 7-8) V3.0-V3.1
$A2 Fade In (Channels 7-8) V3.0-V3.1
$A3 Zero Volume (Channels 7-8) V3.0-V3.1
$A4 Volume Restore (Channels 7-8) V3.0-V3.1
$A5-$DF Acknowledge
$E0 Halt Volume Operations (Master Volume) V3.0-V4.0
$E1 Fade Out (Master Volume) V3.0-V4.0
$E2 Fade In (Master Volume) V3.0-V4.0
$E3 Zero Volume (Master Volume) V3.0-V4.0
$E4 Volume Restore (Master Volume) V3.0-V4.0
$E5-$FF Acknowledge
Acknowledge

Merely echoes back the value you just sent to $2143/$F7.

Halt Volume Operations

The command ID used depends on the version...
Channels 1-6

  • V1.0: $A0
  • V3.0-V3.1: $80

Channels 7-8

  • V1.0: $A5
  • V3.0-V3.1: $A0

Master Volume

  • V3.0-V4.0: $E0

This command halts all volume-related operation. The effect is most noticeable on fades. $2143/$F7 outputs a zero.

Fade Out

The command ID used depends on the version...
Channels 1-6

  • V1.0: $A1
  • V3.0-V3.1: $81

Channels 7-8

  • V1.0: $A6
  • V3.0-V3.1: $A1

Master Volume

  • V3.0-V4.0: $E1

Fades out the volume to 0. On V1.0, this is done at a rate of 3 per tempo tick: on other versions, it's 1 per tempo tick. On V3.0 and later, the original volume value is saved. $2143/$F7 outputs the current volume value of the last channel in the set (or the intended right echo volume value in the master volume's case).
The command does not properly function past V1.0 for channels 1-6. Technically it still works, but a wrong branching location causes the channel ID to use (and the number of channels to copy) to not be initialized properly, which causes the volume values to not be saved.

Fade In

The command ID used depends on the version...
Channels 1-6

  • V1.0: $A2
  • V3.0-V3.1: $82

Channels 7-8

  • V1.0: $A7
  • V3.0-V3.1: $A2

Master Volume

  • V3.0-V4.0: $E2

Fades in the volume to the original volume at a rate of 1 per tempo tick. If no value was saved beforehand, this can overflow back to zero. $2143/$F7 outputs the current volume value of the last channel in the set (or the intended right echo volume value in the master volume's case).

Zero Volume

The command ID used depends on the version...
Channels 1-6

  • V1.0: $A3
  • V3.0-V3.1: $83

Channels 7-8

  • V1.0: $A8
  • V3.0-V3.1: $A3

Master Volume

  • V3.0-V4.0: $E3

Zeroes out the volume, saving the original volume for restoration later on. $2143/$F7 outputs the current volume value (or the intended right echo volume value in the master volume's case) for one tempo tick, then a $01 (or, for the master volume, always outputs a zero).
The command does not properly function past V1.0 for channels 1-6 due to a wrong branching location.

Volume Restore

The command ID used depends on the version...
Channels 1-6

  • V1.0: $A4
  • V3.0-V3.1: $84

Channels 7-8

  • V1.0: $A9
  • V3.0-V3.1: $A4

Master Volume

  • V3.0-V4.0: $E4

Restores the volumes to the saved value. $2143/$F7 outputs the current volume value for one tempo tick, then a $01 (or, for the master volume, always outputs the intended right echo volume value... which is saved to the left master volume by mistake).
The command does not properly function past V1.0 for channels 1-6 due to a wrong branching location.
The master volume variant does not work properly due to a typo in the code: specifically, the right echo volume gets copied to the left master volume by mistake, overwriting the correct value that was copied earlier. TODO document commands TODO for whatever reason some of these commands are bugged on later versions... document these bugs