Difference between revisions of "CDDA"

From NeoGeo Development Wiki
Jump to: navigation, search
m
m (Commands)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This article needs checking and research.
+
'''This article needs checking and research'''.
  
CDDA stands for CD Digital Audio. When loading a game, the "CDDA flag" byte at location $000107 in the [[68k]] program is checked with bit 7 is masked off. Known values: 0, 2, $82.
+
CDDA stands for "CD Digital Audio". When loading a game, the "CDDA flag" byte at location $107 in the [[68k program header]] is checked with bit 7 masked off.
 +
 
 +
* $00 or $01 is for games which use the Z80 RAM default location $FEF8 to play CDDA tracks.
 +
* $02 and up seems to be for games which either use a custom Z80 RAM location, or the BIOS call.
  
 
==Z80 RAM check method==
 
==Z80 RAM check method==
This method was probably implemented to simplify the porting of small games to the NeoGeo CD. Games that didn't need in-game file loading only had to have their vector table and [[sound driver]] code replaced. The sound driver itself translates the regular music commands to CDDA command/tracl pairs and drops them to a specific location in its own RAM, which is then read back and executed by the BIOS when using the [[BIOS Calls|$C0044A call]].
+
This method was probably implemented to simplify the porting of small games to the NeoGeo CD. Games that didn't need in-game file loading only had to have their vector table and [[sound driver]] code replaced. The sound driver itself translates the regular music commands to CDDA command/track pairs and drops them to a specific location in its RAM, which is then read back and executed by the BIOS when using the [[SYSTEM_IO]] ($C0044A) [[BIOS calls|call]] (see difference between the MVS and CD versions of Puzzled: no calls for music, M1 replaced).
  
In the sound drivers of CD games, a table is used to figure out if a received command concerns the YM2610 (mostly sound effects) or a CDDA track.
+
In the sound drivers of CD games, a table is used to figure out if a received command concerns the YM2610 (mostly sound effects) or is a CDDA track.
  
Putting the CDDA flag byte at $000107 to 0 or 1 enables this method and sets the Z80 return address to $FEF8.
+
Putting the CDDA flag byte at $107 to 0 or 1 enables this method and sets the Z80 return address to $FEF8.
Setting the CDDA flag to any other values allows to choose what the return address will be (set with the 16bit value at $00013A).
+
Setting the CDDA flag to any other values allows to choose the address (word at $13A). If the address is 0, this method isn't used.
  
 
For example, [[Puzzled]] uses this method. The CDDA flag is set to 0 in the program header. The 68k sends the exact same "play music" Z80 commands as the MVS version of the game, the sound driver then converts them to CDDA ones and drops them at $FEF8. Command $0743 gets translated to $0532 (intro music, track 32).
 
For example, [[Puzzled]] uses this method. The CDDA flag is set to 0 in the program header. The 68k sends the exact same "play music" Z80 commands as the MVS version of the game, the sound driver then converts them to CDDA ones and drops them at $FEF8. Command $0743 gets translated to $0532 (intro music, track 32).
Line 17: Line 20:
 
BIOS call $C0056A. Command/track pair in D0. (track number in BCD format).
 
BIOS call $C0056A. Command/track pair in D0. (track number in BCD format).
  
Metal Slug 2 waits for a location in the BIOS RAM to be non-zero before calling $C0056A:
+
Metal Slug 2 waits for a location in the BIOS RAM to be non-zero before calling $C0056A (?):
 
<pre>
 
<pre>
 
#:
 
#:
Line 25: Line 28:
 
jsr $C0056A
 
jsr $C0056A
 
</pre>
 
</pre>
 +
 +
Viewpoint sends the command 4 ($04xx, xx being the track number):
 +
The CDDA flag ($107) is $02, and $13A is $0000.
  
 
==Commands==
 
==Commands==
  
*$00: Read track and loop
+
Commands are a two bytes (command type/track) put together into a short (ex: 0x0102)
*$02: Pause ?
+
 
*$05: Read track
+
{{16BitRegister|?|1|-|4|Sync|1|Command|2|Track # (BCD)|8}}
 +
 
 +
Commands are:
 +
*0x0: read track (loop)
 +
*0x1: read track (no loop)
 +
*0x2: pause (ignores track parameter)
 +
*0x3: resume (ignores track parameter)
 +
 
 +
Sync bit setting is:
 +
*0: Seamless play
 +
*1: Halt gameplay while drive is seeking
 +
 
 +
Commands over $07 are ignored.
  
CDDA functionalities are disabled if ($00013A)=$0000. Set to $FFFF if using the default $FEF8 value.
+
Set $13A to $0000 if not using the Z80 RAM.
 +
Set to $FFFF if using the default $FEF8 value.
  
$C0044A must be called every VBlank (all games do this ?) for direct CDDA commands to work.
+
'''BIOSF_SYSTEM_IO must be called every VBlank for direct CDDA commands to work.'''
  
 
CDDA data can be picked up through [[memory mapped registers]] CDDA_LEFTSTREAM and CDDA_RIGHTSTREAM.
 
CDDA data can be picked up through [[memory mapped registers]] CDDA_LEFTSTREAM and CDDA_RIGHTSTREAM.

Latest revision as of 18:07, 10 July 2019

This article needs checking and research.

CDDA stands for "CD Digital Audio". When loading a game, the "CDDA flag" byte at location $107 in the 68k program header is checked with bit 7 masked off.

  • $00 or $01 is for games which use the Z80 RAM default location $FEF8 to play CDDA tracks.
  • $02 and up seems to be for games which either use a custom Z80 RAM location, or the BIOS call.

Z80 RAM check method

This method was probably implemented to simplify the porting of small games to the NeoGeo CD. Games that didn't need in-game file loading only had to have their vector table and sound driver code replaced. The sound driver itself translates the regular music commands to CDDA command/track pairs and drops them to a specific location in its RAM, which is then read back and executed by the BIOS when using the SYSTEM_IO ($C0044A) call (see difference between the MVS and CD versions of Puzzled: no calls for music, M1 replaced).

In the sound drivers of CD games, a table is used to figure out if a received command concerns the YM2610 (mostly sound effects) or is a CDDA track.

Putting the CDDA flag byte at $107 to 0 or 1 enables this method and sets the Z80 return address to $FEF8. Setting the CDDA flag to any other values allows to choose the address (word at $13A). If the address is 0, this method isn't used.

For example, Puzzled uses this method. The CDDA flag is set to 0 in the program header. The 68k sends the exact same "play music" Z80 commands as the MVS version of the game, the sound driver then converts them to CDDA ones and drops them at $FEF8. Command $0743 gets translated to $0532 (intro music, track 32).

Direct method

BIOS call $C0056A. Command/track pair in D0. (track number in BCD format).

Metal Slug 2 waits for a location in the BIOS RAM to be non-zero before calling $C0056A (?):

#:
	move.b	d0,$300001    ;Watchdog kick, interrupts are disabled ?
	tst.b	$10F6D9
	beq.s	#
	jsr	$C0056A

Viewpoint sends the command 4 ($04xx, xx being the track number): The CDDA flag ($107) is $02, and $13A is $0000.

Commands

Commands are a two bytes (command type/track) put together into a short (ex: 0x0102)

Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Def ? -SyncCommandTrack # (BCD)

Commands are:

  • 0x0: read track (loop)
  • 0x1: read track (no loop)
  • 0x2: pause (ignores track parameter)
  • 0x3: resume (ignores track parameter)

Sync bit setting is:

  • 0: Seamless play
  • 1: Halt gameplay while drive is seeking

Commands over $07 are ignored.

Set $13A to $0000 if not using the Z80 RAM. Set to $FFFF if using the default $FEF8 value.

BIOSF_SYSTEM_IO must be called every VBlank for direct CDDA commands to work.

CDDA data can be picked up through memory mapped registers CDDA_LEFTSTREAM and CDDA_RIGHTSTREAM.