use ResourceDASM namespace where needed

This commit is contained in:
Martin Michelsen
2024-07-13 16:26:33 -07:00
parent 70ada6669d
commit a3cc0bd13f
4 changed files with 26 additions and 26 deletions
+12 -12
View File
@@ -115,8 +115,8 @@ public:
if (ends_with(filename, ".dol")) { if (ends_with(filename, ".dol")) {
string name = filename.substr(0, filename.size() - 4); string name = filename.substr(0, filename.size() - 4);
string path = directory + "/" + filename; string path = directory + "/" + filename;
DOLFile dol(path.c_str()); ResourceDASM::DOLFile dol(path.c_str());
auto mem = make_shared<MemoryContext>(); auto mem = make_shared<ResourceDASM::MemoryContext>();
dol.load_into(mem); dol.load_into(mem);
this->mems.emplace(name, mem); this->mems.emplace(name, mem);
this->enable_ppc = true; this->enable_ppc = true;
@@ -124,8 +124,8 @@ public:
} else if (ends_with(filename, ".xbe")) { } else if (ends_with(filename, ".xbe")) {
string name = filename.substr(0, filename.size() - 4); string name = filename.substr(0, filename.size() - 4);
string path = directory + "/" + filename; string path = directory + "/" + filename;
XBEFile xbe(path.c_str()); ResourceDASM::XBEFile xbe(path.c_str());
auto mem = make_shared<MemoryContext>(); auto mem = make_shared<ResourceDASM::MemoryContext>();
xbe.load_into(mem); xbe.load_into(mem);
this->mems.emplace(name, mem); this->mems.emplace(name, mem);
this->log.info("Loaded %s", name.c_str()); this->log.info("Loaded %s", name.c_str());
@@ -133,7 +133,7 @@ public:
string name = filename.substr(0, filename.size() - 4); string name = filename.substr(0, filename.size() - 4);
string path = directory + "/" + filename; string path = directory + "/" + filename;
string data = load_file(path); string data = load_file(path);
auto mem = make_shared<MemoryContext>(); auto mem = make_shared<ResourceDASM::MemoryContext>();
mem->allocate_at(0x8C010000, data.size()); mem->allocate_at(0x8C010000, data.size());
mem->memcpy(0x8C010000, data.data(), data.size()); mem->memcpy(0x8C010000, data.data(), data.size());
this->mems.emplace(name, mem); this->mems.emplace(name, mem);
@@ -204,7 +204,7 @@ public:
} }
uint32_t find_match( uint32_t find_match(
shared_ptr<const MemoryContext> dest_mem, shared_ptr<const ResourceDASM::MemoryContext> dest_mem,
uint32_t src_addr, uint32_t src_addr,
uint32_t src_size, uint32_t src_size,
ExpandMethod expand_method) const { ExpandMethod expand_method) const {
@@ -470,9 +470,9 @@ public:
private: private:
PrefixedLogger log; PrefixedLogger log;
string directory; string directory;
unordered_map<string, shared_ptr<const MemoryContext>> mems; unordered_map<string, shared_ptr<const ResourceDASM::MemoryContext>> mems;
string src_filename; string src_filename;
shared_ptr<const MemoryContext> src_mem; shared_ptr<const ResourceDASM::MemoryContext> src_mem;
bool enable_ppc; bool enable_ppc;
}; };
@@ -490,10 +490,10 @@ void run_address_translator(const std::string& directory, const std::string& use
} }
vector<pair<uint32_t, string>> diff_dol_files(const string& a_filename, const string& b_filename) { vector<pair<uint32_t, string>> diff_dol_files(const string& a_filename, const string& b_filename) {
DOLFile a(a_filename.c_str()); ResourceDASM::DOLFile a(a_filename.c_str());
DOLFile b(b_filename.c_str()); ResourceDASM::DOLFile b(b_filename.c_str());
auto a_mem = make_shared<MemoryContext>(); auto a_mem = make_shared<ResourceDASM::MemoryContext>();
auto b_mem = make_shared<MemoryContext>(); auto b_mem = make_shared<ResourceDASM::MemoryContext>();
a.load_into(a_mem); a.load_into(a_mem);
b.load_into(b_mem); b.load_into(b_mem);
+8 -8
View File
@@ -169,16 +169,16 @@ shared_ptr<CompiledFunctionCode> compile_function_code(
if (!get_include_stack.emplace(name).second) { if (!get_include_stack.emplace(name).second) {
throw runtime_error("mutual recursion between includes: " + name); throw runtime_error("mutual recursion between includes: " + name);
} }
EmulatorBase::AssembleResult ret; ResourceDASM::EmulatorBase::AssembleResult ret;
switch (arch) { switch (arch) {
case CompiledFunctionCode::Architecture::POWERPC: case CompiledFunctionCode::Architecture::POWERPC:
ret = PPC32Emulator::assemble(load_file(asm_filename), get_include); ret = ResourceDASM::PPC32Emulator::assemble(load_file(asm_filename), get_include);
break; break;
case CompiledFunctionCode::Architecture::X86: case CompiledFunctionCode::Architecture::X86:
ret = X86Emulator::assemble(load_file(asm_filename), get_include); ret = ResourceDASM::X86Emulator::assemble(load_file(asm_filename), get_include);
break; break;
case CompiledFunctionCode::Architecture::SH4: case CompiledFunctionCode::Architecture::SH4:
ret = SH4Emulator::assemble(load_file(asm_filename), get_include); ret = ResourceDASM::SH4Emulator::assemble(load_file(asm_filename), get_include);
break; break;
default: default:
throw runtime_error("unknown architecture"); throw runtime_error("unknown architecture");
@@ -198,13 +198,13 @@ shared_ptr<CompiledFunctionCode> compile_function_code(
throw runtime_error("data not found for include: " + name + " (from " + asm_filename + " or " + bin_filename + ")"); throw runtime_error("data not found for include: " + name + " (from " + asm_filename + " or " + bin_filename + ")");
}; };
EmulatorBase::AssembleResult assembled; ResourceDASM::EmulatorBase::AssembleResult assembled;
if (arch == CompiledFunctionCode::Architecture::POWERPC) { if (arch == CompiledFunctionCode::Architecture::POWERPC) {
assembled = PPC32Emulator::assemble(text, get_include); assembled = ResourceDASM::PPC32Emulator::assemble(text, get_include);
} else if (arch == CompiledFunctionCode::Architecture::X86) { } else if (arch == CompiledFunctionCode::Architecture::X86) {
assembled = X86Emulator::assemble(text, get_include); assembled = ResourceDASM::X86Emulator::assemble(text, get_include);
} else if (arch == CompiledFunctionCode::Architecture::SH4) { } else if (arch == CompiledFunctionCode::Architecture::SH4) {
assembled = SH4Emulator::assemble(text, get_include); assembled = ResourceDASM::SH4Emulator::assemble(text, get_include);
} else { } else {
throw runtime_error("invalid architecture"); throw runtime_error("invalid architecture");
} }
+3 -3
View File
@@ -754,19 +754,19 @@ static HandlerResult S_B2(shared_ptr<ProxyServer::LinkedSession> ses, uint16_t,
string disassembly; string disassembly;
if (is_ppc) { if (is_ppc) {
disassembly = PPC32Emulator::disassemble( disassembly = ResourceDASM::PPC32Emulator::disassemble(
&r.pget<uint8_t>(0, code.size()), &r.pget<uint8_t>(0, code.size()),
code.size(), code.size(),
0, 0,
&labels); &labels);
} else if (is_x86) { } else if (is_x86) {
disassembly = X86Emulator::disassemble( disassembly = ResourceDASM::X86Emulator::disassemble(
&r.pget<uint8_t>(0, code.size()), &r.pget<uint8_t>(0, code.size()),
code.size(), code.size(),
0, 0,
&labels); &labels);
} else if (is_sh4) { } else if (is_sh4) {
disassembly = SH4Emulator::disassemble( disassembly = ResourceDASM::SH4Emulator::disassemble(
&r.pget<uint8_t>(0, code.size()), &r.pget<uint8_t>(0, code.size()),
code.size(), code.size(),
0, 0,
+3 -3
View File
@@ -2225,11 +2225,11 @@ std::string assemble_quest_script(const std::string& text, const std::string& in
string native_text = load_file(include_directory + "/" + filename); string native_text = load_file(include_directory + "/" + filename);
string code; string code;
if (is_ppc(quest_version)) { if (is_ppc(quest_version)) {
code = std::move(PPC32Emulator::assemble(native_text).code); code = std::move(ResourceDASM::PPC32Emulator::assemble(native_text).code);
} else if (is_x86(quest_version)) { } else if (is_x86(quest_version)) {
code = std::move(X86Emulator::assemble(native_text).code); code = std::move(ResourceDASM::X86Emulator::assemble(native_text).code);
} else if (is_sh4(quest_version)) { } else if (is_sh4(quest_version)) {
code = std::move(SH4Emulator::assemble(native_text).code); code = std::move(ResourceDASM::SH4Emulator::assemble(native_text).code);
} else { } else {
throw runtime_error("unknown architecture"); throw runtime_error("unknown architecture");
} }