Changes

Jump to navigation Jump to search
2,766 bytes added ,  22:35, 15 April 2015
no edit summary
Line 113: Line 113:  
| 0xC
 
| 0xC
 
| 4
 
| 4
| Physical address of the first audio sample in the loop.
+
| Physical address of the second block of audio data
 
|-
 
|-
 
| 0x10
 
| 0x10
 
| 4
 
| 4
| Total byte-size of the loop sample-data.
+
| Total byte-size of the block
 
|}
 
|}
   −
This initializes state for looping, when looping is used. This command is used immediately after command 0x8. CSND module writes these fields to the channel [[CSND|register]] for the second physical-address, and the channel register for the byte-size.
+
This sets the address and size of the second block of an audio channel. The CSND module writes these fields to the channel [[CSND|register]] for the physical address of the second block and the register for the block size.
    
==Command 0x4==
 
==Command 0x4==
Line 154: Line 154:  
| 0x2
 
| 0x2
 
| 2
 
| 2
| CmdID 0x4
+
| CmdID 0x5
 
|-
 
|-
 
| 0xC
 
| 0xC
Line 176: Line 176:  
| 0x2
 
| 0x2
 
| 2
 
| 2
| CmdID 0x4
+
| CmdID 0x6
 
|-
 
|-
 
| 0xC
 
| 0xC
Line 198: Line 198:  
| 0x2
 
| 0x2
 
| 2
 
| 2
| CmdID 0x4
+
| CmdID 0x7
 
|-
 
|-
 
| 0xC
 
| 0xC
 
| 1
 
| 1
| Value
+
| Duty value (3 bits), see below
 
|-
 
|-
 
| 0x10
 
| 0x10
Line 209: Line 209:  
|}
 
|}
   −
This is similar to cmd2, except this updates channel CNT bit1-bit0.
+
This command updates bit0 through (at least) bit2 of the channel's CNT register. These bits control the duty of a PSG square wave:
 +
 
 +
  0  12.5% "_______-_______-_______-"
 +
  1  25.0% "______--______--______--"
 +
  2  37.5% "_____---_____---_____---"
 +
  3  50.0% "____----____----____----"
 +
  4  62.5% "___-----___-----___-----"
 +
  5  75.0% "__------__------__------"
 +
  6  87.5% "_-------_-------_-------"
 +
  7  0.0% "________________________"
    
==Command 0x8==
 
==Command 0x8==
Line 242: Line 251:  
| 0xC
 
| 0xC
 
| 2
 
| 2
| Left volume
+
| Left channel volume
 
|-
 
|-
 
| 0xE
 
| 0xE
 
| 2
 
| 2
| Right volume
+
| Right channel volume
 
|-
 
|-
 
| 0x10
 
| 0x10
| 0x10
+
| 2
| Usually zero?
+
| Left capture volume
 +
|-
 +
| 0x12
 +
| 2
 +
| Right capture volume
 
|}
 
|}
   −
This sets the playback volumes for the specified channel. This command must be used after command 0x8(user processes use cmd8 a second time before using this command). The parameter values seem to have no affect when not using IMA-ADPCM encoding?
+
This sets the playback and capture volumes for the specified channel. This command is usually used after command 0x8(user processes use cmd8 a second time before using this command).
    
==Command 0xA==
 
==Command 0xA==
Line 268: Line 281:  
| 0xC
 
| 0xC
 
| 4
 
| 4
| Main physical address
+
| Physical address of the first block of audio data
 
|-
 
|-
 
| 0x10
 
| 0x10
 
| 0x4
 
| 0x4
| Audio data byte-size
+
| Total byte-size of the block
 
|-
 
|-
 
| 0x14
 
| 0x14
Line 279: Line 292:  
|}
 
|}
   −
Like command 0xE, this writes the specified parameters to the [[CSND]] channel slot registers for the main audio-data physical address, and the register for the data byte-size.
+
This sets the address and size of the first block of an audio channel. The CSND module writes these fields to the channel [[CSND|register]] for the physical address of the first block and the register for the block size.
    
==Command 0xB==
 
==Command 0xB==
Line 305: Line 318:  
|}
 
|}
   −
This command is used for initializing IMA-ADPCM state(when IMA-ADPCM encoding is used), prior to using command 0xE. [[CSND]] <nowiki>channelslotregister+0x18 = (u16)cmdword[3] | ((cmdword[4] & 0xFF)<<16)</nowiki>. [[CSND]] channelslotregister+0x1C = 0.
+
This command is used for setting the IMA-ADPCM state used to play the first block (when IMA-ADPCM encoding is used), prior to using command 0xE. [[CSND]] <nowiki>channelslotregister+0x18 = (u16)cmdword[3] | ((cmdword[4] & 0xFF)<<16)</nowiki>. [[CSND]] channelslotregister+0x1C = 0.
    
==Command 0xC==
 
==Command 0xC==
Line 316: Line 329:  
| 0x2
 
| 0x2
 
| 2
 
| 2
| CmdID 0xB
+
| CmdID 0xC
 
|-
 
|-
 
| 0xC
 
| 0xC
Line 331: Line 344:  
|}
 
|}
   −
This is used for initializing looping state for IMA-ADPCM encoding. <nowiki>channelslotregister+0x18 = (1<<31) | (u16)cmdword[3] | ((cmdword[4] & 0xFF)<<16)</nowiki>.
+
This is used for setting the IMA-ADPCM state used to play the second block (when IMA-ADPCM encoding is used). <nowiki>channelslotregister+0x1C = (1<<31) | (u16)cmdword[3] | ((cmdword[4] & 0xFF)<<16)</nowiki>.
    
==Command 0xD==
 
==Command 0xD==
Line 343: Line 356:  
| 2
 
| 2
 
| CmdID 0xD
 
| CmdID 0xD
 +
|-
 +
| 0xC
 +
| 1
 +
| 0 = disable ADPCM state reload for the second block, 1 = enable.
 
|}
 
|}
   −
This command is invalid, using this command would result in CSND module immediately continuing to process the command(s) following this one(if any).
+
This command configures bit31 of <nowiki>channelslotregister+0x1C</nowiki>. This bit indicates whether the hardware will load ADPCM state from said register everytime the second block is to be played; or if it will continue using the same state used for the previously emitted sample.
    
==Command 0xE==
 
==Command 0xE==
Line 360: Line 377:  
| 0x8
 
| 0x8
 
| 4
 
| 4
| See below.
+
| See below. (Flags + Timer)
 
|-
 
|-
 
| 0xC
 
| 0xC
 
| 4
 
| 4
| See below. Usually zero?
+
| See below. (Channel volume)
 
|-
 
|-
 
| 0x10
 
| 0x10
 
| 4
 
| 4
| See below. Usually zero?
+
| See below. (Capture volume)
 
|-
 
|-
 
| 0x14
 
| 0x14
 
| 4
 
| 4
| Physical address for the audio data, for the main channel.
+
| Physical address for the first block of audio data.
 
|-
 
|-
 
| 0x18
 
| 0x18
 
| 4
 
| 4
| Physical address for the audio data, for the second channel(only needs set if a flag is set which enables using this address).
+
| Physical address for the second block of audio data.
 
|-
 
|-
 
| 0x1C
 
| 0x1C
 
| 4
 
| 4
| Total byte-size for the audio data.
+
| Total byte-size of one block.
 
|}
 
|}
   −
This initializes the [[CSND]] channel registers located at: 0x1EC03400 + (channel_index*0x20). Whether mono/stereo audio is used is determined via an unknown flag. When looping is used, audio playback initially begins with playing from the first physical address(using the byte-size from the channel register when audio playback was triggered). Once looping begins after the initial audio playback finishes, the second physical address is used for the beginning of the audio data instead(using the same byte-size used with the initial audio playback).
+
This initializes the [[CSND]] channel registers located at: 0x1EC03400 + (channel_index*0x20). It is unknown if stereo samples are supported. In manual mode, the hardware plays the audio data of the first block endlessly ignoring the size field. In one-shot mode, the hardware plays the first block with the specified size and then stops. When looping is enabled, the hardware plays the first block once and then repeats the second forever. Before playing a block, the hardware reads the corresponding address register in order to know where it is located. The block size is either read only once at the beginning (mode 3) or before each block (mode 1, normal looping).
    
===Parameter word 0x8===
 
===Parameter word 0x8===
Line 394: Line 411:  
| Channel index
 
| Channel index
 
|-
 
|-
| 9-6
+
| 6
| ?
+
| 0 = disable linear interpolation, 1 = enable linear interpolation.
 +
|-
 +
| 9-7
 +
| Ignored
 
|-
 
|-
 
| 11-10
 
| 11-10
| 1 = enable looping, 2 = disable looping.
+
| Repeat mode: 0 = manual, 1 = normal looping, 2 = one-shot, 3 = looping with constant block size.
 
|-
 
|-
 
| 13-12
 
| 13-12
| This sets the encoding, some of the names for the following encodings are from [https://github.com/3dshax/ctr/blob/master/ctrtool/cwav.h here]. 0 = PCM8, 1 = PCM16, 2 = IMA-ADPCM. 3 = PSG, similar to DS?
+
| This sets the encoding, some of the names for the following encodings are from [https://github.com/3dshax/ctr/blob/master/ctrtool/cwav.h here]. 0 = PCM8, 1 = PCM16, 2 = IMA-ADPCM. 3 = PSG, similar to DS.
 +
|-
 +
| 14
 +
| 0 = disable playback, 1 = enable playback
 
|-
 
|-
| 15-14
+
| 15
| ?
+
| Ignored
 
|-
 
|-
 
| 31-16
 
| 31-16
 
| Sample rate clamped to the following range(by the user process): 0x42-0xFFFF. This is the same value used with Cmd 0x8, except clamped.
 
| Sample rate clamped to the following range(by the user process): 0x42-0xFFFF. This is the same value used with Cmd 0x8, except clamped.
 
|}
 
|}
 +
 +
Bits 0 through 5 are written as zero to the CNT register.
 +
 +
PSG: Channels 8 through 13 play a square tone that is 32 samples long. Channels 14 and 15 play noise. The duty of the square tones is set using command 0x7.
    
===Parameter word 0xC===
 
===Parameter word 0xC===
Line 417: Line 444:  
|-
 
|-
 
| 15-0
 
| 15-0
| Unknown, this value is clamped to the following range(by the user process): 0x0-0x8000.
+
| Left channel volume, this value is clamped to the following range(by the user process): 0x0-0x8000.
 
|-
 
|-
 
| 31-16
 
| 31-16
| Unknown, this value is clamped to the following range(by the user process): 0x0-0x8000.
+
| Right channel volume, this value is clamped to the following range(by the user process): 0x0-0x8000.
 
|}
 
|}
   Line 430: Line 457:  
|-
 
|-
 
| 15-0
 
| 15-0
| Unknown, this value is clamped to the following range(by the user process): 0x0-0x8000.
+
| Left capture volume, this value is clamped to the following range(by the user process): 0x0-0x8000.
 
|-
 
|-
 
| 31-16
 
| 31-16
| Unknown, this value is clamped to the following range(by the user process): 0x0-0x8000.
+
| Right capture volume, this value is clamped to the following range(by the user process): 0x0-0x8000.
 +
|}
 +
 
 +
==Command 0xF==
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Index Byte
 +
!  Size
 +
!  Description
 +
|-
 +
| 0x2
 +
| 2
 +
| CmdID 0xF
 +
|-
 +
| 0x8
 +
| 4
 +
| Flags, as in command 0xE. Only the timer and the start/stop (bit14) bits are used.
 +
|-
 +
| 0xC
 +
| 4
 +
| Channel volume, same as in command 0xE.
 +
|-
 +
| 0x10
 +
| 4
 +
| Capture volume, same as in command 0xE.
 +
|-
 +
| 0x14
 +
| 4
 +
| Duty (see command 0x7).
 +
|}
 +
 
 +
This channel is similar to command 0xE, but it is tailored for configuring PSG Tone channels (8, 9, 10, 11, 12, 13) as it contains a duty parameter. Channel format is set to PSG.
 +
 
 +
==Command 0x10==
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Index Byte
 +
!  Size
 +
!  Description
 +
|-
 +
| 0x2
 +
| 2
 +
| CmdID 0xF
 +
|-
 +
| 0x8
 +
| 4
 +
| Flags, as in command 0xE. Only the timer and the start/stop (bit14) bits are used. Channel format is set to PSG.
 +
|-
 +
| 0xC
 +
| 4
 +
| Channel volume, same as in command 0xE.
 +
|-
 +
| 0x10
 +
| 4
 +
| Capture volume, same as in command 0xE.
 
|}
 
|}
 +
 +
This channel is identical to command 0xF except for not having a duty parameter. Presumably used to configure PSG Noise channels (14, 15).
 +
 +
==Command 0x100==
 +
Writes bit15 of (u16*)(0x1EC03800+16*X).
 +
 +
==Command 0x101==
 +
Writes bit0 of (u16*)(0x1EC03800+16*X).
 +
 +
==Command 0x102==
 +
Writes bit1 of (u16*)(0x1EC03800+16*X).
 +
 +
==Command 0x103==
 +
Writes bit2 of (u16*)(0x1EC03800+16*X).
 +
 +
==Command 0x104==
 +
Sets (u16*)(0x1EC03800+16*X+4) = -Y.
 +
 +
==Command 0x105==
 +
Sets (u32*)(0x1EC03800+16*X+8) = Y, and (u32*)(0x1EC03800+16*X+12) = Z.
 +
 +
==Command 0x106==
 +
Does the same thing as all 0x100-0x106 combined.
 +
 +
==Command 0x200==
 +
Sends some interrupt to the DSP?
    
==Command 0x300==
 
==Command 0x300==

Navigation menu