MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / LoadFrames

Method LoadFrames

Source/FamiTrackerDocIO.cpp:714–763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

712}
713
714void 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
765void CFamiTrackerDocIO::SaveFrames(const CFamiTrackerModule &modfile, int ver) {
766 modfile.VisitSongs([&] (const CSongData &Song) {

Callers

nothing calls this directly

Calls 11

GetBlockIntMethod · 0.80
GetSongMethod · 0.80
ForeachChannelMethod · 0.80
GetBlockCharMethod · 0.80
VisitSongsMethod · 0.80
SetSongTempoMethod · 0.80
SetSongSpeedMethod · 0.80
GetMachineMethod · 0.80
SetPatternLengthMethod · 0.80
SetFrameCountMethod · 0.45
SetFramePatternMethod · 0.45

Tested by

no test coverage detected