From 8f68d35cbbdcf70b3934bf229a9ac3c717563618 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Mon, 1 Mar 2021 11:15:24 -0500 Subject: [PATCH] [Decomp] Some more collision header files and speed up tests (#296) * some more * faster tests * on by default --- common/CMakeLists.txt | 6 + decompiler/config/all-types.gc | 680 +++++++++--------- .../jak1_ntsc_black_label/label_types.jsonc | 5 +- .../jak1_ntsc_black_label/type_hints.jsonc | 32 +- .../jak1_ntsc_black_label/var_names.jsonc | 3 + goal_src/engine/collide/collide-cache-h.gc | 160 +++++ .../engine/collide/collide-edge-grab-h.gc | 224 ++++++ goal_src/engine/collide/collide-h.gc | 1 + goal_src/engine/collide/collide-touch-h.gc | 155 ++++ goal_src/engine/draw/draw-node-h.gc | 2 +- goal_src/engine/draw/drawable-actor-h.gc | 4 +- goal_src/engine/draw/drawable-ambient-h.gc | 4 +- goal_src/engine/draw/drawable-h.gc | 4 +- .../engine/draw/drawable-inline-array-h.gc | 2 +- goal_src/engine/gfx/depth-cue-h.gc | 28 + goal_src/engine/math/trigonometry.gc | 6 - goal_src/engine/util/types-h.gc | 38 +- goal_src/goal-lib.gc | 66 +- goal_src/goos-lib.gs | 12 +- goal_src/kernel/gkernel.gc | 2 +- goalc/CMakeLists.txt | 6 + .../with_game/test-build-game.gc | 2 +- .../with_game/test-load-game.gc | 3 +- test/goalc/test_game_no_debug.cpp | 2 + test/goalc/test_goal_kernel.cpp | 1 + test/goalc/test_with_game.cpp | 58 +- 26 files changed, 1115 insertions(+), 391 deletions(-) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index ed3bef6c4..94f89ea6a 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -29,4 +29,10 @@ else() target_link_libraries(common stdc++fs) endif() +if(UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") +elseif(WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2") +endif() + install(TARGETS common) diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index d8990c0e5..1dc1b1384 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -4316,7 +4316,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4336,7 +4336,7 @@ :flag-assert #x1200000024 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4364,7 +4364,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4391,7 +4391,7 @@ ;; field distance is a float printed as hex? (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4434,7 +4434,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4468,7 +4468,7 @@ :flag-assert #x1300000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -7388,7 +7388,7 @@ :flag-assert #x1200000040 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -9134,219 +9134,223 @@ ) ) -; ;; collide-touch-h -; (deftype touching-prim (structure) -; ((cprim basic :offset-assert 0) -; (has-tri? basic :offset-assert 4) -; (tri collide-tri-result :inline :offset-assert 16) -; ) -; :method-count-assert 9 -; :size-assert #x64 -; :flag-assert #x900000064 -; ) +;; collide-touch-h +(deftype touching-prim (structure) + ((cprim basic :offset-assert 0) + (has-tri? basic :offset-assert 4) + (tri collide-tri-result :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x64 + :flag-assert #x900000064 + ) -; ;; collide-touch-h -; (deftype touching-prims-entry (structure) -; ((next touching-prims-entry :offset-assert 0) -; (prev touching-prims-entry :offset-assert 4) -; (allocated? basic :offset-assert 8) -; (u float :offset-assert 12) -; (prim1 touching-prim :inline :offset-assert 16) -; (prim2 touching-prim :inline :offset-assert 128) -; ) -; :method-count-assert 13 -; :size-assert #xe4 -; :flag-assert #xd000000e4 -; (:methods -; (dummy-9 () none 9) -; (dummy-10 () none 10) -; (dummy-11 () none 11) -; (dummy-12 () none 12) -; ) -; ) +;; collide-touch-h +(deftype touching-prims-entry (structure) + ((next touching-prims-entry :offset-assert 0) + (prev touching-prims-entry :offset-assert 4) + (allocated? basic :offset-assert 8) + (u float :offset-assert 12) + (prim1 touching-prim :inline :offset-assert 16) + (prim2 touching-prim :inline :offset-assert 128) + ) + :method-count-assert 13 + :size-assert #xe4 + :flag-assert #xd000000e4 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + ) + ) -; ;; collide-touch-h -; (deftype touching-prims-entry-pool (structure) -; ((head touching-prims-entry :offset-assert 0) -; (nodes UNKNOWN 64 :offset-assert 16) -; ) -; :method-count-assert 13 -; :size-assert #x3c10 -; :flag-assert #xd00003c10 -; (:methods -; (dummy-9 () none 9) -; (dummy-10 () none 10) -; (dummy-11 () none 11) -; (dummy-12 () none 12) -; ) -; ) +;; collide-touch-h +(deftype touching-prims-entry-pool (structure) + ((head touching-prims-entry :offset-assert 0) + (nodes touching-prims-entry 64 :inline :offset-assert 16) + ) + :method-count-assert 13 + :size-assert #x3c10 + :flag-assert #xd00003c10 + (:methods + (new (symbol type) _type_ 0) + (dummy-9 () none 9) + (dummy-10 () none 10) + (init-list! (_type_) none 11) + (dummy-12 () none 12) + ) + ) -; ;; collide-touch-h -; (deftype touching-shapes-entry (structure) -; ((cshape1 basic :offset-assert 0) -; (cshape2 basic :offset-assert 4) -; (resolve-u int8 :offset-assert 8) -; (head touching-prims-entry :offset-assert 12) -; ) -; :method-count-assert 18 -; :size-assert #x10 -; :flag-assert #x1200000010 -; (: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) -; ) -; ) +;; collide-touch-h +(deftype touching-shapes-entry (structure) + ((cshape1 basic :offset-assert 0) + (cshape2 basic :offset-assert 4) + (resolve-u int8 :offset-assert 8) + (head touching-prims-entry :offset-assert 12) + ) + :allow-misaligned + :method-count-assert 18 + :size-assert #x10 + :flag-assert #x1200000010 + (: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) + (get-head (_type_) touching-prims-entry 16) + (unknown1 (_type_ (xx (pointer uint32))) uint 17) + ) + ) -; ;; collide-touch-h -; (deftype touching-list (structure) -; ((num-touching-shapes int32 :offset-assert 0) -; (resolve-u int8 :offset-assert 4) -; (touching-shapes UNKNOWN 32 :offset-assert 8) -; ) -; :method-count-assert 15 -; :size-assert #x208 -; :flag-assert #xf00000208 -; (: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) -; ) -; ) +;; collide-touch-h +(deftype touching-list (structure) + ((num-touching-shapes int32 :offset-assert 0) + (resolve-u int8 :offset-assert 4) + (touching-shapes touching-shapes-entry 32 :inline :offset-assert 8) + ) + :method-count-assert 15 + :size-assert #x208 + :flag-assert #xf00000208 + (:methods + (new (symbol type) _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) + ) + ) -; ;; collide-edge-grab-h -; (deftype edge-grab-info (structure) -; ((world-vertex UNKNOWN 6 :offset-assert 0) -; (local-vertex UNKNOWN 6 :offset-assert 96) -; (actor-cshape-prim-offset int32 :offset-assert 192) -; (actor-handle uint64 :offset-assert 200) -; (hanging-matrix matrix :inline :offset-assert 208) -; (edge-vertex UNKNOWN 2 :offset-assert 0) -; (center-hold vector :inline :offset-assert 32) -; (tri-vertex UNKNOWN 3 :offset-assert 48) -; (left-hand-hold vector :inline :offset-assert 272) -; (right-hand-hold vector :inline :offset-assert 288) -; (center-hold-old vector :inline :offset-assert 304) -; (edge-tri-pat uint32 :offset-assert 320) -; ) -; :method-count-assert 11 -; :size-assert #x144 -; :flag-assert #xb00000144 -; (:methods -; (dummy-9 () none 9) -; (dummy-10 () none 10) -; ) -; ) +;; collide-edge-grab-h +(deftype edge-grab-info (structure) + ((world-vertex vector 6 :inline :offset-assert 0) + (local-vertex vector 6 :inline :offset-assert 96) + (actor-cshape-prim-offset int32 :offset-assert 192) + (actor-handle uint64 :offset-assert 200) + (hanging-matrix matrix :inline :offset-assert 208) + (edge-vertex vector 2 :inline :offset 0) + (center-hold vector :inline :offset 32) + (tri-vertex vector 3 :inline :offset 48) + (left-hand-hold vector :inline :offset-assert 272) + (right-hand-hold vector :inline :offset-assert 288) + (center-hold-old vector :inline :offset-assert 304) + (edge-tri-pat uint32 :offset-assert 320) + ) + :method-count-assert 11 + :size-assert #x144 + :flag-assert #xb00000144 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + ) + ) -; ;; collide-edge-grab-h -; (deftype collide-edge-tri (structure) -; ((ctri collide-cache-tri :offset-assert 0) -; (normal vector :inline :offset-assert 16) -; ) -; :method-count-assert 9 -; :size-assert #x20 -; :flag-assert #x900000020 -; ) +;; collide-edge-grab-h +(declare-type collide-cache-tri structure) +(deftype collide-edge-tri (structure) + ((ctri collide-cache-tri :offset-assert 0) + (normal vector :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) -; ;; collide-edge-grab-h -; (deftype collide-edge-edge (structure) -; ((ignore basic :offset-assert 0) -; (etri collide-edge-tri :offset-assert 4) -; (vertex-ptr UNKNOWN 2 :offset-assert 8) -; (outward vector :inline :offset-assert 16) -; (edge-vec-norm vector :inline :offset-assert 32) -; ) -; :method-count-assert 9 -; :size-assert #x30 -; :flag-assert #x900000030 -; ) +;; collide-edge-grab-h +(deftype collide-edge-edge (structure) + ((ignore basic :offset-assert 0) + (etri collide-edge-tri :offset-assert 4) + (vertex-ptr vector 2 :offset-assert 8) + (outward vector :inline :offset-assert 16) + (edge-vec-norm vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) -; ;; collide-edge-grab-h -; (deftype collide-edge-hold-item (structure) -; ((next collide-edge-hold-item :offset-assert 0) -; (rating float :offset-assert 4) -; (split int8 :offset-assert 8) -; (edge collide-edge-edge :offset-assert 12) -; (center-pt vector :inline :offset-assert 16) -; (outward-pt vector :inline :offset-assert 32) -; ) -; :method-count-assert 9 -; :size-assert #x30 -; :flag-assert #x900000030 -; ) +;; collide-edge-grab-h +(deftype collide-edge-hold-item (structure) + ((next collide-edge-hold-item :offset-assert 0) + (rating float :offset-assert 4) + (split int8 :offset-assert 8) + (edge collide-edge-edge :offset-assert 12) + (center-pt vector :inline :offset-assert 16) + (outward-pt vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) -; ;; collide-edge-grab-h -; (deftype collide-edge-hold-list (structure) -; ((num-allocs uint32 :offset-assert 0) -; (num-attempts uint32 :offset-assert 4) -; (head collide-edge-hold-item :offset-assert 8) -; (items UNKNOWN 32 :offset-assert 16) -; (attempts UNKNOWN 32 :offset-assert 1552) -; ) -; :method-count-assert 11 -; :size-assert #x810 -; :flag-assert #xb00000810 -; (:methods -; (dummy-9 () none 9) -; (dummy-10 () none 10) -; ) -; ) +;; collide-edge-grab-h +(deftype collide-edge-hold-list (structure) + ((num-allocs uint32 :offset-assert 0) + (num-attempts uint32 :offset-assert 4) + (head collide-edge-hold-item :offset-assert 8) + (items collide-edge-hold-item 32 :inline :offset-assert 16) + (attempts qword 32 :inline :offset-assert 1552) + ) + :method-count-assert 11 + :size-assert #x810 + :flag-assert #xb00000810 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + ) + ) -; ;; collide-edge-grab-h -; (deftype collide-edge-work (structure) -; ((ccache basic :offset-assert 0) -; (cshape basic :offset-assert 4) -; (num-verts uint32 :offset-assert 8) -; (num-edges uint32 :offset-assert 12) -; (num-tris uint32 :offset-assert 16) -; (cache-fill-box bounding-box :inline :offset-assert 32) -; (within-reach-box bounding-box :inline :offset-assert 64) -; (within-reach-box4w bounding-box4w :inline :offset-assert 96) -; (search-pt vector :inline :offset-assert 128) -; (search-dir-vec vector :inline :offset-assert 144) -; (max-dist-sqrd-to-outward-pt float :offset-assert 160) -; (max-dir-cosa-delta float :offset-assert 164) -; (split-dists UNKNOWN 2 :offset-assert 168) -; (outward-offset vector :inline :offset-assert 176) -; (local-cache-fill-box bounding-box :inline :offset-assert 192) -; (local-within-reach-box bounding-box :inline :offset-assert 224) -; (local-player-spheres UNKNOWN 12 :offset-assert 256) -; (world-player-spheres UNKNOWN 12 :offset-assert 448) -; (local-player-hanging-spheres UNKNOWN 6 :offset-assert 256) -; (world-player-hanging-spheres UNKNOWN 6 :offset-assert 448) -; (local-player-leap-up-spheres UNKNOWN 6 :offset-assert 352) -; (world-player-leap-up-spheres UNKNOWN 6 :offset-assert 544) -; (verts UNKNOWN 64 :offset-assert 640) -; (edges UNKNOWN 96 :offset-assert 1664) -; (tris UNKNOWN 48 :offset-assert 6272) -; (hold-list collide-edge-hold-list :inline :offset-assert 7808) -; ) -; :method-count-assert 20 -; :size-assert #x2690 -; :flag-assert #x1400002690 -; (: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) -; ) -; ) +;; collide-edge-grab-h +(deftype collide-edge-work (structure) + ((ccache basic :offset-assert 0) + (cshape basic :offset-assert 4) + (num-verts uint32 :offset-assert 8) + (num-edges uint32 :offset-assert 12) + (num-tris uint32 :offset-assert 16) + (cache-fill-box bounding-box :inline :offset-assert 32) + (within-reach-box bounding-box :inline :offset-assert 64) + (within-reach-box4w bounding-box4w :inline :offset-assert 96) + (search-pt vector :inline :offset-assert 128) + (search-dir-vec vector :inline :offset-assert 144) + (max-dist-sqrd-to-outward-pt float :offset-assert 160) + (max-dir-cosa-delta float :offset-assert 164) + (split-dists float 2 :offset-assert 168) + (outward-offset vector :inline :offset-assert 176) + (local-cache-fill-box bounding-box :inline :offset-assert 192) + (local-within-reach-box bounding-box :inline :offset-assert 224) + (local-player-spheres sphere 12 :inline :offset-assert 256) + (world-player-spheres sphere 12 :inline :offset-assert 448) + (local-player-hanging-spheres sphere 6 :inline :offset 256) + (world-player-hanging-spheres sphere 6 :inline :offset 448) + (local-player-leap-up-spheres sphere 6 :inline :offset 352) + (world-player-leap-up-spheres sphere 6 :inline :offset 544) + (verts vector 64 :inline :offset-assert 640) + (edges collide-edge-edge 96 :inline :offset-assert 1664) + (tris collide-edge-tri 48 :inline :offset-assert 6272) + (hold-list collide-edge-hold-list :inline :offset-assert 7808) + ) + :method-count-assert 20 + :size-assert #x2690 + :flag-assert #x1400002690 + (: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) + ) + ) ; ;; effect-control-h ; (deftype effect-control (basic) @@ -9671,16 +9675,13 @@ ) ) -; ;; stats-h -; (deftype perf-stat-array (inline-array-class) -; ((length int32 :offset-assert 4) -; (allocated-length int32 :offset-assert 8) -; (data UNKNOWN :dynamic :offset-assert 16) -; ) -; :method-count-assert 9 -; :size-assert #x10 -; :flag-assert #x900000010 -; ) +;; stats-h +(deftype perf-stat-array (inline-array-class) + () + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) ;; bsp-h (deftype bsp-node (structure) @@ -9720,15 +9721,20 @@ :flag-assert #x900000080 ) -; ;; bsp-h +;; bsp-h ; (deftype bsp-header (drawable) -; () +; ((all-visible-list pointer :offset-assert 32) +; (visible-list-length int32 :offset-assert 36) +; (drawable-trees basic :offset-assert 40) +; (pat uint32 :offset-assert 44) +; (pat-length int32 :offset-asert 48) +; ) ; :method-count-assert 20 ; :size-assert #x190 ; :flag-assert #x1400000190 ; (:methods ; (dummy-9 () none 9) -; (dummy-10 () none 10) +; (dummy-10 (_type_) int 10) ; (dummy-11 () none 11) ; (dummy-12 () none 12) ; (dummy-13 () none 13) @@ -9809,99 +9815,99 @@ ) ) -; ;; collide-cache-h -; (deftype collide-puyp-work (structure) -; ((best-u float :offset-assert 0) -; (ignore-pat uint32 :offset-assert 4) -; (tri-out collide-tri-result :offset-assert 8) -; (start-pos vector :inline :offset-assert 16) -; (move-dist vector :inline :offset-assert 32) -; ) -; :method-count-assert 9 -; :size-assert #x30 -; :flag-assert #x900000030 -; ) +;; collide-cache-h +(deftype collide-puyp-work (structure) + ((best-u float :offset-assert 0) + (ignore-pat uint32 :offset-assert 4) + (tri-out collide-tri-result :offset-assert 8) + (start-pos vector :inline :offset-assert 16) + (move-dist vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) -; ;; collide-cache-h -; (deftype collide-cache-tri (structure) -; ((vertex UNKNOWN 3 :offset-assert 0) -; (extra-quad UNKNOWN 16 :offset-assert 48) -; (pat uint32 :offset-assert 48) -; (prim-index uint16 :offset-assert 52) -; (user16 uint16 :offset-assert 54) -; (user32 UNKNOWN 2 :offset-assert 56) -; ) -; :method-count-assert 9 -; :size-assert #x40 -; :flag-assert #x900000040 -; ) +;; collide-cache-h +(deftype collide-cache-tri (structure) + ((vertex vector 3 :inline :offset-assert 0) + ;(extra-quad UNKNOWN 16 :offset-assert 48) + (pat uint32 :offset-assert 48) + (prim-index uint16 :offset-assert 52) + (user16 uint16 :offset-assert 54) + (user32 uint32 2 :offset-assert 56) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) -; ;; collide-cache-h -; (deftype collide-cache-prim (structure) -; ((prim-core collide-prim-core :inline :offset-assert 0) -; (extra-quad UNKNOWN 16 :offset-assert 32) -; (ccache basic :offset-assert 32) -; (prim basic :offset-assert 36) -; (first-tri uint16 :offset-assert 40) -; (num-tris uint16 :offset-assert 42) -; (unused UNKNOWN 4 :offset-assert 44) -; (world-sphere vector :inline :offset-assert 0) -; (collide-as uint64 :offset-assert 16) -; (action uint32 :offset-assert 24) -; (offense int8 :offset-assert 28) -; (prim-type int8 :offset-assert 29) -; ) -; :method-count-assert 11 -; :size-assert #x30 -; :flag-assert #xb00000030 -; (:methods -; (dummy-9 () none 9) -; (dummy-10 () none 10) -; ) -; ) +;; collide-cache-h +(deftype collide-cache-prim (structure) + ((prim-core collide-prim-core :inline :offset-assert 0) + ;;(extra-quad UNKNOWN 16 :offset-assert 32) + (ccache basic :offset-assert 32) + (prim basic :offset-assert 36) + (first-tri uint16 :offset-assert 40) + (num-tris uint16 :offset-assert 42) + (unused uint8 4 :offset-assert 44) + (world-sphere vector :inline :offset 0) + (collide-as uint64 :offset 16) + (action uint32 :offset 24) + (offense int8 :offset 28) + (prim-type int8 :offset 29) + ) + :method-count-assert 11 + :size-assert #x30 + :flag-assert #xb00000030 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + ) + ) -; ;; collide-cache-h -; (deftype collide-cache (basic) -; ((num-tris int32 :offset-assert 4) -; (num-prims int32 :offset-assert 8) -; (ignore-mask uint32 :offset-assert 12) -; (proc basic :offset-assert 16) -; (collide-box bounding-box :inline :offset-assert 32) -; (collide-box4w bounding-box4w :inline :offset-assert 64) -; (collide-with uint64 :offset-assert 96) -; (prims UNKNOWN 100 :offset-assert 112) -; (tris UNKNOWN 461 :offset-assert 4912) -; ) -; :method-count-assert 33 -; :size-assert #x8670 -; :flag-assert #x2100008670 -; (: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) -; ) -; ) +;; collide-cache-h +(deftype collide-cache (basic) + ((num-tris int32 :offset-assert 4) + (num-prims int32 :offset-assert 8) + (ignore-mask uint32 :offset-assert 12) + (proc basic :offset-assert 16) + (collide-box bounding-box :inline :offset-assert 32) + (collide-box4w bounding-box4w :inline :offset-assert 64) + (collide-with uint64 :offset-assert 96) + (prims collide-cache-prim 100 :inline :offset-assert 112) + (tris collide-cache-tri 461 :inline :offset-assert 4912) + ) + :method-count-assert 33 + :size-assert #x8670 + :flag-assert #x2100008670 + (: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) + ) + ) ;; collide-cache-h (deftype collide-list-item (structure) @@ -9943,7 +9949,7 @@ :flag-assert #x1200000070 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -9992,7 +9998,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -10014,7 +10020,7 @@ :flag-assert #x1200000050 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -10043,7 +10049,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -33353,13 +33359,13 @@ ;;(define-extern collide-history object) ;; unknown type ;;(define-extern touching-list object) ;; unknown type ;;(define-extern touching-shapes-entry object) ;; unknown type -;;(define-extern *touching-prims-entry-pool* object) ;; unknown type +(define-extern *touching-prims-entry-pool* touching-prims-entry-pool) ;; unknown type ;;(define-extern touching-prims-entry object) ;; unknown type ;;(define-extern touching-prims-entry-pool object) ;; unknown type -;;(define-extern *touching-list* object) ;; unknown type +(define-extern *touching-list* touching-list) ;; unknown type ;;(define-extern touching-prim object) ;; unknown type ;;(define-extern collide-edge-tri object) ;; unknown type -;;(define-extern *edge-grab-info* object) ;; unknown type +(define-extern *edge-grab-info* edge-grab-info) ;; unknown type ;;(define-extern collide-edge-edge object) ;; unknown type ;;(define-extern edge-grab-info object) ;; unknown type ;;(define-extern collide-edge-hold-list object) ;; unknown type @@ -33407,14 +33413,14 @@ ;;(define-extern view-frustum object) ;; unknown type ;;(define-extern collide-stats object) ;; unknown type ;;(define-extern collide-cache-tri object) ;; unknown type -;;(define-extern *collide-cache* object) ;; unknown type +(define-extern *collide-cache* collide-cache) ;; unknown type ;;(define-extern collide-list-item object) ;; unknown type -;;(define-extern *collide-work* object) ;; unknown type +(define-extern *collide-work* collide-work) ;; unknown type ;;(define-extern collide-using-spheres-params object) ;; unknown type ;;(define-extern collide-puss-work object) ;; unknown type ;;(define-extern collide-puss-sphere object) ;; unknown type ;;(define-extern collide-puyp-work object) ;; unknown type -;;(define-extern *collide-list* object) ;; unknown type +(define-extern *collide-list* collide-list) ;; unknown type ;;(define-extern collide-work object) ;; unknown type ;;(define-extern collide-cache-prim object) ;; unknown type ;;(define-extern collide-list object) ;; unknown type @@ -33627,32 +33633,32 @@ ;;(define-extern nav-max-users object) ;; unknown type ;;(define-extern nav-engine object) ;; unknown type ;;(define-extern nearest-y-threshold object) ;; unknown type -(define-extern dgo-load-begin function) +(define-extern dgo-load-begin (function int int int int int)) (define-extern dgo-load-continue function) (define-extern destroy-mem function) (define-extern str-load (function string int pointer int symbol)) -;;(define-extern *load-str-rpc* object) ;; unknown type +(define-extern *load-str-rpc* rpc-buffer-pair) ;; unknown type ;;(define-extern load-chunk-msg object) ;; unknown type ;;(define-extern *dgo-name* object) ;; unknown type -(define-extern str-ambient-play function) -;;(define-extern *load-str-lock* object) ;; unknown type +(define-extern str-ambient-play (function string none)) +(define-extern *load-str-lock* symbol) ;; unknown type (define-extern str-load-status (function (pointer int32) symbol)) -(define-extern str-load-cancel function) -(define-extern str-play-queue function) -(define-extern str-ambient-stop function) +(define-extern str-load-cancel (function none)) +(define-extern str-play-queue (function string none)) +(define-extern str-ambient-stop (function string none)) (define-extern dgo-load-get-next function) (define-extern find-temp-buffer function) -(define-extern str-play-kick function) +(define-extern str-play-kick (function none)) ;;(define-extern load-dgo-msg object) ;; unknown type -;;(define-extern *load-dgo-rpc* object) ;; unknown type -;;(define-extern *que-str-lock* object) ;; unknown type +(define-extern *load-dgo-rpc* rpc-buffer-pair) ;; unknown type +(define-extern *que-str-lock* symbol) ;; unknown type (define-extern dgo-load-cancel function) (define-extern dgo-load-link function) ;;(define-extern *dgo-time* object) ;; unknown type ;;(define-extern dgo-header object) ;; unknown type -(define-extern str-play-async function) -(define-extern str-play-stop function) -;;(define-extern *play-str-rpc* object) ;; unknown type +(define-extern str-play-async (function string int none)) +(define-extern str-play-stop (function string none)) +(define-extern *play-str-rpc* rpc-buffer-pair) ;; unknown type (define-extern string->sound-name function) ;;(define-extern complete object) ;; unknown type ;;(define-extern busy object) ;; unknown type @@ -36486,7 +36492,7 @@ (define-extern anim-test-obj-init function) (define-extern anim-test-anim-list-handler function) (define-extern anim-tester-add-sequence function) -(define-extern anim-tester-num-print function) +(define-extern anim-tester-num-print (function symbol float none)) ;;(define-extern *anim-tester* object) ;; unknown type ;;(define-extern list-control object) ;; unknown type (define-extern anim-test-edit-seq-insert-item function) diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index bb089cc5b..ee7a99060 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -272,7 +272,10 @@ ["L27", "float", true], ["L25", "_auto_", true], ["L24", "_auto_", true] - ] + ], + + "collide-edge-grab-h":[ + ["L1", "collide-edge-work", true]] diff --git a/decompiler/config/jak1_ntsc_black_label/type_hints.jsonc b/decompiler/config/jak1_ntsc_black_label/type_hints.jsonc index 653e0cf69..2e0a46846 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_hints.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_hints.jsonc @@ -232,7 +232,37 @@ ], "(method 0 collide-shape-prim-group)":[ [11, ["v0", "collide-shape-prim-group"]] - ] + ], + + "(method 11 touching-prims-entry-pool)":[ + [5, ["a1", "(inline-array touching-prims-entry)"]]], + + "(method 0 touching-list)":[ + [6, ["v0", "touching-list"]]], + + "str-load":[ + [21, ["s2", "load-chunk-msg"]] + ], + + "str-play-async":[ + [13, ["s4", "load-chunk-msg"]] + ], + + "str-play-stop":[ + [7, ["v0", "load-chunk-msg"]] + ], + + "str-play-queue":[ + [19, ["v0", "load-chunk-msg"]] + ], + + "str-ambient-play":[ + [7, ["v0", "load-chunk-msg"]] + ], + + "str-ambient-stop":[ + [7, ["v0", "load-chunk-msg"]] + ] diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index d272b3f0c..f7e2b7d25 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -598,6 +598,9 @@ "(method 0 collide-shape)":{ "args":["allocation", "type-to-make", "proc", "collide-list-kind", "prim-id"], "vars":{"s5-0":"obj"} + }, + "(method 11 touching-prims-entry-pool)":{ + "vars":{"a1-0":"current", "v1-0":"prev", "a2-0":"next"} } diff --git a/goal_src/engine/collide/collide-cache-h.gc b/goal_src/engine/collide/collide-cache-h.gc index 34e8c835f..400d49362 100644 --- a/goal_src/engine/collide/collide-cache-h.gc +++ b/goal_src/engine/collide/collide-cache-h.gc @@ -5,3 +5,163 @@ ;; name in dgo: collide-cache-h ;; dgos: GAME, ENGINE +(deftype collide-using-spheres-params (structure) + ((spheres uint32 :offset-assert 0) + (num-spheres uint32 :offset-assert 4) + (collide-with uint64 :offset-assert 8) + (proc basic :offset-assert 16) + (ignore-pat uint32 :offset-assert 20) + (solid-only basic :offset-assert 24) + ) + :method-count-assert 9 + :size-assert #x1c + :flag-assert #x90000001c + ) + +(deftype collide-puss-sphere (structure) + ((bsphere sphere :inline :offset-assert 0) + (bbox4w bounding-box4w :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype collide-puss-work (structure) + ((closest-pt vector :inline :offset-assert 0) + (tri-normal vector :inline :offset-assert 16) + (tri-bbox4w bounding-box4w :inline :offset-assert 32) + (spheres-bbox4w bounding-box4w :inline :offset-assert 64) + (spheres collide-puss-sphere 64 :inline :offset-assert 96) + ) + :method-count-assert 11 + :size-assert #xc60 + :flag-assert #xb00000c60 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + ) + ) + +(deftype collide-puyp-work (structure) + ((best-u float :offset-assert 0) + (ignore-pat uint32 :offset-assert 4) + (tri-out collide-tri-result :offset-assert 8) + (start-pos vector :inline :offset-assert 16) + (move-dist vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + + +(deftype collide-cache-tri (structure) + ((vertex vector 3 :inline :offset-assert 0) + ;(extra-quad UNKNOWN 16 :offset-assert 48) + (pat uint32 :offset-assert 48) + (prim-index uint16 :offset-assert 52) + (user16 uint16 :offset-assert 54) + (user32 uint32 2 :offset-assert 56) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) + +(deftype collide-cache-prim (structure) + ((prim-core collide-prim-core :inline :offset-assert 0) + ;;(extra-quad UNKNOWN 16 :offset-assert 32) + (ccache basic :offset-assert 32) + (prim basic :offset-assert 36) + (first-tri uint16 :offset-assert 40) + (num-tris uint16 :offset-assert 42) + (unused uint8 4 :offset-assert 44) + (world-sphere vector :inline :offset 0) + (collide-as uint64 :offset 16) + (action uint32 :offset 24) + (offense int8 :offset 28) + (prim-type int8 :offset 29) + ) + :method-count-assert 11 + :size-assert #x30 + :flag-assert #xb00000030 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + ) + ) + +(deftype collide-cache (basic) + ((num-tris int32 :offset-assert 4) + (num-prims int32 :offset-assert 8) + (ignore-mask uint32 :offset-assert 12) + (proc basic :offset-assert 16) + (collide-box bounding-box :inline :offset-assert 32) + (collide-box4w bounding-box4w :inline :offset-assert 64) + (collide-with uint64 :offset-assert 96) + (prims collide-cache-prim 100 :inline :offset-assert 112) + (tris collide-cache-tri 461 :inline :offset-assert 4912) + ) + :method-count-assert 33 + :size-assert #x8670 + :flag-assert #x2100008670 + (: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) + ) + ) + +(deftype collide-list-item (structure) + ((mesh basic :offset-assert 0) + (inst basic :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype collide-list (structure) + ((num-items int32 :offset-assert 0) + (items collide-list-item 256 :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x1010 + :flag-assert #x900001010 + ) + +(deftype collide-work (structure) + ((collide-sphere-neg-r sphere :inline :offset-assert 0) + (collide-box4w bounding-box4w :inline :offset-assert 16) + (inv-mat matrix :inline :offset-assert 48) + ) + :method-count-assert 9 + :size-assert #x70 + :flag-assert #x900000070 + ) + +(define-perm *collide-work* collide-work (new 'global 'collide-work)) +(define-perm *collide-cache* collide-cache (new 'global 'collide-cache)) +(define-perm *collide-list* collide-list (new 'global 'collide-list)) diff --git a/goal_src/engine/collide/collide-edge-grab-h.gc b/goal_src/engine/collide/collide-edge-grab-h.gc index 0fbb23de4..d585ff76a 100644 --- a/goal_src/engine/collide/collide-edge-grab-h.gc +++ b/goal_src/engine/collide/collide-edge-grab-h.gc @@ -5,3 +5,227 @@ ;; name in dgo: collide-edge-grab-h ;; dgos: GAME, ENGINE +(deftype edge-grab-info (structure) + ((world-vertex vector 6 :inline :offset-assert 0) + (local-vertex vector 6 :inline :offset-assert 96) + (actor-cshape-prim-offset int32 :offset-assert 192) + (actor-handle uint64 :offset-assert 200) + (hanging-matrix matrix :inline :offset-assert 208) + (edge-vertex vector 2 :inline :offset 0) + (center-hold vector :inline :offset 32) + (tri-vertex vector 3 :inline :offset 48) + (left-hand-hold vector :inline :offset-assert 272) + (right-hand-hold vector :inline :offset-assert 288) + (center-hold-old vector :inline :offset-assert 304) + (edge-tri-pat uint32 :offset-assert 320) + ) + :method-count-assert 11 + :size-assert #x144 + :flag-assert #xb00000144 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + ) + ) + +(declare-type collide-cache-tri structure) +(deftype collide-edge-tri (structure) + ((ctri collide-cache-tri :offset-assert 0) + (normal vector :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype collide-edge-edge (structure) + ((ignore basic :offset-assert 0) + (etri collide-edge-tri :offset-assert 4) + (vertex-ptr vector 2 :offset-assert 8) + (outward vector :inline :offset-assert 16) + (edge-vec-norm vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype collide-edge-hold-item (structure) + ((next collide-edge-hold-item :offset-assert 0) + (rating float :offset-assert 4) + (split int8 :offset-assert 8) + (edge collide-edge-edge :offset-assert 12) + (center-pt vector :inline :offset-assert 16) + (outward-pt vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype collide-edge-hold-list (structure) + ((num-allocs uint32 :offset-assert 0) + (num-attempts uint32 :offset-assert 4) + (head collide-edge-hold-item :offset-assert 8) + (items collide-edge-hold-item 32 :inline :offset-assert 16) + (attempts qword 32 :inline :offset-assert 1552) + ) + :method-count-assert 11 + :size-assert #x810 + :flag-assert #xb00000810 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + ) + ) + +(deftype collide-edge-work (structure) + ((ccache basic :offset-assert 0) + (cshape basic :offset-assert 4) + (num-verts uint32 :offset-assert 8) + (num-edges uint32 :offset-assert 12) + (num-tris uint32 :offset-assert 16) + (cache-fill-box bounding-box :inline :offset-assert 32) + (within-reach-box bounding-box :inline :offset-assert 64) + (within-reach-box4w bounding-box4w :inline :offset-assert 96) + (search-pt vector :inline :offset-assert 128) + (search-dir-vec vector :inline :offset-assert 144) + (max-dist-sqrd-to-outward-pt float :offset-assert 160) + (max-dir-cosa-delta float :offset-assert 164) + (split-dists float 2 :offset-assert 168) + (outward-offset vector :inline :offset-assert 176) + (local-cache-fill-box bounding-box :inline :offset-assert 192) + (local-within-reach-box bounding-box :inline :offset-assert 224) + (local-player-spheres sphere 12 :inline :offset-assert 256) + (world-player-spheres sphere 12 :inline :offset-assert 448) + (local-player-hanging-spheres sphere 6 :inline :offset 256) + (world-player-hanging-spheres sphere 6 :inline :offset 448) + (local-player-leap-up-spheres sphere 6 :inline :offset 352) + (world-player-leap-up-spheres sphere 6 :inline :offset 544) + (verts vector 64 :inline :offset-assert 640) + (edges collide-edge-edge 96 :inline :offset-assert 1664) + (tris collide-edge-tri 48 :inline :offset-assert 6272) + (hold-list collide-edge-hold-list :inline :offset-assert 7808) + ) + :method-count-assert 20 + :size-assert #x2690 + :flag-assert #x1400002690 + (: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) + ) + ) + +(define *collide-edge-work* + (new 'static 'collide-edge-work + :max-dist-sqrd-to-outward-pt 37748736.000000 + :max-dir-cosa-delta (the-as float #x3f19999a) + :split-dists (new 'static 'array float 2 1024.000000 (the-as float #x44b33333)) + :outward-offset (new 'static 'vector + :x (the-as float #x443126e9) + :y 13312.000000 + :w 1.000000 + ) + :local-cache-fill-box (new 'static 'bounding-box + :min (new 'static 'vector + :x -8192.000000 + :y (the-as float #xc62ccccd) + :z -8192.000000 + :w 1.000000 + ) + :max (new 'static 'vector + :x 8192.000000 + :y 24576.000000 + :z 8192.000000 + :w 1.000000 + ) + ) + :local-within-reach-box (new 'static 'bounding-box + :min (new 'static 'vector + :x -6144.000000 + :y (the-as float #x45a66666) + :z -6144.000000 + :w 1.000000 + ) + :max (new 'static 'vector + :x 6144.000000 + :y (the-as float #x462ccccd) + :z 6144.000000 + :w 1.000000 + ) + ) + :local-player-spheres (new 'static 'inline-array sphere 12 + (new 'static 'sphere + :x (the-as float #x44d70a3d) + :y (the-as float #xc44ccccd) + :w (the-as float #x44b33333) + ) + (new 'static 'sphere + :x (the-as float #x450f5c29) + :y (the-as float #xc54ccccd) + :w (the-as float #x44eb851f) + ) + (new 'static 'sphere + :x (the-as float #x44f5c28f) + :y -6144.000000 + :w (the-as float #x44c28f5c) + ) + (new 'static 'sphere + :x (the-as float #x44f5c28f) + :y (the-as float #xc6066666) + :w (the-as float #x44c28f5c) + ) + (new 'static 'sphere + :x (the-as float #x44dc28f6) + :y (the-as float #xc62ccccd) + :w (the-as float #x44a8f5c3) + ) + (new 'static 'sphere + :x (the-as float #x44d1eb85) + :y -13312.000000 + :w (the-as float #x449eb852) + ) + (new 'static 'sphere + :x (the-as float #xc43851ec) + :y 4096.000000 + :w 3072.000000 + ) + (new 'static 'sphere + :x (the-as float #xc43851ec) + :y (the-as float #x45cccccd) + :w 3072.000000 + ) + (new 'static 'sphere + :x (the-as float #xc43851ec) + :y (the-as float #x46133333) + :w 3072.000000 + ) + (new 'static 'sphere + :x (the-as float #x44d70a3d) + :y (the-as float #x45666666) + :w (the-as float #x453851ec) + ) + (new 'static 'sphere + :x (the-as float #x44d70a3d) + :y (the-as float #x45b33333) + :w (the-as float #x453851ec) + ) + (new 'static 'sphere + :x (the-as float #x44d70a3d) + :y (the-as float #x46066666) + :w (the-as float #x453851ec) + ) + ) + ) + ) + +(define-perm *edge-grab-info* edge-grab-info (new 'global 'edge-grab-info)) diff --git a/goal_src/engine/collide/collide-h.gc b/goal_src/engine/collide/collide-h.gc index cef2ce076..676f0559b 100644 --- a/goal_src/engine/collide/collide-h.gc +++ b/goal_src/engine/collide/collide-h.gc @@ -5,3 +5,4 @@ ;; name in dgo: collide-h ;; dgos: GAME, ENGINE +(define *collide-test-flag* #f) \ No newline at end of file diff --git a/goal_src/engine/collide/collide-touch-h.gc b/goal_src/engine/collide/collide-touch-h.gc index 412520925..606889533 100644 --- a/goal_src/engine/collide/collide-touch-h.gc +++ b/goal_src/engine/collide/collide-touch-h.gc @@ -5,3 +5,158 @@ ;; name in dgo: collide-touch-h ;; dgos: GAME, ENGINE +(deftype touching-prim (structure) + ((cprim basic :offset-assert 0) + (has-tri? basic :offset-assert 4) + (tri collide-tri-result :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x64 + :flag-assert #x900000064 + ) + +(deftype touching-prims-entry (structure) + ((next touching-prims-entry :offset-assert 0) + (prev touching-prims-entry :offset-assert 4) + (allocated? basic :offset-assert 8) + (u float :offset-assert 12) + (prim1 touching-prim :inline :offset-assert 16) + (prim2 touching-prim :inline :offset-assert 128) + ) + :method-count-assert 13 + :size-assert #xe4 + :flag-assert #xd000000e4 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + ) + ) + +(deftype touching-prims-entry-pool (structure) + ((head touching-prims-entry :offset-assert 0) + (nodes touching-prims-entry 64 :inline :offset-assert 16) + ) + :method-count-assert 13 + :size-assert #x3c10 + :flag-assert #xd00003c10 + (:methods + (new (symbol type) _type_ 0) + (dummy-9 () none 9) + (dummy-10 () none 10) + (init-list! (_type_) none 11) + (dummy-12 () none 12) + ) + ) + +(defmethod init-list! touching-prims-entry-pool ((obj touching-prims-entry-pool)) + "Initialize all entries to be not allocated and in a linked list." + (local-vars + (prev touching-prims-entry) + (idx int) + (current (inline-array touching-prims-entry)) + (next touching-prims-entry) + ) + (set! prev #f) + (set! current (-> obj nodes)) + (set! (-> obj head) (-> current 0)) + (set! idx 64) + (while (nonzero? idx) + (+! idx -1) + (set! (-> current 0 prev) prev) + (set! next (-> current 1)) + (set! (-> current 0 next) next) + (set! (-> current 0 allocated?) #f) + (set! prev (-> current 0)) + (set! current (the (inline-array touching-prims-entry) next)) + ) + (set! (-> prev next) #f) + (none) + ) + +(defmethod new touching-prims-entry-pool ((allocation symbol) (type-to-make type)) + "Allocate a new touching-prims-entry-pool" + + ;; Note - the original code passed (-> type-to-make size) as an argument. + ;; however, the new method of structure doesn't have this argument. + ;; it uses the same value for the size so it doesn't really matter. + (let ((obj (the touching-prims-entry-pool ((method-of-type structure new) + allocation + type-to-make + ;; (-> type-to-make size) see note + ) + ))) + (init-list! obj) + obj + ) + ) + +(deftype touching-shapes-entry (structure) + ((cshape1 basic :offset-assert 0) + (cshape2 basic :offset-assert 4) + (resolve-u int8 :offset-assert 8) + (head touching-prims-entry :offset-assert 12) + ) + :allow-misaligned + :method-count-assert 18 + :size-assert #x10 + :flag-assert #x1200000010 + (: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) + (get-head (_type_) touching-prims-entry 16) + (unknown1 (_type_ (xx (pointer uint32))) uint 17) + ) + ) + +(deftype touching-list (structure) + ((num-touching-shapes int32 :offset-assert 0) + (resolve-u int8 :offset-assert 4) + (touching-shapes touching-shapes-entry 32 :inline :offset-assert 8) + ) + :method-count-assert 15 + :size-assert #x208 + :flag-assert #xf00000208 + (:methods + (new (symbol type) _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) + ) + ) + +(defmethod new touching-list ((allocation symbol) (type-to-make type)) + "See note in touching-prims-entry-pool" + (let ((obj (the touching-list ((method-of-type structure new) + allocation + type-to-make + ;; (-> type-to-make size) see note + ) + ))) + (set! (-> obj num-touching-shapes) 0) + (set! (-> obj resolve-u) 0) + obj + ) + ) + +(defmethod get-head touching-shapes-entry ((obj touching-shapes-entry)) + (-> obj head) + ) + +(defmethod unknown1 touching-shapes-entry ((obj touching-shapes-entry) (arg0 (pointer uint32))) + (-> arg0 0) + ) + + +(define-perm *touching-prims-entry-pool* touching-prims-entry-pool (new 'global 'touching-prims-entry-pool)) +(define-perm *touching-list* touching-list (new 'global 'touching-list)) + diff --git a/goal_src/engine/draw/draw-node-h.gc b/goal_src/engine/draw/draw-node-h.gc index 9a13d8fd5..f3ed123b3 100644 --- a/goal_src/engine/draw/draw-node-h.gc +++ b/goal_src/engine/draw/draw-node-h.gc @@ -17,7 +17,7 @@ ;; field distance is a float printed as hex? (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) diff --git a/goal_src/engine/draw/drawable-actor-h.gc b/goal_src/engine/draw/drawable-actor-h.gc index 961f3d207..9935e2224 100644 --- a/goal_src/engine/draw/drawable-actor-h.gc +++ b/goal_src/engine/draw/drawable-actor-h.gc @@ -13,7 +13,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -35,6 +35,6 @@ :flag-assert #x1200000044 ) -(defmethod dummy-10 drawable-tree-actor ((obj drawable)) +(defmethod dummy-10 drawable-tree-actor ((obj _type_)) 0 ) diff --git a/goal_src/engine/draw/drawable-ambient-h.gc b/goal_src/engine/draw/drawable-ambient-h.gc index 87d1f1a0a..41a484bc0 100644 --- a/goal_src/engine/draw/drawable-ambient-h.gc +++ b/goal_src/engine/draw/drawable-ambient-h.gc @@ -13,7 +13,7 @@ :flag-assert #x1300000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -35,7 +35,7 @@ :flag-assert #x1200000044 ) -(defmethod dummy-10 drawable-tree-ambient ((obj drawable)) +(defmethod dummy-10 drawable-tree-ambient ((obj _type_)) 0 ) diff --git a/goal_src/engine/draw/drawable-h.gc b/goal_src/engine/draw/drawable-h.gc index f11f98f36..bae4bdfde 100644 --- a/goal_src/engine/draw/drawable-h.gc +++ b/goal_src/engine/draw/drawable-h.gc @@ -16,7 +16,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -35,7 +35,7 @@ :flag-assert #x1200000024 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) diff --git a/goal_src/engine/draw/drawable-inline-array-h.gc b/goal_src/engine/draw/drawable-inline-array-h.gc index e2d5c1675..b9d9a68b8 100644 --- a/goal_src/engine/draw/drawable-inline-array-h.gc +++ b/goal_src/engine/draw/drawable-inline-array-h.gc @@ -13,7 +13,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 (drawable) int 10) + (dummy-10 (_type_) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) diff --git a/goal_src/engine/gfx/depth-cue-h.gc b/goal_src/engine/gfx/depth-cue-h.gc index 4de4e1ba3..36c64fb06 100644 --- a/goal_src/engine/gfx/depth-cue-h.gc +++ b/goal_src/engine/gfx/depth-cue-h.gc @@ -5,3 +5,31 @@ ;; name in dgo: depth-cue-h ;; dgos: GAME, ENGINE +;; depth-cue-h +(deftype depth-cue-data (structure) + ((data vector :inline :offset-assert 0) + (sharpness float :offset 0) + (alpha float :offset 4) + (distance float :offset 8) + (w float :offset 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; depth-cue-h +(deftype depth-cue-work (structure) + ((texture-strip-tmpl dma-gif-packet :inline :offset-assert 0) + (temp-strip-tmpl dma-gif-packet :inline :offset-assert 32) + (stencil-tmpl dma-gif-packet :inline :offset-assert 64) + (clear-color vector4w :inline :offset-assert 96) + (set-color vector4w :inline :offset-assert 112) + (draw-color vector4w :inline :offset-assert 128) + (depth depth-cue-data :offset-assert 144) + (front depth-cue-data :offset-assert 148) + ) + :method-count-assert 9 + :size-assert #x98 + :flag-assert #x900000098 + ) diff --git a/goal_src/engine/math/trigonometry.gc b/goal_src/engine/math/trigonometry.gc index 8b0b8e886..55bdb2862 100644 --- a/goal_src/engine/math/trigonometry.gc +++ b/goal_src/engine/math/trigonometry.gc @@ -33,12 +33,6 @@ (defconstant PI_OVER_2 (the-as float #x3fc90fda)) (defconstant TWO_PI (the-as float #x40c90fda)) -;; convert number of degrees to a rotation. -(defmacro degrees (value) - `(* (/ (the float ,value) 360.0) - 65536.0 - ) - ) (defun radmod ((arg0 float)) "Wrap arg0 to be within (-pi, pi)." diff --git a/goal_src/engine/util/types-h.gc b/goal_src/engine/util/types-h.gc index 579c00075..d619300a2 100644 --- a/goal_src/engine/util/types-h.gc +++ b/goal_src/engine/util/types-h.gc @@ -16,4 +16,40 @@ (deftype part-id (uint32) () :flag-assert #x900000004 - ) \ No newline at end of file + ) + +(defglobalconstant METER_LENGTH 4096.0) + +(defmacro meters (x) + "Convert number to meters. + If the input is a constant float or integer, the result will be a + compile time constant float. Otherwise, it will not be constant." + (cond + ((float? x) + (* METER_LENGTH x) + ) + ((integer? x) + (* METER_LENGTH x) + ) + (#t + `(* METER_LENGTH ,x) + ) + ) + ) + +(defglobalconstant DEGREES_PER_ROT 65536.0) + +(defmacro degrees (x) + "Convert number to degrees unit. + Will keep a constant float/int constant." + (cond + ((or (float? x) (integer? x)) + (* DEGREES_PER_ROT (/ (+ 0.0 x) 360.0)) + ) + (#t + `(* (/ (the float ,x) 360.0) + DEGREES_PER_ROT + ) + ) + ) + ) diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index e60565ac0..caadf79df 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -15,19 +15,18 @@ ;; BUILD SYSTEM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; compile, color, and save a file (defmacro m (file) + "Make: compile a file fully and save the result" `(asm-file ,file :color :write) ) -;; compile, color, save, and disassemble a file. -;; make "debug". (defmacro md (file) + "Make Debug: make + print disassembly for a file" `(asm-file ,file :color :write :disassemble) ) -;; compile, color, load and save a file (defmacro ml (file) + "Make Load: make and load the file through the listener" `(asm-file ,file :color :load :write) ) @@ -37,6 +36,7 @@ (defmacro build-kernel () + "Build kernel and create the KERNEL CGO" `(begin ,@(apply make-build-command all-kernel-goal-files) (build-dgos "goal_src/build/kernel_dgos.txt") @@ -44,6 +44,7 @@ ) (defmacro build-game () + "Build all game code and all game CGOs" `(begin (build-kernel) ,@(apply make-build-command all-goal-files) @@ -52,6 +53,7 @@ ) (defmacro build-data () + "Build all game data" `(begin (asm-data-file game-text "assets/game_text.txt") (asm-data-file game-count "assets/game_count.txt") @@ -59,6 +61,8 @@ ) (defmacro blg () + "Build engine and kernel CGOs (code only, no data for now) and load them in the listener + Uses the blocking dgo-load." `(begin (build-game) (dgo-load "kernel" global #xf #x200000) @@ -67,14 +71,17 @@ ) (defmacro tc () + "Typecheck against the all-types file" `(m "decompiler/config/all-types.gc") ) (defmacro e () + "Exit the compiler" `(:exit) ) (defmacro dbc () + "Put the compiler in debug mode" `(begin (set-config! print-ir #t) (set-config! print-regalloc #t) @@ -93,14 +100,12 @@ `(#cond ((not ,clause) ,@body)) ) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; TARGET CONTROL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro lt (&rest args) - ;; shortcut for listen-to-target. also sends a :status command to make sure - ;; all buffers on the target are flushed. + "Listen to target. Opens a connection and flushes buffers" `(begin (listen-to-target ,@args) (:status) @@ -108,7 +113,7 @@ ) (defmacro r (&rest args) - ;; shortcut to completely reset the target and connect, regardless of current state + "Reset the target state and reconnect." `(begin ;; connect, so we can send reset. if we're already connected, does nothing (listen-to-target ,@args) @@ -122,6 +127,7 @@ ) (defmacro shutdown-target () + "Make the target exit. The runtime itself will exit and not restart automatically." `(begin (reset-target :shutdown) ) @@ -132,30 +138,37 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro db (&rest args) + "Print bytes." `(:pm 1 ,@args) ) (defmacro dh (&rest args) + "Print halfwords (16-bits)" `(:pm 2 ,@args) ) (defmacro dw (&rest args) + "Print words (32-bits)" `(:pm 4 ,@args) ) (defmacro dd (&rest args) + "Print doublewords (64-bits)" `(:pm 8 ,@args) ) (defmacro df (&rest args) + "Print floats (32-bit)" `(:pm 4 ,@args :print-mode float) ) (defmacro segfault () + "Dereference the GOAL 0 pointer, which should be a segfault" `(-> (the (pointer int) 0)) ) (defmacro fpe () + "Trigger a SIGFPE by doing integer division by zero" `(/ 0 0) ) @@ -195,9 +208,8 @@ `(define-extern ,function-name (function ,@type-info)) ) -;; Define a new function, but only if we're debugging. -;; TODO - should place the function in the debug segment! (defmacro defun-debug (name bindings &rest body) + "Define a function which is only present in debug mode. Otherwise the function becomes nothing" `(if *debug-segment* ,(if (and (> (length body) 1) ;; more than one thing in function @@ -215,7 +227,20 @@ ) ) +(defmacro define-perm (name type value) + "Define 'permanent', meaning the original definition will not be blown away by a file reload. + If the value of the symbol is unset (zero) or set to false, it will be defined. + Otherwise, no effect, other than to inform the type system of the symbol type." + `(begin + (define-extern ,name ,type) + (if (or (not ,name) (zero? ,name)) + (set! ,name ,value) + ) + ) + ) + (defmacro while (test &rest body) + "While loop. The test is evaluated before body." (with-gensyms (reloop test-exit) `(begin (goto ,test-exit) @@ -229,6 +254,7 @@ ) (defmacro until (test &rest body) + "Until loop. The body is evaluated before the test." (with-gensyms (reloop) `(begin (label ,reloop) @@ -239,6 +265,7 @@ ) (defmacro dotimes (var &rest body) + "Loop like for (int i = 0; i < end; i++)" `(let (( ,(first var) 0)) (while (< ,(first var) ,(second var)) ,@body @@ -249,6 +276,7 @@ ) (defmacro countdown (var &rest body) + "Loop like for (int i = end; i-- > 0)" `(let ((,(first var) ,(second var))) (while (!= ,(first var) 0) (set! ,(first var) (- ,(first var) 1)) @@ -280,10 +308,6 @@ ) ) -(defmacro +! (place amount) - `(set! ,place (+ ,place ,amount)) - ) - (defmacro if (condition true-case &rest others) (if (> (length others) 1) (error "got too many arguments to if") @@ -439,6 +463,7 @@ ;; todo, make this better `(eq? ,arg '()) ) + (defmacro caar (arg) `(car (car ,arg)) ) @@ -487,19 +512,6 @@ ) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Decompiler Macros -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defmacro <.si (a b) - `(< (the-as int ,a) (the-as int ,b)) - ) - -(defmacro <0.si (a) - `(< (the-as int ,a) (the-as int 0)) - ) - - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (Fake) MIPS Macros ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/goos-lib.gs b/goal_src/goos-lib.gs index a3aaa8e8c..000395210 100644 --- a/goal_src/goos-lib.gs +++ b/goal_src/goos-lib.gs @@ -125,7 +125,15 @@ (defsmacro string? (x) - `(type? 'string ,x)) + `(type? 'string ,x)) + +(defsmacro float? (x) + `(type? 'float ,x) + ) + +(defsmacro integer? (x) + `(type? 'integer ,x) + ) (defsmacro ferror (&rest args) `(error (fmt #f ,@args)) @@ -159,4 +167,4 @@ ) ;; this is checked in a test to see if this file is loaded. -(define __goos-lib-loaded__ #t) \ No newline at end of file +(define __goos-lib-loaded__ #t) diff --git a/goal_src/kernel/gkernel.gc b/goal_src/kernel/gkernel.gc index 5725a0f2d..6347cc91e 100644 --- a/goal_src/kernel/gkernel.gc +++ b/goal_src/kernel/gkernel.gc @@ -13,7 +13,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; HACK ADDED -(define *use-old-listener-print* #t) +(define *use-old-listener-print* #f) ;; Set version number symbols (define *kernel-version* (the binteger (logior (ash *kernel-major-version* 16) *kernel-minor-version*))) diff --git a/goalc/CMakeLists.txt b/goalc/CMakeLists.txt index 9a50cf815..ce8439939 100644 --- a/goalc/CMakeLists.txt +++ b/goalc/CMakeLists.txt @@ -44,6 +44,12 @@ if(WIN32) target_link_libraries(compiler mman) endif() +if(UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") +elseif(WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2") +endif() + add_executable(goalc main.cpp) target_link_libraries(goalc common Zydis compiler) diff --git a/test/goalc/source_templates/with_game/test-build-game.gc b/test/goalc/source_templates/with_game/test-build-game.gc index 133b41135..2900ed218 100644 --- a/test/goalc/source_templates/with_game/test-build-game.gc +++ b/test/goalc/source_templates/with_game/test-build-game.gc @@ -1,2 +1,2 @@ (build-game) -1 \ No newline at end of file +1 diff --git a/test/goalc/source_templates/with_game/test-load-game.gc b/test/goalc/source_templates/with_game/test-load-game.gc index 7937cbd9f..e6d8101c4 100644 --- a/test/goalc/source_templates/with_game/test-load-game.gc +++ b/test/goalc/source_templates/with_game/test-load-game.gc @@ -1,2 +1,3 @@ +(set! *use-old-listener-print* #t) (dgo-load "kernel" global #xf #x200000) ; todo, remove once kernel loads itself. -(dgo-load "game" global #xf #x200000) \ No newline at end of file +(dgo-load "game" global #xf #x200000) diff --git a/test/goalc/test_game_no_debug.cpp b/test/goalc/test_game_no_debug.cpp index f0e0d3a66..245b6d0c9 100644 --- a/test/goalc/test_game_no_debug.cpp +++ b/test/goalc/test_game_no_debug.cpp @@ -9,6 +9,8 @@ TEST(GameNoDebugSegment, Init) { compiler.run_front_end_on_string("(build-kernel)"); std::thread runtime_thread = std::thread(GoalTest::runtime_with_kernel_no_debug_segment); + compiler.run_test_from_string("(set! *use-old-listener-print* #t)"); + // this shouldn't crash compiler.run_test_from_string("(inspect *kernel-context*)"); diff --git a/test/goalc/test_goal_kernel.cpp b/test/goalc/test_goal_kernel.cpp index 6c9038003..1a528d238 100644 --- a/test/goalc/test_goal_kernel.cpp +++ b/test/goalc/test_goal_kernel.cpp @@ -18,6 +18,7 @@ class KernelTest : public testing::Test { printf("Starting GOAL Kernel...\n"); runtime_thread = std::thread(GoalTest::runtime_with_kernel); runner.c = &compiler; + compiler.run_test_from_string("(set! *use-old-listener-print* #t)"); } static void TearDownTestSuite() { diff --git a/test/goalc/test_with_game.cpp b/test/goalc/test_with_game.cpp index 418c0b3ba..c3392e795 100644 --- a/test/goalc/test_with_game.cpp +++ b/test/goalc/test_with_game.cpp @@ -34,6 +34,7 @@ class WithGameTests : public ::testing::Test { runner.c = &compiler; compiler.run_test_from_file("test/goalc/source_templates/with_game/test-load-game.gc"); + compiler.run_test_from_string("(set! *use-old-listener-print* #t)"); } static void TearDownTestSuite() { @@ -61,6 +62,53 @@ std::thread WithGameTests::runtime_thread; Compiler WithGameTests::compiler; GoalTest::CompilerTestRunner WithGameTests::runner; +class WithMinimalGameTests : public ::testing::Test { + public: + static void SetUpTestSuite() { + try { + compiler.run_front_end_on_string("(build-kernel)"); + } catch (std::exception& e) { + fprintf(stderr, "caught exception %s\n", e.what()); + EXPECT_TRUE(false); + } + runtime_thread = std::thread((GoalTest::runtime_with_kernel)); + runner.c = &compiler; + + compiler.run_test_from_string("(dgo-load \"kernel\" global #xf #x200000)"); + + const auto minimal_files = {"goal_src/engine/math/vector-h.gc"}; + for (auto& file : minimal_files) { + compiler.run_test_from_string(fmt::format("(ml \"{}\")", file)); + } + + compiler.run_test_from_string("(set! *use-old-listener-print* #t)"); + } + + static void TearDownTestSuite() { + compiler.shutdown_target(); + runtime_thread.join(); + } + + void SetUp() { + GoalTest::createDirIfAbsent(GoalTest::getTemplateDir(testCategory)); + GoalTest::createDirIfAbsent(GoalTest::getGeneratedDir(testCategory)); + } + + void TearDown() {} + + static std::thread runtime_thread; + static Compiler compiler; + static GoalTest::CompilerTestRunner runner; + + std::string testCategory = "with_game"; + inja::Environment env{GoalTest::getTemplateDir(testCategory), + GoalTest::getGeneratedDir(testCategory)}; +}; + +std::thread WithMinimalGameTests::runtime_thread; +Compiler WithMinimalGameTests::compiler; +GoalTest::CompilerTestRunner WithMinimalGameTests::runner; + namespace { std::vector get_test_pass_string(const std::string& name, int count) { return {fmt::format("Test \"{}\": {} Passes\n0\n", name, count)}; @@ -650,7 +698,7 @@ std::vector vectorMathCaseGen_TwoOperand() { } class VectorFloatParameterizedTestFixtureWithRunner_TwoOperand - : public WithGameTests, + : public WithMinimalGameTests, public ::testing::WithParamInterface { protected: std::string templateFile = "test-vector-math-2-operand.template.gc"; @@ -778,7 +826,7 @@ std::vector vectorMathCaseGen_SingleOperand_N } class VectorFloatParameterizedTestFixtureWithRunner_SingleOperand - : public WithGameTests, + : public WithMinimalGameTests, public ::testing::WithParamInterface { protected: std::string templateFile = "test-vector-math-1-operand.template.gc"; @@ -863,7 +911,7 @@ std::vector vectorMathCaseGen_TwoOperandACC() } class VectorFloatParameterizedTestFixtureWithRunner_TwoOperandACC - : public WithGameTests, + : public WithMinimalGameTests, public ::testing::WithParamInterface { protected: std::string templateFile = "test-vector-math-2-operand-acc.template.gc"; @@ -950,7 +998,7 @@ std::vector vectorMathCaseGen_TwoOperand } class VectorFloatParameterizedTestFixtureWithRunner_TwoOperandQuotient - : public WithGameTests, + : public WithMinimalGameTests, public ::testing::WithParamInterface { protected: std::string templateFile = "test-vector-math-division.template.gc"; @@ -1014,7 +1062,7 @@ std::vector vectorMathCaseGen_OneOperand } class VectorFloatParameterizedTestFixtureWithRunner_OneOperandQuotient - : public WithGameTests, + : public WithMinimalGameTests, public ::testing::WithParamInterface { protected: std::string templateFile = "test-vector-math-sqrt.template.gc";