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: Difference between revisions

From SnesLab
Jump to: navigation, search
(Adding command identifications)
(Adding volume fade documentation with its output)
Line 34: Line 34:
==Communication with the SNES==
==Communication with the SNES==
Each CPUIO register has an individual use.<br>
Each CPUIO register has an individual use.<br>
''TODO output for all CPUIO registers on a per-version basis''
===CPUIO0 ($2140/$F4)===
===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 [[N-SPC_Engine#Communication_with_the_SNES|source build's N-SPC/Kankichi commands]].
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 [[N-SPC_Engine#Communication_with_the_SNES|source build's N-SPC/Kankichi commands]].
''TODO output''
===CPUIO1 ($2141/$F5)===
===CPUIO1 ($2141/$F5)===
This register controls which sound ID will play of of the following channel IDs, depending on the version...
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
* V1.0, V3.0: Channels 7-8
* V2.0, V4.0: Channel 7
* V2.0, V4.0: Channel 7
''TODO output''


===CPUIO2 ($2142/$F6)===
===CPUIO2 ($2142/$F6)===
Only used in V2.0 and V4.0. This register always controls which sound ID will play out of channel 8.
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)===
===CPUIO3 ($2143/$F7)===
Never used in V2.0.<br>
Never used in V2.0. It does output a value, though: namely, whatever you sent in $2142/$F6.<br>
This CPUIO register is used to perform volume fades. The values supported depend on the sound driver version.
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)====
====Commands (V1.0)====
{| class="wikitable sortable"
{| class="wikitable sortable"
Line 53: Line 55:
! Command ID !! Description
! Command ID !! Description
|-
|-
|<tt>$00-$9F</tt> || NOP
|<tt>$00-$9F</tt> || Acknowledge
|-
|-
|<tt>$A0</tt> || Halt Volume Operations (Channels 1-6)
|<tt>$A0</tt> || Halt Volume Operations (Channels 1-6)
Line 75: Line 77:
|<tt>$A9</tt> || Volume Restore (Channels 7-8)
|<tt>$A9</tt> || Volume Restore (Channels 7-8)
|-
|-
|<tt>$AA-$FF</tt> || NOP
|<tt>$AA-$FF</tt> || Acknowledge
|}
|}
====Commands (V3.0-V4.0)====
====Commands (V3.0-V4.0)====
Line 82: Line 84:
! Command ID !! Description !! Versions Supported
! Command ID !! Description !! Versions Supported
|-
|-
|<tt>$00-$7F</tt> || NOP ||  
|<tt>$00-$7F</tt> || Acknowledge ||  
|-
|-
|<tt>$80</tt> || Halt Volume Operations (Channels 1-6) || V3.0-V3.1
|<tt>$80</tt> || Halt Volume Operations (Channels 1-6) || V3.0-V3.1
Line 94: Line 96:
|<tt>$84</tt> || Volume Restore (Channels 1-6) || V3.0-V3.1
|<tt>$84</tt> || Volume Restore (Channels 1-6) || V3.0-V3.1
|-
|-
|<tt>$85-$9F</tt> || NOP ||
|<tt>$85-$9F</tt> || Acknowledge ||
|-
|-
|<tt>$A0</tt> || Halt Volume Operations (Channels 7-8) || V3.0-V3.1
|<tt>$A0</tt> || Halt Volume Operations (Channels 7-8) || V3.0-V3.1
Line 106: Line 108:
|<tt>$A4</tt> || Volume Restore (Channels 7-8) || V3.0-V3.1
|<tt>$A4</tt> || Volume Restore (Channels 7-8) || V3.0-V3.1
|-
|-
|<tt>$A5-$DF</tt> || NOP ||  
|<tt>$A5-$DF</tt> || Acknowledge ||  
|-
|-
|<tt>$E0</tt> || Halt Volume Operations (Master Volume) || V3.0-V4.0
|<tt>$E0</tt> || Halt Volume Operations (Master Volume) || V3.0-V4.0
Line 118: Line 120:
|<tt>$E4</tt> || Volume Restore (Master Volume) || V3.0-V4.0
|<tt>$E4</tt> || Volume Restore (Master Volume) || V3.0-V4.0
|-
|-
|<tt>$E5-$FF</tt> || NOP ||
|<tt>$E5-$FF</tt> || Acknowledge ||
|}
|}
=====Acknowledge=====
Merely echoes back the value you just sent to $2143/$F7.
=====Halt Volume Operations=====
The command ID used depends on the version...<br>
<u>Channels 1-6</u>
* V1.0: <tt>$A0</tt>
* V3.0-V3.1: <tt>$80</tt>
<u>Channels 7-8</u>
* V1.0: <tt>$A5</tt>
* V3.0-V3.1: <tt>$A0</tt>
<u>Master Volume</u>
* V3.0-V4.0: <tt>$E0</tt>
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...<br>
<u>Channels 1-6</u>
* V1.0: <tt>$A1</tt>
* V3.0-V3.1: <tt>$81</tt>
<u>Channels 7-8</u>
* V1.0: <tt>$A6</tt>
* V3.0-V3.1: <tt>$A1</tt>
<u>Master Volume</u>
* V3.0-V4.0: <tt>$E1</tt>
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).<br>
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...<br>
<u>Channels 1-6</u>
* V1.0: <tt>$A2</tt>
* V3.0-V3.1: <tt>$82</tt>
<u>Channels 7-8</u>
* V1.0: <tt>$A7</tt>
* V3.0-V3.1: <tt>$A2</tt>
<u>Master Volume</u>
* V3.0-V4.0: <tt>$E2</tt>
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...<br>
<u>Channels 1-6</u>
* V1.0: <tt>$A3</tt>
* V3.0-V3.1: <tt>$83</tt>
<u>Channels 7-8</u>
* V1.0: <tt>$A8</tt>
* V3.0-V3.1: <tt>$A3</tt>
<u>Master Volume</u>
* V3.0-V4.0: <tt>$E3</tt>
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).<br>
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...<br>
<u>Channels 1-6</u>
* V1.0: <tt>$A4</tt>
* V3.0-V3.1: <tt>$84</tt>
<u>Channels 7-8</u>
* V1.0: <tt>$A9</tt>
* V3.0-V3.1: <tt>$A4</tt>
<u>Master Volume</u>
* V3.0-V4.0: <tt>$E4</tt>
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).<br>
The command does not properly function past V1.0 for channels 1-6 due to a wrong branching location.<br>
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 document commands''
''TODO for whatever reason some of these commands are bugged on later versions... document these bugs''
''TODO for whatever reason some of these commands are bugged on later versions... document these bugs''

Revision as of 18:44, 14 November 2020

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