MCPcopy Create free account
hub / github.com/N64Recomp/N64Recomp / permute

Function permute

RSPRecomp/src/rsp_recomp.cpp:860–890  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

858}
859
860void permute(const std::vector<uint32_t>& base_words, const std::vector<OverlaySlot>& overlay_slots, std::vector<Permutation>& permutations) {
861 auto current = std::vector<uint32_t>(overlay_slots.size(), 0);
862 auto slot_options = std::vector<uint32_t>(overlay_slots.size(), 0);
863
864 for (size_t i = 0; i < overlay_slots.size(); i++) {
865 slot_options[i] = overlay_slots[i].overlays.size();
866 }
867
868 do {
869 Permutation permutation = {
870 .instr_words = std::vector<uint32_t>(base_words),
871 .permutation = std::vector<uint32_t>(current)
872 };
873
874 for (size_t i = 0; i < overlay_slots.size(); i++) {
875 const OverlaySlot &slot = overlay_slots[i];
876 const Overlay &overlay = slot.overlays[current[i]];
877
878 uint32_t word_offset = slot.offset / sizeof(uint32_t);
879
880 size_t size_needed = word_offset + overlay.instr_words.size();
881 if (permutation.instr_words.size() < size_needed) {
882 permutation.instr_words.reserve(size_needed);
883 }
884
885 std::copy(overlay.instr_words.begin(), overlay.instr_words.end(), permutation.instr_words.data() + word_offset);
886 }
887
888 permutations.push_back(permutation);
889 } while (next_permutation(slot_options, current));
890}
891
892std::string make_permutation_string(const std::vector<uint32_t> permutation) {
893 std::string str = "";

Callers 1

mainFunction · 0.85

Calls 1

next_permutationFunction · 0.85

Tested by

no test coverage detected