Reading raw audio sectors
- showka
- 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:
-
- DC Developer
- Posts: 35
- Joined: Thu Mar 17, 2011 11:57 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Reading raw audio sectors
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.
It's one of those things that makes me wonder if it's supposed to be broken.
- BlueCrab
- 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
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;
-
- DC Developer
- Posts: 35
- Joined: Thu Mar 17, 2011 11:57 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Reading raw audio sectors
Yeah, this looks pretty close to what I determined empirically. Do you think you could get it into the official tree?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):
Thanks.
- BlueCrab
- 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
If you can confirm that the patch I posted works, I'll commit it.Multimedia Mike wrote:Yeah, this looks pretty close to what I determined empirically. Do you think you could get it into the official tree?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):
Thanks.
- Quzar
- 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
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.
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
- BlueCrab
- 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
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.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.
- Quzar
- 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
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
- T_chan
- 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
Its indeed a magic value.BlueCrab wrote: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.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 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
- BlueCrab
- 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
Aha! I knew I had seen it somewhere before.T_chan wrote:Its indeed a magic value.BlueCrab wrote: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.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 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