| 1328 | } |
| 1329 | |
| 1330 | void CFamiTrackerDocIO::LoadGrooves(CFamiTrackerModule &modfile, int ver) { |
| 1331 | const int Count = AssertRange(file_.GetBlockChar(), 0, MAX_GROOVE, "Groove count"); |
| 1332 | |
| 1333 | for (int i = 0; i < Count; ++i) { |
| 1334 | int Index = AssertRange(file_.GetBlockChar(), 0, MAX_GROOVE - 1, "Groove index"); |
| 1335 | try { |
| 1336 | std::size_t Size = AssertRange((uint8_t)file_.GetBlockChar(), 1u, ft0cc::doc::groove::max_size, "Groove size"); |
| 1337 | auto pGroove = std::make_unique<ft0cc::doc::groove>(); |
| 1338 | pGroove->resize(Size); |
| 1339 | for (std::size_t j = 0; j < Size; ++j) try { |
| 1340 | pGroove->set_entry(j, AssertRange( |
| 1341 | static_cast<unsigned char>(file_.GetBlockChar()), 1U, 0xFFU, "Groove item")); |
| 1342 | } |
| 1343 | catch (CModuleException &e) { |
| 1344 | e.AppendError("At position " + conv::from_int(j) + ','); |
| 1345 | throw e; |
| 1346 | } |
| 1347 | modfile.SetGroove(Index, std::move(pGroove)); |
| 1348 | } |
| 1349 | catch (CModuleException &e) { |
| 1350 | e.AppendError("At groove " + conv::from_int(Index) + ','); |
| 1351 | throw e; |
| 1352 | } |
| 1353 | } |
| 1354 | |
| 1355 | unsigned int Tracks = file_.GetBlockChar(); |
| 1356 | AssertFileData<MODULE_ERROR_STRICT>(Tracks == modfile.GetSongCount(), "Use-groove flag count does not match song count"); |
| 1357 | for (unsigned i = 0; i < Tracks; ++i) try { |
| 1358 | bool Use = file_.GetBlockChar() == 1; |
| 1359 | if (i >= modfile.GetSongCount()) |
| 1360 | continue; |
| 1361 | int Speed = modfile.GetSong(i)->GetSongSpeed(); |
| 1362 | modfile.GetSong(i)->SetSongGroove(Use); |
| 1363 | if (Use) |
| 1364 | AssertRange(Speed, 0, MAX_GROOVE - 1, "Song default groove index"); |
| 1365 | else |
| 1366 | AssertRange(Speed, 1, MAX_TEMPO, "Song default speed"); |
| 1367 | } |
| 1368 | catch (CModuleException &e) { |
| 1369 | e.AppendError("At song " + conv::from_int(i + 1) + ','); |
| 1370 | throw e; |
| 1371 | } |
| 1372 | } |
| 1373 | |
| 1374 | void CFamiTrackerDocIO::SaveGrooves(const CFamiTrackerModule &modfile, int ver) { |
| 1375 | int Count = 0; |
nothing calls this directly
no test coverage detected