From a572587a0ebf9bccf67e8f7df445b10126d47729 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sat, 5 Jun 2021 16:58:32 -0400 Subject: [PATCH] add types (#559) --- decompiler/IR2/AtomicOpTypeAnalysis.cpp | 16 + decompiler/IR2/Form.cpp | 2 + decompiler/IR2/FormExpressionAnalysis.cpp | 53 ++- decompiler/IR2/GenericElementMatcher.cpp | 14 + decompiler/IR2/GenericElementMatcher.h | 4 +- decompiler/IR2/IR2_common.h | 1 + decompiler/IR2/bitfields.cpp | 15 + decompiler/config/all-types.gc | 187 ++++++--- .../jak1_ntsc_black_label/label_types.jsonc | 8 + .../stack_structures.jsonc | 30 ++ .../jak1_ntsc_black_label/type_casts.jsonc | 27 +- .../jak1_ntsc_black_label/var_names.jsonc | 47 ++- game/kernel/kscheme.cpp | 1 - goal_src/engine/anim/mspace-h.gc | 2 +- goal_src/engine/game/game-h.gc | 2 +- goal_src/engine/level/level-h.gc | 1 + goal_src/kernel/gcommon.gc | 11 +- goal_src/kernel/gkernel-h.gc | 12 + goalc/compiler/compilation/Static.cpp | 2 +- .../reference/all_forward_declarations.gc | 76 ---- .../anim/{aligner-h.gc => aligner-h_REF.gc} | 2 +- .../reference/engine/anim/mspace-h_REF.gc | 11 +- .../reference/engine/debug/debug-h_REF.gc | 74 ++++ .../reference/engine/debug/stats-h_REF.gc | 6 +- .../reference/engine/dma/dma-buffer_REF.gc | 2 +- .../reference/engine/entity/entity-h_REF.gc | 10 +- .../reference/engine/game/game-h_REF.gc | 193 ++++++++++ .../engine/game/generic-obs-h_REF.gc | 356 ++++++++++++++++++ .../reference/engine/gfx/merc/merc-h_REF.gc | 2 +- .../reference/engine/gfx/texture-h_REF.gc | 3 +- .../reference/engine/math/vector-h_REF.gc | 4 +- .../reference/kernel/gcommon_REF.gc | 7 +- 32 files changed, 994 insertions(+), 187 deletions(-) rename test/decompiler/reference/engine/anim/{aligner-h.gc => aligner-h_REF.gc} (97%) create mode 100644 test/decompiler/reference/engine/debug/debug-h_REF.gc create mode 100644 test/decompiler/reference/engine/game/game-h_REF.gc create mode 100644 test/decompiler/reference/engine/game/generic-obs-h_REF.gc diff --git a/decompiler/IR2/AtomicOpTypeAnalysis.cpp b/decompiler/IR2/AtomicOpTypeAnalysis.cpp index 64f53d7b10..faa24a35bd 100644 --- a/decompiler/IR2/AtomicOpTypeAnalysis.cpp +++ b/decompiler/IR2/AtomicOpTypeAnalysis.cpp @@ -474,6 +474,22 @@ TP_Type SimpleExpression::get_type_int2(const TypeState& input, } } + // access with just product and no offset. + if (m_kind == Kind::ADD && arg0_type.kind == TP_Type::Kind::TYPESPEC && + arg0_type.typespec().base_type() == "inline-array" && + arg1_type.kind == TP_Type::Kind::PRODUCT_WITH_CONSTANT) { + FieldReverseLookupInput rd_in; + rd_in.deref = std::nullopt; + rd_in.stride = arg1_type.get_multiplier(); + rd_in.offset = 0; + rd_in.base_type = arg0_type.typespec(); + auto rd = dts.ts.reverse_field_lookup(rd_in); + + if (rd.success) { + return TP_Type::make_from_ts(coerce_to_reg_type(rd.result_type)); + } + } + if (m_kind == Kind::ADD && arg0_type.is_product() && arg1_type.kind == TP_Type::Kind::TYPESPEC) { return TP_Type::make_object_plus_product(arg1_type.typespec(), arg0_type.get_multiplier()); } diff --git a/decompiler/IR2/Form.cpp b/decompiler/IR2/Form.cpp index 917fb351ee..2c5306afef 100644 --- a/decompiler/IR2/Form.cpp +++ b/decompiler/IR2/Form.cpp @@ -1540,6 +1540,8 @@ std::string fixed_operator_to_string(FixedOperatorKind kind) { return "symbol->string"; case FixedOperatorKind::ADDRESS_OF: return "&"; + case FixedOperatorKind::ASM_SLLV_R0: + return ".asm.sllv.r0"; default: assert(false); return ""; diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 304fdf279a..5ac7b5f2f2 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -638,6 +638,9 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, return; } + auto addition_matcher = + GenericOpMatcher::or_match({GenericOpMatcher::fixed(FixedOperatorKind::ADDITION), + GenericOpMatcher::fixed(FixedOperatorKind::ADDITION_PTR)}); if (arg0_type.kind == TP_Type::Kind::INTEGER_CONSTANT_PLUS_VAR) { // try to see if this is valid, from the type system. FieldReverseLookupInput input; @@ -648,8 +651,9 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, if (out.success) { // it is. now we have to modify things // first, look for the index - auto arg0_matcher = Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ADDITION), - {Matcher::any(0), Matcher::integer(input.offset)}); + + auto arg0_matcher = + Matcher::op(addition_matcher, {Matcher::any(0), Matcher::integer(input.offset)}); auto match_result = match(arg0_matcher, args.at(0)); if (match_result.matched) { bool used_index = false; @@ -683,7 +687,7 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, if (is_power_of_two(input.stride, &p2)) { // (+ (shl (-> a0-0 reg-count) 3) 28) auto arg0_matcher = - Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ADDITION), + Matcher::op(addition_matcher, {Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::MULTIPLICATION), {Matcher::any(0), Matcher::integer(input.stride)}), Matcher::integer(input.offset)}); @@ -709,7 +713,7 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, } } else { auto arg0_matcher = - Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ADDITION), + Matcher::op(addition_matcher, {Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::MULTIPLICATION), {Matcher::integer(input.stride), Matcher::any(0)}), Matcher::integer(input.offset)}); @@ -735,6 +739,38 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, } } } + } else if (arg1_type.kind == TP_Type::Kind::PRODUCT_WITH_CONSTANT && + arg0_type.kind == TP_Type::Kind::TYPESPEC && + arg0_type.typespec().base_type() == "inline-array") { + FieldReverseLookupInput rd_in; + rd_in.deref = std::nullopt; + rd_in.stride = arg1_type.get_multiplier(); + rd_in.offset = 0; + rd_in.base_type = arg0_type.typespec(); + auto rd = env.dts->ts.reverse_field_lookup(rd_in); + + if (rd.success) { + auto arg1_matcher = Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::MULTIPLICATION), + {Matcher::any(0), Matcher::integer(rd_in.stride)}); + auto match_result = match(arg1_matcher, args.at(1)); + if (match_result.matched) { + bool used_index = false; + std::vector tokens; + for (auto& tok : rd.tokens) { + if (tok.kind == FieldReverseLookupOutput::Token::Kind::VAR_IDX) { + assert(!used_index); + used_index = true; + tokens.push_back(DerefToken::make_int_expr(match_result.maps.forms.at(0))); + } else { + tokens.push_back(to_token(tok)); + } + } + result->push_back(pool.alloc_element(args.at(0), rd.addr_of, tokens)); + return; + } else { + throw std::runtime_error("Failed to match product_with_constant inline array access."); + } + } } } @@ -2991,13 +3027,20 @@ void push_asm_sllv_to_stack(const AsmOp* op, auto src_var = pop_to_forms({*var}, env, pool, stack, true).at(0); auto as_ba = src_var->try_as_element(); if (as_ba) { + // part of existing chain. BitfieldManip step(BitfieldManip::Kind::SLLV_SEXT, 0); auto other = as_ba->push_step(step, env.dts->ts, pool, env); assert(other); // should immediately get a field. stack.push_value_to_reg(*dst, pool.alloc_single_form(nullptr, other), true, env.get_variable_type(*dst, true)); } else { - throw std::runtime_error("Got invalid bitfield manip for sllv"); + // push it to a weird looking form for initial bitfield setting. + // these are lazily converted at the destination. + stack.push_value_to_reg( + *dst, + pool.alloc_single_element_form( + nullptr, GenericOperator::make_fixed(FixedOperatorKind::ASM_SLLV_R0), src_var), + true, env.get_variable_type(*dst, true)); } } } else { diff --git a/decompiler/IR2/GenericElementMatcher.cpp b/decompiler/IR2/GenericElementMatcher.cpp index bd95ed1262..f8251e2bff 100644 --- a/decompiler/IR2/GenericElementMatcher.cpp +++ b/decompiler/IR2/GenericElementMatcher.cpp @@ -606,6 +606,13 @@ GenericOpMatcher GenericOpMatcher::condition(IR2_Condition::Kind condition) { return m; } +GenericOpMatcher GenericOpMatcher::or_match(const std::vector& matchers) { + GenericOpMatcher m; + m.m_kind = Kind::OR; + m.m_sub_matchers = matchers; + return m; +} + bool GenericOpMatcher::do_match(GenericOperator& input, MatchResult::Maps* maps_out) const { switch (m_kind) { case Kind::FIXED: @@ -623,6 +630,13 @@ bool GenericOpMatcher::do_match(GenericOperator& input, MatchResult::Maps* maps_ return input.condition_kind() == m_condition_kind; } return false; + case Kind::OR: + for (auto& m : m_sub_matchers) { + if (m.do_match(input, maps_out)) { + return true; + } + } + return false; default: assert(false); return false; diff --git a/decompiler/IR2/GenericElementMatcher.h b/decompiler/IR2/GenericElementMatcher.h index 6ddfe10298..be1ecd65c5 100644 --- a/decompiler/IR2/GenericElementMatcher.h +++ b/decompiler/IR2/GenericElementMatcher.h @@ -114,8 +114,9 @@ class GenericOpMatcher { static GenericOpMatcher fixed(FixedOperatorKind kind); static GenericOpMatcher func(const Matcher& func_matcher); static GenericOpMatcher condition(IR2_Condition::Kind condition); + static GenericOpMatcher or_match(const std::vector& matchers); - enum class Kind { FIXED, FUNC, CONDITION, INVALID }; + enum class Kind { FIXED, FUNC, CONDITION, OR, INVALID }; bool do_match(GenericOperator& input, MatchResult::Maps* maps_out) const; @@ -123,6 +124,7 @@ class GenericOpMatcher { Kind m_kind = Kind::INVALID; FixedOperatorKind m_fixed_kind = FixedOperatorKind::INVALID; IR2_Condition::Kind m_condition_kind = IR2_Condition::Kind::INVALID; + std::vector m_sub_matchers; Matcher m_func_matcher; }; diff --git a/decompiler/IR2/IR2_common.h b/decompiler/IR2/IR2_common.h index db5662b03d..5c41b53860 100644 --- a/decompiler/IR2/IR2_common.h +++ b/decompiler/IR2/IR2_common.h @@ -146,6 +146,7 @@ enum class FixedOperatorKind { PCPYLD, SYMBOL_TO_STRING, ADDRESS_OF, + ASM_SLLV_R0, INVALID }; diff --git a/decompiler/IR2/bitfields.cpp b/decompiler/IR2/bitfields.cpp index 26c744c337..9587f93fe7 100644 --- a/decompiler/IR2/bitfields.cpp +++ b/decompiler/IR2/bitfields.cpp @@ -289,6 +289,21 @@ std::optional get_bitfield_initial_set(Form* form, return def; } + auto matcher_sllv = + Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ASM_SLLV_R0), {Matcher::any(0)}); + auto mr_sllv = match(matcher_sllv, strip_int_or_uint_cast(form)); + if (mr_sllv.matched) { + auto value = mr_sllv.maps.forms.at(0); + int size = 32; + int offset = 0; + auto& f = find_field(ts, type, offset, size, {}); + BitFieldDef def; + def.value = value; + def.field_name = f.name(); + def.is_signed = false; + return def; + } + return {}; } diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 3aa83955da..88ff072e01 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -28,8 +28,9 @@ (deftype inline-array-class (basic) ((length int32 :offset-assert 4) (allocated-length int32 :offset-assert 8) - (data uint8 :dynamic :offset-assert 12) ;; might not be here... - (_pad uint8 4) ;; ??? + ;; this is 16-byte aligned. + ;; children of inline-array-class should define their own data which overlays this one. + (_data uint8 :dynamic :offset 16) ) (:methods (new (symbol type int) _type_ 0)) :method-count-assert 9 @@ -493,6 +494,45 @@ (invalid 666) ) +(defenum bucket-id + :type uint32 + :bitfield #f + + (tfrag-tex0 5) + ;; merc0 10 + ;; generic0 11 + + (tfrag-tex1 12) + ;; merc1 17 + ;; generic1 18 + + (shrub-tex0 19) + + (shrub-tex1 25) + + (alpha-tex0 31) + + (alpha-tex1 38) + + (pris-tex0 48) + ;; merc0 49 + ;; generic0 50 + + (pris-tex1 51) + ;; merc1 52 + ;; generic1 53 + + (water-tex0 57) + ;; merc0 58 (+ default) + ;; generic0 59 (+ default) + + (water-tex1 60) + ;; merc1 61 + ;; generic1 62 + ;; debug text 68 + (debug-draw 68) + ) + (define-extern sinteger type) (define-extern wheel type) @@ -5326,7 +5366,9 @@ ) (deftype cspace-array (inline-array-class) - () + ( + (data cspace :inline :dynamic :offset-assert 16) + ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 @@ -9271,7 +9313,7 @@ (deftype process-drawable (process) ((root trsqv :offset-assert 112) - (node-list basic :offset-assert 116) + (node-list cspace-array :offset-assert 116) (draw draw-control :offset-assert 120) (skel basic :offset-assert 124) (nav basic :offset-assert 128) @@ -9392,9 +9434,9 @@ ) -;; - Unknowns +;; - Symbols -;;(define-extern *global-attack-id* object) ;; unknown type +(define-extern *global-attack-id* int) ;; ---------------------- @@ -9902,45 +9944,61 @@ ;; Containing DGOs - ['GAME', 'ENGINE'] ;; Version - 3 +;; - Enums + +(defenum joint-mod-handler-mode + :bitfield #t + :type uint32 + (flex-blend 0) ;; 1 + (look-at 1) ;; 2 + (world-look-at 2) ;; 4 + (rotate 3) ;; 8 + (joint-set 4) ;; 16 + (joint-set* 5) ;; 32 + ;; ?? ;; 64 + (reset 7) ;; 128 + ) + ;; - Types (deftype joint-mod (basic) - ((mode uint32 :offset-assert 4) - (process basic :offset-assert 8) - (joint cspace :offset-assert 12) - (target vector :inline :offset-assert 16) - (twist vector :inline :offset-assert 32) - (twist-max vector :inline :offset-assert 48) - (trans vector :inline :offset-assert 64) - (quat quaternion :inline :offset-assert 80) - (scale vector :inline :offset-assert 96) - (notice-time uint64 :offset-assert 112) - (flex-blend float :offset-assert 120) - (blend float :offset-assert 124) - (max-dist float :offset-assert 128) ;; meters - (ignore-angle float :offset-assert 132) ;; deg - (up uint8 :offset-assert 136) - (nose uint8 :offset-assert 137) - (ear uint8 :offset-assert 138) - (shutting-down? basic :offset-assert 140) - (parented-scale? basic :offset 128) + ((mode joint-mod-handler-mode :offset-assert 4) + (process process-drawable :offset-assert 8) + (joint cspace :offset-assert 12) + (target vector :inline :offset-assert 16) + (twist vector :inline :offset-assert 32) + (twist-max vector :inline :offset-assert 48) + (trans vector :inline :offset-assert 64) + (quat quaternion :inline :offset-assert 80) + (scale vector :inline :offset-assert 96) + (notice-time uint64 :offset-assert 112) + (flex-blend float :offset-assert 120) + (blend float :offset-assert 124) + (max-dist float :offset-assert 128) ;; meters + (ignore-angle float :offset-assert 132) ;; deg + (up uint8 :offset-assert 136) + (nose uint8 :offset-assert 137) + (ear uint8 :offset-assert 138) + (shutting-down? basic :offset-assert 140) + (parented-scale? basic :offset 128) ) :method-count-assert 16 :size-assert #x90 :flag-assert #x1000000090 (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 () none 13) - (dummy-14 () none 14) - (dummy-15 () none 15) + (new (symbol type joint-mod-handler-mode process-drawable int) _type_ 0) + (set-mode! (_type_ joint-mod-handler-mode) _type_ 9) + (set-target! (_type_ vector) none 10) + (look-at-enemy! (_type_ vector symbol process) none 11) + (reset-blend! (_type_) _type_ 12) + (set-twist! (_type_ float float float) vector 13) + (set-trs! (_type_ vector quaternion vector) none 14) + (shut-down! (_type_) float 15) ) ) (deftype try-to-look-at-info (basic) - ((who uint64 :offset-assert 8) + ((who handle :offset-assert 8) (horz float :offset-assert 16) (vert float :offset-assert 20) ) @@ -9950,12 +10008,15 @@ ) (deftype joint-mod-wheel (basic) - ((last-position vector :inline :offset-assert 16) - (angle float :offset-assert 32) - (process basic :offset-assert 36) - (wheel-radius float :offset-assert 40) - (wheel-axis int8 :offset-assert 44) + ((last-position vector :inline :offset-assert 16) + (angle float :offset-assert 32) + (process process-drawable :offset-assert 36) + (wheel-radius float :offset-assert 40) + (wheel-axis int8 :offset-assert 44) ) + (:methods + (new (symbol type process-drawable int float int) _type_) + ) :method-count-assert 9 :size-assert #x2d :flag-assert #x90000002d @@ -9968,6 +10029,9 @@ (set-translation basic :offset-assert 72) (enable basic :offset-assert 76) ) + (:methods + (new (symbol type process-drawable int basic basic basic) _type_) + ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 @@ -9978,6 +10042,9 @@ (node-index int32 :offset-assert 64) (enable basic :offset-assert 68) ) + (:methods + (new (symbol type process-drawable int basic) _type_) + ) :method-count-assert 9 :size-assert #x48 :flag-assert #x900000048 @@ -9990,6 +10057,9 @@ (blend float :offset-assert 116) (enable basic :offset-assert 120) ) + (:methods + (new (symbol type process-drawable int basic) _type_) + ) :method-count-assert 9 :size-assert #x7c :flag-assert #x90000007c @@ -10001,6 +10071,9 @@ (spin-rate float :offset-assert 36) (enable basic :offset-assert 40) ) + (:methods + (new (symbol type process-drawable int vector float) _type_) + ) :method-count-assert 9 :size-assert #x2c :flag-assert #x90000002c @@ -10008,32 +10081,30 @@ ;; - Functions -(define-extern joint-mod-blend-local-callback (function joint-mod-blend-local vector none)) ;; first arg is something WITh a joint-mod, no idea yet! -(define-extern joint-mod-look-at-handler (function cspace none)) ;; TODO +(define-extern joint-mod-blend-local-callback (function cspace transformq none)) +(define-extern joint-mod-look-at-handler (function cspace transformq none)) +(define-extern joint-mod-world-look-at-handler (function cspace transformq none)) +(define-extern joint-mod-rotate-handler (function cspace transformq none)) +(define-extern joint-mod-joint-set-handler (function cspace transformq none)) +(define-extern joint-mod-joint-set*-handler (function cspace transformq none)) +(define-extern joint-mod-wheel-callback (function cspace transformq none)) +(define-extern joint-mod-set-local-callback (function cspace transformq none)) +(define-extern joint-mod-set-world-callback (function cspace transformq none)) +(define-extern joint-mod-spinner-callback (function cspace transformq none)) ;; - Symbols +(define-extern cspace<-parented-transformq-joint! (function cspace transformq none)) +(define-extern cspace<-transformq! (function cspace transformq matrix)) +(define-extern vector<-cspace! (function vector cspace vector)) +(define-extern add-debug-text-sphere (function symbol bucket-id vector float string rgba none)) -(define-extern joint-mod-spinner-callback function) -(define-extern cspace<-parented-transformq-joint! function) -(define-extern joint-mod-set-world-callback function) -(define-extern cspace<-transformq! function) -(define-extern joint-mod-set-local-callback function) -(define-extern joint-mod-wheel-callback function) -(define-extern vector<-cspace! function) -(define-extern add-debug-text-sphere function) -(define-extern joint-mod-world-look-at-handler function) -(define-extern joint-mod-rotate-handler function) -(define-extern joint-mod-joint-set-handler function) -(define-extern joint-mod-joint-set*-handler function) -(define-extern add-debug-matrix function) -(define-extern joint-mod-debug-draw function) +(define-extern add-debug-matrix (function symbol bucket-id matrix none)) +(define-extern joint-mod-debug-draw (function joint-mod none)) +(define-extern last-try-to-look-at-data try-to-look-at-info) +(define-extern *joint-axis-vectors* (inline-array vector)) ;; - Unknowns -;;(define-extern *joint-axis-vectors* object) ;; unknown type -;;(define-extern last-try-to-look-at-data object) ;; unknown type - - ;; ---------------------- ;; File - collide-func-h ;; Source Path - engine/collide/collide-func-h.gc diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index 5a2a693c32..d0eb40442a 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -478,5 +478,13 @@ "actor-link-h": [ ["L79", "float", true] + ], + + "joint-mod-h": [ + ["L100", "float", true], + ["L93", "float", true], + ["L103", "rgba", true], + ["L89", "(inline-array vector)", true, 6], + ["L90", "(inline-array vector)", true, 3] ] } diff --git a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc index 2bce771f31..3f43365923 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -262,5 +262,35 @@ "(method 10 cam-vector-seeker)": [ [16, "vector"] + ], + + "joint-mod-look-at-handler": [ + [16, "vector"], + [32, "vector"], + [64, "vector"], + [80, "vector"], + [96, "vector"] + ], + + "joint-mod-world-look-at-handler": [ + [16, "vector"], + [32, "vector"], + [64, "vector"], + [80, "matrix"], + [144, "vector"], + [160, "vector"], + [176, "matrix"] + ], + + "joint-mod-rotate-handler": [ + [16, "quaternion"], + [32, "quaternion"], + [48, "quaternion"] + ], + + "joint-mod-wheel-callback": [ + [16, "vector"], + [32, "vector"], + [48, "vector"] ] } diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 211fc903c3..e8452dc768 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -397,7 +397,7 @@ // FACT-H "(method 0 fact-info-enemy)": [ - [[3,92], "gp", "fact-info-enemy"], + [[3, 92], "gp", "fact-info-enemy"], [16, "v0", "float"], [28, "v0", "float"], [40, "v0", "float"], @@ -415,7 +415,7 @@ [86, "gp", "fact-info"] ], - "(method 0 fact-info-target)": [[[3,20], "gp", "fact-info-target"]], + "(method 0 fact-info-target)": [[[3, 20], "gp", "fact-info-target"]], "(method 0 align-control)": [ [[8, 13], "t9", "(function object object)"], @@ -465,5 +465,26 @@ "camera-teleport-to-entity": [[9, "a0", "transform"]], - "entity-actor-count": [["_stack_", 16, "res-tag"]] + "entity-actor-count": [["_stack_", 16, "res-tag"]], + + "(method 11 joint-mod)": [ + [15, "s3", "process-drawable"], + [[26, 66], "s3", "fact-info-enemy"], + [46, "v1", "(pointer process)"] + ], + + "joint-mod-look-at-handler": [[[2, 254], "gp", "joint-mod"]], + + "joint-mod-world-look-at-handler": [[[0, 254], "gp", "joint-mod"]], + + "joint-mod-rotate-handler": [[[2, 77], "s4", "joint-mod"]], + + "joint-mod-joint-set-handler": [[[2, 13], "s4", "joint-mod"]], + + "joint-mod-joint-set*-handler": [[[2, 31], "s5", "joint-mod"]], + "joint-mod-wheel-callback": [[[2, 63], "s4", "joint-mod-wheel"]], + "joint-mod-set-local-callback": [[[0, 23], "v1", "joint-mod-set-local"]], + "joint-mod-set-world-callback": [[[0, 23], "v1", "joint-mod-set-world"]], + "joint-mod-blend-local-callback": [[[2, 63], "gp", "joint-mod-blend-local"]], + "joint-mod-spinner-callback": [[[2, 63], "gp", "joint-mod-spinner"]] } diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index 4031c23240..48f9873ad5 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -1660,12 +1660,12 @@ }, "(method 0 fact-info)": { - "args":["allocation", "type-to-make", "proc", "pkup-type", "pkup-amount"], + "args": ["allocation", "type-to-make", "proc", "pkup-type", "pkup-amount"], "vars": { - "gp-0":["obj", "fact-info"], - "s5-0":"ent", - "sv-16":"tag", - "t9-1":["go-func", "(function string none)"] + "gp-0": ["obj", "fact-info"], + "s5-0": "ent", + "sv-16": "tag", + "t9-1": ["go-func", "(function string none)"] } }, @@ -1773,8 +1773,39 @@ "entity-actor-count": { "args": ["res", "name"], - "vars":{ - "sv-16":"tag" + "vars": { + "sv-16": "tag" } - } + }, + + "(method 0 joint-mod)": { + "args": ["allocation", "type-to-make", "mode", "proc", "joint-idx"], + "vars": { + "gp-0": "obj", + "v1-7": "twist-max" + } + }, + + "joint-mod-debug-draw": { + "args":["mod"] + }, + + "(method 9 joint-mod)": { + "args":["obj", "handler-mode"], + "vars":{"v1-0":"joint", "a0-1":"mode"} + }, + + "(method 10 joint-mod)": { + "args":["obj", "target-trans"], + "vars":{"f0-0":"distance"} + }, + + "(method 13 joint-mod)": { "args": ["obj", "x", "y", "z"] }, + "(method 14 joint-mod)": { "args": ["obj", "trans", "rot", "scale"] }, + "(method 11 joint-mod)": { + "args": ["obj", "target-trans", "option", "proc"], + "vars": { "s1-0": "proc-drawable", "s3-1": "enemy-facts", "f30-0": "dist" } + }, + + "joint-mod-look-at-handler": { "args": ["csp", "xform", "mat"] } } diff --git a/game/kernel/kscheme.cpp b/game/kernel/kscheme.cpp index d2f8aa42f0..d93e4e30b4 100644 --- a/game/kernel/kscheme.cpp +++ b/game/kernel/kscheme.cpp @@ -1136,7 +1136,6 @@ u64 call_method_of_type(u32 arg, Ptr type, u32 method_id) { } } printf("[ERROR] call_method_of_type failed!\n"); - assert(false); return arg; } diff --git a/goal_src/engine/anim/mspace-h.gc b/goal_src/engine/anim/mspace-h.gc index 47b10fee7e..3b80b7d4fe 100644 --- a/goal_src/engine/anim/mspace-h.gc +++ b/goal_src/engine/anim/mspace-h.gc @@ -66,7 +66,7 @@ ) (deftype cspace-array (inline-array-class) - () + ((data cspace :inline :dynamic :offset-assert 16)) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 diff --git a/goal_src/engine/game/game-h.gc b/goal_src/engine/game/game-h.gc index 9006972240..56b305adff 100644 --- a/goal_src/engine/game/game-h.gc +++ b/goal_src/engine/game/game-h.gc @@ -8,7 +8,7 @@ (deftype process-drawable (process) ((root trsqv :offset-assert 112) - (node-list basic :offset-assert 116) + (node-list cspace-array :offset-assert 116) (draw draw-control :offset-assert 120) (skel basic :offset-assert 124) (nav basic :offset-assert 128) diff --git a/goal_src/engine/level/level-h.gc b/goal_src/engine/level/level-h.gc index ebf6221901..344ca9fdf5 100644 --- a/goal_src/engine/level/level-h.gc +++ b/goal_src/engine/level/level-h.gc @@ -41,6 +41,7 @@ ;; merc1 61 ;; generic1 62 ;; debug text 68 + (debug-draw 68) ) ;; Information related to visibility data for a level. diff --git a/goal_src/kernel/gcommon.gc b/goal_src/kernel/gcommon.gc index 67c8e1b011..a3f6131324 100644 --- a/goal_src/kernel/gcommon.gc +++ b/goal_src/kernel/gcommon.gc @@ -666,8 +666,9 @@ (deftype inline-array-class (basic) ((length int32 :offset-assert 4) (allocated-length int32 :offset-assert 8) - (data uint8 :dynamic :offset-assert 12) ;; might not be here... - (_pad uint8 4) ;; ??? + ;; this is 16-byte aligned. + ;; children of inline-array-class should define their own data which overlays this one. + (_data uint8 :dynamic :offset 16) ) (:methods (new (symbol type int) _type_ 0)) @@ -1423,3 +1424,9 @@ (the-as uint result) ) ) + +(defmacro as-type (obj type) + `(if (and (nonzero? ,obj) (type-type? (-> ,obj type) ,type)) + (the-as ,type ,obj) + ) + ) diff --git a/goal_src/kernel/gkernel-h.gc b/goal_src/kernel/gkernel-h.gc index 106f74ec17..8c33013bdf 100644 --- a/goal_src/kernel/gkernel-h.gc +++ b/goal_src/kernel/gkernel-h.gc @@ -414,6 +414,18 @@ ) ) +(defmacro process->ppointer (proc) + `(if ,proc (the (pointer process) (-> ,proc ppointer))) + ) + +(defmacro ppointer->handle (pproc) + `(new 'static 'handle :process ,pproc :pid (-> ,pproc 0 pid)) + ) + +(defmacro process->handle (proc) + `(ppointer->handle (process->ppointer ,proc)) + ) + (defmethod print handle ((obj handle)) ;; the get-process-from-handle macro can't deal with ;; a 0 in the process field, so we check it manually here. diff --git a/goalc/compiler/compilation/Static.cpp b/goalc/compiler/compilation/Static.cpp index 495772c1b5..a4d7e6cf13 100644 --- a/goalc/compiler/compilation/Static.cpp +++ b/goalc/compiler/compilation/Static.cpp @@ -308,7 +308,7 @@ Val* Compiler::compile_bitfield_definition(const goos::Object& form, auto field_size = field_info.size; assert(field_offset + field_size <= type_info->get_load_size() * 8); - if (is_integer(field_info.result_type)) { + if (is_integer(field_info.result_type) || field_info.result_type.base_type() == "pointer") { // first, try as a constant s64 value = 0; if (!try_getting_constant_integer(field_value, &value, env)) { diff --git a/test/decompiler/reference/all_forward_declarations.gc b/test/decompiler/reference/all_forward_declarations.gc index ce4de107fd..68c6a62b52 100644 --- a/test/decompiler/reference/all_forward_declarations.gc +++ b/test/decompiler/reference/all_forward_declarations.gc @@ -438,37 +438,6 @@ ;; game-h - TODO (declare-type trsqv basic) (declare-type draw-control basic) -(deftype process-drawable (process) - ((root trsqv :offset-assert 112) - (node-list basic :offset-assert 116) - (draw draw-control :offset-assert 120) - (skel basic :offset-assert 124) - (nav basic :offset-assert 128) - (align basic :offset-assert 132) - (path basic :offset-assert 136) - (vol basic :offset-assert 140) - (fact basic :offset-assert 144) - (link basic :offset-assert 148) - (part basic :offset-assert 152) - (water basic :offset-assert 156) - (sound basic :offset-assert 160) - (state-flags uint32 :offset-assert 164) - (state-time uint64 :offset-assert 168) - ) - :heap-base #x40 - :method-count-assert 20 - :size-assert #xb0 - :flag-assert #x14004000b0 - ;; inherited inspect of process - (:methods - (dummy-14 () none 14) - (dummy-15 () none 15) - (dummy-16 () none 16) - (dummy-17 () none 17) - (dummy-18 () none 18) - (dummy-19 () none 19) - ) - ) ;; game-h - TODO (deftype vector (structure) @@ -495,32 +464,6 @@ :flag-assert #x900000010 ) -(deftype attack-info (structure) - ((trans vector :inline :offset-assert 0) - (vector vector :inline :offset-assert 16) - (intersection vector :inline :offset-assert 32) - (attacker uint64 :offset-assert 48) ;; handle - (invinc-time uint64 :offset-assert 56) - (mask uint32 :offset-assert 64) - (mode basic :offset-assert 68) - (shove-back float :offset-assert 72) ;; meters - (shove-up float :offset-assert 76) ;; meters - (speed float :offset-assert 80) ;; meters - (dist float :offset-assert 84) ;; meters - (control float :offset-assert 88) - (angle basic :offset-assert 92) - (rotate-to float :offset-assert 96) ;; deg - (prev-state basic :offset-assert 100) - ) - :method-count-assert 10 - :size-assert #x68 - :flag-assert #xa00000068 - ;; field handle is likely a value type - (:methods - (dummy-9 () none 9) - ) - ) - ;; definition of type quaternion (deftype quaternion (structure) ((x float :offset-assert 0) @@ -678,25 +621,6 @@ `(-> (the-as (pointer string) (+ SYM_TO_STRING_OFFSET (the-as int ,sym)))) ) -;; TODO - from generic-obs-h -(deftype gui-query (structure) - ((x-position int32 :offset-assert 0) - (y-position int32 :offset-assert 4) - (message basic :offset-assert 8) - (decision basic :offset-assert 12) - (only-allow-cancel basic :offset-assert 16) - (no-msg basic :offset-assert 20) - (message-space int32 :offset-assert 24) - ) - :pack-me - :method-count-assert 11 - :size-assert #x1c - :flag-assert #xb0000001c - (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) - ) - ) (defmacro new-stack-matrix0 () "Get a new matrix on the stack that's set to zero." diff --git a/test/decompiler/reference/engine/anim/aligner-h.gc b/test/decompiler/reference/engine/anim/aligner-h_REF.gc similarity index 97% rename from test/decompiler/reference/engine/anim/aligner-h.gc rename to test/decompiler/reference/engine/anim/aligner-h_REF.gc index df74b8abdb..56162b1d7c 100644 --- a/test/decompiler/reference/engine/anim/aligner-h.gc +++ b/test/decompiler/reference/engine/anim/aligner-h_REF.gc @@ -4,7 +4,7 @@ ;; definition of type align-control (deftype align-control (basic) ((flags uint32 :offset-assert 4) - (process basic :offset-assert 8) + (process process :offset-assert 8) (frame-group basic :offset-assert 12) (frame-num float :offset-assert 16) (matrix matrix 2 :inline :offset-assert 32) diff --git a/test/decompiler/reference/engine/anim/mspace-h_REF.gc b/test/decompiler/reference/engine/anim/mspace-h_REF.gc index 734f74d5dd..8aaeff8892 100644 --- a/test/decompiler/reference/engine/anim/mspace-h_REF.gc +++ b/test/decompiler/reference/engine/anim/mspace-h_REF.gc @@ -80,7 +80,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) @@ -122,7 +122,8 @@ ;; definition of type cspace-array (deftype cspace-array (inline-array-class) - () + ((data cspace :inline :dynamic :offset-assert 16) + ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 @@ -133,7 +134,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) @@ -154,7 +155,3 @@ ;; failed to figure out what this is: (let ((v0-6 0)) ) - - - - diff --git a/test/decompiler/reference/engine/debug/debug-h_REF.gc b/test/decompiler/reference/engine/debug/debug-h_REF.gc new file mode 100644 index 0000000000..756b95d079 --- /dev/null +++ b/test/decompiler/reference/engine/debug/debug-h_REF.gc @@ -0,0 +1,74 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type pos-history +(deftype pos-history (structure) + ((points uint32 :offset-assert 0) + (num-points int32 :offset-assert 4) + (h-first int32 :offset-assert 8) + (h-last int32 :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; definition for method 3 of type pos-history +(defmethod inspect pos-history ((obj pos-history)) + (format #t "[~8x] ~A~%" obj 'pos-history) + (format #t "~Tpoints: #x~X~%" (-> obj points)) + (format #t "~Tnum-points: ~D~%" (-> obj num-points)) + (format #t "~Th-first: ~D~%" (-> obj h-first)) + (format #t "~Th-last: ~D~%" (-> obj h-last)) + obj + ) + +;; definition of type debug-vertex +(deftype debug-vertex (structure) + ((trans vector4w :inline :offset-assert 0) + (normal vector3h :inline :offset-assert 16) + (st vector2h :inline :offset-assert 22) + (color uint32 :offset-assert 28) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +;; definition for method 3 of type debug-vertex +(defmethod inspect debug-vertex ((obj debug-vertex)) + (format #t "[~8x] ~A~%" obj 'debug-vertex) + (format #t "~Ttrans: ~`vector4w`P~%" (-> obj trans)) + (format #t "~Tnormal: ~`vector3h`P~%" (-> obj normal)) + (format #t "~Tst: ~`vector2h`P~%" (-> obj st)) + (format #t "~Tcolor: #x~X~%" (-> obj color)) + obj + ) + +;; definition of type debug-vertex-stats +(deftype debug-vertex-stats (basic) + ((length int32 :offset-assert 4) + (pos-count int32 :offset-assert 8) + (vertex debug-vertex 600 :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x4b10 + :flag-assert #x900004b10 + ) + +;; definition for method 3 of type debug-vertex-stats +(defmethod inspect debug-vertex-stats ((obj debug-vertex-stats)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tpos-count: ~D~%" (-> obj pos-count)) + (format #t "~Tvertex[600] @ #x~X~%" (-> obj vertex)) + obj + ) + +;; failed to figure out what this is: +(let ((v0-3 0)) + ) + + + + diff --git a/test/decompiler/reference/engine/debug/stats-h_REF.gc b/test/decompiler/reference/engine/debug/stats-h_REF.gc index b3616f0a86..b207fc86a6 100644 --- a/test/decompiler/reference/engine/debug/stats-h_REF.gc +++ b/test/decompiler/reference/engine/debug/stats-h_REF.gc @@ -105,7 +105,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) @@ -140,7 +140,3 @@ (set! (-> perf-stat method-table 12) nothing) (set! (-> perf-stat method-table 13) nothing) ) - - - - diff --git a/test/decompiler/reference/engine/dma/dma-buffer_REF.gc b/test/decompiler/reference/engine/dma/dma-buffer_REF.gc index d5b799dba7..e5e42cc045 100644 --- a/test/decompiler/reference/engine/dma/dma-buffer_REF.gc +++ b/test/decompiler/reference/engine/dma/dma-buffer_REF.gc @@ -37,7 +37,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) diff --git a/test/decompiler/reference/engine/entity/entity-h_REF.gc b/test/decompiler/reference/engine/entity/entity-h_REF.gc index 984a914815..64299621e8 100644 --- a/test/decompiler/reference/engine/entity/entity-h_REF.gc +++ b/test/decompiler/reference/engine/entity/entity-h_REF.gc @@ -109,7 +109,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) @@ -129,7 +129,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) @@ -212,7 +212,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) @@ -312,7 +312,3 @@ ;; failed to figure out what this is: (let ((v0-12 0)) ) - - - - diff --git a/test/decompiler/reference/engine/game/game-h_REF.gc b/test/decompiler/reference/engine/game/game-h_REF.gc new file mode 100644 index 0000000000..99e1f4b3f0 --- /dev/null +++ b/test/decompiler/reference/engine/game/game-h_REF.gc @@ -0,0 +1,193 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type process-drawable +(deftype process-drawable (process) + ((root trsqv :offset-assert 112) + (node-list cspace-array :offset-assert 116) + (draw draw-control :offset-assert 120) + (skel basic :offset-assert 124) + (nav basic :offset-assert 128) + (align basic :offset-assert 132) + (path basic :offset-assert 136) + (vol basic :offset-assert 140) + (fact basic :offset-assert 144) + (link basic :offset-assert 148) + (part basic :offset-assert 152) + (water basic :offset-assert 156) + (sound basic :offset-assert 160) + (state-flags uint32 :offset-assert 164) + (state-time uint64 :offset-assert 168) + ) + :heap-base #x40 + :method-count-assert 20 + :size-assert #xb0 + :flag-assert #x14004000b0 + (:methods + (dummy-14 () none 14) + (dummy-15 () none 15) + (dummy-16 () none 16) + (dummy-17 () none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + ) + ) + +;; definition for method 3 of type process-drawable +(defmethod inspect process-drawable ((obj process-drawable)) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 obj) + ) + (format #t "~T~Troot: ~A~%" (-> obj root)) + (format #t "~T~Tnode-list: ~A~%" (-> obj node-list)) + (format #t "~T~Tdraw: ~A~%" (-> obj draw)) + (format #t "~T~Tskel: ~A~%" (-> obj skel)) + (format #t "~T~Tnav: ~A~%" (-> obj nav)) + (format #t "~T~Talign: ~A~%" (-> obj align)) + (format #t "~T~Tpath: ~A~%" (-> obj path)) + (format #t "~T~Tvol: ~A~%" (-> obj vol)) + (format #t "~T~Tfact: ~A~%" (-> obj fact)) + (format #t "~T~Tlink: ~A~%" (-> obj link)) + (format #t "~T~Tpart: ~A~%" (-> obj part)) + (format #t "~T~Twater: ~A~%" (-> obj water)) + (format #t "~T~Tsound: ~A~%" (-> obj sound)) + (format #t "~T~Tstate-flags: ~D~%" (-> obj state-flags)) + (format #t "~T~Tstate-time: ~D~%" (-> obj state-time)) + obj + ) + +;; definition of type process-drawable-reserved +(deftype process-drawable-reserved (process-drawable) + () + :heap-base #x40 + :method-count-assert 63 + :size-assert #xb0 + :flag-assert #x3f004000b0 + (:methods + (dummy-20 () none 20) + (dummy-21 () none 21) + (dummy-22 () none 22) + (dummy-23 () none 23) + (dummy-24 () none 24) + (dummy-25 () none 25) + (dummy-26 () none 26) + (dummy-27 () none 27) + (dummy-28 () none 28) + (dummy-29 () none 29) + (dummy-30 () none 30) + (dummy-31 () none 31) + (dummy-32 () none 32) + (dummy-33 () none 33) + (dummy-34 () none 34) + (dummy-35 () none 35) + (dummy-36 () none 36) + (dummy-37 () none 37) + (dummy-38 () none 38) + (dummy-39 () none 39) + (dummy-40 () none 40) + (dummy-41 () none 41) + (dummy-42 () none 42) + (dummy-43 () none 43) + (dummy-44 () none 44) + (dummy-45 () none 45) + (dummy-46 () none 46) + (dummy-47 () none 47) + (dummy-48 () none 48) + (dummy-49 () none 49) + (dummy-50 () none 50) + (dummy-51 () none 51) + (dummy-52 () none 52) + (dummy-53 () none 53) + (dummy-54 () none 54) + (dummy-55 () none 55) + (dummy-56 () none 56) + (dummy-57 () none 57) + (dummy-58 () none 58) + (dummy-59 () none 59) + (dummy-60 () none 60) + (dummy-61 () none 61) + (dummy-62 () none 62) + ) + ) + +;; definition for method 3 of type process-drawable-reserved +(defmethod inspect process-drawable-reserved ((obj process-drawable-reserved)) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + obj + ) + +;; definition of type attack-info +(deftype attack-info (structure) + ((trans vector :inline :offset-assert 0) + (vector vector :inline :offset-assert 16) + (intersection vector :inline :offset-assert 32) + (attacker uint64 :offset-assert 48) + (invinc-time uint64 :offset-assert 56) + (mask uint32 :offset-assert 64) + (mode basic :offset-assert 68) + (shove-back float :offset-assert 72) + (shove-up float :offset-assert 76) + (speed float :offset-assert 80) + (dist float :offset-assert 84) + (control float :offset-assert 88) + (angle basic :offset-assert 92) + (rotate-to float :offset-assert 96) + (prev-state basic :offset-assert 100) + ) + :method-count-assert 10 + :size-assert #x68 + :flag-assert #xa00000068 + (:methods + (dummy-9 () none 9) + ) + ) + +;; definition for method 3 of type attack-info +(defmethod inspect attack-info ((obj attack-info)) + (format #t "[~8x] ~A~%" obj 'attack-info) + (format #t "~Ttrans: ~`vector`P~%" (-> obj trans)) + (format #t "~Tvector: ~`vector`P~%" (-> obj vector)) + (format #t "~Tintersection: ~`vector`P~%" (-> obj intersection)) + (format #t "~Tattacker: ~`handle`P~%" (-> obj attacker)) + (format #t "~Tinvinc-time: ~D~%" (-> obj invinc-time)) + (format #t "~Tmask: ~D~%" (-> obj mask)) + (format #t "~Tmode: ~A~%" (-> obj mode)) + (format #t "~Tshove-back: (meters ~m)~%" (-> obj shove-back)) + (format #t "~Tshove-up: (meters ~m)~%" (-> obj shove-up)) + (format #t "~Tspeed: (meters ~m)~%" (-> obj speed)) + (format #t "~Tdist: (meters ~m)~%" (-> obj dist)) + (format #t "~Tcontrol: ~f~%" (-> obj control)) + (format #t "~Tangle: ~A~%" (-> obj angle)) + (format #t "~Trotate-to: (deg ~r)~%" (-> obj rotate-to)) + (format #t "~Tprev-state: ~A~%" (-> obj prev-state)) + obj + ) + +;; definition for symbol *global-attack-id*, type int +(define *global-attack-id* 0) + +;; definition of type ground-tween-info +(deftype ground-tween-info (structure) + ((chan uint8 3 :offset-assert 0) + (blend uint32 3 :offset-assert 4) + (group uint32 5 :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x24 + :flag-assert #x900000024 + ) + +;; definition for method 3 of type ground-tween-info +(defmethod inspect ground-tween-info ((obj ground-tween-info)) + (format #t "[~8x] ~A~%" obj 'ground-tween-info) + (format #t "~Tchan[3] @ #x~X~%" (-> obj chan)) + (format #t "~Tblend[3] @ #x~X~%" (-> obj blend)) + (format #t "~Tgroup[5] @ #x~X~%" (-> obj group)) + obj + ) + +;; failed to figure out what this is: +(let ((v0-4 0)) + ) diff --git a/test/decompiler/reference/engine/game/generic-obs-h_REF.gc b/test/decompiler/reference/engine/game/generic-obs-h_REF.gc new file mode 100644 index 0000000000..32f79328ba --- /dev/null +++ b/test/decompiler/reference/engine/game/generic-obs-h_REF.gc @@ -0,0 +1,356 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type manipy +(deftype manipy (process-drawable) + ((new-trans-hook function :offset-assert 176) + (cur-trans-hook function :offset-assert 180) + (cur-event-hook function :offset-assert 184) + (new-joint-anim basic :offset-assert 188) + (new-joint-anim-blend uint64 :offset-assert 192) + (anim-mode basic :offset-assert 200) + (cur-grab-handle uint64 :offset-assert 208) + (cur-target-handle uint64 :offset-assert 216) + (old-grab-pos vector :inline :offset-assert 224) + (joint joint 4 :offset-assert 240) + (new-post-hook function :offset-assert 256) + (cur-post-hook function :offset-assert 260) + (clone-copy-trans basic :offset-assert 264) + (shadow-backup basic :offset-assert 268) + (draw? symbol :offset-assert 272) + ) + :heap-base #xb0 + :method-count-assert 20 + :size-assert #x114 + :flag-assert #x1400b00114 + ) + +;; definition for method 3 of type manipy +(defmethod inspect manipy ((obj manipy)) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + (format #t "~T~Tnew-trans-hook: ~A~%" (-> obj new-trans-hook)) + (format #t "~T~Tcur-trans-hook: ~A~%" (-> obj cur-trans-hook)) + (format #t "~T~Tcur-event-hook: ~A~%" (-> obj cur-event-hook)) + (format #t "~T~Tnew-joint-anim: ~A~%" (-> obj new-joint-anim)) + (format #t "~T~Tnew-joint-anim-blend: ~D~%" (-> obj new-joint-anim-blend)) + (format #t "~T~Tanim-mode: ~A~%" (-> obj anim-mode)) + (format #t "~T~Tcur-grab-handle: ~D~%" (-> obj cur-grab-handle)) + (format #t "~T~Tcur-target-handle: ~D~%" (-> obj cur-target-handle)) + (format #t "~T~Told-grab-pos: ~`vector`P~%" (&-> obj stack 112)) + (format #t "~T~Tjoint[4] @ #x~X~%" (&-> obj stack 128)) + (format #t "~T~Tnew-post-hook: ~A~%" (-> obj new-post-hook)) + (format #t "~T~Tcur-post-hook: ~A~%" (-> obj cur-post-hook)) + (format #t "~T~Tclone-copy-trans: ~A~%" (-> obj clone-copy-trans)) + (format #t "~T~Tshadow-backup: ~A~%" (-> obj shadow-backup)) + (format #t "~T~Tdraw?: ~A~%" (-> obj draw?)) + obj + ) + +;; definition of type part-spawner +(deftype part-spawner (process-drawable) + ((mode uint32 :offset-assert 176) + (enable basic :offset-assert 180) + (radius float :offset-assert 184) + (world-sphere sphere :inline :offset-assert 192) + ) + :heap-base #x60 + :method-count-assert 21 + :size-assert #xd0 + :flag-assert #x15006000d0 + (:methods + (dummy-20 () none 20) + ) + ) + +;; definition for method 3 of type part-spawner +(defmethod inspect part-spawner ((obj part-spawner)) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + (format #t "~T~Tmode: #x~X~%" (-> obj mode)) + (format #t "~T~Tenable: ~A~%" (-> obj enable)) + (format #t "~T~Tradius: (meters ~m)~%" (-> obj radius)) + (format #t "~T~Tworld-sphere: #~%" (&-> obj stack 80)) + obj + ) + +;; definition of type part-tracker +(deftype part-tracker (process) + ((root basic :offset-assert 112) + (part basic :offset-assert 116) + (target uint64 :offset-assert 120) + (callback basic :offset-assert 128) + (linger-callback basic :offset-assert 132) + (duration uint64 :offset-assert 136) + (linger-duration uint64 :offset-assert 144) + (start-time uint64 :offset-assert 152) + (offset vector :inline :offset-assert 160) + (userdata uint64 :offset-assert 176) + (user-time uint64 2 :offset-assert 184) + (user-vector vector 2 :inline :offset-assert 208) + (user-handle uint32 2 :offset-assert 240) + ) + :heap-base #x90 + :method-count-assert 14 + :size-assert #xf8 + :flag-assert #xe009000f8 + ) + +;; definition for method 3 of type part-tracker +(defmethod inspect part-tracker ((obj part-tracker)) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 obj) + ) + (format #t "~T~Troot: ~A~%" (-> obj root)) + (format #t "~T~Tpart: ~A~%" (-> obj part)) + (format #t "~T~Ttarget: ~D~%" (-> obj target)) + (format #t "~T~Tcallback: ~A~%" (-> obj callback)) + (format #t "~T~Tlinger-callback: ~A~%" (-> obj linger-callback)) + (format #t "~T~Tduration: ~D~%" (-> obj duration)) + (format #t "~T~Tlinger-duration: ~D~%" (-> obj linger-duration)) + (format #t "~T~Tstart-time: ~D~%" (-> obj start-time)) + (format #t "~T~Toffset: ~`vector`P~%" (&-> obj stack 48)) + (format #t "~T~Tuserdata: ~A~%" (-> obj userdata)) + (format #t "~T~Tuser-time[2] @ #x~X~%" (&-> obj stack 72)) + (format #t "~T~Tuser-vector[2] @ #x~X~%" (&-> obj stack 96)) + (format #t "~T~Tuser-handle[2] @ #x~X~%" (&-> obj stack 128)) + obj + ) + +;; definition of type camera-tracker +(deftype camera-tracker (process) + ((grab-target uint64 :offset 120) + (grab-event basic :offset-assert 128) + (release-event basic :offset-assert 132) + (old-global-mask uint32 :offset-assert 136) + (old-self-mask uint32 :offset-assert 140) + (old-parent-mask uint32 :offset-assert 144) + (look-at-target uint64 :offset-assert 152) + (pov-target uint64 :offset-assert 160) + (work-process uint64 :offset-assert 168) + (anim-process uint64 :offset-assert 176) + (start-time uint64 :offset-assert 184) + (callback basic :offset-assert 192) + (userdata basic :offset-assert 196) + (message basic :offset-assert 200) + (border-value basic :offset-assert 204) + (mask-to-clear uint32 :offset-assert 208) + (script basic :offset-assert 212) + (script-line basic :offset-assert 216) + (script-func basic :offset-assert 220) + ) + :heap-base #x70 + :method-count-assert 15 + :size-assert #xe0 + :flag-assert #xf007000e0 + (:methods + (dummy-14 () none 14) + ) + ) + +;; definition for method 3 of type camera-tracker +(defmethod inspect camera-tracker ((obj camera-tracker)) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 obj) + ) + (format #t "~T~Tname: ~A~%" (-> obj name)) + (format #t "~T~Tgrab-target: ~D~%" (-> obj grab-target)) + (format #t "~T~Tgrab-event: ~A~%" (-> obj grab-event)) + (format #t "~T~Trelease-event: ~A~%" (-> obj release-event)) + (format #t "~T~Told-global-mask: ~D~%" (-> obj old-global-mask)) + (format #t "~T~Told-self-mask: ~D~%" (-> obj old-self-mask)) + (format #t "~T~Told-parent-mask: ~D~%" (-> obj old-parent-mask)) + (format #t "~T~Tlook-at-target: ~D~%" (-> obj look-at-target)) + (format #t "~T~Tpov-target: ~D~%" (-> obj pov-target)) + (format #t "~T~Twork-process: ~D~%" (-> obj work-process)) + (format #t "~T~Tanim-process: ~D~%" (-> obj anim-process)) + (format #t "~T~Tstart-time: ~D~%" (-> obj start-time)) + (format #t "~T~Tcallback: ~A~%" (-> obj callback)) + (format #t "~T~Tuserdata: ~A~%" (-> obj userdata)) + (format #t "~T~Tmessage: ~A~%" (-> obj message)) + (format #t "~T~Tborder-value: ~A~%" (-> obj border-value)) + (format #t "~T~Tmask-to-clear: ~D~%" (-> obj mask-to-clear)) + (format #t "~T~Tscript: ~A~%" (-> obj script)) + (format #t "~T~Tscript-line: ~A~%" (-> obj script-line)) + (format #t "~T~Tscript-func: ~A~%" (-> obj script-func)) + obj + ) + +;; definition of type touch-tracker +(deftype touch-tracker (process-drawable) + ((duration uint64 :offset-assert 176) + (target uint64 :offset-assert 184) + (event basic :offset-assert 192) + (run-function basic :offset-assert 196) + (callback basic :offset-assert 200) + (event-mode basic :offset-assert 204) + ) + :heap-base #x60 + :method-count-assert 20 + :size-assert #xd0 + :flag-assert #x14006000d0 + ) + +;; definition for method 3 of type touch-tracker +(defmethod inspect touch-tracker ((obj touch-tracker)) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + (format #t "~T~Tduration: ~D~%" (-> obj duration)) + (format #t "~T~Ttarget: ~D~%" (-> obj target)) + (format #t "~T~Tevent: ~A~%" (-> obj event)) + (format #t "~T~Trun-function: ~A~%" (-> obj run-function)) + (format #t "~T~Tcallback: ~A~%" (-> obj callback)) + (format #t "~T~Tevent-mode: ~A~%" (-> obj event-mode)) + obj + ) + +;; definition of type swingpole +(deftype swingpole (process) + ((root basic :offset-assert 112) + (dir vector :inline :offset-assert 128) + (range float :offset-assert 144) + (edge-length float :offset-assert 148) + ) + :heap-base #x30 + :method-count-assert 14 + :size-assert #x98 + :flag-assert #xe00300098 + ) + +;; definition for method 3 of type swingpole +(defmethod inspect swingpole ((obj swingpole)) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 obj) + ) + (format #t "~T~Troot: ~A~%" (-> obj root)) + (format #t "~T~Tdir: ~`vector`P~%" (&-> obj stack 16)) + (format #t "~T~Trange: (meters ~m)~%" (-> obj range)) + (format #t "~T~Tedge-length: (meters ~m)~%" (-> obj edge-length)) + obj + ) + +;; definition of type gui-query +(deftype gui-query (structure) + ((x-position int32 :offset-assert 0) + (y-position int32 :offset-assert 4) + (message basic :offset-assert 8) + (decision basic :offset-assert 12) + (only-allow-cancel basic :offset-assert 16) + (no-msg basic :offset-assert 20) + (message-space int32 :offset-assert 24) + ) + :pack-me + :method-count-assert 11 + :size-assert #x1c + :flag-assert #xb0000001c + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + ) + ) + +;; definition for method 3 of type gui-query +(defmethod inspect gui-query ((obj gui-query)) + (format #t "[~8x] ~A~%" obj 'gui-query) + (format #t "~Tx-position: ~D~%" (-> obj x-position)) + (format #t "~Ty-position: ~D~%" (-> obj y-position)) + (format #t "~Tmessage: ~A~%" (-> obj message)) + (format #t "~Tdecision: ~A~%" (-> obj decision)) + (format #t "~Tonly-allow-cancel: ~A~%" (-> obj only-allow-cancel)) + (format #t "~Tno-msg: ~A~%" (-> obj no-msg)) + (format #t "~Tmessage-space: ~D~%" (-> obj message-space)) + obj + ) + +;; definition of type othercam +(deftype othercam (process) + ((hand uint64 :offset-assert 112) + (old-global-mask uint32 :offset-assert 120) + (mask-to-clear uint32 :offset-assert 124) + (cam-joint-index int32 :offset-assert 128) + (old-pos vector :inline :offset-assert 144) + (old-mat-z vector :inline :offset-assert 160) + (had-valid-frame basic :offset-assert 176) + (border-value basic :offset-assert 180) + (die? basic :offset-assert 184) + (survive-anim-end? basic :offset-assert 188) + (spooling? basic :offset-assert 192) + ) + :heap-base #x60 + :method-count-assert 14 + :size-assert #xc4 + :flag-assert #xe006000c4 + ) + +;; definition for method 3 of type othercam +(defmethod inspect othercam ((obj othercam)) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 obj) + ) + (format #t "~T~Thand: ~D~%" (-> obj hand)) + (format #t "~T~Told-global-mask: ~D~%" (-> obj old-global-mask)) + (format #t "~T~Tmask-to-clear: ~D~%" (-> obj mask-to-clear)) + (format #t "~T~Tcam-joint-index: ~D~%" (-> obj cam-joint-index)) + (format #t "~T~Told-pos: #~%" (&-> obj stack 32)) + (format #t "~T~Told-mat-z: #~%" (&-> obj stack 48)) + (format #t "~T~Thad-valid-frame: ~A~%" (-> obj had-valid-frame)) + (format #t "~T~Tborder-value: ~A~%" (-> obj border-value)) + (format #t "~T~Tdie?: ~A~%" (-> obj die?)) + (format #t "~T~Tsurvive-anim-end?: ~A~%" (-> obj survive-anim-end?)) + (format #t "~T~Tspooling?: ~A~%" (-> obj spooling?)) + obj + ) + +;; definition of type process-hidden +(deftype process-hidden (process) + () + :method-count-assert 15 + :size-assert #x70 + :flag-assert #xf00000070 + (:methods + (dummy-14 () none 14) + ) + ) + +;; definition for method 3 of type process-hidden +(defmethod inspect process-hidden ((obj process-hidden)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tname: ~A~%" (-> obj name)) + (format #t "~Tmask: ~D~%" (-> obj mask)) + (format #t "~Tparent: #x~X~%" (-> obj parent)) + (format #t "~Tbrother: #x~X~%" (-> obj brother)) + (format #t "~Tchild: #x~X~%" (-> obj child)) + (format #t "~Tppointer: #x~X~%" (-> obj ppointer)) + (format #t "~Tself: ~A~%" (-> obj self)) + (format #t "~Tpool: ~A~%" (-> obj pool)) + (format #t "~Tstatus: ~A~%" (-> obj status)) + (format #t "~Tpid: ~D~%" (-> obj pid)) + (format #t "~Tmain-thread: ~A~%" (-> obj main-thread)) + (format #t "~Ttop-thread: ~A~%" (-> obj top-thread)) + (format #t "~Tentity: ~A~%" (-> obj entity)) + (format #t "~Tstate: ~A~%" (-> obj state)) + (format #t "~Ttrans-hook: ~A~%" (-> obj trans-hook)) + (format #t "~Tpost-hook: ~A~%" (-> obj post-hook)) + (format #t "~Tevent-hook: ~A~%" (-> obj event-hook)) + (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~Tnext-state: ~A~%" (-> obj next-state)) + (format #t "~Theap-base: #x~X~%" (-> obj heap-base)) + (format #t "~Theap-top: #x~X~%" (-> obj heap-top)) + (format #t "~Theap-cur: #x~X~%" (-> obj heap-cur)) + (format #t "~Tstack-frame-top: ~A~%" (-> obj stack-frame-top)) + (format #t "~Theap: #~%" (&-> obj heap-base)) + (format #t "~Tconnection-list: ~`'connectable`P~%" (-> obj connection-list)) + (format #t "~Tstack[0] @ #x~X~%" (-> obj stack)) + obj + ) + +;; failed to figure out what this is: +(let ((v0-9 0)) + ) + + + + diff --git a/test/decompiler/reference/engine/gfx/merc/merc-h_REF.gc b/test/decompiler/reference/engine/gfx/merc/merc-h_REF.gc index 040ea225a9..c3ed098405 100644 --- a/test/decompiler/reference/engine/gfx/merc/merc-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/merc/merc-h_REF.gc @@ -23,7 +23,7 @@ (format #t "~Tvertex-skip: ~D~%" (-> obj vertex-skip)) (format #t "~Tvertex-count: ~D~%" (-> obj vertex-count)) (format #t "~Tcurrent-loc: ~D~%" (-> obj current-loc)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 20)) + (format #t "~Tdata[0] @ #x~X~%" (&-> obj _data 16)) obj ) diff --git a/test/decompiler/reference/engine/gfx/texture-h_REF.gc b/test/decompiler/reference/engine/gfx/texture-h_REF.gc index 63d9fd7164..f0e2bcb5af 100644 --- a/test/decompiler/reference/engine/gfx/texture-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/texture-h_REF.gc @@ -359,7 +359,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) @@ -405,4 +405,3 @@ ;; failed to figure out what this is: (let ((v0-14 0)) ) - diff --git a/test/decompiler/reference/engine/math/vector-h_REF.gc b/test/decompiler/reference/engine/math/vector-h_REF.gc index 3d1c305f1f..00a2fb2697 100644 --- a/test/decompiler/reference/engine/math/vector-h_REF.gc +++ b/test/decompiler/reference/engine/math/vector-h_REF.gc @@ -542,7 +542,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) @@ -675,7 +675,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) obj ) diff --git a/test/decompiler/reference/kernel/gcommon_REF.gc b/test/decompiler/reference/kernel/gcommon_REF.gc index 67f8a2e55e..fce4c82308 100644 --- a/test/decompiler/reference/kernel/gcommon_REF.gc +++ b/test/decompiler/reference/kernel/gcommon_REF.gc @@ -453,10 +453,9 @@ ;; definition of type inline-array-class (deftype inline-array-class (basic) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data uint8 :dynamic :offset-assert 12) - (_pad uint8 4 :offset-assert 12) + ((length int32 :offset-assert 4) + (allocated-length int32 :offset-assert 8) + (_data uint8 :dynamic :offset 16) ) :method-count-assert 9 :size-assert #x10