/[pcsx2_0.9.7]/branch/r3113_0.9.7_beta_reference/plugins/cdvdGigaherz/src/TocStuff.cpp
ViewVC logotype

Annotation of /branch/r3113_0.9.7_beta_reference/plugins/cdvdGigaherz/src/TocStuff.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (hide annotations) (download)
Tue Sep 7 03:29:01 2010 UTC (10 years ago) by william
Original Path: branch/r3113_0.9.7_beta/plugins/cdvdGigaherz/src/TocStuff.cpp
File size: 3002 byte(s)
branching from upstream revision (http://pcsx2.googlecode.com/svn/trunk
): r3113 to
https://svn.netsolutions.dnsalias.com/websvn/ps2/pcsx2/pcsx2_0.9.7/branch/r3113_0.9.7_beta
1 william 31 #include "CDVD.h"
2    
3     toc_data cdtoc;
4    
5     s32 cdvdParseTOC()
6     {
7     memset(&cdtoc,0,sizeof(cdtoc));
8    
9     s32 len = src->GetSectorCount();
10    
11     tracks[0].length = len;
12     tracks[0].start_lba=0;
13     tracks[0].type=0;
14     tracks[1].start_lba=0;
15    
16     if(len<=0)
17     {
18     curDiskType=CDVD_TYPE_NODISC;
19     tracks[0].length=0;
20     strack=1;
21     etrack=0;
22     return 0;
23     }
24    
25     s32 lastaddr = src->GetLayerBreakAddress();
26    
27    
28     if(lastaddr>=0)
29     {
30     if((lastaddr > 0)&&(tracks[0].length>lastaddr))
31     {
32     tracks[1].length=lastaddr+1;
33     tracks[1].type=0;
34    
35     tracks[2].start_lba = tracks[1].length;
36     tracks[2].length = tracks[0].length-tracks[1].length;
37     tracks[2].type=0;
38    
39     strack=1;
40     etrack=2;
41     }
42     else
43     {
44     tracks[1].length=tracks[0].length;
45     tracks[1].type=0;
46    
47     strack=1;
48     etrack=1;
49     }
50     }
51     else
52     {
53     u8 min, sec, frm;
54    
55     if(src->ReadTOC((char*)&cdtoc,sizeof(cdtoc))<0)
56     {
57     /*
58     printf(" * CDVD: WARNING ReadTOC() failed, trying to use MCI instead...\n");
59     delete src;
60     int status = MCI_CDGetTOC(source_drive);
61    
62     src=new SOURCECLASS(csrc);
63    
64     if(status<0)*/
65     return -1;
66    
67     //return 0;
68     }
69    
70     #define btoi(b) ((b>>4)*10+(b&0xF))
71    
72     int length = (cdtoc.Length[0]<<8) | cdtoc.Length[1];
73     int descriptors = length/sizeof(cdtoc.Descriptors[0]);
74     for(int i=0;i<descriptors;i++)
75     {
76     switch(cdtoc.Descriptors[i].Point)
77     {
78     case 0xa0:
79     if(cdtoc.Descriptors[i].SessionNumber==cdtoc.FirstCompleteSession)
80     {
81     strack = cdtoc.Descriptors[i].Msf[0];
82     }
83     break;
84     case 0xa1:
85     if(cdtoc.Descriptors[i].SessionNumber==cdtoc.LastCompleteSession)
86     {
87     etrack = cdtoc.Descriptors[i].Msf[0];
88     }
89     break;
90     case 0xa2: // session size
91     if(cdtoc.Descriptors[i].SessionNumber==cdtoc.LastCompleteSession)
92     {
93     min=cdtoc.Descriptors[i].Msf[0];
94     sec=cdtoc.Descriptors[i].Msf[1];
95     frm=cdtoc.Descriptors[i].Msf[2];
96    
97     tracks[0].length = MSF_TO_LBA(min,sec,frm);
98     tracks[0].type = 0;
99     }
100     break;
101     case 0xb0:
102     break;
103     case 0xb1:
104     break;
105     case 0xb2:
106     break;
107     case 0xc0:
108     break;
109     default:
110     if((cdtoc.Descriptors[i].Point<100)&&(cdtoc.Descriptors[i].Point>0))
111     {
112     int tn=cdtoc.Descriptors[i].Point;
113    
114     min=cdtoc.Descriptors[i].Msf[0];
115     sec=cdtoc.Descriptors[i].Msf[1];
116     frm=cdtoc.Descriptors[i].Msf[2];
117    
118     tracks[tn].start_lba = MSF_TO_LBA(min,sec,frm);
119     if(tn>1)
120     tracks[tn-1].length = tracks[tn].start_lba - tracks[tn-1].start_lba;
121    
122     if((cdtoc.Descriptors[i].Control&4)==0)
123     {
124     tracks[tn].type = 1;
125     }
126     else if((cdtoc.Descriptors[i].Control&0xE)==4)
127     {
128     tracks[tn].type = CDVD_MODE1_TRACK;
129     }
130     else
131     {
132     tracks[tn].type = CDVD_MODE1_TRACK;
133     }
134    
135     fprintf(stderr,"Track %d: %d mins %d secs %d frames\n",tn,min,sec,frm);
136     }
137     else if(cdtoc.Descriptors[i].Point>0)
138     {
139     printf("Found code 0x%02x\n",cdtoc.Descriptors[i].Point);
140     }
141     break;
142     }
143     }
144    
145     tracks[etrack].length = tracks[0].length - tracks[etrack].start_lba;
146     }
147    
148     return 0;
149     }

  ViewVC Help
Powered by ViewVC 1.1.22