Skip to content

Commit

Permalink
wip vm 31
Browse files Browse the repository at this point in the history
  • Loading branch information
ate47 committed Jul 28, 2024
1 parent ceda311 commit 4e8ef94
Show file tree
Hide file tree
Showing 6 changed files with 453 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/acts/tools/gsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ void tool::gsc::GSCOBJHandler::DumpExperimental(std::ostream& asmout, const GscI
namespace {
#include "gsc_vm.hpp"
std::unordered_map<byte, std::function<std::shared_ptr<GSCOBJHandler>(byte*,size_t)>> gscReaders = {
{ VM_T831,[](byte* file, size_t fileSize) { return std::make_shared<T831GSCOBJHandler>(file, fileSize); }},
{ VM_T8,[](byte* file, size_t fileSize) { return std::make_shared<T8GSCOBJHandler>(file, fileSize); }},
{ VM_T937,[](byte* file, size_t fileSize) { return std::make_shared<T937GSCOBJHandler>(file, fileSize); }},
{ VM_T9,[](byte* file, size_t fileSize) { return std::make_shared<T9GSCOBJHandler>(file, fileSize); }},
Expand Down
32 changes: 32 additions & 0 deletions src/acts/tools/gsc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,38 @@ namespace tool::gsc {
char* CloneString(const char* str);
};

struct T831GSCOBJ {
byte magic[8];
uint32_t source_crc;
uint32_t include_offset;
uint32_t animtree_offset;
uint32_t cseg_offset;
uint32_t stringtablefixup_offset;
uint32_t devblock_stringtablefixup_offset;
uint32_t exports_offset;
uint32_t imports_offset;
uint32_t fixup_offset;
uint32_t globalvar_offset;
uint32_t profile_offset;
uint32_t cseg_size;
uint32_t name;
uint16_t stringtablefixup_count;
uint16_t exports_count;
uint16_t imports_count;
uint16_t fixup_count;
uint16_t globalvar_count;
uint16_t profile_count;
uint16_t devblock_stringtablefixup_count;
uint8_t include_count;
uint8_t animtree_count;
uint8_t flags;

// @return the vm
inline byte GetVm() {
return magic[7];
}
};

struct T8GSCOBJ {
byte magic[8];
int32_t crc;
Expand Down
28 changes: 26 additions & 2 deletions src/acts/tools/gsc_opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace {
}
namespace tool::gsc::opcode {
VM VMOf(const char* name) {
if (!_strcmpi("t8_35", name) || !_strcmpi("bo4_35", name) || !_strcmpi("blackops4_35", name) || !_strcmpi("35", name)) {
return VM_T835;
if (!_strcmpi("t8_31", name) || !_strcmpi("bo4_31", name) || !_strcmpi("blackops4_31", name) || !_strcmpi("31", name)) {
return VM_T831;
}
if (!_strcmpi("t8", name) || !_strcmpi("bo4", name) || !_strcmpi("blackops4", name) || !_strcmpi("36", name)) {
return VM_T8;
Expand Down Expand Up @@ -2923,6 +2923,29 @@ class OPCodeInfoDevOp : public OPCodeInfo {
}
};

class OPCodeInfoInvalidOpCode : public OPCodeInfo {
public:
OPCodeInfoInvalidOpCode() : OPCodeInfo(OPCODE_InvalidOpCode, "InvalidOpCode") {
}
using OPCodeInfo::OPCodeInfo;

int Dump(std::ostream& out, uint16_t value, ASMContext& context, tool::gsc::T8GSCOBJContext& objctx) const override {
out << "\n";
if (context.m_runDecompiler) {
ASMContextNodeMultOp* node = new ASMContextNodeMultOp("InvalidOpCode", false);

node->AddParam(new ASMContextNodeValue<uint16_t>(value, TYPE_VALUE, true));
// convert it to statement
context.PushASMCNode(node);
context.CompleteStatement();
}
return 0;
}
int Skip(uint16_t value, ASMSkipContext& ctx) const override {
return 0;
}
};

class OPCodeInfoProfileNamed : public OPCodeInfo {
bool m_push;
public:
Expand Down Expand Up @@ -4851,6 +4874,7 @@ namespace tool::gsc::opcode {
RegisterOpCodeHandler(new OPCodeInfoStatement(OPCODE_Unknowna, "Unknowna", "Unknowna()"));
RegisterOpCodeHandler(new OPCodeInfoStatement(OPCODE_Unknownb, "Unknownb", "Unknownb()"));
RegisterOpCodeHandler(new OPCodeInfoStatement(OPCODE_Nop, "Nop", "Nop()"));
RegisterOpCodeHandler(new OPCodeInfoInvalidOpCode());
RegisterOpCodeHandler(new OPCodeInfoDevOp(false));
RegisterOpCodeHandler(new OPCodeInfoStatement(OPCODE_Unknown38, "Unknown38", "operator_Unknown38()"));

Expand Down
Loading

0 comments on commit 4e8ef94

Please sign in to comment.