Skip to content

Commit

Permalink
jak3: add missing files and implement pexcw (#3084)
Browse files Browse the repository at this point in the history
Some files were in the `banned_objects` list and were thus excluded from
the `all_objs` file.

Also implements the `pexcw` instruction which is only used in `hfrag`
code.
  • Loading branch information
Hat-Kid authored Oct 12, 2023
1 parent ce1c2eb commit 598ba1a
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 3 deletions.
4 changes: 3 additions & 1 deletion decompiler/Disasm/InstructionDecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,10 @@ static InstructionKind decode_mmi3(OpcodeFields fields) {
case 0b11011:
ASSERT(fields.rs() == 0);
return IK::PCPYH;
case 0b11110:
return IK::PEXCW;
default:
ASSERT(false);
ASSERT_MSG(false, fmt::format("unknown mmi3: 0b{:b}\n", fields.MMI_func()));
return IK::UNKNOWN;
}
}
Expand Down
4 changes: 4 additions & 0 deletions decompiler/Disasm/OpcodeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ void init_opcode_info() {
drd_srs_srt(def(IK::PXOR, "pxor").gpr128()); // Parallel Exclusive Or

def(IK::PEXEW, "pexew").gpr128().dst_gpr(FT::RD).src_gpr(FT::RT); // Parallel Exchange Even Word
def(IK::PEXCW, "pexcw")
.gpr128()
.dst_gpr(FT::RD)
.src_gpr(FT::RT); // Parallel Exchange Center Word

drd_srt_ssa(def(IK::PSLLW, "psllw").gpr128()); // Parallel Shift Left Logical Word
drd_srt_ssa(def(IK::PSLLH, "psllh").gpr128()); // Parallel Shift Left Logical Halfword
Expand Down
1 change: 1 addition & 0 deletions decompiler/Disasm/OpcodeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ enum class InstructionKind {
PNOR,
PCPYH,
PINTEH,
PEXCW,

// COP1 / FPU
ADDS,
Expand Down
1 change: 1 addition & 0 deletions decompiler/analysis/atomic_op_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ std::unique_ptr<AtomicOp> make_asm_op(const Instruction& i0, int idx) {
case InstructionKind::PMADDH:
case InstructionKind::PMULTH:
case InstructionKind::PEXEW:
case InstructionKind::PEXCW:
case InstructionKind::PNOR:
case InstructionKind::PCPYH:
case InstructionKind::PINTEH:
Expand Down
2 changes: 2 additions & 0 deletions decompiler/analysis/mips2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,8 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output,
return handle_generic_op2(i0, instr_str, "cvtsw");
case InstructionKind::PEXEW:
return handle_generic_op2(i0, instr_str, "pexew");
case InstructionKind::PEXCW:
return handle_generic_op2(i0, instr_str, "pexcw");
case InstructionKind::SQRTS:
return handle_generic_op2(i0, instr_str, "sqrts");
case InstructionKind::PLZCW:
Expand Down
2 changes: 1 addition & 1 deletion decompiler/config/jak3/jak3_config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// if you want to filter to only some object names.
// it will make the decompiler much faster.
"allowed_objects": [],
"banned_objects": ["script", "ragdoll-edit", "gun-states", "manipulator", "hfrag", "hfrag-vu1", "ff-squad-control"],
"banned_objects": [],

////////////////////////////
// CODE ANALYSIS OPTIONS
Expand Down
5 changes: 5 additions & 0 deletions decompiler/config/jak3/ntsc_v1/hacks.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
"adgif-shader<-texture!",

// jak 3
"command-get-process",
"(method 16 ragdoll-edit-info)",
"(anon-function 4 gun-states)",
"(method 10 manipulator)",
"(method 46 ff-squad-control)",
"borrow-city-expansion",
"(method 26 level-group)",
"(anon-function 65 temple-obs)",
Expand Down
8 changes: 8 additions & 0 deletions game/mips2c/mips2c_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,14 @@ struct ExecutionContext {
gprs[dst].du32[3] = s.du32[3];
}

void pexcw(int dst, int src) {
auto s = gpr_src(src);
gprs[dst].du32[0] = s.du32[0];
gprs[dst].du32[1] = s.du32[2];
gprs[dst].du32[2] = s.du32[1];
gprs[dst].du32[3] = s.du32[3];
}

void pcgtw(int rd, int rs, int rt) {
auto s = gpr_src(rs);
auto t = gpr_src(rt);
Expand Down
7 changes: 7 additions & 0 deletions goal_src/jak3/build/all_objs.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
["region", "region", 5, ["GAME"], "engine/level"],
["fma-sphere", "fma-sphere", 5, ["GAME"], "engine/anim"],
["prim-beam-h", "prim-beam-h", 5, ["GAME"], "engine/common-obs"],
["script", "script", 5, ["GAME"], "engine/util"],
["generic-obs", "generic-obs", 5, ["GAME"], "engine/common-obs"],
["lightning", "lightning", 5, ["GAME"], "engine/gfx/generic/lightning"],
["light-trails-h", "light-trails-h", 5, ["GAME"], "engine/gfx/sprite/particles"],
Expand Down Expand Up @@ -319,6 +320,7 @@
["task-arrow", "task-arrow", 5, ["GAME"], "engine/game/task"],
["projectile", "projectile", 5, ["GAME"], "engine/common-obs"],
["ragdoll", "ragdoll", 5, ["GAME"], "engine/physics"],
["ragdoll-edit", "ragdoll-edit", 5, ["GAME"], "engine/physics"],
["lightjak-wings", "lightjak-wings", 5, ["GAME"], "engine/target"],
["target-handler", "target-handler", 5, ["GAME"], "engine/target"],
["target-anim", "target-anim", 5, ["GAME"], "engine/target"],
Expand All @@ -336,6 +338,7 @@
["gun-yellow-shot", "gun-yellow-shot", 5, ["GAME"], "engine/target/gun"],
["gun-red-shot", "gun-red-shot", 5, ["GAME"], "engine/target/gun"],
["gun-dark-shot", "gun-dark-shot", 5, ["GAME"], "engine/target/gun"],
["gun-states", "gun-states", 5, ["GAME"], "engine/target/gun"],
["board-util", "board-util", 5, ["GAME"], "engine/target/board"],
["target-board", "target-board", 5, ["GAME"], "engine/target/board"],
["board-part", "board-part", 5, ["GAME"], "engine/target/board"],
Expand Down Expand Up @@ -393,6 +396,7 @@
["anim-tester", "anim-tester", 5, ["GAME"], "engine/debug"],
["viewer", "viewer", 5, ["GAME"], "engine/debug"],
["part-tester", "part-tester", 5, ["GAME"], "engine/debug"],
["manipulator", "manipulator", 5, ["GAME"], "engine/debug"],
["editable-h", "editable-h", 5, ["GAME"], "engine/debug"],
["editable", "editable", 5, ["GAME"], "engine/debug"],
["editable-player", "editable-player", 5, ["GAME"], "engine/debug"],
Expand Down Expand Up @@ -943,6 +947,8 @@
["towerb-vis", "towerb-vis", 5, ["TOWB"], "levels/tower"],
["hfrag-vu1-h", "hfrag-vu1-h", 5, ["HGA", "WIN", "DST"], "engine/gfx/background/hfrag"],
["hfrag-common", "hfrag-common", 5, ["HGA", "WIN", "DST"], "engine/gfx/background/hfrag"],
["hfrag-vu1", "hfrag-vu1", 5, ["HGA", "WIN", "DST"], "engine/gfx/background/hfrag"],
["hfrag", "hfrag", 5, ["HGA", "WIN", "DST"], "engine/gfx/background/hfrag"],
["hfrag-work", "hfrag-work", 5, ["HGA", "WIN", "DST"], "engine/gfx/background/hfrag"],
["hfrag-texture-anim", "hfrag-texture-anim", 5, ["HGA", "WIN", "DST"], "engine/gfx/background/hfrag"],
["desert-mood", "desert-mood", 5, ["HGA", "WIN", "DST"], "levels/desert"],
Expand Down Expand Up @@ -2409,6 +2415,7 @@
["mh-squad-member", "mh-squad-member", 5, ["CWI"], "levels/city/common"],
["metalhead-flitter", "metalhead-flitter", 5, ["CWI"], "levels/city/traffic/citizen"],
["kg-squad-control", "kg-squad-control", 5, ["CWI"], "levels/city/common"],
["ff-squad-control", "ff-squad-control", 5, ["CWI"], "levels/city/common"],
["mh-squad-control", "mh-squad-control", 5, ["CWI"], "levels/city/common"],
["cty-borrow-manager", "cty-borrow-manager", 5, ["CWI"], "levels/city/common"],
["ctywide-init", "ctywide-init", 5, ["CWI"], "levels/city/common"],
Expand Down
9 changes: 9 additions & 0 deletions goal_src/jak3/engine/debug/manipulator.gc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;;-*-Lisp-*-
(in-package goal)

;; name: manipulator.gc
;; name in dgo: manipulator
;; dgos: GAME

;; DECOMP BEGINS

9 changes: 9 additions & 0 deletions goal_src/jak3/engine/gfx/background/hfrag/hfrag-vu1.gc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;;-*-Lisp-*-
(in-package goal)

;; name: hfrag-vu1.gc
;; name in dgo: hfrag-vu1
;; dgos: HGA, WIN, DST

;; DECOMP BEGINS

9 changes: 9 additions & 0 deletions goal_src/jak3/engine/gfx/background/hfrag/hfrag.gc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;;-*-Lisp-*-
(in-package goal)

;; name: hfrag.gc
;; name in dgo: hfrag
;; dgos: HGA, WIN, DST

;; DECOMP BEGINS

9 changes: 9 additions & 0 deletions goal_src/jak3/engine/physics/ragdoll-edit.gc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;;-*-Lisp-*-
(in-package goal)

;; name: ragdoll-edit.gc
;; name in dgo: ragdoll-edit
;; dgos: GAME

;; DECOMP BEGINS

9 changes: 9 additions & 0 deletions goal_src/jak3/engine/target/gun/gun-states.gc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;;-*-Lisp-*-
(in-package goal)

;; name: gun-states.gc
;; name in dgo: gun-states
;; dgos: GAME

;; DECOMP BEGINS

9 changes: 9 additions & 0 deletions goal_src/jak3/engine/util/script.gc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;;-*-Lisp-*-
(in-package goal)

;; name: script.gc
;; name in dgo: script
;; dgos: GAME

;; DECOMP BEGINS

9 changes: 9 additions & 0 deletions goal_src/jak3/levels/city/common/ff-squad-control.gc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;;-*-Lisp-*-
(in-package goal)

;; name: ff-squad-control.gc
;; name in dgo: ff-squad-control
;; dgos: CWI

;; DECOMP BEGINS

6 changes: 5 additions & 1 deletion scripts/gsrc/skeleton_creation/init_folder_struct_jak3.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@
"light-trails": "gfx/sprite/particles",
"lightning-new": "gfx/generic/lightning",

"hfrag": "gfx/background/hfrag",
"hfrag-h": "gfx/background/hfrag",
"hfrag-vu1": "gfx/background/hfrag",
"hfrag-vu1-h": "gfx/background/hfrag",
"hfrag-common": "gfx/background/hfrag",
"hfrag-work": "gfx/background/hfrag",
Expand Down Expand Up @@ -376,7 +378,9 @@
"jak-pilot-hcar+0-ag": "engine/target",
"rapid-gunner": "levels/stadium",
"spydroid": "levels/common/enemy",
"credits": "levels/title"
"credits": "levels/title",
"ragdoll-edit": "engine/physics",
"manipulator": "engine/debug"
}

# i can be smarter than this...i swear....refactor eventually!
Expand Down

0 comments on commit 598ba1a

Please sign in to comment.