Reading CDDA sound levels: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
mNo edit summary
m (BIOS -> system ROM)
Line 1: Line 1:
Registers {{Reg|REG_CDDALEFTL}} and {{Reg|REG_CDDARIGHTL}} hold the values of the currently streamed CD audio data, in a reversed 16bit 2's complement format suited for the [[LC78815]] DAC (Sample rate =~ 100kHz ?).
Registers {{Reg|REG_CDDALEFTL}} and {{Reg|REG_CDDARIGHTL}} hold the values of the currently streamed CD audio data, in a reversed 16bit 2's complement format suited for the [[LC78815]] DAC (Sample rate =~ 100kHz ?).


The CD2 [[BIOSes|BIOS]] uses the following code to reverse the bits:
The CD2 [[System ROM]] uses the following code to reverse the bits:
<syntaxhighlight>
<syntaxhighlight>
;D1:Input, D0:Output
;D1:Input, D0:Output
Line 15: Line 15:
</syntaxhighlight>
</syntaxhighlight>


The CD2 BIOS reads both registers multiple times during each frame (every 16 raster lines, by using the [[68k interrupts|raster interrupt]]) to get an average value. The displayed vu-meters use a double buffer to avoid getting updated with the average of only the first few register reads (those that were made before the vu-meters were actually drawn to the screen).
The CD2 system ROM reads both registers multiple times during each frame (every 16 raster lines, by using the [[68k interrupts|raster interrupt]]) to get an average value. The displayed vu-meters use a double buffer to avoid getting updated with the average of only the first few register reads (those that were made before the vu-meters were actually drawn to the screen).


==Demo==
==Demo==

Revision as of 06:40, 28 October 2015

Registers REG_CDDALEFTL and REG_CDDARIGHTL hold the values of the currently streamed CD audio data, in a reversed 16bit 2's complement format suited for the LC78815 DAC (Sample rate =~ 100kHz ?).

The CD2 System ROM uses the following code to reverse the bits:

;D1:Input, D0:Output
reverse16bits:
        moveq	#16-1,d7
	moveq	#0,d0
rev:
	lsr	#1,d1
	bcc	zerobit
	bset	d7,d0
zerobit:
	dbf	d7,rev

The CD2 system ROM reads both registers multiple times during each frame (every 16 raster lines, by using the raster interrupt) to get an average value. The displayed vu-meters use a double buffer to avoid getting updated with the average of only the first few register reads (those that were made before the vu-meters were actually drawn to the screen).

Demo

File:Screencap cddaviz.png

This does NOT work on current emulators.

Uses:

Source for AS and iso image: File:Vumeter1.zip

[Youtube video]