From 34e8afa0eea4f37a97d56742e2b1ba7f5c59cb37 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Tue, 31 Aug 2021 11:05:03 -0400 Subject: [PATCH] get started on entity (#793) --- decompiler/IR2/bitfields.cpp | 130 +- decompiler/config/all-types.gc | 156 +- .../anonymous_function_types.jsonc | 4 + .../config/jak1_ntsc_black_label/hacks.jsonc | 3 +- .../jak1_ntsc_black_label/label_types.jsonc | 15 + .../stack_structures.jsonc | 9 + .../jak1_ntsc_black_label/type_casts.jsonc | 67 + .../jak1_ntsc_black_label/var_names.jsonc | 55 + decompiler/util/data_decompile.cpp | 27 +- decompiler/util/data_decompile.h | 3 +- docs/markdown/progress-notes/changelog.md | 4 +- game/system/newpad.cpp | 4 + goal_src/engine/ambient/ambient.gc | 4 + goal_src/engine/draw/drawable.gc | 26 + goal_src/engine/draw/process-drawable-h.gc | 17 + goal_src/engine/entity/entity-h.gc | 36 +- goal_src/engine/entity/entity.gc | 1364 ++++++++++++++++- goal_src/engine/game/generic-obs-h.gc | 26 +- goal_src/engine/game/main.gc | 2 + goal_src/engine/gfx/vis/bsp-h.gc | 4 +- goal_src/engine/gfx/vis/bsp.gc | 4 +- goal_src/engine/level/level-h.gc | 14 +- goal_src/engine/level/level.gc | 5 +- goal_src/engine/nav/navigate-h.gc | 4 +- goal_src/examples/debug-draw-example.gc | 129 ++ goal_src/goal-lib.gc | 5 + goal_src/kernel/gkernel.gc | 4 +- goalc/compiler/compilation/Static.cpp | 18 +- goalc/compiler/compilation/Type.cpp | 2 +- .../reference/engine/entity/entity-h_REF.gc | 34 +- .../engine/game/generic-obs-h_REF.gc | 26 +- .../reference/engine/gfx/vis/bsp-h_REF.gc | 4 +- .../reference/engine/gfx/vis/bsp_REF.gc | 2 +- .../reference/engine/level/level-h_REF.gc | 14 +- .../reference/engine/nav/navigate-h_REF.gc | 32 +- .../reference/kernel/gkernel_REF.gc | 4 +- 36 files changed, 1924 insertions(+), 333 deletions(-) diff --git a/decompiler/IR2/bitfields.cpp b/decompiler/IR2/bitfields.cpp index db63d806a2..fa500137d9 100644 --- a/decompiler/IR2/bitfields.cpp +++ b/decompiler/IR2/bitfields.cpp @@ -728,6 +728,77 @@ Form* cast_sound_name(FormPool& pool, const Env& env, Form* in) { return pool.alloc_single_element_form( nullptr, fmt::format("(static-sound-name \"{}\")", name)); } + +std::optional> get_field_defs_from_expr(const BitFieldType* type_info, + Form* in, + const TypeSpec& typespec, + FormPool& pool, + const Env& env, + std::optional offset) { + auto in_as_generic = strip_int_or_uint_cast(in)->try_as_element(); + std::vector args; + if (in_as_generic && in_as_generic->op().is_fixed(FixedOperatorKind::LOGIOR)) { + args = compact_nested_logiors(in_as_generic, env); + } else { + args = {strip_int_or_uint_cast(in)}; + } + + if (!args.empty()) { + std::vector field_defs; + + for (auto it = args.begin(); it != args.end(); it++) { + auto constant = get_goal_integer_constant(*it, env); + if (constant) { + auto constant_defs = + try_decompile_bitfield_from_int(typespec, env.dts->ts, *constant, false, offset); + if (!constant_defs) { + return std::nullopt; // failed + } + for (auto& x : *constant_defs) { + field_defs.push_back(BitFieldDef::from_constant(x, pool)); + } + + args.erase(it); + break; + } + } + + // now variables + for (auto& arg : args) { + // it's a 64-bit constant so correct to set offset 0 here. + auto maybe_field = get_bitfield_initial_set(strip_int_or_uint_cast(arg), type_info, + env.dts->ts, offset ? *offset : 0); + if (!maybe_field) { + // failed, just return cast. + return std::nullopt; + } + + BitField field_info; + if (!type_info->lookup_field(maybe_field->field_name, &field_info)) { + assert(false); + } + if (field_info.type() == TypeSpec("symbol") || field_info.type() == TypeSpec("type")) { + maybe_field->value = strip_int_or_uint_cast(maybe_field->value); + } + + if (field_info.type() == TypeSpec("float")) { + auto stripped = strip_int_or_uint_cast(maybe_field->value); + auto integer = get_goal_integer_constant(stripped, env); + if (integer) { + float value_f; + u32 value_i = *integer; + memcpy(&value_f, &value_i, 4); + maybe_field->value = + pool.alloc_single_element_form(nullptr, value_f); + } + } + + field_defs.push_back(*maybe_field); + } + return field_defs; + } + return std::vector(); +} } // namespace /*! @@ -752,8 +823,9 @@ Form* cast_to_bitfield(const BitFieldType* type_info, // check if it's just a constant: auto in_as_atom = form_as_atom(in); if (in_as_atom && in_as_atom->is_int()) { + // will always be 64-bits auto fields = - try_decompile_bitfield_from_int(typespec, env.dts->ts, in_as_atom->get_int(), false); + try_decompile_bitfield_from_int(typespec, env.dts->ts, in_as_atom->get_int(), false, {}); if (!fields) { return pool.alloc_single_element_form(nullptr, typespec, in); } @@ -761,46 +833,32 @@ Form* cast_to_bitfield(const BitFieldType* type_info, pool); } - auto in_as_generic = strip_int_or_uint_cast(in)->try_as_element(); - std::vector args; - if (in_as_generic && in_as_generic->op().is_fixed(FixedOperatorKind::LOGIOR)) { - args = compact_nested_logiors(in_as_generic, env); - } else { - args = {strip_int_or_uint_cast(in)}; - } - - if (!args.empty()) { - std::vector field_defs; + bool bitfield_128 = type_info->get_size_in_memory() == 16; + if (bitfield_128) { + auto in_no_cast = strip_int_or_uint_cast(in); + auto pcpyld_matcher = + Matcher::fixed_op(FixedOperatorKind::PCPYLD, {Matcher::any(0), Matcher::any(1)}); + auto mr = match(pcpyld_matcher, in_no_cast); + if (mr.matched) { + auto upper = mr.maps.forms.at(0); + auto lower = mr.maps.forms.at(1); - for (auto it = args.begin(); it != args.end(); it++) { - auto constant = get_goal_integer_constant(*it, env); - if (constant) { - auto constant_defs = - try_decompile_bitfield_from_int(typespec, env.dts->ts, *constant, false); - if (!constant_defs) { - return pool.alloc_single_element_form(nullptr, typespec, in); - } - for (auto& x : *constant_defs) { - field_defs.push_back(BitFieldDef::from_constant(x, pool)); - } + auto upper_defs = get_field_defs_from_expr(type_info, upper, typespec, pool, env, 64); + auto lower_defs = get_field_defs_from_expr(type_info, lower, typespec, pool, env, 0); - args.erase(it); - break; + if (upper_defs && lower_defs) { + lower_defs->insert(lower_defs->end(), upper_defs->begin(), upper_defs->end()); + return pool.alloc_single_element_form(nullptr, typespec, + *lower_defs); } } - - // now variables - for (auto& arg : args) { - // it's a 64-bit constant so correct to set offset 0 here. - auto maybe_field = - get_bitfield_initial_set(strip_int_or_uint_cast(arg), type_info, env.dts->ts, 0); - if (!maybe_field) { - // failed, just return cast. - return pool.alloc_single_element_form(nullptr, typespec, in); - } - field_defs.push_back(*maybe_field); + return pool.alloc_single_element_form(nullptr, typespec, in); + } else { + auto field_defs = get_field_defs_from_expr(type_info, in, typespec, pool, env, {}); + if (field_defs) { + return pool.alloc_single_element_form(nullptr, typespec, + *field_defs); } - return pool.alloc_single_element_form(nullptr, typespec, field_defs); } // all failed, just return whatever. diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index f49537f0fc..baba6c8a2e 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -624,6 +624,7 @@ (bit-7 7) (real-complete 8) (bit-9 9) + (bit-10 10) ) (defenum path-control-flag @@ -1262,7 +1263,7 @@ ;; - Functions -(define-extern entity-deactivate-handler (function process object none)) +(define-extern entity-deactivate-handler (function process entity none)) (define-extern process-disconnect (function process int)) (define-extern throw (function symbol object int)) (define-extern set-to-run-bootstrap (function none)) @@ -4968,7 +4969,7 @@ :flag-assert #x1d00000a30 (:methods (deactivate (_type_) _type_ 9) - (dummy-10 (_type_ int) symbol 10) + (is-object-visible? (_type_ int) symbol 10) (add-irq-to-tex-buckets! (_type_) none 11) (unload! (_type_) _type_ 12) (bsp-name (_type_) symbol 13) @@ -5021,18 +5022,18 @@ (level-get-with-status (_type_ symbol) level 10) (level-get-for-use (_type_ symbol symbol) level 11) (activate-levels! (_type_) int 12) - (dummy-13 () none 13) - (dummy-14 (_type_ object) none 14) - (dummy-15 () none 15) + (debug-print-entities (_type_ symbol type) none 13) + (debug-draw-actors (_type_ symbol) none 14) + (dummy-15 (_type_) object 15) (dummy-16 (_type_) int 16) (level-get-target-inside (_type_) level 17) (alloc-levels! (_type_ symbol) int 18) (load-commands-set! (_type_ pair) pair 19) (art-group-get-by-name (_type_ string) art-group 20) (load-command-get-index (_type_ symbol int) pair 21) - (dummy-22 () none 22) - (dummy-23 () none 23) - (dummy-24 () none 24) + (update-vis-volumes (_type_) none 22) + (update-vis-volumes-from-nav-mesh (_type_) none 23) + (print-volume-sizes (_type_) none 24) (level-status (_type_ symbol) symbol 25) (level-get-most-disposable (_type_) level 26) ) @@ -10094,8 +10095,8 @@ ) (deftype part-tracker (process) - ((root basic :offset-assert 112) - (part basic :offset-assert 116) + ((root trsqv :offset-assert 112) + (part sparticle-launch-control :offset-assert 116) (target uint64 :offset-assert 120) (callback basic :offset-assert 128) (linger-callback basic :offset-assert 132) @@ -11819,7 +11820,7 @@ (unk-data-4 float :offset-assert 160) (unk-data-5 float :offset-assert 164) (adgifs adgif-shader-array :offset-assert 168) - (unk-data-6 pointer :offset-assert 172) + (actor-birth-order (pointer uint32) :offset-assert 172) (unk-data-7 pointer :offset-assert 176) (unk-data-8 uint32 55 :offset-assert 180) @@ -11829,7 +11830,7 @@ :flag-assert #x1400000190 (:methods (relocate (_type_ kheap (pointer uint8)) none :replace 7) - (dummy-18 (_type_) none 18) + (birth (_type_) none 18) (dummy-19 (_type_) none 19) ) ) @@ -13027,7 +13028,7 @@ :size-assert #x40 :flag-assert #xa00000040 (:methods - (dummy-9 () none 9) + (dummy-9 (_type_ vector) none 9) ) ) @@ -13055,11 +13056,11 @@ :flag-assert #x1b00000034 ;; unrecognized get op: (set! t9 find-parent-method) parent was res-lump (:methods - (dummy-22 () none 22) - (dummy-23 () none 23) - (dummy-24 () none 24) - (dummy-25 () none 25) - (dummy-26 () none 26) + (birth! (_type_) _type_ 22) + (kill! (_type_) _type_ 23) + (add-to-level! (_type_ level-group level actor-id) none 24) + (remove-from-level! (_type_ level-group) _type_ 25) + (get-level (_type_) level 26) ) ) @@ -13093,7 +13094,7 @@ ) (deftype entity-ambient-data-array (inline-array-class) - () + ((data entity-ambient-data :dynamic :inline)) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 @@ -13106,7 +13107,7 @@ :flag-assert #x1d00000034 (:methods (dummy-27 () none 27) - (dummy-28 () none 28) + (birth-ambient! (_type_) none 28) ) ) @@ -13117,6 +13118,7 @@ (etype type :offset-assert 56) ;; probably type (task uint8 :offset-assert 60) (vis-id uint16 :offset-assert 62) + (vis-id-signed int16 :offset 62) ;; added (quat quaternion :inline :offset-assert 64) ) :method-count-assert 31 @@ -13126,8 +13128,8 @@ (:methods (next-actor (_type_) entity-actor 27) (prev-actor (_type_) entity-actor 28) - (dummy-29 () none 29) - (dummy-30 () none 30) + (debug-print (_type_ symbol type) none 29) + (dummy-30 (_type_ entity-perm-status symbol) none 30) ) ) @@ -14519,7 +14521,7 @@ (node-count int32 :offset-assert 176) (nodes uint32 :offset-assert 180) (vertex-count int32 :offset-assert 184) - (vertex uint32 :offset-assert 188) + (vertex (inline-array vector) :offset-assert 188) (poly-count int32 :offset-assert 192) (poly uint32 :offset-assert 196) (route uint32 :offset-assert 200) @@ -14538,7 +14540,7 @@ (dummy-16 () none 16) (dummy-17 (_type_) none 17) (dummy-18 () none 18) - (dummy-19 () none 19) + (compute-bounding-box (_type_ vector vector) none 19) (dummy-20 () none 20) (dummy-21 () none 21) (dummy-22 () none 22) @@ -17434,7 +17436,7 @@ (define-extern command-get-int (function object int int)) (define-extern ambient-hint-spawn (function symbol symbol process-tree none)) (define-extern command-get-float (function object float float)) -(define-extern process-by-ename function) +(define-extern process-by-ename (function string process)) (define-extern point-in-polygon function) (define-extern try-corner function) (define-extern split-monotone-polygon function) @@ -18627,7 +18629,7 @@ (define-extern camera-fov-draw function) (define-extern cam-line-dma function) (define-extern camera-line2d function) -(define-extern camera-plot-float-func function) +(define-extern camera-plot-float-func (function float float float float (function float float) vector4w none)) (define-extern cam-debug-add-coll-tri function) (define-extern debug-euler function) (define-extern bike-cam-limit function) @@ -18905,7 +18907,7 @@ (define-extern line-in-view-frustum? function) (define-extern process-drawable-random-point! function) -(define-extern process-drawable-from-entity! (function process-drawable object none)) +(define-extern process-drawable-from-entity! (function process-drawable res-lump none)) (define-extern cam-launcher-long-joystick function) (define-extern hide-hud-quick (function none)) (define-extern command-get-process function) @@ -19649,7 +19651,7 @@ (define-extern dma-add-process-drawable-hud function) (define-extern foreground-engine-execute (function engine display-frame int int none)) (define-extern main-debug-hook function) -(define-extern main-draw-hook function) +(define-extern main-draw-hook (function none)) (define-extern swap-display (function display none)) (define-extern marks-cam-restore function) (define-extern eddie-cam-restore function) @@ -19840,23 +19842,23 @@ ;; - Functions (define-extern task-control-reset (function symbol none)) -(define-extern init-entity function) -(define-extern birth-viewer function) -(define-extern update-actor-vis-box function) -(define-extern process-status-bits function) -(define-extern entity-by-meters function) -(define-extern entity-process-count function) -(define-extern entity-count function) -(define-extern entity-remap-names function) -(define-extern expand-vis-box-with-point function) -(define-extern entity-task-complete-on function) -(define-extern entity-task-complete-off function) -(define-extern entity-speed-test function) +(define-extern init-entity (function process entity none)) +(define-extern birth-viewer (function process entity object)) +(define-extern update-actor-vis-box (function process-drawable vector vector none)) +(define-extern process-status-bits (function process symbol none)) +(define-extern entity-by-meters (function float float float entity-actor)) +(define-extern entity-process-count (function symbol int)) +(define-extern entity-count (function int)) +(define-extern entity-remap-names (function pair none)) +(define-extern expand-vis-box-with-point (function entity vector none)) +(define-extern entity-task-complete-on (function entity none)) +(define-extern entity-task-complete-off (function entity none)) +(define-extern entity-speed-test (function string none)) ;; - Unknowns (define-extern *compact-actors* symbol) -;;(define-extern *vis-actors* object) ;; unknown type +(define-extern *vis-actors* symbol) ;; ---------------------- @@ -21418,28 +21420,15 @@ ;; - Types -; (deftype viewer (process-drawable) -; ((janim basic :offset-assert 176) -; ) -; :method-count-assert 20 -; :size-assert #xb4 -; :heap-base #x50 -; :flag-assert #x14005000b4 -; ;; inherited inspect of process-drawable -; (: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) -; ) -; ) +(deftype viewer (process-drawable) + ((janim art-joint-anim :offset-assert 176) + ) + :method-count-assert 20 + :size-assert #xb4 + :heap-base #x50 + :flag-assert #x14005000b4 + ;; inherited inspect of process-drawable + ) ;; - Functions @@ -21452,11 +21441,11 @@ ;; - Unknowns ;;(define-extern *viewer* object) ;; unknown type -;;(define-extern viewer-ja-name object) ;; unknown type -;;(define-extern viewer-geo-name object) ;; unknown type +(define-extern viewer-ja-name string) +(define-extern viewer-geo-name string) (define-extern *viewer-sg* skeleton-group) -;;(define-extern viewer-process object) ;; unknown type -;;(define-extern viewer-string object) ;; unknown type +(define-extern viewer-process (state viewer)) +(define-extern viewer-string string) ;; ---------------------- @@ -29150,29 +29139,16 @@ ;; - Types -; (deftype springbox (process-drawable) -; ((spring-height meters :offset-assert 176) -; (smush float :offset-assert 180) -; ) -; :method-count-assert 20 -; :size-assert #xb8 -; :heap-base #x50 -; :flag-assert #x14005000b8 -; ;; inherited inspect of process-drawable -; (: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) -; ) -; ) +(deftype springbox (process-drawable) + ((spring-height meters :offset-assert 176) + (smush float :offset-assert 180) + ) + :method-count-assert 20 + :size-assert #xb8 + :heap-base #x50 + :flag-assert #x14005000b8 + ;; inherited inspect of process-drawable + ) ;; - Unknowns diff --git a/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc b/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc index a2a5f4f1f4..98d6e8b63d 100644 --- a/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc @@ -679,6 +679,10 @@ "basebutton": [ [1, "(function symbol :behavior target)"] ], + + "entity": [ + [10, "(function process-drawable none)"] + ], "placeholder-do-not-add-below": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc index a128485921..5b50c924a4 100644 --- a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc @@ -418,7 +418,8 @@ "(method 8 process-tree)", "(method 16 load-state)", "(method 15 load-state)", - "build-continue-menu" + "build-continue-menu", + "entity-remap-names" ], // If format is used with the wrong number of arguments, diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index 99cf52bb29..a83fba398e 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -427,6 +427,21 @@ // ["L276", "sparticle-launch-group", true], ], + "entity": [ + ["L483", "vector"], + ["L482", "vector"], + ["L480", "vector"], + ["L479", "vector"], + ["L478", "vector"], + ["L477", "vector"], + ["L476", "vector"], + ["L475", "vector4w"], + ["L474", "vector4w"], + ["L473", "vector4w"], + ["L472", "vector4w"], + ["L471", "vector4w"] + ], + // please do not add things after this entry! git is dumb. "object-file-that-doesnt-actually-exist-and-i-just-put-this-here-to-prevent-merge-conflicts-with-this-file": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc index 670b1cc109..0f114cc99e 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -1401,5 +1401,14 @@ [16, "event-message-block"] ], + "update-actor-vis-box": [ + [16, "vector"] + ], + + "(method 14 level-group)":[ + [16, "vector"], + [32, "vector"] + ], + "placeholder-do-not-add-below!": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 238c90d1f7..4b0abd55eb 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -2481,5 +2481,72 @@ [30, "t9", "(function int debug-menu-msg float float int)"] ], + "entity-remap-names": [ + [33, "a1", "int"], + [39, "a2", "int"] + ], + + "process-status-bits": [ + [[15, 59], "s3", "process-drawable"] + ], + + "(method 13 level-group)": [ + [[56, 61], "a0", "entity-actor"] + ], + + "(method 24 entity)": [ + [[39, 45], "a0", "entity-actor"] + ], + + "(method 23 level-group)": [ + [53, "a0", "entity-actor"], + [57, "v1", "entity-actor"], + [[29, 31], "v0", "(inline-array vector)"] + ], + + "(method 24 level-group)": [ + [51, "v1", "entity-actor"], + [[55, 57], "s1", "(inline-array vector)"] + ], + + "init-entity": [ + [31, "t9", "(function process function process entity none)"] + ], + + "(method 19 bsp-header)": [ + [[53, 63], "s2", "process"], + [74, "s2", "part-tracker"], + [[104, 122], "v1", "process-drawable"], + [[129, 148], "v1", "process-drawable"], + [[123, 127], "a0", "process-drawable"] + ], + + "(method 3 entity)": [ + [7, "t9", "(function entity entity)"] + ], + + "(method 3 entity-actor)": [ + [7, "t9", "(function entity-actor entity-actor)"] + ], + + "(method 14 level-group)": [ + [[54, 164], "s1", "process-drawable"], + [[319, 342], "s0", "process-drawable"], + [368, "v1", "(pointer process-drawable)"], + [[384, 494], "s5", "process-drawable"] + ], + + "(method 22 level-group)": [ + [[28, 30], "v0", "(inline-array vector)"] + ], + + "expand-vis-box-with-point": [ + [10, "v0", "(inline-array vector)"] + ], + + "(method 28 entity-ambient)": [ + [79, "v1", "int"] + ], + "placeholder-do-not-add-below": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index 0cd72f5ebf..b94de87195 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -3290,5 +3290,60 @@ "(anon-function 82 default-menu)": { "vars":{"s4-0":["s4-0", "texture-id"]} }, + + "process-status-bits": { + "vars":{"s3-0":["proc-draw", "process-drawable"]} + }, + + "(method 29 entity-actor)":{ + "args":["obj", "mode", "expected-type"] + }, + + "(method 13 level-group)":{ + "args":["obj", "mode", "expected-type"] + }, + + "(method 24 entity)": { + "args":["obj", "lev-group", "lev", "aid"], + "vars":{ + "v1-4":"level-link", + "t0-5":"other-prev", + "t1-1":"other-front" + } + }, + + "update-actor-vis-box": { + "args":["proc", "min-pt", "max-pt"], + "vars":{"v1-4":"world-bounds-origin", "f0-0":"radius"} + }, + + "init-entity": { + "args":["proc", "ent"] + }, + + "(method 22 entity-actor)": { + "vars":{ + "s5-0":"entity-type", + "v1-0":"info", + "s4-0":"entity-process" + } + }, + + "(method 18 bsp-header)": { + "vars":{ + "a2-0":"existing-actor-count", + "s4-0":"birth-idx", + "a0-4":"idx-to-birth", + "v1-25":"actor-to-birth", + "a2-5":"existing-amb-count", + "s4-1":"amb-array", + "s3-0":"bsp-ambs", + "a0-10":"amb-to-birth", + "s4-2":"cams" + } + + }, + + "aaaaaaaaaaaaaaaaaaaaaaa": {} } diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index 1f1d686e0c..fd4e1c7af8 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -1192,23 +1192,36 @@ std::optional> try_decompile_bitfield_from_int( const TypeSpec& type, const TypeSystem& ts, u64 value, - bool require_success) { + bool require_success, + std::optional offset) { u64 touched_bits = 0; std::vector result; auto type_info = dynamic_cast(ts.lookup_type(type)); assert(type_info); + int start_bit = 0; + + if (offset) { + start_bit = *offset; + } + int end_bit = 64 + start_bit; + for (auto& field : type_info->fields()) { + if (field.offset() < start_bit || (field.offset() + field.size()) > end_bit) { + continue; + } + u64 bitfield_value; bool is_signed = ts.tc(TypeSpec("int"), field.type()) && !ts.tc(TypeSpec("uint"), field.type()); if (is_signed) { // signed s64 signed_value = value; - bitfield_value = extract_bitfield(signed_value, field.offset(), field.size()); + bitfield_value = + extract_bitfield(signed_value, field.offset() - start_bit, field.size()); } else { // unsigned - bitfield_value = extract_bitfield(value, field.offset(), field.size()); + bitfield_value = extract_bitfield(value, field.offset() - start_bit, field.size()); } if (bitfield_value != 0) { @@ -1226,13 +1239,15 @@ std::optional> try_decompile_bitfield_from_int( if (nested_bitfield_type) { BitFieldConstantDef::NestedField nested; nested.field_type = field.type(); - nested.fields = *try_decompile_bitfield_from_int(field.type(), ts, bitfield_value, true); + // never nested 128-bit bitfields + nested.fields = + *try_decompile_bitfield_from_int(field.type(), ts, bitfield_value, true, {}); def.nested_field = nested; } result.push_back(def); } - for (int i = field.offset(); i < field.offset() + field.size(); i++) { + for (int i = field.offset() - start_bit; i < field.offset() + field.size() - start_bit; i++) { touched_bits |= (u64(1) << i); } } @@ -1254,7 +1269,7 @@ std::optional> try_decompile_bitfield_from_int( std::vector decompile_bitfield_from_int(const TypeSpec& type, const TypeSystem& ts, u64 value) { - return *try_decompile_bitfield_from_int(type, ts, value, true); + return *try_decompile_bitfield_from_int(type, ts, value, true, {}); } std::vector decompile_bitfield_enum_from_int(const TypeSpec& type, diff --git a/decompiler/util/data_decompile.h b/decompiler/util/data_decompile.h index 6303f62934..1788e6d00b 100644 --- a/decompiler/util/data_decompile.h +++ b/decompiler/util/data_decompile.h @@ -98,7 +98,8 @@ std::optional> try_decompile_bitfield_from_int( const TypeSpec& type, const TypeSystem& ts, u64 value, - bool require_success); + bool require_success, + std::optional offset); std::vector decompile_bitfield_enum_from_int(const TypeSpec& type, const TypeSystem& ts, diff --git a/docs/markdown/progress-notes/changelog.md b/docs/markdown/progress-notes/changelog.md index 7cdd29671d..9cb746abee 100644 --- a/docs/markdown/progress-notes/changelog.md +++ b/docs/markdown/progress-notes/changelog.md @@ -194,4 +194,6 @@ - It is possible to access fields of the parent of a forward declared type - Fixed a bug where casting a value to seconds, then setting a field of type seconds would incorrectly fail type-check - Fixed a bug where nested rlet's didn't properly share register constraints, leading to inefficient register allocation, and some rare cases a regalloc constraint error -- Lambdas may now be used in static pairs. \ No newline at end of file +- Lambdas may now be used in static pairs. +- Dynamically constructed bitfields created with `(new 'static ...` may now set fields with `structure` type. +- Allocations on `'loading-level` are now permitted. \ No newline at end of file diff --git a/game/system/newpad.cpp b/game/system/newpad.cpp index 2ac9daaf2a..e9b2bd1837 100644 --- a/game/system/newpad.cpp +++ b/game/system/newpad.cpp @@ -124,6 +124,10 @@ void DefaultMapping(MappingInfo& mapping) { } } + // r1/l1 + MapButton(mapping, Button::L1, 0, GLFW_KEY_U); + MapButton(mapping, Button::R1, 0, GLFW_KEY_I); + // face buttons MapButton(mapping, Button::Ecks, 0, GLFW_KEY_Z); MapButton(mapping, Button::Square, 0, GLFW_KEY_X); diff --git a/goal_src/engine/ambient/ambient.gc b/goal_src/engine/ambient/ambient.gc index 2a79a2e077..b8ea66e41f 100644 --- a/goal_src/engine/ambient/ambient.gc +++ b/goal_src/engine/ambient/ambient.gc @@ -5,3 +5,7 @@ ;; name in dgo: ambient ;; dgos: GAME, ENGINE +(defmethod birth-ambient! entity-ambient ((obj entity-ambient)) + ;; TODO stub + (none) + ) \ No newline at end of file diff --git a/goal_src/engine/draw/drawable.gc b/goal_src/engine/draw/drawable.gc index b9759b7e07..16a4198467 100644 --- a/goal_src/engine/draw/drawable.gc +++ b/goal_src/engine/draw/drawable.gc @@ -5,6 +5,32 @@ ;; name in dgo: drawable ;; dgos: GAME, ENGINE +(defun real-main-draw-hook () + (when *slow-frame-rate* + (dotimes (v1-2 #xc3500) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + ) + ) + "Function to be executed to set up for engine dma" + ;; lots more in this function. + (when *debug-segment* + (debug-draw-actors *level* *display-actor-marks*) + ) + ) + +(defun main-draw-hook () + "Nice." + (real-main-draw-hook) + (none) + ) + +(define *draw-hook* main-draw-hook) + (defun debug-init-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) "Initialize a bucket for debug draw with the given zbuf and test settings" (let* ((t0-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) diff --git a/goal_src/engine/draw/process-drawable-h.gc b/goal_src/engine/draw/process-drawable-h.gc index b712fb26a3..7ca62835ff 100644 --- a/goal_src/engine/draw/process-drawable-h.gc +++ b/goal_src/engine/draw/process-drawable-h.gc @@ -148,3 +148,20 @@ (-> arg0 frame-num) ) +(defenum entity-perm-status + :bitfield #t + :type uint16 + (bit-0 0) + (bit-1 1) + (dead 2) + (bit-3 3) + (bit-4 4) + (user-set-from-cstage 5) + (complete 6) + (bit-7 7) + (real-complete 8) + (bit-9 9) + (bit-10 10) + ) + +(define-extern process-entity-status! (function process entity-perm-status symbol int)) \ No newline at end of file diff --git a/goal_src/engine/entity/entity-h.gc b/goal_src/engine/entity/entity-h.gc index ba04a6542c..9d8dd21f75 100644 --- a/goal_src/engine/entity/entity-h.gc +++ b/goal_src/engine/entity/entity-h.gc @@ -9,21 +9,6 @@ (define *generate-actor-vis-start* #f) (define *generate-actor-vis-output* #f) -(defenum entity-perm-status - :bitfield #t - :type uint16 - (bit-0 0) - (bit-1 1) - (dead 2) - (bit-3 3) - (bit-4 4) - (user-set-from-cstage 5) - (complete 6) - (bit-7 7) - (real-complete 8) - (bit-9 9) - ) - ;; definition of type entity-perm (deftype entity-perm (structure) ((user-object object 2 :offset-assert 0) @@ -67,7 +52,7 @@ :size-assert #x40 :flag-assert #xa00000040 (:methods - (dummy-9 () none 9) + (dummy-9 (_type_ vector) none 9) ) ) @@ -97,11 +82,11 @@ :size-assert #x34 :flag-assert #x1b00000034 (:methods - (dummy-22 () none 22) - (dummy-23 () none 23) - (dummy-24 () none 24) - (dummy-25 () none 25) - (dummy-26 () none 26) + (birth! (_type_) _type_ 22) + (kill! (_type_) _type_ 23) + (add-to-level! (_type_ level-group level actor-id) none 24) + (remove-from-level! (_type_ level-group) _type_ 25) + (get-level (_type_) level 26) ) ) @@ -132,7 +117,7 @@ ) (deftype entity-ambient-data-array (inline-array-class) - () + ((data entity-ambient-data :inline :dynamic)) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 @@ -146,7 +131,7 @@ :flag-assert #x1d00000034 (:methods (dummy-27 () none 27) - (dummy-28 () none 28) + (birth-ambient! (_type_) none 28) ) ) @@ -155,6 +140,7 @@ (etype type :offset-assert 56) (task uint8 :offset-assert 60) (vis-id uint16 :offset-assert 62) + (vis-id-signed int16 :offset 62) ;; added (quat quaternion :inline :offset-assert 64) ) :method-count-assert 31 @@ -163,8 +149,8 @@ (:methods (next-actor (_type_) entity-actor 27) (prev-actor (_type_) entity-actor 28) - (dummy-29 () none 29) - (dummy-30 () none 30) + (debug-print (_type_ symbol type) none 29) + (dummy-30 (_type_ entity-perm-status symbol) none 30) ) ) diff --git a/goal_src/engine/entity/entity.gc b/goal_src/engine/entity/entity.gc index c80d7a40bb..a2a8fe1be9 100644 --- a/goal_src/engine/entity/entity.gc +++ b/goal_src/engine/entity/entity.gc @@ -5,84 +5,1226 @@ ;; name in dgo: entity ;; dgos: GAME, ENGINE -;; needs cleanup, but this does work! +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; global entity settings +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define *spawn-actors* #t) +(define *compact-actors* #t) +(define *vis-actors* #t) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; entity basic methods +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmethod mem-usage drawable-actor ((obj drawable-actor) (arg0 memory-usage-block) (arg1 int)) + "Update memory use for a drawable-actor" + (set! (-> arg0 length) (max 44 (-> arg0 length))) + (set! (-> arg0 data 43 name) "entity") + (+! (-> arg0 data 43 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 43 used) v1-6) + (+! (-> arg0 data 43 total) (logand -16 (+ v1-6 15))) + ) + + ;; note: does something with flags here. + (mem-usage (-> obj actor) arg0 (logior arg1 64)) + (the-as drawable-actor 0) + ) + +(defmethod mem-usage drawable-inline-array-actor ((obj drawable-inline-array-actor) (arg0 memory-usage-block) (arg1 int)) + "update memory use for a group of drawable actors." + (set! (-> arg0 length) (max 1 (-> arg0 length))) + (set! (-> arg0 data 0 name) (symbol->string 'drawable-group)) + (+! (-> arg0 data 0 count) 1) + (let ((v1-7 32)) + (+! (-> arg0 data 0 used) v1-7) + (+! (-> arg0 data 0 total) (logand -16 (+ v1-7 15))) + ) + (dotimes (s3-0 (-> obj length)) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + (the-as drawable-inline-array-actor 0) + ) + +(defmethod print entity-links ((obj entity-links)) + (format #t "#" (-> obj process) obj) + obj + ) + +(defmethod print entity-perm ((obj entity-perm)) + (format #t "#" + (-> obj aid) + (-> obj task) + (-> obj status) + (-> obj user-uint64) + obj + ) + obj + ) + +(defmethod birth! entity ((obj entity)) + "children of entity should override this." + (format #t "birth ~A~%" obj) + obj + ) + +(defmethod kill! entity ((obj entity)) + "children of entity should override this." + (format #t "kill ~A~%" obj) + obj + ) + +(defmethod print entity ((obj entity)) + "print an entity, with its name from the res." + (format #t "#<~A :name ~S @ #x~X>" + (-> obj type) + (res-lump-struct obj 'name object) + obj + ) + obj + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; entity finding +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmethod get-level entity ((obj entity)) + "Get the level that the entity belongs to." + + ;; loop over levels + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + ;; only if the level is active + (when (= (-> a1-3 status) 'active) + ;; check if we are inside the heap + (if (and (>= (the-as int obj) (the-as int (-> a1-3 heap base))) + (< (the-as int obj) (the-as int (-> a1-3 heap top-base))) + ) + (return a1-3) + ) + ) + ) + ) + (-> *level* level-default) + ) + (defun entity-by-name ((arg0 string)) + "Get an entity with the given name. Will search in + -actors, for each level + -ambients, for each level + -cameras, for each level. + All the searching is in the bsp." (dotimes (s5-0 (-> *level* length)) - (let ((s4-0 (the-as basic (-> *level* level s5-0)))) - (when (= (-> (the-as level s4-0) status) 'active) - (let ((s3-0 (-> (the-as level s4-0) bsp actors))) - (when (nonzero? s3-0) - (dotimes (s2-0 (-> s3-0 length)) - (let ((s1-0 (-> s3-0 data s2-0 actor))) - (if - (name= - (the-as - basic - ((method-of-type res-lump get-property-struct) - (the-as res-lump s1-0) - 'name - 'interp - -1000000000.0 - #f - (the-as (pointer res-tag) #f) - *res-static-buf* + (let ((s4-0 (-> *level* level s5-0))) + (when (= (-> s4-0 status) 'active) + (let ((s3-0 (-> s4-0 bsp actors))) + (when (nonzero? s3-0) + (dotimes (s2-0 (-> s3-0 length)) + (let ((s1-0 (-> s3-0 data s2-0 actor))) + (if (name= (res-lump-struct s1-0 'name basic) arg0) + (return s1-0) + ) + ) + ) + ) + ) + (let ((s3-1 (-> s4-0 bsp ambients))) + (when (nonzero? s3-1) + (dotimes (s2-1 (-> s3-1 length)) + (let ((s1-1 (-> s3-1 data s2-1 ambient))) + (if (name= (res-lump-struct s1-1 'name basic) arg0) + (return s1-1) + ) + ) + ) + ) + ) + (let ((s4-1 (-> s4-0 bsp cameras))) + (when (nonzero? s4-1) + (dotimes (s3-2 (-> s4-1 length)) + (let ((s2-2 (-> s4-1 s3-2))) + (if (name= (res-lump-struct s2-2 'name basic) arg0) + (return s2-2) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity #f) + ) + +(defun entity-by-type ((arg0 type)) + "Get an entity-actor with the _exactly_ the given type. + Searches over all entity-actors in all levels, looking in the bsp" + (dotimes (s5-0 (-> *level* length)) + (let ((v1-3 (-> *level* level s5-0))) + (when (= (-> v1-3 status) 'active) + (let ((s4-0 (-> v1-3 bsp actors))) + (when (nonzero? s4-0) + (dotimes (s3-0 (-> s4-0 length)) + (let ((s2-0 (-> s4-0 data s3-0 actor))) + (if (and (type-type? (-> s2-0 type) entity-actor) + (= (-> s2-0 etype) arg0) + ) + (return s2-0) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity-actor #f) + ) + +(defun entity-by-aid ((arg0 uint)) + "Get an entity by actor-id. This looks through the entity-links-array, so it + will require that the level is somewhat loaded." + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + (when (= (-> a1-3 status) 'active) + (let ((a1-4 (-> a1-3 entity))) + (when (nonzero? a1-4) + (let ((a2-4 0) + (a3-2 (+ (-> a1-4 length) -1)) ) + 0 + (while (>= a3-2 a2-4) + (let* ((t0-3 (+ a2-4 (/ (- a3-2 a2-4) 2))) + (t1-2 (-> a1-4 data t0-3)) + (t2-0 (-> t1-2 perm aid)) + ) + (cond + ((= t2-0 arg0) + (return (-> t1-2 entity)) + ) + ((< (the-as uint t2-0) arg0) + (set! a2-4 (+ t0-3 1)) + ) + (else + (set! a3-2 (+ t0-3 -1)) ) - arg0 ) - (return (the entity s1-0)) ) ) ) ) ) - (let ((s3-1 (-> (the-as level s4-0) bsp ambients))) - (when (nonzero? s3-1) - (dotimes (s2-1 (-> s3-1 length)) - (let ((s1-1 (-> s3-1 data s2-1 ambient))) - (if - (name= - (the-as - basic - ((method-of-type res-lump get-property-struct) - (the-as res-lump s1-1) - 'name - 'interp - -1000000000.0 - #f - (the-as (pointer res-tag) #f) - *res-static-buf* - ) + ) + ) + ) + (the-as entity #f) + ) + +(defun entity-by-meters ((arg0 float) (arg1 float) (arg2 float)) + "Get an entity by position. The coordinate are rounded to the nearest 1/4096th of a meter." + (dotimes (v1-0 (-> *level* length)) + (let ((a3-3 (-> *level* level v1-0))) + (when (= (-> a3-3 status) 'active) + (let ((a3-5 (-> a3-3 bsp actors))) + (when (nonzero? a3-5) + (dotimes (t0-4 (-> a3-5 length)) + (let* ((t1-3 (-> a3-5 data t0-4 actor)) + (t2-1 (-> t1-3 extra trans)) + ) + (if (and (= (the float (the int (-> t2-1 x))) arg0) + (= (the float (the int (-> t2-1 y))) arg1) + (= (the float (the int (-> t2-1 z))) arg2) + ) + (return t1-3) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity-actor #f) + ) + +(defun process-by-ename ((arg0 string)) + "Get the process for the entity with the given name. If there is no entity or process, #f." + (let ((v1-0 (entity-by-name arg0))) + (if v1-0 + (-> v1-0 extra process) + ) + ) + ) + +(defun entity-process-count ((arg0 symbol)) + "Count the number of entities with a process. If arg0 is 'vis, will count visible entities." + (let ((gp-0 0)) + (dotimes (s4-0 (-> *level* length)) + (let ((s3-0 (-> *level* level s4-0))) + (when (= (-> s3-0 status) 'active) + (let ((s2-0 (-> s3-0 bsp level entity))) + (dotimes (s1-0 (-> s2-0 length)) + (let ((v1-9 (-> s2-0 data s1-0 entity))) + (case arg0 + (('vis) + (if (is-object-visible? s3-0 (-> v1-9 extra vis-id)) + (+! gp-0 1) + ) + ) + (else + (if (-> v1-9 extra process) + (+! gp-0 1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + gp-0 + ) + ) + +(defun entity-count () + "Count the number of entities. Uses the entity-links" + (let ((v0-0 0)) + (dotimes (v1-0 (-> *level* length)) + (let ((a0-3 (-> *level* level v1-0))) + (when (= (-> a0-3 status) 'active) + (let ((a0-6 (-> a0-3 bsp level entity))) + (dotimes (a1-3 (-> a0-6 length)) + (-> a0-6 data a1-3 entity) ;; value is unused. + (+! v0-0 1) + ) + ) + ) + ) + ) + v0-0 + ) + ) + +(defun entity-remap-names ((arg0 pair)) + "Rename entities by location. Changes their res." + (let ((s5-0 (car arg0))) + (while (not (null? arg0)) + ;; look up by the given position. + (let ((a0-2 (entity-by-meters + (the float (/ (the-as int (car (cdr s5-0))) 8)) + (the float (/ (the-as int (car (cdr (cdr s5-0)))) 8)) + (the float (/ (the-as int (car (cdr (cdr (cdr s5-0))))) 8)) + ) + ) + ) + (if a0-2 + ;; if we found an entity, modify its res. + (add-data! a0-2 + (new 'static 'res-tag + :name 'name + :key-frame -1000000000.0 + :elt-count #x1 + :elt-type string + ) + (the-as pointer (car s5-0)) + ) + ) + ) + (set! arg0 (cdr arg0)) + (set! s5-0 (car arg0)) + ) + ) + 0 + (none) + ) + +;;;;;;;;;;;;;;;;;;;;;; +;; entity inspection +;;;;;;;;;;;;;;;;;;;;;; + +(defun-debug process-status-bits ((arg0 process) (arg1 symbol)) + "Print to arg1 three characters representing the status of a process + The first is an r, if we should run. + The second is a d, if we draw (only if we are process-drawable) + The third is the LOD of the drawing. (also only for process-drawable)" + (let* ((s5-0 arg0) + (proc-draw (the-as process-drawable + (if (and (nonzero? s5-0) (type-type? (-> s5-0 type) process-drawable)) + s5-0 + ) + ) + ) + ) + (if (and (the-as process proc-draw) (zero? (-> proc-draw draw))) + (set! proc-draw (the-as process-drawable #f)) + ) + + ;; first char is r or ' '. r for run. + ;; second char is d or ' '. I think d is draw. + ;; third char is a number 0-4 or a ' '. This is the lod. + (format arg1 "~C~C~C" + (if (and arg0 (zero? (logand (-> *kernel-context* prevent-from-run) (-> arg0 mask))) + (run-logic? arg0) + ) + #\r + #\\s ;; space + ) + (if (and proc-draw (logtest? (-> proc-draw draw status) 8)) + #\d + #\\s + ) + (cond + ((and proc-draw (logtest? (-> proc-draw draw status) 8)) + (case (-> proc-draw draw cur-lod) + ((0) #\0) + ((1) #\1) + ((2) #\2) + ((3) #\3) + ((4) #\4) + ) + ) + (else + #\\s + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod print process ((obj process)) + "Fancier print for process that can also print status of process drawables." + (format #t "#<~A ~S ~A :state ~S :flags " + (-> obj type) + (-> obj name) + (-> obj status) + (if (-> obj state) + (-> obj state name) + ) + ) + (process-status-bits obj #t) + (format #t " :stack ~D/~D :heap ~D/~D @ #x~X>" + (&- (-> obj top-thread stack-top) (the-as uint (-> obj top-thread sp))) + (-> obj main-thread stack-size) + (- + (-> obj allocated-length) + (&- (-> obj heap-top) (the-as uint (-> obj heap-cur))) ) - arg0 + (-> obj allocated-length) + obj + ) + obj + ) + +(defmethod inspect entity ((obj entity)) + ((the-as (function entity entity) (find-parent-method entity 3)) obj) + (format #t "~Ttrans: ~`vector`P~%" (-> obj trans)) + (format #t "~Taid: ~A~%" (-> obj aid)) ;; probably a bad idea to print this with ~A... + obj + ) + +(defmethod inspect entity-actor ((obj entity-actor)) + ((the-as (function entity-actor entity-actor) (find-parent-method entity-actor 3)) obj) + (format #t "~Tnav-mesh: ~A~%" (-> obj nav-mesh)) + (format #t "~Tetype: ~A~%" (-> obj etype)) + (format #t "~Ttask: ~d~%" (-> obj task)) + (format #t "~Tvis-id: ~d~%" (-> obj vis-id-signed)) + (format #t "~Tquat: ~`vector`P~%" (-> obj quat)) + obj + ) + +(defmethod debug-print entity-actor ((obj entity-actor) (mode symbol) (expected-type type)) + "Debug print info about an entity-actor. This is designed to generate rows for the table + printed by method debug-print-entities of level-group." + (let ((s4-0 (-> obj etype))) + (when (or (not expected-type) + (and s4-0 (valid? s4-0 type #f #f 0) (type-type? s4-0 expected-type)) + ) + + ;; print vis id, addr, name. + (format #t "~5D #x~8X ~-21S" + (-> obj extra vis-id) + obj + (res-lump-struct obj 'name object) + ) + + ;; I have no idea what could have generated this. + (let ((t9-4 format) + (a0-5 #t) + (a1-5 "~8D ~3D ~-4S #x~4X") + (a2-4 (-> obj extra perm aid)) + (a3-3 (-> obj extra perm task)) + (t0-3 (-> obj extra level nickname)) + ) + (set! t0-3 (cond + (t0-3 + t0-3 + ) + (else + (-> obj extra level name) + ) + ) + ) + (format a0-5 a1-5 a2-4 a3-3 t0-3 (-> obj extra perm status)) + ) + + ;; location + (if (= mode 'entity-meters) + (format #t " :trans ~14m ~14m ~14m " + (-> obj extra trans x) + (-> obj extra trans y) + (-> obj extra trans z) + ) + (format #t " :trans ~14f ~14f ~14f " + (-> obj extra trans x) + (-> obj extra trans y) + (-> obj extra trans z) + ) + ) + + ;; if we have an associated process, print info. + (let* ((s3-2 (-> obj extra process)) + (s4-2 (if (and (nonzero? s3-2) (type-type? (-> s3-2 type) process-drawable)) + s3-2 + ) + ) + ) + (format #t ":pr #x~8X ~-12S ~-21S ~-5S/~-5S " (if (-> obj extra process) + (-> obj extra process) + 0 + ) + (if (-> obj extra process) + (-> obj extra process name) + "" + ) + (if (and (-> obj extra process) (-> obj extra process state)) + (-> obj extra process state name) + "" + ) + (if (-> obj extra process) + (* (- (-> obj extra process allocated-length) + (&- (-> obj extra process heap-top) + (the-as uint (-> obj extra process heap-cur)) + ) + ) + 8 + ) + "" + ) + (if (-> obj extra process) + (* (-> obj extra process allocated-length) 8) + "" + ) + ) + (process-status-bits s4-2 #t) + ) + (format #t "~%") + (if (= mode 'entity-perm) + (format #t " ~`entity-perm`P~%" (-> obj extra perm)) + ) + ) + ) + (none) + ) + +(defmethod debug-print-entities level-group ((obj level-group) (mode symbol) (expected-type type)) + "Print a table of entities. If expected-type is #f, print all. Otherwise, print only entities of the given type. + Modes: + 'art-group: print art groups instead. + 'entity-meters: print entity location in meters. + 'entity-perm: also print entity-perm values." + + ;; no way this fit on their screen back in ~2000. + (format #t " id address name aid tsk lev status x y z address name state heap flags~%") + (dotimes (s3-0 (-> obj length)) + (let ((s2-0 (-> obj level s3-0))) + (when (= (-> s2-0 status) 'active) + (case mode + (('art-group) + (format #t "level ~A~%" (-> s2-0 name)) + (dotimes (s1-0 (-> s2-0 art-group art-group-array length)) + (format #t "~T~2D ~S~%"s1-0 (-> s2-0 art-group art-group-array s1-0 name)) + ) + ) + (else + (let ((s2-1 (-> s2-0 bsp level entity))) + (dotimes (s1-1 (-> s2-1 length)) + (debug-print (the-as entity-actor (-> s2-1 data s1-1 entity)) mode expected-type) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + + + +;;;;;;;;;;;;;;;;;; +;; entity setup +;;;;;;;;;;;;;;;;;; + +(defmethod add-to-level! entity ((obj entity) (lev-group level-group) (lev level) (aid actor-id)) + "Add us to a level." + + ;; grab the first free link + (let ((level-link (-> lev entity data (-> lev entity length)))) + (+! (-> lev entity length) 1) + + ;; attach the entity to the link + (set! (-> level-link process) #f) + (set! (-> level-link entity) obj) + (set! (-> obj extra) level-link) + (cond + ((-> lev-group entity-link) + ;; add to linked list of existing + (let* ((other-prev (-> lev-group entity-link)) + (other-front (-> other-prev next-link)) + ) + (set! (-> other-prev next-link) level-link) + (set! (-> level-link prev-link) other-prev) + (set! (-> level-link next-link) other-front) + (set! (-> other-front prev-link) level-link) + ) + ) + (else + ;; we're the first in the level. + (set! (-> level-link prev-link) level-link) + (set! (-> level-link next-link) level-link) + ) + ) + + ;; remember the start of the list + (set! (-> lev-group entity-link) level-link) + ;; update the trans. + (set! (-> level-link trans quad) (-> obj trans quad)) + ) + + ;; set us up + (set! (-> obj extra perm aid) aid) + (set! (-> obj extra level) lev) + (cond + ((= (-> obj type) entity-actor) + (set! (-> (the-as entity-actor obj) extra perm task) + (the-as game-task (-> (the-as entity-actor obj) task)) + ) + (set! (-> (the-as entity-actor obj) extra vis-id) + (-> (the-as entity-actor obj) vis-id-signed) ) - (return (the entity s1-1)) + ) + (else + (set! (-> obj extra perm task) (game-task none)) + (set! (-> obj extra vis-id) 0) + 0 + ) + ) + (none) + ) + +(defmethod remove-from-level! entity ((obj entity) (arg0 level-group)) + "Remove us from the level." + (let ((v1-0 (-> obj extra))) + (cond + ((= (-> v1-0 next-link) v1-0) + (set! (-> arg0 entity-link) #f) + ) + (else + (set! (-> v1-0 next-link prev-link) (-> v1-0 prev-link)) + (set! (-> v1-0 prev-link next-link) (-> v1-0 next-link)) + (if (= (-> arg0 entity-link) v1-0) + (set! (-> arg0 entity-link) (-> v1-0 prev-link)) + ) + ) + ) + ) + obj + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;; +;; visibility update +;;;;;;;;;;;;;;;;;;;;;;;;; + +;; the visibility system is pretty simple and there is a single axis-aligned bounding box. +;; these methods are debug tools for updating these. + +(defun update-actor-vis-box ((proc process-drawable) (min-pt vector) (max-pt vector)) + "Update the min-pt and max-pt vector so that the box encloses the bounding box around the bounds sphere + in the process-drawable." + (when (and proc (nonzero? (-> proc draw))) + ;; add the draw origin offset. + (let ((world-bounds-origin (vector+! (new 'stack-no-clear 'vector) (-> proc draw origin) (-> proc draw bounds))) + (radius (-> proc draw bounds w)) + ) + (set! (-> min-pt x) (fmin (-> min-pt x) (- (-> world-bounds-origin x) radius))) + (set! (-> min-pt y) (fmin (-> min-pt y) (- (-> world-bounds-origin y) radius))) + (set! (-> min-pt z) (fmin (-> min-pt z) (- (-> world-bounds-origin z) radius))) + (set! (-> max-pt x) (fmax (-> max-pt x) (+ (-> world-bounds-origin x) radius))) + (set! (-> max-pt y) (fmax (-> max-pt y) (+ (-> world-bounds-origin y) radius))) + (set! (-> max-pt z) (fmax (-> max-pt z) (+ (-> world-bounds-origin z) radius))) + ) + ) + 0 + (none) + ) + +(defmethod update-vis-volumes level-group ((obj level-group)) + (local-vars + (v1-10 symbol) + (sv-16 process) + (sv-32 (function process-drawable vector vector none)) + (sv-48 process-tree) + ) + + (format 0 "call to update-vis-volumes, which may have a compiler bug.~%") + (dotimes (s5-0 (-> obj length)) + (let ((v1-3 (-> obj level s5-0))) + (when (= (-> v1-3 status) 'active) + (let ((s4-0 (-> v1-3 bsp level entity))) + (dotimes (s3-0 (-> s4-0 length)) + (let* ((s0-0 (-> s4-0 data s3-0 entity)) + (v0-0 (the-as (inline-array vector) + ((method-of-type res-lump get-property-data) + s0-0 + 'visvol + 'interp + -1000000000.0 + (the-as pointer #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (s2-0 (-> v0-0 0)) + (s1-0 (-> v0-0 1)) + ) + (let ((s0-1 (-> s0-0 extra process))) + ;; I am pretty sure there is a GOAL compiler bug here. + ;; the output makes zero sense, but I don't think it matters: + ;; this function doesn't seem like it should ever be run outside of development + ;; and the compiler bug has no effect? + (set! + v1-10 + (when (and (nonzero? s0-1) (type-type? (-> s0-1 type) process-drawable)) + ;; i think it spills the wrong variable here + (set! sv-16 (the-as process v1-10)) + ;; then immediate spills the right one. + (set! sv-16 s0-1) + v1-10 + ) + ) + ) + (when sv-16 + (update-actor-vis-box (the-as process-drawable sv-16) s2-0 s1-0) + (let ((s0-2 (-> sv-16 child))) + (while s0-2 + (set! sv-32 update-actor-vis-box) + (set! sv-48 (-> s0-2 0)) + (let ((a0-7 (if (and (nonzero? sv-48) (type-type? (-> sv-48 type) process-drawable)) + sv-48 + ) + ) + (a1-5 s2-0) + (a2-2 s1-0) + ) + (sv-32 (the-as process-drawable a0-7) a1-5 a2-2) + ) + (set! s0-2 (-> s0-2 0 brother)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod update-vis-volumes-from-nav-mesh level-group ((obj level-group)) + "Update the visvol to fit the entire nav-mesh. Does this for all actors in bsps. + Probably only used for debugging." + (local-vars (sv-16 entity) (sv-32 entity)) + ;; loop over levels + (dotimes (s5-0 (-> obj length)) + (let ((v1-3 (-> obj level s5-0))) + (when (= (-> v1-3 status) 'active) ;; only active levels + ;; loop over entities + (let ((s4-0 (-> v1-3 bsp level entity))) + (dotimes (s3-0 (-> s4-0 length)) + (set! sv-32 (-> s4-0 data s3-0 entity)) + ;; look up the bounding box. + (let* ((v0-0 (res-lump-data sv-32 'visvol (inline-array vector))) + (s1-0 (-> v0-0 0)) + (s2-0 (-> v0-0 1)) + ) + ;; + (let ((s0-0 (-> sv-32 extra trans))) + + ;; sometimes the nav-mesh may be in a different actor, I guess. + ;; so try to look that up. + (set! sv-16 sv-32) + (let* ((v0-1 (entity-actor-lookup sv-32 'nav-mesh-actor 0))) + (when v0-1 + (set! sv-16 v0-1) + ) + ) + + (cond + ((and (type-type? (-> sv-16 type) entity-actor) + (nonzero? (-> (the-as entity-actor sv-16) nav-mesh)) + ) + ;; we got a nav-mesh! compute the bounding box + (compute-bounding-box + (-> (the-as entity-actor sv-16) nav-mesh) + s1-0 + s2-0 + ) + ) + (else + ;; no nav-mesh found, just use the default position + (set! (-> s1-0 quad) (-> s0-0 quad)) + (set! (-> s2-0 quad) (-> s0-0 quad)) + ) + ) + ) + + ;; add some padding to make a 6x6 meter box. + (let ((f1-0 -12288.0) + (f0-0 12288.0) + ) + (+! (-> s1-0 x) f1-0) + (+! (-> s1-0 y) f1-0) + (+! (-> s1-0 z) f1-0) + (+! (-> s2-0 x) f0-0) + (+! (-> s2-0 y) f0-0) + (+! (-> s2-0 z) f0-0) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(declare-type money basic) +(declare-type crate basic) +(declare-type springbox basic) +(declare-type fuel-cell basic) + + + +(defmethod print-volume-sizes level-group ((obj level-group)) + "Loop through all entities and print their visibility. + Excludes crate, fuel-cell and springbox." + (local-vars + (sv-16 type) + (sv-32 (function _varargs_ object)) + (sv-48 symbol) + (sv-64 string) + (sv-80 entity) + ) + (dotimes (s5-0 (-> obj length)) + (let ((v1-3 (-> obj level s5-0))) + (when (= (-> v1-3 status) 'active) + (let ((s4-0 (-> v1-3 bsp level entity))) + (dotimes (s3-0 (-> s4-0 length)) + (set! sv-80 (-> s4-0 data s3-0 entity)) + ;; lookup volume and dist. + (let ((s1-0 (res-lump-data sv-80 'visvol (inline-array vector))) + (f30-0 (res-lump-float sv-80 'vis-dist :default 409600.0)) + (s2-0 (-> sv-80 extra trans)) + ) + (if (type-type? (-> sv-80 type) entity-actor) + (set! sv-16 (-> (the-as entity-actor sv-80) etype)) + (set! sv-16 (the-as type #f)) + ) + (let ((s0-0 (-> s1-0 0)) + (s1-1 (-> s1-0 1)) + ) + + ;; This technically will work on type objects because it just checks for value equality. + ;; the code here is super weird. I have no idea what was going on, or why there are two or's. + (when (not (or (name= sv-16 money) + (or (name= sv-16 crate) (name= sv-16 fuel-cell) (name= sv-16 springbox)) + ) + ) + (format #t "actor-vis ~S ~6,,1M " (res-lump-struct sv-80 'name basic) f30-0) + (format #t "~6,,1M ~6,,1M ~6,,1M ~6,,1M ~6,,1M ~6,,1M~%" + (- (-> s0-0 x) (-> s2-0 x)) + (- (-> s0-0 y) (-> s2-0 y)) + (- (-> s0-0 z) (-> s2-0 z)) + (- (-> s1-1 x) (-> s2-0 x)) + (- (-> s1-1 y) (-> s2-0 y)) + (- (-> s1-1 z) (-> s2-0 z)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun expand-vis-box-with-point ((arg0 entity) (arg1 vector)) + "Expand the visibility box of the given entity to include the given point." + (let ((v1-1 (res-lump-data arg0 'visvol (inline-array vector)))) + (when v1-1 + (let ((a0-2 (-> v1-1 0)) + (v1-2 (-> v1-1 1)) + ) + (set! (-> a0-2 x) (fmin (-> a0-2 x) (-> arg1 x))) + (set! (-> a0-2 y) (fmin (-> a0-2 y) (-> arg1 y))) + (set! (-> a0-2 z) (fmin (-> a0-2 z) (-> arg1 z))) + (set! (-> v1-2 x) (fmax (-> v1-2 x) (-> arg1 x))) + (set! (-> v1-2 y) (fmax (-> v1-2 y) (-> arg1 y))) + (set! (-> v1-2 z) (fmax (-> v1-2 z) (-> arg1 z))) + ) + ) + ) + 0 + (none) + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;; +;; The Debug Draw Method +;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; TODO + +;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Camera Birthing +;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmethod birth! entity-camera ((obj entity-camera)) + (add-connection + *camera-engine* + *camera* + (the-as (function object object object object object) nothing) + obj + #f + #f + ) + obj + ) + +;; definition for method 23 of type entity-camera +(defmethod kill! entity-camera ((obj entity-camera)) + (remove-by-param1 *camera-engine* obj) + obj + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Actor Birthing +;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defmacro birth-log (str &rest args) + "Debug print to stdout of runtime for debugging actor inits." + `(format 0 ,(string-append "[BIRTH] " str) ,@args) + ) + +(defun init-entity ((proc process) (ent entity)) + "This function starts up an entity! + The process should not be activated yet." + + (birth-log "(init-entity ~A ~A)~%" proc ent) + + ;; activate the process. It goes in the entity-pool, which is a child of the main active-pool. + (activate proc *entity-pool* (res-lump-struct ent 'name basic) (the-as pointer #x70004000)) + + ;; link the entity and the process + (set! (-> proc entity) ent) + (set! (-> ent extra process) proc) + + (birth-log "activated: ~A ~A, now doing init ~A~%" proc ent (method-of-object proc copy-defaults!)) + + ;; run the initializer + (run-now-in-process proc (method-of-object proc copy-defaults!) proc ent) + + (none) + ) + + +;; TODO +(define-extern birth-viewer (function process entity object)) + +(defmethod birth! entity-actor ((obj entity-actor)) + "Create a process for this entity and start it." + (birth-log "call to birth! on ~A~%" obj) + (let* ((entity-type (-> obj etype)) + (info (entity-info-lookup entity-type)) + (entity-process (get-process *default-dead-pool* entity-type + (if info + (-> + info + heap-size + ) + #x4000 + ) + ) + ) + ) + (cond + ((not entity-process) + (birth-log "could not birth because there is no process.~%") + ) + ((begin + (set! (-> entity-process type) entity-type) + (and entity-type + (valid? entity-type type #f #f 0) + (valid? (method-of-object entity-process copy-defaults!) function #f #f 0) + ) + ) + (init-entity entity-process obj) + ) + (else + (birth-log "could not birth because there was an issue.~%") + (when (not (birth-viewer entity-process obj)) + (format + 0 + "ERROR: no proper process type named ~A exists in the code, could not start ~A~%" + entity-type + obj + ) + (logior! (-> obj extra perm status) (entity-perm-status bit-0)) + ) + ) + ) + ) + obj + ) + +(defun entity-deactivate-handler ((arg0 process) (arg1 entity)) + "Handle a deactivation in the entity. + The entity directly stores a process so should remove that after deactivating." + (when (= arg0 (-> arg1 extra process)) + (logclear! (-> arg1 extra perm status) (entity-perm-status bit-1 bit-3)) + (set! (-> arg1 extra process) #f) + ) + (none) + ) + +(defmethod kill! entity-actor ((obj entity-actor)) + "Kill an actor." + (let ((a0-1 (-> obj extra process))) + (if a0-1 + (deactivate a0-1) + (entity-deactivate-handler a0-1 obj) + ) + ) + obj + ) + +(defmethod birth bsp-header ((obj bsp-header)) + "Birth everything in the level." + ;; (local-vars (v1-71 int) (s5-0 int)) + ;; (.mfc0 s5-0 Count) + + ;; how many actors do we need? + (let ((actor-count (if (nonzero? (-> obj actors)) + (-> obj actors length) + 0 + ) ) + ) + (cond + ((not (-> obj level entity)) + ;; we don't have an array of entity-links. allocate one. + (set! (-> obj level entity) (new 'loading-level 'entity-links-array actor-count)) + ) + ((< (-> obj level entity allocated-length) actor-count) + ;; we do, but it's not big enough. Complain. + (format 0 "ERROR: Attempting to rebirth level ~A with incorrect entity table size ~D/~D~%" + (-> obj level) + actor-count + (-> obj level entity allocated-length) ) + ) + ) + ) + + ;; reset our entity links array to 0. + (set! (-> obj level entity length) 0) + + ;; NOTE: we don't actually birth the actors. It is too slow. + ;; so it gets spread over multiple frames later. + (when (nonzero? (-> obj actors)) + (birth-log "add-to-level! for ~D actors for ~A~%" (-> obj actors length) obj) + (dotimes (birth-idx (-> obj actors length)) + (let* ((idx-to-birth (-> obj actor-birth-order birth-idx)) + (actor-to-birth (-> obj actors data (logand idx-to-birth #xffff) actor)) + ) + (birth-log "now adding to level: ~D ~D ~A~%" birth-idx idx-to-birth actor-to-birth) + (add-to-level! actor-to-birth *level* (-> obj level) (the-as actor-id (-> actor-to-birth aid))) + ) + ) + ) + + (let ((existing-amb-count (if (nonzero? (-> obj ambients)) + (-> obj ambients length) + 0 + ) + ) ) + (cond + ((not (-> obj level ambient)) + (set! + (-> obj level ambient) + (new 'loading-level 'entity-ambient-data-array existing-amb-count) + ) + ) + ((< (-> obj level ambient allocated-length) existing-amb-count) + (format + 0 + "ERROR: Attempting to rebirth level ~A with incorrect ambient table size ~D/~D~%" + (-> obj level) + existing-amb-count + (-> obj level ambient allocated-length) + ) ) ) - (set! s4-0 (-> (the-as level s4-0) bsp cameras)) - (when (nonzero? (the-as (array entity-camera) s4-0)) - (dotimes (s3-2 (-> (the-as (array entity-camera) s4-0) length)) - (let ((s2-2 (-> (the-as (array entity-camera) s4-0) s3-2))) - (if - (name= - (the-as - basic - ((method-of-type res-lump get-property-struct) - s2-2 - 'name - 'interp - -1000000000.0 - #f - (the-as (pointer res-tag) #f) - *res-static-buf* + ) + + (set! (-> obj level ambient length) 0) + 0 + (let ((amb-array (-> obj level ambient)) + (bsp-ambs (-> obj ambients)) + ) + (when (nonzero? bsp-ambs) + (dotimes (s2-0 (-> bsp-ambs length)) + (let ((amb-to-birth (-> bsp-ambs data s2-0 ambient))) + (set! + (-> amb-to-birth extra) + (the-as entity-links (-> amb-array data (-> amb-array length))) + ) + (birth-ambient! amb-to-birth) + ) + (+! (-> amb-array length) 1) + ) + ) + ) + (let ((cams (-> obj cameras))) + (when (nonzero? cams) + (dotimes (s3-1 (-> cams length)) + (birth-log "birth cam: ~A~%" (-> cams s3-1)) + (birth! (-> cams s3-1)) + ) + ) + ) + + ; (.mfc0 v1-71 Count) + ; (let ((a3-3 (- v1-71 s5-0))) + ; (format 0 "Done ~S in ~D~%" "birth" a3-3) + ; ) + (none) + ) + + +(defmethod debug-draw-actors level-group ((obj level-group) (arg0 symbol)) + ;; TODO lots more here. + (local-vars + (sv-48 (function symbol bucket-id string vector font-color vector2h symbol)) + (sv-64 symbol) + (sv-80 int) + (sv-96 (function symbol bucket-id string vector font-color vector2h symbol)) + (sv-112 symbol) + (sv-128 int) + (sv-144 (function _varargs_ object)) + (sv-160 string) + (sv-176 string) + (sv-192 (function symbol bucket-id string vector font-color vector2h symbol)) + (sv-208 symbol) + (sv-224 int) + (sv-240 (function symbol bucket-id vector vector rgba symbol)) + (sv-256 symbol) + (sv-272 int) + (sv-288 pointer) + (sv-304 pointer) + ) + (when + (and arg0 (not (or (= *master-mode* 'menu) (= *master-mode* 'progress)))) + (dotimes (s4-0 (-> obj length)) + (let ((v1-8 (-> obj level s4-0))) + (when (= (-> v1-8 status) 'active) + (let ((s3-0 (-> v1-8 bsp level entity))) + (dotimes (s2-0 (-> s3-0 length)) + (let* ((s0-0 (-> s3-0 data s2-0 entity)) + (s1-0 (-> s0-0 extra trans)) + ) + (cond + ((or (= arg0 'full) (-> s0-0 extra process)) + (add-debug-x + #t + (bucket-id debug-draw1) + s1-0 + (the-as rgba (if (-> s0-0 extra process) + (the-as uint #x8080ff80) + (the-as uint #x800000ff) + ) + ) + ) + (set! sv-192 add-debug-text-3d) + (set! sv-208 #t) + (set! sv-224 68) + (let + ((a2-13 + ((method-of-type res-lump get-property-struct) + s0-0 + 'name + 'interp + -1000000000.0 + #f + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (t0-8 + (if + (logtest? + (-> s0-0 extra perm status) + (entity-perm-status bit-0 bit-1) + ) + 1 + 5 + ) + ) + (t1-8 + (new 'static 'vector + :x + 0.000000000000000000000000000000000000000734684 + ) + ) + ) + (sv-192 + sv-208 + (the-as bucket-id sv-224) + (the-as string a2-13) + s1-0 + (the-as font-color t0-8) + (the-as vector2h t1-8) + ) ) ) - arg0 ) - (return (the entity s2-2)) ) ) ) @@ -90,23 +1232,84 @@ ) ) ) - (the-as entity #f) - ) - -(defun entity-by-type ((arg0 type)) - (dotimes (s5-0 (-> *level* length)) - (let ((v1-3 (-> *level* level s5-0))) - (when (= (-> v1-3 status) 'active) - (let ((s4-0 (-> v1-3 bsp actors))) - (when (nonzero? s4-0) - (dotimes (s3-0 (-> s4-0 length)) - (let ((s2-0 (-> s4-0 data s3-0 actor))) - (if - (and - (type-type? (-> s2-0 type) entity-actor) - (= (-> s2-0 etype) arg0) + + (when + (and + *display-actor-vis* + (not (or *display-actor-anim* *display-process-anim*)) + ) + (let ((s5-1 *display-actor-vis*)) + (dotimes (s4-1 (-> obj length)) + (let ((s3-1 (-> obj level s4-1))) + (when (= (-> s3-1 status) 'active) + (let ((s2-1 (-> s3-1 bsp level entity))) + (dotimes (s1-2 (-> s2-1 length)) + (let ((s0-2 (-> s2-1 data s1-2 entity))) + (let + ((v0-15 + ((method-of-type res-lump get-property-data) + s0-2 + 'visvol + 'interp + -1000000000.0 + (the-as pointer #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (a1-16 (-> s0-2 extra vis-id)) + ) + (when (and v0-15 (or (= s5-1 #t) (= s5-1 'box))) + (set! sv-240 add-debug-box) + (set! sv-256 #t) + (set! sv-272 68) + (set! sv-288 (&+ v0-15 0)) + (set! sv-304 (&+ v0-15 16)) + (let ((t0-10 (if (is-object-visible? s3-1 a1-16) + (the-as uint #x80808000) + (the-as uint #x80800080) + ) + ) + ) + (sv-240 + sv-256 + (the-as bucket-id sv-272) + (the-as vector sv-288) + (the-as vector sv-304) + (the-as rgba t0-10) + ) + ) + ) + ) + (when (or (= s5-1 #t) (= s5-1 'sphere)) + (let ((s0-3 (-> s0-2 extra process))) + (when s0-3 + (when + (and + (type-type? (-> s0-3 type) process-drawable) + (nonzero? (-> (the-as process-drawable s0-3) draw)) + ) + (add-debug-x + #t + (bucket-id debug-draw1) + (-> (the-as process-drawable s0-3) root trans) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + (add-debug-sphere + #t + (bucket-id debug-draw0) + (vector+! + (new 'stack-no-clear 'vector) + (-> (the-as process-drawable s0-3) draw origin) + (-> (the-as process-drawable s0-3) draw bounds) + ) + (-> (the-as process-drawable s0-3) draw bounds w) + (new 'static 'rgba :r #x80 :a #x80) + ) + ) + ) + ) ) - (return s2-0) ) ) ) @@ -115,12 +1318,7 @@ ) ) ) - (the-as entity-actor #f) - ) - -;; TODO - for misty-teetertotter | rigid-body -(define-extern process-drawable-from-entity! (function process-drawable object none)) -;; TODO - for misty-warehouse -(define-extern process-entity-status! (function process entity-perm-status symbol int)) -;; TODO - for warrior -(define-extern entity-birth-no-kill (function entity none)) + (none)) + +(define-extern process-drawable-from-entity! (function process-drawable res-lump none)) +(define-extern entity-birth-no-kill (function entity none)) \ No newline at end of file diff --git a/goal_src/engine/game/generic-obs-h.gc b/goal_src/engine/game/generic-obs-h.gc index 573e08384e..5b0370b33b 100644 --- a/goal_src/engine/game/generic-obs-h.gc +++ b/goal_src/engine/game/generic-obs-h.gc @@ -47,19 +47,19 @@ ) (deftype part-tracker (process) - ((root basic :offset-assert 112) - (part basic :offset-assert 116) - (target uint64 :offset-assert 120) - (callback basic :offset-assert 128) - (linger-callback basic :offset-assert 132) - (duration uint64 :offset-assert 136) - (linger-duration uint64 :offset-assert 144) - (start-time uint64 :offset-assert 152) - (offset vector :inline :offset-assert 160) - (userdata uint64 :offset-assert 176) - (user-time uint64 2 :offset-assert 184) - (user-vector vector 2 :inline :offset-assert 208) - (user-handle uint32 2 :offset-assert 240) + ((root trsqv :offset-assert 112) + (part sparticle-launch-control :offset-assert 116) + (target uint64 :offset-assert 120) + (callback basic :offset-assert 128) + (linger-callback basic :offset-assert 132) + (duration uint64 :offset-assert 136) + (linger-duration uint64 :offset-assert 144) + (start-time uint64 :offset-assert 152) + (offset vector :inline :offset-assert 160) + (userdata uint64 :offset-assert 176) + (user-time uint64 2 :offset-assert 184) + (user-vector vector 2 :inline :offset-assert 208) + (user-handle uint32 2 :offset-assert 240) ) :heap-base #x90 :method-count-assert 14 diff --git a/goal_src/engine/game/main.gc b/goal_src/engine/game/main.gc index 472ed7b581..eb6415f2b1 100644 --- a/goal_src/engine/game/main.gc +++ b/goal_src/engine/game/main.gc @@ -973,6 +973,8 @@ ;; main cheats ;; update-camera ;; draw hook + (*draw-hook*) + (add-ee-profile-frame 'draw :g #x80) ;; menu hook (*menu-hook*) (add-ee-profile-frame 'draw :g #x40) diff --git a/goal_src/engine/gfx/vis/bsp-h.gc b/goal_src/engine/gfx/vis/bsp-h.gc index d94acc32a9..3714f0cf30 100644 --- a/goal_src/engine/gfx/vis/bsp-h.gc +++ b/goal_src/engine/gfx/vis/bsp-h.gc @@ -61,7 +61,7 @@ (unk-data-4 float :offset-assert 160) (unk-data-5 float :offset-assert 164) (adgifs adgif-shader-array :offset-assert 168) - (unk-data-6 pointer :offset-assert 172) + (actor-birth-order (pointer uint32) :offset-assert 172) (unk-data-7 pointer :offset-assert 176) (unk-data-8 uint32 55 :offset-assert 180) ) @@ -70,7 +70,7 @@ :flag-assert #x1400000190 (:methods (relocate (_type_ kheap (pointer uint8)) none :replace 7) - (dummy-18 (_type_) none 18) + (birth (_type_) none 18) (dummy-19 (_type_) none 19) ) ) diff --git a/goal_src/engine/gfx/vis/bsp.gc b/goal_src/engine/gfx/vis/bsp.gc index f08792a5df..e6a0ad812c 100644 --- a/goal_src/engine/gfx/vis/bsp.gc +++ b/goal_src/engine/gfx/vis/bsp.gc @@ -141,8 +141,8 @@ ) ) - ;; add unk-data-6 - (when (nonzero? (-> obj unk-data-6)) + ;; add actor-birth-order + (when (nonzero? (-> obj actor-birth-order)) (set! (-> mem-use length) (max 58 (-> mem-use length))) (set! (-> mem-use data 57 name) "bsp-misc") (+! (-> mem-use data 57 count) 1) diff --git a/goal_src/engine/level/level-h.gc b/goal_src/engine/level/level-h.gc index 352ebc334b..483b43d657 100644 --- a/goal_src/engine/level/level-h.gc +++ b/goal_src/engine/level/level-h.gc @@ -152,7 +152,7 @@ :flag-assert #x1d00000a30 (:methods (deactivate (_type_) _type_ 9) - (dummy-10 (_type_ int) symbol 10) + (is-object-visible? (_type_ int) symbol 10) (add-irq-to-tex-buckets! (_type_) none 11) (unload! (_type_) _type_ 12) (bsp-name (_type_) symbol 13) @@ -211,18 +211,18 @@ (level-get-with-status (_type_ symbol) level 10) (level-get-for-use (_type_ symbol symbol) level 11) (activate-levels! (_type_) int 12) - (dummy-13 () none 13) - (dummy-14 (_type_ object) none 14) - (dummy-15 () none 15) + (debug-print-entities (_type_ symbol type) none 13) + (debug-draw-actors (_type_ symbol) none 14) + (dummy-15 (_type_) object 15) (dummy-16 (_type_) int 16) (level-get-target-inside (_type_) level 17) (alloc-levels! (_type_ symbol) int 18) (load-commands-set! (_type_ pair) pair 19) (art-group-get-by-name (_type_ string) art-group 20) (load-command-get-index (_type_ symbol int) pair 21) - (dummy-22 () none 22) - (dummy-23 () none 23) - (dummy-24 () none 24) + (update-vis-volumes (_type_) none 22) + (update-vis-volumes-from-nav-mesh (_type_) none 23) + (print-volume-sizes (_type_) none 24) (level-status (_type_ symbol) symbol 25) (level-get-most-disposable (_type_) level 26) ) diff --git a/goal_src/engine/level/level.gc b/goal_src/engine/level/level.gc index a51603071f..c56cb86df6 100644 --- a/goal_src/engine/level/level.gc +++ b/goal_src/engine/level/level.gc @@ -722,7 +722,7 @@ (set! loading-level (-> obj heap)) (set! (-> *level* log-in-level-bsp) (-> obj bsp)) (set! (-> *level* loading-level) obj) - ;; (dummy-18 (-> obj bsp)) TODO + (birth (-> obj bsp)) (set! (-> obj status) 'alive) ;; (dummy-15 *game-info*) TODO ;; (send-event *camera* 'level-activate (-> obj name)) @@ -859,6 +859,9 @@ ) ;; method 10 level +(defmethod is-object-visible? level ((obj level) (arg0 int)) + ;; hack! TODO + #t) ;; method 15 level ;; method 27 level diff --git a/goal_src/engine/nav/navigate-h.gc b/goal_src/engine/nav/navigate-h.gc index fd7885bf75..2734caff11 100644 --- a/goal_src/engine/nav/navigate-h.gc +++ b/goal_src/engine/nav/navigate-h.gc @@ -148,7 +148,7 @@ (node-count int32 :offset-assert 176) (nodes uint32 :offset-assert 180) (vertex-count int32 :offset-assert 184) - (vertex uint32 :offset-assert 188) + (vertex (inline-array vector) :offset-assert 188) (poly-count int32 :offset-assert 192) (poly uint32 :offset-assert 196) (route uint32 :offset-assert 200) @@ -167,7 +167,7 @@ (dummy-16 () none 16) (dummy-17 (_type_) none 17) (dummy-18 () none 18) - (dummy-19 () none 19) + (compute-bounding-box (_type_ vector vector) none 19) (dummy-20 () none 20) (dummy-21 () none 21) (dummy-22 () none 22) diff --git a/goal_src/examples/debug-draw-example.gc b/goal_src/examples/debug-draw-example.gc index a5a50b08ac..ccf0bd61b5 100644 --- a/goal_src/examples/debug-draw-example.gc +++ b/goal_src/examples/debug-draw-example.gc @@ -11,6 +11,12 @@ (lg) ;; have the runtime load the game engine (test-play) ;; start the game loop (ml "goal_src/examples/debug-draw-example.gc") ;; build and load this file. + +;; to get control of camera from keyboard +(kill-test-procs) +(launch-wasd-process) + +;; you can turn on actor marks (full) or visibilty boxes in the debug menu. |# (defun hack-update-camera ((location vector) (inv-rot matrix)) @@ -104,6 +110,94 @@ ) +(define *wasd-camera-transform* (new 'global 'transform)) + + +(defun wasd-camera-update () + (let ((local-trans (new-stack-vector0)) + (trans *wasd-camera-transform*) + (pad-idx 0)) + ;; circle/square move camera relative x (left and right) + (set! (-> local-trans x) + (cond + ((logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons circle)) + -80.0 + ) + ((logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons square)) + 80.0 + ) + (else + 0.0 + ) + ) + ) + + ;; no way to move camera relative y (up/down) + (set! (-> local-trans y) 0.0) + + ;; in and out movement + (set! (-> local-trans z) + (cond + ((logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons down)) + -800.0 + ) + ((logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons up)) + 800.0 + ) + (else + 0.0 + ) + ) + ) + (set! (-> local-trans w) 1.0) + + ;; rotate this into world frame + (let ((inv-cam-rot (new-stack-vector0)) + (cam-rot-mat (new-stack-matrix0))) + ;; unused. + (vector-negate! inv-cam-rot (-> trans rot)) + ;; convert rotation to rotation matrix. + (matrix-rotate-zyx! cam-rot-mat (-> trans rot)) + ;; and rotate the translation. + (vector-matrix*! local-trans local-trans cam-rot-mat) + ) + + ;; and update the transform + (vector+! (-> trans trans) (-> trans trans) local-trans) + + + ;; don't forget to fix w. + (set! (-> trans trans w) 1.0) + + ;; global translation + (if (logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons l1)) + (set! (-> trans trans y) (+ 800.0 (-> trans trans y))) + ) + (if (logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons r1)) + (set! (-> trans trans y) (+ -800.0 (-> trans trans y))) + ) + + ;; rotation (don't allow camera roll) + (if (logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons x)) + (set! (-> trans rot x) (+ 54.13336 (-> trans rot x))) + ) + (if (logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons triangle)) + (set! (-> trans rot x) (+ -54.13336 (-> trans rot x))) + ) + (if (logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons left)) + (set! (-> trans rot y) (+ 546.13336 (-> trans rot y))) + ) + (if (logtest? (-> *cpad-list* cpads pad-idx button0-abs 0) (pad-buttons right)) + (set! (-> trans rot y) (+ -546.13336 (-> trans rot y))) + ) + + (set! (-> trans scale x) 1.) + (set! (-> trans scale y) 1.) + (set! (-> trans scale z) 1.) + (set! (-> trans scale w) 1.) + ) + ) + (defun launch-test-process () "Call this to launch a process that draws the debug demo" (let ((proc (get-process *nk-dead-pool* process 1024))) @@ -122,6 +216,41 @@ ) + +(defun launch-wasd-process () + "Launch a process to control the camera with keyboard. + Note that the test process above also controls the camera and should be killed first. + For example, after loading this file, do + (kill-test-procs) + (launch-wasd-process)" + (let ((proc (get-process *nk-dead-pool* process 1024))) + (activate proc *active-pool* 'test *kernel-dram-stack*) + (set! (-> *wasd-camera-transform* trans y) (meters 4.0)) + (run-next-time-in-process proc (lambda () + (let ((iter 0)) + (while #t + (wasd-camera-update) + (let ((mat (new-stack-matrix0))) + (transform-matrix-calc! *wasd-camera-transform* mat) + (set! (-> mat data 3) 0.) + (set! (-> mat data 7) 0.) + (set! (-> mat data 11) 0.) + (set! (-> mat data 12) 0.) + (set! (-> mat data 13) 0.) + (set! (-> mat data 14) 0.) + (set! (-> mat data 15) 1.) + ;;(matrix-transpose! mat mat) + (hack-update-camera (-> *wasd-camera-transform* trans) mat) + ) + (suspend) + (+! iter 1) + ) + ) + ) + ) + proc) + ) + ;; This will spawn a process the first time this file is loaded (define-perm *test-process* process (launch-test-process)) diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index 52552e9ecd..d2c88d822b 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -712,6 +712,11 @@ (dbg) ) ) + +(defmacro mi () + "Make ISO" + `(make-group "iso") + ) ;;;;;;;;;;;;;;;;;;; ;; enum stuff ;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/kernel/gkernel.gc b/goal_src/kernel/gkernel.gc index f4899e9f1b..5445f48c37 100644 --- a/goal_src/kernel/gkernel.gc +++ b/goal_src/kernel/gkernel.gc @@ -2336,8 +2336,8 @@ ;; this is not yet defined. -(define-extern entity-deactivate-handler (function process object none)) -(define entity-deactivate-handler (the (function process object none) nothing)) +(define-extern entity-deactivate-handler (function process entity none)) +(define entity-deactivate-handler (the (function process entity none) nothing)) (define-extern process-disconnect (function process int)) diff --git a/goalc/compiler/compilation/Static.cpp b/goalc/compiler/compilation/Static.cpp index b1ba9f16d2..13af6c3a37 100644 --- a/goalc/compiler/compilation/Static.cpp +++ b/goalc/compiler/compilation/Static.cpp @@ -418,9 +418,21 @@ Val* Compiler::compile_bitfield_definition(const goos::Object& form, form, "Field {} is a symbol, which cannot be constructed at compile time yet.", field_name_def); } - } - - else { + } else if (m_ts.tc(TypeSpec("structure"), field_info.result_type)) { + if (allow_dynamic_construction) { + DynamicDef dyn; + dyn.definition = field_value; + dyn.field_offset = field_offset; + dyn.field_size = field_size; + dyn.field_name = field_name_def; + dyn.expected_type = coerce_to_reg_type(field_info.result_type); + dynamic_defs.push_back(dyn); + } else { + throw_compiler_error( + form, "Field {} is a structure, which cannot be constructed at compile time yet.", + field_name_def); + } + } else { throw_compiler_error(form, "Bitfield field {} with type {} cannot be set statically.", field_name_def, field_info.result_type.print()); } diff --git a/goalc/compiler/compilation/Type.cpp b/goalc/compiler/compilation/Type.cpp index 9faf67ab41..a0ef2229cc 100644 --- a/goalc/compiler/compilation/Type.cpp +++ b/goalc/compiler/compilation/Type.cpp @@ -1148,7 +1148,7 @@ Val* Compiler::compile_new(const goos::Object& form, const goos::Object& _rest, rest = &pair_cdr(*rest); if (allocation == "global" || allocation == "debug" || allocation == "process" || - allocation == "process-level-heap") { + allocation == "process-level-heap" || allocation == "loading-level") { // allocate on a named heap return compile_heap_new(form, allocation, type, rest, env); } else if (allocation == "static") { diff --git a/test/decompiler/reference/engine/entity/entity-h_REF.gc b/test/decompiler/reference/engine/entity/entity-h_REF.gc index 12e7e38cef..dbbfa2850b 100644 --- a/test/decompiler/reference/engine/entity/entity-h_REF.gc +++ b/test/decompiler/reference/engine/entity/entity-h_REF.gc @@ -75,7 +75,7 @@ :size-assert #x40 :flag-assert #xa00000040 (:methods - (dummy-9 () none 9) + (dummy-9 (_type_ vector) none 9) ) ) @@ -147,11 +147,11 @@ :size-assert #x34 :flag-assert #x1b00000034 (:methods - (dummy-22 () none 22) - (dummy-23 () none 23) - (dummy-24 () none 24) - (dummy-25 () none 25) - (dummy-26 () none 26) + (birth! (_type_) _type_ 22) + (kill! (_type_) _type_ 23) + (add-to-level! (_type_ level-group level actor-id) none 24) + (remove-from-level! (_type_ level-group) _type_ 25) + (get-level (_type_) level 26) ) ) @@ -203,7 +203,8 @@ ;; definition of type entity-ambient-data-array (deftype entity-ambient-data-array (inline-array-class) - () + ((data entity-ambient-data :inline :dynamic :offset-assert 16) + ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 @@ -214,7 +215,7 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format #t "~Tdata[0] @ #x~X~%" (-> obj _data)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj data)) obj ) @@ -229,17 +230,18 @@ :flag-assert #x1d00000034 (:methods (dummy-27 () none 27) - (dummy-28 () none 28) + (birth-ambient! (_type_) none 28) ) ) ;; definition of type entity-actor (deftype entity-actor (entity) - ((nav-mesh nav-mesh :offset-assert 52) - (etype type :offset-assert 56) - (task uint8 :offset-assert 60) - (vis-id uint16 :offset-assert 62) - (quat quaternion :inline :offset-assert 64) + ((nav-mesh nav-mesh :offset-assert 52) + (etype type :offset-assert 56) + (task uint8 :offset-assert 60) + (vis-id uint16 :offset-assert 62) + (vis-id-signed int16 :offset 62) + (quat quaternion :inline :offset-assert 64) ) :method-count-assert 31 :size-assert #x50 @@ -247,8 +249,8 @@ (:methods (next-actor (_type_) entity-actor 27) (prev-actor (_type_) entity-actor 28) - (dummy-29 () none 29) - (dummy-30 () none 30) + (debug-print (_type_ symbol type) none 29) + (dummy-30 (_type_ entity-perm-status symbol) none 30) ) ) diff --git a/test/decompiler/reference/engine/game/generic-obs-h_REF.gc b/test/decompiler/reference/engine/game/generic-obs-h_REF.gc index 4e74e1f04d..da40dbfa76 100644 --- a/test/decompiler/reference/engine/game/generic-obs-h_REF.gc +++ b/test/decompiler/reference/engine/game/generic-obs-h_REF.gc @@ -78,19 +78,19 @@ ;; definition of type part-tracker (deftype part-tracker (process) - ((root basic :offset-assert 112) - (part basic :offset-assert 116) - (target uint64 :offset-assert 120) - (callback basic :offset-assert 128) - (linger-callback basic :offset-assert 132) - (duration uint64 :offset-assert 136) - (linger-duration uint64 :offset-assert 144) - (start-time uint64 :offset-assert 152) - (offset vector :inline :offset-assert 160) - (userdata uint64 :offset-assert 176) - (user-time uint64 2 :offset-assert 184) - (user-vector vector 2 :inline :offset-assert 208) - (user-handle uint32 2 :offset-assert 240) + ((root trsqv :offset-assert 112) + (part sparticle-launch-control :offset-assert 116) + (target uint64 :offset-assert 120) + (callback basic :offset-assert 128) + (linger-callback basic :offset-assert 132) + (duration uint64 :offset-assert 136) + (linger-duration uint64 :offset-assert 144) + (start-time uint64 :offset-assert 152) + (offset vector :inline :offset-assert 160) + (userdata uint64 :offset-assert 176) + (user-time uint64 2 :offset-assert 184) + (user-vector vector 2 :inline :offset-assert 208) + (user-handle uint32 2 :offset-assert 240) ) :heap-base #x90 :method-count-assert 14 diff --git a/test/decompiler/reference/engine/gfx/vis/bsp-h_REF.gc b/test/decompiler/reference/engine/gfx/vis/bsp-h_REF.gc index 63b5dd5c0c..0cbadd7862 100644 --- a/test/decompiler/reference/engine/gfx/vis/bsp-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/vis/bsp-h_REF.gc @@ -53,7 +53,7 @@ (unk-data-4 float :offset-assert 160) (unk-data-5 float :offset-assert 164) (adgifs adgif-shader-array :offset-assert 168) - (unk-data-6 pointer :offset-assert 172) + (actor-birth-order (pointer uint32) :offset-assert 172) (unk-data-7 pointer :offset-assert 176) (unk-data-8 uint32 55 :offset-assert 180) ) @@ -62,7 +62,7 @@ :flag-assert #x1400000190 (:methods (relocate (_type_ kheap (pointer uint8)) none :replace 7) - (dummy-18 (_type_) none 18) + (birth (_type_) none 18) (dummy-19 (_type_) none 19) ) ) diff --git a/test/decompiler/reference/engine/gfx/vis/bsp_REF.gc b/test/decompiler/reference/engine/gfx/vis/bsp_REF.gc index f7c1c88de0..fd99a743c4 100644 --- a/test/decompiler/reference/engine/gfx/vis/bsp_REF.gc +++ b/test/decompiler/reference/engine/gfx/vis/bsp_REF.gc @@ -113,7 +113,7 @@ ) ) ) - (when (nonzero? (-> obj unk-data-6)) + (when (nonzero? (-> obj actor-birth-order)) (set! (-> mem-use length) (max 58 (-> mem-use length))) (set! (-> mem-use data 57 name) "bsp-misc") (+! (-> mem-use data 57 count) 1) diff --git a/test/decompiler/reference/engine/level/level-h_REF.gc b/test/decompiler/reference/engine/level/level-h_REF.gc index f552b591c1..fde738b66e 100644 --- a/test/decompiler/reference/engine/level/level-h_REF.gc +++ b/test/decompiler/reference/engine/level/level-h_REF.gc @@ -186,7 +186,7 @@ :flag-assert #x1d00000a30 (:methods (deactivate (_type_) _type_ 9) - (dummy-10 (_type_ int) symbol 10) + (is-object-visible? (_type_ int) symbol 10) (add-irq-to-tex-buckets! (_type_) none 11) (unload! (_type_) _type_ 12) (bsp-name (_type_) symbol 13) @@ -294,18 +294,18 @@ (level-get-with-status (_type_ symbol) level 10) (level-get-for-use (_type_ symbol symbol) level 11) (activate-levels! (_type_) int 12) - (dummy-13 () none 13) - (dummy-14 (_type_ object) none 14) - (dummy-15 () none 15) + (debug-print-entities (_type_ symbol type) none 13) + (debug-draw-actors (_type_ symbol) none 14) + (dummy-15 (_type_) object 15) (dummy-16 (_type_) int 16) (level-get-target-inside (_type_) level 17) (alloc-levels! (_type_ symbol) int 18) (load-commands-set! (_type_ pair) pair 19) (art-group-get-by-name (_type_ string) art-group 20) (load-command-get-index (_type_ symbol int) pair 21) - (dummy-22 () none 22) - (dummy-23 () none 23) - (dummy-24 () none 24) + (update-vis-volumes (_type_) none 22) + (update-vis-volumes-from-nav-mesh (_type_) none 23) + (print-volume-sizes (_type_) none 24) (level-status (_type_ symbol) symbol 25) (level-get-most-disposable (_type_) level 26) ) diff --git a/test/decompiler/reference/engine/nav/navigate-h_REF.gc b/test/decompiler/reference/engine/nav/navigate-h_REF.gc index 8272e4b0b9..13972e2bf7 100644 --- a/test/decompiler/reference/engine/nav/navigate-h_REF.gc +++ b/test/decompiler/reference/engine/nav/navigate-h_REF.gc @@ -239,21 +239,21 @@ ;; 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) + ((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 (inline-array vector) :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 @@ -269,7 +269,7 @@ (dummy-16 () none 16) (dummy-17 (_type_) none 17) (dummy-18 () none 18) - (dummy-19 () none 19) + (compute-bounding-box (_type_ vector vector) none 19) (dummy-20 () none 20) (dummy-21 () none 21) (dummy-22 () none 22) diff --git a/test/decompiler/reference/kernel/gkernel_REF.gc b/test/decompiler/reference/kernel/gkernel_REF.gc index c2ddd16d1d..60368302e3 100644 --- a/test/decompiler/reference/kernel/gkernel_REF.gc +++ b/test/decompiler/reference/kernel/gkernel_REF.gc @@ -1652,10 +1652,10 @@ (the-as (function none :behavior process) nothing) ) -;; definition for symbol entity-deactivate-handler, type (function process object none) +;; definition for symbol entity-deactivate-handler, type (function process entity none) (define entity-deactivate-handler - (the-as (function process object none) nothing) + (the-as (function process entity none) nothing) ) ;; definition for method 10 of type process