Skip to content

Commit

Permalink
CHD - Backport skmp@1d7ecda
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 25, 2018
1 parent f4e1306 commit bb51449
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
3 changes: 0 additions & 3 deletions core/deps/chdr/cdrom.h
Expand Up @@ -20,9 +20,6 @@
CONSTANTS
***************************************************************************/

/* tracks are padded to a multiple of this many frames */
extern const uint32_t CD_TRACK_PADDING;

#define CD_MAX_TRACKS (99) /* AFAIK the theoretical limit */
#define CD_MAX_SECTOR_DATA (2352)
#define CD_MAX_SUBCODE_DATA (96)
Expand Down
29 changes: 17 additions & 12 deletions core/imgread/chd.cpp
Expand Up @@ -2,6 +2,9 @@

#include "deps/chdr/chd.h"

/* tracks are padded to a multiple of this many frames */
const uint32_t CD_TRACK_PADDING = 4;

struct CHDDisc : Disc
{
chd_file* chd;
Expand Down Expand Up @@ -91,10 +94,11 @@ bool CHDDisc::TryOpen(const wchar* file)
u8 flags;
char temp[512];
u32 temp_len;
u32 total_frames=150;
u32 total_frames = 150;

u32 total_secs=0;
u32 total_hunks=0;
u32 total_secs = 0;
u32 total_hunks = 0;
int extraframes = 0;

for(;;)
{
Expand Down Expand Up @@ -139,15 +143,16 @@ bool CHDDisc::TryOpen(const wchar* file)
}
printf("%s\n",temp);
Track t;
t.StartFAD=total_frames;
total_frames+=frames;
t.EndFAD=total_frames-1;
t.ADDR=0;
t.CTRL=strcmp(type,"AUDIO")==0?0:4;
t.file = new CHDTrack(this,t.StartFAD,total_hunks,strcmp(type,"MODE1")?2352:2048);

total_hunks+=frames/sph;
if (frames%sph)
t.StartFAD = total_frames + extraframes;
int padded = (frames + CD_TRACK_PADDING - 1) / CD_TRACK_PADDING;
extraframes += (padded * CD_TRACK_PADDING) - frames;
total_frames += frames;
t.EndFAD = total_frames - 1 + extraframes;
t.ADDR = 0;
t.CTRL = strcmp(type,"AUDIO") == 0 ? 0 : 4;
t.file = new CHDTrack(this, t.StartFAD, total_hunks, strcmp(type,"MODE1") ? 2352 : 2048);
total_hunks += frames / sph;
if (frames % sph)
total_hunks++;

tracks.push_back(t);
Expand Down

0 comments on commit bb51449

Please sign in to comment.