add DOL file loader
This commit is contained in:
+39
-3
@@ -4,9 +4,12 @@
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "Menu.hh"
|
||||
|
||||
|
||||
|
||||
bool function_compiler_available();
|
||||
@@ -21,14 +24,19 @@ struct CompiledFunctionCode {
|
||||
std::vector<uint16_t> relocation_deltas;
|
||||
std::unordered_map<std::string, uint32_t> label_offsets;
|
||||
uint32_t entrypoint_offset_offset;
|
||||
uint8_t index; // 00-FE (FF = index not specified)
|
||||
std::string name;
|
||||
uint32_t index; // 0 = unused (not registered in index_to_function)
|
||||
uint32_t menu_item_id;
|
||||
|
||||
std::string generate_client_command(
|
||||
const std::unordered_map<std::string, uint32_t>& label_writes = {},
|
||||
const std::string& suffix = "") const;
|
||||
};
|
||||
|
||||
std::shared_ptr<CompiledFunctionCode> compile_function_code(const std::string& text);
|
||||
std::shared_ptr<CompiledFunctionCode> compile_function_code(
|
||||
const std::string& directory,
|
||||
const std::string& name,
|
||||
const std::string& text);
|
||||
|
||||
|
||||
|
||||
@@ -36,5 +44,33 @@ struct FunctionCodeIndex {
|
||||
FunctionCodeIndex(const std::string& directory);
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<CompiledFunctionCode>> name_to_function;
|
||||
std::vector<std::shared_ptr<CompiledFunctionCode>> index_to_function;
|
||||
std::unordered_map<uint32_t, std::shared_ptr<CompiledFunctionCode>> index_to_function;
|
||||
std::unordered_map<uint32_t, std::shared_ptr<CompiledFunctionCode>> menu_item_id_to_patch_function;
|
||||
|
||||
std::map<std::string, std::shared_ptr<CompiledFunctionCode>> name_to_patch_function;
|
||||
|
||||
std::vector<MenuItem> patch_menu() const;
|
||||
inline bool patch_menu_empty() const {
|
||||
return this->name_to_patch_function.empty();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct DOLFileIndex {
|
||||
struct DOLFile {
|
||||
uint32_t menu_item_id;
|
||||
std::string name;
|
||||
std::string data;
|
||||
};
|
||||
|
||||
std::vector<std::shared_ptr<DOLFile>> item_id_to_file;
|
||||
std::map<std::string, std::shared_ptr<DOLFile>> name_to_file;
|
||||
|
||||
DOLFileIndex(const std::string& directory);
|
||||
|
||||
std::vector<MenuItem> menu() const;
|
||||
inline bool empty() const {
|
||||
return this->name_to_file.empty() && this->item_id_to_file.empty();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user