diff --git a/README.md b/README.md index 48e63d31f3..27115c5fdf 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,16 @@ Run tests: ./test.sh ``` +Note: we have found that `clang` and `lld` are significantly faster to compile and link than `gcc`, generate faster code, and have better warning messages. To install these: +``` +sudo apt install lld clang +``` +and run `cmake` (in a fresh build directory) with: +``` +cmake -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .. +``` +this decreases the compile and link time from ~10 seconds to ~4 seconds. + ## Getting Started - Linux (Arch) Install packages and init repository: diff --git a/decompiler/IR2/Env.cpp b/decompiler/IR2/Env.cpp index e2bfed5417..8e21c8c227 100644 --- a/decompiler/IR2/Env.cpp +++ b/decompiler/IR2/Env.cpp @@ -417,12 +417,12 @@ std::vector Env::extract_visible_variables( return entries; } -goos::Object Env::local_var_type_list(const Form* top_level_form, - int nargs_to_ignore, - int* count_out) const { +FunctionVariableDefinitions Env::local_var_type_list(const Form* top_level_form, + int nargs_to_ignore) const { assert(nargs_to_ignore <= 8); auto vars = extract_visible_variables(top_level_form); + FunctionVariableDefinitions result; std::vector elts; elts.push_back(pretty_print::to_symbol("local-vars")); int count = 0; @@ -432,6 +432,11 @@ goos::Object Env::local_var_type_list(const Form* top_level_form, continue; } + if (x.reg_id.reg == Register(Reg::GPR, Reg::S6)) { + result.had_pp = true; + continue; + } + std::string lookup_name = x.name(); auto remapped = m_var_remap.find(lookup_name); if (remapped != m_var_remap.end()) { @@ -459,10 +464,11 @@ goos::Object Env::local_var_type_list(const Form* top_level_form, count++; } - if (count_out) { - *count_out = count; + result.count = count; + if (count > 0) { + result.local_vars = pretty_print::build_list(elts); } - return pretty_print::build_list(elts); + return result; } std::unordered_set Env::get_ssa_var(const RegAccessSet& vars) const { diff --git a/decompiler/IR2/Env.h b/decompiler/IR2/Env.h index 321905f0a5..e18d5ab451 100644 --- a/decompiler/IR2/Env.h +++ b/decompiler/IR2/Env.h @@ -42,6 +42,12 @@ struct StackSpillEntry { } }; +struct FunctionVariableDefinitions { + std::optional local_vars; + bool had_pp = false; + int count = 0; +}; + /*! * An "environment" for a single function. * This contains data for an entire function, like which registers are live when, the types of @@ -122,9 +128,8 @@ class Env { std::vector extract_visible_variables(const Form* top_level_form) const; std::string print_local_var_types(const Form* top_level_form) const; - goos::Object local_var_type_list(const Form* top_level_form, - int nargs_to_ignore, - int* count_out) const; + FunctionVariableDefinitions local_var_type_list(const Form* top_level_form, + int nargs_to_ignore) const; std::unordered_set get_ssa_var(const RegAccessSet& vars) const; RegId get_program_var_id(const RegisterAccess& var) const; diff --git a/decompiler/IR2/Form.cpp b/decompiler/IR2/Form.cpp index c8db019b52..53eca6a596 100644 --- a/decompiler/IR2/Form.cpp +++ b/decompiler/IR2/Form.cpp @@ -314,7 +314,8 @@ goos::Object SetVarElement::to_form_internal(const Env& env) const { } } - return pretty_print::build_list("set!", m_dst.to_form(env), m_src->to_form(env)); + return pretty_print::build_list( + "set!", m_dst.to_form(env, RegisterAccess::Print::AS_VARIABLE_NO_CAST), m_src->to_form(env)); } std::optional SetVarElement::required_cast(const Env& env) const { diff --git a/decompiler/ObjectFile/ObjectFileDB.cpp b/decompiler/ObjectFile/ObjectFileDB.cpp index bc00d33319..9b38f05137 100644 --- a/decompiler/ObjectFile/ObjectFileDB.cpp +++ b/decompiler/ObjectFile/ObjectFileDB.cpp @@ -187,7 +187,6 @@ void ObjectFileDB::load_map_file(const std::string& map_data) { } } -constexpr int MAX_CHUNK_SIZE = 0x8000; /*! * Load the objects stored in the given DGO into the ObjectFileDB */ diff --git a/decompiler/ObjectFile/ObjectFileDB_IR2.cpp b/decompiler/ObjectFile/ObjectFileDB_IR2.cpp index 0e267b0f86..16ded1d9cf 100644 --- a/decompiler/ObjectFile/ObjectFileDB_IR2.cpp +++ b/decompiler/ObjectFile/ObjectFileDB_IR2.cpp @@ -467,7 +467,7 @@ void ObjectFileDB::ir2_cfg_build_pass() { try { build_initial_forms(func); } catch (std::exception& e) { - func.warnings.general_warning("Failed to structure"); + func.warnings.general_warning("Failed to structure: {}", e.what()); func.ir2.top_form = nullptr; } } diff --git a/decompiler/analysis/final_output.cpp b/decompiler/analysis/final_output.cpp index 52282fedb2..15e28ab279 100644 --- a/decompiler/analysis/final_output.cpp +++ b/decompiler/analysis/final_output.cpp @@ -19,6 +19,26 @@ goos::Object get_arg_list_for_function(const Function& func, const Env& env) { return pretty_print::build_list(argument_elts); } +namespace { +void append_to_body(goos::Object* top_form, + const std::vector& inline_body, + const FunctionVariableDefinitions& var_dec) { + if (var_dec.local_vars) { + pretty_print::append(*top_form, pretty_print::build_list(*var_dec.local_vars)); + } + + if (var_dec.had_pp) { + std::vector body_with_pp; + body_with_pp.push_back(pretty_print::to_symbol("with-pp")); + body_with_pp.insert(body_with_pp.end(), inline_body.begin(), inline_body.end()); + pretty_print::append(*top_form, + pretty_print::build_list(pretty_print::build_list(body_with_pp))); + } else { + pretty_print::append(*top_form, pretty_print::build_list(inline_body)); + } +} +} // namespace + std::string final_defun_out(const Function& func, const Env& env, const DecompilerTypeSystem& dts, @@ -31,8 +51,8 @@ std::string final_defun_out(const Function& func, return e.what(); } - int var_count = 0; - auto var_dec = env.local_var_type_list(func.ir2.top_form, func.type.arg_count() - 1, &var_count); + // int var_count = 0; + auto var_dec = env.local_var_type_list(func.ir2.top_form, func.type.arg_count() - 1); auto arguments = get_arg_list_for_function(func, env); if (func.guessed_name.kind == FunctionName::FunctionKind::GLOBAL) { @@ -48,11 +68,7 @@ std::string final_defun_out(const Function& func, top.push_back(arguments); auto top_form = pretty_print::build_list(top); - if (var_count > 0) { - append(top_form, pretty_print::build_list(var_dec)); - } - - append(top_form, pretty_print::build_list(inline_body)); + append_to_body(&top_form, inline_body, var_dec); return pretty_print::to_string(top_form); } @@ -67,11 +83,7 @@ std::string final_defun_out(const Function& func, top.push_back(arguments); auto top_form = pretty_print::build_list(top); - if (var_count > 0) { - append(top_form, pretty_print::build_list(var_dec)); - } - - append(top_form, pretty_print::build_list(inline_body)); + append_to_body(&top_form, inline_body, var_dec); return pretty_print::to_string(top_form); } @@ -82,11 +94,7 @@ std::string final_defun_out(const Function& func, top.push_back(arguments); auto top_form = pretty_print::build_list(top); - if (var_count > 0) { - append(top_form, pretty_print::build_list(var_dec)); - } - - append(top_form, pretty_print::build_list(inline_body)); + append_to_body(&top_form, inline_body, var_dec); return pretty_print::to_string(top_form); } @@ -99,11 +107,7 @@ std::string final_defun_out(const Function& func, top.push_back(arguments); auto top_form = pretty_print::build_list(top); - if (var_count > 0) { - append(top_form, pretty_print::build_list(var_dec)); - } - - append(top_form, pretty_print::build_list(inline_body)); + append_to_body(&top_form, inline_body, var_dec); return pretty_print::to_string(top_form); } return "nyi"; @@ -194,10 +198,9 @@ std::string write_from_top_level(const Function& top_level, std::string result; // local vars: - int var_count = 0; - auto var_dec = env.local_var_type_list(top_level.ir2.top_form, 0, &var_count); - if (var_count > 0) { - result += pretty_print::to_string(var_dec); + auto var_dec = env.local_var_type_list(top_level.ir2.top_form, 0); + if (var_dec.local_vars) { + result += pretty_print::to_string(*var_dec.local_vars); result += '\n'; result += '\n'; } diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 499a5edd8b..94d0028c92 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -541,6 +541,8 @@ (define-extern lavaspoutdrip type) +(define-extern string->symbol (function string symbol)) + ;; ---------------------- ;; File - gstring-h @@ -1700,9 +1702,9 @@ ;; - Types (deftype curve (structure) - ((cverts uint32 :offset-assert 0) + ((cverts pointer :offset-assert 0) (num-cverts int32 :offset-assert 4) - (knots uint32 :offset-assert 8) + (knots pointer :offset-assert 8) (num-knots int32 :offset-assert 12) (length float :offset-assert 16) ) @@ -8973,7 +8975,7 @@ (get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer :no-virtual 9) (get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure :no-virtual 10) (get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 :no-virtual 11) - (get-property-value2 (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 :no-virtual 12) + (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float :no-virtual 12) (get-tag-index-data (_type_ int) pointer 13) (get-tag-data (_type_ res-tag) pointer 14) (dummy-15 (_type_ res-tag) res-tag 15) @@ -10484,7 +10486,7 @@ ) (deftype collide-shape (trsqv) - ((process basic :offset-assert 140) + ((process process :offset-assert 140) (max-iteration-count uint8 :offset-assert 144) (nav-flags uint8 :offset-assert 145) (pad-byte uint8 2 :offset-assert 146) @@ -12595,6 +12597,7 @@ (defenum entity-perm-status :bitfield #t :type uint16 + (bit-1 1) (dead 2) (complete 6)) @@ -12628,7 +12631,7 @@ (next-link entity-links :offset-assert 4) (entity basic :offset-assert 8) (process process :offset-assert 12) - (level basic :offset-assert 16) + (level level :offset-assert 16) (vis-id int32 :offset-assert 20) (trans vector :inline :offset-assert 32) (perm entity-perm :inline :offset-assert 48) @@ -13192,9 +13195,9 @@ (apply-function-forward (_type_ (function entity-actor object object) object) int 16) (apply-function-reverse (_type_ (function entity-actor object object) object) int 17) (apply-all (_type_ (function entity-actor object object) object) int 18) - (dummy-19 (_type_ object) none 19) - (dummy-20 (_type_ object) none 20) ;; weird sc error - (dummy-21 (_type_ object) none 21) ;; weird sc error + (send-to-all (_type_ object) none 19) + (send-to-all-after (_type_ object) object 20) + (send-to-all-before (_type_ object) object 21) (send-to-next-and-prev (_type_ object) none 22) (send-to-next (_type_ object) none 23) (send-to-prev (_type_ object) none 24) @@ -13522,30 +13525,30 @@ ;; - Symbols -(define-extern float-save-redline function) -(define-extern float-lookup-redline function) -(define-extern float-save-blueline function) -(define-extern float-lookup-blueline function) -(define-extern float-save-greenline function) -(define-extern float-lookup-greenline function) -(define-extern float-save-yellowline function) -(define-extern float-lookup-yellowline function) -(define-extern float-save-timeplot function) -(define-extern float-lookup-timeplot function) +(define-extern float-save-redline (function float none)) +(define-extern float-lookup-redline (function float float)) +(define-extern float-save-blueline (function float none)) +(define-extern float-lookup-blueline (function float float)) +(define-extern float-save-greenline (function float none)) +(define-extern float-lookup-greenline (function float float)) +(define-extern float-save-yellowline (function float none)) +(define-extern float-lookup-yellowline (function float float)) +(define-extern float-save-timeplot (function float none)) +(define-extern float-lookup-timeplot (function float float)) ;; - Unknowns -;;(define-extern *timeplot-index* object) ;; unknown type -;;(define-extern *timeplot-table* object) ;; unknown type -;;(define-extern *yellowline-index* object) ;; unknown type -;;(define-extern *yellowline-table* object) ;; unknown type -;;(define-extern *greenline-index* object) ;; unknown type -;;(define-extern *greenline-table* object) ;; unknown type -;;(define-extern *blueline-index* object) ;; unknown type -;;(define-extern *blueline-table* object) ;; unknown type -;;(define-extern *redline-index* object) ;; unknown type -;;(define-extern *redline-table* object) ;; unknown type -;;(define-extern *cam-layout* object) ;; unknown type +(define-extern *timeplot-index* int) +(define-extern *timeplot-table* (pointer float)) +(define-extern *yellowline-index* int) +(define-extern *yellowline-table* (pointer float)) +(define-extern *greenline-index* int) +(define-extern *greenline-table* (pointer float)) +(define-extern *blueline-index* int) +(define-extern *blueline-table* (pointer float)) +(define-extern *redline-index* int) +(define-extern *redline-table* (pointer float)) +(define-extern *cam-layout* symbol) ;; ---------------------- @@ -13953,64 +13956,51 @@ ;; - Types -; (deftype path-control (basic) -; ((flags uint32 :offset-assert 4) -; (name basic :offset-assert 8) -; (process basic :offset-assert 12) -; (curve curve :inline :offset-assert 16) -; (num-cverts int32 :offset-assert 20) -; (cverts uint32 :offset-assert 16) -; ) -; :method-count-assert 21 -; :size-assert #x24 -; :flag-assert #x1500000024 -; (: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) -; (dummy-16 () none 16) -; (dummy-17 () none 17) -; (dummy-18 () none 18) -; (dummy-19 () none 19) -; (dummy-20 () none 20) -; ) -; ) +(defenum path-control-flag + :bitfield #t + :type uint32 + (display 0) + (not-found 4) + ) -; (deftype curve-control (path-control) -; ((flags uint32 :offset-assert 4) -; (name basic :offset-assert 8) -; (process basic :offset-assert 12) -; (curve curve :inline :offset-assert 16) -; (num-cverts int32 :offset-assert 20) -; (cverts uint32 :offset-assert 16) -; ) -; :method-count-assert 21 -; :size-assert #x24 -; :flag-assert #x1500000024 -; (: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) -; (dummy-16 () none 16) -; (dummy-17 () none 17) -; (dummy-18 () none 18) -; (dummy-19 () none 19) -; (dummy-20 () none 20) -; ) -; ) +(deftype path-control (basic) + ((flags path-control-flag :offset-assert 4) + (name basic :offset-assert 8) + (process basic :offset-assert 12) + (curve curve :inline :offset-assert 16) + (num-cverts int32 :offset 20) + (cverts pointer :offset 16) + ) + :method-count-assert 21 + :size-assert #x24 + :flag-assert #x1500000024 + (:methods + (new (symbol type process symbol float) _type_) + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + (dummy-14 () none 14) + (length-as-float (_type_) float 15) + (dummy-16 () none 16) + (get-num-verts (_type_) int 17) + (should-display? (_type_) symbol 18) + (dummy-19 () none 19) + (dummy-20 () none 20) + ) + ) - -;; - Unknowns - -;;(define-extern string->symbol object) ;; unknown type +(deftype curve-control (path-control) + () + + (:methods + (new (symbol type process symbol float) _type_) + ) + :method-count-assert 21 + :size-assert #x24 + :flag-assert #x1500000024 + ) ;; ---------------------- @@ -14065,15 +14055,15 @@ :flag-assert #x900000050 ) -; (deftype nav-route-portal (structure) -; ((next-poly nav-poly :offset-assert 0) -; (vertex UNKNOWN 2 :offset-assert 4) -; (edge-index int8 :offset-assert 12) -; ) -; :method-count-assert 9 -; :size-assert #xd -; :flag-assert #x90000000d -; ) +(deftype nav-route-portal (structure) + ((next-poly nav-poly :offset-assert 0) + (vertex nav-vertex 2 :offset-assert 4) + (edge-index int8 :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #xd + :flag-assert #x90000000d + ) (deftype clip-travel-vector-to-mesh-return-info (structure) ((found-boundary basic :offset-assert 0) @@ -14094,30 +14084,30 @@ :flag-assert #x9000000a0 ) -; (deftype nav-node (structure) -; ((center-x float :offset-assert 0) -; (center-y float :offset-assert 4) -; (center-z float :offset-assert 8) -; (type uint16 :offset-assert 12) -; (parent-offset uint16 :offset-assert 14) -; (center vector :inline :offset-assert 0) -; (radius-x float :offset-assert 16) -; (radius-y float :offset-assert 20) -; (radius-z float :offset-assert 24) -; (left-offset uint16 :offset-assert 28) -; (right-offset uint16 :offset-assert 30) -; (num-tris uint32 :offset-assert 28) -; (radius vector :inline :offset-assert 16) -; (scale-x float :offset-assert 32) -; (first-tris UNKNOWN 4 :offset-assert 36) -; (scale-z float :offset-assert 40) -; (last-tris UNKNOWN 4 :offset-assert 44) -; (scale vector :inline :offset-assert 32) -; ) -; :method-count-assert 9 -; :size-assert #x30 -; :flag-assert #x900000030 -; ) +(deftype nav-node (structure) + ((center-x float :offset-assert 0) + (center-y float :offset-assert 4) + (center-z float :offset-assert 8) + (type uint16 :offset-assert 12) + (parent-offset uint16 :offset-assert 14) + (center vector :inline :offset 0) + (radius-x float :offset-assert 16) + (radius-y float :offset-assert 20) + (radius-z float :offset-assert 24) + (left-offset uint16 :offset-assert 28) + (right-offset uint16 :offset-assert 30) + (num-tris uint32 :offset 28) + (radius vector :inline :offset 16) + (scale-x float :offset-assert 32) + (first-tris uint8 4 :offset-assert 36) + (scale-z float :offset-assert 40) + (last-tris uint8 4 :offset-assert 44) + (scale vector :inline :offset 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) (deftype nav-lookup-elem (structure) ((vec vector :inline :offset-assert 0) @@ -14134,50 +14124,50 @@ :flag-assert #x900000020 ) -; (deftype nav-mesh (basic) -; ((user-list basic :offset-assert 4) -; (poly-lookup-history UNKNOWN 2 :offset-assert 8) -; (debug-time uint8 :offset-assert 10) -; (static-sphere-count uint8 :offset-assert 11) -; (static-sphere uint32 :offset-assert 12) -; (bounds sphere :inline :offset-assert 16) -; (origin vector :inline :offset-assert 32) -; (cache UNKNOWN 4 :offset-assert 48) -; (node-count int32 :offset-assert 176) -; (nodes uint32 :offset-assert 180) -; (vertex-count int32 :offset-assert 184) -; (vertex uint32 :offset-assert 188) -; (poly-count int32 :offset-assert 192) -; (poly uint32 :offset-assert 196) -; (route uint32 :offset-assert 200) -; ) -; :method-count-assert 30 -; :size-assert #xcc -; :flag-assert #x1e000000cc -; (: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) -; (dummy-16 () none 16) -; (dummy-17 () none 17) -; (dummy-18 () none 18) -; (dummy-19 () none 19) -; (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) -; ) -; ) +(deftype nav-mesh (basic) + ((user-list engine :offset-assert 4) + (poly-lookup-history uint8 2 :offset-assert 8) + (debug-time uint8 :offset-assert 10) + (static-sphere-count uint8 :offset-assert 11) + (static-sphere uint32 :offset-assert 12) + (bounds sphere :inline :offset-assert 16) + (origin vector :inline :offset-assert 32) + (cache nav-lookup-elem 4 :inline :offset-assert 48) ;; guess on type + (node-count int32 :offset-assert 176) + (nodes uint32 :offset-assert 180) + (vertex-count int32 :offset-assert 184) + (vertex uint32 :offset-assert 188) + (poly-count int32 :offset-assert 192) + (poly uint32 :offset-assert 196) + (route uint32 :offset-assert 200) + ) + :method-count-assert 30 + :size-assert #xcc + :flag-assert #x1e000000cc + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 (_type_) none 13) + (dummy-14 () none 14) + (dummy-15 () none 15) + (dummy-16 () none 16) + (dummy-17 (_type_) none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + (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) + ) + ) (deftype check-vector-collision-with-nav-spheres-info (structure) ((u float :offset-assert 0) @@ -14198,78 +14188,87 @@ :flag-assert #x900000014 ) -; (deftype nav-control (basic) -; ((flags uint32 :offset-assert 4) -; (process basic :offset-assert 8) -; (shape basic :offset-assert 12) -; (mesh basic :offset-assert 16) -; (gap-event basic :offset-assert 20) -; (block-event basic :offset-assert 24) -; (current-poly nav-poly :offset-assert 28) -; (next-poly nav-poly :offset-assert 32) -; (target-poly nav-poly :offset-assert 36) -; (portal UNKNOWN 2 :offset-assert 40) -; (nearest-y-threshold meters :offset-assert 48) -; (event-temp vector :inline :offset-assert 64) -; (old-travel vector :inline :offset-assert 80) -; (blocked-travel vector :inline :offset-assert 96) -; (prev-pos vector :inline :offset-assert 112) -; (extra-nav-sphere vector :inline :offset-assert 128) -; (travel vector :inline :offset-assert 144) -; (target-pos vector :inline :offset-assert 160) -; (destination-pos vector :inline :offset-assert 176) -; (block-time uint64 :offset-assert 192) -; (block-count float :offset-assert 200) -; (user-poly nav-poly :offset-assert 204) -; (nav-cull-radius float :offset-assert 208) -; (num-spheres int16 :offset-assert 212) -; (max-spheres int16 :offset-assert 214) -; (sphere UNKNOWN :dynamic :offset-assert 224) -; ) -; :method-count-assert 36 -; :size-assert #xe0 -; :flag-assert #x24000000e0 -; (: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) -; (dummy-16 () none 16) -; (dummy-17 () none 17) -; (dummy-18 () none 18) -; (dummy-19 () none 19) -; (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) -; ) -; ) +(defenum nav-control-flags + :bitfield #t + :type uint32 + (display-marks 0) + (bit8 8) + (bit13 13) + ) + +(deftype nav-control (basic) + ((flags nav-control-flags :offset-assert 4) + (process basic :offset-assert 8) + (shape collide-shape :offset-assert 12) + (mesh nav-mesh :offset-assert 16) + (gap-event basic :offset-assert 20) + (block-event basic :offset-assert 24) + (current-poly nav-poly :offset-assert 28) + (next-poly nav-poly :offset-assert 32) + (target-poly nav-poly :offset-assert 36) + (portal nav-route-portal 2 :offset-assert 40) ;; guess + (nearest-y-threshold float :offset-assert 48) ;; meters + (event-temp vector :inline :offset-assert 64) + (old-travel vector :inline :offset-assert 80) + (blocked-travel vector :inline :offset-assert 96) + (prev-pos vector :inline :offset-assert 112) + (extra-nav-sphere vector :inline :offset-assert 128) + (travel vector :inline :offset-assert 144) + (target-pos vector :inline :offset-assert 160) + (destination-pos vector :inline :offset-assert 176) + (block-time uint64 :offset-assert 192) + (block-count float :offset-assert 200) + (user-poly nav-poly :offset-assert 204) + (nav-cull-radius float :offset-assert 208) + (num-spheres int16 :offset-assert 212) + (max-spheres int16 :offset-assert 214) + (sphere sphere :inline :dynamic :offset-assert 224) ;; guess + ) + :method-count-assert 36 + :size-assert #xe0 + :flag-assert #x24000000e0 + (:methods + (new (symbol type collide-shape int float) _type_) + (dummy-9 () none 9) + (point-in-bounds? (_type_ vector) symbol 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + (dummy-14 () none 14) + (set-target-pos! (_type_ vector) none 15) + (dummy-16 () none 16) + (dummy-17 () none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + (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) + (should-display? (_type_) symbol 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) + ) + ) ;; - Symbols -(define-extern nav-mesh-connect function) -(define-extern has-nav-mesh? function) +(define-extern nav-mesh-connect (function process trsqv nav-control nav-mesh)) +(define-extern has-nav-mesh? (function entity-actor symbol)) ;; - Unknowns -;;(define-extern process-level-heap object) ;; unknown type -;;(define-extern *default-nav-mesh* object) ;; unknown type +(define-extern process-level-heap kheap) ;; unknown type +(define-extern *default-nav-mesh* nav-mesh) ;; unknown type ;; ---------------------- diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index fcf1934988..ed2229a339 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -547,5 +547,13 @@ "vol-h": [ ["L13", "float", true] + ], + + "assert-h": [ + ["L4", "__assert-info-private-struct", true] + ], + + "navigate-h": [ + ["L20", "float", true] ] } diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 84b24ac355..88c0f96085 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -589,7 +589,7 @@ "(method 12 ambient-sound)": [[[8, 20], "v1", "sound-rpc-set-param"]], "sound-buffer-dump": [[[14, 25], "s3", "sound-rpc-play"]], "actor-link-subtask-complete-hook": [[1, "v1", "entity-links"]], - + "(method 0 vol-control)": [ [[9, 14], "t9", "(function object object)"], [30, "s5", "res-lump"], @@ -601,14 +601,33 @@ [113, "s5", "res-lump"], [117, "s5", "res-lump"] ], - - "point-in-air-box?": [ - [5, "f1", "float"] - ], - + + "point-in-air-box?": [[5, "f1", "float"]], + "(method 3 air-box)": [ [16, "f0", "float"], [22, "f0", "float"], [28, "f0", "float"] + ], + + "(method 0 path-control)": [ + [15, "t9", "(function string none)"], + ["_stack_", 16, "res-tag"] + ], + + "(method 0 curve-control)": [[[13, 55], "s3", "entity"]], + + "nav-mesh-connect": [ + [[4, 15], "s2", "entity-actor"], + [19, "v1", "entity"], + [20, "v1", "entity-links"], + [72, "v1", "entity"], + [73, "v1", "entity-links"], + [76, "a0", "entity"], + [77, "a0", "entity-links"] + ], + + "(method 0 nav-control)": [ + [17, "t9", "(function string none)"] ] } diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index eabfd955f5..fa0271f36c 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -1954,6 +1954,26 @@ }, "sound-buffer-dump": { "vars": { "s3-0": ["cmd", "sound-rpc-play"] } + }, + + "(method 0 path-control)": { + "args":["allocation", "type-to-make", "proc", "name", "time"], + "vars": {"gp-0":["obj", "path-control"], "s3-1":"ent", "v1-7":"lookup-entity", "sv-16":"tag", "v1-9":"data"} + }, + + "(method 0 curve-control)": { + "args":["allocation", "type-to-make", "proc", "name", "time"], + "vars": {"gp-0":"obj", "s3-1":"ent", "v1-3":"lookup-entity"} + }, + + "nav-mesh-connect": { + "args":["proc", "trans", "nav-cont"], + "vars": {"s2-0":"ent", "v0-0":"lookup-entity", "s3-0":"entity-nav-mesh"} + }, + + "(method 0 nav-control)": { + "args":["allocation", "type-to-make", "shape", "sphere-count", "nearest-y-threshold-default"], + "vars": {"s5-0":["obj", "nav-control"], "a0-3":"ent"} } diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index 7d812f639a..f7687ae91f 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -967,10 +967,10 @@ std::vector decompile_bitfield_enum_from_int(const TypeSpec& type, } if (reconstructed != value) { - throw std::runtime_error( - fmt::format("Failed to decompile bitfield enum. Original value is 0x{:x} but we could only " - "make 0x{:x} using the available fields.", - value, reconstructed)); + throw std::runtime_error(fmt::format( + "Failed to decompile bitfield enum {}. Original value is 0x{:x} but we could only " + "make 0x{:x} using the available fields.", + type.print(), value, reconstructed)); } // unordered map will give us these fields in a weird order, let's order them explicitly. diff --git a/goal_src/engine/camera/cam-debug-h.gc b/goal_src/engine/camera/cam-debug-h.gc index 4052c2d9e1..3791fb4d73 100644 --- a/goal_src/engine/camera/cam-debug-h.gc +++ b/goal_src/engine/camera/cam-debug-h.gc @@ -5,3 +5,97 @@ ;; name in dgo: cam-debug-h ;; dgos: GAME, ENGINE + +;; this file is debug only +(when *debug-segment* + (define *redline-table* (the-as (pointer float) (malloc 'debug 1600))) + (define *redline-index* 0) + + (defun float-save-redline ((arg0 float)) + (set! (-> *redline-table* *redline-index*) arg0) + (set! *redline-index* (+ *redline-index* 1)) + (when (>= *redline-index* 400) + (set! *redline-index* 0) + ) + (none) + ) + + (defun float-lookup-redline ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *redline-index*) 400))) + (-> *redline-table* a0-3) + ) + ) + + (define *blueline-table* (the-as (pointer float) (malloc 'debug 1600))) + (define *blueline-index* 0) + (defun float-save-blueline ((arg0 float)) + (set! (-> *blueline-table* *blueline-index*) arg0) + (set! *blueline-index* (+ *blueline-index* 1)) + (when (>= *blueline-index* 400) + (set! *blueline-index* 0) + ) + (none) + ) + + (defun float-lookup-blueline ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *blueline-index*) 400))) + (-> *blueline-table* a0-3) + ) + ) + + (define *greenline-table* (the-as (pointer float) (malloc 'debug 1600))) + (define *greenline-index* 0) + (defun float-save-greenline ((arg0 float)) + (set! (-> *greenline-table* *greenline-index*) arg0) + (set! *greenline-index* (+ *greenline-index* 1)) + (when (>= *greenline-index* 400) + (set! *greenline-index* 0) + ) + (none) + ) + + (defun float-lookup-greenline ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *greenline-index*) 400))) + (-> *greenline-table* a0-3) + ) + ) + + (define *yellowline-table* (the-as (pointer float) (malloc 'debug 1600))) + (define *yellowline-index* 0) + + (defun float-save-yellowline ((arg0 float)) + (set! (-> *yellowline-table* *yellowline-index*) arg0) + (set! *yellowline-index* (+ *yellowline-index* 1)) + (when (>= *yellowline-index* 400) + (set! *yellowline-index* 0) + ) + (none) + ) + + (defun float-lookup-yellowline ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *yellowline-index*) 400))) + (-> *yellowline-table* a0-3) + ) + ) + + (define *timeplot-table* (the-as (pointer float) (malloc 'debug 1600))) + (define *timeplot-index* 0) + + (defun float-save-timeplot ((arg0 float)) + (set! (-> *timeplot-table* *timeplot-index*) arg0) + (set! *timeplot-index* (+ *timeplot-index* 1)) + (when (>= *timeplot-index* 400) + (set! *timeplot-index* 0) + ) + (none) + ) + + (defun float-lookup-timeplot ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *timeplot-index*) 400))) + (-> *timeplot-table* a0-3) + ) + ) + + (define-perm *cam-layout* symbol #f) + + ) diff --git a/goal_src/engine/camera/cam-interface-h.gc b/goal_src/engine/camera/cam-interface-h.gc index 5e4e07e6ea..4f9a22d671 100644 --- a/goal_src/engine/camera/cam-interface-h.gc +++ b/goal_src/engine/camera/cam-interface-h.gc @@ -8,4 +8,11 @@ ;; NOTE - forward declaration needed for cam-interface (define-extern *camera-dummy-vector* vector) (define-extern *camera* camera-master) ;; unknown type -(define-extern *camera-combiner* camera-combiner) ;; unknown type + +(define *camera-read-analog* #t) +(define *camera-read-buttons* #t) +(define *cam-free-move-along-z* #t) +(define-perm *camera-init-mat* matrix #f) +(define-perm *camera* camera-master #f) +(define-perm *camera-combiner* camera-combiner #f) +(define-perm *camera-orbit-target* process-drawable #f) diff --git a/goal_src/engine/camera/cam-interface.gc b/goal_src/engine/camera/cam-interface.gc index 8bf24be0c6..bb94eedd21 100644 --- a/goal_src/engine/camera/cam-interface.gc +++ b/goal_src/engine/camera/cam-interface.gc @@ -108,23 +108,22 @@ ;; INFO: Return type mismatch int vs none. ;; Used lq/sq (defun camera-teleport-to-entity ((arg0 entity-actor)) - (local-vars (pp process)) - (let ((gp-0 (new 'stack 'transformq))) - (let ((v1-1 (-> gp-0 trans))) - (set! (-> v1-1 quad) (-> (the-as transform (-> arg0 extra)) scale quad)) + (with-pp + (let ((gp-0 (new 'stack 'transformq))) + (let ((v1-1 (-> gp-0 trans))) + (set! (-> v1-1 quad) (-> (the-as transform (-> arg0 extra)) scale quad)) + ) + (quaternion-copy! (the-as quaternion (-> gp-0 rot)) (-> arg0 quat)) + (vector-identity! (-> gp-0 scale)) + (let ((a1-2 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-2 from) pp) + (set! (-> a1-2 num-params) 1) + (set! (-> a1-2 message) 'teleport-to-transformq) + (set! (-> a1-2 param 0) (the-as uint gp-0)) + (send-event-function *camera* a1-2) + ) + ) + (none) ) - (quaternion-copy! (the-as quaternion (-> gp-0 rot)) (-> arg0 quat)) - (vector-identity! (-> gp-0 scale)) - (let ((a1-2 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-2 from) pp) - (set! (-> a1-2 num-params) 1) - (set! (-> a1-2 message) 'teleport-to-transformq) - (set! (-> a1-2 param 0) (the-as uint gp-0)) - (send-event-function *camera* a1-2) - ) - ) - (none) ) - ) - diff --git a/goal_src/engine/camera/cam-update-h.gc b/goal_src/engine/camera/cam-update-h.gc index 8364d8049a..9fac4200d9 100644 --- a/goal_src/engine/camera/cam-update-h.gc +++ b/goal_src/engine/camera/cam-update-h.gc @@ -5,58 +5,12 @@ ;; name in dgo: cam-update-h ;; dgos: GAME, ENGINE -;; NOTE - not defined in the actual game, this is the only file this is stored to! -(define-extern *camera-other-root* vector) -(define-extern *camera-other-trans* vector) -;; NOTE - these one is also wrote to in cam-layout, but that file is compiled later -(define-extern *camera-look-through-other* int) -(rlet ((vf0 :class vf)) - (init-vf0-vector) - - ;; definition for symbol *external-cam-options*, type int - (define *external-cam-options* 0) - - ;; definition for symbol *external-cam-mode*, type symbol - (define *external-cam-mode* #f) - - ;; failed to figure out what this is: - (when (or (not *camera-look-through-other*) (zero? *camera-look-through-other*)) - (set! *camera-look-through-other* 0) - (let ((v1-4 0)) - ) - ) - - ;; definition (perm) for symbol *camera-other-fov*, type bfloat - (define-perm *camera-other-fov* bfloat (new 'static 'bfloat :data 11650.845)) - - ;; failed to figure out what this is: - (when (or (not *camera-other-trans*) (zero? *camera-other-trans*)) - (let ((v1-15 (new 'global 'vector))) - (.svf (&-> v1-15 quad) vf0) - (set! *camera-other-trans* v1-15) - ) - ) - - ;; definition (perm) for symbol *camera-other-matrix*, type matrix - (define-perm *camera-other-matrix* matrix - (matrix-identity! (new 'global 'matrix)) - ) - - ;; definition (perm) for symbol *camera-smush-control*, type smush-control - (define-perm *camera-smush-control* smush-control - (set-zero! (new 'global 'smush-control)) - ) - - ;; failed to figure out what this is: - (when (or (not *camera-other-root*) (zero? *camera-other-root*)) - (let ((v1-34 (new 'global 'vector))) - (.svf (&-> v1-34 quad) vf0) - (set! *camera-other-root* v1-34) - ) - ) - - ;; failed to figure out what this is: - (none) - -) +(define *external-cam-options* 0) +(define *external-cam-mode* #f) +(define-perm *camera-look-through-other* int 0) +(define-perm *camera-other-fov* bfloat (new 'static 'bfloat :data 11650.845)) +(define-perm *camera-other-trans* vector (vector-reset! (new 'global 'vector))) +(define-perm *camera-other-matrix* matrix (matrix-identity! (new 'global 'matrix))) +(define-perm *camera-smush-control* smush-control (set-zero! (new 'global 'smush-control))) +(define-perm *camera-other-root* vector (vector-reset! (new 'global 'vector))) diff --git a/goal_src/engine/camera/camera-h.gc b/goal_src/engine/camera/camera-h.gc index d87195f1e2..b2343707e8 100644 --- a/goal_src/engine/camera/camera-h.gc +++ b/goal_src/engine/camera/camera-h.gc @@ -24,19 +24,18 @@ ) ;; definition for symbol *CAMERA-bank*, type camera-bank -(define - *CAMERA-bank* - (new 'static 'camera-bank - :collide-move-rad 1638.4 - :min-detectable-velocity 40.96 - :attack-timeout #x4b - :default-string-max-y 12288.0 - :default-string-min-y 4096.0 - :default-string-max-z 51200.0 - :default-string-min-z 20480.0 - :default-string-push-z 40960.0 - :default-tilt-adjust -1183.289 - ) +(define *CAMERA-bank* + (new 'static 'camera-bank + :collide-move-rad 1638.4 + :min-detectable-velocity 40.96 + :attack-timeout #x4b + :default-string-max-y 12288.0 + :default-string-min-y 4096.0 + :default-string-max-z 51200.0 + :default-string-min-z 20480.0 + :default-string-push-z 40960.0 + :default-tilt-adjust -1183.289 + ) ) ;; definition of type cam-index @@ -48,9 +47,9 @@ :size-assert #x30 :flag-assert #xb00000030 (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) - ) + (dummy-9 () none 9) + (dummy-10 () none 10) + ) ) ;; definition of type tracking-point (deftype tracking-point (structure) @@ -96,22 +95,22 @@ :size-assert #x664 :flag-assert #x1800000664 (: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) - (dummy-16 () none 16) - (dummy-17 () none 17) - (dummy-18 () none 18) - (dummy-19 () none 19) - (dummy-20 () none 20) - (dummy-21 () none 21) - (dummy-22 () none 22) - (dummy-23 () none 23) - ) + (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) + (dummy-16 () none 16) + (dummy-17 () none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + (dummy-20 () none 20) + (dummy-21 () none 21) + (dummy-22 () none 22) + (dummy-23 () none 23) + ) ) ;; definition of type cam-float-seeker @@ -128,19 +127,16 @@ :size-assert #x18 :flag-assert #xd00000018 (:methods - (init-cam-float-seeker (_type_ float float float float) none 9) - (copy-cam-float-seeker (_type_ _type_) none 10) - (TODO-RENAME-11 (_type_ float) none 11) - (TODO-RENAME-12 (_type_ float) float 12) - ) + (init-cam-float-seeker (_type_ float float float float) none 9) + (copy-cam-float-seeker (_type_ _type_) none 10) + (TODO-RENAME-11 (_type_ float) none 11) + (TODO-RENAME-12 (_type_ float) float 12) + ) ) ;; definition for method 9 of type cam-float-seeker ;; INFO: Return type mismatch int vs none. -(defmethod - init-cam-float-seeker - cam-float-seeker - ((obj cam-float-seeker) (arg0 float) (arg1 float) (arg2 float) (arg3 float)) +(defmethod init-cam-float-seeker cam-float-seeker ((obj cam-float-seeker) (arg0 float) (arg1 float) (arg2 float) (arg3 float)) (set! (-> obj target) arg0) (set! (-> obj value) arg0) (set! (-> obj vel) 0.0) @@ -152,10 +148,7 @@ ;; definition for method 10 of type cam-float-seeker ;; INFO: Return type mismatch int vs none. -(defmethod - copy-cam-float-seeker - cam-float-seeker - ((obj cam-float-seeker) (arg0 cam-float-seeker)) +(defmethod copy-cam-float-seeker cam-float-seeker ((obj cam-float-seeker) (arg0 cam-float-seeker)) (set! (-> obj target) (-> arg0 target)) (set! (-> obj value) (-> arg0 value)) (set! (-> obj vel) (-> arg0 vel)) @@ -169,26 +162,26 @@ ;; INFO: Return type mismatch int vs none. (defmethod TODO-RENAME-11 cam-float-seeker ((obj cam-float-seeker) (arg0 float)) (let ((f0-0 0.0)) - ) + ) (let ((f0-1 0.0)) - ) + ) (let* ((f1-2 (- (+ (-> obj target) arg0) (-> obj value))) (f0-5 (* (-> obj max-partial) (fabs f1-2))) ) - (let ((f1-3 (* f1-2 (* (-> obj accel) (-> *display* time-adjust-ratio))))) - (set! (-> obj vel) (+ (-> obj vel) f1-3)) + (let ((f1-3 (* f1-2 (* (-> obj accel) (-> *display* time-adjust-ratio))))) + (set! (-> obj vel) (+ (-> obj vel) f1-3)) + ) + (let ((f1-6 (fabs (-> obj vel))) + (f0-6 (fmin f0-5 (-> obj max-vel))) + ) + (if (< f0-6 f1-6) + (set! (-> obj vel) (* (-> obj vel) (/ f0-6 f1-6))) + ) + ) ) - (let ((f1-6 (fabs (-> obj vel))) - (f0-6 (fmin f0-5 (-> obj max-vel))) - ) - (if (< f0-6 f1-6) - (set! (-> obj vel) (* (-> obj vel) (/ f0-6 f1-6))) - ) - ) - ) (let ((f0-10 (* (-> obj vel) (-> *display* time-adjust-ratio)))) - (set! (-> obj value) (+ (-> obj value) f0-10)) - ) + (set! (-> obj value) (+ (-> obj value) f0-10)) + ) (none) ) @@ -196,9 +189,9 @@ (defmethod TODO-RENAME-12 cam-float-seeker ((obj cam-float-seeker) (arg0 float)) (set! (-> obj value) (+ (-> obj target) arg0)) (let ((f0-2 0.0)) - (set! (-> obj vel) f0-2) - f0-2 - ) + (set! (-> obj vel) f0-2) + f0-2 + ) ) ;; definition of type cam-vector-seeker @@ -214,48 +207,42 @@ :size-assert #x3c :flag-assert #xb0000003c (:methods - (TODO-RENAME-9 (_type_ vector float float float) none 9) - (TODO-RENAME-10 (_type_ vector) none 10) - ) + (TODO-RENAME-9 (_type_ vector float float float) none 9) + (TODO-RENAME-10 (_type_ vector) none 10) + ) ) ;; definition for method 9 of type cam-vector-seeker ;; INFO: Return type mismatch int vs none. ;; Used lq/sq -(defmethod - TODO-RENAME-9 - cam-vector-seeker - ((obj cam-vector-seeker) (arg0 vector) (arg1 float) (arg2 float) (arg3 float)) +(defmethod TODO-RENAME-9 cam-vector-seeker ((obj cam-vector-seeker) (arg0 vector) (arg1 float) (arg2 float) (arg3 float)) (rlet ((vf0 :class vf)) - (init-vf0-vector) - (cond - (arg0 - (let ((v1-0 (-> obj target))) - (set! (-> v1-0 quad) (-> arg0 quad)) + (init-vf0-vector) + (cond + (arg0 + (let ((v1-0 (-> obj target))) + (set! (-> v1-0 quad) (-> arg0 quad)) + ) + (let ((v1-1 (-> obj value))) + (set! (-> v1-1 quad) (-> arg0 quad)) + ) + ) + (else + (.svf (&-> (-> obj target) quad) vf0) + (.svf (&-> (-> obj value) quad) vf0) + ) ) - (let ((v1-1 (-> obj value))) - (set! (-> v1-1 quad) (-> arg0 quad)) - ) - ) - (else - (.svf (&-> (-> obj target) quad) vf0) - (.svf (&-> (-> obj value) quad) vf0) - ) + (.svf (&-> (-> obj vel) quad) vf0) + (set! (-> obj accel) arg1) + (set! (-> obj max-vel) arg2) + (set! (-> obj max-partial) arg3) + (none) ) - (.svf (&-> (-> obj vel) quad) vf0) - (set! (-> obj accel) arg1) - (set! (-> obj max-vel) arg2) - (set! (-> obj max-partial) arg3) - (none) - ) ) ;; definition for method 10 of type cam-vector-seeker ;; INFO: Return type mismatch int vs none. -(defmethod - TODO-RENAME-10 - cam-vector-seeker - ((obj cam-vector-seeker) (arg0 vector)) +(defmethod TODO-RENAME-10 cam-vector-seeker ((obj cam-vector-seeker) (arg0 vector)) (rlet ((vf0 :class vf) (vf1 :class vf) (vf2 :class vf) @@ -263,117 +250,117 @@ (vf5 :class vf) (vf6 :class vf) ) - (init-vf0-vector) - (let ((gp-0 (new 'stack-no-clear 'vector))) - (let ((f0-0 0.0)) - ) - (cond - (arg0 - (let ((a0-1 gp-0)) - (let ((v1-0 (-> obj target))) - (.mov.vf vf6 vf0 :mask #b1000) - (.lvf vf4 (&-> v1-0 quad)) + (init-vf0-vector) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((f0-0 0.0)) ) - (.lvf vf5 (&-> arg0 quad)) - (.add.vf vf6 vf4 vf5 :mask #b111) - (.svf (&-> a0-1 quad) vf6) - ) - (let ((a1-1 gp-0)) - (let ((v1-1 gp-0) - (a0-2 (-> obj value)) + (cond + (arg0 + (let ((a0-1 gp-0)) + (let ((v1-0 (-> obj target))) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> v1-0 quad)) ) - (.lvf vf4 (&-> v1-1 quad)) - (.lvf vf5 (&-> a0-2 quad)) - ) - (.mov.vf vf6 vf0 :mask #b1000) - (.sub.vf vf6 vf4 vf5 :mask #b111) - (.svf (&-> a1-1 quad) vf6) - ) - ) - (else - (let ((a1-2 gp-0)) - (let ((v1-2 (-> obj target)) - (a0-3 (-> obj value)) - ) - (.lvf vf4 (&-> v1-2 quad)) - (.lvf vf5 (&-> a0-3 quad)) - ) - (.mov.vf vf6 vf0 :mask #b1000) - (.sub.vf vf6 vf4 vf5 :mask #b111) - (.svf (&-> a1-2 quad) vf6) - ) - ) - ) - (let ((f30-1 (* (-> obj max-partial) (vector-length gp-0)))) - (let ((v1-3 gp-0)) - (let ((a0-5 gp-0) - (f0-3 (* (-> obj accel) (-> *display* time-adjust-ratio))) - ) - (.lvf vf1 (&-> a0-5 quad)) - (let ((a0-6 f0-3)) - (.mov vf2 a0-6) - ) - ) - (.add.x.vf vf1 vf0 vf0 :mask #b1000) - (.mul.x.vf vf1 vf1 vf2 :mask #b111) - (.svf (&-> v1-3 quad) vf1) - ) - (let ((a1-4 (-> obj vel))) - (let ((v1-4 (-> obj vel)) - (a0-7 gp-0) - ) - (.mov.vf vf6 vf0 :mask #b1000) - (.lvf vf4 (&-> v1-4 quad)) - (.lvf vf5 (&-> a0-7 quad)) - ) - (.add.vf vf6 vf4 vf5 :mask #b111) - (.svf (&-> a1-4 quad) vf6) - ) - (let ((f0-4 (vector-length (-> obj vel))) - (f1-2 (fmin f30-1 (-> obj max-vel))) + (.lvf vf5 (&-> arg0 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a0-1 quad) vf6) + ) + (let ((a1-1 gp-0)) + (let ((v1-1 gp-0) + (a0-2 (-> obj value)) + ) + (.lvf vf4 (&-> v1-1 quad)) + (.lvf vf5 (&-> a0-2 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-1 quad) vf6) ) - (when (< f1-2 f0-4) - (let ((v1-6 (-> obj vel))) - (let ((a0-9 (-> obj vel)) - (f0-5 (/ f1-2 f0-4)) - ) - (.lvf vf1 (&-> a0-9 quad)) - (let ((a0-10 f0-5)) - (.mov vf2 a0-10) - ) ) + (else + (let ((a1-2 gp-0)) + (let ((v1-2 (-> obj target)) + (a0-3 (-> obj value)) + ) + (.lvf vf4 (&-> v1-2 quad)) + (.lvf vf5 (&-> a0-3 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-2 quad) vf6) + ) + ) + ) + (let ((f30-1 (* (-> obj max-partial) (vector-length gp-0)))) + (let ((v1-3 gp-0)) + (let ((a0-5 gp-0) + (f0-3 (* (-> obj accel) (-> *display* time-adjust-ratio))) + ) + (.lvf vf1 (&-> a0-5 quad)) + (let ((a0-6 f0-3)) + (.mov vf2 a0-6) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> v1-3 quad) vf1) + ) + (let ((a1-4 (-> obj vel))) + (let ((v1-4 (-> obj vel)) + (a0-7 gp-0) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> v1-4 quad)) + (.lvf vf5 (&-> a0-7 quad)) + ) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-4 quad) vf6) + ) + (let ((f0-4 (vector-length (-> obj vel))) + (f1-2 (fmin f30-1 (-> obj max-vel))) + ) + (when (< f1-2 f0-4) + (let ((v1-6 (-> obj vel))) + (let ((a0-9 (-> obj vel)) + (f0-5 (/ f1-2 f0-4)) + ) + (.lvf vf1 (&-> a0-9 quad)) + (let ((a0-10 f0-5)) + (.mov vf2 a0-10) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> v1-6 quad) vf1) + ) + ) + ) + ) + (let ((v1-7 gp-0)) + (let ((a0-11 (-> obj vel)) + (f0-6 (-> *display* time-adjust-ratio)) + ) + (.lvf vf1 (&-> a0-11 quad)) + (let ((a0-12 f0-6)) + (.mov vf2 a0-12) + ) + ) (.add.x.vf vf1 vf0 vf0 :mask #b1000) (.mul.x.vf vf1 vf1 vf2 :mask #b111) - (.svf (&-> v1-6 quad) vf1) + (.svf (&-> v1-7 quad) vf1) + ) + (let ((v1-8 (-> obj value))) + (let ((a0-13 (-> obj value))) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-13 quad)) + ) + (.lvf vf5 (&-> gp-0 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-8 quad) vf6) ) - ) ) - ) - (let ((v1-7 gp-0)) - (let ((a0-11 (-> obj vel)) - (f0-6 (-> *display* time-adjust-ratio)) - ) - (.lvf vf1 (&-> a0-11 quad)) - (let ((a0-12 f0-6)) - (.mov vf2 a0-12) - ) - ) - (.add.x.vf vf1 vf0 vf0 :mask #b1000) - (.mul.x.vf vf1 vf1 vf2 :mask #b111) - (.svf (&-> v1-7 quad) vf1) - ) - (let ((v1-8 (-> obj value))) - (let ((a0-13 (-> obj value))) - (.mov.vf vf6 vf0 :mask #b1000) - (.lvf vf4 (&-> a0-13 quad)) - ) - (.lvf vf5 (&-> gp-0 quad)) - (.add.vf vf6 vf4 vf5 :mask #b111) - (.svf (&-> v1-8 quad) vf6) - ) + (none) ) - (none) - ) ) ;; definition of type cam-rotation-tracker diff --git a/goal_src/engine/collide/collide-shape-h.gc b/goal_src/engine/collide/collide-shape-h.gc index 49f70d0c28..94b3ea3d0a 100644 --- a/goal_src/engine/collide/collide-shape-h.gc +++ b/goal_src/engine/collide/collide-shape-h.gc @@ -286,7 +286,7 @@ ;; an actual instance of a collision primitive. ;; it's based on a transform (q means quaternion, v means with derivatives) (deftype collide-shape (trsqv) - ((process basic :offset-assert 140) + ((process process :offset-assert 140) (max-iteration-count uint8 :offset-assert 144) (nav-flags uint8 :offset-assert 145) (pad-byte uint8 2 :offset-assert 146) diff --git a/goal_src/engine/data/res-h.gc b/goal_src/engine/data/res-h.gc index 4723220eb9..d01b7a6c82 100644 --- a/goal_src/engine/data/res-h.gc +++ b/goal_src/engine/data/res-h.gc @@ -44,7 +44,7 @@ (get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer :no-virtual 9) (get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure :no-virtual 10) (get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 :no-virtual 11) - (get-property-value2 (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 :no-virtual 12) + (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float :no-virtual 12) (get-tag-index-data (_type_ int) pointer 13) (get-tag-data (_type_ res-tag) pointer 14) (dummy-15 (_type_ res-tag) res-tag 15) diff --git a/goal_src/engine/data/res.gc b/goal_src/engine/data/res.gc index 58f2bb4820..a60c72bf6c 100644 --- a/goal_src/engine/data/res.gc +++ b/goal_src/engine/data/res.gc @@ -594,7 +594,7 @@ This is updated from the entity system used in Crash 2, which had most of these ) ) -(defmethod get-property-value2 res-lump ((obj res-lump) (name symbol) (mode symbol) (time float) (default uint128) (tag-addr (pointer res-tag)) (buf-addr pointer)) +(defmethod get-property-value-float res-lump ((obj res-lump) (name symbol) (mode symbol) (time float) (default float) (tag-addr (pointer res-tag)) (buf-addr pointer)) "same as get-property-value but float type is checked first?" (let ((tag-pair (lookup-tag-idx obj name mode time))) @@ -612,24 +612,24 @@ This is updated from the entity system used in Crash 2, which had most of these ) (cond ((type-type? tag-type float) - (set! default (the-as uint128 (deref float data))) + (set! default (deref float data)) ) ((type-type? tag-type uinteger) (case (-> tag elt-type size) - ((1) (set! default (the-as uint128 (deref uint8 data)))) - ((2) (set! default (the-as uint128 (deref uint16 data)))) - ((4) (set! default (the-as uint128 (deref uint32 data)))) - ((16) (set! default (the-as uint128 (deref uint128 data)))) - (else (set! default (the-as uint128 (deref uint64 data)))) + ((1) (set! default (the float (deref uint8 data)))) + ((2) (set! default (the float (deref uint16 data)))) + ((4) (set! default (the float (deref uint32 data)))) + ((16) (set! default (the float (deref uint128 data)))) + (else (set! default (the float (deref uint64 data)))) ) ) ((type-type? tag-type integer) (case (-> tag elt-type size) - ((1) (set! default (the-as uint128 (deref int8 data)))) - ((2) (set! default (the-as uint128 (deref int16 data)))) - ((4) (set! default (the-as uint128 (deref int32 data)))) - ((16) (set! default (the-as uint128 (deref uint128 data)))) - (else (set! default (the-as uint128 (deref uint64 data)))) + ((1) (set! default (the float (deref int8 data)))) + ((2) (set! default (the float (deref int16 data)))) + ((4) (set! default (the float (deref int32 data)))) + ((16) (set! default (the float (deref uint128 data)))) + (else (set! default (the float (deref uint64 data)))) ) ) (else @@ -645,16 +645,15 @@ This is updated from the entity system used in Crash 2, which had most of these (defmacro res-lump-float (lump name &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default 0.0)) "Helper macro to get a float from a res-lump with no interpolation." - `(the-as float ((method-of-type res-lump get-property-value2) + `((method-of-type res-lump get-property-value-float) ,lump ,name 'interp -1000000000.0 - (the-as uint128 ,default) + ,default ,tag-ptr *res-static-buf* ) - ) ) (defmethod sort! res-lump ((obj res-lump)) @@ -697,7 +696,7 @@ This is updated from the entity system used in Crash 2, which had most of these (curve-data (get-property-data obj points-name 'exact time (the pointer #f) (& points-tag) *res-static-buf*))) (when curve-data - (set! (-> curve-target cverts) (the uint curve-data)) + (set! (-> curve-target cverts) curve-data) (set! (-> curve-target num-cverts) (the int (-> points-tag elt-count))) (when (< MAX_CURVE_CONTROL_POINTS (-> curve-target num-cverts)) @@ -712,7 +711,7 @@ This is updated from the entity system used in Crash 2, which had most of these (set! curve-data (get-property-data obj knots-name 'exact time (the pointer #f) (& knots-tag) *res-static-buf*)) (when curve-data - (set! (-> curve-target knots) (the uint curve-data)) + (set! (-> curve-target knots) curve-data) (set! (-> curve-target num-knots) (the int (-> knots-tag elt-count))) (set! result #t) ) diff --git a/goal_src/engine/entity/actor-link-h.gc b/goal_src/engine/entity/actor-link-h.gc index ade91c8dbf..b39d37666c 100644 --- a/goal_src/engine/entity/actor-link-h.gc +++ b/goal_src/engine/entity/actor-link-h.gc @@ -84,9 +84,9 @@ (apply-function-forward (_type_ (function entity-actor object object) object) int 16) (apply-function-reverse (_type_ (function entity-actor object object) object) int 17) (apply-all (_type_ (function entity-actor object object) object) int 18) - (dummy-19 (_type_ object) none 19) - (dummy-20 (_type_ object) none 20) - (dummy-21 (_type_ object) none 21) + (send-to-all (_type_ object) none 19) + (send-to-all-after (_type_ object) object 20) + (send-to-all-before (_type_ object) object 21) (send-to-next-and-prev (_type_ object) none 22) (send-to-next (_type_ object) none 23) (send-to-prev (_type_ object) none 24) @@ -221,7 +221,56 @@ 0 ) -;; TODO: 20 and 21 don't decompile yet +;; method 20 +(defmethod send-to-all-after actor-link-info ((obj actor-link-info) (message object)) + (with-pp + (let ((iter (-> obj next)) + (result (the object #f))) + (while iter + (let ((proc (-> (the entity-links (-> iter extra)) process))) + (when proc + (let ((msg-block (new 'stack-no-clear 'event-message-block))) + (set! (-> msg-block from) pp) + (set! (-> msg-block num-params) 0) + (set! (-> msg-block message) (the basic message)) + + (let ((send-result (send-event-function (the process proc) msg-block))) + (set! result (and result send-result)) + ) + ) + ) + (set! iter (entity-actor-lookup iter 'next-actor 0)) + ) + ) + result + ) + ) + ) + +(defmethod send-to-all-before actor-link-info ((obj actor-link-info) (message object)) + (with-pp + (let ((iter (-> obj prev)) + (result (the object #f))) + (while iter + (let ((proc (-> (the entity-links (-> iter extra)) process))) + (when proc + (let ((msg-block (new 'stack-no-clear 'event-message-block))) + (set! (-> msg-block from) pp) + (set! (-> msg-block num-params) 0) + (set! (-> msg-block message) (the basic message)) + + (let ((send-result (send-event-function (the process proc) msg-block))) + (set! result (and result send-result)) + ) + ) + ) + (set! iter (entity-actor-lookup iter 'prev-actor 0)) + ) + ) + result + ) + ) + ) (defmethod send-to-next actor-link-info ((obj actor-link-info) (arg0 object)) "Send event arg0 to the next actor's process" @@ -277,9 +326,9 @@ (none) ) -(defmethod dummy-19 actor-link-info ((obj actor-link-info) (arg0 object)) - (dummy-20 obj arg0) - (dummy-21 obj arg0) +(defmethod send-to-all actor-link-info ((obj actor-link-info) (arg0 object)) + (send-to-all-after obj arg0) + (send-to-all-before obj arg0) (none) ) diff --git a/goal_src/engine/entity/entity-h.gc b/goal_src/engine/entity/entity-h.gc index e243255ccd..f67892dad0 100644 --- a/goal_src/engine/entity/entity-h.gc +++ b/goal_src/engine/entity/entity-h.gc @@ -17,6 +17,7 @@ (defenum entity-perm-status :bitfield #t :type uint16 + (bit-1 1) (dead 2) (complete 6)) @@ -52,7 +53,7 @@ (next-link entity-links :offset-assert 4) (entity basic :offset-assert 8) (process process :offset-assert 12) - (level basic :offset-assert 16) + (level level :offset-assert 16) (vis-id int32 :offset-assert 20) (trans vector :inline :offset-assert 32) (perm entity-perm :inline :offset-assert 48) diff --git a/goal_src/engine/geometry/geometry-h.gc b/goal_src/engine/geometry/geometry-h.gc index 87e9844256..4d0b421fd7 100644 --- a/goal_src/engine/geometry/geometry-h.gc +++ b/goal_src/engine/geometry/geometry-h.gc @@ -8,9 +8,9 @@ (defconstant MAX_CURVE_CONTROL_POINTS 256) (deftype curve (structure) - ((cverts uint32 :offset-assert 0) + ((cverts pointer :offset-assert 0) (num-cverts int32 :offset-assert 4) - (knots uint32 :offset-assert 8) + (knots pointer :offset-assert 8) (num-knots int32 :offset-assert 12) (length float :offset-assert 16) ) diff --git a/goal_src/engine/geometry/vol-h.gc b/goal_src/engine/geometry/vol-h.gc index 112f858601..16e3ed1f25 100644 --- a/goal_src/engine/geometry/vol-h.gc +++ b/goal_src/engine/geometry/vol-h.gc @@ -51,135 +51,126 @@ ;; definition for method 0 of type vol-control ;; INFO: Return type mismatch object vs vol-control. ;; Used lq/sq -(defmethod - new - vol-control - ((allocation symbol) (type-to-make type) (arg0 process-drawable)) - (local-vars (pp process)) - (let - ((gp-0 - (the-as - object - (object-new allocation type-to-make (the-as int (-> type-to-make size))) - ) - ) - ) - (if (zero? (the-as vol-control gp-0)) - (begin - (let ((t9-1 (the-as (function object object) enter-state)) - (a0-1 "memory") - ) - (set! (-> pp next-state) process-drawable-art-error) - (t9-1 a0-1) - ) - (set! gp-0 0) - (goto cfg-13) - ) - ) - (set! (-> (the-as vol-control gp-0) process) arg0) - (let* ((s5-1 (-> (the-as vol-control gp-0) process entity)) - (s4-0 - (-> - ((method-of-type res-lump lookup-tag-idx) - (the-as res-lump s5-1) - 'vol - 'exact - 0.0 +(defmethod new vol-control ((allocation symbol) (type-to-make type) (arg0 process-drawable)) + (with-pp + (let ((gp-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (if (zero? (the-as vol-control gp-0)) + (begin + (let ((t9-1 (the-as (function object object) enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + (t9-1 a0-1) ) - lo - ) + (set! gp-0 0) + (goto cfg-13) ) ) - (when (>= s4-0 0) - (let ((s3-0 s4-0) - (s2-0 (-> (-> (the-as res-lump s5-1) tag) s4-0)) - ) - (let ((v1-10 0)) - ) - (while (= (-> s2-0 name) (-> (-> (the-as res-lump s5-1) tag) s4-0 name)) - (let - ((v1-12 - (make-property-data - (the-as res-lump s5-1) - 0.0 - (the-as res-tag-pair s3-0) - (the-as pointer #f) - ) - ) - (a0-8 - (-> - (the-as vol-control gp-0) - pos-vol - (-> (the-as vol-control gp-0) pos-vol-count) - ) - ) - ) - (set! (-> a0-8 num-planes) (the-as int (-> s2-0 elt-count))) - (set! (-> a0-8 plane) (the-as uint v1-12)) - ) - (set! - (-> (the-as vol-control gp-0) pos-vol-count) - (+ (-> (the-as vol-control gp-0) pos-vol-count) 1) - ) - (+! s3-0 1) - (set! s2-0 (-> (-> (the-as res-lump s5-1) tag) s3-0)) - ) - ) - ) - ) - (let* ((s5-2 (-> (the-as vol-control gp-0) process entity)) - (s4-1 - (-> - ((method-of-type res-lump lookup-tag-idx) - (the-as res-lump s5-2) - 'cutoutvol - 'exact - 0.0 + (set! (-> (the-as vol-control gp-0) process) arg0) + (let* ((s5-1 (-> (the-as vol-control gp-0) process entity)) + (s4-0 + (-> + ((method-of-type res-lump lookup-tag-idx) + (the-as res-lump s5-1) + 'vol + 'exact + 0.0 + ) + lo + ) + ) ) - lo + (when (>= s4-0 0) + (let ((s3-0 s4-0) + (s2-0 (-> (-> (the-as res-lump s5-1) tag) s4-0)) + ) + (let ((v1-10 0)) + ) + (while (= (-> s2-0 name) (-> (-> (the-as res-lump s5-1) tag) s4-0 name)) + (let + ((v1-12 + (make-property-data + (the-as res-lump s5-1) + 0.0 + (the-as res-tag-pair s3-0) + (the-as pointer #f) + ) + ) + (a0-8 + (-> + (the-as vol-control gp-0) + pos-vol + (-> (the-as vol-control gp-0) pos-vol-count) + ) + ) + ) + (set! (-> a0-8 num-planes) (the-as int (-> s2-0 elt-count))) + (set! (-> a0-8 plane) (the-as uint v1-12)) + ) + (set! + (-> (the-as vol-control gp-0) pos-vol-count) + (+ (-> (the-as vol-control gp-0) pos-vol-count) 1) + ) + (+! s3-0 1) + (set! s2-0 (-> (-> (the-as res-lump s5-1) tag) s3-0)) + ) ) - ) ) - (when (>= s4-1 0) - (let ((s3-1 s4-1) - (s2-1 (-> (-> (the-as res-lump s5-2) tag) s4-1)) - ) - (let ((v1-29 0)) - ) - (while (= (-> s2-1 name) (-> (-> (the-as res-lump s5-2) tag) s4-1 name)) - (let - ((v1-31 - (make-property-data - (the-as res-lump s5-2) - 0.0 - (the-as res-tag-pair s3-1) - (the-as pointer #f) - ) - ) - (a0-19 - (-> - (the-as vol-control gp-0) - neg-vol - (-> (the-as vol-control gp-0) neg-vol-count) - ) - ) - ) - (set! (-> a0-19 num-planes) (the-as int (-> s2-1 elt-count))) - (set! (-> a0-19 plane) (the-as uint v1-31)) ) - (set! - (-> (the-as vol-control gp-0) neg-vol-count) - (+ (-> (the-as vol-control gp-0) neg-vol-count) 1) + (let* ((s5-2 (-> (the-as vol-control gp-0) process entity)) + (s4-1 + (-> + ((method-of-type res-lump lookup-tag-idx) + (the-as res-lump s5-2) + 'cutoutvol + 'exact + 0.0 + ) + lo + ) + ) + ) + (when (>= s4-1 0) + (let ((s3-1 s4-1) + (s2-1 (-> (-> (the-as res-lump s5-2) tag) s4-1)) + ) + (let ((v1-29 0)) + ) + (while (= (-> s2-1 name) (-> (-> (the-as res-lump s5-2) tag) s4-1 name)) + (let + ((v1-31 + (make-property-data + (the-as res-lump s5-2) + 0.0 + (the-as res-tag-pair s3-1) + (the-as pointer #f) + ) + ) + (a0-19 + (-> + (the-as vol-control gp-0) + neg-vol + (-> (the-as vol-control gp-0) neg-vol-count) + ) + ) + ) + (set! (-> a0-19 num-planes) (the-as int (-> s2-1 elt-count))) + (set! (-> a0-19 plane) (the-as uint v1-31)) + ) + (set! + (-> (the-as vol-control gp-0) neg-vol-count) + (+ (-> (the-as vol-control gp-0) neg-vol-count) 1) + ) + (+! s3-1 1) + (set! s2-1 (-> (-> (the-as res-lump s5-2) tag) s3-1)) + ) + ) + ) ) - (+! s3-1 1) - (set! s2-1 (-> (-> (the-as res-lump s5-2) tag) s3-1)) - ) + (label cfg-13) + (the-as vol-control gp-0) ) - ) ) - (label cfg-13) - (the-as vol-control gp-0) - ) ) ;; definition for method 11 of type vol-control diff --git a/goal_src/engine/nav/navigate-h.gc b/goal_src/engine/nav/navigate-h.gc index 553b9b2e3a..6861bb4f3b 100644 --- a/goal_src/engine/nav/navigate-h.gc +++ b/goal_src/engine/nav/navigate-h.gc @@ -5,3 +5,427 @@ ;; name in dgo: navigate-h ;; dgos: GAME, ENGINE +(defenum nav-control-flags + :bitfield #t + :type uint32 + (display-marks 0) + (bit8 8) + (bit13 13) + ) + +(deftype nav-poly (structure) + ((id uint8 :offset-assert 0) + (vertex uint8 3 :offset-assert 1) + (adj-poly uint8 3 :offset-assert 4) + (pat uint8 :offset-assert 7) ;; pat-material, mode, event? + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype nav-vertex (vector) + () + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype nav-sphere (structure) + ((trans sphere :inline :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype nav-ray (structure) + ((current-pos vector :inline :offset-assert 0) + (dir vector :inline :offset-assert 16) + (dest-pos vector :inline :offset-assert 32) + (current-poly nav-poly :offset-assert 48) + (next-poly nav-poly :offset-assert 52) + (len float :offset-assert 56) + (last-edge int8 :offset-assert 60) + (terminated basic :offset-assert 64) + (reached-dest basic :offset-assert 68) + (hit-boundary basic :offset-assert 72) + (hit-gap basic :offset-assert 76) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + +(deftype nav-route-portal (structure) + ((next-poly nav-poly :offset-assert 0) + (vertex nav-vertex 2 :offset-assert 4) + (edge-index int8 :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #xd + :flag-assert #x90000000d + ) + + +(deftype clip-travel-vector-to-mesh-return-info (structure) + ((found-boundary basic :offset-assert 0) + (intersection vector :inline :offset-assert 16) + (boundary-normal vector :inline :offset-assert 32) + (prev-normal vector :inline :offset-assert 48) + (next-normal vector :inline :offset-assert 64) + (poly nav-poly :offset-assert 80) + (gap-poly nav-poly :offset-assert 84) + (edge int32 :offset-assert 88) + (vert-prev vector :inline :offset-assert 96) + (vert-0 vector :inline :offset-assert 112) + (vert-1 vector :inline :offset-assert 128) + (vert-next vector :inline :offset-assert 144) + ) + :method-count-assert 9 + :size-assert #xa0 + :flag-assert #x9000000a0 + ) + +(deftype nav-node (structure) + ((center-x float :offset-assert 0) + (center-y float :offset-assert 4) + (center-z float :offset-assert 8) + (type uint16 :offset-assert 12) + (parent-offset uint16 :offset-assert 14) + (center vector :inline :offset 0) + (radius-x float :offset-assert 16) + (radius-y float :offset-assert 20) + (radius-z float :offset-assert 24) + (left-offset uint16 :offset-assert 28) + (right-offset uint16 :offset-assert 30) + (num-tris uint32 :offset 28) + (radius vector :inline :offset 16) + (scale-x float :offset-assert 32) + (first-tris uint8 4 :offset-assert 36) + (scale-z float :offset-assert 40) + (last-tris uint8 4 :offset-assert 44) + (scale vector :inline :offset 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype nav-lookup-elem (structure) + ((vec vector :inline :offset-assert 0) + (y-thresh float :offset 12) + (time uint32 :offset-assert 16) + (node-offset uint32 :offset-assert 20) + (lookup-type uint8 :offset-assert 24) + (poly-ind uint8 :offset-assert 25) + (dummy0 uint16 :offset-assert 26) + (dummy uint32 :offset-assert 28) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype nav-mesh (basic) + ((user-list engine :offset-assert 4) + (poly-lookup-history uint8 2 :offset-assert 8) + (debug-time uint8 :offset-assert 10) + (static-sphere-count uint8 :offset-assert 11) + (static-sphere uint32 :offset-assert 12) + (bounds sphere :inline :offset-assert 16) + (origin vector :inline :offset-assert 32) + (cache nav-lookup-elem 4 :inline :offset-assert 48) + (node-count int32 :offset-assert 176) + (nodes uint32 :offset-assert 180) + (vertex-count int32 :offset-assert 184) + (vertex uint32 :offset-assert 188) + (poly-count int32 :offset-assert 192) + (poly uint32 :offset-assert 196) + (route uint32 :offset-assert 200) + ) + :method-count-assert 30 + :size-assert #xcc + :flag-assert #x1e000000cc + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 (_type_) none 13) + (dummy-14 () none 14) + (dummy-15 () none 15) + (dummy-16 () none 16) + (dummy-17 (_type_) none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + (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) + ) + ) + +(define-extern *default-nav-mesh* nav-mesh) + +(deftype check-vector-collision-with-nav-spheres-info (structure) + ((u float :offset-assert 0) + (intersect vector :inline :offset-assert 16) + (normal vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype nav-gap-info (structure) + ((dest vector :inline :offset-assert 0) + (poly nav-poly :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x14 + :flag-assert #x900000014 + ) + +(deftype nav-control (basic) + ((flags nav-control-flags :offset-assert 4) + (process basic :offset-assert 8) + (shape collide-shape :offset-assert 12) + (mesh nav-mesh :offset-assert 16) + (gap-event basic :offset-assert 20) + (block-event basic :offset-assert 24) + (current-poly nav-poly :offset-assert 28) + (next-poly nav-poly :offset-assert 32) + (target-poly nav-poly :offset-assert 36) + (portal nav-route-portal 2 :offset-assert 40) + (nearest-y-threshold float :offset-assert 48) + (event-temp vector :inline :offset-assert 64) + (old-travel vector :inline :offset-assert 80) + (blocked-travel vector :inline :offset-assert 96) + (prev-pos vector :inline :offset-assert 112) + (extra-nav-sphere vector :inline :offset-assert 128) + (travel vector :inline :offset-assert 144) + (target-pos vector :inline :offset-assert 160) + (destination-pos vector :inline :offset-assert 176) + (block-time uint64 :offset-assert 192) + (block-count float :offset-assert 200) + (user-poly nav-poly :offset-assert 204) + (nav-cull-radius float :offset-assert 208) + (num-spheres int16 :offset-assert 212) + (max-spheres int16 :offset-assert 214) + (sphere sphere :inline :dynamic :offset-assert 224) + ) + :method-count-assert 36 + :size-assert #xe0 + :flag-assert #x24000000e0 + (:methods + (new (symbol type collide-shape int float) _type_ 0) + (dummy-9 () none 9) + (point-in-bounds? (_type_ vector) symbol 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + (dummy-14 () none 14) + (set-target-pos! (_type_ vector) none 15) + (dummy-16 () none 16) + (dummy-17 () none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + (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) + (should-display? (_type_) symbol 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) + ) + ) + +(defun nav-mesh-connect ((proc process) (trans trsqv) (nav-cont nav-control)) + (with-pp + ;; try to find an entity with a nav-mesh, first from the given process + (let ((ent (-> proc entity))) + (when (zero? (-> (the-as entity-actor ent) nav-mesh)) + ;; and if that doesn't have one already, lookup from the res-lump + (let ((lookup-entity (entity-actor-lookup (the-as res-lump ent) 'nav-mesh-actor 0))) + (if lookup-entity + (set! ent lookup-entity) + ) + ) + ) + + ;; now, look at the nav-mesh from the entity + (let ((entity-nav-mesh (-> (the-as entity-actor ent) nav-mesh))) + (cond + ((nonzero? entity-nav-mesh) + ;; we have a nav mesh mesh already + (when (zero? (-> entity-nav-mesh user-list)) + ;; but, no engine, maybe because this is the first time we're doing this for the level. + + ;; this seems like a bit of a hack. We'd like to allocate the engine on a level heap. + ;; but I guess we can't assume that process-level-heap is set correctly here. + ;; so we grab the entity-links from the current pp's entity, and look at that level. + ;; I'm not sure why we do this on the current pp instead of the proc we were given... + (set! process-level-heap + (-> (the-as entity-links (-> (the-as entity (-> pp entity)) extra)) level heap) + ) + + ;; now construct the engine, looking up the size from the res-lump. + (set! (-> entity-nav-mesh user-list) + (new 'process-level-heap 'engine 'nav-engine + (the int ((method-of-type res-lump get-property-value) + (the-as res-lump ent) + 'nav-max-users + 'interp + -1000000000.0 + (the-as uint128 32) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + + ;; do some setup + (dummy-13 entity-nav-mesh) + (dummy-17 entity-nav-mesh) + ) + + ;; in all cases, do the connection + ;; connect the nav-mesh engine: + (add-connection (-> entity-nav-mesh user-list) + proc ;; to the given process + (the-as (function object object object object object) nothing) ;; no function + ;; and some weird parameters. + proc + nav-cont + trans + ) + ) + (else + ;; we couldn't find a nav-mesh. Set a bit. + (if (and nav-cont (-> proc entity)) + (set! (-> (the-as entity-links (-> (the-as entity (-> proc entity)) extra)) perm status) + (logior (-> (the-as entity-links (-> (the-as entity (-> proc entity)) extra)) perm status) + (entity-perm-status bit-1) + ) + ) + ) + ;; no nav-mesh, so give us a default-nav-mesh. + (set! entity-nav-mesh *default-nav-mesh*) + ) + ) + entity-nav-mesh + ) + ) + ) + ) + +;; todo fix up this +(defmethod new nav-control ((allocation symbol) (type-to-make type) (shape collide-shape) (sphere-count int) (nearest-y-threshold-default float)) + (with-pp + (let ((obj (object-new allocation type-to-make + (the-as int (+ (-> type-to-make size) (* sphere-count 16))) + ) + ) + ) + ;; check for alloc fail. + (when (zero? obj) + (go process-drawable-art-error "memory") + (set! obj (the-as nav-control 0)) + (goto cfg-4) + ) + ;; set up fields + (set! (-> obj max-spheres) sphere-count) + (set! (-> obj flags) (nav-control-flags bit8 bit13)) + ;; connect things + (set! (-> obj mesh) (nav-mesh-connect (-> shape process) shape obj)) + + ;; get the nearest-y-threshold + (let ((ent (-> shape process entity))) + (set! (-> obj nearest-y-threshold) + ((method-of-type res-lump get-property-value-float) + (the-as res-lump ent) + 'nearest-y-threshold + 'interp + -1000000000.0 + nearest-y-threshold-default + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (set! (-> obj shape) shape) + (set! (-> obj process) (-> shape process)) + (set! (-> obj gap-event) #f) + (set! (-> obj current-poly) #f) + (set! (-> obj next-poly) #f) + (set! (-> obj target-poly) #f) + (set! (-> obj user-poly) #f) + (set! (-> obj portal 0) #f) + (set! (-> obj portal 1) #f) + (set! (-> obj nav-cull-radius) 40960.0) + (label cfg-4) + (the-as nav-control obj) + ) + ) + ) + + +;; definition for method 29 of type nav-control +(defmethod should-display? nav-control ((obj nav-control)) + (and + *display-nav-marks* + (nonzero? (logand (-> obj flags) (nav-control-flags display-marks))) + ) + ) + +(defmethod point-in-bounds? nav-control ((obj nav-control) (arg0 vector)) + "Is the point in bounds?" + (let ((v1-1 (-> obj mesh bounds))) + ;; w is the sphere radius + (>= (-> v1-1 w) (vector-vector-distance arg0 v1-1)) + ) + ) + +(defmethod set-target-pos! nav-control ((obj nav-control) (arg0 vector)) + (set! (-> obj target-pos quad) (-> arg0 quad)) + (none) + ) + +;; definition for function has-nav-mesh? +;; INFO: Return type mismatch structure vs symbol. +(defun has-nav-mesh? ((arg0 entity-actor)) + "Does the actor have a nav mesh? Either loaded an in the nav-mesh field, or in + the res-lump." + (the-as + symbol + (or (-> arg0 nav-mesh) ;; has it loaded already + ;; has it in the res-lump + ((method-of-type res-lump get-property-struct) + arg0 + 'nav-mesh-actor + 'interp + -1000000000.0 + #f + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) diff --git a/goal_src/engine/nav/path-h.gc b/goal_src/engine/nav/path-h.gc index d5fb09d8df..e40c1b3468 100644 --- a/goal_src/engine/nav/path-h.gc +++ b/goal_src/engine/nav/path-h.gc @@ -5,3 +5,168 @@ ;; name in dgo: path-h ;; dgos: GAME, ENGINE +(defenum path-control-flag + :bitfield #t + :type uint32 + (display 0) + (not-found 4) + ) + +;; A path-control is a curve that can be loaded from res-lump/entities. +(deftype path-control (basic) + ((flags path-control-flag :offset-assert 4) + (name basic :offset-assert 8) + (process basic :offset-assert 12) + (curve curve :inline :offset-assert 16) + (num-cverts int32 :offset 20) + (cverts pointer :offset 16) + ) + :method-count-assert 21 + :size-assert #x24 + :flag-assert #x1500000024 + (:methods + (new (symbol type process symbol float) _type_ 0) + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + (dummy-14 () none 14) + (length-as-float (_type_) float 15) + (dummy-16 () none 16) + (get-num-verts (_type_) int 17) + (should-display? (_type_) symbol 18) + (dummy-19 () none 19) + (dummy-20 () none 20) + ) + ) + +;; A curve-control is very similar, but also gets knots. +(deftype curve-control (path-control) + () + :method-count-assert 21 + :size-assert #x24 + :flag-assert #x1500000024 + (:methods + (new (symbol type process symbol float) _type_ 0) + ) + ) + +(defmethod new path-control ((allocation symbol) (type-to-make type) (proc process) (name symbol) (time float)) + (local-vars (tag res-tag)) + (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + + (when (zero? obj) + ;; allocation failed. + (go process-drawable-art-error "memory") + (set! obj (the-as path-control 0)) + (goto cfg-9) + ) + + (set! (-> obj process) proc) + (set! (-> obj name) name) + (let ((ent (-> proc entity))) + (when (= name 'path) + ;; if we are a path, try to look up the path-actor. + (let ((lookup-entity (entity-actor-lookup (the-as res-lump ent) 'path-actor 0))) + (if lookup-entity + (set! ent lookup-entity) + ) + ) + ) + + ;; look up the curve data + (set! tag (new 'static 'res-tag)) + (let ((data ((method-of-type res-lump get-property-data) + (the-as res-lump ent) + name + 'interp + time + (the-as pointer #f) + (& tag) + *res-static-buf* + ) + ) + ) + + (cond + (data + ;; success, we got some data + (set! (-> obj curve cverts) data) + (set! (-> obj curve num-cverts) (the-as int (-> tag elt-count))) + ) + (else + ;; did not find the data. Set flags and zero stuff + (set! (-> obj flags) (logior (-> obj flags) (path-control-flag not-found))) + (set! (-> obj curve cverts) (the-as pointer #f)) + (set! (-> obj curve num-cverts) 0) + ) + ) + ) + ) + (label cfg-9) + (the-as path-control obj) + ) + ) + +(defmethod should-display? path-control ((obj path-control)) + "Should we display path marks?" + (and *display-path-marks* + (nonzero? (logand (-> obj flags) (path-control-flag display))) + ) + ) + +(defmethod length-as-float path-control ((obj path-control)) + "Get the number of edges as a float" + (the float (+ (-> obj curve num-cverts) -1)) + ) + +(defmethod get-num-verts path-control ((obj path-control)) + "Get the number of vertices" + (-> obj curve num-cverts) + ) + +(defmethod new curve-control ((allocation symbol) (type-to-make type) (proc process) (name symbol) (time float)) + (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> obj process) proc) + (set! (-> obj name) name) + (let* ((ent (the-as entity (-> proc entity))) + (v1-2 name) + (s2-0 (cond + ((= v1-2 'path) + 'path-k ;; for knots? + ) + (else + ;; appends a -k to the symbol name. + (let ((s2-1 string->symbol)) + (format (clear *temp-string*) "~A-k" name) + (s2-1 *temp-string*) + ) + ) + ) + ) + ) + (let ((lookup-entity (entity-actor-lookup ent 'path-actor 0))) + (if lookup-entity + (set! ent lookup-entity) + ) + ) + (when (not (get-curve-data! ent (-> obj curve) name s2-0 time)) + (cond + ((> (-> obj curve num-cverts) 0) + ;; downgrade us to a path-control, we got cverts but no knots. + (set! (-> obj type) path-control) + ) + (else + ;; couldn't get anything, mark as bad. + (set! (-> obj flags) (logior (-> obj flags) (path-control-flag not-found))) + (set! (-> obj curve cverts) (the-as pointer #f)) + (set! (-> obj curve num-cverts) 0) + ) + ) + ) + ) + obj + ) + ) + diff --git a/goalc/compiler/compilation/Type.cpp b/goalc/compiler/compilation/Type.cpp index f0e63ebc3b..91148bba20 100644 --- a/goalc/compiler/compilation/Type.cpp +++ b/goalc/compiler/compilation/Type.cpp @@ -1039,7 +1039,8 @@ Val* Compiler::compile_new(const goos::Object& form, const goos::Object& _rest, auto type = pair_car(*rest); rest = &pair_cdr(*rest); - if (allocation == "global" || allocation == "debug" || allocation == "process") { + if (allocation == "global" || allocation == "debug" || allocation == "process" || + allocation == "process-level-heap") { // allocate on a named heap return compile_heap_new(form, allocation, type, rest, env); } else if (allocation == "static") { diff --git a/test/decompiler/reference/all_forward_declarations.gc b/test/decompiler/reference/all_forward_declarations.gc index 9b1ed5e83a..cac6abba5b 100644 --- a/test/decompiler/reference/all_forward_declarations.gc +++ b/test/decompiler/reference/all_forward_declarations.gc @@ -906,6 +906,7 @@ (defenum entity-perm-status :bitfield #t :type uint16 + (bit-1 1) (dead 2) (complete 6)) @@ -1060,3 +1061,28 @@ ) ) (define-extern *progress-process* (pointer progress)) +(define-extern entity-by-name (function string entity)) +(define-extern entity-by-aid (function uint entity)) + +(declare-type nav-mesh basic) +(define-extern *default-nav-mesh* nav-mesh) + +(defenum path-control-flag + :bitfield #t + :type uint32 + (display 0) + (not-found 4) + ) + +(defenum nav-control-flags + :bitfield #t + :type uint32 + (display-marks 0) + (bit8 8) + (bit13 13) + ) + +(defmacro with-pp (&rest body) + `(rlet ((pp :reg r13 :reset-here #t :type process)) + ,@body) + ) diff --git a/test/decompiler/reference/engine/anim/aligner-h_REF.gc b/test/decompiler/reference/engine/anim/aligner-h_REF.gc index 56162b1d7c..bbdaef1320 100644 --- a/test/decompiler/reference/engine/anim/aligner-h_REF.gc +++ b/test/decompiler/reference/engine/anim/aligner-h_REF.gc @@ -47,25 +47,26 @@ new align-control ((allocation symbol) (type-to-make type) (arg0 process)) - (local-vars (pp process)) - (let - ((obj - (object-new allocation type-to-make (the-as int (-> type-to-make size))) + (with-pp + (let + ((obj + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) ) - ) - (if (zero? obj) - (return (begin - (let ((t9-1 (the-as (function object object) enter-state)) - (a0-1 "memory") - ) - (set! (-> pp next-state) process-drawable-art-error) - (t9-1 a0-1) + (if (zero? obj) + (return (begin + (let ((t9-1 (the-as (function object object) enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + (t9-1 a0-1) + ) + (the-as align-control 0) ) - (the-as align-control 0) - ) + ) ) + (set! (-> obj process) arg0) + obj ) - (set! (-> obj process) arg0) - obj ) ) diff --git a/test/decompiler/reference/engine/camera/cam-debug-h_REF.gc b/test/decompiler/reference/engine/camera/cam-debug-h_REF.gc new file mode 100644 index 0000000000..e2f6bf6e0c --- /dev/null +++ b/test/decompiler/reference/engine/camera/cam-debug-h_REF.gc @@ -0,0 +1,146 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(when *debug-segment* +;; definition for symbol *redline-table*, type (pointer float) +(define *redline-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *redline-index*, type int +(define *redline-index* 0) + +;; definition for function float-save-redline +;; INFO: Return type mismatch int vs none. +(defun float-save-redline ((arg0 float)) + (set! (-> *redline-table* *redline-index*) arg0) + (set! *redline-index* (+ *redline-index* 1)) + (when (>= *redline-index* 400) + (set! *redline-index* 0) + (let ((v0-1 0)) + ) + ) + (none) + ) + +;; definition for function float-lookup-redline +(defun float-lookup-redline ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *redline-index*) 400))) + (-> *redline-table* a0-3) + ) + ) + +;; definition for symbol *blueline-table*, type (pointer float) +(define *blueline-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *blueline-index*, type int +(define *blueline-index* 0) + +;; definition for function float-save-blueline +;; INFO: Return type mismatch int vs none. +(defun float-save-blueline ((arg0 float)) + (set! (-> *blueline-table* *blueline-index*) arg0) + (set! *blueline-index* (+ *blueline-index* 1)) + (when (>= *blueline-index* 400) + (set! *blueline-index* 0) + (let ((v0-1 0)) + ) + ) + (none) + ) + +;; definition for function float-lookup-blueline +(defun float-lookup-blueline ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *blueline-index*) 400))) + (-> *blueline-table* a0-3) + ) + ) + +;; definition for symbol *greenline-table*, type (pointer float) +(define *greenline-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *greenline-index*, type int +(define *greenline-index* 0) + +;; definition for function float-save-greenline +;; INFO: Return type mismatch int vs none. +(defun float-save-greenline ((arg0 float)) + (set! (-> *greenline-table* *greenline-index*) arg0) + (set! *greenline-index* (+ *greenline-index* 1)) + (when (>= *greenline-index* 400) + (set! *greenline-index* 0) + (let ((v0-1 0)) + ) + ) + (none) + ) + +;; definition for function float-lookup-greenline +(defun float-lookup-greenline ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *greenline-index*) 400))) + (-> *greenline-table* a0-3) + ) + ) + +;; definition for symbol *yellowline-table*, type (pointer float) +(define *yellowline-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *yellowline-index*, type int +(define *yellowline-index* 0) + +;; definition for function float-save-yellowline +;; INFO: Return type mismatch int vs none. +(defun float-save-yellowline ((arg0 float)) + (set! (-> *yellowline-table* *yellowline-index*) arg0) + (set! *yellowline-index* (+ *yellowline-index* 1)) + (when (>= *yellowline-index* 400) + (set! *yellowline-index* 0) + (let ((v0-1 0)) + ) + ) + (none) + ) + +;; definition for function float-lookup-yellowline +(defun float-lookup-yellowline ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *yellowline-index*) 400))) + (-> *yellowline-table* a0-3) + ) + ) + +;; definition for symbol *timeplot-table*, type (pointer float) +(define *timeplot-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *timeplot-index*, type int +(define *timeplot-index* 0) + +;; definition for function float-save-timeplot +;; INFO: Return type mismatch int vs none. +(defun float-save-timeplot ((arg0 float)) + (set! (-> *timeplot-table* *timeplot-index*) arg0) + (set! *timeplot-index* (+ *timeplot-index* 1)) + (when (>= *timeplot-index* 400) + (set! *timeplot-index* 0) + (let ((v0-1 0)) + ) + ) + (none) + ) + +;; definition for function float-lookup-timeplot +(defun float-lookup-timeplot ((arg0 float)) + (let ((a0-3 (mod (+ (+ (the int arg0) -1) *timeplot-index*) 400))) + (-> *timeplot-table* a0-3) + ) + ) + +;; definition (perm) for symbol *cam-layout*, type symbol +(define-perm *cam-layout* symbol #f) + +;; failed to figure out what this is: +(let ((v0-6 0)) + ) + +) + + + diff --git a/test/decompiler/reference/engine/camera/cam-interface_REF.gc b/test/decompiler/reference/engine/camera/cam-interface_REF.gc index bca7ca6d81..2753e1255d 100644 --- a/test/decompiler/reference/engine/camera/cam-interface_REF.gc +++ b/test/decompiler/reference/engine/camera/cam-interface_REF.gc @@ -99,25 +99,25 @@ ;; INFO: Return type mismatch int vs none. ;; Used lq/sq (defun camera-teleport-to-entity ((arg0 entity-actor)) - (local-vars (pp process)) - (let ((gp-0 (new 'stack 'transformq))) - (set! - (-> gp-0 trans quad) - (-> (the-as transform (-> arg0 extra)) scale quad) - ) - (quaternion-copy! (the-as quaternion (-> gp-0 rot)) (-> arg0 quat)) - (vector-identity! (-> gp-0 scale)) - (let ((a1-2 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-2 from) pp) - (set! (-> a1-2 num-params) 1) - (set! (-> a1-2 message) 'teleport-to-transformq) - (set! (-> a1-2 param 0) (the-as uint gp-0)) - (send-event-function *camera* a1-2) + (with-pp (let ((gp-0 (new 'stack 'transformq))) + (set! + (-> gp-0 trans quad) + (-> (the-as transform (-> arg0 extra)) scale quad) + ) + (quaternion-copy! (the-as quaternion (-> gp-0 rot)) (-> arg0 quat)) + (vector-identity! (-> gp-0 scale)) + (let ((a1-2 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-2 from) pp) + (set! (-> a1-2 num-params) 1) + (set! (-> a1-2 message) 'teleport-to-transformq) + (set! (-> a1-2 param 0) (the-as uint gp-0)) + (send-event-function *camera* a1-2) + ) + ) + (let ((v0-4 0)) ) + (none) ) - (let ((v0-4 0)) - ) - (none) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc b/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc index 722e701656..d3545cdc87 100644 --- a/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc @@ -389,17 +389,17 @@ ;; definition of type collide-shape (deftype collide-shape (trsqv) - ((process basic :offset-assert 140) - (max-iteration-count uint8 :offset-assert 144) - (nav-flags uint8 :offset-assert 145) - (pad-byte uint8 2 :offset-assert 146) - (pat-ignore-mask uint32 :offset-assert 148) - (event-self basic :offset-assert 152) - (event-other basic :offset-assert 156) - (root-prim basic :offset-assert 160) - (riders basic :offset-assert 164) - (backup-collide-as uint64 :offset-assert 168) - (backup-collide-with uint64 :offset-assert 176) + ((process process :offset-assert 140) + (max-iteration-count uint8 :offset-assert 144) + (nav-flags uint8 :offset-assert 145) + (pad-byte uint8 2 :offset-assert 146) + (pat-ignore-mask uint32 :offset-assert 148) + (event-self basic :offset-assert 152) + (event-other basic :offset-assert 156) + (root-prim basic :offset-assert 160) + (riders basic :offset-assert 164) + (backup-collide-as uint64 :offset-assert 168) + (backup-collide-with uint64 :offset-assert 176) ) :method-count-assert 56 :size-assert #xb8 diff --git a/test/decompiler/reference/engine/data/res-h_REF.gc b/test/decompiler/reference/engine/data/res-h_REF.gc index 1d209e3b02..6c0169dad0 100644 --- a/test/decompiler/reference/engine/data/res-h_REF.gc +++ b/test/decompiler/reference/engine/data/res-h_REF.gc @@ -33,7 +33,7 @@ (get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer 9) (get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure 10) (get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 11) - (get-property-value2 (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 12) + (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float 12) (get-tag-index-data (_type_ int) pointer 13) (get-tag-data (_type_ res-tag) pointer 14) (dummy-15 (_type_ res-tag) res-tag 15) diff --git a/test/decompiler/reference/engine/debug/assert-h_REF.gc b/test/decompiler/reference/engine/debug/assert-h_REF.gc new file mode 100644 index 0000000000..5afc72f1ca --- /dev/null +++ b/test/decompiler/reference/engine/debug/assert-h_REF.gc @@ -0,0 +1,70 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type __assert-info-private-struct +(deftype __assert-info-private-struct (structure) + ((filename string :offset-assert 0) + (line-num uint16 :offset-assert 4) + (column-num uint16 :offset-assert 6) + ) + :method-count-assert 11 + :size-assert #x8 + :flag-assert #xb00000008 + (:methods + (set-private-assert-info (_type_ string uint16 uint16) int 9) + (print-private-assert-info (_type_) int 10) + ) + ) + +;; definition for method 3 of type __assert-info-private-struct +(defmethod + inspect + __assert-info-private-struct + ((obj __assert-info-private-struct)) + (format #t "[~8x] ~A~%" obj '__assert-info-private-struct) + (format #t "~Tfilename: ~A~%" (-> obj filename)) + (format #t "~Tline-num: ~D~%" (-> obj line-num)) + (format #t "~Tcolumn-num: ~D~%" (-> obj column-num)) + obj + ) + +;; definition for method 9 of type __assert-info-private-struct +(defmethod + set-private-assert-info + __assert-info-private-struct + ((obj __assert-info-private-struct) + (filename string) + (line-num uint16) + (column-num uint16) + ) + (set! (-> obj filename) filename) + (set! (-> obj line-num) (the-as uint line-num)) + (set! (-> obj column-num) (the-as uint column-num)) + 0 + ) + +;; definition for method 10 of type __assert-info-private-struct +(defmethod + print-private-assert-info + __assert-info-private-struct + ((obj __assert-info-private-struct)) + (format + #t + "file ~S.gc, line ~D, col ~D.~%" + (-> obj filename) + (-> obj line-num) + (-> obj column-num) + ) + 0 + ) + +;; definition for symbol *__private-assert-info*, type __assert-info-private-struct +(define *__private-assert-info* (new 'static '__assert-info-private-struct)) + +;; failed to figure out what this is: +(let ((v0-4 0)) + ) + + + + diff --git a/test/decompiler/reference/engine/entity/actor-link-h_REF.gc b/test/decompiler/reference/engine/entity/actor-link-h_REF.gc new file mode 100644 index 0000000000..48b2560515 --- /dev/null +++ b/test/decompiler/reference/engine/entity/actor-link-h_REF.gc @@ -0,0 +1,460 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function entity-actor-lookup +;; INFO: Return type mismatch entity vs entity-actor. +;; Used lq/sq +(defun entity-actor-lookup ((lump res-lump) (name symbol) (idx int)) + (local-vars (sv-16 res-tag)) + (set! sv-16 (new 'static 'res-tag)) + (let + ((v1-1 + (the-as + (pointer uint32) + (get-property-data + lump + name + 'interp + -1000000000.0 + (the-as pointer #f) + (& sv-16) + *res-static-buf* + ) + ) + ) + ) + (the-as + entity-actor + (when (and v1-1 (< idx (the-as int (-> sv-16 elt-count)))) + (if (= (-> sv-16 elt-type) string) + (entity-by-name + (the-as string (-> (the-as (pointer uint32) (&+ v1-1 (* idx 4))) 0)) + ) + (entity-by-aid (-> (the-as (pointer uint32) (&+ v1-1 (* idx 4))) 0)) + ) + ) + ) + ) + ) + +;; definition for function entity-actor-count +;; WARN: Check prologue - tricky store of r0 +;; Used lq/sq +(defun entity-actor-count ((res res-lump) (name symbol)) + (local-vars (tag res-tag)) + (set! tag (new 'static 'res-tag)) + (if + (get-property-data + res + name + 'interp + -1000000000.0 + (the-as pointer #f) + (& tag) + *res-static-buf* + ) + (the-as int (-> tag elt-count)) + 0 + ) + ) + +;; definition of type actor-link-info +(deftype actor-link-info (basic) + ((process process :offset-assert 4) + (next entity-actor :offset-assert 8) + (prev entity-actor :offset-assert 12) + ) + :method-count-assert 26 + :size-assert #x10 + :flag-assert #x1a00000010 + (:methods + (new (symbol type process) _type_ 0) + (get-matching-actor-type-mask (_type_ type) int 9) + (actor-count-before (_type_) int 10) + (link (_type_) entity-actor 11) + (get-next (_type_) entity-actor 12) + (get-prev (_type_) entity-actor 13) + (get-next-process (_type_) process 14) + (get-prev-process (_type_) process 15) + (apply-function-forward (_type_ (function entity-actor object object) object) int 16) + (apply-function-reverse (_type_ (function entity-actor object object) object) int 17) + (apply-all (_type_ (function entity-actor object object) object) int 18) + (send-to-all (_type_ object) none 19) + (send-to-all-after (_type_ object) object 20) + (send-to-all-before (_type_ object) object 21) + (send-to-next-and-prev (_type_ object) none 22) + (send-to-next (_type_ object) none 23) + (send-to-prev (_type_ object) none 24) + (actor-count (_type_) int 25) + ) + ) + +;; definition for method 3 of type actor-link-info +(defmethod inspect actor-link-info ((obj actor-link-info)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tprocess: ~A~%" (-> obj process)) + (format #t "~Tnext: ~A~%" (-> obj next)) + (format #t "~Tprev: ~A~%" (-> obj prev)) + obj + ) + +;; definition for method 27 of type entity-actor +(defmethod next-actor entity-actor ((obj entity-actor)) + (entity-actor-lookup obj 'next-actor 0) + ) + +;; definition for method 28 of type entity-actor +(defmethod prev-actor entity-actor ((obj entity-actor)) + (entity-actor-lookup obj 'prev-actor 0) + ) + +;; definition for method 0 of type actor-link-info +(defmethod + new + actor-link-info + ((allocation symbol) (type-to-make type) (proc process)) + (let + ((obj + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (set! (-> obj process) proc) + (let ((ent (-> proc entity))) + (set! + (-> obj next) + (entity-actor-lookup (the-as res-lump ent) 'next-actor 0) + ) + ) + (let ((a0-2 (-> proc entity))) + (set! + (-> obj prev) + (entity-actor-lookup (the-as res-lump a0-2) 'prev-actor 0) + ) + ) + obj + ) + ) + +;; definition for method 12 of type actor-link-info +(defmethod get-next actor-link-info ((obj actor-link-info)) + (-> obj next) + ) + +;; definition for method 13 of type actor-link-info +(defmethod get-prev actor-link-info ((obj actor-link-info)) + (-> obj prev) + ) + +;; definition for method 14 of type actor-link-info +;; INFO: Return type mismatch basic vs process. +(defmethod get-next-process actor-link-info ((obj actor-link-info)) + (the-as + process + (and (-> obj next) (-> (the-as entity-links (-> obj next extra)) process)) + ) + ) + +;; definition for method 15 of type actor-link-info +;; INFO: Return type mismatch basic vs process. +(defmethod get-prev-process actor-link-info ((obj actor-link-info)) + (the-as + process + (and (-> obj prev) (-> (the-as entity-links (-> obj prev extra)) process)) + ) + ) + +;; definition for method 11 of type actor-link-info +(defmethod link actor-link-info ((obj actor-link-info)) + (let ((a0-1 (-> obj process entity))) + (set! + (-> obj next) + (entity-actor-lookup (the-as res-lump a0-1) 'next-actor 0) + ) + ) + (let ((a0-2 (-> obj process entity))) + (set! + (-> obj prev) + (entity-actor-lookup (the-as res-lump a0-2) 'prev-actor 0) + ) + ) + (-> obj next) + ) + +;; definition for method 16 of type actor-link-info +(defmethod + apply-function-forward + actor-link-info + ((obj actor-link-info) + (arg0 (function entity-actor object object)) + (arg1 object) + ) + (let ((s3-0 (-> obj next))) + (while s3-0 + (if (arg0 s3-0 arg1) + (return (the-as int #f)) + ) + (set! s3-0 (entity-actor-lookup s3-0 'next-actor 0)) + ) + ) + 0 + ) + +;; definition for method 17 of type actor-link-info +(defmethod + apply-function-reverse + actor-link-info + ((obj actor-link-info) + (arg0 (function entity-actor object object)) + (arg1 object) + ) + (let ((s3-0 (-> obj prev))) + (while s3-0 + (if (arg0 s3-0 arg1) + (return (the-as int #f)) + ) + (set! s3-0 (entity-actor-lookup s3-0 'prev-actor 0)) + ) + ) + 0 + ) + +;; definition for method 18 of type actor-link-info +(defmethod + apply-all + actor-link-info + ((obj actor-link-info) + (arg0 (function entity-actor object object)) + (arg1 object) + ) + (let ((s4-0 (-> obj process entity))) + (while (let ((a0-2 s4-0)) + (entity-actor-lookup (the-as res-lump a0-2) 'prev-actor 0) + ) + (set! s4-0 (entity-actor-lookup (the-as res-lump s4-0) 'prev-actor 0)) + ) + (while s4-0 + (if (arg0 (the-as entity-actor s4-0) arg1) + (return (the-as int #f)) + ) + (let ((a0-4 s4-0)) + (set! s4-0 (entity-actor-lookup (the-as res-lump a0-4) 'next-actor 0)) + ) + ) + ) + 0 + ) + +;; definition for method 20 of type actor-link-info +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 21 of type actor-link-info +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 23 of type actor-link-info +;; INFO: Return type mismatch int vs none. +(defmethod send-to-next actor-link-info ((obj actor-link-info) (arg0 object)) + (with-pp (let ((a0-1 (-> obj next))) + (when a0-1 + (let ((a0-2 (-> (the-as entity-links (-> a0-1 extra)) process))) + (when a0-2 + (let ((v1-4 (new 'stack-no-clear 'event-message-block))) + (set! (-> v1-4 from) pp) + (set! (-> v1-4 num-params) 0) + (set! (-> v1-4 message) (the-as basic arg0)) + (send-event-function a0-2 v1-4) + ) + ) + ) + ) + ) + (let ((v0-1 0)) + ) + (none) + ) + ) + +;; definition for method 24 of type actor-link-info +;; INFO: Return type mismatch int vs none. +(defmethod send-to-prev actor-link-info ((obj actor-link-info) (arg0 object)) + (with-pp (let ((a0-1 (-> obj prev))) + (when a0-1 + (let ((a0-2 (-> (the-as entity-links (-> a0-1 extra)) process))) + (when a0-2 + (let ((v1-4 (new 'stack-no-clear 'event-message-block))) + (set! (-> v1-4 from) pp) + (set! (-> v1-4 num-params) 0) + (set! (-> v1-4 message) (the-as basic arg0)) + (send-event-function a0-2 v1-4) + ) + ) + ) + ) + ) + (let ((v0-1 0)) + ) + (none) + ) + ) + +;; definition for method 22 of type actor-link-info +(defmethod + send-to-next-and-prev + actor-link-info + ((obj actor-link-info) (arg0 object)) + (send-to-next obj arg0) + (send-to-prev obj arg0) + (none) + ) + +;; definition for method 19 of type actor-link-info +;; INFO: Return type mismatch object vs none. +(defmethod send-to-all actor-link-info ((obj actor-link-info) (arg0 object)) + (send-to-all-after obj arg0) + (send-to-all-before obj arg0) + (none) + ) + +;; definition for method 25 of type actor-link-info +(defmethod actor-count actor-link-info ((obj actor-link-info)) + (let ((actor (-> obj process entity)) + (count 0) + ) + (while (let ((a0-2 actor)) + (entity-actor-lookup (the-as res-lump a0-2) 'prev-actor 0) + ) + (set! actor (entity-actor-lookup (the-as res-lump actor) 'prev-actor 0)) + ) + (while actor + (+! count 1) + (let ((a0-3 actor)) + (set! actor (entity-actor-lookup (the-as res-lump a0-3) 'next-actor 0)) + ) + ) + count + ) + ) + +;; definition for method 9 of type actor-link-info +(defmethod + get-matching-actor-type-mask + actor-link-info + ((obj actor-link-info) (matching-type type)) + (let ((actor (the-as entity-actor (-> obj process entity))) + (mask 0) + ) + (let ((current-bit 1)) + (while (let ((a0-2 actor)) + (entity-actor-lookup a0-2 'prev-actor 0) + ) + (set! actor (entity-actor-lookup actor 'prev-actor 0)) + ) + (while actor + (if (= (-> actor etype) matching-type) + (set! mask (logior mask current-bit)) + ) + (let ((a0-3 actor)) + (set! actor (entity-actor-lookup a0-3 'next-actor 0)) + ) + (set! current-bit (* current-bit 2)) + ) + ) + mask + ) + ) + +;; definition for method 10 of type actor-link-info +(defmethod actor-count-before actor-link-info ((obj actor-link-info)) + (let* ((this-actor (-> obj process entity)) + (actor this-actor) + (count 0) + ) + (while (let ((a0-2 actor)) + (entity-actor-lookup (the-as res-lump a0-2) 'prev-actor 0) + ) + (set! actor (entity-actor-lookup (the-as res-lump actor) 'prev-actor 0)) + ) + (while (!= actor this-actor) + (+! count 1) + (let ((a0-3 actor)) + (set! actor (entity-actor-lookup (the-as res-lump a0-3) 'next-actor 0)) + ) + ) + count + ) + ) + +;; definition for function actor-link-subtask-complete-hook +(defun + actor-link-subtask-complete-hook + ((arg0 entity-actor) (arg1 (pointer symbol))) + (cond + ((nonzero? + (logand + (-> (the-as entity-links (-> arg0 extra)) perm status) + (entity-perm-status complete) + ) + ) + (set! (-> arg1 0) #t) + #f + ) + (else + (set! (-> arg1 0) #f) + #t + ) + ) + ) + +;; definition for function actor-link-dead-hook +(defun actor-link-dead-hook ((arg0 entity-actor) (arg1 (pointer symbol))) + (cond + ((nonzero? + (logand + (-> (the-as entity-links (-> arg0 extra)) perm status) + (entity-perm-status dead) + ) + ) + (set! (-> arg1 0) #t) + #f + ) + (else + (set! (-> arg1 0) #f) + #t + ) + ) + ) + +;; definition for function alt-actor-list-subtask-incomplete-count +(defun alt-actor-list-subtask-incomplete-count ((arg0 process-drawable)) + (let + ((alt-actor-count + (entity-actor-count (the-as res-lump (-> arg0 entity)) 'alt-actor) + ) + (incomplete-count 0) + ) + (dotimes (alt-actor-idx alt-actor-count) + (let + ((a0-3 + (entity-actor-lookup + (the-as res-lump (-> arg0 entity)) + 'alt-actor + alt-actor-idx + ) + ) + ) + (if + (or + (not a0-3) + (zero? + (logand + (-> (the-as entity-links (-> a0-3 extra)) perm status) + (entity-perm-status complete) + ) + ) + ) + (+! incomplete-count 1) + ) + ) + ) + incomplete-count + ) + ) diff --git a/test/decompiler/reference/engine/entity/entity-h_REF.gc b/test/decompiler/reference/engine/entity/entity-h_REF.gc index 22e45577eb..e1c926f730 100644 --- a/test/decompiler/reference/engine/entity/entity-h_REF.gc +++ b/test/decompiler/reference/engine/entity/entity-h_REF.gc @@ -63,7 +63,7 @@ (next-link entity-links :offset-assert 4) (entity basic :offset-assert 8) (process process :offset-assert 12) - (level basic :offset-assert 16) + (level level :offset-assert 16) (vis-id int32 :offset-assert 20) (trans vector :inline :offset-assert 32) (perm entity-perm :inline :offset-assert 48) diff --git a/test/decompiler/reference/engine/game/fact-h_REF.gc b/test/decompiler/reference/engine/game/fact-h_REF.gc index 111a9cb993..6378626c2d 100644 --- a/test/decompiler/reference/engine/game/fact-h_REF.gc +++ b/test/decompiler/reference/engine/game/fact-h_REF.gc @@ -244,100 +244,102 @@ (pkup-type pickup-type) (pkup-amount float) ) - (local-vars (pp process) (tag res-tag)) - (let - ((obj - (object-new allocation type-to-make (the-as int (-> type-to-make size))) - ) - ) - (let ((ent (-> proc entity))) - (if (zero? obj) - (begin - (let ((go-func (the-as (function string none) enter-state)) - (a0-1 "memory") - ) - (set! (-> pp next-state) process-drawable-art-error) - (go-func a0-1) - ) - (set! obj (the-as fact-info 0)) - (goto cfg-10) + (local-vars (tag res-tag)) + (with-pp + (let + ((obj + (object-new allocation type-to-make (the-as int (-> type-to-make size))) ) ) - (set! (-> obj process) proc) - (set! tag (new 'static 'res-tag)) - (let - ((v1-6 - (the-as - (pointer int32) - ((method-of-type res-lump get-property-data) - (the-as res-lump ent) - 'eco-info - 'interp - 0.0 - (the-as pointer #f) - (& tag) - *res-static-buf* + (let ((ent (-> proc entity))) + (if (zero? obj) + (begin + (let ((go-func (the-as (function string none) enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + (go-func a0-1) + ) + (set! obj (the-as fact-info 0)) + (goto cfg-10) + ) + ) + (set! (-> obj process) proc) + (set! tag (new 'static 'res-tag)) + (let + ((v1-6 + (the-as + (pointer int32) + ((method-of-type res-lump get-property-data) + (the-as res-lump ent) + 'eco-info + 'interp + 0.0 + (the-as pointer #f) + (& tag) + *res-static-buf* + ) ) ) ) - ) - (cond - (v1-6 - (let ((a0-6 (-> tag elt-count))) - (set! (-> obj pickup-type) (the-as pickup-type (-> v1-6 0))) - (set! pkup-amount (cond - ((< (the-as uint 1) (the-as uint a0-6)) - (the float (-> v1-6 1)) + (cond + (v1-6 + (let ((a0-6 (-> tag elt-count))) + (set! (-> obj pickup-type) (the-as pickup-type (-> v1-6 0))) + (set! pkup-amount (cond + ((< (the-as uint 1) (the-as uint a0-6)) + (the float (-> v1-6 1)) + ) + (else + (empty) + pkup-amount + ) ) - (else - (empty) - pkup-amount - ) - ) + ) ) + (set! (-> obj pickup-amount) pkup-amount) + ) + (else + (set! (-> obj pickup-type) pkup-type) + (set! (-> obj pickup-amount) pkup-amount) ) - (set! (-> obj pickup-amount) pkup-amount) - ) - (else - (set! (-> obj pickup-type) pkup-type) - (set! (-> obj pickup-amount) pkup-amount) ) ) - ) - (set! - (-> obj options) - (the-as - uint - ((method-of-type res-lump get-property-value) - (the-as res-lump ent) - 'options - 'interp - -1000000000.0 - (the-as uint128 0) - (the-as (pointer res-tag) #f) - *res-static-buf* - ) - ) - ) - (if (nonzero? (logand #x80200 (the-as int (-> obj options)))) (set! - (-> obj fade-time) + (-> obj options) (the-as uint - (the - int - (* - 300.0 - (the-as - float - ((method-of-type res-lump get-property-value2) - (the-as res-lump ent) - 'timeout - 'interp - -1000000000.0 - (the-as uint128 0.0) - (the-as (pointer res-tag) #f) - *res-static-buf* + ((method-of-type res-lump get-property-value) + (the-as res-lump ent) + 'options + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if (nonzero? (logand #x80200 (the-as int (-> obj options)))) + (set! + (-> obj fade-time) + (the-as + uint + (the + int + (* + 300.0 + (the-as + float + ((method-of-type res-lump get-property-value-float) + (the-as res-lump ent) + 'timeout + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) ) ) ) @@ -345,9 +347,9 @@ ) ) ) + (label cfg-10) + obj ) - (label cfg-10) - obj ) ) @@ -379,12 +381,12 @@ (-> obj speed) (the-as float - ((method-of-type res-lump get-property-value2) + ((method-of-type res-lump get-property-value-float) (the-as res-lump entity) 'speed 'interp -1000000000.0 - (the-as uint128 1.0) + 1.0 (the-as (pointer res-tag) #f) *res-static-buf* ) @@ -394,12 +396,12 @@ (-> obj idle-distance) (the-as float - ((method-of-type res-lump get-property-value2) + ((method-of-type res-lump get-property-value-float) (the-as res-lump entity) 'idle-distance 'interp -1000000000.0 - (the-as uint128 327680.0) + 327680.0 (the-as (pointer res-tag) #f) *res-static-buf* ) @@ -409,12 +411,12 @@ (-> obj notice-top) (the-as float - ((method-of-type res-lump get-property-value2) + ((method-of-type res-lump get-property-value-float) (the-as res-lump entity) 'notice-top 'interp -1000000000.0 - (the-as uint128 4096000.0) + 4096000.0 (the-as (pointer res-tag) #f) *res-static-buf* ) @@ -424,12 +426,12 @@ (-> obj notice-bottom) (the-as float - ((method-of-type res-lump get-property-value2) + ((method-of-type res-lump get-property-value-float) (the-as res-lump entity) 'notice-bottom 'interp -1000000000.0 - (the-as uint128 4096000.0) + 4096000.0 (the-as (pointer res-tag) #f) *res-static-buf* ) @@ -439,12 +441,12 @@ (-> obj cam-horz) (the-as float - ((method-of-type res-lump get-property-value2) + ((method-of-type res-lump get-property-value-float) (the-as res-lump entity) 'cam-horz 'interp -1000000000.0 - (the-as uint128 0.0) + 0.0 (the-as (pointer res-tag) #f) *res-static-buf* ) @@ -454,12 +456,12 @@ (-> obj cam-vert) (the-as float - ((method-of-type res-lump get-property-value2) + ((method-of-type res-lump get-property-value-float) (the-as res-lump entity) 'cam-vert 'interp -1000000000.0 - (the-as uint128 0.0) + 0.0 (the-as (pointer res-tag) #f) *res-static-buf* ) @@ -469,12 +471,12 @@ (-> obj cam-notice-dist) (the-as float - ((method-of-type res-lump get-property-value2) + ((method-of-type res-lump get-property-value-float) (the-as res-lump entity) 'cam-notice-dist 'interp -1000000000.0 - (the-as uint128 -4096.0) + -4096.0 (the-as (pointer res-tag) #f) *res-static-buf* ) diff --git a/test/decompiler/reference/engine/geometry/geometry-h_REF.gc b/test/decompiler/reference/engine/geometry/geometry-h_REF.gc index df13f3f289..17d5a16225 100644 --- a/test/decompiler/reference/engine/geometry/geometry-h_REF.gc +++ b/test/decompiler/reference/engine/geometry/geometry-h_REF.gc @@ -3,11 +3,11 @@ ;; definition of type curve (deftype curve (structure) - ((cverts uint32 :offset-assert 0) - (num-cverts int32 :offset-assert 4) - (knots uint32 :offset-assert 8) - (num-knots int32 :offset-assert 12) - (length float :offset-assert 16) + ((cverts pointer :offset-assert 0) + (num-cverts int32 :offset-assert 4) + (knots pointer :offset-assert 8) + (num-knots int32 :offset-assert 12) + (length float :offset-assert 16) ) :method-count-assert 9 :size-assert #x14 diff --git a/test/decompiler/reference/engine/geometry/vol-h_REF.gc b/test/decompiler/reference/engine/geometry/vol-h_REF.gc index 26dd6ac0b1..765ab6f377 100644 --- a/test/decompiler/reference/engine/geometry/vol-h_REF.gc +++ b/test/decompiler/reference/engine/geometry/vol-h_REF.gc @@ -78,130 +78,131 @@ new vol-control ((allocation symbol) (type-to-make type) (arg0 process-drawable)) - (local-vars (pp process)) - (let - ((gp-0 - (the-as - object - (object-new allocation type-to-make (the-as int (-> type-to-make size))) + (with-pp + (let + ((gp-0 + (the-as + object + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) ) ) - ) - (if (zero? (the-as vol-control gp-0)) - (begin - (let ((t9-1 (the-as (function object object) enter-state)) - (a0-1 "memory") - ) - (set! (-> pp next-state) process-drawable-art-error) - (t9-1 a0-1) + (if (zero? (the-as vol-control gp-0)) + (begin + (let ((t9-1 (the-as (function object object) enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + (t9-1 a0-1) + ) + (set! gp-0 0) + (goto cfg-13) ) - (set! gp-0 0) - (goto cfg-13) ) - ) - (set! (-> (the-as vol-control gp-0) process) arg0) - (let* ((s5-1 (-> (the-as vol-control gp-0) process entity)) - (s4-0 - (-> - ((method-of-type res-lump lookup-tag-idx) - (the-as res-lump s5-1) - 'vol - 'exact - 0.0 + (set! (-> (the-as vol-control gp-0) process) arg0) + (let* ((s5-1 (-> (the-as vol-control gp-0) process entity)) + (s4-0 + (-> + ((method-of-type res-lump lookup-tag-idx) + (the-as res-lump s5-1) + 'vol + 'exact + 0.0 + ) + lo ) - lo + ) + ) + (when (>= s4-0 0) + (let ((s3-0 s4-0) + (s2-0 (-> (-> (the-as res-lump s5-1) tag) s4-0)) + ) + (let ((v1-10 0)) + ) + (while (= (-> s2-0 name) (-> (-> (the-as res-lump s5-1) tag) s4-0 name)) + (let + ((v1-12 + (make-property-data + (the-as res-lump s5-1) + 0.0 + (the-as res-tag-pair s3-0) + (the-as pointer #f) + ) + ) + (a0-8 + (-> + (the-as vol-control gp-0) + pos-vol + (-> (the-as vol-control gp-0) pos-vol-count) ) ) ) - (when (>= s4-0 0) - (let ((s3-0 s4-0) - (s2-0 (-> (-> (the-as res-lump s5-1) tag) s4-0)) - ) - (let ((v1-10 0)) - ) - (while (= (-> s2-0 name) (-> (-> (the-as res-lump s5-1) tag) s4-0 name)) - (let - ((v1-12 - (make-property-data - (the-as res-lump s5-1) - 0.0 - (the-as res-tag-pair s3-0) - (the-as pointer #f) - ) - ) - (a0-8 - (-> - (the-as vol-control gp-0) - pos-vol - (-> (the-as vol-control gp-0) pos-vol-count) - ) - ) + (set! (-> a0-8 num-planes) (the-as int (-> s2-0 elt-count))) + (set! (-> a0-8 plane) (the-as uint v1-12)) ) - (set! (-> a0-8 num-planes) (the-as int (-> s2-0 elt-count))) - (set! (-> a0-8 plane) (the-as uint v1-12)) + (set! + (-> (the-as vol-control gp-0) pos-vol-count) + (+ (-> (the-as vol-control gp-0) pos-vol-count) 1) + ) + (+! s3-0 1) + (set! s2-0 (-> (-> (the-as res-lump s5-1) tag) s3-0)) ) - (set! - (-> (the-as vol-control gp-0) pos-vol-count) - (+ (-> (the-as vol-control gp-0) pos-vol-count) 1) - ) - (+! s3-0 1) - (set! s2-0 (-> (-> (the-as res-lump s5-1) tag) s3-0)) ) ) ) - ) - (let* ((s5-2 (-> (the-as vol-control gp-0) process entity)) - (s4-1 - (-> - ((method-of-type res-lump lookup-tag-idx) - (the-as res-lump s5-2) - 'cutoutvol - 'exact - 0.0 + (let* ((s5-2 (-> (the-as vol-control gp-0) process entity)) + (s4-1 + (-> + ((method-of-type res-lump lookup-tag-idx) + (the-as res-lump s5-2) + 'cutoutvol + 'exact + 0.0 + ) + lo ) - lo + ) + ) + (when (>= s4-1 0) + (let ((s3-1 s4-1) + (s2-1 (-> (-> (the-as res-lump s5-2) tag) s4-1)) + ) + (let ((v1-29 0)) + ) + (while (= (-> s2-1 name) (-> (-> (the-as res-lump s5-2) tag) s4-1 name)) + (let + ((v1-31 + (make-property-data + (the-as res-lump s5-2) + 0.0 + (the-as res-tag-pair s3-1) + (the-as pointer #f) + ) + ) + (a0-19 + (-> + (the-as vol-control gp-0) + neg-vol + (-> (the-as vol-control gp-0) neg-vol-count) ) ) ) - (when (>= s4-1 0) - (let ((s3-1 s4-1) - (s2-1 (-> (-> (the-as res-lump s5-2) tag) s4-1)) - ) - (let ((v1-29 0)) - ) - (while (= (-> s2-1 name) (-> (-> (the-as res-lump s5-2) tag) s4-1 name)) - (let - ((v1-31 - (make-property-data - (the-as res-lump s5-2) - 0.0 - (the-as res-tag-pair s3-1) - (the-as pointer #f) - ) - ) - (a0-19 - (-> - (the-as vol-control gp-0) - neg-vol - (-> (the-as vol-control gp-0) neg-vol-count) - ) - ) + (set! (-> a0-19 num-planes) (the-as int (-> s2-1 elt-count))) + (set! (-> a0-19 plane) (the-as uint v1-31)) ) - (set! (-> a0-19 num-planes) (the-as int (-> s2-1 elt-count))) - (set! (-> a0-19 plane) (the-as uint v1-31)) + (set! + (-> (the-as vol-control gp-0) neg-vol-count) + (+ (-> (the-as vol-control gp-0) neg-vol-count) 1) + ) + (+! s3-1 1) + (set! s2-1 (-> (-> (the-as res-lump s5-2) tag) s3-1)) ) - (set! - (-> (the-as vol-control gp-0) neg-vol-count) - (+ (-> (the-as vol-control gp-0) neg-vol-count) 1) - ) - (+! s3-1 1) - (set! s2-1 (-> (-> (the-as res-lump s5-2) tag) s3-1)) ) ) ) + (label cfg-13) + (the-as vol-control gp-0) ) - (label cfg-13) - (the-as vol-control gp-0) ) ) @@ -209,7 +210,3 @@ (defmethod TODO-RENAME-11 vol-control ((obj vol-control)) (and *display-vol-marks* (nonzero? (logand (-> obj flags) 1))) ) - - - - diff --git a/test/decompiler/reference/engine/math/quaternion_REF.gc b/test/decompiler/reference/engine/math/quaternion_REF.gc index 418573115a..a5c1a82dc4 100644 --- a/test/decompiler/reference/engine/math/quaternion_REF.gc +++ b/test/decompiler/reference/engine/math/quaternion_REF.gc @@ -1095,19 +1095,23 @@ ;; definition (debug) for function quaternion-validate ;; INFO: Return type mismatch int vs none. (defun-debug quaternion-validate ((arg0 quaternion)) - (local-vars (pp process)) - (let ((f0-0 (quaternion-norm arg0))) - (when (or (< 1.01 f0-0) (< f0-0 0.99)) - (format #t "WARNING: bad quaternion (magnitude ~F) process is " f0-0) - (if (and pp (type-type? (-> pp type) process-tree)) - (format #t "~A~%" (-> pp name)) - (format #t "#f~%") - ) + (with-pp (let ((f0-0 (quaternion-norm arg0))) + (when (or (< 1.01 f0-0) (< f0-0 0.99)) + (format + #t + "WARNING: bad quaternion (magnitude ~F) process is " + f0-0 + ) + (if (and pp (type-type? (-> pp type) process-tree)) + (format #t "~A~%" (-> pp name)) + (format #t "#f~%") + ) + ) + ) + (let ((v0-5 0)) ) + (none) ) - (let ((v0-5 0)) - ) - (none) ) ;; definition for function quaternion-xz-angle diff --git a/test/decompiler/reference/engine/nav/navigate-h_REF.gc b/test/decompiler/reference/engine/nav/navigate-h_REF.gc new file mode 100644 index 0000000000..7376cb3057 --- /dev/null +++ b/test/decompiler/reference/engine/nav/navigate-h_REF.gc @@ -0,0 +1,655 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type nav-poly +(deftype nav-poly (structure) + ((id uint8 :offset-assert 0) + (vertex uint8 3 :offset-assert 1) + (adj-poly uint8 3 :offset-assert 4) + (pat uint8 :offset-assert 7) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +;; definition for method 3 of type nav-poly +(defmethod inspect nav-poly ((obj nav-poly)) + (format #t "[~8x] ~A~%" obj 'nav-poly) + (format #t "~Tid: ~D~%" (-> obj id)) + (format #t "~Tvertex[3] @ #x~X~%" (-> obj vertex)) + (format #t "~Tadj-poly[3] @ #x~X~%" (-> obj adj-poly)) + (format #t "~Tpat: ~D~%" (-> obj pat)) + obj + ) + +;; definition of type nav-vertex +(deftype nav-vertex (vector) + () + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; definition for method 3 of type nav-vertex +;; Used lq/sq +(defmethod inspect nav-vertex ((obj nav-vertex)) + (format #t "[~8x] ~A~%" obj 'nav-vertex) + (format #t "~Tdata[4] @ #x~X~%" (&-> obj x)) + (format #t "~Tx: ~f~%" (-> obj x)) + (format #t "~Ty: ~f~%" (-> obj y)) + (format #t "~Tz: ~f~%" (-> obj z)) + (format #t "~Tw: ~f~%" (-> obj w)) + (format #t "~Tquad: ~D~%" (-> obj quad)) + obj + ) + +;; definition of type nav-sphere +(deftype nav-sphere (structure) + ((trans sphere :inline :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; definition for method 3 of type nav-sphere +(defmethod inspect nav-sphere ((obj nav-sphere)) + (format #t "[~8x] ~A~%" obj 'nav-sphere) + (format #t "~Ttrans: #~%" (-> obj trans)) + obj + ) + +;; definition of type nav-ray +(deftype nav-ray (structure) + ((current-pos vector :inline :offset-assert 0) + (dir vector :inline :offset-assert 16) + (dest-pos vector :inline :offset-assert 32) + (current-poly nav-poly :offset-assert 48) + (next-poly nav-poly :offset-assert 52) + (len float :offset-assert 56) + (last-edge int8 :offset-assert 60) + (terminated basic :offset-assert 64) + (reached-dest basic :offset-assert 68) + (hit-boundary basic :offset-assert 72) + (hit-gap basic :offset-assert 76) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + +;; definition for method 3 of type nav-ray +(defmethod inspect nav-ray ((obj nav-ray)) + (format #t "[~8x] ~A~%" obj 'nav-ray) + (format #t "~Tcurrent-pos: #~%" (-> obj current-pos)) + (format #t "~Tdir: #~%" (-> obj dir)) + (format #t "~Tdest-pos: #~%" (-> obj dest-pos)) + (format #t "~Tcurrent-poly: #~%" (-> obj current-poly)) + (format #t "~Tnext-poly: #~%" (-> obj next-poly)) + (format #t "~Tlen: (meters ~m)~%" (-> obj len)) + (format #t "~Tlast-edge: ~D~%" (-> obj last-edge)) + (format #t "~Tterminated: ~A~%" (-> obj terminated)) + (format #t "~Treached-dest: ~A~%" (-> obj reached-dest)) + (format #t "~Thit-boundary: ~A~%" (-> obj hit-boundary)) + (format #t "~Thit-gap: ~A~%" (-> obj hit-gap)) + obj + ) + +;; definition of type nav-route-portal +(deftype nav-route-portal (structure) + ((next-poly nav-poly :offset-assert 0) + (vertex nav-vertex 2 :offset-assert 4) + (edge-index int8 :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #xd + :flag-assert #x90000000d + ) + +;; definition for method 3 of type nav-route-portal +(defmethod inspect nav-route-portal ((obj nav-route-portal)) + (format #t "[~8x] ~A~%" obj 'nav-route-portal) + (format #t "~Tnext-poly: #~%" (-> obj next-poly)) + (format #t "~Tvertex[2] @ #x~X~%" (-> obj vertex)) + (format #t "~Tedge-index: ~D~%" (-> obj edge-index)) + obj + ) + +;; definition of type clip-travel-vector-to-mesh-return-info +(deftype clip-travel-vector-to-mesh-return-info (structure) + ((found-boundary basic :offset-assert 0) + (intersection vector :inline :offset-assert 16) + (boundary-normal vector :inline :offset-assert 32) + (prev-normal vector :inline :offset-assert 48) + (next-normal vector :inline :offset-assert 64) + (poly nav-poly :offset-assert 80) + (gap-poly nav-poly :offset-assert 84) + (edge int32 :offset-assert 88) + (vert-prev vector :inline :offset-assert 96) + (vert-0 vector :inline :offset-assert 112) + (vert-1 vector :inline :offset-assert 128) + (vert-next vector :inline :offset-assert 144) + ) + :method-count-assert 9 + :size-assert #xa0 + :flag-assert #x9000000a0 + ) + +;; definition for method 3 of type clip-travel-vector-to-mesh-return-info +(defmethod + inspect + clip-travel-vector-to-mesh-return-info + ((obj clip-travel-vector-to-mesh-return-info)) + (format #t "[~8x] ~A~%" obj 'clip-travel-vector-to-mesh-return-info) + (format #t "~Tfound-boundary: ~A~%" (-> obj found-boundary)) + (format #t "~Tintersection: #~%" (-> obj intersection)) + (format #t "~Tboundary-normal: #~%" (-> obj boundary-normal)) + (format #t "~Tprev-normal: #~%" (-> obj prev-normal)) + (format #t "~Tnext-normal: #~%" (-> obj next-normal)) + (format #t "~Tpoly: #~%" (-> obj poly)) + (format #t "~Tgap-poly: #~%" (-> obj gap-poly)) + (format #t "~Tedge: ~D~%" (-> obj edge)) + (format #t "~Tvert-prev: #~%" (-> obj vert-prev)) + (format #t "~Tvert-0: #~%" (-> obj vert-0)) + (format #t "~Tvert-1: #~%" (-> obj vert-1)) + (format #t "~Tvert-next: #~%" (-> obj vert-next)) + obj + ) + +;; definition of type nav-node +(deftype nav-node (structure) + ((center-x float :offset-assert 0) + (center-y float :offset-assert 4) + (center-z float :offset-assert 8) + (type uint16 :offset-assert 12) + (parent-offset uint16 :offset-assert 14) + (center vector :inline :offset 0) + (radius-x float :offset-assert 16) + (radius-y float :offset-assert 20) + (radius-z float :offset-assert 24) + (left-offset uint16 :offset-assert 28) + (right-offset uint16 :offset-assert 30) + (num-tris uint32 :offset 28) + (radius vector :inline :offset 16) + (scale-x float :offset-assert 32) + (first-tris uint8 4 :offset-assert 36) + (scale-z float :offset-assert 40) + (last-tris uint8 4 :offset-assert 44) + (scale vector :inline :offset 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +;; definition for method 3 of type nav-node +(defmethod inspect nav-node ((obj nav-node)) + (format #t "[~8x] ~A~%" obj 'nav-node) + (format #t "~Tcenter-x: ~f~%" (-> obj center-x)) + (format #t "~Tcenter-y: ~f~%" (-> obj center-y)) + (format #t "~Tcenter-z: ~f~%" (-> obj center-z)) + (format #t "~Ttype: ~D~%" (-> obj type)) + (format #t "~Tparent-offset: ~D~%" (-> obj parent-offset)) + (format #t "~Tcenter: #~%" (&-> obj center-x)) + (format #t "~Tradius-x: ~f~%" (-> obj radius-x)) + (format #t "~Tradius-y: ~f~%" (-> obj radius-y)) + (format #t "~Tradius-z: ~f~%" (-> obj radius-z)) + (format #t "~Tleft-offset: ~D~%" (-> obj left-offset)) + (format #t "~Tright-offset: ~D~%" (-> obj right-offset)) + (format #t "~Tnum-tris: ~D~%" (-> obj num-tris)) + (format #t "~Tradius: #~%" (&-> obj radius-x)) + (format #t "~Tscale-x: ~f~%" (-> obj scale-x)) + (format #t "~Tfirst-tris[4] @ #x~X~%" (-> obj first-tris)) + (format #t "~Tscale-z: ~f~%" (-> obj scale-z)) + (format #t "~Tlast-tris[4] @ #x~X~%" (-> obj last-tris)) + (format #t "~Tscale: #~%" (&-> obj scale-x)) + obj + ) + +;; definition of type nav-lookup-elem +(deftype nav-lookup-elem (structure) + ((vec vector :inline :offset-assert 0) + (y-thresh float :offset 12) + (time uint32 :offset-assert 16) + (node-offset uint32 :offset-assert 20) + (lookup-type uint8 :offset-assert 24) + (poly-ind uint8 :offset-assert 25) + (dummy0 uint16 :offset-assert 26) + (dummy uint32 :offset-assert 28) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +;; definition for method 3 of type nav-lookup-elem +(defmethod inspect nav-lookup-elem ((obj nav-lookup-elem)) + (format #t "[~8x] ~A~%" obj 'nav-lookup-elem) + (format #t "~Tvec: #~%" (-> obj vec)) + (format #t "~Ty-thresh: ~f~%" (-> obj vec w)) + (format #t "~Ttime: ~D~%" (-> obj time)) + (format #t "~Tnode-offset: ~D~%" (-> obj node-offset)) + (format #t "~Tlookup-type: ~D~%" (-> obj lookup-type)) + (format #t "~Tpoly-ind: ~D~%" (-> obj poly-ind)) + (format #t "~Tdummy0: ~D~%" (-> obj dummy0)) + (format #t "~Tdummy: ~D~%" (-> obj dummy)) + obj + ) + +;; definition of type nav-mesh +(deftype nav-mesh (basic) + ((user-list engine :offset-assert 4) + (poly-lookup-history uint8 2 :offset-assert 8) + (debug-time uint8 :offset-assert 10) + (static-sphere-count uint8 :offset-assert 11) + (static-sphere uint32 :offset-assert 12) + (bounds sphere :inline :offset-assert 16) + (origin vector :inline :offset-assert 32) + (cache nav-lookup-elem 4 :inline :offset-assert 48) + (node-count int32 :offset-assert 176) + (nodes uint32 :offset-assert 180) + (vertex-count int32 :offset-assert 184) + (vertex uint32 :offset-assert 188) + (poly-count int32 :offset-assert 192) + (poly uint32 :offset-assert 196) + (route uint32 :offset-assert 200) + ) + :method-count-assert 30 + :size-assert #xcc + :flag-assert #x1e000000cc + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 (_type_) none 13) + (dummy-14 () none 14) + (dummy-15 () none 15) + (dummy-16 () none 16) + (dummy-17 (_type_) none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + (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) + ) + ) + +;; definition for method 3 of type nav-mesh +(defmethod inspect nav-mesh ((obj nav-mesh)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tuser-list: ~A~%" (-> obj user-list)) + (format #t "~Tpoly-lookup-history[2] @ #x~X~%" (-> obj poly-lookup-history)) + (format #t "~Tdebug-time: ~D~%" (-> obj debug-time)) + (format #t "~Tstatic-sphere-count: ~D~%" (-> obj static-sphere-count)) + (format #t "~Tstatic-sphere: #x~X~%" (-> obj static-sphere)) + (format #t "~Tbounds: ~`sphere`P~%" (-> obj bounds)) + (format #t "~Torigin: ~`vector`P~%" (-> obj origin)) + (format #t "~Tcache[4] @ #x~X~%" (-> obj cache)) + (format #t "~Tnode-count: ~D~%" (-> obj node-count)) + (format #t "~Tnodes: #x~X~%" (-> obj nodes)) + (format #t "~Tvertex-count: ~D~%" (-> obj vertex-count)) + (format #t "~Tvertex: #x~X~%" (-> obj vertex)) + (format #t "~Tpoly-count: ~D~%" (-> obj poly-count)) + (format #t "~Tpoly: #x~X~%" (-> obj poly)) + (format #t "~Troute: #x~X~%" (-> obj route)) + obj + ) + +;; definition of type check-vector-collision-with-nav-spheres-info +(deftype check-vector-collision-with-nav-spheres-info (structure) + ((u float :offset-assert 0) + (intersect vector :inline :offset-assert 16) + (normal vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +;; definition for method 3 of type check-vector-collision-with-nav-spheres-info +(defmethod + inspect + check-vector-collision-with-nav-spheres-info + ((obj check-vector-collision-with-nav-spheres-info)) + (format #t "[~8x] ~A~%" obj 'check-vector-collision-with-nav-spheres-info) + (format #t "~Tu: ~f~%" (-> obj u)) + (format #t "~Tintersect: #~%" (-> obj intersect)) + (format #t "~Tnormal: #~%" (-> obj normal)) + obj + ) + +;; definition of type nav-gap-info +(deftype nav-gap-info (structure) + ((dest vector :inline :offset-assert 0) + (poly nav-poly :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x14 + :flag-assert #x900000014 + ) + +;; definition for method 3 of type nav-gap-info +(defmethod inspect nav-gap-info ((obj nav-gap-info)) + (format #t "[~8x] ~A~%" obj 'nav-gap-info) + (format #t "~Tdest: #~%" (-> obj dest)) + (format #t "~Tpoly: #~%" (-> obj poly)) + obj + ) + +;; definition of type nav-control +(deftype nav-control (basic) + ((flags nav-control-flags :offset-assert 4) + (process basic :offset-assert 8) + (shape collide-shape :offset-assert 12) + (mesh nav-mesh :offset-assert 16) + (gap-event basic :offset-assert 20) + (block-event basic :offset-assert 24) + (current-poly nav-poly :offset-assert 28) + (next-poly nav-poly :offset-assert 32) + (target-poly nav-poly :offset-assert 36) + (portal nav-route-portal 2 :offset-assert 40) + (nearest-y-threshold float :offset-assert 48) + (event-temp vector :inline :offset-assert 64) + (old-travel vector :inline :offset-assert 80) + (blocked-travel vector :inline :offset-assert 96) + (prev-pos vector :inline :offset-assert 112) + (extra-nav-sphere vector :inline :offset-assert 128) + (travel vector :inline :offset-assert 144) + (target-pos vector :inline :offset-assert 160) + (destination-pos vector :inline :offset-assert 176) + (block-time uint64 :offset-assert 192) + (block-count float :offset-assert 200) + (user-poly nav-poly :offset-assert 204) + (nav-cull-radius float :offset-assert 208) + (num-spheres int16 :offset-assert 212) + (max-spheres int16 :offset-assert 214) + (sphere sphere :inline :dynamic :offset-assert 224) + ) + :method-count-assert 36 + :size-assert #xe0 + :flag-assert #x24000000e0 + (:methods + (new (symbol type collide-shape int float) _type_ 0) + (dummy-9 () none 9) + (point-in-bounds? (_type_ vector) symbol 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + (dummy-14 () none 14) + (set-target-pos! (_type_ vector) none 15) + (dummy-16 () none 16) + (dummy-17 () none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + (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) + (should-display? (_type_) symbol 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) + ) + ) + +;; definition for method 3 of type nav-control +(defmethod inspect nav-control ((obj nav-control)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tflags: #x~X~%" (-> obj flags)) + (format #t "~Tprocess: ~A~%" (-> obj process)) + (format #t "~Tshape: ~A~%" (-> obj shape)) + (format #t "~Tmesh: ~A~%" (-> obj mesh)) + (format #t "~Tgap-event: ~A~%" (-> obj gap-event)) + (format #t "~Tblock-event: ~A~%" (-> obj block-event)) + (format #t "~Tcurrent-poly: #~%" (-> obj current-poly)) + (format #t "~Tnext-poly: #~%" (-> obj next-poly)) + (format #t "~Ttarget-poly: #~%" (-> obj target-poly)) + (format #t "~Tportal[2] @ #x~X~%" (-> obj portal)) + (format + #t + "~Tnearest-y-threshold: (meters ~m)~%" + (-> obj nearest-y-threshold) + ) + (format #t "~Tevent-temp: ~`vector`P~%" (-> obj event-temp)) + (format #t "~Told-travel: ~`vector`P~%" (-> obj old-travel)) + (format #t "~Tblocked-travel: ~`vector`P~%" (-> obj blocked-travel)) + (format #t "~Tprev-pos: ~`vector`P~%" (-> obj prev-pos)) + (format #t "~Textra-nav-sphere: ~`vector`P~%" (-> obj extra-nav-sphere)) + (format #t "~Ttravel: ~`vector`P~%" (-> obj travel)) + (format #t "~Ttarget-pos: ~`vector`P~%" (-> obj target-pos)) + (format #t "~Tdestination-pos: ~`vector`P~%" (-> obj destination-pos)) + (format #t "~Tblock-time: ~D~%" (-> obj block-time)) + (format #t "~Tblock-count: ~f~%" (-> obj block-count)) + (format #t "~Tuser-poly: #~%" (-> obj user-poly)) + (format #t "~Tnav-cull-radius: ~f~%" (-> obj nav-cull-radius)) + (format #t "~Tnum-spheres: ~D~%" (-> obj num-spheres)) + (format #t "~Tmax-spheres: ~D~%" (-> obj max-spheres)) + (format #t "~Tsphere[0] @ #x~X~%" (-> obj sphere)) + obj + ) + +;; definition for function nav-mesh-connect +;; Used lq/sq +(defun nav-mesh-connect ((proc process) (trans trsqv) (nav-cont nav-control)) + (local-vars (sv-16 type) (sv-32 symbol)) + (with-pp (let ((ent (-> proc entity))) + (when (zero? (-> (the-as entity-actor ent) nav-mesh)) + (let + ((lookup-entity + (entity-actor-lookup (the-as res-lump ent) 'nav-mesh-actor 0) + ) + ) + (if lookup-entity + (set! ent lookup-entity) + ) + ) + ) + (let ((entity-nav-mesh (-> (the-as entity-actor ent) nav-mesh))) + (cond + ((nonzero? entity-nav-mesh) + (when (zero? (-> entity-nav-mesh user-list)) + (set! + process-level-heap + (-> + (the-as + entity-links + (-> (the-as entity (-> pp entity)) extra) + ) + level + heap + ) + ) + (let ((s1-0 (method-of-type engine new)) + (s0-0 'process-level-heap) + ) + (set! sv-16 engine) + (set! sv-32 'nav-engine) + (let + ((a3-1 + ((method-of-type res-lump get-property-value) + (the-as res-lump ent) + 'nav-max-users + 'interp + -1000000000.0 + (the-as uint128 32) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (set! + (-> entity-nav-mesh user-list) + (s1-0 s0-0 sv-16 sv-32 (the-as int a3-1)) + ) + ) + ) + (dummy-13 entity-nav-mesh) + (dummy-17 entity-nav-mesh) + ) + (add-connection + (-> entity-nav-mesh user-list) + proc + (the-as (function object object object object object) nothing) + proc + nav-cont + trans + ) + ) + (else + (if (and nav-cont (-> proc entity)) + (set! + (-> + (the-as + entity-links + (-> (the-as entity (-> proc entity)) extra) + ) + perm + status + ) + (logior + (-> + (the-as + entity-links + (-> (the-as entity (-> proc entity)) extra) + ) + perm + status + ) + (entity-perm-status bit-1) + ) + ) + ) + (set! entity-nav-mesh *default-nav-mesh*) + ) + ) + entity-nav-mesh + ) + ) + ) + ) + +;; definition for method 0 of type nav-control +;; INFO: Return type mismatch object vs nav-control. +(defmethod + new + nav-control + ((allocation symbol) + (type-to-make type) + (shape collide-shape) + (sphere-count int) + (nearest-y-threshold-default float) + ) + (with-pp + (let + ((obj + (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (the-as uint (* sphere-count 16)))) + ) + ) + ) + (if (zero? obj) + (begin + (let ((t9-1 (the-as function enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + ((the-as (function string none) t9-1) a0-1) + ) + (set! obj (the-as nav-control 0)) + (goto cfg-4) + ) + ) + (set! (-> obj max-spheres) sphere-count) + (set! (-> obj flags) (nav-control-flags bit8 bit13)) + (set! (-> obj mesh) (nav-mesh-connect (-> shape process) shape obj)) + (let ((ent (-> shape process entity))) + (set! + (-> obj nearest-y-threshold) + ((method-of-type res-lump get-property-value-float) + (the-as res-lump ent) + 'nearest-y-threshold + 'interp + -1000000000.0 + nearest-y-threshold-default + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (set! (-> obj shape) shape) + (set! (-> obj process) (-> shape process)) + (set! (-> obj gap-event) #f) + (set! (-> obj current-poly) #f) + (set! (-> obj next-poly) #f) + (set! (-> obj target-poly) #f) + (set! (-> obj user-poly) #f) + (set! (-> obj portal 0) #f) + (set! (-> obj portal 1) #f) + (set! (-> obj nav-cull-radius) 40960.0) + (label cfg-4) + (the-as nav-control obj) + ) + ) + ) + +;; definition for method 29 of type nav-control +(defmethod should-display? nav-control ((obj nav-control)) + (and + *display-nav-marks* + (nonzero? (logand (-> obj flags) (nav-control-flags display-marks))) + ) + ) + +;; definition for method 10 of type nav-control +(defmethod point-in-bounds? nav-control ((obj nav-control) (arg0 vector)) + (let ((v1-1 (-> obj mesh bounds))) + (>= (-> v1-1 w) (vector-vector-distance arg0 v1-1)) + ) + ) + +;; definition for method 15 of type nav-control +;; INFO: Return type mismatch vector vs none. +;; Used lq/sq +(defmethod set-target-pos! nav-control ((obj nav-control) (arg0 vector)) + (set! (-> obj target-pos quad) (-> arg0 quad)) + (none) + ) + +;; definition for function has-nav-mesh? +;; INFO: Return type mismatch structure vs symbol. +(defun has-nav-mesh? ((arg0 entity-actor)) + (the-as + symbol + (or + (-> arg0 nav-mesh) + ((method-of-type res-lump get-property-struct) + arg0 + 'nav-mesh-actor + 'interp + -1000000000.0 + #f + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) diff --git a/test/decompiler/reference/engine/nav/path-h_REF.gc b/test/decompiler/reference/engine/nav/path-h_REF.gc new file mode 100644 index 0000000000..5dc0313626 --- /dev/null +++ b/test/decompiler/reference/engine/nav/path-h_REF.gc @@ -0,0 +1,230 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type path-control +(deftype path-control (basic) + ((flags path-control-flag :offset-assert 4) + (name basic :offset-assert 8) + (process basic :offset-assert 12) + (curve curve :inline :offset-assert 16) + (num-cverts int32 :offset 20) + (cverts pointer :offset 16) + ) + :method-count-assert 21 + :size-assert #x24 + :flag-assert #x1500000024 + (:methods + (new (symbol type process symbol float) _type_ 0) + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + (dummy-14 () none 14) + (length-as-float (_type_) float 15) + (dummy-16 () none 16) + (get-num-verts (_type_) int 17) + (should-display? (_type_) symbol 18) + (dummy-19 () none 19) + (dummy-20 () none 20) + ) + ) + +;; definition for method 3 of type path-control +(defmethod inspect path-control ((obj path-control)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tflags: #x~X~%" (-> obj flags)) + (format #t "~Tname: ~A~%" (-> obj name)) + (format #t "~Tprocess: ~A~%" (-> obj process)) + (format #t "~Tcurve: #~%" (-> obj curve)) + (format #t "~Tnum-cverts: ~D~%" (-> obj curve num-cverts)) + (format #t "~Tcverts: #x~X~%" (-> obj curve cverts)) + obj + ) + +;; definition of type curve-control +(deftype curve-control (path-control) + () + :method-count-assert 21 + :size-assert #x24 + :flag-assert #x1500000024 + (:methods + (new (symbol type process symbol float) _type_ 0) + ) + ) + +;; definition for method 3 of type curve-control +(defmethod inspect curve-control ((obj curve-control)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tflags: #x~X~%" (-> obj flags)) + (format #t "~Tname: ~A~%" (-> obj name)) + (format #t "~Tprocess: ~A~%" (-> obj process)) + (format #t "~Tcurve: #~%" (-> obj curve)) + (format #t "~Tnum-cverts: ~D~%" (-> obj curve num-cverts)) + (format #t "~Tcverts: #x~X~%" (-> obj curve cverts)) + obj + ) + +;; definition for method 0 of type path-control +;; INFO: Return type mismatch object vs path-control. +;; Used lq/sq +(defmethod + new + path-control + ((allocation symbol) + (type-to-make type) + (proc process) + (name symbol) + (time float) + ) + (local-vars (tag res-tag)) + (with-pp + (let + ((obj + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (if (zero? obj) + (begin + (let ((t9-1 (the-as function enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + ((the-as (function string none) t9-1) a0-1) + ) + (set! obj (the-as path-control 0)) + (goto cfg-9) + ) + ) + (set! (-> obj process) proc) + (set! (-> obj name) name) + (let ((ent (-> proc entity))) + (when (= name 'path) + (let + ((lookup-entity + (entity-actor-lookup (the-as res-lump ent) 'path-actor 0) + ) + ) + (if lookup-entity + (set! ent lookup-entity) + ) + ) + ) + (set! tag (new 'static 'res-tag)) + (let + ((data + ((method-of-type res-lump get-property-data) + (the-as res-lump ent) + name + 'interp + time + (the-as pointer #f) + (& tag) + *res-static-buf* + ) + ) + ) + (cond + (data + (set! (-> obj curve cverts) data) + (set! (-> obj curve num-cverts) (the-as int (-> tag elt-count))) + ) + (else + (set! + (-> obj flags) + (logior (-> obj flags) (path-control-flag not-found)) + ) + (set! (-> obj curve cverts) (the-as pointer #f)) + (set! (-> obj curve num-cverts) 0) + (let ((v1-16 0)) + ) + ) + ) + ) + ) + (label cfg-9) + (the-as path-control obj) + ) + ) + ) + +;; definition for method 18 of type path-control +(defmethod should-display? path-control ((obj path-control)) + (and + *display-path-marks* + (nonzero? (logand (-> obj flags) (path-control-flag display))) + ) + ) + +;; definition for method 15 of type path-control +(defmethod length-as-float path-control ((obj path-control)) + (the float (+ (-> obj curve num-cverts) -1)) + ) + +;; definition for method 17 of type path-control +(defmethod get-num-verts path-control ((obj path-control)) + (-> obj curve num-cverts) + ) + +;; definition for method 0 of type curve-control +(defmethod + new + curve-control + ((allocation symbol) + (type-to-make type) + (proc process) + (name symbol) + (time float) + ) + (let + ((obj + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (set! (-> obj process) proc) + (set! (-> obj name) name) + (let* ((ent (the-as entity (-> proc entity))) + (v1-2 name) + (s2-0 (cond + ((= v1-2 'path) + 'path-k + ) + (else + (let ((s2-1 string->symbol)) + (format (clear *temp-string*) "~A-k" name) + (s2-1 *temp-string*) + ) + ) + ) + ) + ) + (let ((lookup-entity (entity-actor-lookup ent 'path-actor 0))) + (if lookup-entity + (set! ent lookup-entity) + ) + ) + (when (not (get-curve-data! ent (-> obj curve) name s2-0 time)) + (cond + ((> (-> obj curve num-cverts) 0) + (set! (-> obj type) path-control) + ) + (else + (set! + (-> obj flags) + (logior (-> obj flags) (path-control-flag not-found)) + ) + (set! (-> obj curve cverts) (the-as pointer #f)) + (set! (-> obj curve num-cverts) 0) + (let ((v1-11 0)) + ) + ) + ) + ) + ) + obj + ) + ) + +;; failed to figure out what this is: +(let ((v0-9 0)) + ) diff --git a/test/decompiler/reference/engine/sound/gsound-h_REF.gc b/test/decompiler/reference/engine/sound/gsound-h_REF.gc index e013dfda00..aacce6cb6d 100644 --- a/test/decompiler/reference/engine/sound/gsound-h_REF.gc +++ b/test/decompiler/reference/engine/sound/gsound-h_REF.gc @@ -790,7 +790,3 @@ ;; failed to figure out what this is: (let ((v0-65 0)) ) - - - - diff --git a/test/decompiler/reference/engine/ui/progress-h_REF.gc b/test/decompiler/reference/engine/ui/progress-h_REF.gc new file mode 100644 index 0000000000..a9a6e51468 --- /dev/null +++ b/test/decompiler/reference/engine/ui/progress-h_REF.gc @@ -0,0 +1,316 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type count-info +(deftype count-info (structure) + ((money-count int32 :offset-assert 0) + (buzzer-count int32 :offset-assert 4) + ) + :pack-me + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +;; definition for method 3 of type count-info +(defmethod inspect count-info ((obj count-info)) + (format #t "[~8x] ~A~%" obj 'count-info) + (format #t "~Tmoney-count: ~D~%" (-> obj money-count)) + (format #t "~Tbuzzer-count: ~D~%" (-> obj buzzer-count)) + obj + ) + +;; definition of type game-count-info +(deftype game-count-info (basic) + ((length int32 :offset-assert 4) + (data count-info :inline :dynamic :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +;; definition for method 3 of type game-count-info +(defmethod inspect game-count-info ((obj game-count-info)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj data)) + obj + ) + +;; definition of type task-info-data +(deftype task-info-data (basic) + ((task-id uint8 :offset-assert 4) + (task-name symbol 4 :offset-assert 8) + (text-index-when-resolved int32 :offset-assert 24) + ) + :method-count-assert 9 + :size-assert #x1c + :flag-assert #x90000001c + ) + +;; definition for method 3 of type task-info-data +(defmethod inspect task-info-data ((obj task-info-data)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Ttask-id: ~D~%" (-> obj task-id)) + (format #t "~Ttask-name[4] @ #x~X~%" (-> obj task-name)) + (format + #t + "~Ttext-index-when-resolved: ~D~%" + (-> obj text-index-when-resolved) + ) + obj + ) + +;; definition of type level-tasks-info +(deftype level-tasks-info (basic) + ((level-name-id uint32 :offset-assert 4) + (text-group-index int32 :offset-assert 8) + (nb-of-tasks int32 :offset-assert 12) + (buzzer-task-index int32 :offset-assert 16) + (task-info task-info-data 8 :offset-assert 20) + ) + :method-count-assert 9 + :size-assert #x34 + :flag-assert #x900000034 + ) + +;; definition for method 3 of type level-tasks-info +(defmethod inspect level-tasks-info ((obj level-tasks-info)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlevel-name-id: ~D~%" (-> obj level-name-id)) + (format #t "~Ttext-group-index: ~D~%" (-> obj text-group-index)) + (format #t "~Tnb-of-tasks: ~D~%" (-> obj nb-of-tasks)) + (format #t "~Tbuzzer-task-index: ~D~%" (-> obj buzzer-task-index)) + (format #t "~Ttask-info[8] @ #x~X~%" (-> obj task-info)) + obj + ) + +;; definition of type game-option +(deftype game-option (basic) + ((option-type uint64 :offset-assert 8) + (name uint32 :offset-assert 16) + (scale basic :offset-assert 20) + (param1 float :offset-assert 24) + (param2 float :offset-assert 28) + (param3 int32 :offset-assert 32) + (value-to-modify uint32 :offset-assert 36) + ) + :method-count-assert 9 + :size-assert #x28 + :flag-assert #x900000028 + ) + +;; definition for method 3 of type game-option +(defmethod inspect game-option ((obj game-option)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Toption-type: ~D~%" (-> obj option-type)) + (format #t "~Tname: ~D~%" (-> obj name)) + (format #t "~Tscale: ~A~%" (-> obj scale)) + (format #t "~Tparam1: ~f~%" (-> obj param1)) + (format #t "~Tparam2: ~f~%" (-> obj param2)) + (format #t "~Tparam3: ~D~%" (-> obj param3)) + (format #t "~Tvalue-to-modify: #x~X~%" (-> obj value-to-modify)) + obj + ) + +;; definition of type progress +(deftype progress (process) + ((current-debug-string int32 :offset-assert 112) + (current-debug-language int32 :offset-assert 116) + (current-debug-group int32 :offset-assert 120) + (in-out-position int32 :offset-assert 124) + (display-state uint64 :offset-assert 128) + (next-display-state uint64 :offset-assert 136) + (option-index int32 :offset-assert 144) + (selected-option basic :offset-assert 148) + (completion-percentage float :offset-assert 152) + (ready-to-run basic :offset-assert 156) + (display-level-index int32 :offset-assert 160) + (next-level-index int32 :offset-assert 164) + (task-index int32 :offset-assert 168) + (in-transition basic :offset-assert 172) + (last-in-transition basic :offset-assert 176) + (force-transition basic :offset-assert 180) + (stat-transition basic :offset-assert 184) + (level-transition int32 :offset-assert 188) + (language-selection uint64 :offset-assert 192) + (language-direction basic :offset-assert 200) + (language-transition basic :offset-assert 204) + (language-x-offset int32 :offset-assert 208) + (sides-x-scale float :offset-assert 212) + (sides-y-scale float :offset-assert 216) + (left-x-offset int32 :offset-assert 220) + (right-x-offset int32 :offset-assert 224) + (button-scale float :offset-assert 228) + (slot-scale float :offset-assert 232) + (left-side-x-scale float :offset-assert 236) + (left-side-y-scale float :offset-assert 240) + (right-side-x-scale float :offset-assert 244) + (right-side-y-scale float :offset-assert 248) + (small-orb-y-offset int32 :offset-assert 252) + (big-orb-y-offset int32 :offset-assert 256) + (transition-offset int32 :offset-assert 260) + (transition-offset-invert int32 :offset-assert 264) + (transition-percentage float :offset-assert 268) + (transition-percentage-invert float :offset-assert 272) + (transition-speed float :offset-assert 276) + (total-nb-of-power-cells int32 :offset-assert 280) + (total-nb-of-orbs int32 :offset-assert 284) + (total-nb-of-buzzers int32 :offset-assert 288) + (card-info mc-slot-info :offset-assert 292) + (last-option-index-change uint64 :offset-assert 296) + (video-mode-timeout uint64 :offset-assert 304) + (display-state-stack uint64 5 :offset-assert 312) + (option-index-stack uint32 5 :offset-assert 352) + (display-state-pos int32 :offset-assert 372) + (nb-of-icons int32 :offset-assert 376) + (icons uint32 6 :offset-assert 380) + (max-nb-of-particles int32 :offset-assert 404) + (nb-of-particles int32 :offset-assert 408) + (particles uint32 40 :offset-assert 412) + (particle-state uint32 40 :offset-assert 572) + ) + :method-count-assert 59 + :size-assert #x2dc + :flag-assert #x3b000002dc + (: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) + (dummy-20 () none 20) + (dummy-21 () none 21) + (dummy-22 () none 22) + (TODO-RENAME-23 (_type_ symbol symbol) 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) + ) + ) + +;; definition for method 3 of type progress +(defmethod inspect progress ((obj progress)) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 obj) + ) + (format #t "~T~Tcurrent-debug-string: ~D~%" (-> obj current-debug-string)) + (format #t "~T~Tcurrent-debug-language: ~D~%" (-> obj current-debug-language)) + (format #t "~T~Tcurrent-debug-group: ~D~%" (-> obj current-debug-group)) + (format #t "~T~Tin-out-position: ~D~%" (-> obj in-out-position)) + (format #t "~T~Tdisplay-state: ~D~%" (-> obj display-state)) + (format #t "~T~Tnext-display-state: ~D~%" (-> obj next-display-state)) + (format #t "~T~Toption-index: ~D~%" (-> obj option-index)) + (format #t "~T~Tselected-option: ~A~%" (-> obj selected-option)) + (format #t "~T~Tcompletion-percentage: ~f~%" (-> obj completion-percentage)) + (format #t "~T~Tready-to-run: ~A~%" (-> obj ready-to-run)) + (format #t "~T~Tdisplay-level-index: ~D~%" (-> obj display-level-index)) + (format #t "~T~Tnext-level-index: ~D~%" (-> obj next-level-index)) + (format #t "~T~Ttask-index: ~D~%" (-> obj task-index)) + (format #t "~T~Tin-transition: ~A~%" (-> obj in-transition)) + (format #t "~T~Tlast-in-transition: ~A~%" (-> obj last-in-transition)) + (format #t "~T~Tforce-transition: ~A~%" (-> obj force-transition)) + (format #t "~T~Tstat-transition: ~A~%" (-> obj stat-transition)) + (format #t "~T~Tlevel-transition: ~D~%" (-> obj level-transition)) + (format #t "~T~Tlanguage-selection: ~D~%" (-> obj language-selection)) + (format #t "~T~Tlanguage-direction: ~A~%" (-> obj language-direction)) + (format #t "~T~Tlanguage-transition: ~A~%" (-> obj language-transition)) + (format #t "~T~Tlanguage-x-offset: ~D~%" (-> obj language-x-offset)) + (format #t "~T~Tsides-x-scale: ~f~%" (-> obj sides-x-scale)) + (format #t "~T~Tsides-y-scale: ~f~%" (-> obj sides-y-scale)) + (format #t "~T~Tleft-x-offset: ~D~%" (-> obj left-x-offset)) + (format #t "~T~Tright-x-offset: ~D~%" (-> obj right-x-offset)) + (format #t "~T~Tbutton-scale: ~f~%" (-> obj button-scale)) + (format #t "~T~Tslot-scale: ~f~%" (-> obj slot-scale)) + (format #t "~T~Tleft-side-x-scale: ~f~%" (-> obj left-side-x-scale)) + (format #t "~T~Tleft-side-y-scale: ~f~%" (-> obj left-side-y-scale)) + (format #t "~T~Tright-side-x-scale: ~f~%" (-> obj right-side-x-scale)) + (format #t "~T~Tright-side-y-scale: ~f~%" (-> obj right-side-y-scale)) + (format #t "~T~Tsmall-orb-y-offset: ~D~%" (-> obj small-orb-y-offset)) + (format #t "~T~Tbig-orb-y-offset: ~D~%" (-> obj big-orb-y-offset)) + (format #t "~T~Ttransition-offset: ~D~%" (-> obj transition-offset)) + (format + #t + "~T~Ttransition-offset-invert: ~D~%" + (-> obj transition-offset-invert) + ) + (format #t "~T~Ttransition-percentage: ~f~%" (-> obj transition-percentage)) + (format + #t + "~T~Ttransition-percentage-invert: ~f~%" + (-> obj transition-percentage-invert) + ) + (format #t "~T~Ttransition-speed: ~f~%" (-> obj transition-speed)) + (format + #t + "~T~Ttotal-nb-of-power-cells: ~D~%" + (-> obj total-nb-of-power-cells) + ) + (format #t "~T~Ttotal-nb-of-orbs: ~D~%" (-> obj total-nb-of-orbs)) + (format #t "~T~Ttotal-nb-of-buzzers: ~D~%" (-> obj total-nb-of-buzzers)) + (format #t "~T~Tcard-info: #~%" (-> obj card-info)) + (format + #t + "~T~Tlast-option-index-change: ~D~%" + (-> obj last-option-index-change) + ) + (format #t "~T~Tvideo-mode-timeout: ~D~%" (-> obj video-mode-timeout)) + (format #t "~T~Tdisplay-state-stack[5] @ #x~X~%" (&-> obj stack 200)) + (format #t "~T~Toption-index-stack[5] @ #x~X~%" (&-> obj stack 240)) + (format #t "~T~Tdisplay-state-pos: ~D~%" (-> obj display-state-pos)) + (format #t "~T~Tnb-of-icons: ~D~%" (-> obj nb-of-icons)) + (format #t "~T~Ticons[6] @ #x~X~%" (&-> obj stack 268)) + (format #t "~T~Tmax-nb-of-particles: ~D~%" (-> obj max-nb-of-particles)) + (format #t "~T~Tnb-of-particles: ~D~%" (-> obj nb-of-particles)) + (format #t "~T~Tparticles[40] @ #x~X~%" (&-> obj stack 300)) + (format #t "~T~Tparticle-state[40] @ #x~X~%" (&-> obj stack 460)) + obj + ) + +;; definition for symbol *progress-process*, type (pointer progress) +(define *progress-process* (the-as (pointer progress) #f)) + +;; definition for symbol *progress-last-task-index*, type int +(define *progress-last-task-index* 0) + +;; failed to figure out what this is: +(let ((v0-12 0)) + ) + + + + diff --git a/test/decompiler/reference/kernel/gkernel_REF.gc b/test/decompiler/reference/kernel/gkernel_REF.gc index 05c126e68d..fd44695a1f 100644 --- a/test/decompiler/reference/kernel/gkernel_REF.gc +++ b/test/decompiler/reference/kernel/gkernel_REF.gc @@ -200,12 +200,12 @@ ;; definition for function remove-exit (defun remove-exit () - (local-vars (pp process)) - (when (-> pp stack-frame-top) - (let ((v0-0 (-> pp stack-frame-top next))) - (set! (-> pp stack-frame-top) v0-0) - v0-0 - ) + (with-pp (when (-> pp stack-frame-top) + (let ((v0-0 (-> pp stack-frame-top next))) + (set! (-> pp stack-frame-top) v0-0) + v0-0 + ) + ) ) ) @@ -1515,14 +1515,14 @@ new protect-frame ((allocation symbol) (type-to-make type) (arg0 (function object))) - (local-vars (pp process)) - (let ((v0-0 (the-as object (+ (the-as int allocation) 4)))) - (set! (-> (the-as protect-frame v0-0) type) type-to-make) - (set! (-> (the-as protect-frame v0-0) name) 'protect-frame) - (set! (-> (the-as protect-frame v0-0) exit) arg0) - (set! (-> (the-as protect-frame v0-0) next) (-> pp stack-frame-top)) - (set! (-> pp stack-frame-top) (the-as protect-frame v0-0)) - (the-as protect-frame v0-0) + (with-pp (let ((v0-0 (the-as object (+ (the-as int allocation) 4)))) + (set! (-> (the-as protect-frame v0-0) type) type-to-make) + (set! (-> (the-as protect-frame v0-0) name) 'protect-frame) + (set! (-> (the-as protect-frame v0-0) exit) arg0) + (set! (-> (the-as protect-frame v0-0) next) (-> pp stack-frame-top)) + (set! (-> pp stack-frame-top) (the-as protect-frame v0-0)) + (the-as protect-frame v0-0) + ) ) ) @@ -1814,59 +1814,60 @@ ;; WARN: Unsupported inline assembly instruction kind - [lw ra, return-from-thread(s7)] ;; WARN: Unsupported inline assembly instruction kind - [jr ra] (defmethod deactivate process ((obj process)) - (local-vars (pp process) (s7-0 none) (ra-0 int)) - (when (!= (-> obj status) 'dead) - (set! (-> obj next-state) dead-state) - (if (-> obj entity) - (entity-deactivate-handler obj (-> obj entity)) - ) - (let ((s5-0 pp)) - (let ((s4-0 (-> obj stack-frame-top))) - (while (the-as protect-frame s4-0) - (let ((v1-5 (-> s4-0 type))) - (if (or (= v1-5 protect-frame) (= v1-5 state)) - ((-> (the-as protect-frame s4-0) exit)) - ) - ) - (set! (the-as protect-frame s4-0) (-> (the-as protect-frame s4-0) next)) - ) - ) - (let ((s6-2 s5-0)) - ) - ) - (process-disconnect obj) - (let ((v1-11 (-> obj child))) - (while v1-11 - (let ((s5-1 (-> v1-11 0 brother))) - (deactivate (-> v1-11 0)) - (set! v1-11 s5-1) - ) - ) - ) - (return-process (-> obj pool) obj) - (set! (-> obj state) #f) - (set! (-> obj next-state) #f) - (set! (-> obj entity) #f) - (set! (-> obj pid) 0) - (cond - ((= (-> *kernel-context* current-process) obj) - (set! (-> obj status) 'dead) - (.lw ra-0 return-from-thread s7-0) - (.jr ra-0) - (nop!) - (let ((v1-21 0)) - ) - ) - ((= (-> obj status) 'initialize) - (set! (-> obj status) 'dead) - (throw 'initialize #f) - ) - ) - (set! (-> obj status) 'dead) - (let ((v0-7 0)) - ) + (local-vars (s7-0 none) (ra-0 int)) + (with-pp (when (!= (-> obj status) 'dead) + (set! (-> obj next-state) dead-state) + (if (-> obj entity) + (entity-deactivate-handler obj (-> obj entity)) + ) + (let ((s5-0 pp)) + (let ((s4-0 (-> obj stack-frame-top))) + (while (the-as protect-frame s4-0) + (let ((v1-5 (-> s4-0 type))) + (if (or (= v1-5 protect-frame) (= v1-5 state)) + ((-> (the-as protect-frame s4-0) exit)) + ) + ) + (set! s4-0 (-> (the-as protect-frame s4-0) next)) + ) + ) + (let ((s6-2 s5-0)) + ) + ) + (process-disconnect obj) + (let ((v1-11 (-> obj child))) + (while v1-11 + (let ((s5-1 (-> v1-11 0 brother))) + (deactivate (-> v1-11 0)) + (set! v1-11 s5-1) + ) + ) + ) + (return-process (-> obj pool) obj) + (set! (-> obj state) #f) + (set! (-> obj next-state) #f) + (set! (-> obj entity) #f) + (set! (-> obj pid) 0) + (cond + ((= (-> *kernel-context* current-process) obj) + (set! (-> obj status) 'dead) + (.lw ra-0 return-from-thread s7-0) + (.jr ra-0) + (nop!) + (let ((v1-21 0)) + ) + ) + ((= (-> obj status) 'initialize) + (set! (-> obj status) 'dead) + (throw 'initialize #f) + ) + ) + (set! (-> obj status) 'dead) + (let ((v0-7 0)) + ) + ) + (none) ) - (none) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/kernel/gstate_REF.gc b/test/decompiler/reference/kernel/gstate_REF.gc index 27009c5470..974e7b85ab 100644 --- a/test/decompiler/reference/kernel/gstate_REF.gc +++ b/test/decompiler/reference/kernel/gstate_REF.gc @@ -62,83 +62,78 @@ (arg4 object) (arg5 object) ) - (local-vars - (pp process) - (s7-0 none) - (sp-0 none) - (sp-1 int) - (ra-0 int) - (sv-0 none) - ) - (set! - (-> pp mask) - (logand (lognot (process-mask sleep sleep-code)) (-> pp mask)) - ) - (set! (-> pp mask) (logior (-> pp mask) (process-mask going))) - (cond - ((= (-> pp status) 'initialize) - (set! (-> pp trans-hook) #f) - (set-to-run (-> pp main-thread) enter-state arg0 arg1 arg2 arg3 arg4 arg5) - (set! (-> pp status) 'initialize-go) - (throw 'initialize #t) - #t + (local-vars (s7-0 none) (sp-0 none) (sp-1 int) (ra-0 int) (sv-0 none)) + (with-pp + (set! + (-> pp mask) + (logand (lognot (process-mask sleep sleep-code)) (-> pp mask)) ) - ((!= (-> *kernel-context* current-process) pp) - (let ((s0-0 (-> pp status))) + (set! (-> pp mask) (logior (-> pp mask) (process-mask going))) + (cond + ((= (-> pp status) 'initialize) (set! (-> pp trans-hook) #f) (set-to-run (-> pp main-thread) enter-state arg0 arg1 arg2 arg3 arg4 arg5) - (set! (-> pp status) s0-0) + (set! (-> pp status) 'initialize-go) + (throw 'initialize #t) + #t ) - #t - ) - ((= (-> pp main-thread) (-> pp top-thread)) - (set! (-> pp state) (-> pp next-state)) - (let ((s0-1 (-> pp stack-frame-top))) - (while s0-1 - (let ((v1-10 (-> s0-1 type))) - (if (or (= v1-10 protect-frame) (= v1-10 state)) - ((-> (the-as protect-frame s0-1) exit)) + ((!= (-> *kernel-context* current-process) pp) + (let ((s0-0 (-> pp status))) + (set! (-> pp trans-hook) #f) + (set-to-run (-> pp main-thread) enter-state arg0 arg1 arg2 arg3 arg4 arg5) + (set! (-> pp status) s0-0) + ) + #t + ) + ((= (-> pp main-thread) (-> pp top-thread)) + (set! (-> pp state) (-> pp next-state)) + (let ((s0-1 (-> pp stack-frame-top))) + (while s0-1 + (let ((v1-10 (-> s0-1 type))) + (if (or (= v1-10 protect-frame) (= v1-10 state)) + ((-> (the-as protect-frame s0-1) exit)) + ) + ) + (set! s0-1 (-> s0-1 next)) + ) + ) + (set! (-> pp mask) (logand (lognot (process-mask going)) (-> pp mask))) + (let ((s0-2 (-> pp state))) + (set! (-> pp event-hook) (-> s0-2 event)) + (if (-> s0-2 exit) + (set! (-> pp stack-frame-top) s0-2) + (set! (-> pp stack-frame-top) #f) + ) + (set! (-> pp post-hook) (-> s0-2 post)) + (set! (-> pp trans-hook) (-> s0-2 trans)) + (let ((t9-4 (-> s0-2 enter))) + (if t9-4 + (t9-4 arg0 arg1 arg2 arg3 arg4 arg5) ) ) - (set! s0-1 (-> s0-1 next)) - ) - ) - (set! (-> pp mask) (logand (lognot (process-mask going)) (-> pp mask))) - (let ((s0-2 (-> pp state))) - (set! (-> pp event-hook) (-> s0-2 event)) - (if (-> s0-2 exit) - (set! (-> pp stack-frame-top) s0-2) - (set! (-> pp stack-frame-top) #f) - ) - (set! (-> pp post-hook) (-> s0-2 post)) - (set! (-> pp trans-hook) (-> s0-2 trans)) - (let ((t9-4 (-> s0-2 enter))) - (if t9-4 - (t9-4 arg0 arg1 arg2 arg3 arg4 arg5) + (let ((t9-5 (-> s0-2 trans))) + (if t9-5 + (t9-5) + ) + ) + (let ((v1-28 (-> pp main-thread))) + (.lwu sp-1 28 v1-28) + ) + (let ((t9-6 (-> s0-2 code))) + (.lw ra-0 return-from-thread-dead s7-0) + (.jr t9-6) ) ) - (let ((t9-5 (-> s0-2 trans))) - (if t9-5 - (t9-5) - ) - ) - (let ((v1-28 (-> pp main-thread))) - (.lwu sp-1 28 v1-28) - ) - (let ((t9-6 (-> s0-2 code))) - (.lw ra-0 return-from-thread-dead s7-0) - (.jr t9-6) - ) + arg4 ) - arg4 - ) - (else - (set! (-> pp trans-hook) #f) - (set-to-run (-> pp main-thread) enter-state arg0 arg1 arg2 arg3 arg4 arg5) - (when (!= (-> pp top-thread name) 'post) - (let ((v0-2 (the-as object return-from-thread))) - (.sw (the-as (function none) v0-2) 0 sp-0) - v0-2 + (else + (set! (-> pp trans-hook) #f) + (set-to-run (-> pp main-thread) enter-state arg0 arg1 arg2 arg3 arg4 arg5) + (when (!= (-> pp top-thread name) 'post) + (let ((v0-2 (the-as object return-from-thread))) + (.sw (the-as (function none) v0-2) 0 sp-0) + v0-2 + ) ) ) ) @@ -147,24 +142,25 @@ ;; definition for function send-event-function (defun send-event-function ((arg0 process) (arg1 event-message-block)) - (local-vars (pp process)) - (when (and arg0 (!= (-> arg0 type) process-tree) (-> arg0 event-hook)) - (let ((gp-0 pp)) - (let ((s6-1 arg0)) - ) - (let - ((v0-0 - ((-> arg0 event-hook) - (-> arg1 from) - (-> arg1 num-params) - (-> arg1 message) - arg1 + (with-pp + (when (and arg0 (!= (-> arg0 type) process-tree) (-> arg0 event-hook)) + (let ((gp-0 pp)) + (let ((s6-1 arg0)) + ) + (let + ((v0-0 + ((-> arg0 event-hook) + (-> arg1 from) + (-> arg1 num-params) + (-> arg1 message) + arg1 + ) ) ) + (let ((s6-2 gp-0)) + ) + v0-0 ) - (let ((s6-2 gp-0)) - ) - v0-0 ) ) ) diff --git a/test/goalc/test_with_game.cpp b/test/goalc/test_with_game.cpp index 08d251367c..023836b3c8 100644 --- a/test/goalc/test_with_game.cpp +++ b/test/goalc/test_with_game.cpp @@ -835,6 +835,8 @@ struct VectorFloatTestCase { virtual VectorFloatRegister getExpectedResult() = 0; virtual void setJson(nlohmann::json& data, std::string func) = 0; + + virtual ~VectorFloatTestCase() = default; }; struct VectorFloatTestCase_TwoOperand : VectorFloatTestCase { diff --git a/test/offline/offline_test_main.cpp b/test/offline/offline_test_main.cpp index dfc1f37cf4..05898d1a0d 100644 --- a/test/offline/offline_test_main.cpp +++ b/test/offline/offline_test_main.cpp @@ -46,23 +46,35 @@ const std::unordered_set g_functions_expected_to_reject = { "(method 9 bounding-box)", // handwritten asm loop "(method 14 bounding-box)", // handwritten asm loop // trig - "exp", "atan0", "sincos!", "sincos-rad!", + "exp", + "atan0", + "sincos!", + "sincos-rad!", // matrix "(method 9 matrix)", // handwritten asm loop - "matrix-axis-sin-cos!", "matrix-axis-sin-cos-vu!", + "matrix-axis-sin-cos!", + "matrix-axis-sin-cos-vu!", // dma-h "dma-count-until-done", // dma asm loop - "dma-sync-with-count", "dma-send-no-scratch", "dma-sync-fast", + "dma-sync-with-count", + "dma-send-no-scratch", + "dma-sync-fast", // dma - "symlink2", "symlink3", "dma-sync-hang", // handwritten asm - "vector=", // asm branching + "symlink2", + "symlink3", + "dma-sync-hang", // handwritten asm + "vector=", // asm branching // display "vblank-handler", // asm - "vif1-handler", "vif1-handler-debug", + "vif1-handler", + "vif1-handler-debug", // stats-h - "(method 11 perf-stat)", "(method 12 perf-stat)", + "(method 11 perf-stat)", + "(method 12 perf-stat)", // ripple - asm - "ripple-execute-init", "ripple-create-wave-table", "ripple-apply-wave-table", + "ripple-execute-init", + "ripple-create-wave-table", + "ripple-apply-wave-table", "ripple-matrix-scale", // ripple - calls an asm function "ripple-execute", @@ -74,6 +86,10 @@ const std::unordered_set g_functions_expected_to_reject = { // collide-mesh-h "(method 11 collide-mesh-cache)", // asm + + // actor-link-h + "(method 21 actor-link-info)", // BUG: sc cfg / cfg-ir bug + "(method 20 actor-link-info)", }; const std::unordered_set g_functions_to_skip_compiling = { diff --git a/third-party/11zip/extlibs/minizip/src/miniunz.c b/third-party/11zip/extlibs/minizip/src/miniunz.c index a2c01dcd9c..5044f065ad 100644 --- a/third-party/11zip/extlibs/minizip/src/miniunz.c +++ b/third-party/11zip/extlibs/minizip/src/miniunz.c @@ -142,7 +142,7 @@ char* dirname; int makedir(newdir) -char* newdir; +const char* newdir; { char* buffer; char* p; diff --git a/third-party/lzokay/lzokay.cpp b/third-party/lzokay/lzokay.cpp index e59e9cab3f..160718bf7d 100644 --- a/third-party/lzokay/lzokay.cpp +++ b/third-party/lzokay/lzokay.cpp @@ -70,19 +70,19 @@ constexpr std::size_t Max255Count = std::size_t(~0) / 255 - 2; constexpr uint32_t M1MaxOffset = 0x0400; constexpr uint32_t M2MaxOffset = 0x0800; constexpr uint32_t M3MaxOffset = 0x4000; -constexpr uint32_t M4MaxOffset = 0xbfff; +//constexpr uint32_t M4MaxOffset = 0xbfff; -constexpr uint32_t M1MinLen = 2; -constexpr uint32_t M1MaxLen = 2; +//constexpr uint32_t M1MinLen = 2; +//constexpr uint32_t M1MaxLen = 2; constexpr uint32_t M2MinLen = 3; constexpr uint32_t M2MaxLen = 8; -constexpr uint32_t M3MinLen = 3; +//constexpr uint32_t M3MinLen = 3; constexpr uint32_t M3MaxLen = 33; -constexpr uint32_t M4MinLen = 3; +//constexpr uint32_t M4MinLen = 3; constexpr uint32_t M4MaxLen = 9; constexpr uint32_t M1Marker = 0x0; -constexpr uint32_t M2Marker = 0x40; +//constexpr uint32_t M2Marker = 0x40; constexpr uint32_t M3Marker = 0x20; constexpr uint32_t M4Marker = 0x10;