Log in

View Full Version : read one bit in a SPRM / make use of SPRM15


skeg64
11th November 2004, 17:13
Hi,
I am authoring with Maestro. I'm trying to make use of SPRM 15, which contains the audio capabilites of the player.
This register uses 11 of the 16 bits, with the other 5 not defined. Each bit that is used denotes whether a certain audio format can be decoded by the player. The value stored in the SPRM is the sum of the values for all supported formats. For example, a player that can play MPEG, DTS and AC3 would have the following breakdown:

................................ Bit .|. Value.|. 0N/OFF.|. Total
-----------------------------------------------------------------
(Reserved)....................... 0 ..... 1 ....... 0 ....... 0
(Reserved)....................... 1 ..... 2 ....... 0 ....... 0
SDDS Karaoke capability (option). 2 ..... 4 ....... 0 ....... 0
DTS Karaoke capability (option).. 3 ..... 8 ....... 0 ....... 0
MPEG Karaoke capability 1st bit.. 4 ..... 16 ...... 0 ....... 0
MPEG Karaoke capability 2nd bit.. 5 ..... 32 ...... 0 ....... 0
AC-3 Karaoke capability.......... 6 ..... 64 ...... 0 ....... 0
PCM Karaoke capability........... 7 ..... 128 ..... 0 ....... 0
(Reserved)....................... 8 ..... 256 ..... 0 ....... 0
(Reserved)....................... 9 ..... 512 ..... 0 ....... 0
SDDS capability (option)........ 10 ..... 1024 .... 0 ....... 0
DTS capability (option)......... 11 ..... 2048 .... 1 .... 2048
MPEG capability first bit....... 12 ..... 4096 .... 1 .... 4096
MPEG capability second bit...... 13 ..... 8192 .... 0 ....... 0
AC-3 capability................. 14 ..... 16384 ... 1 ... 16384
(Reserved)...................... 15 ..... 32768 ... 0 ....... 0
.................................................. Total: 22528

Since 11 bits can potentially be used here, there are obviously 2^11 different values that could be in this register.
My question is, how do I make use of this SPRM, without writing commands for all 2^11 possible values? Is there a way to tell if a certain bit is turned ON or OFF?
I can test for AC3 by checking if the value is > 16383. But how would I test for DTS capabilites?

OK, I could do:
MOV GP0, SPRM15
SUB GP0, 16384 if (GP0 > 16383)
SUB GP0, 4096 if (GP0 > 4095)
(Output command) if (GP0 > 2047)

That would test for DTS. But say I want to test for SDDS Karaoke, that's a lot of lines of commands! What if I want to test them in ascending order, that's about 91 lines of code, at a rough estimate. Is there a faster way to check the value of a particular bit?
Thanks in advance for any help. P.S. don't ask me why I want to do this, I am more interested in it for academic reasons.

SomeJoe
11th November 2004, 22:28
You can use bitwise AND to mask off the other bits, and then compare the results with 0.

For instance, to check for AC3 Karaoke capability:


MOV GP0,SPRM15
AND GP0,64
GOTO (Has AC3 Karaoke) IF (GP0>0)

skeg64
12th November 2004, 15:06
Thanks! That's just what I was looking for.
To tell you the truth, I didn't know how bitwise AND worked in DVD authoring, but I now understand it from your example.
Cheers

mpucoder
12th November 2004, 17:26
You can even make this simpler with the bitwise immediate COMPARE

GOTO (Has AC3 Karaoke) IF (SPRM15&64)

In hex:
01 91 00 8F 00 40 00 nn
nn is the line number

The bitwise compare does a bitwise and, then does the command (in this case GOTO, it could be another) if the result is non-zero.

skeg64
20th November 2004, 04:13
That's even better, thanks!

A slight correction, though: you cannot do bitwise AND between a SPRM and an intermediate (at least not in Maestro). So your code would be:

MOV GP0, 64
(output command has Ac3 Karaoke) IF (GP0&SPRM15)