MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / FindLayer1Start

Function FindLayer1Start

pcsx2/CDVD/CDVDisoReader.cpp:117–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117static void FindLayer1Start()
118{
119 if (layer1searched)
120 return;
121
122 layer1searched = true;
123
124 std::array<u8, CD_FRAMESIZE_RAW> buffer;
125
126 // The ISO9660 primary volume descriptor for layer 0 is located at sector 16
127 iso.ReadSync(buffer.data(), 16);
128 if (!testForPrimaryVolumeDescriptor(buffer))
129 {
130 Console.Error("isoFile: Invalid layer0 Primary Volume Descriptor");
131 return;
132 }
133
134 // The volume space size (sector count) is located at bytes 80-87 - 80-83
135 // is the little endian size, 84-87 is the big endian size.
136 const int offset = iso.GetBlockOffset();
137 uint blockresult = buffer[offset + 80] + (buffer[offset + 81] << 8) + (buffer[offset + 82] << 16) + (buffer[offset + 83] << 24);
138
139 // If the ISO sector count is larger than the volume size, then we should
140 // have a dual layer DVD. Layer 1 is on a different volume.
141 if (blockresult < iso.GetBlockCount())
142 {
143 // The layer 1 start LSN contains the primary volume descriptor for layer 1.
144 // The check might be a bit unnecessary though.
145 if (iso.ReadSync(buffer.data(), blockresult) == -1)
146 return;
147
148 if (!testForPrimaryVolumeDescriptor(buffer))
149 {
150 Console.Error("isoFile: Invalid layer1 Primary Volume Descriptor");
151 return;
152 }
153 layer1start = blockresult;
154 Console.WriteLn(Color_Blue, "isoFile: second layer found at sector 0x%08x", layer1start);
155 }
156}
157
158// Should return 0 if no error occurred, or -1 if layer detection FAILED.
159static s32 ISOgetDualInfo(s32* dualType, u32* _layer1start)

Callers 2

ISOgetDualInfoFunction · 0.85
ISOgetTOCFunction · 0.85

Calls 7

ReadSyncMethod · 0.45
dataMethod · 0.45
ErrorMethod · 0.45
GetBlockOffsetMethod · 0.45
GetBlockCountMethod · 0.45
WriteLnMethod · 0.45

Tested by

no test coverage detected