Reading raw audio sectors

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
showka
DCEmu Freak
DCEmu Freak
Posts: 95
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Fri Nov 23, 2001 12:01 pm
Location: Border Town
Has thanked: 0
Been thanked: 0
Contact:

Re: Reading raw audio sectors

Post by showka »

Great! Glad to hear it worked.
Multimedia Mike
DC Developer
DC Developer
Posts: 35
Joined: Thu Mar 17, 2011 11:57 pm
Has thanked: 0
Been thanked: 0
Contact:

Re: Reading raw audio sectors

Post by Multimedia Mike »

Update on the original query: cdrom_set_sector_size() doesn't work as is (in the current version of KOS). However, I was able to modify it to make it work (modified one of the parameters while reconciling the KOS code with a really ancient DC program that does this correctly).

It's one of those things that makes me wonder if it's supposed to be broken.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Reading raw audio sectors

Post by BlueCrab »

I don't think there's any particular reason for it to be broken... I'm guessing this should fix it (as this is how I do it in Yabause, although in assembly, not in C):

Code: Select all

diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c
index 90fefba..6b4e66f 100644
--- a/kernel/arch/dreamcast/hardware/cdrom.c
+++ b/kernel/arch/dreamcast/hardware/cdrom.c
@@ -208,11 +208,19 @@ int cdrom_reinit() {
 
     /* Check disc type and set parameters */
     gdc_get_drv_stat(params);
-    cdxa = params[1] == 32;
-    params[0] = 0;              /* 0 = set, 1 = get */
-    params[1] = 8192;           /* ? */
-    params[2] = cdxa ? 2048 : 1024;     /* CD-XA mode 1/2 */
-    params[3] = sector_size;        /* sector size */
+    if(sector_size != 2352) {
+        cdxa = params[1] == 32;
+        params[0] = 0;              /* 0 = set, 1 = get */
+        params[1] = 8192;           /* ? */
+        params[2] = cdxa ? 2048 : 1024;     /* CD-XA mode 1/2 */
+        params[3] = sector_size;        /* sector size */
+    }
+    else {
+        params[0] = 0;
+        params[1] = 4096;
+        params[2] = 1024;
+        params[3] = 2352;
+    }
 
     if(gdc_change_data_type(params) < 0) {
         rv = ERR_SYS;
Multimedia Mike
DC Developer
DC Developer
Posts: 35
Joined: Thu Mar 17, 2011 11:57 pm
Has thanked: 0
Been thanked: 0
Contact:

Re: Reading raw audio sectors

Post by Multimedia Mike »

BlueCrab wrote:I don't think there's any particular reason for it to be broken... I'm guessing this should fix it (as this is how I do it in Yabause, although in assembly, not in C):
Yeah, this looks pretty close to what I determined empirically. Do you think you could get it into the official tree?

Thanks.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Reading raw audio sectors

Post by BlueCrab »

Multimedia Mike wrote:
BlueCrab wrote:I don't think there's any particular reason for it to be broken... I'm guessing this should fix it (as this is how I do it in Yabause, although in assembly, not in C):
Yeah, this looks pretty close to what I determined empirically. Do you think you could get it into the official tree?

Thanks.
If you can confirm that the patch I posted works, I'll commit it. :wink:
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7499
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 10 times
Contact:

Re: Reading raw audio sectors

Post by Quzar »

Blue, why did you change params[1] to be 4096 for 2352 sectors and 8192 otherwise? Do we know what this param does?

The last change to the cdrom code was actually mine that I needed for reading raw sectors from PCE-CD games for HuCast. iirc it worked fine there, but they weren't audio sectors, they were data.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Reading raw audio sectors

Post by BlueCrab »

Quzar wrote:Blue, why did you change params[1] to be 4096 for 2352 sectors and 8192 otherwise? Do we know what this param does?

The last change to the cdrom code was actually mine that I needed for reading raw sectors from PCE-CD games for HuCast. iirc it worked fine there, but they weren't audio sectors, they were data.
I know there was some reason for it explained many moons ago. Basically, it boiled down to 4096 being a "magic" value for 2352 byte sectors. I'm pretty sure I needed it for raw reads in Yabause, so I'm not sure why you wouldn't need it for HuCast.
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7499
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 10 times
Contact:

Re: Reading raw audio sectors

Post by Quzar »

Just went back to my sources. Turns out I don't have sources for the last released version, and the one I do have just has notes saying that I can't do the sector reading -_-. I misremembered, the reason for the update I did for KOS was towards that goal, but it seems I never achieved it. This may very well have been why. Hrm.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
User avatar
T_chan
DC Developer
DC Developer
Posts: 32
Joined: Mon Aug 22, 2011 12:45 pm
Has thanked: 12 times
Been thanked: 22 times

Re: Reading raw audio sectors

Post by T_chan »

BlueCrab wrote:
Quzar wrote:Blue, why did you change params[1] to be 4096 for 2352 sectors and 8192 otherwise? Do we know what this param does?

The last change to the cdrom code was actually mine that I needed for reading raw sectors from PCE-CD games for HuCast. iirc it worked fine there, but they weren't audio sectors, they were data.
I know there was some reason for it explained many moons ago. Basically, it boiled down to 4096 being a "magic" value for 2352 byte sectors. I'm pretty sure I needed it for raw reads in Yabause, so I'm not sure why you wouldn't need it for HuCast.
Its indeed a magic value.
I found it many many years ago by doing a little disassembly of the dc bios,
and posted my findings on the KOS mailing list.

see: viewtopic.php?f=29&t=83304
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Reading raw audio sectors

Post by BlueCrab »

T_chan wrote:
BlueCrab wrote:
Quzar wrote:Blue, why did you change params[1] to be 4096 for 2352 sectors and 8192 otherwise? Do we know what this param does?

The last change to the cdrom code was actually mine that I needed for reading raw sectors from PCE-CD games for HuCast. iirc it worked fine there, but they weren't audio sectors, they were data.
I know there was some reason for it explained many moons ago. Basically, it boiled down to 4096 being a "magic" value for 2352 byte sectors. I'm pretty sure I needed it for raw reads in Yabause, so I'm not sure why you wouldn't need it for HuCast.
Its indeed a magic value.
I found it many many years ago by doing a little disassembly of the dc bios,
and posted my findings on the KOS mailing list.

see: viewtopic.php?f=29&t=83304
Aha! I knew I had seen it somewhere before. 8-)
Post Reply