| 712 | } |
| 713 | |
| 714 | void CFamiTrackerDocIO::LoadFrames(CFamiTrackerModule &modfile, int ver) { |
| 715 | if (ver == 1) { |
| 716 | unsigned int FrameCount = AssertRange(file_.GetBlockInt(), 1, MAX_FRAMES, "Song frame count"); |
| 717 | /*m_iChannelsAvailable =*/ AssertRange<MODULE_ERROR_OFFICIAL>(AssertRange(file_.GetBlockInt(), |
| 718 | 0, (int)CHANID_COUNT, "Track count"), 0, (int)MAX_CHANNELS, "Track count"); |
| 719 | auto &Song = *modfile.GetSong(0); |
| 720 | Song.SetFrameCount(FrameCount); |
| 721 | for (unsigned i = 0; i < FrameCount; ++i) { |
| 722 | modfile.GetChannelOrder().ForeachChannel([&] (stChannelID j) { |
| 723 | unsigned Pattern = static_cast<unsigned char>(file_.GetBlockChar()); |
| 724 | AssertRange(Pattern, 0U, static_cast<unsigned>(MAX_PATTERN - 1), "Pattern index"); |
| 725 | Song.SetFramePattern(i, j, Pattern); |
| 726 | }); |
| 727 | } |
| 728 | } |
| 729 | else if (ver > 1) { |
| 730 | modfile.VisitSongs([&] (CSongData &song) { |
| 731 | unsigned int FrameCount = AssertRange(file_.GetBlockInt(), 1, MAX_FRAMES, "Song frame count"); |
| 732 | unsigned int Speed = AssertRange<MODULE_ERROR_STRICT>(file_.GetBlockInt(), 0, MAX_TEMPO, "Song default speed"); |
| 733 | song.SetFrameCount(FrameCount); |
| 734 | |
| 735 | if (ver >= 3) { |
| 736 | unsigned int Tempo = AssertRange<MODULE_ERROR_STRICT>(file_.GetBlockInt(), 0, MAX_TEMPO, "Song default tempo"); |
| 737 | song.SetSongTempo(Tempo); |
| 738 | song.SetSongSpeed(Speed); |
| 739 | } |
| 740 | else { |
| 741 | if (Speed < 20) { |
| 742 | song.SetSongTempo(modfile.GetMachine() == machine_t::NTSC ? DEFAULT_TEMPO_NTSC : DEFAULT_TEMPO_PAL); |
| 743 | song.SetSongSpeed(Speed); |
| 744 | } |
| 745 | else { |
| 746 | song.SetSongTempo(Speed); |
| 747 | song.SetSongSpeed(DEFAULT_SPEED); |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | unsigned PatternLength = AssertRange(file_.GetBlockInt(), 1, MAX_PATTERN_LENGTH, "Song default row count"); |
| 752 | song.SetPatternLength(PatternLength); |
| 753 | |
| 754 | for (unsigned i = 0; i < FrameCount; ++i) { |
| 755 | modfile.GetChannelOrder().ForeachChannel([&] (stChannelID j) { |
| 756 | // Read pattern index |
| 757 | int Pattern = static_cast<unsigned char>(file_.GetBlockChar()); |
| 758 | song.SetFramePattern(i, j, AssertRange(Pattern, 0, MAX_PATTERN - 1, "Pattern index")); |
| 759 | }); |
| 760 | } |
| 761 | }); |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | void CFamiTrackerDocIO::SaveFrames(const CFamiTrackerModule &modfile, int ver) { |
| 766 | modfile.VisitSongs([&] (const CSongData &Song) { |
nothing calls this directly
no test coverage detected