4398 |
if (lst3LS) { |
if (lst3LS) { |
4399 |
RIFF::Chunk* ckSCSL = lst3LS->GetSubChunk(CHUNK_ID_SCSL); |
RIFF::Chunk* ckSCSL = lst3LS->GetSubChunk(CHUNK_ID_SCSL); |
4400 |
if (ckSCSL) { |
if (ckSCSL) { |
4401 |
int slotCount = ckSCSL->ReadUint32(); |
int headerSize = ckSCSL->ReadUint32(); |
4402 |
int slotSize = ckSCSL->ReadUint32(); |
int slotCount = ckSCSL->ReadUint32(); |
4403 |
int unknownSpace = slotSize - 2*sizeof(uint32_t); // in case of future extensions |
if (slotCount) { |
4404 |
for (int i = 0; i < slotCount; ++i) { |
int slotSize = ckSCSL->ReadUint32(); |
4405 |
_ScriptPooolEntry e; |
ckSCSL->SetPos(headerSize); // in case of future header extensions |
4406 |
e.fileOffset = ckSCSL->ReadUint32(); |
int unknownSpace = slotSize - 2*sizeof(uint32_t); // in case of future slot extensions |
4407 |
e.bypass = ckSCSL->ReadUint32() & 1; |
for (int i = 0; i < slotCount; ++i) { |
4408 |
if (unknownSpace) ckSCSL->SetPos(unknownSpace, RIFF::stream_curpos); // in case of future extensions |
_ScriptPooolEntry e; |
4409 |
scriptPoolFileOffsets.push_back(e); |
e.fileOffset = ckSCSL->ReadUint32(); |
4410 |
|
e.bypass = ckSCSL->ReadUint32() & 1; |
4411 |
|
if (unknownSpace) ckSCSL->SetPos(unknownSpace, RIFF::stream_curpos); // in case of future extensions |
4412 |
|
scriptPoolFileOffsets.push_back(e); |
4413 |
|
} |
4414 |
} |
} |
4415 |
} |
} |
4416 |
} |
} |
4496 |
if (pScriptRefs) { |
if (pScriptRefs) { |
4497 |
RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS); |
RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS); |
4498 |
if (!lst3LS) lst3LS = pCkInstrument->AddSubList(LIST_TYPE_3LS); |
if (!lst3LS) lst3LS = pCkInstrument->AddSubList(LIST_TYPE_3LS); |
4499 |
const int totalSize = pScriptRefs->size() * 2*sizeof(uint32_t); |
const int slotCount = pScriptRefs->size(); |
4500 |
|
const int headerSize = 3 * sizeof(uint32_t); |
4501 |
|
const int slotSize = 2 * sizeof(uint32_t); |
4502 |
|
const int totalChunkSize = headerSize + slotCount * slotSize; |
4503 |
RIFF::Chunk* ckSCSL = lst3LS->GetSubChunk(CHUNK_ID_SCSL); |
RIFF::Chunk* ckSCSL = lst3LS->GetSubChunk(CHUNK_ID_SCSL); |
4504 |
if (!ckSCSL) ckSCSL = lst3LS->AddSubChunk(CHUNK_ID_SCSL, totalSize); |
if (!ckSCSL) ckSCSL = lst3LS->AddSubChunk(CHUNK_ID_SCSL, totalChunkSize); |
4505 |
else ckSCSL->Resize(totalSize); |
else ckSCSL->Resize(totalChunkSize); |
4506 |
uint8_t* pData = (uint8_t*) ckSCSL->LoadChunkData(); |
uint8_t* pData = (uint8_t*) ckSCSL->LoadChunkData(); |
4507 |
for (int i = 0, pos = 0; i < pScriptRefs->size(); ++i) { |
int pos = 0; |
4508 |
int fileOffset = |
store32(&pData[pos], headerSize); |
4509 |
(*pScriptRefs)[i].script->pChunk->GetFilePos() - |
pos += sizeof(uint32_t); |
4510 |
(*pScriptRefs)[i].script->pChunk->GetPos() - |
store32(&pData[pos], slotCount); |
4511 |
CHUNK_HEADER_SIZE; |
pos += sizeof(uint32_t); |
4512 |
store32(&pData[pos], fileOffset); |
store32(&pData[pos], slotSize); |
4513 |
|
pos += sizeof(uint32_t); |
4514 |
|
for (int i = 0; i < slotCount; ++i) { |
4515 |
|
// arbitrary value, the actual file offset will be updated in |
4516 |
|
// UpdateScriptFileOffsets() after the file has been resized |
4517 |
|
int bogusFileOffset = 0; |
4518 |
|
store32(&pData[pos], bogusFileOffset); |
4519 |
pos += sizeof(uint32_t); |
pos += sizeof(uint32_t); |
4520 |
store32(&pData[pos], (*pScriptRefs)[i].bypass ? 1 : 0); |
store32(&pData[pos], (*pScriptRefs)[i].bypass ? 1 : 0); |
4521 |
pos += sizeof(uint32_t); |
pos += sizeof(uint32_t); |
4523 |
} |
} |
4524 |
} |
} |
4525 |
|
|
4526 |
|
void Instrument::UpdateScriptFileOffsets() { |
4527 |
|
// own gig format extensions |
4528 |
|
if (pScriptRefs) { |
4529 |
|
RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS); |
4530 |
|
RIFF::Chunk* ckSCSL = lst3LS->GetSubChunk(CHUNK_ID_SCSL); |
4531 |
|
const int slotCount = pScriptRefs->size(); |
4532 |
|
const int headerSize = 3 * sizeof(uint32_t); |
4533 |
|
ckSCSL->SetPos(headerSize); |
4534 |
|
for (int i = 0; i < slotCount; ++i) { |
4535 |
|
uint32_t fileOffset = |
4536 |
|
(*pScriptRefs)[i].script->pChunk->GetFilePos() - |
4537 |
|
(*pScriptRefs)[i].script->pChunk->GetPos() - |
4538 |
|
CHUNK_HEADER_SIZE; |
4539 |
|
ckSCSL->WriteUint32(&fileOffset); |
4540 |
|
// jump over flags entry (containing the bypass flag) |
4541 |
|
ckSCSL->SetPos(sizeof(uint32_t), RIFF::stream_curpos); |
4542 |
|
} |
4543 |
|
} |
4544 |
|
} |
4545 |
|
|
4546 |
/** |
/** |
4547 |
* Returns the appropriate Region for a triggered note. |
* Returns the appropriate Region for a triggered note. |
4548 |
* |
* |
4678 |
if (scriptPoolFileOffsets.empty()) return; |
if (scriptPoolFileOffsets.empty()) return; |
4679 |
File* pFile = (File*) GetParent(); |
File* pFile = (File*) GetParent(); |
4680 |
for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) { |
for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) { |
4681 |
uint32_t offset = scriptPoolFileOffsets[k].fileOffset; |
uint32_t soughtOffset = scriptPoolFileOffsets[k].fileOffset; |
4682 |
for (uint i = 0; pFile->GetScriptGroup(i); ++i) { |
for (uint i = 0; pFile->GetScriptGroup(i); ++i) { |
4683 |
ScriptGroup* group = pFile->GetScriptGroup(i); |
ScriptGroup* group = pFile->GetScriptGroup(i); |
4684 |
for (uint s = 0; group->GetScript(s); ++s) { |
for (uint s = 0; group->GetScript(s); ++s) { |
4685 |
Script* script = group->GetScript(s); |
Script* script = group->GetScript(s); |
4686 |
if (script->pChunk) { |
if (script->pChunk) { |
4687 |
script->pChunk->SetPos(0); |
uint32_t offset = script->pChunk->GetFilePos() - |
4688 |
if (script->pChunk->GetFilePos() - |
script->pChunk->GetPos() - |
4689 |
script->pChunk->GetPos() - |
CHUNK_HEADER_SIZE; |
4690 |
CHUNK_HEADER_SIZE == offset) |
if (offset == soughtOffset) |
4691 |
{ |
{ |
4692 |
_ScriptPooolRef ref; |
_ScriptPooolRef ref; |
4693 |
ref.script = script; |
ref.script = script; |
5946 |
if (einf && pVersion && pVersion->major == 3) pRIFF->MoveSubChunk(_3crc, einf); |
if (einf && pVersion && pVersion->major == 3) pRIFF->MoveSubChunk(_3crc, einf); |
5947 |
} |
} |
5948 |
} |
} |
5949 |
|
|
5950 |
|
void File::UpdateFileOffsets() { |
5951 |
|
DLS::File::UpdateFileOffsets(); |
5952 |
|
|
5953 |
|
for (Instrument* instrument = GetFirstInstrument(); instrument; |
5954 |
|
instrument = GetNextInstrument()) |
5955 |
|
{ |
5956 |
|
instrument->UpdateScriptFileOffsets(); |
5957 |
|
} |
5958 |
|
} |
5959 |
|
|
5960 |
/** |
/** |
5961 |
* Enable / disable automatic loading. By default this properyt is |
* Enable / disable automatic loading. By default this properyt is |