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

Function main

RecompModMerger/main.cpp:209–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209int main(int argc, const char** argv) {
210 if (argc != 8) {
211 printf("Usage: %s <function symbol toml> <symbol file 1> <binary 1> <symbol file 2> <binary 2> <output symbol file> <output binary file>\n", argv[0]);
212 return EXIT_SUCCESS;
213 }
214
215 const char* function_symbol_toml_path = argv[1];
216 const char* sym_file_path_1 = argv[2];
217 const char* binary_path_1 = argv[3];
218 const char* sym_file_path_2 = argv[4];
219 const char* binary_path_2 = argv[5];
220 const char* output_sym_path = argv[6];
221 const char* output_binary_path = argv[7];
222
223 // Load the symbol and binary files.
224 std::vector<char> sym_file_1;
225 if (!read_file(sym_file_path_1, sym_file_1)) {
226 fprintf(stderr, "Error reading file %s\n", sym_file_path_1);
227 return EXIT_FAILURE;
228 }
229
230 std::vector<uint8_t> binary_1;
231 if (!read_file(binary_path_1, binary_1)) {
232 fprintf(stderr, "Error reading file %s\n", binary_path_1);
233 return EXIT_FAILURE;
234 }
235
236 std::vector<char> sym_file_2;
237 if (!read_file(sym_file_path_2, sym_file_2)) {
238 fprintf(stderr, "Error reading file %s\n", sym_file_path_2);
239 return EXIT_FAILURE;
240 }
241
242 std::vector<uint8_t> binary_2;
243 if (!read_file(binary_path_2, binary_2)) {
244 fprintf(stderr, "Error reading file %s\n", binary_path_2);
245 return EXIT_FAILURE;
246 }
247
248 N64Recomp::ModSymbolsError err;
249
250 // Parse the symbol toml.
251 std::vector<uint8_t> dummy_rom{};
252 N64Recomp::Context reference_context{};
253 if (!N64Recomp::Context::from_symbol_file(function_symbol_toml_path, std::move(dummy_rom), reference_context, false)) {
254 fprintf(stderr, "Failed to load provided function reference symbol file\n");
255 return EXIT_FAILURE;
256 }
257
258 // Build a reference section lookup of rom address.
259 std::unordered_map<uint32_t, uint16_t> sections_by_rom{};
260 for (size_t section_index = 0; section_index < reference_context.sections.size(); section_index++) {
261 sections_by_rom[reference_context.sections[section_index].rom_addr] = section_index;
262 }
263
264 // Parse the two contexts.
265 N64Recomp::Context context1{};
266 err = N64Recomp::parse_mod_symbols(sym_file_1, binary_1, sections_by_rom, context1);

Callers

nothing calls this directly

Calls 5

copy_into_contextFunction · 0.85
write_fileFunction · 0.85
reinterpret_span_charFunction · 0.85
read_fileFunction · 0.70

Tested by

no test coverage detected