MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / StoreSamples

Method StoreSamples

Source/Compiler.cpp:1267–1319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1265}
1266
1267void CCompiler::StoreSamples()
1268{
1269 /*
1270 * DPCM sample list
1271 *
1272 * Each sample is stored as a pair of the sample address and sample size
1273 *
1274 */
1275
1276 unsigned int iAddedSamples = 0;
1277 unsigned int iSampleAddress = 0x0000;
1278
1279 auto &Dm = *m_pModule->GetDSampleManager(); // // //
1280
1281 // Get sample start address
1282 m_iSamplesSize = 0;
1283
1284 CChunk &Chunk = CreateChunk({CHUNK_SAMPLE_POINTERS}); // // //
1285 m_pSamplePointersChunk = &Chunk;
1286
1287 // Store DPCM samples in a separate array
1288 for (unsigned int i = 0; i < m_iSamplesUsed; ++i) {
1289
1290 unsigned int iIndex = m_iSampleBank[i];
1291 Assert(iIndex != 0xFF);
1292 auto pDSample = Dm.GetDSample(iIndex);
1293 unsigned int iSize = pDSample->size();
1294
1295 if (iSize > 0) {
1296 // Fill sample list
1297 unsigned char iSampleAddr = iSampleAddress >> 6;
1298 unsigned char iSampleSize = iSize >> 4;
1299 unsigned char iSampleBank = 0;
1300
1301 // Update SAMPLE_ITEM_WIDTH here
1302 Chunk.StoreByte(iSampleAddr);
1303 Chunk.StoreByte(iSampleSize);
1304 Chunk.StoreByte(iSampleBank);
1305
1306 // Add this sample to storage
1307 m_vSamples.push_back(pDSample);
1308
1309 // Pad end of samples
1310 unsigned int iAdjust = AdjustSampleAddress(iSampleAddress + iSize);
1311
1312 ++iAddedSamples;
1313 iSampleAddress += iSize + iAdjust;
1314 m_iSamplesSize += iSize + iAdjust;
1315 }
1316 }
1317
1318 Print(" * DPCM samples used: " + conv::from_int(m_iSamplesUsed) + " (" + conv::from_int(m_iSamplesSize) + " bytes)\n");
1319}
1320
1321int CCompiler::GetSampleIndex(int SampleNumber)
1322{

Callers 3

ExportNSF_NSFEMethod · 0.45
ExportNES_PRGMethod · 0.45
ExportBIN_ASMMethod · 0.45

Calls 5

from_intFunction · 0.85
StoreByteMethod · 0.80
GetDSampleManagerMethod · 0.45
GetDSampleMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected