| 83 | } |
| 84 | |
| 85 | bool CModuleImporter::Validate() const { |
| 86 | if (modfile_.GetSongCount() + imported_.GetSongCount() > MAX_TRACKS) { |
| 87 | AfxMessageBox(IDS_IMPORT_FAILED, MB_ICONEXCLAMATION); |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | for (const auto &it : inst_index_) |
| 92 | if (it.second >= MAX_INSTRUMENTS) { |
| 93 | AfxMessageBox(IDS_IMPORT_INSTRUMENT_COUNT, MB_ICONERROR); |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | for (const auto &it : groove_index_) |
| 98 | if (it.second >= MAX_GROOVE) { |
| 99 | AfxMessageBox(IDS_IMPORT_GROOVE_SLOTS, MB_ICONEXCLAMATION); |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | if (inst_mode_ != import_mode_t::none) { |
| 104 | // // // Check DPCM sample count |
| 105 | // TODO: allow importing only used samples |
| 106 | auto *pSamps = modfile_.GetDSampleManager(); |
| 107 | auto *pImportedSamps = imported_.GetDSampleManager(); // // // |
| 108 | if (pSamps->GetDSampleCount() + pImportedSamps->GetDSampleCount() > MAX_DSAMPLES) { |
| 109 | AfxMessageBox(IDS_IMPORT_SAMPLE_SLOTS, MB_ICONEXCLAMATION); |
| 110 | return false; |
| 111 | } |
| 112 | |
| 113 | const inst_type_t INST[] = {INST_2A03, INST_VRC6, INST_N163, INST_S5B}; // // // |
| 114 | |
| 115 | // Check sequence count |
| 116 | // TODO: allow importing only used sequences |
| 117 | auto *pInsts = modfile_.GetInstrumentManager(); |
| 118 | auto *pImportedInsts = imported_.GetInstrumentManager(); |
| 119 | for (inst_type_t i : INST) |
| 120 | for (auto t : enum_values<sequence_t>()) { |
| 121 | int seqCount = pInsts->GetSequenceCount(i, t); |
| 122 | seqCount += pImportedInsts->GetSequenceCount(i, t); |
| 123 | if (seqCount > MAX_SEQUENCES) { // // // |
| 124 | AfxMessageBox(IDS_IMPORT_SEQUENCE_COUNT, MB_ICONERROR); |
| 125 | return false; |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | return true; |
| 131 | } |
| 132 | |
| 133 | void CModuleImporter::DoImport(bool doDetune) { |
| 134 | ImportInstruments(); |
no test coverage detected