| 378 | } |
| 379 | |
| 380 | void CFamiTrackerDocIO::LoadHeader(CFamiTrackerModule &modfile, int ver) { |
| 381 | if (ver == 1) { |
| 382 | // Single track |
| 383 | auto &Song = *modfile.GetSong(0); |
| 384 | modfile.GetChannelOrder().ForeachChannel([&] (stChannelID i) { |
| 385 | try { |
| 386 | // Channel type (unused) |
| 387 | AssertRange<MODULE_ERROR_STRICT>(file_.GetBlockChar(), 0, (int)CHANID_COUNT - 1, "Channel type index"); |
| 388 | // Effect columns |
| 389 | Song.SetEffectColumnCount(i, AssertRange<MODULE_ERROR_STRICT>( |
| 390 | file_.GetBlockChar(), 0, MAX_EFFECT_COLUMNS - 1, "Effect column count") + 1); |
| 391 | } |
| 392 | catch (CModuleException &e) { |
| 393 | e.AppendError("At track + " + std::string {FTEnv.GetSoundChipService()->GetChannelFullName(i)}); |
| 394 | throw e; |
| 395 | } |
| 396 | }); |
| 397 | } |
| 398 | else if (ver >= 2) { |
| 399 | // Multiple tracks |
| 400 | unsigned Tracks = AssertRange(file_.GetBlockChar() + 1, 1, static_cast<int>(MAX_TRACKS), "Song count"); // 0 means one song |
| 401 | if (!modfile.GetSong(Tracks - 1)) // allocate |
| 402 | throw CModuleException::WithMessage("Unable to allocate song"); |
| 403 | |
| 404 | // Song names |
| 405 | if (ver >= 3) |
| 406 | modfile.VisitSongs([&] (CSongData &song) { song.SetTitle(file_.ReadString()); }); |
| 407 | |
| 408 | modfile.GetChannelOrder().ForeachChannel([&] (stChannelID i) { |
| 409 | try { |
| 410 | AssertRange<MODULE_ERROR_STRICT>(file_.GetBlockChar(), 0, (int)CHANID_COUNT - 1, "Channel type index"); // Channel type (unused) |
| 411 | modfile.VisitSongs([&] (CSongData &song, unsigned index) { |
| 412 | try { |
| 413 | song.SetEffectColumnCount(i, AssertRange<MODULE_ERROR_STRICT>( |
| 414 | file_.GetBlockChar(), 0, MAX_EFFECT_COLUMNS - 1, "Effect column count") + 1); |
| 415 | } |
| 416 | catch (CModuleException &e) { |
| 417 | e.AppendError("At song " + conv::from_int(index + 1) + ','); |
| 418 | throw e; |
| 419 | } |
| 420 | }); |
| 421 | } |
| 422 | catch (CModuleException &e) { |
| 423 | e.AppendError("At track " + std::string {FTEnv.GetSoundChipService()->GetChannelFullName(i)} + ','); |
| 424 | throw e; |
| 425 | } |
| 426 | }); |
| 427 | |
| 428 | if (ver >= 4) // // // 050B |
| 429 | for (unsigned int i = 0; i < Tracks; ++i) { |
| 430 | int First = static_cast<unsigned char>(file_.GetBlockChar()); |
| 431 | int Second = static_cast<unsigned char>(file_.GetBlockChar()); |
| 432 | if (i == 0) |
| 433 | modfile.SetHighlight({First, Second}); |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 |
nothing calls this directly
no test coverage detected