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

Method Visit

Source/SongLengthScanner.cpp:41–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40 template <typename F, typename G>
41 void Visit(F cb, G fx) {
42 unsigned FrameCount = song_view_.GetSong().GetFrameCount();
43 unsigned Rows = song_view_.GetSong().GetPatternLength();
44
45 std::bitset<MAX_PATTERN_LENGTH> RowVisited[MAX_FRAMES] = { }; // // //
46 while (!RowVisited[f_][r_]) {
47 RowVisited[f_][r_] = true;
48
49 int Bxx = -1;
50 int Dxx = -1;
51 bool Cxx = false;
52
53 song_view_.ForeachTrack([&] (const CTrackData &track /* , stChannelID id */) {
54 const auto &Note = track.GetPatternOnFrame(f_).GetNoteOn(r_); // // //
55 for (unsigned l = 0, m = track.GetEffectColumnCount(); l < m; ++l) {
56 switch (Note.Effects[l].fx) {
57 case effect_t::JUMP:
58 Bxx = Note.Effects[l].param;
59 break;
60 case effect_t::SKIP:
61 Dxx = Note.Effects[l].param;
62 break;
63 case effect_t::HALT:
64 Cxx = true;
65 break;
66 default:
67 fx(/* id, */ Note.Effects[l]);
68 }
69 }
70 });
71
72 if (Cxx && !first_)
73 break;
74 cb();
75 if (Cxx)
76 break;
77
78 if (Bxx != -1) {
79 f_ = std::min(static_cast<unsigned int>(Bxx), FrameCount - 1);
80 r_ = 0;
81 }
82 else if (Dxx != -1) {
83 if (++f_ >= FrameCount)
84 f_ = 0;
85 r_ = std::min(static_cast<unsigned int>(Dxx), Rows - 1);
86 }
87 else if (++r_ >= Rows) { // // //
88 r_ = 0;
89 if (++f_ >= FrameCount)
90 f_ = 0;
91 }
92 }
93
94 first_ = false;
95 }
96
97private:
98 CConstSongView song_view_;

Callers 1

ComputeMethod · 0.80

Calls 5

GetSongMethod · 0.80
GetPatternLengthMethod · 0.80
GetFrameCountMethod · 0.45
ForeachTrackMethod · 0.45
GetEffectColumnCountMethod · 0.45

Tested by

no test coverage detected