Author Topic: Neogeo cd mode1/2352 support  (Read 1298 times)

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 412
  • Karma: +17/-1
  • lr-fbalpha developer
Neogeo cd mode1/2352 support
« on: May 29, 2018, 03:30:16 AM »
Hi,

I hooked the neogeo cd emulation in lr-fbalpha yesterday, and now i'm trying to get cue with a MODE1/2352 track to load (they don't in standalone either, which is sad since popular dumps like those from redump use this format), an example cue would be like this :
Code: [Select]
FILE "Last Resort (Japan) (En,Ja) (Track 01).bin" BINARY
  TRACK 01 MODE1/2352
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 02).bin" BINARY
  TRACK 02 AUDIO
    FLAGS DCP
    INDEX 00 00:00:00
    INDEX 01 00:03:00
FILE "Last Resort (Japan) (En,Ja) (Track 03).bin" BINARY
  TRACK 03 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 04).bin" BINARY
  TRACK 04 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 05).bin" BINARY
  TRACK 05 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 06).bin" BINARY
  TRACK 06 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 07).bin" BINARY
  TRACK 07 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 08).bin" BINARY
  TRACK 08 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 09).bin" BINARY
  TRACK 09 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 10).bin" BINARY
  TRACK 10 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 11).bin" BINARY
  TRACK 11 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 12).bin" BINARY
  TRACK 12 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 13).bin" BINARY
  TRACK 13 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 14).bin" BINARY
  TRACK 14 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 15).bin" BINARY
  TRACK 15 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 16).bin" BINARY
  TRACK 16 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 17).bin" BINARY
  TRACK 17 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 18).bin" BINARY
  TRACK 18 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 19).bin" BINARY
  TRACK 19 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00
FILE "Last Resort (Japan) (En,Ja) (Track 20).bin" BINARY
  TRACK 20 AUDIO
    FLAGS DCP
    INDEX 01 00:00:00

From what i understand in https://github.com/mamedev/mame/blob/master/src/lib/util/cdrom.cpp, they are tracks with a sector size of 2336 bytes and an offset of 16 bytes, so i tried to do the following in fba's code :
Code: [Select]
struct isowavTRACK_DATA {
char Control;
int Mode;
char TrackNumber;
char Address[4];
TCHAR* Filename;
};

static int isowavGetTrackSizes()
{
// determine the lenght of the .iso / .mp3 files to complete the TOC

FILE*  h;

for (int i = isowavTOC->FirstTrack - 1; i < isowavTOC->LastTrack; i++) {

const char* address;

if (isowavTOC->TrackData[i].Control & 4) {

// data track

h = _tfopen(isowavTOC->TrackData[i].Filename, _T("rb"));
if (h == NULL) return 1;

if (isowavTOC->TrackData[i].Mode == 2352) {
fseek(h, 16, SEEK_END);
address = isowavLBAToMSF((ftell(h) + 2335) / 2336 + isowavMSFToLBA(isowavTOC->TrackData[i].Address));
} else {
fseek(h, 0, SEEK_END);
address = isowavLBAToMSF((ftell(h) + 2047) / 2048 + isowavMSFToLBA(isowavTOC->TrackData[i].Address));
}

if(h) fclose(h);

} else {

// audio track

h = _tfopen(isowavTOC->TrackData[i].Filename, _T("rb"));
if (h == NULL)return 1;

fseek(h, 0, SEEK_END);

address = isowavLBAToMSF(((ftell(h) + 2047) / 2048) + isowavMSFToLBA(isowavTOC->TrackData[i].Address));
if(h) fclose(h);
}

isowavTOC->TrackData[i + 1].Address[0] += 0; // always 0 [?]
isowavTOC->TrackData[i + 1].Address[1] += address[1]; // M
isowavTOC->TrackData[i + 1].Address[2] += address[2]; // S
isowavTOC->TrackData[i + 1].Address[3] += address[3]; // F
}

return 0;
}


static int isowavParseCueFile()
{
[...]
// type of track

if ((t = LabelCheck(s, _T("MODE1/2048"))) != 0) {
isowavTOC->TrackData[track - 1].Control = 4;
isowavTOC->TrackData[track - 1].Mode = 2048;

continue;
}
if ((t = LabelCheck(s, _T("MODE1/2352"))) != 0) {
isowavTOC->TrackData[track - 1].Control = 4;
isowavTOC->TrackData[track - 1].Mode = 2352;

continue;
}
if ((t = LabelCheck(s, _T("AUDIO"))) != 0) {
isowavTOC->TrackData[track - 1].Control = 0;

continue;
}
[...]
}

Of course it doesn't work, any idea what i'm doing wrong ?

Best regards :).
« Last Edit: May 29, 2018, 03:33:40 AM by barbudreadmon »

Offline dink

  • Administrator
  • *****
  • Posts: 3038
  • Karma: +259/-0
  • feed the horse yumyum
Re: Neogeo cd mode1/2352 support
« Reply #1 on: May 30, 2018, 09:53:22 PM »
Nice, really looking forward to bin/cue support in fba :D

I found some info that suggests that mode1/2352 has a 2048 sector size and offset of 16 (maybe?)  weird? hmm, give it a try?

check out this little proggy - binchunker, it converts .bin/.cue to .iso/.wav, and has a lot of nice info in it:
https://github.com/phracker/bchunk/blob/master/bchunk.c

best regards & good luck,
- dink

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 412
  • Karma: +17/-1
  • lr-fbalpha developer
Re: Neogeo cd mode1/2352 support
« Reply #2 on: May 31, 2018, 02:01:07 AM »
Actually i noticed this one from my other libretro port project. It gives the same feeling as the fba cd implementation and accept all formats except chd. I definitely think i can somehow port it to fba.

Offline SirVH

  • Newbies
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Neogeo cd mode1/2352 support
« Reply #3 on: April 15, 2019, 01:52:27 AM »
Actually i noticed this one from my other libretro port project. It gives the same feeling as the fba cd implementation and accept all formats except chd. I definitely think i can somehow port it to fba.

Did you managed to port that into FBA?

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 412
  • Karma: +17/-1
  • lr-fbalpha developer
Re: Neogeo cd mode1/2352 support
« Reply #4 on: April 15, 2019, 06:12:54 AM »
Did you managed to port that into FBA?
Nope, i failed, and cd reading implementation in fbalpha was rewritten (along with ngcd emulation) since then, it's now only accepting ccd/sub/img iso (aka trurip) and single file MODE1/2352 bin/cue.
« Last Edit: April 15, 2019, 06:15:07 AM by barbudreadmon »

Offline SirVH

  • Newbies
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Neogeo cd mode1/2352 support
« Reply #5 on: April 16, 2019, 01:22:44 PM »
Oh, so FBA now supports only the format of the least popular group? No TOSEC (ISO+WAV), Redump (CUE + Multiple bins) or MAME (CHDs)?

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 412
  • Karma: +17/-1
  • lr-fbalpha developer
Re: Neogeo cd mode1/2352 support
« Reply #6 on: April 16, 2019, 03:10:58 PM »
Oh, so FBA now supports only the format of the least popular group? No TOSEC (ISO+WAV), Redump (CUE + Multiple bins) or MAME (CHDs)?
In this case it was more about using DAO dumps, which were less troublesome (a lot of attempts were done to fix the issues with the non-DAO dumps before deciding to move to DAO dumps), than about popularity. Anyway that's no big deal if you use cdmage to convert your isos to bin/cue.

Offline dink

  • Administrator
  • *****
  • Posts: 3038
  • Karma: +259/-0
  • feed the horse yumyum
Re: Neogeo cd mode1/2352 support
« Reply #7 on: April 16, 2019, 07:00:04 PM »
not supporting anything besides bin/cue is a non-issue.  grab the trurip torrent and have it all in an hour or 2, or convert your old rips with cdmage.  see http://neo-source.com/index.php?topic=2487.msg26465#msg26465

best regards,
- dink