| 35 | namespace |
| 36 | { |
| 37 | size_t loadModuleSection(std::weak_ptr<Module> mod, const BinaryContainer& ctr, |
| 38 | size_t globCsr, uint32_t version) |
| 39 | { |
| 40 | std::shared_ptr<Module> modLocked = mod.lock(); |
| 41 | |
| 42 | size_t modOfs = ctr.readUint32(globCsr); |
| 43 | size_t modCsr = globCsr + 4; |
| 44 | size_t modTitleLen = ctr.readUint32(modCsr); |
| 45 | modCsr += 4; |
| 46 | if (modTitleLen > 0) { |
| 47 | modLocked->setTitle(ctr.readString(modCsr, modTitleLen)); |
| 48 | modCsr += modTitleLen; |
| 49 | } |
| 50 | size_t modAuthorLen = ctr.readUint32(modCsr); |
| 51 | modCsr += 4; |
| 52 | if (modAuthorLen > 0) { |
| 53 | modLocked->setAuthor(ctr.readString(modCsr, modAuthorLen)); |
| 54 | modCsr += modAuthorLen; |
| 55 | } |
| 56 | size_t modCopyrightLen = ctr.readUint32(modCsr); |
| 57 | modCsr += 4; |
| 58 | if (modCopyrightLen > 0) { |
| 59 | modLocked->setCopyright(ctr.readString(modCsr, modCopyrightLen)); |
| 60 | modCsr += modCopyrightLen; |
| 61 | } |
| 62 | size_t modCommentLen = ctr.readUint32(modCsr); |
| 63 | modCsr += 4; |
| 64 | if (modCommentLen > 0) { |
| 65 | modLocked->setComment(ctr.readString(modCsr, modCommentLen)); |
| 66 | modCsr += modCommentLen; |
| 67 | } |
| 68 | modLocked->setTickFrequency(ctr.readUint32(modCsr)); |
| 69 | modCsr += 4; |
| 70 | modLocked->setStepHighlight1Distance(ctr.readUint32(modCsr)); |
| 71 | modCsr += 4; |
| 72 | if (version >= Version::toBCD(1, 0, 3)) { |
| 73 | modLocked->setStepHighlight2Distance(ctr.readUint32(modCsr)); |
| 74 | modCsr += 4; |
| 75 | } |
| 76 | else { |
| 77 | modLocked->setStepHighlight2Distance(modLocked->getStepHighlight1Distance() * 4); |
| 78 | } |
| 79 | if (version >= Version::toBCD(1, 3, 0)) { |
| 80 | auto mixType = static_cast<MixerType>(ctr.readUint8(modCsr++)); |
| 81 | modLocked->setMixerType(mixType); |
| 82 | if (mixType == MixerType::CUSTOM) { |
| 83 | modLocked->setCustomMixerFMLevel(ctr.readInt8(modCsr++) / 10.0); |
| 84 | modLocked->setCustomMixerSSGLevel(ctr.readInt8(modCsr++) / 10.0); |
| 85 | } |
| 86 | } |
| 87 | else { |
| 88 | modLocked->setMixerType(MixerType::UNSPECIFIED); |
| 89 | } |
| 90 | |
| 91 | return globCsr + modOfs; |
| 92 | } |
| 93 | |
| 94 | size_t loadInstrumentSection(std::weak_ptr<InstrumentsManager> instMan, |
no test coverage detected