News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Does anyone know how to change the TOC of a cue/bin file  (Read 3538 times)

mcdra

  • Jr. Member
  • **
  • Posts: 12
    • View Profile
Does anyone know how to change the TOC of a cue/bin file
« on: April 06, 2020, 09:34:30 am »
I need to generate a .cue/.bin CD file with a specific CD Table of Contents file.  Does anyone know how to do something like this?  I thought the .cue file stored the Table of Contents but I don't seem to be seeing it there.  I know the TOC is located on the Lead In Data of the disc so does that mean I would need to look around the .bin file with a hex editor to change it manually or is there some tool I can use to change this?  Help or guidance on this topic would be most appreciated.

Jorpho

  • Hero Member
  • *****
  • Posts: 4341
  • The cat screams with the voice of a man.
    • View Profile
Re: Does anyone know how to change the TOC of a cue/bin file
« Reply #1 on: April 06, 2020, 12:23:34 pm »
Can you be more specific about what exactly you want to change?

A moment of Googling suggests it is fairly trivial to generate a .TOC file from a .CUE.
https://github.com/cmcginty/mktoc
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Supper

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • stargood
Re: Does anyone know how to change the TOC of a cue/bin file
« Reply #2 on: April 06, 2020, 01:24:06 pm »
Welcome to the cumbersome, complicated, and underdocumented world of CD-ROM formats!

The short answer is that the CUE file "is" the table of contents, or rather a simplified human-readable version of it stripped down to the essential information. The "true" TOC information is not part of the disc data proper, and you won't find it in the .bin -- it's stored in the subchannel data (which may not even be included with your disc image if you're working from a BIN+CUE). There is almost never any reason to touch the subchannel data. Most emulators don't even use it, except in rare circumstances such as PlayStation games that need it for copy protection.

So the answer to your question is that whatever you need to change, you can change via the CUE file. What exactly are you trying to do?

One of the more helpful resources on this topic is the NoCash PSX specifications. See the CD-ROM format and BIN/CUE format sections.

Valendian

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: Does anyone know how to change the TOC of a cue/bin file
« Reply #3 on: April 06, 2020, 02:55:17 pm »
The TOC has nothing to do with subchannel data.

The TOC is often confused with the file system. As a ROM hacker you should not have to change the TOC, but you may want to change the contents of the file system (move files around or resize files). You can use the (badly named) TOC changer to do this.

You can change the TOC by editing the CUE file directly and point the burning software at your modified CUE file. The TOC is part of the lead in. It describes a session or what tacks (songs) are on the disc. It is almost not used for data discs (just a single track that spans the entire disc and the BIN file contains a raw dump of that track). Audio CD's make use of the TOC to add artist and song name to the tracks (songs). Here are some examples
https://en.wikipedia.org/wiki/Cue_sheet_(computing)

Code: [Select]
REM GENRE Electronica
REM DATE 1998
PERFORMER "Faithless"
TITLE "Live in Berlin"
FILE "Faithless - Live in Berlin.mp3" MP3
  TRACK 01 AUDIO
    TITLE "Reverence"
    PERFORMER "Faithless"
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    TITLE "She's My Baby"
    PERFORMER "Faithless"
    INDEX 01 06:42:00
  TRACK 03 AUDIO
    TITLE "Take the Long Way Home"
    PERFORMER "Faithless"
    INDEX 01 10:54:00
  TRACK 04 AUDIO
    TITLE "Insomnia"
    PERFORMER "Faithless"
    INDEX 01 17:04:00
  TRACK 05 AUDIO
    TITLE "Bring the Family Back"
    PERFORMER "Faithless"
    INDEX 01 25:44:00
  TRACK 06 AUDIO
    TITLE "Salva Mea"
    PERFORMER "Faithless"
    INDEX 01 30:50:00
  TRACK 07 AUDIO
    TITLE "Dirty Old Man"
    PERFORMER "Faithless"
    INDEX 01 38:24:00
  TRACK 08 AUDIO
    TITLE "God Is a DJ"
    PERFORMER "Faithless"
    INDEX 01 42:35:00

mcdra

  • Jr. Member
  • **
  • Posts: 12
    • View Profile
Re: Does anyone know how to change the TOC of a cue/bin file
« Reply #4 on: April 06, 2020, 03:26:07 pm »
What I'm trying to do is create Dummy CDs for the game Monster Rancher 2.  From what documentation I've read on Legend Cup and MRM is  that, Monster Rancher 2 spawns monsters by reading the TOC on the lead in of a CD so all the data on the disc is unnecessary.  As long as you have a bin file with a specific table of contents you could make any monster you want while not needing to hunt down obscure CDs or cue/bin files.  The TOC files for rare monsters exist as a .ccd plain text dump.  Now I could just get some blank CDs and burn some dummy discs and rip those discs as cue/bin files to achieve what I want but that's a lot of extra steps and I don't want to buy a bunch of blank CDs just for that.  I was hoping to simplify the process by skipping the step burning dummy disks and making cue files with a dummy bin file directly from what I have.  I hope what I'm asking for makes sense.  I've been scouring google for resources and haven't had much luck so I thought I'd reach out for guidance.

(Before anyone says, "why not use the ccd file directly for this purpose?" I'm not because emulators on Lakka prefers cue/bin format for emulation)

Jorpho

  • Hero Member
  • *****
  • Posts: 4341
  • The cat screams with the voice of a man.
    • View Profile
Re: Does anyone know how to change the TOC of a cue/bin file
« Reply #5 on: April 06, 2020, 04:19:38 pm »
Now I could just get some blank CDs and burn some dummy discs and rip those discs as cue/bin files to achieve what I want but that's a lot of extra steps and I don't want to buy a bunch of blank CDs just for that.
It's been a while since I've looked into it, but as I recall there are virtual drive programs that simulate a CD burner precisely for cases such as these.  There probably are more elegant ways of doing it, but if you've already scoured the Internet, you might as well take the straightforward approach.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Supper

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • stargood
Re: Does anyone know how to change the TOC of a cue/bin file
« Reply #6 on: April 06, 2020, 05:55:35 pm »
The TOC has nothing to do with subchannel data.

Strictly speaking, on an actual, physical disc, the TOC is specified in the subchannel data of the lead-in, which is how a CD drive determines the contents of the disc. A CUE or CCD file encodes (the important parts of) this information in a form that's easier to work with.

But yes, looking at the specifications more closely, it seems that the lead-in data is omitted from even from the SUB file of a CCD disc image, and is encoded solely in the CCD instead. Sorry, the subchannel data is the part of the disc I know the least about because it's almost never relevant as far as hacking goes.

As for what you're trying to do specifically... Well, what you technically want is to convert a CCD file to a CUE. However, it's not that simple. Here is the data that Monster Rancher 2 specifically uses from the disc:

Quote
-Total CD time (minutes, seconds)
-1st track seconds
-Last track seconds

The problem here is that the CUE format does not encode as much information as a CCD. Specifically, the length of the last track, as well as of the overall disc, are not included in the CUE. They are implicitly determined from the size of the accompanying BIN file. In other words, without a BIN file of the correct size, the resulting CUE is meaningless for the purpose of MR2's generator algorithm. For instance, this is what a converted CUE for "Birdie.txt" looks like:

Code: [Select]
FILE "Birdie.img" BINARY
  TRACK 01 MODE2/2352
    INDEX 01 00:00:00

All this tells you is that there's a single data track that continues until the end of the disc. Without a valid "Birdie.img" of the same size as the disc that produced the original image, this is meaningless for MR2's purposes.

It's perfectly possible in principle to create a conversion program that would generate a dummy BIN file that matches the size of the image specified in the CCD, allowing a CUE to work (probably, assuming the emulator handles everything correctly), but that's getting pretty specialized. Finding a way to use the existing CCD files would be a much better solution than jumping through a bunch of convoluted hoops with converters.

Or hell, you could just use cheats instead, because I'm assuming this game is popular enough that someone's come up with codes for it.

mcdra

  • Jr. Member
  • **
  • Posts: 12
    • View Profile
Re: Does anyone know how to change the TOC of a cue/bin file
« Reply #7 on: April 06, 2020, 09:46:58 pm »
It's perfectly possible in principle to create a conversion program that would generate a dummy BIN file that matches the size of the image specified in the CCD, allowing a CUE to work (probably, assuming the emulator handles everything correctly), but that's getting pretty specialized. Finding a way to use the existing CCD files would be a much better solution than jumping through a bunch of convoluted hoops with converters.

Or hell, you could just use cheats instead, because I'm assuming this game is popular enough that someone's come up with codes for it.
Ugh I'll have to ask one of my roommates to pick up some CD-Rs and get to producing.  Thanks and that answers my question!

I could and there are plenty but I'd prefer not to use cheats if I can avoid it

Valendian

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: Does anyone know how to change the TOC of a cue/bin file
« Reply #8 on: April 07, 2020, 02:27:50 am »
Would be much faster and cheaper to use cheats then to burn CDs. This is gonna be very random