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

Function main

RSPRecomp/src/rsp_recomp.cpp:1087–1196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1085}
1086
1087int main(int argc, const char** argv) {
1088 if (argc != 2) {
1089 fmt::print("Usage: {} [config file]\n", argv[0]);
1090 std::exit(EXIT_SUCCESS);
1091 }
1092
1093 RSPRecompilerConfig config;
1094 if (!read_config(std::filesystem::path{argv[1]}, config)) {
1095 fmt::print("Failed to parse config file {}\n", argv[0]);
1096 std::exit(EXIT_FAILURE);
1097 }
1098
1099 std::vector<uint32_t> instr_words{};
1100 std::vector<OverlaySlot> overlay_slots{};
1101 instr_words.resize(config.text_size / sizeof(uint32_t));
1102 {
1103 std::ifstream rom_file{ config.rom_file_path, std::ios_base::binary };
1104
1105 if (!rom_file.good()) {
1106 fmt::print(stderr, "Failed to open rom file\n");
1107 return EXIT_FAILURE;
1108 }
1109
1110 rom_file.seekg(config.text_offset);
1111 rom_file.read(reinterpret_cast<char*>(instr_words.data()), config.text_size);
1112
1113 for (const RSPRecompilerOverlaySlotConfig &slot_config : config.overlay_slots) {
1114 OverlaySlot slot{};
1115 slot.offset = (slot_config.text_address - config.text_address) & rsp_mem_mask;
1116
1117 for (const RSPRecompilerOverlayConfig &overlay_config : slot_config.overlays) {
1118 Overlay overlay{};
1119 overlay.instr_words.resize(overlay_config.size / sizeof(uint32_t));
1120
1121 rom_file.seekg(config.text_offset + overlay_config.offset);
1122 rom_file.read(reinterpret_cast<char*>(overlay.instr_words.data()), overlay_config.size);
1123
1124 slot.overlays.push_back(overlay);
1125 }
1126
1127 overlay_slots.push_back(slot);
1128 }
1129 }
1130
1131 // Create overlay permutations
1132 std::vector<Permutation> permutations{};
1133 if (!overlay_slots.empty()) {
1134 permute(instr_words, overlay_slots, permutations);
1135 }
1136
1137 // Disable appropriate pseudo instructions
1138 RabbitizerConfig_Cfg.pseudos.pseudoMove = false;
1139 RabbitizerConfig_Cfg.pseudos.pseudoBeqz = false;
1140 RabbitizerConfig_Cfg.pseudos.pseudoBnez = false;
1141 RabbitizerConfig_Cfg.pseudos.pseudoNot = false;
1142
1143 // Decode the instruction words into instructions
1144 std::vector<rabbitizer::InstructionRsp> instrs{};

Callers

nothing calls this directly

Calls 8

read_configFunction · 0.85
permuteFunction · 0.85
create_functionFunction · 0.85
make_permutation_stringFunction · 0.85
byteswapFunction · 0.70
goodMethod · 0.45

Tested by

no test coverage detected