Hey Rockin'-B!

Hey Rockin'-B!

Yo Rockin'-B,

I got your PM and here's some code to play CDDA tracks on the Saturn. The line 'Play_cdda(6, 12, 5)' is the most important one because it tells the Saturn: Play CD audio tracks 6 through 12, 5 times. Change the number to something like 'Play_cdda(6, 6, 10)' and it would play track 6, 10 times.

*Heh, guess I'm just rambling now so here's what my 'OBJECT' file looks like:

==================================================

# source_program

SRCS = codeB01.c

SYSOBJS = $(CMNDIR)/cinit.o $(SGLLDR)/sglarea.o

OBJS = $(SRCS:.c=.o)

LIBS = -lcd -lsgl

*Now here's my actual program code:

=========================

#include <sgl.h>

#include <sgl_cd.h>

#include <sega_cdc.h>

#include "sddrvs.dat"

#define scsp_map_size 4

void Set_volume(int temp1)

{

slSndVolume(temp1);

return;

}

void Set_cdda_pan(int temp1, int temp2, int temp3, int temp4)

{

slCDDAOn(temp1, temp2, temp3, temp4);

return;

}

int Setup_sound(void)

{

char map[] = {0xff,0xff,0xff,0xff};

int i, y = 0;

slInitSound(sddrvstsk, sizeof(sddrvstsk), (Uint8 *)map, (4));

CDC_CdInit(0x00,0x00,0x05,0x0f);

return;

}

void Play_cdda(int temp1, int temp2, int temp3)

{

CdcPly plywk;

CdcPly *ply = &plywk;

CDC_PLY_STYPE(ply) = CDC_PTYPE_TNO ;

CDC_PLY_STNO(ply) = temp1 ;

CDC_PLY_SIDX(ply) = 1 ;

CDC_PLY_ETYPE(ply) = CDC_PTYPE_TNO ;

CDC_PLY_ETNO(ply) = temp2 ;

CDC_PLY_EIDX(ply) = 99 ;

CDC_PLY_PMODE(ply) = CDC_PM_DFL+ temp3 ;

CDC_CdPlay(ply);

return;

}

int ss_main()

{

slInitSystem(TV_704x240, NULL, 1);

slPrint("CDDA playback example v0.01", slLocate(2, 2));

slPrint(" >>Plays back track number 6 - 12, 5x.", slLocate(2, 3));

Setup_sound();

Set_volume(127);

Set_cdda_pan(127, 127, 0, 0);

Play_cdda(6, 12, 5);

while(-1)

{

slSynch();

}

}

// END OF CODE!!

Well, that should just about do it! Hey, if you have any questions feel free. But give it a shot and tell me what you think. Like always, any thoughts are more than welcome.

On a side note: I burned a CD with audio tracks from SOR2 and played them with this program. Streets of Rage music on the Saturn....beautiful. Freaking mint!!

Hey, see ya & happy coding!!
 

RockinB

Staff member
Hey Rockin'-B!

Hi Zaksund,

Thanks for your CDDA code. As you can read in the CDDA help topic, I got the CDC demo for playing CDDA to work, too.

Yesterday, I made a little demo that implements basic operations like play, pause and stop.

Cool thing to have CDDA music available! :banana

But maybe you can help me out explaining the pan setting. It's for left and right channel, but we allready have output level adjustment for left & right channel. So what is pan for? Stupid, but I don't know it right now.

Why don't you add your game to the contest?

Thanks,

The Rockin'-B
 

RockinB

Staff member
Hey Rockin'-B!

Ahh...

what a ****!

CDDA works fine in theory and with my demo and an original audio CD.

But when it comes to include it into a game and add CDDA tracks after the mode1 track, there occur a number of problems:

- some tracks start at wrong position, sometimes the CD-ROM is seeking for a while

(the wrong start positions are always the same, even after some attempts of bugfixing in code and in .CUE file)

- the game sometimes hangs after a track is started, like being in a loop

(in some situations in the game the PCM played keeps looping endlessly)

I think of 2 problems:

- general problems with iso and track layout

- incompatibilities between SGL PCM usage and CDC library?

But the fact that it worked with a real audio CD keeps me thinking... I found out that the SegaCueMaker does NOT produce a CD like described in the official Saturn CD layout manual. At least some gaps before CDDA tracks and after the last CDDA track are missing. But correcting this did not made the game run well.

So maybe it's something with .CTI file. Every CD I burn got one problem: when inserted into a non modded Saturn, the Saturn keeps reading again and again and does NOT say that it's no game CD!

I found out that the EndVolume(and another one which I can't remember) keyword in .CTI file is much later in file than described in the above mentioned manual.(there is genscr.exe in sbl: easily creates a file similar to our .CTI files from a directory --> maybe we should use this?)

Sorry for writing so much, but I don't want to keep any secret ;) .

Can you give me more info about how you burned the CD and made the ISO(possibly info about your .CTI and .CUE files)?

Thanks,

The Rockin'-B
 

RockinB

Staff member
Hey Rockin'-B!

Reinhart, it could be something with security ring. I just thought if this could have anything to do with my wrong CDDA track start problem. But later to that... .

Now, after reading a hint in MANCDC.TXT about prohibited SCU-DMA access while using CDC, I remembered that PCM data is transfered into sound RAM everytime it is played by possibly using DMA. So I compiled without using PCM and the freezing problem was removed!

:banana

So what this means is:

when using both, CDDA and PCM you have two possibilities:

1. make sure that CDDA and PCM playback don't occur at the same time, or

2. transfer PCM to sound RAM before using CDDA and play it from this location

The thing to proove is if the SGL PCM functions allow PCM already being in sound RAM, otherwise SBL must be used. But it would be very dumb if SGL's PCM is not capable of this.

But the remaining problem is with wrong CDDA track start when playing... . I could verify that even the bios build in CD player has exactly the same problems resulting in the same wrong track starts.... . And it displays 17 instead of 8 tracks, although tracks 9-17 cannot be played back.

So it must be definitely a problem with ISO or track layout.

I cannot find any other examples of .CTI files and .CUE files, so here are mine:

MSCD.CTI:

Disc CDROM MineSweeper.DSK

LeadIn MODE1

PostGap 150

EndTrack

Track MODE1

Pause 150

Volume ISO9660 MineSweeper.DSK

SystemArea "ip.bin"



PrimaryVolume

SystemIdentifier "SEGA SEGASATURN"

VolumeIdentifier "MineSweeper"

VolumeSetIdentifier "MineSweeper"

LogicalBlockSize 2048

PublisherIdentifier "THEROCKINB"

DataPreparerIdentifier "THEROCKINB"

ApplicationIdentifier "MineSweeper"

CopyrightFileIdentifier "CPY.TXT"

AbstractFileIdentifier "ABS.TXT"

BibliographicFileIdentifier "BIB.TXT"

Lpath ; Path tables as specified for Saturn

Mpath



Hierarchy

File 0MS.BIN

Source C:\dev\SATURN\SGL\PROJECTS\MineSwpr\SL.BIN

EndFile

File ABS.TXT

Source C:\dev\SATURN\SGL\PROJECTS\MineSwpr\ABS.TXT

EndFile

File BIB.TXT

Source C:\dev\SATURN\SGL\PROJECTS\MineSwpr\BIB.TXT

EndFile

File CPY.TXT

Source C:\dev\SATURN\SGL\PROJECTS\MineSwpr\CPY.TXT

EndFile

File MineSwpr.rar

Source C:\dev\SATURN\SGL\PROJECTS\MineSwpr\MineSwpr.rar

EndFile

File README.TXT

Source C:\dev\SATURN\SGL\PROJECTS\MineSwpr\README.TXT

EndFile

EndHierarchy

EndPrimaryVolume

EndVolume

PostGap 150

EndTrack

Leadout CDDA

Empty 500

EndTrack

EndDisc

Note that I checked the possibility to create such a file with previously mentioned SCRGEN.EXE. The result is not fully compatible with buildcd.exe. After removing all incompatibilities, the only difference to my MSCD.CTI file above is 600 for LeadOut.

And we cannot use CDDA tracks referenced in .CTI file(like it's done in sega examples) because buildcd.exe does not give out a propper cd image. So we have to use the .CUE file to include CDDA tracks.

MSCD.CUE:

FILE "MSCD.ISO" BINARY

TRACK 01 MODE1/2048

INDEX 01 00:00:00

POSTGAP 00:02:00

FILE "2.mp3" MP3

TRACK 02 AUDIO

PREGAP 00:02:00

INDEX 01 00:00:00

FILE "3.mp3" MP3

TRACK 03 AUDIO

PREGAP 00:02:00

INDEX 01 00:00:00

FILE "4.mp3" MP3

TRACK 04 AUDIO

PREGAP 00:02:00

INDEX 01 00:00:00

FILE "5.mp3" MP3

TRACK 05 AUDIO

PREGAP 00:02:00

INDEX 01 00:00:00

FILE "6.mp3" MP3

TRACK 06 AUDIO

PREGAP 00:02:00

INDEX 01 00:00:00

FILE "7.mp3" MP3

TRACK 7 AUDIO

PREGAP 00:02:00

INDEX 01 00:00:00

FILE "8.mp3" MP3

TRACK 8 AUDIO

PREGAP 00:02:00

INDEX 01 00:00:00

POSTGAP 00:02:00


So please inform me if you can build a CD with audio tracks with CORRECT start positions when playing CDDA. Or maybe you find an error in my files above... .

I need help :(

The Rockin'-B
 

RockinB

Staff member
Hey Rockin'-B!

:damn: Oh please somebody shoot me, please! Hurry up before someone sees how a dumbass I've been... .

The CDDA worked perfectly correct(aside the PCM DMA problems),

the only problem was my swaptrick. I got used to only swap once. But when CDDA is used, I need to swap twice, or track positions(other than track 1) won't be correct.

And that's the reason why Saturn CD player showed 17 tracks instead of 8...because I used Sega Rally for swapping which got 17 tracks... .

Man what a luck that this idea came to my mind, otherwise I would have searched the error for years.

Good night,

The Rockin'-B
 
Top