MCPcopy Create free account
hub / github.com/BambooTracker/BambooTracker / loadModuleSection

Function loadModuleSection

BambooTracker/io/btm_io.cpp:37–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35namespace
36{
37size_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
94size_t loadInstrumentSection(std::weak_ptr<InstrumentsManager> instMan,

Callers 1

loadMethod · 0.85

Calls 15

readUint32Method · 0.80
readStringMethod · 0.80
setAuthorMethod · 0.80
setCopyrightMethod · 0.80
setTickFrequencyMethod · 0.80
readUint8Method · 0.80
setMixerTypeMethod · 0.80
setCustomMixerFMLevelMethod · 0.80
readInt8Method · 0.80

Tested by

no test coverage detected