From b7f040986eeb3093e5f52f5922b44a4fc749b59f Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Fri, 26 Feb 2021 22:22:54 -0500 Subject: [PATCH] [Decomp] Decompile connect.gc (#288) * decompile connect * decompile lots of types --- decompiler/analysis/expression_build.cpp | 4 +- decompiler/config/all-types.gc | 315 ++++++---- .../jak1_ntsc_black_label/label_types.jsonc | 5 +- .../jak1_ntsc_black_label/type_hints.jsonc | 22 +- .../jak1_ntsc_black_label/var_names.jsonc | 15 + goal_src/engine/anim/mspace-h.gc | 81 +++ goal_src/engine/debug/memory-usage-h.gc | 29 + goal_src/engine/draw/draw-node-h.gc | 32 + goal_src/engine/draw/drawable-actor-h.gc | 33 + goal_src/engine/draw/drawable-ambient-h.gc | 82 +++ goal_src/engine/draw/drawable-group-h.gc | 7 + goal_src/engine/draw/drawable-h.gc | 40 ++ .../engine/draw/drawable-inline-array-h.gc | 18 + goal_src/engine/draw/drawable-tree-h.gc | 9 + goal_src/engine/engine/connect.gc | 564 ++++++++++++++++++ goal_src/engine/game/settings-h.gc | 135 +++++ goal_src/engine/game/task/game-task-h.gc | 1 + goal_src/engine/game/task/hint-control-h.gc | 31 + goal_src/engine/gfx/generic/generic-h.gc | 251 ++++++++ goal_src/engine/gfx/hw/display-h.gc | 2 + goal_src/engine/gfx/lights-h.gc | 102 ++++ goal_src/engine/gfx/ocean/ocean-h.gc | 406 +++++++++++++ goal_src/engine/ui/text-h.gc | 2 +- goal_src/kernel-defs.gc | 2 +- goal_src/kernel/gkernel.gc | 2 +- 25 files changed, 2055 insertions(+), 135 deletions(-) diff --git a/decompiler/analysis/expression_build.cpp b/decompiler/analysis/expression_build.cpp index 3c3a9cf42..450019aec 100644 --- a/decompiler/analysis/expression_build.cpp +++ b/decompiler/analysis/expression_build.cpp @@ -84,7 +84,9 @@ bool convert_to_expressions(Form* top_level_form, } else { new_entries = stack.rewrite(pool, f.ir2.env); } - assert(!new_entries.empty()); + if (new_entries.empty()) { + new_entries.push_back(pool.alloc_element()); + } top_level_form->clear(); for (auto x : new_entries) { top_level_form->push_back(x); diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index ac726ab05..503f3377b 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -60,6 +60,9 @@ (define-extern file-stream-length (function file-stream int)) (define-extern file-stream-read (function file-stream pointer int int)) +(define-extern kmalloc (function kheap int int string pointer)) +(define-extern global kheap) + (define-extern dma-sync (function pointer int int int)) (define-extern flush-cache (function int none)) @@ -520,7 +523,7 @@ (define-extern set-to-run (function cpu-thread function object object object object object object pointer)) (define-extern set-to-run-bootstrap (function none)) (define-extern entity-deactivate-handler (function process object none)) -(define-extern process-disconnect (function object none)) + (define-extern stack-frame type) (define-extern state type) @@ -3940,8 +3943,9 @@ :flag-assert #x900000010 ) +(declare-type engine basic) (deftype connection (connectable) - ((param0 basic :offset-assert 16) + ((param0 (function object object object object object) :offset-assert 16) (param1 basic :offset-assert 20) (param2 basic :offset-assert 24) (param3 basic :offset-assert 28) @@ -3952,38 +3956,53 @@ :flag-assert #xe00000020 ;; field param1 is a basic loaded with a signed load field param2 is a basic loaded with a signed load field param3 is a basic loaded with a signed load (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 () none 13) + (print (connection) _type_ 2) + (get-engine (connection) engine 9) + (get-process (connection) process 10) + (belongs-to-engine? (connection engine) symbol 11) + (belongs-to-process? (connection process) symbol 12) + (move-to-dead (connection) connection 13) ) ) -; ;; connect -; (deftype engine (basic) -; () -; :method-count-assert 24 -; :size-assert #x80 -; :flag-assert #x1800000080 -; (: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) -; ) -; ) +;; connect +(deftype engine (basic) + ((name basic :offset-assert 4) + (length int16 :offset-assert 8) ;; in use elts of the data array + (allocated-length int16 :offset-assert 10) ;; size of the data array + (engine-time uint64 :offset-assert 16) ;; frame that we last executed + + ;; terminating nodes for the next0/prev0 linked lists + (alive-list connectable :inline :offset-assert 32) + (alive-list-end connectable :inline :offset-assert 48) + (dead-list connectable :inline :offset-assert 64) + (dead-list-end connectable :inline :offset-assert 80) + + ;; storage for nodes. this is dynamically sized. + (data connection 1 :inline :offset-assert 96) + ) + :method-count-assert 24 + :size-assert #x80 + :flag-assert #x1800000080 + (:methods + (new (symbol type basic int) _type_ 0) + (inspect-all-connections (engine) none 9) + (apply-to-connections (engine (xx (function connectable none))) none 10) + (apply-to-connections-reverse (engine (xx (function connectable none))) none 11) + (execute-connections (engine object) none 12) + (execute-connections-and-move-to-dead (engine object) none 13) + (execute-connections-if-needed (engine object) none 14) + (add-connection (engine process (xx (function object object object object object)) object object object) connection 15) + (remove-from-process (engine process) none 16) + (remove-matching (engine (xx (function connection engine symbol))) none 17) + (remove-all (engine) none 18) + (remove-by-param1 (engine object) none 19) + (remove-by-param2 (engine int) none 20) + (get-first-connectable (engine) connectable 21) + (get-last-connectable (engine) connectable 22) + (unknown-1 (engine (xx (pointer uint32))) uint 23) + ) + ) ;;;;;;;;;;;;;;;; ;; text-h @@ -4031,11 +4050,11 @@ (screeny int32 :offset-assert 36) (vibration basic :offset-assert 40) (play-hints basic :offset-assert 44) - (movie basic :offset-assert 48) ;; special print - (talking basic :offset-assert 52) ;; special print - (spooling basic :offset-assert 56) ;; special print - (hint basic :offset-assert 60) ;; special print - (ambient basic :offset-assert 64) ;; special print + (movie (pointer process) :offset-assert 48) ;; special print + (talking (pointer process) :offset-assert 52) ;; special print + (spooling (pointer process) :offset-assert 56) ;; special print + (hint (pointer process) :offset-assert 60) ;; special print + (ambient (pointer process) :offset-assert 64) ;; special print (video-mode basic :offset-assert 68) (aspect-ratio basic :offset-assert 72) (sound-flava uint8 :offset-assert 76) @@ -4073,12 +4092,13 @@ ((current setting-data :inline :offset-assert 16) (target setting-data :inline :offset-assert 224) (default setting-data :inline :offset-assert 432) - (engine basic :offset-assert 628) + (engine engine :offset-assert 628) ) :method-count-assert 14 :size-assert #x278 :flag-assert #xe00000278 (:methods + (new (symbol type int) _type_ 0) (dummy-9 () none 9) (dummy-10 () none 10) (dummy-11 () none 11) @@ -4127,6 +4147,10 @@ :flag-assert #x900000070 ) +(define-extern store-image function) +;;(define-extern gs-store-image-packet object) ;; unknown type +(define-extern gs-set-default-store-image (function gs-store-image-packet int int int int int int int int)) + ;;;;;;;;;;;;;;;;;; ;; memory-usage-h ;;;;;;;;;;;;;;;;;; @@ -4207,7 +4231,7 @@ (deftype joint (basic) ((name basic :offset-assert 4) (number int32 :offset-assert 8) - (parent basic :offset-assert 12) + (parent joint :offset-assert 12) (bind-pose matrix :inline :offset-assert 16) ) :method-count-assert 9 @@ -4250,7 +4274,7 @@ ;; mspace-h (deftype cspace (structure) ((parent cspace :offset-assert 0) - (joint basic :offset-assert 4) + (joint joint :offset-assert 4) (joint-num int16 :offset-assert 8) (geo basic :offset-assert 12) (bone bone :offset-assert 16) @@ -4289,7 +4313,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4309,7 +4333,7 @@ :flag-assert #x1200000024 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4320,6 +4344,11 @@ ) ) +(deftype drawable-group (drawable) + ((pad uint8 4)) + :flag-assert #x1200000024 + ) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-inline-array-h ;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -4332,7 +4361,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4359,7 +4388,7 @@ ;; field distance is a float printed as hex? (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4370,15 +4399,25 @@ ) ) -; ;; draw-node-h -; (deftype draw-node-dma (structure) -; ((banka UNKNOWN 32 :offset-assert 4) -; (bankb UNKNOWN 32 :offset-assert 1028) -; ) -; :method-count-assert 9 -; :size-assert #x800 -; :flag-assert #x900000800 -; ) +;; draw-node-h +(deftype draw-node-dma (structure) + ((banka draw-node 32 :inline :offset-assert 0) + (bankb draw-node 32 :inline :offset-assert 1024) + ) + :method-count-assert 9 + :size-assert #x800 + :flag-assert #x900000800 + ) + +(deftype drawable-tree (drawable-group) + () + :flag-assert #x1200000024 + ) + +(deftype drawable-tree-array (drawable-group) + () + :flag-assert #x1200000024 + ) ;;;;;;;;;;;;;;;;;;;;; ;; drawable-actor-h @@ -4392,7 +4431,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4403,6 +4442,16 @@ ) ) +(deftype drawable-tree-actor (drawable-tree) + () + :flag-assert #x1200000024 + ) + +(deftype drawable-inline-array-actor (drawable-inline-array) + ((paid uint8 36)) + :flag-assert #x1200000044 + ) + ;;;;;;;;;;;;;;;;;;;;;; ;; drawable-ambient-h ;;;;;;;;;;;;;;;;;;;;;; @@ -4416,7 +4465,7 @@ :flag-assert #x1300000020 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -4428,6 +4477,16 @@ ) ) +(deftype drawable-tree-ambient (drawable-tree) + () + :flag-assert #x1200000024 + ) + +(deftype drawable-inline-array-ambient (drawable-inline-array) + ((paid uint8 36)) + :flag-assert #x1200000044 + ) + ;; drawable-ambient-h (deftype level-hint (process) ((text-id-to-display uint32 :offset-assert 112) @@ -4527,13 +4586,13 @@ ) ; ;; generic-h -; (deftype gsf-vertex-array (UNKNOWN) -; ((vtx UNKNOWN :dynamic :offset-assert 0) -; ) -; :method-count-assert 0 -; :size-assert #x0 -; :flag-assert #x0 -; ) +(deftype gsf-vertex-array (structure) + ((vtx gsf-vertex :dynamic :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x0 + :flag-assert #x900000000 + ) ; ;; generic-h (deftype gsf-fx-vertex (structure) @@ -4546,14 +4605,14 @@ ) -; ;; generic-h -; (deftype gsf-fx-vertex-array (UNKNOWN) -; ((data UNKNOWN :dynamic :offset-assert 0) -; ) -; :method-count-assert 0 -; :size-assert #x0 -; :flag-assert #x0 -; ) +;; generic-h +(deftype gsf-fx-vertex-array (structure) + ((data gsf-fx-vertex :dynamic :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x0 + :flag-assert #x900000000 + ) ; ;; generic-h (deftype gsf-header (structure) @@ -4844,17 +4903,13 @@ :flag-assert #x90000000c ) -;; todo -; (deftype light-volume-array (array) -; ((type basic :offset-assert 0) -; (length int32 :offset-assert 4) -; (allocated-length int32 :offset-assert 8) -; (content-type basic :offset-assert 12) -; ) -; :method-count-assert 9 -; :size-assert #x10 -; :flag-assert #x900000010 -; ) +; todo +(deftype light-volume-array (array) + () + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) ;; lights-h (deftype light-group (structure) @@ -4953,6 +5008,7 @@ (deftype ocean-mid-masks (basic) ((data uint32 :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 @@ -4963,6 +5019,7 @@ ((mask uint16 4 :offset-assert 0) (word uint64 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 @@ -4973,6 +5030,7 @@ ((parent int16 :offset-assert 0) (child int16 :offset-assert 2) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -5060,47 +5118,47 @@ :flag-assert #x900000400 ) -; ;; ocean-h -; (deftype ocean-wave-frames (structure) -; ((frame UNKNOWN 64 :offset-assert 0) -; ) -; :method-count-assert 9 -; :size-assert #x0 -; :flag-assert #x900010000 -; ) +;; ocean-h +(deftype ocean-wave-frames (structure) + ((frame ocean-wave-data 64 :inline :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x10000 + ;:flag-assert #x900010000 + ) -; ;; ocean-h -; (deftype ocean-work (basic) -; ((deltas vector :inline :offset-assert 16) -; (map-min vector :inline :offset-assert 32) -; (map-max vector :inline :offset-assert 48) -; (interp vector :inline :offset-assert 64) -; (corner-array UNKNOWN 25 :offset-assert 80) -; (corner-count int32 :offset-assert 2080) -; (temp-vecs UNKNOWN 4 :offset-assert 2096) -; (mid-mask-ptrs UNKNOWN 36 :offset-assert 2160) -; (mid-camera-masks UNKNOWN 36 :offset-assert 2304) -; (trans-mask-ptrs UNKNOWN 64 :offset-assert 2592) -; (trans-camera-masks UNKNOWN 16 :offset-assert 2848) -; (trans-temp-masks UNKNOWN 16 :offset-assert 2976) -; (near-mask-indices UNKNOWN 16 :offset-assert 3104) -; (mid-minx uint8 :offset-assert 3136) -; (mid-maxx uint8 :offset-assert 3137) -; (mid-minz uint8 :offset-assert 3138) -; (mid-maxz uint8 :offset-assert 3139) -; (near-minx uint8 :offset-assert 3140) -; (near-maxx uint8 :offset-assert 3141) -; (near-minz uint8 :offset-assert 3142) -; (near-maxz uint8 :offset-assert 3143) -; (temp-minx uint8 :offset-assert 3144) -; (temp-maxx uint8 :offset-assert 3145) -; (temp-minz uint8 :offset-assert 3146) -; (temp-maxz uint8 :offset-assert 3147) -; ) -; :method-count-assert 9 -; :size-assert #xc4c -; :flag-assert #x900000c4c -; ) +;; ocean-h +(deftype ocean-work (basic) + ((deltas vector :inline :offset-assert 16) + (map-min vector :inline :offset-assert 32) + (map-max vector :inline :offset-assert 48) + (interp vector :inline :offset-assert 64) + (corner-array ocean-corner 25 :inline :offset-assert 80) + (corner-count int32 :offset-assert 2080) + (temp-vecs vector 4 :inline :offset-assert 2096) + (mid-mask-ptrs pointer 36 :offset-assert 2160) + (mid-camera-masks ocean-mid-masks 36 :inline :offset-assert 2304) + (trans-mask-ptrs pointer 64 :offset-assert 2592) + (trans-camera-masks ocean-trans-mask 16 :inline :offset-assert 2848) + (trans-temp-masks ocean-trans-mask 16 :inline :offset-assert 2976) + (near-mask-indices uint16 16 :offset-assert 3104) + (mid-minx uint8 :offset-assert 3136) + (mid-maxx uint8 :offset-assert 3137) + (mid-minz uint8 :offset-assert 3138) + (mid-maxz uint8 :offset-assert 3139) + (near-minx uint8 :offset-assert 3140) + (near-maxx uint8 :offset-assert 3141) + (near-minz uint8 :offset-assert 3142) + (near-maxz uint8 :offset-assert 3143) + (temp-minx uint8 :offset-assert 3144) + (temp-maxx uint8 :offset-assert 3145) + (temp-minz uint8 :offset-assert 3146) + (temp-maxz uint8 :offset-assert 3147) + ) + :method-count-assert 9 + :size-assert #xc4c + :flag-assert #x900000c4c + ) ;; ocean-h (deftype ocean-vu0-work (structure) @@ -7300,7 +7358,7 @@ :flag-assert #x1200000040 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -9845,7 +9903,7 @@ :flag-assert #x1200000070 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -9894,7 +9952,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -9916,7 +9974,7 @@ :flag-assert #x1200000050 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -9945,7 +10003,7 @@ :flag-assert #x1200000020 (:methods (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-10 (drawable) int 10) (dummy-11 () none 11) (dummy-12 () none 12) (dummy-13 () none 13) @@ -32622,7 +32680,8 @@ ;;(define-extern end-calc object) ;; unknown type ;;(define-extern engine object) ;; unknown type ;;(define-extern connectable object) ;; unknown type -(define-extern connection-process-apply function) +(define-extern connection-process-apply (function process (function object none) symbol)) +(define-extern process-disconnect (function process int)) ;;(define-extern connection object) ;; unknown type ;;(define-extern *common-text* object) ;; unknown type ;;(define-extern *common-text-heap* object) ;; unknown type @@ -32633,9 +32692,7 @@ ;;(define-extern scf-time object) ;; unknown type ;;(define-extern setting-data object) ;; unknown type ;;(define-extern setting-control object) ;; unknown type -(define-extern store-image function) -;;(define-extern gs-store-image-packet object) ;; unknown type -(define-extern gs-set-default-store-image function) + ;;(define-extern file-stream-close object) ;; unknown type ;;(define-extern file-stream-write object) ;; unknown type ;;(define-extern write object) ;; unknown type diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index a3e97cd9f..54da23d9d 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -139,6 +139,9 @@ ["L46", "float", true], ["L50", "float", true], ["L49", "float", true] - ] + ], + + "text-h":[ + ["L2", "_auto_", true]] } \ No newline at end of file diff --git a/decompiler/config/jak1_ntsc_black_label/type_hints.jsonc b/decompiler/config/jak1_ntsc_black_label/type_hints.jsonc index eca947daa..6e87fc560 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_hints.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_hints.jsonc @@ -200,8 +200,28 @@ "move-target-from-pad":[ [2, ["sp", "int"]], [3, ["s4", "vector"]] - ] + ], + "(method 0 engine)":[ + [39, ["v0", "int"]], + [40, ["v0", "engine"]] + ], + + "(method 12 engine)":[ + [7, ["s4", "connection"]] + ], + + "(method 13 engine)":[ + [7, ["s4", "connection"]] + ], + + "(method 15 engine)":[ + [6, ["v1", "connection"]]], + + "(method 19 engine)":[ + [8, ["a0", "connection"]]], + "(method 20 engine)":[ + [8, ["a0", "connection"]]] diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index 7d618d096..3e1a76028 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -556,6 +556,21 @@ } + }, + + "(method 0 engine)":{ + "args":["allocation", "type-to-make", "name", "length"], + "vars":{"v0-0":"obj", "v1-11":"idx-to-link", "a0-1":"end-idx"} + }, + + "connection-process-apply":{ + "args":["proc", "func"], + "vars":{"s5-0":"iter"} + }, + + "(method 15 engine)":{ + "args":["obj", "proc", "func", "p1", "p2", "p3"], + "vars":{"v1-0":"con"} } diff --git a/goal_src/engine/anim/mspace-h.gc b/goal_src/engine/anim/mspace-h.gc index 32db60f61..47b10fee7 100644 --- a/goal_src/engine/anim/mspace-h.gc +++ b/goal_src/engine/anim/mspace-h.gc @@ -5,3 +5,84 @@ ;; name in dgo: mspace-h ;; dgos: GAME, ENGINE +(deftype joint (basic) + ((name basic :offset-assert 4) + (number int32 :offset-assert 8) + (parent joint :offset-assert 12) + (bind-pose matrix :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + +(deftype bone-cache (structure) + ((bone-matrix uint32 :offset-assert 0) + (parent-matrix uint32 :offset-assert 4) + (dummy uint32 :offset-assert 8) + (frame uint32 :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype bone (structure) + ((transform matrix :inline :offset-assert 0) + (position vector :inline :offset 48) ;; overlays the matrix + (scale vector :inline :offset-assert 64) + (cache bone-cache :inline :offset-assert 80) + ) + :method-count-assert 9 + :size-assert #x60 + :flag-assert #x900000060 + ) + +(deftype skeleton (inline-array-class) + () + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) +(set! (-> skeleton heap-base) 96) + +(deftype cspace (structure) + ((parent cspace :offset-assert 0) + (joint joint :offset-assert 4) + (joint-num int16 :offset-assert 8) + (geo basic :offset-assert 12) + (bone bone :offset-assert 16) + (param0 basic :offset-assert 20) + (param1 basic :offset-assert 24) + (param2 basic :offset-assert 28) + ) + :method-count-assert 10 + :size-assert #x20 + :flag-assert #xa00000020 + ;; params are loaded with signed loads. + (:methods + (dummy-9 () none 9) + ) + ) + +(deftype cspace-array (inline-array-class) + () + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) +(set! (-> cspace-array heap-base) 32) + + +(defmethod print cspace ((obj cspace)) + "Print a cspace, with the attached joint" + (format #t "#" + (if (-> obj joint) + (-> obj joint name) + "nojoint") + obj + ) + obj + ) + + diff --git a/goal_src/engine/debug/memory-usage-h.gc b/goal_src/engine/debug/memory-usage-h.gc index 08f7f123f..194153f17 100644 --- a/goal_src/engine/debug/memory-usage-h.gc +++ b/goal_src/engine/debug/memory-usage-h.gc @@ -5,3 +5,32 @@ ;; name in dgo: memory-usage-h ;; dgos: GAME, ENGINE +(deftype memory-usage-info (structure) + ((name basic :offset-assert 0) + (count int32 :offset-assert 4) + (used int32 :offset-assert 8) + (total int32 :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype memory-usage-block (basic) + ((work-bsp basic :offset-assert 4) + (length int32 :offset-assert 8) + (data memory-usage-info 109 :inline :offset-assert 16) ;; guess + ) + :method-count-assert 12 + :size-assert #x6e0 + :flag-assert #xc000006e0 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + ) + ) + +(define *mem-usage* (new 'debug 'memory-usage-block)) +(define *dma-mem-usage* (new 'debug 'memory-usage-block)) +(define *temp-mem-usage* #f) diff --git a/goal_src/engine/draw/draw-node-h.gc b/goal_src/engine/draw/draw-node-h.gc index 6aca05a60..9a13d8fd5 100644 --- a/goal_src/engine/draw/draw-node-h.gc +++ b/goal_src/engine/draw/draw-node-h.gc @@ -5,3 +5,35 @@ ;; name in dgo: draw-node-h ;; dgos: GAME, ENGINE +(deftype draw-node (drawable) + ((child-count uint8 :offset 6) + (flags uint8 :offset 7) + (child uint32 :offset 8) + (distance float :offset 12) + ) + :method-count-assert 18 + :size-assert #x20 + :flag-assert #x1200000020 + ;; field distance is a float printed as hex? + (:methods + (dummy-9 () none 9) + (dummy-10 (drawable) int 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) + ) + ) + +;; the types of these fields are a guess for now. +(deftype draw-node-dma (structure) + ((banka draw-node 32 :inline :offset-assert 0) + (bankb draw-node 32 :inline :offset-assert 1024) + ) + :method-count-assert 9 + :size-assert #x800 + :flag-assert #x900000800 + ) diff --git a/goal_src/engine/draw/drawable-actor-h.gc b/goal_src/engine/draw/drawable-actor-h.gc index c91ffd444..961f3d207 100644 --- a/goal_src/engine/draw/drawable-actor-h.gc +++ b/goal_src/engine/draw/drawable-actor-h.gc @@ -5,3 +5,36 @@ ;; name in dgo: drawable-actor-h ;; dgos: GAME, ENGINE +(deftype drawable-actor (drawable) + ((actor basic :offset 8) + ) + :method-count-assert 18 + :size-assert #x20 + :flag-assert #x1200000020 + (:methods + (dummy-9 () none 9) + (dummy-10 (drawable) int 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) + ) + ) + + +(deftype drawable-tree-actor (drawable-tree) + () + :flag-assert #x1200000024 + ) + +(deftype drawable-inline-array-actor (drawable-inline-array) + ((paid uint8 36)) + :flag-assert #x1200000044 + ) + +(defmethod dummy-10 drawable-tree-actor ((obj drawable)) + 0 + ) diff --git a/goal_src/engine/draw/drawable-ambient-h.gc b/goal_src/engine/draw/drawable-ambient-h.gc index 11a122a25..87d1f1a0a 100644 --- a/goal_src/engine/draw/drawable-ambient-h.gc +++ b/goal_src/engine/draw/drawable-ambient-h.gc @@ -5,3 +5,85 @@ ;; name in dgo: drawable-ambient-h ;; dgos: GAME, ENGINE +(deftype drawable-ambient (drawable) + ((ambient basic :offset 8) + ) + :method-count-assert 19 + :size-assert #x20 + :flag-assert #x1300000020 + (:methods + (dummy-9 () none 9) + (dummy-10 (drawable) int 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) + ) + ) + +(deftype drawable-tree-ambient (drawable-tree) + () + :flag-assert #x1200000024 + ) + +(deftype drawable-inline-array-ambient (drawable-inline-array) + ((paid uint8 36)) + :flag-assert #x1200000044 + ) + +(defmethod dummy-10 drawable-tree-ambient ((obj drawable)) + 0 + ) + +;; TODO dummy-16 + +(deftype level-hint (process) + ((text-id-to-display uint32 :offset-assert 112) + (sound-to-play basic :offset-assert 116) + (trans vector :offset-assert 120) + (sound-id uint32 :offset-assert 124) + (mode basic :offset-assert 128) + (total-time uint64 :offset-assert 136) + (total-off-time uint64 :offset-assert 144) + (last-time uint64 :offset-assert 152) + (voicebox uint64 :offset-assert 160) + ) + :heap-base #x40 + :method-count-assert 16 + :size-assert #xa8 + :flag-assert #x10004000a8 + ;; inherited inspect of process + (:methods + (dummy-14 () none 14) + (dummy-15 () none 15) + ) + ) + +(defmethod inspect level-hint ((obj level-hint)) + (local-vars (t9-0 (function process process))) + (set! t9-0 (method-of-type process inspect)) + (t9-0 obj) + (format '#t "~T~Ttext-id-to-display: ~D~%" (-> obj text-id-to-display)) + (format '#t "~T~Tsound-to-play: ~A~%" (-> obj sound-to-play)) + (format '#t "~T~Ttrans: #~%" (-> obj trans)) + (format '#t "~T~Tsound-id: ~D~%" (-> obj sound-id)) + (format '#t "~T~Tmode: ~A~%" (-> obj mode)) + (format '#t "~T~Ttotal-time: ~D~%" (-> obj total-time)) + (format '#t "~T~Ttotal-off-time: ~D~%" (-> obj total-off-time)) + (format '#t "~T~Tlast-time: ~D~%" (-> obj last-time)) + (format '#t "~T~Tvoicebox: ~D~%" (-> obj voicebox)) + obj + ) + +(deftype ambient-list (structure) + ((num-items int32 :offset-assert 0) + (items uint32 2048 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x2004 + :flag-assert #x900002004 + ) diff --git a/goal_src/engine/draw/drawable-group-h.gc b/goal_src/engine/draw/drawable-group-h.gc index ce52431e1..0a18b65b3 100644 --- a/goal_src/engine/draw/drawable-group-h.gc +++ b/goal_src/engine/draw/drawable-group-h.gc @@ -5,3 +5,10 @@ ;; name in dgo: drawable-group-h ;; dgos: GAME, ENGINE + +(deftype drawable-group (drawable) + ((pad uint8 4)) ;; todo - what's here? + :flag-assert #x1200000024 + ) + +(define *collide-nodes* 0) diff --git a/goal_src/engine/draw/drawable-h.gc b/goal_src/engine/draw/drawable-h.gc index 604caa166..f11f98f36 100644 --- a/goal_src/engine/draw/drawable-h.gc +++ b/goal_src/engine/draw/drawable-h.gc @@ -5,3 +5,43 @@ ;; name in dgo: drawable-h ;; dgos: GAME, ENGINE +;; These are the base classes for the draw nodes in the engine. + +(deftype drawable (basic) + ((id int16 :offset-assert 4) + (bsphere vector :inline :offset-assert 16) + ) + :method-count-assert 18 + :size-assert #x20 + :flag-assert #x1200000020 + (:methods + (dummy-9 () none 9) + (dummy-10 (drawable) int 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) ;; takes at least 3 args, return type is same as the 3rd arg. + (dummy-17 () none 17) + ) + ) + +(deftype drawable-error (drawable) + ((name basic :offset-assert 32) + ) + :method-count-assert 18 + :size-assert #x24 + :flag-assert #x1200000024 + (:methods + (dummy-9 () none 9) + (dummy-10 (drawable) int 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) + ) + ) diff --git a/goal_src/engine/draw/drawable-inline-array-h.gc b/goal_src/engine/draw/drawable-inline-array-h.gc index 03a015823..e2d5c1675 100644 --- a/goal_src/engine/draw/drawable-inline-array-h.gc +++ b/goal_src/engine/draw/drawable-inline-array-h.gc @@ -5,3 +5,21 @@ ;; name in dgo: drawable-inline-array-h ;; dgos: GAME, ENGINE +(deftype drawable-inline-array (drawable) + ((length int16 :offset 6) ;; this is kinda weird. + ) + :method-count-assert 18 + :size-assert #x20 + :flag-assert #x1200000020 + (:methods + (dummy-9 () none 9) + (dummy-10 (drawable) int 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) + ) + ) diff --git a/goal_src/engine/draw/drawable-tree-h.gc b/goal_src/engine/draw/drawable-tree-h.gc index 50edac35c..b8c966da4 100644 --- a/goal_src/engine/draw/drawable-tree-h.gc +++ b/goal_src/engine/draw/drawable-tree-h.gc @@ -5,3 +5,12 @@ ;; name in dgo: drawable-tree-h ;; dgos: GAME, ENGINE +(deftype drawable-tree (drawable-group) + () + :flag-assert #x1200000024 + ) + +(deftype drawable-tree-array (drawable-group) + () + :flag-assert #x1200000024 + ) diff --git a/goal_src/engine/engine/connect.gc b/goal_src/engine/engine/connect.gc index ff945b188..d8f5068b3 100644 --- a/goal_src/engine/engine/connect.gc +++ b/goal_src/engine/engine/connect.gc @@ -5,3 +5,567 @@ ;; name in dgo: connect ;; dgos: GAME, ENGINE +;; This extremely confusing "connection system" allows the connection between +;; "engines" and "processes". Basically, a process may add connections to an engine. +;; A "connection" is really just a function that gets called when the engine runs. + + +;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; connectable +;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; A connectable is the linked-list node part of a connection. +;; The connections themselves are owned by the engine. + +;; the next0/prev0 references are used for how this belongs in the connectable list +;; belonging to the _engine_. These terminate on special nodes stored in the engine: +;; alive-list/alive-list-end for the active connections, and dead-list/dead-list-end +;; for the inactive. + +;; the next1/prev1 references are used to build a linked list _per process_. +;; the head of this list is the inline connectable in process and it ends with #f. +;; This is a bit confusing at first, but these belong to two linked lists... +;; These terminate on both ends with #f. + +(deftype connectable (structure) + ((next0 connectable :offset-assert 0) + (prev0 connectable :offset-assert 4) + (next1 connectable :offset-assert 8) + (prev1 connectable :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; connection +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; this is the actual data for the connection. +;; it may be used in multiple ways, but it appears like +;; the first param0 is a function that receives +;; the three other params as arguments, plus the engine it is connect to as a 4th. +;; in some cases, the return value is checked for 'dead. + +(declare-type engine basic) +(deftype connection (connectable) + ((param0 (function object object object object object) :offset-assert 16) + (param1 basic :offset-assert 20) + (param2 basic :offset-assert 24) + (param3 basic :offset-assert 28) + (quad uint128 2 :offset 0) + ) + :method-count-assert 14 + :size-assert #x20 + :flag-assert #xe00000020 + ;; the params are loaded with a signed load, which is kinda weird... + (:methods + (print (connection) _type_ 2) + (get-engine (connection) engine 9) + (get-process (connection) process 10) + (belongs-to-engine? (connection engine) symbol 11) + (belongs-to-process? (connection process) symbol 12) + (move-to-dead (connection) connection 13) + ) + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; engine +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; an engine is a collection of connections. +;; you can iterate over the connections, or run them. +;; the engine is dynamically sized based on how many connections it can store. + +(deftype engine (basic) + ((name basic :offset-assert 4) + (length int16 :offset-assert 8) ;; in use elts of the data array + (allocated-length int16 :offset-assert 10) ;; size of the data array + (engine-time uint64 :offset-assert 16) ;; frame that we last executed + + ;; terminating nodes for the next0/prev0 linked lists + (alive-list connectable :inline :offset-assert 32) + (alive-list-end connectable :inline :offset-assert 48) + (dead-list connectable :inline :offset-assert 64) + (dead-list-end connectable :inline :offset-assert 80) + + ;; storage for nodes. this is dynamically sized. + (data connection 1 :inline :offset-assert 96) + ) + :method-count-assert 24 + :size-assert #x80 + :flag-assert #x1800000080 + (:methods + (new (symbol type basic int) _type_ 0) + (inspect-all-connections (engine) none 9) + (apply-to-connections (engine (xx (function connectable none))) none 10) + (apply-to-connections-reverse (engine (xx (function connectable none))) none 11) + (execute-connections (engine object) none 12) + (execute-connections-and-move-to-dead (engine object) none 13) + (execute-connections-if-needed (engine object) none 14) + (add-connection (engine process (xx (function object object object object object)) object object object) connection 15) + (remove-from-process (engine process) none 16) + (remove-matching (engine (xx (function connection engine symbol))) none 17) + (remove-all (engine) none 18) + (remove-by-param1 (engine object) none 19) + (remove-by-param2 (engine int) none 20) + (get-first-connectable (engine) connectable 21) + (get-last-connectable (engine) connectable 22) + (unknown-1 (engine (xx (pointer uint32))) uint 23) + ) + ) + +(defmethod belongs-to-process? connection ((obj connection) (arg0 process)) + "Does this connection belong to the given process?" + (= arg0 ((method-of-type connection get-process) obj)) + ) + +(defmethod print connection ((obj connection)) + "Print a connection and its parameters" + (format '#t "#" + (-> obj param0) + (-> obj param1) + (-> obj param2) + (-> obj param3) + obj + ) + obj + ) + +(defmethod get-engine connection ((obj connection)) + "Get the engine for this connection. This must be used on a live connection." + (while (-> obj prev0) + (nop!) + (nop!) + (set! obj (the connection (-> obj prev0))) + ) + ;; the alive-list node has prev0 = #f, so we can just do an offset trick. + (the-as engine (&+ obj -28)) + ) + +(defmethod get-process connection ((obj connection)) + "Get the process for this connection" + ;; use prev1 to iterate through the process list. + (while (-> obj prev1) + (nop!) + (nop!) + (set! obj (the connection (-> obj prev1))) + ) + ;; got to the root connection-list in the process. + (the-as process (&+ obj -92)) + ) + +(defmethod belongs-to-engine? connection ((obj connection) (arg0 engine)) + "Check to see if this connection is located in the data section of the engine. + This works on dead or alive connections." + ;; we can be clever and just see if it has the right address. + (and (< (the-as int arg0) (the-as int obj)) + (< (the-as int obj) (the-as int (-> arg0 data (-> arg0 allocated-length)))) + ) + ) + +(defmethod get-first-connectable engine ((obj engine)) + "Get the first connectable on the alive list. + This should be a valid connection." + (-> obj alive-list next0) + ) + +(defmethod get-last-connectable engine ((obj engine)) + "Get the last connectable on the alive list. + I think the returned connectable is invalid." + (-> obj alive-list-end) + ) + +(defmethod unknown-1 engine ((obj engine) (arg0 (pointer uint32))) + "Not clear what this does. Possibly get next." + (the-as uint32 (-> arg0 0)) + ) + +(defmethod new engine ((allocation symbol) (type-to-make type) (name basic) (length int)) + "Allocate a new engine with enough room for length connections." + (local-vars (obj engine) (idx-to-link int) (end-idx int)) + (set! obj (object-new allocation type-to-make + (the-as int (+ (-> type-to-make size) (the-as uint (shl (+ length -1) 5)))) + ) + ) + (set! (-> obj allocated-length) length) + ;; in use + (set! (-> obj length) 0) + (set! (-> obj name) name) + + ;; link the alive list first/last with next0/prev0 + ;; alive-list <-> alive-list-end + (set! (-> obj alive-list next0) (-> obj alive-list-end)) + (set! (-> obj alive-list prev0) #f) + (set! (-> obj alive-list next1) #f) + (set! (-> obj alive-list prev1) #f) + (set! (-> obj alive-list-end next0) #f) + (set! (-> obj alive-list-end prev0) (-> obj alive-list)) + (set! (-> obj alive-list-end next1) #f) + (set! (-> obj alive-list-end prev1) #f) + + ;; link the dead list first/last with the stuff in data. + ;; dead-list <-> (-> data 0) ... dead-list-end + + ;; dead-list to data[0] + (set! (-> obj dead-list next0) (-> obj data 0)) + (set! (-> obj dead-list prev0) #f) + (set! (-> obj dead-list next1) #f) + (set! (-> obj dead-list prev1) #f) + ;; end to data[-1] + (set! (-> obj dead-list-end next0) #f) + (set! (-> obj dead-list-end prev0) (-> obj data (+ length -1))) + (set! (-> obj dead-list-end next1) #f) + (set! (-> obj dead-list-end prev1) #f) + + ;; data[0] to dead-list + (set! (-> obj data 0 prev0) (-> obj dead-list)) + + ;; data[0] to data[1] + (set! (-> obj data 0 next0) (the connectable (&+ obj 124))) + + ;; loop over datas. + (set! idx-to-link 1) + (set! end-idx (+ length -2)) + (while (>= end-idx idx-to-link) + (set! (-> obj data idx-to-link prev0) (-> obj data (+ idx-to-link -1))) + (set! (-> obj data idx-to-link next0) (-> obj data (+ idx-to-link 1))) + (+! idx-to-link 1) + ) + + ;; data[-1] to data[-2] + (set! (-> obj data (+ length -1) prev0) (-> obj data (+ length -2))) + ;; data[-1] to dead-list-end + (set! (-> obj data (+ length -1) next0) (-> obj dead-list-end)) + obj + ) + +(defmethod print engine ((obj engine)) + "Print an engine and its name" + (format '#t "#<~A ~A @ #x~X>" (-> obj type) (-> obj name) obj) + obj + ) + +(defmethod inspect engine ((obj engine)) + (local-vars (s5-0 binteger) (s5-1 binteger) (s5-2 binteger) (s5-3 binteger)) + (format '#t "[~8x] ~A~%" obj (-> obj type)) + (format '#t "~Tname: ~A~%" (-> obj name)) + (format '#t "~Tengine-time: ~D~%" (-> obj engine-time)) + (format '#t "~Tallocated-length: ~D~%" (-> obj allocated-length)) + (format '#t "~Tlength: ~D~%" (-> obj length)) + (format '#t "~Talive-list:~%") + (set! s5-0 *print-column*) + (set! *print-column* (+ *print-column* 8)) + ((method-of-type connectable inspect) (-> obj alive-list)) + (set! *print-column* s5-0) + (format '#t "~Talive-list-end:~%") + (set! s5-1 *print-column*) + (set! *print-column* (+ *print-column* 8)) + ((method-of-type connectable inspect) (-> obj alive-list-end)) + (set! *print-column* s5-1) + (format '#t "~Tdead-list:~%") + (set! s5-2 *print-column*) + (set! *print-column* (+ *print-column* 8)) + ((method-of-type connectable inspect) (-> obj dead-list)) + (set! *print-column* s5-2) + (format '#t "~Tdead-list-end:~%") + (set! s5-3 *print-column*) + (set! *print-column* (+ *print-column* 8)) + ((method-of-type connectable inspect) (-> obj dead-list-end)) + (set! *print-column* s5-3) + (format '#t "~Tdata[~D]: @ #x~X~%" (-> obj allocated-length) (-> obj data)) + obj + ) + +(defmethod length engine ((obj engine)) + "Get the in-use length of an engine" + (-> obj length) + ) + +(defmethod asize-of engine ((obj engine)) + "Get the size in memory of an engine" + (the-as int + (+ (-> engine size) (the-as uint (shl (+ (-> obj allocated-length) -1) 5))) + ) + ) + +(defmethod apply-to-connections engine ((obj engine) (arg0 (function connectable none))) + "Apply the given function to all the live connectables in an engine" + (local-vars + (iter connectable) + (next connectable) + ) + (set! iter (-> obj alive-list next0)) + (set! next (-> iter next0)) + (while (!= iter (-> obj alive-list-end)) + (arg0 iter) + (set! iter next) + (set! next (-> next next0)) + ) + (none) + ) + +(defmethod apply-to-connections-reverse engine ((obj engine) (arg0 (function connectable none))) + "Apply the given function to all the live conntables in the engine, iterating backward." + (local-vars (s4-0 connectable)) + (set! s4-0 (-> obj alive-list-end prev0)) + (while (!= s4-0 (-> obj alive-list)) + (arg0 s4-0) + (set! s4-0 (-> s4-0 prev0)) + ) + (none) + ) + +(defmethod execute-connections engine ((obj engine) (arg0 object)) + "Iterate through all live connectables and execute them." + (local-vars (s4-0 connectable)) + + ;; update the engine-time + (set! (-> obj engine-time) (-> *display* real-frame-counter)) + ;; iterate! + (set! s4-0 (-> obj alive-list-end prev0)) + (while (!= s4-0 (-> obj alive-list)) + ;; Execute! + ((-> (the-as connection s4-0) param0) + (-> (the-as connection s4-0) param1) + (-> (the-as connection s4-0) param2) + (-> (the-as connection s4-0) param3) + arg0 + ) + (set! s4-0 (-> s4-0 prev0)) + ) + (none) + ) + +(defmethod execute-connections-and-move-to-dead engine ((obj engine) (arg0 object)) + "Execute connections, but remove dead connections from the list." + (local-vars (v0-2 int) (v1-2 object) (s4-0 connectable)) + + ;; update the engine time + (set! (-> obj engine-time) (-> *display* real-frame-counter)) + (set! s4-0 (-> obj alive-list-end prev0)) + + ;; iterate through alive list in reverse + (while (!= s4-0 (-> obj alive-list)) + (set! v1-2 + ((-> (the-as connection s4-0) param0) + (-> (the-as connection s4-0) param1) + (-> (the-as connection s4-0) param2) + (-> (the-as connection s4-0) param3) + arg0 + ) + ) + (set! s4-0 (-> s4-0 prev0)) + ;; if we died, move us to the dead list. + (if (= v1-2 'dead) + (move-to-dead (the-as connection (-> s4-0 next0))) + ) + ) + (none) + ) + +(defmethod execute-connections-if-needed engine ((obj engine) (arg0 object)) + "Execute connections, but only if it hasn't been done on this frame." + (when (!= (-> *display* real-frame-counter) (-> obj engine-time)) + (execute-connections obj arg0) + ) + ) + +(defun connection-process-apply ((proc process) (func (function object none))) + "Apply a function to all connectables of a process." + (local-vars (iter connectable)) + (when proc + ;; iterate with next1 to stay in the process list. + (set! iter (-> proc connection-list next1)) + (while iter + (func iter) + (set! iter (-> iter next1)) + ) + #f + ) + ) + +(when *debug-segment* + (defmethod inspect-all-connections engine ((obj engine)) + "inspect all of the connections." + (apply-to-connections obj + (the (function connection none) (method-of-type connection inspect))) + ) + ) + + +(defmethod add-connection engine + ((obj engine) + (proc process) + (func (function object object object object object)) + (p1 object) + (p2 object) + (p3 object) + ) + "Add a connection between this engine and a given process." + (local-vars (con connectable)) + ;; grab a connection from the dead list + (set! con (-> obj dead-list next0)) + + ;; when we have both a valid process and a valid connectable + (when (not (or (not proc) + (= con (-> obj dead-list-end)))) + (let ((con (the connection con))) + ;; set the params of the connection + (set! (-> con param0) func) + (set! (-> con param1) (the basic p1)) + (set! (-> con param2) (the basic p2)) + (set! (-> con param3) (the basic p3)) + ;; splice us out of the dead list + (set! (-> obj dead-list next0) (-> con next0)) + (set! (-> con next0 prev0) (-> obj dead-list)) + ;; and into the live list + (set! (-> con next0) (-> obj alive-list next0)) + (set! (-> con next0 prev0) con) + (set! (-> con prev0) (-> obj alive-list)) + (set! (-> obj alive-list next0) con) + ;; also splice into the process list + (set! (-> con next1) (-> proc connection-list next1)) + (when (-> con next1) + (set! (-> con next1 prev1) con) + ) + (set! (-> con prev1) (-> proc connection-list)) + (set! (-> proc connection-list next1) con) + (set! (-> obj length) (+ (-> obj length) 1)) + con + ) + ) + ) + + +(defmethod move-to-dead connection ((obj connection)) + "Move this connection from the alive list to the dead list" + (local-vars (v1-1 engine)) + ;; get our engine + (set! v1-1 (get-engine obj)) + ;; splice us out of the engine list + (set! (-> obj prev0 next0) (-> obj next0)) + (set! (-> obj next0 prev0) (-> obj prev0)) + ;; splice us out of the process list list + (set! (-> obj prev1 next1) (-> obj next1)) + ;; next can be #f for process list! + (if (-> obj next1) + (set! (-> obj next1 prev1) (-> obj prev1)) + ) + ;; insert to the beginning of the deat list + (set! (-> obj next0) (-> v1-1 dead-list next0)) + (set! (-> obj next0 prev0) obj) + (set! (-> obj prev0) (-> v1-1 dead-list)) + (set! (-> v1-1 dead-list next0) obj) + ;; decrement the length. + (set! (-> v1-1 length) (+ (-> v1-1 length) -1)) + obj + ) + +(defun process-disconnect ((arg0 process)) + "Disconnect all connections for the given process." + (local-vars (v0-1 int) (gp-0 connectable)) + (when arg0 + ;; use 1 list for process + (set! gp-0 (-> arg0 connection-list next1)) + (while gp-0 + (move-to-dead (the-as connection gp-0)) + (set! gp-0 (-> gp-0 next1)) + ) + ) + (set! v0-1 0) + ) + +(defmethod remove-from-process engine ((obj engine) (proc process)) + "Remove all connections from process for this engine" + (local-vars (iter connection)) + (when proc + (set! iter (the connection (-> proc connection-list next1))) + (while iter + ;; only delete ones for this engine. + (if (belongs-to-engine? iter obj) + (move-to-dead iter) + ) + ;; through process list + (set! iter (the connection (-> iter next1))) + ) + ) + (none) + ) + +(defmethod remove-matching engine ((obj engine) (arg0 (function connection engine symbol))) + "call the given function on each connection and the engine. + if it returns truthy, move to dead that connection." + (local-vars + (s3-0 connectable) + (s4-0 connectable) + ) + ;; tricky iteration because of deleting. + (set! s4-0 (-> obj alive-list next0)) + (set! s3-0 (-> s4-0 next0)) + (while (!= s4-0 (-> obj alive-list-end)) + (if (arg0 (the-as connection s4-0) obj) + ((method-of-type connection move-to-dead) (the-as connection s4-0)) + ) + (set! s4-0 s3-0) + (set! s3-0 (-> s3-0 next0)) + ) + (none) + ) + +(defmethod remove-all engine ((obj engine)) + "Remove all connections from an engine" + (local-vars + (a0-1 connectable) + (s5-0 connectable) + ) + (set! a0-1 (-> obj alive-list next0)) + (set! s5-0 (-> a0-1 next0)) + (while + (!= a0-1 (-> obj alive-list-end)) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + (set! a0-1 s5-0) + (set! s5-0 (-> s5-0 next0)) + ) + (none) + ) + + +(defmethod remove-by-param1 engine ((obj engine) (arg0 object)) + "Remove all connections with param1 matching arg0." + (local-vars + (a0-1 connectable) + (s4-0 connectable) + ) + (set! a0-1 (-> obj alive-list next0)) + (set! s4-0 (-> a0-1 next0)) + (while (!= a0-1 (-> obj alive-list-end)) + (if (= (-> (the-as connection a0-1) param1) arg0) + ((method-of-type connection move-to-dead) (the connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + (none) + ) + +(defmethod remove-by-param2 engine ((obj engine) (arg0 int)) + "Remove all connections with param2 matching arg0" + (local-vars + (a0-1 connectable) + (s4-0 connectable) + ) + (set! a0-1 (-> obj alive-list next0)) + (set! s4-0 (-> a0-1 next0)) + (while (!= a0-1 (-> obj alive-list-end)) + (if (= (-> (the-as connection a0-1) param2) arg0) + ((method-of-type connection move-to-dead) (the connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + (none) + ) diff --git a/goal_src/engine/game/settings-h.gc b/goal_src/engine/game/settings-h.gc index 08e7154df..80c5e4559 100644 --- a/goal_src/engine/game/settings-h.gc +++ b/goal_src/engine/game/settings-h.gc @@ -5,3 +5,138 @@ ;; name in dgo: settings-h ;; dgos: GAME, ENGINE +(deftype setting-data (structure) + ((border-mode basic :offset-assert 0) + (sfx-volume float :offset-assert 4) + (music-volume float :offset-assert 8) + (dialog-volume float :offset-assert 12) + (process-mask uint32 :offset-assert 16) + (common-page int32 :offset-assert 20) + (language int64 :offset-assert 24) + (screenx int32 :offset-assert 32) + (screeny int32 :offset-assert 36) + (vibration basic :offset-assert 40) + (play-hints basic :offset-assert 44) + (movie (pointer process) :offset-assert 48) ;; special print + (talking (pointer process) :offset-assert 52) ;; special print + (spooling (pointer process) :offset-assert 56) ;; special print + (hint (pointer process) :offset-assert 60) ;; special print + (ambient (pointer process) :offset-assert 64) ;; special print + (video-mode basic :offset-assert 68) + (aspect-ratio basic :offset-assert 72) + (sound-flava uint8 :offset-assert 76) + (auto-save basic :offset-assert 80) + (music-volume-movie float :offset-assert 84) + (sfx-volume-movie float :offset-assert 88) + (music basic :offset-assert 92) + (bg-r float :offset-assert 96) + (bg-g float :offset-assert 100) + (bg-b float :offset-assert 104) + (bg-a float :offset-assert 108) + (bg-a-speed float :offset-assert 112) + (bg-a-force float :offset-assert 116) + (allow-progress basic :offset-assert 120) + (allow-pause basic :offset-assert 124) + (sound-flava-priority float :offset-assert 128) + (ocean-off basic :offset-assert 132) + (allow-look-around basic :offset-assert 136) + (ambient-volume float :offset-assert 140) + (ambient-volume-movie float :offset-assert 144) + (dialog-volume-hint float :offset-assert 148) + (dummy uint32 11 :offset-assert 152) + ) + :method-count-assert 10 + :size-assert #xc4 + :flag-assert #xa000000c4 + (:methods + (dummy-9 () none 9) + ) + ) + +(defmethod inspect setting-data ((obj setting-data)) + (format #t "[~8x] ~A~%" obj 'setting-data) + (format #t "~Tborder-mode: ~A~%" (-> obj border-mode)) + (format #t "~Tsfx-volume: ~f~%" (-> obj sfx-volume)) + (format #t "~Tmusic-volume: ~f~%" (-> obj music-volume)) + (format #t "~Tdialog-volume: ~f~%" (-> obj dialog-volume)) + (format #t "~Tprocess-mask: ~D~%" (-> obj process-mask)) + (format #t "~Tcommon-page: ~D~%" (-> obj common-page)) + (format #t "~Tlanguage: ~D~%" (-> obj language)) + (format #t "~Tscreenx: ~D~%" (-> obj screenx)) + (format #t "~Tscreeny: ~D~%" (-> obj screeny)) + (format #t "~Tvibration: ~A~%" (-> obj vibration)) + (format #t "~Tplay-hints: ~A~%" (-> obj play-hints)) + (format #t "~Tmovie: ~A~%" (as-process (-> obj movie))) + (format #t "~Ttalking: ~A~%" (as-process (-> obj talking))) + (format #t "~Tspooling: ~A~%" (as-process (-> obj spooling))) + (format #t "~Thint: ~A~%" (as-process (-> obj hint))) + (format #t "~Tambient: ~A~%" (as-process (-> obj ambient))) + (format #t "~Tvideo-mode: ~A~%" (-> obj video-mode)) + (format #t "~Taspect-ratio: ~A~%" (-> obj aspect-ratio)) + (format #t "~Tsound-flava: ~D~%" (-> obj sound-flava)) + (format #t "~Tauto-save: ~A~%" (-> obj auto-save)) + (format #t "~Tmusic-volume-movie: ~f~%" (-> obj music-volume-movie)) + (format #t "~Tsfx-volume-movie: ~f~%" (-> obj sfx-volume-movie)) + (format #t "~Tmusic: ~A~%" (-> obj music)) + (format #t "~Tbg-r: ~f~%" (-> obj bg-r)) + (format #t "~Tbg-g: ~f~%" (-> obj bg-g)) + (format #t "~Tbg-b: ~f~%" (-> obj bg-b)) + (format #t "~Tbg-a: ~f~%" (-> obj bg-a)) + (format #t "~Tbg-a-speed: ~f~%" (-> obj bg-a-speed)) + (format #t "~Tbg-a-force: ~f~%" (-> obj bg-a-force)) + (format #t "~Tallow-progress: ~A~%" (-> obj allow-progress)) + (format #t "~Tallow-pause: ~A~%" (-> obj allow-pause)) + (format #t "~Tsound-flava-priority: ~f~%" (-> obj sound-flava-priority)) + (format #t "~Tocean-off: ~A~%" (-> obj ocean-off)) + (format #t "~Tallow-look-around: ~A~%" (-> obj allow-look-around)) + (format #t "~Tambient-volume: ~f~%" (-> obj ambient-volume)) + (format #t "~Tambient-volume-movie: ~f~%" (-> obj ambient-volume-movie)) + (format #t "~Tdialog-volume-hint: ~f~%" (-> obj dialog-volume-hint)) + (format #t "~Tdummy[11] @ #x~X~%" (-> obj dummy)) + obj + ) + +(deftype setting-control (basic) + ((current setting-data :inline :offset-assert 16) + (target setting-data :inline :offset-assert 224) + (default setting-data :inline :offset-assert 432) + (engine engine :offset-assert 628) + ) + :method-count-assert 14 + :size-assert #x278 + :flag-assert #xe00000278 + (:methods + (new (symbol type int) _type_ 0) + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + ) + ) + +(defmethod new setting-control ((allocation symbol) (type-to-make type) (max-connections int)) + "Allocate a new setting-control and its engine" + (local-vars (s4-0 setting-control)) + (set! s4-0 (object-new allocation type-to-make (the-as int (-> type-to-make size)))) + (set! (-> s4-0 engine) + ((method-of-type engine new) allocation engine 'setting-control max-connections) + ) + s4-0 + ) + + +(deftype scf-time (structure) + ((stat uint8 :offset-assert 0) + (second uint8 :offset-assert 1) + (minute uint8 :offset-assert 2) + (hour uint8 :offset-assert 3) + (week uint8 :offset-assert 4) + (day uint8 :offset-assert 5) + (month uint8 :offset-assert 6) + (year uint8 :offset-assert 7) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) diff --git a/goal_src/engine/game/task/game-task-h.gc b/goal_src/engine/game/task/game-task-h.gc index d4ac2b112..1b5f54a1c 100644 --- a/goal_src/engine/game/task/game-task-h.gc +++ b/goal_src/engine/game/task/game-task-h.gc @@ -5,3 +5,4 @@ ;; name in dgo: game-task-h ;; dgos: GAME, ENGINE +;; this file has no code. diff --git a/goal_src/engine/game/task/hint-control-h.gc b/goal_src/engine/game/task/hint-control-h.gc index ac090aa41..9c5cafc26 100644 --- a/goal_src/engine/game/task/hint-control-h.gc +++ b/goal_src/engine/game/task/hint-control-h.gc @@ -5,3 +5,34 @@ ;; name in dgo: hint-control-h ;; dgos: GAME, ENGINE +(deftype level-hint-control (structure) + ((delay-before-playing uint64 :offset-assert 0) + (id uint32 :offset-assert 8) + (num-attempts-before-playing int8 :offset-assert 12) + (num-success-before-killing int8 :offset-assert 13) + (num-attempts int8 :offset-assert 14) + (num-success int8 :offset-assert 15) + (start-time uint64 :offset-assert 16) + (last-time-called uint64 :offset-assert 24) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype task-hint-control (structure) + ((task uint8 :offset-assert 0) + (delay uint64 :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype task-hint-control-group (structure) + ((tasks basic :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) diff --git a/goal_src/engine/gfx/generic/generic-h.gc b/goal_src/engine/gfx/generic/generic-h.gc index 70934229d..d8dedf049 100644 --- a/goal_src/engine/gfx/generic/generic-h.gc +++ b/goal_src/engine/gfx/generic/generic-h.gc @@ -5,3 +5,254 @@ ;; name in dgo: generic-h ;; dgos: GAME, ENGINE +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; GENERIC RENDERER +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; The generic renderer is the slow but general renderer. + + +;; gsf, what does it stand for? +(deftype gsf-vertex (structure) + ((data uint32 8 :offset-assert 0) + (byte uint8 32 :offset 0) + (quad uint128 2 :offset 0) + (vt qword :inline :offset 0) + (pos vector3s :inline :offset 0) + (tex vector2uh :inline :offset 12) + (nrm vector3s :inline :offset 16) + (nc qword :inline :offset 16) + (clr vector4ub :inline :offset 28) + (dtex vector2uh :inline :offset 16) + (dclr vector4ub :inline :offset 20) + ) + :pack-me + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +;; dynamically sized array of gsf-verts +(deftype gsf-vertex-array (structure) + ((vtx gsf-vertex :dynamic :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x0 + :flag-assert #x900000000 + ) + + +(deftype gsf-fx-vertex (structure) + ((clr vector4ub :inline :offset-assert 0) + (tex vector2uh :inline :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype gsf-fx-vertex-array (structure) + ((data gsf-fx-vertex :dynamic :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x0 + :flag-assert #x900000000 + ) + +(deftype gsf-header (structure) + ((num-strips uint8 :offset-assert 0) + (expanded uint8 :offset-assert 1) + (num-dps uint16 :offset-assert 2) + (num-vtxs uint16 :offset-assert 4) + (strip-table uint8 10 :offset-assert 6) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype gsf-ik (structure) + ((index uint8 :offset-assert 0) + (no-kick uint8 :offset-assert 1) + ) + :method-count-assert 9 + :size-assert #x2 + :flag-assert #x900000002 + ) + +(deftype gsf-info (structure) + ((ptr-iks uint32 :offset-assert 0) + (ptr-verts uint32 :offset-assert 4) + (ptr-fx uint32 :offset-assert 8) + (dummy2 uint32 :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype gsf-buffer (structure) + ((data uint8 8192 :offset-assert 0) + (info gsf-info :inline :offset 0) + (header gsf-header :inline :offset 16) + (work-area uint8 :dynamic :offset 32) + ) + :method-count-assert 9 + :size-assert #x2000 + :flag-assert #x900002000 + ) + +(deftype generic-frag (structure) + ((start-pos uint16 :offset-assert 0) + (end-pos uint16 :offset-assert 2) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(deftype generic-strip (structure) + ((pos uint16 :offset-assert 0) + (len uint16 :offset-assert 2) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(deftype generic-envmap-saves (structure) + ((index-mask vector4w :inline :offset-assert 0) + (verts uint128 12 :offset-assert 16) + (kicks uint128 4 :offset-assert 208) + ) + :method-count-assert 9 + :size-assert #x110 + :flag-assert #x900000110 + ) + +(deftype generic-interp-job (structure) + ((job-type uint16 :offset-assert 0) + (num uint16 :offset-assert 2) + (first uint16 :offset-assert 4) + (pad uint16 :offset-assert 6) + (ptr-data uint32 :offset-assert 8) + (morph-z uint16 :offset-assert 12) + (morph-w uint16 :offset-assert 14) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype generic-saves (structure) + ((ptr-dma uint32 :offset-assert 0) + (ptr-vtxs uint32 :offset-assert 4) + (ptr-clrs uint32 :offset-assert 8) + (ptr-texs uint32 :offset-assert 12) + (ptr-env-clrs uint32 :offset-assert 16) + (ptr-env-texs uint32 :offset-assert 20) + (cur-outbuf uint32 :offset-assert 24) + (ptr-fx-buf uint32 :offset-assert 28) + (xor-outbufs uint32 :offset-assert 32) + (num-dps uint32 :offset-assert 36) + (qwc uint32 :offset-assert 40) + (gsf-buf gsf-buffer :offset-assert 44) + (ptr-shaders uint32 :offset-assert 48) + (ptr-env-shader uint32 :offset-assert 52) + (is-envmap uint32 :offset-assert 56) + (basep uint32 :offset-assert 60) + (ptr-interp-job generic-interp-job :offset-assert 64) + (gifbuf-adr uint32 :offset-assert 68) + (inbuf-adr uint32 :offset-assert 72) + (fade-val uint32 :offset-assert 76) + (time-of-day-color uint32 :offset-assert 80) + (to-vu0-waits uint32 :offset-assert 84) + (to-spr-waits uint32 :offset-assert 88) + (from-spr-waits uint32 :offset-assert 92) + (envmap generic-envmap-saves :inline :offset-assert 96) + ) + :method-count-assert 9 + :size-assert #x170 + :flag-assert #x900000170 + ) + +(deftype generic-gif-tag (structure) + ((data uint32 4 :offset-assert 0) + (qword qword :inline :offset 0) + (fan-prim uint32 :offset 0) + (str-prim uint32 :offset 4) + (regs uint32 :offset 8) + (num-strips uint32 :offset 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype ad-cmd (structure) + ((word uint32 4 :offset-assert 0) + (quad uint128 :offset 0) + (data uint64 :offset 0) + (cmds uint64 :offset 8) + (cmd uint8 :offset 8) + (x uint32 :offset 0) + (y uint32 :offset 4) + (z uint32 :offset 8) + (w uint32 :offset 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype generic-envmap-consts (structure) + ((consts vector :inline :offset-assert 0) + (strgif generic-gif-tag :inline :offset-assert 16) + (colors vector4w :inline :offset-assert 32) + (shader adgif-shader :inline :offset-assert 48) + ) + :method-count-assert 9 + :size-assert #x80 + :flag-assert #x900000080 + ) + +(deftype generic-consts (structure) + ((dma-header dma-packet :inline :offset-assert 0) + (vif-header uint32 4 :offset-assert 16) + (dma-ref-vtxs dma-packet :inline :offset-assert 32) + (dma-cnt-call dma-packet :inline :offset-assert 48) + (matrix matrix :inline :offset-assert 64) + (base-strgif generic-gif-tag :inline :offset-assert 128) + (alpha-opaque ad-cmd :inline :offset-assert 144) + (alpha-translucent ad-cmd :inline :offset-assert 160) + (ztest-normal ad-cmd :inline :offset-assert 176) + (ztest-opaque ad-cmd :inline :offset-assert 192) + (adcmd-offsets uint8 16 :offset-assert 208) + ;;(adcmds UNKNOWN 4 :offset-assert 144) + (stcycle-tag uint32 :offset-assert 224) + (unpack-vtx-tag uint32 :offset-assert 228) + (unpack-clr-tag uint32 :offset-assert 232) + (unpack-tex-tag uint32 :offset-assert 236) + (mscal-tag uint32 :offset-assert 240) + (flush-tag uint32 :offset-assert 244) + (reset-cycle-tag uint32 :offset-assert 248) + (dummy0 uint32 :offset-assert 252) + (dma-tag-cnt uint64 :offset-assert 256) + (envmap generic-envmap-consts :inline :offset-assert 272) + (light-consts vector :inline :offset-assert 400) + (texture-offset uint16 8 :offset-assert 416) + ) + :method-count-assert 9 + :size-assert #x1b0 + :flag-assert #x9000001b0 + ) + +(deftype generic-storage (structure) + ((data uint128 16 :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x100 + :flag-assert #x900000100 + ) + +(define *gsf-buffer* (kmalloc global 9216 64 "malloc")) diff --git a/goal_src/engine/gfx/hw/display-h.gc b/goal_src/engine/gfx/hw/display-h.gc index 2eba8b8b6..dcbce07f9 100644 --- a/goal_src/engine/gfx/hw/display-h.gc +++ b/goal_src/engine/gfx/hw/display-h.gc @@ -142,6 +142,8 @@ ) ) +(define-extern *display* display) + (defmethod new display ((allocation symbol) (type-to-make type) (psm int) (w int) (h int) (ztest int) (zpsm int)) (local-vars (obj display)) (set! obj diff --git a/goal_src/engine/gfx/lights-h.gc b/goal_src/engine/gfx/lights-h.gc index 539da9f2e..36940de7f 100644 --- a/goal_src/engine/gfx/lights-h.gc +++ b/goal_src/engine/gfx/lights-h.gc @@ -5,3 +5,105 @@ ;; name in dgo: lights-h ;; dgos: GAME, ENGINE +(deftype vu-lights (structure) + ((direction uint128 3 :offset-assert 0) + (color uint128 3 :offset-assert 48) + (ambient vector :inline :offset-assert 96) + ) + :method-count-assert 9 + :size-assert #x70 + :flag-assert #x900000070 + ) + +(deftype light (structure) + ((direction vector :inline :offset-assert 0) + (color rgbaf :inline :offset-assert 16) + (levels vector :inline :offset-assert 32) + (level float :offset 32) + (sort-level float :offset 36) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype light-ellipse (structure) + ((matrix matrix :inline :offset-assert 0) + (color rgbaf :inline :offset-assert 64) + (name basic :offset 12) + (decay-start float :offset 28) + (ambient-point-ratio float :offset 44) + (level float :offset 60) + (func-symbol basic :offset 76) + (func basic :offset 76) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + +;; This likely doesn't work correctly in both GOAL and OpenGOAL +(deftype light-array (array) + () + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype light-volume (basic) + ((light-array basic :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype light-volume-sphere (light-volume) + ((bsphere sphere :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype light-volume-planes (light-volume) + ((planes vertical-planes :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #xc + :flag-assert #x90000000c + ) + +(deftype light-volume-array (array) + () + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(defmethod print light ((obj light)) + (format #t "# obj levels data 0) + (-> obj direction data 0) + (-> obj direction data 1) + (-> obj direction data 2) + ) + (format #t "~F ~F ~F @ #x~X>" + (-> obj color data 0) + (-> obj color data 1) + (-> obj color data 2) + obj + ) + obj + ) + +(deftype light-group (structure) + ((dir0 light :inline :offset-assert 0) + (dir1 light :inline :offset-assert 48) + (dir2 light :inline :offset-assert 96) + (ambi light :inline :offset-assert 144) + ) + :method-count-assert 9 + :size-assert #xc0 + :flag-assert #x9000000c0 + ) diff --git a/goal_src/engine/gfx/ocean/ocean-h.gc b/goal_src/engine/gfx/ocean/ocean-h.gc index 1a96b2a5f..7e5fbbd04 100644 --- a/goal_src/engine/gfx/ocean/ocean-h.gc +++ b/goal_src/engine/gfx/ocean/ocean-h.gc @@ -5,3 +5,409 @@ ;; name in dgo: ocean-h ;; dgos: GAME, ENGINE +(deftype ocean-corner (structure) + ((bsphere sphere :inline :offset-assert 0) + (start-corner vector :inline :offset-assert 16) + (y-scales vector :inline :offset-assert 32) + (alphas vector :inline :offset-assert 48) + (colors uint32 4 :offset-assert 64) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + +(deftype ocean-wave-info (structure) + ((frequency float :offset-assert 0) + (amplitude float :offset-assert 4) + (wave-speed float :offset-assert 8) + (angle float :offset-assert 12) + (kx float :offset-assert 16) + (ky float :offset-assert 20) + (w float :offset-assert 24) + (flags int32 :offset-assert 28) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype ocean-vertex (structure) + ((pos vector :inline :offset-assert 0) + (stq vector :inline :offset-assert 16) + (col vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype ocean-spheres (structure) + ((spheres uint128 36 :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x240 + :flag-assert #x900000240 + ) + +(deftype ocean-colors (structure) + ((colors uint32 2548 :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x27d0 + :flag-assert #x9000027d0 + ) + +(deftype ocean-mid-mask (structure) + ((mask uint8 8 :offset-assert 0) + (dword uint64 :offset 0) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype ocean-mid-indices (basic) + ((data uint16 36 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x4c + :flag-assert #x90000004c + ) + +(deftype ocean-mid-masks (basic) + ((data uint32 :offset-assert 4) + ) + :pack-me + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype ocean-trans-mask (structure) + ((mask uint16 4 :offset-assert 0) + (word uint64 :offset 0) + ) + :pack-me + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype ocean-trans-index (structure) + ((parent int16 :offset-assert 0) + (child int16 :offset-assert 2) + ) + :pack-me + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(deftype ocean-trans-indices (basic) + ((data uint32 2304 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x2404 + :flag-assert #x900002404 + ) + +(deftype ocean-near-index (structure) + ((data uint16 16 :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + + +(deftype ocean-near-indices (basic) + ((data uint32 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype ocean-near-colors (structure) + ((color0 vector :inline :offset-assert 0) + (color1 vector :inline :offset-assert 16) + (color2 vector :inline :offset-assert 32) + (color3 vector :inline :offset-assert 48) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) + +(deftype ocean-map (basic) + ((start-corner vector :inline :offset-assert 16) + (far-color vector :inline :offset-assert 32) + (ocean-spheres ocean-spheres :offset-assert 48) + (ocean-colors ocean-colors :offset-assert 52) + (ocean-mid-indices basic :offset-assert 56) + (ocean-trans-indices basic :offset-assert 60) + (ocean-near-indices basic :offset-assert 64) + (ocean-mid-masks basic :offset-assert 68) + ) + :method-count-assert 9 + :size-assert #x48 + :flag-assert #x900000048 + ) + +(deftype ocean-trans-strip (structure) + ((verts uint128 10 :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #xa0 + :flag-assert #x9000000a0 + ) + +(deftype ocean-trans-strip-array (structure) + ((data ocean-trans-strip 4 :inline :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x280 + :flag-assert #x900000280 + ) + + +(deftype ocean-wave-data (structure) + ((data uint8 1024 :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x400 + :flag-assert #x900000400 + ) + +;; the size of this type overflows. +(deftype ocean-wave-frames (structure) + ((frame ocean-wave-data 64 :inline :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x10000 + ;:flag-assert #x900010000 + ) + +(deftype ocean-work (basic) + ((deltas vector :inline :offset-assert 16) + (map-min vector :inline :offset-assert 32) + (map-max vector :inline :offset-assert 48) + (interp vector :inline :offset-assert 64) + (corner-array ocean-corner 25 :inline :offset-assert 80) + (corner-count int32 :offset-assert 2080) + (temp-vecs vector 4 :inline :offset-assert 2096) + (mid-mask-ptrs pointer 36 :offset-assert 2160) + (mid-camera-masks ocean-mid-masks 36 :inline :offset-assert 2304) + (trans-mask-ptrs pointer 64 :offset-assert 2592) + (trans-camera-masks ocean-trans-mask 16 :inline :offset-assert 2848) + (trans-temp-masks ocean-trans-mask 16 :inline :offset-assert 2976) + (near-mask-indices uint16 16 :offset-assert 3104) + (mid-minx uint8 :offset-assert 3136) + (mid-maxx uint8 :offset-assert 3137) + (mid-minz uint8 :offset-assert 3138) + (mid-maxz uint8 :offset-assert 3139) + (near-minx uint8 :offset-assert 3140) + (near-maxx uint8 :offset-assert 3141) + (near-minz uint8 :offset-assert 3142) + (near-maxz uint8 :offset-assert 3143) + (temp-minx uint8 :offset-assert 3144) + (temp-maxx uint8 :offset-assert 3145) + (temp-minz uint8 :offset-assert 3146) + (temp-maxz uint8 :offset-assert 3147) + ) + :method-count-assert 9 + :size-assert #xc4c + :flag-assert #x900000c4c + ) + +(define *ocean-work* (new 'static 'ocean-work)) +(define *ocean-facing* 0) +(define *ocean-off* #f) +(define *ocean-mid-off* #f) +(define *ocean-near-off* #f) +(define *ocean-heights* #f) +(define *ocean-verts* #f) + +(deftype ocean-vu0-work (structure) + ((scales vector :inline :offset-assert 0) + (mask-hi vector4w :inline :offset-assert 16) + (mask-lo vector4w :inline :offset-assert 32) + (lights vu-lights :inline :offset-assert 48) + (wait-to-vu0 uint32 :offset-assert 160) + ) + :method-count-assert 9 + :size-assert #xa4 + :flag-assert #x9000000a4 + ) + +(deftype ocean-texture-constants (structure) + ((giftag qword :inline :offset-assert 0) + (buffers vector4w :inline :offset-assert 16) + (dests vector4w :inline :offset-assert 32) + (start vector :inline :offset-assert 48) + (offsets vector :inline :offset-assert 64) + (constants vector :inline :offset-assert 80) + (cam-nrm vector :inline :offset-assert 96) + ) + :method-count-assert 9 + :size-assert #x70 + :flag-assert #x900000070 + ) + +(deftype ocean-texture-work (structure) + ((sprite-tmpl dma-gif-packet :inline :offset-assert 0) + (sprite-tmpl2 dma-gif-packet :inline :offset-assert 32) + (adgif-tmpl dma-gif-packet :inline :offset-assert 64) + ) + :method-count-assert 9 + :size-assert #x60 + :flag-assert #x900000060 + ) + +(deftype ocean-mid-vertex (structure) + ((stq vector :inline :offset-assert 0) + (col vector :inline :offset-assert 16) + (pos vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype ocean-mid-constants (structure) + ((hmge-scale vector :inline :offset-assert 0) + (inv-hmge-scale vector :inline :offset-assert 16) + (hvdf-offset vector :inline :offset-assert 32) + (fog vector :inline :offset-assert 48) + (constants vector :inline :offset-assert 64) + (constants2 vector :inline :offset-assert 80) + (drw-fan qword :inline :offset-assert 96) + (env-fan qword :inline :offset-assert 112) + (drw-adgif qword :inline :offset-assert 128) + (drw-texture adgif-shader :inline :offset-assert 144) + (drw-strip-0 qword :inline :offset-assert 224) + (drw-strip-1 qword :inline :offset-assert 240) + (env-adgif qword :inline :offset-assert 256) + (env-texture adgif-shader :inline :offset-assert 272) + (env-strip qword :inline :offset-assert 352) + (env-color vector :inline :offset-assert 368) + (index-table uint128 8 :offset-assert 384) + (pos0 vector :inline :offset-assert 512) + (pos1 vector :inline :offset-assert 528) + (pos2 vector :inline :offset-assert 544) + (pos3 vector :inline :offset-assert 560) + ) + :method-count-assert 9 + :size-assert #x240 + :flag-assert #x900000240 + ) + +(deftype ocean-mid-upload (structure) + ((rot matrix :inline :offset-assert 0) + (matrix matrix :inline :offset-assert 64) + (colors uint128 108 :offset-assert 128) + (masks uint128 2 :offset-assert 1856) + ) + :method-count-assert 9 + :size-assert #x760 + :flag-assert #x900000760 + ) + +(deftype ocean-mid-upload2 (structure) + ((rot matrix :inline :offset-assert 0) + (matrix matrix :inline :offset-assert 64) + (count vector4w :inline :offset-assert 128) + (tex0 vector :inline :offset-assert 144) + (tex1 vector :inline :offset-assert 160) + (tex2 vector :inline :offset-assert 176) + (tex3 vector :inline :offset-assert 192) + (clr0 vector :inline :offset-assert 208) + (clr1 vector :inline :offset-assert 224) + (clr2 vector :inline :offset-assert 240) + (clr3 vector :inline :offset-assert 256) + (verts uint128 18 :offset-assert 272) + ) + :method-count-assert 9 + :size-assert #x230 + :flag-assert #x900000230 + ) + +(deftype ocean-mid-work (structure) + ((env0 vector :inline :offset-assert 0) + (env1 vector :inline :offset-assert 16) + (env2 vector :inline :offset-assert 32) + (hmg0 vector :inline :offset-assert 48) + (hmg1 vector :inline :offset-assert 64) + (hmg2 vector :inline :offset-assert 80) + (indices uint128 16 :offset-assert 96) + ) + :method-count-assert 9 + :size-assert #x160 + :flag-assert #x900000160 + ) + +(deftype ocean-near-constants (structure) + ((hmge-scale vector :inline :offset-assert 0) + (inv-hmge-scale vector :inline :offset-assert 16) + (hvdf-offset vector :inline :offset-assert 32) + (fog vector :inline :offset-assert 48) + (constants vector :inline :offset-assert 64) + (constants2 vector :inline :offset-assert 80) + (constants3 vector :inline :offset-assert 96) + (constants4 vector :inline :offset-assert 112) + (drw-fan qword :inline :offset-assert 128) + (drw2-fan qword :inline :offset-assert 144) + (env-fan qword :inline :offset-assert 160) + (drw-adgif qword :inline :offset-assert 176) + (drw-texture adgif-shader :inline :offset-assert 192) + (drw-strip qword :inline :offset-assert 272) + (env-adgif qword :inline :offset-assert 288) + (env-texture adgif-shader :inline :offset-assert 304) + (env-strip qword :inline :offset-assert 384) + (env-color vector :inline :offset-assert 400) + (drw2-adgif qword :inline :offset-assert 416) + (drw2-tex0 qword :inline :offset-assert 432) + (drw2-frame qword :inline :offset-assert 448) + (drw2-strip qword :inline :offset-assert 464) + (drw3-adgif qword :inline :offset-assert 480) + (drw3-frame qword :inline :offset-assert 496) + (index-table uint128 4 :offset-assert 512) + ) + :method-count-assert 9 + :size-assert #x240 + :flag-assert #x900000240 + ) + +(deftype ocean-near-upload (structure) + ((rot matrix :inline :offset-assert 0) + (matrix matrix :inline :offset-assert 64) + (masks uint128 2 :offset-assert 128) + (start-height vector4w :inline :offset-assert 160) + (start-st vector :inline :offset-assert 176) + (near-colors ocean-near-colors :inline :offset-assert 192) + ) + :method-count-assert 9 + :size-assert #x100 + :flag-assert #x900000100 + ) + + +(deftype ocean-near-vertex (structure) + ((stq vector :inline :offset-assert 0) + (clr vector :inline :offset-assert 16) + (pos vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype ocean-near-work (structure) + ((verts-ptr vector :inline :offset-assert 0) + (indices uint128 16 :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x110 + :flag-assert #x900000110 + ) diff --git a/goal_src/engine/ui/text-h.gc b/goal_src/engine/ui/text-h.gc index d49a68ff3..54d109021 100644 --- a/goal_src/engine/ui/text-h.gc +++ b/goal_src/engine/ui/text-h.gc @@ -36,7 +36,7 @@ ) ;; todo, need support for array -;(define *text-group-names* #("common")) +(define *text-group-names* (new 'static 'boxed-array string 1 "common")) (define *common-text-heap* (new 'global 'kheap)) ;; probably some other type. diff --git a/goal_src/kernel-defs.gc b/goal_src/kernel-defs.gc index e2efbc339..332329e89 100644 --- a/goal_src/kernel-defs.gc +++ b/goal_src/kernel-defs.gc @@ -73,7 +73,7 @@ (define-extern unload (function string none)) (define-extern _format (function _varargs_ object)) (define-extern malloc (function symbol int pointer)) -(define-extern kmalloc (function kheap int int string)) +(define-extern kmalloc (function kheap int int string pointer)) (define-extern new-dynamic-structure (function kheap type int structure)) (define-extern method-set! (function type int function none)) ;; may actually return function. (define-extern link (function pointer pointer int kheap int pointer)) diff --git a/goal_src/kernel/gkernel.gc b/goal_src/kernel/gkernel.gc index bdda17f7a..5725a0f2d 100644 --- a/goal_src/kernel/gkernel.gc +++ b/goal_src/kernel/gkernel.gc @@ -2384,7 +2384,7 @@ (define-extern entity-deactivate-handler (function process object none)) (define entity-deactivate-handler (the (function process object none) nothing)) -(define-extern process-disconnect (function object none)) +(define-extern process-disconnect (function process int)) (defmethod deactivate process ((obj process)) "Deactivate a process. This returns the process to the dead pool