3759 |
return dimreg; |
return dimreg; |
3760 |
} |
} |
3761 |
|
|
3762 |
|
int Region::GetDimensionRegionIndexByValue(const uint DimValues[8]) { |
3763 |
|
uint8_t bits; |
3764 |
|
int veldim = -1; |
3765 |
|
int velbitpos; |
3766 |
|
int bitpos = 0; |
3767 |
|
int dimregidx = 0; |
3768 |
|
for (uint i = 0; i < Dimensions; i++) { |
3769 |
|
if (pDimensionDefinitions[i].dimension == dimension_velocity) { |
3770 |
|
// the velocity dimension must be handled after the other dimensions |
3771 |
|
veldim = i; |
3772 |
|
velbitpos = bitpos; |
3773 |
|
} else { |
3774 |
|
switch (pDimensionDefinitions[i].split_type) { |
3775 |
|
case split_type_normal: |
3776 |
|
if (pDimensionRegions[0]->DimensionUpperLimits[i]) { |
3777 |
|
// gig3: all normal dimensions (not just the velocity dimension) have custom zone ranges |
3778 |
|
for (bits = 0 ; bits < pDimensionDefinitions[i].zones ; bits++) { |
3779 |
|
if (DimValues[i] <= pDimensionRegions[bits << bitpos]->DimensionUpperLimits[i]) break; |
3780 |
|
} |
3781 |
|
} else { |
3782 |
|
// gig2: evenly sized zones |
3783 |
|
bits = uint8_t(DimValues[i] / pDimensionDefinitions[i].zone_size); |
3784 |
|
} |
3785 |
|
break; |
3786 |
|
case split_type_bit: // the value is already the sought dimension bit number |
3787 |
|
const uint8_t limiter_mask = (0xff << pDimensionDefinitions[i].bits) ^ 0xff; |
3788 |
|
bits = DimValues[i] & limiter_mask; // just make sure the value doesn't use more bits than allowed |
3789 |
|
break; |
3790 |
|
} |
3791 |
|
dimregidx |= bits << bitpos; |
3792 |
|
} |
3793 |
|
bitpos += pDimensionDefinitions[i].bits; |
3794 |
|
} |
3795 |
|
dimregidx &= 255; |
3796 |
|
DimensionRegion* dimreg = pDimensionRegions[dimregidx]; |
3797 |
|
if (!dimreg) return -1; |
3798 |
|
if (veldim != -1) { |
3799 |
|
// (dimreg is now the dimension region for the lowest velocity) |
3800 |
|
if (dimreg->VelocityTable) // custom defined zone ranges |
3801 |
|
bits = dimreg->VelocityTable[DimValues[veldim] & 127]; |
3802 |
|
else // normal split type |
3803 |
|
bits = uint8_t((DimValues[veldim] & 127) / pDimensionDefinitions[veldim].zone_size); |
3804 |
|
|
3805 |
|
const uint8_t limiter_mask = (1 << pDimensionDefinitions[veldim].bits) - 1; |
3806 |
|
dimregidx |= (bits & limiter_mask) << velbitpos; |
3807 |
|
dimregidx &= 255; |
3808 |
|
} |
3809 |
|
return dimregidx; |
3810 |
|
} |
3811 |
|
|
3812 |
/** |
/** |
3813 |
* Returns the appropriate DimensionRegion for the given dimension bit |
* Returns the appropriate DimensionRegion for the given dimension bit |
3814 |
* numbers (zone index). You usually use <i>GetDimensionRegionByValue</i> |
* numbers (zone index). You usually use <i>GetDimensionRegionByValue</i> |
4094 |
for (int i = 0; i < nameSize; ++i) |
for (int i = 0; i < nameSize; ++i) |
4095 |
Name[i] = ckScri->ReadUint8(); |
Name[i] = ckScri->ReadUint8(); |
4096 |
// to handle potential future extensions of the header |
// to handle potential future extensions of the header |
4097 |
ckScri->SetPos(headerSize - 6*sizeof(int32_t) + nameSize, RIFF::stream_curpos); |
ckScri->SetPos(sizeof(int32_t) + headerSize); |
4098 |
// read actual script data |
// read actual script data |
4099 |
uint32_t scriptSize = ckScri->GetSize() - ckScri->GetPos(); |
uint32_t scriptSize = ckScri->GetSize() - ckScri->GetPos(); |
4100 |
data.resize(scriptSize); |
data.resize(scriptSize); |
4179 |
this->pGroup = pGroup; |
this->pGroup = pGroup; |
4180 |
} |
} |
4181 |
|
|
4182 |
|
/** |
4183 |
|
* Returns the script group this script currently belongs to. Each script |
4184 |
|
* is a member of exactly one ScriptGroup. |
4185 |
|
* |
4186 |
|
* @returns current script group |
4187 |
|
*/ |
4188 |
|
ScriptGroup* Script::GetGroup() const { |
4189 |
|
return pGroup; |
4190 |
|
} |
4191 |
|
|
4192 |
void Script::RemoveAllScriptReferences() { |
void Script::RemoveAllScriptReferences() { |
4193 |
File* pFile = pGroup->pFile; |
File* pFile = pGroup->pFile; |
4194 |
for (int i = 0; pFile->GetInstrument(i); ++i) { |
for (int i = 0; pFile->GetInstrument(i); ++i) { |