mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Cleanup (#49)
* Auto debug info generation and some cleanup * Cleaned dry code from segments * Fixed gCurrentCompressionType bss bs
This commit is contained in:
+10
-15
@@ -250,13 +250,6 @@ void Companion::ExtractNode(YAML::Node& node, std::string& name, SWrapper* binar
|
||||
file.close();
|
||||
break;
|
||||
}
|
||||
case ExportType::Code: {
|
||||
endptr = exporter->get()->Export(stream, result.value(), name, node, &name);
|
||||
if (this->IsDebug() && endptr.has_value() && endptr->index() == 0) {
|
||||
stream << "// 0x" << std::hex << std::uppercase << std::get<0>(endptr.value()) << "\n\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
endptr = exporter->get()->Export(stream, result.value(), name, node, &name);
|
||||
break;
|
||||
@@ -689,7 +682,7 @@ void Companion::Process() {
|
||||
} else {
|
||||
const auto offset = assetNode["offset"].as<uint32_t>();
|
||||
if(gCurrentFileOffset) {
|
||||
if (IS_SEGMENTED(offset) == false) {
|
||||
if (!IS_SEGMENTED(offset)) {
|
||||
assetNode["offset"] = (gCurrentSegmentNumber << 24) | offset;
|
||||
}
|
||||
}
|
||||
@@ -765,16 +758,18 @@ void Companion::Process() {
|
||||
|
||||
for (size_t i = 0; i < entries.size(); i++) {
|
||||
const auto result = entries[i];
|
||||
const auto hasSize = result.endptr.has_value();
|
||||
if (hasSize && this->IsDebug()) {
|
||||
stream << "// 0x" << std::hex << std::uppercase << ASSET_PTR(result.addr) << "\n";
|
||||
}
|
||||
|
||||
stream << result.buffer;
|
||||
|
||||
if(i < entries.size() - 1 && this->gConfig.exporterType == ExportType::Code){
|
||||
auto endptr = result.endptr;
|
||||
if(!endptr.has_value()){
|
||||
continue;
|
||||
}
|
||||
|
||||
#define ASSET_PTR(x) IS_SEGMENTED(x) ? SEGMENT_OFFSET(x) : x
|
||||
if (hasSize && this->IsDebug()) {
|
||||
stream << "// 0x" << std::hex << std::uppercase << ASSET_PTR(result.endptr.value()) << "\n\n";
|
||||
}
|
||||
|
||||
if(hasSize && i < entries.size() - 1 && this->gConfig.exporterType == ExportType::Code){
|
||||
uint32_t startptr = ASSET_PTR(result.endptr.value());
|
||||
uint32_t end = ASSET_PTR(entries[i + 1].addr);
|
||||
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ private:
|
||||
uint32_t gCurrentFileOffset;
|
||||
uint32_t gCurrentSegmentNumber;
|
||||
std::optional<VRAMEntry> gCurrentVram;
|
||||
CompressionType gCurrentCompressionType;
|
||||
CompressionType gCurrentCompressionType = CompressionType::None;
|
||||
std::vector<Table> gTables;
|
||||
std::variant<std::vector<std::string>, std::string> gWriteOrder;
|
||||
std::unordered_map<std::string, std::shared_ptr<BaseFactory>> gFactories;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define SEGMENT_NUMBER(x) (((uint32_t)(x) >> 24) & 0xFF)
|
||||
// I would love to use 0x01000000, but the stupid compiler takes it as 0x01
|
||||
#define IS_SEGMENTED(x) (((uint32_t)(x) > 16777216) && (SEGMENT_NUMBER(x) < 0x20))
|
||||
#define ASSET_PTR(x) (IS_SEGMENTED(x) ? SEGMENT_OFFSET(x) : (x))
|
||||
|
||||
#define tab "\t"
|
||||
#define fourSpaceTab " "
|
||||
|
||||
@@ -8,18 +8,7 @@ ExportResult BlobCodeExporter::Export(std::ostream &write, std::shared_ptr<IPars
|
||||
auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
auto data = std::static_pointer_cast<RawBuffer>(raw)->mBuffer;
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
if(node["ctype"]) {
|
||||
write << node["ctype"].as<std::string>() << " " << symbol << "[] = {\n" << tab;
|
||||
} else {
|
||||
write << "u8 " << symbol << "[] = {\n" << tab;
|
||||
}
|
||||
write << GetSafeNode<std::string>(node, "ctype", "u8") << " " << symbol << "[] = {\n" << tab;
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if ((i % 15 == 0) && i != 0) {
|
||||
@@ -34,7 +23,7 @@ ExportResult BlobCodeExporter::Export(std::ostream &write, std::shared_ptr<IPars
|
||||
write << "// size: 0x" << std::hex << std::uppercase << data.size() << "\n";
|
||||
}
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + data.size();
|
||||
return offset + data.size();
|
||||
}
|
||||
|
||||
ExportResult BlobBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -114,13 +114,6 @@ ExportResult DListCodeExporter::Export(std::ostream &write, std::shared_ptr<IPar
|
||||
gfxd_lightsn_callback(GFXDOverride::Light);
|
||||
GFXDSetGBIVersion();
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
gfxd_puts(("Gfx " + symbol + "[] = {\n").c_str());
|
||||
gfxd_execute();
|
||||
|
||||
@@ -132,7 +125,7 @@ ExportResult DListCodeExporter::Export(std::ostream &write, std::shared_ptr<IPar
|
||||
write << "// count: " << std::to_string(sz / 8) << " Gfx\n";
|
||||
}
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + sz;
|
||||
return offset + sz;
|
||||
}
|
||||
|
||||
void DebugDisplayList(uint32_t w0, uint32_t w1){
|
||||
|
||||
@@ -162,15 +162,11 @@ ExportResult TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IP
|
||||
|
||||
if(end == offset){
|
||||
write << "};\n";
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
write << "// size: 0x" << std::hex << std::uppercase << ASSET_PTR((end - start) + data.size()) << "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
write << GetSafeNode<std::string>(node, "ctype", "static const u8") << " " << symbol << "[] = {\n";
|
||||
|
||||
write << tab << "#include \"" << Companion::Instance->GetOutputPath() + "/" << *replacement << ".inc.c\"\n";
|
||||
@@ -181,7 +177,7 @@ ExportResult TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IP
|
||||
write << "// size: 0x" << std::hex << std::uppercase << sz << "\n";
|
||||
}
|
||||
}
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + data.size();
|
||||
return offset + data.size();
|
||||
}
|
||||
|
||||
ExportResult TextureBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement) {
|
||||
|
||||
@@ -37,20 +37,11 @@ ExportResult Vec3fCodeExporter::Export(std::ostream &write, std::shared_ptr<IPar
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
const auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
auto vecData = std::static_pointer_cast<Vec3fData>(raw);
|
||||
auto off = offset;
|
||||
int i;
|
||||
|
||||
if(IS_SEGMENTED(off)) {
|
||||
off = SEGMENT_OFFSET(off);
|
||||
}
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
write << "// 0x" << std::uppercase << std::hex << off << "\n";
|
||||
}
|
||||
int i = 0;
|
||||
|
||||
write << "Vec3f " << symbol << "[] = {";
|
||||
|
||||
int cols = 120 / (3 * vecData->mMaxWidth + 8);
|
||||
i = 0;
|
||||
for(Vec3f v : vecData->mVecs) {
|
||||
if((i++ % cols) == 0) {
|
||||
write << "\n" << fourSpaceTab;
|
||||
@@ -64,7 +55,7 @@ ExportResult Vec3fCodeExporter::Export(std::ostream &write, std::shared_ptr<IPar
|
||||
write << "// Count: " << vecData->mVecs.size() << " Vec3fs\n";
|
||||
}
|
||||
|
||||
return (IS_SEGMENTED(off) ? SEGMENT_OFFSET(off) : off) + vecData->mVecs.size() * sizeof(Vec3f);
|
||||
return offset + vecData->mVecs.size() * sizeof(Vec3f);
|
||||
}
|
||||
|
||||
ExportResult Vec3fBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -24,17 +24,6 @@ ExportResult VtxCodeExporter::Export(std::ostream &write, std::shared_ptr<IParse
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
write << "Vtx " << symbol << "[] = {\n";
|
||||
|
||||
for (int i = 0; i < vtx.size(); ++i) {
|
||||
@@ -68,7 +57,7 @@ ExportResult VtxCodeExporter::Export(std::ostream &write, std::shared_ptr<IParse
|
||||
write << "// count: " << std::to_string(vtx.size()) << " Vtxs\n";
|
||||
}
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + vtx.size() * sizeof(VtxRaw);
|
||||
return offset + vtx.size() * sizeof(VtxRaw);
|
||||
}
|
||||
|
||||
ExportResult VtxBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -23,10 +23,6 @@ ExportResult MK64::CourseVtxCodeExporter::Export(std::ostream &write, std::share
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
const auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
write << "CourseVtx " << symbol << "[] = {\n";
|
||||
|
||||
for (int i = 0; i < vtx.size(); ++i) {
|
||||
@@ -51,13 +47,9 @@ ExportResult MK64::CourseVtxCodeExporter::Export(std::ostream &write, std::share
|
||||
// {{{ x, y, z }, { tc1, tc2 }, { c1, c2, c3, c4 }}}
|
||||
write << "{{{" << NUM(x) << ", " << NUM(y) << ", " << NUM(z) << "}, {" << NUM(tc1) << ", " << NUM(tc2) << "}, {" << COL(c1) << ", " << COL(c2) << ", " << COL(c3) << ", " << COL(c4) << "}}},\n";
|
||||
}
|
||||
write << "};\n";
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
write << fourSpaceTab << "// 0x" << std::hex << std::uppercase << (offset + (sizeof(CourseVtx) * vtx.size())) << "\n";
|
||||
}
|
||||
|
||||
write << "};\n\n";
|
||||
return std::nullopt;
|
||||
return offset + vtx.size() * sizeof(CourseVtx);
|
||||
}
|
||||
|
||||
ExportResult MK64::CourseVtxBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -23,10 +23,6 @@ ExportResult MK64::SpawnDataCodeExporter::Export(std::ostream &write, std::share
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
const auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
write << "ActorSpawnData " << symbol << "[] = {\n";
|
||||
|
||||
for (int i = 0; i < spawns.size(); i++) {
|
||||
@@ -45,7 +41,7 @@ ExportResult MK64::SpawnDataCodeExporter::Export(std::ostream &write, std::share
|
||||
}
|
||||
write << "};\n";
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + (sizeof(MK64::ActorSpawnData) * spawns.size());
|
||||
return offset + spawns.size() * sizeof(MK64::ActorSpawnData);
|
||||
}
|
||||
|
||||
ExportResult MK64::SpawnDataBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -46,7 +46,7 @@ ExportResult MK64::TrackSectionsCodeExporter::Export(std::ostream &write, std::s
|
||||
}
|
||||
write << "};\n";
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + (sizeof(MK64::TrackSections) * sections.size());
|
||||
return offset + sections.size() * sizeof(MK64::TrackSections);
|
||||
}
|
||||
|
||||
ExportResult MK64::TrackSectionsBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -21,6 +21,7 @@ ExportResult MK64::WaypointHeaderExporter::Export(std::ostream &write, std::shar
|
||||
ExportResult MK64::WaypointCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
auto waypoints = std::static_pointer_cast<WaypointData>(raw)->mWaypoints;
|
||||
auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
|
||||
write << "TrackWaypoint " << symbol << "[] = {\n";
|
||||
|
||||
@@ -39,8 +40,9 @@ ExportResult MK64::WaypointCodeExporter::Export(std::ostream &write, std::shared
|
||||
// {{{ x, y, z }, f, { tc1, tc2 }, { c1, c2, c3, c4 }}}
|
||||
write << "{" << NUM(x) << ", " << NUM(y) << ", " << NUM(z) << ", " << NUM(seg) << " },\n";
|
||||
}
|
||||
write << "};\n\n";
|
||||
return std::nullopt;
|
||||
write << "};\n";
|
||||
|
||||
return offset + waypoints.size() * sizeof(MK64::TrackWaypoint);
|
||||
}
|
||||
|
||||
ExportResult MK64::WaypointBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -63,9 +63,6 @@ ExportResult SF64::AnimCodeExporter::Export(std::ostream &write, std::shared_ptr
|
||||
keyDefaultName << symbol << "_joint_key_" << std::uppercase << std::hex << keyOffset;
|
||||
auto keyName = GetSafeNode(node, "data_symbol", keyDefaultName.str());
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
write << "// 0x" << std::uppercase << std::hex << dataOffset << "\n";
|
||||
}
|
||||
auto dataCount = anim->mFrameData.size();
|
||||
// write << "Frame data end: 0x" << std::hex << std::uppercase << (dataOffset + sizeof(uint16_t) * dataCount) << "\n";
|
||||
// write << "JointKey start: 0x" << std::hex << std::uppercase << keyOffset << "\n";
|
||||
@@ -98,7 +95,7 @@ ExportResult SF64::AnimCodeExporter::Export(std::ostream &write, std::shared_ptr
|
||||
|
||||
return OffsetEntry {
|
||||
anim->mDataOffset,
|
||||
(IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + 0xC
|
||||
offset + 0xC
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -29,14 +29,8 @@ ExportResult SF64::ColPolyCodeExporter::Export(std::ostream &write, std::shared_
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
const auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
auto colpolys = std::static_pointer_cast<SF64::ColPolyData>(raw);
|
||||
auto off = offset;
|
||||
auto off = ASSET_PTR(offset);
|
||||
int i;
|
||||
if(IS_SEGMENTED(off)) {
|
||||
off = SEGMENT_OFFSET(off);
|
||||
}
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
write << "// 0x" << std::uppercase << std::hex << off << "\n";
|
||||
}
|
||||
|
||||
write << "CollisionPoly " << symbol << "[] = {";
|
||||
int width = std::log10(colpolys->mMesh.size()) + 1;
|
||||
@@ -75,10 +69,7 @@ ExportResult SF64::ColPolyCodeExporter::Export(std::ostream &write, std::shared_
|
||||
if (meshOffset != defaultMeshOffset) {
|
||||
write << "// SF64:COLPOLY alert: Gap detected between polys and mesh\n\n";
|
||||
}
|
||||
off = meshOffset;
|
||||
if(IS_SEGMENTED(off)) {
|
||||
off = SEGMENT_OFFSET(off);
|
||||
}
|
||||
off = ASSET_PTR(meshOffset);
|
||||
defaultMeshSymbol << symbol << "_mesh_" << std::uppercase << std::hex << off;
|
||||
auto meshSymbol = GetSafeNode(node, "mesh_symbol", defaultMeshSymbol.str());
|
||||
|
||||
@@ -108,7 +99,7 @@ ExportResult SF64::ColPolyCodeExporter::Export(std::ostream &write, std::shared_
|
||||
write << "// Mesh vertex count: " << colpolys->mMesh.size() << "\n";
|
||||
}
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + colpolys->mMesh.size() * sizeof(Vec3s);
|
||||
return offset + colpolys->mMesh.size() * sizeof(Vec3s);
|
||||
}
|
||||
|
||||
ExportResult SF64::ColPolyBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -25,13 +25,7 @@ ExportResult SF64::EnvSettingsCodeExporter::Export(std::ostream &write, std::sha
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
const auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
auto env = std::static_pointer_cast<SF64::EnvSettingsData>(raw);
|
||||
auto off = offset;
|
||||
if(IS_SEGMENTED(off)) {
|
||||
off = SEGMENT_OFFSET(off);
|
||||
}
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
write << "// 0x" << std::uppercase << std::hex << off << "\n";
|
||||
}
|
||||
|
||||
write << "EnvSettings " << symbol << " = {\n";
|
||||
write << fourSpaceTab;
|
||||
write << std::dec << env->mType << ", ";
|
||||
@@ -56,7 +50,7 @@ ExportResult SF64::EnvSettingsCodeExporter::Export(std::ostream &write, std::sha
|
||||
write << env->mAmbB << ",\n";
|
||||
write << "};\n";
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + sizeof(EnvSettingsData);
|
||||
return offset + sizeof(EnvSettingsData);
|
||||
}
|
||||
|
||||
ExportResult SF64::EnvSettingsBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -30,20 +30,14 @@ ExportResult SF64::HitboxCodeExporter::Export(std::ostream &write, std::shared_p
|
||||
auto index = 0;
|
||||
auto count = hitbox->mData[index++];
|
||||
auto hasType2 = false;
|
||||
auto off = offset;
|
||||
|
||||
if(IS_SEGMENTED(off)) {
|
||||
off = SEGMENT_OFFSET(off);
|
||||
}
|
||||
for(int type : hitbox->mTypes) {
|
||||
if(type == 2) {
|
||||
hasType2 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
write << "// 0x" << std::uppercase << std::hex << off << "\n";
|
||||
}
|
||||
|
||||
write << "f32 " << symbol << "[] = {\n";
|
||||
write << fourSpaceTab << count << ",\n";
|
||||
|
||||
@@ -78,7 +72,7 @@ ExportResult SF64::HitboxCodeExporter::Export(std::ostream &write, std::shared_p
|
||||
}
|
||||
write << "};\n";
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + sizeof(float) * index;
|
||||
return offset + sizeof(float) * index;
|
||||
}
|
||||
|
||||
ExportResult SF64::HitboxBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -79,17 +79,6 @@ ExportResult SF64::MessageCodeExporter::Export(std::ostream &write, std::shared_
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
write << "// ";
|
||||
bool lastWasSpace = false;
|
||||
for (int i = 0; i < message.size(); ++i) {
|
||||
@@ -132,7 +121,7 @@ ExportResult SF64::MessageCodeExporter::Export(std::ostream &write, std::shared_
|
||||
write << "// count: " << std::to_string(message.size()) << " chars\n";
|
||||
}
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + message.size() * sizeof(uint16_t);
|
||||
return offset + message.size() * sizeof(uint16_t);
|
||||
}
|
||||
|
||||
ExportResult SF64::MessageBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -21,17 +21,6 @@ ExportResult SF64::MessageLookupCodeExporter::Export(std::ostream &write, std::s
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
write << "// clang-format on\n";
|
||||
write << "MsgLookup " << symbol << "[] = {\n" << fourSpaceTab;
|
||||
for (int i = 0; i < table.size(); ++i) {
|
||||
@@ -52,7 +41,7 @@ ExportResult SF64::MessageLookupCodeExporter::Export(std::ostream &write, std::s
|
||||
}
|
||||
|
||||
write << "\n};\n";
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + table.size() * sizeof(uint16_t);
|
||||
return offset + table.size() * sizeof(uint16_t);
|
||||
}
|
||||
|
||||
ExportResult SF64::MessageLookupBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -22,13 +22,6 @@ ExportResult SF64::ObjInitCodeExporter::Export(std::ostream &write, std::shared_
|
||||
auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
auto objs = std::static_pointer_cast<ObjInitData>(raw)->mObjInit;
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
write << "ObjectInit " << symbol << "[] = {\n";
|
||||
for(auto& obj : objs) {
|
||||
auto enumName = Companion::Instance->GetEnumFromValue("ObjectId", obj.id).value_or(std::to_string(obj.id));
|
||||
@@ -46,7 +39,7 @@ ExportResult SF64::ObjInitCodeExporter::Export(std::ostream &write, std::shared_
|
||||
write << "// count: " << std::to_string(objs.size()) << " ObjectInits\n";
|
||||
}
|
||||
|
||||
return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + sizeof(ObjectInit) * objs.size();
|
||||
return offset + sizeof(ObjectInit) * objs.size();
|
||||
}
|
||||
|
||||
ExportResult SF64::ObjInitBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
|
||||
@@ -40,13 +40,9 @@ ExportResult SF64::ScriptCodeExporter::Export(std::ostream &write, std::shared_p
|
||||
auto sortedPtrs = script->mPtrs;
|
||||
std::sort(sortedPtrs.begin(), sortedPtrs.end());
|
||||
std::vector<std::string> scriptNames;
|
||||
auto cmdOff = script->mCmdsStart;
|
||||
auto cmdOff = ASSET_PTR(script->mCmdsStart);
|
||||
auto cmdIndex = 0;
|
||||
|
||||
if(IS_SEGMENTED(cmdOff)) {
|
||||
cmdOff = SEGMENT_OFFSET(cmdOff);
|
||||
}
|
||||
|
||||
for(int i = 0; i < sortedPtrs.size(); i++) {
|
||||
std::ostringstream scriptDefaultName;
|
||||
scriptDefaultName << symbol << "_cmds_" << std::uppercase << std::hex << cmdOff;
|
||||
@@ -75,13 +71,7 @@ ExportResult SF64::ScriptCodeExporter::Export(std::ostream &write, std::shared_p
|
||||
write << "\n";
|
||||
}
|
||||
|
||||
if (Companion::Instance->IsDebug()) {
|
||||
if (IS_SEGMENTED(offset)) {
|
||||
offset = SEGMENT_OFFSET(offset);
|
||||
}
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
write << "// 0x" << std::hex << std::uppercase << ASSET_PTR(offset) << "\n";
|
||||
write << "u16* " << symbol << "[] = {";
|
||||
for(int i = 0; i < script->mPtrs.size(); i++) {
|
||||
if((i % 5) == 0) {
|
||||
@@ -97,7 +87,7 @@ ExportResult SF64::ScriptCodeExporter::Export(std::ostream &write, std::shared_p
|
||||
|
||||
return OffsetEntry {
|
||||
script->mCmdsStart,
|
||||
static_cast<uint32_t>((IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + script->mPtrs.size() * sizeof(uint32_t))
|
||||
static_cast<uint32_t>(offset + script->mPtrs.size() * sizeof(uint32_t))
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user